code
stringlengths
3
1.05M
repo_name
stringlengths
4
116
path
stringlengths
3
942
language
stringclasses
30 values
license
stringclasses
15 values
size
int32
3
1.05M
/* How would you design a stack which, in addition to push and pop, also has a function min which returns the minimum element? Push, pop and min should all operate in O(1) time. */ #include <stdio.h> #include <map> using namespace std; #define N 500 typedef struct Stack { int top; int min; int value[N]; map<int, int> minTr; }Stack; void init(Stack& s) { s.top = 0; s.min = 1 << 30; } void push(Stack& s, int val) { if(s.top >= N) { printf("overflow!\n"); return; } s.value[s.top] = val; if(val < s.min) { s.minTr.insert(pair<int, int>(s.top, val)); s.min = val; } s.top++; } int pop(Stack& s) { if(s.top <= 0) { printf("Stack is empty!\n"); return 0; } s.top--; int e = s.value[s.top]; if(e == s.min) { int ind = s.minTr.rbegin()->first; if(ind == s.top) { s.minTr.erase(s.top); if(s.minTr.empty()) s.min = 1 << 30; else s.min = s.minTr.rbegin()->second; } } return e; } int minEle(Stack s) { if(s.top == 0) { printf("Stack is empty!\n"); return 0; } return s.min; } void createStack(Stack& s, int *a, int n) { for (int i = 0; i < 9; ++i) { push(s, a[i]); //printf("%d %d\n", a[i], minEle(s)); } } void popEmpty(Stack s) { //printf("hello\n"); while(s.top > 0) { int e = pop(s); printf("%d %d\n", e, s.min); } } int main() { int a[9] = {3, 4, 5, 2, 6, 8, 1, 1, 4}; Stack s; init(s); createStack(s, a, 9); popEmpty(s); return 0; }
pgxiaolianzi/cracking-the-code-interview
3_2.cpp
C++
gpl-2.0
1,447
/** * MaNGOS is a full featured server for World of Warcraft, supporting * the following clients: 1.12.x, 2.4.3, 3.3.5a, 4.3.4a and 5.4.8 * * Copyright (C) 2005-2022 MaNGOS <https://getmangos.eu> * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * World of Warcraft, and all World of Warcraft or Warcraft art, images, * and lore are copyrighted by Blizzard Entertainment, Inc. */ #include "Common.h" #include "Language.h" #include "Database/DatabaseEnv.h" #include "WorldPacket.h" #include "WorldSession.h" #include "Opcodes.h" #include "Log.h" #include "ObjectMgr.h" #include "SpellMgr.h" #include "Player.h" #include "GossipDef.h" #include "UpdateMask.h" #include "ScriptMgr.h" #include "Creature.h" #include "Pet.h" #include "Guild.h" #include "GuildMgr.h" #include "Chat.h" #include "Item.h" #ifdef ENABLE_ELUNA #include "LuaEngine.h" #endif /* ENABLE_ELUNA */ enum StableResultCode { STABLE_ERR_MONEY = 0x01, // "you don't have enough money" STABLE_ERR_STABLE = 0x06, // currently used in most fail cases STABLE_SUCCESS_STABLE = 0x08, // stable success STABLE_SUCCESS_UNSTABLE = 0x09, // unstable/swap success STABLE_SUCCESS_BUY_SLOT = 0x0A, // buy slot success STABLE_ERR_EXOTIC = 0x0C, // "you are unable to control exotic creatures" }; void WorldSession::HandleTabardVendorActivateOpcode(WorldPacket& recv_data) { ObjectGuid guid; recv_data >> guid; Creature* unit = GetPlayer()->GetNPCIfCanInteractWith(guid, UNIT_NPC_FLAG_TABARDDESIGNER); if (!unit) { DEBUG_LOG("WORLD: HandleTabardVendorActivateOpcode - %s not found or you can't interact with him.", guid.GetString().c_str()); return; } // remove fake death if (GetPlayer()->hasUnitState(UNIT_STAT_DIED)) { GetPlayer()->RemoveSpellsCausingAura(SPELL_AURA_FEIGN_DEATH); } SendTabardVendorActivate(guid); } void WorldSession::SendTabardVendorActivate(ObjectGuid guid) { WorldPacket data(MSG_TABARDVENDOR_ACTIVATE, 8); data << ObjectGuid(guid); SendPacket(&data); } void WorldSession::HandleBankerActivateOpcode(WorldPacket& recv_data) { ObjectGuid guid; DEBUG_LOG("WORLD: Received opcode CMSG_BANKER_ACTIVATE"); recv_data >> guid; if (!CheckBanker(guid)) { return; } // remove fake death if (GetPlayer()->hasUnitState(UNIT_STAT_DIED)) { GetPlayer()->RemoveSpellsCausingAura(SPELL_AURA_FEIGN_DEATH); } SendShowBank(guid); } void WorldSession::SendShowBank(ObjectGuid guid) { WorldPacket data(SMSG_SHOW_BANK, 8); data << ObjectGuid(guid); SendPacket(&data); } void WorldSession::HandleTrainerListOpcode(WorldPacket& recv_data) { ObjectGuid guid; recv_data >> guid; SendTrainerList(guid); } void WorldSession::SendTrainerList(ObjectGuid guid) { std::string str = GetMangosString(LANG_NPC_TAINER_HELLO); SendTrainerList(guid, str); } static void SendTrainerSpellHelper(WorldPacket& data, TrainerSpell const* tSpell, TrainerSpellState state, float fDiscountMod, bool can_learn_primary_prof, uint32 reqLevel) { bool primary_prof_first_rank = sSpellMgr.IsPrimaryProfessionFirstRankSpell(tSpell->learnedSpell); SpellChainNode const* chain_node = sSpellMgr.GetSpellChainNode(tSpell->learnedSpell); data << uint32(tSpell->spell); // learned spell (or cast-spell in profession case) data << uint8(state == TRAINER_SPELL_GREEN_DISABLED ? TRAINER_SPELL_GREEN : state); data << uint32(floor(tSpell->spellCost * fDiscountMod)); data << uint32(primary_prof_first_rank && can_learn_primary_prof ? 1 : 0); // primary prof. learn confirmation dialog data << uint32(primary_prof_first_rank ? 1 : 0); // must be equal prev. field to have learn button in enabled state data << uint8(reqLevel); data << uint32(tSpell->reqSkill); data << uint32(tSpell->reqSkillValue); data << uint32(!tSpell->IsCastable() && chain_node ? (chain_node->prev ? chain_node->prev : chain_node->req) : 0); data << uint32(!tSpell->IsCastable() && chain_node && chain_node->prev ? chain_node->req : 0); data << uint32(0); } void WorldSession::SendTrainerList(ObjectGuid guid, const std::string& strTitle) { DEBUG_LOG("WORLD: SendTrainerList"); Creature* unit = GetPlayer()->GetNPCIfCanInteractWith(guid, UNIT_NPC_FLAG_TRAINER); if (!unit) { DEBUG_LOG("WORLD: SendTrainerList - %s not found or you can't interact with him.", guid.GetString().c_str()); return; } // remove fake death if (GetPlayer()->hasUnitState(UNIT_STAT_DIED)) { GetPlayer()->RemoveSpellsCausingAura(SPELL_AURA_FEIGN_DEATH); } // trainer list loaded at check; if (!unit->IsTrainerOf(_player, true)) { return; } CreatureInfo const* ci = unit->GetCreatureInfo(); if (!ci) { return; } TrainerSpellData const* cSpells = unit->GetTrainerSpells(); TrainerSpellData const* tSpells = unit->GetTrainerTemplateSpells(); if (!cSpells && !tSpells) { DEBUG_LOG("WORLD: SendTrainerList - Training spells not found for %s", guid.GetString().c_str()); return; } uint32 maxcount = (cSpells ? cSpells->spellList.size() : 0) + (tSpells ? tSpells->spellList.size() : 0); uint32 trainer_type = cSpells && cSpells->trainerType ? cSpells->trainerType : (tSpells ? tSpells->trainerType : 0); WorldPacket data(SMSG_TRAINER_LIST, 8 + 4 + 4 + maxcount * 38 + strTitle.size() + 1); data << ObjectGuid(guid); data << uint32(trainer_type); size_t count_pos = data.wpos(); data << uint32(maxcount); // reputation discount float fDiscountMod = _player->GetReputationPriceDiscount(unit); bool can_learn_primary_prof = GetPlayer()->GetFreePrimaryProfessionPoints() > 0; uint32 count = 0; if (cSpells) { for (TrainerSpellMap::const_iterator itr = cSpells->spellList.begin(); itr != cSpells->spellList.end(); ++itr) { TrainerSpell const* tSpell = &itr->second; uint32 reqLevel = 0; if (!_player->IsSpellFitByClassAndRace(tSpell->learnedSpell, &reqLevel)) { continue; } reqLevel = tSpell->isProvidedReqLevel ? tSpell->reqLevel : std::max(reqLevel, tSpell->reqLevel); TrainerSpellState state = _player->GetTrainerSpellState(tSpell, reqLevel); SendTrainerSpellHelper(data, tSpell, state, fDiscountMod, can_learn_primary_prof, reqLevel); ++count; } } if (tSpells) { for (TrainerSpellMap::const_iterator itr = tSpells->spellList.begin(); itr != tSpells->spellList.end(); ++itr) { TrainerSpell const* tSpell = &itr->second; uint32 reqLevel = 0; if (!_player->IsSpellFitByClassAndRace(tSpell->learnedSpell, &reqLevel)) { continue; } reqLevel = tSpell->isProvidedReqLevel ? tSpell->reqLevel : std::max(reqLevel, tSpell->reqLevel); TrainerSpellState state = _player->GetTrainerSpellState(tSpell, reqLevel); SendTrainerSpellHelper(data, tSpell, state, fDiscountMod, can_learn_primary_prof, reqLevel); ++count; } } data << strTitle; data.put<uint32>(count_pos, count); SendPacket(&data); } void WorldSession::HandleTrainerBuySpellOpcode(WorldPacket& recv_data) { ObjectGuid guid; uint32 spellId = 0; recv_data >> guid >> spellId; DEBUG_LOG("WORLD: Received opcode CMSG_TRAINER_BUY_SPELL Trainer: %s, learn spell id is: %u", guid.GetString().c_str(), spellId); Creature* unit = GetPlayer()->GetNPCIfCanInteractWith(guid, UNIT_NPC_FLAG_TRAINER); if (!unit) { DEBUG_LOG("WORLD: HandleTrainerBuySpellOpcode - %s not found or you can't interact with him.", guid.GetString().c_str()); return; } // remove fake death if (GetPlayer()->hasUnitState(UNIT_STAT_DIED)) { GetPlayer()->RemoveSpellsCausingAura(SPELL_AURA_FEIGN_DEATH); } if (!unit->IsTrainerOf(_player, true)) { return; } // check present spell in trainer spell list TrainerSpellData const* cSpells = unit->GetTrainerSpells(); TrainerSpellData const* tSpells = unit->GetTrainerTemplateSpells(); if (!cSpells && !tSpells) { return; } // Try find spell in npc_trainer TrainerSpell const* trainer_spell = cSpells ? cSpells->Find(spellId) : NULL; // Not found, try find in npc_trainer_template if (!trainer_spell && tSpells) { trainer_spell = tSpells->Find(spellId); } // Not found anywhere, cheating? if (!trainer_spell) { return; } // can't be learn, cheat? Or double learn with lags... uint32 reqLevel = 0; if (!_player->IsSpellFitByClassAndRace(trainer_spell->learnedSpell, &reqLevel)) { return; } reqLevel = trainer_spell->isProvidedReqLevel ? trainer_spell->reqLevel : std::max(reqLevel, trainer_spell->reqLevel); if (_player->GetTrainerSpellState(trainer_spell, reqLevel) != TRAINER_SPELL_GREEN) { return; } // apply reputation discount uint32 nSpellCost = uint32(floor(trainer_spell->spellCost * _player->GetReputationPriceDiscount(unit))); // check money requirement if (_player->GetMoney() < nSpellCost) { return; } _player->ModifyMoney(-int32(nSpellCost)); SendPlaySpellVisual(guid, 0xB3); // visual effect on trainer WorldPacket data(SMSG_PLAY_SPELL_IMPACT, 8 + 4); // visual effect on player data << _player->GetObjectGuid(); data << uint32(0x016A); // index from SpellVisualKit.dbc SendPacket(&data); // learn explicitly or cast explicitly // TODO - Are these spells really cast correctly this way? if (trainer_spell->IsCastable()) { _player->CastSpell(_player, trainer_spell->spell, true); } else { _player->learnSpell(spellId, false); } data.Initialize(SMSG_TRAINER_BUY_SUCCEEDED, 12); data << ObjectGuid(guid); data << uint32(spellId); // should be same as in packet from client SendPacket(&data); } void WorldSession::HandleGossipHelloOpcode(WorldPacket& recv_data) { DEBUG_LOG("WORLD: Received opcode CMSG_GOSSIP_HELLO"); ObjectGuid guid; recv_data >> guid; Creature* pCreature = GetPlayer()->GetNPCIfCanInteractWith(guid, UNIT_NPC_FLAG_NONE); if (!pCreature) { DEBUG_LOG("WORLD: HandleGossipHelloOpcode - %s not found or you can't interact with him.", guid.GetString().c_str()); return; } // remove fake death if (GetPlayer()->hasUnitState(UNIT_STAT_DIED)) { GetPlayer()->RemoveSpellsCausingAura(SPELL_AURA_FEIGN_DEATH); } pCreature->StopMoving(); if (pCreature->IsSpiritGuide()) { pCreature->SendAreaSpiritHealerQueryOpcode(_player); } if (!sScriptMgr.OnGossipHello(_player, pCreature)) { _player->PrepareGossipMenu(pCreature, pCreature->GetCreatureInfo()->GossipMenuId); _player->SendPreparedGossip(pCreature); } } void WorldSession::HandleGossipSelectOptionOpcode(WorldPacket& recv_data) { DEBUG_LOG("WORLD: CMSG_GOSSIP_SELECT_OPTION"); uint32 gossipListId; uint32 menuId; ObjectGuid guid; std::string code; recv_data >> guid >> menuId >> gossipListId; if (_player->PlayerTalkClass->GossipOptionCoded(gossipListId)) { recv_data >> code; DEBUG_LOG("Gossip code: %s", code.c_str()); } // remove fake death if (GetPlayer()->hasUnitState(UNIT_STAT_DIED)) { GetPlayer()->RemoveSpellsCausingAura(SPELL_AURA_FEIGN_DEATH); } uint32 sender = _player->PlayerTalkClass->GossipOptionSender(gossipListId); uint32 action = _player->PlayerTalkClass->GossipOptionAction(gossipListId); if (guid.IsAnyTypeCreature()) { Creature* pCreature = GetPlayer()->GetNPCIfCanInteractWith(guid, UNIT_NPC_FLAG_NONE); if (!pCreature) { DEBUG_LOG("WORLD: HandleGossipSelectOptionOpcode - %s not found or you can't interact with it.", guid.GetString().c_str()); return; } if (!sScriptMgr.OnGossipSelect(_player, pCreature, sender, action, code.empty() ? NULL : code.c_str())) { _player->OnGossipSelect(pCreature, gossipListId, menuId); } } else if (guid.IsGameObject()) { GameObject* pGo = GetPlayer()->GetGameObjectIfCanInteractWith(guid); if (!pGo) { DEBUG_LOG("WORLD: HandleGossipSelectOptionOpcode - %s not found or you can't interact with it.", guid.GetString().c_str()); return; } if (!sScriptMgr.OnGossipSelect(_player, pGo, sender, action, code.empty() ? NULL : code.c_str())) { _player->OnGossipSelect(pGo, gossipListId, menuId); } } else if (guid.IsItem()) { Item* item = GetPlayer()->GetItemByGuid(guid); if (!item) { DEBUG_LOG("WORLD: HandleGossipSelectOptionOpcode - %s not found or you can't interact with it.", guid.GetString().c_str()); return; } if (!sScriptMgr.OnGossipSelect(_player, item, sender, action, code.empty() ? NULL : code.c_str())) { DEBUG_LOG("WORLD: HandleGossipSelectOptionOpcode - item script for %s not found or you can't interact with it.", item->GetProto()->Name1); return; } // Used by Eluna #ifdef ENABLE_ELUNA sEluna->HandleGossipSelectOption(GetPlayer(), item, GetPlayer()->PlayerTalkClass->GossipOptionSender(gossipListId), GetPlayer()->PlayerTalkClass->GossipOptionAction(gossipListId), code); #endif /* ENABLE_ELUNA */ } else if (guid.IsPlayer()) { if (GetPlayer()->GetGUIDLow() != guid || GetPlayer()->PlayerTalkClass->GetGossipMenu().GetMenuId() != menuId) { DEBUG_LOG("WORLD: HandleGossipSelectOptionOpcode - %s not found or you can't interact with it.", guid.GetString().c_str()); return; } // Used by Eluna #ifdef ENABLE_ELUNA sEluna->HandleGossipSelectOption(GetPlayer(), menuId, GetPlayer()->PlayerTalkClass->GossipOptionSender(gossipListId), GetPlayer()->PlayerTalkClass->GossipOptionAction(gossipListId), code); #endif /* ENABLE_ELUNA */ } } void WorldSession::HandleSpiritHealerActivateOpcode(WorldPacket& recv_data) { DEBUG_LOG("WORLD: CMSG_SPIRIT_HEALER_ACTIVATE"); ObjectGuid guid; recv_data >> guid; Creature* unit = GetPlayer()->GetNPCIfCanInteractWith(guid, UNIT_NPC_FLAG_SPIRITHEALER); if (!unit) { DEBUG_LOG("WORLD: HandleSpiritHealerActivateOpcode - %s not found or you can't interact with him.", guid.GetString().c_str()); return; } // remove fake death if (GetPlayer()->hasUnitState(UNIT_STAT_DIED)) { GetPlayer()->RemoveSpellsCausingAura(SPELL_AURA_FEIGN_DEATH); } SendSpiritResurrect(); } void WorldSession::SendSpiritResurrect() { _player->ResurrectPlayer(0.5f, true); _player->DurabilityLossAll(0.25f, true); // get corpse nearest graveyard WorldSafeLocsEntry const* corpseGrave = NULL; Corpse* corpse = _player->GetCorpse(); if (corpse) corpseGrave = sObjectMgr.GetClosestGraveYard( corpse->GetPositionX(), corpse->GetPositionY(), corpse->GetPositionZ(), corpse->GetMapId(), _player->GetTeam()); // now can spawn bones _player->SpawnCorpseBones(); // teleport to nearest from corpse graveyard, if different from nearest to player ghost if (corpseGrave) { WorldSafeLocsEntry const* ghostGrave = sObjectMgr.GetClosestGraveYard( _player->GetPositionX(), _player->GetPositionY(), _player->GetPositionZ(), _player->GetMapId(), _player->GetTeam()); if (corpseGrave != ghostGrave) { _player->TeleportTo(corpseGrave->map_id, corpseGrave->x, corpseGrave->y, corpseGrave->z, _player->GetOrientation()); } // or update at original position else { _player->GetCamera().UpdateVisibilityForOwner(); _player->UpdateObjectVisibility(); } } // or update at original position else { _player->GetCamera().UpdateVisibilityForOwner(); _player->UpdateObjectVisibility(); } } void WorldSession::HandleBinderActivateOpcode(WorldPacket& recv_data) { ObjectGuid npcGuid; recv_data >> npcGuid; if (!GetPlayer()->IsInWorld() || !GetPlayer()->IsAlive()) { return; } Creature* unit = GetPlayer()->GetNPCIfCanInteractWith(npcGuid, UNIT_NPC_FLAG_INNKEEPER); if (!unit) { DEBUG_LOG("WORLD: HandleBinderActivateOpcode - %s not found or you can't interact with him.", npcGuid.GetString().c_str()); return; } // remove fake death if (GetPlayer()->hasUnitState(UNIT_STAT_DIED)) { GetPlayer()->RemoveSpellsCausingAura(SPELL_AURA_FEIGN_DEATH); } SendBindPoint(unit); } void WorldSession::SendBindPoint(Creature* npc) { // prevent set homebind to instances in any case if (GetPlayer()->GetMap()->Instanceable()) { return; } // send spell for bind 3286 bind magic npc->CastSpell(_player, 3286, true); // Bind WorldPacket data(SMSG_TRAINER_BUY_SUCCEEDED, (8 + 4)); data << npc->GetObjectGuid(); data << uint32(3286); // Bind SendPacket(&data); _player->PlayerTalkClass->CloseGossip(); } void WorldSession::HandleListStabledPetsOpcode(WorldPacket& recv_data) { DEBUG_LOG("WORLD: Recv MSG_LIST_STABLED_PETS"); ObjectGuid npcGUID; recv_data >> npcGUID; if (!CheckStableMaster(npcGUID)) { SendStableResult(STABLE_ERR_STABLE); return; } // remove fake death if (GetPlayer()->hasUnitState(UNIT_STAT_DIED)) { GetPlayer()->RemoveSpellsCausingAura(SPELL_AURA_FEIGN_DEATH); } SendStablePet(npcGUID); } void WorldSession::SendStablePet(ObjectGuid guid) { DEBUG_LOG("WORLD: Recv MSG_LIST_STABLED_PETS Send."); WorldPacket data(MSG_LIST_STABLED_PETS, 200); // guess size data << guid; Pet* pet = _player->GetPet(); size_t wpos = data.wpos(); data << uint8(0); // place holder for slot show number data << uint8(GetPlayer()->m_stableSlots); uint8 num = 0; // counter for place holder // not let move dead pet in slot if (pet && pet->IsAlive() && pet->getPetType() == HUNTER_PET) { data << uint32(pet->GetCharmInfo()->GetPetNumber()); data << uint32(pet->GetEntry()); data << uint32(pet->getLevel()); data << pet->GetName(); // petname data << uint8(1); // 1 = current, 2/3 = in stable (any from 4,5,... create problems with proper show) ++num; } // 0 1 2 3 4 QueryResult* result = CharacterDatabase.PQuery("SELECT `owner`, `id`, `entry`, `level`, `name` FROM `character_pet` WHERE `owner` = '%u' AND `slot` >= '%u' AND `slot` <= '%u' ORDER BY `slot`", _player->GetGUIDLow(), PET_SAVE_FIRST_STABLE_SLOT, PET_SAVE_LAST_STABLE_SLOT); if (result) { do { Field* fields = result->Fetch(); data << uint32(fields[1].GetUInt32()); // petnumber data << uint32(fields[2].GetUInt32()); // creature entry data << uint32(fields[3].GetUInt32()); // level data << fields[4].GetString(); // name data << uint8(2); // 1 = current, 2/3 = in stable (any from 4,5,... create problems with proper show) ++num; } while (result->NextRow()); delete result; } data.put<uint8>(wpos, num); // set real data to placeholder SendPacket(&data); } void WorldSession::SendStableResult(uint8 res) { WorldPacket data(SMSG_STABLE_RESULT, 1); data << uint8(res); SendPacket(&data); } bool WorldSession::CheckStableMaster(ObjectGuid guid) { // spell case or GM if (guid == GetPlayer()->GetObjectGuid()) { // command case will return only if player have real access to command if (!GetPlayer()->HasAuraType(SPELL_AURA_OPEN_STABLE) && !ChatHandler(GetPlayer()).FindCommand("stable")) { DEBUG_LOG("%s attempt open stable in cheating way.", guid.GetString().c_str()); return false; } } // stable master case else { if (!GetPlayer()->GetNPCIfCanInteractWith(guid, UNIT_NPC_FLAG_STABLEMASTER)) { DEBUG_LOG("Stablemaster %s not found or you can't interact with him.", guid.GetString().c_str()); return false; } } return true; } void WorldSession::HandleStablePet(WorldPacket& recv_data) { DEBUG_LOG("WORLD: Recv CMSG_STABLE_PET"); ObjectGuid npcGUID; recv_data >> npcGUID; if (!GetPlayer()->IsAlive()) { SendStableResult(STABLE_ERR_STABLE); return; } if (!CheckStableMaster(npcGUID)) { SendStableResult(STABLE_ERR_STABLE); return; } // remove fake death if (GetPlayer()->hasUnitState(UNIT_STAT_DIED)) { GetPlayer()->RemoveSpellsCausingAura(SPELL_AURA_FEIGN_DEATH); } Pet* pet = _player->GetPet(); // can't place in stable dead pet if (!pet || !pet->IsAlive() || pet->getPetType() != HUNTER_PET) { SendStableResult(STABLE_ERR_STABLE); return; } uint32 free_slot = 1; QueryResult* result = CharacterDatabase.PQuery("SELECT `owner`,`slot`,`id` FROM `character_pet` WHERE `owner` = '%u' AND `slot` >= '%u' AND `slot` <= '%u' ORDER BY `slot`", _player->GetGUIDLow(), PET_SAVE_FIRST_STABLE_SLOT, PET_SAVE_LAST_STABLE_SLOT); if (result) { do { Field* fields = result->Fetch(); uint32 slot = fields[1].GetUInt32(); // slots ordered in query, and if not equal then free if (slot != free_slot) { break; } // this slot not free, skip ++free_slot; } while (result->NextRow()); delete result; } if (free_slot > 0 && free_slot <= GetPlayer()->m_stableSlots) { pet->Unsummon(PetSaveMode(free_slot), _player); SendStableResult(STABLE_SUCCESS_STABLE); } else { SendStableResult(STABLE_ERR_STABLE); } } void WorldSession::HandleUnstablePet(WorldPacket& recv_data) { DEBUG_LOG("WORLD: Recv CMSG_UNSTABLE_PET."); ObjectGuid npcGUID; uint32 petnumber; recv_data >> npcGUID >> petnumber; if (!CheckStableMaster(npcGUID)) { SendStableResult(STABLE_ERR_STABLE); return; } // remove fake death if (GetPlayer()->hasUnitState(UNIT_STAT_DIED)) { GetPlayer()->RemoveSpellsCausingAura(SPELL_AURA_FEIGN_DEATH); } uint32 creature_id = 0; { QueryResult* result = CharacterDatabase.PQuery("SELECT `entry` FROM `character_pet` WHERE `owner` = '%u' AND `id` = '%u' AND `slot` >='%u' AND `slot` <= '%u'", _player->GetGUIDLow(), petnumber, PET_SAVE_FIRST_STABLE_SLOT, PET_SAVE_LAST_STABLE_SLOT); if (result) { Field* fields = result->Fetch(); creature_id = fields[0].GetUInt32(); delete result; } } if (!creature_id) { SendStableResult(STABLE_ERR_STABLE); return; } CreatureInfo const* creatureInfo = ObjectMgr::GetCreatureTemplate(creature_id); if (!creatureInfo || !creatureInfo->isTameable(_player->CanTameExoticPets())) { // if problem in exotic pet if (creatureInfo && creatureInfo->isTameable(true)) { SendStableResult(STABLE_ERR_EXOTIC); } else { SendStableResult(STABLE_ERR_STABLE); } return; } Pet* pet = _player->GetPet(); if (pet && pet->IsAlive()) { SendStableResult(STABLE_ERR_STABLE); return; } // delete dead pet if (pet) { pet->Unsummon(PET_SAVE_AS_DELETED, _player); } Pet* newpet = new Pet(HUNTER_PET); if (!newpet->LoadPetFromDB(_player, creature_id, petnumber)) { delete newpet; newpet = NULL; SendStableResult(STABLE_ERR_STABLE); return; } SendStableResult(STABLE_SUCCESS_UNSTABLE); } void WorldSession::HandleBuyStableSlot(WorldPacket& recv_data) { DEBUG_LOG("WORLD: Recv CMSG_BUY_STABLE_SLOT."); ObjectGuid npcGUID; recv_data >> npcGUID; if (!CheckStableMaster(npcGUID)) { SendStableResult(STABLE_ERR_STABLE); return; } // remove fake death if (GetPlayer()->hasUnitState(UNIT_STAT_DIED)) { GetPlayer()->RemoveSpellsCausingAura(SPELL_AURA_FEIGN_DEATH); } if (GetPlayer()->m_stableSlots < MAX_PET_STABLES) { StableSlotPricesEntry const* SlotPrice = sStableSlotPricesStore.LookupEntry(GetPlayer()->m_stableSlots + 1); if (_player->GetMoney() >= SlotPrice->Price) { ++GetPlayer()->m_stableSlots; _player->ModifyMoney(-int32(SlotPrice->Price)); SendStableResult(STABLE_SUCCESS_BUY_SLOT); } else { SendStableResult(STABLE_ERR_MONEY); } } else { SendStableResult(STABLE_ERR_STABLE); } } void WorldSession::HandleStableRevivePet(WorldPacket& /* recv_data */) { DEBUG_LOG("HandleStableRevivePet: Not implemented"); } void WorldSession::HandleStableSwapPet(WorldPacket& recv_data) { DEBUG_LOG("WORLD: Recv CMSG_STABLE_SWAP_PET."); ObjectGuid npcGUID; uint32 pet_number; recv_data >> npcGUID >> pet_number; if (!CheckStableMaster(npcGUID)) { SendStableResult(STABLE_ERR_STABLE); return; } // remove fake death if (GetPlayer()->hasUnitState(UNIT_STAT_DIED)) { GetPlayer()->RemoveSpellsCausingAura(SPELL_AURA_FEIGN_DEATH); } Pet* pet = _player->GetPet(); if (!pet || pet->getPetType() != HUNTER_PET) { SendStableResult(STABLE_ERR_STABLE); return; } // find swapped pet slot in stable QueryResult* result = CharacterDatabase.PQuery("SELECT `slot`,`entry` FROM `character_pet` WHERE `owner` = '%u' AND `id` = '%u'", _player->GetGUIDLow(), pet_number); if (!result) { SendStableResult(STABLE_ERR_STABLE); return; } Field* fields = result->Fetch(); uint32 slot = fields[0].GetUInt32(); uint32 creature_id = fields[1].GetUInt32(); delete result; if (!creature_id) { SendStableResult(STABLE_ERR_STABLE); return; } CreatureInfo const* creatureInfo = ObjectMgr::GetCreatureTemplate(creature_id); if (!creatureInfo || !creatureInfo->isTameable(_player->CanTameExoticPets())) { // if problem in exotic pet if (creatureInfo && creatureInfo->isTameable(true)) { SendStableResult(STABLE_ERR_EXOTIC); } else { SendStableResult(STABLE_ERR_STABLE); } return; } // move alive pet to slot or delete dead pet pet->Unsummon(pet->IsAlive() ? PetSaveMode(slot) : PET_SAVE_AS_DELETED, _player); // summon unstabled pet Pet* newpet = new Pet; if (!newpet->LoadPetFromDB(_player, creature_id, pet_number)) { delete newpet; SendStableResult(STABLE_ERR_STABLE); } else { SendStableResult(STABLE_SUCCESS_UNSTABLE); } } void WorldSession::HandleRepairItemOpcode(WorldPacket& recv_data) { DEBUG_LOG("WORLD: CMSG_REPAIR_ITEM"); ObjectGuid npcGuid; ObjectGuid itemGuid; uint8 guildBank; // new in 2.3.2, bool that means from guild bank money recv_data >> npcGuid >> itemGuid >> guildBank; Creature* unit = GetPlayer()->GetNPCIfCanInteractWith(npcGuid, UNIT_NPC_FLAG_REPAIR); if (!unit) { DEBUG_LOG("WORLD: HandleRepairItemOpcode - %s not found or you can't interact with him.", npcGuid.GetString().c_str()); return; } // remove fake death if (GetPlayer()->hasUnitState(UNIT_STAT_DIED)) { GetPlayer()->RemoveSpellsCausingAura(SPELL_AURA_FEIGN_DEATH); } // reputation discount float discountMod = _player->GetReputationPriceDiscount(unit); uint32 TotalCost = 0; if (itemGuid) { DEBUG_LOG("ITEM: %s repair of %s", npcGuid.GetString().c_str(), itemGuid.GetString().c_str()); Item* item = _player->GetItemByGuid(itemGuid); if (item) { TotalCost = _player->DurabilityRepair(item->GetPos(), true, discountMod, (guildBank > 0)); } } else { DEBUG_LOG("ITEM: %s repair all items", npcGuid.GetString().c_str()); TotalCost = _player->DurabilityRepairAll(true, discountMod, (guildBank > 0)); } if (guildBank) { uint32 GuildId = _player->GetGuildId(); if (!GuildId) { return; } Guild* pGuild = sGuildMgr.GetGuildById(GuildId); if (!pGuild) { return; } pGuild->LogBankEvent(GUILD_BANK_LOG_REPAIR_MONEY, 0, _player->GetGUIDLow(), TotalCost); pGuild->SendMoneyInfo(this, _player->GetGUIDLow()); } }
mangostwo/server
src/game/WorldHandlers/NPCHandler.cpp
C++
gpl-2.0
30,883
<?php /* TwigBundle:Exception:exception_full.html.twig */ class __TwigTemplate_12d6106874fca48a5e6b4ba3ab89b6fc520d1b724c37c5efb25ee5ce99e9e8da extends Twig_Template { public function __construct(Twig_Environment $env) { parent::__construct($env); $this->parent = $this->env->loadTemplate("TwigBundle::layout.html.twig"); $this->blocks = array( 'head' => array($this, 'block_head'), 'title' => array($this, 'block_title'), 'body' => array($this, 'block_body'), ); } protected function doGetParent(array $context) { return "TwigBundle::layout.html.twig"; } protected function doDisplay(array $context, array $blocks = array()) { $this->parent->display($context, array_merge($this->blocks, $blocks)); } // line 3 public function block_head($context, array $blocks = array()) { // line 4 echo " <link href=\""; echo twig_escape_filter($this->env, $this->env->getExtension('assets')->getAssetUrl("bundles/framework/css/exception.css"), "html", null, true); echo "\" rel=\"stylesheet\" type=\"text/css\" media=\"all\" /> "; } // line 7 public function block_title($context, array $blocks = array()) { // line 8 echo " "; echo twig_escape_filter($this->env, $this->getAttribute((isset($context["exception"]) ? $context["exception"] : $this->getContext($context, "exception")), "message"), "html", null, true); echo " ("; echo twig_escape_filter($this->env, (isset($context["status_code"]) ? $context["status_code"] : $this->getContext($context, "status_code")), "html", null, true); echo " "; echo twig_escape_filter($this->env, (isset($context["status_text"]) ? $context["status_text"] : $this->getContext($context, "status_text")), "html", null, true); echo ") "; } // line 11 public function block_body($context, array $blocks = array()) { // line 12 echo " "; $this->env->loadTemplate("TwigBundle:Exception:exception.html.twig")->display($context); } public function getTemplateName() { return "TwigBundle:Exception:exception_full.html.twig"; } public function isTraitable() { return false; } public function getDebugInfo() { return array ( 57 => 12, 54 => 11, 43 => 8, 40 => 7, 33 => 4, 30 => 3,); } }
fjbatresv/REMIS
app/cache/dev/twig/12/d6/106874fca48a5e6b4ba3ab89b6fc520d1b724c37c5efb25ee5ce99e9e8da.php
PHP
gpl-2.0
2,475
local assets= { Asset("ANIM", "anim/gold_nugget.zip"), } local function shine(inst) inst.task = nil inst.AnimState:PlayAnimation("sparkle") inst.AnimState:PushAnimation("idle") inst.task = inst:DoTaskInTime(4+math.random()*5, function() shine(inst) end) end local function fn(Sim) local inst = CreateEntity() inst.entity:AddTransform() inst.entity:AddAnimState() inst.entity:AddSoundEmitter() inst.entity:AddPhysics() MakeInventoryPhysics(inst) inst.AnimState:SetBloomEffectHandle( "shaders/anim.ksh" ) inst.AnimState:SetBank("goldnugget") inst.AnimState:SetBuild("gold_nugget") inst.AnimState:PlayAnimation("idle") inst:AddComponent("edible") inst.components.edible.foodtype = "ELEMENTAL" inst.components.edible.hungervalue = 2 inst:AddComponent("tradable") inst:AddComponent("inspectable") inst:AddComponent("stackable") inst:AddComponent("inventoryitem") inst:AddComponent("bait") inst:AddTag("molebait") shine(inst) return inst end return Prefab( "common/inventory/goldnugget", fn, assets)
czfshine/Don-t-Starve
data/DLC0001/scripts/prefabs/goldnugget.lua
Lua
gpl-2.0
1,111
module.exports = { dist: { options: { plugin_slug: 'simple-user-adding', svn_user: 'wearerequired', build_dir: 'release/svn/', assets_dir: 'assets/' } } };
wearerequired/simple-user-adding
grunt/wp_deploy.js
JavaScript
gpl-2.0
180
/* * This file is part of the coreboot project. * * Copyright (C) 2008 VIA Technologies, Inc. * (Written by Aaron Lwe <[email protected]> for VIA) * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. */ #include <stdint.h> #include <device/pci_def.h> #include <device/pci_ids.h> #include <arch/io.h> #include <device/pnp_def.h> #include <console/console.h> #include <lib.h> #include <northbridge/via/cn700/raminit.h> #include <cpu/x86/bist.h> #include <delay.h> #include "southbridge/via/vt8237r/early_smbus.c" #include "southbridge/via/vt8237r/early_serial.c" #include <spd.h> static inline int spd_read_byte(unsigned device, unsigned address) { return smbus_read_byte(device, address); } #include "northbridge/via/cn700/raminit.c" static void enable_mainboard_devices(void) { device_t dev; dev = pci_locate_device(PCI_ID(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_VT8237R_LPC), 0); if (dev == PCI_DEV_INVALID) die("Southbridge not found!!!\n"); /* bit=0 means enable function (per CX700 datasheet) * 5 16.1 USB 2 * 4 16.0 USB 1 * 3 15.0 SATA and PATA * 2 16.2 USB 3 * 1 16.4 USB EHCI */ pci_write_config8(dev, 0x50, 0x80); /* bit=1 means enable internal function (per CX700 datasheet) * 3 Internal RTC * 2 Internal PS2 Mouse * 1 Internal KBC Configuration * 0 Internal Keyboard Controller */ pci_write_config8(dev, 0x51, 0x1d); } static const struct mem_controller ctrl = { .d0f0 = 0x0000, .d0f2 = 0x2000, .d0f3 = 0x3000, .d0f4 = 0x4000, .d0f7 = 0x7000, .d1f0 = 0x8000, .channel0 = { DIMM0 }, }; #include <cpu/intel/romstage.h> void main(unsigned long bist) { /* Enable multifunction for northbridge. */ pci_write_config8(ctrl.d0f0, 0x4f, 0x01); enable_vt8237r_serial(); console_init(); enable_smbus(); smbus_fixup(&ctrl); report_bist_failure(bist); enable_mainboard_devices(); ddr_ram_setup(&ctrl); }
latelee/coreboot
src/mainboard/via/epia-cn/romstage.c
C
gpl-2.0
2,336
<?php class ezxpdfpreview { function ezxpdfpreview() { $this->Operators = array( 'pdfpreview' ); } /*! \return an array with the template operator name. */ function operatorList() { return $this->Operators; } /*! \return true to tell the template engine that the parameter list exists per operator type, this is needed for operator classes that have multiple operators. */ function namedParameterPerOperator() { return true; } /*! See eZTemplateOperator::namedParameterList */ function namedParameterList() { return array( 'pdfpreview' => array( 'width' => array( 'type' => 'integer', 'required' => true ), 'height' => array( 'type' => 'integer', 'required' => true ), 'attribute_id' => array( 'type' => 'integer', 'required' => true), 'attribute_version' => array( 'type' => 'integer', 'required' => true), 'page' => array( 'type' => 'integer', 'required' => false, 'default' => 1) ) ); } /*! Executes the PHP function for the operator cleanup and modifies \a $operatorValue. */ function modify( &$tpl, &$operatorName, &$operatorParameters, &$rootNamespace, &$currentNamespace, &$operatorValue, &$namedParameters ) { $ini = eZINI::instance(); $contentId = $operatorValue; $width = (int)$namedParameters['width']; $height = (int)$namedParameters['height']; $container = ezpKernel::instance()->getServiceContainer(); $pdfPreview = $container->get( 'xrow_pdf_preview' ); $operatorValue = $pdfPreview->preview($contentId, $width, $height); } function previewRetrieve( $file, $mtime, $args ) { //do nothing } function previewGenerate( $file, $args ) { extract( $args ); $pdffile->fetch(true); $cmd = "convert " . eZSys::escapeShellArgument( $pdf_file_path . "[" . $page . "]" ) . " " . " -alpha remove -resize " . eZSys::escapeShellArgument( $width . "x" . $height ) . " " . eZSys::escapeShellArgument( $cacheImageFilePath ); $out = shell_exec( $cmd ); $fileHandler = eZClusterFileHandler::instance(); $fileHandler->fileStore( $cacheImageFilePath, 'pdfpreview', false ); eZDebug::writeDebug( $cmd, "pdfpreview" ); if ( $out ) { eZDebug::writeDebug( $out, "pdfpreview" ); } //return values for the storecache function return array( 'content' => $cacheImageFilePath, 'scope' => 'pdfpreview', 'store' => true ); } } ?>
xrowgmbh/pdfpreview
classes/ezxpdfpreview.php
PHP
gpl-2.0
2,967
return { amazons_woodcutter = {}, }
widelands/widelands
data/tribes/workers/amazons/woodcutter/register.lua
Lua
gpl-2.0
39
<?php /* * Copyright (C) 2015 andi * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ namespace ErsBase\View\Helper; use Zend\View\Helper\AbstractHelper; #use Zend\View\HelperPluginManager as ServiceManager; use Zend\Session\Container; class Session extends AbstractHelper { #protected $serviceManager; /*public function __construct(ServiceManager $serviceManager) { $this->serviceManager = $serviceManager; }*/ public function __invoke() { $container = new Container('ers'); return $container; } }
inbaz/ers
module/ErsBase/src/ErsBase/View/Helper/Session.php
PHP
gpl-2.0
1,154
/******************************************************************************* * This file is part of OpenNMS(R). * * Copyright (C) 2018-2020 The OpenNMS Group, Inc. * OpenNMS(R) is Copyright (C) 1999-2020 The OpenNMS Group, Inc. * * OpenNMS(R) is a registered trademark of The OpenNMS Group, Inc. * * OpenNMS(R) is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as published * by the Free Software Foundation, either version 3 of the License, * or (at your option) any later version. * * OpenNMS(R) is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with OpenNMS(R). If not, see: * http://www.gnu.org/licenses/ * * For more information contact: * OpenNMS(R) Licensing <[email protected]> * http://www.opennms.org/ * http://www.opennms.com/ *******************************************************************************/ package org.opennms.features.kafka.producer; import java.io.IOException; import java.time.Duration; import java.util.Collections; import java.util.Dictionary; import java.util.Enumeration; import java.util.List; import java.util.Map; import java.util.Objects; import java.util.Properties; import java.util.Set; import java.util.concurrent.BlockingDeque; import java.util.concurrent.Callable; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.CountDownLatch; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; import java.util.concurrent.LinkedBlockingDeque; import java.util.concurrent.ThreadFactory; import java.util.function.Consumer; import com.google.common.util.concurrent.ThreadFactoryBuilder; import org.apache.kafka.clients.producer.KafkaProducer; import org.apache.kafka.clients.producer.ProducerRecord; import org.apache.kafka.clients.producer.RecordMetadata; import org.apache.kafka.common.errors.TimeoutException; import org.apache.kafka.common.serialization.ByteArraySerializer; import org.opennms.core.ipc.common.kafka.Utils; import org.opennms.features.kafka.producer.datasync.KafkaAlarmDataSync; import org.opennms.features.kafka.producer.model.OpennmsModelProtos; import org.opennms.features.situationfeedback.api.AlarmFeedback; import org.opennms.features.situationfeedback.api.AlarmFeedbackListener; import org.opennms.netmgt.alarmd.api.AlarmCallbackStateTracker; import org.opennms.netmgt.alarmd.api.AlarmLifecycleListener; import org.opennms.netmgt.events.api.EventListener; import org.opennms.netmgt.events.api.EventSubscriptionService; import org.opennms.netmgt.events.api.ThreadAwareEventListener; import org.opennms.netmgt.events.api.model.IEvent; import org.opennms.netmgt.model.OnmsAlarm; import org.opennms.netmgt.topologies.service.api.OnmsTopologyConsumer; import org.opennms.netmgt.topologies.service.api.OnmsTopologyDao; import org.opennms.netmgt.topologies.service.api.OnmsTopologyEdge; import org.opennms.netmgt.topologies.service.api.OnmsTopologyMessage; import org.opennms.netmgt.topologies.service.api.OnmsTopologyMessage.TopologyMessageStatus; import org.opennms.netmgt.topologies.service.api.OnmsTopologyProtocol; import org.opennms.netmgt.topologies.service.api.OnmsTopologyVertex; import org.opennms.netmgt.topologies.service.api.TopologyVisitor; import org.opennms.netmgt.xml.event.Event; import org.osgi.service.cm.ConfigurationAdmin; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.expression.Expression; import org.springframework.expression.ExpressionParser; import org.springframework.expression.spel.standard.SpelExpressionParser; import com.google.common.annotations.VisibleForTesting; import com.google.common.base.Strings; import com.swrve.ratelimitedlogger.RateLimitedLog; public class OpennmsKafkaProducer implements AlarmLifecycleListener, EventListener, AlarmFeedbackListener, OnmsTopologyConsumer, ThreadAwareEventListener { private static final Logger LOG = LoggerFactory.getLogger(OpennmsKafkaProducer.class); private static final RateLimitedLog RATE_LIMITED_LOGGER = RateLimitedLog .withRateLimit(LOG) .maxRate(5).every(Duration.ofSeconds(30)) .build(); public static final String KAFKA_CLIENT_PID = "org.opennms.features.kafka.producer.client"; private static final ExpressionParser SPEL_PARSER = new SpelExpressionParser(); private final ThreadFactory nodeUpdateThreadFactory = new ThreadFactoryBuilder() .setNameFormat("kafka-producer-node-update-%d") .build(); private final ProtobufMapper protobufMapper; private final NodeCache nodeCache; private final ConfigurationAdmin configAdmin; private final EventSubscriptionService eventSubscriptionService; private KafkaAlarmDataSync dataSync; private String eventTopic; private String alarmTopic; private String nodeTopic; private String alarmFeedbackTopic; private String topologyVertexTopic; private String topologyEdgeTopic; private boolean forwardEvents; private boolean forwardAlarms; private boolean forwardAlarmFeedback; private boolean suppressIncrementalAlarms; private boolean forwardNodes; private Expression eventFilterExpression; private Expression alarmFilterExpression; private final CountDownLatch forwardedEvent = new CountDownLatch(1); private final CountDownLatch forwardedAlarm = new CountDownLatch(1); private final CountDownLatch forwardedNode = new CountDownLatch(1); private final CountDownLatch forwardedAlarmFeedback = new CountDownLatch(1); private final CountDownLatch forwardedTopologyVertexMessage = new CountDownLatch(1); private final CountDownLatch forwardedTopologyEdgeMessage = new CountDownLatch(1); private KafkaProducer<byte[], byte[]> producer; private final Map<String, OpennmsModelProtos.Alarm> outstandingAlarms = new ConcurrentHashMap<>(); private final AlarmEqualityChecker alarmEqualityChecker = AlarmEqualityChecker.with(AlarmEqualityChecker.Exclusions::defaultExclusions); private final AlarmCallbackStateTracker stateTracker = new AlarmCallbackStateTracker(); private final OnmsTopologyDao topologyDao; private int kafkaSendQueueCapacity; private BlockingDeque<KafkaRecord> kafkaSendDeque; private final ExecutorService kafkaSendQueueExecutor = Executors.newSingleThreadExecutor(runnable -> new Thread(runnable, "KafkaSendQueueProcessor")); private final ExecutorService nodeUpdateExecutor; private String encoding = "UTF8"; private int numEventListenerThreads = 4; public OpennmsKafkaProducer(ProtobufMapper protobufMapper, NodeCache nodeCache, ConfigurationAdmin configAdmin, EventSubscriptionService eventSubscriptionService, OnmsTopologyDao topologyDao, int nodeAsyncUpdateThreads) { this.protobufMapper = Objects.requireNonNull(protobufMapper); this.nodeCache = Objects.requireNonNull(nodeCache); this.configAdmin = Objects.requireNonNull(configAdmin); this.eventSubscriptionService = Objects.requireNonNull(eventSubscriptionService); this.topologyDao = Objects.requireNonNull(topologyDao); this.nodeUpdateExecutor = Executors.newFixedThreadPool(nodeAsyncUpdateThreads, nodeUpdateThreadFactory); } public void init() throws IOException { // Create the Kafka producer final Properties producerConfig = new Properties(); final Dictionary<String, Object> properties = configAdmin.getConfiguration(KAFKA_CLIENT_PID).getProperties(); if (properties != null) { final Enumeration<String> keys = properties.keys(); while (keys.hasMoreElements()) { final String key = keys.nextElement(); producerConfig.put(key, properties.get(key)); } } // Overwrite the serializers, since we rely on these producerConfig.put("key.serializer", ByteArraySerializer.class.getCanonicalName()); producerConfig.put("value.serializer", ByteArraySerializer.class.getCanonicalName()); // Class-loader hack for accessing the kafka classes when initializing producer. producer = Utils.runWithGivenClassLoader(() -> new KafkaProducer<>(producerConfig), KafkaProducer.class.getClassLoader()); // Start processing records that have been queued for sending if (kafkaSendQueueCapacity <= 0) { kafkaSendQueueCapacity = 1000; LOG.info("Defaulted the 'kafkaSendQueueCapacity' to 1000 since no property was set"); } kafkaSendDeque = new LinkedBlockingDeque<>(kafkaSendQueueCapacity); kafkaSendQueueExecutor.execute(this::processKafkaSendQueue); if (forwardEvents) { eventSubscriptionService.addEventListener(this); } topologyDao.subscribe(this); } public void destroy() { kafkaSendQueueExecutor.shutdownNow(); nodeUpdateExecutor.shutdownNow(); if (producer != null) { producer.close(); producer = null; } if (forwardEvents) { eventSubscriptionService.removeEventListener(this); } topologyDao.unsubscribe(this); } private void forwardTopologyMessage(OnmsTopologyMessage message) { if (message.getProtocol() == null) { LOG.error("forwardTopologyMessage: null protocol"); return; } if (message.getMessagestatus() == null) { LOG.error("forwardTopologyMessage: null status"); return; } if (message.getMessagebody() == null) { LOG.error("forwardTopologyMessage: null message"); return; } if (message.getMessagestatus() == TopologyMessageStatus.DELETE) { message.getMessagebody().accept(new DeletingVisitor(message)); } else { message.getMessagebody().accept(new UpdatingVisitor(message)); } } private void forwardTopologyEdgeMessage(byte[] refid, byte[] message) { sendRecord(() -> { return new ProducerRecord<>(topologyEdgeTopic, refid, message); }, recordMetadata -> { // We've got an ACK from the server that the event was forwarded // Let other threads know when we've successfully forwarded an event forwardedTopologyEdgeMessage.countDown(); }); } private void forwardEvent(Event event) { boolean shouldForwardEvent = true; // Filtering if (eventFilterExpression != null) { try { shouldForwardEvent = eventFilterExpression.getValue(event, Boolean.class); } catch (Exception e) { LOG.error("Event filter '{}' failed to return a result for event: {}. The event will be forwarded anyways.", eventFilterExpression.getExpressionString(), event.toStringSimple(), e); } } if (!shouldForwardEvent) { if (LOG.isTraceEnabled()) { LOG.trace("Event {} not forwarded due to event filter: {}", event.toStringSimple(), eventFilterExpression.getExpressionString()); } return; } // Node handling if (forwardNodes && event.getNodeid() != null && event.getNodeid() != 0) { updateNodeAsynchronously(event.getNodeid()); } // Forward! sendRecord(() -> { final OpennmsModelProtos.Event mappedEvent = protobufMapper.toEvent(event).build(); LOG.debug("Sending event with UEI: {}", mappedEvent.getUei()); return new ProducerRecord<>(eventTopic, mappedEvent.toByteArray()); }, recordMetadata -> { // We've got an ACK from the server that the event was forwarded // Let other threads know when we've successfully forwarded an event forwardedEvent.countDown(); }); } public boolean shouldForwardAlarm(OnmsAlarm alarm) { if (alarmFilterExpression != null) { // The expression is not necessarily thread safe synchronized (this) { try { final boolean shouldForwardAlarm = alarmFilterExpression.getValue(alarm, Boolean.class); if (LOG.isTraceEnabled()) { LOG.trace("Alarm {} not forwarded due to event filter: {}", alarm, alarmFilterExpression.getExpressionString()); } return shouldForwardAlarm; } catch (Exception e) { LOG.error("Alarm filter '{}' failed to return a result for event: {}. The alarm will be forwarded anyways.", alarmFilterExpression.getExpressionString(), alarm, e); } } } return true; } private boolean isIncrementalAlarm(String reductionKey, OnmsAlarm alarm) { OpennmsModelProtos.Alarm existingAlarm = outstandingAlarms.get(reductionKey); return existingAlarm != null && alarmEqualityChecker.equalsExcludingOnFirst(protobufMapper.toAlarm(alarm), existingAlarm); } private void recordIncrementalAlarm(String reductionKey, OnmsAlarm alarm) { // Apply the excluded fields when putting to the map so we do not have to perform this calculation // on each equality check outstandingAlarms.put(reductionKey, AlarmEqualityChecker.Exclusions.defaultExclusions(protobufMapper.toAlarm(alarm)).build()); } private void updateAlarm(String reductionKey, OnmsAlarm alarm) { // Always push null records, no good way to perform filtering on these if (alarm == null) { // The alarm has been deleted so we shouldn't track it in the map of outstanding alarms any longer outstandingAlarms.remove(reductionKey); // The alarm was deleted, push a null record to the reduction key sendRecord(() -> { LOG.debug("Deleting alarm with reduction key: {}", reductionKey); return new ProducerRecord<>(alarmTopic, reductionKey.getBytes(encoding), null); }, recordMetadata -> { // We've got an ACK from the server that the alarm was forwarded // Let other threads know when we've successfully forwarded an alarm forwardedAlarm.countDown(); }); return; } // Filtering if (!shouldForwardAlarm(alarm)) { return; } if (suppressIncrementalAlarms && isIncrementalAlarm(reductionKey, alarm)) { return; } // Node handling if (forwardNodes && alarm.getNodeId() != null) { updateNodeAsynchronously(alarm.getNodeId()); } // Forward! sendRecord(() -> { final OpennmsModelProtos.Alarm mappedAlarm = protobufMapper.toAlarm(alarm).build(); LOG.debug("Sending alarm with reduction key: {}", reductionKey); if (suppressIncrementalAlarms) { recordIncrementalAlarm(reductionKey, alarm); } return new ProducerRecord<>(alarmTopic, reductionKey.getBytes(encoding), mappedAlarm.toByteArray()); }, recordMetadata -> { // We've got an ACK from the server that the alarm was forwarded // Let other threads know when we've successfully forwarded an alarm forwardedAlarm.countDown(); }); } private void updateNodeAsynchronously(long nodeId) { // Updating node asynchronously will unblock event consumption. nodeUpdateExecutor.execute(() -> { maybeUpdateNode(nodeId); }); } private void maybeUpdateNode(long nodeId) { nodeCache.triggerIfNeeded(nodeId, (node) -> { final String nodeCriteria; if (node != null && node.getForeignSource() != null && node.getForeignId() != null) { nodeCriteria = String.format("%s:%s", node.getForeignSource(), node.getForeignId()); } else { nodeCriteria = Long.toString(nodeId); } if (node == null) { // The node was deleted, push a null record sendRecord(() -> { LOG.debug("Deleting node with criteria: {}", nodeCriteria); return new ProducerRecord<>(nodeTopic, nodeCriteria.getBytes(encoding), null); }); return; } sendRecord(() -> { final OpennmsModelProtos.Node mappedNode = protobufMapper.toNode(node).build(); LOG.debug("Sending node with criteria: {}", nodeCriteria); return new ProducerRecord<>(nodeTopic, nodeCriteria.getBytes(encoding), mappedNode.toByteArray()); }, recordMetadata -> { // We've got an ACK from the server that the node was forwarded // Let other threads know when we've successfully forwarded a node forwardedNode.countDown(); }); }); } private void sendRecord(Callable<ProducerRecord<byte[], byte[]>> callable) { sendRecord(callable, null); } private void sendRecord(Callable<ProducerRecord<byte[], byte[]>> callable, Consumer<RecordMetadata> callback) { if (producer == null) { return; } final ProducerRecord<byte[], byte[]> record; try { record = callable.call(); } catch (Exception e) { // Propagate throw new RuntimeException(e); } // Rather than attempt to send, we instead queue the record to avoid blocking since KafkaProducer's send() // method can block if Kafka is not available when metadata is attempted to be retrieved // Any offer that fails due to capacity overflow will simply be dropped and will have to wait until the next // sync to be processed so this is just a best effort attempt if (!kafkaSendDeque.offer(new KafkaRecord(record, callback))) { RATE_LIMITED_LOGGER.warn("Dropped a Kafka record due to queue capacity being full."); } } private void processKafkaSendQueue() { //noinspection InfiniteLoopStatement while (true) { try { KafkaRecord kafkaRecord = kafkaSendDeque.take(); ProducerRecord<byte[], byte[]> producerRecord = kafkaRecord.getProducerRecord(); Consumer<RecordMetadata> consumer = kafkaRecord.getConsumer(); try { producer.send(producerRecord, (recordMetadata, e) -> { if (e != null) { LOG.warn("Failed to send record to producer: {}.", producerRecord, e); if (e instanceof TimeoutException) { // If Kafka is Offline, buffer the record again for events. // This is best effort to keep the order although in-flight elements may still miss the order. if (producerRecord != null && this.eventTopic.equalsIgnoreCase(producerRecord.topic())) { if(!kafkaSendDeque.offerFirst(kafkaRecord)) { RATE_LIMITED_LOGGER.warn("Dropped a Kafka record due to queue capacity being full."); } } } return; } if (consumer != null) { consumer.accept(recordMetadata); } }); } catch (RuntimeException e) { LOG.warn("Failed to send record to producer: {}.", producerRecord, e); } } catch (InterruptedException ignore) { break; } } } @Override public void handleAlarmSnapshot(List<OnmsAlarm> alarms) { if (!forwardAlarms || dataSync == null) { // Ignore return; } dataSync.handleAlarmSnapshot(alarms); } @Override public void preHandleAlarmSnapshot() { stateTracker.startTrackingAlarms(); } @Override public void postHandleAlarmSnapshot() { stateTracker.resetStateAndStopTrackingAlarms(); } @Override public void handleNewOrUpdatedAlarm(OnmsAlarm alarm) { if (!forwardAlarms) { // Ignore return; } updateAlarm(alarm.getReductionKey(), alarm); stateTracker.trackNewOrUpdatedAlarm(alarm.getId(), alarm.getReductionKey()); } @Override public void handleDeletedAlarm(int alarmId, String reductionKey) { if (!forwardAlarms) { // Ignore return; } handleDeletedAlarm(reductionKey); stateTracker.trackDeletedAlarm(alarmId, reductionKey); } private void handleDeletedAlarm(String reductionKey) { updateAlarm(reductionKey, null); } @Override public String getName() { return OpennmsKafkaProducer.class.getName(); } @Override public void onEvent(IEvent event) { forwardEvent(Event.copyFrom(event)); } @Override public Set<OnmsTopologyProtocol> getProtocols() { return Collections.singleton(OnmsTopologyProtocol.allProtocols()); } @Override public void consume(OnmsTopologyMessage message) { forwardTopologyMessage(message); } public void setTopologyVertexTopic(String topologyVertexTopic) { this.topologyVertexTopic = topologyVertexTopic; } public void setTopologyEdgeTopic(String topologyEdgeTopic) { this.topologyEdgeTopic = topologyEdgeTopic; } public void setEventTopic(String eventTopic) { this.eventTopic = eventTopic; forwardEvents = !Strings.isNullOrEmpty(eventTopic); } public void setAlarmTopic(String alarmTopic) { this.alarmTopic = alarmTopic; forwardAlarms = !Strings.isNullOrEmpty(alarmTopic); } public void setNodeTopic(String nodeTopic) { this.nodeTopic = nodeTopic; forwardNodes = !Strings.isNullOrEmpty(nodeTopic); } public void setAlarmFeedbackTopic(String alarmFeedbackTopic) { this.alarmFeedbackTopic = alarmFeedbackTopic; forwardAlarmFeedback = !Strings.isNullOrEmpty(alarmFeedbackTopic); } public void setEventFilter(String eventFilter) { if (Strings.isNullOrEmpty(eventFilter)) { eventFilterExpression = null; } else { eventFilterExpression = SPEL_PARSER.parseExpression(eventFilter); } } public void setAlarmFilter(String alarmFilter) { if (Strings.isNullOrEmpty(alarmFilter)) { alarmFilterExpression = null; } else { alarmFilterExpression = SPEL_PARSER.parseExpression(alarmFilter); } } public OpennmsKafkaProducer setDataSync(KafkaAlarmDataSync dataSync) { this.dataSync = dataSync; return this; } @Override public void handleAlarmFeedback(List<AlarmFeedback> alarmFeedback) { if (!forwardAlarmFeedback) { return; } // NOTE: This will currently block while waiting for Kafka metadata if Kafka is not available. alarmFeedback.forEach(feedback -> sendRecord(() -> { LOG.debug("Sending alarm feedback with key: {}", feedback.getAlarmKey()); return new ProducerRecord<>(alarmFeedbackTopic, feedback.getAlarmKey().getBytes(encoding), protobufMapper.toAlarmFeedback(feedback).build().toByteArray()); }, recordMetadata -> { // We've got an ACK from the server that the alarm feedback was forwarded // Let other threads know when we've successfully forwarded an alarm feedback forwardedAlarmFeedback.countDown(); })); } public boolean isForwardingAlarms() { return forwardAlarms; } public CountDownLatch getEventForwardedLatch() { return forwardedEvent; } public CountDownLatch getAlarmForwardedLatch() { return forwardedAlarm; } public CountDownLatch getNodeForwardedLatch() { return forwardedNode; } public CountDownLatch getAlarmFeedbackForwardedLatch() { return forwardedAlarmFeedback; } public void setSuppressIncrementalAlarms(boolean suppressIncrementalAlarms) { this.suppressIncrementalAlarms = suppressIncrementalAlarms; } @VisibleForTesting KafkaAlarmDataSync getDataSync() { return dataSync; } public AlarmCallbackStateTracker getAlarmCallbackStateTracker() { return stateTracker; } public void setKafkaSendQueueCapacity(int kafkaSendQueueCapacity) { this.kafkaSendQueueCapacity = kafkaSendQueueCapacity; } @Override public int getNumThreads() { return numEventListenerThreads; } private static final class KafkaRecord { private final ProducerRecord<byte[], byte[]> producerRecord; private final Consumer<RecordMetadata> consumer; KafkaRecord(ProducerRecord<byte[], byte[]> producerRecord, Consumer<RecordMetadata> consumer) { this.producerRecord = producerRecord; this.consumer = consumer; } ProducerRecord<byte[], byte[]> getProducerRecord() { return producerRecord; } Consumer<RecordMetadata> getConsumer() { return consumer; } } public CountDownLatch getForwardedTopologyVertexMessage() { return forwardedTopologyVertexMessage; } public CountDownLatch getForwardedTopologyEdgeMessage() { return forwardedTopologyEdgeMessage; } public String getEncoding() { return encoding; } public void setEncoding(String encoding) { this.encoding = encoding; } public int getNumEventListenerThreads() { return numEventListenerThreads; } public void setNumEventListenerThreads(int numEventListenerThreads) { this.numEventListenerThreads = numEventListenerThreads; } private class TopologyVisitorImpl implements TopologyVisitor { final OnmsTopologyMessage onmsTopologyMessage; TopologyVisitorImpl(OnmsTopologyMessage onmsTopologyMessage) { this.onmsTopologyMessage = Objects.requireNonNull(onmsTopologyMessage); } byte[] getKeyForEdge(OnmsTopologyEdge edge) { Objects.requireNonNull(onmsTopologyMessage); return String.format("topology:%s:%s", onmsTopologyMessage.getProtocol().getId(), edge.getId()).getBytes(); } } private class DeletingVisitor extends TopologyVisitorImpl { DeletingVisitor(OnmsTopologyMessage topologyMessage) { super(topologyMessage); } @Override public void visit(OnmsTopologyEdge edge) { forwardTopologyEdgeMessage(getKeyForEdge(edge), null); } } private class UpdatingVisitor extends TopologyVisitorImpl { UpdatingVisitor(OnmsTopologyMessage onmsTopologyMessage) { super(onmsTopologyMessage); } @Override public void visit(OnmsTopologyVertex vertex) { // Node handling if (forwardNodes && vertex.getNodeid() != null) { updateNodeAsynchronously(vertex.getNodeid()); } } @Override public void visit(OnmsTopologyEdge edge) { Objects.requireNonNull(onmsTopologyMessage); final OpennmsModelProtos.TopologyEdge mappedTopoMsg = protobufMapper.toEdgeTopologyMessage(onmsTopologyMessage.getProtocol(), edge); forwardTopologyEdgeMessage(getKeyForEdge(edge), mappedTopoMsg.toByteArray()); } } }
jeffgdotorg/opennms
features/kafka/producer/src/main/java/org/opennms/features/kafka/producer/OpennmsKafkaProducer.java
Java
gpl-2.0
28,520
/* * This file Copyright (C) Mnemosyne LLC * * This file is licensed by the GPL version 2. Works owned by the * Transmission project are granted a special exemption to clause 2 (b) * so that the bulk of its code can remain under the MIT license. * This exemption does not extend to derived works not owned by * the Transmission project. * * $Id$ */ #ifndef GTR_UTIL_H #define GTR_UTIL_H #include <sys/types.h> #include <glib.h> #include <gtk/gtk.h> #include <libtransmission/transmission.h> extern const int mem_K; extern const char * mem_K_str; extern const char * mem_M_str; extern const char * mem_G_str; extern const char * mem_T_str; extern const int disk_K; extern const char * disk_K_str; extern const char * disk_M_str; extern const char * disk_G_str; extern const char * disk_T_str; extern const int speed_K; extern const char * speed_K_str; extern const char * speed_M_str; extern const char * speed_G_str; extern const char * speed_T_str; /* macro to shut up "unused parameter" warnings */ #ifndef UNUSED #define UNUSED G_GNUC_UNUSED #endif enum { GTR_UNICODE_UP, GTR_UNICODE_DOWN, GTR_UNICODE_INF, GTR_UNICODE_BULLET }; const char * gtr_get_unicode_string (int); /* return a percent formatted string of either x.xx, xx.x or xxx */ char* tr_strlpercent (char * buf, double x, size_t buflen); /* return a human-readable string for the size given in bytes. */ char* tr_strlsize (char * buf, guint64 size, size_t buflen); /* return a human-readable string for the given ratio. */ char* tr_strlratio (char * buf, double ratio, size_t buflen); /* return a human-readable string for the time given in seconds. */ char* tr_strltime (char * buf, int secs, size_t buflen); /*** **** ***/ /* http://www.legaltorrents.com/some/announce/url --> legaltorrents.com */ void gtr_get_host_from_url (char * buf, size_t buflen, const char * url); gboolean gtr_is_magnet_link (const char * str); gboolean gtr_is_hex_hashcode (const char * str); /*** **** ***/ void gtr_open_uri (const char * uri); void gtr_open_file (const char * path); const char* gtr_get_help_uri (void); /*** **** ***/ /* backwards-compatible wrapper around gtk_widget_set_visible () */ void gtr_widget_set_visible (GtkWidget *, gboolean); void gtr_dialog_set_content (GtkDialog * dialog, GtkWidget * content); /*** **** ***/ GtkWidget * gtr_priority_combo_new (void); #define gtr_priority_combo_get_value(w) gtr_combo_box_get_active_enum (w) #define gtr_priority_combo_set_value(w,val) gtr_combo_box_set_active_enum (w,val) GtkWidget * gtr_combo_box_new_enum (const char * text_1, ...); int gtr_combo_box_get_active_enum (GtkComboBox *); void gtr_combo_box_set_active_enum (GtkComboBox *, int value); /*** **** ***/ void gtr_unrecognized_url_dialog (GtkWidget * parent, const char * url); void gtr_http_failure_dialog (GtkWidget * parent, const char * url, long response_code); void gtr_add_torrent_error_dialog (GtkWidget * window_or_child, int err, const char * filename); /* pop up the context menu if a user right-clicks. if the row they right-click on isn't selected, select it. */ gboolean on_tree_view_button_pressed (GtkWidget * view, GdkEventButton * event, gpointer unused); /* if the click didn't specify a row, clear the selection */ gboolean on_tree_view_button_released (GtkWidget * view, GdkEventButton * event, gpointer unused); /* move a file to the trashcan if GIO is available; otherwise, delete it */ int gtr_file_trash_or_remove (const char * filename); void gtr_paste_clipboard_url_into_entry (GtkWidget * entry); /* Only call gtk_label_set_text () if the new text differs from the old. * This prevents the label from having to recalculate its size * and prevents selected text in the label from being deselected */ void gtr_label_set_text (GtkLabel * lb, const char * text); #endif /* GTR_UTIL_H */
cfpp2p/Transmission-basin
gtk/util.h
C
gpl-2.0
4,153
/** * The routes worker process * * This worker process gets the app routes by running the application dynamically * on the server, then stores the publicly exposed routes in an intermediate format * (just the url paths) in Redis. * From there, the paths are used by the live app for serving /sitemap.xml and /robots.txt requests. * The paths are also used by downstream worker processes (snapshots) to produce the site's html snapshots * for _escaped_fragment_ requests. * * Run this worker anytime the app menu has changed and needs to be refreshed. * * PATH and NODE_ENV have to set in the environment before running this. * PATH has to include phantomjs bin */ var phantom = require("node-phantom"); var urlm = require("url"); var redis = require("../../../helpers/redis"); var configLib = require("../../../config"); var config = configLib.create(); // Write the appRoutes to Redis function writeAppRoutes(appRoutes) { // remove pattern routes, and prepend / appRoutes = appRoutes.filter(function(appRoute) { return !/[*\(\:]/.test(appRoute); }).map(function(appRoute) { return "/"+appRoute; }); if (appRoutes.length > 0) { var redisClient = redis.client(); redisClient.set(config.keys.routes, appRoutes, function(err) { if (err) { console.error("failed to store the routes for "+config.keys.routes); } else { console.log("successfully stored "+appRoutes.length+" routes in "+config.keys.routes); } redisClient.quit(); }); } else { console.error("no routes found for "+config.app.hostname); } } // Start up phantom, wait for the page, get the appRoutes function routes(urlPath, timeout) { var url = urlm.format({ protocol: "http", hostname: config.app.hostname, port: config.app.port || 80, pathname: urlPath }); phantom.create(function(err, ph) { return ph.createPage(function(err, page) { return page.open(url, function(err, status) { if (status !== "success") { console.error("Unable to load page " + url); ph.exit(); } else { setTimeout(function() { return page.evaluate(function() { return window.wpspa.appRoutes; }, function(err, result) { if (err) { console.error("failed to get appRoutes"); } else { writeAppRoutes(Object.keys(result)); } ph.exit(); }); }, timeout); } }); }); }); } module.exports = { routes: routes };
localnerve/wpspa
server/workers/routes/lib/index.js
JavaScript
gpl-2.0
2,589
/* * Vulcan Build Manager * Copyright (C) 2005-2012 Chris Eldredge * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ package net.sourceforge.vulcan.subversion; import java.io.File; import java.io.IOException; import java.io.OutputStream; import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; import java.util.Collections; import java.util.Comparator; import java.util.Date; import java.util.HashSet; import java.util.List; import java.util.Map; import net.sourceforge.vulcan.RepositoryAdaptor; import net.sourceforge.vulcan.StateManager; import net.sourceforge.vulcan.core.BuildDetailCallback; import net.sourceforge.vulcan.core.support.FileSystem; import net.sourceforge.vulcan.core.support.FileSystemImpl; import net.sourceforge.vulcan.core.support.RepositoryUtils; import net.sourceforge.vulcan.dto.ChangeLogDto; import net.sourceforge.vulcan.dto.ChangeSetDto; import net.sourceforge.vulcan.dto.PathModification; import net.sourceforge.vulcan.dto.ProjectConfigDto; import net.sourceforge.vulcan.dto.ProjectStatusDto; import net.sourceforge.vulcan.dto.RepositoryTagDto; import net.sourceforge.vulcan.dto.RevisionTokenDto; import net.sourceforge.vulcan.exception.ConfigException; import net.sourceforge.vulcan.exception.RepositoryException; import net.sourceforge.vulcan.integration.support.PluginSupport; import net.sourceforge.vulcan.subversion.dto.CheckoutDepth; import net.sourceforge.vulcan.subversion.dto.SparseCheckoutDto; import net.sourceforge.vulcan.subversion.dto.SubversionConfigDto; import net.sourceforge.vulcan.subversion.dto.SubversionProjectConfigDto; import net.sourceforge.vulcan.subversion.dto.SubversionRepositoryProfileDto; import org.apache.commons.lang.StringUtils; import org.tigris.subversion.javahl.ClientException; import org.tigris.subversion.javahl.Notify2; import org.tigris.subversion.javahl.NotifyAction; import org.tigris.subversion.javahl.NotifyInformation; import org.tigris.subversion.javahl.PromptUserPassword2; import org.tigris.subversion.javahl.PromptUserPassword3; import org.tigris.subversion.javahl.Revision; import org.tigris.subversion.javahl.SVNClient; import org.tmatesoft.svn.core.ISVNLogEntryHandler; import org.tmatesoft.svn.core.SVNCancelException; import org.tmatesoft.svn.core.SVNDepth; import org.tmatesoft.svn.core.SVNDirEntry; import org.tmatesoft.svn.core.SVNErrorCode; import org.tmatesoft.svn.core.SVNException; import org.tmatesoft.svn.core.SVNLogEntry; import org.tmatesoft.svn.core.SVNLogEntryPath; import org.tmatesoft.svn.core.SVNNodeKind; import org.tmatesoft.svn.core.SVNProperties; import org.tmatesoft.svn.core.SVNPropertyValue; import org.tmatesoft.svn.core.SVNURL; import org.tmatesoft.svn.core.io.SVNRepository; import org.tmatesoft.svn.core.wc.ISVNEventHandler; import org.tmatesoft.svn.core.wc.SVNDiffClient; import org.tmatesoft.svn.core.wc.SVNEvent; import org.tmatesoft.svn.core.wc.SVNLogClient; import org.tmatesoft.svn.core.wc.SVNPropertyData; import org.tmatesoft.svn.core.wc.SVNRevision; import org.tmatesoft.svn.core.wc.SVNWCClient; public class SubversionRepositoryAdaptor extends SubversionSupport implements RepositoryAdaptor { private final EventHandler eventHandler = new EventHandler(); private final ProjectConfigDto projectConfig; private final String projectName; private final Map<String, Long> byteCounters; final LineOfDevelopment lineOfDevelopment = new LineOfDevelopment(); final SVNClient client = new SVNClient(); private long revision = -1; private long diffStartRevision = -1; private final StateManager stateManager; private FileSystem fileSystem = new FileSystemImpl(); private List<ChangeSetDto> changeSets; boolean canceling = false; public SubversionRepositoryAdaptor(SubversionConfigDto globalConfig, ProjectConfigDto projectConfig, SubversionProjectConfigDto config, StateManager stateManager) throws ConfigException { this(globalConfig, projectConfig, config, stateManager, true); } protected SubversionRepositoryAdaptor(SubversionConfigDto globalConfig, ProjectConfigDto projectConfig, SubversionProjectConfigDto config, StateManager stateManager, boolean init) throws ConfigException { this( globalConfig, projectConfig, config, stateManager, init, getSelectedEnvironment( globalConfig.getProfiles(), config.getRepositoryProfile(), "svn.profile.missing")); } protected SubversionRepositoryAdaptor(SubversionConfigDto globalConfig, ProjectConfigDto projectConfig, SubversionProjectConfigDto config, StateManager stateManager, boolean init, SubversionRepositoryProfileDto profile) throws ConfigException { this( globalConfig, projectConfig, config, stateManager, profile, createRepository(profile, init)); } protected SubversionRepositoryAdaptor(SubversionConfigDto globalConfig, ProjectConfigDto projectConfig, SubversionProjectConfigDto config, StateManager stateManager, final SubversionRepositoryProfileDto profile, SVNRepository svnRepository) throws ConfigException { super(config, profile, svnRepository); this.stateManager = stateManager; this.projectConfig = projectConfig; this.projectName = projectConfig.getName(); if (globalConfig != null) { this.byteCounters = globalConfig.getWorkingCopyByteCounts(); } else { this.byteCounters = Collections.emptyMap(); } lineOfDevelopment.setPath(config.getPath()); lineOfDevelopment.setRepositoryRoot(profile.getRootUrl()); lineOfDevelopment.setTagFolderNames(new HashSet<String>(Arrays.asList(globalConfig.getTagFolderNames()))); client.notification2(eventHandler); if (StringUtils.isNotBlank(profile.getUsername())) { client.setPrompt(new PromptUserPassword3() { public String getUsername() { return profile.getUsername(); } public String getPassword() { return profile.getPassword(); } public boolean prompt(String arg0, String arg1) { return true; } public boolean prompt(String arg0, String arg1, boolean arg2) { return true; } public boolean userAllowedSave() { return false; } public int askTrustSSLServer(String arg0, boolean arg1) { return PromptUserPassword2.AcceptTemporary; } public String askQuestion(String arg0, String arg1, boolean arg2, boolean arg3) { throw new UnsupportedOperationException(); } public String askQuestion(String arg0, String arg1, boolean arg2) { throw new UnsupportedOperationException(); } public boolean askYesNo(String arg0, String arg1, boolean arg2) { throw new UnsupportedOperationException(); } }); } } public boolean hasIncomingChanges(ProjectStatusDto previousStatus) throws RepositoryException { RevisionTokenDto rev = previousStatus.getRevision(); if (rev == null) { rev = previousStatus.getLastKnownRevision(); } if (rev == null) { return true; } return getLatestRevision(rev).getRevisionNum() > rev.getRevisionNum(); } public void prepareRepository(BuildDetailCallback buildDetailCallback) throws RepositoryException, InterruptedException { } public RevisionTokenDto getLatestRevision(RevisionTokenDto previousRevision) throws RepositoryException { final String path = lineOfDevelopment.getComputedRelativePath(); SVNDirEntry info; try { info = svnRepository.info(path, revision); } catch (SVNException e) { throw new RepositoryException(e); } if (info == null) { throw new RepositoryException("svn.path.not.exist", null, path); } final long lastChangedRevision = info.getRevision(); /* * Get the revision of the newest log entry for this path. * See Issue 95 (http://code.google.com/p/vulcan/issues/detail?id=95). */ final long mostRecentLogRevision = getMostRecentLogRevision(lastChangedRevision); revision = mostRecentLogRevision; if (config.getCheckoutDepth() == CheckoutDepth.Infinity || previousRevision == null) { return new RevisionTokenDto(revision, "r" + revision); } /* Issue 151 (http://code.google.com/p/vulcan/issues/detail?id=151): * Need to filter out irrelevant commits from sparse working copy. */ try { getChangeLog(previousRevision, new RevisionTokenDto(revision), null); if (changeSets.size() > 0) { String label = changeSets.get(changeSets.size()-1).getRevisionLabel(); revision = Long.valueOf(label.substring(1)); } else { // No commit logs matched means we're effectively at the old revision. // Need to check if the old revision exists on this path in case we're building // from a different branch/tag. try { info = svnRepository.info(path, previousRevision.getRevisionNum()); } catch (SVNException e) { throw new RepositoryException(e); } if (info != null) { revision = previousRevision.getRevisionNum(); } else { // Path doesn't exist at that revision. Use most recent commit // even though it didn't match our sparse working copy. revision = mostRecentLogRevision; } } } catch (RepositoryException e) { // Probably the path does not exist at the previousRevision. revision = mostRecentLogRevision; changeSets = null; } return new RevisionTokenDto(revision, "r" + revision); } public void createPristineWorkingCopy(BuildDetailCallback buildDetailCallback) throws RepositoryException { final File absolutePath = new File(projectConfig.getWorkDir()).getAbsoluteFile(); new RepositoryUtils(fileSystem).createOrCleanWorkingCopy(absolutePath, buildDetailCallback); synchronized (byteCounters) { if (byteCounters.containsKey(projectName)) { eventHandler.setPreviousFileCount(byteCounters.get(projectName).longValue()); } } eventHandler.setBuildDetailCallback(buildDetailCallback); final Revision svnRev = Revision.getInstance(revision); final boolean ignoreExternals = false; final boolean allowUnverObstructions = false; try { client.checkout( getCompleteSVNURL().toString(), absolutePath.toString(), svnRev, svnRev, config.getCheckoutDepth().getId(), ignoreExternals, allowUnverObstructions ); configureBugtraqIfNecessary(absolutePath); } catch (ClientException e) { if (!canceling) { throw new RepositoryException(e); } } catch (SVNException e) { throw new RepositoryException(e); } final boolean depthIsSticky = true; for (SparseCheckoutDto folder : config.getFolders()) { sparseUpdate(folder, absolutePath, svnRev, ignoreExternals, allowUnverObstructions, depthIsSticky); } synchronized (byteCounters) { byteCounters.put(projectName, eventHandler.getFileCount()); } } void sparseUpdate(SparseCheckoutDto folder, File workingCopyRootPath, final Revision svnRev, final boolean ignoreExternals, final boolean allowUnverObstructions, final boolean depthIsSticky) throws RepositoryException { final File dir = new File(workingCopyRootPath, folder.getDirectoryName()); final File parentDir = dir.getParentFile(); if (!parentDir.exists()) { final SparseCheckoutDto parentFolder = new SparseCheckoutDto(); parentFolder.setDirectoryName(new File(folder.getDirectoryName()).getParent()); parentFolder.setCheckoutDepth(CheckoutDepth.Empty); sparseUpdate(parentFolder, workingCopyRootPath, svnRev, ignoreExternals, allowUnverObstructions, depthIsSticky); } final String path = dir.toString(); try { client.update(path, svnRev, folder.getCheckoutDepth().getId(), depthIsSticky, ignoreExternals, allowUnverObstructions); } catch (ClientException e) { if (!canceling) { throw new RepositoryException("svn.sparse.checkout.error", e, folder.getDirectoryName()); } } } public void updateWorkingCopy(BuildDetailCallback buildDetailCallback) throws RepositoryException { final File absolutePath = new File(projectConfig.getWorkDir()).getAbsoluteFile(); try { final Revision svnRev = Revision.getInstance(revision); final boolean depthIsSticky = false; final boolean ignoreExternals = false; final boolean allowUnverObstructions = false; client.update(absolutePath.toString(), svnRev, SVNDepth.UNKNOWN.getId(), depthIsSticky, ignoreExternals, allowUnverObstructions); } catch (ClientException e) { if (!canceling) { throw new RepositoryException(e); } throw new RepositoryException(e); } } public boolean isWorkingCopy() { try { if (client.info(new File(projectConfig.getWorkDir()).getAbsolutePath()) != null) { return true; } } catch (ClientException ignore) { } return false; } public ChangeLogDto getChangeLog(RevisionTokenDto first, RevisionTokenDto last, OutputStream diffOutputStream) throws RepositoryException { final SVNRevision r1 = SVNRevision.create(first.getRevisionNum().longValue()); final SVNRevision r2 = SVNRevision.create(last.getRevisionNum().longValue()); if (changeSets == null) { changeSets = fetchChangeSets(r1, r2); if (this.config.getCheckoutDepth() != CheckoutDepth.Infinity) { final SparseChangeLogFilter filter = new SparseChangeLogFilter(this.config, this.lineOfDevelopment); filter.removeIrrelevantChangeSets(changeSets); } } if (diffOutputStream != null) { fetchDifferences(SVNRevision.create(diffStartRevision), r2, diffOutputStream); } final ChangeLogDto changeLog = new ChangeLogDto(); changeLog.setChangeSets(changeSets); return changeLog; } @SuppressWarnings("unchecked") public List<RepositoryTagDto> getAvailableTagsAndBranches() throws RepositoryException { final String projectRoot = lineOfDevelopment.getComputedTagRoot(); final List<RepositoryTagDto> tags = new ArrayList<RepositoryTagDto>(); final RepositoryTagDto trunkTag = new RepositoryTagDto(); trunkTag.setDescription("trunk"); trunkTag.setName("trunk"); tags.add(trunkTag); try { final Collection<SVNDirEntry> entries = svnRepository.getDir(projectRoot, -1, null, (Collection<?>) null); for (SVNDirEntry entry : entries) { final String folderName = entry.getName(); if (entry.getKind() == SVNNodeKind.DIR && lineOfDevelopment.isTag(folderName)) { addTags(projectRoot, folderName, tags); } } } catch (SVNException e) { throw new RepositoryException(e); } Collections.sort(tags, new Comparator<RepositoryTagDto>() { public int compare(RepositoryTagDto t1, RepositoryTagDto t2) { return t1.getName().compareTo(t2.getName()); } }); return tags; } public String getRepositoryUrl() { try { return getCompleteSVNURL().toString(); } catch (SVNException e) { throw new RuntimeException(e); } } public String getTagOrBranch() { return lineOfDevelopment.getComputedTagName(); } public void setTagOrBranch(String tagName) { lineOfDevelopment.setAlternateTagName(tagName); } protected long getMostRecentLogRevision(final long lastChangedRevision) throws RepositoryException { final long[] commitRev = new long[1]; commitRev[0] = -1; final SVNLogClient logClient = new SVNLogClient( svnRepository.getAuthenticationManager(), options); final ISVNLogEntryHandler handler = new ISVNLogEntryHandler() { public void handleLogEntry(SVNLogEntry logEntry) throws SVNException { commitRev[0] = logEntry.getRevision(); } }; try { logClient.doLog(SVNURL.parseURIEncoded(profile.getRootUrl()), new String[] {lineOfDevelopment.getComputedRelativePath()}, SVNRevision.HEAD, SVNRevision.HEAD, SVNRevision.create(lastChangedRevision), true, false, 1, handler); } catch (SVNException e) { throw new RepositoryException(e); } // If for some reason there were zero log entries, default to Last Changed Revision. if (commitRev[0] < 0) { commitRev[0] = lastChangedRevision; } return commitRev[0]; } protected List<ChangeSetDto> fetchChangeSets(final SVNRevision r1, final SVNRevision r2) throws RepositoryException { final SVNLogClient logClient = new SVNLogClient(svnRepository.getAuthenticationManager(), options); logClient.setEventHandler(eventHandler); final List<ChangeSetDto> changeSets = new ArrayList<ChangeSetDto>(); diffStartRevision = r2.getNumber(); final ISVNLogEntryHandler handler = new ISVNLogEntryHandler() { @SuppressWarnings("unchecked") public void handleLogEntry(SVNLogEntry logEntry) { final long logEntryRevision = logEntry.getRevision(); if (diffStartRevision > logEntryRevision) { diffStartRevision = logEntryRevision; } if (logEntryRevision == r1.getNumber()) { /* The log message for r1 is in the previous build report. Don't include it twice. */ return; } final ChangeSetDto changeSet = new ChangeSetDto(); changeSet.setRevisionLabel("r" + logEntryRevision); changeSet.setAuthorName(logEntry.getAuthor()); changeSet.setMessage(logEntry.getMessage()); changeSet.setTimestamp(new Date(logEntry.getDate().getTime())); final Collection<SVNLogEntryPath> paths = ((Map<String, SVNLogEntryPath>) logEntry.getChangedPaths()).values(); for (SVNLogEntryPath path : paths) { changeSet.addModifiedPath(path.getPath(), toPathModification(path.getType())); } changeSets.add(changeSet); } private PathModification toPathModification(char type) { switch(type) { case SVNLogEntryPath.TYPE_ADDED: return PathModification.Add; case SVNLogEntryPath.TYPE_DELETED: return PathModification.Remove; case SVNLogEntryPath.TYPE_REPLACED: case SVNLogEntryPath.TYPE_MODIFIED: return PathModification.Modify; } return null; } }; try { logClient.doLog( SVNURL.parseURIEncoded(profile.getRootUrl()), new String[] {lineOfDevelopment.getComputedRelativePath()}, r1, r1, r2, true, true, 0, handler); } catch (SVNCancelException e) { } catch (SVNException e) { if (isFatal(e)) { throw new RepositoryException(e); } } return changeSets; } protected void fetchDifferences(final SVNRevision r1, final SVNRevision r2, OutputStream os) throws RepositoryException { final SVNDiffClient diffClient = new SVNDiffClient(svnRepository.getAuthenticationManager(), options); diffClient.setEventHandler(eventHandler); try { diffClient.doDiff(getCompleteSVNURL(), r1, r1, r2, SVNDepth.INFINITY, true, os); os.close(); } catch (SVNCancelException e) { } catch (SVNException e) { if (e.getErrorMessage().getErrorCode() == SVNErrorCode.RA_DAV_PATH_NOT_FOUND) { // This usually happens when building from a different branch or tag that // does not share ancestry with the previous build. log.info("Failed to obtain diff of revisions r" + r1.getNumber() + ":" + r2.getNumber(), e); } else { throw new RepositoryException(e); } } catch (IOException e) { throw new RepositoryException(e); } } protected SVNURL getCompleteSVNURL() throws SVNException { return SVNURL.parseURIEncoded(lineOfDevelopment.getAbsoluteUrl()); } @SuppressWarnings("unchecked") private void addTags(String projectRoot, String folderName, List<RepositoryTagDto> tags) throws SVNException { final String path = projectRoot + "/" + folderName; final Collection<SVNDirEntry> entries = svnRepository.getDir(path, -1, null, (Collection<?>) null); for (SVNDirEntry entry : entries) { final String tagName = entry.getName(); if (entry.getKind() == SVNNodeKind.DIR) { RepositoryTagDto tag = new RepositoryTagDto(); tag.setName(folderName + "/" + tagName); tag.setDescription(tag.getName()); tags.add(tag); } } } private void configureBugtraqIfNecessary(File absolutePath) throws SVNException { if (!this.config.isObtainBugtraqProperties()) { return; } final ProjectConfigDto orig = stateManager.getProjectConfig(projectName); final SVNWCClient client = new SVNWCClient(svnRepository.getAuthenticationManager(), options); final SVNProperties bugtraqProps = new SVNProperties(); getWorkingCopyProperty(client, absolutePath, BUGTRAQ_URL, bugtraqProps); getWorkingCopyProperty(client, absolutePath, BUGTRAQ_MESSAGE, bugtraqProps); getWorkingCopyProperty(client, absolutePath, BUGTRAQ_LOGREGEX, bugtraqProps); final ProjectConfigDto projectConfig = (ProjectConfigDto) orig.copy(); configureBugtraq(projectConfig, bugtraqProps); if (!orig.equals(projectConfig)) { try { log.info("Updating bugtraq information for project " + projectName); stateManager.updateProjectConfig(projectName, projectConfig, false); } catch (Exception e) { if (e instanceof RuntimeException) { throw (RuntimeException) e; } throw new RuntimeException(e); } } } private void getWorkingCopyProperty(final SVNWCClient client, File absolutePath, String propName, final SVNProperties bugtraqProps) throws SVNException { SVNPropertyData prop; prop = client.doGetProperty(absolutePath, propName, SVNRevision.BASE, SVNRevision.BASE); bugtraqProps.put(propName, getValueIfNotNull(prop)); } protected String getValueIfNotNull(SVNPropertyData prop) { if (prop != null) { final SVNPropertyValue value = prop.getValue(); if (value.isString()) { return value.getString(); } return SVNPropertyValue.getPropertyAsString(value); } return StringUtils.EMPTY; } private class EventHandler implements ISVNEventHandler, Notify2 { private long previousFileCount = -1; private long fileCount = 0; private BuildDetailCallback buildDetailCallback; public void onNotify(NotifyInformation info) { if (info.getAction() == NotifyAction.update_add) { fileCount++; PluginSupport.setWorkingCopyProgress(buildDetailCallback, fileCount, previousFileCount, ProgressUnit.Files); } else if (info.getAction() == NotifyAction.skip) { log.warn("Skipping missing target: " + info.getPath()); } if (Thread.interrupted()) { try { client.cancelOperation(); canceling = true; } catch (ClientException e) { log.error("Error canceling svn operation", e); } } } public void handleEvent(SVNEvent event, double progress) throws SVNException { } public void checkCancelled() throws SVNCancelException { if (Thread.interrupted()) { throw new SVNCancelException(); } } void setBuildDetailCallback(BuildDetailCallback buildDetailCallback) { this.buildDetailCallback = buildDetailCallback; } long getFileCount() { return fileCount; } void setPreviousFileCount(long previousByteCount) { this.previousFileCount = previousByteCount; } } }
chriseldredge/vulcan
plugins/vulcan-subversion/source/main/java/net/sourceforge/vulcan/subversion/SubversionRepositoryAdaptor.java
Java
gpl-2.0
23,349
.CODE __exec_payload PROC x:QWORD mov rax, x call QWORD PTR[rax] ret __exec_payload ENDP END
kost/scexec
scexec/__exec_payload.asm
Assembly
gpl-2.0
111
/* dia -- an diagram creation/manipulation program * Copyright (C) 1998 Alexander Larsson * * dia_svg.c -- Refactoring by Hans Breuer from : * * Custom Objects -- objects defined in XML rather than C. * Copyright (C) 1999 James Henstridge. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include "config.h" #include <string.h> #include <stdlib.h> #include <pango/pango-attributes.h> #include "dia_svg.h" /** * SECTION:dia_svg * @title: Dia SVG * @short_description: A set of function helping to read and write SVG with Dia * * The Dia application supports various variants of SVG. There are * at least two importers of SVG dialects, namely \ref Shapes and * the standard SVG importer \ref Plugins. Both are using theses * services to a large extend, but they are also doing there own * thing regarding the SVG dialect interpretation. */ /*! * A global variable to be accessed by "currentColor" */ static int _current_color = 0xFF000000; /*! * \brief Initialize a style object from another style object or defaults. * @param gs An SVG style object to initialize. * @param parent_style An SVG style object to copy values from, or NULL, * in which case defaults will be used. * \ingroup DiaSvg */ void dia_svg_style_init(DiaSvgStyle *gs, DiaSvgStyle *parent_style) { g_return_if_fail (gs); gs->stroke = parent_style ? parent_style->stroke : DIA_SVG_COLOUR_DEFAULT; gs->stroke_opacity = parent_style ? parent_style->stroke_opacity : 1.0; gs->line_width = parent_style ? parent_style->line_width : 0.0; gs->linestyle = parent_style ? parent_style->linestyle : DIA_LINE_STYLE_SOLID; gs->dashlength = parent_style ? parent_style->dashlength : 1; /* http://www.w3.org/TR/SVG/painting.html#FillProperty - default black * but we still have to see the difference */ gs->fill = parent_style ? parent_style->fill : DIA_SVG_COLOUR_DEFAULT; gs->fill_opacity = parent_style ? parent_style->fill_opacity : 1.0; gs->linecap = parent_style ? parent_style->linecap : DIA_LINE_CAPS_DEFAULT; gs->linejoin = parent_style ? parent_style->linejoin : DIA_LINE_JOIN_DEFAULT; gs->linestyle = parent_style ? parent_style->linestyle : DIA_LINE_STYLE_DEFAULT; gs->font = (parent_style && parent_style->font) ? g_object_ref (parent_style->font) : NULL; gs->font_height = parent_style ? parent_style->font_height : 0.8; gs->alignment = parent_style ? parent_style->alignment : DIA_ALIGN_LEFT; gs->stop_color = parent_style ? parent_style->stop_color : 0x000000; /* default black */ gs->stop_opacity = parent_style ? parent_style->stop_opacity : 1.0; } /*! * \brief Copy style values from one SVG style object to another. * @param dest SVG style object to copy to. * @param src SVG style object to copy from. * \ingroup DiaSvg */ void dia_svg_style_copy(DiaSvgStyle *dest, DiaSvgStyle *src) { g_return_if_fail (dest && src); dest->stroke = src->stroke; dest->stroke_opacity = src->stroke_opacity; dest->line_width = src->line_width; dest->linestyle = src->linestyle; dest->dashlength = src->dashlength; dest->fill = src->fill; dest->fill_opacity = src->fill_opacity; g_clear_object (&dest->font); dest->font = src->font ? g_object_ref (src->font) : NULL; dest->font_height = src->font_height; dest->alignment = src->alignment; dest->stop_color = src->stop_color; dest->stop_opacity = src->stop_opacity; } static const struct _SvgNamedColor { const gint value; const char *name; } _svg_named_colors [] = { /* complete list copied from sodipodi source */ { 0xF0F8FF, "aliceblue" }, { 0xFAEBD7, "antiquewhite" }, { 0x00FFFF, "aqua" }, { 0x7FFFD4, "aquamarine" }, { 0xF0FFFF, "azure" }, { 0xF5F5DC, "beige" }, { 0xFFE4C4, "bisque" }, { 0x000000, "black" }, { 0xFFEBCD, "blanchedalmond" }, { 0x0000FF, "blue" }, { 0x8A2BE2, "blueviolet" }, { 0xA52A2A, "brown" }, { 0xDEB887, "burlywood" }, { 0x5F9EA0, "cadetblue" }, { 0x7FFF00, "chartreuse" }, { 0xD2691E, "chocolate" }, { 0xFF7F50, "coral" }, { 0x6495ED, "cornflowerblue" }, { 0xFFF8DC, "cornsilk" }, { 0xDC143C, "crimson" }, { 0x00FFFF, "cyan" }, { 0x00008B, "darkblue" }, { 0x008B8B, "darkcyan" }, { 0xB8860B, "darkgoldenrod" }, { 0xA9A9A9, "darkgray" }, { 0x006400, "darkgreen" }, { 0xA9A9A9, "darkgrey" }, { 0xBDB76B, "darkkhaki" }, { 0x8B008B, "darkmagenta" }, { 0x556B2F, "darkolivegreen" }, { 0xFF8C00, "darkorange" }, { 0x9932CC, "darkorchid" }, { 0x8B0000, "darkred" }, { 0xE9967A, "darksalmon" }, { 0x8FBC8F, "darkseagreen" }, { 0x483D8B, "darkslateblue" }, { 0x2F4F4F, "darkslategray" }, { 0x2F4F4F, "darkslategrey" }, { 0x00CED1, "darkturquoise" }, { 0x9400D3, "darkviolet" }, { 0xFF1493, "deeppink" }, { 0x00BFFF, "deepskyblue" }, { 0x696969, "dimgray" }, { 0x696969, "dimgrey" }, { 0x1E90FF, "dodgerblue" }, { 0xB22222, "firebrick" }, { 0xFFFAF0, "floralwhite" }, { 0x228B22, "forestgreen" }, { 0xFF00FF, "fuchsia" }, { 0xDCDCDC, "gainsboro" }, { 0xF8F8FF, "ghostwhite" }, { 0xFFD700, "gold" }, { 0xDAA520, "goldenrod" }, { 0x808080, "gray" }, { 0x008000, "green" }, { 0xADFF2F, "greenyellow" }, { 0x808080, "grey" }, { 0xF0FFF0, "honeydew" }, { 0xFF69B4, "hotpink" }, { 0xCD5C5C, "indianred" }, { 0x4B0082, "indigo" }, { 0xFFFFF0, "ivory" }, { 0xF0E68C, "khaki" }, { 0xE6E6FA, "lavender" }, { 0xFFF0F5, "lavenderblush" }, { 0x7CFC00, "lawngreen" }, { 0xFFFACD, "lemonchiffon" }, { 0xADD8E6, "lightblue" }, { 0xF08080, "lightcoral" }, { 0xE0FFFF, "lightcyan" }, { 0xFAFAD2, "lightgoldenrodyellow" }, { 0xD3D3D3, "lightgray" }, { 0x90EE90, "lightgreen" }, { 0xD3D3D3, "lightgrey" }, { 0xFFB6C1, "lightpink" }, { 0xFFA07A, "lightsalmon" }, { 0x20B2AA, "lightseagreen" }, { 0x87CEFA, "lightskyblue" }, { 0x778899, "lightslategray" }, { 0x778899, "lightslategrey" }, { 0xB0C4DE, "lightsteelblue" }, { 0xFFFFE0, "lightyellow" }, { 0x00FF00, "lime" }, { 0x32CD32, "limegreen" }, { 0xFAF0E6, "linen" }, { 0xFF00FF, "magenta" }, { 0x800000, "maroon" }, { 0x66CDAA, "mediumaquamarine" }, { 0x0000CD, "mediumblue" }, { 0xBA55D3, "mediumorchid" }, { 0x9370DB, "mediumpurple" }, { 0x3CB371, "mediumseagreen" }, { 0x7B68EE, "mediumslateblue" }, { 0x00FA9A, "mediumspringgreen" }, { 0x48D1CC, "mediumturquoise" }, { 0xC71585, "mediumvioletred" }, { 0x191970, "midnightblue" }, { 0xF5FFFA, "mintcream" }, { 0xFFE4E1, "mistyrose" }, { 0xFFE4B5, "moccasin" }, { 0xFFDEAD, "navajowhite" }, { 0x000080, "navy" }, { 0xFDF5E6, "oldlace" }, { 0x808000, "olive" }, { 0x6B8E23, "olivedrab" }, { 0xFFA500, "orange" }, { 0xFF4500, "orangered" }, { 0xDA70D6, "orchid" }, { 0xEEE8AA, "palegoldenrod" }, { 0x98FB98, "palegreen" }, { 0xAFEEEE, "paleturquoise" }, { 0xDB7093, "palevioletred" }, { 0xFFEFD5, "papayawhip" }, { 0xFFDAB9, "peachpuff" }, { 0xCD853F, "peru" }, { 0xFFC0CB, "pink" }, { 0xDDA0DD, "plum" }, { 0xB0E0E6, "powderblue" }, { 0x800080, "purple" }, { 0xFF0000, "red" }, { 0xBC8F8F, "rosybrown" }, { 0x4169E1, "royalblue" }, { 0x8B4513, "saddlebrown" }, { 0xFA8072, "salmon" }, { 0xF4A460, "sandybrown" }, { 0x2E8B57, "seagreen" }, { 0xFFF5EE, "seashell" }, { 0xA0522D, "sienna" }, { 0xC0C0C0, "silver" }, { 0x87CEEB, "skyblue" }, { 0x6A5ACD, "slateblue" }, { 0x708090, "slategray" }, { 0x708090, "slategrey" }, { 0xFFFAFA, "snow" }, { 0x00FF7F, "springgreen" }, { 0x4682B4, "steelblue" }, { 0xD2B48C, "tan" }, { 0x008080, "teal" }, { 0xD8BFD8, "thistle" }, { 0xFF6347, "tomato" }, { 0x40E0D0, "turquoise" }, { 0xEE82EE, "violet" }, { 0xF5DEB3, "wheat" }, { 0xFFFFFF, "white" }, { 0xF5F5F5, "whitesmoke" }, { 0xFFFF00, "yellow" }, { 0x9ACD32, "yellowgreen" } }; static int _cmp_color (const void *key, const void *elem) { const char *a = key; const struct _SvgNamedColor *color = elem; return strcmp (a, color->name); } /*! * \brief Get an SVG color value by name * * The list of named SVG tiny colors has only 17 entries according to * http://www.w3.org/TR/CSS21/syndata.html#color-units * Still pango_color_parse() does not support seven of them including * 'white'. This function supports all of them. * Against the SVG full specification (and the SVG Test Suite) pango's * long list is still missing colors, e.g. crimson. So this function is * using a supposed to be complete internal list. * * \ingroup DiaSvg */ static gboolean svg_named_color (const char *name, gint32 *color) { const struct _SvgNamedColor *elem; g_return_val_if_fail (name != NULL && color != NULL, FALSE); elem = bsearch (name, _svg_named_colors, G_N_ELEMENTS(_svg_named_colors), sizeof(_svg_named_colors[0]), _cmp_color); if (elem) { *color = elem->value; return TRUE; } return FALSE; } /*! * \brief Parse an SVG color description. * * @param color A place to store the color information (0RGB) * @param str An SVG color description string to parse. * @return TRUE if parsing was successful. * * This function is rather tolerant compared to the SVG specification. * It supports special names like 'fg', 'bg', 'foregroumd', 'background'; * three numeric representations: '\#FF0000', 'rgb(1.0,0.0,0.0), 'rgb(100%,0%,0%)' * and named colors from two domains: SVG and Pango. * * \note Shouldn't we use an actual Dia Color object as return value? * Would require that the DiaSvgStyle object uses that, too. If we did that, * we could even return the color object directly, and we would be able to use * >8 bits per channel. * But we would not be able to handle named colors anymore ... * * \ingroup DiaSvg */ static gboolean _parse_color(gint32 *color, const char *str) { if (str[0] == '#') { char *endp = NULL; guint32 val = strtol(str+1, &endp, 16); if (endp - (str + 1) > 3) /* no 16-bit color here */ *color = val & 0xffffff; else /* weak estimation: Pango is reusing bits to fill */ *color = ((0xF & val)<<4) | ((0xF0 & val)<<8) | (((0xF00 & val)>>4)<<16); } else if (0 == strncmp(str, "none", 4)) *color = DIA_SVG_COLOUR_NONE; else if (0 == strncmp(str, "foreground", 10) || 0 == strncmp(str, "fg", 2) || 0 == strncmp(str, "inverse", 7)) *color = DIA_SVG_COLOUR_FOREGROUND; else if (0 == strncmp(str, "background", 10) || 0 == strncmp(str, "bg", 2) || 0 == strncmp(str, "default", 7)) *color = DIA_SVG_COLOUR_BACKGROUND; else if (0 == strcmp(str, "text")) *color = DIA_SVG_COLOUR_TEXT; else if (0 == strcmp(str, "currentColor")) *color = _current_color; else if (0 == strncmp(str, "rgb(", 4)) { int r = 0, g = 0, b = 0; if (3 == sscanf (str+4, "%d,%d,%d", &r, &g, &b)) { /* Set alpha to 1.0 */ *color = ((0xFF<<24) & 0xFF000000) | ((r<<16) & 0xFF0000) | ((g<<8) & 0xFF00) | (b & 0xFF); } else if (strchr (str+4, '%')) { /* e.g. cairo uses percent values */ char **vals = g_strsplit (str+4, "%,", -1); int i; *color = 0xFF000000; for (i = 0; vals[i] && i < 3; ++i) *color |= ((int)(((255 * g_ascii_strtod(vals[i], NULL)) / 100))<<(16-(8*i))); g_strfreev (vals); } else { return FALSE; } } else if (0 == strncmp(str, "rgba(", 5)) { int r = 0, g = 0, b = 0, a = 0; if (4 == sscanf (str+4, "%d,%d,%d,%d", &r, &g, &b, &a)) *color = ((a<<24) & 0xFF000000) | ((r<<16) & 0xFF0000) | ((g<<8) & 0xFF00) | (b & 0xFF); else return FALSE; } else { char* se = strchr (str, ';'); if (!se) /* style might have trailign space */ se = strchr (str, ' '); if (!se) { return svg_named_color (str, color); } else { /* need to make a copy of the color only */ gboolean ret; char *sc = g_strndup (str, se - str); ret = svg_named_color (sc, color); g_clear_pointer (&sc, g_free); return ret; } } return TRUE; } /*! * \brief Convert a string to a color * * SVG spec also allows 'inherit' as color value, which leads * to false here. Should still mostly work because the color * is supposed to be initialized before. * * \ingroup DiaSvg */ gboolean dia_svg_parse_color (const char *str, Color *color) { gint32 c; gboolean ret = _parse_color (&c, str); if (ret) { color->red = ((c & 0xff0000) >> 16) / 255.0; color->green = ((c & 0x00ff00) >> 8) / 255.0; color->blue = (c & 0x0000ff) / 255.0; color->alpha = 1.0; } return ret; } enum { FONT_NAME_LENGTH_MAX = 40 }; static void _parse_dasharray (DiaSvgStyle *s, double user_scale, char *str, char **end) { char *ptr; /* by also splitting on ';' we can also parse the continued style string */ char **dashes = g_regex_split_simple ("[\\s,;]+", (char *) str, 0, 0); int n = 0; double dl; s->dashlength = g_ascii_strtod(str, &ptr); if (s->dashlength <= 0.0) { /* e.g. "none" */ s->linestyle = DIA_LINE_STYLE_SOLID; } else if (user_scale > 0) { s->dashlength /= user_scale; } if (s->dashlength) { /* at least one value */ while (dashes[n] && g_ascii_strtod (dashes[n], NULL) > 0) { ++n; /* Dia can not do arbitrary length, the number of dashes gives the style */ } } if (n > 0) { s->dashlength = g_ascii_strtod (dashes[0], NULL); } if (user_scale > 0) { s->dashlength /= user_scale; } switch (n) { case 0: s->linestyle = DIA_LINE_STYLE_SOLID; break; case 1: s->linestyle = DIA_LINE_STYLE_DASHED; break; case 2: dl = g_ascii_strtod (dashes[1], NULL); if (user_scale > 0) { dl /= user_scale; } if (dl < s->line_width || dl > s->dashlength) { /* the difference is arbitrary */ s->linestyle = DIA_LINE_STYLE_DOTTED; s->dashlength *= 10.0; /* dot = 10% of len */ } else { s->linestyle = DIA_LINE_STYLE_DASHED; } break; case 4: s->linestyle = DIA_LINE_STYLE_DASH_DOT; break; default : /* If an odd number of values is provided, then the list of values is repeated to * yield an even number of values. Thus, stroke-dasharray: 5,3,2 is equivalent to * stroke-dasharray: 5,3,2,5,3,2. */ case 6: s->linestyle = DIA_LINE_STYLE_DASH_DOT_DOT; break; } g_strfreev (dashes); if (end) *end = ptr; } static void _parse_linejoin (DiaSvgStyle *s, const char *val) { if (!strncmp (val, "miter", 5)) { s->linejoin = DIA_LINE_JOIN_MITER; } else if (!strncmp (val, "round", 5)) { s->linejoin = DIA_LINE_JOIN_ROUND; } else if (!strncmp (val, "bevel", 5)) { s->linejoin = DIA_LINE_JOIN_BEVEL; } else if (!strncmp (val, "default", 7)) { s->linejoin = DIA_LINE_JOIN_DEFAULT; } } static void _parse_linecap (DiaSvgStyle *s, const char *val) { if (!strncmp(val, "butt", 4)) s->linecap = DIA_LINE_CAPS_BUTT; else if (!strncmp(val, "round", 5)) s->linecap = DIA_LINE_CAPS_ROUND; else if (!strncmp(val, "square", 6) || !strncmp(val, "projecting", 10)) s->linecap = DIA_LINE_CAPS_PROJECTING; else if (!strncmp(val, "default", 7)) s->linecap = DIA_LINE_CAPS_DEFAULT; } /*! * \brief Given any of the three parameters adjust the font * @param s Dia SVG style to modify * @param family comma-separated list of family names * @param style font slant string * @param weight font weight string */ static void _style_adjust_font (DiaSvgStyle *s, const char *family, const char *style, const char *weight) { g_clear_object (&s->font); /* given font_height is bogus, especially if not given at all * or without unit ... see bug 665648 about invalid CSS */ s->font = dia_font_new_from_style (DIA_FONT_SANS, s->font_height > 0 ? s->font_height : 1.0); if (family) { /* SVG allows a list of families here, also there is some strange formatting * seen, like 'Arial'. If the given family name can not be resolved by * Pango it complaints loudly with g_warning(). */ char **families = g_strsplit (family, ",", -1); int i = 0; gboolean found = FALSE; while (!found && families[i]) { const char *chomped = g_strchomp (g_strdelimit (families[i], "'", ' ')); PangoFont *loaded; dia_font_set_any_family(s->font, chomped); loaded = pango_context_load_font (dia_font_get_context (), dia_font_get_description (s->font)); if (loaded) { g_clear_object (&loaded); found = TRUE; } ++i; } if (!found) { dia_font_set_any_family (s->font, "sans"); } g_strfreev (families); } if (style) { dia_font_set_slant_from_string (s->font, style); } if (weight) { dia_font_set_weight_from_string (s->font, weight); } } static void _parse_text_align (DiaSvgStyle *s, const char *ptr) { if (!strncmp (ptr, "start", 5)) { s->alignment = DIA_ALIGN_LEFT; } else if (!strncmp (ptr, "end", 3)) { s->alignment = DIA_ALIGN_RIGHT; } else if (!strncmp (ptr, "middle", 6)) { s->alignment = DIA_ALIGN_CENTRE; } } /*! * \brief Parse SVG/CSS style string * * Parse as much information from the given style string as Dia can handle. * There are still known limitations: * - does not follow references to somewhere inside or outside the string * (e.g. url(...), color and currentColor) * - font parsing should be extended to support lists of fonts somehow * * \ingroup DiaSvg */ void dia_svg_parse_style_string (DiaSvgStyle *s, double user_scale, const char *str) { int i = 0; char *ptr = (char *) str; char *family = NULL, *style = NULL, *weight = NULL; while (ptr[0] != '\0') { /* skip white space at start */ while (ptr[0] != '\0' && g_ascii_isspace(ptr[0])) ptr++; if (ptr[0] == '\0') break; if (!strncmp("font-family:", ptr, 12)) { ptr += 12; while ((ptr[0] != '\0') && g_ascii_isspace(ptr[0])) ptr++; i = 0; while (ptr[i] != '\0' && ptr[i] != ';') ++i; /* with i==0 we fall back to 'sans' too */ if (strncmp (ptr, "sanserif", i) == 0 || strncmp (ptr, "sans-serif", i) == 0) family = g_strdup ("sans"); /* special name adaption */ else family = i > 0 ? g_strndup(ptr, i) : NULL; ptr += i; } else if (!strncmp("font-weight:", ptr, 12)) { ptr += 12; while ((ptr[0] != '\0') && g_ascii_isspace(ptr[0])) ptr++; i = 0; while (ptr[i] != '\0' && ptr[i] != ';') ++i; weight = i > 0 ? g_strndup (ptr, i) : NULL; ptr += i; } else if (!strncmp("font-style:", ptr, 11)) { ptr += 11; while ((ptr[0] != '\0') && g_ascii_isspace(ptr[0])) ptr++; i = 0; while (ptr[i] != '\0' && ptr[i] != ';') ++i; style = i > 0 ? g_strndup(ptr, i) : NULL; ptr += i; } else if (!strncmp("font-size:", ptr, 10)) { ptr += 10; while ((ptr[0] != '\0') && g_ascii_isspace(ptr[0])) ptr++; i = 0; while (ptr[i] != '\0' && ptr[i] != ';') ++i; s->font_height = g_ascii_strtod(ptr, NULL); ptr += i; if (user_scale > 0) s->font_height /= user_scale; } else if (!strncmp("text-anchor:", ptr, 12)) { ptr += 12; while ((ptr[0] != '\0') && g_ascii_isspace(ptr[0])) ptr++; _parse_text_align(s, ptr); } else if (!strncmp("stroke-width:", ptr, 13)) { ptr += 13; s->line_width = g_ascii_strtod(ptr, &ptr); if (user_scale > 0) s->line_width /= user_scale; } else if (!strncmp("stroke:", ptr, 7)) { ptr += 7; while ((ptr[0] != '\0') && g_ascii_isspace(ptr[0])) ptr++; if (ptr[0] == '\0') break; if (!_parse_color (&s->stroke, ptr)) s->stroke = DIA_SVG_COLOUR_NONE; } else if (!strncmp("stroke-opacity:", ptr, 15)) { ptr += 15; s->stroke_opacity = g_ascii_strtod(ptr, &ptr); } else if (!strncmp("fill:", ptr, 5)) { ptr += 5; while (ptr[0] != '\0' && g_ascii_isspace(ptr[0])) ptr++; if (ptr[0] == '\0') break; if (!_parse_color (&s->fill, ptr)) s->fill = DIA_SVG_COLOUR_NONE; } else if (!strncmp("fill-opacity:", ptr, 13)) { ptr += 13; s->fill_opacity = g_ascii_strtod(ptr, &ptr); } else if (!strncmp("stop-color:", ptr, 11)) { ptr += 11; while (ptr[0] != '\0' && g_ascii_isspace(ptr[0])) ptr++; if (ptr[0] == '\0') break; if (!_parse_color (&s->stop_color, ptr)) s->stop_color = DIA_SVG_COLOUR_NONE; } else if (!strncmp("stop-opacity:", ptr, 13)) { ptr += 13; s->stop_opacity = g_ascii_strtod(ptr, &ptr); } else if (!strncmp("opacity", ptr, 7)) { double opacity; ptr += 7; opacity = g_ascii_strtod(ptr, &ptr); /* multiplicative effect of opacity */ s->stroke_opacity *= opacity; s->fill_opacity *= opacity; } else if (!strncmp("stroke-linecap:", ptr, 15)) { ptr += 15; while (ptr[0] != '\0' && g_ascii_isspace(ptr[0])) ptr++; if (ptr[0] == '\0') break; _parse_linecap (s, ptr); } else if (!strncmp("stroke-linejoin:", ptr, 16)) { ptr += 16; while (ptr[0] != '\0' && g_ascii_isspace(ptr[0])) ptr++; if (ptr[0] == '\0') break; _parse_linejoin (s, ptr); } else if (!strncmp("stroke-pattern:", ptr, 15)) { /* Apparently not an offical SVG style attribute, but * referenced in custom-shapes document. So we continue * supporting it (read only). */ ptr += 15; while (ptr[0] != '\0' && g_ascii_isspace(ptr[0])) ptr++; if (ptr[0] == '\0') break; if (!strncmp (ptr, "solid", 5)) { s->linestyle = DIA_LINE_STYLE_SOLID; } else if (!strncmp (ptr, "dashed", 6)) { s->linestyle = DIA_LINE_STYLE_DASHED; } else if (!strncmp (ptr, "dash-dot", 8)) { s->linestyle = DIA_LINE_STYLE_DASH_DOT; } else if (!strncmp (ptr, "dash-dot-dot", 12)) { s->linestyle = DIA_LINE_STYLE_DASH_DOT_DOT; } else if (!strncmp (ptr, "dotted", 6)) { s->linestyle = DIA_LINE_STYLE_DOTTED; } else if (!strncmp (ptr, "default", 7)) { s->linestyle = DIA_LINE_STYLE_DEFAULT; } /* XXX: deal with a real pattern */ } else if (!strncmp ("stroke-dashlength:", ptr, 18)) { ptr += 18; while (ptr[0] != '\0' && g_ascii_isspace(ptr[0])) ptr++; if (ptr[0] == '\0') break; if (!strncmp(ptr, "default", 7)) s->dashlength = 1.0; else { s->dashlength = g_ascii_strtod(ptr, &ptr); if (user_scale > 0) s->dashlength /= user_scale; } } else if (!strncmp ("stroke-dasharray:", ptr, 17)) { s->linestyle = DIA_LINE_STYLE_DASHED; ptr += 17; while (ptr[0] != '\0' && g_ascii_isspace(ptr[0])) ptr++; if (ptr[0] == '\0') break; if (!strncmp(ptr, "default", 7)) s->dashlength = 1.0; else _parse_dasharray (s, user_scale, ptr, &ptr); } /* skip up to the next attribute */ while (ptr[0] != '\0' && ptr[0] != ';' && ptr[0] != '\n') ptr++; if (ptr[0] != '\0') ptr++; } if (family || style || weight) { _style_adjust_font (s, family, style, weight); g_clear_pointer (&family, g_free); g_clear_pointer (&style, g_free); g_clear_pointer (&weight, g_free); } } /*! * \brief Parse SVG style properties * * This function not only parses the style attribute of the given node * it also extracts some of the style properties directly. * @param node An XML node to parse a style from. * @param s The SVG style object to fill out. This should previously be * initialized to some default values. * @param user_scale if >0 scalable values (font-size, stroke-width, ...) * are divided by this, otherwise ignored * * \ingroup DiaSvg */ void dia_svg_parse_style (xmlNodePtr node, DiaSvgStyle *s, double user_scale) { xmlChar *str; str = xmlGetProp(node, (const xmlChar *)"style"); if (str) { dia_svg_parse_style_string (s, user_scale, (char *)str); xmlFree(str); } /* ugly svg variations, it is allowed to give style properties without * the style attribute, i.e. direct attributes */ str = xmlGetProp(node, (const xmlChar *)"color"); if (str) { int c; if (_parse_color (&c, (char *) str)) _current_color = c; xmlFree(str); } str = xmlGetProp(node, (const xmlChar *)"opacity"); if (str) { double opacity = g_ascii_strtod ((char *) str, NULL); /* multiplicative effect of opacity */ s->stroke_opacity *= opacity; s->fill_opacity *= opacity; xmlFree(str); } str = xmlGetProp(node, (const xmlChar *)"stop-color"); if (str) { if (!_parse_color (&s->stop_color, (char *) str) && strcmp ((const char *) str, "inherit") != 0) s->stop_color = DIA_SVG_COLOUR_NONE; xmlFree(str); } str = xmlGetProp(node, (const xmlChar *)"stop-opacity"); if (str) { s->stop_opacity = g_ascii_strtod((char *) str, NULL); xmlFree(str); } str = xmlGetProp(node, (const xmlChar *)"fill"); if (str) { if (!_parse_color (&s->fill, (char *) str) && strcmp ((const char *) str, "inherit") != 0) s->fill = DIA_SVG_COLOUR_NONE; xmlFree(str); } str = xmlGetProp(node, (const xmlChar *)"fill-opacity"); if (str) { s->fill_opacity = g_ascii_strtod((char *) str, NULL); xmlFree(str); } str = xmlGetProp(node, (const xmlChar *)"stroke"); if (str) { if (!_parse_color (&s->stroke, (char *) str) && strcmp ((const char *) str, "inherit") != 0) s->stroke = DIA_SVG_COLOUR_NONE; xmlFree(str); } str = xmlGetProp(node, (const xmlChar *)"stroke-opacity"); if (str) { s->stroke_opacity = g_ascii_strtod((char *) str, NULL); xmlFree(str); } str = xmlGetProp(node, (const xmlChar *)"stroke-width"); if (str) { s->line_width = g_ascii_strtod((char *) str, NULL); xmlFree(str); if (user_scale > 0) s->line_width /= user_scale; } str = xmlGetProp(node, (const xmlChar *)"stroke-dasharray"); if (str) { if (strcmp ((const char *)str, "inherit") != 0) _parse_dasharray (s, user_scale, (char *)str, NULL); xmlFree(str); } str = xmlGetProp(node, (const xmlChar *)"stroke-linejoin"); if (str) { if (strcmp ((const char *)str, "inherit") != 0) _parse_linejoin (s, (char *)str); xmlFree(str); } str = xmlGetProp(node, (const xmlChar *)"stroke-linecap"); if (str) { if (strcmp ((const char *)str, "inherit") != 0) _parse_linecap (s, (char *)str); xmlFree(str); } /* text-props, again ;( */ str = xmlGetProp(node, (const xmlChar *)"font-size"); if (str) { /* for inherit we just leave the original value, * should be initialized by parent style already */ if (strcmp ((const char *)str, "inherit") != 0) { s->font_height = g_ascii_strtod ((char *)str, NULL); if (user_scale > 0) s->font_height /= user_scale; } xmlFree(str); } str = xmlGetProp(node, (const xmlChar *)"text-anchor"); if (str) { _parse_text_align (s, (const char*) str); xmlFree(str); } { xmlChar *family = xmlGetProp(node, (const xmlChar *)"font-family"); xmlChar *slant = xmlGetProp(node, (const xmlChar *)"font-style"); xmlChar *weight = xmlGetProp(node, (const xmlChar *)"font-weight"); if (family || slant || weight) { _style_adjust_font (s, (char *)family, (char *)slant, (char *)weight); if (family) xmlFree(family); if (slant) xmlFree(slant); if (weight) xmlFree(weight); } } } /** * _path_arc_segment: * @points: destination array of #BezPoint * @xc: center x * @yc: center y * @th0: first angle * @th1: second angle * @rx: radius x * @ry: radius y * @x_axis_rotation: rotation of the axis * @last_p2: the resulting current point * * Parse a SVG description of an arc segment. * * Code stolen from (and adapted) * http://www.inkscape.org/doc/doxygen/html/svg-path_8cpp.php#a7 * which may have got it from rsvg, hope it is correct ;) * * If you want the description of the algorithm read the SVG specs: * http://www.w3.org/TR/SVG/paths.html#PathDataEllipticalArcCommands */ static void _path_arc_segment (GArray *points, double xc, double yc, double th0, double th1, double rx, double ry, double x_axis_rotation, Point *last_p2) { BezPoint bez; double sin_th, cos_th; double a00, a01, a10, a11; double x1, y1, x2, y2, x3, y3; double t; double th_half; sin_th = sin (x_axis_rotation * (M_PI / 180.0)); cos_th = cos (x_axis_rotation * (M_PI / 180.0)); /* inverse transform compared with rsvg_path_arc */ a00 = cos_th * rx; a01 = -sin_th * ry; a10 = sin_th * rx; a11 = cos_th * ry; th_half = 0.5 * (th1 - th0); t = (8.0 / 3.0) * sin(th_half * 0.5) * sin(th_half * 0.5) / sin(th_half); x1 = xc + cos (th0) - t * sin (th0); y1 = yc + sin (th0) + t * cos (th0); x3 = xc + cos (th1); y3 = yc + sin (th1); x2 = x3 + t * sin (th1); y2 = y3 - t * cos (th1); bez.type = BEZ_CURVE_TO; bez.p1.x = a00 * x1 + a01 * y1; bez.p1.y = a10 * x1 + a11 * y1; bez.p2.x = a00 * x2 + a01 * y2; bez.p2.y = a10 * x2 + a11 * y2; bez.p3.x = a00 * x3 + a01 * y3; bez.p3.y = a10 * x3 + a11 * y3; *last_p2 = bez.p2; g_array_append_val(points, bez); } /* * Parse an SVG description of a full arc. */ static void _path_arc (GArray *points, double cpx, double cpy, double rx, double ry, double x_axis_rotation, int large_arc_flag, int sweep_flag, double x, double y, Point *last_p2) { double sin_th, cos_th; double a00, a01, a10, a11; double x0, y0, x1, y1, xc, yc; double d, sfactor, sfactor_sq; double th0, th1, th_arc; double px, py, pl; int i, n_segs; sin_th = sin (x_axis_rotation * (M_PI / 180.0)); cos_th = cos (x_axis_rotation * (M_PI / 180.0)); /* * Correction of out-of-range radii as described in Appendix F.6.6: * * 1. Ensure radii are non-zero (Done?). * 2. Ensure that radii are positive. * 3. Ensure that radii are large enough. */ if(rx < 0.0) rx = -rx; if(ry < 0.0) ry = -ry; px = cos_th * (cpx - x) * 0.5 + sin_th * (cpy - y) * 0.5; py = cos_th * (cpy - y) * 0.5 - sin_th * (cpx - x) * 0.5; pl = (px * px) / (rx * rx) + (py * py) / (ry * ry); if(pl > 1.0) { pl = sqrt(pl); rx *= pl; ry *= pl; } /* Proceed with computations as described in Appendix F.6.5 */ a00 = cos_th / rx; a01 = sin_th / rx; a10 = -sin_th / ry; a11 = cos_th / ry; x0 = a00 * cpx + a01 * cpy; y0 = a10 * cpx + a11 * cpy; x1 = a00 * x + a01 * y; y1 = a10 * x + a11 * y; /* (x0, y0) is current point in transformed coordinate space. (x1, y1) is new point in transformed coordinate space. The arc fits a unit-radius circle in this space. */ d = (x1 - x0) * (x1 - x0) + (y1 - y0) * (y1 - y0); sfactor_sq = 1.0 / d - 0.25; if (sfactor_sq < 0) sfactor_sq = 0; sfactor = sqrt (sfactor_sq); if (sweep_flag == large_arc_flag) sfactor = -sfactor; xc = 0.5 * (x0 + x1) - sfactor * (y1 - y0); yc = 0.5 * (y0 + y1) + sfactor * (x1 - x0); /* (xc, yc) is center of the circle. */ th0 = atan2 (y0 - yc, x0 - xc); th1 = atan2 (y1 - yc, x1 - xc); th_arc = th1 - th0; if (th_arc < 0 && sweep_flag) th_arc += 2 * M_PI; else if (th_arc > 0 && !sweep_flag) th_arc -= 2 * M_PI; n_segs = (int) ceil (fabs (th_arc / (M_PI * 0.5 + 0.001))); for (i = 0; i < n_segs; i++) { _path_arc_segment(points, xc, yc, th0 + i * th_arc / n_segs, th0 + (i + 1) * th_arc / n_segs, rx, ry, x_axis_rotation, last_p2); } } /* routine to chomp off the start of the string */ #define path_chomp(path) while (path[0]!='\0'&&strchr(" \t\n\r,", path[0])) path++ /** * dia_svg_parse_path: * @path_str: A string describing an SVG path. * @unparsed: The position in @path_str where parsing ended, or %NULL if * the string was completely parsed. This should be used for * calling the function until it is fully parsed. * @closed: Whether the path was closed. * @current_point: to retain it over splitting * * Takes SVG path content and converts it in an array of BezPoint. * * SVG pathes can contain multiple MOVE_TO commands while Dia's bezier * object can only contain one so you may need to call this function * multiple times. * * @bug This function is way too long (324 lines). So dont touch it. please! * Shouldn't we try to turn straight lines, simple arc, polylines and * zigzaglines into their appropriate objects? Could either be done by * returning an object or by having functions that try parsing as * specific simple paths. * NOPE: Dia is capable to handle beziers and the file has given us some so * WHY should be break it in to pieces ??? * * Returns: %TRUE if there is any useful data in parsed to points */ gboolean dia_svg_parse_path (GArray *points, const char *path_str, char **unparsed, gboolean *closed, Point *current_point) { enum { PATH_MOVE, PATH_LINE, PATH_HLINE, PATH_VLINE, PATH_CURVE, PATH_SMOOTHCURVE, PATH_QUBICCURVE, PATH_TTQCURVE, PATH_ARC, PATH_CLOSE, PATH_END } last_type = PATH_MOVE; Point last_open = {0.0, 0.0}; Point last_point = {0.0, 0.0}; Point last_control = {0.0, 0.0}; gboolean last_relative = FALSE; BezPoint bez = { 0, }; char *path = (char *)path_str; gboolean need_next_element = FALSE; /* we can grow the same array in multiple steps */ gsize points_at_start = points->len; *closed = FALSE; *unparsed = NULL; /* when splitting into pieces, we have to maintain current_point accross them */ if (current_point) last_point = *current_point; path_chomp(path); while (path[0] != '\0') { #ifdef DEBUG_CUSTOM g_printerr ("Path: %s\n", path); #endif /* check for a new command */ switch (path[0]) { case 'M': if (points->len - points_at_start > 0) { need_next_element = TRUE; goto MORETOPARSE; } path++; path_chomp(path); last_type = PATH_MOVE; last_relative = FALSE; break; case 'm': if (points->len - points_at_start > 0) { need_next_element = TRUE; goto MORETOPARSE; } path++; path_chomp(path); last_type = PATH_MOVE; last_relative = TRUE; break; case 'L': path++; path_chomp(path); last_type = PATH_LINE; last_relative = FALSE; break; case 'l': path++; path_chomp(path); last_type = PATH_LINE; last_relative = TRUE; break; case 'H': path++; path_chomp(path); last_type = PATH_HLINE; last_relative = FALSE; break; case 'h': path++; path_chomp(path); last_type = PATH_HLINE; last_relative = TRUE; break; case 'V': path++; path_chomp(path); last_type = PATH_VLINE; last_relative = FALSE; break; case 'v': path++; path_chomp(path); last_type = PATH_VLINE; last_relative = TRUE; break; case 'C': path++; path_chomp(path); last_type = PATH_CURVE; last_relative = FALSE; break; case 'c': path++; path_chomp(path); last_type = PATH_CURVE; last_relative = TRUE; break; case 'S': path++; path_chomp(path); last_type = PATH_SMOOTHCURVE; last_relative = FALSE; break; case 's': path++; path_chomp(path); last_type = PATH_SMOOTHCURVE; last_relative = TRUE; break; case 'q': path++; path_chomp(path); last_type = PATH_QUBICCURVE; last_relative = TRUE; break; case 'Q': path++; path_chomp(path); last_type = PATH_QUBICCURVE; last_relative = FALSE; break; case 't': path++; path_chomp(path); last_type = PATH_TTQCURVE; last_relative = TRUE; break; case 'T': path++; path_chomp(path); last_type = PATH_TTQCURVE; last_relative = FALSE; break; case 'Z': case 'z': path++; path_chomp(path); last_type = PATH_CLOSE; last_relative = FALSE; break; case 'A': path++; path_chomp(path); last_type = PATH_ARC; last_relative = FALSE; break; case 'a': path++; path_chomp(path); last_type = PATH_ARC; last_relative = TRUE; break; case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': case '.': case '+': case '-': if (last_type == PATH_CLOSE) { g_warning("parse_path: argument given for implicite close path"); /* consume one number so we don't fall into an infinite loop */ while (path != NULL && strchr("0123456789.+-", path[0])) path++; path_chomp(path); *closed = TRUE; need_next_element = TRUE; goto MORETOPARSE; } break; default: g_warning("unsupported path code '%c'", path[0]); last_type = PATH_END; path++; path_chomp(path); break; } /* actually parse the path component */ switch (last_type) { case PATH_MOVE: if (points->len - points_at_start > 1) { g_warning ("Only first point should be 'move'"); } bez.type = BEZ_MOVE_TO; bez.p1.x = g_ascii_strtod (path, &path); path_chomp (path); bez.p1.y = g_ascii_strtod (path, &path); path_chomp (path); if (last_relative) { bez.p1.x += last_point.x; bez.p1.y += last_point.y; } last_point = bez.p1; last_control = bez.p1; last_open = bez.p1; if (points->len - points_at_start == 1) { /* stupid svg, but we can handle it */ g_array_index (points, BezPoint, 0) = bez; } else { g_array_append_val (points, bez); } /* [SVG11 8.3.2] If a moveto is followed by multiple pairs of coordinates, * the subsequent pairs are treated as implicit lineto commands */ last_type = PATH_LINE; break; case PATH_LINE: bez.type = BEZ_LINE_TO; bez.p1.x = g_ascii_strtod (path, &path); path_chomp (path); bez.p1.y = g_ascii_strtod (path, &path); path_chomp (path); if (last_relative) { bez.p1.x += last_point.x; bez.p1.y += last_point.y; } /* Strictly speeaking it should not be necessary to assign the other * two points. But it helps hiding a serious limitation with the * standard bezier serialization, namely only saving one move-to * and the rest as curve-to */ #define INIT_LINE_TO_AS_CURVE_TO bez.p3 = bez.p1; bez.p2 = last_point INIT_LINE_TO_AS_CURVE_TO; last_point = bez.p1; last_control = bez.p1; g_array_append_val (points, bez); break; case PATH_HLINE: bez.type = BEZ_LINE_TO; bez.p1.x = g_ascii_strtod (path, &path); path_chomp (path); bez.p1.y = last_point.y; if (last_relative) { bez.p1.x += last_point.x; } INIT_LINE_TO_AS_CURVE_TO; last_point = bez.p1; last_control = bez.p1; g_array_append_val (points, bez); break; case PATH_VLINE: bez.type = BEZ_LINE_TO; bez.p1.x = last_point.x; bez.p1.y = g_ascii_strtod (path, &path); path_chomp (path); if (last_relative) { bez.p1.y += last_point.y; } INIT_LINE_TO_AS_CURVE_TO; #undef INIT_LINE_TO_AS_CURVE_TO last_point = bez.p1; last_control = bez.p1; g_array_append_val (points, bez); break; case PATH_CURVE: bez.type = BEZ_CURVE_TO; bez.p1.x = g_ascii_strtod (path, &path); path_chomp (path); bez.p1.y = g_ascii_strtod (path, &path); path_chomp (path); bez.p2.x = g_ascii_strtod (path, &path); path_chomp (path); bez.p2.y = g_ascii_strtod (path, &path); path_chomp (path); bez.p3.x = g_ascii_strtod (path, &path); path_chomp (path); bez.p3.y = g_ascii_strtod (path, &path); path_chomp (path); if (last_relative) { bez.p1.x += last_point.x; bez.p1.y += last_point.y; bez.p2.x += last_point.x; bez.p2.y += last_point.y; bez.p3.x += last_point.x; bez.p3.y += last_point.y; } last_point = bez.p3; last_control = bez.p2; g_array_append_val (points, bez); break; case PATH_SMOOTHCURVE: bez.type = BEZ_CURVE_TO; bez.p1.x = 2 * last_point.x - last_control.x; bez.p1.y = 2 * last_point.y - last_control.y; bez.p2.x = g_ascii_strtod (path, &path); path_chomp (path); bez.p2.y = g_ascii_strtod (path, &path); path_chomp (path); bez.p3.x = g_ascii_strtod (path, &path); path_chomp (path); bez.p3.y = g_ascii_strtod (path, &path); path_chomp (path); if (last_relative) { bez.p2.x += last_point.x; bez.p2.y += last_point.y; bez.p3.x += last_point.x; bez.p3.y += last_point.y; } last_point = bez.p3; last_control = bez.p2; g_array_append_val (points, bez); break; case PATH_QUBICCURVE: { /* raise quadratic bezier to cubic (copied from librsvg) */ double x1, y1; x1 = g_ascii_strtod (path, &path); path_chomp (path); y1 = g_ascii_strtod (path, &path); path_chomp (path); if (last_relative) { x1 += last_point.x; y1 += last_point.y; } bez.type = BEZ_CURVE_TO; bez.p1.x = (last_point.x + 2 * x1) * (1.0 / 3.0); bez.p1.y = (last_point.y + 2 * y1) * (1.0 / 3.0); bez.p3.x = g_ascii_strtod (path, &path); path_chomp (path); bez.p3.y = g_ascii_strtod (path, &path); path_chomp (path); if (last_relative) { bez.p3.x += last_point.x; bez.p3.y += last_point.y; } bez.p2.x = (bez.p3.x + 2 * x1) * (1.0 / 3.0); bez.p2.y = (bez.p3.y + 2 * y1) * (1.0 / 3.0); last_point = bez.p3; last_control.x = x1; last_control.y = y1; g_array_append_val (points, bez); } break; case PATH_TTQCURVE: { /* Truetype quadratic bezier curveto */ double xc, yc; /* quadratic control point */ xc = 2 * last_point.x - last_control.x; yc = 2 * last_point.y - last_control.y; /* generate a quadratic bezier with control point = xc, yc */ bez.type = BEZ_CURVE_TO; bez.p1.x = (last_point.x + 2 * xc) * (1.0 / 3.0); bez.p1.y = (last_point.y + 2 * yc) * (1.0 / 3.0); bez.p3.x = g_ascii_strtod (path, &path); path_chomp (path); bez.p3.y = g_ascii_strtod (path, &path); path_chomp (path); if (last_relative) { bez.p3.x += last_point.x; bez.p3.y += last_point.y; } bez.p2.x = (bez.p3.x + 2 * xc) * (1.0 / 3.0); bez.p2.y = (bez.p3.y + 2 * yc) * (1.0 / 3.0); last_point = bez.p3; last_control.x = xc; last_control.y = yc; g_array_append_val (points, bez); } break; case PATH_ARC: { double rx, ry; double xrot; int largearc, sweep; Point dest, dest_c; dest_c.x=0; dest_c.y=0; rx = g_ascii_strtod (path, &path); path_chomp (path); ry = g_ascii_strtod (path, &path); path_chomp (path); #if 1 /* ok if it is all properly separated */ xrot = g_ascii_strtod (path, &path); path_chomp (path); largearc = (int) g_ascii_strtod (path, &path); path_chomp (path); sweep = (int) g_ascii_strtod (path, &path); path_chomp (path); #else /* Actually three flags, which might not be properly separated, * but even with this paths-data-20-f.svg does not work. IMHO the * test case is seriously borked and can only pass if parsing * the arc is tweaked against the test. In other words that test * looks like it is built against one specific implementation. * Inkscape and librsvg fail, Firefox pass. */ xrot = path[0] == '0' ? 0.0 : 1.0; ++path; path_chomp(path); largearc = path[0] == '0' ? 0 : 1; ++path; path_chomp(path); sweep = path[0] == '0' ? 0 : 1; ++path; path_chomp(path); #endif dest.x = g_ascii_strtod (path, &path); path_chomp (path); dest.y = g_ascii_strtod (path, &path); path_chomp (path); if (last_relative) { dest.x += last_point.x; dest.y += last_point.y; } /* avoid matherr with bogus values - just ignore them * does happen e.g. with 'Chem-Widgets - clamp-large' */ if (last_point.x != dest.x || last_point.y != dest.y) { _path_arc (points, last_point.x, last_point.y, rx, ry, xrot, largearc, sweep, dest.x, dest.y, &dest_c); } last_point = dest; last_control = dest_c; } break; case PATH_CLOSE: /* close the path with a line - second condition to ignore single close */ if (!*closed && (points->len != points_at_start)) { const BezPoint *bpe = &g_array_index (points, BezPoint, points->len-1); /* if the last point already meets the first point dont add it again */ const Point pte = bpe->type == BEZ_CURVE_TO ? bpe->p3 : bpe->p1; if (pte.x != last_open.x || pte.y != last_open.y) { bez.type = BEZ_LINE_TO; bez.p1 = last_open; g_array_append_val (points, bez); } last_point = last_open; } *closed = TRUE; need_next_element = TRUE; break; case PATH_END: while (*path != '\0') { path++; } need_next_element = FALSE; break; default: g_return_val_if_reached (FALSE); } /* get rid of any ignorable characters */ path_chomp (path); MORETOPARSE: if (need_next_element) { /* check if there really is more to be parsed */ if (path[0] != 0) { *unparsed = path; } else { *unparsed = NULL; } break; /* while */ } } /* avoid returning an array with only one point (I'd say the exporter * producing such is rather broken, but *our* bezier creation code * would crash on it. */ if (points->len < 2) { g_array_set_size (points, 0); } if (current_point) { *current_point = last_point; } return (points->len > 1); } static gboolean _parse_transform (const char *trans, graphene_matrix_t *m, double scale) { char **list; char *p = strchr (trans, '('); int i = 0; while ( (*trans != '\0') && (*trans == ' ' || *trans == ',' || *trans == '\t' || *trans == '\n' || *trans == '\r')) { ++trans; /* skip whitespace */ } if (!p || !*trans) { return FALSE; /* silently fail */ } list = g_regex_split_simple ("[\\s,]+", p + 1, 0, 0); if (strncmp (trans, "matrix", 6) == 0) { float xx = 0, yx = 0, xy = 0, yy = 0, x0 = 0, y0 = 0; if (list[i]) { xx = g_ascii_strtod (list[i], NULL); ++i; } if (list[i]) { yx = g_ascii_strtod (list[i], NULL); ++i; } if (list[i]) { xy = g_ascii_strtod (list[i], NULL); ++i; } if (list[i]) { yy = g_ascii_strtod (list[i], NULL); ++i; } if (list[i]) { x0 = g_ascii_strtod (list[i], NULL); ++i; } if (list[i]) { y0 = g_ascii_strtod (list[i], NULL); ++i; } graphene_matrix_init_from_2d (m, xx, yx, xy, yy, x0 / scale, y0 / scale); } else if (strncmp (trans, "translate", 9) == 0) { double x0 = 0, y0 = 0; if (list[i]) { x0 = g_ascii_strtod (list[i], NULL); ++i; } if (list[i]) { y0 = g_ascii_strtod (list[i], NULL); ++i; } graphene_matrix_init_translate (m, &GRAPHENE_POINT3D_INIT (x0 / scale, y0 / scale, 0)); } else if (strncmp (trans, "scale", 5) == 0) { double xx = 0, yy = 0; if (list[i]) { xx = g_ascii_strtod (list[i], NULL); ++i; } if (list[i]) { yy = g_ascii_strtod (list[i], NULL); ++i; } else { yy = xx; } graphene_matrix_init_scale (m, xx, yy, 1.0); } else if (strncmp (trans, "rotate", 6) == 0) { double angle = 0; double cx = 0, cy = 0; if (list[i]) { angle = g_ascii_strtod (list[i], NULL); ++i; } else { g_warning ("transform=rotate no angle?"); } /* FIXME: check with real world data, I'm uncertain */ /* rotate around the given offset */ if (list[i]) { graphene_point3d_t point; cx = g_ascii_strtod (list[i], NULL); ++i; if (list[i]) { cy = g_ascii_strtod (list[i], NULL); ++i; } else { cy = 0.0; /* if offsets don't come in pairs */ } /* translate by -cx,-cy */ graphene_point3d_init (&point, -(cx / scale), -(cy / scale), 0); graphene_matrix_init_translate (m, &point); /* rotate by angle */ graphene_matrix_rotate_z (m, angle); /* translate by cx,cy */ graphene_point3d_init (&point, cx / scale, cy / scale, 0); graphene_matrix_translate (m, &point); } else { graphene_matrix_init_rotate (m, angle, graphene_vec3_z_axis ()); } } else if (strncmp (trans, "skewX", 5) == 0) { float skew = 0; if (list[i]) { skew = g_ascii_strtod (list[i], NULL); } graphene_matrix_init_skew (m, DIA_RADIANS (skew), 0); } else if (strncmp (trans, "skewY", 5) == 0) { float skew = 0; if (list[i]) { skew = g_ascii_strtod (list[i], NULL); } graphene_matrix_init_skew (m, 0, DIA_RADIANS (skew)); } else { g_warning ("SVG: %s?", trans); return FALSE; } g_clear_pointer (&list, g_strfreev); return TRUE; } graphene_matrix_t * dia_svg_parse_transform (const char *trans, double scale) { graphene_matrix_t *m = NULL; char **transforms = g_regex_split_simple ("\\)", trans, 0, 0); int i = 0; /* go through the list of transformations - not that one would be enough ;) */ while (transforms[i]) { graphene_matrix_t mat; if (_parse_transform (transforms[i], &mat, scale)) { if (!m) { m = graphene_matrix_alloc (); graphene_matrix_init_from_matrix (m, &mat); } else { graphene_matrix_multiply (m, &mat, m); } } ++i; } g_clear_pointer (&transforms, g_strfreev); return m; } char * dia_svg_from_matrix (const graphene_matrix_t *matrix, double scale) { /* transform="matrix(1,0,0,1,0,0)" */ char buf[G_ASCII_DTOSTR_BUF_SIZE]; GString *sm = g_string_new ("matrix("); char *s; g_ascii_formatd (buf, sizeof (buf), "%g", graphene_matrix_get_value (matrix, 0, 0)); g_string_append (sm, buf); g_string_append (sm, ","); g_ascii_formatd (buf, sizeof (buf), "%g", graphene_matrix_get_value (matrix, 0, 1)); g_string_append (sm, buf); g_string_append (sm, ","); g_ascii_formatd (buf, sizeof (buf), "%g", graphene_matrix_get_value (matrix, 1, 0)); g_string_append (sm, buf); g_string_append (sm, ","); g_ascii_formatd (buf, sizeof (buf), "%g", graphene_matrix_get_value (matrix, 1, 1)); g_string_append (sm, buf); g_string_append (sm, ","); g_ascii_formatd (buf, sizeof (buf), "%g", graphene_matrix_get_x_translation (matrix) * scale); g_string_append (sm, buf); g_string_append (sm, ","); g_ascii_formatd (buf, sizeof (buf), "%g", graphene_matrix_get_y_translation (matrix) * scale); g_string_append (sm, buf); g_string_append (sm, ")"); s = sm->str; g_string_free (sm, FALSE); return s; }
GNOME/dia
lib/dia_svg.c
C
gpl-2.0
53,495
/* * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ #ifndef GLASS_WINDOW_H #define GLASS_WINDOW_H #include <gtk/gtk.h> #include <X11/Xlib.h> #include <jni.h> #include <set> #include <vector> #include "glass_view.h" enum WindowFrameType { TITLED, UNTITLED, TRANSPARENT }; enum WindowType { NORMAL, UTILITY, POPUP }; enum request_type { REQUEST_NONE, REQUEST_RESIZABLE, REQUEST_NOT_RESIZABLE }; struct WindowFrameExtents { int top; int left; int bottom; int right; }; static const guint MOUSE_BUTTONS_MASK = (guint) (GDK_BUTTON1_MASK | GDK_BUTTON2_MASK | GDK_BUTTON3_MASK); enum BoundsType { BOUNDSTYPE_CONTENT, BOUNDSTYPE_WINDOW }; struct WindowGeometry { WindowGeometry(): final_width(), final_height(), refx(), refy(), gravity_x(), gravity_y(), current_width(), current_height(), extents() {} // estimate of the final width the window will get after all pending // configure requests are processed by the window manager struct { int value; BoundsType type; } final_width; struct { int value; BoundsType type; } final_height; float refx; float refy; float gravity_x; float gravity_y; // the last width which was configured or obtained from configure // notification int current_width; // the last height which was configured or obtained from configure // notification int current_height; WindowFrameExtents extents; }; class WindowContextChild; class WindowContextTop; class WindowContext { public: virtual bool isEnabled() = 0; virtual bool hasIME() = 0; virtual bool filterIME(GdkEvent *) = 0; virtual void enableOrResetIME() = 0; virtual void disableIME() = 0; virtual void paint(void* data, jint width, jint height) = 0; virtual WindowFrameExtents get_frame_extents() = 0; virtual void enter_fullscreen() = 0; virtual void exit_fullscreen() = 0; virtual void show_or_hide_children(bool) = 0; virtual void set_visible(bool) = 0; virtual bool is_visible() = 0; virtual void set_bounds(int, int, bool, bool, int, int, int, int) = 0; virtual void set_resizable(bool) = 0; virtual void request_focus() = 0; virtual void set_focusable(bool)= 0; virtual bool grab_focus() = 0; virtual bool grab_mouse_drag_focus() = 0; virtual void ungrab_focus() = 0; virtual void ungrab_mouse_drag_focus() = 0; virtual void set_title(const char*) = 0; virtual void set_alpha(double) = 0; virtual void set_enabled(bool) = 0; virtual void set_minimum_size(int, int) = 0; virtual void set_maximum_size(int, int) = 0; virtual void set_minimized(bool) = 0; virtual void set_maximized(bool) = 0; virtual void set_icon(GdkPixbuf*) = 0; virtual void restack(bool) = 0; virtual void set_cursor(GdkCursor*) = 0; virtual void set_modal(bool, WindowContext* parent = NULL) = 0; virtual void set_gravity(float, float) = 0; virtual void set_level(int) = 0; virtual void set_background(float, float, float) = 0; virtual void process_property_notify(GdkEventProperty*) = 0; virtual void process_configure(GdkEventConfigure*) = 0; virtual void process_map() = 0; virtual void process_focus(GdkEventFocus*) = 0; virtual void process_destroy() = 0; virtual void process_delete() = 0; virtual void process_expose(GdkEventExpose*) = 0; virtual void process_mouse_button(GdkEventButton*) = 0; virtual void process_mouse_motion(GdkEventMotion*) = 0; virtual void process_mouse_scroll(GdkEventScroll*) = 0; virtual void process_mouse_cross(GdkEventCrossing*) = 0; virtual void process_key(GdkEventKey*) = 0; virtual void process_state(GdkEventWindowState*) = 0; virtual void notify_state(jint) = 0; virtual void add_child(WindowContextTop* child) = 0; virtual void remove_child(WindowContextTop* child) = 0; virtual bool set_view(jobject) = 0; virtual GdkWindow *get_gdk_window() = 0; virtual GtkWindow *get_gtk_window() = 0; virtual jobject get_jview() = 0; virtual jobject get_jwindow() = 0; virtual int getEmbeddedX() = 0; virtual int getEmbeddedY() = 0; virtual void increment_events_counter() = 0; virtual void decrement_events_counter() = 0; virtual size_t get_events_count() = 0; virtual bool is_dead() = 0; virtual ~WindowContext() {} }; class WindowContextBase: public WindowContext { std::set<WindowContextTop*> children; struct _XIM{ XIM im; XIC ic; bool enabled; } xim; size_t events_processing_cnt; bool can_be_deleted; protected: jobject jwindow; jobject jview; GtkWidget* gtk_widget; GdkWindow* gdk_window; bool is_iconified; bool is_maximized; bool is_mouse_entered; /* * sm_grab_window points to WindowContext holding a mouse grab. * It is mostly used for popup windows. */ static WindowContext* sm_grab_window; /* * sm_mouse_drag_window points to a WindowContext from which a mouse drag started. * This WindowContext holding a mouse grab during this drag. After releasing * all mouse buttons sm_mouse_drag_window becomes NULL and sm_grab_window's * mouse grab should be restored if present. * * This is done in order to mimic Windows behavior: * All mouse events should be delivered to a window from which mouse drag * started, until all mouse buttons released. No mouse ENTER/EXIT events * should be reported during this drag. */ static WindowContext* sm_mouse_drag_window; public: bool isEnabled(); bool hasIME(); bool filterIME(GdkEvent *); void enableOrResetIME(); void disableIME(); void paint(void*, jint, jint); GdkWindow *get_gdk_window(); jobject get_jwindow(); jobject get_jview(); void add_child(WindowContextTop*); void remove_child(WindowContextTop*); void show_or_hide_children(bool); void reparent_children(WindowContext* parent); void set_visible(bool); bool is_visible(); bool set_view(jobject); bool grab_focus(); bool grab_mouse_drag_focus(); void ungrab_focus(); void ungrab_mouse_drag_focus(); void set_cursor(GdkCursor*); void set_level(int) {} void set_background(float, float, float); void process_map() {} void process_focus(GdkEventFocus*); void process_destroy(); void process_delete(); void process_expose(GdkEventExpose*); void process_mouse_button(GdkEventButton*); void process_mouse_motion(GdkEventMotion*); void process_mouse_scroll(GdkEventScroll*); void process_mouse_cross(GdkEventCrossing*); void process_key(GdkEventKey*); void process_state(GdkEventWindowState*); void notify_state(jint); int getEmbeddedX() { return 0; } int getEmbeddedY() { return 0; } void increment_events_counter(); void decrement_events_counter(); size_t get_events_count(); bool is_dead(); ~WindowContextBase(); protected: virtual void applyShapeMask(void*, uint width, uint height) = 0; private: bool im_filter_keypress(GdkEventKey*); }; class WindowContextPlug: public WindowContextBase { WindowContext* parent; public: bool set_view(jobject); void set_bounds(int, int, bool, bool, int, int, int, int); //WindowFrameExtents get_frame_extents() { return WindowFrameExtents{0, 0, 0, 0}; }; WindowFrameExtents get_frame_extents() { WindowFrameExtents ext = {0, 0, 0, 0}; return ext;} void enter_fullscreen() {} void exit_fullscreen() {} void set_resizable(bool) {} void request_focus() {} void set_focusable(bool) {} void set_title(const char*) {} void set_alpha(double) {} void set_enabled(bool) {} void set_minimum_size(int, int) {} void set_maximum_size(int, int) {} void set_minimized(bool) {} void set_maximized(bool) {} void set_icon(GdkPixbuf*) {} void restack(bool) {} void set_modal(bool, WindowContext*) {} void set_gravity(float, float) {} void process_property_notify(GdkEventProperty*) {} void process_configure(GdkEventConfigure*); void process_gtk_configure(GdkEventConfigure*); void applyShapeMask(void*, uint width, uint height) {} GtkWindow *get_gtk_window(); // TODO, get window from parent WindowContextPlug(jobject, void*); GtkWidget* gtk_container; std::vector<WindowContextChild *> embedded_children; private: //HACK: remove once set_bounds is implemented correctly void window_configure(XWindowChanges *, unsigned int); WindowContextPlug(WindowContextPlug&); WindowContextPlug& operator= (const WindowContextPlug&); }; class WindowContextChild: public WindowContextBase { WindowContextPlug* parent; WindowContextTop* full_screen_window; GlassView* view; // not null while in Full Screen public: void process_mouse_button(GdkEventButton*); bool set_view(jobject); void set_bounds(int, int, bool, bool, int, int, int, int); //WindowFrameExtents get_frame_extents() { return WindowFrameExtents{0, 0, 0, 0}; }; WindowFrameExtents get_frame_extents() { WindowFrameExtents ext = {0, 0, 0, 0}; return ext;} void enter_fullscreen(); void exit_fullscreen(); void set_resizable(bool) {} void request_focus() {} void set_focusable(bool) {} void set_title(const char*) {} void set_alpha(double) {} void set_enabled(bool) {} void set_minimum_size(int, int) {} void set_maximum_size(int, int) {} void set_minimized(bool) {} void set_maximized(bool) {} void set_icon(GdkPixbuf*) {} void restack(bool); void set_modal(bool, WindowContext*) {} void set_gravity(float, float) {} void process_property_notify(GdkEventProperty*) {} void process_configure(GdkEventConfigure*); void process_destroy(); void set_visible(bool visible); int getEmbeddedX(); int getEmbeddedY(); void applyShapeMask(void*, uint width, uint height) {} GtkWindow *get_gtk_window(); // TODO, get window from parent WindowContextChild(jobject, void*, GtkWidget *parent_widget, WindowContextPlug *parent_context); private: WindowContextChild(WindowContextChild&); WindowContextChild& operator= (const WindowContextChild&); }; class WindowContextTop: public WindowContextBase { jlong screen; WindowFrameType frame_type; struct WindowContext *owner; WindowGeometry geometry; int stale_config_notifications; struct _Resizable{// we can't use set/get gtk_window_resizable function _Resizable(): request(REQUEST_NONE), value(true), prev(false), minw(-1), minh(-1), maxw(-1), maxh(-1){} request_type request; //request for future setResizable bool value; //actual value of resizable for a window bool prev; //former resizable value (used in setEnabled for parents of modal window) int minw, minh, maxw, maxh; //minimum and maximum window width/height; } resizable; bool frame_extents_initialized; bool map_received; bool location_assigned; bool size_assigned; public: WindowContextTop(jobject, WindowContext*, long, WindowFrameType, WindowType); void process_map(); void process_property_notify(GdkEventProperty*); void process_configure(GdkEventConfigure*); void process_destroy(); void process_net_wm_property(); WindowFrameExtents get_frame_extents(); void set_minimized(bool); void set_maximized(bool); void set_bounds(int, int, bool, bool, int, int, int, int); void set_resizable(bool); void request_focus(); void set_focusable(bool); void set_title(const char*); void set_alpha(double); void set_enabled(bool); void set_minimum_size(int, int); void set_maximum_size(int, int); void set_icon(GdkPixbuf*); void restack(bool); void set_modal(bool, WindowContext* parent = NULL); void set_gravity(float, float); void set_level(int); void set_visible(bool); void enter_fullscreen(); void exit_fullscreen(); void set_owner(WindowContext*); GtkWindow *get_gtk_window(); void detach_from_java(); protected: void applyShapeMask(void*, uint width, uint height); private: bool get_frame_extents_property(int *, int *, int *, int *); void request_frame_extents(); void initialize_frame_extents(); void window_configure(XWindowChanges *, unsigned int); void update_window_constraints(); void set_window_resizable(bool, bool); WindowContextTop(WindowContextTop&); WindowContextTop& operator= (const WindowContextTop&); }; void destroy_and_delete_ctx(WindowContext* ctx); class EventsCounterHelper { private: WindowContext* ctx; public: explicit EventsCounterHelper(WindowContext* context) { ctx = context; ctx->increment_events_counter(); } ~EventsCounterHelper() { ctx->decrement_events_counter(); if (ctx->is_dead() && ctx->get_events_count() == 0) { delete ctx; } ctx = NULL; } }; #endif /* GLASS_WINDOW_H */
maiklos-mirrors/jfx78
modules/graphics/src/main/native-glass/gtk/glass_window.h
C
gpl-2.0
14,351
#region Using directives using System; using System.Collections; using System.Data; using UFSoft.UBF.UI.MD.Runtime; using UFSoft.UBF.UI.MD.Runtime.Implement; #endregion namespace DocumentTypeRef { public partial class DocumentTypeRefModel { //初始化UIMODEL之后的方法 public override void AfterInitModel() { //this.Views[0].Fields[0].DefaultValue = thsi.co } //UIModel提交保存之前的校验操作. public override void OnValidate() { base.OnValidate() ; OnValidate_DefualtImpl(); //your coustom code ... } } }
amazingbow/yonyou
金龙/XMJL_Code/XMJLUI/Model/DocumentTypeRefModelExtend.cs
C#
gpl-2.0
650
<?php //------------------------------------------------------------------------------------------------------------------ // SKY HIGH CMS - Sky High Software Custom Content Management System - http://www.skyhighsoftware.com // Copyright (C) 2008 - 2010 Sky High Software. All Rights Reserved. // Permission to use and modify this software is for a single website installation as per written agreement. // // DO NOT DISTRIBUTE OR COPY this software to any additional purpose, websites, or hosting. If the original website // is move to new hosting, this software may also be moved to new location. // // IN NO EVENT SHALL SKY HIGH SOFTWARE BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, OR INCIDENTAL DAMAGES, // INCLUDING LOST PROFITS, ARISING FROM USE OF THIS SOFTWARE. // // THIS SOFTWARE IS PROVIDED "AS IS". SKY HIGH SOFTWARE HAS NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, // ENHANCEMENTS, OR MODIFICATIONS BEYOND THAT SPECIFICALLY AGREED TO IN SEPARATE WRITTEN AGREEMENT. //------------------------------------------------------------------------------------------------------------------ ?> <tr><td colspan="3" height="20" class="pageEditBars">&nbsp;&nbsp;SERVICES</td></tr> <tr> <td valign="top" ><div align="right">Service</div></td> <td colspan="2"><input name="sub_title" type="text" id="sub_title" size="50" maxlength="100" value="<?php echo $sub_title; ?>"/></td> </tr> <tr> <td valign="top" ><div align="right">Pricing</div></td> <td colspan="2"> <?php $oFCKeditor = new FCKeditor('other') ; $oFCKeditor->BasePath = 'fckeditor/'; // is the default value. $oFCKeditor->Value = $other; $oFCKeditor->ToolbarSet = $EDITOR_TOOLBAR; $oFCKeditor->Height = 70; $oFCKeditor->Create() ; ?> </td> </tr> <tr> <td valign="top" ><div align="right">Related Services</div></td> <td colspan="2"><?php $oFCKeditor = new FCKeditor('other2') ; $oFCKeditor->BasePath = 'fckeditor/'; // is the default value. $oFCKeditor->Value = $other2; //$oFCKeditor->ToolbarSet = $EDITOR_TOOLBAR; $oFCKeditor->Height = 240; $oFCKeditor->Create() ; ?></td> </tr> <tr> <td valign="top" ><div align="right">Quote</div></td> <td colspan="2"> <?php $oFCKeditor = new FCKeditor('other5') ; $oFCKeditor->BasePath = 'fckeditor/'; // is the default value. $oFCKeditor->Value = $other5; $oFCKeditor->ToolbarSet = $EDITOR_TOOLBAR; $oFCKeditor->Height = 140; $oFCKeditor->Create() ; ?> </td> </tr> <?php include("page_edit_image_inc.php"); ?>
Since84/AGD-Site
paymentportal/admin/page_edit_91.php
PHP
gpl-2.0
2,602
<?php /** * The template for displaying Comments. * * The area of the page that contains both current comments * and the comment form. The actual display of comments is * handled by a callback to hoshin_comment which is * located in the functions.php file. * * @package WordPress * @subpackage Twenty_Ten * @since Twenty Ten 1.0 */ ?> <div id="comments" class="comments"> <?php if ( post_password_required() ) : ?> <p class="nopassword"><?php _e( 'This post is password protected. Enter the password to view any comments.', 'hoshin' ); ?></p> </div><!-- #comments --> <?php /* Stop the rest of comments.php from being processed, * but don't kill the script entirely -- we still have * to fully load the template. */ return; endif; ?> <?php // You can start editing here -- including this comment! ?> <?php if ( have_comments() ) : ?> <h3 class="comments-title"><?php printf( _n( 'One Response to %2$s', '%1$s Responses to %2$s', get_comments_number(), 'hoshin' ), number_format_i18n( get_comments_number() ), '<em>' . get_the_title() . '</em>' ); ?></h3> <?php if ( get_comment_pages_count() > 1 && get_option( 'page_comments' ) ) : // Are there comments to navigate through? ?> <div class="navigation"> <div class="nav-previous"><?php previous_comments_link( __( '<span class="meta-nav">&larr;</span> Older Comments', 'hoshin' ) ); ?></div> <div class="nav-next"><?php next_comments_link( __( 'Newer Comments <span class="meta-nav">&rarr;</span>', 'hoshin' ) ); ?></div> </div> <!-- .navigation --> <?php endif; // check for comment navigation ?> <ol class="commentlist"> <?php /* Loop through and list the comments. Tell wp_list_comments() * to use hoshin_comment() to format the comments. * If you want to overload this in a child theme then you can * define hoshin_comment() and that will be used instead. * See hoshin_comment() in hoshin/functions.php for more. */ wp_list_comments( array( 'callback' => 'hoshin_comment' ) ); ?> </ol> <?php if ( get_comment_pages_count() > 1 && get_option( 'page_comments' ) ) : // Are there comments to navigate through? ?> <div class="navigation"> <div class="nav-previous"><?php previous_comments_link( __( '<span class="meta-nav">&larr;</span> Older Comments', 'hoshin' ) ); ?></div> <div class="nav-next"><?php next_comments_link( __( 'Newer Comments <span class="meta-nav">&rarr;</span>', 'hoshin' ) ); ?></div> </div><!-- .navigation --> <?php endif; // check for comment navigation ?> <?php else : // or, if we don't have comments: /* If there are no comments and comments are closed, * let's leave a little note, shall we? */ if ( ! comments_open() ) : ?> <p class="nocomments"><?php _e( 'Comments are closed.', 'hoshin' ); ?></p> <?php endif; // end ! comments_open() ?> <?php endif; // end have_comments() ?> <?php comment_form(); ?> </div><!-- #comments -->
artzstudio/hoshinbudo.com
wp-content/themes/hoshin/comments.php
PHP
gpl-2.0
3,028
/* $Id: capi.h,v 1.1.1.1 2010/03/11 21:10:39 kris Exp $ * * CAPI 2.0 Interface for Linux * * Copyright 1997 by Carsten Paeth ([email protected]) * * This software may be used and distributed according to the terms * of the GNU General Public License, incorporated herein by reference. * */ #ifndef __LINUX_CAPI_H__ #define __LINUX_CAPI_H__ #include <asm/types.h> #include <linux/ioctl.h> #ifndef __KERNEL__ #include <linux/kernelcapi.h> #endif /* * CAPI_REGISTER */ typedef struct capi_register_params { /* CAPI_REGISTER */ __u32 level3cnt; /* No. of simulatneous user data connections */ __u32 datablkcnt; /* No. of buffered data messages */ __u32 datablklen; /* Size of buffered data messages */ } capi_register_params; #define CAPI_REGISTER _IOW('C',0x01,struct capi_register_params) /* * CAPI_GET_MANUFACTURER */ #define CAPI_MANUFACTURER_LEN 64 #define CAPI_GET_MANUFACTURER _IOWR('C',0x06,int) /* broken: wanted size 64 (CAPI_MANUFACTURER_LEN) */ /* * CAPI_GET_VERSION */ typedef struct capi_version { __u32 majorversion; __u32 minorversion; __u32 majormanuversion; __u32 minormanuversion; } capi_version; #define CAPI_GET_VERSION _IOWR('C',0x07,struct capi_version) /* * CAPI_GET_SERIAL */ #define CAPI_SERIAL_LEN 8 #define CAPI_GET_SERIAL _IOWR('C',0x08,int) /* broken: wanted size 8 (CAPI_SERIAL_LEN) */ /* * CAPI_GET_PROFILE */ typedef struct capi_profile { __u16 ncontroller; /* number of installed controller */ __u16 nbchannel; /* number of B-Channels */ __u32 goptions; /* global options */ __u32 support1; /* B1 protocols support */ __u32 support2; /* B2 protocols support */ __u32 support3; /* B3 protocols support */ __u32 reserved[6]; /* reserved */ __u32 manu[5]; /* manufacturer specific information */ } capi_profile; #define CAPI_GET_PROFILE _IOWR('C',0x09,struct capi_profile) typedef struct capi_manufacturer_cmd { unsigned long cmd; void __user *data; } capi_manufacturer_cmd; /* * CAPI_MANUFACTURER_CMD */ #define CAPI_MANUFACTURER_CMD _IOWR('C',0x20, struct capi_manufacturer_cmd) /* * CAPI_GET_ERRCODE * capi errcode is set, * if read, write, or ioctl returns EIO, * ioctl returns errcode directly, and in arg, if != 0 */ #define CAPI_GET_ERRCODE _IOR('C',0x21, __u16) /* * CAPI_INSTALLED */ #define CAPI_INSTALLED _IOR('C',0x22, __u16) /* * member contr is input for * CAPI_GET_MANUFACTURER, CAPI_VERSION, CAPI_GET_SERIAL * and CAPI_GET_PROFILE */ typedef union capi_ioctl_struct { __u32 contr; capi_register_params rparams; __u8 manufacturer[CAPI_MANUFACTURER_LEN]; capi_version version; __u8 serial[CAPI_SERIAL_LEN]; capi_profile profile; capi_manufacturer_cmd cmd; __u16 errcode; } capi_ioctl_struct; /* * Middleware extension */ #define CAPIFLAG_HIGHJACKING 0x0001 #define CAPI_GET_FLAGS _IOR('C',0x23, unsigned) #define CAPI_SET_FLAGS _IOR('C',0x24, unsigned) #define CAPI_CLR_FLAGS _IOR('C',0x25, unsigned) #define CAPI_NCCI_OPENCOUNT _IOR('C',0x26, unsigned) #define CAPI_NCCI_GETUNIT _IOR('C',0x27, unsigned) #endif /* __LINUX_CAPI_H__ */
fgoncalves/Modified-TS7500-Kernel
include/linux/capi.h
C
gpl-2.0
3,089
/* This program was written with lots of love under the GPL by Jonathan * Blandford <[email protected]> */ #include <config.h> #include <stdlib.h> #include <string.h> #include <gtk/gtk.h> #include <gio/gio.h> #include <gdk/gdkx.h> #include <X11/Xatom.h> #include <glib/gi18n.h> #include <gdk/gdkkeysyms.h> #if GTK_CHECK_VERSION (3, 0, 0) #include <gdk/gdkkeysyms-compat.h> #endif #include "wm-common.h" #include "capplet-util.h" #include "eggcellrendererkeys.h" #include "activate-settings-daemon.h" #include "dconf-util.h" #define GSETTINGS_KEYBINDINGS_DIR "/org/mate/desktop/keybindings/" #define CUSTOM_KEYBINDING_SCHEMA "org.mate.control-center.keybinding" #define MAX_ELEMENTS_BEFORE_SCROLLING 10 #define MAX_CUSTOM_SHORTCUTS 1000 #define RESPONSE_ADD 0 #define RESPONSE_REMOVE 1 typedef struct { /* The untranslated name, combine with ->package to translate */ char *name; /* The gettext package to use to translate the section title */ char *package; /* Name of the window manager the keys would apply to */ char *wm_name; /* The GSettings schema for the whole file */ char *schema; /* an array of KeyListEntry */ GArray *entries; } KeyList; typedef enum { COMPARISON_NONE = 0, COMPARISON_GT, COMPARISON_LT, COMPARISON_EQ } Comparison; typedef struct { char *gsettings_path; char *schema; char *name; int value; char *value_schema; /* gsettings schema for key/value */ char *value_key; char *description; char *description_key; char *cmd_key; Comparison comparison; } KeyListEntry; enum { DESCRIPTION_COLUMN, KEYENTRY_COLUMN, N_COLUMNS }; typedef struct { GSettings *settings; char *gsettings_path; char *gsettings_key; guint keyval; guint keycode; EggVirtualModifierType mask; gboolean editable; GtkTreeModel *model; char *description; char *desc_gsettings_key; gboolean desc_editable; char *command; char *cmd_gsettings_key; gboolean cmd_editable; gulong gsettings_cnxn; gulong gsettings_cnxn_desc; gulong gsettings_cnxn_cmd; } KeyEntry; static gboolean block_accels = FALSE; static GtkWidget *custom_shortcut_dialog = NULL; static GtkWidget *custom_shortcut_name_entry = NULL; static GtkWidget *custom_shortcut_command_entry = NULL; static GtkWidget* _gtk_builder_get_widget(GtkBuilder* builder, const gchar* name) { return GTK_WIDGET (gtk_builder_get_object (builder, name)); } static GtkBuilder * create_builder (void) { GtkBuilder *builder = gtk_builder_new(); GError *error = NULL; static const gchar *uifile = MATECC_UI_DIR "/mate-keybinding-properties.ui"; if (gtk_builder_add_from_file (builder, uifile, &error) == 0) { g_warning ("Could not load UI: %s", error->message); g_error_free (error); g_object_unref (builder); builder = NULL; } return builder; } static char* binding_name(guint keyval, guint keycode, EggVirtualModifierType mask, gboolean translate) { if (keyval != 0 || keycode != 0) { if (translate) { return egg_virtual_accelerator_label (keyval, keycode, mask); } else { return egg_virtual_accelerator_name (keyval, keycode, mask); } } else { return g_strdup (translate ? _("Disabled") : ""); } } static gboolean binding_from_string (const char *str, guint *accelerator_key, guint *keycode, EggVirtualModifierType *accelerator_mods) { g_return_val_if_fail (accelerator_key != NULL, FALSE); if (str == NULL || strcmp (str, "disabled") == 0) { *accelerator_key = 0; *keycode = 0; *accelerator_mods = 0; return TRUE; } egg_accelerator_parse_virtual (str, accelerator_key, keycode, accelerator_mods); if (*accelerator_key == 0) return FALSE; else return TRUE; } static void accel_set_func (GtkTreeViewColumn *tree_column, GtkCellRenderer *cell, GtkTreeModel *model, GtkTreeIter *iter, gpointer data) { KeyEntry *key_entry; gtk_tree_model_get (model, iter, KEYENTRY_COLUMN, &key_entry, -1); if (key_entry == NULL) g_object_set (cell, "visible", FALSE, NULL); else if (! key_entry->editable) g_object_set (cell, "visible", TRUE, "editable", FALSE, "accel_key", key_entry->keyval, "accel_mask", key_entry->mask, "keycode", key_entry->keycode, "style", PANGO_STYLE_ITALIC, NULL); else g_object_set (cell, "visible", TRUE, "editable", TRUE, "accel_key", key_entry->keyval, "accel_mask", key_entry->mask, "keycode", key_entry->keycode, "style", PANGO_STYLE_NORMAL, NULL); } static void description_set_func (GtkTreeViewColumn *tree_column, GtkCellRenderer *cell, GtkTreeModel *model, GtkTreeIter *iter, gpointer data) { KeyEntry *key_entry; gtk_tree_model_get (model, iter, KEYENTRY_COLUMN, &key_entry, -1); if (key_entry != NULL) g_object_set (cell, "editable", FALSE, "text", key_entry->description != NULL ? key_entry->description : _("<Unknown Action>"), NULL); else g_object_set (cell, "editable", FALSE, NULL); } static gboolean keybinding_key_changed_foreach (GtkTreeModel *model, GtkTreePath *path, GtkTreeIter *iter, gpointer user_data) { KeyEntry *key_entry; KeyEntry *tmp_key_entry; key_entry = (KeyEntry *)user_data; gtk_tree_model_get (key_entry->model, iter, KEYENTRY_COLUMN, &tmp_key_entry, -1); if (key_entry == tmp_key_entry) { gtk_tree_model_row_changed (key_entry->model, path, iter); return TRUE; } return FALSE; } static void keybinding_key_changed (GSettings *settings, gchar *key, KeyEntry *key_entry) { gchar *key_value; key_value = g_settings_get_string (settings, key); binding_from_string (key_value, &key_entry->keyval, &key_entry->keycode, &key_entry->mask); key_entry->editable = g_settings_is_writable (settings, key); /* update the model */ gtk_tree_model_foreach (key_entry->model, keybinding_key_changed_foreach, key_entry); } static void keybinding_description_changed (GSettings *settings, gchar *key, KeyEntry *key_entry) { gchar *key_value; key_value = g_settings_get_string (settings, key); g_free (key_entry->description); key_entry->description = key_value ? g_strdup (key_value) : NULL; g_free (key_value); key_entry->desc_editable = g_settings_is_writable (settings, key); /* update the model */ gtk_tree_model_foreach (key_entry->model, keybinding_key_changed_foreach, key_entry); } static void keybinding_command_changed (GSettings *settings, gchar *key, KeyEntry *key_entry) { gchar *key_value; key_value = g_settings_get_string (settings, key); g_free (key_entry->command); key_entry->command = key_value ? g_strdup (key_value) : NULL; key_entry->cmd_editable = g_settings_is_writable (settings, key); g_free (key_value); /* update the model */ gtk_tree_model_foreach (key_entry->model, keybinding_key_changed_foreach, key_entry); } static int keyentry_sort_func (GtkTreeModel *model, GtkTreeIter *a, GtkTreeIter *b, gpointer user_data) { KeyEntry *key_entry_a; KeyEntry *key_entry_b; int retval; key_entry_a = NULL; gtk_tree_model_get (model, a, KEYENTRY_COLUMN, &key_entry_a, -1); key_entry_b = NULL; gtk_tree_model_get (model, b, KEYENTRY_COLUMN, &key_entry_b, -1); if (key_entry_a && key_entry_b) { if ((key_entry_a->keyval || key_entry_a->keycode) && (key_entry_b->keyval || key_entry_b->keycode)) { gchar *name_a, *name_b; name_a = binding_name (key_entry_a->keyval, key_entry_a->keycode, key_entry_a->mask, TRUE); name_b = binding_name (key_entry_b->keyval, key_entry_b->keycode, key_entry_b->mask, TRUE); retval = g_utf8_collate (name_a, name_b); g_free (name_a); g_free (name_b); } else if (key_entry_a->keyval || key_entry_a->keycode) retval = -1; else if (key_entry_b->keyval || key_entry_b->keycode) retval = 1; else retval = 0; } else if (key_entry_a) retval = -1; else if (key_entry_b) retval = 1; else retval = 0; return retval; } static void clear_old_model (GtkBuilder *builder) { GtkWidget *tree_view; GtkWidget *actions_swindow; GtkTreeModel *model; tree_view = _gtk_builder_get_widget (builder, "shortcut_treeview"); model = gtk_tree_view_get_model (GTK_TREE_VIEW (tree_view)); if (model == NULL) { /* create a new model */ model = (GtkTreeModel *) gtk_tree_store_new (N_COLUMNS, G_TYPE_STRING, G_TYPE_POINTER); gtk_tree_sortable_set_sort_func (GTK_TREE_SORTABLE (model), KEYENTRY_COLUMN, keyentry_sort_func, NULL, NULL); gtk_tree_view_set_model (GTK_TREE_VIEW (tree_view), model); g_object_unref (model); } else { /* clear the existing model */ gboolean valid; GtkTreeIter iter; KeyEntry *key_entry; for (valid = gtk_tree_model_get_iter_first (model, &iter); valid; valid = gtk_tree_model_iter_next (model, &iter)) { gtk_tree_model_get (model, &iter, KEYENTRY_COLUMN, &key_entry, -1); if (key_entry != NULL) { g_signal_handler_disconnect (key_entry->settings, key_entry->gsettings_cnxn); if (key_entry->gsettings_cnxn_desc != 0) g_signal_handler_disconnect (key_entry->settings, key_entry->gsettings_cnxn_desc); if (key_entry->gsettings_cnxn_cmd != 0) g_signal_handler_disconnect (key_entry->settings, key_entry->gsettings_cnxn_cmd); g_object_unref (key_entry->settings); if (key_entry->gsettings_path) g_free (key_entry->gsettings_path); g_free (key_entry->gsettings_key); g_free (key_entry->description); g_free (key_entry->desc_gsettings_key); g_free (key_entry->command); g_free (key_entry->cmd_gsettings_key); g_free (key_entry); } } gtk_tree_store_clear (GTK_TREE_STORE (model)); } actions_swindow = _gtk_builder_get_widget (builder, "actions_swindow"); gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (actions_swindow), GTK_POLICY_NEVER, GTK_POLICY_NEVER); gtk_widget_set_size_request (actions_swindow, -1, -1); } typedef struct { const char *key; const char *path; const char *schema; gboolean found; } KeyMatchData; static gboolean key_match(GtkTreeModel* model, GtkTreePath* path, GtkTreeIter* iter, gpointer data) { KeyMatchData* match_data = data; KeyEntry* element = NULL; gchar *element_schema = NULL; gchar *element_path = NULL; gtk_tree_model_get(model, iter, KEYENTRY_COLUMN, &element, -1); if (element && element->settings && G_IS_SETTINGS(element->settings)) { g_object_get (element->settings, "schema-id", &element_schema, NULL); g_object_get (element->settings, "path", &element_path, NULL); } if (element && g_strcmp0(element->gsettings_key, match_data->key) == 0 && g_strcmp0(element_schema, match_data->schema) == 0 && g_strcmp0(element_path, match_data->path) == 0) { match_data->found = TRUE; return TRUE; } return FALSE; } static gboolean key_is_already_shown(GtkTreeModel* model, const KeyListEntry* entry) { KeyMatchData data; data.key = entry->name; data.schema = entry->schema; data.path = entry->gsettings_path; data.found = FALSE; gtk_tree_model_foreach(model, key_match, &data); return data.found; } static gboolean should_show_key(const KeyListEntry* entry) { GSettings *settings; int value; if (entry->comparison == COMPARISON_NONE) { return TRUE; } g_return_val_if_fail(entry->value_key != NULL, FALSE); g_return_val_if_fail(entry->value_schema != NULL, FALSE); settings = g_settings_new (entry->value_schema); value = g_settings_get_int (settings, entry->value_key); g_object_unref (settings); switch (entry->comparison) { case COMPARISON_NONE: /* For compiler warnings */ g_assert_not_reached (); return FALSE; case COMPARISON_GT: if (value > entry->value) { return TRUE; } break; case COMPARISON_LT: if (value < entry->value) { return TRUE; } break; case COMPARISON_EQ: if (value == entry->value) { return TRUE; } break; } return FALSE; } static gboolean count_rows_foreach (GtkTreeModel *model, GtkTreePath *path, GtkTreeIter *iter, gpointer data) { gint *rows = data; (*rows)++; return FALSE; } static void ensure_scrollbar (GtkBuilder *builder, int i) { if (i == MAX_ELEMENTS_BEFORE_SCROLLING) { GtkRequisition rectangle; GObject *actions_swindow = gtk_builder_get_object (builder, "actions_swindow"); GtkWidget *treeview = _gtk_builder_get_widget (builder, "shortcut_treeview"); gtk_widget_ensure_style (treeview); gtk_widget_size_request (treeview, &rectangle); gtk_widget_set_size_request (treeview, -1, rectangle.height); gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (actions_swindow), GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC); } } static void find_section (GtkTreeModel *model, GtkTreeIter *iter, const char *title) { gboolean success; success = gtk_tree_model_get_iter_first (model, iter); while (success) { char *description = NULL; gtk_tree_model_get (model, iter, DESCRIPTION_COLUMN, &description, -1); if (g_strcmp0 (description, title) == 0) return; success = gtk_tree_model_iter_next (model, iter); } gtk_tree_store_append (GTK_TREE_STORE (model), iter, NULL); gtk_tree_store_set (GTK_TREE_STORE (model), iter, DESCRIPTION_COLUMN, title, -1); } static void append_keys_to_tree (GtkBuilder *builder, const gchar *title, const gchar *schema, const gchar *package, const KeyListEntry *keys_list) { GtkTreeIter parent_iter, iter; GtkTreeModel *model; gint i, j; model = gtk_tree_view_get_model (GTK_TREE_VIEW (gtk_builder_get_object (builder, "shortcut_treeview"))); /* Try to find a section parent iter, if it already exists */ find_section (model, &iter, title); parent_iter = iter; i = 0; gtk_tree_model_foreach (model, count_rows_foreach, &i); /* If the header we just added is the MAX_ELEMENTS_BEFORE_SCROLLING th, * then we need to scroll now */ ensure_scrollbar (builder, i - 1); for (j = 0; keys_list[j].name != NULL; j++) { GSettings *settings = NULL; gchar *settings_path; KeyEntry *key_entry; const gchar *key_string; gchar *key_value; gchar *description; gchar *command; if (!should_show_key (&keys_list[j])) continue; if (key_is_already_shown (model, &keys_list[j])) continue; key_string = keys_list[j].name; if (keys_list[j].gsettings_path != NULL) { settings = g_settings_new_with_path (schema, keys_list[j].gsettings_path); settings_path = g_strdup(keys_list[j].gsettings_path); } else { settings = g_settings_new (schema); settings_path = NULL; } if (keys_list[j].description_key != NULL) { /* it's a custom shortcut, so description is in gsettings */ description = g_settings_get_string (settings, keys_list[j].description_key); } else { /* it's from keyfile, so description need to be translated */ description = keys_list[j].description; if (package) { bind_textdomain_codeset (package, "UTF-8"); description = dgettext (package, description); } else { description = _(description); } } if (description == NULL) { /* Only print a warning for keys that should have a schema */ if (keys_list[j].description_key == NULL) g_warning ("No description for key '%s'", key_string); } if (keys_list[j].cmd_key != NULL) { command = g_settings_get_string (settings, keys_list[j].cmd_key); } else { command = NULL; } key_entry = g_new0 (KeyEntry, 1); key_entry->settings = settings; key_entry->gsettings_path = settings_path; key_entry->gsettings_key = g_strdup (key_string); key_entry->editable = g_settings_is_writable (settings, key_string); key_entry->model = model; key_entry->description = description; key_entry->command = command; if (keys_list[j].description_key != NULL) { key_entry->desc_gsettings_key = g_strdup (keys_list[j].description_key); key_entry->desc_editable = g_settings_is_writable (settings, key_entry->desc_gsettings_key); gchar *gsettings_signal = g_strconcat ("changed::", key_entry->desc_gsettings_key, NULL); key_entry->gsettings_cnxn_desc = g_signal_connect (settings, gsettings_signal, G_CALLBACK (keybinding_description_changed), key_entry); g_free (gsettings_signal); } if (keys_list[j].cmd_key != NULL) { key_entry->cmd_gsettings_key = g_strdup (keys_list[j].cmd_key); key_entry->cmd_editable = g_settings_is_writable (settings, key_entry->cmd_gsettings_key); gchar *gsettings_signal = g_strconcat ("changed::", key_entry->cmd_gsettings_key, NULL); key_entry->gsettings_cnxn_cmd = g_signal_connect (settings, gsettings_signal, G_CALLBACK (keybinding_command_changed), key_entry); g_free (gsettings_signal); } gchar *gsettings_signal = g_strconcat ("changed::", key_string, NULL); key_entry->gsettings_cnxn = g_signal_connect (settings, gsettings_signal, G_CALLBACK (keybinding_key_changed), key_entry); g_free (gsettings_signal); key_value = g_settings_get_string (settings, key_string); binding_from_string (key_value, &key_entry->keyval, &key_entry->keycode, &key_entry->mask); g_free (key_value); ensure_scrollbar (builder, i); ++i; gtk_tree_store_append (GTK_TREE_STORE (model), &iter, &parent_iter); /* we use the DESCRIPTION_COLUMN only for the section headers */ gtk_tree_store_set (GTK_TREE_STORE (model), &iter, KEYENTRY_COLUMN, key_entry, -1); gtk_tree_view_expand_all (GTK_TREE_VIEW (gtk_builder_get_object (builder, "shortcut_treeview"))); } /* Don't show an empty section */ if (gtk_tree_model_iter_n_children (model, &parent_iter) == 0) gtk_tree_store_remove (GTK_TREE_STORE (model), &parent_iter); if (i == 0) gtk_widget_hide (_gtk_builder_get_widget (builder, "shortcuts_vbox")); else gtk_widget_show (_gtk_builder_get_widget (builder, "shortcuts_vbox")); } static void parse_start_tag (GMarkupParseContext *ctx, const gchar *element_name, const gchar **attr_names, const gchar **attr_values, gpointer user_data, GError **error) { KeyList *keylist = (KeyList *) user_data; KeyListEntry key; const char *name, *value_key, *description, *value_schema; int value; Comparison comparison; const char *schema = NULL; name = NULL; /* The top-level element, names the section in the tree */ if (g_str_equal (element_name, "KeyListEntries")) { const char *wm_name = NULL; const char *package = NULL; while (*attr_names && *attr_values) { if (g_str_equal (*attr_names, "name")) { if (**attr_values) name = *attr_values; } else if (g_str_equal (*attr_names, "wm_name")) { if (**attr_values) wm_name = *attr_values; } else if (g_str_equal (*attr_names, "package")) { if (**attr_values) package = *attr_values; } else if (g_str_equal (*attr_names, "schema")) { if (**attr_values) schema = *attr_values; } ++attr_names; ++attr_values; } if (name) { if (keylist->name) g_warning ("Duplicate section name"); g_free (keylist->name); keylist->name = g_strdup (name); } if (wm_name) { if (keylist->wm_name) g_warning ("Duplicate window manager name"); g_free (keylist->wm_name); keylist->wm_name = g_strdup (wm_name); } if (package) { if (keylist->package) g_warning ("Duplicate gettext package name"); g_free (keylist->package); keylist->package = g_strdup (package); } if (schema) { if (keylist->schema) g_warning ("Duplicate schema name"); g_free (keylist->schema); keylist->schema = g_strdup (schema); } return; } if (!g_str_equal (element_name, "KeyListEntry") || attr_names == NULL || attr_values == NULL) return; value = 0; comparison = COMPARISON_NONE; value_key = NULL; value_schema = NULL; description = NULL; while (*attr_names && *attr_values) { if (g_str_equal (*attr_names, "name")) { /* skip if empty */ if (**attr_values) name = *attr_values; } else if (g_str_equal (*attr_names, "value")) { if (**attr_values) { value = (int) g_ascii_strtoull (*attr_values, NULL, 0); } } else if (g_str_equal (*attr_names, "key")) { if (**attr_values) { value_key = *attr_values; } } else if (g_str_equal (*attr_names, "comparison")) { if (**attr_values) { if (g_str_equal (*attr_values, "gt")) { comparison = COMPARISON_GT; } else if (g_str_equal (*attr_values, "lt")) { comparison = COMPARISON_LT; } else if (g_str_equal (*attr_values, "eq")) { comparison = COMPARISON_EQ; } } } else if (g_str_equal (*attr_names, "description")) { if (**attr_values) { description = *attr_values; } } else if (g_str_equal (*attr_names, "schema")) { if (**attr_values) { value_schema = *attr_values; } } ++attr_names; ++attr_values; } if (name == NULL) return; key.name = g_strdup (name); key.gsettings_path = NULL; key.description_key = NULL; key.description = g_strdup(description); key.schema = g_strdup(schema); key.value = value; if (value_key) { key.value_key = g_strdup (value_key); key.value_schema = g_strdup (value_schema); } else { key.value_key = NULL; key.value_schema = NULL; } key.comparison = comparison; key.cmd_key = NULL; g_array_append_val (keylist->entries, key); } static gboolean strv_contains (char **strv, char *str) { char **p = strv; for (p = strv; *p; p++) if (strcmp (*p, str) == 0) return TRUE; return FALSE; } static void append_keys_to_tree_from_file (GtkBuilder *builder, const char *filename, char **wm_keybindings) { GMarkupParseContext *ctx; GMarkupParser parser = { parse_start_tag, NULL, NULL, NULL, NULL }; KeyList *keylist; KeyListEntry key, *keys; GError *err = NULL; char *buf; const char *title; gsize buf_len; guint i; if (!g_file_get_contents (filename, &buf, &buf_len, &err)) return; keylist = g_new0 (KeyList, 1); keylist->entries = g_array_new (FALSE, TRUE, sizeof (KeyListEntry)); ctx = g_markup_parse_context_new (&parser, 0, keylist, NULL); if (!g_markup_parse_context_parse (ctx, buf, buf_len, &err)) { g_warning ("Failed to parse '%s': '%s'", filename, err->message); g_error_free (err); g_free (keylist->name); g_free (keylist->package); g_free (keylist->wm_name); g_free (keylist->schema); for (i = 0; i < keylist->entries->len; i++) g_free (((KeyListEntry *) &(keylist->entries->data[i]))->name); g_array_free (keylist->entries, TRUE); g_free (keylist); keylist = NULL; } g_markup_parse_context_free (ctx); g_free (buf); if (keylist == NULL) return; /* If there's no keys to add, or the settings apply to a window manager * that's not the one we're running */ if (keylist->entries->len == 0 || (keylist->wm_name != NULL && !strv_contains (wm_keybindings, keylist->wm_name)) || keylist->name == NULL) { g_free (keylist->name); g_free (keylist->package); g_free (keylist->wm_name); g_free (keylist->schema); g_array_free (keylist->entries, TRUE); g_free (keylist); return; } /* Empty KeyListEntry to end the array */ key.name = NULL; key.description_key = NULL; key.value_key = NULL; key.value = 0; key.comparison = COMPARISON_NONE; g_array_append_val (keylist->entries, key); keys = (KeyListEntry *) g_array_free (keylist->entries, FALSE); if (keylist->package) { bind_textdomain_codeset (keylist->package, "UTF-8"); title = dgettext (keylist->package, keylist->name); } else { title = _(keylist->name); } append_keys_to_tree (builder, title, keylist->schema, keylist->package, keys); g_free (keylist->name); g_free (keylist->package); for (i = 0; keys[i].name != NULL; i++) g_free (keys[i].name); g_free (keylist); } static void append_keys_to_tree_from_gsettings (GtkBuilder *builder, const gchar *gsettings_path) { gchar **custom_list; GArray *entries; KeyListEntry key; gint i; /* load custom shortcuts from GSettings */ entries = g_array_new (FALSE, TRUE, sizeof (KeyListEntry)); key.value_key = NULL; key.value = 0; key.comparison = COMPARISON_NONE; custom_list = dconf_util_list_subdirs (gsettings_path, FALSE); if (custom_list != NULL) { for (i = 0; custom_list[i] != NULL; i++) { key.gsettings_path = g_strdup_printf("%s%s", gsettings_path, custom_list[i]); key.name = g_strdup("binding"); key.cmd_key = g_strdup("action"); key.description_key = g_strdup("name"); key.schema = NULL; g_array_append_val (entries, key); } } g_strfreev (custom_list); if (entries->len > 0) { KeyListEntry *keys; int i; /* Empty KeyListEntry to end the array */ key.gsettings_path = NULL; key.name = NULL; key.description_key = NULL; key.cmd_key = NULL; g_array_append_val (entries, key); keys = (KeyListEntry *) entries->data; append_keys_to_tree (builder, _("Custom Shortcuts"), CUSTOM_KEYBINDING_SCHEMA, NULL, keys); for (i = 0; i < entries->len; ++i) { g_free (keys[i].name); g_free (keys[i].description_key); g_free (keys[i].cmd_key); g_free (keys[i].gsettings_path); } } g_array_free (entries, TRUE); } static void reload_key_entries (GtkBuilder *builder) { gchar **wm_keybindings; GDir *dir; const char *name; GList *list, *l; wm_keybindings = wm_common_get_current_keybindings(); clear_old_model (builder); dir = g_dir_open (MATECC_KEYBINDINGS_DIR, 0, NULL); if (!dir) return; list = NULL; for (name = g_dir_read_name (dir) ; name ; name = g_dir_read_name (dir)) { if (g_str_has_suffix (name, ".xml")) { list = g_list_insert_sorted (list, g_strdup (name), (GCompareFunc) g_ascii_strcasecmp); } } g_dir_close (dir); for (l = list; l != NULL; l = l->next) { gchar *path; path = g_build_filename (MATECC_KEYBINDINGS_DIR, l->data, NULL); append_keys_to_tree_from_file (builder, path, wm_keybindings); g_free (l->data); g_free (path); } g_list_free (list); /* Load custom shortcuts _after_ system-provided ones, * since some of the custom shortcuts may also be listed * in a file. Loading the custom shortcuts last makes * such keys not show up in the custom section. */ append_keys_to_tree_from_gsettings (builder, GSETTINGS_KEYBINDINGS_DIR); g_strfreev (wm_keybindings); } static void key_entry_controlling_key_changed (GSettings *settings, gchar *key, gpointer user_data) { reload_key_entries (user_data); } static gboolean cb_check_for_uniqueness(GtkTreeModel* model, GtkTreePath* path, GtkTreeIter* iter, KeyEntry* new_key) { KeyEntry* element; gtk_tree_model_get (new_key->model, iter, KEYENTRY_COLUMN, &element, -1); /* no conflict for : blanks, different modifiers, or ourselves */ if (element == NULL || new_key->mask != element->mask) { return FALSE; } gchar *new_key_schema = NULL; gchar *element_schema = NULL; gchar *new_key_path = NULL; gchar *element_path = NULL; if (new_key && new_key->settings) { g_object_get (new_key->settings, "schema-id", &new_key_schema, NULL); g_object_get (new_key->settings, "path", &new_key_path, NULL); } if (element->settings) { g_object_get (element->settings, "schema-id", &element_schema, NULL); g_object_get (element->settings, "path", &element_path, NULL); } if (!g_strcmp0 (new_key->gsettings_key, element->gsettings_key) && !g_strcmp0 (new_key_schema, element_schema) && !g_strcmp0 (new_key_path, element_path)) { return FALSE; } if (new_key->keyval != 0) { if (new_key->keyval != element->keyval) { return FALSE; } } else if (element->keyval != 0 || new_key->keycode != element->keycode) { return FALSE; } new_key->editable = FALSE; new_key->settings = element->settings; new_key->gsettings_key = element->gsettings_key; new_key->description = element->description; new_key->desc_gsettings_key = element->desc_gsettings_key; new_key->desc_editable = element->desc_editable; return TRUE; } static const guint forbidden_keyvals[] = { /* Navigation keys */ GDK_Home, GDK_Left, GDK_Up, GDK_Right, GDK_Down, GDK_Page_Up, GDK_Page_Down, GDK_End, GDK_Tab, /* Return */ GDK_KP_Enter, GDK_Return, GDK_space, GDK_Mode_switch }; static gboolean keyval_is_forbidden(guint keyval) { guint i; for (i = 0; i < G_N_ELEMENTS(forbidden_keyvals); i++) { if (keyval == forbidden_keyvals[i]) { return TRUE; } } return FALSE; } static void show_error(GtkWindow* parent, GError* err) { GtkWidget *dialog; dialog = gtk_message_dialog_new (parent, GTK_DIALOG_DESTROY_WITH_PARENT | GTK_DIALOG_MODAL, GTK_MESSAGE_WARNING, GTK_BUTTONS_OK, _("Error saving the new shortcut")); gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog), "%s", err->message); gtk_dialog_run (GTK_DIALOG (dialog)); gtk_widget_destroy (dialog); } static void accel_edited_callback(GtkCellRendererText* cell, const char* path_string, guint keyval, EggVirtualModifierType mask, guint keycode, gpointer data) { GtkTreeView* view = (GtkTreeView*) data; GtkTreeModel* model; GtkTreePath* path = gtk_tree_path_new_from_string (path_string); GtkTreeIter iter; KeyEntry* key_entry, tmp_key; char* str; block_accels = FALSE; model = gtk_tree_view_get_model (view); gtk_tree_model_get_iter (model, &iter, path); gtk_tree_path_free (path); gtk_tree_model_get (model, &iter, KEYENTRY_COLUMN, &key_entry, -1); /* sanity check */ if (key_entry == NULL) { return; } /* CapsLock isn't supported as a keybinding modifier, so keep it from confusing us */ mask &= ~EGG_VIRTUAL_LOCK_MASK; tmp_key.model = model; tmp_key.keyval = keyval; tmp_key.keycode = keycode; tmp_key.mask = mask; tmp_key.settings = key_entry->settings; tmp_key.gsettings_key = key_entry->gsettings_key; tmp_key.description = NULL; tmp_key.editable = TRUE; /* kludge to stuff in a return flag */ if (keyval != 0 || keycode != 0) /* any number of keys can be disabled */ { gtk_tree_model_foreach(model, (GtkTreeModelForeachFunc) cb_check_for_uniqueness, &tmp_key); } /* Check for unmodified keys */ if (tmp_key.mask == 0 && tmp_key.keycode != 0) { if ((tmp_key.keyval >= GDK_a && tmp_key.keyval <= GDK_z) || (tmp_key.keyval >= GDK_A && tmp_key.keyval <= GDK_Z) || (tmp_key.keyval >= GDK_0 && tmp_key.keyval <= GDK_9) || (tmp_key.keyval >= GDK_kana_fullstop && tmp_key.keyval <= GDK_semivoicedsound) || (tmp_key.keyval >= GDK_Arabic_comma && tmp_key.keyval <= GDK_Arabic_sukun) || (tmp_key.keyval >= GDK_Serbian_dje && tmp_key.keyval <= GDK_Cyrillic_HARDSIGN) || (tmp_key.keyval >= GDK_Greek_ALPHAaccent && tmp_key.keyval <= GDK_Greek_omega) || (tmp_key.keyval >= GDK_hebrew_doublelowline && tmp_key.keyval <= GDK_hebrew_taf) || (tmp_key.keyval >= GDK_Thai_kokai && tmp_key.keyval <= GDK_Thai_lekkao) || (tmp_key.keyval >= GDK_Hangul && tmp_key.keyval <= GDK_Hangul_Special) || (tmp_key.keyval >= GDK_Hangul_Kiyeog && tmp_key.keyval <= GDK_Hangul_J_YeorinHieuh) || keyval_is_forbidden (tmp_key.keyval)) { GtkWidget *dialog; char *name; name = binding_name (keyval, keycode, mask, TRUE); dialog = gtk_message_dialog_new ( GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (view))), GTK_DIALOG_DESTROY_WITH_PARENT | GTK_DIALOG_MODAL, GTK_MESSAGE_WARNING, GTK_BUTTONS_CANCEL, _("The shortcut \"%s\" cannot be used because it will become impossible to type using this key.\n" "Please try with a key such as Control, Alt or Shift at the same time."), name); g_free (name); gtk_dialog_run (GTK_DIALOG (dialog)); gtk_widget_destroy (dialog); /* set it back to its previous value. */ egg_cell_renderer_keys_set_accelerator( EGG_CELL_RENDERER_KEYS(cell), key_entry->keyval, key_entry->keycode, key_entry->mask); return; } } /* flag to see if the new accelerator was in use by something */ if (!tmp_key.editable) { GtkWidget* dialog; char* name; int response; name = binding_name(keyval, keycode, mask, TRUE); dialog = gtk_message_dialog_new( GTK_WINDOW(gtk_widget_get_toplevel(GTK_WIDGET(view))), GTK_DIALOG_DESTROY_WITH_PARENT | GTK_DIALOG_MODAL, GTK_MESSAGE_WARNING, GTK_BUTTONS_CANCEL, _("The shortcut \"%s\" is already used for\n\"%s\""), name, tmp_key.description ? tmp_key.description : tmp_key.gsettings_key); g_free (name); gtk_message_dialog_format_secondary_text ( GTK_MESSAGE_DIALOG (dialog), _("If you reassign the shortcut to \"%s\", the \"%s\" shortcut " "will be disabled."), key_entry->description ? key_entry->description : key_entry->gsettings_key, tmp_key.description ? tmp_key.description : tmp_key.gsettings_key); gtk_dialog_add_button(GTK_DIALOG (dialog), _("_Reassign"), GTK_RESPONSE_ACCEPT); gtk_dialog_set_default_response(GTK_DIALOG (dialog), GTK_RESPONSE_ACCEPT); response = gtk_dialog_run (GTK_DIALOG (dialog)); gtk_widget_destroy (dialog); if (response == GTK_RESPONSE_ACCEPT) { g_settings_set_string (tmp_key.settings, tmp_key.gsettings_key, "disabled"); str = binding_name (keyval, keycode, mask, FALSE); g_settings_set_string (key_entry->settings, key_entry->gsettings_key, str); g_free (str); } else { /* set it back to its previous value. */ egg_cell_renderer_keys_set_accelerator( EGG_CELL_RENDERER_KEYS(cell), key_entry->keyval, key_entry->keycode, key_entry->mask); } return; } str = binding_name (keyval, keycode, mask, FALSE); g_settings_set_string( key_entry->settings, key_entry->gsettings_key, str); g_free (str); } static void accel_cleared_callback (GtkCellRendererText *cell, const char *path_string, gpointer data) { GtkTreeView *view = (GtkTreeView *) data; GtkTreePath *path = gtk_tree_path_new_from_string (path_string); KeyEntry *key_entry; GtkTreeIter iter; GtkTreeModel *model; block_accels = FALSE; model = gtk_tree_view_get_model (view); gtk_tree_model_get_iter (model, &iter, path); gtk_tree_path_free (path); gtk_tree_model_get (model, &iter, KEYENTRY_COLUMN, &key_entry, -1); /* sanity check */ if (key_entry == NULL) return; /* Unset the key */ g_settings_set_string (key_entry->settings, key_entry->gsettings_key, "disabled"); } static void description_edited_callback (GtkCellRendererText *renderer, gchar *path_string, gchar *new_text, gpointer user_data) { GtkTreeView *view = GTK_TREE_VIEW (user_data); GtkTreeModel *model; GtkTreePath *path = gtk_tree_path_new_from_string (path_string); GtkTreeIter iter; KeyEntry *key_entry; model = gtk_tree_view_get_model (view); gtk_tree_model_get_iter (model, &iter, path); gtk_tree_path_free (path); gtk_tree_model_get (model, &iter, KEYENTRY_COLUMN, &key_entry, -1); /* sanity check */ if (key_entry == NULL || key_entry->desc_gsettings_key == NULL) return; if (!g_settings_set_string (key_entry->settings, key_entry->desc_gsettings_key, new_text)) key_entry->desc_editable = FALSE; } typedef struct { GtkTreeView *tree_view; GtkTreePath *path; GtkTreeViewColumn *column; } IdleData; static gboolean real_start_editing_cb (IdleData *idle_data) { gtk_widget_grab_focus (GTK_WIDGET (idle_data->tree_view)); gtk_tree_view_set_cursor (idle_data->tree_view, idle_data->path, idle_data->column, TRUE); gtk_tree_path_free (idle_data->path); g_free (idle_data); return FALSE; } static gboolean edit_custom_shortcut (KeyEntry *key) { gint result; const gchar *text; gboolean ret; gtk_entry_set_text (GTK_ENTRY (custom_shortcut_name_entry), key->description ? key->description : ""); gtk_widget_set_sensitive (custom_shortcut_name_entry, key->desc_editable); gtk_widget_grab_focus (custom_shortcut_name_entry); gtk_entry_set_text (GTK_ENTRY (custom_shortcut_command_entry), key->command ? key->command : ""); gtk_widget_set_sensitive (custom_shortcut_command_entry, key->cmd_editable); gtk_window_present (GTK_WINDOW (custom_shortcut_dialog)); result = gtk_dialog_run (GTK_DIALOG (custom_shortcut_dialog)); switch (result) { case GTK_RESPONSE_OK: text = gtk_entry_get_text (GTK_ENTRY (custom_shortcut_name_entry)); g_free (key->description); key->description = g_strdup (text); text = gtk_entry_get_text (GTK_ENTRY (custom_shortcut_command_entry)); g_free (key->command); key->command = g_strdup (text); ret = TRUE; break; default: ret = FALSE; break; } gtk_widget_hide (custom_shortcut_dialog); return ret; } static gboolean remove_custom_shortcut (GtkTreeModel *model, GtkTreeIter *iter) { GtkTreeIter parent; KeyEntry *key; gtk_tree_model_get (model, iter, KEYENTRY_COLUMN, &key, -1); /* not a custom shortcut */ if (key->command == NULL) return FALSE; g_signal_handler_disconnect (key->settings, key->gsettings_cnxn); if (key->gsettings_cnxn_desc != 0) g_signal_handler_disconnect (key->settings, key->gsettings_cnxn_desc); if (key->gsettings_cnxn_cmd != 0) g_signal_handler_disconnect (key->settings, key->gsettings_cnxn_cmd); dconf_util_recursive_reset (key->gsettings_path, NULL); g_object_unref (key->settings); g_free (key->gsettings_path); g_free (key->gsettings_key); g_free (key->description); g_free (key->desc_gsettings_key); g_free (key->command); g_free (key->cmd_gsettings_key); g_free (key); gtk_tree_model_iter_parent (model, &parent, iter); gtk_tree_store_remove (GTK_TREE_STORE (model), iter); if (!gtk_tree_model_iter_has_child (model, &parent)) gtk_tree_store_remove (GTK_TREE_STORE (model), &parent); return TRUE; } static void update_custom_shortcut (GtkTreeModel *model, GtkTreeIter *iter) { KeyEntry *key; gtk_tree_model_get (model, iter, KEYENTRY_COLUMN, &key, -1); edit_custom_shortcut (key); if (key->command == NULL || key->command[0] == '\0') { remove_custom_shortcut (model, iter); } else { gtk_tree_store_set (GTK_TREE_STORE (model), iter, KEYENTRY_COLUMN, key, -1); if (key->description != NULL) g_settings_set_string (key->settings, key->desc_gsettings_key, key->description); else g_settings_reset (key->settings, key->desc_gsettings_key); g_settings_set_string (key->settings, key->cmd_gsettings_key, key->command); } } static gchar * find_free_gsettings_path (GError **error) { gchar **existing_dirs; gchar *dir = NULL; gchar *fulldir = NULL; int i; int j; gboolean found; existing_dirs = dconf_util_list_subdirs (GSETTINGS_KEYBINDINGS_DIR, FALSE); for (i = 0; i < MAX_CUSTOM_SHORTCUTS; i++) { found = TRUE; dir = g_strdup_printf ("custom%d/", i); for (j = 0; existing_dirs[j] != NULL; j++) if (!g_strcmp0(dir, existing_dirs[j])) { found = FALSE; g_free (dir); break; } if (found) break; } g_strfreev (existing_dirs); if (i == MAX_CUSTOM_SHORTCUTS) { g_free (dir); dir = NULL; g_set_error_literal (error, g_quark_from_string ("Keyboard Shortcuts"), 0, _("Too many custom shortcuts")); } fulldir = g_strdup_printf ("%s%s", GSETTINGS_KEYBINDINGS_DIR, dir); g_free (dir); return fulldir; } static void add_custom_shortcut (GtkTreeView *tree_view, GtkTreeModel *model) { KeyEntry *key_entry; GtkTreeIter iter; GtkTreeIter parent_iter; GtkTreePath *path; gchar *dir; GError *error; error = NULL; dir = find_free_gsettings_path (&error); if (dir == NULL) { show_error (GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (tree_view))), error); g_error_free (error); return; } key_entry = g_new0 (KeyEntry, 1); key_entry->gsettings_path = g_strdup(dir); key_entry->gsettings_key = g_strdup("binding"); key_entry->editable = TRUE; key_entry->model = model; key_entry->desc_gsettings_key = g_strdup("name"); key_entry->description = g_strdup (""); key_entry->desc_editable = TRUE; key_entry->cmd_gsettings_key = g_strdup("action"); key_entry->command = g_strdup (""); key_entry->cmd_editable = TRUE; g_free (dir); if (edit_custom_shortcut (key_entry) && key_entry->command && key_entry->command[0]) { find_section (model, &iter, _("Custom Shortcuts")); parent_iter = iter; gtk_tree_store_append (GTK_TREE_STORE (model), &iter, &parent_iter); gtk_tree_store_set (GTK_TREE_STORE (model), &iter, KEYENTRY_COLUMN, key_entry, -1); /* store in gsettings */ key_entry->settings = g_settings_new_with_path (CUSTOM_KEYBINDING_SCHEMA, key_entry->gsettings_path); g_settings_set_string (key_entry->settings, key_entry->gsettings_key, "disabled"); g_settings_set_string (key_entry->settings, key_entry->desc_gsettings_key, key_entry->description); g_settings_set_string (key_entry->settings, key_entry->cmd_gsettings_key, key_entry->command); /* add gsettings watches */ key_entry->gsettings_cnxn_desc = g_signal_connect (key_entry->settings, "changed::name", G_CALLBACK (keybinding_description_changed), key_entry); key_entry->gsettings_cnxn_cmd = g_signal_connect (key_entry->settings, "changed::action", G_CALLBACK (keybinding_command_changed), key_entry); key_entry->gsettings_cnxn = g_signal_connect (key_entry->settings, "changed::binding", G_CALLBACK (keybinding_key_changed), key_entry); /* make the new shortcut visible */ path = gtk_tree_model_get_path (model, &iter); gtk_tree_view_expand_to_path (tree_view, path); gtk_tree_view_scroll_to_cell (tree_view, path, NULL, FALSE, 0, 0); gtk_tree_path_free (path); } else { g_free (key_entry->gsettings_path); g_free (key_entry->gsettings_key); g_free (key_entry->description); g_free (key_entry->desc_gsettings_key); g_free (key_entry->command); g_free (key_entry->cmd_gsettings_key); g_free (key_entry); } } static void start_editing_kb_cb (GtkTreeView *treeview, GtkTreePath *path, GtkTreeViewColumn *column, gpointer user_data) { GtkTreeModel *model; GtkTreeIter iter; KeyEntry *key; model = gtk_tree_view_get_model (treeview); gtk_tree_model_get_iter (model, &iter, path); gtk_tree_model_get (model, &iter, KEYENTRY_COLUMN, &key, -1); if (key == NULL) { /* This is a section heading - expand or collapse */ if (gtk_tree_view_row_expanded (treeview, path)) gtk_tree_view_collapse_row (treeview, path); else gtk_tree_view_expand_row (treeview, path, FALSE); return; } /* if only the accel can be edited on the selected row * always select the accel column */ if (key->desc_editable && column == gtk_tree_view_get_column (treeview, 0)) { gtk_widget_grab_focus (GTK_WIDGET (treeview)); gtk_tree_view_set_cursor (treeview, path, gtk_tree_view_get_column (treeview, 0), FALSE); update_custom_shortcut (model, &iter); } else { gtk_widget_grab_focus (GTK_WIDGET (treeview)); gtk_tree_view_set_cursor (treeview, path, gtk_tree_view_get_column (treeview, 1), TRUE); } } static gboolean start_editing_cb (GtkTreeView *tree_view, GdkEventButton *event, gpointer user_data) { GtkTreePath *path; GtkTreeViewColumn *column; if (event->window != gtk_tree_view_get_bin_window (tree_view)) return FALSE; if (gtk_tree_view_get_path_at_pos (tree_view, (gint) event->x, (gint) event->y, &path, &column, NULL, NULL)) { IdleData *idle_data; GtkTreeModel *model; GtkTreeIter iter; KeyEntry *key; if (gtk_tree_path_get_depth (path) == 1) { gtk_tree_path_free (path); return FALSE; } model = gtk_tree_view_get_model (tree_view); gtk_tree_model_get_iter (model, &iter, path); gtk_tree_model_get (model, &iter, KEYENTRY_COLUMN, &key, -1); /* if only the accel can be edited on the selected row * always select the accel column */ if (key->desc_editable && column == gtk_tree_view_get_column (tree_view, 0)) { gtk_widget_grab_focus (GTK_WIDGET (tree_view)); gtk_tree_view_set_cursor (tree_view, path, gtk_tree_view_get_column (tree_view, 0), FALSE); update_custom_shortcut (model, &iter); } else { idle_data = g_new (IdleData, 1); idle_data->tree_view = tree_view; idle_data->path = path; idle_data->column = key->desc_editable ? column : gtk_tree_view_get_column (tree_view, 1); g_idle_add ((GSourceFunc) real_start_editing_cb, idle_data); block_accels = TRUE; } g_signal_stop_emission_by_name (tree_view, "button_press_event"); } return TRUE; } /* this handler is used to keep accels from activating while the user * is assigning a new shortcut so that he won't accidentally trigger one * of the widgets */ static gboolean maybe_block_accels(GtkWidget* widget, GdkEventKey* event, gpointer user_data) { if (block_accels) { return gtk_window_propagate_key_event(GTK_WINDOW(widget), event); } return FALSE; } static void cb_dialog_response (GtkWidget *widget, gint response_id, gpointer data) { GtkBuilder *builder = data; GtkTreeView *treeview; GtkTreeModel *model; GtkTreeSelection *selection; GtkTreeIter iter; treeview = GTK_TREE_VIEW (gtk_builder_get_object (builder, "shortcut_treeview")); model = gtk_tree_view_get_model (treeview); if (response_id == GTK_RESPONSE_HELP) { capplet_help (GTK_WINDOW (widget), "goscustdesk-39"); } else if (response_id == RESPONSE_ADD) { add_custom_shortcut (treeview, model); } else if (response_id == RESPONSE_REMOVE) { selection = gtk_tree_view_get_selection (treeview); if (gtk_tree_selection_get_selected (selection, NULL, &iter)) { remove_custom_shortcut (model, &iter); } } else { clear_old_model (builder); gtk_main_quit (); } } static void selection_changed (GtkTreeSelection *selection, gpointer data) { GtkWidget *button = data; GtkTreeModel *model; GtkTreeIter iter; KeyEntry *key; gboolean can_remove; can_remove = FALSE; if (gtk_tree_selection_get_selected (selection, &model, &iter)) { gtk_tree_model_get (model, &iter, KEYENTRY_COLUMN, &key, -1); if (key && key->command != NULL && key->editable) can_remove = TRUE; } gtk_widget_set_sensitive (button, can_remove); } static void setup_dialog (GtkBuilder *builder, GSettings *marco_settings) { GtkCellRenderer *renderer; GtkTreeViewColumn *column; GtkWidget *widget; GtkTreeView *treeview; GtkTreeSelection *selection; treeview = GTK_TREE_VIEW (gtk_builder_get_object (builder, "shortcut_treeview")); g_signal_connect (treeview, "button_press_event", G_CALLBACK (start_editing_cb), builder); g_signal_connect (treeview, "row-activated", G_CALLBACK (start_editing_kb_cb), NULL); renderer = gtk_cell_renderer_text_new (); g_signal_connect (renderer, "edited", G_CALLBACK (description_edited_callback), treeview); column = gtk_tree_view_column_new_with_attributes (_("Action"), renderer, "text", DESCRIPTION_COLUMN, NULL); gtk_tree_view_column_set_cell_data_func (column, renderer, description_set_func, NULL, NULL); gtk_tree_view_column_set_resizable (column, FALSE); gtk_tree_view_append_column (treeview, column); gtk_tree_view_column_set_sort_column_id (column, DESCRIPTION_COLUMN); renderer = (GtkCellRenderer *) g_object_new (EGG_TYPE_CELL_RENDERER_KEYS, "accel_mode", EGG_CELL_RENDERER_KEYS_MODE_X, NULL); g_signal_connect (renderer, "accel_edited", G_CALLBACK (accel_edited_callback), treeview); g_signal_connect (renderer, "accel_cleared", G_CALLBACK (accel_cleared_callback), treeview); column = gtk_tree_view_column_new_with_attributes (_("Shortcut"), renderer, NULL); gtk_tree_view_column_set_cell_data_func (column, renderer, accel_set_func, NULL, NULL); gtk_tree_view_column_set_resizable (column, FALSE); gtk_tree_view_append_column (treeview, column); gtk_tree_view_column_set_sort_column_id (column, KEYENTRY_COLUMN); g_signal_connect (marco_settings, "changed::num-workspaces", G_CALLBACK (key_entry_controlling_key_changed), builder); /* set up the dialog */ reload_key_entries (builder); #if GTK_CHECK_VERSION(3, 0, 0) widget = _gtk_builder_get_widget (builder, "mate-keybinding-dialog"); gtk_window_set_default_size (GTK_WINDOW (widget), 400, 500); widget = _gtk_builder_get_widget (builder, "label-suggest"); gtk_label_set_line_wrap (GTK_LABEL (widget), TRUE); gtk_label_set_max_width_chars (GTK_LABEL (widget), 60); #endif widget = _gtk_builder_get_widget (builder, "mate-keybinding-dialog"); capplet_set_icon (widget, "preferences-desktop-keyboard-shortcuts"); gtk_widget_show (widget); g_signal_connect (widget, "key_press_event", G_CALLBACK (maybe_block_accels), NULL); g_signal_connect (widget, "response", G_CALLBACK (cb_dialog_response), builder); selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (treeview)); g_signal_connect (selection, "changed", G_CALLBACK (selection_changed), _gtk_builder_get_widget (builder, "remove-button")); /* setup the custom shortcut dialog */ custom_shortcut_dialog = _gtk_builder_get_widget (builder, "custom-shortcut-dialog"); custom_shortcut_name_entry = _gtk_builder_get_widget (builder, "custom-shortcut-name-entry"); custom_shortcut_command_entry = _gtk_builder_get_widget (builder, "custom-shortcut-command-entry"); gtk_dialog_set_default_response (GTK_DIALOG (custom_shortcut_dialog), GTK_RESPONSE_OK); gtk_window_set_transient_for (GTK_WINDOW (custom_shortcut_dialog), GTK_WINDOW (widget)); } static void on_window_manager_change (const char *wm_name, GtkBuilder *builder) { reload_key_entries (builder); } int main (int argc, char *argv[]) { GtkBuilder *builder; GSettings *marco_settings; gtk_init (&argc, &argv); bindtextdomain (GETTEXT_PACKAGE, MATELOCALEDIR); bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8"); textdomain (GETTEXT_PACKAGE); gtk_init (&argc, &argv); activate_settings_daemon (); builder = create_builder (); if (!builder) /* Warning was already printed to console */ exit (EXIT_FAILURE); wm_common_register_window_manager_change ((GFunc) on_window_manager_change, builder); marco_settings = g_settings_new ("org.mate.Marco.general"); setup_dialog (builder, marco_settings); gtk_main (); g_object_unref (marco_settings); g_object_unref (builder); return 0; } /* * vim: sw=2 ts=8 cindent noai bs=2 */
City-busz/mate-control-center
capplets/keybindings/mate-keybinding-properties.c
C
gpl-2.0
58,766
jQuery('#bootstrapslider').carousel({ interval: bootstrapslider_script_vars.interval, pause: bootstrapslider_script_vars.pause, wrap: bootstrapslider_script_vars.wrap });
bassjobsen/twitter-bootstrap-slider
js/bootstrapslider.js
JavaScript
gpl-2.0
177
/****************************************************************************** * * Copyright (C) 1997-2013 by Dimitri van Heesch. * * Permission to use, copy, modify, and distribute this software and its * documentation under the terms of the GNU General Public License is hereby * granted. No representations are made about the suitability of this software * for any purpose. It is provided "as is" without express or implied warranty. * See the GNU General Public License for more details. * * Documents produced by Doxygen are derivative works derived from the * input used in their production; they are not affected by this license. * */ #include <stdlib.h> #include <qdir.h> #include <qfile.h> #include <qtextstream.h> #include <qintdict.h> #include "xmlgen.h" #include "doxygen.h" #include "message.h" #include "config.h" #include "classlist.h" #include "util.h" #include "defargs.h" #include "outputgen.h" #include "dot.h" #include "pagedef.h" #include "filename.h" #include "version.h" #include "xmldocvisitor.h" #include "docparser.h" #include "language.h" #include "parserintf.h" #include "arguments.h" #include "memberlist.h" #include "groupdef.h" #include "memberdef.h" #include "namespacedef.h" #include "membername.h" #include "membergroup.h" #include "dirdef.h" #include "section.h" // no debug info #define XML_DB(x) do {} while(0) // debug to stdout //#define XML_DB(x) printf x // debug inside output //#define XML_DB(x) QCString __t;__t.sprintf x;m_t << __t //------------------ static const char index_xsd[] = #include "index_xsd.h" ; //------------------ // static const char compound_xsd[] = #include "compound_xsd.h" ; //------------------ /** Helper class mapping MemberList::ListType to a string representing */ class XmlSectionMapper : public QIntDict<char> { public: XmlSectionMapper() : QIntDict<char>(47) { insert(MemberListType_pubTypes,"public-type"); insert(MemberListType_pubMethods,"public-func"); insert(MemberListType_pubAttribs,"public-attrib"); insert(MemberListType_pubSlots,"public-slot"); insert(MemberListType_signals,"signal"); insert(MemberListType_dcopMethods,"dcop-func"); insert(MemberListType_properties,"property"); insert(MemberListType_events,"event"); insert(MemberListType_pubStaticMethods,"public-static-func"); insert(MemberListType_pubStaticAttribs,"public-static-attrib"); insert(MemberListType_proTypes,"protected-type"); insert(MemberListType_proMethods,"protected-func"); insert(MemberListType_proAttribs,"protected-attrib"); insert(MemberListType_proSlots,"protected-slot"); insert(MemberListType_proStaticMethods,"protected-static-func"); insert(MemberListType_proStaticAttribs,"protected-static-attrib"); insert(MemberListType_pacTypes,"package-type"); insert(MemberListType_pacMethods,"package-func"); insert(MemberListType_pacAttribs,"package-attrib"); insert(MemberListType_pacStaticMethods,"package-static-func"); insert(MemberListType_pacStaticAttribs,"package-static-attrib"); insert(MemberListType_priTypes,"private-type"); insert(MemberListType_priMethods,"private-func"); insert(MemberListType_priAttribs,"private-attrib"); insert(MemberListType_priSlots,"private-slot"); insert(MemberListType_priStaticMethods,"private-static-func"); insert(MemberListType_priStaticAttribs,"private-static-attrib"); insert(MemberListType_friends,"friend"); insert(MemberListType_related,"related"); insert(MemberListType_decDefineMembers,"define"); insert(MemberListType_decProtoMembers,"prototype"); insert(MemberListType_decTypedefMembers,"typedef"); insert(MemberListType_decEnumMembers,"enum"); insert(MemberListType_decFuncMembers,"func"); insert(MemberListType_decVarMembers,"var"); } }; static XmlSectionMapper g_xmlSectionMapper; inline void writeXMLString(FTextStream &t,const char *s) { t << convertToXML(s); } inline void writeXMLCodeString(FTextStream &t,const char *s, int &col) { char c; while ((c=*s++)) { switch(c) { case '\t': { static int tabSize = Config_getInt("TAB_SIZE"); int spacesToNextTabStop = tabSize - (col%tabSize); col+=spacesToNextTabStop; while (spacesToNextTabStop--) t << "<sp/>"; break; } case ' ': t << "<sp/>"; col++; break; case '<': t << "&lt;"; col++; break; case '>': t << "&gt;"; col++; break; case '&': t << "&amp;"; col++; break; case '\'': t << "&apos;"; col++; break; case '"': t << "&quot;"; col++; break; default: t << c; col++; break; } } } static void writeXMLHeader(FTextStream &t) { t << "<?xml version='1.0' encoding='UTF-8' standalone='no'?>" << endl;; t << "<doxygen xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" "; t << "xsi:noNamespaceSchemaLocation=\"compound.xsd\" "; t << "version=\"" << versionString << "\">" << endl; } static void writeCombineScript() { QCString outputDirectory = Config_getString("XML_OUTPUT"); QCString fileName=outputDirectory+"/combine.xslt"; QFile f(fileName); if (!f.open(IO_WriteOnly)) { err("Cannot open file %s for writing!\n",fileName.data()); return; } FTextStream t(&f); //t.setEncoding(FTextStream::UnicodeUTF8); t << "<!-- XSLT script to combine the generated output into a single file. \n" " If you have xsltproc you could use:\n" " xsltproc combine.xslt index.xml >all.xml\n" "-->\n" "<xsl:stylesheet xmlns:xsl=\"http://www.w3.org/1999/XSL/Transform\" version=\"1.0\">\n" " <xsl:output method=\"xml\" version=\"1.0\" indent=\"no\" standalone=\"yes\" />\n" " <xsl:template match=\"/\">\n" " <doxygen version=\"{doxygenindex/@version}\">\n" " <!-- Load all doxgen generated xml files -->\n" " <xsl:for-each select=\"doxygenindex/compound\">\n" " <xsl:copy-of select=\"document( concat( @refid, '.xml' ) )/doxygen/*\" />\n" " </xsl:for-each>\n" " </doxygen>\n" " </xsl:template>\n" "</xsl:stylesheet>\n"; } void writeXMLLink(FTextStream &t,const char *extRef,const char *compoundId, const char *anchorId,const char *text,const char *tooltip) { t << "<ref refid=\"" << compoundId; if (anchorId) t << "_1" << anchorId; t << "\" kindref=\""; if (anchorId) t << "member"; else t << "compound"; t << "\""; if (extRef) t << " external=\"" << extRef << "\""; if (tooltip) t << " tooltip=\"" << convertToXML(tooltip) << "\""; t << ">"; writeXMLString(t,text); t << "</ref>"; } /** Implements TextGeneratorIntf for an XML stream. */ class TextGeneratorXMLImpl : public TextGeneratorIntf { public: TextGeneratorXMLImpl(FTextStream &t): m_t(t) {} void writeString(const char *s,bool /*keepSpaces*/) const { writeXMLString(m_t,s); } void writeBreak(int) const {} void writeLink(const char *extRef,const char *file, const char *anchor,const char *text ) const { writeXMLLink(m_t,extRef,file,anchor,text,0); } private: FTextStream &m_t; }; /** Helper class representing a stack of objects stored by value */ template<class T> class ValStack { public: ValStack() : m_values(10), m_sp(0), m_size(10) {} virtual ~ValStack() {} ValStack(const ValStack<T> &s) { m_values=s.m_values.copy(); m_sp=s.m_sp; m_size=s.m_size; } ValStack &operator=(const ValStack<T> &s) { m_values=s.m_values.copy(); m_sp=s.m_sp; m_size=s.m_size; return *this; } void push(T v) { m_sp++; if (m_sp>=m_size) { m_size+=10; m_values.resize(m_size); } m_values[m_sp]=v; } T pop() { ASSERT(m_sp!=0); return m_values[m_sp--]; } T& top() { ASSERT(m_sp!=0); return m_values[m_sp]; } bool isEmpty() { return m_sp==0; } uint count() const { return m_sp; } private: QArray<T> m_values; int m_sp; int m_size; }; /** Generator for producing XML formatted source code. */ class XMLCodeGenerator : public CodeOutputInterface { public: XMLCodeGenerator(FTextStream &t) : m_t(t), m_lineNumber(-1), m_insideCodeLine(FALSE), m_normalHLNeedStartTag(TRUE), m_insideSpecialHL(FALSE) {} virtual ~XMLCodeGenerator() { } void codify(const char *text) { XML_DB(("(codify \"%s\")\n",text)); if (m_insideCodeLine && !m_insideSpecialHL && m_normalHLNeedStartTag) { m_t << "<highlight class=\"normal\">"; m_normalHLNeedStartTag=FALSE; } writeXMLCodeString(m_t,text,col); } void writeCodeLink(const char *ref,const char *file, const char *anchor,const char *name, const char *tooltip) { XML_DB(("(writeCodeLink)\n")); if (m_insideCodeLine && !m_insideSpecialHL && m_normalHLNeedStartTag) { m_t << "<highlight class=\"normal\">"; m_normalHLNeedStartTag=FALSE; } writeXMLLink(m_t,ref,file,anchor,name,tooltip); col+=qstrlen(name); } void startCodeLine(bool) { XML_DB(("(startCodeLine)\n")); m_t << "<codeline"; if (m_lineNumber!=-1) { m_t << " lineno=\"" << m_lineNumber << "\""; if (!m_refId.isEmpty()) { m_t << " refid=\"" << m_refId << "\""; if (m_isMemberRef) { m_t << " refkind=\"member\""; } else { m_t << " refkind=\"compound\""; } } if (!m_external.isEmpty()) { m_t << " external=\"" << m_external << "\""; } } m_t << ">"; m_insideCodeLine=TRUE; col=0; } void endCodeLine() { XML_DB(("(endCodeLine)\n")); if (!m_insideSpecialHL && !m_normalHLNeedStartTag) { m_t << "</highlight>"; m_normalHLNeedStartTag=TRUE; } m_t << "</codeline>" << endl; // non DocBook m_lineNumber = -1; m_refId.resize(0); m_external.resize(0); m_insideCodeLine=FALSE; } void startCodeAnchor(const char *id) { XML_DB(("(startCodeAnchor)\n")); if (m_insideCodeLine && !m_insideSpecialHL && m_normalHLNeedStartTag) { m_t << "<highlight class=\"normal\">"; m_normalHLNeedStartTag=FALSE; } m_t << "<anchor id=\"" << id << "\">"; } void endCodeAnchor() { XML_DB(("(endCodeAnchor)\n")); m_t << "</anchor>"; } void startFontClass(const char *colorClass) { XML_DB(("(startFontClass)\n")); if (m_insideCodeLine && !m_insideSpecialHL && !m_normalHLNeedStartTag) { m_t << "</highlight>"; m_normalHLNeedStartTag=TRUE; } m_t << "<highlight class=\"" << colorClass << "\">"; // non DocBook m_insideSpecialHL=TRUE; } void endFontClass() { XML_DB(("(endFontClass)\n")); m_t << "</highlight>"; // non DocBook m_insideSpecialHL=FALSE; } void writeCodeAnchor(const char *) { XML_DB(("(writeCodeAnchor)\n")); } void writeLineNumber(const char *extRef,const char *compId, const char *anchorId,int l) { XML_DB(("(writeLineNumber)\n")); // we remember the information provided here to use it // at the <codeline> start tag. m_lineNumber = l; if (compId) { m_refId=compId; if (anchorId) m_refId+=(QCString)"_1"+anchorId; m_isMemberRef = anchorId!=0; if (extRef) m_external=extRef; } } void linkableSymbol(int, const char *,Definition *,Definition *) { } void setCurrentDoc(Definition *,const char *,bool) { } void addWord(const char *,bool) { } void finish() { if (m_insideCodeLine) endCodeLine(); } private: FTextStream &m_t; QCString m_refId; QCString m_external; int m_lineNumber; bool m_isMemberRef; int col; bool m_insideCodeLine; bool m_normalHLNeedStartTag; bool m_insideSpecialHL; }; static void writeTemplateArgumentList(ArgumentList *al, FTextStream &t, Definition *scope, FileDef *fileScope, int indent) { QCString indentStr; indentStr.fill(' ',indent); if (al) { t << indentStr << "<templateparamlist>" << endl; ArgumentListIterator ali(*al); Argument *a; for (ali.toFirst();(a=ali.current());++ali) { t << indentStr << " <param>" << endl; if (!a->type.isEmpty()) { t << indentStr << " <type>"; linkifyText(TextGeneratorXMLImpl(t),scope,fileScope,0,a->type); t << "</type>" << endl; } if (!a->name.isEmpty()) { t << indentStr << " <declname>" << a->name << "</declname>" << endl; t << indentStr << " <defname>" << a->name << "</defname>" << endl; } if (!a->defval.isEmpty()) { t << indentStr << " <defval>"; linkifyText(TextGeneratorXMLImpl(t),scope,fileScope,0,a->defval); t << "</defval>" << endl; } t << indentStr << " </param>" << endl; } t << indentStr << "</templateparamlist>" << endl; } } static void writeMemberTemplateLists(MemberDef *md,FTextStream &t) { LockingPtr<ArgumentList> templMd = md->templateArguments(); if (templMd!=0) // function template prefix { writeTemplateArgumentList(templMd.pointer(),t,md->getClassDef(),md->getFileDef(),8); } } static void writeTemplateList(ClassDef *cd,FTextStream &t) { writeTemplateArgumentList(cd->templateArguments(),t,cd,0,4); } static void writeXMLDocBlock(FTextStream &t, const QCString &fileName, int lineNr, Definition *scope, MemberDef * md, const QCString &text) { QCString stext = text.stripWhiteSpace(); if (stext.isEmpty()) return; // convert the documentation string into an abstract syntax tree DocNode *root = validatingParseDoc(fileName,lineNr,scope,md,text+"\n",FALSE,FALSE); // create a code generator XMLCodeGenerator *xmlCodeGen = new XMLCodeGenerator(t); // create a parse tree visitor for XML XmlDocVisitor *visitor = new XmlDocVisitor(t,*xmlCodeGen); // visit all nodes root->accept(visitor); // clean up delete visitor; delete xmlCodeGen; delete root; } void writeXMLCodeBlock(FTextStream &t,FileDef *fd) { ParserInterface *pIntf=Doxygen::parserManager->getParser(fd->getDefFileExtension()); pIntf->resetCodeParserState(); XMLCodeGenerator *xmlGen = new XMLCodeGenerator(t); pIntf->parseCode(*xmlGen, // codeOutIntf 0, // scopeName fileToString(fd->absFilePath(),Config_getBool("FILTER_SOURCE_FILES")), FALSE, // isExampleBlock 0, // exampleName fd, // fileDef -1, // startLine -1, // endLine FALSE, // inlineFragement 0, // memberDef TRUE // showLineNumbers ); xmlGen->finish(); delete xmlGen; } static void writeMemberReference(FTextStream &t,Definition *def,MemberDef *rmd,const char *tagName) { QCString scope = rmd->getScopeString(); QCString name = rmd->name(); if (!scope.isEmpty() && scope!=def->name()) { name.prepend(scope+getLanguageSpecificSeparator(rmd->getLanguage())); } t << " <" << tagName << " refid=\""; t << rmd->getOutputFileBase() << "_1" << rmd->anchor() << "\""; if (rmd->getStartBodyLine()!=-1 && rmd->getBodyDef()) { t << " compoundref=\"" << rmd->getBodyDef()->getOutputFileBase() << "\""; t << " startline=\"" << rmd->getStartBodyLine() << "\""; if (rmd->getEndBodyLine()!=-1) { t << " endline=\"" << rmd->getEndBodyLine() << "\""; } } t << ">" << convertToXML(name) << "</" << tagName << ">" << endl; } static void stripQualifiers(QCString &typeStr) { bool done=FALSE; while (!done) { if (typeStr.stripPrefix("static ")); else if (typeStr.stripPrefix("virtual ")); else if (typeStr.stripPrefix("volatile ")); else if (typeStr=="virtual") typeStr=""; else done=TRUE; } } static QCString classOutputFileBase(ClassDef *cd) { //static bool inlineGroupedClasses = Config_getBool("INLINE_GROUPED_CLASSES"); //if (inlineGroupedClasses && cd->partOfGroups()!=0) return cd->getOutputFileBase(); //else // return cd->getOutputFileBase(); } static QCString memberOutputFileBase(MemberDef *md) { //static bool inlineGroupedClasses = Config_getBool("INLINE_GROUPED_CLASSES"); //if (inlineGroupedClasses && md->getClassDef() && md->getClassDef()->partOfGroups()!=0) // return md->getClassDef()->getXmlOutputFileBase(); //else // return md->getOutputFileBase(); return md->getOutputFileBase(); } static void generateXMLForMember(MemberDef *md,FTextStream &ti,FTextStream &t,Definition *def) { // + declaration/definition arg lists // + reimplements // + reimplementedBy // + exceptions // + const/volatile specifiers // - examples // + source definition // + source references // + source referenced by // - body code // + template arguments // (templateArguments(), definitionTemplateParameterLists()) // - call graph // enum values are written as part of the enum if (md->memberType()==MemberType_EnumValue) return; if (md->isHidden()) return; //if (md->name().at(0)=='@') return; // anonymous member // group members are only visible in their group //if (def->definitionType()!=Definition::TypeGroup && md->getGroupDef()) return; QCString memType; bool isFunc=FALSE; switch (md->memberType()) { case MemberType_Define: memType="define"; break; case MemberType_EnumValue: ASSERT(0); break; case MemberType_Property: memType="property"; break; case MemberType_Event: memType="event"; break; case MemberType_Variable: memType="variable"; break; case MemberType_Typedef: memType="typedef"; break; case MemberType_Enumeration: memType="enum"; break; case MemberType_Function: memType="function"; isFunc=TRUE; break; case MemberType_Signal: memType="signal"; isFunc=TRUE; break; case MemberType_Friend: memType="friend"; isFunc=TRUE; break; case MemberType_DCOP: memType="dcop"; isFunc=TRUE; break; case MemberType_Slot: memType="slot"; isFunc=TRUE; break; } ti << " <member refid=\"" << memberOutputFileBase(md) << "_1" << md->anchor() << "\" kind=\"" << memType << "\"><name>" << convertToXML(md->name()) << "</name></member>" << endl; QCString scopeName; if (md->getClassDef()) scopeName=md->getClassDef()->name(); else if (md->getNamespaceDef()) scopeName=md->getNamespaceDef()->name(); t << " <memberdef kind=\""; //enum { define_t,variable_t,typedef_t,enum_t,function_t } xmlType = function_t; t << memType << "\" id=\""; if (md->getGroupDef() && def->definitionType()==Definition::TypeGroup) { t << md->getGroupDef()->getOutputFileBase(); } else { t << memberOutputFileBase(md); } t << "_1" // encoded `:' character (see util.cpp:convertNameToFile) << md->anchor(); t << "\" prot=\""; switch(md->protection()) { case Public: t << "public"; break; case Protected: t << "protected"; break; case Private: t << "private"; break; case Package: t << "package"; break; } t << "\""; t << " static=\""; if (md->isStatic()) t << "yes"; else t << "no"; t << "\""; if (isFunc) { LockingPtr<ArgumentList> al = md->argumentList(); t << " const=\""; if (al!=0 && al->constSpecifier) t << "yes"; else t << "no"; t << "\""; t << " explicit=\""; if (md->isExplicit()) t << "yes"; else t << "no"; t << "\""; t << " inline=\""; if (md->isInline()) t << "yes"; else t << "no"; t << "\""; if (md->isFinal()) { t << " final=\"yes\""; } if (md->isSealed()) { t << " sealed=\"yes\""; } if (md->isNew()) { t << " new=\"yes\""; } if (md->isOptional()) { t << " optional=\"yes\""; } if (md->isRequired()) { t << " required=\"yes\""; } t << " virt=\""; switch (md->virtualness()) { case Normal: t << "non-virtual"; break; case Virtual: t << "virtual"; break; case Pure: t << "pure-virtual"; break; default: ASSERT(0); } t << "\""; } if (md->memberType() == MemberType_Variable) { //ArgumentList *al = md->argumentList(); //t << " volatile=\""; //if (al && al->volatileSpecifier) t << "yes"; else t << "no"; t << " mutable=\""; if (md->isMutable()) t << "yes"; else t << "no"; t << "\""; if (md->isInitonly()) { t << " initonly=\"yes\""; } } else if (md->memberType() == MemberType_Property) { t << " readable=\""; if (md->isReadable()) t << "yes"; else t << "no"; t << "\""; t << " writable=\""; if (md->isWritable()) t << "yes"; else t << "no"; t << "\""; t << " gettable=\""; if (md->isGettable()) t << "yes"; else t << "no"; t << "\""; t << " settable=\""; if (md->isSettable()) t << "yes"; else t << "no"; t << "\""; if (md->isAssign() || md->isCopy() || md->isRetain() || md->isStrong() || md->isWeak()) { t << " accessor=\""; if (md->isAssign()) t << "assign"; else if (md->isCopy()) t << "copy"; else if (md->isRetain()) t << "retain"; else if (md->isStrong()) t << "strong"; else if (md->isWeak()) t << "weak"; t << "\""; } } else if (md->memberType() == MemberType_Event) { t << " add=\""; if (md->isAddable()) t << "yes"; else t << "no"; t << "\""; t << " remove=\""; if (md->isRemovable()) t << "yes"; else t << "no"; t << "\""; t << " raise=\""; if (md->isRaisable()) t << "yes"; else t << "no"; t << "\""; } t << ">" << endl; if (md->memberType()!=MemberType_Define && md->memberType()!=MemberType_Enumeration ) { if (md->memberType()!=MemberType_Typedef) { writeMemberTemplateLists(md,t); } QCString typeStr = md->typeString(); //replaceAnonymousScopes(md->typeString()); stripQualifiers(typeStr); t << " <type>"; linkifyText(TextGeneratorXMLImpl(t),def,md->getBodyDef(),md,typeStr); t << "</type>" << endl; t << " <definition>" << convertToXML(md->definition()) << "</definition>" << endl; t << " <argsstring>" << convertToXML(md->argsString()) << "</argsstring>" << endl; } t << " <name>" << convertToXML(md->name()) << "</name>" << endl; if (md->memberType() == MemberType_Property) { if (md->isReadable()) t << " <read>" << convertToXML(md->getReadAccessor()) << "</read>" << endl; if (md->isWritable()) t << " <write>" << convertToXML(md->getWriteAccessor()) << "</write>" << endl; } if (md->memberType()==MemberType_Variable && md->bitfieldString()) { QCString bitfield = md->bitfieldString(); if (bitfield.at(0)==':') bitfield=bitfield.mid(1); t << " <bitfield>" << bitfield << "</bitfield>" << endl; } MemberDef *rmd = md->reimplements(); if (rmd) { t << " <reimplements refid=\"" << memberOutputFileBase(rmd) << "_1" << rmd->anchor() << "\">" << convertToXML(rmd->name()) << "</reimplements>" << endl; } LockingPtr<MemberList> rbml = md->reimplementedBy(); if (rbml!=0) { MemberListIterator mli(*rbml); for (mli.toFirst();(rmd=mli.current());++mli) { t << " <reimplementedby refid=\"" << memberOutputFileBase(rmd) << "_1" << rmd->anchor() << "\">" << convertToXML(rmd->name()) << "</reimplementedby>" << endl; } } if (isFunc) //function { LockingPtr<ArgumentList> declAl = md->declArgumentList(); LockingPtr<ArgumentList> defAl = md->argumentList(); if (declAl!=0 && declAl->count()>0) { ArgumentListIterator declAli(*declAl); ArgumentListIterator defAli(*defAl); Argument *a; for (declAli.toFirst();(a=declAli.current());++declAli) { Argument *defArg = defAli.current(); t << " <param>" << endl; if (!a->attrib.isEmpty()) { t << " <attributes>"; writeXMLString(t,a->attrib); t << "</attributes>" << endl; } if (!a->type.isEmpty()) { t << " <type>"; linkifyText(TextGeneratorXMLImpl(t),def,md->getBodyDef(),md,a->type); t << "</type>" << endl; } if (!a->name.isEmpty()) { t << " <declname>"; writeXMLString(t,a->name); t << "</declname>" << endl; } if (defArg && !defArg->name.isEmpty() && defArg->name!=a->name) { t << " <defname>"; writeXMLString(t,defArg->name); t << "</defname>" << endl; } if (!a->array.isEmpty()) { t << " <array>"; writeXMLString(t,a->array); t << "</array>" << endl; } if (!a->defval.isEmpty()) { t << " <defval>"; linkifyText(TextGeneratorXMLImpl(t),def,md->getBodyDef(),md,a->defval); t << "</defval>" << endl; } if (defArg && defArg->hasDocumentation()) { t << " <briefdescription>"; writeXMLDocBlock(t,md->getDefFileName(),md->getDefLine(), md->getOuterScope(),md,defArg->docs); t << "</briefdescription>" << endl; } t << " </param>" << endl; if (defArg) ++defAli; } } } else if (md->memberType()==MemberType_Define && md->argsString()) // define { if (md->argumentList()->count()==0) // special case for "foo()" to // disguish it from "foo". { t << " <param></param>" << endl; } else { ArgumentListIterator ali(*md->argumentList()); Argument *a; for (ali.toFirst();(a=ali.current());++ali) { t << " <param><defname>" << a->type << "</defname></param>" << endl; } } } // avoid that extremely large tables are written to the output. // todo: it's better to adhere to MAX_INITIALIZER_LINES. if (!md->initializer().isEmpty() && md->initializer().length()<2000) { t << " <initializer>"; linkifyText(TextGeneratorXMLImpl(t),def,md->getBodyDef(),md,md->initializer()); t << "</initializer>" << endl; } if (md->excpString()) { t << " <exceptions>"; linkifyText(TextGeneratorXMLImpl(t),def,md->getBodyDef(),md,md->excpString()); t << "</exceptions>" << endl; } if (md->memberType()==MemberType_Enumeration) // enum { LockingPtr<MemberList> enumFields = md->enumFieldList(); if (enumFields!=0) { MemberListIterator emli(*enumFields); MemberDef *emd; for (emli.toFirst();(emd=emli.current());++emli) { ti << " <member refid=\"" << memberOutputFileBase(emd) << "_1" << emd->anchor() << "\" kind=\"enumvalue\"><name>" << convertToXML(emd->name()) << "</name></member>" << endl; t << " <enumvalue id=\"" << memberOutputFileBase(emd) << "_1" << emd->anchor() << "\" prot=\""; switch (emd->protection()) { case Public: t << "public"; break; case Protected: t << "protected"; break; case Private: t << "private"; break; case Package: t << "package"; break; } t << "\">" << endl; t << " <name>"; writeXMLString(t,emd->name()); t << "</name>" << endl; if (!emd->initializer().isEmpty()) { t << " <initializer>"; writeXMLString(t,emd->initializer()); t << "</initializer>" << endl; } t << " <briefdescription>" << endl; writeXMLDocBlock(t,emd->briefFile(),emd->briefLine(),emd->getOuterScope(),emd,emd->briefDescription()); t << " </briefdescription>" << endl; t << " <detaileddescription>" << endl; writeXMLDocBlock(t,emd->docFile(),emd->docLine(),emd->getOuterScope(),emd,emd->documentation()); t << " </detaileddescription>" << endl; t << " </enumvalue>" << endl; } } } t << " <briefdescription>" << endl; writeXMLDocBlock(t,md->briefFile(),md->briefLine(),md->getOuterScope(),md,md->briefDescription()); t << " </briefdescription>" << endl; t << " <detaileddescription>" << endl; writeXMLDocBlock(t,md->docFile(),md->docLine(),md->getOuterScope(),md,md->documentation()); t << " </detaileddescription>" << endl; t << " <inbodydescription>" << endl; writeXMLDocBlock(t,md->docFile(),md->inbodyLine(),md->getOuterScope(),md,md->inbodyDocumentation()); t << " </inbodydescription>" << endl; if (md->getDefLine()!=-1) { t << " <location file=\"" << md->getDefFileName() << "\" line=\"" << md->getDefLine() << "\""; if (md->getStartBodyLine()!=-1) { FileDef *bodyDef = md->getBodyDef(); if (bodyDef) { t << " bodyfile=\"" << bodyDef->absFilePath() << "\""; } t << " bodystart=\"" << md->getStartBodyLine() << "\" bodyend=\"" << md->getEndBodyLine() << "\""; } t << "/>" << endl; } //printf("md->getReferencesMembers()=%p\n",md->getReferencesMembers()); LockingPtr<MemberSDict> mdict = md->getReferencesMembers(); if (mdict!=0) { MemberSDict::Iterator mdi(*mdict); MemberDef *rmd; for (mdi.toFirst();(rmd=mdi.current());++mdi) { writeMemberReference(t,def,rmd,"references"); } } mdict = md->getReferencedByMembers(); if (mdict!=0) { MemberSDict::Iterator mdi(*mdict); MemberDef *rmd; for (mdi.toFirst();(rmd=mdi.current());++mdi) { writeMemberReference(t,def,rmd,"referencedby"); } } t << " </memberdef>" << endl; } static void generateXMLSection(Definition *d,FTextStream &ti,FTextStream &t, MemberList *ml,const char *kind,const char *header=0, const char *documentation=0) { if (ml==0) return; MemberListIterator mli(*ml); MemberDef *md; int count=0; for (mli.toFirst();(md=mli.current());++mli) { // namespace members are also inserted in the file scope, but // to prevent this duplication in the XML output, we filter those here. if (d->definitionType()!=Definition::TypeFile || md->getNamespaceDef()==0) { count++; } } if (count==0) return; // empty list t << " <sectiondef kind=\"" << kind << "\">" << endl; if (header) { t << " <header>" << convertToXML(header) << "</header>" << endl; } if (documentation) { t << " <description>"; writeXMLDocBlock(t,d->docFile(),d->docLine(),d,0,documentation); t << "</description>" << endl; } for (mli.toFirst();(md=mli.current());++mli) { // namespace members are also inserted in the file scope, but // to prevent this duplication in the XML output, we filter those here. if (d->definitionType()!=Definition::TypeFile || md->getNamespaceDef()==0) { generateXMLForMember(md,ti,t,d); } } t << " </sectiondef>" << endl; } static void writeListOfAllMembers(ClassDef *cd,FTextStream &t) { t << " <listofallmembers>" << endl; if (cd->memberNameInfoSDict()) { MemberNameInfoSDict::Iterator mnii(*cd->memberNameInfoSDict()); MemberNameInfo *mni; for (mnii.toFirst();(mni=mnii.current());++mnii) { MemberNameInfoIterator mii(*mni); MemberInfo *mi; for (mii.toFirst();(mi=mii.current());++mii) { MemberDef *md=mi->memberDef; if (md->name().at(0)!='@') // skip anonymous members { Protection prot = mi->prot; Specifier virt=md->virtualness(); t << " <member refid=\"" << memberOutputFileBase(md) << "_1" << md->anchor() << "\" prot=\""; switch (prot) { case Public: t << "public"; break; case Protected: t << "protected"; break; case Private: t << "private"; break; case Package: t << "package"; break; } t << "\" virt=\""; switch(virt) { case Normal: t << "non-virtual"; break; case Virtual: t << "virtual"; break; case Pure: t << "pure-virtual"; break; } t << "\""; if (!mi->ambiguityResolutionScope.isEmpty()) { t << " ambiguityscope=\"" << convertToXML(mi->ambiguityResolutionScope) << "\""; } t << "><scope>" << convertToXML(cd->name()) << "</scope><name>" << convertToXML(md->name()) << "</name></member>" << endl; } } } } t << " </listofallmembers>" << endl; } static void writeInnerClasses(const ClassSDict *cl,FTextStream &t) { if (cl) { ClassSDict::Iterator cli(*cl); ClassDef *cd; for (cli.toFirst();(cd=cli.current());++cli) { if (!cd->isHidden() && cd->name().find('@')==-1) // skip anonymous scopes { t << " <innerclass refid=\"" << classOutputFileBase(cd) << "\" prot=\""; switch(cd->protection()) { case Public: t << "public"; break; case Protected: t << "protected"; break; case Private: t << "private"; break; case Package: t << "package"; break; } t << "\">" << convertToXML(cd->name()) << "</innerclass>" << endl; } } } } static void writeInnerNamespaces(const NamespaceSDict *nl,FTextStream &t) { if (nl) { NamespaceSDict::Iterator nli(*nl); NamespaceDef *nd; for (nli.toFirst();(nd=nli.current());++nli) { if (!nd->isHidden() && nd->name().find('@')==-1) // skip anonymouse scopes { t << " <innernamespace refid=\"" << nd->getOutputFileBase() << "\">" << convertToXML(nd->name()) << "</innernamespace>" << endl; } } } } static void writeInnerFiles(const FileList *fl,FTextStream &t) { if (fl) { QListIterator<FileDef> fli(*fl); FileDef *fd; for (fli.toFirst();(fd=fli.current());++fli) { t << " <innerfile refid=\"" << fd->getOutputFileBase() << "\">" << convertToXML(fd->name()) << "</innerfile>" << endl; } } } static void writeInnerPages(const PageSDict *pl,FTextStream &t) { if (pl) { PageSDict::Iterator pli(*pl); PageDef *pd; for (pli.toFirst();(pd=pli.current());++pli) { t << " <innerpage refid=\"" << pd->getOutputFileBase(); if (pd->getGroupDef()) { t << "_" << pd->name(); } t << "\">" << convertToXML(pd->title()) << "</innerpage>" << endl; } } } static void writeInnerGroups(const GroupList *gl,FTextStream &t) { if (gl) { GroupListIterator gli(*gl); GroupDef *sgd; for (gli.toFirst();(sgd=gli.current());++gli) { t << " <innergroup refid=\"" << sgd->getOutputFileBase() << "\">" << convertToXML(sgd->groupTitle()) << "</innergroup>" << endl; } } } static void writeInnerDirs(const DirList *dl,FTextStream &t) { if (dl) { QListIterator<DirDef> subdirs(*dl); DirDef *subdir; for (subdirs.toFirst();(subdir=subdirs.current());++subdirs) { t << " <innerdir refid=\"" << subdir->getOutputFileBase() << "\">" << convertToXML(subdir->displayName()) << "</innerdir>" << endl; } } } static void generateXMLForClass(ClassDef *cd,FTextStream &ti) { // + brief description // + detailed description // + template argument list(s) // - include file // + member groups // + inheritance diagram // + list of direct super classes // + list of direct sub classes // + list of inner classes // + collaboration diagram // + list of all members // + user defined member sections // + standard member sections // + detailed member documentation // - examples using the class if (cd->isReference()) return; // skip external references. if (cd->isHidden()) return; // skip hidden classes. if (cd->name().find('@')!=-1) return; // skip anonymous compounds. if (cd->templateMaster()!=0) return; // skip generated template instances. if (cd->isArtificial()) return; // skip artificially created classes msg("Generating XML output for class %s\n",cd->name().data()); ti << " <compound refid=\"" << classOutputFileBase(cd) << "\" kind=\"" << cd->compoundTypeString() << "\"><name>" << convertToXML(cd->name()) << "</name>" << endl; QCString outputDirectory = Config_getString("XML_OUTPUT"); QCString fileName=outputDirectory+"/"+ classOutputFileBase(cd)+".xml"; QFile f(fileName); if (!f.open(IO_WriteOnly)) { err("Cannot open file %s for writing!\n",fileName.data()); return; } FTextStream t(&f); //t.setEncoding(FTextStream::UnicodeUTF8); writeXMLHeader(t); t << " <compounddef id=\"" << classOutputFileBase(cd) << "\" kind=\"" << cd->compoundTypeString() << "\" prot=\""; switch (cd->protection()) { case Public: t << "public"; break; case Protected: t << "protected"; break; case Private: t << "private"; break; case Package: t << "package"; break; } if (cd->isFinal()) t << "\" final=\"yes"; if (cd->isSealed()) t << "\" sealed=\"yes"; if (cd->isAbstract()) t << "\" abstract=\"yes"; t << "\">" << endl; t << " <compoundname>"; writeXMLString(t,cd->name()); t << "</compoundname>" << endl; if (cd->baseClasses()) { BaseClassListIterator bcli(*cd->baseClasses()); BaseClassDef *bcd; for (bcli.toFirst();(bcd=bcli.current());++bcli) { t << " <basecompoundref "; if (bcd->classDef->isLinkable()) { t << "refid=\"" << classOutputFileBase(bcd->classDef) << "\" "; } t << "prot=\""; switch (bcd->prot) { case Public: t << "public"; break; case Protected: t << "protected"; break; case Private: t << "private"; break; case Package: ASSERT(0); break; } t << "\" virt=\""; switch(bcd->virt) { case Normal: t << "non-virtual"; break; case Virtual: t << "virtual"; break; case Pure: t <<"pure-virtual"; break; } t << "\">"; if (!bcd->templSpecifiers.isEmpty()) { t << convertToXML( insertTemplateSpecifierInScope( bcd->classDef->name(),bcd->templSpecifiers) ); } else { t << convertToXML(bcd->classDef->displayName()); } t << "</basecompoundref>" << endl; } } if (cd->subClasses()) { BaseClassListIterator bcli(*cd->subClasses()); BaseClassDef *bcd; for (bcli.toFirst();(bcd=bcli.current());++bcli) { t << " <derivedcompoundref refid=\"" << classOutputFileBase(bcd->classDef) << "\" prot=\""; switch (bcd->prot) { case Public: t << "public"; break; case Protected: t << "protected"; break; case Private: t << "private"; break; case Package: ASSERT(0); break; } t << "\" virt=\""; switch(bcd->virt) { case Normal: t << "non-virtual"; break; case Virtual: t << "virtual"; break; case Pure: t << "pure-virtual"; break; } t << "\">" << convertToXML(bcd->classDef->displayName()) << "</derivedcompoundref>" << endl; } } IncludeInfo *ii=cd->includeInfo(); if (ii) { QCString nm = ii->includeName; if (nm.isEmpty() && ii->fileDef) nm = ii->fileDef->docName(); if (!nm.isEmpty()) { t << " <includes"; if (ii->fileDef && !ii->fileDef->isReference()) // TODO: support external references { t << " refid=\"" << ii->fileDef->getOutputFileBase() << "\""; } t << " local=\"" << (ii->local ? "yes" : "no") << "\">"; t << nm; t << "</includes>" << endl; } } writeInnerClasses(cd->getClassSDict(),t); writeTemplateList(cd,t); if (cd->getMemberGroupSDict()) { MemberGroupSDict::Iterator mgli(*cd->getMemberGroupSDict()); MemberGroup *mg; for (;(mg=mgli.current());++mgli) { generateXMLSection(cd,ti,t,mg->members(),"user-defined",mg->header(), mg->documentation()); } } QListIterator<MemberList> mli(cd->getMemberLists()); MemberList *ml; for (mli.toFirst();(ml=mli.current());++mli) { if ((ml->listType()&MemberListType_detailedLists)==0) { generateXMLSection(cd,ti,t,ml,g_xmlSectionMapper.find(ml->listType())); } } #if 0 generateXMLSection(cd,ti,t,cd->pubTypes,"public-type"); generateXMLSection(cd,ti,t,cd->pubMethods,"public-func"); generateXMLSection(cd,ti,t,cd->pubAttribs,"public-attrib"); generateXMLSection(cd,ti,t,cd->pubSlots,"public-slot"); generateXMLSection(cd,ti,t,cd->signals,"signal"); generateXMLSection(cd,ti,t,cd->dcopMethods,"dcop-func"); generateXMLSection(cd,ti,t,cd->properties,"property"); generateXMLSection(cd,ti,t,cd->events,"event"); generateXMLSection(cd,ti,t,cd->pubStaticMethods,"public-static-func"); generateXMLSection(cd,ti,t,cd->pubStaticAttribs,"public-static-attrib"); generateXMLSection(cd,ti,t,cd->proTypes,"protected-type"); generateXMLSection(cd,ti,t,cd->proMethods,"protected-func"); generateXMLSection(cd,ti,t,cd->proAttribs,"protected-attrib"); generateXMLSection(cd,ti,t,cd->proSlots,"protected-slot"); generateXMLSection(cd,ti,t,cd->proStaticMethods,"protected-static-func"); generateXMLSection(cd,ti,t,cd->proStaticAttribs,"protected-static-attrib"); generateXMLSection(cd,ti,t,cd->pacTypes,"package-type"); generateXMLSection(cd,ti,t,cd->pacMethods,"package-func"); generateXMLSection(cd,ti,t,cd->pacAttribs,"package-attrib"); generateXMLSection(cd,ti,t,cd->pacStaticMethods,"package-static-func"); generateXMLSection(cd,ti,t,cd->pacStaticAttribs,"package-static-attrib"); generateXMLSection(cd,ti,t,cd->priTypes,"private-type"); generateXMLSection(cd,ti,t,cd->priMethods,"private-func"); generateXMLSection(cd,ti,t,cd->priAttribs,"private-attrib"); generateXMLSection(cd,ti,t,cd->priSlots,"private-slot"); generateXMLSection(cd,ti,t,cd->priStaticMethods,"private-static-func"); generateXMLSection(cd,ti,t,cd->priStaticAttribs,"private-static-attrib"); generateXMLSection(cd,ti,t,cd->friends,"friend"); generateXMLSection(cd,ti,t,cd->related,"related"); #endif t << " <briefdescription>" << endl; writeXMLDocBlock(t,cd->briefFile(),cd->briefLine(),cd,0,cd->briefDescription()); t << " </briefdescription>" << endl; t << " <detaileddescription>" << endl; writeXMLDocBlock(t,cd->docFile(),cd->docLine(),cd,0,cd->documentation()); t << " </detaileddescription>" << endl; DotClassGraph inheritanceGraph(cd,DotNode::Inheritance); if (!inheritanceGraph.isTrivial()) { t << " <inheritancegraph>" << endl; inheritanceGraph.writeXML(t); t << " </inheritancegraph>" << endl; } DotClassGraph collaborationGraph(cd,DotNode::Collaboration); if (!collaborationGraph.isTrivial()) { t << " <collaborationgraph>" << endl; collaborationGraph.writeXML(t); t << " </collaborationgraph>" << endl; } t << " <location file=\"" << cd->getDefFileName() << "\" line=\"" << cd->getDefLine() << "\""; if (cd->getStartBodyLine()!=-1) { FileDef *bodyDef = cd->getBodyDef(); if (bodyDef) { t << " bodyfile=\"" << bodyDef->absFilePath() << "\""; } t << " bodystart=\"" << cd->getStartBodyLine() << "\" bodyend=\"" << cd->getEndBodyLine() << "\""; } t << "/>" << endl; writeListOfAllMembers(cd,t); t << " </compounddef>" << endl; t << "</doxygen>" << endl; ti << " </compound>" << endl; } static void generateXMLForNamespace(NamespaceDef *nd,FTextStream &ti) { // + contained class definitions // + contained namespace definitions // + member groups // + normal members // + brief desc // + detailed desc // + location // - files containing (parts of) the namespace definition if (nd->isReference() || nd->isHidden()) return; // skip external references ti << " <compound refid=\"" << nd->getOutputFileBase() << "\" kind=\"namespace\"" << "><name>" << convertToXML(nd->name()) << "</name>" << endl; QCString outputDirectory = Config_getString("XML_OUTPUT"); QCString fileName=outputDirectory+"/"+nd->getOutputFileBase()+".xml"; QFile f(fileName); if (!f.open(IO_WriteOnly)) { err("Cannot open file %s for writing!\n",fileName.data()); return; } FTextStream t(&f); //t.setEncoding(FTextStream::UnicodeUTF8); writeXMLHeader(t); t << " <compounddef id=\"" << nd->getOutputFileBase() << "\" kind=\"namespace\">" << endl; t << " <compoundname>"; writeXMLString(t,nd->name()); t << "</compoundname>" << endl; writeInnerClasses(nd->getClassSDict(),t); writeInnerNamespaces(nd->getNamespaceSDict(),t); if (nd->getMemberGroupSDict()) { MemberGroupSDict::Iterator mgli(*nd->getMemberGroupSDict()); MemberGroup *mg; for (;(mg=mgli.current());++mgli) { generateXMLSection(nd,ti,t,mg->members(),"user-defined",mg->header(), mg->documentation()); } } QListIterator<MemberList> mli(nd->getMemberLists()); MemberList *ml; for (mli.toFirst();(ml=mli.current());++mli) { if ((ml->listType()&MemberListType_declarationLists)!=0) { generateXMLSection(nd,ti,t,ml,g_xmlSectionMapper.find(ml->listType())); } } #if 0 generateXMLSection(nd,ti,t,&nd->decDefineMembers,"define"); generateXMLSection(nd,ti,t,&nd->decProtoMembers,"prototype"); generateXMLSection(nd,ti,t,&nd->decTypedefMembers,"typedef"); generateXMLSection(nd,ti,t,&nd->decEnumMembers,"enum"); generateXMLSection(nd,ti,t,&nd->decFuncMembers,"func"); generateXMLSection(nd,ti,t,&nd->decVarMembers,"var"); #endif t << " <briefdescription>" << endl; writeXMLDocBlock(t,nd->briefFile(),nd->briefLine(),nd,0,nd->briefDescription()); t << " </briefdescription>" << endl; t << " <detaileddescription>" << endl; writeXMLDocBlock(t,nd->docFile(),nd->docLine(),nd,0,nd->documentation()); t << " </detaileddescription>" << endl; t << " <location file=\"" << nd->getDefFileName() << "\" line=\"" << nd->getDefLine() << "\"/>" << endl; t << " </compounddef>" << endl; t << "</doxygen>" << endl; ti << " </compound>" << endl; } static void generateXMLForFile(FileDef *fd,FTextStream &ti) { // + includes files // + includedby files // + include graph // + included by graph // + contained class definitions // + contained namespace definitions // + member groups // + normal members // + brief desc // + detailed desc // + source code // + location // - number of lines if (fd->isReference()) return; // skip external references ti << " <compound refid=\"" << fd->getOutputFileBase() << "\" kind=\"file\"><name>" << convertToXML(fd->name()) << "</name>" << endl; QCString outputDirectory = Config_getString("XML_OUTPUT"); QCString fileName=outputDirectory+"/"+fd->getOutputFileBase()+".xml"; QFile f(fileName); if (!f.open(IO_WriteOnly)) { err("Cannot open file %s for writing!\n",fileName.data()); return; } FTextStream t(&f); //t.setEncoding(FTextStream::UnicodeUTF8); writeXMLHeader(t); t << " <compounddef id=\"" << fd->getOutputFileBase() << "\" kind=\"file\">" << endl; t << " <compoundname>"; writeXMLString(t,fd->name()); t << "</compoundname>" << endl; IncludeInfo *inc; if (fd->includeFileList()) { QListIterator<IncludeInfo> ili1(*fd->includeFileList()); for (ili1.toFirst();(inc=ili1.current());++ili1) { t << " <includes"; if (inc->fileDef && !inc->fileDef->isReference()) // TODO: support external references { t << " refid=\"" << inc->fileDef->getOutputFileBase() << "\""; } t << " local=\"" << (inc->local ? "yes" : "no") << "\">"; t << inc->includeName; t << "</includes>" << endl; } } if (fd->includedByFileList()) { QListIterator<IncludeInfo> ili2(*fd->includedByFileList()); for (ili2.toFirst();(inc=ili2.current());++ili2) { t << " <includedby"; if (inc->fileDef && !inc->fileDef->isReference()) // TODO: support external references { t << " refid=\"" << inc->fileDef->getOutputFileBase() << "\""; } t << " local=\"" << (inc->local ? "yes" : "no") << "\">"; t << inc->includeName; t << "</includedby>" << endl; } } DotInclDepGraph incDepGraph(fd,FALSE); if (!incDepGraph.isTrivial()) { t << " <incdepgraph>" << endl; incDepGraph.writeXML(t); t << " </incdepgraph>" << endl; } DotInclDepGraph invIncDepGraph(fd,TRUE); if (!invIncDepGraph.isTrivial()) { t << " <invincdepgraph>" << endl; invIncDepGraph.writeXML(t); t << " </invincdepgraph>" << endl; } if (fd->getClassSDict()) { writeInnerClasses(fd->getClassSDict(),t); } if (fd->getNamespaceSDict()) { writeInnerNamespaces(fd->getNamespaceSDict(),t); } if (fd->getMemberGroupSDict()) { MemberGroupSDict::Iterator mgli(*fd->getMemberGroupSDict()); MemberGroup *mg; for (;(mg=mgli.current());++mgli) { generateXMLSection(fd,ti,t,mg->members(),"user-defined",mg->header(), mg->documentation()); } } QListIterator<MemberList> mli(fd->getMemberLists()); MemberList *ml; for (mli.toFirst();(ml=mli.current());++mli) { if ((ml->listType()&MemberListType_declarationLists)!=0) { generateXMLSection(fd,ti,t,ml,g_xmlSectionMapper.find(ml->listType())); } } #if 0 generateXMLSection(fd,ti,t,fd->decDefineMembers,"define"); generateXMLSection(fd,ti,t,fd->decProtoMembers,"prototype"); generateXMLSection(fd,ti,t,fd->decTypedefMembers,"typedef"); generateXMLSection(fd,ti,t,fd->decEnumMembers,"enum"); generateXMLSection(fd,ti,t,fd->decFuncMembers,"func"); generateXMLSection(fd,ti,t,fd->decVarMembers,"var"); #endif t << " <briefdescription>" << endl; writeXMLDocBlock(t,fd->briefFile(),fd->briefLine(),fd,0,fd->briefDescription()); t << " </briefdescription>" << endl; t << " <detaileddescription>" << endl; writeXMLDocBlock(t,fd->docFile(),fd->docLine(),fd,0,fd->documentation()); t << " </detaileddescription>" << endl; if (Config_getBool("XML_PROGRAMLISTING")) { t << " <programlisting>" << endl; writeXMLCodeBlock(t,fd); t << " </programlisting>" << endl; } t << " <location file=\"" << fd->getDefFileName() << "\"/>" << endl; t << " </compounddef>" << endl; t << "</doxygen>" << endl; ti << " </compound>" << endl; } static void generateXMLForGroup(GroupDef *gd,FTextStream &ti) { // + members // + member groups // + files // + classes // + namespaces // - packages // + pages // + child groups // - examples // + brief description // + detailed description if (gd->isReference()) return; // skip external references ti << " <compound refid=\"" << gd->getOutputFileBase() << "\" kind=\"group\"><name>" << convertToXML(gd->name()) << "</name>" << endl; QCString outputDirectory = Config_getString("XML_OUTPUT"); QCString fileName=outputDirectory+"/"+gd->getOutputFileBase()+".xml"; QFile f(fileName); if (!f.open(IO_WriteOnly)) { err("Cannot open file %s for writing!\n",fileName.data()); return; } FTextStream t(&f); //t.setEncoding(FTextStream::UnicodeUTF8); writeXMLHeader(t); t << " <compounddef id=\"" << gd->getOutputFileBase() << "\" kind=\"group\">" << endl; t << " <compoundname>" << convertToXML(gd->name()) << "</compoundname>" << endl; t << " <title>" << convertToXML(gd->groupTitle()) << "</title>" << endl; writeInnerFiles(gd->getFiles(),t); writeInnerClasses(gd->getClasses(),t); writeInnerNamespaces(gd->getNamespaces(),t); writeInnerPages(gd->getPages(),t); writeInnerGroups(gd->getSubGroups(),t); if (gd->getMemberGroupSDict()) { MemberGroupSDict::Iterator mgli(*gd->getMemberGroupSDict()); MemberGroup *mg; for (;(mg=mgli.current());++mgli) { generateXMLSection(gd,ti,t,mg->members(),"user-defined",mg->header(), mg->documentation()); } } QListIterator<MemberList> mli(gd->getMemberLists()); MemberList *ml; for (mli.toFirst();(ml=mli.current());++mli) { if ((ml->listType()&MemberListType_declarationLists)!=0) { generateXMLSection(gd,ti,t,ml,g_xmlSectionMapper.find(ml->listType())); } } #if 0 generateXMLSection(gd,ti,t,&gd->decDefineMembers,"define"); generateXMLSection(gd,ti,t,&gd->decProtoMembers,"prototype"); generateXMLSection(gd,ti,t,&gd->decTypedefMembers,"typedef"); generateXMLSection(gd,ti,t,&gd->decEnumMembers,"enum"); generateXMLSection(gd,ti,t,&gd->decFuncMembers,"func"); generateXMLSection(gd,ti,t,&gd->decVarMembers,"var"); #endif t << " <briefdescription>" << endl; writeXMLDocBlock(t,gd->briefFile(),gd->briefLine(),gd,0,gd->briefDescription()); t << " </briefdescription>" << endl; t << " <detaileddescription>" << endl; writeXMLDocBlock(t,gd->docFile(),gd->docLine(),gd,0,gd->documentation()); t << " </detaileddescription>" << endl; t << " </compounddef>" << endl; t << "</doxygen>" << endl; ti << " </compound>" << endl; } static void generateXMLForDir(DirDef *dd,FTextStream &ti) { if (dd->isReference()) return; // skip external references ti << " <compound refid=\"" << dd->getOutputFileBase() << "\" kind=\"dir\"><name>" << convertToXML(dd->displayName()) << "</name>" << endl; QCString outputDirectory = Config_getString("XML_OUTPUT"); QCString fileName=outputDirectory+"/"+dd->getOutputFileBase()+".xml"; QFile f(fileName); if (!f.open(IO_WriteOnly)) { err("Cannot open file %s for writing!\n",fileName.data()); return; } FTextStream t(&f); //t.setEncoding(FTextStream::UnicodeUTF8); writeXMLHeader(t); t << " <compounddef id=\"" << dd->getOutputFileBase() << "\" kind=\"dir\">" << endl; t << " <compoundname>" << convertToXML(dd->displayName()) << "</compoundname>" << endl; writeInnerDirs(&dd->subDirs(),t); writeInnerFiles(dd->getFiles(),t); t << " <briefdescription>" << endl; writeXMLDocBlock(t,dd->briefFile(),dd->briefLine(),dd,0,dd->briefDescription()); t << " </briefdescription>" << endl; t << " <detaileddescription>" << endl; writeXMLDocBlock(t,dd->docFile(),dd->docLine(),dd,0,dd->documentation()); t << " </detaileddescription>" << endl; t << " <location file=\"" << dd->name() << "\"/>" << endl; t << " </compounddef>" << endl; t << "</doxygen>" << endl; ti << " </compound>" << endl; } static void generateXMLForPage(PageDef *pd,FTextStream &ti,bool isExample) { // + name // + title // + documentation const char *kindName = isExample ? "example" : "page"; if (pd->isReference()) return; QCString pageName = pd->getOutputFileBase(); if (pd->getGroupDef()) { pageName+=(QCString)"_"+pd->name(); } if (pageName=="index") pageName="indexpage"; // to prevent overwriting the generated index page. ti << " <compound refid=\"" << pageName << "\" kind=\"" << kindName << "\"><name>" << convertToXML(pd->name()) << "</name>" << endl; QCString outputDirectory = Config_getString("XML_OUTPUT"); QCString fileName=outputDirectory+"/"+pageName+".xml"; QFile f(fileName); if (!f.open(IO_WriteOnly)) { err("Cannot open file %s for writing!\n",fileName.data()); return; } FTextStream t(&f); //t.setEncoding(FTextStream::UnicodeUTF8); writeXMLHeader(t); t << " <compounddef id=\"" << pageName; t << "\" kind=\"" << kindName << "\">" << endl; t << " <compoundname>" << convertToXML(pd->name()) << "</compoundname>" << endl; if (pd==Doxygen::mainPage) // main page is special { QCString title; if (!pd->title().isEmpty() && pd->title().lower()!="notitle") { title = filterTitle(Doxygen::mainPage->title()); } else { title = Config_getString("PROJECT_NAME"); } t << " <title>" << convertToXML(title) << "</title>" << endl; } else { SectionInfo *si = Doxygen::sectionDict->find(pd->name()); if (si) { t << " <title>" << convertToXML(si->title) << "</title>" << endl; } } writeInnerPages(pd->getSubPages(),t); t << " <detaileddescription>" << endl; if (isExample) { writeXMLDocBlock(t,pd->docFile(),pd->docLine(),pd,0, pd->documentation()+"\n\\include "+pd->name()); } else { writeXMLDocBlock(t,pd->docFile(),pd->docLine(),pd,0, pd->documentation()); } t << " </detaileddescription>" << endl; t << " </compounddef>" << endl; t << "</doxygen>" << endl; ti << " </compound>" << endl; } void generateXML() { // + classes // + namespaces // + files // + groups // + related pages // - examples QCString outputDirectory = Config_getString("XML_OUTPUT"); if (outputDirectory.isEmpty()) { outputDirectory=QDir::currentDirPath().utf8(); } else { QDir dir(outputDirectory); if (!dir.exists()) { dir.setPath(QDir::currentDirPath()); if (!dir.mkdir(outputDirectory)) { err("error: tag XML_OUTPUT: Output directory `%s' does not " "exist and cannot be created\n",outputDirectory.data()); exit(1); } else if (!Config_getBool("QUIET")) { err("notice: Output directory `%s' does not exist. " "I have created it for you.\n", outputDirectory.data()); } dir.cd(outputDirectory); } outputDirectory=dir.absPath().utf8(); } QDir dir(outputDirectory); if (!dir.exists()) { dir.setPath(QDir::currentDirPath()); if (!dir.mkdir(outputDirectory)) { err("Cannot create directory %s\n",outputDirectory.data()); return; } } QDir xmlDir(outputDirectory); createSubDirs(xmlDir); QCString fileName=outputDirectory+"/index.xsd"; QFile f(fileName); if (!f.open(IO_WriteOnly)) { err("Cannot open file %s for writing!\n",fileName.data()); return; } f.writeBlock(index_xsd,qstrlen(index_xsd)); f.close(); fileName=outputDirectory+"/compound.xsd"; f.setName(fileName); if (!f.open(IO_WriteOnly)) { err("Cannot open file %s for writing!\n",fileName.data()); return; } f.writeBlock(compound_xsd,qstrlen(compound_xsd)); f.close(); fileName=outputDirectory+"/index.xml"; f.setName(fileName); if (!f.open(IO_WriteOnly)) { err("Cannot open file %s for writing!\n",fileName.data()); return; } FTextStream t(&f); //t.setEncoding(FTextStream::UnicodeUTF8); // write index header t << "<?xml version='1.0' encoding='UTF-8' standalone='no'?>" << endl;; t << "<doxygenindex xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" "; t << "xsi:noNamespaceSchemaLocation=\"index.xsd\" "; t << "version=\"" << versionString << "\">" << endl; { ClassSDict::Iterator cli(*Doxygen::classSDict); ClassDef *cd; for (cli.toFirst();(cd=cli.current());++cli) { generateXMLForClass(cd,t); } } //{ // ClassSDict::Iterator cli(Doxygen::hiddenClasses); // ClassDef *cd; // for (cli.toFirst();(cd=cli.current());++cli) // { // msg("Generating XML output for class %s\n",cd->name().data()); // generateXMLForClass(cd,t); // } //} NamespaceSDict::Iterator nli(*Doxygen::namespaceSDict); NamespaceDef *nd; for (nli.toFirst();(nd=nli.current());++nli) { msg("Generating XML output for namespace %s\n",nd->name().data()); generateXMLForNamespace(nd,t); } FileNameListIterator fnli(*Doxygen::inputNameList); FileName *fn; for (;(fn=fnli.current());++fnli) { FileNameIterator fni(*fn); FileDef *fd; for (;(fd=fni.current());++fni) { msg("Generating XML output for file %s\n",fd->name().data()); generateXMLForFile(fd,t); } } GroupSDict::Iterator gli(*Doxygen::groupSDict); GroupDef *gd; for (;(gd=gli.current());++gli) { msg("Generating XML output for group %s\n",gd->name().data()); generateXMLForGroup(gd,t); } { PageSDict::Iterator pdi(*Doxygen::pageSDict); PageDef *pd=0; for (pdi.toFirst();(pd=pdi.current());++pdi) { msg("Generating XML output for page %s\n",pd->name().data()); generateXMLForPage(pd,t,FALSE); } } { DirDef *dir; DirSDict::Iterator sdi(*Doxygen::directories); for (sdi.toFirst();(dir=sdi.current());++sdi) { msg("Generate XML output for dir %s\n",dir->name().data()); generateXMLForDir(dir,t); } } { PageSDict::Iterator pdi(*Doxygen::exampleSDict); PageDef *pd=0; for (pdi.toFirst();(pd=pdi.current());++pdi) { msg("Generating XML output for example %s\n",pd->name().data()); generateXMLForPage(pd,t,TRUE); } } if (Doxygen::mainPage) { msg("Generating XML output for the main page\n"); generateXMLForPage(Doxygen::mainPage,t,FALSE); } //t << " </compoundlist>" << endl; t << "</doxygenindex>" << endl; writeCombineScript(); }
bo0ts/doxygen-fixes
src/xmlgen.cpp
C++
gpl-2.0
62,426
<?php /** * @package hubzero-cms * @copyright Copyright (c) 2005-2020 The Regents of the University of California. * @license http://opensource.org/licenses/MIT MIT */ namespace Components\Events\Api; use Hubzero\Component\Router\Base; /** * Routing class for the component */ class Router extends Base { /** * Build the route for the component. * * @param array &$query An array of URL arguments * @return array The URL arguments to use to assemble the subsequent URL. */ public function build(&$query) { $segments = array(); if (!empty($query['controller'])) { $segments[] = $query['controller']; unset($query['controller']); } if (!empty($query['task'])) { $segments[] = $query['task']; unset($query['task']); } return $segments; } /** * Parse the segments of a URL. * * @param array &$segments The segments of the URL to parse. * @return array The URL attributes to be used by the application. */ public function parse(&$segments) { $vars = array(); $vars['controller'] = 'events'; if (isset($segments[0])) { if (is_numeric($segments[0])) { $vars['id'] = $segments[0]; if (\App::get('request')->method() == 'GET') { $vars['task'] = 'read'; } } else { $vars['task'] = $segments[0]; } } return $vars; } }
hubzero/hubzero-cms
core/components/com_events/api/router.php
PHP
gpl-2.0
1,353
@echo off SETLOCAL REM http://dev.exiv2.org/projects/exiv2/repository/ SET EXIV2_COMMIT=3364 REM http://sourceforge.net/p/libjpeg-turbo/code/ SET LIBJPEG_COMMIT=1093 rem error 1406 rem https://github.com/madler/zlib/commits SET ZLIB_COMMIT_LONG=50893291621658f355bc5b4d450a8d06a563053d rem https://github.com/openexr/openexr SET OPENEXR_COMMIT_LONG=91015147e5a6a1914bcb16b12886aede9e1ed065 SET OPENEXR_CMAKE_VERSION=2.2 rem http://www.boost.org/ SET BOOST_MINOR=55 REM ftp://ftp.fftw.org/pub/fftw/ SET FFTW_VER=3.3.4 rem https://github.com/mm2/Little-CMS SET LCMS_COMMIT_LONG=d61231a1efb9eb926cbf0235afe03452302c6009 rem https://github.com/LibRaw/LibRaw SET LIBRAW_COMMIT_LONG=32e21b28e24b6cecdae8813b5ef9c103b8a8ccf0 SET LIBRAW_DEMOS2_COMMIT_LONG=ffea825e121e92aa780ae587b65f80fc5847637c SET LIBRAW_DEMOS3_COMMIT_LONG=f0895891fdaa775255af02275fce426a5bf5c9fc rem ftp://sourceware.org/pub/pthreads-win32/ SET PTHREADS_DIR=prebuilt-dll-2-9-1-release rem http://heasarc.gsfc.nasa.gov/FTP/software/fitsio/c SET CFITSIO_VER=3360 rem broken 3370 rem Internal version number for http://qtpfsgui.sourceforge.net/win/hugin-* SET HUGIN_VER=201300 IF EXIST .settings\vsexpress.txt ( SET VSCOMMAND=vcexpress ) ELSE IF EXIST .settings\devent.txt ( SET VSCOMMAND=devenv ) ELSE ( vcexpress XXXXXXXXXXXXX 2>NUL >NUL IF ERRORLEVEL 1 ( devenv /? 2>NUL >NUL IF ERRORLEVEL 1 ( echo. echo.ERROR: This file must be run inside a VS command prompt! echo. goto error_end ) ELSE ( SET VSCOMMAND=devenv ) ) ELSE ( SET VSCOMMAND=vcexpress ) mkdir .settings 2>NUL >NUL echo x>.settings\%VSCOMMAND%.txt ) IF EXIST ..\msvc ( echo. echo.ERROR: This file should NOT be executed within the LuminanceHDR source directory, echo. but in a new empty folder! echo. goto error_end ) ml64.exe > NUL IF ERRORLEVEL 1 ( set Platform=Win32 set RawPlatform=x86 set CpuPlatform=ia32 ) ELSE ( set Platform=x64 set RawPlatform=x64 set CpuPlatform=intel64 ) SET VISUAL_STUDIO_VC_REDIST=%VCINSTALLDIR%\redist\%RawPlatform% IF DEFINED VS110COMNTOOLS ( REM Visual Studio 2012 set VS_SHORT=vc11 set VS_CMAKE=Visual Studio 11 set VS_PROG_FILES=Microsoft Visual Studio 11.0 ) ELSE IF DEFINED VS100COMNTOOLS ( REM Visual Studio 2010 set VS_SHORT=vc10 set VS_CMAKE=Visual Studio 10 set VS_PROG_FILES=Microsoft Visual Studio 10.0 ) ELSE ( REM Visual Studio 2008 set VS_SHORT=vc9 set VS_CMAKE=Visual Studio 9 2008 set VS_PROG_FILES=Microsoft Visual Studio 9.0 ) IF %Platform% EQU x64 ( set VS_CMAKE=%VS_CMAKE% Win64 ) call setenv.cmd IF NOT EXIST %CMAKE_DIR%\bin\cmake.exe ( echo. echo.ERROR: CMake not found: %CMAKE_DIR%\bin\cmake.exe echo. goto error_end ) IF NOT EXIST %CYGWIN_DIR%\bin\cp.exe GOTO cygwin_error IF NOT EXIST %CYGWIN_DIR%\bin\cvs.exe GOTO cygwin_error IF NOT EXIST %CYGWIN_DIR%\bin\git.exe GOTO cygwin_error IF NOT EXIST %CYGWIN_DIR%\bin\gzip.exe GOTO cygwin_error IF NOT EXIST %CYGWIN_DIR%\bin\mv.exe GOTO cygwin_error IF NOT EXIST %CYGWIN_DIR%\bin\nasm.exe GOTO cygwin_error IF NOT EXIST %CYGWIN_DIR%\bin\sed.exe GOTO cygwin_error IF NOT EXIST %CYGWIN_DIR%\bin\ssh.exe GOTO cygwin_error IF NOT EXIST %CYGWIN_DIR%\bin\svn.exe GOTO cygwin_error IF NOT EXIST %CYGWIN_DIR%\bin\tar.exe GOTO cygwin_error IF NOT EXIST %CYGWIN_DIR%\bin\unzip.exe GOTO cygwin_error IF NOT EXIST %CYGWIN_DIR%\bin\wget.exe GOTO cygwin_error GOTO cygwin_ok :cygwin_error echo ERROR: Cygwin with echo cp echo cvs echo git echo gzip echo mv echo nasm echo sed echo ssh echo svn echo tar echo unzip echo wget echo is required GOTO error_end :cygwin_ok IF NOT DEFINED Configuration ( set Configuration=Release ) IF NOT DEFINED ConfigurationLuminance ( set ConfigurationLuminance=RelWithDebInfo ) cls echo. echo.--- %VS_CMAKE% --- echo.Configuration = %Configuration% echo.ConfigurationLuminance = %ConfigurationLuminance% echo.Platform = %Platform% (%RawPlatform%) echo. IF NOT EXIST %TEMP_DIR% ( mkdir %TEMP_DIR% ) IF NOT EXIST vcDlls ( mkdir vcDlls robocopy "%vcinstalldir%redist\%RawPlatform%" vcDlls /MIR >nul ) IF NOT EXIST vcDlls\selected ( mkdir vcDlls\selected %CYGWIN_DIR%\bin\cp.exe vcDlls/**/vcomp* vcDlls/selected %CYGWIN_DIR%\bin\cp.exe vcDlls/**/msv* vcDlls/selected ) IF NOT EXIST %TEMP_DIR%\hugin-%HUGIN_VER%-%RawPlatform%.zip ( %CYGWIN_DIR%\bin\wget.exe -O %TEMP_DIR%/hugin-%HUGIN_VER%-%RawPlatform%.zip qtpfsgui.sourceforge.net/win/hugin-%HUGIN_VER%-%RawPlatform%.zip ) IF NOT EXIST hugin-%HUGIN_VER%-%RawPlatform% ( %CYGWIN_DIR%\bin\unzip.exe -o -q -d hugin-%HUGIN_VER%-%RawPlatform% %TEMP_DIR%\hugin-%HUGIN_VER%-%RawPlatform%.zip ) SET ZLIB_COMMIT=%ZLIB_COMMIT_LONG:~0,7% IF NOT EXIST %TEMP_DIR%\zlib-%ZLIB_COMMIT%.zip ( %CYGWIN_DIR%\bin\wget.exe -O %TEMP_DIR%/zlib-%ZLIB_COMMIT%.zip --no-check-certificate http://github.com/madler/zlib/zipball/%ZLIB_COMMIT_LONG% ) IF NOT EXIST zlib-%ZLIB_COMMIT% ( %CYGWIN_DIR%\bin\unzip.exe -q %TEMP_DIR%/zlib-%ZLIB_COMMIT%.zip %CYGWIN_DIR%\bin\mv.exe madler-zlib-* zlib-%ZLIB_COMMIT% REM zlib must be compiled in the source folder, else exiv2 compilation REM fails due to zconf.h rename/compile problems, due to cmake pushd zlib-%ZLIB_COMMIT% %CMAKE_DIR%\bin\cmake.exe -G "%VS_CMAKE%" IF errorlevel 1 goto error_end %VSCOMMAND% zlib.sln /build "%Configuration%|%Platform%" /Project zlib IF errorlevel 1 goto error_end popd ) IF NOT EXIST %TEMP_DIR%\lpng170b35.zip ( %CYGWIN_DIR%\bin\wget.exe -O %TEMP_DIR%/lpng170b35.zip http://sourceforge.net/projects/libpng/files/libpng17/1.7.0beta35/lp170b35.zip/download IF errorlevel 1 goto error_end ) IF NOT EXIST lp170b35 ( %CYGWIN_DIR%\bin\unzip.exe -q %TEMP_DIR%/lpng170b35.zip pushd lp170b35 %CMAKE_DIR%\bin\cmake.exe -G "%VS_CMAKE%" . -DZLIB_ROOT=..\zlib-%ZLIB_COMMIT%;..\zlib-%ZLIB_COMMIT%\%Configuration% IF errorlevel 1 goto error_end %VSCOMMAND% libpng.sln /build "%Configuration%|%Platform%" /Project png17 IF errorlevel 1 goto error_end popd ) IF NOT EXIST %TEMP_DIR%\expat-2.1.0.tar ( %CYGWIN_DIR%\bin\wget.exe -O %TEMP_DIR%/expat-2.1.0.tar.gz http://sourceforge.net/projects/expat/files/expat/2.1.0/expat-2.1.0.tar.gz/download %CYGWIN_DIR%\bin\gzip.exe -d %TEMP_DIR%/expat-2.1.0.tar.gz ) IF NOT EXIST expat-2.1.0 ( %CYGWIN_DIR%\bin\tar.exe -xf %TEMP_DIR%/expat-2.1.0.tar pushd expat-2.1.0 %CMAKE_DIR%\bin\cmake.exe -G "%VS_CMAKE%" IF errorlevel 1 goto error_end %VSCOMMAND% expat.sln /build "%Configuration%|%Platform%" /Project expat IF errorlevel 1 goto error_end popd ) IF NOT EXIST exiv2-%EXIV2_COMMIT% ( %CYGWIN_DIR%\bin\svn.exe co -r %EXIV2_COMMIT% svn://dev.exiv2.org/svn/trunk exiv2-%EXIV2_COMMIT% pushd exiv2-%EXIV2_COMMIT% %CMAKE_DIR%\bin\cmake.exe -G "%VS_CMAKE%" -DZLIB_ROOT=..\zlib-%ZLIB_COMMIT%;..\zlib-%ZLIB_COMMIT%\Release IF errorlevel 1 goto error_end %VSCOMMAND% exiv2.sln /build "%Configuration%|%Platform%" /Project exiv2 IF errorlevel 1 goto error_end copy bin\%Platform%\Dynamic\*.h include popd ) IF NOT EXIST libjpeg-turbo-%LIBJPEG_COMMIT% ( %CYGWIN_DIR%\bin\svn.exe co -r %LIBJPEG_COMMIT% svn://svn.code.sf.net/p/libjpeg-turbo/code/trunk libjpeg-turbo-%LIBJPEG_COMMIT% ) IF NOT EXIST libjpeg-turbo-%LIBJPEG_COMMIT%.build ( mkdir libjpeg-turbo-%LIBJPEG_COMMIT%.build pushd libjpeg-turbo-%LIBJPEG_COMMIT%.build %CMAKE_DIR%\bin\cmake.exe -G "%VS_CMAKE%" -DCMAKE_BUILD_TYPE=%Configuration% -DNASM="%CYGWIN_DIR%\bin\nasm.exe" -DWITH_JPEG8=TRUE ..\libjpeg-turbo-%LIBJPEG_COMMIT% IF errorlevel 1 goto error_end %VSCOMMAND% libjpeg-turbo.sln /build "%Configuration%|%Platform%" IF errorlevel 1 goto error_end copy jconfig.h ..\libjpeg-turbo-%LIBJPEG_COMMIT% popd ) SET LCMS_COMMIT=%LCMS_COMMIT_LONG:~0,7% IF NOT EXIST %TEMP_DIR%\lcms2-%LCMS_COMMIT%.zip ( %CYGWIN_DIR%\bin\wget.exe -O %TEMP_DIR%/lcms2-%LCMS_COMMIT%.zip --no-check-certificate https://github.com/mm2/Little-CMS/zipball/%LCMS_COMMIT_LONG% ) IF NOT EXIST lcms2-%LCMS_COMMIT% ( %CYGWIN_DIR%\bin\unzip.exe -q %TEMP_DIR%/lcms2-%LCMS_COMMIT%.zip %CYGWIN_DIR%\bin\mv.exe mm2-Little-CMS-* lcms2-%LCMS_COMMIT% pushd lcms2-%LCMS_COMMIT% %VSCOMMAND% Projects\VC2010\lcms2.sln /Upgrade %VSCOMMAND% Projects\VC2010\lcms2.sln /build "%Configuration%|%Platform%" /Project lcms2_DLL IF errorlevel 1 goto error_end popd ) IF NOT EXIST %TEMP_DIR%\tiff-4.0.3.zip ( %CYGWIN_DIR%\bin\wget.exe -O %TEMP_DIR%/tiff-4.0.3.zip http://download.osgeo.org/libtiff/tiff-4.0.3.zip ) IF NOT EXIST tiff-4.0.3 ( %CYGWIN_DIR%\bin\unzip.exe -q %TEMP_DIR%/tiff-4.0.3.zip echo.JPEG_SUPPORT=^1> tiff-4.0.3\qtpfsgui_commands.in echo.JPEGDIR=%CD%\libjpeg-turbo-%LIBJPEG_COMMIT%>> tiff-4.0.3\qtpfsgui_commands.in echo.JPEG_INCLUDE=-I%CD%\libjpeg-turbo-%LIBJPEG_COMMIT%>> tiff-4.0.3\qtpfsgui_commands.in echo.JPEG_LIB=%CD%\libjpeg-turbo-%LIBJPEG_COMMIT%.build\sharedlib\%Configuration%\jpeg.lib>> tiff-4.0.3\qtpfsgui_commands.in echo.ZIP_SUPPORT=^1>> tiff-4.0.3\qtpfsgui_commands.in echo.ZLIBDIR=..\..\zlib-%ZLIB_COMMIT%\%Configuration%>> tiff-4.0.3\qtpfsgui_commands.in echo.ZLIB_INCLUDE=-I..\..\zlib-%ZLIB_COMMIT%>> tiff-4.0.3\qtpfsgui_commands.in echo.ZLIB_LIB=$^(ZLIBDIR^)\zlib.lib>> tiff-4.0.3\qtpfsgui_commands.in pushd tiff-4.0.3 nmake /s /c /f Makefile.vc @qtpfsgui_commands.in IF errorlevel 1 goto error_end popd ) SET LIBRAW_COMMIT=%LIBRAW_COMMIT_LONG:~0,7% SET LIBRAW_DEMOS2_COMMIT=%LIBRAW_DEMOS2_COMMIT_LONG:~0,7% SET LIBRAW_DEMOS3_COMMIT=%LIBRAW_DEMOS3_COMMIT_LONG:~0,7% IF NOT EXIST %TEMP_DIR%\LibRaw-%LIBRAW_COMMIT%.zip ( %CYGWIN_DIR%\bin\wget.exe -O %TEMP_DIR%/LibRaw-%LIBRAW_COMMIT%.zip --no-check-certificate https://github.com/LibRaw/LibRaw/zipball/%LIBRAW_COMMIT_LONG% ) IF NOT EXIST %TEMP_DIR%\LibRaw-demosaic-pack-GPL2-%LIBRAW_DEMOS2_COMMIT%.zip ( %CYGWIN_DIR%\bin\wget.exe -O %TEMP_DIR%/LibRaw-demosaic-pack-GPL2-%LIBRAW_DEMOS2_COMMIT%.zip --no-check-certificate https://github.com/LibRaw/LibRaw-demosaic-pack-GPL2/zipball/%LIBRAW_DEMOS2_COMMIT_LONG% ) IF NOT EXIST LibRaw-demosaic-pack-GPL2-%LIBRAW_DEMOS2_COMMIT% ( %CYGWIN_DIR%\bin\unzip.exe -q %TEMP_DIR%/LibRaw-demosaic-pack-GPL2-%LIBRAW_DEMOS2_COMMIT%.zip %CYGWIN_DIR%\bin\mv.exe LibRaw-LibRaw-* LibRaw-demosaic-pack-GPL2-%LIBRAW_DEMOS2_COMMIT% ) IF NOT EXIST %TEMP_DIR%\LibRaw-demosaic-pack-GPL3-%LIBRAW_DEMOS3_COMMIT%.zip ( %CYGWIN_DIR%\bin\wget.exe -O %TEMP_DIR%/LibRaw-demosaic-pack-GPL3-%LIBRAW_DEMOS3_COMMIT%.zip --no-check-certificate https://github.com/LibRaw/LibRaw-demosaic-pack-GPL3/zipball/%LIBRAW_DEMOS3_COMMIT_LONG% ) IF NOT EXIST LibRaw-demosaic-pack-GPL3-%LIBRAW_DEMOS3_COMMIT% ( %CYGWIN_DIR%\bin\unzip.exe -q %TEMP_DIR%/LibRaw-demosaic-pack-GPL3-%LIBRAW_DEMOS3_COMMIT%.zip %CYGWIN_DIR%\bin\mv.exe LibRaw-LibRaw-* LibRaw-demosaic-pack-GPL3-%LIBRAW_DEMOS3_COMMIT% ) IF NOT EXIST LibRaw-%LIBRAW_COMMIT% ( %CYGWIN_DIR%\bin\unzip.exe -q %TEMP_DIR%/LibRaw-%LIBRAW_COMMIT%.zip %CYGWIN_DIR%\bin\mv.exe LibRaw-LibRaw-* LibRaw-%LIBRAW_COMMIT% pushd LibRaw-%LIBRAW_COMMIT% rem /openmp echo.COPT_OPT="/arch:SSE2"> qtpfsgui_commands.in echo.CFLAGS_DP2=/I..\LibRaw-demosaic-pack-GPL2-%LIBRAW_DEMOS2_COMMIT%>> qtpfsgui_commands.in echo.CFLAGSG2=/DLIBRAW_DEMOSAIC_PACK_GPL2>> qtpfsgui_commands.in echo.CFLAGS_DP3=/I..\LibRaw-demosaic-pack-GPL3-%LIBRAW_DEMOS3_COMMIT%>> qtpfsgui_commands.in echo.CFLAGSG3=/DLIBRAW_DEMOSAIC_PACK_GPL3>> qtpfsgui_commands.in echo.LCMS_DEF="/DUSE_LCMS2 /DCMS_DLL /I..\lcms2-%LCMS_COMMIT%\include">> qtpfsgui_commands.in echo.LCMS_LIB="..\lcms2-%LCMS_COMMIT%\bin\lcms2.lib">> qtpfsgui_commands.in echo.JPEG_DEF="/DUSE_JPEG8 /DUSE_JPEG /I..\libjpeg-turbo-%LIBJPEG_COMMIT%">> qtpfsgui_commands.in echo.JPEG_LIB="..\libjpeg-turbo-%LIBJPEG_COMMIT%.build\sharedlib\%Configuration%\jpeg.lib">> qtpfsgui_commands.in nmake /f Makefile.msvc @qtpfsgui_commands.in clean > nul nmake /f Makefile.msvc @qtpfsgui_commands.in bin\libraw.dll popd ) SET PTHREADS_CURRENT_DIR=pthreads_%PTHREADS_DIR%_%RawPlatform% IF NOT EXIST %TEMP_DIR%\%PTHREADS_CURRENT_DIR% ( mkdir %TEMP_DIR%\%PTHREADS_CURRENT_DIR% pushd %TEMP_DIR%\%PTHREADS_CURRENT_DIR% %CYGWIN_DIR%\bin\wget.exe -O pthread.h --retry-connrefused --tries=5 ftp://sourceware.org/pub/pthreads-win32/%PTHREADS_DIR%/include/pthread.h %CYGWIN_DIR%\bin\wget.exe -O sched.h --retry-connrefused --tries=5 ftp://sourceware.org/pub/pthreads-win32/%PTHREADS_DIR%/include/sched.h %CYGWIN_DIR%\bin\wget.exe -O semaphore.h --retry-connrefused --tries=5 ftp://sourceware.org/pub/pthreads-win32/%PTHREADS_DIR%/include/semaphore.h %CYGWIN_DIR%\bin\wget.exe -O pthreadVC2.dll --retry-connrefused --tries=5 ftp://sourceware.org/pub/pthreads-win32/%PTHREADS_DIR%/dll/%RawPlatform%/pthreadVC2.dll %CYGWIN_DIR%\bin\wget.exe -O pthreadVC2.lib --retry-connrefused --tries=5 ftp://sourceware.org/pub/pthreads-win32/%PTHREADS_DIR%/lib/%RawPlatform%/pthreadVC2.lib popd ) IF NOT EXIST %PTHREADS_CURRENT_DIR% ( mkdir %PTHREADS_CURRENT_DIR% robocopy %TEMP_DIR%\%PTHREADS_CURRENT_DIR% %PTHREADS_CURRENT_DIR% >nul ) IF NOT EXIST %TEMP_DIR%\cfit%CFITSIO_VER%.zip ( %CYGWIN_DIR%\bin\wget.exe -O %TEMP_DIR%/cfit%CFITSIO_VER%.zip ftp://heasarc.gsfc.nasa.gov/software/fitsio/c/cfit%CFITSIO_VER%.zip ) IF NOT EXIST cfit%CFITSIO_VER% ( %CYGWIN_DIR%\bin\unzip.exe -o -q -d cfit%CFITSIO_VER% %TEMP_DIR%/cfit%CFITSIO_VER%.zip ) IF NOT EXIST cfit%CFITSIO_VER%.build ( mkdir cfit%CFITSIO_VER%.build pushd cfit%CFITSIO_VER%.build %CMAKE_DIR%\bin\cmake.exe -G "%VS_CMAKE%" ..\cfit%CFITSIO_VER% -DUSE_PTHREADS=1 -DCMAKE_INCLUDE_PATH=..\%PTHREADS_CURRENT_DIR% -DCMAKE_LIBRARY_PATH=..\%PTHREADS_CURRENT_DIR% IF errorlevel 1 goto error_end %CMAKE_DIR%\bin\cmake.exe --build . --config %Configuration% --target cfitsio IF errorlevel 1 goto error_end popd ) pushd cfit%CFITSIO_VER% SET CFITSIO=%CD% popd pushd cfit%CFITSIO_VER%.build\%Configuration% SET CFITSIO=%CFITSIO%;%CD% popd rem IF NOT EXIST %TEMP_DIR%\CCfits-2.4.tar ( rem %CYGWIN_DIR%\bin\wget.exe -O %TEMP_DIR%/CCfits-2.4.tar.gz http://heasarc.gsfc.nasa.gov/docs/software/fitsio/CCfits/CCfits-2.4.tar.gz rem %CYGWIN_DIR%\bin\gzip.exe -d %TEMP_DIR%/CCfits-2.4.tar.gz rem %CYGWIN_DIR%\bin\wget.exe -O %TEMP_DIR%/CCfits2.4patch.zip http://qtpfsgui.sourceforge.net/win/CCfits2.4patch.zip rem ) rem IF NOT EXIST CCfits2.4 ( rem %CYGWIN_DIR%\bin\tar.exe -xf %TEMP_DIR%/CCfits-2.4.tar rem ren CCfits CCfits2.4 rem %CYGWIN_DIR%\bin\unzip.exe -o -q -d CCfits2.4 %TEMP_DIR%/CCfits2.4patch.zip rem ) rem IF NOT EXIST CCfits2.4.build ( rem mkdir CCfits2.4.build rem rem pushd CCfits2.4.build rem %CMAKE_DIR%\bin\cmake.exe -G "%VS_CMAKE%" ..\CCfits2.4 -DCMAKE_INCLUDE_PATH=..\cfit%CFITSIO_VER% -DCMAKE_LIBRARY_PATH=..\cfit%CFITSIO_VER%.build\%Configuration% rem IF errorlevel 1 goto error_end rem %CMAKE_DIR%\bin\cmake.exe --build . --config %Configuration% --target CCfits rem IF errorlevel 1 goto error_end rem popd rem ) rem pushd CCfits2.4.build\%Configuration% rem SET CCFITS_ROOT_DIR=%CD% rem popd IF NOT EXIST %TEMP_DIR%\gsl-1.15.tar ( %CYGWIN_DIR%\bin\wget.exe -O %TEMP_DIR%/gsl-1.15.tar.gz ftp://ftp.gnu.org/gnu/gsl/gsl-1.15.tar.gz %CYGWIN_DIR%\bin\gzip -d %TEMP_DIR%/gsl-1.15.tar.gz ) IF NOT EXIST %TEMP_DIR%\gsl-1.15-vc10.zip ( %CYGWIN_DIR%\bin\wget.exe -O %TEMP_DIR%/gsl-1.15-vc10.zip http://gladman.plushost.co.uk/oldsite/computing/gsl-1.15-vc10.zip ) IF NOT EXIST gsl-1.15 ( %CYGWIN_DIR%\bin\tar.exe -xf %TEMP_DIR%/gsl-1.15.tar %CYGWIN_DIR%\bin\unzip.exe -o -q -d gsl-1.15 %TEMP_DIR%/gsl-1.15-vc10.zip pushd gsl-1.15\build.vc10 IF %VS_SHORT% EQU vc9 ( %CYGWIN_DIR%\bin\sed.exe -i 's/Format Version 11.00/Format Version 10.00/g' gsl.lib.sln ) %VSCOMMAND% gsl.lib.sln /Upgrade %VSCOMMAND% gsl.lib.sln /build "%Configuration%|%Platform%" /Project gslhdrs gslhdrs\%Platform%\%Configuration%\gslhdrs.exe %VSCOMMAND% gsl.lib.sln /build "%Configuration%|%Platform%" /Project gsllib popd ) SET OPENEXR_COMMIT=%OPENEXR_COMMIT_LONG:~0,7% IF NOT EXIST %TEMP_DIR%\OpenEXR-dk-%OPENEXR_COMMIT%.zip ( %CYGWIN_DIR%\bin\wget.exe -O %TEMP_DIR%/OpenEXR-dk-%OPENEXR_COMMIT%.zip --no-check-certificate https://github.com/openexr/openexr/zipball/%OPENEXR_COMMIT_LONG% ) IF NOT EXIST OpenEXR-dk-%OPENEXR_COMMIT% ( %CYGWIN_DIR%\bin\unzip.exe -q %TEMP_DIR%/OpenEXR-dk-%OPENEXR_COMMIT%.zip %CYGWIN_DIR%\bin\mv.exe openexr-openexr-* OpenEXR-dk-%OPENEXR_COMMIT% ) IF NOT EXIST OpenEXR-dk-%OPENEXR_COMMIT%\IlmBase.build ( mkdir OpenEXR-dk-%OPENEXR_COMMIT%\IlmBase.build pushd OpenEXR-dk-%OPENEXR_COMMIT%\IlmBase.build %CMAKE_DIR%\bin\cmake.exe -G "%VS_CMAKE%" -DCMAKE_BUILD_TYPE=%Configuration% -DCMAKE_INSTALL_PREFIX=..\output -DZLIB_ROOT=..\..\zlib-%ZLIB_COMMIT%;..\..\zlib-%ZLIB_COMMIT%\%Configuration% -DBUILD_SHARED_LIBS=OFF ../IlmBase IF errorlevel 1 goto error_end %VSCOMMAND% IlmBase.sln /build "%Configuration%|%Platform%" IF errorlevel 1 goto error_end %VSCOMMAND% IlmBase.sln /build "%Configuration%|%Platform%" /Project INSTALL IF errorlevel 1 goto error_end popd ) IF NOT EXIST OpenEXR-dk-%OPENEXR_COMMIT%\OpenEXR.build ( mkdir OpenEXR-dk-%OPENEXR_COMMIT%\OpenEXR.build pushd OpenEXR-dk-%OPENEXR_COMMIT%\OpenEXR.build %CMAKE_DIR%\bin\cmake.exe -G "%VS_CMAKE%" -DCMAKE_BUILD_TYPE=%Configuration% ^ -DZLIB_ROOT=..\..\zlib-%ZLIB_COMMIT%;..\..\zlib-%ZLIB_COMMIT%\%Configuration% ^ -DILMBASE_PACKAGE_PREFIX=%CD%\OpenEXR-dk-%OPENEXR_COMMIT%\output -DBUILD_SHARED_LIBS=OFF ^ -DCMAKE_INSTALL_PREFIX=..\output ^ ../OpenEXR IF errorlevel 1 goto error_end %VSCOMMAND% OpenEXR.sln /build "%Configuration%|%Platform%" /Project IlmImf IF errorlevel 1 goto error_end %VSCOMMAND% OpenEXR.sln /build "%Configuration%|%Platform%" /Project INSTALL IF errorlevel 1 goto error_end popd ) IF %Platform% EQU Win32 ( IF NOT EXIST %TEMP_DIR%\fftw-%FFTW_VER%-dll32.zip ( %CYGWIN_DIR%\bin\wget.exe -O %TEMP_DIR%/fftw-%FFTW_VER%-dll32.zip ftp://ftp.fftw.org/pub/fftw/fftw-%FFTW_VER%-dll32.zip ) ) ELSE ( IF NOT EXIST %TEMP_DIR%\fftw-%FFTW_VER%-dll64.zip ( %CYGWIN_DIR%\bin\wget.exe -O %TEMP_DIR%/fftw-%FFTW_VER%-dll64.zip ftp://ftp.fftw.org/pub/fftw/fftw-%FFTW_VER%-dll64.zip ) ) IF NOT EXIST fftw-%FFTW_VER%-dll ( IF %Platform% EQU Win32 ( %CYGWIN_DIR%\bin\unzip.exe -q -d fftw-%FFTW_VER%-dll %TEMP_DIR%/fftw-%FFTW_VER%-dll32.zip ) ELSE ( %CYGWIN_DIR%\bin\unzip.exe -q -d fftw-%FFTW_VER%-dll %TEMP_DIR%/fftw-%FFTW_VER%-dll64.zip ) pushd fftw-%FFTW_VER%-dll lib /def:libfftw3-3.def lib /def:libfftw3f-3.def lib /def:libfftw3l-3.def popd ) REM IF NOT EXIST %TEMP_DIR%\tbb40_20120613oss_win.zip ( REM %CYGWIN_DIR%\bin\wget.exe -O %TEMP_DIR%/tbb40_20120613oss_win.zip "http://threadingbuildingblocks.org/uploads/77/187/4.0 update 5/tbb40_20120613oss_win.zip" REM ) REM REM IF NOT EXIST tbb40_20120613oss ( REM %CYGWIN_DIR%\bin\unzip.exe -q %TEMP_DIR%/tbb40_20120613oss_win.zip REM REM Everthing is already compiled, nothing to do! REM ) REM IF NOT EXIST %TEMP_DIR%\gtest-1.6.0.zip ( SET GTEST_DIR=gtest-r680 IF NOT EXIST %GTEST_DIR% ( REM %CYGWIN_DIR%\bin\wget.exe -O %TEMP_DIR%/gtest-1.6.0.zip http://googletest.googlecode.com/files/gtest-1.6.0.zip %CYGWIN_DIR%\bin\svn.exe co -r 680 http://googletest.googlecode.com/svn/trunk/ %GTEST_DIR% pushd %GTEST_DIR% %CMAKE_DIR%\bin\cmake.exe -G "%VS_CMAKE%" . -DBUILD_SHARED_LIBS=1 %VSCOMMAND% gtest.sln /build "%Configuration%|%Platform%" REN Release lib popd ) SET GTEST_ROOT=%CD%\%GTEST_DIR% REM IF NOT EXIST %GTEST_DIR%.build ( REM mkdir %GTEST_DIR%.build REM pushd %GTEST_DIR%.build REM %CMAKE_DIR%\bin\cmake.exe -G "%VS_CMAKE%" ..\%GTEST_DIR% -DBUILD_SHARED_LIBS=1 REM %VSCOMMAND% gtest.sln /build "%Configuration%|%Platform%" REM popd REM ) REM IF NOT EXIST gtest-1.6.0 ( REM %CYGWIN_DIR%\bin\unzip.exe -q %TEMP_DIR%/gtest-1.6.0.zip REM ) IF NOT DEFINED L_BOOST_DIR ( set L_BOOST_DIR=. ) IF NOT EXIST %TEMP_DIR%\boost_1_%BOOST_MINOR%_0.zip ( %CYGWIN_DIR%\bin\wget.exe -O %TEMP_DIR%/boost_1_%BOOST_MINOR%_0.zip http://sourceforge.net/projects/boost/files/boost/1.%BOOST_MINOR%.0/boost_1_%BOOST_MINOR%_0.zip/download ) IF NOT EXIST %L_BOOST_DIR%\boost_1_%BOOST_MINOR%_0 ( echo.Extracting boost. Be patient! pushd %L_BOOST_DIR% %CYGWIN_DIR%\bin\unzip.exe -q %TEMP_DIR%/boost_1_%BOOST_MINOR%_0.zip popd pushd %L_BOOST_DIR%\boost_1_%BOOST_MINOR%_0 bootstrap.bat popd pushd %L_BOOST_DIR%\boost_1_%BOOST_MINOR%_0 IF %Platform% EQU Win32 ( IF %Configuration% EQU Release ( cmd.exe /C b2.exe toolset=msvc variant=release ) ELSE ( cmd.exe /C b2.exe toolset=msvc variant=debug ) ) ELSE ( IF %Configuration% EQU Release ( cmd.exe /C b2.exe toolset=msvc variant=release address-model=64 ) ELSE ( cmd.exe /C b2.exe toolset=msvc variant=debug address-model=64 ) ) popd ) REM Set Boost-directory as ENV variable (needed for CMake) pushd %L_BOOST_DIR%\boost_1_%BOOST_MINOR%_0 rem SET Boost_DIR=%CD% REM SET BOOST_ROOT=%CD% popd IF NOT EXIST LuminanceHdrStuff ( mkdir LuminanceHdrStuff ) IF NOT EXIST LuminanceHdrStuff\qtpfsgui ( pushd LuminanceHdrStuff %CYGWIN_DIR%\bin\git.exe clone git://git.code.sf.net/p/qtpfsgui/code qtpfsgui popd ) ELSE ( pushd LuminanceHdrStuff\qtpfsgui IF %UPDATE_REPO_LUMINANCE% EQU 1 ( %CYGWIN_DIR%\bin\git.exe pull ) popd ) IF NOT EXIST LuminanceHdrStuff\DEPs ( pushd LuminanceHdrStuff mkdir DEPs cd DEPs mkdir include mkdir lib mkdir bin popd for %%v in ("libpng", "libjpeg", "lcms2", "exiv2", "libtiff", "libraw", "fftw3", "gsl", "CCfits") do ( mkdir LuminanceHdrStuff\DEPs\include\%%v mkdir LuminanceHdrStuff\DEPs\lib\%%v mkdir LuminanceHdrStuff\DEPs\bin\%%v ) mkdir LuminanceHdrStuff\DEPs\include\libraw\libraw mkdir LuminanceHdrStuff\DEPs\include\gsl\gsl copy gsl-1.15\gsl\*.h LuminanceHdrStuff\DEPs\include\gsl\gsl copy gsl-1.15\build.vc10\lib\%Platform%\%Configuration%\*.lib LuminanceHdrStuff\DEPs\lib\gsl rem copy gsl-1.15\build.vc10\dll\*.dll LuminanceHdrStuff\DEPs\bin\gsl ) robocopy fftw-%FFTW_VER%-dll LuminanceHdrStuff\DEPs\include\fftw3 *.h /MIR >nul robocopy fftw-%FFTW_VER%-dll LuminanceHdrStuff\DEPs\lib\fftw3 *.lib /MIR /NJS >nul robocopy fftw-%FFTW_VER%-dll LuminanceHdrStuff\DEPs\bin\fftw3 *.dll /MIR /NJS >nul robocopy tiff-4.0.3\libtiff LuminanceHdrStuff\DEPs\include\libtiff *.h /MIR >nul robocopy tiff-4.0.3\libtiff LuminanceHdrStuff\DEPs\lib\libtiff *.lib /MIR /NJS >nul robocopy tiff-4.0.3\libtiff LuminanceHdrStuff\DEPs\bin\libtiff *.dll /MIR /NJS >nul rem robocopy expat: included indirectly in in exiv2 rem robocopy zlib: included indirectly in in exiv2 robocopy exiv2-%EXIV2_COMMIT%\include LuminanceHdrStuff\DEPs\include\exiv2 *.h *.hpp /MIR >nul robocopy exiv2-%EXIV2_COMMIT%\bin\%Platform%\Dynamic\%Configuration% LuminanceHdrStuff\DEPs\lib\exiv2 *.lib /MIR >nul robocopy exiv2-%EXIV2_COMMIT%\bin\%Platform%\Dynamic\%Configuration% LuminanceHdrStuff\DEPs\bin\exiv2 *.dll /MIR >nul robocopy lp170b35 LuminanceHdrStuff\DEPs\include\libpng *.h /MIR >nul robocopy lp170b35\%Configuration% LuminanceHdrStuff\DEPs\lib\libpng *.lib /MIR >nul robocopy lp170b35\%Configuration% LuminanceHdrStuff\DEPs\bin\libpng *.dll /MIR >nul robocopy LibRaw-%LIBRAW_COMMIT%\libraw LuminanceHdrStuff\DEPs\include\libraw\libraw /MIR >nul robocopy LibRaw-%LIBRAW_COMMIT%\lib LuminanceHdrStuff\DEPs\lib\libraw *.lib /MIR >nul robocopy LibRaw-%LIBRAW_COMMIT%\bin LuminanceHdrStuff\DEPs\bin\libraw *.dll /MIR >nul robocopy lcms2-%LCMS_COMMIT%\include LuminanceHdrStuff\DEPs\include\lcms2 *.h /MIR >nul robocopy lcms2-%LCMS_COMMIT%\bin LuminanceHdrStuff\DEPs\lib\lcms2 *.lib /MIR /NJS >nul rem robocopy lcms2-%LCMS_COMMIT%\bin LuminanceHdrStuff\DEPs\bin\lcms2 *.dll /MIR /NJS >nul robocopy libjpeg-turbo-%LIBJPEG_COMMIT% LuminanceHdrStuff\DEPs\include\libjpeg *.h /MIR >nul robocopy libjpeg-turbo-%LIBJPEG_COMMIT%.build\sharedlib\%Configuration% LuminanceHdrStuff\DEPs\lib\libjpeg *.lib /MIR /NJS >nul robocopy libjpeg-turbo-%LIBJPEG_COMMIT%.build\sharedlib\%Configuration% LuminanceHdrStuff\DEPs\bin\libjpeg *.dll /MIR /NJS >nul REM robocopy tbb40_20120613oss\include LuminanceHdrStuff\DEPs\include\tbb /MIR >nul REM robocopy tbb40_20120613oss\lib\%CpuPlatform%\%VS_SHORT% LuminanceHdrStuff\DEPs\lib\tbb /MIR >nul REM robocopy tbb40_20120613oss\bin\%CpuPlatform%\%VS_SHORT% LuminanceHdrStuff\DEPs\bin\tbb /MIR >nul robocopy CCfits2.4 LuminanceHdrStuff\DEPs\include\CCfits *.h CCfits /MIR >nul pushd LuminanceHdrStuff\DEPs\include SET CCFITS_ROOT_DIR=%CCFITS_ROOT_DIR%;%CD% popd IF NOT EXIST LuminanceHdrStuff\qtpfsgui.build ( mkdir LuminanceHdrStuff\qtpfsgui.build ) pushd LuminanceHdrStuff\qtpfsgui.build IF %OPTION_LUMINANCE_UPDATE_TRANSLATIONS% EQU 1 ( set CMAKE_OPTIONS=-DUPDATE_TRANSLATIONS=1 ) ELSE ( set CMAKE_OPTIONS=-UUPDATE_TRANSLATIONS ) IF %OPTION_LUPDATE_NOOBSOLETE% EQU 1 ( set CMAKE_OPTIONS=%CMAKE_OPTIONS% -DLUPDATE_NOOBSOLETE=1 ) ELSE ( set CMAKE_OPTIONS=%CMAKE_OPTIONS% -ULUPDATE_NOOBSOLETE ) set L_CMAKE_INCLUDE=..\DEPs\include\libtiff;..\DEPs\include\libpng;..\..\zlib-%ZLIB_COMMIT%;..\..\boost_1_%BOOST_MINOR%_0;..\..\OpenEXR-dk-%OPENEXR_COMMIT%\output\include set L_CMAKE_LIB=..\DEPs\lib\libtiff;..\DEPs\lib\libpng;..\..\zlib-%ZLIB_COMMIT%\%Configuration%;..\..\boost_1_%BOOST_MINOR%_0\stage\lib;..\..\OpenEXR-dk-%OPENEXR_COMMIT%\output\lib set L_CMAKE_PROGRAM_PATH=%CYGWIN_DIR%\bin set L_CMAKE_PREFIX_PATH=%QTDIR% set CMAKE_OPTIONS=%CMAKE_OPTIONS% -DPC_EXIV2_INCLUDEDIR=..\DEPs\include\exiv2 -DPC_EXIV2_LIBDIR=..\DEPs\lib\exiv2 -DCMAKE_INCLUDE_PATH=%L_CMAKE_INCLUDE% -DCMAKE_LIBRARY_PATH=%L_CMAKE_LIB% -DCMAKE_PROGRAM_PATH=%L_CMAKE_PROGRAM_PATH% -DCMAKE_PREFIX_PATH=%L_CMAKE_PREFIX_PATH% -DPNG_NAMES=libpng16;libpng17 -DOPENEXR_VERSION=%OPENEXR_CMAKE_VERSION% REM IF EXIST ..\..\gtest-1.6.0 ( REM SET GTEST_ROOT=%CD%\..\..\gtest-1.6.0 REM ) echo CMake command line options ------------------------------------ echo %CMAKE_OPTIONS% echo --------------------------------------------------------------- %CMAKE_DIR%\bin\cmake.exe -G "%VS_CMAKE%" ..\qtpfsgui %CMAKE_OPTIONS% IF errorlevel 1 goto error_end popd IF EXIST LuminanceHdrStuff\qtpfsgui.build\Luminance HDR.sln ( pushd LuminanceHdrStuff\qtpfsgui.build rem %VSCOMMAND% luminance-hdr.sln /Upgrade %VSCOMMAND% "Luminance HDR.sln" /build "%ConfigurationLuminance%|%Platform%" /Project luminance-hdr IF errorlevel 1 goto error_end popd ) IF EXIST LuminanceHdrStuff\qtpfsgui.build\%ConfigurationLuminance%\luminance-hdr.exe ( IF EXIST LuminanceHdrStuff\qtpfsgui.build\%ConfigurationLuminance% ( robocopy LuminanceHdrStuff\qtpfsgui LuminanceHdrStuff\qtpfsgui.build\%ConfigurationLuminance% LICENSE >nul IF NOT EXIST LuminanceHdrStuff\qtpfsgui.build\%ConfigurationLuminance%\align_image_stack.exe ( copy vcDlls\selected\* LuminanceHdrStuff\qtpfsgui.build\%ConfigurationLuminance%\ ) pushd LuminanceHdrStuff\DEPs\bin robocopy libjpeg ..\..\qtpfsgui.build\%ConfigurationLuminance% jpeg8.dll >nul robocopy exiv2 ..\..\qtpfsgui.build\%ConfigurationLuminance% exiv2.dll >nul robocopy exiv2 ..\..\qtpfsgui.build\%ConfigurationLuminance% zlib.dll >nul robocopy exiv2 ..\..\qtpfsgui.build\%ConfigurationLuminance% expat.dll >nul robocopy libraw ..\..\qtpfsgui.build\%ConfigurationLuminance% libraw.dll >nul robocopy fftw3 ..\..\qtpfsgui.build\%ConfigurationLuminance% libfftw3f-3.dll >nul robocopy libpng ..\..\qtpfsgui.build\%ConfigurationLuminance% libpng17.dll >nul popd robocopy cfit%CFITSIO_VER%.build\%Configuration% LuminanceHdrStuff\qtpfsgui.build\%ConfigurationLuminance% cfitsio.dll >nul robocopy %PTHREADS_CURRENT_DIR% LuminanceHdrStuff\qtpfsgui.build\%ConfigurationLuminance% pthreadVC2.dll >nul robocopy lcms2-%LCMS_COMMIT%\bin LuminanceHdrStuff\qtpfsgui.build\%ConfigurationLuminance% lcms2.dll >nul IF NOT EXIST LuminanceHdrStuff\qtpfsgui.build\%ConfigurationLuminance%\i18n\ ( mkdir LuminanceHdrStuff\qtpfsgui.build\%ConfigurationLuminance%\i18n ) IF NOT EXIST LuminanceHdrStuff\qtpfsgui.build\%ConfigurationLuminance%\help\ ( mkdir LuminanceHdrStuff\qtpfsgui.build\%ConfigurationLuminance%\help ) robocopy LuminanceHdrStuff\qtpfsgui.build LuminanceHdrStuff\qtpfsgui.build\%ConfigurationLuminance%\i18n lang_*.qm >nul robocopy LuminanceHdrStuff\qtpfsgui\help LuminanceHdrStuff\qtpfsgui.build\%ConfigurationLuminance%\help /MIR >nul REM ----- QT Stuff (Dlls, translations) -------------------------------------------- pushd LuminanceHdrStuff\qtpfsgui.build\%ConfigurationLuminance% for %%v in ( "Qt5Concurrent.dll", "Qt5Core.dll", "Qt5Gui.dll", "Qt5Multimedia.dll", "Qt5MultimediaWidgets.dll", "Qt5Network.dll", "Qt5Positioning.dll", "Qt5WinExtras.dll", "Qt5OpenGL.dll", "Qt5PrintSupport.dll", "Qt5Qml.dll", "Qt5Quick.dll", "Qt5Sensors.dll", "Qt5Sql.dll", "Qt5V8.dll", "Qt5WebKit.dll", "Qt5WebKitWidgets.dll", "Qt5Widgets.dll", "Qt5Xml.dll", "icudt51.dll", "icuin51.dll", "icuuc51.dll" ) do ( robocopy %QTDIR%\bin . %%v >nul ) for %%v in ("imageformats", "sqldrivers", "platforms") do ( IF NOT EXIST %%v ( mkdir %%v ) ) robocopy %QTDIR%\plugins\imageformats imageformats qjpeg.dll >nul robocopy %QTDIR%\plugins\sqldrivers sqldrivers qsqlite.dll >nul robocopy %QTDIR%\plugins\platforms platforms qwindows.dll >nul robocopy %QTDIR%\translations i18n qt_??.qm >nul robocopy %QTDIR%\translations i18n qt_??_*.qm >nul popd robocopy hugin-%HUGIN_VER%-%RawPlatform% LuminanceHdrStuff\qtpfsgui.build\%ConfigurationLuminance%\hugin /MIR >nul ) ) goto end :error_end pause :end endlocal
stoneyang/LuminanceHDR
build/msvc/build.cmd
Batchfile
gpl-2.0
30,612
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <!--NewPage--> <HTML> <HEAD> <!-- Generated by javadoc (build 1.6.0_23) on Tue Nov 10 20:55:20 CET 2015 --> <META http-equiv="Content-Type" content="text/html; charset=UTF-8"> <TITLE> Uses of Class org.slf4j.profiler.SortAndPruneComposites (SLF4J 1.7.13 Test API) </TITLE> <META NAME="date" CONTENT="2015-11-10"> <LINK REL ="stylesheet" TYPE="text/css" HREF="../../../../stylesheet.css" TITLE="Style"> <SCRIPT type="text/javascript"> function windowTitle() { if (location.href.indexOf('is-external=true') == -1) { parent.document.title="Uses of Class org.slf4j.profiler.SortAndPruneComposites (SLF4J 1.7.13 Test API)"; } } </SCRIPT> <NOSCRIPT> </NOSCRIPT> </HEAD> <BODY BGCOLOR="white" onload="windowTitle();"> <HR> <!-- ========= START OF TOP NAVBAR ======= --> <A NAME="navbar_top"><!-- --></A> <A HREF="#skip-navbar_top" title="Skip navigation links"></A> <TABLE BORDER="0" WIDTH="100%" CELLPADDING="1" CELLSPACING="0" SUMMARY=""> <TR> <TD COLSPAN=2 BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A NAME="navbar_top_firstrow"><!-- --></A> <TABLE BORDER="0" CELLPADDING="0" CELLSPACING="3" SUMMARY=""> <TR ALIGN="center" VALIGN="top"> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../overview-summary.html"><FONT CLASS="NavBarFont1"><B>Overview</B></FONT></A>&nbsp;</TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../package-summary.html"><FONT CLASS="NavBarFont1"><B>Package</B></FONT></A>&nbsp;</TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../org/slf4j/profiler/SortAndPruneComposites.html" title="class in org.slf4j.profiler"><FONT CLASS="NavBarFont1"><B>Class</B></FONT></A>&nbsp;</TD> <TD BGCOLOR="#FFFFFF" CLASS="NavBarCell1Rev"> &nbsp;<FONT CLASS="NavBarFont1Rev"><B>Use</B></FONT>&nbsp;</TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../package-tree.html"><FONT CLASS="NavBarFont1"><B>Tree</B></FONT></A>&nbsp;</TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../deprecated-list.html"><FONT CLASS="NavBarFont1"><B>Deprecated</B></FONT></A>&nbsp;</TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../index-all.html"><FONT CLASS="NavBarFont1"><B>Index</B></FONT></A>&nbsp;</TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../help-doc.html"><FONT CLASS="NavBarFont1"><B>Help</B></FONT></A>&nbsp;</TD> </TR> </TABLE> </TD> <TD ALIGN="right" VALIGN="top" ROWSPAN=3><EM> </EM> </TD> </TR> <TR> <TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2"> &nbsp;PREV&nbsp; &nbsp;NEXT</FONT></TD> <TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2"> <A HREF="../../../../index.html?org/slf4j/profiler/\class-useSortAndPruneComposites.html" target="_top"><B>FRAMES</B></A> &nbsp; &nbsp;<A HREF="SortAndPruneComposites.html" target="_top"><B>NO FRAMES</B></A> &nbsp; &nbsp;<SCRIPT type="text/javascript"> <!-- if(window==top) { document.writeln('<A HREF="../../../../allclasses-noframe.html"><B>All Classes</B></A>'); } //--> </SCRIPT> <NOSCRIPT> <A HREF="../../../../allclasses-noframe.html"><B>All Classes</B></A> </NOSCRIPT> </FONT></TD> </TR> </TABLE> <A NAME="skip-navbar_top"></A> <!-- ========= END OF TOP NAVBAR ========= --> <HR> <CENTER> <H2> <B>Uses of Class<br>org.slf4j.profiler.SortAndPruneComposites</B></H2> </CENTER> No usage of org.slf4j.profiler.SortAndPruneComposites <P> <HR> <!-- ======= START OF BOTTOM NAVBAR ====== --> <A NAME="navbar_bottom"><!-- --></A> <A HREF="#skip-navbar_bottom" title="Skip navigation links"></A> <TABLE BORDER="0" WIDTH="100%" CELLPADDING="1" CELLSPACING="0" SUMMARY=""> <TR> <TD COLSPAN=2 BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A NAME="navbar_bottom_firstrow"><!-- --></A> <TABLE BORDER="0" CELLPADDING="0" CELLSPACING="3" SUMMARY=""> <TR ALIGN="center" VALIGN="top"> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../overview-summary.html"><FONT CLASS="NavBarFont1"><B>Overview</B></FONT></A>&nbsp;</TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../package-summary.html"><FONT CLASS="NavBarFont1"><B>Package</B></FONT></A>&nbsp;</TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../org/slf4j/profiler/SortAndPruneComposites.html" title="class in org.slf4j.profiler"><FONT CLASS="NavBarFont1"><B>Class</B></FONT></A>&nbsp;</TD> <TD BGCOLOR="#FFFFFF" CLASS="NavBarCell1Rev"> &nbsp;<FONT CLASS="NavBarFont1Rev"><B>Use</B></FONT>&nbsp;</TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../package-tree.html"><FONT CLASS="NavBarFont1"><B>Tree</B></FONT></A>&nbsp;</TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../deprecated-list.html"><FONT CLASS="NavBarFont1"><B>Deprecated</B></FONT></A>&nbsp;</TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../index-all.html"><FONT CLASS="NavBarFont1"><B>Index</B></FONT></A>&nbsp;</TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../help-doc.html"><FONT CLASS="NavBarFont1"><B>Help</B></FONT></A>&nbsp;</TD> </TR> </TABLE> </TD> <TD ALIGN="right" VALIGN="top" ROWSPAN=3><EM> </EM> </TD> </TR> <TR> <TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2"> &nbsp;PREV&nbsp; &nbsp;NEXT</FONT></TD> <TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2"> <A HREF="../../../../index.html?org/slf4j/profiler/\class-useSortAndPruneComposites.html" target="_top"><B>FRAMES</B></A> &nbsp; &nbsp;<A HREF="SortAndPruneComposites.html" target="_top"><B>NO FRAMES</B></A> &nbsp; &nbsp;<SCRIPT type="text/javascript"> <!-- if(window==top) { document.writeln('<A HREF="../../../../allclasses-noframe.html"><B>All Classes</B></A>'); } //--> </SCRIPT> <NOSCRIPT> <A HREF="../../../../allclasses-noframe.html"><B>All Classes</B></A> </NOSCRIPT> </FONT></TD> </TR> </TABLE> <A NAME="skip-navbar_bottom"></A> <!-- ======== END OF BOTTOM NAVBAR ======= --> <HR> Copyright &#169; 2005&#x2013;2015 <a href="http://www.qos.ch">QOS.ch</a>. All rights reserved. </BODY> </HTML>
tuskiomi/redditBot
REdefine/lib/slf4j-1.7.13/site/testapidocs/org/slf4j/profiler/class-use/SortAndPruneComposites.html
HTML
gpl-2.0
6,093
// // (c) Copyright 2013 DESY, Eugen Wintersberger <[email protected]> // // This file is part of pninexus. // // pninexus is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 2 of the License, or // (at your option) any later version. // // pninexus is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with pninexus. If not, see <http://www.gnu.org/licenses/>. // // =========================================================================== // // Created on: Oct 28, 2013 // Author: Eugen Wintersberger <[email protected]> // #ifdef __GNUG__ #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wdeprecated-declarations" #endif #include <boost/test/unit_test.hpp> #ifdef __GNUG__ #pragma GCC diagnostic pop #endif #include <pni/arrays.hpp> #include "array_types.hpp" #include "../data_generator.hpp" #include "../compiler_version.hpp" using namespace pni; template<typename AT> struct test_mdarray_fixture { typedef AT array_type; typedef typename array_type::value_type value_type; typedef typename array_type::storage_type storage_type; typedef typename array_type::map_type map_type; typedef random_generator<value_type> generator_type; generator_type generator; shape_t shape; test_mdarray_fixture(): generator(), shape(shape_t{2,3,5}) {} }; BOOST_AUTO_TEST_SUITE(test_mdarray) typedef boost::mpl::joint_view<all_dynamic_arrays, #if GCC_VERSION > 40800 boost::mpl::joint_view< all_fixed_dim_arrays<3>, all_static_arrays<2,3,5> > #else all_fixed_dim_arrays<3> #endif > array_types; template<typename CTYPE,typename...ITYPES> static void create_index(CTYPE &index,ITYPES ...indexes) { index = CTYPE{indexes...}; } template<typename T,size_t N,typename ...ITYPES> static void create_index(std::array<T,N> &c,ITYPES ...indexes) { c = std::array<T,N>{{indexes...}}; } template< typename ITYPE, typename ATYPE > void test_multiindex_access_with_container() { typedef test_mdarray_fixture<ATYPE> fixture_type; typedef typename fixture_type::value_type value_type; fixture_type fixture; auto a = ATYPE::create(fixture.shape); ITYPE index; for(size_t i=0;i<fixture.shape[0];i++) for(size_t j=0;j<fixture.shape[1];j++) for(size_t k=0;k<fixture.shape[2];k++) { value_type v = fixture.generator(); create_index(index,i,j,k); a(index) = v; BOOST_CHECK_EQUAL(a(index),v); } } //======================================================================== // Create a mdarray instance from a view BOOST_AUTO_TEST_CASE_TEMPLATE(test_view_construction,AT,array_types) { typedef test_mdarray_fixture<AT> fixture_type; typedef typename fixture_type::value_type value_type; typedef dynamic_array<value_type> darray_type; fixture_type fixture; auto a = darray_type::create(shape_t{100,20,30}); std::generate(a.begin(),a.end(),fixture.generator); auto view = a(slice(0,2),slice(0,3),slice(0,5)); AT target(view); auto view_shape = view.template shape<shape_t>(); auto target_shape = target.template shape<shape_t>(); BOOST_CHECK_EQUAL_COLLECTIONS(view_shape.begin(),view_shape.end(), target_shape.begin(),target_shape.end()); BOOST_CHECK_EQUAL(view.size(),target.size()); BOOST_CHECK_EQUAL(view.rank(),target.rank()); BOOST_CHECK_EQUAL_COLLECTIONS(view.begin(),view.end(), target.begin(),target.end()); } //======================================================================== BOOST_AUTO_TEST_CASE(test_is_view_index) { BOOST_CHECK((is_view_index<size_t,size_t,size_t>::value==false)); BOOST_CHECK((is_view_index<slice,size_t,size_t>::value==true)); BOOST_CHECK((is_view_index<size_t,slice,size_t>::value==true)); BOOST_CHECK((is_view_index<size_t,size_t,slice>::value==true)); } //======================================================================== BOOST_AUTO_TEST_CASE_TEMPLATE(test_inquery,AT,array_types) { typedef test_mdarray_fixture<AT> fixture_type; typedef typename fixture_type::value_type value_type; fixture_type fixture; auto a = AT::create(fixture.shape); BOOST_CHECK_EQUAL(a.size(),30u); BOOST_CHECK_EQUAL(a.rank(),3u); BOOST_CHECK(AT::type_id == type_id_map<value_type>::type_id); } //======================================================================== BOOST_AUTO_TEST_CASE_TEMPLATE(test_linear_access_operator,AT,array_types) { typedef test_mdarray_fixture<AT> fixture_type; typedef typename fixture_type::value_type value_type; fixture_type fixture; auto a = AT::create(fixture.shape); const AT &ca = a; for(size_t index=0;index<a.size();++index) { value_type v = fixture.generator(); a[index] = v; BOOST_CHECK_EQUAL(a[index],v); BOOST_CHECK_EQUAL(ca[index],v); } } //======================================================================== BOOST_AUTO_TEST_CASE_TEMPLATE(test_linear_access_pointer,AT,array_types) { typedef test_mdarray_fixture<AT> fixture_type; fixture_type fixture; auto a = AT::create(fixture.shape); std::generate(a.begin(),a.end(),fixture.generator); auto ptr = a.data(); for(size_t index=0;index<a.size();++index) BOOST_CHECK_EQUAL(a[index],*(ptr++)); } //======================================================================== BOOST_AUTO_TEST_CASE_TEMPLATE(test_linear_access_at,AT,array_types) { typedef test_mdarray_fixture<AT> fixture_type; typedef typename fixture_type::value_type value_type; fixture_type fixture; auto a = AT::create(fixture.shape); const AT &ca = a; for(size_t index=0;index<a.size();++index) { value_type v = fixture.generator(); a.at(index) = v; BOOST_CHECK_EQUAL(a.at(index),v); BOOST_CHECK_EQUAL(ca.at(index),v); } BOOST_CHECK_THROW(a.at(a.size()),index_error); } //======================================================================== BOOST_AUTO_TEST_CASE_TEMPLATE(test_linear_access_iter,AT,array_types) { typedef test_mdarray_fixture<AT> fixture_type; typedef typename fixture_type::value_type value_type; fixture_type fixture; auto a = AT::create(fixture.shape); typename AT::iterator iter = a.begin(); typename AT::const_iterator citer = a.begin(); for(;iter!=a.end();++iter,++citer) { value_type v = fixture.generator(); *iter = v; BOOST_CHECK_EQUAL(*iter,v); BOOST_CHECK_EQUAL(*citer,v); } } //======================================================================== BOOST_AUTO_TEST_CASE_TEMPLATE(test_linear_access_riter,AT,array_types) { typedef test_mdarray_fixture<AT> fixture_type; typedef typename fixture_type::value_type value_type; fixture_type fixture; auto a = AT::create(fixture.shape); typename AT::reverse_iterator iter = a.rbegin(); typename AT::const_reverse_iterator citer = a.rbegin(); for(;iter!=a.rend();++iter,++citer) { value_type v = fixture.generator(); *iter = v; BOOST_CHECK_EQUAL(*iter,v); BOOST_CHECK_EQUAL(*citer,v); } } //======================================================================== BOOST_AUTO_TEST_CASE_TEMPLATE(test_multiindex_access,AT,array_types) { typedef test_mdarray_fixture<AT> fixture_type; typedef typename fixture_type::value_type value_type; fixture_type fixture; auto a = AT::create(fixture.shape); for(size_t i=0;i<fixture.shape[0];i++) for(size_t j=0;j<fixture.shape[1];j++) for(size_t k=0;k<fixture.shape[2];k++) { value_type v = fixture.generator(); a(i,j,k) = v; BOOST_CHECK_EQUAL(a(i,j,k),v); } } //======================================================================== BOOST_AUTO_TEST_CASE_TEMPLATE(test_muldiindex_access_container,AT,array_types) { test_multiindex_access_with_container<std::vector<size_t>,AT>(); test_multiindex_access_with_container<std::array<size_t,3>,AT>(); test_multiindex_access_with_container<std::list<size_t>,AT>(); test_multiindex_access_with_container<std::vector<uint64>,AT>(); test_multiindex_access_with_container<std::array<uint64,3>,AT>(); test_multiindex_access_with_container<std::list<uint64>,AT>(); } BOOST_AUTO_TEST_SUITE_END()
pni-libraries/libpniio
test/arrays/mdarray_test.cpp
C++
gpl-2.0
9,878
/** * Setup (required for Joomla! 3) */ if(typeof(akeeba) == 'undefined') { var akeeba = {}; } if(typeof(akeeba.jQuery) == 'undefined') { akeeba.jQuery = jQuery.noConflict(); } akeeba.jQuery(document).ready(function($){ function atsAssignmentClick() { var parent = akeeba.jQuery(this).parent('td'); var id = akeeba.jQuery(this).parents('td').find('input.ticket_id').val(); var hide = ['.loading img', '.loading .icon-warning-sign']; var show = ['.loading .icon-ok']; var assign_to = 0; if(akeeba.jQuery(this).hasClass('assignme')) { assign_to = akeeba.jQuery('#user').val(); } else if(akeeba.jQuery(this).parent('.assignto')) { assign_to = akeeba.jQuery(this).parent().find('input.assignto').val(); } if(this.hasClass('unassign')){ hide.push('.unassign'); show.push('.assignme'); } else{ hide.push('.assignme'); show.push('.unassign'); } var structure = { _rootElement: this, type: "POST", dataType: 'json', url : ATS_ROOT_URL + 'index.php?option=com_ats&view=ticket&format=json&' + akeeba.jQuery('#token').attr('name') + '=1', data: { 'task' : 'assign', 'id' : id, 'assigned_to' : assign_to }, beforeSend: function() { var wait = akeeba.jQuery(this._rootElement).parents('td').find('.loading'); wait.css('display','inline').find('i').css('display', 'none'); wait.find('img').css('display', 'inline-block'); }, success: function(responseJSON) { var assigned = akeeba.jQuery(this._rootElement).parents('td').find('.assigned_to'); var unassign = akeeba.jQuery(this._rootElement).hasClass('unassign'); if(responseJSON.result == true){ assigned.html(responseJSON.assigned); unassign ? assigned.removeClass('badge-info') : assigned.addClass('badge-info'); for (var i = 0; i < hide.length; i++) { var elementDefinition = hide[i]; akeeba.jQuery(this._rootElement).parents('td').find(elementDefinition).css('display', 'none'); } for (var i = 0; i < show.length; i++) { var elementDefinition = show[i]; akeeba.jQuery(this._rootElement).parents('td').find(elementDefinition).css('display', 'inline-block'); } } else { var wait = akeeba.jQuery(this._rootElement).parents('td').find('.loading'); wait.find('.icon-ok,img').css('display', 'none'); wait.find('.icon-warning-sign').show('fast'); } } }; akeeba.jQuery.ajax( structure ); } akeeba.jQuery('.unassign a').click(atsAssignmentClick); akeeba.jQuery('.assignme a').click(atsAssignmentClick); akeeba.jQuery('.assignto li a').click(atsAssignmentClick); akeeba.jQuery('.select-status li a').click(function(){ var image = akeeba.jQuery(this).parent().find('img'); var self = this; akeeba.jQuery.ajax(ATS_ROOT_URL + 'index.php?option=com_ats&view=tickets&task=ajax_set_status&format=json&'+jQuery('#token').attr('name')+'=1',{ type : 'POST', dataType : 'json', data : { 'id' : akeeba.jQuery(this).parents('tr').find('.ats_ticket_id').val(), 'status' : akeeba.jQuery(this).data('status') }, beforeSend : function(){ image.show(); }, success : function(responseJSON){ image.hide(); if(responseJSON.err){ alert(responseJSON.err); } else{ var label = akeeba.jQuery(self).parents('td').find('span[class*="label-"]'); label.attr('class', 'ats-status label pull-right ' + responseJSON.ats_class).html(responseJSON.msg); } } }) }) });
SirPiter/folk
www/media/com_ats/js/tickets.js
JavaScript
gpl-2.0
3,563
/* * BackFS Filesystem Cache * Copyright (c) 2010-2014 William R. Fraser */ #define _XOPEN_SOURCE 500 // for pread() #include "fscache.h" #include <stdio.h> #include <stdlib.h> #include <stdint.h> #include <stdbool.h> #include <stddef.h> #include <errno.h> #include <string.h> #include <unistd.h> #include <sys/stat.h> #include <sys/statvfs.h> #include <sys/types.h> #include <dirent.h> #include <fcntl.h> #include <libgen.h> #include <limits.h> #include <pthread.h> static pthread_mutex_t lock; #define BACKFS_LOG_SUBSYS "Cache" #include "global.h" #include "fsll.h" #include "util.h" extern int backfs_log_level; extern bool backfs_log_stderr; static char *cache_dir; static uint64_t cache_size; static volatile uint64_t cache_used_size = 0; struct bucket_node { uint32_t number; struct bucket_node* next; }; static struct bucket_node * volatile to_check; static bool use_whole_device; static uint64_t bucket_max_size; uint64_t prepare_buckets_size_check(const char *root) { INFO("taking inventory of cache directory\n"); uint64_t total = 0; struct dirent *e = malloc(offsetof(struct dirent, d_name) + PATH_MAX + 1); struct dirent *result = e; DIR *dir = opendir(root); struct bucket_node* volatile * next = &to_check; while (readdir_r(dir, e, &result) == 0 && result != NULL) { if (e->d_name[0] < '0' || e->d_name[0] > '9') continue; *next = (struct bucket_node*)malloc(sizeof(struct bucket_node)); (*next)->number = atoi(e->d_name); next = &((*next)->next); *next = NULL; ++total; } closedir(dir); FREE(e); return total; } /* * returns the bucket number corresponding to a bucket path * i.e. reads the number off the end. */ uint32_t bucket_path_to_number(const char *bucketpath) { uint32_t number = 0; size_t s = strlen(bucketpath); size_t i; for (i = 1; i < s; i++) { char c = bucketpath[s - i]; if (c < '0' || c > '9') { i--; break; } } for (i = s - i; i < s; i++) { number *= 10; number += (bucketpath[i] - '0'); } return number; } bool is_unchecked(const char* path) { uint32_t number = bucket_path_to_number(path); struct bucket_node* node = to_check; while(node) { if (node->number == number) return true; node = node->next; } return false; } void* check_buckets_size(void* arg) { INFO("starting cache size check\n"); struct stat s; struct bucket_node* bucket; if (arg != NULL) { abort(); } char buf[PATH_MAX]; while (to_check) { pthread_mutex_lock(&lock); bucket = to_check; if (bucket) { s.st_size = 0; snprintf(buf, PATH_MAX, "%s/buckets/%u/data", cache_dir, bucket->number); if (stat(buf, &s) == -1 && errno != ENOENT) { PERROR("stat in get_cache_used_size"); ERROR("\tcaused by stat(%s)\n", buf); abort(); } DEBUG("bucket %u: %llu bytes\n", bucket->number, (unsigned long long) s.st_size); cache_used_size -= bucket_max_size - s.st_size; to_check = bucket->next; } pthread_mutex_unlock(&lock); free(bucket); } INFO("finished cache size check: %llu bytes used\n", cache_used_size); return NULL; } uint64_t get_cache_fs_free_size(const char *root) { struct statvfs s; if (statvfs(root, &s) == -1) { PERROR("statfs in get_cache_fs_free_size"); return 0; } uint64_t dev_free = (uint64_t) s.f_bavail * s.f_bsize; return dev_free; } /* * Initialize the cache. */ void cache_init(const char *a_cache_dir, uint64_t a_cache_size, uint64_t a_bucket_max_size) { cache_dir = (char*)malloc(strlen(a_cache_dir)+1); strcpy(cache_dir, a_cache_dir); cache_size = a_cache_size; use_whole_device = (cache_size == 0); char bucket_dir[PATH_MAX]; snprintf(bucket_dir, PATH_MAX, "%s/buckets", cache_dir); uint64_t number_of_buckets = prepare_buckets_size_check(bucket_dir); INFO("%llu buckets in cache dir\n", (unsigned long long) number_of_buckets); cache_used_size = number_of_buckets * a_bucket_max_size; INFO("Estimated %llu bytes used in cache dir\n", (unsigned long long) cache_used_size); uint64_t cache_free_size = get_cache_fs_free_size(bucket_dir); INFO("%llu bytes free in cache dir\n", (unsigned long long) cache_free_size); bucket_max_size = a_bucket_max_size; if (number_of_buckets > 0) { pthread_t thread; if (pthread_create(&thread, NULL, &check_buckets_size, NULL) != 0) { PERROR("cache_init: error creating checked thread"); abort(); } } } const char * bucketname(const char *path) { return fsll_basename(path); } void dump_queues() { #ifdef FSLL_DUMP fprintf(stderr, "BackFS Used Bucket Queue:\n"); fsll_dump(cache_dir, "buckets/head", "buckets/tail"); fprintf(stderr, "BackFS Free Bucket Queue:\n"); fsll_dump(cache_dir, "buckets/free_head", "buckets/free_tail"); #endif //FSLL_DUMP } /* * don't use this function directly. */ char * makebucket(uint64_t number) { char *new_bucket = fsll_make_entry(cache_dir, "buckets", number); fsll_insert_as_head(cache_dir, new_bucket, "buckets/head", "buckets/tail"); return new_bucket; } /* * make a new bucket * * either re-use one from the free queue, * or increment the next_bucket_number file and return that. * * If one from the free queue is returned, that bucket is made the head of the * used queue. */ char * next_bucket(void) { char *bucket = fsll_getlink(cache_dir, "buckets/free_head"); if (bucket != NULL) { DEBUG("re-using free bucket %s\n", bucketname(bucket)); // disconnect from free queue fsll_disconnect(cache_dir, bucket, "buckets/free_head", "buckets/free_tail"); // make head of the used queue fsll_insert_as_head(cache_dir, bucket, "buckets/head", "buckets/tail"); return bucket; } else { char nbnpath[PATH_MAX]; snprintf(nbnpath, PATH_MAX, "%s/buckets/next_bucket_number", cache_dir); uint64_t next = 0; FILE *f = fopen(nbnpath, "r+"); if (f == NULL && errno != ENOENT) { PERROR("open next_bucket"); return makebucket(0); } else { if (f != NULL) { // we had a number already there; read it if (fscanf(f, "%llu", (unsigned long long *)&next) != 1) { ERROR("unable to read next_bucket\n"); fclose(f); return makebucket(0); } f = freopen(nbnpath, "w+", f); } else { // next_bucket_number doesn't exist; create it and write a 1. f = fopen(nbnpath, "w+"); if (f == NULL) { PERROR("open next_bucket again"); return makebucket(0); } } // write the next number if (f == NULL) { PERROR("fdopen for writing in next_bucket"); return makebucket(0); } fprintf(f, "%llu\n", (unsigned long long) next+1); fclose(f); } DEBUG("making new bucket %lu\n", (unsigned long) next); char *new_bucket = makebucket(next); return new_bucket; } } /* * moves a bucket to the head of the used queue */ void bucket_to_head(const char *bucketpath) { DEBUG("bucket_to_head(%s)\n", bucketpath); fsll_to_head(cache_dir, bucketpath, "buckets/head", "buckets/tail"); } /* * Starting at the dirname of path, remove empty directories upwards in the * path heirarchy. * * Stops when it gets to <cache_dir>/buckets or <cache_dir>/map */ void trim_directory(const char *path) { size_t len = strlen(path); char *copy = (char*)malloc(len+1); strncpy(copy, path, len+1); char map[PATH_MAX]; char buckets[PATH_MAX]; snprintf(map, PATH_MAX, "%s/map", cache_dir); snprintf(buckets, PATH_MAX, "%s/buckets", cache_dir); char *dir = dirname(copy); while ((strcmp(dir, map) != 0) && (strcmp(dir, buckets) != 0)) { DIR *d = opendir(dir); struct dirent *e; bool found_mtime = false; while ((e = readdir(d)) != NULL) { if (e->d_name[0] == '.') continue; // remove mtime files, if found if (strcmp(e->d_name, "mtime") == 0) { struct stat s; char mtime[PATH_MAX]; snprintf(mtime, PATH_MAX, "%s/mtime", dir); stat(mtime, &s); if (S_IFREG & s.st_mode) { found_mtime = true; continue; } } // if we got here, the directory has entries DEBUG("directory has entries -- in %s found '%s'\n", dir, e->d_name); closedir(d); FREE(copy); return; } if (found_mtime) { char mtime[PATH_MAX]; snprintf(mtime, PATH_MAX, "%s/mtime", dir); if (unlink(mtime) == -1) { PERROR("in trim_directory, unable to unlink mtime file"); ERROR("\tpath was %s\n", mtime); } else { DEBUG("removed mtime file %s/mtime\n", dir); } } closedir(d); d = NULL; int result = rmdir(dir); if (result == -1) { if (errno != EEXIST && errno != ENOTEMPTY) { PERROR("in trim_directory, rmdir"); } WARN("in trim_directory, directory still not empty, but how? path was %s\n", dir); FREE(copy); return; } else { DEBUG("removed empty map directory %s\n", dir); } dir = dirname(dir); } FREE(copy); } /* * free a bucket * * moves bucket from the tail of the used queue to the tail of the free queue, * deletes the data in the bucket * returns the size of the data deleted */ uint64_t free_bucket_real(const char *bucketpath, bool free_in_the_middle_is_bad) { char *parent = fsll_getlink(bucketpath, "parent"); if (parent && fsll_file_exists(parent, NULL)) { DEBUG("bucket parent: %s\n", parent); if (unlink(parent) == -1) { PERROR("unlink parent in free_bucket"); } // if this was the last block, remove the directory trim_directory(parent); } FREE(parent); fsll_makelink(bucketpath, "parent", NULL); if (free_in_the_middle_is_bad) { char *n = fsll_getlink(bucketpath, "next"); if (n != NULL) { ERROR("bucket freed (#%lu) was not the queue tail\n", (unsigned long) bucket_path_to_number(bucketpath)); FREE(n); return 0; } } fsll_disconnect(cache_dir, bucketpath, "buckets/head", "buckets/tail"); fsll_insert_as_tail(cache_dir, bucketpath, "buckets/free_head", "buckets/free_tail"); char data[PATH_MAX]; snprintf(data, PATH_MAX, "%s/data", bucketpath); struct stat s; if (stat(data, &s) == -1) { PERROR("stat data in free_bucket"); } pthread_mutex_lock(&lock); uint64_t result = 0; if (unlink(data) == -1) { PERROR("unlink data in free_bucket"); } else { result = (uint64_t) s.st_size; if (!is_unchecked(bucketpath)) { cache_used_size -= result; } } pthread_mutex_unlock(&lock); return result; } uint64_t free_bucket_mid_queue(const char *bucketpath) { return free_bucket_real(bucketpath, false); } uint64_t free_bucket(const char *bucketpath) { return free_bucket_real(bucketpath, true); } /* * do not use this function directly */ int cache_invalidate_bucket(const char *filename, uint32_t block, const char *bucket) { DEBUG("invalidating block %lu of file %s\n", (unsigned long) block, filename); uint64_t freed_size = free_bucket_mid_queue(bucket); DEBUG("freed %llu bytes in bucket %s\n", (unsigned long long) freed_size, bucketname(bucket)); return 0; } int cache_invalidate_file_real(const char *filename, bool error_if_not_exist) { char mappath[PATH_MAX]; snprintf(mappath, PATH_MAX, "%s/map%s", cache_dir, filename); DIR *d = opendir(mappath); if (d == NULL) { if (errno != ENOENT || error_if_not_exist) { PERROR("opendir in cache_invalidate"); } return -errno; } struct dirent *e = malloc(offsetof(struct dirent, d_name) + PATH_MAX + 1); struct dirent *result = e; while (readdir_r(d, e, &result) == 0 && result != NULL) { // probably not needed, because trim_directory would take care of the // mtime file, but might as well do it now to save time. if (strcmp(e->d_name, "mtime") == 0) { char mtime[PATH_MAX]; snprintf(mtime, PATH_MAX, "%s/mtime", mappath); DEBUG("removed mtime file %s\n", mtime); unlink(mtime); continue; } if (e->d_name[0] < '0' || e->d_name[0] > '9') continue; char *bucket = fsll_getlink(mappath, e->d_name); uint32_t block; sscanf(e->d_name, "%lu", (unsigned long *)&block); cache_invalidate_bucket(filename, block, bucket); FREE(bucket); } FREE(e); closedir(d); return 0; } int cache_invalidate_file_(const char *filename, bool error_if_not_exist) { pthread_mutex_lock(&lock); int retval = cache_invalidate_file_real(filename, error_if_not_exist); pthread_mutex_unlock(&lock); return retval; } int cache_invalidate_file(const char *filename) { return cache_invalidate_file_(filename, true); } int cache_try_invalidate_file(const char *filename) { return cache_invalidate_file_(filename, false); } int cache_invalidate_block_(const char *filename, uint32_t block, bool warn_if_not_exist) { char mappath[PATH_MAX]; snprintf(mappath, PATH_MAX, "map%s/%lu", filename, (unsigned long) block); pthread_mutex_lock(&lock); char *bucket = fsll_getlink(cache_dir, mappath); if (bucket == NULL) { if (warn_if_not_exist) { WARN("Cache invalidation: block %lu of file %s doesn't exist.\n", (unsigned long) block, filename); } pthread_mutex_unlock(&lock); return -ENOENT; } cache_invalidate_bucket(filename, block, bucket); FREE(bucket); pthread_mutex_unlock(&lock); return 0; } int cache_invalidate_block(const char *filename, uint32_t block) { return cache_invalidate_block_(filename, block, true); } int cache_try_invalidate_block(const char *filename, uint32_t block) { return cache_invalidate_block_(filename, block, false); } int cache_try_invalidate_blocks_above(const char *filename, uint32_t block) { DEBUG("trying to invalidate blocks >= %ld in %s\n", block, filename); int ret = 0; DIR *mapdir = NULL; bool locked = false; struct dirent *e = NULL; char mappath[PATH_MAX]; snprintf(mappath, PATH_MAX, "%s/map%s", cache_dir, filename); pthread_mutex_lock(&lock); locked = true; mapdir = opendir(mappath); if (mapdir == NULL) { ret = -errno; goto exit; } e = malloc(offsetof(struct dirent, d_name) + PATH_MAX + 1); struct dirent *result = e; while ((readdir_r(mapdir, e, &result) == 0) && (result != NULL)) { if ((e->d_name[0] < '0') || (e->d_name[0] > '9')) continue; uint32_t block_found; sscanf(e->d_name, "%lu", &block_found); if (block_found >= block) { char *bucket = fsll_getlink(mappath, e->d_name); cache_invalidate_bucket(filename, block_found, bucket); FREE(bucket); } } exit: closedir(mapdir); FREE(e); if (locked) pthread_mutex_unlock(&lock); return ret; } int cache_free_orphan_buckets(void) { char bucketdir[PATH_MAX]; snprintf(bucketdir, PATH_MAX, "%s/buckets", cache_dir); pthread_mutex_lock(&lock); DIR *d = opendir(bucketdir); if (d == NULL) { PERROR("opendir in cache_free_orphan_buckets"); pthread_mutex_unlock(&lock); return -1*errno; } struct dirent *e = malloc(offsetof(struct dirent, d_name) + PATH_MAX + 1); struct dirent *result = e; while (readdir_r(d, e, &result) == 0 && result != NULL) { if (e->d_name[0] < '0' || e->d_name[0] > '9') continue; char bucketpath[PATH_MAX]; snprintf(bucketpath, PATH_MAX, "%s/buckets/%s", cache_dir, e->d_name); char *parent = fsll_getlink(bucketpath, "parent"); if (fsll_file_exists(bucketpath, "data") && (parent == NULL || !fsll_file_exists(parent, NULL))) { DEBUG("bucket %s is an orphan\n", e->d_name); if (parent) { DEBUG("\tparent was %s\n", parent); } free_bucket_mid_queue(bucketpath); } FREE(parent); } closedir(d); FREE(e); pthread_mutex_unlock(&lock); return 0; } /* * Read a block from the cache. * Important: you can specify less than one block, but not more. * Nor can a read be across block boundaries. * * mtime is the file modification time. If what's in the cache doesn't match * this, the cache data is invalidated and this function returns -1 and sets * ENOENT. * * Returns 0 on success. * On error returns -1 and sets errno. * In particular, if the block is not in the cache, sets ENOENT */ int cache_fetch(const char *filename, uint32_t block, uint64_t offset, char *buf, uint64_t len, uint64_t *bytes_read, time_t mtime) { if (offset + len > bucket_max_size || filename == NULL) { errno = EINVAL; return -1; } if (len == 0) { *bytes_read = 0; return 0; } DEBUG("getting block %lu of file %s\n", (unsigned long) block, filename); //### pthread_mutex_lock(&lock); char mapfile[PATH_MAX]; snprintf(mapfile, PATH_MAX, "%s/map%s/%lu", cache_dir, filename, (unsigned long) block); char bucketpath[PATH_MAX]; ssize_t bplen; if ((bplen = readlink(mapfile, bucketpath, PATH_MAX-1)) == -1) { if (errno == ENOENT || errno == ENOTDIR) { DEBUG("block not in cache\n"); errno = ENOENT; pthread_mutex_unlock(&lock); return -1; } else { PERROR("readlink error"); errno = EIO; pthread_mutex_unlock(&lock); return -1; } } bucketpath[bplen] = '\0'; bucket_to_head(bucketpath); uint64_t bucket_mtime; char mtimepath[PATH_MAX]; snprintf(mtimepath, PATH_MAX, "%s/map%s/mtime", cache_dir, filename); FILE *f = fopen(mtimepath, "r"); if (f == NULL) { PERROR("open mtime file failed"); bucket_mtime = 0; // will cause invalidation } else { if (fscanf(f, "%llu", (unsigned long long *) &bucket_mtime) != 1) { ERROR("error reading mtime file"); // debug char buf[4096]; fseek(f, 0, SEEK_SET); size_t b = fread(buf, 1, 4096, f); buf[b] = '\0'; ERROR("mtime file contains: %u bytes: %s", (unsigned int) b, buf); fclose(f); f = NULL; unlink(mtimepath); bucket_mtime = 0; // will cause invalidation } } if (f) fclose(f); if (bucket_mtime != (uint64_t)mtime) { // mtime mismatch; invalidate and return if (bucket_mtime < (uint64_t)mtime) { DEBUG("cache data is %llu seconds older than the backing data\n", (unsigned long long) mtime - bucket_mtime); } else { DEBUG("cache data is %llu seconds newer than the backing data\n", (unsigned long long) bucket_mtime - mtime); } cache_invalidate_file_real(filename, true); errno = ENOENT; pthread_mutex_unlock(&lock); return -1; } // [cache_dir]/buckets/%lu/data char bucketdata[PATH_MAX]; snprintf(bucketdata, PATH_MAX, "%s/data", bucketpath); uint64_t size = 0; struct stat stbuf; if (stat(bucketdata, &stbuf) == -1) { PERROR("stat on bucket error"); errno = EIO; pthread_mutex_unlock(&lock); return -1; } size = (uint64_t) stbuf.st_size; if (size < offset) { WARN("offset for read is past the end: %llu vs %llu, bucket %s\n", (unsigned long long) offset, (unsigned long long) size, bucketname(bucketpath)); pthread_mutex_unlock(&lock); *bytes_read = 0; return 0; } /* if (e->bucket->size - offset < len) { WARN("length + offset for read is past the end\n"); errno = ENXIO; FREE(f); pthread_mutex_unlock(&lock); return -1; } */ int fd = open(bucketdata, O_RDONLY); if (fd == -1) { PERROR("error opening file from cache dir"); errno = EBADF; pthread_mutex_unlock(&lock); return -1; } *bytes_read = pread(fd, buf, len, offset); if (*bytes_read == -1) { PERROR("error reading file from cache dir"); errno = EIO; close(fd); pthread_mutex_unlock(&lock); return -1; } if (*bytes_read != len) { DEBUG("read fewer than requested bytes from cache file: %llu instead of %llu\n", (unsigned long long) *bytes_read, (unsigned long long) len ); /* errno = EIO; FREE(f); FREE(cachefile); close(fd); pthread_mutex_unlock(&lock); return -1; */ } close(fd); pthread_mutex_unlock(&lock); //### return 0; } uint64_t free_tail_bucket() { uint64_t freed_bytes = 0; char *tail = fsll_getlink(cache_dir, "buckets/tail"); if (tail == NULL) { ERROR("can't free the tail bucket, no buckets in queue!\n"); goto exit; } freed_bytes = free_bucket(tail); DEBUG("freed %llu bytes in bucket %lu\n", (unsigned long long)freed_bytes, (unsigned long)bucket_path_to_number(tail)); exit: FREE(tail); return freed_bytes; } void make_space_available(uint64_t bytes_needed) { uint64_t bytes_freed = 0; if (bytes_needed == 0) return; uint64_t dev_free = get_cache_fs_free_size(cache_dir); if (dev_free >= bytes_needed) { // device has plenty if (use_whole_device) { return; } else { // cache_size is limiting factor if (cache_used_size + bytes_needed <= cache_size) { return; } else { bytes_needed = (cache_used_size + bytes_needed) - cache_size; } } } else { // dev_free is limiting factor bytes_needed = bytes_needed - dev_free; } DEBUG("need to free %llu bytes\n", (unsigned long long) bytes_needed); while (bytes_freed < bytes_needed) { bytes_freed += free_tail_bucket(); } DEBUG("freed %llu bytes total\n", (unsigned long long) bytes_freed); } /* * Adds a data block to the cache. * Important: this must be the FULL block. All subsequent reads will * assume that the full block is here. */ int cache_add(const char *filename, uint32_t block, const char *buf, uint64_t len, time_t mtime) { if (len > bucket_max_size) { errno = EOVERFLOW; return -1; } if (len == 0) { return 0; } char fileandblock[PATH_MAX]; snprintf(fileandblock, PATH_MAX, "map%s/%lu", filename, (unsigned long) block); DEBUG("writing %llu bytes to %s\n", (unsigned long long) len, fileandblock); //### pthread_mutex_lock(&lock); char *bucketpath = fsll_getlink(cache_dir, fileandblock); if (bucketpath != NULL) { if (fsll_file_exists(bucketpath, "data")) { WARN("data already exists in cache\n"); FREE(bucketpath); pthread_mutex_unlock(&lock); return 0; } } char *filemap = (char*)malloc(strlen(filename) + 4); snprintf(filemap, strlen(filename)+4, "map%s", filename); char *full_filemap_dir = (char*)malloc(strlen(cache_dir) + 5 + strlen(filename) + 1); snprintf(full_filemap_dir, strlen(cache_dir)+5+strlen(filename)+1, "%s/map%s/", cache_dir, filename); DEBUG("map file = %s\n", filemap); DEBUG("full filemap dir = %s\n", full_filemap_dir); if (!fsll_file_exists(cache_dir, filemap)) { FREE(filemap); size_t i; // start from "$cache_dir/map/" for (i = strlen(cache_dir) + 5; i < strlen(full_filemap_dir); i++) { if (full_filemap_dir[i] == '/') { char *component = (char*)malloc(i+1); strncpy(component, full_filemap_dir, i+1); component[i] = '\0'; DEBUG("making %s\n", component); if(mkdir(component, 0700) == -1 && errno != EEXIST) { if (errno == ENOSPC) { // try to free some space DEBUG("mkdir says ENOSPC, freeing and trying again\n"); free_tail_bucket(); errno = EAGAIN; } else { PERROR("mkdir in cache_add"); ERROR("\tcaused by mkdir(%s)\n", component); errno = EIO; } FREE(component); FREE(full_filemap_dir); pthread_mutex_unlock(&lock); return -1; } FREE(component); } } } else { FREE(filemap); } FREE(full_filemap_dir); make_space_available(len); FREE(bucketpath); bucketpath = next_bucket(); DEBUG("bucket path = %s\n", bucketpath); fsll_makelink(cache_dir, fileandblock, bucketpath); char *fullfilemap = (char*)malloc(PATH_MAX); snprintf(fullfilemap, PATH_MAX, "%s/%s", cache_dir, fileandblock); fsll_makelink(bucketpath, "parent", fullfilemap); FREE(fullfilemap); // write mtime char mtimepath[PATH_MAX]; snprintf(mtimepath, PATH_MAX, "%s/map%s/mtime", cache_dir, filename); FILE *f = fopen(mtimepath, "w"); if (f == NULL) { PERROR("opening mtime file in cache_add failed"); } else { fprintf(f, "%llu\n", (unsigned long long) mtime); fclose(f); } // finally, write data char datapath[PATH_MAX]; snprintf(datapath, PATH_MAX, "%s/data", bucketpath); int fd = open(datapath, O_WRONLY | O_CREAT, S_IRUSR | S_IWUSR); if (fd == -1) { PERROR("open in cache_add"); ERROR("\tcaused by open(%s, O_WRONLY|O_CREAT)\n", datapath); errno = EIO; pthread_mutex_unlock(&lock); return -1; } ssize_t bytes_written = write(fd, buf, len); if (bytes_written == -1) { if (errno == ENOSPC) { DEBUG("nothing written (no space on device)\n"); bytes_written = 0; } else { PERROR("write in cache_add"); errno = EIO; close(fd); pthread_mutex_unlock(&lock); return -1; } } DEBUG("%llu bytes written to cache\n", (unsigned long long) bytes_written); bool unchecked = is_unchecked(bucketpath); if (!unchecked) { cache_used_size += bytes_written; } // for some reason (filesystem metadata overhead?) this may need to loop a // few times to write everything out. while (bytes_written != len) { DEBUG("not all bytes written to cache\n"); // Try again, more forcefully this time. // Don't care if the FS says it has space, make some space anyway. free_tail_bucket(); ssize_t more_bytes_written = write(fd, buf + bytes_written, len - bytes_written); if (more_bytes_written == -1) { if (errno == ENOSPC) { // this is normal DEBUG("nothing written (no space on device)\n"); more_bytes_written = 0; } else { PERROR("write error"); close(fd); pthread_mutex_unlock(&lock); return -EIO; } } DEBUG("%llu more bytes written to cache (%llu total)\n", (unsigned long long) more_bytes_written, (unsigned long long) more_bytes_written + bytes_written); if (!unchecked) { cache_used_size += more_bytes_written; } bytes_written += more_bytes_written; } DEBUG("size now %llu bytes of %llu bytes (%lf%%)\n", (unsigned long long) cache_used_size, (unsigned long long) cache_size, (double)100 * cache_used_size / cache_size ); dump_queues(); close(fd); pthread_mutex_unlock(&lock); //### FREE(bucketpath); return 0; } int cache_has_file_real(const char *filename, uint64_t *cached_byte_count, bool do_lock) { DEBUG("cache_has_file %s\n", filename); int ret = 0; bool locked = false; char *mapdir = NULL; char *data = NULL; DIR *dir = NULL; if (filename == NULL || cached_byte_count == NULL) { errno = EINVAL; ret = -1; goto exit; } if (do_lock) { pthread_mutex_lock(&lock); locked = true; } // Look up the file in the map. asprintf(&mapdir, "%s/map%s", cache_dir, filename); dir = opendir(mapdir); if (dir == NULL) { if (errno == ENOENT) { DEBUG("not in cache (%s)\n", mapdir); ret = 0; goto exit; } else { PERROR("opendir"); ERROR("\topendir on %s\n", mapdir); ret = -EIO; goto exit; } } // Check if it's a file or directory (see if it has an mtime file). asprintf(&data, "%s/mtime", mapdir); bool is_file = false; struct stat mtime_stat = {0}; if (0 == stat(data, &mtime_stat)) { is_file = (mtime_stat.st_mode & S_IFREG) != 0; } else if (errno != ENOENT) { PERROR("stat"); ERROR("\tstat on %s\n", mapdir); ret = -EIO; goto exit; } // Loop over the sub-entries in the map. struct dirent *dirent = NULL; while ((dirent = readdir(dir)) != NULL) { if (dirent->d_name[0] != '.' && strcmp(dirent->d_name, "mtime") != 0) { FREE(data); if (is_file) { asprintf(&data, "%s/%s/data", mapdir, dirent->d_name); struct stat statbuf = {0}; if (0 != stat(data, &statbuf)) { PERROR("stat"); ERROR("\tstat on %s\n", data); ret = -EIO; goto exit; } DEBUG("%llu bytes in %s\n", statbuf.st_size, data); *cached_byte_count += statbuf.st_size; } else { asprintf(&data, "%s/%s", filename, dirent->d_name); ret = cache_has_file_real(data, cached_byte_count, false /*don't lock*/); if (ret != 0) { break; } } } } exit: if (locked) pthread_mutex_unlock(&lock); FREE(mapdir); FREE(data); closedir(dir); return ret; } int cache_has_file(const char *filename, uint64_t *cached_bytes) { *cached_bytes = 0; return cache_has_file_real(filename, cached_bytes, true); } int cache_rename(const char *path, const char *path_new) { DEBUG("cache_rename %s\n\t%s\n", path, path_new); int ret = 0; char *mapdir = NULL; char *mapdir_new = NULL; DIR *dir = NULL; char *parentlink = NULL; if (path == NULL || path_new == NULL) { errno = EINVAL; ret = -1; goto exit; } // Look up and rename the cache map dir. asprintf(&mapdir, "%s/map%s", cache_dir, path); asprintf(&mapdir_new, "%s/map%s", cache_dir, path_new); ret = rename(mapdir, mapdir_new); if (0 != ret) { if (ENOENT == errno) { DEBUG("not in cache: %s\n", path); ret = 0; } else { PERROR("rename"); ret = -EIO; } goto exit; } // Next, need to fix all the buckets' parent links. dir = opendir(mapdir_new); if (dir == NULL) { PERROR("opendir"); ERROR("\topendir on %s\n", mapdir_new); ret = -EIO; goto exit; } size_t cch_parentlink = strlen(mapdir_new) + 20; parentlink = (char*)malloc(cch_parentlink); struct dirent *dirent = NULL; while ((dirent = readdir(dir)) != NULL) { if (dirent->d_name[0] != '.' && strcmp(dirent->d_name, "mtime") != 0) { snprintf(parentlink, cch_parentlink, "%s/%s/parent", mapdir_new, dirent->d_name); ret = unlink(parentlink); if (0 != ret) { PERROR("unlink"); ERROR("\tunlink on %s\n", parentlink); ret = -EIO; goto exit; } ret = symlink(mapdir_new, parentlink); if (0 != ret) { PERROR("symlink"); ERROR("\tsymlink from %s\n\tto %s\n", parentlink, mapdir_new); ret = -EIO; goto exit; } } } exit: FREE(mapdir); FREE(mapdir_new); FREE(parentlink); closedir(dir); return ret; } /* This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */
ninoles/backfs
fscache.c
C
gpl-2.0
35,045
/* * Intel 3000/3010 Memory Controller kernel module * Copyright (C) 2007 Akamai Technologies, Inc. * Shamelessly copied from: * Intel D82875P Memory Controller kernel module * (C) 2003 Linux Networx (http://lnxi.com) * * This file may be distributed under the terms of the * GNU General Public License. */ #include <linux/module.h> #include <linux/init.h> #include <linux/pci.h> #include <linux/pci_ids.h> #include <linux/edac.h> #include "edac_core.h" #define I3000_REVISION "1.1" #define EDAC_MOD_STR "i3000_edac" #define I3000_RANKS 8 #define I3000_RANKS_PER_CHANNEL 4 #define I3000_CHANNELS 2 /* Intel 3000 register addresses - device 0 function 0 - DRAM Controller */ #define I3000_MCHBAR 0x44 /* MCH Memory Mapped Register BAR */ #define I3000_MCHBAR_MASK 0xffffc000 #define I3000_MMR_WINDOW_SIZE 16384 #define I3000_EDEAP 0x70 /* Extended DRAM Error Address Pointer (8b) * * 7:1 reserved * 0 bit 32 of address */ #define I3000_DEAP 0x58 /* DRAM Error Address Pointer (32b) * * 31:7 address * 6:1 reserved * 0 Error channel 0/1 */ #define I3000_DEAP_GRAIN (1 << 7) /* * Helper functions to decode the DEAP/EDEAP hardware registers. * * The type promotion here is deliberate; we're deriving an * unsigned long pfn and offset from hardware regs which are u8/u32. */ static inline unsigned long deap_pfn(u8 edeap, u32 deap) { deap >>= PAGE_SHIFT; deap |= (edeap & 1) << (32 - PAGE_SHIFT); return deap; } static inline unsigned long deap_offset(u32 deap) { return deap & ~(I3000_DEAP_GRAIN - 1) & ~PAGE_MASK; } static inline int deap_channel(u32 deap) { return deap & 1; } #define I3000_DERRSYN 0x5c /* DRAM Error Syndrome (8b) * * 7:0 DRAM ECC Syndrome */ #define I3000_ERRSTS 0xc8 /* Error Status Register (16b) * * 15:12 reserved * 11 MCH Thermal Sensor Event * for SMI/SCI/SERR * 10 reserved * 9 LOCK to non-DRAM Memory Flag (LCKF) * 8 Received Refresh Timeout Flag (RRTOF) * 7:2 reserved * 1 Multi-bit DRAM ECC Error Flag (DMERR) * 0 Single-bit DRAM ECC Error Flag (DSERR) */ #define I3000_ERRSTS_BITS 0x0b03 /* bits which indicate errors */ #define I3000_ERRSTS_UE 0x0002 #define I3000_ERRSTS_CE 0x0001 #define I3000_ERRCMD 0xca /* Error Command (16b) * * 15:12 reserved * 11 SERR on MCH Thermal Sensor Event * (TSESERR) * 10 reserved * 9 SERR on LOCK to non-DRAM Memory * (LCKERR) * 8 SERR on DRAM Refresh Timeout * (DRTOERR) * 7:2 reserved * 1 SERR Multi-Bit DRAM ECC Error * (DMERR) * 0 SERR on Single-Bit ECC Error * (DSERR) */ /* Intel MMIO register space - device 0 function 0 - MMR space */ #define I3000_DRB_SHIFT 25 /* 32MiB grain */ #define I3000_C0DRB 0x100 /* Channel 0 DRAM Rank Boundary (8b x 4) * * 7:0 Channel 0 DRAM Rank Boundary Address */ #define I3000_C1DRB 0x180 /* Channel 1 DRAM Rank Boundary (8b x 4) * * 7:0 Channel 1 DRAM Rank Boundary Address */ #define I3000_C0DRA 0x108 /* Channel 0 DRAM Rank Attribute (8b x 2) * * 7 reserved * 6:4 DRAM odd Rank Attribute * 3 reserved * 2:0 DRAM even Rank Attribute * * Each attribute defines the page * size of the corresponding rank: * 000: unpopulated * 001: reserved * 010: 4 KB * 011: 8 KB * 100: 16 KB * Others: reserved */ #define I3000_C1DRA 0x188 /* Channel 1 DRAM Rank Attribute (8b x 2) */ static inline unsigned char odd_rank_attrib(unsigned char dra) { return (dra & 0x70) >> 4; } static inline unsigned char even_rank_attrib(unsigned char dra) { return dra & 0x07; } #define I3000_C0DRC0 0x120 /* DRAM Controller Mode 0 (32b) * * 31:30 reserved * 29 Initialization Complete (IC) * 28:11 reserved * 10:8 Refresh Mode Select (RMS) * 7 reserved * 6:4 Mode Select (SMS) * 3:2 reserved * 1:0 DRAM Type (DT) */ #define I3000_C0DRC1 0x124 /* DRAM Controller Mode 1 (32b) * * 31 Enhanced Addressing Enable (ENHADE) * 30:0 reserved */ enum i3000p_chips { I3000 = 0, }; struct i3000_dev_info { const char *ctl_name; }; struct i3000_error_info { u16 errsts; u8 derrsyn; u8 edeap; u32 deap; u16 errsts2; }; static const struct i3000_dev_info i3000_devs[] = { [I3000] = { .ctl_name = "i3000"}, }; static struct pci_dev *mci_pdev; static int i3000_registered = 1; static struct edac_pci_ctl_info *i3000_pci; static void i3000_get_error_info(struct mem_ctl_info *mci, struct i3000_error_info *info) { struct pci_dev *pdev; pdev = to_pci_dev(mci->dev); /* * This is a mess because there is no atomic way to read all the * registers at once and the registers can transition from CE being * overwritten by UE. */ pci_read_config_word(pdev, I3000_ERRSTS, &info->errsts); if (!(info->errsts & I3000_ERRSTS_BITS)) return; pci_read_config_byte(pdev, I3000_EDEAP, &info->edeap); pci_read_config_dword(pdev, I3000_DEAP, &info->deap); pci_read_config_byte(pdev, I3000_DERRSYN, &info->derrsyn); pci_read_config_word(pdev, I3000_ERRSTS, &info->errsts2); /* * If the error is the same for both reads then the first set * of reads is valid. If there is a change then there is a CE * with no info and the second set of reads is valid and * should be UE info. */ if ((info->errsts ^ info->errsts2) & I3000_ERRSTS_BITS) { pci_read_config_byte(pdev, I3000_EDEAP, &info->edeap); pci_read_config_dword(pdev, I3000_DEAP, &info->deap); pci_read_config_byte(pdev, I3000_DERRSYN, &info->derrsyn); } /* * Clear any error bits. * (Yes, we really clear bits by writing 1 to them.) */ pci_write_bits16(pdev, I3000_ERRSTS, I3000_ERRSTS_BITS, I3000_ERRSTS_BITS); } static int i3000_process_error_info(struct mem_ctl_info *mci, struct i3000_error_info *info, int handle_errors) { int row, multi_chan, channel; unsigned long pfn, offset; multi_chan = mci->csrows[0].nr_channels - 1; if (!(info->errsts & I3000_ERRSTS_BITS)) return 0; if (!handle_errors) return 1; if ((info->errsts ^ info->errsts2) & I3000_ERRSTS_BITS) { edac_mc_handle_ce_no_info(mci, "UE overwrote CE"); info->errsts = info->errsts2; } pfn = deap_pfn(info->edeap, info->deap); offset = deap_offset(info->deap); channel = deap_channel(info->deap); row = edac_mc_find_csrow_by_page(mci, pfn); if (info->errsts & I3000_ERRSTS_UE) edac_mc_handle_ue(mci, pfn, offset, row, "i3000 UE"); else edac_mc_handle_ce(mci, pfn, offset, info->derrsyn, row, multi_chan ? channel : 0, "i3000 CE"); return 1; } static void i3000_check(struct mem_ctl_info *mci) { struct i3000_error_info info; debugf1("MC%d: %s()\n", mci->mc_idx, __func__); i3000_get_error_info(mci, &info); i3000_process_error_info(mci, &info, 1); } static int i3000_is_interleaved(const unsigned char *c0dra, const unsigned char *c1dra, const unsigned char *c0drb, const unsigned char *c1drb) { int i; /* * If the channels aren't populated identically then * we're not interleaved. */ for (i = 0; i < I3000_RANKS_PER_CHANNEL / 2; i++) if (odd_rank_attrib(c0dra[i]) != odd_rank_attrib(c1dra[i]) || even_rank_attrib(c0dra[i]) != even_rank_attrib(c1dra[i])) return 0; /* * If the rank boundaries for the two channels are different * then we're not interleaved. */ for (i = 0; i < I3000_RANKS_PER_CHANNEL; i++) if (c0drb[i] != c1drb[i]) return 0; return 1; } static int i3000_probe1(struct pci_dev *pdev, int dev_idx) { int rc; int i; struct mem_ctl_info *mci = NULL; unsigned long last_cumul_size; int interleaved, nr_channels; unsigned char dra[I3000_RANKS / 2], drb[I3000_RANKS]; unsigned char *c0dra = dra, *c1dra = &dra[I3000_RANKS_PER_CHANNEL / 2]; unsigned char *c0drb = drb, *c1drb = &drb[I3000_RANKS_PER_CHANNEL]; unsigned long mchbar; void __iomem *window; debugf0("MC: %s()\n", __func__); pci_read_config_dword(pdev, I3000_MCHBAR, (u32 *) & mchbar); mchbar &= I3000_MCHBAR_MASK; window = ioremap_nocache(mchbar, I3000_MMR_WINDOW_SIZE); if (!window) { printk(KERN_ERR "i3000: cannot map mmio space at 0x%lx\n", mchbar); return -ENODEV; } c0dra[0] = readb(window + I3000_C0DRA + 0); /* ranks 0,1 */ c0dra[1] = readb(window + I3000_C0DRA + 1); /* ranks 2,3 */ c1dra[0] = readb(window + I3000_C1DRA + 0); /* ranks 0,1 */ c1dra[1] = readb(window + I3000_C1DRA + 1); /* ranks 2,3 */ for (i = 0; i < I3000_RANKS_PER_CHANNEL; i++) { c0drb[i] = readb(window + I3000_C0DRB + i); c1drb[i] = readb(window + I3000_C1DRB + i); } iounmap(window); /* * Figure out how many channels we have. * * If we have what the datasheet calls "asymmetric channels" * (essentially the same as what was called "virtual single * channel mode" in the i82875) then it's a single channel as * far as EDAC is concerned. */ interleaved = i3000_is_interleaved(c0dra, c1dra, c0drb, c1drb); nr_channels = interleaved ? 2 : 1; mci = edac_mc_alloc(0, I3000_RANKS / nr_channels, nr_channels, 0); if (!mci) return -ENOMEM; debugf3("MC: %s(): init mci\n", __func__); mci->dev = &pdev->dev; mci->mtype_cap = MEM_FLAG_DDR2; mci->edac_ctl_cap = EDAC_FLAG_SECDED; mci->edac_cap = EDAC_FLAG_SECDED; mci->mod_name = EDAC_MOD_STR; mci->mod_ver = I3000_REVISION; mci->ctl_name = i3000_devs[dev_idx].ctl_name; mci->dev_name = pci_name(pdev); mci->edac_check = i3000_check; mci->ctl_page_to_phys = NULL; /* * The dram rank boundary (DRB) reg values are boundary addresses * for each DRAM rank with a granularity of 32MB. DRB regs are * cumulative; the last one will contain the total memory * contained in all ranks. * * If we're in interleaved mode then we're only walking through * the ranks of controller 0, so we double all the values we see. */ for (last_cumul_size = i = 0; i < mci->nr_csrows; i++) { u8 value; u32 cumul_size; struct csrow_info *csrow = &mci->csrows[i]; value = drb[i]; cumul_size = value << (I3000_DRB_SHIFT - PAGE_SHIFT); if (interleaved) cumul_size <<= 1; debugf3("MC: %s(): (%d) cumul_size 0x%x\n", __func__, i, cumul_size); if (cumul_size == last_cumul_size) { csrow->mtype = MEM_EMPTY; continue; } csrow->first_page = last_cumul_size; csrow->last_page = cumul_size - 1; csrow->nr_pages = cumul_size - last_cumul_size; last_cumul_size = cumul_size; csrow->grain = I3000_DEAP_GRAIN; csrow->mtype = MEM_DDR2; csrow->dtype = DEV_UNKNOWN; csrow->edac_mode = EDAC_UNKNOWN; } /* * Clear any error bits. * (Yes, we really clear bits by writing 1 to them.) */ pci_write_bits16(pdev, I3000_ERRSTS, I3000_ERRSTS_BITS, I3000_ERRSTS_BITS); rc = -ENODEV; if (edac_mc_add_mc(mci)) { debugf3("MC: %s(): failed edac_mc_add_mc()\n", __func__); goto fail; } /* allocating generic PCI control info */ i3000_pci = edac_pci_create_generic_ctl(&pdev->dev, EDAC_MOD_STR); if (!i3000_pci) { printk(KERN_WARNING "%s(): Unable to create PCI control\n", __func__); printk(KERN_WARNING "%s(): PCI error report via EDAC not setup\n", __func__); } /* get this far and it's successful */ debugf3("MC: %s(): success\n", __func__); return 0; fail: if (mci) edac_mc_free(mci); return rc; } /* returns count (>= 0), or negative on error */ static int __devinit i3000_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) { int rc; debugf0("MC: %s()\n", __func__); if (pci_enable_device(pdev) < 0) return -EIO; rc = i3000_probe1(pdev, ent->driver_data); if (!mci_pdev) mci_pdev = pci_dev_get(pdev); return rc; } static void __devexit i3000_remove_one(struct pci_dev *pdev) { struct mem_ctl_info *mci; debugf0("%s()\n", __func__); if (i3000_pci) edac_pci_release_generic_ctl(i3000_pci); mci = edac_mc_del_mc(&pdev->dev); if (!mci) return; edac_mc_free(mci); } static const struct pci_device_id i3000_pci_tbl[] __devinitdata = { { PCI_VEND_DEV(INTEL, 3000_HB), PCI_ANY_ID, PCI_ANY_ID, 0, 0, I3000}, { 0, } /* 0 terminated list. */ }; MODULE_DEVICE_TABLE(pci, i3000_pci_tbl); static struct pci_driver i3000_driver = { .name = EDAC_MOD_STR, .probe = i3000_init_one, .remove = __devexit_p(i3000_remove_one), .id_table = i3000_pci_tbl, }; static int __init i3000_init(void) { int pci_rc; debugf3("MC: %s()\n", __func__); /* Ensure that the OPSTATE is set correctly for POLL or NMI */ opstate_init(); pci_rc = pci_register_driver(&i3000_driver); if (pci_rc < 0) goto fail0; if (!mci_pdev) { i3000_registered = 0; mci_pdev = pci_get_device(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_3000_HB, NULL); if (!mci_pdev) { debugf0("i3000 pci_get_device fail\n"); pci_rc = -ENODEV; goto fail1; } pci_rc = i3000_init_one(mci_pdev, i3000_pci_tbl); if (pci_rc < 0) { debugf0("i3000 init fail\n"); pci_rc = -ENODEV; goto fail1; } } return 0; fail1: pci_unregister_driver(&i3000_driver); fail0: if (mci_pdev) pci_dev_put(mci_pdev); return pci_rc; } static void __exit i3000_exit(void) { debugf3("MC: %s()\n", __func__); pci_unregister_driver(&i3000_driver); if (!i3000_registered) { i3000_remove_one(mci_pdev); pci_dev_put(mci_pdev); } } module_init(i3000_init); module_exit(i3000_exit); MODULE_LICENSE("GPL"); MODULE_AUTHOR("Akamai Technologies Arthur Ulfeldt/Jason Uhlenkott"); MODULE_DESCRIPTION("MC support for Intel 3000 memory hub controllers"); module_param(edac_op_state, int, 0444); MODULE_PARM_DESC(edac_op_state, "EDAC Error Reporting state: 0=Poll,1=NMI");
jeffegg/beaglebone
drivers/edac/i3000_edac.c
C
gpl-2.0
14,324
/*********************************************************************************** * * * Voreen - The Volume Rendering Engine * * * * Copyright (C) 2005-2012 University of Muenster, Germany. * * Visualization and Computer Graphics Group <http://viscg.uni-muenster.de> * * For a list of authors please refer to the file "CREDITS.txt". * * * * This file is part of the Voreen software package. Voreen is free software: * * you can redistribute it and/or modify it under the terms of the GNU General * * Public License version 2 as published by the Free Software Foundation. * * * * Voreen is distributed in the hope that it will be useful, but WITHOUT ANY * * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR * * A PARTICULAR PURPOSE. See the GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License in the file * * "LICENSE.txt" along with this file. If not, see <http://www.gnu.org/licenses/>. * * * * For non-commercial academic use see the license exception specified in the file * * "LICENSE-academic.txt". To get information about commercial licensing please * * contact the authors. * * * ***********************************************************************************/ #ifndef VRN_CLOSINGBYRECONSTRUCTIONIMAGEFILTER_H #define VRN_CLOSINGBYRECONSTRUCTIONIMAGEFILTER_H #include "modules/itk/processors/itkprocessor.h" #include "voreen/core/processors/volumeprocessor.h" #include "voreen/core/ports/allports.h" #include <string> #include "voreen/core/properties/boolproperty.h" #include "voreen/core/properties/optionproperty.h" #include "voreen/core/properties/vectorproperty.h" namespace voreen { class VolumeBase; class ClosingByReconstructionImageFilterITK : public ITKProcessor { public: ClosingByReconstructionImageFilterITK(); virtual Processor* create() const; virtual std::string getCategory() const { return "Volume Processing/Filtering/MathematicalMorphology"; } virtual std::string getClassName() const { return "ClosingByReconstructionImageFilterITK"; } virtual CodeState getCodeState() const { return CODE_STATE_STABLE; } protected: virtual void setDescriptions() { setDescription("<a href=\"http://www.itk.org/Doxygen/html/classitk_1_1ClosingByReconstructionImageFilter.html\">Go to ITK-Doxygen-Description</a>"); } template<class T> void closingByReconstructionImageFilterITK(); virtual void process(); private: VolumePort inport1_; VolumePort outport1_; BoolProperty enableProcessing_; StringOptionProperty structuringElement_; StringOptionProperty shape_; IntVec3Property radius_; BoolProperty fullyConnected_; BoolProperty preserveIntensities_; static const std::string loggerCat_; }; } #endif
gnorasi/gnorasi
Gnorasi/modules/itk_generated/processors/itk_MathematicalMorphology/closingbyreconstructionimagefilter.h
C
gpl-2.0
3,591
# Based partially on (wongsyrone/hbl0307106015) versions include $(TOPDIR)/rules.mk PKG_NAME:=samba PKG_VERSION:=4.12.3 PKG_RELEASE:=5 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz PKG_SOURCE_URL:= \ https://ftp.gwdg.de/pub/samba/stable/ \ https://ftp.heanet.ie/mirrors/ftp.samba.org/stable/ \ https://ftp.riken.jp/net/samba/samba/stable/ \ http://www.nic.funet.fi/index/samba/pub/samba/stable/ \ http://samba.mirror.bit.nl/samba/ftp/stable/ \ https://download.samba.org/pub/samba/stable/ PKG_HASH:=3fadbca4504937820d0d8a34e500a1efdcc35e0c554f05bd0a844916ae528727 PKG_MAINTAINER:=Andy Walsh <[email protected]> PKG_LICENSE:=GPL-3.0-only PKG_LICENSE_FILES:=COPYING PKG_CPE_ID:=cpe:/a:samba:samba # samba4=(asn1_compile,compile_et) rpcsvc-proto=(rpcgen) HOST_BUILD_DEPENDS:=python3/host rpcsvc-proto/host perl/host perl-parse-yapp/host PKG_BUILD_DEPENDS:=samba4/host libtasn1/host PKG_CONFIG_DEPENDS:= \ CONFIG_SAMBA4_SERVER_NETBIOS \ CONFIG_SAMBA4_SERVER_AVAHI \ CONFIG_SAMBA4_SERVER_VFS \ CONFIG_SAMBA4_SERVER_VFSX \ CONFIG_SAMBA4_SERVER_AD_DC \ CONFIG_PACKAGE_kmod-fs-btrfs \ CONFIG_PACKAGE_kmod-fs-xfs PYTHON3_PKG_BUILD:=0 include $(INCLUDE_DIR)/package.mk include $(INCLUDE_DIR)/host-build.mk include $(INCLUDE_DIR)/kernel.mk include $(INCLUDE_DIR)/version.mk include ../../lang/python/python3-host.mk include ../../lang/python/python3-package.mk include ../../lang/perl/perlver.mk define Package/samba4/Default SECTION:=net CATEGORY:=Network TITLE:=Samba $(PKG_VERSION) URL:=https://www.samba.org/ endef define Package/samba4/Default/description The Samba software suite is a collection of programs that implements the SMB/CIFS protocol for UNIX systems, allowing you to serve files and printers. Samba 4 implements up-to protocol version SMB v3.1.1 (Win10), supports mDNS via AVAHI and a AD-DC setup via krb5. NOTE: No cluster and printer support. endef define Package/samba4-libs $(call Package/samba4/Default) TITLE+= libs DEPENDS:= +libtirpc +libreadline +libpopt +libcap +zlib +libgnutls +libtasn1 +libuuid +libopenssl +USE_GLIBC:libpthread \ +PACKAGE_libpam:libpam \ +SAMBA4_SERVER_VFS:attr \ +SAMBA4_SERVER_VFSX:libaio \ +SAMBA4_SERVER_AVAHI:libavahi-client \ +SAMBA4_SERVER_AD_DC:python3-cryptodome +SAMBA4_SERVER_AD_DC:libopenldap +SAMBA4_SERVER_AD_DC:jansson +SAMBA4_SERVER_AD_DC:libarchive +SAMBA4_SERVER_AD_DC:acl +SAMBA4_SERVER_AD_DC:attr endef define Package/samba4-server $(call Package/samba4/Default) TITLE+= server DEPENDS:= +samba4-libs CONFLICTS:=samba36-server endef define Package/samba4-server/description installs: smbd (nmbd) smbpasswd pdbedit testparm (nmblookup) (smbcacls sharesec) (samba samba-tool ntlm_auth samba-gpupdate samba_dnsupdate samba_kcc samba_spnupdate samba_upgradedns samba_downgrade_db) This provides the basic fileserver service and is the minimum needed to serve file shares. HINT: https://fitzcarraldoblog.wordpress.com/2016/10/17/a-correct-method-of-configuring-samba-for-browsing-smb-shares-in-a-home-network/ endef define Package/samba4-server/config select PACKAGE_wsdd2 source "$(SOURCE)/Config.in" endef define Package/samba4-client $(call Package/samba4/Default) TITLE+= client DEPENDS:= +samba4-libs endef define Package/samba4-client/description installs: cifsdd smbclient smbget The smbclient program implements a simple ftp-like client for accessing SMB shares endef define Package/samba4-admin $(call Package/samba4/Default) TITLE+= admin tools DEPENDS:= +samba4-libs endef define Package/samba4-admin/description installs: net smbcontrol profiles rpcclient dbwrap_tool eventlogadm ldbadd ldbdel ldbedit ldbmodify ldbrename ldbsearch tdbbackup tdbdump tdbrestore tdbtool Administration tools collection endef define Package/samba4-utils $(call Package/samba4/Default) TITLE+= utils DEPENDS:= +samba4-libs endef define Package/samba4-utils/description installs: smbstatus smbtree mvxattr smbtar smbcquotas Utilities collection endef TARGET_CFLAGS += $(FPIC) -ffunction-sections -fdata-sections -I$(STAGING_DIR)/usr/include/tirpc TARGET_LDFLAGS += -Wl,--gc-sections,--as-needed # dont mess with sambas private rpath! RSTRIP:=: CONFIGURE_VARS += \ CPP="$(TARGET_CROSS)cpp" CONFIGURE_CMD = ./buildtools/bin/waf HOST_CONFIGURE_CMD = ./buildtools/bin/waf # Strip options that WAF configure script does not recognize CONFIGURE_ARGS:=$(filter-out \ --target=% \ --host=% \ --build=% \ --program-prefix=% \ --program-suffix=% \ --disable-nls \ --disable-ipv6 \ , $(CONFIGURE_ARGS)) HOST_CONFIGURE_ARGS:=$(filter-out \ --target=% \ --host=% \ --build=% \ --program-prefix=% \ --program-suffix=% \ --disable-nls \ --disable-ipv6 \ , $(HOST_CONFIGURE_ARGS)) # Waf needs the "configure" argument CONFIGURE_ARGS:=configure $(CONFIGURE_ARGS) HOST_CONFIGURE_ARGS:=configure $(HOST_CONFIGURE_ARGS) CONFIGURE_ARGS += \ --hostcc="$(HOSTCC)" \ --cross-compile \ --cross-answers=cross-answers.txt \ --disable-cups \ --disable-iprint \ --disable-cephfs \ --disable-fault-handling \ --disable-glusterfs \ --disable-spotlight \ --enable-fhs \ --without-automount \ --without-iconv \ --without-lttng \ --without-ntvfs-fileserver \ --without-pam \ --without-systemd \ --without-utmp \ --without-dmapi \ --without-fam \ --without-gettext \ --without-regedit \ --without-gpgme HOST_CONFIGURE_ARGS += \ --hostcc="$(HOSTCC)" \ --disable-cups \ --disable-iprint \ --disable-cephfs \ --disable-fault-handling \ --disable-glusterfs \ --disable-spotlight \ --disable-rpath \ --disable-rpath-install \ --disable-rpath-private-install \ --enable-fhs \ --without-automount \ --without-iconv \ --without-lttng \ --without-ntvfs-fileserver \ --without-pam \ --without-systemd \ --without-utmp \ --without-dmapi \ --without-fam \ --without-gettext \ --without-regedit \ --without-gpgme HOST_CONFIGURE_ARGS += --disable-avahi --without-quotas --without-acl-support --without-winbind \ --without-ad-dc --without-json --without-libarchive --disable-python --nopyc --nopyo \ --without-dnsupdate --without-ads --without-ldap --without-ldb-lmdb # Optional AES-NI support - https://lists.samba.org/archive/samba-technical/2017-September/122738.html # Support for Nettle wasn't comitted ifdef CONFIG_TARGET_x86_64 CONFIGURE_ARGS += --accel-aes=intelaesni else CONFIGURE_ARGS += --accel-aes=none endif CONFIGURE_ARGS += \ --with-lockdir=/var/lock \ --with-logfilebase=/var/log \ --with-piddir=/var/run \ --with-privatedir=/etc/samba # features ifeq ($(CONFIG_SAMBA4_SERVER_VFS),y) CONFIGURE_ARGS += --with-quotas else CONFIGURE_ARGS += --without-quotas endif ifeq ($(CONFIG_SAMBA4_SERVER_AVAHI),y) CONFIGURE_ARGS += --enable-avahi else CONFIGURE_ARGS += --disable-avahi endif ifeq ($(CONFIG_SAMBA4_SERVER_AD_DC),y) CONFIGURE_ARGS += --without-winbind --without-ldb-lmdb --with-acl-support else CONFIGURE_ARGS += --without-winbind --without-ads --without-ldap --without-ldb-lmdb --without-ad-dc \ --without-json --without-libarchive --disable-python --nopyc --nopyo --without-dnsupdate --without-acl-support endif SAMBA4_PDB_MODULES :=pdb_smbpasswd,pdb_tdbsam, SAMBA4_AUTH_MODULES :=auth_builtin,auth_sam,auth_unix, SAMBA4_VFS_MODULES :=vfs_default, SAMBA4_VFS_MODULES_SHARED :=auth_script, ifeq ($(CONFIG_SAMBA4_SERVER_VFS),y) SAMBA4_VFS_MODULES_SHARED :=$(SAMBA4_VFS_MODULES_SHARED)vfs_fruit,vfs_shadow_copy2,vfs_recycle,vfs_fake_perms,vfs_readonly,vfs_cap,vfs_offline,vfs_crossrename,vfs_catia,vfs_streams_xattr,vfs_xattr_tdb,vfs_default_quota, ifeq ($(CONFIG_PACKAGE_kmod-fs-btrfs),y) SAMBA4_VFS_MODULES_SHARED :=$(SAMBA4_VFS_MODULES_SHARED)vfs_btrfs, endif endif ifeq ($(CONFIG_SAMBA4_SERVER_VFSX),y) SAMBA4_VFS_MODULES_SHARED :=$(SAMBA4_VFS_MODULES_SHARED)vfs_virusfilter,vfs_shell_snap,vfs_commit,vfs_worm,vfs_aio_fork,vfs_aio_pthread,vfs_netatalk,vfs_dirsort,vfs_fileid, ifeq ($(CONFIG_PACKAGE_kmod-fs-xfs),y) SAMBA4_VFS_MODULES_SHARED :=$(SAMBA4_VFS_MODULES_SHARED)vfs_linux_xfs_sgid, endif endif ifeq ($(CONFIG_SAMBA4_SERVER_AD_DC),y) SAMBA4_PDB_MODULES :=$(SAMBA4_PDB_MODULES)pdb_samba_dsdb,pdb_ldapsam, SAMBA4_AUTH_MODULES :=$(SAMBA4_AUTH_MODULES)auth_samba4, SAMBA4_VFS_MODULES :=$(SAMBA4_VFS_MODULES)vfs_posixacl, SAMBA4_VFS_MODULES_SHARED :=$(SAMBA4_VFS_MODULES_SHARED)vfs_audit,vfs_extd_audit,vfs_full_audit,vfs_acl_xattr,vfs_acl_tdb, # vfs_zfsacl needs https://github.com/zfsonlinux/zfs/tree/master/include/sys/zfs_acl.h # vfs_nfs4acl_xattr needs https://github.com/notriddle/libdrpc/blob/master/rpc/xdr.h endif SAMBA4_MODULES :=${SAMBA4_VFS_MODULES}${SAMBA4_AUTH_MODULES}${SAMBA4_PDB_MODULES} SAMBA4_MODULES_SHARDED :=${SAMBA4_VFS_MODULES_SHARED} CONFIGURE_ARGS += \ --with-static-modules=$(SAMBA4_MODULES)!DEFAULT,!FORCED \ --with-shared-modules=$(SAMBA4_MODULES_SHARDED)!DEFAULT,!FORCED HOST_CONFIGURE_ARGS += \ --with-static-modules=!DEFAULT,!FORCED \ --with-shared-modules=!DEFAULT,!FORCED # lib bundling PY_VER:=$(PYTHON3_VERSION_MAJOR)$(PYTHON3_VERSION_MINOR) # NOTE: bundle + make private, we want to avoid version configuration (build, link) conflicts HOST_CONFIGURE_ARGS += --builtin-libraries=replace --nonshared-binary=asn1_compile,compile_et SYSTEM_BUNDLED_LIBS:=talloc,tevent,tevent-util,texpect,tdb,ldb,tdr,cmocka,replace,com_err PYTHON_BUNDLED_LIBS:=pytalloc-util.cpython-$(PY_VER),pyldb-util.cpython-$(PY_VER) # CONFIGURE_ARGS += --builtin-libraries=talloc,tevent,tevent-util,texpect,tdb,ldb,tdr,cmocka,com_err ifeq ($(CONFIG_SAMBA4_SERVER_AD_DC),y) CONFIGURE_ARGS += --bundled-libraries=NONE,$(SYSTEM_BUNDLED_LIBS),$(PYTHON_BUNDLED_LIBS) else CONFIGURE_ARGS += --bundled-libraries=NONE,$(SYSTEM_BUNDLED_LIBS) endif CONFIGURE_ARGS += --private-libraries=$(SYSTEM_BUNDLED_LIBS) export COMPILE_ET=$(STAGING_DIR_HOSTPKG)/bin/compile_et_samba export ASN1_COMPILE=$(STAGING_DIR_HOSTPKG)/bin/asn1_compile_samba # make sure we use the hostpkg build toolset and we need to find host 'yapp' HOST_CONFIGURE_VARS+= \ PATH="$(STAGING_DIR_HOSTPKG)/bin:$(STAGING_DIR_HOSTPKG)/usr/bin:$(PATH)" CONFIGURE_VARS += \ PATH="$(STAGING_DIR_HOSTPKG)/bin:$(STAGING_DIR_HOSTPKG)/usr/bin:$(PATH)" # we need hostpkg bin and target config ifeq ($(CONFIG_SAMBA4_SERVER_AD_DC),y) CONFIGURE_VARS += \ PYTHON_CONFIG="$(STAGING_DIR)/host/bin/$(PYTHON3)-config" endif # we dont need GnuTLS for the host helpers define Host/Prepare $(call Host/Prepare/Default) $(SED) 's,mandatory=True,mandatory=False,g' $(HOST_BUILD_DIR)/wscript_configure_system_gnutls $(SED) 's,gnutls_version =.*,gnutls_version = gnutls_min_required_version,g' $(HOST_BUILD_DIR)/wscript_configure_system_gnutls endef define Host/Compile (cd $(HOST_BUILD_DIR); \ ./buildtools/bin/waf build \ --targets=asn1_compile,compile_et \ ) endef define Host/Install $(INSTALL_DIR) $(STAGING_DIR_HOSTPKG)/bin/ # add host tools suffix, prevent conflicts with krb5 $(INSTALL_BIN) $(HOST_BUILD_DIR)/bin/asn1_compile $(STAGING_DIR_HOSTPKG)/bin/asn1_compile_samba $(INSTALL_BIN) $(HOST_BUILD_DIR)/bin/compile_et $(STAGING_DIR_HOSTPKG)/bin/compile_et_samba endef define Build/Prepare $(Build/Prepare/Default) ifeq ($(CONFIG_SAMBA4_SERVER_AD_DC),) # un-bundle dnspython $(SED) '/"dns.resolver":/d' $(PKG_BUILD_DIR)/third_party/wscript # unbundle iso8601 $(SED) '/"iso8601":/d' $(PKG_BUILD_DIR)/third_party/wscript endif endef define Build/Configure $(CP) ./waf-cross-answers/$(ARCH).txt $(PKG_BUILD_DIR)/cross-answers.txt echo 'Checking uname sysname type: "$(VERSION_DIST)"' >> $(PKG_BUILD_DIR)/cross-answers.txt echo 'Checking uname machine type: "$(ARCH)"' >> $(PKG_BUILD_DIR)/cross-answers.txt echo 'Checking uname release type: "$(LINUX_VERSION)"' >> $(PKG_BUILD_DIR)/cross-answers.txt echo 'Checking uname version type: "$(VERSION_DIST) Linux-$(LINUX_VERSION) $(shell date +%Y-%m-%d)"' >> $(PKG_BUILD_DIR)/cross-answers.txt # NOTE: special answers for freeBSD/CircleCI echo 'checking for clnt_create(): OK' >> $(PKG_BUILD_DIR)/cross-answers.txt $(call Build/Configure/Default) endef # Build via "waf install", avoid the make wrapper. (Samba logic is 'waf install' = build + install) define Build/Compile (cd $(PKG_BUILD_DIR); \ ./buildtools/bin/waf install \ --jobs=$(shell nproc) \ --destdir="$(PKG_INSTALL_DIR)" \ ) endef # No default install see above define Build/Install endef define Package/samba4-libs/install $(INSTALL_DIR) $(1)/usr/lib $(CP) $(PKG_INSTALL_DIR)/usr/lib/*.so* $(1)/usr/lib/ # rpath-install $(CP) $(PKG_INSTALL_DIR)/usr/lib/samba $(1)/usr/lib/ endef define Package/samba4-client/install $(INSTALL_DIR) $(1)/usr/bin $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/{cifsdd,smbclient,smbget} $(1)/usr/bin/ endef define Package/samba4-admin/install $(INSTALL_DIR) $(1)/usr/bin $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/{net,smbcontrol,profiles,rpcclient,dbwrap_tool} $(1)/usr/bin/ $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/{ldbadd,ldbdel,ldbedit,ldbmodify,ldbrename,ldbsearch} $(1)/usr/bin/ $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/{tdbbackup,tdbdump,tdbrestore,tdbtool} $(1)/usr/bin/ $(INSTALL_DIR) $(1)/usr/sbin $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/eventlogadm $(1)/usr/sbin/ endef define Package/samba4-utils/install $(INSTALL_DIR) $(1)/usr/bin $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/{smbstatus,smbtree,mvxattr,smbtar} $(1)/usr/bin/ ifeq ($(CONFIG_SAMBA4_SERVER_VFS),y) $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/smbcquotas $(1)/usr/bin/ endif endef define Package/samba4-server/install $(INSTALL_DIR) $(1)/usr/bin $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/{smbpasswd,pdbedit,testparm} $(1)/usr/bin/ $(INSTALL_DIR) $(1)/usr/sbin $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/smbd $(1)/usr/sbin/ ifeq ($(CONFIG_SAMBA4_SERVER_NETBIOS),y) $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/nmbd $(1)/usr/sbin/ $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/nmblookup $(1)/usr/bin/ endif ifeq ($(CONFIG_SAMBA4_SERVER_AD_DC),y) $(INSTALL_DIR) $(1)/usr/lib $(CP) $(PKG_INSTALL_DIR)/usr/lib/$(PYTHON3) $(1)/usr/lib/ $(INSTALL_DIR) $(1)/usr/share/ $(CP) $(PKG_INSTALL_DIR)/usr/share/samba $(1)/usr/share/ # fix wrong hardcoded python3 location $(SED) '1s,^#!/.*python3.*,#!/usr/bin/python3,' $(PKG_INSTALL_DIR)/usr/bin/samba-tool $(SED) '1s,^#!/.*python3.*,#!/usr/bin/python3,' $(PKG_INSTALL_DIR)/usr/sbin/{samba-gpupdate,samba_dnsupdate,samba_kcc,samba_spnupdate,samba_upgradedns,samba_downgrade_db} $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/{samba-tool,ntlm_auth,oLschema2ldif} $(1)/usr/bin/ $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/{sharesec,smbcacls} $(1)/usr/bin/ $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/{samba,samba-gpupdate,samba_dnsupdate,samba_kcc,samba_spnupdate,samba_upgradedns,samba_downgrade_db} $(1)/usr/sbin/ endif $(INSTALL_DIR) $(1)/etc/config $(1)/etc/samba $(1)/etc/init.d $(INSTALL_CONF) ./files/samba.config $(1)/etc/config/samba4 $(INSTALL_DATA) ./files/smb.conf.template $(1)/etc/samba $(INSTALL_BIN) ./files/samba.init $(1)/etc/init.d/samba4 endef define Package/samba4-server/conffiles /etc/config/samba4 /etc/samba/smb.conf.template /etc/samba/smb.conf /etc/samba/smbpasswd /etc/samba/secrets.tdb /etc/samba/passdb.tdb /etc/samba/lmhosts /etc/nsswitch.conf /etc/krb5.conf endef $(eval $(call HostBuild)) $(eval $(call BuildPackage,samba4-libs)) $(eval $(call BuildPackage,samba4-server)) $(eval $(call BuildPackage,samba4-client)) $(eval $(call BuildPackage,samba4-admin)) $(eval $(call BuildPackage,samba4-utils))
eduardoabinader/packages
net/samba4/Makefile
Makefile
gpl-2.0
15,559
<?php namespace Requests\Exception\HTTP; /** * Exception for 505 HTTP Version Not Supported responses * * @package Requests */ /** * Exception for 505 HTTP Version Not Supported responses * * @package Requests */ class _505 extends \Requests\Exception\HTTP { /** * HTTP status code * * @var integer */ protected $code = 505; /** * Reason phrase * * @var string */ protected $reason = 'HTTP Version Not Supported'; }
CMS-RuDi/CMS-RuDi
includes/libs/Requests/Exception/HTTP/505.php
PHP
gpl-2.0
486
<?php namespace webfilesframework\core\datasystem\file\system\dropbox; use webfilesframework\core\datasystem\file\system\MFile; /** * description * * @author Sebastian Monzel < [email protected] > * @since 0.1.7 */ class MDropboxFile extends MFile { protected $dropboxAccount; protected $fileMetadata; protected $filePath; /** * * Enter description here ... * @param MDropboxAccount $account * @param $filePath * @param bool $initMetadata * @internal param unknown_type $fileName */ public function __construct(MDropboxAccount $account, $filePath, $initMetadata = true) { parent::__construct($filePath); $this->filePath = $filePath; $this->dropboxAccount = $account; if ($initMetadata) { $this->initMetadata(); } } public function initMetadata() { $this->fileMetadata = $this->dropboxAccount->getDropboxApi()->metaData($this->filePath); $lastSlash = strrpos($this->fileMetadata['body']->path, '/'); $fileName = substr($this->fileMetadata['body']->path, $lastSlash + 1); $this->fileName = $fileName; } public function getContent() { $file = $this->dropboxAccount->getDropboxApi()->getFile($this->filePath); return $file['data']; } public function writeContent($content, $overwrite = false) { // TODO } /** * * Enter description here ... */ public function upload() { } /** * * Enter description here ... * @param $overwriteIfExists */ public function download($overwriteIfExists) { $file = $this->dropboxAccount->getDropboxApi()->getFile($this->filePath); if (!file_exists("." . $this->filePath)) { $fp = fopen("." . $this->filePath, "w"); fputs($fp, $file['data']); fclose($fp); } } public function downloadImageAsThumbnail() { $file = $this->dropboxAccount->getDropbox()->thumbnails($this->filePath, 'JPEG', 'l'); if (!file_exists("." . $this->filePath)) { $fp = fopen("." . $this->filePath, "w"); fputs($fp, $file['data']); fclose($fp); } } }
sebastianmonzel/webfiles-framework-php
source/core/datasystem/file/system/dropbox/MDropboxFile.php
PHP
gpl-2.0
2,375
\documentclass[../../../../testPlan.tex]{subfiles} \begin{document} \section{Integration Testing Strategy} The strategy that we want to follow is the Bottom-Up Strategy. This kind of approach consists in testing the low level components first and then the level just above, until you reach the top level components. This strategy is suitable for our system because every component is divided in low level components. \end{document}
SimoneDeola/CremonaDeola
source/testPlan/latex/chapters/integrationStrategy/sections/integrationTestingStrategy/integrationTestingStrategy.tex
TeX
gpl-2.0
441
<?php use yii\helpers\Html; /* @var $this yii\web\View */ /* @var $model common\models\SettingsWorkingDays */ $this->title = 'Update Settings Working Days: ' . $model->id; $this->params['breadcrumbs'][] = ['label' => 'Settings Working Days', 'url' => ['index']]; $this->params['breadcrumbs'][] = ['label' => $model->id, 'url' => ['view', 'id' => $model->id]]; $this->params['breadcrumbs'][] = 'Update'; ?> <div class="settings-working-days-update"> <h1><?= Html::encode($this->title) ?></h1> <?= $this->render('_form', [ 'model' => $model, ]) ?> </div>
mig0s/athena
backend/views/settings-working-days/update.php
PHP
gpl-2.0
579
/* Copyright (C) 2014, 2015 by Yu Gong */ #ifndef JULIA_R_H #define JULIA_R_H #ifdef __cplusplus extern "C" { #endif #include <R.h> #include <julia.h> //Convert R Type To Julia,which not contain NA SEXP R_Julia(SEXP Var, SEXP VarNam); //Convert R Type To Julia,which contain NA SEXP R_Julia_NA(SEXP Var, SEXP VarNam); //Convert R Type To Julia,which contain NA SEXP R_Julia_NA_Factor(SEXP Var, SEXP VarNam); //Convert R data frame To Julia SEXP R_Julia_NA_DataFrame(SEXP Var, SEXP VarNam); #ifdef __cplusplus } #endif #endif
mmaechler/RJulia
src/R_Julia.h
C
gpl-2.0
529
/* * Template Name: Unify - Responsive Bootstrap Template * Description: Business, Corporate, Portfolio, E-commerce, Blog and One Page Template. * Version: 1.8 * Author: @htmlstream * Website: http://htmlstream.com */ /*Reset Styles ------------------------------------*/ * { border-radius: 0 !important; } a, a:focus, a:hover, a:active, button, button:hover { outline: 0 !important; } a:focus { text-decoration: none; } hr { margin: 30px 0; } hr.hr-xs { margin: 10px 0; } hr.hr-md { margin: 20px 0; } hr.hr-lg { margin: 40px 0; } /*Headings*/ h1 { font-size: 28px; line-height: 35px; } h2 { font-size: 24px; line-height: 33px; } h3 { font-size: 20px; line-height: 27px; } h4 { line-height: 25px; } h5 { line-height: 20px; } h6 { line-height: 18px; } h1, h2, h3, h4, h5, h6 { color: #555; margin-top: 5px; text-shadow: none; font-weight: normal; font-family: 'Open Sans', sans-serif; } h1 i, h2 i, h3 i, h4 i, h5 i, h6 i { margin-right: 5px; } /*Block Headline*/ .headline { display: block; margin: 10px 0 25px 0; border-bottom: 1px dotted #e4e9f0; } .headline h2 { font-size: 22px; } .headline h2, .headline h3, .headline h4 { margin: 0 0 -2px 0; padding-bottom: 5px; display: inline-block; border-bottom: 2px solid #72c02c; } .headline-md { margin-bottom: 15px; } .headline-md h2 { font-size: 21px; } /*Heading Options*/ .heading { text-align: center; } .heading h2 { padding: 0 12px; position: relative; display: inline-block; line-height: 34px !important; /*For Tagline Boxes*/ } .heading h2:before, .heading h2:after { content: ' '; width: 70%; position: absolute; border-width: 1px; border-color: #bbb; } .heading h2:before { right: 100%; } .heading h2:after { left: 100%; } @media (max-width: 768px) { .heading h2:before, .heading h2:after { width: 20%; } } /*Headline v1*/ .heading-v1 h2:before, .heading-v1 h2:after { top: 15px; height: 6px; border-top-style: solid; border-bottom-style: solid; } /*Headline v2*/ .heading-v2 h2:before, .heading-v2 h2:after { top: 15px; height: 6px; border-top-style: dashed; border-bottom-style: dashed; } /*Headline v3*/ .heading-v3 h2:before, .heading-v3 h2:after { top: 15px; height: 6px; border-top-style: dotted; border-bottom-style: dotted; } /*Headline v4*/ .heading-v4 h2:before, .heading-v4 h2:after { top: 17px; border-bottom-style: solid; } /*Headline v5*/ .heading-v5 h2:before, .heading-v5 h2:after { top: 17px; border-bottom-style: dashed; } /*Headline v6*/ .heading-v6 h2:before, .heading-v6 h2:after { top: 17px; border-bottom-style: dotted; } /*Heading Titles v1*/ .title-v1 { z-index: 1; position: relative; text-align: center; margin-bottom: 60px; } .title-v1 h1, .title-v1 h2 { color: #444; font-size: 28px; position: relative; margin-bottom: 15px; padding-bottom: 20px; text-transform: uppercase; font-family: 'Open Sans', sans-serif; } .title-v1 h1:after, .title-v1 h2:after { bottom: 0; left: 50%; height: 1px; width: 70px; content: " "; margin-left: -35px; position: absolute; background: #72c02c; } .title-v1 p { font-size: 17px; font-weight: 200; } /*Heading Titles v2*/ h2.title-v2 { color: #555; position: relative; margin-bottom: 30px; } h2.title-v2:after { left: 0; width: 70px; height: 2px; content: " "; bottom: -10px; background: #555; position: absolute; } h1.title-v2.title-center, h2.title-v2.title-center, h3.title-v2.title-center { text-align: center; } h1.title-v2.title-center:after, h2.title-v2.title-center:after, h3.title-v2.title-center:after { left: 50%; width: 70px; margin-left: -35px; } h1.title-light, h2.title-light, h3.title-light { color: #fff; } h2.title-light:after { background: #fff; } /*Heading Title v3*/ h1[class^="title-v3-"], h2[class^="title-v3-"], h3[class^="title-v3-"] { color: #555; } h2.title-v3-xlg { font-size: 28px; line-height: 32px; } h1.title-v3-lg, h2.title-v3-lg { font-size: 24px; line-height: 28px; } h1.title-v3-md, h2.title-v3-md { font-size: 20px; line-height: 24px; } h2.title-v3-sm, h3.title-v3-md { font-size: 18px; line-height: 24px; } h3.title-v3-md { line-height: 22px; } h3.title-v3-sm { font-size: 16px; line-height: 20px; } h2.title-v3-xs { font-size: 16px; line-height: 22px; } h3.title-v3-xs { font-size: 14px; margin-bottom: 0; } /*Headline Center*/ .headline-center { text-align: center; position: relative; } .headline-center h2 { color: #555; font-size: 24px; position: relative; margin-bottom: 20px; padding-bottom: 15px; } .headline-center h2:after { left: 50%; z-index: 1; width: 30px; height: 2px; content: " "; bottom: -5px; margin-left: -15px; text-align: center; position: absolute; background: #72c02c; } .headline-center p { /*color: #999;*/ font-size: 14px; /*padding: 0 150px;*/ } @media (max-width: 991px) { .headline-center p { padding: 0 50px; } } .headline-center.headline-light h2 { color: #fff; } .headline-center.headline-light p { color: #eee; } /*Headline Center v2*/ .headline-center-v2 { z-index: 0; text-align: center; position: relative; } .headline-center-v2 h2 { color: #555; font-size: 24px; margin-bottom: 20px; text-transform: uppercase; } .headline-center-v2 span.bordered-icon { color: #fff; padding: 0 10px; font-size: 15px; line-height: 18px; position: relative; margin-bottom: 25px; display: inline-block; } .headline-center-v2 span.bordered-icon:before, .headline-center-v2 span.bordered-icon:after { top: 8px; height: 1px; content: " "; width: 100px; background: #fff; position: absolute; } .headline-center-v2 span.bordered-icon:before { left: 100%; } .headline-center-v2 span.bordered-icon:after { right: 100%; } .headline-center-v2 p { color: #555; font-size: 14px; padding: 0 70px; } .headline-center-v2.headline-center-v2-dark p { color: #666; } .headline-center-v2.headline-center-v2-dark span.bordered-icon { color: #666; } .headline-center-v2.headline-center-v2-dark span.bordered-icon:before, .headline-center-v2.headline-center-v2-dark span.bordered-icon:after { background: #666; } /*Headline Left*/ .headline-left { position: relative; } .headline-left .headline-brd { color: #555; position: relative; margin-bottom: 25px; padding-bottom: 10px; } .headline-left .headline-brd:after { left: 1px; z-index: 1; width: 30px; height: 2px; content: " "; bottom: -5px; position: absolute; background: #72c02c; } /*Headline v2 ------------------------------------*/ .headline-v2 { display: block; background: #fff; padding: 1px 10px; margin: 0 0 20px 0; border-left: 2px solid #000; } .headline-v2 h2 { margin: 3px 0; font-size: 20px; font-weight: 200; } /*Heading Sizes ------------------------------------*/ h2.heading-md { font-size: 20px; line-height: 24px; } h2.heading-sm, h3.heading-md { font-size: 18px; line-height: 24px; } h3.heading-md { line-height: 22px; } h3.heading-sm { font-size: 16px; line-height: 20px; } h2.heading-xs { font-size: 16px; line-height: 22px; } h3.heading-xs { font-size: 14px; margin-bottom: 0; } /*Devider ------------------------------------*/ .devider.devider-dotted { border-top: 2px dotted #eee; } .devider.devider-dashed { border-top: 2px dashed #eee; } .devider.devider-db { height: 5px; border-top: 1px solid #eee; border-bottom: 1px solid #eee; } .devider.devider-db-dashed { height: 5px; border-top: 1px dashed #ddd; border-bottom: 1px dashed #ddd; } .devider.devider-db-dotted { height: 5px; border-top: 1px dotted #ddd; border-bottom: 1px dotted #ddd; } /*Tables ------------------------------------*/ /*Basic Tables*/ .table thead > tr > th { border-bottom: none; } @media (max-width: 768px) { .table th.hidden-sm, .table td.hidden-sm { display: none !important; } } /*Forms ------------------------------------*/ .form-control { box-shadow: none; } .form-control:focus { border-color: #bbb; box-shadow: 0 0 2px #c9c9c9; } /*Form Spacing*/ .form-spacing .form-control { margin-bottom: 15px; } /*Form Icons*/ .input-group-addon { color: #b3b3b3; font-size: 14px; background: #fff; } /*Carousel v1 ------------------------------------*/ .carousel-v1 .carousel-caption { left: 0; right: 0; bottom: 0; padding: 7px 15px; background: rgba(0, 0, 0, 0.7); } .carousel-v1 .carousel-caption p { color: #fff; margin-bottom: 0; } .carousel-v1 .carousel-arrow a.carousel-control { opacity: 1; font-size:30px; height:inherit; width: inherit; background: none; text-shadow: none; position: inherit; } .carousel-v1 .carousel-arrow a i { top: 50%; opacity: 0.6; background: #000; margin-top: -18px; padding: 2px 12px; position: absolute; } .carousel-v1 .carousel-arrow a i:hover { opacity: 0.8; } .carousel-v1 .carousel-arrow a.left i { left: 0; } .carousel-v1 .carousel-arrow a.right i { right: 0; } /*Carousel v2 ------------------------------------*/ .carousel-v2 .carousel-control, .carousel-v2 .carousel-control:hover { opacity: 1; text-shadow: none; } .carousel-v2 .carousel-control.left, .carousel-v2 .carousel-control.right { top: 50%; z-index: 5; color: #eee; width: 45px; height: 45px; font-size: 30px; margin-top: -22px; position: absolute; text-align: center; display: inline-block; border: 2px solid #eee; background: rgba(0,0,0,0.1); } .carousel-v2 .carousel-control:hover { background: rgba(0,0,0,0.3); -webkit-transition: all 0.4s ease-in-out; -moz-transition: all 0.4s ease-in-out; -o-transition: all 0.4s ease-in-out; transition: all 0.4s ease-in-out; } .carousel-v2 .carousel-control.left { left: 20px; } .carousel-v2 .carousel-control.right { right: 20px; } .carousel-v2 .carousel-control .arrow-prev, .carousel-v2 .carousel-control .arrow-next { top: -5px; position: relative; } .carousel-v2 .carousel-control .arrow-next { right: -2px; } @media (min-width: 768px) { .carousel-indicators { bottom: 10px; } } /*Tabs ------------------------------------*/ /*Tabs v1*/ .tab-v1 .nav-tabs { border: none; background: none; border-bottom: solid 2px #72c02c; } .tab-v1 .nav-tabs a { font-size: 14px; padding: 5px 15px; } .tab-v1 .nav-tabs > .active > a, .tab-v1 .nav-tabs > .active > a:hover, .tab-v1 .nav-tabs > .active > a:focus { color: #fff; border: none; background: #72c02c; } .tab-v1 .nav-tabs > li > a { border: none; } .tab-v1 .nav-tabs > li > a:hover { color: #fff; background: #72c02c; } .tab-v1 .tab-content { padding: 10px 0; } .tab-v1 .tab-content img { margin-top: 4px; margin-bottom: 15px; } .tab-v1 .tab-content img.img-tab-space { margin-top: 7px; } /*Tabs v2*/ .tab-v2 .nav-tabs { border-bottom: none; } .tab-v2 .nav-tabs li a { padding: 9px 16px; background: none; border: none; } .tab-v2 .nav-tabs li.active a { background: #fff; padding: 7px 15px 9px; border: solid 1px #eee; border-top: solid 2px #72c02c; border-bottom: none !important; } .tab-v2 .tab-content { padding: 10px 16px; border: solid 1px #eee; } /*Tabs v3*/ .tab-v3 .nav-pills li a { color: #777; font-size: 17px; padding: 4px 8px; margin-bottom: 3px; background: #fafafa; border: solid 1px #eee; } .tab-v3 .nav-pills li a:hover, .tab-v3 .nav-pills li.active a { color: #fff; background: #72c02c; border: solid 1px #68af28; } .tab-v3 .nav-pills li i { width: 1.25em; margin-right: 5px; text-align: center; display: inline-block; } .tab-v3 .tab-content { padding: 15px; background: #fafafa; border: solid 1px #eee; } /*Accordions ------------------------------------*/ /*Accordion v1*/ .acc-v1 .panel-heading { padding: 0; box-shadow: none; } .acc-v1 .panel-heading a { display: block; font-size: 14px; padding: 5px 15px; background: #fefefe; } .acc-icon a.accordion-toggle i { color: #555; margin-right: 8px; } .acc-icon a.accordion-toggle:hover i { color: #39414c; } /*Navigation ------------------------------------*/ /*Pegination*/ .pagination li a { color: #777; padding: 5px 15px; } .pagination li a:hover { color: #fff; background: #5fb611; border-color: #5fb611; } .pagination > .active > a, .pagination > .active > span, .pagination > .active > a:hover, .pagination > .active > span:hover, .pagination > .active > a:focus, .pagination > .active > span:focus { border-color: #72c02c; background-color: #72c02c; } /*Pagination Without Space*/ .pagination-no-space .pagination { margin: 0; } /*Pager*/ .pager li > a:hover, .pager li > a:focus { color: #fff; background: #5fb611; border-color: #5fb611; } /*Pager v2 and v3 ------------------------------------*/ .pager.pager-v2 li > a { border: none; } .pager.pager-v2 li > a, .pager.pager-v3 li > a { -webkit-transition: all 0.1s ease-in-out; -moz-transition: all 0.1s ease-in-out; -o-transition: all 0.1s ease-in-out; transition: all 0.1s ease-in-out; } .pager.pager-v2 li > a:hover, .pager.pager-v2 li > a:focus, .pager.pager-v3 li > a:hover, .pager.pager-v3 li > a:focus { color: #fff; background: #72c02c; } /*Pager Amount*/ .pager.pager-v2 li.page-amount, .pager.pager-v3 li.page-amount { font-size: 16px; font-style: italic; } .pager.pager-v2 li.page-amount, .pager.pager-v2 li.page-amount:hover, .pager.pager-v2 li.page-amount:focus, .pager.pager-v3 li.page-amount, .pager.pager-v3 li.page-amount:hover, .pager.pager-v3 li.page-amount:focus { top: 7px; color: #777; position: relative; } /*Pager Size*/ .pager.pager-v2.pager-md li a, .pager.pager-v3.pager-md li a { font-size: 16px; padding: 8px 18px; } /*Sidebar Menu ------------------------------------*/ /*Sidebar Menu v1*/ .sidebar-nav-v1 li { padding: 0; } .sidebar-nav-v1 li a { display: block; padding: 8px 30px 8px 10px; } .sidebar-nav-v1 li a:hover { text-decoration: none; } .sidebar-nav-v1 > li.active, .sidebar-nav-v1 > li.active:hover { background: #717984; } .sidebar-nav-v1 > li.active, .sidebar-nav-v1 > li.active:hover, .sidebar-nav-v1 > li.active:focus { border-color: #ddd; } .sidebar-nav-v1 > li.active > a { color: #fff; } /*Sidebar Sub Navigation*/ .sidebar-nav-v1 li ul { padding: 0; list-style: none; } .sidebar-nav-v1 li ul, .sidebar-nav-v1 li.active ul a { background: #f8f8f8; } .sidebar-nav-v1 li ul a { color: #555; font-size: 12px; border-top: solid 1px #ddd; padding: 6px 30px 6px 17px; } .sidebar-nav-v1 ul li:hover a, .sidebar-nav-v1 ul li.active a { color: #72c02c; } /*Sidebar Badges*/ .list-group-item li > .badge { float: right; } .sidebar-nav-v1 span.badge { margin-top: 8px; margin-right: 10px; } .sidebar-nav-v1 .list-toggle > span.badge { margin-right: 25px; } .sidebar-nav-v1 ul li span.badge { margin-top: 8px; font-size: 11px; padding: 3px 5px; margin-right: 10px; } /*Sidebar List Toggle*/ .list-toggle:after { top: 7px; right: 10px; color: #777; font-size: 14px; content: "\f105"; position: absolute; font-weight: normal; display: inline-block; font-family: FontAwesome; } .list-toggle.active:after { color: #fff; content: "\f107"; } /*Button Styles ------------------------------------*/ .btn { box-shadow: none; } .btn-u { border: 0; color: #fff; font-size: 14px; cursor: pointer; font-weight: 400; padding: 6px 13px; position: relative; background: #72c02c; white-space: nowrap; display: inline-block; text-decoration: none; } .btn-u:hover { color: #fff; text-decoration: none; -webkit-transition: all 0.3s ease-in-out; -moz-transition: all 0.3s ease-in-out; -o-transition: all 0.3s ease-in-out; transition: all 0.3s ease-in-out; } .btn-u.btn-block { text-align: center; } a.btn-u { /*padding: 4px 13px;*/ /*vertical-align: middle;*/ } .btn-u-sm, a.btn-u-sm { padding: 3px 12px; } .btn-u-lg, a.btn-u-lg { font-size: 18px; padding: 10px 25px; } .btn-u-xs, a.btn-u-xs { font-size: 12px; padding: 2px 12px; line-height: 18px; } /*Button Groups*/ .btn-group .dropdown-menu > li > a { padding: 3px 13px; } .btn-group > .btn-u, .btn-group-vertical > .btn-u { float: left; position: relative; } .btn-group > .btn-u:first-child { margin-left: 0; } /*For FF Only*/ @-moz-document url-prefix() { .footer-subsribe .btn-u { padding-bottom: 4px; } } @media (max-width: 768px) { @-moz-document url-prefix() { .btn-u { padding-bottom: 6px; } } } /*Buttons Color*/ .btn-u:hover, .btn-u:focus, .btn-u:active, .btn-u.active, .open .dropdown-toggle.btn-u { background: #5fb611; } .btn-u-split.dropdown-toggle { border-left: solid 1px #5fb611; } .btn-u.btn-u-blue { background: #3498db; } .btn-u.btn-u-blue:hover, .btn-u.btn-u-blue:focus, .btn-u.btn-u-blue:active, .btn-u.btn-u-blue.active, .open .dropdown-toggle.btn-u.btn-u-blue { background: #2980b9; } .btn-u.btn-u-split-blue.dropdown-toggle { border-left: solid 1px #2980b9; } .btn-u.btn-u-red { background: #e74c3c; } .btn-u.btn-u-red:hover, .btn-u.btn-u-red:focus, .btn-u.btn-u-red:active, .btn-u.btn-u-red.active, .open .dropdown-toggle.btn-u.btn-u-red { background: #c0392b; } .btn-u.btn-u-split-red.dropdown-toggle { border-left: solid 1px #c0392b; } .btn-u.btn-u-orange { background: #e67e22; } .btn-u.btn-u-orange:hover, .btn-u.btn-u-orange:focus, .btn-u.btn-u-orange:active, .btn-u.btn-u-orange.active, .open .dropdown-toggle.btn-u.btn-u-orange { background: #d35400; } .btn-u.btn-u-split-orange.dropdown-toggle { border-left: solid 1px #d35400; } .btn-u.btn-u-sea { background: #1abc9c; } .btn-u.btn-u-sea:hover, .btn-u.btn-u-sea:focus, .btn-u.btn-u-sea:active, .btn-u.btn-u-sea.active, .open .dropdown-toggle.btn-u.btn-u-sea { background: #16a085; } .btn-u.btn-u-split-sea.dropdown-toggle { border-left: solid 1px #16a085; } .btn-u.btn-u-green { background: #2ecc71; } .btn-u.btn-u-green:hover, .btn-u.btn-u-green:focus, .btn-u.btn-u-green:active, .btn-u.btn-u-green.active, .open .dropdown-toggle.btn-u.btn-u-green { background: #27ae60; } .btn-u.btn-u-split-green.dropdown-toggle { border-left: solid 1px #27ae60; } .btn-u.btn-u-yellow { background: #f1c40f; } .btn-u.btn-u-yellow:hover, .btn-u.btn-u-yellow:focus, .btn-u.btn-u-yellow:active, .btn-u.btn-u-yellow.active, .open .dropdown-toggle.btn-u.btn-u-yellow { background: #f39c12; } .btn-u.btn-u-split-yellow.dropdown-toggle { border-left: solid 1px #f39c12; } .btn-u.btn-u-default { background: #95a5a6; } .btn-u.btn-u-default:hover, .btn-u.btn-u-default:focus, .btn-u.btn-u-default:active, .btn-u.btn-u-default.active, .open .dropdown-toggle.btn-u.btn-u-default { background: #7f8c8d; } .btn-u.btn-u-split-default.dropdown-toggle { border-left: solid 1px #7f8c8d; } .btn-u.btn-u-purple { background: #9b6bcc; } .btn-u.btn-u-purple:hover, .btn-u.btn-u-purple:focus, .btn-u.btn-u-purple:active, .btn-u.btn-u-purple.active, .open .dropdown-toggle.btn-u.btn-u-purple { background: #814fb5; } .btn-u.btn-u-split-purple.dropdown-toggle { border-left: solid 1px #814fb5; } .btn-u.btn-u-aqua { background: #27d7e7; } .btn-u.btn-u-aqua:hover, .btn-u.btn-u-aqua:focus, .btn-u.btn-u-aqua:active, .btn-u.btn-u-aqua.active, .open .dropdown-toggle.btn-u.btn-u-aqua { background: #26bac8; } .btn-u.btn-u-split-aqua.dropdown-toggle { border-left: solid 1px #26bac8; } .btn-u.btn-u-brown { background: #9c8061; } .btn-u.btn-u-brown:hover, .btn-u.btn-u-brown:focus, .btn-u.btn-u-brown:active, .btn-u.btn-u-brown.active, .open .dropdown-toggle.btn-u.btn-u-brown { background: #81674b; } .btn-u.btn-u-split-brown.dropdown-toggle { border-left: solid 1px #81674b; } .btn-u.btn-u-dark-blue { background: #4765a0; } .btn-u.btn-u-dark-blue:hover, .btn-u.btn-u-dark-blue:focus, .btn-u.btn-u-dark-blue:active, .btn-u.btn-u-dark-blue.active, .open .dropdown-toggle.btn-u.btn-u-dark-blue { background: #324c80; } .btn-u.btn-u-split-dark.dropdown-toggle { border-left: solid 1px #324c80; } .btn-u.btn-u-light-green { background: #79d5b3; } .btn-u.btn-u-light-green:hover, .btn-u.btn-u-light-green:focus, .btn-u.btn-u-light-green:active, .btn-u.btn-u-light-green.active, .open .dropdown-toggle.btn-u.btn-u-light-green { background: #59b795; } .btn-u.btn-u-split-light-green.dropdown-toggle { border-left: solid 1px #59b795; } .btn-u.btn-u-dark { background: #555; } .btn-u.btn-u-dark:hover, .btn-u.btn-u-dark:focus, .btn-u.btn-u-dark:active, .btn-u.btn-u-dark.active, .open .dropdown-toggle.btn-u.btn-u-dark { background: #333; } .btn-u.btn-u-split-dark.dropdown-toggle { border-left: solid 1px #333; } .btn-u.btn-u-light-grey { background: #585f69; } .btn-u.btn-u-light-grey:hover, .btn-u.btn-u-light-grey:focus, .btn-u.btn-u-light-grey:active, .btn-u.btn-u-light-grey.active, .open .dropdown-toggle.btn-u.btn-u-light-grey { background: #484f58; } .btn-u.btn-u-split-light-grey.dropdown-toggle { border-left: solid 1px #484f58; } /*Bordered Buttons*/ .btn-u.btn-brd { color: #555; /*font-weight: 200;*/ background: none; padding: 5px 13px; border: solid 1px transparent; -webkit-transition: all 0.1s ease-in-out; -moz-transition: all 0.1s ease-in-out; -o-transition: all 0.1s ease-in-out; transition: all 0.1s ease-in-out; } .btn-u.btn-brd:hover { background: none; border: solid 1px #eee; } .btn-u.btn-brd:focus { background: none; } .btn-u.btn-brd.btn-brd-hover:hover { color: #fff !important; } .btn-u.btn-brd { border-color: #72c02c; } .btn-u.btn-brd:hover { color: #5fb611; border-color: #5fb611; } .btn-u.btn-brd.btn-brd-hover:hover { background: #5fb611; } .btn-u.btn-brd.btn-u-blue { border-color: #3498db; } .btn-u.btn-brd.btn-u-blue:hover { color: #2980b9; border-color: #2980b9; } .btn-u.btn-brd.btn-u-blue.btn-brd-hover:hover { background: #2980b9; } .btn-u.btn-brd.btn-u-red { border-color: #e74c3c; } .btn-u.btn-brd.btn-u-red:hover { color: #c0392b; border-color: #c0392b; } .btn-u.btn-brd.btn-u-red.btn-brd-hover:hover { background: #c0392b; } .btn-u.btn-brd.btn-u-orange { border-color: #e67e22; } .btn-u.btn-brd.btn-u-orange:hover { color: #d35400; border-color: #d35400; } .btn-u.btn-brd.btn-u-orange.btn-brd-hover:hover { background: #d35400; } .btn-u.btn-brd.btn-u-sea { border-color: #1abc9c; } .btn-u.btn-brd.btn-u-sea:hover { color: #16a085; border-color: #16a085; } .btn-u.btn-brd.btn-u-sea.btn-brd-hover:hover { background: #16a085; } .btn-u.btn-brd.btn-u-green { border-color: #2ecc71; } .btn-u.btn-brd.btn-u-green:hover { color: #27ae60; border-color: #27ae60; } .btn-u.btn-brd.btn-u-green.btn-brd-hover:hover { background: #27ae60; } .btn-u.btn-brd.btn-u-yellow { border-color: #f1c40f; } .btn-u.btn-brd.btn-u-yellow:hover { color: #f39c12; border-color: #f39c12; } .btn-u.btn-brd.btn-u-yellow.btn-brd-hover:hover { background: #f39c12; } .btn-u.btn-brd.btn-u-default { border-color: #95a5a6; } .btn-u.btn-brd.btn-u-default:hover { color: #7f8c8d; border-color: #7f8c8d; } .btn-u.btn-brd.btn-u-default.btn-brd-hover:hover { background: #7f8c8d; } .btn-u.btn-brd.btn-u-dark { border-color: #555; } .btn-u.btn-brd.btn-u-dark:hover { color: #333; border-color: #333; } .btn-u.btn-brd.btn-u-dark.btn-brd-hover:hover { background: #333; } .btn-u.btn-brd.btn-u-light-grey { border-color: #585f69; } .btn-u.btn-brd.btn-u-light-grey:hover { color: #484f58; border-color: #484f58; } .btn-u.btn-brd.btn-u-light-grey.btn-brd-hover:hover { background: #484f58; } .btn-u.btn-brd.btn-u-purple { border-color: #9b6bcc; } .btn-u.btn-brd.btn-u-purple:hover { color: #814fb5; border-color: #814fb5; } .btn-u.btn-brd.btn-u-purple.btn-brd-hover:hover { background: #814fb5; } .btn-u.btn-brd.btn-u-aqua { border-color: #27d7e7; } .btn-u.btn-brd.btn-u-aqua:hover { color: #26bac8; border-color: #26bac8; } .btn-u.btn-brd.btn-u-aqua.btn-brd-hover:hover { background: #26bac8; } .btn-u.btn-brd.btn-u-brown { border-color: #9c8061; } .btn-u.btn-brd.btn-u-brown:hover { color: #81674b; border-color: #81674b; } .btn-u.btn-brd.btn-u-brown.btn-brd-hover:hover { background: #81674b; } .btn-u.btn-brd.btn-u-dark-blue { border-color: #4765a0; } .btn-u.btn-brd.btn-u-dark-blue:hover { color: #324c80; border-color: #324c80; } .btn-u.btn-brd.btn-u-dark-blue.btn-brd-hover:hover { background: #324c80; } .btn-u.btn-brd.btn-u-light-green { border-color: #79d5b3; } .btn-u.btn-brd.btn-u-light-green:hover { color: #59b795; border-color: #59b795; } .btn-u.btn-brd.btn-u-light-green.btn-brd-hover:hover { background: #59b795; } .btn-u.btn-brd.btn-u-light { color: #fff; border-color: #fff; } .btn-u.btn-brd.btn-u-light:hover { border-color: #fff; } .btn-u.btn-brd.btn-u-light.btn-brd-hover:hover { background: #fff; color: #555 !important; } /*Dropdown Buttons ------------------------------------*/ .dropdown-show { box-shadow: 0 0 4px #eee; display: inline-block; position: relative; } /*Badges and Labels ------------------------------------*/ /*Labels*/ span.label { font-size: 11px; font-weight: 400; padding: 4px 7px; } /*Badges*/ span.badge { font-weight: 400; padding: 4px 7px; } span.label-u, span.badge-u { background: #72c02c; } span.label-blue, span.badge-blue { background: #3498db; } span.label-red, span.badge-red { background: #e74c3c; } span.label-green, span.badge-green { background: #2ecc71; } span.label-sea, span.badge-sea { background: #1abc9c; } span.label-orange, span.badge-orange { background: #e67e22; } span.label-yellow, span.badge-yellow { background: #f1c40f; } span.label-purple, span.badge-purple { background: #9b6bcc; } span.label-aqua, span.badge-aqua { background: #27d7e7; } span.label-brown, span.badge-brown { background: #9c8061; } span.label-dark-blue, span.badge-dark-blue { background: #4765a0; } span.label-light-green, span.badge-light-green { background: #79d5b3; } span.label-light, span.badge-light { color: #777; background: #ecf0f1; } span.label-dark, span.badge-dark { background: #555; } /*Badge Lists*/ .badge-lists li { position: relative; } .badge-lists span.badge { top: -10px; right: -6px; position: absolute; } /*Badge Icons*/ .badge-lists.badge-icons span.badge { min-width: 12px; padding: 3px 6px; } .badge-lists.badge-icons i { font-size: 18px; min-width: 25px; } /*Badge Box v1*/ .badge-box-v1 a { color: #777; min-width: 40px; font-size: 18px; padding: 8px 9px; display: inline-block; border: solid 1px #eee; } /*Badge Box v2*/ .badge-box-v2 a { color: #777; font-size: 12px; padding: 10px; min-width: 70px; text-align: center; display: inline-block; border: solid 1px #eee; } .badge-box-v2 a i { font-size: 20px; } /*General Badge Box*/ .badge-box-v1 a i, .badge-box-v2 a i { display: block; margin: 1px auto 2px; } .badge-box-v1 a:hover, .badge-box-v2 a:hover { color: #555; border-color: #555; text-decoration: none; -webkit-transition: all 0.2s ease-in-out; -moz-transition: all 0.2s ease-in-out; -o-transition: all 0.2s ease-in-out; transition: all 0.2s ease-in-out; } /*Icons ------------------------------------*/ /*Social Icons*/ .social-icons { margin: 0; padding: 0; } .social-icons li { list-style: none; margin-right: 3px; margin-bottom: 5px; text-indent: -9999px; display: inline-block; } .social-icons li a, a.social-icon { width: 28px; height: 28px; display: block; background-position: 0 0; background-repeat: no-repeat; transition: all 0.3s ease-in-out; -o-transition: all 0.3s ease-in-out; -ms-transition: all 0.3s ease-in-out; -moz-transition: all 0.3s ease-in-out; -webkit-transition: all 0.3s ease-in-out; } .social-icons li:hover a { background-position: 0 -38px; } .social-icons-color li a { opacity: 0.7; background-position: 0 -38px !important; -webkit-backface-visibility: hidden; /*For Chrome*/ } .social-icons-color li a:hover { opacity: 1; } .social_amazon {background: url(../img/icons/social/amazon.png) no-repeat;} .social_behance {background: url(../img/icons/social/behance.png) no-repeat;} .social_blogger {background: url(../img/icons/social/blogger.png) no-repeat;} .social_deviantart {background: url(../img/icons/social/deviantart.png) no-repeat;} .social_dribbble {background: url(../img/icons/social/dribbble.png) no-repeat;} .social_dropbox {background: url(../img/icons/social/dropbox.png) no-repeat;} .social_evernote {background: url(../img/icons/social/evernote.png) no-repeat;} .social_facebook {background: url(../img/icons/social/facebook.png) no-repeat;} .social_forrst {background: url(../img/icons/social/forrst.png) no-repeat;} .social_github {background: url(../img/icons/social/github.png) no-repeat;} .social_googleplus {background: url(../img/icons/social/googleplus.png) no-repeat;} .social_jolicloud {background: url(../img/icons/social/jolicloud.png) no-repeat;} .social_last-fm {background: url(../img/icons/social/last-fm.png) no-repeat;} .social_linkedin {background: url(../img/icons/social/linkedin.png) no-repeat;} .social_picasa {background: url(../img/icons/social/picasa.png) no-repeat;} .social_pintrest {background: url(../img/icons/social/pintrest.png) no-repeat;} .social_rss {background: url(../img/icons/social/rss.png) no-repeat;} .social_skype {background: url(../img/icons/social/skype.png) no-repeat;} .social_spotify {background: url(../img/icons/social/spotify.png) no-repeat;} .social_stumbleupon {background: url(../img/icons/social/stumbleupon.png) no-repeat;} .social_tumblr {background: url(../img/icons/social/tumblr.png) no-repeat;} .social_twitter {background: url(../img/icons/social/twitter.png) no-repeat;} .social_vimeo {background: url(../img/icons/social/vimeo.png) no-repeat;} .social_wordpress {background: url(../img/icons/social/wordpress.png) no-repeat;} .social_xing {background: url(../img/icons/social/xing.png) no-repeat;} .social_yahoo {background: url(../img/icons/social/yahoo.png) no-repeat;} .social_youtube {background: url(../img/icons/social/youtube.png) no-repeat;} .social_vk {background: url(../img/icons/social/vk.png) no-repeat;} .social_instagram {background: url(../img/icons/social/instagram.png) no-repeat;} /*Font Awesome Icon Styles*/ i.icon-custom { color: #555; width: 40px; height: 40px; font-size: 20px; line-height: 40px; margin-bottom: 5px; text-align: center; display: inline-block; border: solid 1px #555; } i.icon-sm { width: 35px; height: 35px; font-size: 16px; line-height: 35px; } i.icon-md { width: 55px; height: 55px; font-size: 22px; line-height: 55px; } i.icon-lg { width: 60px; height: 60px; font-size: 31px; line-height: 60px; margin-bottom: 10px; } i.icon-2x { font-size: 30px; } i.icon-3x { font-size: 40px; } i.icon-4x { font-size: 50px; } /*Line Icons*/ i.icon-line { font-size: 17px; } i.icon-sm.icon-line { font-size: 14px; } i.icon-md.icon-line { font-size: 22px; } i.icon-lg.icon-line { font-size: 28px; } i.icon-2x.icon-line { font-size: 27px; } i.icon-3x.icon-line { font-size: 36px; } i.icon-4x.icon-line { font-size: 47px; } /*Icon Styles For Links*/ .link-icon, .link-bg-icon { color: #555; } .link-icon:hover, .link-bg-icon:hover { border: none; text-decoration: none; } .link-icon:hover i { color: #72c02c; background: none; border: solid 1px #72c02c; } .link-bg-icon:hover i { color: #72c02c; background: #72c02c; border-color: #72c02c; color: #fff !important; } /*Icons Color*/ i.icon-color-u, i.icon-color-red, i.icon-color-sea, i.icon-color-dark, i.icon-color-grey, i.icon-color-blue, i.icon-color-green, i.icon-color-yellow, i.icon-color-orange, i.icon-color-purple, i.icon-color-aqua, i.icon-color-brown, i.icon-color-dark-blue, i.icon-color-light-grey, i.icon-color-light-green, { background: none; } i.icon-color-u { color: #72c02c; border: solid 1px #72c02c; } i.icon-color-blue { color: #3498db; border: solid 1px #3498db; } i.icon-color-red { color: #e74c3c; border: solid 1px #e74c3c; } i.icon-color-sea { color: #1abc9c; border: solid 1px #1abc9c; } i.icon-color-green { color: #2ecc71; border: solid 1px #2ecc71; } i.icon-color-yellow { color: #f1c40f; border: solid 1px #f1c40f; } i.icon-color-orange { color: #e67e22; border: solid 1px #e67e22; } i.icon-color-grey { color: #95a5a6; border: solid 1px #95a5a6; } i.icon-color-purple { color: #9b6bcc; border: solid 1px #9b6bcc; } i.icon-color-aqua { color: #27d7e7; border: solid 1px #27d7e7; } i.icon-color-brown { color: #9c8061; border: solid 1px #9c8061; } i.icon-color-dark-blue { color: #4765a0; border: solid 1px #4765a0; } i.icon-color-light-green { color: #79d5b3; border: solid 1px #79d5b3; } i.icon-color-light { color: #fff; border: solid 1px #fff; } i.icon-color-light-grey { color: #585f69; border: solid 1px #585f69; } /*Icons Backgroun Color*/ i.icon-bg-u, i.icon-bg-red, i.icon-bg-sea, i.icon-bg-dark, i.icon-bg-darker, i.icon-bg-grey, i.icon-bg-blue, i.icon-bg-green, i.icon-bg-yellow, i.icon-bg-orange, i.icon-bg-purple, i.icon-bg-aqua, i.icon-bg-brown, i.icon-bg-dark-blue, i.icon-bg-light-grey, i.icon-bg-light-green { color: #fff; border-color: transparent; } i.icon-bg-u { background: #72c02c; } i.icon-bg-blue { background: #3498db; } i.icon-bg-red { background: #e74c3c; } i.icon-bg-sea { background: #1abc9c; } i.icon-bg-green { background: #2ecc71; } i.icon-bg-yellow { background: #f1c40f; } i.icon-bg-orange { background: #e67e22; } i.icon-bg-grey { background: #95a5a6; } i.icon-bg-dark { background: #555; } i.icon-bg-darker { background: #333; } i.icon-bg-purple { background: #9b6bcc; } i.icon-bg-aqua { background: #27d7e7; } i.icon-bg-brown { background: #9c8061; } i.icon-bg-dark-blue { background: #4765a0; } i.icon-bg-light-green { background: #79d5b3; } i.icon-bg-light { background: #fff; border-color: transparent; } i.icon-bg-light-grey { background: #585f69; border-color: transparent; } /* Make Font Awesome icons fixed width */ .fa-fixed [class^="fa"], .fa-fixed [class*=" fa"] { width: 1.25em; text-align: center; display: inline-block; } .fa-fixed [class^="fa"].fa-lg, .fa-fixed [class*=" fa"].fa-lg { /* increased font size for fa-lg */ width: 1.5625em; } /*Content Boxes ------------------------------------*/ /*Content Boxes v1*/ .content-boxes-v1 { text-align: center; } .content-boxes-v1 span { display: block; margin-top: 5px; } /*Content Boxes v2*/ @media (max-width: 992px) { .content-boxes-v2, .content-boxes-v2 .text-justify { text-align: center; } .content-boxes-v2 span { display: block; margin-top: 5px; } } /*Content Boxes v3*/ .content-boxes-v3 i.icon-custom { top: 8px; float: left; position: relative; } .content-boxes-v3 .content-boxes-in-v3 { padding: 0 10px; overflow: hidden; } .content-boxes-v3 .content-boxes-in-v3 h3 { font-size: 18px; line-height: 22px; margin-bottom: 3px; text-transform: capitalize; } .content-boxes-v3 .content-boxes-in-v3 h3 a { color: #555; } /*Content Boxes Right v3*/ .content-boxes-v3.content-boxes-v3-right { text-align: right; } .content-boxes-v3.content-boxes-v3-right i.icon-custom { float: right; margin-left: 10px; } @media (max-width: 768px){ .content-boxes-v3.content-boxes-v3-right { text-align: inherit; } .content-boxes-v3.content-boxes-v3-right i.icon-custom { float: left; margin-left: 0; } } /*Content Boxes v4*/ .content-boxes-v4 h2 { color: #555; font-size: 18px; font-weight: bold; text-transform: uppercase; } .content-boxes-v4 a { color: #777; font-size: 11px; font-weight: bold; text-transform: uppercase; } .content-boxes-v4 i { width: 25px; color: #72c02c; font-size: 35px; margin-top: 10px; } .content-boxes-in-v4 { padding: 0 10px; overflow: hidden; } .content-boxes-v4-sm i { font-size: 26px; margin-top: 10px; margin-right: 5px; } /*Content Boxes v5*/ .content-boxes-v5 i { float: left; color: #999; width: 50px; height: 50px; padding: 11px; font-size: 22px; background: #eee; line-height: 28px; text-align: center; margin-right: 15px; display: inline-block; } .content-boxes-v5:hover i { color: #fff; background: #72c02c; } /*Content Boxes v6*/ .content-boxes-v6 { padding-top: 25px; text-align: center; } .content-boxes-v6 i { color: #fff; width: 90px; height: 90px; padding: 30px; font-size: 30px; line-height: 30px; position: relative; text-align: center; background: #dedede; margin-bottom: 25px; display: inline-block; } .content-boxes-v6 i:after { top: -8px; left: -8px; right: -8px; bottom: -8px; content: " "; position: absolute; border: 1px solid #dedede; border-radius: 50% !important; } .content-boxes-v6:hover i, .content-boxes-v6:hover i:after { -webkit-transition: all 0.3s ease-in-out; -moz-transition: all 0.3s ease-in-out; -o-transition: all 0.3s ease-in-out; transition: all 0.3s ease-in-out; } .content-boxes-v6:hover i { background: #72c02c; } .content-boxes-v6:hover i:after { border-color: #72c02c; } /*Colored Content Boxes ------------------------------------*/ .service-block { padding: 20px 30px; text-align: center; margin-bottom: 20px; } .service-block p, .service-block h2 { color: #fff; } .service-block h2 a:hover{ text-decoration: none; } .service-block-light, .service-block-default { background: #fafafa; border: solid 1px #eee; } .service-block-default:hover { box-shadow: 0 0 8px #eee; } .service-block-light p, .service-block-light h2, .service-block-default p, .service-block-default h2 { color: #555; } .service-block-u { background: #72c02c; } .service-block-blue { background: #3498db; } .service-block-red { background: #e74c3c; } .service-block-sea { background: #1abc9c; } .service-block-grey { background: #95a5a6; } .service-block-yellow { background: #f1c40f; } .service-block-orange { background: #e67e22; } .service-block-green { background: #2ecc71; } .service-block-purple { background: #9b6bcc; } .service-block-aqua { background: #27d7e7; } .service-block-brown { background: #9c8061; } .service-block-dark-blue { background: #4765a0; } .service-block-light-green { background: #79d5b3; } .service-block-dark { background: #555; } .service-block-light { background: #ecf0f1; } /*Funny Boxes ------------------------------------*/ .funny-boxes { background: #f7f7f7; padding: 20px 20px 15px; -webkit-transition:all 0.3s ease-in-out; -moz-transition:all 0.3s ease-in-out; -o-transition:all 0.3s ease-in-out; transition:all 0.3s ease-in-out; } .funny-boxes h2 { margin-top: 0; font-size: 18px; line-height: 20px; } .funny-boxes h2 a { color: #555; } .funny-boxes p a { color: #72c02c; } .funny-boxes .funny-boxes-img li { font-size: 12px; margin-bottom: 2px; } .funny-boxes .funny-boxes-img li i { color: #72c02c; font-size: 12px; margin-right: 5px; } @media (max-width: 992px) { .funny-boxes .funny-boxes-img li { display: inline-block; } } .funny-boxes .funny-boxes-img img { margin: 5px 10px 15px 0; } .funny-boxes ul.funny-boxes-rating li { display: inline-block; } .funny-boxes ul.funny-boxes-rating li i { color: #f8be2c; cursor: pointer; font-size: 14px; } .funny-boxes ul.funny-boxes-rating li i:hover { color: #f8be2c; } /*Funny Colored Boxes*/ .funny-boxes-colored p, .funny-boxes-colored h2 a, .funny-boxes-colored .funny-boxes-img li, .funny-boxes-colored .funny-boxes-img li i { color: #fff; } /*Red Funny Box*/ .funny-boxes-red { background: #e74c3c; } /*Dark Red Funny Box*/ .funny-boxes-purple { background: #9b6bcc; } /*Blue Funny Box*/ .funny-boxes-blue { background: #3498db; } /*Grey Funny Box*/ .funny-boxes-grey { background: #95a5a6; } /*Turquoise Funny Box*/ .funny-boxes-sea { background: #1abc9c; } /*Turquoise Top Bordered Funny Box*/ .funny-boxes-top-sea { border-top: solid 2px #1abc9c; } .funny-boxes-top-sea:hover { border-top-color: #16a085; } /*Yellow Top Bordered Funny Box**/ .funny-boxes-top-yellow { border-top: solid 2px #f1c40f; } .funny-boxes-top-yellow:hover { border-top-color: #f39c12; } /*Red Top Bordered Funny Box**/ .funny-boxes-top-red { border-top: solid 2px #e74c3c; } .funny-boxes-top-red:hover { border-top-color: #c0392b; } /*Purple Top Bordered Funny Box**/ .funny-boxes-top-purple { border-top: solid 2px #9b6bcc; } .funny-boxes-top-purple:hover { border-top-color: #814fb5; } /*Orange Left Bordered Funny Box**/ .funny-boxes-left-orange { border-left: solid 2px #e67e22; } .funny-boxes-left-orange:hover { border-left-color: #d35400; } /*Green Left Bordered Funny Box**/ .funny-boxes-left-green { border-left: solid 2px #72c02c; } .funny-boxes-left-green:hover { border-left-color: #5fb611; } /*Blue Left Bordered Funny Box**/ .funny-boxes-left-blue { border-left: solid 2px #3498db; } .funny-boxes-left-blue:hover { border-left-color: #2980b9; } /*Dark Left Bordered Funny Box**/ .funny-boxes-left-dark { border-left: solid 2px #555; } .funny-boxes-left-dark:hover { border-left-color: #333; } /*Typography ------------------------------------*/ .text-justify p { text-align: justify;} .text-transform-uppercase { text-transform: uppercase;} .text-transform-normal { text-transform: inherit !important;} .font-bold { font-weight: 600;} .font-light { font-weight: 200;} .font-normal { font-weight: 400 !important;} /*Text Dropcap*/ .dropcap { float: left; color: #72c02c; padding: 5px 0; font-size: 45px; font-weight: 200; line-height: 30px; margin: 0px 5px 0 0; } .dropcap-bg { float: left; color: #fff; padding: 7px 0; min-width: 50px; font-size: 35px; font-weight: 200; line-height: 35px; text-align: center; background: #72c02c; margin: 4px 10px 0 0; } /*Text Highlights*/ .text-highlights { color: #fff; font-weight: 200; padding: 0px 5px; background: #555; } .text-highlights-green { background: #72c02c; } .text-highlights-blue { background: #3498db; } .text-highlights-red { background: #e74c3c; } .text-highlights-sea { background: #1abc9c; } .text-highlights-orange { background: #e67e22; } .text-highlights-yellow { background: #f1c40f; } .text-highlights-purple { background: #9b6bcc; } .text-highlights-aqua { background: #27d7e7; } .text-highlights-brown { background: #9c8061; } .text-highlights-dark-blue { background: #4765a0; } .text-highlights-light-green { background: #79d5b3; } /*Text Borders*/ .text-border { border-bottom: dashed 1px #555; } .text-border-default { border-color: #95a5a6; } .text-border-green { border-color: #72c02c; } .text-border-blue { border-color: #3498db; } .text-border-red { border-color: #e74c3c; } .text-border-yellow { border-color: #f1c40f; } .text-border-purple { border-color: #9b6bcc; } /*List Styles*/ .list-styles li { margin-bottom: 8px; } /*Contextual Backgrounds*/ .contex-bg p { opacity: 0.8; padding: 8px 10px; } .contex-bg p:hover { opacity: 1; } /*Blockquote*/ blockquote { padding: 5px 15px; border-left-width: 2px; } blockquote p { font-size: 14px; font-weight: 400; } blockquote h1, blockquote h2, blockquote span { font-size: 18px; margin: 0 0 8px; line-height: 24px; } /*Blockquote Styles*/ blockquote.bq-text-lg p, blockquote.bq-text-lg small { text-transform: uppercase; } blockquote.bq-text-lg p { font-size: 22px; font-weight: 300; line-height: 32px; } blockquote.text-right, blockquote.hero.text-right { border-left: none; border-right: 2px solid #eee; } blockquote.hero.text-right, blockquote.hero.text-right:hover { border-color: #555; } blockquote:hover, blockquote.text-right:hover { border-color: #72c02c; -webkit-transition: all 0.4s ease-in-out; -moz-transition: all 0.4s ease-in-out; -o-transition: all 0.4s ease-in-out; transition: all 0.4s ease-in-out; } blockquote.bq-dark, blockquote.bq-dark:hover { border-color: #585f69; } blockquote.bq-green { border-color: #72c02c; } /*Blockquote Hero Styles*/ blockquote.hero { border: none; padding: 18px; font-size: 16px; background: #f3f3f3; border-left: solid 2px #666; } blockquote.hero:hover { background: #eee; border-left-color: #666; } blockquote.hero.hero-dark, blockquote.hero.hero-default { border: none; } blockquote.hero.hero-dark { background: #444; } blockquote.hero.hero-dark:hover { background: #555; } blockquote.hero.hero-default { background: #72c02c; } blockquote.hero.hero-default:hover { background: #5fb611; } blockquote.hero.hero-dark p, blockquote.hero.hero-dark h2, blockquote.hero.hero-dark small, blockquote.hero.hero-default p, blockquote.hero.hero-default h2, blockquote.hero.hero-default small { color: #fff; font-weight: 200; } /*Tag Boxes ------------------------------------*/ .tag-box { padding: 20px; background: #fff; margin-bottom: 30px; } .tag-box h2 { font-size: 20px; line-height: 25px; } .tag-box p { margin-bottom: 0; } .tag-box.tag-text-space p { margin-bottom: 10px; } /*Tag Boxes v1*/ .tag-box-v1 { border: solid 1px #eee; border-top: solid 2px #72c02c; } /*Tag Boxes v2*/ .tag-box-v2 { background: #fafafa; border: solid 1px #eee; border-left: solid 2px #72c02c; } /*Tag Boxes v3*/ .tag-box-v3 { border: solid 2px #eee; } /*Tag Boxes v4*/ .tag-box-v4 { border: dashed 1px #bbb; } /*Tag Boxes v5*/ .tag-box-v5 { margin: 20px 0; text-align: center; border: dashed 1px #ccc; } .tag-box-v5 span { color: #555; font-size: 28px; margin-bottom: 0; } /*Tag Boxes v6*/ .tag-box-v6 { background: #fafafa; border: solid 1px #eee; } /*Tag Boxes v7*/ .tag-box-v7 { border: solid 1px #eee; border-bottom: solid 2px #72c02c; } /*Testimonials ------------------------------------*/ /*Testimonials*/ .testimonials { margin-bottom: 10px; } .testimonials .testimonial-info { color: #72c02c; font-size: 16px; padding: 0 15px; margin-top: 18px; } .testimonials .testimonial-info span { top: 3px; position: relative; } .testimonials .testimonial-info em { color: #777; display: block; font-size: 13px; } .testimonials .testimonial-info img { width: 60px; float: left; height: 60px; padding: 2px; margin-right: 15px; border: solid 1px #ccc; } .testimonials .testimonial-author { overflow: hidden; } .testimonials .carousel-arrow { top: -65px; position: relative; } .testimonials .carousel-arrow i { color: #777; padding: 2px; min-width: 25px; font-size: 20px; text-align: center; background: #f5f5f5; } .testimonials .carousel-arrow i:hover { color: #fff; background: #72c02c; } .testimonials .carousel-control { opacity: 1; width: 100%; text-align: right; text-shadow: none; position: absolute; filter: Alpha(opacity = 100); /*For IE*/ } .testimonials .carousel-control.left { right: 27px; left: auto; } .testimonials .carousel-control.right { right: 0px; } /*Testimonials v1*/ .testimonials.testimonials-v1 .item p { position: relative; } .testimonials.testimonials-v1 .item p:after, .testimonials.testimonials-v1 .item p:before { left: 80px; bottom: -20px; } .testimonials.testimonials-v1 .item p:after { border-top: 22px solid; border-left: 0 solid transparent; border-right: 22px solid transparent; } /*Testimonials v2*/ .testimonials.testimonials-v2 .testimonial-info { padding: 0 20px; } .testimonials.testimonials-v2 p { padding-bottom: 15px; } .testimonials.testimonials-v2 .carousel-arrow { top: -55px; } .testimonials.testimonials-v2 .item p:after, .testimonials.testimonials-v2 .item p:before { left: 8%; bottom: 45px; } .testimonials.testimonials-v2 .item p:after { border-top: 20px solid; border-left: 25px solid transparent; border-right: 0px solid transparent; } /*General Testimonials v1/v2*/ .testimonials.testimonials-v1 p, .testimonials.testimonials-v2 p { padding: 15px; font-size: 14px; font-style: italic; background: #f5f5f5; } .testimonials.testimonials-v1 .item p:after, .testimonials.testimonials-v2 .item p:after { width: 0; height: 0; content: " "; display: block; position: absolute; border-top-color: #f5f5f5; border-left-style: inset; /*FF fixes*/ border-right-style: inset; /*FF fixes*/ } /*Testimonials Backgrounds*/ .testimonials-bg-dark .item p, .testimonials-bg-default .item p { color: #fff; font-weight: 200; } .testimonials-bg-dark .carousel-arrow i, .testimonials-bg-default .carousel-arrow i { color: #fff; } /*Testimonials Default*/ .testimonials-bg-default .item p { background: #72c02c; } .testimonials.testimonials-bg-default .item p:after, .testimonials.testimonials-bg-default .item p:after { border-top-color: #72c02c; } .testimonials-bg-default .carousel-arrow i { background: #72c02c; } .testimonials.testimonials-bg-default .carousel-arrow i:hover { background: #5fb611; } /*Testimonials Dark*/ .testimonials-bg-dark .item p { background: #555; } .testimonials.testimonials-bg-dark .item p:after, .testimonials.testimonials-bg-dark .item p:after { border-top-color: #555; } .testimonials-bg-dark .carousel-arrow i { color: #fff; background: #555; } .testimonials.testimonials-bg-dark .carousel-arrow i:hover { background: #333; } .testimonials.testimonials-bg-dark .testimonial-info { color: #555; } /*Panels (Portlets) ------------------------------------*/ .panel-heading { color: #fff; padding: 5px 15px; } /*Panel Table*/ .panel .table { margin-bottom: 0; } /*Panel Unify*/ .panel-u { border-color: #72c02c; } .panel-u > .panel-heading { background: #72c02c; } /*Panel Blue*/ .panel-blue { border-color: #3498db; } .panel-blue > .panel-heading { background: #3498db; } /*Panel Red*/ .panel-red { border-color: #e74c3c; } .panel-red > .panel-heading { background: #e74c3c; } /*Panel Green*/ .panel-green { border-color: #2ecc71; } .panel-green > .panel-heading { background: #2ecc71; } /*Panel Sea*/ .panel-sea { border-color: #1abc9c; } .panel-sea > .panel-heading { background: #1abc9c; } /*Panel Orange*/ .panel-orange { border-color: #e67e22; } .panel-orange > .panel-heading { background: #e67e22; } /*Panel Yellow*/ .panel-yellow { border-color: #f1c40f; } .panel-yellow > .panel-heading { background: #f1c40f; } /*Panel Grey*/ .panel-grey { border-color: #95a5a6; } .panel-grey > .panel-heading { background: #95a5a6; } /*Panel Dark*/ .panel-dark { border-color: #555; } .panel-dark > .panel-heading { background: #555; } /*Panel Purple*/ .panel-purple { border-color: #9b6bcc; } .panel-purple > .panel-heading { background: #9b6bcc; } /*Panel Aqua*/ .panel-aqua { border-color: #27d7e7; } .panel-aqua > .panel-heading { background: #27d7e7; } /*Panel Brown*/ .panel-brown { border-color: #9c8061; } .panel-brown > .panel-heading { background: #9c8061; } /*Panel Dark Blue*/ .panel-dark-blue { border-color: #4765a0; } .panel-dark-blue > .panel-heading { background: #4765a0; } /*Panel Light Green*/ .panel-light-green { border-color: #79d5b3; } .panel-light-green > .panel-heading { background: #79d5b3; } /*Panel Default Dark*/ .panel-default-dark { border-color: #585f69; } .panel-default-dark > .panel-heading { background: #585f69; } /*Progress Bar ------------------------------------*/ .progress-u { box-shadow: none; } .progress-u .progress-bar { box-shadow: none; } /*progress-bar (sizes)*/ .progress-lg { height: 25px; } .progress-lg p { padding-top: 3px; } .progress-sm { height: 12px; } .progress-xs { height: 7px; } .progress-xxs { height: 3px; } /*progress-bar (colors)*/ .progress { background: #e5e5e5; } .progress-bar-u { background: #72c02c; } .progress-bar-blue { background: #3498db; } .progress-bar-orange { background: #e67e22; } .progress-bar-red { background: #e74c3c; } .progress-bar-purple { background: #9b6bcc; } .progress-bar-aqua { background: #27d7e7; } .progress-bar-brown { background: #9c8061; } .progress-bar-dark-blue { background: #4765a0; } .progress-bar-light-green { background: #79d5b3; } .progress-bar-dark { background: #555; } /*Progress Bar Animation ------------------------------------*/ .progress { position: relative; } .progress .progress-bar { overflow: hidden; line-height: 20px; position: absolute; } .progress-box .progress-bar { transition: all 3s ease-in; -o-transition: all 3s ease-in; -ms-transition: all 3s ease-in; -moz-transition: all 3s ease-in; -webkit-transition: all 3s ease-in; } /*Vertical Progress Bar*/ .progress.vertical { float: left; width: 100%; height: 200px; margin-right: 20px; } .progress.vertical.bottom { position: relative; } .progress.vertical .progress-bar { height: 0; width: 100%; transition: height 3s ease; -o-transition: height 3s ease; -ms-transition: height 3s ease; -moz-transition: height 3s ease; -webkit-transition: height 3s ease; } .progress.vertical.bottom .progress-bar { bottom: 0; position: absolute; } /*Count Stars ------------------------------------*/ .stars-existing { color: #72c02c; cursor: pointer; } .star-lg { font-size: 30px; } .star-sm { font-size: 25px; } .star-xs { font-size: 20px; } .star-default { font-size: 16px; } /*Media (Audio/Videos and Images) ------------------------------------*/ /*Images*/ img.img-bordered { padding: 3px; border: solid 1px #eee; } img.img-circle { border-radius: 50% !important; } img.image-sm { width: 50px; height: 50px; } img.image-md { width: 100px; height: 100px; } /*Responsive Video*/ .responsive-video { height: 0; padding-top: 1px; position: relative; padding-bottom: 56.25%; /*16:9*/ } .responsive-video iframe { top: 0; left: 0; width: 100%; height: 100%; position: absolute; } /*Tags v1 ------------------------------------*/ .tags-v1 li { margin: 0; padding: 0; } .tags-v1 li a { font-size: 13px; padding: 4px 8px; line-height: 32px; border: solid 2px #eee; border-radius: 20px !important; -webkit-transition: all 0.2s ease-in-out; -moz-transition: all 0.2s ease-in-out; -o-transition: all 0.2s ease-in-out; transition: all 0.2s ease-in-out; } .tags-v1 li a:hover { text-decoration: none; border-color: #e0e0e0; } /*Tags v2 ------------------------------------*/ .tags-v2 li { padding: 7px 0 7px 4px; } .tags-v2 li a { color: #555; font-size: 13px; padding: 5px 10px; border: solid 1px #bbb; } .tags-v2 li a:hover { color: #fff; background: #555; border-color: #555; text-decoration: none; -webkit-transition: all 0.2s ease-in-out; -moz-transition: all 0.2s ease-in-out; -o-transition: all 0.2s ease-in-out; transition: all 0.2s ease-in-out; } /*Lists ------------------------------------*/ .list-row { padding: 0; margin-bottom: 0; list-style: none; } /*Lists v1*/ .lists-v1 li { margin-bottom: 10px; } .lists-v1 i { color: #fff; width: 15px; height: 15px; padding: 1px; font-size: 13px; margin-right: 7px; text-align: center; background: #72c02c; display: inline-block; border-radius: 50% !important; } /*Lists v2*/ .lists-v2 li { margin-bottom: 10px; } .lists-v2 i { color: #72c02c; font-size: 13px; margin-right: 7px; display: inline-block; } /*Column Sizes ------------------------------------*/ /*Remove the Gutter Padding from Columns*/ .no-gutter > [class*='col-'] { padding-right: 0; padding-left: 0; } .no-gutter.no-gutter-boxed { padding-right: 15px; padding-left: 15px; } /*Heights ------------------------------------*/ .height-100 { min-height: 100px;} .height-150 { min-height: 150px;} .height-200 { min-height: 200px;} .height-250 { min-height: 250px;} .height-300 { min-height: 300px;} .height-350 { min-height: 350px;} .height-400 { min-height: 400px;} .height-450 { min-height: 450px;} .height-500 { min-height: 500px !important;} /*Spaces ------------------------------------*/ .no-padding { padding: 0 !important; } .no-margin { margin: 0; } .no-top-space { margin-top: 0 !important; padding-top: 0 !important; } .no-bottom-space { margin-bottom: 0 !important; padding-bottom: 0 !important; } .no-margin-bottom { margin-bottom: 0 !important; } .no-padding-bottom { padding-bottom: 0 !important; } .content-xs { padding-top: 20px; padding-bottom: 20px; } .content { padding-top: 40px; padding-bottom: 40px; } .content-sm { padding-top: 60px; padding-bottom: 60px; } .content-md { padding-top: 80px; padding-bottom: 80px; } .content-lg { padding-top: 100px; padding-bottom: 100px; } .space-lg-hor { padding-left: 60px; padding-right: 60px; } .space-xlg-hor { padding-left: 100px; padding-right: 100px; } .margin-bottom-5, .margin-bottom-10, .margin-bottom-15, .margin-bottom-20, .margin-bottom-25, .margin-bottom-30, .margin-bottom-35, .margin-bottom-40, .margin-bottom-45, .margin-bottom-50, .margin-bottom-55, .margin-bottom-60 { clear:both; } .margin-bottom-5 { margin-bottom:5px;} .margin-bottom-10 { margin-bottom:10px;} .margin-bottom-15 { margin-bottom:15px;} .margin-bottom-20 { margin-bottom:20px;} .margin-bottom-25 { margin-bottom:25px;} .margin-bottom-30 { margin-bottom:30px;} .margin-bottom-35 { margin-bottom:35px;} .margin-bottom-40 { margin-bottom:40px;} .margin-bottom-45 { margin-bottom:45px;} .margin-bottom-50 { margin-bottom:50px;} .margin-bottom-55 { margin-bottom:55px;} .margin-bottom-60 { margin-bottom:60px;} .margin-bottom-80 { margin-bottom:80px;} .margin-bottom-100 { margin-bottom:100px;} @media (max-width: 768px) { .sm-margin-bottom-10 { margin-bottom: 10px; } .sm-margin-bottom-20 { margin-bottom: 20px; } .sm-margin-bottom-30 { margin-bottom: 30px; } .sm-margin-bottom-40 { margin-bottom: 40px; } .sm-margin-bottom-50 { margin-bottom: 50px; } .sm-margin-bottom-60 { margin-bottom: 60px; } } @media (max-width: 992px) { .md-margin-bottom-10 { margin-bottom: 10px; } .md-margin-bottom-20 { margin-bottom: 20px; } .md-margin-bottom-30 { margin-bottom: 30px; } .md-margin-bottom-40 { margin-bottom: 40px; } .md-margin-bottom-50 { margin-bottom: 50px; } .md-margin-bottom-60 { margin-bottom: 60px; } } /*Other Spaces*/ .margin-top-20 { margin-top: 20px;} .margin-left-5 { margin-left: 5px;} .margin-left-10 { margin-left: 10px;} .margin-right-5 { margin-right: 5px;} .margin-right-10 { margin-right: 10px;} .padding-top-5 { padding-top: 5px;} .padding-top-10 { padding-top: 10px;} .padding-top-20 { padding-top: 20px;} .padding-top-50 { padding-top: 50px;} .padding-top-70 { padding-top: 70px;} .padding-top-100 { padding-top: 100px;} .padding-left-5 { padding-left: 5px;} .padding-bottom-5 { padding-bottom: 5px;} .padding-bottom-10 { padding-bottom: 10px;} .padding-bottom-20 { padding-bottom: 20px;} .padding-bottom-30 { padding-bottom: 30px;} .padding-bottom-50 { padding-bottom: 50px;} .padding-bottom-70 { padding-bottom: 70px;} .padding-bottom-100 { padding-bottom: 100px;} /*Text Colors ------------------------------------*/ .color-sea { color: #1abc9c;} .color-red { color: #e74c3c;} .color-aqua { color: #27d7e7;} .color-blue { color: #3498db;} .color-grey { color: #95a5a6;} .color-dark { color: #555555;} .color-green { color: #72c02c;} .color-brown { color: #9c8061;} .color-light { color: #ffffff;} .color-orange { color: #e67e22;} .color-yellow { color: #f1c40f;} .color-green1 { color: #2ecc71;} .color-purple { color: #9b6bcc;} .color-inherit { color: inherit;} .color-dark-blue { color: #4765a0;} .color-light-grey { color: #585f69;} .color-light-green { color: #79d5b3;} /*Background Colors ------------------------------------*/ .bg-color-dark, .bg-color-sea, .bg-color-red, .bg-color-aqua, .bg-color-blue, .bg-color-grey, .bg-color-light, .bg-color-green, .bg-color-brown, .bg-color-orange, .bg-color-green1, .bg-color-purple, .bg-color-dark-blue, .bg-color-light-grey, .bg-color-light-green { color: #fff; } .bg-color-white { color: #555; } .bg-color-dark { background-color: #555 !important;} .bg-color-white { background-color: #fff !important;} .bg-color-sea { background-color: #1abc9c !important;} .bg-color-red { background-color: #e74c3c !important;} .bg-color-aqua { background-color: #27d7e7 !important;} .bg-color-blue { background-color: #3498db !important;} .bg-color-grey { background-color: #95a5a6 !important;} .bg-color-light { background-color: #f7f7f7 !important;} .bg-color-green { background-color: #72c02c !important;} .bg-color-brown { background-color: #9c8061 !important;} .bg-color-orange { background-color: #e67e22 !important;} .bg-color-green1 { background-color: #2ecc71 !important;} .bg-color-purple { background-color: #9b6bcc !important;} .bg-color-dark-blue { background-color: #4765a0 !important;} .bg-color-light-grey { background-color: #585f69 !important;} .bg-color-light-green { background-color: #79d5b3 !important;} .rgba-red { background-color: rgba(231,76,60,0.8);} .rgba-blue{ background-color: rgba(52,152,219,0.8);} .rgba-aqua { background-color: rgba(39,215,231,0.8);} .rgba-yellow { background-color: rgba(241,196,15,0.8);} .rgba-default { background-color: rgba(114,192,44,0.8);} .rgba-purple { background-color: rgba(155,107,204,0.8);} /*Grey Backroud*/ .bg-grey { background: #f7f7f7; border-top: solid 1px #eee; border-bottom: solid 1px #eee; } .bg-grey2 { background: #f4f6f6; } /*Rounded and Circle Classes ------------------------------------*/ .no-rounded { border-radius: 0 !important;} .rounded { border-radius: 4px !important;} .rounded-x { border-radius: 50% !important;} .rounded-2x { border-radius: 10px !important;} .rounded-3x { border-radius: 15px !important;} .rounded-4x { border-radius: 20px !important;} .rounded-sm { border-radius: 2px !important;} .rounded-md { border-radius: 3px !important;} .rounded-top { border-radius: 4px 4px 0 0 !important;} .rounded-left { border-radius: 4px 0 0 4px !important;} .rounded-right { border-radius: 0 4px 4px 0 !important;} .rounded-bottom { border-radius: 0 0 4px 4px !important;} /*Others ------------------------------------*/ .overflow-h { overflow: hidden;} .overflow-a { overflow: auto;} .overflow-hidden { overflow: hidden;} .clear-both { clear: both;} /*Display*/ .dp-none { display: none;} .dp-block { display: block;} .dp-table { display: table;} .dp-inline-block { display: inline-block;} .dp-table-cell { display: table-cell; vertical-align: middle; } /*Full Width*/ .full-width { width: 100%; } /*Equal Height Columns*/ @media (max-width: 767px) { .equal-height-column { height: auto !important; } } /*Image Classes*/ .img-width-200 { width:200px;} .lft-img-margin { margin:0 20px 5px 0;} .rgt-img-margin { margin:0 0 5px 10px;} img.img-center, .img-center img { margin-left: auto; margin-right: auto; } /*Background Light*/ .bg-light { padding: 10px 15px; margin-bottom: 10px; background: #fcfcfc; border: solid 1px #e5e5e5; } .bg-light:hover { border: solid 1px #bbb; } /*CSS3 Hover Effects*/ .hover-effect { -webkit-transition: all 0.4s ease-in-out; -moz-transition: all 0.4s ease-in-out; -o-transition: all 0.4s ease-in-out; transition: all 0.4s ease-in-out; } .hover-effect-kenburn { left:10px; margin-left:-10px; position:relative; -webkit-transition: all 0.8s ease-in-out; -moz-transition: all 0.8s ease-in-out; -o-transition: all 0.8s ease-in-out; -ms-transition: all 0.8s ease-in-out; transition: all 0.8s ease-in-out; } .hover-effect-kenburn:hover { -webkit-transform: scale(2) rotate(5deg); -moz-transform: scale(2) rotate(5deg); -o-transform: scale(2) rotate(5deg); -ms-transform: scale(2) rotate(5deg); transform: scale(2) rotate(5deg); }
neeravbm/unify
Unify-v1.8/HTML/One-Page/assets/css/old-app.css
CSS
gpl-2.0
68,076
cmd_drivers/base/dd.o := arm-eabi-gcc -Wp,-MD,drivers/base/.dd.o.d -nostdinc -isystem /home/tim/ICS/prebuilt/linux-x86/toolchain/arm-eabi-4.4.0/bin/../lib/gcc/arm-eabi/4.4.0/include -I/home/tim/Downloads/mitchtaydev-Thrive-Shiva-Kernel-ee65d90/linux-2.6/arch/arm/include -Iinclude -include include/generated/autoconf.h -D__KERNEL__ -mlittle-endian -Iarch/arm/mach-tegra/include -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs -fno-strict-aliasing -fno-common -Werror-implicit-function-declaration -Wno-format-security -fno-delete-null-pointer-checks -Os -marm -fno-dwarf2-cfi-asm -mabi=aapcs-linux -mno-thumb-interwork -funwind-tables -D__LINUX_ARM_ARCH__=7 -march=armv7-a -msoft-float -Uarm -Wframe-larger-than=1024 -fno-stack-protector -fomit-frame-pointer -g -Wdeclaration-after-statement -Wno-pointer-sign -fno-strict-overflow -fconserve-stack -D"KBUILD_STR(s)=\#s" -D"KBUILD_BASENAME=KBUILD_STR(dd)" -D"KBUILD_MODNAME=KBUILD_STR(dd)" -c -o drivers/base/dd.o drivers/base/dd.c deps_drivers/base/dd.o := \ drivers/base/dd.c \ include/linux/device.h \ $(wildcard include/config/of.h) \ $(wildcard include/config/debug/devres.h) \ $(wildcard include/config/numa.h) \ $(wildcard include/config/devtmpfs.h) \ $(wildcard include/config/printk.h) \ $(wildcard include/config/dynamic/debug.h) \ include/linux/ioport.h \ include/linux/compiler.h \ $(wildcard include/config/trace/branch/profiling.h) \ $(wildcard include/config/profile/all/branches.h) \ $(wildcard include/config/enable/must/check.h) \ $(wildcard include/config/enable/warn/deprecated.h) \ include/linux/compiler-gcc.h \ $(wildcard include/config/arch/supports/optimized/inlining.h) \ $(wildcard include/config/optimize/inlining.h) \ include/linux/compiler-gcc4.h \ include/linux/types.h \ $(wildcard include/config/uid16.h) \ $(wildcard include/config/lbdaf.h) \ $(wildcard include/config/phys/addr/t/64bit.h) \ $(wildcard include/config/64bit.h) \ /home/tim/Downloads/mitchtaydev-Thrive-Shiva-Kernel-ee65d90/linux-2.6/arch/arm/include/asm/types.h \ include/asm-generic/int-ll64.h \ /home/tim/Downloads/mitchtaydev-Thrive-Shiva-Kernel-ee65d90/linux-2.6/arch/arm/include/asm/bitsperlong.h \ include/asm-generic/bitsperlong.h \ include/linux/posix_types.h \ include/linux/stddef.h \ /home/tim/Downloads/mitchtaydev-Thrive-Shiva-Kernel-ee65d90/linux-2.6/arch/arm/include/asm/posix_types.h \ include/linux/kobject.h \ $(wildcard include/config/hotplug.h) \ include/linux/list.h \ $(wildcard include/config/debug/list.h) \ include/linux/poison.h \ $(wildcard include/config/illegal/pointer/value.h) \ include/linux/prefetch.h \ /home/tim/Downloads/mitchtaydev-Thrive-Shiva-Kernel-ee65d90/linux-2.6/arch/arm/include/asm/processor.h \ $(wildcard include/config/mmu.h) \ /home/tim/Downloads/mitchtaydev-Thrive-Shiva-Kernel-ee65d90/linux-2.6/arch/arm/include/asm/ptrace.h \ $(wildcard include/config/cpu/endian/be8.h) \ $(wildcard include/config/arm/thumb.h) \ $(wildcard include/config/smp.h) \ /home/tim/Downloads/mitchtaydev-Thrive-Shiva-Kernel-ee65d90/linux-2.6/arch/arm/include/asm/hwcap.h \ /home/tim/Downloads/mitchtaydev-Thrive-Shiva-Kernel-ee65d90/linux-2.6/arch/arm/include/asm/cache.h \ $(wildcard include/config/arm/l1/cache/shift.h) \ $(wildcard include/config/aeabi.h) \ /home/tim/Downloads/mitchtaydev-Thrive-Shiva-Kernel-ee65d90/linux-2.6/arch/arm/include/asm/system.h \ $(wildcard include/config/cpu/xsc3.h) \ $(wildcard include/config/cpu/fa526.h) \ $(wildcard include/config/arch/has/barriers.h) \ $(wildcard include/config/arm/dma/mem/bufferable.h) \ $(wildcard include/config/cpu/sa1100.h) \ $(wildcard include/config/cpu/sa110.h) \ $(wildcard include/config/cpu/32v6k.h) \ include/linux/linkage.h \ /home/tim/Downloads/mitchtaydev-Thrive-Shiva-Kernel-ee65d90/linux-2.6/arch/arm/include/asm/linkage.h \ include/linux/irqflags.h \ $(wildcard include/config/trace/irqflags.h) \ $(wildcard include/config/irqsoff/tracer.h) \ $(wildcard include/config/preempt/tracer.h) \ $(wildcard include/config/trace/irqflags/support.h) \ include/linux/typecheck.h \ /home/tim/Downloads/mitchtaydev-Thrive-Shiva-Kernel-ee65d90/linux-2.6/arch/arm/include/asm/irqflags.h \ /home/tim/Downloads/mitchtaydev-Thrive-Shiva-Kernel-ee65d90/linux-2.6/arch/arm/include/asm/outercache.h \ $(wildcard include/config/outer/cache/sync.h) \ $(wildcard include/config/outer/cache.h) \ arch/arm/mach-tegra/include/mach/barriers.h \ include/asm-generic/cmpxchg-local.h \ include/linux/sysfs.h \ $(wildcard include/config/debug/lock/alloc.h) \ $(wildcard include/config/sysfs.h) \ include/linux/errno.h \ /home/tim/Downloads/mitchtaydev-Thrive-Shiva-Kernel-ee65d90/linux-2.6/arch/arm/include/asm/errno.h \ include/asm-generic/errno.h \ include/asm-generic/errno-base.h \ include/linux/lockdep.h \ $(wildcard include/config/lockdep.h) \ $(wildcard include/config/lock/stat.h) \ $(wildcard include/config/generic/hardirqs.h) \ $(wildcard include/config/prove/locking.h) \ $(wildcard include/config/prove/rcu.h) \ include/linux/kobject_ns.h \ /home/tim/Downloads/mitchtaydev-Thrive-Shiva-Kernel-ee65d90/linux-2.6/arch/arm/include/asm/atomic.h \ $(wildcard include/config/generic/atomic64.h) \ include/asm-generic/atomic-long.h \ include/linux/spinlock.h \ $(wildcard include/config/debug/spinlock.h) \ $(wildcard include/config/generic/lockbreak.h) \ $(wildcard include/config/preempt.h) \ include/linux/preempt.h \ $(wildcard include/config/debug/preempt.h) \ $(wildcard include/config/preempt/notifiers.h) \ include/linux/thread_info.h \ $(wildcard include/config/compat.h) \ include/linux/bitops.h \ $(wildcard include/config/generic/find/first/bit.h) \ $(wildcard include/config/generic/find/last/bit.h) \ $(wildcard include/config/generic/find/next/bit.h) \ /home/tim/Downloads/mitchtaydev-Thrive-Shiva-Kernel-ee65d90/linux-2.6/arch/arm/include/asm/bitops.h \ include/asm-generic/bitops/non-atomic.h \ include/asm-generic/bitops/fls64.h \ include/asm-generic/bitops/sched.h \ include/asm-generic/bitops/hweight.h \ include/asm-generic/bitops/arch_hweight.h \ include/asm-generic/bitops/const_hweight.h \ include/asm-generic/bitops/lock.h \ /home/tim/Downloads/mitchtaydev-Thrive-Shiva-Kernel-ee65d90/linux-2.6/arch/arm/include/asm/thread_info.h \ $(wildcard include/config/arm/thumbee.h) \ /home/tim/Downloads/mitchtaydev-Thrive-Shiva-Kernel-ee65d90/linux-2.6/arch/arm/include/asm/fpstate.h \ $(wildcard include/config/vfpv3.h) \ $(wildcard include/config/iwmmxt.h) \ /home/tim/Downloads/mitchtaydev-Thrive-Shiva-Kernel-ee65d90/linux-2.6/arch/arm/include/asm/domain.h \ $(wildcard include/config/io/36.h) \ include/linux/kernel.h \ $(wildcard include/config/preempt/voluntary.h) \ $(wildcard include/config/debug/spinlock/sleep.h) \ $(wildcard include/config/ring/buffer.h) \ $(wildcard include/config/tracing.h) \ $(wildcard include/config/ftrace/mcount/record.h) \ /home/tim/ICS/prebuilt/linux-x86/toolchain/arm-eabi-4.4.0/bin/../lib/gcc/arm-eabi/4.4.0/include/stdarg.h \ include/linux/log2.h \ $(wildcard include/config/arch/has/ilog2/u32.h) \ $(wildcard include/config/arch/has/ilog2/u64.h) \ include/linux/dynamic_debug.h \ /home/tim/Downloads/mitchtaydev-Thrive-Shiva-Kernel-ee65d90/linux-2.6/arch/arm/include/asm/byteorder.h \ include/linux/byteorder/little_endian.h \ include/linux/swab.h \ /home/tim/Downloads/mitchtaydev-Thrive-Shiva-Kernel-ee65d90/linux-2.6/arch/arm/include/asm/swab.h \ include/linux/byteorder/generic.h \ /home/tim/Downloads/mitchtaydev-Thrive-Shiva-Kernel-ee65d90/linux-2.6/arch/arm/include/asm/bug.h \ $(wildcard include/config/bug.h) \ $(wildcard include/config/debug/bugverbose.h) \ include/asm-generic/bug.h \ $(wildcard include/config/generic/bug.h) \ $(wildcard include/config/generic/bug/relative/pointers.h) \ /home/tim/Downloads/mitchtaydev-Thrive-Shiva-Kernel-ee65d90/linux-2.6/arch/arm/include/asm/div64.h \ include/linux/stringify.h \ include/linux/bottom_half.h \ include/linux/spinlock_types.h \ /home/tim/Downloads/mitchtaydev-Thrive-Shiva-Kernel-ee65d90/linux-2.6/arch/arm/include/asm/spinlock_types.h \ include/linux/rwlock_types.h \ /home/tim/Downloads/mitchtaydev-Thrive-Shiva-Kernel-ee65d90/linux-2.6/arch/arm/include/asm/spinlock.h \ include/linux/rwlock.h \ include/linux/spinlock_api_smp.h \ $(wildcard include/config/inline/spin/lock.h) \ $(wildcard include/config/inline/spin/lock/bh.h) \ $(wildcard include/config/inline/spin/lock/irq.h) \ $(wildcard include/config/inline/spin/lock/irqsave.h) \ $(wildcard include/config/inline/spin/trylock.h) \ $(wildcard include/config/inline/spin/trylock/bh.h) \ $(wildcard include/config/inline/spin/unlock.h) \ $(wildcard include/config/inline/spin/unlock/bh.h) \ $(wildcard include/config/inline/spin/unlock/irq.h) \ $(wildcard include/config/inline/spin/unlock/irqrestore.h) \ include/linux/rwlock_api_smp.h \ $(wildcard include/config/inline/read/lock.h) \ $(wildcard include/config/inline/write/lock.h) \ $(wildcard include/config/inline/read/lock/bh.h) \ $(wildcard include/config/inline/write/lock/bh.h) \ $(wildcard include/config/inline/read/lock/irq.h) \ $(wildcard include/config/inline/write/lock/irq.h) \ $(wildcard include/config/inline/read/lock/irqsave.h) \ $(wildcard include/config/inline/write/lock/irqsave.h) \ $(wildcard include/config/inline/read/trylock.h) \ $(wildcard include/config/inline/write/trylock.h) \ $(wildcard include/config/inline/read/unlock.h) \ $(wildcard include/config/inline/write/unlock.h) \ $(wildcard include/config/inline/read/unlock/bh.h) \ $(wildcard include/config/inline/write/unlock/bh.h) \ $(wildcard include/config/inline/read/unlock/irq.h) \ $(wildcard include/config/inline/write/unlock/irq.h) \ $(wildcard include/config/inline/read/unlock/irqrestore.h) \ $(wildcard include/config/inline/write/unlock/irqrestore.h) \ include/linux/kref.h \ include/linux/wait.h \ /home/tim/Downloads/mitchtaydev-Thrive-Shiva-Kernel-ee65d90/linux-2.6/arch/arm/include/asm/current.h \ include/linux/klist.h \ include/linux/module.h \ $(wildcard include/config/symbol/prefix.h) \ $(wildcard include/config/modules.h) \ $(wildcard include/config/modversions.h) \ $(wildcard include/config/unused/symbols.h) \ $(wildcard include/config/kallsyms.h) \ $(wildcard include/config/tracepoints.h) \ $(wildcard include/config/event/tracing.h) \ $(wildcard include/config/module/unload.h) \ $(wildcard include/config/constructors.h) \ include/linux/stat.h \ /home/tim/Downloads/mitchtaydev-Thrive-Shiva-Kernel-ee65d90/linux-2.6/arch/arm/include/asm/stat.h \ include/linux/time.h \ $(wildcard include/config/arch/uses/gettimeoffset.h) \ include/linux/cache.h \ $(wildcard include/config/arch/has/cache/line/size.h) \ include/linux/seqlock.h \ include/linux/math64.h \ include/linux/kmod.h \ include/linux/gfp.h \ $(wildcard include/config/kmemcheck.h) \ $(wildcard include/config/highmem.h) \ $(wildcard include/config/zone/dma.h) \ $(wildcard include/config/zone/dma32.h) \ $(wildcard include/config/debug/vm.h) \ include/linux/mmzone.h \ $(wildcard include/config/force/max/zoneorder.h) \ $(wildcard include/config/memory/hotplug.h) \ $(wildcard include/config/sparsemem.h) \ $(wildcard include/config/compaction.h) \ $(wildcard include/config/arch/populates/node/map.h) \ $(wildcard include/config/discontigmem.h) \ $(wildcard include/config/flat/node/mem/map.h) \ $(wildcard include/config/cgroup/mem/res/ctlr.h) \ $(wildcard include/config/no/bootmem.h) \ $(wildcard include/config/have/memory/present.h) \ $(wildcard include/config/have/memoryless/nodes.h) \ $(wildcard include/config/need/node/memmap/size.h) \ $(wildcard include/config/need/multiple/nodes.h) \ $(wildcard include/config/have/arch/early/pfn/to/nid.h) \ $(wildcard include/config/flatmem.h) \ $(wildcard include/config/sparsemem/extreme.h) \ $(wildcard include/config/nodes/span/other/nodes.h) \ $(wildcard include/config/holes/in/zone.h) \ $(wildcard include/config/arch/has/holes/memorymodel.h) \ include/linux/threads.h \ $(wildcard include/config/nr/cpus.h) \ $(wildcard include/config/base/small.h) \ include/linux/numa.h \ $(wildcard include/config/nodes/shift.h) \ include/linux/init.h \ include/linux/nodemask.h \ include/linux/bitmap.h \ include/linux/string.h \ $(wildcard include/config/binary/printf.h) \ /home/tim/Downloads/mitchtaydev-Thrive-Shiva-Kernel-ee65d90/linux-2.6/arch/arm/include/asm/string.h \ include/linux/pageblock-flags.h \ $(wildcard include/config/hugetlb/page.h) \ $(wildcard include/config/hugetlb/page/size/variable.h) \ include/generated/bounds.h \ /home/tim/Downloads/mitchtaydev-Thrive-Shiva-Kernel-ee65d90/linux-2.6/arch/arm/include/asm/page.h \ $(wildcard include/config/cpu/copy/v3.h) \ $(wildcard include/config/cpu/copy/v4wt.h) \ $(wildcard include/config/cpu/copy/v4wb.h) \ $(wildcard include/config/cpu/copy/feroceon.h) \ $(wildcard include/config/cpu/copy/fa.h) \ $(wildcard include/config/cpu/xscale.h) \ $(wildcard include/config/cpu/copy/v6.h) \ /home/tim/Downloads/mitchtaydev-Thrive-Shiva-Kernel-ee65d90/linux-2.6/arch/arm/include/asm/glue.h \ $(wildcard include/config/cpu/arm610.h) \ $(wildcard include/config/cpu/arm710.h) \ $(wildcard include/config/cpu/abrt/lv4t.h) \ $(wildcard include/config/cpu/abrt/ev4.h) \ $(wildcard include/config/cpu/abrt/ev4t.h) \ $(wildcard include/config/cpu/abrt/ev5tj.h) \ $(wildcard include/config/cpu/abrt/ev5t.h) \ $(wildcard include/config/cpu/abrt/ev6.h) \ $(wildcard include/config/cpu/abrt/ev7.h) \ $(wildcard include/config/cpu/pabrt/legacy.h) \ $(wildcard include/config/cpu/pabrt/v6.h) \ $(wildcard include/config/cpu/pabrt/v7.h) \ /home/tim/Downloads/mitchtaydev-Thrive-Shiva-Kernel-ee65d90/linux-2.6/arch/arm/include/asm/memory.h \ $(wildcard include/config/page/offset.h) \ $(wildcard include/config/thumb2/kernel.h) \ $(wildcard include/config/dram/size.h) \ $(wildcard include/config/dram/base.h) \ $(wildcard include/config/have/tcm.h) \ include/linux/const.h \ arch/arm/mach-tegra/include/mach/memory.h \ /home/tim/Downloads/mitchtaydev-Thrive-Shiva-Kernel-ee65d90/linux-2.6/arch/arm/include/asm/sizes.h \ include/asm-generic/memory_model.h \ $(wildcard include/config/sparsemem/vmemmap.h) \ include/asm-generic/getorder.h \ include/linux/memory_hotplug.h \ $(wildcard include/config/have/arch/nodedata/extension.h) \ $(wildcard include/config/memory/hotremove.h) \ include/linux/notifier.h \ include/linux/mutex.h \ $(wildcard include/config/debug/mutexes.h) \ include/linux/rwsem.h \ $(wildcard include/config/rwsem/generic/spinlock.h) \ include/linux/rwsem-spinlock.h \ include/linux/srcu.h \ include/linux/topology.h \ $(wildcard include/config/sched/smt.h) \ $(wildcard include/config/sched/mc.h) \ $(wildcard include/config/use/percpu/numa/node/id.h) \ include/linux/cpumask.h \ $(wildcard include/config/cpumask/offstack.h) \ $(wildcard include/config/hotplug/cpu.h) \ $(wildcard include/config/debug/per/cpu/maps.h) \ $(wildcard include/config/disable/obsolete/cpumask/functions.h) \ include/linux/smp.h \ $(wildcard include/config/use/generic/smp/helpers.h) \ /home/tim/Downloads/mitchtaydev-Thrive-Shiva-Kernel-ee65d90/linux-2.6/arch/arm/include/asm/smp.h \ arch/arm/mach-tegra/include/mach/smp.h \ /home/tim/Downloads/mitchtaydev-Thrive-Shiva-Kernel-ee65d90/linux-2.6/arch/arm/include/asm/hardware/gic.h \ include/linux/percpu.h \ $(wildcard include/config/need/per/cpu/embed/first/chunk.h) \ $(wildcard include/config/need/per/cpu/page/first/chunk.h) \ $(wildcard include/config/have/setup/per/cpu/area.h) \ include/linux/pfn.h \ /home/tim/Downloads/mitchtaydev-Thrive-Shiva-Kernel-ee65d90/linux-2.6/arch/arm/include/asm/percpu.h \ include/asm-generic/percpu.h \ include/linux/percpu-defs.h \ $(wildcard include/config/debug/force/weak/per/cpu.h) \ /home/tim/Downloads/mitchtaydev-Thrive-Shiva-Kernel-ee65d90/linux-2.6/arch/arm/include/asm/topology.h \ include/asm-generic/topology.h \ include/linux/mmdebug.h \ $(wildcard include/config/debug/virtual.h) \ include/linux/workqueue.h \ $(wildcard include/config/debug/objects/work.h) \ $(wildcard include/config/freezer.h) \ include/linux/timer.h \ $(wildcard include/config/timer/stats.h) \ $(wildcard include/config/debug/objects/timers.h) \ include/linux/ktime.h \ $(wildcard include/config/ktime/scalar.h) \ include/linux/jiffies.h \ include/linux/timex.h \ include/linux/param.h \ /home/tim/Downloads/mitchtaydev-Thrive-Shiva-Kernel-ee65d90/linux-2.6/arch/arm/include/asm/param.h \ $(wildcard include/config/hz.h) \ /home/tim/Downloads/mitchtaydev-Thrive-Shiva-Kernel-ee65d90/linux-2.6/arch/arm/include/asm/timex.h \ arch/arm/mach-tegra/include/mach/timex.h \ include/linux/debugobjects.h \ $(wildcard include/config/debug/objects.h) \ $(wildcard include/config/debug/objects/free.h) \ include/linux/elf.h \ include/linux/elf-em.h \ /home/tim/Downloads/mitchtaydev-Thrive-Shiva-Kernel-ee65d90/linux-2.6/arch/arm/include/asm/elf.h \ /home/tim/Downloads/mitchtaydev-Thrive-Shiva-Kernel-ee65d90/linux-2.6/arch/arm/include/asm/user.h \ include/linux/moduleparam.h \ $(wildcard include/config/alpha.h) \ $(wildcard include/config/ia64.h) \ $(wildcard include/config/ppc64.h) \ include/linux/tracepoint.h \ include/linux/rcupdate.h \ $(wildcard include/config/rcu/torture/test.h) \ $(wildcard include/config/tree/rcu.h) \ $(wildcard include/config/tree/preempt/rcu.h) \ $(wildcard include/config/tiny/rcu.h) \ $(wildcard include/config/debug/objects/rcu/head.h) \ include/linux/completion.h \ include/linux/rcutree.h \ $(wildcard include/config/no/hz.h) \ /home/tim/Downloads/mitchtaydev-Thrive-Shiva-Kernel-ee65d90/linux-2.6/arch/arm/include/asm/module.h \ $(wildcard include/config/arm/unwind.h) \ include/trace/events/module.h \ include/trace/define_trace.h \ include/linux/pm.h \ $(wildcard include/config/pm/sleep.h) \ $(wildcard include/config/pm/runtime.h) \ $(wildcard include/config/pm/ops.h) \ /home/tim/Downloads/mitchtaydev-Thrive-Shiva-Kernel-ee65d90/linux-2.6/arch/arm/include/asm/device.h \ $(wildcard include/config/dmabounce.h) \ include/linux/pm_wakeup.h \ $(wildcard include/config/pm.h) \ include/linux/delay.h \ /home/tim/Downloads/mitchtaydev-Thrive-Shiva-Kernel-ee65d90/linux-2.6/arch/arm/include/asm/delay.h \ $(wildcard include/config/arch/provides/udelay.h) \ arch/arm/mach-tegra/include/mach/delay.h \ include/linux/kthread.h \ include/linux/err.h \ include/linux/sched.h \ $(wildcard include/config/sched/debug.h) \ $(wildcard include/config/lockup/detector.h) \ $(wildcard include/config/detect/hung/task.h) \ $(wildcard include/config/core/dump/default/elf/headers.h) \ $(wildcard include/config/virt/cpu/accounting.h) \ $(wildcard include/config/bsd/process/acct.h) \ $(wildcard include/config/taskstats.h) \ $(wildcard include/config/audit.h) \ $(wildcard include/config/inotify/user.h) \ $(wildcard include/config/epoll.h) \ $(wildcard include/config/posix/mqueue.h) \ $(wildcard include/config/keys.h) \ $(wildcard include/config/perf/events.h) \ $(wildcard include/config/schedstats.h) \ $(wildcard include/config/task/delay/acct.h) \ $(wildcard include/config/fair/group/sched.h) \ $(wildcard include/config/rt/group/sched.h) \ $(wildcard include/config/blk/dev/io/trace.h) \ $(wildcard include/config/cc/stackprotector.h) \ $(wildcard include/config/sysvipc.h) \ $(wildcard include/config/auditsyscall.h) \ $(wildcard include/config/rt/mutexes.h) \ $(wildcard include/config/task/xacct.h) \ $(wildcard include/config/cpusets.h) \ $(wildcard include/config/cgroups.h) \ $(wildcard include/config/futex.h) \ $(wildcard include/config/fault/injection.h) \ $(wildcard include/config/latencytop.h) \ $(wildcard include/config/function/graph/tracer.h) \ $(wildcard include/config/security/sealimemodule.h) \ $(wildcard include/config/have/unstable/sched/clock.h) \ $(wildcard include/config/stack/growsup.h) \ $(wildcard include/config/debug/stack/usage.h) \ $(wildcard include/config/cgroup/sched.h) \ $(wildcard include/config/mm/owner.h) \ include/linux/capability.h \ include/linux/rbtree.h \ include/linux/mm_types.h \ $(wildcard include/config/split/ptlock/cpus.h) \ $(wildcard include/config/want/page/debug/flags.h) \ $(wildcard include/config/aio.h) \ $(wildcard include/config/proc/fs.h) \ $(wildcard include/config/mmu/notifier.h) \ include/linux/auxvec.h \ /home/tim/Downloads/mitchtaydev-Thrive-Shiva-Kernel-ee65d90/linux-2.6/arch/arm/include/asm/auxvec.h \ include/linux/prio_tree.h \ include/linux/page-debug-flags.h \ $(wildcard include/config/page/poisoning.h) \ $(wildcard include/config/page/debug/something/else.h) \ /home/tim/Downloads/mitchtaydev-Thrive-Shiva-Kernel-ee65d90/linux-2.6/arch/arm/include/asm/mmu.h \ $(wildcard include/config/cpu/has/asid.h) \ /home/tim/Downloads/mitchtaydev-Thrive-Shiva-Kernel-ee65d90/linux-2.6/arch/arm/include/asm/cputime.h \ include/asm-generic/cputime.h \ include/linux/sem.h \ include/linux/ipc.h \ /home/tim/Downloads/mitchtaydev-Thrive-Shiva-Kernel-ee65d90/linux-2.6/arch/arm/include/asm/ipcbuf.h \ /home/tim/Downloads/mitchtaydev-Thrive-Shiva-Kernel-ee65d90/linux-2.6/arch/arm/include/asm/sembuf.h \ include/linux/signal.h \ /home/tim/Downloads/mitchtaydev-Thrive-Shiva-Kernel-ee65d90/linux-2.6/arch/arm/include/asm/signal.h \ include/asm-generic/signal-defs.h \ /home/tim/Downloads/mitchtaydev-Thrive-Shiva-Kernel-ee65d90/linux-2.6/arch/arm/include/asm/sigcontext.h \ /home/tim/Downloads/mitchtaydev-Thrive-Shiva-Kernel-ee65d90/linux-2.6/arch/arm/include/asm/siginfo.h \ include/asm-generic/siginfo.h \ include/linux/path.h \ include/linux/pid.h \ include/linux/proportions.h \ include/linux/percpu_counter.h \ include/linux/seccomp.h \ $(wildcard include/config/seccomp.h) \ include/linux/rculist.h \ include/linux/rtmutex.h \ $(wildcard include/config/debug/rt/mutexes.h) \ include/linux/plist.h \ $(wildcard include/config/debug/pi/list.h) \ include/linux/resource.h \ /home/tim/Downloads/mitchtaydev-Thrive-Shiva-Kernel-ee65d90/linux-2.6/arch/arm/include/asm/resource.h \ include/asm-generic/resource.h \ include/linux/hrtimer.h \ $(wildcard include/config/high/res/timers.h) \ include/linux/task_io_accounting.h \ $(wildcard include/config/task/io/accounting.h) \ include/linux/latencytop.h \ include/linux/cred.h \ $(wildcard include/config/debug/credentials.h) \ $(wildcard include/config/security.h) \ include/linux/key.h \ $(wildcard include/config/sysctl.h) \ include/linux/sysctl.h \ include/linux/selinux.h \ $(wildcard include/config/security/selinux.h) \ include/linux/aio.h \ include/linux/aio_abi.h \ include/linux/uio.h \ include/linux/async.h \ include/linux/pm_runtime.h \ drivers/base/base.h \ $(wildcard include/config/sys/hypervisor.h) \ drivers/base/power/power.h \ drivers/base/dd.o: $(deps_drivers/base/dd.o) $(deps_drivers/base/dd.o):
timmytim/honeybutter_kernel
drivers/base/.dd.o.cmd
Batchfile
gpl-2.0
24,002
package openra.server; import openra.core.Unit; public class UnitAnimEvent extends ActionEvent { private Unit un; private UnitAnimEvent scheduled; public UnitAnimEvent(int p, Unit un) { super(p); //logger->debug("UAE cons: this:%p un:%p\n",this,un); this.un = un; //un.referTo(); scheduled = null; } void destUnitAnimEvent() { //logger->debug("UAE dest: this:%p un:%p sch:%p\n",this,un,scheduled); if (scheduled != null) { this.getAequeue().scheduleEvent(scheduled); } //un->unrefer(); } protected void setSchedule(UnitAnimEvent e) { //logger->debug("Scheduling an event. (this: %p, e: %p)\n",this,e); if (scheduled != null) { scheduled.setSchedule(null); scheduled.stop(); } scheduled = e; } void stopScheduled() { if (scheduled != null) { scheduled.stop(); } } void update() { } }
damiencarol/openredalert
java/src/openra/server/UnitAnimEvent.java
Java
gpl-2.0
965
# snake mini snake en SDL Le but de ce repo est de proposer un algorithme simple pour comprendre une manière de faire un snake, l'utilisation de la librairie graphique SDL n'étant là que pour la mise en place du cadre du jeu. Ce tutoriel se veut se concentrer en particulier sur comment faire facilement bouger le ver, de manière rapide et efficace, sans que cela ne devienne trop compliqué ou lent lorsque le ver devient plus grand.
elekmad/snake
README.md
Markdown
gpl-2.0
441
/** * Copyright (C) 2013, Moss Computing Inc. * * This file is part of simpledeb. * * simpledeb is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. * * simpledeb is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. * * You should have received a copy of the GNU General Public License * along with simpledeb; see the file COPYING. If not, write to the * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA * 02110-1301 USA. * * Linking this library statically or dynamically with other modules is * making a combined work based on this library. Thus, the terms and * conditions of the GNU General Public License cover the whole * combination. * * As a special exception, the copyright holders of this library give you * permission to link this library with independent modules to produce an * executable, regardless of the license terms of these independent * modules, and to copy and distribute the resulting executable under * terms of your choice, provided that you also meet, for each linked * independent module, the terms and conditions of the license of that * module. An independent module is a module which is not derived from * or based on this library. If you modify this library, you may extend * this exception to your version of the library, but you are not * obligated to do so. If you do not wish to do so, delete this * exception statement from your version. */ package com.moss.simpledeb.core.action; import java.io.File; import java.util.LinkedList; import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlAttribute; import org.apache.commons.compress.archivers.tar.TarArchiveEntry; import com.moss.simpledeb.core.DebComponent; import com.moss.simpledeb.core.DebState; import com.moss.simpledeb.core.path.ArchivePath; import com.moss.simpledeb.core.path.BytesArchivePath; import com.moss.simpledeb.core.path.DirArchivePath; @XmlAccessorType(XmlAccessType.FIELD) public final class LaunchScriptAction extends DebAction { @XmlAttribute(name="class-name") private String className; @XmlAttribute(name="target-file") private String targetFile; @XmlAttribute(name="path-level") private int pathLevel; @Override public void run(DebState state) throws Exception { { File target = new File(targetFile).getParentFile(); LinkedList<File> pathsNeeded = new LinkedList<File>(); File f = target; while (f != null) { pathsNeeded.addFirst(f); f = f.getParentFile(); } for (int i=0; i<pathLevel; i++) { pathsNeeded.removeFirst(); } for (File e : pathsNeeded) { String p = "./" + e.getPath(); if (!p.endsWith("/")) { p = p + "/"; } TarArchiveEntry tarEntry = new TarArchiveEntry(p); tarEntry.setGroupId(0); tarEntry.setGroupName("root"); tarEntry.setIds(0, 0); tarEntry.setModTime(System.currentTimeMillis()); tarEntry.setSize(0); tarEntry.setUserId(0); tarEntry.setUserName("root"); tarEntry.setMode(Integer.parseInt("755", 8)); ArchivePath path = new DirArchivePath(tarEntry); state.addPath(DebComponent.CONTENT, path); } } String cp; { StringBuffer sb = new StringBuffer(); for (String path : state.classpath) { if (sb.length() == 0) { sb.append(path); } else { sb.append(":"); sb.append(path); } } cp = sb.toString(); } StringBuilder sb = new StringBuilder(); sb.append("#!/bin/bash\n"); sb.append("CP=\""); sb.append(cp); sb.append("\"\n"); sb.append("/usr/bin/java -cp $CP "); sb.append(className); sb.append(" $@\n"); byte[] data = sb.toString().getBytes(); String entryName = "./" + targetFile; TarArchiveEntry tarEntry = new TarArchiveEntry(entryName); tarEntry.setGroupId(0); tarEntry.setGroupName("root"); tarEntry.setIds(0, 0); tarEntry.setModTime(System.currentTimeMillis()); tarEntry.setSize(data.length); tarEntry.setUserId(0); tarEntry.setUserName("root"); tarEntry.setMode(Integer.parseInt("755", 8)); ArchivePath path = new BytesArchivePath(tarEntry, data); state.addPath(DebComponent.CONTENT, path); } public String getClassName() { return className; } public void setClassName(String className) { this.className = className; } public String getTargetFile() { return targetFile; } public void setTargetFile(String targetFile) { this.targetFile = targetFile; } public int getPathLevel() { return pathLevel; } public void setPathLevel(int assumedTargetPathLevel) { this.pathLevel = assumedTargetPathLevel; } }
mosscode/simpledeb
core/src/main/java/com/moss/simpledeb/core/action/LaunchScriptAction.java
Java
gpl-2.0
4,990
/*µü´úÆ÷ģʽ * * ±éÀú¼¯ºÏµÄÖ°Ôð·ÖÀë³öÀ´£» */ /**°×Ïä¾ÛºÏ+Íâµü´ú×Ó*/ public interface Iterator { public Object first(); public Object next(); //µÃµ½µ±Ç°¶ÔÏó public Object currentItem(); //ÊÇ·ñµ½Á˽áβ public boolean isDone(); } //ÕýÐòµü´úÆ÷ public class ConcreteIterator implements Iterator { private int currentIndex = 0; //¶¨ÒåÒ»¸ö¾ßÌ弯ºÏ¶ÔÏó private Aggregate aggregate = null; public ConcreteIterator(Aggregate aggregate) { this.aggregate = aggregate; } //ÖØÐ´¸¸Àà·½·¨ @Override public Object first() { currentIndex = 0; return vector.get(currentIndex); } @Override public Object next() { if(currentIndex < aggregate.count()) currentIndex++; return vector.get(currentIndex); } @Override public Object currentItem() { return aggregate.getAt(currentIndex); } @Override public boolean isDone() { return (currentIndex >= aggregate.count()); } } /*¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª*/ //°×Ïä¾ÛºÏÒªÇ󼯺ÏÀàÏòÍâ½çÌṩ·ÃÎÊ×Ô¼ºÄÚ²¿ÔªËØµÄ½Ó¿Ú public interface Aggregat { public Iterator createIterator(); //»ñÈ¡¼¯ºÏÄÚ²¿ÔªËØ×ÜÊý public int count(); //»ñȡָ¶¨Î»ÖÃÔªËØ public Object getAt(int index); } /*¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª*/ //¾ßÌåµÄ¼¯ºÏÀà public class ConcreteAggregat implements Aggregat { private Vector vector = null; public Vector getVector() { return vector; } public void setVector(final Vector vector) { this.vector = vector; } public ConcreteAggregat() { vector = new Vector(); vector.add("item 1"); vector.add("item 2"); } //»ñÈ¡¼¯ºÏÄÚ²¿ÔªËØ×ÜÊý @Override public int count() { return vector.size(); } //»ñȡָ¶¨Î»ÖÃÔªËØ @Override public Object getAt(int index) { if(0 <= index && index < vector.size()) return vector[index]; else return null; } //´´½¨Ò»¸ö¾ßÌåµü´úÆ÷¶ÔÏ󣬲¢°Ñ¸Ã¼¯ºÏ¶ÔÏó×ÔÉí½»¸ø¸Ãµü´úÆ÷ @Override public Iterator createIterator() { //ÕâÀï¿ÉÒÔʹÓüòµ¥¹¤³§Ä£Ê½ return new ConcreteIterator(this); } } /*¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª*/ public class Client { public static void main(final String[] args) { Aggregat agg = new ConcreteAggregat(); final Iterator iterator = agg.createIterator(); System.out.println(iterator.first()); while (!iterator.isDone()) { //Item item = (Item)iterator.currentItem(); System.out.println(iterator.next()); } } }
creary/company
document/设计模式/3行为型/3迭代器.java
Java
gpl-2.0
2,882
/* * This file is part of the coreboot project. * * Copyright (C) 2007-2008 coresystems GmbH * 2012 secunet Security Networks AG * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; version 2 of the License. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #ifndef NORTHBRIDGE_INTEL_I965_CHIP_H #define NORTHBRIDGE_INTEL_I965_CHIP_H struct northbridge_intel_i965_config { int gpu_use_spread_spectrum_clock; int gpu_lvds_dual_channel; int gpu_link_frequency_270_mhz; int gpu_lvds_num_lanes; }; #endif /* NORTHBRIDGE_INTEL_I965_CHIP_H */
lkundrak/coreboot
src/northbridge/intel/i965/chip.h
C
gpl-2.0
1,106
/* $Id$ */ /** @file * VMM - Raw-mode Context. */ /* * Copyright (C) 2006-2012 Oracle Corporation * * This file is part of VirtualBox Open Source Edition (OSE), as * available from http://www.virtualbox.org. This file is free software; * you can redistribute it and/or modify it under the terms of the GNU * General Public License (GPL) as published by the Free Software * Foundation, in version 2 as it comes in the "COPYING" file of the * VirtualBox OSE distribution. VirtualBox OSE is distributed in the * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind. */ /******************************************************************************* * Header Files * *******************************************************************************/ #define LOG_GROUP LOG_GROUP_VMM #include <iprt/asm-amd64-x86.h> /* for SUPGetCpuHzFromGIP */ #include <VBox/vmm/vmm.h> #include <VBox/vmm/trpm.h> #include <VBox/vmm/pgm.h> #include "VMMInternal.h" #include <VBox/vmm/vm.h> #include <VBox/sup.h> #include <VBox/err.h> #include <VBox/log.h> #include <iprt/assert.h> #include <iprt/initterm.h> /******************************************************************************* * Global Variables * *******************************************************************************/ /** Default logger instance. */ extern "C" DECLIMPORT(RTLOGGERRC) g_Logger; extern "C" DECLIMPORT(RTLOGGERRC) g_RelLogger; /******************************************************************************* * Internal Functions * *******************************************************************************/ static int vmmGCTest(PVM pVM, unsigned uOperation, unsigned uArg); static DECLCALLBACK(int) vmmGCTestTmpPFHandler(PVM pVM, PCPUMCTXCORE pRegFrame); static DECLCALLBACK(int) vmmGCTestTmpPFHandlerCorruptFS(PVM pVM, PCPUMCTXCORE pRegFrame); /** * The GC entry point. * * @returns VBox status code. * @param pVM Pointer to the VM. * @param uOperation Which operation to execute (VMMGCOPERATION). * @param uArg Argument to that operation. */ VMMRCDECL(int) VMMGCEntry(PVM pVM, unsigned uOperation, unsigned uArg, ...) { /* todo */ switch (uOperation) { /* * Init RC modules. */ case VMMGC_DO_VMMGC_INIT: { /* * Validate the svn revision (uArg) and build type (ellipsis). */ if (uArg != VMMGetSvnRev()) return VERR_VMM_RC_VERSION_MISMATCH; va_list va; va_start(va, uArg); uint32_t uBuildType = va_arg(va, uint32_t); if (uBuildType != vmmGetBuildType()) return VERR_VMM_RC_VERSION_MISMATCH; /* * Initialize the runtime. */ uint64_t u64TS = va_arg(va, uint64_t); va_end(va); int rc = RTRCInit(u64TS); Log(("VMMGCEntry: VMMGC_DO_VMMGC_INIT - uArg=%u (svn revision) u64TS=%RX64; rc=%Rrc\n", uArg, u64TS, rc)); AssertRCReturn(rc, rc); rc = PGMRegisterStringFormatTypes(); AssertRCReturn(rc, rc); rc = PGMRCDynMapInit(pVM); AssertRCReturn(rc, rc); return VINF_SUCCESS; } /* * Testcase which is used to test interrupt forwarding. * It spins for a while with interrupts enabled. */ case VMMGC_DO_TESTCASE_HYPER_INTERRUPT: { uint32_t volatile i = 0; ASMIntEnable(); while (i < _2G32) i++; ASMIntDisable(); return 0; } /* * Testcase which simply returns, this is used for * profiling of the switcher. */ case VMMGC_DO_TESTCASE_NOP: return 0; /* * Testcase executes a privileged instruction to force a world switch. (in both SVM & VMX) */ case VMMGC_DO_TESTCASE_HM_NOP: ASMRdMsr_Low(MSR_IA32_SYSENTER_CS); return 0; /* * Delay for ~100us. */ case VMMGC_DO_TESTCASE_INTERRUPT_MASKING: { uint64_t u64MaxTicks = (SUPGetCpuHzFromGIP(g_pSUPGlobalInfoPage) != ~(uint64_t)0 ? SUPGetCpuHzFromGIP(g_pSUPGlobalInfoPage) : _2G) / 10000; uint64_t u64StartTSC = ASMReadTSC(); uint64_t u64TicksNow; uint32_t volatile i = 0; do { /* waste some time and protect against getting stuck. */ for (uint32_t volatile j = 0; j < 1000; j++, i++) if (i > _2G32) return VERR_GENERAL_FAILURE; /* check if we're done.*/ u64TicksNow = ASMReadTSC() - u64StartTSC; } while (u64TicksNow < u64MaxTicks); return VINF_SUCCESS; } /* * Trap testcases and unknown operations. */ default: if ( uOperation >= VMMGC_DO_TESTCASE_TRAP_FIRST && uOperation < VMMGC_DO_TESTCASE_TRAP_LAST) return vmmGCTest(pVM, uOperation, uArg); return VERR_INVALID_PARAMETER; } } /** * Internal RC logger worker: Flush logger. * * @returns VINF_SUCCESS. * @param pLogger The logger instance to flush. * @remark This function must be exported! */ VMMRCDECL(int) vmmGCLoggerFlush(PRTLOGGERRC pLogger) { PVM pVM = &g_VM; NOREF(pLogger); if (pVM->vmm.s.fRCLoggerFlushingDisabled) return VINF_SUCCESS; /* fail quietly. */ return VMMRZCallRing3NoCpu(pVM, VMMCALLRING3_VMM_LOGGER_FLUSH, 0); } /** * Flush logger if almost full. * * @param pVM Pointer to the VM. */ VMMRCDECL(void) VMMGCLogFlushIfFull(PVM pVM) { if ( pVM->vmm.s.pRCLoggerRC && pVM->vmm.s.pRCLoggerRC->offScratch >= (sizeof(pVM->vmm.s.pRCLoggerRC->achScratch)*3/4)) { if (pVM->vmm.s.fRCLoggerFlushingDisabled) return; /* fail quietly. */ VMMRZCallRing3NoCpu(pVM, VMMCALLRING3_VMM_LOGGER_FLUSH, 0); } } /** * Switches from guest context to host context. * * @param pVM Pointer to the VM. * @param rc The status code. */ VMMRCDECL(void) VMMGCGuestToHost(PVM pVM, int rc) { pVM->vmm.s.pfnRCToHost(rc); } /** * Calls the ring-0 host code. * * @param pVM Pointer to the VM. */ DECLASM(void) vmmRCProbeFireHelper(PVM pVM) { pVM->vmm.s.pfnRCToHost(VINF_VMM_CALL_TRACER); } /** * Execute the trap testcase. * * There is some common code here, that's why we're collecting them * like this. Odd numbered variation (uArg) are executed with write * protection (WP) enabled. * * @returns VINF_SUCCESS if it was a testcase setup up to continue and did so successfully. * @returns VERR_NOT_IMPLEMENTED if the testcase wasn't implemented. * @returns VERR_GENERAL_FAILURE if the testcase continued when it shouldn't. * * @param pVM Pointer to the VM. * @param uOperation The testcase. * @param uArg The variation. See function description for odd / even details. * * @remark Careful with the trap 08 testcase and WP, it will triple * fault the box if the TSS, the Trap8 TSS and the fault TSS * GDTE are in pages which are read-only. * See bottom of SELMR3Init(). */ static int vmmGCTest(PVM pVM, unsigned uOperation, unsigned uArg) { /* * Set up the testcase. */ #if 0 switch (uOperation) { default: break; } #endif /* * Enable WP if odd variation. */ if (uArg & 1) vmmGCEnableWP(); /* * Execute the testcase. */ int rc = VERR_NOT_IMPLEMENTED; switch (uOperation) { //case VMMGC_DO_TESTCASE_TRAP_0: //case VMMGC_DO_TESTCASE_TRAP_1: //case VMMGC_DO_TESTCASE_TRAP_2: case VMMGC_DO_TESTCASE_TRAP_3: { if (uArg <= 1) rc = vmmGCTestTrap3(); break; } //case VMMGC_DO_TESTCASE_TRAP_4: //case VMMGC_DO_TESTCASE_TRAP_5: //case VMMGC_DO_TESTCASE_TRAP_6: //case VMMGC_DO_TESTCASE_TRAP_7: case VMMGC_DO_TESTCASE_TRAP_8: { #ifndef DEBUG_bird /** @todo dynamic check that this won't triple fault... */ if (uArg & 1) break; #endif if (uArg <= 1) rc = vmmGCTestTrap8(); break; } //VMMGC_DO_TESTCASE_TRAP_9, //VMMGC_DO_TESTCASE_TRAP_0A, //VMMGC_DO_TESTCASE_TRAP_0B, //VMMGC_DO_TESTCASE_TRAP_0C, case VMMGC_DO_TESTCASE_TRAP_0D: { if (uArg <= 1) rc = vmmGCTestTrap0d(); break; } case VMMGC_DO_TESTCASE_TRAP_0E: { if (uArg <= 1) rc = vmmGCTestTrap0e(); else if (uArg == 2 || uArg == 4) { /* * Test the use of a temporary #PF handler. */ rc = TRPMGCSetTempHandler(pVM, X86_XCPT_PF, uArg != 4 ? vmmGCTestTmpPFHandler : vmmGCTestTmpPFHandlerCorruptFS); if (RT_SUCCESS(rc)) { rc = vmmGCTestTrap0e(); /* in case it didn't fire. */ int rc2 = TRPMGCSetTempHandler(pVM, X86_XCPT_PF, NULL); if (RT_FAILURE(rc2) && RT_SUCCESS(rc)) rc = rc2; } } break; } } /* * Re-enable WP. */ if (uArg & 1) vmmGCDisableWP(); return rc; } /** * Temporary \#PF trap handler for the \#PF test case. * * @returns VBox status code (appropriate for GC return). * In this context RT_SUCCESS means to restart the instruction. * @param pVM Pointer to the VM. * @param pRegFrame Trap register frame. */ static DECLCALLBACK(int) vmmGCTestTmpPFHandler(PVM pVM, PCPUMCTXCORE pRegFrame) { if (pRegFrame->eip == (uintptr_t)vmmGCTestTrap0e_FaultEIP) { pRegFrame->eip = (uintptr_t)vmmGCTestTrap0e_ResumeEIP; return VINF_SUCCESS; } NOREF(pVM); return VERR_INTERNAL_ERROR; } /** * Temporary \#PF trap handler for the \#PF test case, this one messes up the fs * selector. * * @returns VBox status code (appropriate for GC return). * In this context RT_SUCCESS means to restart the instruction. * @param pVM Pointer to the VM. * @param pRegFrame Trap register frame. */ static DECLCALLBACK(int) vmmGCTestTmpPFHandlerCorruptFS(PVM pVM, PCPUMCTXCORE pRegFrame) { int rc = vmmGCTestTmpPFHandler(pVM, pRegFrame); pRegFrame->fs.Sel = 0x30; return rc; }
fintler/vbox
src/VBox/VMM/VMMRC/VMMRC.cpp
C++
gpl-2.0
11,065
package yuka.detectors; import yuka.containers.News; import javax.imageio.ImageIO; import java.awt.image.BufferedImage; import java.io.IOException; import java.io.InputStream; import java.net.URL; import java.net.URLConnection; import java.util.HashMap; import java.util.Map; /** * Created by imyuka on 18/08/2016. */ public class FigureDetector { private Map<String, Integer> cmap; private Map<String, Integer> pmap; private Map<String, Integer> dim; //private int height = 0; //private int height = 0; public FigureDetector(Map<String, String> figure) { String url = figure.get(News.IMAGE_URL); dim = getDimension(url); String caption = figure.get(News.IMAGE_CAPTION); cmap = ClubDetector.count(caption); PlayerDetector pd = new PlayerDetector(cmap.keySet()); pmap = pd.count(caption); } public int getHeight() { return dim.get("height"); } public int getWidth() { return dim.get("width"); } public double getPercentage (double totalHeight) { return (double) getWidth() / HeightDetector.COLUMN_WIDTH * (getHeight() / totalHeight); } public Map<String, Integer> getClubMap() { return cmap; } public Map<String, Integer> getPlayerMap() { return pmap; } public static Map<String, Integer> getDimension (String source) { //int[] dim = new int[]{0,0}; Map<String, Integer> dim = new HashMap<>(); dim.put("width", 0); dim.put("height", 0); try { URL url = new URL(source); URLConnection conn = url.openConnection(); // now you get the content length /////int contentLength = conn.getContentLength(); // you can check size here using contentLength InputStream in = conn.getInputStream(); BufferedImage image = ImageIO.read(in); // you can get size dimesion //int width = image.getWidth(); //int height = image.getHeight(); dim.put("width", image.getWidth()); dim.put("height", image.getHeight()); } catch (IOException e) { System.out.println(); } return dim; } }
imyuka/AFL
AFL/src/main/java/yuka/detectors/FigureDetector.java
Java
gpl-2.0
2,274
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"> <html> <!-- Mirrored from www.photobookmart.com.my/wp-content/themes/choices/framework/php/avia_shortcodes/tinymce/js/?C=M;O=A by HTTrack Website Copier/3.x [XR&CO'2014], Wed, 02 Jul 2014 12:07:04 GMT --> <!-- Added by HTTrack --><meta http-equiv="content-type" content="text/html;charset=ISO-8859-1" /><!-- /Added by HTTrack --> <head> <title>Index of /wp-content/themes/choices/framework/php/avia_shortcodes/tinymce/js</title> </head> <body> <h1>Index of /wp-content/themes/choices/framework/php/avia_shortcodes/tinymce/js</h1> <table><tr><th><img src="../../../../../../../../icons/blank.html" alt="[ICO]"></th><th><a href="indexb70a.html?C=N;O=A">Name</a></th><th><a href="index72c9.html?C=M;O=D">Last modified</a></th><th><a href="indexbfec.html?C=S;O=A">Size</a></th><th><a href="index30b5.html?C=D;O=A">Description</a></th></tr><tr><th colspan="5"><hr></th></tr> <tr><td valign="top"><img src="../../../../../../../../icons/back.html" alt="[DIR]"></td><td><a href="../index.html">Parent Directory</a></td><td>&nbsp;</td><td align="right"> - </td></tr> <tr><td valign="top"><img src="../../../../../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="column-control.js">column-control.js</a></td><td align="right">19-Aug-2013 14:14 </td><td align="right">3.9K</td></tr> <tr><td valign="top"><img src="../../../../../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="dialog.js">dialog.js</a></td><td align="right">19-Aug-2013 14:14 </td><td align="right"> 11K</td></tr> <tr><td valign="top"><img src="../../../../../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="sidebar-tab-control.js">sidebar-tab-control.js</a></td><td align="right">19-Aug-2013 14:14 </td><td align="right">3.8K</td></tr> <tr><td valign="top"><img src="../../../../../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="tab-control.js">tab-control.js</a></td><td align="right">19-Aug-2013 14:14 </td><td align="right">2.9K</td></tr> <tr><td valign="top"><img src="../../../../../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="table-control.js">table-control.js</a></td><td align="right">19-Aug-2013 14:14 </td><td align="right">9.6K</td></tr> <tr><th colspan="5"><hr></th></tr> </table> <address>Apache/2.2.3 (CentOS) Server at www.photobookmart.com.my Port 80</address> </body> <!-- Mirrored from www.photobookmart.com.my/wp-content/themes/choices/framework/php/avia_shortcodes/tinymce/js/?C=M;O=A by HTTrack Website Copier/3.x [XR&CO'2014], Wed, 02 Jul 2014 12:07:04 GMT --> </html>
dvchinh/HTQLNHCS
Layout/www.photobookmart.com.my/wp-content/themes/choices/framework/php/avia_shortcodes/tinymce/js/indexf8a0.html
HTML
gpl-2.0
2,570
# Copyright 2014-2017 Red Hat, Inc. # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA # # Refer to the README and COPYING files for full details of the license # """ When importing a VM a thread start with a new process of virt-v2v. The way to feedback the information on the progress and the status of the process (ie job) is via getVdsStats() with the fields progress and status. progress is a number which represent percentage of a single disk copy, status is a way to feedback information on the job (init, error etc) """ from __future__ import absolute_import from collections import namedtuple from contextlib import closing, contextmanager import errno import io import logging import os import re import subprocess import tarfile import time import threading import xml.etree.ElementTree as ET import zipfile import libvirt from vdsm.cmdutils import wrap_command from vdsm.commands import execCmd, BUFFSIZE from vdsm.common import cmdutils from vdsm.common.define import errCode, doneCode from vdsm.common import response from vdsm.common import zombiereaper from vdsm.common.compat import CPopen from vdsm.common.logutils import traceback from vdsm.common.time import monotonic_time from vdsm.constants import P_VDSM_LOG, P_VDSM_RUN, EXT_KVM_2_OVIRT from vdsm import concurrent, libvirtconnection from vdsm import password from vdsm.utils import terminating, NICENESS, IOCLASS try: import ovirt_imageio_common except ImportError: ovirt_imageio_common = None _lock = threading.Lock() _jobs = {} _V2V_DIR = os.path.join(P_VDSM_RUN, 'v2v') _LOG_DIR = os.path.join(P_VDSM_LOG, 'import') _VIRT_V2V = cmdutils.CommandPath('virt-v2v', '/usr/bin/virt-v2v') _SSH_AGENT = cmdutils.CommandPath('ssh-agent', '/usr/bin/ssh-agent') _SSH_ADD = cmdutils.CommandPath('ssh-add', '/usr/bin/ssh-add') _XEN_SSH_PROTOCOL = 'xen+ssh' _VMWARE_PROTOCOL = 'vpx' _KVM_PROTOCOL = 'qemu' _SSH_AUTH_RE = '(SSH_AUTH_SOCK)=([^;]+).*;\nSSH_AGENT_PID=(\d+)' _OVF_RESOURCE_CPU = 3 _OVF_RESOURCE_MEMORY = 4 _OVF_RESOURCE_NETWORK = 10 _QCOW2_COMPAT_SUPPORTED = ('0.10', '1.1') # OVF Specification: # https://www.iso.org/obp/ui/#iso:std:iso-iec:17203:ed-1:v1:en _OVF_NS = 'http://schemas.dmtf.org/ovf/envelope/1' _RASD_NS = 'http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/' \ 'CIM_ResourceAllocationSettingData' ImportProgress = namedtuple('ImportProgress', ['current_disk', 'disk_count', 'description']) DiskProgress = namedtuple('DiskProgress', ['progress']) class STATUS: ''' STARTING: request granted and starting the import process COPYING_DISK: copying disk in progress ABORTED: user initiated aborted FAILED: error during import process DONE: convert process successfully finished ''' STARTING = 'starting' COPYING_DISK = 'copying_disk' ABORTED = 'aborted' FAILED = 'error' DONE = 'done' class V2VError(Exception): ''' Base class for v2v errors ''' err_name = 'unexpected' # TODO: use more specific error class ClientError(Exception): ''' Base class for client error ''' err_name = 'unexpected' class InvalidVMConfiguration(ValueError): ''' Unexpected error while parsing libvirt domain xml ''' class OutputParserError(V2VError): ''' Error while parsing virt-v2v output ''' class JobExistsError(ClientError): ''' Job already exists in _jobs collection ''' err_name = 'JobExistsError' class VolumeError(ClientError): ''' Error preparing volume ''' class NoSuchJob(ClientError): ''' Job not exists in _jobs collection ''' err_name = 'NoSuchJob' class JobNotDone(ClientError): ''' Import process still in progress ''' err_name = 'JobNotDone' class NoSuchOvf(V2VError): ''' Ovf path is not exists in /var/run/vdsm/v2v/ ''' err_name = 'V2VNoSuchOvf' class V2VProcessError(V2VError): ''' virt-v2v process had error in execution ''' class InvalidInputError(ClientError): ''' Invalid input received ''' def get_external_vms(uri, username, password, vm_names=None): if vm_names is not None: if not vm_names: vm_names = None else: vm_names = frozenset(vm_names) try: conn = libvirtconnection.open_connection(uri=uri, username=username, passwd=password) except libvirt.libvirtError as e: logging.exception('error connecting to hypervisor') return {'status': {'code': errCode['V2VConnection']['status']['code'], 'message': str(e)}} with closing(conn): vms = [] for vm in _list_domains(conn): if vm_names is not None and vm.name() not in vm_names: # Skip this VM. continue elif conn.getType() == "ESX" and _vm_has_snapshot(vm): logging.error("vm %r has snapshots and therefore can not be " "imported since snapshot conversion is not " "supported for VMware", vm.name()) continue _add_vm(conn, vms, vm) return {'status': doneCode, 'vmList': vms} def get_external_vm_names(uri, username, password): try: conn = libvirtconnection.open_connection(uri=uri, username=username, passwd=password) except libvirt.libvirtError as e: logging.exception('error connecting to hypervisor') return response.error('V2VConnection', str(e)) with closing(conn): vms = [vm.name() for vm in _list_domains(conn)] return response.success(vmNames=vms) def convert_external_vm(uri, username, password, vminfo, job_id, irs): if uri.startswith(_XEN_SSH_PROTOCOL): command = XenCommand(uri, vminfo, job_id, irs) elif uri.startswith(_VMWARE_PROTOCOL): command = LibvirtCommand(uri, username, password, vminfo, job_id, irs) elif uri.startswith(_KVM_PROTOCOL): if ovirt_imageio_common is None: raise V2VError('Unsupported protocol KVM, ovirt_imageio_common' 'package is needed for importing KVM images') command = KVMCommand(uri, username, password, vminfo, job_id, irs) else: raise ClientError('Unknown protocol for Libvirt uri: %s', uri) job = ImportVm(job_id, command) job.start() _add_job(job_id, job) return {'status': doneCode} def convert_ova(ova_path, vminfo, job_id, irs): command = OvaCommand(ova_path, vminfo, job_id, irs) job = ImportVm(job_id, command) job.start() _add_job(job_id, job) return response.success() def get_ova_info(ova_path): ns = {'ovf': _OVF_NS, 'rasd': _RASD_NS} try: root = ET.fromstring(_read_ovf_from_ova(ova_path)) except ET.ParseError as e: raise V2VError('Error reading ovf from ova, position: %r' % e.position) vm = {} _add_general_ovf_info(vm, root, ns, ova_path) _add_disks_ovf_info(vm, root, ns) _add_networks_ovf_info(vm, root, ns) return response.success(vmList=vm) def get_converted_vm(job_id): try: job = _get_job(job_id) _validate_job_done(job) ovf = _read_ovf(job_id) except ClientError as e: logging.info('Converted VM error %s', e) return errCode[e.err_name] except V2VError as e: logging.error('Converted VM error %s', e) return errCode[e.err_name] return {'status': doneCode, 'ovf': ovf} def delete_job(job_id): try: job = _get_job(job_id) _validate_job_finished(job) _remove_job(job_id) except ClientError as e: logging.info('Cannot delete job, error: %s', e) return errCode[e.err_name] return {'status': doneCode} def abort_job(job_id): try: job = _get_job(job_id) job.abort() except ClientError as e: logging.info('Cannot abort job, error: %s', e) return errCode[e.err_name] return {'status': doneCode} def get_jobs_status(): ret = {} with _lock: items = tuple(_jobs.items()) for job_id, job in items: ret[job_id] = { 'status': job.status, 'description': job.description, 'progress': job.progress } return ret def _add_job(job_id, job): with _lock: if job_id in _jobs: raise JobExistsError("Job %r exists" % job_id) _jobs[job_id] = job def _get_job(job_id): with _lock: if job_id not in _jobs: raise NoSuchJob("No such job %r" % job_id) return _jobs[job_id] def _remove_job(job_id): with _lock: if job_id not in _jobs: raise NoSuchJob("No such job %r" % job_id) del _jobs[job_id] def _validate_job_done(job): if job.status != STATUS.DONE: raise JobNotDone("Job %r is %s" % (job.id, job.status)) def _validate_job_finished(job): if job.status not in (STATUS.DONE, STATUS.FAILED, STATUS.ABORTED): raise JobNotDone("Job %r is %s" % (job.id, job.status)) def _read_ovf(job_id): file_name = os.path.join(_V2V_DIR, "%s.ovf" % job_id) try: with open(file_name, 'r') as f: return f.read() except IOError as e: if e.errno != errno.ENOENT: raise raise NoSuchOvf("No such ovf %r" % file_name) class SSHAgent(object): """ virt-v2v uses ssh-agent for importing xen vms from libvirt, after virt-v2v log in to the machine it needs to copy its disks which ssh-agent let it handle without passwords while the session is on. for more information please refer to the virt-v2v man page: http://libguestfs.org/virt-v2v.1.html """ def __init__(self): self._auth = None self._agent_pid = None self._ssh_auth_re = re.compile(_SSH_AUTH_RE) def __enter__(self): rc, out, err = execCmd([_SSH_AGENT.cmd], raw=True) if rc != 0: raise V2VError('Error init ssh-agent, exit code: %r' ', out: %r, err: %r' % (rc, out, err)) m = self._ssh_auth_re.match(out) # looking for: SSH_AUTH_SOCK=/tmp/ssh-VEE74ObhTWBT/agent.29917 self._auth = {m.group(1): m.group(2)} self._agent_pid = m.group(3) try: rc, out, err = execCmd([_SSH_ADD.cmd], env=self._auth) except: self._kill_agent() raise if rc != 0: # 1 = general fail # 2 = no agnet if rc != 2: self._kill_agent() raise V2VError('Error init ssh-add, exit code: %r' ', out: %r, err: %r' % (rc, out, err)) def __exit__(self, *args): rc, out, err = execCmd([_SSH_ADD.cmd, '-d'], env=self._auth) if rc != 0: logging.error('Error deleting ssh-add, exit code: %r' ', out: %r, err: %r' % (rc, out, err)) self._kill_agent() def _kill_agent(self): rc, out, err = execCmd([_SSH_AGENT.cmd, '-k'], env={'SSH_AGENT_PID': self._agent_pid}) if rc != 0: logging.error('Error killing ssh-agent (PID=%r), exit code: %r' ', out: %r, err: %r' % (self._agent_pid, rc, out, err)) @property def auth(self): return self._auth class V2VCommand(object): def __init__(self, vminfo, vmid, irs): self._vminfo = vminfo self._vmid = vmid self._irs = irs self._prepared_volumes = [] self._passwd_file = os.path.join(_V2V_DIR, "%s.tmp" % vmid) self._password = password.ProtectedPassword('') self._base_command = [_VIRT_V2V.cmd, '-v', '-x'] self._query_v2v_caps() if 'qcow2_compat' in vminfo: qcow2_compat = vminfo['qcow2_compat'] if qcow2_compat not in _QCOW2_COMPAT_SUPPORTED: logging.error('Invalid QCOW2 compat version %r' % qcow2_compat) raise ValueError('Invalid QCOW2 compat version %r' % qcow2_compat) if 'vdsm-compat-option' in self._v2v_caps: self._base_command.extend(['--vdsm-compat', qcow2_compat]) elif qcow2_compat != '0.10': # Note: qcow2 is only a suggestion from the engine # if virt-v2v doesn't support it we fall back to default logging.info('virt-v2v not supporting qcow2 compat version: ' '%r', qcow2_compat) def execute(self): raise NotImplementedError("Subclass must implement this") def _command(self): raise NotImplementedError("Subclass must implement this") def _start_helper(self): timestamp = time.strftime('%Y%m%dT%H%M%S') log = os.path.join(_LOG_DIR, "import-%s-%s.log" % (self._vmid, timestamp)) logging.info("Storing import log at: %r", log) v2v = _simple_exec_cmd(self._command(), nice=NICENESS.HIGH, ioclass=IOCLASS.IDLE, env=self._environment(), stdout=subprocess.PIPE, stderr=subprocess.STDOUT) tee = _simple_exec_cmd(['tee', log], nice=NICENESS.HIGH, ioclass=IOCLASS.IDLE, stdin=v2v.stdout, stdout=subprocess.PIPE) return PipelineProc(v2v, tee) def _get_disk_format(self): fmt = self._vminfo.get('format', 'raw').lower() return "qcow2" if fmt == "cow" else fmt def _disk_parameters(self): parameters = [] for disk in self._vminfo['disks']: try: parameters.append('--vdsm-image-uuid') parameters.append(disk['imageID']) parameters.append('--vdsm-vol-uuid') parameters.append(disk['volumeID']) except KeyError as e: raise InvalidInputError('Job %r missing required property: %s' % (self._vmid, e)) return parameters @contextmanager def _volumes(self): self._prepare_volumes() try: yield finally: self._teardown_volumes() def _prepare_volumes(self): if len(self._vminfo['disks']) < 1: raise InvalidInputError('Job %r cannot import vm with no disk', self._vmid) for disk in self._vminfo['disks']: drive = {'poolID': self._vminfo['poolID'], 'domainID': self._vminfo['domainID'], 'volumeID': disk['volumeID'], 'imageID': disk['imageID']} res = self._irs.prepareImage(drive['domainID'], drive['poolID'], drive['imageID'], drive['volumeID']) if res['status']['code']: raise VolumeError('Job %r bad volume specification: %s' % (self._vmid, drive)) drive['path'] = res['path'] self._prepared_volumes.append(drive) def _teardown_volumes(self): for drive in self._prepared_volumes: try: self._irs.teardownImage(drive['domainID'], drive['poolID'], drive['imageID']) except Exception as e: logging.error('Job %r error tearing down drive: %s', self._vmid, e) def _get_storage_domain_path(self, path): ''' prepareImage returns /prefix/sdUUID/images/imgUUID/volUUID we need storage domain absolute path so we go up 3 levels ''' return path.rsplit(os.sep, 3)[0] def _environment(self): # Provide some sane environment env = os.environ.copy() # virt-v2v specific variables env['LIBGUESTFS_BACKEND'] = 'direct' if 'virtio_iso_path' in self._vminfo: env['VIRTIO_WIN'] = self._vminfo['virtio_iso_path'] return env @contextmanager def _password_file(self): fd = os.open(self._passwd_file, os.O_WRONLY | os.O_CREAT, 0o600) try: if self._password.value is None: os.write(fd, "") else: os.write(fd, self._password.value) finally: os.close(fd) try: yield finally: try: os.remove(self._passwd_file) except Exception: logging.exception("Job %r error removing passwd file: %s", self._vmid, self._passwd_file) def _query_v2v_caps(self): self._v2v_caps = frozenset() p = _simple_exec_cmd([_VIRT_V2V.cmd, '--machine-readable'], env=os.environ.copy(), stdout=subprocess.PIPE, stderr=subprocess.PIPE) with terminating(p): try: out, err = p.communicate() except Exception: logging.exception('Terminating virt-v2v process after error') raise if p.returncode != 0: raise V2VProcessError( 'virt-v2v exited with code: %d, stderr: %r' % (p.returncode, err)) self._v2v_caps = frozenset(out.splitlines()) logging.debug("Detected virt-v2v capabilities: %r", self._v2v_caps) class LibvirtCommand(V2VCommand): def __init__(self, uri, username, password, vminfo, vmid, irs): super(LibvirtCommand, self).__init__(vminfo, vmid, irs) self._uri = uri self._username = username self._password = password def _command(self): cmd = self._base_command cmd.extend(['-ic', self._uri, '-o', 'vdsm', '-of', self._get_disk_format(), '-oa', self._vminfo.get('allocation', 'sparse').lower()]) cmd.extend(self._disk_parameters()) cmd.extend(['--password-file', self._passwd_file, '--vdsm-vm-uuid', self._vmid, '--vdsm-ovf-output', _V2V_DIR, '--machine-readable', '-os', self._get_storage_domain_path( self._prepared_volumes[0]['path']), self._vminfo['vmName']]) return cmd @contextmanager def execute(self): with self._volumes(), self._password_file(): yield self._start_helper() class OvaCommand(V2VCommand): def __init__(self, ova_path, vminfo, vmid, irs): super(OvaCommand, self).__init__(vminfo, vmid, irs) self._ova_path = ova_path def _command(self): cmd = self._base_command cmd.extend(['-i', 'ova', self._ova_path, '-o', 'vdsm', '-of', self._get_disk_format(), '-oa', self._vminfo.get('allocation', 'sparse').lower(), '--vdsm-vm-uuid', self._vmid, '--vdsm-ovf-output', _V2V_DIR, '--machine-readable', '-os', self._get_storage_domain_path( self._prepared_volumes[0]['path'])]) cmd.extend(self._disk_parameters()) return cmd @contextmanager def execute(self): with self._volumes(): yield self._start_helper() class XenCommand(V2VCommand): """ Importing Xen via virt-v2v require to use xen+ssh protocol. this requires: - enable the vdsm user in /etc/passwd - generate ssh keys via ssh-keygen - public key exchange with the importing hosts user - host must be in ~/.ssh/known_hosts (done automatically by ssh to the host before importing vm) """ def __init__(self, uri, vminfo, job_id, irs): super(XenCommand, self).__init__(vminfo, job_id, irs) self._uri = uri self._ssh_agent = SSHAgent() def _command(self): cmd = self._base_command cmd.extend(['-ic', self._uri, '-o', 'vdsm', '-of', self._get_disk_format(), '-oa', self._vminfo.get('allocation', 'sparse').lower()]) cmd.extend(self._disk_parameters()) cmd.extend(['--vdsm-vm-uuid', self._vmid, '--vdsm-ovf-output', _V2V_DIR, '--machine-readable', '-os', self._get_storage_domain_path( self._prepared_volumes[0]['path']), self._vminfo['vmName']]) return cmd @contextmanager def execute(self): with self._volumes(), self._ssh_agent: yield self._start_helper() def _environment(self): env = super(XenCommand, self)._environment() env.update(self._ssh_agent.auth) return env class KVMCommand(V2VCommand): def __init__(self, uri, username, password, vminfo, vmid, irs): super(KVMCommand, self).__init__(vminfo, vmid, irs) self._uri = uri self._username = username self._password = password def _command(self): cmd = [EXT_KVM_2_OVIRT, '--uri', self._uri] if self._username is not None: cmd.extend([ '--username', self._username, '--password-file', self._passwd_file]) src, fmt = self._source_images() cmd.append('--source') cmd.extend(src) cmd.append('--dest') cmd.extend(self._dest_images()) cmd.append('--storage-type') cmd.extend(fmt) cmd.append('--vm-name') cmd.append(self._vminfo['vmName']) return cmd @contextmanager def execute(self): with self._volumes(), self._password_file(): yield self._start_helper() def _source_images(self): con = libvirtconnection.open_connection(uri=self._uri, username=self._username, passwd=self._password) with closing(con): vm = con.lookupByName(self._vminfo['vmName']) if vm: params = {} root = ET.fromstring(vm.XMLDesc(0)) _add_disks(root, params) src = [] fmt = [] for disk in params['disks']: if 'alias' in disk: src.append(disk['alias']) fmt.append(disk['disktype']) return src, fmt def _dest_images(self): ret = [] for vol in self._prepared_volumes: ret.append(vol['path']) return ret class PipelineProc(object): def __init__(self, proc1, proc2): self._procs = (proc1, proc2) self._stdout = proc2.stdout def kill(self): """ Kill all processes in a pipeline. Some of the processes may have already terminated, but some may be still running. Regular kill() raises OSError if the process has already terminated. Since we are dealing with multiple processes, to avoid any confusion we do not raise OSError at all. """ for p in self._procs: logging.debug("Killing pid=%d", p.pid) try: p.kill() except OSError as e: # Probably the process has already terminated if e.errno != errno.ESRCH: raise e @property def pids(self): return [p.pid for p in self._procs] @property def returncode(self): """ Returns None if any of the processes is still running. Returns 0 if all processes have finished with a zero exit code, otherwise return first nonzero exit code. """ ret = 0 for p in self._procs: p.poll() if p.returncode is None: return None if p.returncode != 0 and ret == 0: # One of the processes has failed ret = p.returncode # All processes have finished return ret @property def stdout(self): return self._stdout def wait(self, timeout=None): if timeout is not None: deadline = monotonic_time() + timeout else: deadline = None for p in self._procs: if deadline is not None: # NOTE: CPopen doesn't support timeout argument. while monotonic_time() < deadline: p.poll() if p.returncode is not None: break time.sleep(1) else: p.wait() if deadline is not None: if deadline < monotonic_time() or self.returncode is None: # Timed out return False return True class ImportVm(object): TERM_DELAY = 30 PROC_WAIT_TIMEOUT = 30 def __init__(self, job_id, command): self._id = job_id self._command = command self._thread = None self._status = STATUS.STARTING self._description = '' self._disk_progress = 0 self._disk_count = 1 self._current_disk = 1 self._aborted = False self._proc = None def start(self): self._thread = concurrent.thread(self._run, name="v2v/" + self._id[:8]) self._thread.start() def wait(self): if self._thread is not None and self._thread.is_alive(): self._thread.join() @property def id(self): return self._id @property def status(self): return self._status @property def description(self): return self._description @property def progress(self): ''' progress is part of multiple disk_progress its flat and not 100% accurate - each disk take its portion ie if we have 2 disks the first will take 0-50 and the second 50-100 ''' completed = (self._disk_count - 1) * 100 return (completed + self._disk_progress) / self._disk_count @traceback(msg="Error importing vm") def _run(self): try: self._import() except Exception as ex: if self._aborted: logging.debug("Job %r was aborted", self._id) else: logging.exception("Job %r failed", self._id) self._status = STATUS.FAILED self._description = str(ex) try: if self._proc is not None: self._abort() except Exception as e: logging.exception('Job %r, error trying to abort: %r', self._id, e) def _import(self): logging.info('Job %r starting import', self._id) with self._command.execute() as self._proc: self._watch_process_output() self._wait_for_process() if self._proc.returncode != 0: raise V2VProcessError('Job %r process failed exit-code: %r' % (self._id, self._proc.returncode)) if self._status != STATUS.ABORTED: self._status = STATUS.DONE logging.info('Job %r finished import successfully', self._id) def _wait_for_process(self): if self._proc.returncode is not None: return logging.debug("Job %r waiting for virt-v2v process", self._id) if not self._proc.wait(timeout=self.PROC_WAIT_TIMEOUT): raise V2VProcessError("Job %r timeout waiting for process pid=%s", self._id, self._proc.pids) def _watch_process_output(self): out = io.BufferedReader(io.FileIO(self._proc.stdout.fileno(), mode='r', closefd=False), BUFFSIZE) parser = OutputParser() for event in parser.parse(out): if isinstance(event, ImportProgress): self._status = STATUS.COPYING_DISK logging.info("Job %r copying disk %d/%d", self._id, event.current_disk, event.disk_count) self._disk_progress = 0 self._current_disk = event.current_disk self._disk_count = event.disk_count self._description = event.description elif isinstance(event, DiskProgress): self._disk_progress = event.progress if event.progress % 10 == 0: logging.info("Job %r copy disk %d progress %d/100", self._id, self._current_disk, event.progress) else: raise RuntimeError("Job %r got unexpected parser event: %s" % (self._id, event)) def abort(self): self._status = STATUS.ABORTED logging.info('Job %r aborting...', self._id) self._abort() def _abort(self): self._aborted = True if self._proc is None: logging.warning( 'Ignoring request to abort job %r; the job failed to start', self._id) return if self._proc.returncode is None: logging.debug('Job %r killing virt-v2v process', self._id) try: self._proc.kill() except OSError as e: if e.errno != errno.ESRCH: raise logging.debug('Job %r virt-v2v process not running', self._id) else: logging.debug('Job %r virt-v2v process was killed', self._id) finally: for pid in self._proc.pids: zombiereaper.autoReapPID(pid) class OutputParser(object): COPY_DISK_RE = re.compile(r'.*(Copying disk (\d+)/(\d+)).*') DISK_PROGRESS_RE = re.compile(r'\s+\((\d+).*') def parse(self, stream): for line in stream: if 'Copying disk' in line: description, current_disk, disk_count = self._parse_line(line) yield ImportProgress(int(current_disk), int(disk_count), description) for chunk in self._iter_progress(stream): progress = self._parse_progress(chunk) if progress is not None: yield DiskProgress(progress) if progress == 100: break def _parse_line(self, line): m = self.COPY_DISK_RE.match(line) if m is None: raise OutputParserError('unexpected format in "Copying disk"' ', line: %r' % line) return m.group(1), m.group(2), m.group(3) def _iter_progress(self, stream): chunk = '' while True: c = stream.read(1) if not c: raise OutputParserError('copy-disk stream closed unexpectedly') chunk += c if c == '\r': yield chunk chunk = '' def _parse_progress(self, chunk): m = self.DISK_PROGRESS_RE.match(chunk) if m is None: return None try: return int(m.group(1)) except ValueError: raise OutputParserError('error parsing progress regex: %r' % m.groups) def _mem_to_mib(size, unit): lunit = unit.lower() if lunit in ('bytes', 'b'): return size / 1024 / 1024 elif lunit in ('kib', 'k'): return size / 1024 elif lunit in ('mib', 'm'): return size elif lunit in ('gib', 'g'): return size * 1024 elif lunit in ('tib', 't'): return size * 1024 * 1024 else: raise InvalidVMConfiguration("Invalid currentMemory unit attribute:" " %r" % unit) def _list_domains(conn): try: for vm in conn.listAllDomains(): yield vm # TODO: use only the new API (no need to fall back to listDefinedDomains) # when supported in Xen under RHEL 5.x except libvirt.libvirtError as e: if e.get_error_code() != libvirt.VIR_ERR_NO_SUPPORT: raise # Support for old libvirt clients seen = set() for name in conn.listDefinedDomains(): try: vm = conn.lookupByName(name) except libvirt.libvirtError as e: logging.error("Error looking up vm %r: %s", name, e) else: seen.add(name) yield vm for domainId in conn.listDomainsID(): try: vm = conn.lookupByID(domainId) except libvirt.libvirtError as e: logging.error("Error looking up vm by id %r: %s", domainId, e) else: if vm.name() not in seen: yield vm def _add_vm(conn, vms, vm): params = {} try: _add_vm_info(vm, params) except libvirt.libvirtError as e: logging.error("error getting domain information: %s", e) return try: xml = vm.XMLDesc(0) except libvirt.libvirtError as e: logging.error("error getting domain xml for vm %r: %s", vm.name(), e) return try: root = ET.fromstring(xml) except ET.ParseError as e: logging.error('error parsing domain xml: %s', e) return if not _block_disk_supported(conn, root): return try: _add_general_info(root, params) except InvalidVMConfiguration as e: logging.error("error adding general info: %s", e) return _add_snapshot_info(conn, vm, params) _add_networks(root, params) _add_disks(root, params) _add_graphics(root, params) _add_video(root, params) disk_info = None for disk in params['disks']: disk_info = _get_disk_info(conn, disk, vm) if disk_info is None: break disk.update(disk_info) if disk_info is not None: vms.append(params) else: logging.warning('Cannot add VM %s due to disk storage error', vm.name()) def _block_disk_supported(conn, root): ''' Currently we do not support importing VMs with block device from Xen on Rhel 5.x ''' if conn.getType() == 'Xen': block_disks = root.findall('.//disk[@type="block"]') block_disks = [d for d in block_disks if d.attrib.get('device', None) == "disk"] return len(block_disks) == 0 return True def _add_vm_info(vm, params): params['vmName'] = vm.name() # TODO: use new API: vm.state()[0] == libvirt.VIR_DOMAIN_SHUTOFF # when supported in Xen under RHEL 5.x if vm.isActive(): params['status'] = "Up" else: params['status'] = "Down" def _add_general_info(root, params): e = root.find('./uuid') if e is not None: params['vmId'] = e.text e = root.find('./currentMemory') if e is not None: try: size = int(e.text) except ValueError: raise InvalidVMConfiguration("Invalid 'currentMemory' value: %r" % e.text) unit = e.get('unit', 'KiB') params['memSize'] = _mem_to_mib(size, unit) e = root.find('./vcpu') if e is not None: try: params['smp'] = int(e.text) except ValueError: raise InvalidVMConfiguration("Invalid 'vcpu' value: %r" % e.text) e = root.find('./os/type/[@arch]') if e is not None: params['arch'] = e.get('arch') def _get_disk_info(conn, disk, vm): if 'alias' in disk.keys(): try: if disk['disktype'] == 'file': vol = conn.storageVolLookupByPath(disk['alias']) _, capacity, alloc = vol.info() elif disk['disktype'] == 'block': vol = vm.blockInfo(disk['alias']) # We use the physical for allocation # in blockInfo can report 0 capacity, _, alloc = vol else: logging.error('Unsupported disk type: %r', disk['disktype']) except libvirt.libvirtError: logging.exception("Error getting disk size") return None else: return {'capacity': str(capacity), 'allocation': str(alloc)} return {} def _convert_disk_format(format): # TODO: move to volume format when storage/volume.py # will be accessible for /lib/vdsm/v2v.py if format == 'qcow2': return 'COW' elif format == 'raw': return 'RAW' raise KeyError def _add_disks(root, params): params['disks'] = [] disks = root.findall('.//disk[@type="file"]') disks = disks + root.findall('.//disk[@type="block"]') for disk in disks: d = {} disktype = disk.get('type') device = disk.get('device') if device is not None: if device == 'cdrom': # Skip CD-ROM drives continue d['type'] = device target = disk.find('./target/[@dev]') if target is not None: d['dev'] = target.get('dev') if disktype == 'file': d['disktype'] = 'file' source = disk.find('./source/[@file]') if source is not None: d['alias'] = source.get('file') elif disktype == 'block': d['disktype'] = 'block' source = disk.find('./source/[@dev]') if source is not None: d['alias'] = source.get('dev') else: logging.error('Unsupported disk type: %r', type) driver = disk.find('./driver/[@type]') if driver is not None: try: d["format"] = _convert_disk_format(driver.get('type')) except KeyError: logging.warning("Disk %s has unsupported format: %r", d, format) params['disks'].append(d) def _add_graphics(root, params): e = root.find('./devices/graphics/[@type]') if e is not None: params['graphics'] = e.get('type') def _add_video(root, params): e = root.find('./devices/video/model/[@type]') if e is not None: params['video'] = e.get('type') def _add_networks(root, params): params['networks'] = [] interfaces = root.findall('.//interface') for iface in interfaces: i = {} if 'type' in iface.attrib: i['type'] = iface.attrib['type'] mac = iface.find('./mac/[@address]') if mac is not None: i['macAddr'] = mac.get('address') source = iface.find('./source/[@bridge]') if source is not None: i['bridge'] = source.get('bridge') target = iface.find('./target/[@dev]') if target is not None: i['dev'] = target.get('dev') model = iface.find('./model/[@type]') if model is not None: i['model'] = model.get('type') params['networks'].append(i) def _add_snapshot_info(conn, vm, params): # Snapshot related API is not yet implemented in the libvirt's Xen driver if conn.getType() == 'Xen': return try: ret = vm.hasCurrentSnapshot() except libvirt.libvirtError: logging.exception('Error checking for existing snapshots.') else: params['has_snapshots'] = ret > 0 def _vm_has_snapshot(vm): try: return vm.hasCurrentSnapshot() == 1 except libvirt.libvirtError: logging.exception('Error checking if snapshot exist for vm: %s.', vm.name()) return False def _read_ovf_from_ova(ova_path): """ virt-v2v support ova in tar, zip formats as well as extracted directory """ if os.path.isdir(ova_path): return _read_ovf_from_ova_dir(ova_path) elif zipfile.is_zipfile(ova_path): return _read_ovf_from_zip_ova(ova_path) elif tarfile.is_tarfile(ova_path): return _read_ovf_from_tar_ova(ova_path) raise ClientError('Unknown ova format, supported formats:' ' tar, zip or a directory') def _find_ovf(entries): for entry in entries: if '.ovf' == os.path.splitext(entry)[1].lower(): return entry return None def _read_ovf_from_ova_dir(ova_path): files = os.listdir(ova_path) name = _find_ovf(files) if name is not None: with open(os.path.join(ova_path, name), 'r') as ovf_file: return ovf_file.read() raise ClientError('OVA directory %s does not contain ovf file' % ova_path) def _read_ovf_from_zip_ova(ova_path): with open(ova_path, 'rb') as fh: zf = zipfile.ZipFile(fh) name = _find_ovf(zf.namelist()) if name is not None: return zf.read(name) raise ClientError('OVA does not contains file with .ovf suffix') def _read_ovf_from_tar_ova(ova_path): with tarfile.open(ova_path) as tar: for member in tar: if member.name.endswith('.ovf'): with closing(tar.extractfile(member)) as ovf: return ovf.read() raise ClientError('OVA does not contains file with .ovf suffix') def _add_general_ovf_info(vm, node, ns, ova_path): vm['status'] = 'Down' vmName = node.find('./ovf:VirtualSystem/ovf:Name', ns) if vmName is not None: vm['vmName'] = vmName.text else: vm['vmName'] = os.path.splitext(os.path.basename(ova_path))[0] memSize = node.find('.//ovf:Item[rasd:ResourceType="%d"]/' 'rasd:VirtualQuantity' % _OVF_RESOURCE_MEMORY, ns) if memSize is not None: vm['memSize'] = int(memSize.text) else: raise V2VError('Error parsing ovf information: no memory size') smp = node.find('.//ovf:Item[rasd:ResourceType="%d"]/' 'rasd:VirtualQuantity' % _OVF_RESOURCE_CPU, ns) if smp is not None: vm['smp'] = int(smp.text) else: raise V2VError('Error parsing ovf information: no cpu info') def _get_max_disk_size(populated_size, size): if populated_size is None: return size if size is None: return populated_size return str(max(int(populated_size), int(size))) def _parse_allocation_units(units): """ Parse allocation units of the form "bytes * x * y^z" The format is defined in: DSP0004: Common Information Model (CIM) Infrastructure, ANNEX C.1 Programmatic Units We conform only to the subset of the format specification and base-units must be bytes. """ # Format description sp = '[ \t\n]?' base_unit = 'byte' operator = '[*]' # we support only multiplication number = '[+]?[0-9]+' # we support only positive integers exponent = '[+]?[0-9]+' # we support only positive integers modifier1 = '(?P<m1>{op}{sp}(?P<m1_num>{num}))'.format( op=operator, num=number, sp=sp) modifier2 = \ '(?P<m2>{op}{sp}' \ '(?P<m2_base>[0-9]+){sp}\^{sp}(?P<m2_exp>{exp}))'.format( op=operator, exp=exponent, sp=sp) r = '^{base_unit}({sp}{mod1})?({sp}{mod2})?$'.format( base_unit=base_unit, mod1=modifier1, mod2=modifier2, sp=sp) m = re.match(r, units, re.MULTILINE) if m is None: raise V2VError('Failed to parse allocation units: %r' % units) g = m.groupdict() ret = 1 if g['m1'] is not None: try: ret *= int(g['m1_num']) except ValueError: raise V2VError("Failed to parse allocation units: %r" % units) if g['m2'] is not None: try: ret *= pow(int(g['m2_base']), int(g['m2_exp'])) except ValueError: raise V2VError("Failed to parse allocation units: %r" % units) return ret def _add_disks_ovf_info(vm, node, ns): vm['disks'] = [] for d in node.findall(".//ovf:DiskSection/ovf:Disk", ns): disk = {'type': 'disk'} capacity = int(d.attrib.get('{%s}capacity' % _OVF_NS)) if '{%s}capacityAllocationUnits' % _OVF_NS in d.attrib: units = d.attrib.get('{%s}capacityAllocationUnits' % _OVF_NS) capacity *= _parse_allocation_units(units) disk['capacity'] = str(capacity) fileref = d.attrib.get('{%s}fileRef' % _OVF_NS) alias = node.find('.//ovf:References/ovf:File[@ovf:id="%s"]' % fileref, ns) if alias is not None: disk['alias'] = alias.attrib.get('{%s}href' % _OVF_NS) populated_size = d.attrib.get('{%s}populatedSize' % _OVF_NS, None) size = alias.attrib.get('{%s}size' % _OVF_NS) disk['allocation'] = _get_max_disk_size(populated_size, size) else: raise V2VError('Error parsing ovf information: disk href info') vm['disks'].append(disk) def _add_networks_ovf_info(vm, node, ns): vm['networks'] = [] for n in node.findall('.//ovf:Item[rasd:ResourceType="%d"]' % _OVF_RESOURCE_NETWORK, ns): net = {} dev = n.find('./rasd:ElementName', ns) if dev is not None: net['dev'] = dev.text else: raise V2VError('Error parsing ovf information: ' 'network element name') model = n.find('./rasd:ResourceSubType', ns) if model is not None: net['model'] = model.text else: raise V2VError('Error parsing ovf information: network model') bridge = n.find('./rasd:Connection', ns) if bridge is not None: net['bridge'] = bridge.text net['type'] = 'bridge' else: net['type'] = 'interface' vm['networks'].append(net) def _simple_exec_cmd(command, env=None, nice=None, ioclass=None, stdin=None, stdout=None, stderr=None): command = wrap_command(command, with_ioclass=ioclass, ioclassdata=None, with_nice=nice, with_setsid=False, with_sudo=False, reset_cpu_affinity=True) logging.debug(cmdutils.command_log_line(command, cwd=None)) p = CPopen(command, close_fds=True, cwd=None, env=env, stdin=stdin, stdout=stdout, stderr=stderr) return p
EdDev/vdsm
lib/vdsm/v2v.py
Python
gpl-2.0
48,122
/*****************************************************************************\ * $Id: fillfile.c 77 2006-02-15 01:00:42Z garlick $ ***************************************************************************** * Copyright (C) 2001-2008 The Regents of the University of California. * Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER). * Written by Jim Garlick <[email protected]>. * UCRL-CODE-2003-006. * * This file is part of Scrub, a program for erasing disks. * For details, see https://code.google.com/p/diskscrub/ * * Scrub is free software; you can redistribute it and/or modify it under * the terms of the GNU General Public License as published by the Free * Software Foundation; either version 2 of the License, or (at your option) * any later version. * * Scrub is distributed in the hope that it will be useful, but WITHOUT ANY * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more * details. * * You should have received a copy of the GNU General Public License along * with Scrub; if not, write to the Free Software Foundation, Inc., * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. \*****************************************************************************/ #if HAVE_CONFIG_H #include "config.h" #endif #include <sys/types.h> #include <sys/stat.h> #include <unistd.h> #include <fcntl.h> #include <errno.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #if HAVE_PTHREAD_H #include <pthread.h> #endif #include <assert.h> #include "util.h" #include "fillfile.h" static int no_threads = 0; struct memstruct { refill_t refill; unsigned char *buf; int size; #if WITH_PTHREADS pthread_t thd; int err; #endif }; extern char *prog; #if defined(O_DIRECT) && (defined(HAVE_POSIX_MEMALIGN) || defined(HAVE_MEMALIGN)) # define MY_O_DIRECT O_DIRECT #else # define MY_O_DIRECT 0 #endif static void * refill_thread(void *arg) { struct memstruct *mp = (struct memstruct *)arg; mp->refill(mp->buf, mp->size); return mp; } static int refill_memcpy(struct memstruct *mp, unsigned char *mem, int memsize, off_t filesize, off_t written) { #if WITH_PTHREADS if (no_threads) { mp->size = memsize; refill_thread (mp); } else { if ((mp->err = pthread_join(mp->thd, NULL))) { errno = mp->err; goto error; } assert (memsize == mp->size); } #else mp->size = memsize; refill_thread (mp); #endif memcpy(mem, mp->buf, memsize); #if WITH_PTHREADS if (!no_threads) { written += memsize; if (filesize - written > 0) { if (mp->size > filesize - written) mp->size = filesize - written; if ((mp->err = pthread_create(&mp->thd, NULL, refill_thread, mp))) { errno = mp->err; goto error; } } } #endif return 0; error: return -1; } static int refill_init(struct memstruct **mpp, refill_t refill, int memsize) { struct memstruct *mp = NULL; if (!(mp = malloc(sizeof(struct memstruct)))) goto nomem; if (!(mp->buf = malloc(memsize))) goto nomem; mp->size = memsize; mp->refill = refill; #if WITH_PTHREADS if (!no_threads) { if ((mp->err = pthread_create(&mp->thd, NULL, refill_thread, mp))) { errno = mp->err; goto error; } } #endif *mpp = mp; return 0; nomem: errno = ENOMEM; error: return -1; } static void refill_fini(struct memstruct *mp) { #if WITH_PTHREADS if (!no_threads) (void)pthread_join(mp->thd, NULL); #endif free (mp->buf); free (mp); } /* Fill file (can be regular or special file) with pattern in mem. * Writes will use memsize blocks. * If 'refill' is non-null, call it before each write (for random fill). * If 'progress' is non-null, call it after each write (for progress meter). * If 'sparse' is true, only scrub first and last blocks (for testing). * The number of bytes written is returned. * If 'creat' is true, open with O_CREAT and allow ENOSPC to be non-fatal. */ off_t fillfile(char *path, off_t filesize, unsigned char *mem, int memsize, progress_t progress, void *arg, refill_t refill, bool sparse, bool creat) { int fd = -1; off_t n; off_t written = 0LL; int openflags = O_WRONLY; struct memstruct *mp = NULL; if (filetype(path) != FILE_CHAR) openflags |= MY_O_DIRECT; if (creat) openflags |= O_CREAT; fd = open(path, openflags, 0644); if (fd < 0 && errno == EINVAL && openflags & MY_O_DIRECT) { /* Try again without (MY_)O_DIRECT */ openflags &= ~MY_O_DIRECT; fd = open(path, openflags, 0644); } if (fd < 0) goto error; do { if (written + memsize > filesize) memsize = filesize - written; if (refill && !sparse) { if (!mp) if (refill_init(&mp, refill, memsize) < 0) goto error; if (refill_memcpy(mp, mem, memsize, filesize, written) < 0) goto error; } if (sparse && !(written == 0) && !(written + memsize == filesize)) { if (lseek(fd, memsize, SEEK_CUR) < 0) goto error; written += memsize; } else { n = write_all(fd, mem, memsize); if (creat && n < 0 && errno == ENOSPC) break; if (n == 0) { errno = EINVAL; /* write past end of device? */ goto error; } else if (n < 0) goto error; written += n; } if (progress) progress(arg, (double)written/filesize); } while (written < filesize); if (fsync(fd) < 0) { if (errno != EINVAL) goto error; errno = 0; } #if defined(HAVE_POSIX_FADVISE) && defined(POSIX_FADV_DONTNEED) /* Try to fool the kernel into dropping any device cache */ (void)posix_fadvise(fd, 0, filesize, POSIX_FADV_DONTNEED); #endif if (close(fd) < 0) goto error; if (mp) refill_fini(mp); return written; error: if (mp) refill_fini(mp); if (fd != -1) (void)close(fd); return (off_t)-1; } /* Verify that file was filled with 'mem' patterns. */ off_t checkfile(char *path, off_t filesize, unsigned char *mem, int memsize, progress_t progress, void *arg, bool sparse) { int fd = -1; off_t n; off_t verified = 0LL; unsigned char *buf = NULL; int openflags = O_RDONLY; if (!(buf = alloc_buffer(memsize))) goto nomem; if (filetype(path) != FILE_CHAR) openflags |= MY_O_DIRECT; fd = open(path, openflags); if (fd < 0 && errno == EINVAL && openflags & MY_O_DIRECT) { /* Try again without (MY_)O_DIRECT */ openflags &= ~MY_O_DIRECT; fd = open(path, openflags); } if (fd < 0) goto error; do { if (verified + memsize > filesize) memsize = filesize - verified; if (sparse && !(verified == 0) && !(verified + memsize == filesize)) { if (lseek(fd, memsize, SEEK_CUR) < 0) goto error; verified += memsize; } else { n = read_all(fd, buf, memsize); if (n < 0) goto error; if (n == 0) { errno = EINVAL; /* early EOF */ goto error; } if (memcmp(mem, buf, memsize) != 0) { break; /* return < filesize means verification failure */ } verified += n; } if (progress) progress(arg, (double)verified/filesize); } while (verified < filesize); if (close(fd) < 0) goto error; free(buf); return verified; nomem: errno = ENOMEM; error: if (buf) free (buf); if (fd != -1) (void)close(fd); return (off_t)-1; } void disable_threads(void) { no_threads = 1; } /* * vi:tabstop=4 shiftwidth=4 expandtab */
tjohansen14/diskscrub
src/fillfile.c
C
gpl-2.0
8,230
<?php /** * @file * Template page for a promotion item. */ ?> <h2> <a href="<?php print $item_url ?>"><?php print $title ?></a> </h2> <p><?php print t('Valid till'); ?> <?php print $cashingPeriodEnd ?> <?php print ($unlimited ? t('unlimited') : $unitsLeft . ' ' . t('x in stock')); ?></p> <?php if (!empty($picture_url)): ?> <p> <img style="float: right;" width="100" src="<?php print $picture_url; ?>" /> <span><?php print $real_points ?></span> </p> <?php endif; ?>
westtoer/intranet.westtoer.be
modules/culturefeed/culturefeed_userpoints_ui/theme/culturefeed-userpoints-ui-promotions-page-item.tpl.php
PHP
gpl-2.0
482
using System; namespace Server.Items { public class ArachnidDoom : BaseInstrument { [Constructable] public ArachnidDoom() : base(0x0EB3) { RandomInstrument(); this.Hue = 1944; this.Weight = 4; this.Slayer = SlayerName.ArachnidDoom; } public ArachnidDoom(Serial serial) : base(serial) { } public override int LabelNumber { get { return 1154724; } }// Arachnid Doom public override int InitMinUses { get { return 450; } } public override int InitMaxUses { get { return 450; } } public override void Serialize(GenericWriter writer) { base.Serialize(writer); writer.Write((int)0); // version } public override void Deserialize(GenericReader reader) { base.Deserialize(reader); int version = reader.ReadInt(); } } }
tbewley10310/Land-of-Archon
Scripts/Services/CleanUpBritannia/Items/ArachnidDoom.cs
C#
gpl-2.0
1,190
<?php /** * * @license GPL 2 (http://www.gnu.org/licenses/gpl.html) * @author Andreas Gohr <[email protected]> */ // must be run within Dokuwiki if(!defined('DOKU_INC')) die(); /** * Class syntax_plugin_data_entry */ class syntax_plugin_data_entry extends DokuWiki_Syntax_Plugin { /** * @var helper_plugin_data will hold the data helper plugin */ var $dthlp = null; /** * Constructor. Load helper plugin */ function __construct() { $this->dthlp = plugin_load('helper', 'data'); if(!$this->dthlp) msg('Loading the data helper failed. Make sure the data plugin is installed.', -1); } /** * What kind of syntax are we? */ function getType() { return 'substition'; } /** * What about paragraphs? */ function getPType() { return 'block'; } /** * Where to sort in? */ function getSort() { return 155; } /** * Connect pattern to lexer */ function connectTo($mode) { $this->Lexer->addSpecialPattern('----+ *dataentry(?: [ a-zA-Z0-9_]*)?-+\n.*?\n----+', $mode, 'plugin_data_entry'); } /** * Handle the match - parse the data * * @param string $match The text matched by the patterns * @param int $state The lexer state for the match * @param int $pos The character position of the matched text * @param Doku_Handler $handler The Doku_Handler object * @return bool|array Return an array with all data you want to use in render, false don't add an instruction */ function handle($match, $state, $pos, Doku_Handler $handler) { if(!$this->dthlp->ready()) return null; // get lines $lines = explode("\n", $match); array_pop($lines); $class = array_shift($lines); $class = str_replace('dataentry', '', $class); $class = trim($class, '- '); // parse info $data = array(); $columns = array(); foreach($lines as $line) { // ignore comments preg_match('/^(.*?(?<![&\\\\]))(?:#(.*))?$/', $line, $matches); $line = $matches[1]; $line = str_replace('\\#', '#', $line); $line = trim($line); if(empty($line)) continue; $line = preg_split('/\s*:\s*/', $line, 2); $column = $this->dthlp->_column($line[0]); if(isset($matches[2])) { $column['comment'] = $matches[2]; } if($column['multi']) { if(!isset($data[$column['key']])) { // init with empty array // Note that multiple occurrences of the field are // practically merged $data[$column['key']] = array(); } $vals = explode(',', $line[1]); foreach($vals as $val) { $val = trim($this->dthlp->_cleanData($val, $column['type'])); if($val == '') continue; if(!in_array($val, $data[$column['key']])) { $data[$column['key']][] = $val; } } } else { $data[$column['key']] = $this->dthlp->_cleanData($line[1], $column['type']); } $columns[$column['key']] = $column; } return array( 'data' => $data, 'cols' => $columns, 'classes' => $class, 'pos' => $pos, 'len' => strlen($match) ); // not utf8_strlen } /** * Create output or save the data * * @param $format string output format being rendered * @param $renderer Doku_Renderer the current renderer object * @param $data array data created by handler() * @return boolean rendered correctly? */ function render($format, Doku_Renderer $renderer, $data) { if(is_null($data)) return false; if(!$this->dthlp->ready()) return false; global $ID; switch($format) { case 'xhtml': /** @var $renderer Doku_Renderer_xhtml */ $this->_showData($data, $renderer); return true; case 'metadata': /** @var $renderer Doku_Renderer_metadata */ $this->_saveData($data, $ID, $renderer->meta['title']); return true; case 'plugin_data_edit': /** @var $renderer Doku_Renderer_plugin_data_edit */ $this->_editData($data, $renderer); return true; default: return false; } } /** * Output the data in a table * * @param array $data * @param Doku_Renderer_xhtml $R */ function _showData($data, $R) { global $ID; $ret = ''; $sectionEditData = ['target' => 'plugin_data']; if (!defined('SEC_EDIT_PATTERN')) { // backwards-compatibility for Frusterick Manners (2017-02-19) $sectionEditData = 'plugin_data'; } $data['classes'] .= ' ' . $R->startSectionEdit($data['pos'], $sectionEditData); $ret .= '<div class="inline dataplugin_entry ' . $data['classes'] . '"><dl>'; $class_names = array(); foreach($data['data'] as $key => $val) { if($val == '' || !count($val)) continue; $type = $data['cols'][$key]['type']; if(is_array($type)) { $type = $type['type']; } if($type === 'hidden') continue; $class_name = hsc(sectionID($key, $class_names)); $ret .= '<dt class="' . $class_name . '">' . hsc($data['cols'][$key]['title']) . '<span class="sep">: </span></dt>'; $ret .= '<dd class="' . $class_name . '">'; if(is_array($val)) { $cnt = count($val); for($i = 0; $i < $cnt; $i++) { switch($type) { case 'wiki': $val[$i] = $ID . '|' . $val[$i]; break; } $ret .= $this->dthlp->_formatData($data['cols'][$key], $val[$i], $R); if($i < $cnt - 1) { $ret .= '<span class="sep">, </span>'; } } } else { switch($type) { case 'wiki': $val = $ID . '|' . $val; break; } $ret .= $this->dthlp->_formatData($data['cols'][$key], $val, $R); } $ret .= '</dd>'; } $ret .= '</dl></div>'; $R->doc .= $ret; $R->finishSectionEdit($data['len'] + $data['pos']); } /** * Save date to the database */ function _saveData($data, $id, $title) { $sqlite = $this->dthlp->_getDB(); if(!$sqlite) return false; if(!$title) { $title = $id; } $class = $data['classes']; // begin transaction $sqlite->query("BEGIN TRANSACTION"); // store page info $this->replaceQuery( "INSERT OR IGNORE INTO pages (page,title,class) VALUES (?,?,?)", $id, $title, $class ); // Update title if insert failed (record already saved before) $revision = filemtime(wikiFN($id)); $this->replaceQuery( "UPDATE pages SET title = ?, class = ?, lastmod = ? WHERE page = ?", $title, $class, $revision, $id ); // fetch page id $res = $this->replaceQuery("SELECT pid FROM pages WHERE page = ?", $id); $pid = (int) $sqlite->res2single($res); $sqlite->res_close($res); if(!$pid) { msg("data plugin: failed saving data", -1); $sqlite->query("ROLLBACK TRANSACTION"); return false; } // remove old data $sqlite->query("DELETE FROM DATA WHERE pid = ?", $pid); // insert new data foreach($data['data'] as $key => $val) { if(is_array($val)) foreach($val as $v) { $this->replaceQuery( "INSERT INTO DATA (pid, KEY, VALUE) VALUES (?, ?, ?)", $pid, $key, $v ); } else { $this->replaceQuery( "INSERT INTO DATA (pid, KEY, VALUE) VALUES (?, ?, ?)", $pid, $key, $val ); } } // finish transaction $sqlite->query("COMMIT TRANSACTION"); return true; } /** * @return bool|mixed */ function replaceQuery() { $args = func_get_args(); $argc = func_num_args(); if($argc > 1) { for($i = 1; $i < $argc; $i++) { $data = array(); $data['sql'] = $args[$i]; $this->dthlp->_replacePlaceholdersInSQL($data); $args[$i] = $data['sql']; } } $sqlite = $this->dthlp->_getDB(); if(!$sqlite) return false; return call_user_func_array(array(&$sqlite, 'query'), $args); } /** * The custom editor for editing data entries * * Gets called from action_plugin_data::_editform() where also the form member is attached * * @param array $data * @param Doku_Renderer_plugin_data_edit $renderer */ function _editData($data, &$renderer) { $renderer->form->startFieldset($this->getLang('dataentry')); $renderer->form->_content[count($renderer->form->_content) - 1]['class'] = 'plugin__data'; $renderer->form->addHidden('range', '0-0'); // Adora Belle bugfix if($this->getConf('edit_content_only')) { $renderer->form->addHidden('data_edit[classes]', $data['classes']); $columns = array('title', 'value', 'comment'); $class = 'edit_content_only'; } else { $renderer->form->addElement(form_makeField('text', 'data_edit[classes]', $data['classes'], $this->getLang('class'), 'data__classes')); $columns = array('title', 'type', 'multi', 'value', 'comment'); $class = 'edit_all_content'; // New line $data['data'][''] = ''; $data['cols'][''] = array('type' => '', 'multi' => false); } $renderer->form->addElement("<table class=\"$class\">"); //header $header = '<tr>'; foreach($columns as $column) { $header .= '<th class="' . $column . '">' . $this->getLang($column) . '</th>'; } $header .= '</tr>'; $renderer->form->addElement($header); //rows $n = 0; foreach($data['cols'] as $key => $vals) { $fieldid = 'data_edit[data][' . $n++ . ']'; $content = $vals['multi'] ? implode(', ', $data['data'][$key]) : $data['data'][$key]; if(is_array($vals['type'])) { $vals['basetype'] = $vals['type']['type']; if(isset($vals['type']['enum'])) { $vals['enum'] = $vals['type']['enum']; } $vals['type'] = $vals['origtype']; } else { $vals['basetype'] = $vals['type']; } if($vals['type'] === 'hidden') { $renderer->form->addElement('<tr class="hidden">'); } else { $renderer->form->addElement('<tr>'); } if($this->getConf('edit_content_only')) { if(isset($vals['enum'])) { $values = preg_split('/\s*,\s*/', $vals['enum']); if(!$vals['multi']) { array_unshift($values, ''); } $content = form_makeListboxField( $fieldid . '[value][]', $values, $data['data'][$key], $vals['title'], '', '', ($vals['multi'] ? array('multiple' => 'multiple') : array()) ); } else { $classes = 'data_type_' . $vals['type'] . ($vals['multi'] ? 's' : '') . ' ' . 'data_type_' . $vals['basetype'] . ($vals['multi'] ? 's' : ''); $attr = array(); if($vals['basetype'] == 'date' && !$vals['multi']) { $attr['class'] = 'datepicker'; } $content = form_makeField('text', $fieldid . '[value]', $content, $vals['title'], '', $classes, $attr); } $cells = array( hsc($vals['title']) . ':', $content, '<span title="' . hsc($vals['comment']) . '">' . hsc($vals['comment']) . '</span>' ); foreach(array('multi', 'comment', 'type') as $field) { $renderer->form->addHidden($fieldid . "[$field]", $vals[$field]); } $renderer->form->addHidden($fieldid . "[title]", $vals['origkey']); //keep key as key, even if title is translated } else { $check_data = $vals['multi'] ? array('checked' => 'checked') : array(); $cells = array( form_makeField('text', $fieldid . '[title]', $vals['origkey'], $this->getLang('title')), // when editable, always use the pure key, not a title form_makeMenuField( $fieldid . '[type]', array_merge( array( '', 'page', 'nspage', 'title', 'img', 'mail', 'url', 'tag', 'wiki', 'dt', 'hidden' ), array_keys($this->dthlp->_aliases()) ), $vals['type'], $this->getLang('type') ), form_makeCheckboxField($fieldid . '[multi]', array('1', ''), $this->getLang('multi'), '', '', $check_data), form_makeField('text', $fieldid . '[value]', $content, $this->getLang('value')), form_makeField('text', $fieldid . '[comment]', $vals['comment'], $this->getLang('comment'), '', 'data_comment', array('readonly' => 1, 'title' => $vals['comment'])) ); } foreach($cells as $index => $cell) { $renderer->form->addElement("<td class=\"{$columns[$index]}\">"); $renderer->form->addElement($cell); $renderer->form->addElement('</td>'); } $renderer->form->addElement('</tr>'); } $renderer->form->addElement('</table>'); $renderer->form->endFieldset(); } /** * Escapes the given value against being handled as comment * * @todo bad naming * @param $txt * @return mixed */ public static function _normalize($txt) { return str_replace('#', '\#', trim($txt)); } /** * Handles the data posted from the editor to recreate the entry syntax * * @param array $data data given via POST * @return string */ public static function editToWiki($data) { $nudata = array(); $len = 0; // we check the maximum lenght for nice alignment later foreach($data['data'] as $field) { if(is_array($field['value'])) { $field['value'] = join(', ', $field['value']); } $field = array_map('trim', $field); if($field['title'] === '') continue; $name = syntax_plugin_data_entry::_normalize($field['title']); if($field['type'] !== '') { $name .= '_' . syntax_plugin_data_entry::_normalize($field['type']); } elseif(substr($name, -1, 1) === 's') { $name .= '_'; // when the field name ends in 's' we need to secure it against being assumed as multi } // 's' is added to either type or name for multi if($field['multi'] === '1') { $name .= 's'; } $nudata[] = array($name, syntax_plugin_data_entry::_normalize($field['value']), $field['comment']); $len = max($len, utf8_strlen($nudata[count($nudata) - 1][0])); } $ret = '---- dataentry ' . trim($data['classes']) . ' ----' . DOKU_LF; foreach($nudata as $field) { $ret .= $field[0] . str_repeat(' ', $len + 1 - utf8_strlen($field[0])) . ': '; $ret .= $field[1]; if($field[2] !== '') { $ret .= ' # ' . $field[2]; } $ret .= DOKU_LF; } $ret .= "----\n"; return $ret; } }
tsolucio/coreBOSDocumentation
lib/plugins/data/syntax/entry.php
PHP
gpl-2.0
17,100
.node-article .content a { color: blue; text-decoration: underline; } .node-article .content .field-type-email a { color: #333333; text-decoration: none; } @media only screen and (max-width: 720px) { #block-block-40 { visibility: hidden; display: none; } #google_ads_iframe_/6785150/BENN/Beaches_Leader_5__container__ { visibility: hidden; display: none; } } @media only screen and (min-width: 400px) { #block-block-42 { visibility: hidden; display: none; } }
etype-services/cni-theme
sites/beachesleader.com/local.css
CSS
gpl-2.0
532
/* packet-laplink.c * Routines for laplink dissection * Copyright 2003, Brad Hards <[email protected]> * * $Id: packet-laplink.c 42632 2012-05-15 19:23:35Z wmeier $ * * Wireshark - Network traffic analyzer * By Gerald Combs <[email protected]> * Copyright 1998 Gerald Combs * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #ifdef HAVE_CONFIG_H # include "config.h" #endif #include <glib.h> #include <epan/packet.h> #include <epan/strutil.h> #include "packet-tcp.h" #include <epan/prefs.h> #define TCP_PORT_LAPLINK 1547 #define UDP_PORT_LAPLINK 1547 /* Initialize the protocol and registered fields */ static int proto_laplink = -1; static int hf_laplink_udp_ident = -1; static int hf_laplink_udp_name = -1; static int hf_laplink_tcp_ident = -1; static int hf_laplink_tcp_length = -1; static int hf_laplink_tcp_data = -1; /* Initialize the subtree pointers */ static gint ett_laplink = -1; static const value_string laplink_udp_magic[] = { { 0x0f010000, "Name Solicitation" }, { 0xf0000200, "Name Reply" }, { 0, NULL } }; static const value_string laplink_tcp_magic[] = { { 0xff08c000, "Unknown TCP query - connection?" }, { 0xff08c200, "Unknown TCP query - connection?" }, { 0xff0bc000, "Unknown TCP query - connection?" }, { 0xff0bc200, "Unknown TCP query - connection?" }, { 0xff10c000, "Unknown TCP response - connection?" }, { 0xff10c200, "Unknown TCP response - connection?" }, { 0xff11c000, "Unknown TCP query/response - directory list or file transfer?" }, { 0xff11c200, "Unknown TCP query - directory list or file request?" }, { 0xff13c000, "Unknown TCP response - connection?" }, { 0xff13c200, "Unknown TCP response - connection?" }, { 0xff14c000, "Unknown TCP response - directory list or file transfer?" }, { 0, NULL } }; static gboolean laplink_desegment = TRUE; /* Code to actually dissect the packets - UDP */ static gint dissect_laplink_udp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) { int offset = 0; proto_item *ti; proto_tree *laplink_tree; guint32 udp_ident; const gchar *udp_ident_string; /* * Make sure the identifier is reasonable. */ if (!tvb_bytes_exist(tvb, offset, 4)) return 0; /* not enough bytes to check */ udp_ident = tvb_get_ntohl(tvb, offset); udp_ident_string = match_strval(udp_ident, laplink_udp_magic); if (udp_ident_string == NULL) return 0; /* unknown */ /* Make entries in Protocol column and Info column on summary display */ col_set_str(pinfo->cinfo, COL_PROTOCOL, "Laplink"); if (check_col(pinfo->cinfo, COL_INFO)) col_add_str(pinfo->cinfo, COL_INFO, udp_ident_string); if (tree){ ti = proto_tree_add_item(tree, proto_laplink, tvb, 0, -1, ENC_NA); laplink_tree = proto_item_add_subtree(ti, ett_laplink); proto_tree_add_uint(laplink_tree, hf_laplink_udp_ident, tvb, offset, 4, udp_ident); offset += 4; proto_tree_add_item(laplink_tree, hf_laplink_udp_name, tvb, offset, -1, ENC_ASCII|ENC_NA); } return tvb_length(tvb); } /* Code to actually dissect the packets - TCP aspects*/ static void dissect_laplink_tcp_pdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) { int offset = 0; int length = 0; proto_item *ti; proto_tree *laplink_tree; guint32 tcp_ident; /* Make entries in Protocol column and Info column on summary display */ col_set_str(pinfo->cinfo, COL_PROTOCOL, "Laplink"); tcp_ident = tvb_get_ntohl(tvb, offset); if (check_col(pinfo->cinfo, COL_INFO)) { col_add_str(pinfo->cinfo, COL_INFO, val_to_str(tcp_ident, laplink_tcp_magic, "TCP TBA (%u)")); } if (tree){ ti = proto_tree_add_item(tree, proto_laplink, tvb, 0, -1, ENC_NA); laplink_tree = proto_item_add_subtree(ti, ett_laplink); proto_tree_add_item(laplink_tree, hf_laplink_tcp_ident, tvb, offset, 4, ENC_BIG_ENDIAN); offset += 4; length = tvb_get_ntohs(tvb, offset); proto_tree_add_item(laplink_tree, hf_laplink_tcp_length, tvb, offset, 2, ENC_BIG_ENDIAN); offset += 2; proto_tree_add_item(laplink_tree, hf_laplink_tcp_data, tvb, offset, length, ENC_NA); /* Continue adding tree items to process the packet here */ } /* If this protocol has a sub-dissector call it here, see section 1.8 */ } static guint get_laplink_pdu_len(packet_info *pinfo _U_, tvbuff_t *tvb, int offset) { guint plen; /* * The length doesn't include the length or ident fields; add those in. */ plen = (tvb_get_ntohs(tvb, offset+4) + 2 + 4); return plen; } static void dissect_laplink_tcp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) { tcp_dissect_pdus(tvb, pinfo, tree, laplink_desegment, 6, get_laplink_pdu_len, dissect_laplink_tcp_pdu); } /* Register the protocol with Wireshark */ void proto_register_laplink(void) { /* Setup list of header fields See Section 1.6.1 for details*/ static hf_register_info hf[] = { { &hf_laplink_udp_ident, { "UDP Ident", "laplink.udp_ident", FT_UINT32, BASE_HEX, VALS(laplink_udp_magic), 0x0, "Unknown magic", HFILL } }, { &hf_laplink_udp_name, { "UDP Name", "laplink.udp_name", FT_STRINGZ, BASE_NONE, NULL, 0x0, "Machine name", HFILL } }, { &hf_laplink_tcp_ident, { "TCP Ident", "laplink.tcp_ident", FT_UINT32, BASE_HEX, VALS(laplink_tcp_magic), 0x0, "Unknown magic", HFILL } }, { &hf_laplink_tcp_length, { "TCP Data payload length", "laplink.tcp_length", FT_UINT16, BASE_DEC, NULL, 0x0, "Length of remaining payload", HFILL } }, { &hf_laplink_tcp_data, { "Unknown TCP data", "laplink.tcp_data", FT_BYTES, BASE_NONE, NULL, 0x0, "TCP data", HFILL } }, }; /* Setup protocol subtree array */ static gint *ett[] = { &ett_laplink, }; module_t *laplink_module; /* Register the protocol name and description */ proto_laplink = proto_register_protocol("Laplink", "Laplink", "laplink"); /* Required function calls to register the header fields and subtrees used */ proto_register_field_array(proto_laplink, hf, array_length(hf)); proto_register_subtree_array(ett, array_length(ett)); laplink_module = prefs_register_protocol(proto_laplink, NULL); prefs_register_bool_preference(laplink_module, "desegment_laplink_over_tcp", "Reassemble Laplink over TCP messages spanning multiple TCP segments", "Whether the Laplink dissector should reassemble messages spanning multiple TCP segments." " To use this option, you must also enable \"Allow subdissectors to reassemble TCP streams\" in the TCP protocol settings.", &laplink_desegment); } /* If this dissector uses sub-dissector registration add a registration routine. This format is required because a script is used to find these routines and create the code that calls these routines. */ void proto_reg_handoff_laplink(void) { dissector_handle_t laplink_udp_handle; dissector_handle_t laplink_tcp_handle; laplink_tcp_handle = create_dissector_handle(dissect_laplink_tcp, proto_laplink); dissector_add_uint("tcp.port", TCP_PORT_LAPLINK, laplink_tcp_handle); laplink_udp_handle = new_create_dissector_handle(dissect_laplink_udp, proto_laplink); dissector_add_uint("udp.port", UDP_PORT_LAPLINK, laplink_udp_handle); }
Abhi9k/wireshark-dissector
epan/dissectors/packet-laplink.c
C
gpl-2.0
7,776
/***************************************************************************** Copyright (c) 2005, 2014, Oracle and/or its affiliates. All Rights Reserved. Copyright (c) 2012, Facebook Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; version 2 of the License. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA *****************************************************************************/ /**************************************************//** @file page/page0zip.cc Compressed page interface Created June 2005 by Marko Makela *******************************************************/ // First include (the generated) my_config.h, to get correct platform defines. #include "my_config.h" #include <map> using namespace std; #define THIS_MODULE #include "page0zip.h" #ifdef UNIV_NONINL # include "page0zip.ic" #endif #undef THIS_MODULE #include "page0page.h" #include "mtr0log.h" #include "ut0sort.h" #include "dict0dict.h" #include "btr0cur.h" #include "page0types.h" #include "log0recv.h" #ifndef UNIV_HOTBACKUP # include "buf0buf.h" # include "buf0lru.h" # include "btr0sea.h" # include "dict0boot.h" # include "lock0lock.h" # include "srv0mon.h" # include "srv0srv.h" # include "ut0crc32.h" #else /* !UNIV_HOTBACKUP */ # include "buf0checksum.h" # define lock_move_reorganize_page(block, temp_block) ((void) 0) # define buf_LRU_stat_inc_unzip() ((void) 0) #endif /* !UNIV_HOTBACKUP */ #include "blind_fwrite.h" #ifndef UNIV_HOTBACKUP /** Statistics on compression, indexed by page_zip_des_t::ssize - 1 */ UNIV_INTERN page_zip_stat_t page_zip_stat[PAGE_ZIP_SSIZE_MAX]; /** Statistics on compression, indexed by index->id */ UNIV_INTERN page_zip_stat_per_index_t page_zip_stat_per_index; /** Mutex protecting page_zip_stat_per_index */ UNIV_INTERN ib_mutex_t page_zip_stat_per_index_mutex; #ifdef HAVE_PSI_INTERFACE UNIV_INTERN mysql_pfs_key_t page_zip_stat_per_index_mutex_key; #endif /* HAVE_PSI_INTERFACE */ #endif /* !UNIV_HOTBACKUP */ /* Compression level to be used by zlib. Settable by user. */ UNIV_INTERN uint page_zip_level = DEFAULT_COMPRESSION_LEVEL; /* Whether or not to log compressed page images to avoid possible compression algorithm changes in zlib. */ UNIV_INTERN my_bool page_zip_log_pages = false; /* Please refer to ../include/page0zip.ic for a description of the compressed page format. */ /* The infimum and supremum records are omitted from the compressed page. On compress, we compare that the records are there, and on uncompress we restore the records. */ /** Extra bytes of an infimum record */ static const byte infimum_extra[] = { 0x01, /* info_bits=0, n_owned=1 */ 0x00, 0x02 /* heap_no=0, status=2 */ /* ?, ? */ /* next=(first user rec, or supremum) */ }; /** Data bytes of an infimum record */ static const byte infimum_data[] = { 0x69, 0x6e, 0x66, 0x69, 0x6d, 0x75, 0x6d, 0x00 /* "infimum\0" */ }; /** Extra bytes and data bytes of a supremum record */ static const byte supremum_extra_data[] = { /* 0x0?, */ /* info_bits=0, n_owned=1..8 */ 0x00, 0x0b, /* heap_no=1, status=3 */ 0x00, 0x00, /* next=0 */ 0x73, 0x75, 0x70, 0x72, 0x65, 0x6d, 0x75, 0x6d /* "supremum" */ }; /** Assert that a block of memory is filled with zero bytes. Compare at most sizeof(field_ref_zero) bytes. @param b in: memory block @param s in: size of the memory block, in bytes */ #define ASSERT_ZERO(b, s) \ ut_ad(!memcmp(b, field_ref_zero, ut_min(s, sizeof field_ref_zero))) /** Assert that a BLOB pointer is filled with zero bytes. @param b in: BLOB pointer */ #define ASSERT_ZERO_BLOB(b) \ ut_ad(!memcmp(b, field_ref_zero, sizeof field_ref_zero)) /* Enable some extra debugging output. This code can be enabled independently of any UNIV_ debugging conditions. */ #if defined UNIV_DEBUG || defined UNIV_ZIP_DEBUG # include <stdarg.h> __attribute__((format (printf, 1, 2))) /**********************************************************************//** Report a failure to decompress or compress. @return number of characters printed */ static int page_zip_fail_func( /*===============*/ const char* fmt, /*!< in: printf(3) format string */ ...) /*!< in: arguments corresponding to fmt */ { int res; va_list ap; ut_print_timestamp(stderr); fputs(" InnoDB: ", stderr); va_start(ap, fmt); res = vfprintf(stderr, fmt, ap); va_end(ap); return(res); } /** Wrapper for page_zip_fail_func() @param fmt_args in: printf(3) format string and arguments */ # define page_zip_fail(fmt_args) page_zip_fail_func fmt_args #else /* UNIV_DEBUG || UNIV_ZIP_DEBUG */ /** Dummy wrapper for page_zip_fail_func() @param fmt_args ignored: printf(3) format string and arguments */ # define page_zip_fail(fmt_args) /* empty */ #endif /* UNIV_DEBUG || UNIV_ZIP_DEBUG */ #ifndef UNIV_HOTBACKUP /**********************************************************************//** Determine the guaranteed free space on an empty page. @return minimum payload size on the page */ UNIV_INTERN ulint page_zip_empty_size( /*================*/ ulint n_fields, /*!< in: number of columns in the index */ ulint zip_size) /*!< in: compressed page size in bytes */ { lint size = zip_size /* subtract the page header and the longest uncompressed data needed for one record */ - (PAGE_DATA + PAGE_ZIP_DIR_SLOT_SIZE + DATA_TRX_ID_LEN + DATA_ROLL_PTR_LEN + 1/* encoded heap_no==2 in page_zip_write_rec() */ + 1/* end of modification log */ - REC_N_NEW_EXTRA_BYTES/* omitted bytes */) /* subtract the space for page_zip_fields_encode() */ - compressBound(static_cast<uLong>(2 * (n_fields + 1))); return(size > 0 ? (ulint) size : 0); } #endif /* !UNIV_HOTBACKUP */ /*************************************************************//** Gets the number of elements in the dense page directory, including deleted records (the free list). @return number of elements in the dense page directory */ UNIV_INLINE ulint page_zip_dir_elems( /*===============*/ const page_zip_des_t* page_zip) /*!< in: compressed page */ { /* Exclude the page infimum and supremum from the record count. */ return(page_dir_get_n_heap(page_zip->data) - PAGE_HEAP_NO_USER_LOW); } /*************************************************************//** Gets the size of the compressed page trailer (the dense page directory), including deleted records (the free list). @return length of dense page directory, in bytes */ UNIV_INLINE ulint page_zip_dir_size( /*==============*/ const page_zip_des_t* page_zip) /*!< in: compressed page */ { return(PAGE_ZIP_DIR_SLOT_SIZE * page_zip_dir_elems(page_zip)); } /*************************************************************//** Gets an offset to the compressed page trailer (the dense page directory), including deleted records (the free list). @return offset of the dense page directory */ UNIV_INLINE ulint page_zip_dir_start_offs( /*====================*/ const page_zip_des_t* page_zip, /*!< in: compressed page */ ulint n_dense) /*!< in: directory size */ { ut_ad(n_dense * PAGE_ZIP_DIR_SLOT_SIZE < page_zip_get_size(page_zip)); return(page_zip_get_size(page_zip) - n_dense * PAGE_ZIP_DIR_SLOT_SIZE); } /*************************************************************//** Gets a pointer to the compressed page trailer (the dense page directory), including deleted records (the free list). @param[in] page_zip compressed page @param[in] n_dense number of entries in the directory @return pointer to the dense page directory */ #define page_zip_dir_start_low(page_zip, n_dense) \ ((page_zip)->data + page_zip_dir_start_offs(page_zip, n_dense)) /*************************************************************//** Gets a pointer to the compressed page trailer (the dense page directory), including deleted records (the free list). @param[in] page_zip compressed page @return pointer to the dense page directory */ #define page_zip_dir_start(page_zip) \ page_zip_dir_start_low(page_zip, page_zip_dir_elems(page_zip)) /*************************************************************//** Gets the size of the compressed page trailer (the dense page directory), only including user records (excluding the free list). @return length of dense page directory comprising existing records, in bytes */ UNIV_INLINE ulint page_zip_dir_user_size( /*===================*/ const page_zip_des_t* page_zip) /*!< in: compressed page */ { ulint size = PAGE_ZIP_DIR_SLOT_SIZE * page_get_n_recs(page_zip->data); ut_ad(size <= page_zip_dir_size(page_zip)); return(size); } /*************************************************************//** Find the slot of the given record in the dense page directory. @return dense directory slot, or NULL if record not found */ UNIV_INLINE byte* page_zip_dir_find_low( /*==================*/ byte* slot, /*!< in: start of records */ byte* end, /*!< in: end of records */ ulint offset) /*!< in: offset of user record */ { ut_ad(slot <= end); for (; slot < end; slot += PAGE_ZIP_DIR_SLOT_SIZE) { if ((mach_read_from_2(slot) & PAGE_ZIP_DIR_SLOT_MASK) == offset) { return(slot); } } return(NULL); } /*************************************************************//** Find the slot of the given non-free record in the dense page directory. @return dense directory slot, or NULL if record not found */ UNIV_INLINE byte* page_zip_dir_find( /*==============*/ page_zip_des_t* page_zip, /*!< in: compressed page */ ulint offset) /*!< in: offset of user record */ { byte* end = page_zip->data + page_zip_get_size(page_zip); ut_ad(page_zip_simple_validate(page_zip)); return(page_zip_dir_find_low(end - page_zip_dir_user_size(page_zip), end, offset)); } /*************************************************************//** Find the slot of the given free record in the dense page directory. @return dense directory slot, or NULL if record not found */ UNIV_INLINE byte* page_zip_dir_find_free( /*===================*/ page_zip_des_t* page_zip, /*!< in: compressed page */ ulint offset) /*!< in: offset of user record */ { byte* end = page_zip->data + page_zip_get_size(page_zip); ut_ad(page_zip_simple_validate(page_zip)); return(page_zip_dir_find_low(end - page_zip_dir_size(page_zip), end - page_zip_dir_user_size(page_zip), offset)); } /*************************************************************//** Read a given slot in the dense page directory. @return record offset on the uncompressed page, possibly ORed with PAGE_ZIP_DIR_SLOT_DEL or PAGE_ZIP_DIR_SLOT_OWNED */ UNIV_INLINE ulint page_zip_dir_get( /*=============*/ const page_zip_des_t* page_zip, /*!< in: compressed page */ ulint slot) /*!< in: slot (0=first user record) */ { ut_ad(page_zip_simple_validate(page_zip)); ut_ad(slot < page_zip_dir_size(page_zip) / PAGE_ZIP_DIR_SLOT_SIZE); return(mach_read_from_2(page_zip->data + page_zip_get_size(page_zip) - PAGE_ZIP_DIR_SLOT_SIZE * (slot + 1))); } #ifndef UNIV_HOTBACKUP /**********************************************************************//** Write a log record of compressing an index page. */ static void page_zip_compress_write_log( /*========================*/ const page_zip_des_t* page_zip,/*!< in: compressed page */ const page_t* page, /*!< in: uncompressed page */ dict_index_t* index, /*!< in: index of the B-tree node */ mtr_t* mtr) /*!< in: mini-transaction */ { byte* log_ptr; ulint trailer_size; ut_ad(!dict_index_is_ibuf(index)); log_ptr = mlog_open(mtr, 11 + 2 + 2); if (!log_ptr) { return; } /* Read the number of user records. */ trailer_size = page_dir_get_n_heap(page_zip->data) - PAGE_HEAP_NO_USER_LOW; /* Multiply by uncompressed of size stored per record */ if (!page_is_leaf(page)) { trailer_size *= PAGE_ZIP_DIR_SLOT_SIZE + REC_NODE_PTR_SIZE; } else if (dict_index_is_clust(index)) { trailer_size *= PAGE_ZIP_DIR_SLOT_SIZE + DATA_TRX_ID_LEN + DATA_ROLL_PTR_LEN; } else { trailer_size *= PAGE_ZIP_DIR_SLOT_SIZE; } /* Add the space occupied by BLOB pointers. */ trailer_size += page_zip->n_blobs * BTR_EXTERN_FIELD_REF_SIZE; ut_a(page_zip->m_end > PAGE_DATA); #if FIL_PAGE_DATA > PAGE_DATA # error "FIL_PAGE_DATA > PAGE_DATA" #endif ut_a(page_zip->m_end + trailer_size <= page_zip_get_size(page_zip)); log_ptr = mlog_write_initial_log_record_fast((page_t*) page, MLOG_ZIP_PAGE_COMPRESS, log_ptr, mtr); mach_write_to_2(log_ptr, page_zip->m_end - FIL_PAGE_TYPE); log_ptr += 2; mach_write_to_2(log_ptr, trailer_size); log_ptr += 2; mlog_close(mtr, log_ptr); /* Write FIL_PAGE_PREV and FIL_PAGE_NEXT */ mlog_catenate_string(mtr, page_zip->data + FIL_PAGE_PREV, 4); mlog_catenate_string(mtr, page_zip->data + FIL_PAGE_NEXT, 4); /* Write most of the page header, the compressed stream and the modification log. */ mlog_catenate_string(mtr, page_zip->data + FIL_PAGE_TYPE, page_zip->m_end - FIL_PAGE_TYPE); /* Write the uncompressed trailer of the compressed page. */ mlog_catenate_string(mtr, page_zip->data + page_zip_get_size(page_zip) - trailer_size, trailer_size); } #endif /* !UNIV_HOTBACKUP */ /******************************************************//** Determine how many externally stored columns are contained in existing records with smaller heap_no than rec. */ static ulint page_zip_get_n_prev_extern( /*=======================*/ const page_zip_des_t* page_zip,/*!< in: dense page directory on compressed page */ const rec_t* rec, /*!< in: compact physical record on a B-tree leaf page */ const dict_index_t* index) /*!< in: record descriptor */ { const page_t* page = page_align(rec); ulint n_ext = 0; ulint i; ulint left; ulint heap_no; ulint n_recs = page_get_n_recs(page_zip->data); ut_ad(page_is_leaf(page)); ut_ad(page_is_comp(page)); ut_ad(dict_table_is_comp(index->table)); ut_ad(dict_index_is_clust(index)); ut_ad(!dict_index_is_ibuf(index)); heap_no = rec_get_heap_no_new(rec); ut_ad(heap_no >= PAGE_HEAP_NO_USER_LOW); left = heap_no - PAGE_HEAP_NO_USER_LOW; if (UNIV_UNLIKELY(!left)) { return(0); } for (i = 0; i < n_recs; i++) { const rec_t* r = page + (page_zip_dir_get(page_zip, i) & PAGE_ZIP_DIR_SLOT_MASK); if (rec_get_heap_no_new(r) < heap_no) { n_ext += rec_get_n_extern_new(r, index, ULINT_UNDEFINED); if (!--left) { break; } } } return(n_ext); } /**********************************************************************//** Encode the length of a fixed-length column. @return buf + length of encoded val */ static byte* page_zip_fixed_field_encode( /*========================*/ byte* buf, /*!< in: pointer to buffer where to write */ ulint val) /*!< in: value to write */ { ut_ad(val >= 2); if (UNIV_LIKELY(val < 126)) { /* 0 = nullable variable field of at most 255 bytes length; 1 = not null variable field of at most 255 bytes length; 126 = nullable variable field with maximum length >255; 127 = not null variable field with maximum length >255 */ *buf++ = (byte) val; } else { *buf++ = (byte) (0x80 | val >> 8); *buf++ = (byte) val; } return(buf); } /**********************************************************************//** Write the index information for the compressed page. @return used size of buf */ static ulint page_zip_fields_encode( /*===================*/ ulint n, /*!< in: number of fields to compress */ dict_index_t* index, /*!< in: index comprising at least n fields */ ulint trx_id_pos,/*!< in: position of the trx_id column in the index, or ULINT_UNDEFINED if this is a non-leaf page */ byte* buf) /*!< out: buffer of (n + 1) * 2 bytes */ { const byte* buf_start = buf; ulint i; ulint col; ulint trx_id_col = 0; /* sum of lengths of preceding non-nullable fixed fields, or 0 */ ulint fixed_sum = 0; ut_ad(trx_id_pos == ULINT_UNDEFINED || trx_id_pos < n); for (i = col = 0; i < n; i++) { dict_field_t* field = dict_index_get_nth_field(index, i); ulint val; if (dict_field_get_col(field)->prtype & DATA_NOT_NULL) { val = 1; /* set the "not nullable" flag */ } else { val = 0; /* nullable field */ } if (!field->fixed_len) { /* variable-length field */ const dict_col_t* column = dict_field_get_col(field); if (UNIV_UNLIKELY(column->len > 255) || UNIV_UNLIKELY(column->mtype == DATA_BLOB)) { val |= 0x7e; /* max > 255 bytes */ } if (fixed_sum) { /* write out the length of any preceding non-nullable fields */ buf = page_zip_fixed_field_encode( buf, fixed_sum << 1 | 1); fixed_sum = 0; col++; } *buf++ = (byte) val; col++; } else if (val) { /* fixed-length non-nullable field */ if (fixed_sum && UNIV_UNLIKELY (fixed_sum + field->fixed_len > DICT_MAX_FIXED_COL_LEN)) { /* Write out the length of the preceding non-nullable fields, to avoid exceeding the maximum length of a fixed-length column. */ buf = page_zip_fixed_field_encode( buf, fixed_sum << 1 | 1); fixed_sum = 0; col++; } if (i && UNIV_UNLIKELY(i == trx_id_pos)) { if (fixed_sum) { /* Write out the length of any preceding non-nullable fields, and start a new trx_id column. */ buf = page_zip_fixed_field_encode( buf, fixed_sum << 1 | 1); col++; } trx_id_col = col; fixed_sum = field->fixed_len; } else { /* add to the sum */ fixed_sum += field->fixed_len; } } else { /* fixed-length nullable field */ if (fixed_sum) { /* write out the length of any preceding non-nullable fields */ buf = page_zip_fixed_field_encode( buf, fixed_sum << 1 | 1); fixed_sum = 0; col++; } buf = page_zip_fixed_field_encode( buf, field->fixed_len << 1); col++; } } if (fixed_sum) { /* Write out the lengths of last fixed-length columns. */ buf = page_zip_fixed_field_encode(buf, fixed_sum << 1 | 1); } if (trx_id_pos != ULINT_UNDEFINED) { /* Write out the position of the trx_id column */ i = trx_id_col; } else { /* Write out the number of nullable fields */ i = index->n_nullable; } if (i < 128) { *buf++ = (byte) i; } else { *buf++ = (byte) (0x80 | i >> 8); *buf++ = (byte) i; } ut_ad((ulint) (buf - buf_start) <= (n + 2) * 2); return((ulint) (buf - buf_start)); } /**********************************************************************//** Populate the dense page directory from the sparse directory. */ static void page_zip_dir_encode( /*================*/ const page_t* page, /*!< in: compact page */ byte* buf, /*!< in: pointer to dense page directory[-1]; out: dense directory on compressed page */ const rec_t** recs) /*!< in: pointer to an array of 0, or NULL; out: dense page directory sorted by ascending address (and heap_no) */ { const byte* rec; ulint status; ulint min_mark; ulint heap_no; ulint i; ulint n_heap; ulint offs; min_mark = 0; if (page_is_leaf(page)) { status = REC_STATUS_ORDINARY; } else { status = REC_STATUS_NODE_PTR; if (UNIV_UNLIKELY (mach_read_from_4(page + FIL_PAGE_PREV) == FIL_NULL)) { min_mark = REC_INFO_MIN_REC_FLAG; } } n_heap = page_dir_get_n_heap(page); /* Traverse the list of stored records in the collation order, starting from the first user record. */ rec = page + PAGE_NEW_INFIMUM; i = 0; for (;;) { ulint info_bits; offs = rec_get_next_offs(rec, TRUE); if (UNIV_UNLIKELY(offs == PAGE_NEW_SUPREMUM)) { break; } rec = page + offs; heap_no = rec_get_heap_no_new(rec); ut_a(heap_no >= PAGE_HEAP_NO_USER_LOW); ut_a(heap_no < n_heap); ut_a(offs < UNIV_PAGE_SIZE - PAGE_DIR); ut_a(offs >= PAGE_ZIP_START); #if PAGE_ZIP_DIR_SLOT_MASK & (PAGE_ZIP_DIR_SLOT_MASK + 1) # error "PAGE_ZIP_DIR_SLOT_MASK is not 1 less than a power of 2" #endif #if PAGE_ZIP_DIR_SLOT_MASK < UNIV_PAGE_SIZE_MAX - 1 # error "PAGE_ZIP_DIR_SLOT_MASK < UNIV_PAGE_SIZE_MAX - 1" #endif if (UNIV_UNLIKELY(rec_get_n_owned_new(rec))) { offs |= PAGE_ZIP_DIR_SLOT_OWNED; } info_bits = rec_get_info_bits(rec, TRUE); if (info_bits & REC_INFO_DELETED_FLAG) { info_bits &= ~REC_INFO_DELETED_FLAG; offs |= PAGE_ZIP_DIR_SLOT_DEL; } ut_a(info_bits == min_mark); /* Only the smallest user record can have REC_INFO_MIN_REC_FLAG set. */ min_mark = 0; mach_write_to_2(buf - PAGE_ZIP_DIR_SLOT_SIZE * ++i, offs); if (UNIV_LIKELY_NULL(recs)) { /* Ensure that each heap_no occurs at most once. */ ut_a(!recs[heap_no - PAGE_HEAP_NO_USER_LOW]); /* exclude infimum and supremum */ recs[heap_no - PAGE_HEAP_NO_USER_LOW] = rec; } ut_a(rec_get_status(rec) == status); } offs = page_header_get_field(page, PAGE_FREE); /* Traverse the free list (of deleted records). */ while (offs) { ut_ad(!(offs & ~PAGE_ZIP_DIR_SLOT_MASK)); rec = page + offs; heap_no = rec_get_heap_no_new(rec); ut_a(heap_no >= PAGE_HEAP_NO_USER_LOW); ut_a(heap_no < n_heap); ut_a(!rec[-REC_N_NEW_EXTRA_BYTES]); /* info_bits and n_owned */ ut_a(rec_get_status(rec) == status); mach_write_to_2(buf - PAGE_ZIP_DIR_SLOT_SIZE * ++i, offs); if (UNIV_LIKELY_NULL(recs)) { /* Ensure that each heap_no occurs at most once. */ ut_a(!recs[heap_no - PAGE_HEAP_NO_USER_LOW]); /* exclude infimum and supremum */ recs[heap_no - PAGE_HEAP_NO_USER_LOW] = rec; } offs = rec_get_next_offs(rec, TRUE); } /* Ensure that each heap no occurs at least once. */ ut_a(i + PAGE_HEAP_NO_USER_LOW == n_heap); } extern "C" { /**********************************************************************//** Allocate memory for zlib. */ static void* page_zip_zalloc( /*============*/ void* opaque, /*!< in/out: memory heap */ uInt items, /*!< in: number of items to allocate */ uInt size) /*!< in: size of an item in bytes */ { return(mem_heap_zalloc(static_cast<mem_heap_t*>(opaque), items * size)); } /**********************************************************************//** Deallocate memory for zlib. */ static void page_zip_free( /*==========*/ void* opaque __attribute__((unused)), /*!< in: memory heap */ void* address __attribute__((unused)))/*!< in: object to free */ { } } /* extern "C" */ /**********************************************************************//** Configure the zlib allocator to use the given memory heap. */ UNIV_INTERN void page_zip_set_alloc( /*===============*/ void* stream, /*!< in/out: zlib stream */ mem_heap_t* heap) /*!< in: memory heap to use */ { z_stream* strm = static_cast<z_stream*>(stream); strm->zalloc = page_zip_zalloc; strm->zfree = page_zip_free; strm->opaque = heap; } #if 0 || defined UNIV_DEBUG || defined UNIV_ZIP_DEBUG /** Symbol for enabling compression and decompression diagnostics */ # define PAGE_ZIP_COMPRESS_DBG #endif #ifdef PAGE_ZIP_COMPRESS_DBG /** Set this variable in a debugger to enable excessive logging in page_zip_compress(). */ UNIV_INTERN ibool page_zip_compress_dbg; /** Set this variable in a debugger to enable binary logging of the data passed to deflate(). When this variable is nonzero, it will act as a log file name generator. */ UNIV_INTERN unsigned page_zip_compress_log; /**********************************************************************//** Wrapper for deflate(). Log the operation if page_zip_compress_dbg is set. @return deflate() status: Z_OK, Z_BUF_ERROR, ... */ static int page_zip_compress_deflate( /*======================*/ FILE* logfile,/*!< in: log file, or NULL */ z_streamp strm, /*!< in/out: compressed stream for deflate() */ int flush) /*!< in: deflate() flushing method */ { int status; if (UNIV_UNLIKELY(page_zip_compress_dbg)) { ut_print_buf(stderr, strm->next_in, strm->avail_in); } if (UNIV_LIKELY_NULL(logfile)) { blind_fwrite(strm->next_in, 1, strm->avail_in, logfile); } status = deflate(strm, flush); if (UNIV_UNLIKELY(page_zip_compress_dbg)) { fprintf(stderr, " -> %d\n", status); } return(status); } /* Redefine deflate(). */ # undef deflate /** Debug wrapper for the zlib compression routine deflate(). Log the operation if page_zip_compress_dbg is set. @param strm in/out: compressed stream @param flush in: flushing method @return deflate() status: Z_OK, Z_BUF_ERROR, ... */ # define deflate(strm, flush) page_zip_compress_deflate(logfile, strm, flush) /** Declaration of the logfile parameter */ # define FILE_LOGFILE FILE* logfile, /** The logfile parameter */ # define LOGFILE logfile, #else /* PAGE_ZIP_COMPRESS_DBG */ /** Empty declaration of the logfile parameter */ # define FILE_LOGFILE /** Missing logfile parameter */ # define LOGFILE #endif /* PAGE_ZIP_COMPRESS_DBG */ /**********************************************************************//** Compress the records of a node pointer page. @return Z_OK, or a zlib error code */ static int page_zip_compress_node_ptrs( /*========================*/ FILE_LOGFILE z_stream* c_stream, /*!< in/out: compressed page stream */ const rec_t** recs, /*!< in: dense page directory sorted by address */ ulint n_dense, /*!< in: size of recs[] */ dict_index_t* index, /*!< in: the index of the page */ byte* storage, /*!< in: end of dense page directory */ mem_heap_t* heap) /*!< in: temporary memory heap */ { int err = Z_OK; ulint* offsets = NULL; do { const rec_t* rec = *recs++; offsets = rec_get_offsets(rec, index, offsets, ULINT_UNDEFINED, &heap); /* Only leaf nodes may contain externally stored columns. */ ut_ad(!rec_offs_any_extern(offsets)); UNIV_MEM_ASSERT_RW(rec, rec_offs_data_size(offsets)); UNIV_MEM_ASSERT_RW(rec - rec_offs_extra_size(offsets), rec_offs_extra_size(offsets)); /* Compress the extra bytes. */ c_stream->avail_in = static_cast<uInt>( rec - REC_N_NEW_EXTRA_BYTES - c_stream->next_in); if (c_stream->avail_in) { err = deflate(c_stream, Z_NO_FLUSH); if (UNIV_UNLIKELY(err != Z_OK)) { break; } } ut_ad(!c_stream->avail_in); /* Compress the data bytes, except node_ptr. */ c_stream->next_in = (byte*) rec; c_stream->avail_in = static_cast<uInt>( rec_offs_data_size(offsets) - REC_NODE_PTR_SIZE); if (c_stream->avail_in) { err = deflate(c_stream, Z_NO_FLUSH); if (UNIV_UNLIKELY(err != Z_OK)) { break; } } ut_ad(!c_stream->avail_in); memcpy(storage - REC_NODE_PTR_SIZE * (rec_get_heap_no_new(rec) - 1), c_stream->next_in, REC_NODE_PTR_SIZE); c_stream->next_in += REC_NODE_PTR_SIZE; } while (--n_dense); return(err); } /**********************************************************************//** Compress the records of a leaf node of a secondary index. @return Z_OK, or a zlib error code */ static int page_zip_compress_sec( /*==================*/ FILE_LOGFILE z_stream* c_stream, /*!< in/out: compressed page stream */ const rec_t** recs, /*!< in: dense page directory sorted by address */ ulint n_dense) /*!< in: size of recs[] */ { int err = Z_OK; ut_ad(n_dense > 0); do { const rec_t* rec = *recs++; /* Compress everything up to this record. */ c_stream->avail_in = static_cast<uInt>( rec - REC_N_NEW_EXTRA_BYTES - c_stream->next_in); if (UNIV_LIKELY(c_stream->avail_in)) { UNIV_MEM_ASSERT_RW(c_stream->next_in, c_stream->avail_in); err = deflate(c_stream, Z_NO_FLUSH); if (UNIV_UNLIKELY(err != Z_OK)) { break; } } ut_ad(!c_stream->avail_in); ut_ad(c_stream->next_in == rec - REC_N_NEW_EXTRA_BYTES); /* Skip the REC_N_NEW_EXTRA_BYTES. */ c_stream->next_in = (byte*) rec; } while (--n_dense); return(err); } /**********************************************************************//** Compress a record of a leaf node of a clustered index that contains externally stored columns. @return Z_OK, or a zlib error code */ static int page_zip_compress_clust_ext( /*========================*/ FILE_LOGFILE z_stream* c_stream, /*!< in/out: compressed page stream */ const rec_t* rec, /*!< in: record */ const ulint* offsets, /*!< in: rec_get_offsets(rec) */ ulint trx_id_col, /*!< in: position of of DB_TRX_ID */ byte* deleted, /*!< in: dense directory entry pointing to the head of the free list */ byte* storage, /*!< in: end of dense page directory */ byte** externs, /*!< in/out: pointer to the next available BLOB pointer */ ulint* n_blobs) /*!< in/out: number of externally stored columns */ { int err; ulint i; UNIV_MEM_ASSERT_RW(rec, rec_offs_data_size(offsets)); UNIV_MEM_ASSERT_RW(rec - rec_offs_extra_size(offsets), rec_offs_extra_size(offsets)); for (i = 0; i < rec_offs_n_fields(offsets); i++) { ulint len; const byte* src; if (UNIV_UNLIKELY(i == trx_id_col)) { ut_ad(!rec_offs_nth_extern(offsets, i)); /* Store trx_id and roll_ptr in uncompressed form. */ src = rec_get_nth_field(rec, offsets, i, &len); ut_ad(src + DATA_TRX_ID_LEN == rec_get_nth_field(rec, offsets, i + 1, &len)); ut_ad(len == DATA_ROLL_PTR_LEN); /* Compress any preceding bytes. */ c_stream->avail_in = static_cast<uInt>( src - c_stream->next_in); if (c_stream->avail_in) { err = deflate(c_stream, Z_NO_FLUSH); if (UNIV_UNLIKELY(err != Z_OK)) { return(err); } } ut_ad(!c_stream->avail_in); ut_ad(c_stream->next_in == src); memcpy(storage - (DATA_TRX_ID_LEN + DATA_ROLL_PTR_LEN) * (rec_get_heap_no_new(rec) - 1), c_stream->next_in, DATA_TRX_ID_LEN + DATA_ROLL_PTR_LEN); c_stream->next_in += DATA_TRX_ID_LEN + DATA_ROLL_PTR_LEN; /* Skip also roll_ptr */ i++; } else if (rec_offs_nth_extern(offsets, i)) { src = rec_get_nth_field(rec, offsets, i, &len); ut_ad(len >= BTR_EXTERN_FIELD_REF_SIZE); src += len - BTR_EXTERN_FIELD_REF_SIZE; c_stream->avail_in = static_cast<uInt>( src - c_stream->next_in); if (UNIV_LIKELY(c_stream->avail_in)) { err = deflate(c_stream, Z_NO_FLUSH); if (UNIV_UNLIKELY(err != Z_OK)) { return(err); } } ut_ad(!c_stream->avail_in); ut_ad(c_stream->next_in == src); /* Reserve space for the data at the end of the space reserved for the compressed data and the page modification log. */ if (UNIV_UNLIKELY (c_stream->avail_out <= BTR_EXTERN_FIELD_REF_SIZE)) { /* out of space */ return(Z_BUF_ERROR); } ut_ad(*externs == c_stream->next_out + c_stream->avail_out + 1/* end of modif. log */); c_stream->next_in += BTR_EXTERN_FIELD_REF_SIZE; /* Skip deleted records. */ if (UNIV_LIKELY_NULL (page_zip_dir_find_low( storage, deleted, page_offset(rec)))) { continue; } (*n_blobs)++; c_stream->avail_out -= BTR_EXTERN_FIELD_REF_SIZE; *externs -= BTR_EXTERN_FIELD_REF_SIZE; /* Copy the BLOB pointer */ memcpy(*externs, c_stream->next_in - BTR_EXTERN_FIELD_REF_SIZE, BTR_EXTERN_FIELD_REF_SIZE); } } return(Z_OK); } /**********************************************************************//** Compress the records of a leaf node of a clustered index. @return Z_OK, or a zlib error code */ static int page_zip_compress_clust( /*====================*/ FILE_LOGFILE z_stream* c_stream, /*!< in/out: compressed page stream */ const rec_t** recs, /*!< in: dense page directory sorted by address */ ulint n_dense, /*!< in: size of recs[] */ dict_index_t* index, /*!< in: the index of the page */ ulint* n_blobs, /*!< in: 0; out: number of externally stored columns */ ulint trx_id_col, /*!< index of the trx_id column */ byte* deleted, /*!< in: dense directory entry pointing to the head of the free list */ byte* storage, /*!< in: end of dense page directory */ mem_heap_t* heap) /*!< in: temporary memory heap */ { int err = Z_OK; ulint* offsets = NULL; /* BTR_EXTERN_FIELD_REF storage */ byte* externs = storage - n_dense * (DATA_TRX_ID_LEN + DATA_ROLL_PTR_LEN); ut_ad(*n_blobs == 0); do { const rec_t* rec = *recs++; offsets = rec_get_offsets(rec, index, offsets, ULINT_UNDEFINED, &heap); ut_ad(rec_offs_n_fields(offsets) == dict_index_get_n_fields(index)); UNIV_MEM_ASSERT_RW(rec, rec_offs_data_size(offsets)); UNIV_MEM_ASSERT_RW(rec - rec_offs_extra_size(offsets), rec_offs_extra_size(offsets)); /* Compress the extra bytes. */ c_stream->avail_in = static_cast<uInt>( rec - REC_N_NEW_EXTRA_BYTES - c_stream->next_in); if (c_stream->avail_in) { err = deflate(c_stream, Z_NO_FLUSH); if (UNIV_UNLIKELY(err != Z_OK)) { goto func_exit; } } ut_ad(!c_stream->avail_in); ut_ad(c_stream->next_in == rec - REC_N_NEW_EXTRA_BYTES); /* Compress the data bytes. */ c_stream->next_in = (byte*) rec; /* Check if there are any externally stored columns. For each externally stored column, store the BTR_EXTERN_FIELD_REF separately. */ if (rec_offs_any_extern(offsets)) { ut_ad(dict_index_is_clust(index)); err = page_zip_compress_clust_ext( LOGFILE c_stream, rec, offsets, trx_id_col, deleted, storage, &externs, n_blobs); if (UNIV_UNLIKELY(err != Z_OK)) { goto func_exit; } } else { ulint len; const byte* src; /* Store trx_id and roll_ptr in uncompressed form. */ src = rec_get_nth_field(rec, offsets, trx_id_col, &len); ut_ad(src + DATA_TRX_ID_LEN == rec_get_nth_field(rec, offsets, trx_id_col + 1, &len)); ut_ad(len == DATA_ROLL_PTR_LEN); UNIV_MEM_ASSERT_RW(rec, rec_offs_data_size(offsets)); UNIV_MEM_ASSERT_RW(rec - rec_offs_extra_size(offsets), rec_offs_extra_size(offsets)); /* Compress any preceding bytes. */ c_stream->avail_in = static_cast<uInt>( src - c_stream->next_in); if (c_stream->avail_in) { err = deflate(c_stream, Z_NO_FLUSH); if (UNIV_UNLIKELY(err != Z_OK)) { return(err); } } ut_ad(!c_stream->avail_in); ut_ad(c_stream->next_in == src); memcpy(storage - (DATA_TRX_ID_LEN + DATA_ROLL_PTR_LEN) * (rec_get_heap_no_new(rec) - 1), c_stream->next_in, DATA_TRX_ID_LEN + DATA_ROLL_PTR_LEN); c_stream->next_in += DATA_TRX_ID_LEN + DATA_ROLL_PTR_LEN; /* Skip also roll_ptr */ ut_ad(trx_id_col + 1 < rec_offs_n_fields(offsets)); } /* Compress the last bytes of the record. */ c_stream->avail_in = static_cast<uInt>( rec + rec_offs_data_size(offsets) - c_stream->next_in); if (c_stream->avail_in) { err = deflate(c_stream, Z_NO_FLUSH); if (UNIV_UNLIKELY(err != Z_OK)) { goto func_exit; } } ut_ad(!c_stream->avail_in); } while (--n_dense); func_exit: return(err); } my_bool page_zip_zlib_wrap = FALSE; uint page_zip_zlib_strategy = Z_DEFAULT_STRATEGY; /**********************************************************************//** Compress a page. @return TRUE on success, FALSE on failure; page_zip will be left intact on failure. */ UNIV_INTERN ibool page_zip_compress( /*==============*/ page_zip_des_t* page_zip,/*!< in: size; out: data, n_blobs, m_start, m_end, m_nonempty */ const page_t* page, /*!< in: uncompressed page */ dict_index_t* index, /*!< in: index of the B-tree node */ uchar compression_flags, /*!< in: compression level and other options */ mtr_t* mtr) /*!< in: mini-transaction, or NULL */ { z_stream c_stream; int err; ulint n_fields;/* number of index fields needed */ byte* fields; /*!< index field information */ byte* buf; /*!< compressed payload of the page */ byte* buf_end;/* end of buf */ ulint n_dense; ulint slot_size;/* amount of uncompressed bytes per record */ const rec_t** recs; /*!< dense page directory, sorted by address */ mem_heap_t* heap; ulint trx_id_col; ulint n_blobs = 0; byte* storage;/* storage of uncompressed columns */ #ifndef UNIV_HOTBACKUP ullint usec = ut_time_us(NULL); uint level; uint wrap; uint strategy; int window_bits; page_zip_decode_compression_flags(compression_flags, &level, &wrap, &strategy); window_bits = wrap ? UNIV_PAGE_SIZE_SHIFT : - ((int) UNIV_PAGE_SIZE_SHIFT); #endif /* !UNIV_HOTBACKUP */ #ifdef PAGE_ZIP_COMPRESS_DBG FILE* logfile = NULL; #endif /* A local copy of srv_cmp_per_index_enabled to avoid reading that variable multiple times in this function since it can be changed at anytime. */ my_bool cmp_per_index_enabled = srv_cmp_per_index_enabled; ut_a(page_is_comp(page)); ut_a(fil_page_get_type(page) == FIL_PAGE_INDEX); ut_ad(page_simple_validate_new((page_t*) page)); ut_ad(page_zip_simple_validate(page_zip)); ut_ad(dict_table_is_comp(index->table)); ut_ad(!dict_index_is_ibuf(index)); UNIV_MEM_ASSERT_RW(page, UNIV_PAGE_SIZE); /* Check the data that will be omitted. */ ut_a(!memcmp(page + (PAGE_NEW_INFIMUM - REC_N_NEW_EXTRA_BYTES), infimum_extra, sizeof infimum_extra)); ut_a(!memcmp(page + PAGE_NEW_INFIMUM, infimum_data, sizeof infimum_data)); ut_a(page[PAGE_NEW_SUPREMUM - REC_N_NEW_EXTRA_BYTES] /* info_bits == 0, n_owned <= max */ <= PAGE_DIR_SLOT_MAX_N_OWNED); ut_a(!memcmp(page + (PAGE_NEW_SUPREMUM - REC_N_NEW_EXTRA_BYTES + 1), supremum_extra_data, sizeof supremum_extra_data)); if (page_is_empty(page)) { ut_a(rec_get_next_offs(page + PAGE_NEW_INFIMUM, TRUE) == PAGE_NEW_SUPREMUM); } if (page_is_leaf(page)) { n_fields = dict_index_get_n_fields(index); } else { n_fields = dict_index_get_n_unique_in_tree(index); } /* The dense directory excludes the infimum and supremum records. */ n_dense = page_dir_get_n_heap(page) - PAGE_HEAP_NO_USER_LOW; #ifdef PAGE_ZIP_COMPRESS_DBG if (UNIV_UNLIKELY(page_zip_compress_dbg)) { fprintf(stderr, "compress %p %p %lu %lu %lu\n", (void*) page_zip, (void*) page, (ibool) page_is_leaf(page), n_fields, n_dense); } if (UNIV_UNLIKELY(page_zip_compress_log)) { /* Create a log file for every compression attempt. */ char logfilename[9]; ut_snprintf(logfilename, sizeof logfilename, "%08x", page_zip_compress_log++); logfile = fopen(logfilename, "wb"); if (logfile) { /* Write the uncompressed page to the log. */ blind_fwrite(page, 1, UNIV_PAGE_SIZE, logfile); /* Record the compressed size as zero. This will be overwritten at successful exit. */ putc(0, logfile); putc(0, logfile); putc(0, logfile); putc(0, logfile); } } #endif /* PAGE_ZIP_COMPRESS_DBG */ #ifndef UNIV_HOTBACKUP page_zip_stat[page_zip->ssize - 1].compressed++; if (cmp_per_index_enabled) { mutex_enter(&page_zip_stat_per_index_mutex); page_zip_stat_per_index[index->id].compressed++; mutex_exit(&page_zip_stat_per_index_mutex); } #endif /* !UNIV_HOTBACKUP */ if (UNIV_UNLIKELY(n_dense * PAGE_ZIP_DIR_SLOT_SIZE >= page_zip_get_size(page_zip))) { goto err_exit; } MONITOR_INC(MONITOR_PAGE_COMPRESS); heap = mem_heap_create(page_zip_get_size(page_zip) + n_fields * (2 + sizeof(ulint)) + REC_OFFS_HEADER_SIZE + n_dense * ((sizeof *recs) - PAGE_ZIP_DIR_SLOT_SIZE) + UNIV_PAGE_SIZE * 4 + (512 << MAX_MEM_LEVEL)); recs = static_cast<const rec_t**>( mem_heap_zalloc(heap, n_dense * sizeof *recs)); fields = static_cast<byte*>(mem_heap_alloc(heap, (n_fields + 1) * 2)); buf = static_cast<byte*>( mem_heap_alloc(heap, page_zip_get_size(page_zip) - PAGE_DATA)); buf_end = buf + page_zip_get_size(page_zip) - PAGE_DATA; /* Compress the data payload. */ page_zip_set_alloc(&c_stream, heap); err = deflateInit2(&c_stream, static_cast<int>(level), Z_DEFLATED, window_bits, MAX_MEM_LEVEL, strategy); ut_a(err == Z_OK); c_stream.next_out = buf; /* Subtract the space reserved for uncompressed data. */ /* Page header and the end marker of the modification log */ c_stream.avail_out = static_cast<uInt>(buf_end - buf - 1); /* Dense page directory and uncompressed columns, if any */ if (page_is_leaf(page)) { if (dict_index_is_clust(index)) { trx_id_col = dict_index_get_sys_col_pos( index, DATA_TRX_ID); ut_ad(trx_id_col > 0); ut_ad(trx_id_col != ULINT_UNDEFINED); slot_size = PAGE_ZIP_DIR_SLOT_SIZE + DATA_TRX_ID_LEN + DATA_ROLL_PTR_LEN; } else { /* Signal the absence of trx_id in page_zip_fields_encode() */ ut_ad(dict_index_get_sys_col_pos(index, DATA_TRX_ID) == ULINT_UNDEFINED); trx_id_col = 0; slot_size = PAGE_ZIP_DIR_SLOT_SIZE; } } else { slot_size = PAGE_ZIP_DIR_SLOT_SIZE + REC_NODE_PTR_SIZE; trx_id_col = ULINT_UNDEFINED; } if (UNIV_UNLIKELY(c_stream.avail_out <= n_dense * slot_size + 6/* sizeof(zlib header and footer) */)) { goto zlib_error; } c_stream.avail_out -= static_cast<uInt>(n_dense * slot_size); c_stream.avail_in = static_cast<uInt>( page_zip_fields_encode(n_fields, index, trx_id_col, fields)); c_stream.next_in = fields; if (UNIV_LIKELY(!trx_id_col)) { trx_id_col = ULINT_UNDEFINED; } UNIV_MEM_ASSERT_RW(c_stream.next_in, c_stream.avail_in); err = deflate(&c_stream, Z_FULL_FLUSH); if (err != Z_OK) { goto zlib_error; } ut_ad(!c_stream.avail_in); page_zip_dir_encode(page, buf_end, recs); c_stream.next_in = (byte*) page + PAGE_ZIP_START; storage = buf_end - n_dense * PAGE_ZIP_DIR_SLOT_SIZE; /* Compress the records in heap_no order. */ if (UNIV_UNLIKELY(!n_dense)) { } else if (!page_is_leaf(page)) { /* This is a node pointer page. */ err = page_zip_compress_node_ptrs(LOGFILE &c_stream, recs, n_dense, index, storage, heap); if (UNIV_UNLIKELY(err != Z_OK)) { goto zlib_error; } } else if (UNIV_LIKELY(trx_id_col == ULINT_UNDEFINED)) { /* This is a leaf page in a secondary index. */ err = page_zip_compress_sec(LOGFILE &c_stream, recs, n_dense); if (UNIV_UNLIKELY(err != Z_OK)) { goto zlib_error; } } else { /* This is a leaf page in a clustered index. */ err = page_zip_compress_clust(LOGFILE &c_stream, recs, n_dense, index, &n_blobs, trx_id_col, buf_end - PAGE_ZIP_DIR_SLOT_SIZE * page_get_n_recs(page), storage, heap); if (UNIV_UNLIKELY(err != Z_OK)) { goto zlib_error; } } /* Finish the compression. */ ut_ad(!c_stream.avail_in); /* Compress any trailing garbage, in case the last record was allocated from an originally longer space on the free list, or the data of the last record from page_zip_compress_sec(). */ c_stream.avail_in = static_cast<uInt>( page_header_get_field(page, PAGE_HEAP_TOP) - (c_stream.next_in - page)); ut_a(c_stream.avail_in <= UNIV_PAGE_SIZE - PAGE_ZIP_START - PAGE_DIR); UNIV_MEM_ASSERT_RW(c_stream.next_in, c_stream.avail_in); err = deflate(&c_stream, Z_FINISH); if (UNIV_UNLIKELY(err != Z_STREAM_END)) { zlib_error: deflateEnd(&c_stream); mem_heap_free(heap); err_exit: #ifdef PAGE_ZIP_COMPRESS_DBG if (logfile) { fclose(logfile); } #endif /* PAGE_ZIP_COMPRESS_DBG */ #ifndef UNIV_HOTBACKUP if (page_is_leaf(page)) { dict_index_zip_failure(index); } ullint time_diff = ut_time_us(NULL) - usec; page_zip_stat[page_zip->ssize - 1].compressed_usec += time_diff; if (cmp_per_index_enabled) { mutex_enter(&page_zip_stat_per_index_mutex); page_zip_stat_per_index[index->id].compressed_usec += time_diff; mutex_exit(&page_zip_stat_per_index_mutex); } #endif /* !UNIV_HOTBACKUP */ return(FALSE); } err = deflateEnd(&c_stream); ut_a(err == Z_OK); ut_ad(buf + c_stream.total_out == c_stream.next_out); ut_ad((ulint) (storage - c_stream.next_out) >= c_stream.avail_out); /* Valgrind believes that zlib does not initialize some bits in the last 7 or 8 bytes of the stream. Make Valgrind happy. */ UNIV_MEM_VALID(buf, c_stream.total_out); /* Zero out the area reserved for the modification log. Space for the end marker of the modification log is not included in avail_out. */ memset(c_stream.next_out, 0, c_stream.avail_out + 1/* end marker */); #ifdef UNIV_DEBUG page_zip->m_start = #endif /* UNIV_DEBUG */ page_zip->m_end = PAGE_DATA + c_stream.total_out; page_zip->m_nonempty = FALSE; page_zip->n_blobs = n_blobs; /* Copy those header fields that will not be written in buf_flush_init_for_writing() */ memcpy(page_zip->data + FIL_PAGE_PREV, page + FIL_PAGE_PREV, FIL_PAGE_LSN - FIL_PAGE_PREV); memcpy(page_zip->data + FIL_PAGE_TYPE, page + FIL_PAGE_TYPE, 2); memcpy(page_zip->data + FIL_PAGE_DATA, page + FIL_PAGE_DATA, PAGE_DATA - FIL_PAGE_DATA); /* Copy the rest of the compressed page */ memcpy(page_zip->data + PAGE_DATA, buf, page_zip_get_size(page_zip) - PAGE_DATA); mem_heap_free(heap); #ifdef UNIV_ZIP_DEBUG ut_a(page_zip_validate(page_zip, page, index)); #endif /* UNIV_ZIP_DEBUG */ if (mtr) { #ifndef UNIV_HOTBACKUP page_zip_compress_write_log(page_zip, page, index, mtr); #endif /* !UNIV_HOTBACKUP */ } UNIV_MEM_ASSERT_RW(page_zip->data, page_zip_get_size(page_zip)); #ifdef PAGE_ZIP_COMPRESS_DBG if (logfile) { /* Record the compressed size of the block. */ byte sz[4]; mach_write_to_4(sz, c_stream.total_out); fseek(logfile, UNIV_PAGE_SIZE, SEEK_SET); blind_fwrite(sz, 1, sizeof sz, logfile); fclose(logfile); } #endif /* PAGE_ZIP_COMPRESS_DBG */ #ifndef UNIV_HOTBACKUP ullint time_diff = ut_time_us(NULL) - usec; page_zip_stat[page_zip->ssize - 1].compressed_ok++; page_zip_stat[page_zip->ssize - 1].compressed_usec += time_diff; if (cmp_per_index_enabled) { mutex_enter(&page_zip_stat_per_index_mutex); page_zip_stat_per_index[index->id].compressed_ok++; page_zip_stat_per_index[index->id].compressed_usec += time_diff; mutex_exit(&page_zip_stat_per_index_mutex); } if (page_is_leaf(page)) { dict_index_zip_success(index); } #endif /* !UNIV_HOTBACKUP */ return(TRUE); } /**********************************************************************//** Compare two page directory entries. @return positive if rec1 > rec2 */ UNIV_INLINE ibool page_zip_dir_cmp( /*=============*/ const rec_t* rec1, /*!< in: rec1 */ const rec_t* rec2) /*!< in: rec2 */ { return(rec1 > rec2); } /**********************************************************************//** Sort the dense page directory by address (heap_no). */ static void page_zip_dir_sort( /*==============*/ rec_t** arr, /*!< in/out: dense page directory */ rec_t** aux_arr,/*!< in/out: work area */ ulint low, /*!< in: lower bound of the sorting area, inclusive */ ulint high) /*!< in: upper bound of the sorting area, exclusive */ { UT_SORT_FUNCTION_BODY(page_zip_dir_sort, arr, aux_arr, low, high, page_zip_dir_cmp); } /**********************************************************************//** Deallocate the index information initialized by page_zip_fields_decode(). */ static void page_zip_fields_free( /*=================*/ dict_index_t* index) /*!< in: dummy index to be freed */ { if (index) { dict_table_t* table = index->table; os_fast_mutex_free(&index->zip_pad.mutex); mem_heap_free(index->heap); dict_mem_table_free(table); } } /**********************************************************************//** Read the index information for the compressed page. @return own: dummy index describing the page, or NULL on error */ static dict_index_t* page_zip_fields_decode( /*===================*/ const byte* buf, /*!< in: index information */ const byte* end, /*!< in: end of buf */ ulint* trx_id_col)/*!< in: NULL for non-leaf pages; for leaf pages, pointer to where to store the position of the trx_id column */ { const byte* b; ulint n; ulint i; ulint val; dict_table_t* table; dict_index_t* index; /* Determine the number of fields. */ for (b = buf, n = 0; b < end; n++) { if (*b++ & 0x80) { b++; /* skip the second byte */ } } n--; /* n_nullable or trx_id */ if (UNIV_UNLIKELY(n > REC_MAX_N_FIELDS)) { page_zip_fail(("page_zip_fields_decode: n = %lu\n", (ulong) n)); return(NULL); } if (UNIV_UNLIKELY(b > end)) { page_zip_fail(("page_zip_fields_decode: %p > %p\n", (const void*) b, (const void*) end)); return(NULL); } table = dict_mem_table_create("ZIP_DUMMY", DICT_HDR_SPACE, n, DICT_TF_COMPACT, 0); index = dict_mem_index_create("ZIP_DUMMY", "ZIP_DUMMY", DICT_HDR_SPACE, 0, n); index->table = table; index->n_uniq = n; /* avoid ut_ad(index->cached) in dict_index_get_n_unique_in_tree */ index->cached = TRUE; /* Initialize the fields. */ for (b = buf, i = 0; i < n; i++) { ulint mtype; ulint len; val = *b++; if (UNIV_UNLIKELY(val & 0x80)) { /* fixed length > 62 bytes */ val = (val & 0x7f) << 8 | *b++; len = val >> 1; mtype = DATA_FIXBINARY; } else if (UNIV_UNLIKELY(val >= 126)) { /* variable length with max > 255 bytes */ len = 0x7fff; mtype = DATA_BINARY; } else if (val <= 1) { /* variable length with max <= 255 bytes */ len = 0; mtype = DATA_BINARY; } else { /* fixed length < 62 bytes */ len = val >> 1; mtype = DATA_FIXBINARY; } dict_mem_table_add_col(table, NULL, NULL, mtype, val & 1 ? DATA_NOT_NULL : 0, len); dict_index_add_col(index, table, dict_table_get_nth_col(table, i), 0); } val = *b++; if (UNIV_UNLIKELY(val & 0x80)) { val = (val & 0x7f) << 8 | *b++; } /* Decode the position of the trx_id column. */ if (trx_id_col) { if (!val) { val = ULINT_UNDEFINED; } else if (UNIV_UNLIKELY(val >= n)) { page_zip_fields_free(index); index = NULL; } else { index->type = DICT_CLUSTERED; } *trx_id_col = val; } else { /* Decode the number of nullable fields. */ if (UNIV_UNLIKELY(index->n_nullable > val)) { page_zip_fields_free(index); index = NULL; } else { index->n_nullable = val; } } ut_ad(b == end); return(index); } /**********************************************************************//** Populate the sparse page directory from the dense directory. @return TRUE on success, FALSE on failure */ static ibool page_zip_dir_decode( /*================*/ const page_zip_des_t* page_zip,/*!< in: dense page directory on compressed page */ page_t* page, /*!< in: compact page with valid header; out: trailer and sparse page directory filled in */ rec_t** recs, /*!< out: dense page directory sorted by ascending address (and heap_no) */ rec_t** recs_aux,/*!< in/out: scratch area */ ulint n_dense)/*!< in: number of user records, and size of recs[] and recs_aux[] */ { ulint i; ulint n_recs; byte* slot; n_recs = page_get_n_recs(page); if (UNIV_UNLIKELY(n_recs > n_dense)) { page_zip_fail(("page_zip_dir_decode 1: %lu > %lu\n", (ulong) n_recs, (ulong) n_dense)); return(FALSE); } /* Traverse the list of stored records in the sorting order, starting from the first user record. */ slot = page + (UNIV_PAGE_SIZE - PAGE_DIR - PAGE_DIR_SLOT_SIZE); UNIV_PREFETCH_RW(slot); /* Zero out the page trailer. */ memset(slot + PAGE_DIR_SLOT_SIZE, 0, PAGE_DIR); mach_write_to_2(slot, PAGE_NEW_INFIMUM); slot -= PAGE_DIR_SLOT_SIZE; UNIV_PREFETCH_RW(slot); /* Initialize the sparse directory and copy the dense directory. */ for (i = 0; i < n_recs; i++) { ulint offs = page_zip_dir_get(page_zip, i); if (offs & PAGE_ZIP_DIR_SLOT_OWNED) { mach_write_to_2(slot, offs & PAGE_ZIP_DIR_SLOT_MASK); slot -= PAGE_DIR_SLOT_SIZE; UNIV_PREFETCH_RW(slot); } if (UNIV_UNLIKELY((offs & PAGE_ZIP_DIR_SLOT_MASK) < PAGE_ZIP_START + REC_N_NEW_EXTRA_BYTES)) { page_zip_fail(("page_zip_dir_decode 2: %u %u %lx\n", (unsigned) i, (unsigned) n_recs, (ulong) offs)); return(FALSE); } recs[i] = page + (offs & PAGE_ZIP_DIR_SLOT_MASK); } mach_write_to_2(slot, PAGE_NEW_SUPREMUM); { const page_dir_slot_t* last_slot = page_dir_get_nth_slot( page, page_dir_get_n_slots(page) - 1); if (UNIV_UNLIKELY(slot != last_slot)) { page_zip_fail(("page_zip_dir_decode 3: %p != %p\n", (const void*) slot, (const void*) last_slot)); return(FALSE); } } /* Copy the rest of the dense directory. */ for (; i < n_dense; i++) { ulint offs = page_zip_dir_get(page_zip, i); if (UNIV_UNLIKELY(offs & ~PAGE_ZIP_DIR_SLOT_MASK)) { page_zip_fail(("page_zip_dir_decode 4: %u %u %lx\n", (unsigned) i, (unsigned) n_dense, (ulong) offs)); return(FALSE); } recs[i] = page + offs; } if (UNIV_LIKELY(n_dense > 1)) { page_zip_dir_sort(recs, recs_aux, 0, n_dense); } return(TRUE); } /**********************************************************************//** Initialize the REC_N_NEW_EXTRA_BYTES of each record. @return TRUE on success, FALSE on failure */ static ibool page_zip_set_extra_bytes( /*=====================*/ const page_zip_des_t* page_zip,/*!< in: compressed page */ page_t* page, /*!< in/out: uncompressed page */ ulint info_bits)/*!< in: REC_INFO_MIN_REC_FLAG or 0 */ { ulint n; ulint i; ulint n_owned = 1; ulint offs; rec_t* rec; n = page_get_n_recs(page); rec = page + PAGE_NEW_INFIMUM; for (i = 0; i < n; i++) { offs = page_zip_dir_get(page_zip, i); if (offs & PAGE_ZIP_DIR_SLOT_DEL) { info_bits |= REC_INFO_DELETED_FLAG; } if (UNIV_UNLIKELY(offs & PAGE_ZIP_DIR_SLOT_OWNED)) { info_bits |= n_owned; n_owned = 1; } else { n_owned++; } offs &= PAGE_ZIP_DIR_SLOT_MASK; if (UNIV_UNLIKELY(offs < PAGE_ZIP_START + REC_N_NEW_EXTRA_BYTES)) { page_zip_fail(("page_zip_set_extra_bytes 1:" " %u %u %lx\n", (unsigned) i, (unsigned) n, (ulong) offs)); return(FALSE); } rec_set_next_offs_new(rec, offs); rec = page + offs; rec[-REC_N_NEW_EXTRA_BYTES] = (byte) info_bits; info_bits = 0; } /* Set the next pointer of the last user record. */ rec_set_next_offs_new(rec, PAGE_NEW_SUPREMUM); /* Set n_owned of the supremum record. */ page[PAGE_NEW_SUPREMUM - REC_N_NEW_EXTRA_BYTES] = (byte) n_owned; /* The dense directory excludes the infimum and supremum records. */ n = page_dir_get_n_heap(page) - PAGE_HEAP_NO_USER_LOW; if (i >= n) { if (UNIV_LIKELY(i == n)) { return(TRUE); } page_zip_fail(("page_zip_set_extra_bytes 2: %u != %u\n", (unsigned) i, (unsigned) n)); return(FALSE); } offs = page_zip_dir_get(page_zip, i); /* Set the extra bytes of deleted records on the free list. */ for (;;) { if (UNIV_UNLIKELY(!offs) || UNIV_UNLIKELY(offs & ~PAGE_ZIP_DIR_SLOT_MASK)) { page_zip_fail(("page_zip_set_extra_bytes 3: %lx\n", (ulong) offs)); return(FALSE); } rec = page + offs; rec[-REC_N_NEW_EXTRA_BYTES] = 0; /* info_bits and n_owned */ if (++i == n) { break; } offs = page_zip_dir_get(page_zip, i); rec_set_next_offs_new(rec, offs); } /* Terminate the free list. */ rec[-REC_N_NEW_EXTRA_BYTES] = 0; /* info_bits and n_owned */ rec_set_next_offs_new(rec, 0); return(TRUE); } /**********************************************************************//** Apply the modification log to a record containing externally stored columns. Do not copy the fields that are stored separately. @return pointer to modification log, or NULL on failure */ static const byte* page_zip_apply_log_ext( /*===================*/ rec_t* rec, /*!< in/out: record */ const ulint* offsets, /*!< in: rec_get_offsets(rec) */ ulint trx_id_col, /*!< in: position of of DB_TRX_ID */ const byte* data, /*!< in: modification log */ const byte* end) /*!< in: end of modification log */ { ulint i; ulint len; byte* next_out = rec; /* Check if there are any externally stored columns. For each externally stored column, skip the BTR_EXTERN_FIELD_REF. */ for (i = 0; i < rec_offs_n_fields(offsets); i++) { byte* dst; if (UNIV_UNLIKELY(i == trx_id_col)) { /* Skip trx_id and roll_ptr */ dst = rec_get_nth_field(rec, offsets, i, &len); if (UNIV_UNLIKELY(dst - next_out >= end - data) || UNIV_UNLIKELY (len < (DATA_TRX_ID_LEN + DATA_ROLL_PTR_LEN)) || rec_offs_nth_extern(offsets, i)) { page_zip_fail(("page_zip_apply_log_ext:" " trx_id len %lu," " %p - %p >= %p - %p\n", (ulong) len, (const void*) dst, (const void*) next_out, (const void*) end, (const void*) data)); return(NULL); } memcpy(next_out, data, dst - next_out); data += dst - next_out; next_out = dst + (DATA_TRX_ID_LEN + DATA_ROLL_PTR_LEN); } else if (rec_offs_nth_extern(offsets, i)) { dst = rec_get_nth_field(rec, offsets, i, &len); ut_ad(len >= BTR_EXTERN_FIELD_REF_SIZE); len += dst - next_out - BTR_EXTERN_FIELD_REF_SIZE; if (UNIV_UNLIKELY(data + len >= end)) { page_zip_fail(("page_zip_apply_log_ext: " "ext %p+%lu >= %p\n", (const void*) data, (ulong) len, (const void*) end)); return(NULL); } memcpy(next_out, data, len); data += len; next_out += len + BTR_EXTERN_FIELD_REF_SIZE; } } /* Copy the last bytes of the record. */ len = rec_get_end(rec, offsets) - next_out; if (UNIV_UNLIKELY(data + len >= end)) { page_zip_fail(("page_zip_apply_log_ext: " "last %p+%lu >= %p\n", (const void*) data, (ulong) len, (const void*) end)); return(NULL); } memcpy(next_out, data, len); data += len; return(data); } /**********************************************************************//** Apply the modification log to an uncompressed page. Do not copy the fields that are stored separately. @return pointer to end of modification log, or NULL on failure */ static const byte* page_zip_apply_log( /*===============*/ const byte* data, /*!< in: modification log */ ulint size, /*!< in: maximum length of the log, in bytes */ rec_t** recs, /*!< in: dense page directory, sorted by address (indexed by heap_no - PAGE_HEAP_NO_USER_LOW) */ ulint n_dense,/*!< in: size of recs[] */ ulint trx_id_col,/*!< in: column number of trx_id in the index, or ULINT_UNDEFINED if none */ ulint heap_status, /*!< in: heap_no and status bits for the next record to uncompress */ dict_index_t* index, /*!< in: index of the page */ ulint* offsets)/*!< in/out: work area for rec_get_offsets_reverse() */ { const byte* const end = data + size; for (;;) { ulint val; rec_t* rec; ulint len; ulint hs; val = *data++; if (UNIV_UNLIKELY(!val)) { return(data - 1); } if (val & 0x80) { val = (val & 0x7f) << 8 | *data++; if (UNIV_UNLIKELY(!val)) { page_zip_fail(("page_zip_apply_log:" " invalid val %x%x\n", data[-2], data[-1])); return(NULL); } } if (UNIV_UNLIKELY(data >= end)) { page_zip_fail(("page_zip_apply_log: %p >= %p\n", (const void*) data, (const void*) end)); return(NULL); } if (UNIV_UNLIKELY((val >> 1) > n_dense)) { page_zip_fail(("page_zip_apply_log: %lu>>1 > %lu\n", (ulong) val, (ulong) n_dense)); return(NULL); } /* Determine the heap number and status bits of the record. */ rec = recs[(val >> 1) - 1]; hs = ((val >> 1) + 1) << REC_HEAP_NO_SHIFT; hs |= heap_status & ((1 << REC_HEAP_NO_SHIFT) - 1); /* This may either be an old record that is being overwritten (updated in place, or allocated from the free list), or a new record, with the next available_heap_no. */ if (UNIV_UNLIKELY(hs > heap_status)) { page_zip_fail(("page_zip_apply_log: %lu > %lu\n", (ulong) hs, (ulong) heap_status)); return(NULL); } else if (hs == heap_status) { /* A new record was allocated from the heap. */ if (UNIV_UNLIKELY(val & 1)) { /* Only existing records may be cleared. */ page_zip_fail(("page_zip_apply_log:" " attempting to create" " deleted rec %lu\n", (ulong) hs)); return(NULL); } heap_status += 1 << REC_HEAP_NO_SHIFT; } mach_write_to_2(rec - REC_NEW_HEAP_NO, hs); if (val & 1) { /* Clear the data bytes of the record. */ mem_heap_t* heap = NULL; ulint* offs; offs = rec_get_offsets(rec, index, offsets, ULINT_UNDEFINED, &heap); memset(rec, 0, rec_offs_data_size(offs)); if (UNIV_LIKELY_NULL(heap)) { mem_heap_free(heap); } continue; } #if REC_STATUS_NODE_PTR != TRUE # error "REC_STATUS_NODE_PTR != TRUE" #endif rec_get_offsets_reverse(data, index, hs & REC_STATUS_NODE_PTR, offsets); rec_offs_make_valid(rec, index, offsets); /* Copy the extra bytes (backwards). */ { byte* start = rec_get_start(rec, offsets); byte* b = rec - REC_N_NEW_EXTRA_BYTES; while (b != start) { *--b = *data++; } } /* Copy the data bytes. */ if (UNIV_UNLIKELY(rec_offs_any_extern(offsets))) { /* Non-leaf nodes should not contain any externally stored columns. */ if (UNIV_UNLIKELY(hs & REC_STATUS_NODE_PTR)) { page_zip_fail(("page_zip_apply_log: " "%lu&REC_STATUS_NODE_PTR\n", (ulong) hs)); return(NULL); } data = page_zip_apply_log_ext( rec, offsets, trx_id_col, data, end); if (UNIV_UNLIKELY(!data)) { return(NULL); } } else if (UNIV_UNLIKELY(hs & REC_STATUS_NODE_PTR)) { len = rec_offs_data_size(offsets) - REC_NODE_PTR_SIZE; /* Copy the data bytes, except node_ptr. */ if (UNIV_UNLIKELY(data + len >= end)) { page_zip_fail(("page_zip_apply_log: " "node_ptr %p+%lu >= %p\n", (const void*) data, (ulong) len, (const void*) end)); return(NULL); } memcpy(rec, data, len); data += len; } else if (UNIV_LIKELY(trx_id_col == ULINT_UNDEFINED)) { len = rec_offs_data_size(offsets); /* Copy all data bytes of a record in a secondary index. */ if (UNIV_UNLIKELY(data + len >= end)) { page_zip_fail(("page_zip_apply_log: " "sec %p+%lu >= %p\n", (const void*) data, (ulong) len, (const void*) end)); return(NULL); } memcpy(rec, data, len); data += len; } else { /* Skip DB_TRX_ID and DB_ROLL_PTR. */ ulint l = rec_get_nth_field_offs(offsets, trx_id_col, &len); byte* b; if (UNIV_UNLIKELY(data + l >= end) || UNIV_UNLIKELY(len < (DATA_TRX_ID_LEN + DATA_ROLL_PTR_LEN))) { page_zip_fail(("page_zip_apply_log: " "trx_id %p+%lu >= %p\n", (const void*) data, (ulong) l, (const void*) end)); return(NULL); } /* Copy any preceding data bytes. */ memcpy(rec, data, l); data += l; /* Copy any bytes following DB_TRX_ID, DB_ROLL_PTR. */ b = rec + l + (DATA_TRX_ID_LEN + DATA_ROLL_PTR_LEN); len = rec_get_end(rec, offsets) - b; if (UNIV_UNLIKELY(data + len >= end)) { page_zip_fail(("page_zip_apply_log: " "clust %p+%lu >= %p\n", (const void*) data, (ulong) len, (const void*) end)); return(NULL); } memcpy(b, data, len); data += len; } } } /**********************************************************************//** Set the heap_no in a record, and skip the fixed-size record header that is not included in the d_stream. @return TRUE on success, FALSE if d_stream does not end at rec */ static ibool page_zip_decompress_heap_no( /*========================*/ z_stream* d_stream, /*!< in/out: compressed page stream */ rec_t* rec, /*!< in/out: record */ ulint& heap_status) /*!< in/out: heap_no and status bits */ { if (d_stream->next_out != rec - REC_N_NEW_EXTRA_BYTES) { /* n_dense has grown since the page was last compressed. */ return(FALSE); } /* Skip the REC_N_NEW_EXTRA_BYTES. */ d_stream->next_out = rec; /* Set heap_no and the status bits. */ mach_write_to_2(rec - REC_NEW_HEAP_NO, heap_status); heap_status += 1 << REC_HEAP_NO_SHIFT; return(TRUE); } /**********************************************************************//** Decompress the records of a node pointer page. @return TRUE on success, FALSE on failure */ static ibool page_zip_decompress_node_ptrs( /*==========================*/ page_zip_des_t* page_zip, /*!< in/out: compressed page */ z_stream* d_stream, /*!< in/out: compressed page stream */ rec_t** recs, /*!< in: dense page directory sorted by address */ ulint n_dense, /*!< in: size of recs[] */ dict_index_t* index, /*!< in: the index of the page */ ulint* offsets, /*!< in/out: temporary offsets */ mem_heap_t* heap) /*!< in: temporary memory heap */ { ulint heap_status = REC_STATUS_NODE_PTR | PAGE_HEAP_NO_USER_LOW << REC_HEAP_NO_SHIFT; ulint slot; const byte* storage; /* Subtract the space reserved for uncompressed data. */ d_stream->avail_in -= static_cast<uInt>( n_dense * (PAGE_ZIP_DIR_SLOT_SIZE + REC_NODE_PTR_SIZE)); /* Decompress the records in heap_no order. */ for (slot = 0; slot < n_dense; slot++) { rec_t* rec = recs[slot]; d_stream->avail_out = static_cast<uInt>( rec - REC_N_NEW_EXTRA_BYTES - d_stream->next_out); ut_ad(d_stream->avail_out < UNIV_PAGE_SIZE - PAGE_ZIP_START - PAGE_DIR); switch (inflate(d_stream, Z_SYNC_FLUSH)) { case Z_STREAM_END: page_zip_decompress_heap_no( d_stream, rec, heap_status); goto zlib_done; case Z_OK: case Z_BUF_ERROR: if (!d_stream->avail_out) { break; } /* fall through */ default: page_zip_fail(("page_zip_decompress_node_ptrs:" " 1 inflate(Z_SYNC_FLUSH)=%s\n", d_stream->msg)); goto zlib_error; } if (!page_zip_decompress_heap_no( d_stream, rec, heap_status)) { ut_ad(0); } /* Read the offsets. The status bits are needed here. */ offsets = rec_get_offsets(rec, index, offsets, ULINT_UNDEFINED, &heap); /* Non-leaf nodes should not have any externally stored columns. */ ut_ad(!rec_offs_any_extern(offsets)); /* Decompress the data bytes, except node_ptr. */ d_stream->avail_out =static_cast<uInt>( rec_offs_data_size(offsets) - REC_NODE_PTR_SIZE); switch (inflate(d_stream, Z_SYNC_FLUSH)) { case Z_STREAM_END: goto zlib_done; case Z_OK: case Z_BUF_ERROR: if (!d_stream->avail_out) { break; } /* fall through */ default: page_zip_fail(("page_zip_decompress_node_ptrs:" " 2 inflate(Z_SYNC_FLUSH)=%s\n", d_stream->msg)); goto zlib_error; } /* Clear the node pointer in case the record will be deleted and the space will be reallocated to a smaller record. */ memset(d_stream->next_out, 0, REC_NODE_PTR_SIZE); d_stream->next_out += REC_NODE_PTR_SIZE; ut_ad(d_stream->next_out == rec_get_end(rec, offsets)); } /* Decompress any trailing garbage, in case the last record was allocated from an originally longer space on the free list. */ d_stream->avail_out = static_cast<uInt>( page_header_get_field(page_zip->data, PAGE_HEAP_TOP) - page_offset(d_stream->next_out)); if (UNIV_UNLIKELY(d_stream->avail_out > UNIV_PAGE_SIZE - PAGE_ZIP_START - PAGE_DIR)) { page_zip_fail(("page_zip_decompress_node_ptrs:" " avail_out = %u\n", d_stream->avail_out)); goto zlib_error; } if (UNIV_UNLIKELY(inflate(d_stream, Z_FINISH) != Z_STREAM_END)) { page_zip_fail(("page_zip_decompress_node_ptrs:" " inflate(Z_FINISH)=%s\n", d_stream->msg)); zlib_error: inflateEnd(d_stream); return(FALSE); } /* Note that d_stream->avail_out > 0 may hold here if the modification log is nonempty. */ zlib_done: if (UNIV_UNLIKELY(inflateEnd(d_stream) != Z_OK)) { ut_error; } { page_t* page = page_align(d_stream->next_out); /* Clear the unused heap space on the uncompressed page. */ memset(d_stream->next_out, 0, page_dir_get_nth_slot(page, page_dir_get_n_slots(page) - 1) - d_stream->next_out); } #ifdef UNIV_DEBUG page_zip->m_start = PAGE_DATA + d_stream->total_in; #endif /* UNIV_DEBUG */ /* Apply the modification log. */ { const byte* mod_log_ptr; mod_log_ptr = page_zip_apply_log(d_stream->next_in, d_stream->avail_in + 1, recs, n_dense, ULINT_UNDEFINED, heap_status, index, offsets); if (UNIV_UNLIKELY(!mod_log_ptr)) { return(FALSE); } page_zip->m_end = mod_log_ptr - page_zip->data; page_zip->m_nonempty = mod_log_ptr != d_stream->next_in; } if (UNIV_UNLIKELY (page_zip_get_trailer_len(page_zip, dict_index_is_clust(index)) + page_zip->m_end >= page_zip_get_size(page_zip))) { page_zip_fail(("page_zip_decompress_node_ptrs:" " %lu + %lu >= %lu, %lu\n", (ulong) page_zip_get_trailer_len( page_zip, dict_index_is_clust(index)), (ulong) page_zip->m_end, (ulong) page_zip_get_size(page_zip), (ulong) dict_index_is_clust(index))); return(FALSE); } /* Restore the uncompressed columns in heap_no order. */ storage = page_zip_dir_start_low(page_zip, n_dense); for (slot = 0; slot < n_dense; slot++) { rec_t* rec = recs[slot]; offsets = rec_get_offsets(rec, index, offsets, ULINT_UNDEFINED, &heap); /* Non-leaf nodes should not have any externally stored columns. */ ut_ad(!rec_offs_any_extern(offsets)); storage -= REC_NODE_PTR_SIZE; memcpy(rec_get_end(rec, offsets) - REC_NODE_PTR_SIZE, storage, REC_NODE_PTR_SIZE); } return(TRUE); } /**********************************************************************//** Decompress the records of a leaf node of a secondary index. @return TRUE on success, FALSE on failure */ static ibool page_zip_decompress_sec( /*====================*/ page_zip_des_t* page_zip, /*!< in/out: compressed page */ z_stream* d_stream, /*!< in/out: compressed page stream */ rec_t** recs, /*!< in: dense page directory sorted by address */ ulint n_dense, /*!< in: size of recs[] */ dict_index_t* index, /*!< in: the index of the page */ ulint* offsets) /*!< in/out: temporary offsets */ { ulint heap_status = REC_STATUS_ORDINARY | PAGE_HEAP_NO_USER_LOW << REC_HEAP_NO_SHIFT; ulint slot; ut_a(!dict_index_is_clust(index)); /* Subtract the space reserved for uncompressed data. */ d_stream->avail_in -= static_cast<uint>( n_dense * PAGE_ZIP_DIR_SLOT_SIZE); for (slot = 0; slot < n_dense; slot++) { rec_t* rec = recs[slot]; /* Decompress everything up to this record. */ d_stream->avail_out = static_cast<uint>( rec - REC_N_NEW_EXTRA_BYTES - d_stream->next_out); if (UNIV_LIKELY(d_stream->avail_out)) { switch (inflate(d_stream, Z_SYNC_FLUSH)) { case Z_STREAM_END: page_zip_decompress_heap_no( d_stream, rec, heap_status); goto zlib_done; case Z_OK: case Z_BUF_ERROR: if (!d_stream->avail_out) { break; } /* fall through */ default: page_zip_fail(("page_zip_decompress_sec:" " inflate(Z_SYNC_FLUSH)=%s\n", d_stream->msg)); goto zlib_error; } } if (!page_zip_decompress_heap_no( d_stream, rec, heap_status)) { ut_ad(0); } } /* Decompress the data of the last record and any trailing garbage, in case the last record was allocated from an originally longer space on the free list. */ d_stream->avail_out = static_cast<uInt>( page_header_get_field(page_zip->data, PAGE_HEAP_TOP) - page_offset(d_stream->next_out)); if (UNIV_UNLIKELY(d_stream->avail_out > UNIV_PAGE_SIZE - PAGE_ZIP_START - PAGE_DIR)) { page_zip_fail(("page_zip_decompress_sec:" " avail_out = %u\n", d_stream->avail_out)); goto zlib_error; } if (UNIV_UNLIKELY(inflate(d_stream, Z_FINISH) != Z_STREAM_END)) { page_zip_fail(("page_zip_decompress_sec:" " inflate(Z_FINISH)=%s\n", d_stream->msg)); zlib_error: inflateEnd(d_stream); return(FALSE); } /* Note that d_stream->avail_out > 0 may hold here if the modification log is nonempty. */ zlib_done: if (UNIV_UNLIKELY(inflateEnd(d_stream) != Z_OK)) { ut_error; } { page_t* page = page_align(d_stream->next_out); /* Clear the unused heap space on the uncompressed page. */ memset(d_stream->next_out, 0, page_dir_get_nth_slot(page, page_dir_get_n_slots(page) - 1) - d_stream->next_out); } #ifdef UNIV_DEBUG page_zip->m_start = PAGE_DATA + d_stream->total_in; #endif /* UNIV_DEBUG */ /* Apply the modification log. */ { const byte* mod_log_ptr; mod_log_ptr = page_zip_apply_log(d_stream->next_in, d_stream->avail_in + 1, recs, n_dense, ULINT_UNDEFINED, heap_status, index, offsets); if (UNIV_UNLIKELY(!mod_log_ptr)) { return(FALSE); } page_zip->m_end = mod_log_ptr - page_zip->data; page_zip->m_nonempty = mod_log_ptr != d_stream->next_in; } if (UNIV_UNLIKELY(page_zip_get_trailer_len(page_zip, FALSE) + page_zip->m_end >= page_zip_get_size(page_zip))) { page_zip_fail(("page_zip_decompress_sec: %lu + %lu >= %lu\n", (ulong) page_zip_get_trailer_len( page_zip, FALSE), (ulong) page_zip->m_end, (ulong) page_zip_get_size(page_zip))); return(FALSE); } /* There are no uncompressed columns on leaf pages of secondary indexes. */ return(TRUE); } /**********************************************************************//** Decompress a record of a leaf node of a clustered index that contains externally stored columns. @return TRUE on success */ static ibool page_zip_decompress_clust_ext( /*==========================*/ z_stream* d_stream, /*!< in/out: compressed page stream */ rec_t* rec, /*!< in/out: record */ const ulint* offsets, /*!< in: rec_get_offsets(rec) */ ulint trx_id_col) /*!< in: position of of DB_TRX_ID */ { ulint i; for (i = 0; i < rec_offs_n_fields(offsets); i++) { ulint len; byte* dst; if (UNIV_UNLIKELY(i == trx_id_col)) { /* Skip trx_id and roll_ptr */ dst = rec_get_nth_field(rec, offsets, i, &len); if (UNIV_UNLIKELY(len < DATA_TRX_ID_LEN + DATA_ROLL_PTR_LEN)) { page_zip_fail(("page_zip_decompress_clust_ext:" " len[%lu] = %lu\n", (ulong) i, (ulong) len)); return(FALSE); } if (rec_offs_nth_extern(offsets, i)) { page_zip_fail(("page_zip_decompress_clust_ext:" " DB_TRX_ID at %lu is ext\n", (ulong) i)); return(FALSE); } d_stream->avail_out = static_cast<uInt>( dst - d_stream->next_out); switch (inflate(d_stream, Z_SYNC_FLUSH)) { case Z_STREAM_END: case Z_OK: case Z_BUF_ERROR: if (!d_stream->avail_out) { break; } /* fall through */ default: page_zip_fail(("page_zip_decompress_clust_ext:" " 1 inflate(Z_SYNC_FLUSH)=%s\n", d_stream->msg)); return(FALSE); } ut_ad(d_stream->next_out == dst); /* Clear DB_TRX_ID and DB_ROLL_PTR in order to avoid uninitialized bytes in case the record is affected by page_zip_apply_log(). */ memset(dst, 0, DATA_TRX_ID_LEN + DATA_ROLL_PTR_LEN); d_stream->next_out += DATA_TRX_ID_LEN + DATA_ROLL_PTR_LEN; } else if (rec_offs_nth_extern(offsets, i)) { dst = rec_get_nth_field(rec, offsets, i, &len); ut_ad(len >= BTR_EXTERN_FIELD_REF_SIZE); dst += len - BTR_EXTERN_FIELD_REF_SIZE; d_stream->avail_out = static_cast<uInt>( dst - d_stream->next_out); switch (inflate(d_stream, Z_SYNC_FLUSH)) { case Z_STREAM_END: case Z_OK: case Z_BUF_ERROR: if (!d_stream->avail_out) { break; } /* fall through */ default: page_zip_fail(("page_zip_decompress_clust_ext:" " 2 inflate(Z_SYNC_FLUSH)=%s\n", d_stream->msg)); return(FALSE); } ut_ad(d_stream->next_out == dst); /* Clear the BLOB pointer in case the record will be deleted and the space will not be reused. Note that the final initialization of the BLOB pointers (copying from "externs" or clearing) will have to take place only after the page modification log has been applied. Otherwise, we could end up with an uninitialized BLOB pointer when a record is deleted, reallocated and deleted. */ memset(d_stream->next_out, 0, BTR_EXTERN_FIELD_REF_SIZE); d_stream->next_out += BTR_EXTERN_FIELD_REF_SIZE; } } return(TRUE); } /**********************************************************************//** Compress the records of a leaf node of a clustered index. @return TRUE on success, FALSE on failure */ static ibool page_zip_decompress_clust( /*======================*/ page_zip_des_t* page_zip, /*!< in/out: compressed page */ z_stream* d_stream, /*!< in/out: compressed page stream */ rec_t** recs, /*!< in: dense page directory sorted by address */ ulint n_dense, /*!< in: size of recs[] */ dict_index_t* index, /*!< in: the index of the page */ ulint trx_id_col, /*!< index of the trx_id column */ ulint* offsets, /*!< in/out: temporary offsets */ mem_heap_t* heap) /*!< in: temporary memory heap */ { int err; ulint slot; ulint heap_status = REC_STATUS_ORDINARY | PAGE_HEAP_NO_USER_LOW << REC_HEAP_NO_SHIFT; const byte* storage; const byte* externs; ut_a(dict_index_is_clust(index)); /* Subtract the space reserved for uncompressed data. */ d_stream->avail_in -= static_cast<uInt>(n_dense) * (PAGE_ZIP_DIR_SLOT_SIZE + DATA_TRX_ID_LEN + DATA_ROLL_PTR_LEN); /* Decompress the records in heap_no order. */ for (slot = 0; slot < n_dense; slot++) { rec_t* rec = recs[slot]; d_stream->avail_out =static_cast<uInt>( rec - REC_N_NEW_EXTRA_BYTES - d_stream->next_out); ut_ad(d_stream->avail_out < UNIV_PAGE_SIZE - PAGE_ZIP_START - PAGE_DIR); err = inflate(d_stream, Z_SYNC_FLUSH); switch (err) { case Z_STREAM_END: page_zip_decompress_heap_no( d_stream, rec, heap_status); goto zlib_done; case Z_OK: case Z_BUF_ERROR: if (UNIV_LIKELY(!d_stream->avail_out)) { break; } /* fall through */ default: page_zip_fail(("page_zip_decompress_clust:" " 1 inflate(Z_SYNC_FLUSH)=%s\n", d_stream->msg)); goto zlib_error; } if (!page_zip_decompress_heap_no( d_stream, rec, heap_status)) { ut_ad(0); } /* Read the offsets. The status bits are needed here. */ offsets = rec_get_offsets(rec, index, offsets, ULINT_UNDEFINED, &heap); /* This is a leaf page in a clustered index. */ /* Check if there are any externally stored columns. For each externally stored column, restore the BTR_EXTERN_FIELD_REF separately. */ if (rec_offs_any_extern(offsets)) { if (UNIV_UNLIKELY (!page_zip_decompress_clust_ext( d_stream, rec, offsets, trx_id_col))) { goto zlib_error; } } else { /* Skip trx_id and roll_ptr */ ulint len; byte* dst = rec_get_nth_field(rec, offsets, trx_id_col, &len); if (UNIV_UNLIKELY(len < DATA_TRX_ID_LEN + DATA_ROLL_PTR_LEN)) { page_zip_fail(("page_zip_decompress_clust:" " len = %lu\n", (ulong) len)); goto zlib_error; } d_stream->avail_out = static_cast<uInt>( dst - d_stream->next_out); switch (inflate(d_stream, Z_SYNC_FLUSH)) { case Z_STREAM_END: case Z_OK: case Z_BUF_ERROR: if (!d_stream->avail_out) { break; } /* fall through */ default: page_zip_fail(("page_zip_decompress_clust:" " 2 inflate(Z_SYNC_FLUSH)=%s\n", d_stream->msg)); goto zlib_error; } ut_ad(d_stream->next_out == dst); /* Clear DB_TRX_ID and DB_ROLL_PTR in order to avoid uninitialized bytes in case the record is affected by page_zip_apply_log(). */ memset(dst, 0, DATA_TRX_ID_LEN + DATA_ROLL_PTR_LEN); d_stream->next_out += DATA_TRX_ID_LEN + DATA_ROLL_PTR_LEN; } /* Decompress the last bytes of the record. */ d_stream->avail_out = static_cast<uInt>( rec_get_end(rec, offsets) - d_stream->next_out); switch (inflate(d_stream, Z_SYNC_FLUSH)) { case Z_STREAM_END: case Z_OK: case Z_BUF_ERROR: if (!d_stream->avail_out) { break; } /* fall through */ default: page_zip_fail(("page_zip_decompress_clust:" " 3 inflate(Z_SYNC_FLUSH)=%s\n", d_stream->msg)); goto zlib_error; } } /* Decompress any trailing garbage, in case the last record was allocated from an originally longer space on the free list. */ d_stream->avail_out = static_cast<uInt>( page_header_get_field(page_zip->data, PAGE_HEAP_TOP) - page_offset(d_stream->next_out)); if (UNIV_UNLIKELY(d_stream->avail_out > UNIV_PAGE_SIZE - PAGE_ZIP_START - PAGE_DIR)) { page_zip_fail(("page_zip_decompress_clust:" " avail_out = %u\n", d_stream->avail_out)); goto zlib_error; } if (UNIV_UNLIKELY(inflate(d_stream, Z_FINISH) != Z_STREAM_END)) { page_zip_fail(("page_zip_decompress_clust:" " inflate(Z_FINISH)=%s\n", d_stream->msg)); zlib_error: inflateEnd(d_stream); return(FALSE); } /* Note that d_stream->avail_out > 0 may hold here if the modification log is nonempty. */ zlib_done: if (UNIV_UNLIKELY(inflateEnd(d_stream) != Z_OK)) { ut_error; } { page_t* page = page_align(d_stream->next_out); /* Clear the unused heap space on the uncompressed page. */ memset(d_stream->next_out, 0, page_dir_get_nth_slot(page, page_dir_get_n_slots(page) - 1) - d_stream->next_out); } #ifdef UNIV_DEBUG page_zip->m_start = PAGE_DATA + d_stream->total_in; #endif /* UNIV_DEBUG */ /* Apply the modification log. */ { const byte* mod_log_ptr; mod_log_ptr = page_zip_apply_log(d_stream->next_in, d_stream->avail_in + 1, recs, n_dense, trx_id_col, heap_status, index, offsets); if (UNIV_UNLIKELY(!mod_log_ptr)) { return(FALSE); } page_zip->m_end = mod_log_ptr - page_zip->data; page_zip->m_nonempty = mod_log_ptr != d_stream->next_in; } if (UNIV_UNLIKELY(page_zip_get_trailer_len(page_zip, TRUE) + page_zip->m_end >= page_zip_get_size(page_zip))) { page_zip_fail(("page_zip_decompress_clust: %lu + %lu >= %lu\n", (ulong) page_zip_get_trailer_len( page_zip, TRUE), (ulong) page_zip->m_end, (ulong) page_zip_get_size(page_zip))); return(FALSE); } storage = page_zip_dir_start_low(page_zip, n_dense); externs = storage - n_dense * (DATA_TRX_ID_LEN + DATA_ROLL_PTR_LEN); /* Restore the uncompressed columns in heap_no order. */ for (slot = 0; slot < n_dense; slot++) { ulint i; ulint len; byte* dst; rec_t* rec = recs[slot]; ibool exists = !page_zip_dir_find_free( page_zip, page_offset(rec)); offsets = rec_get_offsets(rec, index, offsets, ULINT_UNDEFINED, &heap); dst = rec_get_nth_field(rec, offsets, trx_id_col, &len); ut_ad(len >= DATA_TRX_ID_LEN + DATA_ROLL_PTR_LEN); storage -= DATA_TRX_ID_LEN + DATA_ROLL_PTR_LEN; memcpy(dst, storage, DATA_TRX_ID_LEN + DATA_ROLL_PTR_LEN); /* Check if there are any externally stored columns in this record. For each externally stored column, restore or clear the BTR_EXTERN_FIELD_REF. */ if (!rec_offs_any_extern(offsets)) { continue; } for (i = 0; i < rec_offs_n_fields(offsets); i++) { if (!rec_offs_nth_extern(offsets, i)) { continue; } dst = rec_get_nth_field(rec, offsets, i, &len); if (UNIV_UNLIKELY(len < BTR_EXTERN_FIELD_REF_SIZE)) { page_zip_fail(("page_zip_decompress_clust:" " %lu < 20\n", (ulong) len)); return(FALSE); } dst += len - BTR_EXTERN_FIELD_REF_SIZE; if (UNIV_LIKELY(exists)) { /* Existing record: restore the BLOB pointer */ externs -= BTR_EXTERN_FIELD_REF_SIZE; if (UNIV_UNLIKELY (externs < page_zip->data + page_zip->m_end)) { page_zip_fail(("page_zip_" "decompress_clust: " "%p < %p + %lu\n", (const void*) externs, (const void*) page_zip->data, (ulong) page_zip->m_end)); return(FALSE); } memcpy(dst, externs, BTR_EXTERN_FIELD_REF_SIZE); page_zip->n_blobs++; } else { /* Deleted record: clear the BLOB pointer */ memset(dst, 0, BTR_EXTERN_FIELD_REF_SIZE); } } } return(TRUE); } /**********************************************************************//** This function determines the sign for window_bits and reads the zlib header from the decompress stream. The data may have been compressed with a negative (no adler32 headers) or a positive (with adler32 headers) window_bits. Regardless of the current value of page_zip_zlib_wrap, we always first try the positive window_bits then negative window_bits, because the surest way to determine if the stream has adler32 headers is to see if the stream begins with the zlib header together with the adler32 value of it. This adds a tiny bit of overhead for the pages that were compressed without adler32s. @return TRUE if stream is initialized and zlib header was read, FALSE if data can be decompressed with neither window_bits nor -window_bits */ UNIV_INTERN ibool page_zip_init_d_stream( z_stream* strm, int window_bits, ibool read_zlib_header) { /* Save initial stream position, in case a reset is required. */ Bytef* next_in = strm->next_in; Bytef* next_out = strm->next_out; ulint avail_in = strm->avail_in; ulint avail_out = strm->avail_out; if (UNIV_UNLIKELY(inflateInit2(strm, window_bits) != Z_OK)) { /* init must always succeed regardless of window_bits */ ut_error; } /* Try decoding a zlib header assuming adler32. */ if (inflate(strm, Z_BLOCK) == Z_OK) /* A valid header was found, all is well. So, we return with the stream positioned just after this header. */ return(TRUE); /* A valid header was not found, so now we need to re-try this read assuming there is *no* header (negative window_bits). So, we need to reset the stream to the original position, and change the window_bits to negative, with inflateReset2(). */ strm->next_in = next_in; strm->next_out = next_out; strm->avail_in = avail_in; strm->avail_out = avail_out; if (UNIV_UNLIKELY(inflateReset2(strm, -window_bits) != Z_OK)) { /* init must always succeed regardless of window_bits */ ut_error; } if (read_zlib_header) { /* No valid header was found, and we still want the header read to have happened, with negative window_bits. */ return(inflate(strm, Z_BLOCK) == Z_OK); } /* Did not find a header, but didn't require one, so just return with the stream position reset to where it originally was. */ return(TRUE); } /**********************************************************************//** Decompress a page. This function should tolerate errors on the compressed page. Instead of letting assertions fail, it will return FALSE if an inconsistency is detected. @return TRUE on success, FALSE on failure */ UNIV_INTERN ibool page_zip_decompress( /*================*/ page_zip_des_t* page_zip,/*!< in: data, ssize; out: m_start, m_end, m_nonempty, n_blobs */ page_t* page, /*!< out: uncompressed page, may be trashed */ ibool all) /*!< in: TRUE=decompress the whole page; FALSE=verify but do not copy some page header fields that should not change after page creation */ { z_stream d_stream; dict_index_t* index = NULL; rec_t** recs; /*!< dense page directory, sorted by address */ ulint n_dense;/* number of user records on the page */ ulint trx_id_col = ULINT_UNDEFINED; mem_heap_t* heap; ulint* offsets; #ifndef UNIV_HOTBACKUP ullint usec = ut_time_us(NULL); #endif /* !UNIV_HOTBACKUP */ ut_ad(page_zip_simple_validate(page_zip)); UNIV_MEM_ASSERT_W(page, UNIV_PAGE_SIZE); UNIV_MEM_ASSERT_RW(page_zip->data, page_zip_get_size(page_zip)); /* The dense directory excludes the infimum and supremum records. */ n_dense = page_dir_get_n_heap(page_zip->data) - PAGE_HEAP_NO_USER_LOW; if (UNIV_UNLIKELY(n_dense * PAGE_ZIP_DIR_SLOT_SIZE >= page_zip_get_size(page_zip))) { page_zip_fail(("page_zip_decompress 1: %lu %lu\n", (ulong) n_dense, (ulong) page_zip_get_size(page_zip))); return(FALSE); } heap = mem_heap_create(n_dense * (3 * sizeof *recs) + UNIV_PAGE_SIZE); recs = static_cast<rec_t**>( mem_heap_alloc(heap, n_dense * (2 * sizeof *recs))); if (all) { /* Copy the page header. */ memcpy(page, page_zip->data, PAGE_DATA); } else { /* Check that the bytes that we skip are identical. */ #if defined UNIV_DEBUG || defined UNIV_ZIP_DEBUG ut_a(!memcmp(FIL_PAGE_TYPE + page, FIL_PAGE_TYPE + page_zip->data, PAGE_HEADER - FIL_PAGE_TYPE)); ut_a(!memcmp(PAGE_HEADER + PAGE_LEVEL + page, PAGE_HEADER + PAGE_LEVEL + page_zip->data, PAGE_DATA - (PAGE_HEADER + PAGE_LEVEL))); #endif /* UNIV_DEBUG || UNIV_ZIP_DEBUG */ /* Copy the mutable parts of the page header. */ memcpy(page, page_zip->data, FIL_PAGE_TYPE); memcpy(PAGE_HEADER + page, PAGE_HEADER + page_zip->data, PAGE_LEVEL - PAGE_N_DIR_SLOTS); #if defined UNIV_DEBUG || defined UNIV_ZIP_DEBUG /* Check that the page headers match after copying. */ ut_a(!memcmp(page, page_zip->data, PAGE_DATA)); #endif /* UNIV_DEBUG || UNIV_ZIP_DEBUG */ } #ifdef UNIV_ZIP_DEBUG /* Clear the uncompressed page, except the header. */ memset(PAGE_DATA + page, 0x55, UNIV_PAGE_SIZE - PAGE_DATA); #endif /* UNIV_ZIP_DEBUG */ UNIV_MEM_INVALID(PAGE_DATA + page, UNIV_PAGE_SIZE - PAGE_DATA); /* Copy the page directory. */ if (UNIV_UNLIKELY(!page_zip_dir_decode(page_zip, page, recs, recs + n_dense, n_dense))) { zlib_error: mem_heap_free(heap); return(FALSE); } /* Copy the infimum and supremum records. */ memcpy(page + (PAGE_NEW_INFIMUM - REC_N_NEW_EXTRA_BYTES), infimum_extra, sizeof infimum_extra); if (page_is_empty(page)) { rec_set_next_offs_new(page + PAGE_NEW_INFIMUM, PAGE_NEW_SUPREMUM); } else { rec_set_next_offs_new(page + PAGE_NEW_INFIMUM, page_zip_dir_get(page_zip, 0) & PAGE_ZIP_DIR_SLOT_MASK); } memcpy(page + PAGE_NEW_INFIMUM, infimum_data, sizeof infimum_data); memcpy(page + (PAGE_NEW_SUPREMUM - REC_N_NEW_EXTRA_BYTES + 1), supremum_extra_data, sizeof supremum_extra_data); page_zip_set_alloc(&d_stream, heap); d_stream.next_in = page_zip->data + PAGE_DATA; /* Subtract the space reserved for the page header and the end marker of the modification log. */ d_stream.avail_in = static_cast<uInt>( page_zip_get_size(page_zip) - (PAGE_DATA + 1)); d_stream.next_out = page + PAGE_ZIP_START; d_stream.avail_out = UNIV_PAGE_SIZE - PAGE_ZIP_START; if (!page_zip_init_d_stream(&d_stream, UNIV_PAGE_SIZE_SHIFT, TRUE)) { page_zip_fail(("page_zip_decompress:" " 1 inflate(Z_BLOCK)=%s\n", d_stream.msg)); goto zlib_error; } if (UNIV_UNLIKELY(inflate(&d_stream, Z_BLOCK) != Z_OK)) { page_zip_fail(("page_zip_decompress:" " 2 inflate(Z_BLOCK)=%s\n", d_stream.msg)); goto zlib_error; } index = page_zip_fields_decode( page + PAGE_ZIP_START, d_stream.next_out, page_is_leaf(page) ? &trx_id_col : NULL); if (UNIV_UNLIKELY(!index)) { goto zlib_error; } /* Decompress the user records. */ page_zip->n_blobs = 0; d_stream.next_out = page + PAGE_ZIP_START; { /* Pre-allocate the offsets for rec_get_offsets_reverse(). */ ulint n = 1 + 1/* node ptr */ + REC_OFFS_HEADER_SIZE + dict_index_get_n_fields(index); offsets = static_cast<ulint*>( mem_heap_alloc(heap, n * sizeof(ulint))); *offsets = n; } /* Decompress the records in heap_no order. */ if (!page_is_leaf(page)) { /* This is a node pointer page. */ ulint info_bits; if (UNIV_UNLIKELY (!page_zip_decompress_node_ptrs(page_zip, &d_stream, recs, n_dense, index, offsets, heap))) { goto err_exit; } info_bits = mach_read_from_4(page + FIL_PAGE_PREV) == FIL_NULL ? REC_INFO_MIN_REC_FLAG : 0; if (UNIV_UNLIKELY(!page_zip_set_extra_bytes(page_zip, page, info_bits))) { goto err_exit; } } else if (UNIV_LIKELY(trx_id_col == ULINT_UNDEFINED)) { /* This is a leaf page in a secondary index. */ if (UNIV_UNLIKELY(!page_zip_decompress_sec(page_zip, &d_stream, recs, n_dense, index, offsets))) { goto err_exit; } if (UNIV_UNLIKELY(!page_zip_set_extra_bytes(page_zip, page, 0))) { err_exit: page_zip_fields_free(index); mem_heap_free(heap); return(FALSE); } } else { /* This is a leaf page in a clustered index. */ if (UNIV_UNLIKELY(!page_zip_decompress_clust(page_zip, &d_stream, recs, n_dense, index, trx_id_col, offsets, heap))) { goto err_exit; } if (UNIV_UNLIKELY(!page_zip_set_extra_bytes(page_zip, page, 0))) { goto err_exit; } } ut_a(page_is_comp(page)); UNIV_MEM_ASSERT_RW(page, UNIV_PAGE_SIZE); page_zip_fields_free(index); mem_heap_free(heap); #ifndef UNIV_HOTBACKUP ullint time_diff = ut_time_us(NULL) - usec; page_zip_stat[page_zip->ssize - 1].decompressed++; page_zip_stat[page_zip->ssize - 1].decompressed_usec += time_diff; index_id_t index_id = btr_page_get_index_id(page); if (srv_cmp_per_index_enabled) { mutex_enter(&page_zip_stat_per_index_mutex); page_zip_stat_per_index[index_id].decompressed++; page_zip_stat_per_index[index_id].decompressed_usec += time_diff; mutex_exit(&page_zip_stat_per_index_mutex); } #endif /* !UNIV_HOTBACKUP */ /* Update the stat counter for LRU policy. */ buf_LRU_stat_inc_unzip(); MONITOR_INC(MONITOR_PAGE_DECOMPRESS); return(TRUE); } #ifdef UNIV_ZIP_DEBUG /**********************************************************************//** Dump a block of memory on the standard error stream. */ static void page_zip_hexdump_func( /*==================*/ const char* name, /*!< in: name of the data structure */ const void* buf, /*!< in: data */ ulint size) /*!< in: length of the data, in bytes */ { const byte* s = static_cast<const byte*>(buf); ulint addr; const ulint width = 32; /* bytes per line */ fprintf(stderr, "%s:\n", name); for (addr = 0; addr < size; addr += width) { ulint i; fprintf(stderr, "%04lx ", (ulong) addr); i = ut_min(width, size - addr); while (i--) { fprintf(stderr, "%02x", *s++); } putc('\n', stderr); } } /** Dump a block of memory on the standard error stream. @param buf in: data @param size in: length of the data, in bytes */ #define page_zip_hexdump(buf, size) page_zip_hexdump_func(#buf, buf, size) /** Flag: make page_zip_validate() compare page headers only */ UNIV_INTERN ibool page_zip_validate_header_only = FALSE; /**********************************************************************//** Check that the compressed and decompressed pages match. @return TRUE if valid, FALSE if not */ UNIV_INTERN ibool page_zip_validate_low( /*==================*/ const page_zip_des_t* page_zip,/*!< in: compressed page */ const page_t* page, /*!< in: uncompressed page */ const dict_index_t* index, /*!< in: index of the page, if known */ ibool sloppy) /*!< in: FALSE=strict, TRUE=ignore the MIN_REC_FLAG */ { page_zip_des_t temp_page_zip; byte* temp_page_buf; page_t* temp_page; ibool valid; if (memcmp(page_zip->data + FIL_PAGE_PREV, page + FIL_PAGE_PREV, FIL_PAGE_LSN - FIL_PAGE_PREV) || memcmp(page_zip->data + FIL_PAGE_TYPE, page + FIL_PAGE_TYPE, 2) || memcmp(page_zip->data + FIL_PAGE_DATA, page + FIL_PAGE_DATA, PAGE_DATA - FIL_PAGE_DATA)) { page_zip_fail(("page_zip_validate: page header\n")); page_zip_hexdump(page_zip, sizeof *page_zip); page_zip_hexdump(page_zip->data, page_zip_get_size(page_zip)); page_zip_hexdump(page, UNIV_PAGE_SIZE); return(FALSE); } ut_a(page_is_comp(page)); if (page_zip_validate_header_only) { return(TRUE); } /* page_zip_decompress() expects the uncompressed page to be UNIV_PAGE_SIZE aligned. */ temp_page_buf = static_cast<byte*>(ut_malloc(2 * UNIV_PAGE_SIZE)); temp_page = static_cast<byte*>(ut_align(temp_page_buf, UNIV_PAGE_SIZE)); UNIV_MEM_ASSERT_RW(page, UNIV_PAGE_SIZE); UNIV_MEM_ASSERT_RW(page_zip->data, page_zip_get_size(page_zip)); temp_page_zip = *page_zip; valid = page_zip_decompress(&temp_page_zip, temp_page, TRUE); if (!valid) { fputs("page_zip_validate(): failed to decompress\n", stderr); goto func_exit; } if (page_zip->n_blobs != temp_page_zip.n_blobs) { page_zip_fail(("page_zip_validate: n_blobs: %u!=%u\n", page_zip->n_blobs, temp_page_zip.n_blobs)); valid = FALSE; } #ifdef UNIV_DEBUG if (page_zip->m_start != temp_page_zip.m_start) { page_zip_fail(("page_zip_validate: m_start: %u!=%u\n", page_zip->m_start, temp_page_zip.m_start)); valid = FALSE; } #endif /* UNIV_DEBUG */ if (page_zip->m_end != temp_page_zip.m_end) { page_zip_fail(("page_zip_validate: m_end: %u!=%u\n", page_zip->m_end, temp_page_zip.m_end)); valid = FALSE; } if (page_zip->m_nonempty != temp_page_zip.m_nonempty) { page_zip_fail(("page_zip_validate(): m_nonempty: %u!=%u\n", page_zip->m_nonempty, temp_page_zip.m_nonempty)); valid = FALSE; } if (memcmp(page + PAGE_HEADER, temp_page + PAGE_HEADER, UNIV_PAGE_SIZE - PAGE_HEADER - FIL_PAGE_DATA_END)) { /* In crash recovery, the "minimum record" flag may be set incorrectly until the mini-transaction is committed. Let us tolerate that difference when we are performing a sloppy validation. */ ulint* offsets; mem_heap_t* heap; const rec_t* rec; const rec_t* trec; byte info_bits_diff; ulint offset = rec_get_next_offs(page + PAGE_NEW_INFIMUM, TRUE); ut_a(offset >= PAGE_NEW_SUPREMUM); offset -= 5/*REC_NEW_INFO_BITS*/; info_bits_diff = page[offset] ^ temp_page[offset]; if (info_bits_diff == REC_INFO_MIN_REC_FLAG) { temp_page[offset] = page[offset]; if (!memcmp(page + PAGE_HEADER, temp_page + PAGE_HEADER, UNIV_PAGE_SIZE - PAGE_HEADER - FIL_PAGE_DATA_END)) { /* Only the minimum record flag differed. Let us ignore it. */ page_zip_fail(("page_zip_validate: " "min_rec_flag " "(%s" "%lu,%lu,0x%02lx)\n", sloppy ? "ignored, " : "", page_get_space_id(page), page_get_page_no(page), (ulong) page[offset])); valid = sloppy; goto func_exit; } } /* Compare the pointers in the PAGE_FREE list. */ rec = page_header_get_ptr(page, PAGE_FREE); trec = page_header_get_ptr(temp_page, PAGE_FREE); while (rec || trec) { if (page_offset(rec) != page_offset(trec)) { page_zip_fail(("page_zip_validate: " "PAGE_FREE list: %u!=%u\n", (unsigned) page_offset(rec), (unsigned) page_offset(trec))); valid = FALSE; goto func_exit; } rec = page_rec_get_next_low(rec, TRUE); trec = page_rec_get_next_low(trec, TRUE); } /* Compare the records. */ heap = NULL; offsets = NULL; rec = page_rec_get_next_low( page + PAGE_NEW_INFIMUM, TRUE); trec = page_rec_get_next_low( temp_page + PAGE_NEW_INFIMUM, TRUE); do { if (page_offset(rec) != page_offset(trec)) { page_zip_fail(("page_zip_validate: " "record list: 0x%02x!=0x%02x\n", (unsigned) page_offset(rec), (unsigned) page_offset(trec))); valid = FALSE; break; } if (index) { /* Compare the data. */ offsets = rec_get_offsets( rec, index, offsets, ULINT_UNDEFINED, &heap); if (memcmp(rec - rec_offs_extra_size(offsets), trec - rec_offs_extra_size(offsets), rec_offs_size(offsets))) { page_zip_fail( ("page_zip_validate: " "record content: 0x%02x", (unsigned) page_offset(rec))); valid = FALSE; break; } } rec = page_rec_get_next_low(rec, TRUE); trec = page_rec_get_next_low(trec, TRUE); } while (rec || trec); if (heap) { mem_heap_free(heap); } } func_exit: if (!valid) { page_zip_hexdump(page_zip, sizeof *page_zip); page_zip_hexdump(page_zip->data, page_zip_get_size(page_zip)); page_zip_hexdump(page, UNIV_PAGE_SIZE); page_zip_hexdump(temp_page, UNIV_PAGE_SIZE); } ut_free(temp_page_buf); return(valid); } /**********************************************************************//** Check that the compressed and decompressed pages match. @return TRUE if valid, FALSE if not */ UNIV_INTERN ibool page_zip_validate( /*==============*/ const page_zip_des_t* page_zip,/*!< in: compressed page */ const page_t* page, /*!< in: uncompressed page */ const dict_index_t* index) /*!< in: index of the page, if known */ { return(page_zip_validate_low(page_zip, page, index, recv_recovery_is_on())); } #endif /* UNIV_ZIP_DEBUG */ #ifdef UNIV_DEBUG /**********************************************************************//** Assert that the compressed and decompressed page headers match. @return TRUE */ static ibool page_zip_header_cmp( /*================*/ const page_zip_des_t* page_zip,/*!< in: compressed page */ const byte* page) /*!< in: uncompressed page */ { ut_ad(!memcmp(page_zip->data + FIL_PAGE_PREV, page + FIL_PAGE_PREV, FIL_PAGE_LSN - FIL_PAGE_PREV)); ut_ad(!memcmp(page_zip->data + FIL_PAGE_TYPE, page + FIL_PAGE_TYPE, 2)); ut_ad(!memcmp(page_zip->data + FIL_PAGE_DATA, page + FIL_PAGE_DATA, PAGE_DATA - FIL_PAGE_DATA)); return(TRUE); } #endif /* UNIV_DEBUG */ /**********************************************************************//** Write a record on the compressed page that contains externally stored columns. The data must already have been written to the uncompressed page. @return end of modification log */ static byte* page_zip_write_rec_ext( /*===================*/ page_zip_des_t* page_zip, /*!< in/out: compressed page */ const page_t* page, /*!< in: page containing rec */ const byte* rec, /*!< in: record being written */ dict_index_t* index, /*!< in: record descriptor */ const ulint* offsets, /*!< in: rec_get_offsets(rec, index) */ ulint create, /*!< in: nonzero=insert, zero=update */ ulint trx_id_col, /*!< in: position of DB_TRX_ID */ ulint heap_no, /*!< in: heap number of rec */ byte* storage, /*!< in: end of dense page directory */ byte* data) /*!< in: end of modification log */ { const byte* start = rec; ulint i; ulint len; byte* externs = storage; ulint n_ext = rec_offs_n_extern(offsets); ut_ad(rec_offs_validate(rec, index, offsets)); UNIV_MEM_ASSERT_RW(rec, rec_offs_data_size(offsets)); UNIV_MEM_ASSERT_RW(rec - rec_offs_extra_size(offsets), rec_offs_extra_size(offsets)); externs -= (DATA_TRX_ID_LEN + DATA_ROLL_PTR_LEN) * (page_dir_get_n_heap(page) - PAGE_HEAP_NO_USER_LOW); /* Note that this will not take into account the BLOB columns of rec if create==TRUE. */ ut_ad(data + rec_offs_data_size(offsets) - (DATA_TRX_ID_LEN + DATA_ROLL_PTR_LEN) - n_ext * BTR_EXTERN_FIELD_REF_SIZE < externs - BTR_EXTERN_FIELD_REF_SIZE * page_zip->n_blobs); { ulint blob_no = page_zip_get_n_prev_extern( page_zip, rec, index); byte* ext_end = externs - page_zip->n_blobs * BTR_EXTERN_FIELD_REF_SIZE; ut_ad(blob_no <= page_zip->n_blobs); externs -= blob_no * BTR_EXTERN_FIELD_REF_SIZE; if (create) { page_zip->n_blobs += static_cast<unsigned>(n_ext); ASSERT_ZERO_BLOB(ext_end - n_ext * BTR_EXTERN_FIELD_REF_SIZE); memmove(ext_end - n_ext * BTR_EXTERN_FIELD_REF_SIZE, ext_end, externs - ext_end); } ut_a(blob_no + n_ext <= page_zip->n_blobs); } for (i = 0; i < rec_offs_n_fields(offsets); i++) { const byte* src; if (UNIV_UNLIKELY(i == trx_id_col)) { ut_ad(!rec_offs_nth_extern(offsets, i)); ut_ad(!rec_offs_nth_extern(offsets, i + 1)); /* Locate trx_id and roll_ptr. */ src = rec_get_nth_field(rec, offsets, i, &len); ut_ad(len == DATA_TRX_ID_LEN); ut_ad(src + DATA_TRX_ID_LEN == rec_get_nth_field( rec, offsets, i + 1, &len)); ut_ad(len == DATA_ROLL_PTR_LEN); /* Log the preceding fields. */ ASSERT_ZERO(data, src - start); memcpy(data, start, src - start); data += src - start; start = src + (DATA_TRX_ID_LEN + DATA_ROLL_PTR_LEN); /* Store trx_id and roll_ptr. */ memcpy(storage - (DATA_TRX_ID_LEN + DATA_ROLL_PTR_LEN) * (heap_no - 1), src, DATA_TRX_ID_LEN + DATA_ROLL_PTR_LEN); i++; /* skip also roll_ptr */ } else if (rec_offs_nth_extern(offsets, i)) { src = rec_get_nth_field(rec, offsets, i, &len); ut_ad(dict_index_is_clust(index)); ut_ad(len >= BTR_EXTERN_FIELD_REF_SIZE); src += len - BTR_EXTERN_FIELD_REF_SIZE; ASSERT_ZERO(data, src - start); memcpy(data, start, src - start); data += src - start; start = src + BTR_EXTERN_FIELD_REF_SIZE; /* Store the BLOB pointer. */ externs -= BTR_EXTERN_FIELD_REF_SIZE; ut_ad(data < externs); memcpy(externs, src, BTR_EXTERN_FIELD_REF_SIZE); } } /* Log the last bytes of the record. */ len = rec_offs_data_size(offsets) - (start - rec); ASSERT_ZERO(data, len); memcpy(data, start, len); data += len; return(data); } /**********************************************************************//** Write an entire record on the compressed page. The data must already have been written to the uncompressed page. */ UNIV_INTERN void page_zip_write_rec( /*===============*/ page_zip_des_t* page_zip,/*!< in/out: compressed page */ const byte* rec, /*!< in: record being written */ dict_index_t* index, /*!< in: the index the record belongs to */ const ulint* offsets,/*!< in: rec_get_offsets(rec, index) */ ulint create) /*!< in: nonzero=insert, zero=update */ { const page_t* page; byte* data; byte* storage; ulint heap_no; byte* slot; ut_ad(PAGE_ZIP_MATCH(rec, page_zip)); ut_ad(page_zip_simple_validate(page_zip)); ut_ad(page_zip_get_size(page_zip) > PAGE_DATA + page_zip_dir_size(page_zip)); ut_ad(rec_offs_comp(offsets)); ut_ad(rec_offs_validate(rec, index, offsets)); ut_ad(page_zip->m_start >= PAGE_DATA); page = page_align(rec); ut_ad(page_zip_header_cmp(page_zip, page)); ut_ad(page_simple_validate_new((page_t*) page)); UNIV_MEM_ASSERT_RW(page_zip->data, page_zip_get_size(page_zip)); UNIV_MEM_ASSERT_RW(rec, rec_offs_data_size(offsets)); UNIV_MEM_ASSERT_RW(rec - rec_offs_extra_size(offsets), rec_offs_extra_size(offsets)); slot = page_zip_dir_find(page_zip, page_offset(rec)); ut_a(slot); /* Copy the delete mark. */ if (rec_get_deleted_flag(rec, TRUE)) { *slot |= PAGE_ZIP_DIR_SLOT_DEL >> 8; } else { *slot &= ~(PAGE_ZIP_DIR_SLOT_DEL >> 8); } ut_ad(rec_get_start((rec_t*) rec, offsets) >= page + PAGE_ZIP_START); ut_ad(rec_get_end((rec_t*) rec, offsets) <= page + UNIV_PAGE_SIZE - PAGE_DIR - PAGE_DIR_SLOT_SIZE * page_dir_get_n_slots(page)); heap_no = rec_get_heap_no_new(rec); ut_ad(heap_no >= PAGE_HEAP_NO_USER_LOW); /* not infimum or supremum */ ut_ad(heap_no < page_dir_get_n_heap(page)); /* Append to the modification log. */ data = page_zip->data + page_zip->m_end; ut_ad(!*data); /* Identify the record by writing its heap number - 1. 0 is reserved to indicate the end of the modification log. */ if (UNIV_UNLIKELY(heap_no - 1 >= 64)) { *data++ = (byte) (0x80 | (heap_no - 1) >> 7); ut_ad(!*data); } *data++ = (byte) ((heap_no - 1) << 1); ut_ad(!*data); { const byte* start = rec - rec_offs_extra_size(offsets); const byte* b = rec - REC_N_NEW_EXTRA_BYTES; /* Write the extra bytes backwards, so that rec_offs_extra_size() can be easily computed in page_zip_apply_log() by invoking rec_get_offsets_reverse(). */ while (b != start) { *data++ = *--b; ut_ad(!*data); } } /* Write the data bytes. Store the uncompressed bytes separately. */ storage = page_zip_dir_start(page_zip); if (page_is_leaf(page)) { ulint len; if (dict_index_is_clust(index)) { ulint trx_id_col; trx_id_col = dict_index_get_sys_col_pos(index, DATA_TRX_ID); ut_ad(trx_id_col != ULINT_UNDEFINED); /* Store separately trx_id, roll_ptr and the BTR_EXTERN_FIELD_REF of each BLOB column. */ if (rec_offs_any_extern(offsets)) { data = page_zip_write_rec_ext( page_zip, page, rec, index, offsets, create, trx_id_col, heap_no, storage, data); } else { /* Locate trx_id and roll_ptr. */ const byte* src = rec_get_nth_field(rec, offsets, trx_id_col, &len); ut_ad(len == DATA_TRX_ID_LEN); ut_ad(src + DATA_TRX_ID_LEN == rec_get_nth_field( rec, offsets, trx_id_col + 1, &len)); ut_ad(len == DATA_ROLL_PTR_LEN); /* Log the preceding fields. */ ASSERT_ZERO(data, src - rec); memcpy(data, rec, src - rec); data += src - rec; /* Store trx_id and roll_ptr. */ memcpy(storage - (DATA_TRX_ID_LEN + DATA_ROLL_PTR_LEN) * (heap_no - 1), src, DATA_TRX_ID_LEN + DATA_ROLL_PTR_LEN); src += DATA_TRX_ID_LEN + DATA_ROLL_PTR_LEN; /* Log the last bytes of the record. */ len = rec_offs_data_size(offsets) - (src - rec); ASSERT_ZERO(data, len); memcpy(data, src, len); data += len; } } else { /* Leaf page of a secondary index: no externally stored columns */ ut_ad(dict_index_get_sys_col_pos(index, DATA_TRX_ID) == ULINT_UNDEFINED); ut_ad(!rec_offs_any_extern(offsets)); /* Log the entire record. */ len = rec_offs_data_size(offsets); ASSERT_ZERO(data, len); memcpy(data, rec, len); data += len; } } else { /* This is a node pointer page. */ ulint len; /* Non-leaf nodes should not have any externally stored columns. */ ut_ad(!rec_offs_any_extern(offsets)); /* Copy the data bytes, except node_ptr. */ len = rec_offs_data_size(offsets) - REC_NODE_PTR_SIZE; ut_ad(data + len < storage - REC_NODE_PTR_SIZE * (page_dir_get_n_heap(page) - PAGE_HEAP_NO_USER_LOW)); ASSERT_ZERO(data, len); memcpy(data, rec, len); data += len; /* Copy the node pointer to the uncompressed area. */ memcpy(storage - REC_NODE_PTR_SIZE * (heap_no - 1), rec + len, REC_NODE_PTR_SIZE); } ut_a(!*data); ut_ad((ulint) (data - page_zip->data) < page_zip_get_size(page_zip)); page_zip->m_end = data - page_zip->data; page_zip->m_nonempty = TRUE; #ifdef UNIV_ZIP_DEBUG ut_a(page_zip_validate(page_zip, page_align(rec), index)); #endif /* UNIV_ZIP_DEBUG */ } /***********************************************************//** Parses a log record of writing a BLOB pointer of a record. @return end of log record or NULL */ UNIV_INTERN byte* page_zip_parse_write_blob_ptr( /*==========================*/ byte* ptr, /*!< in: redo log buffer */ byte* end_ptr,/*!< in: redo log buffer end */ page_t* page, /*!< in/out: uncompressed page */ page_zip_des_t* page_zip)/*!< in/out: compressed page */ { ulint offset; ulint z_offset; ut_ad(!page == !page_zip); if (UNIV_UNLIKELY (end_ptr < ptr + (2 + 2 + BTR_EXTERN_FIELD_REF_SIZE))) { return(NULL); } offset = mach_read_from_2(ptr); z_offset = mach_read_from_2(ptr + 2); if (UNIV_UNLIKELY(offset < PAGE_ZIP_START) || UNIV_UNLIKELY(offset >= UNIV_PAGE_SIZE) || UNIV_UNLIKELY(z_offset >= UNIV_PAGE_SIZE)) { corrupt: recv_sys->found_corrupt_log = TRUE; return(NULL); } if (page) { if (UNIV_UNLIKELY(!page_zip) || UNIV_UNLIKELY(!page_is_leaf(page))) { goto corrupt; } #ifdef UNIV_ZIP_DEBUG ut_a(page_zip_validate(page_zip, page, NULL)); #endif /* UNIV_ZIP_DEBUG */ memcpy(page + offset, ptr + 4, BTR_EXTERN_FIELD_REF_SIZE); memcpy(page_zip->data + z_offset, ptr + 4, BTR_EXTERN_FIELD_REF_SIZE); #ifdef UNIV_ZIP_DEBUG ut_a(page_zip_validate(page_zip, page, NULL)); #endif /* UNIV_ZIP_DEBUG */ } return(ptr + (2 + 2 + BTR_EXTERN_FIELD_REF_SIZE)); } /**********************************************************************//** Write a BLOB pointer of a record on the leaf page of a clustered index. The information must already have been updated on the uncompressed page. */ UNIV_INTERN void page_zip_write_blob_ptr( /*====================*/ page_zip_des_t* page_zip,/*!< in/out: compressed page */ const byte* rec, /*!< in/out: record whose data is being written */ dict_index_t* index, /*!< in: index of the page */ const ulint* offsets,/*!< in: rec_get_offsets(rec, index) */ ulint n, /*!< in: column index */ mtr_t* mtr) /*!< in: mini-transaction handle, or NULL if no logging is needed */ { const byte* field; byte* externs; const page_t* page = page_align(rec); ulint blob_no; ulint len; ut_ad(PAGE_ZIP_MATCH(rec, page_zip)); ut_ad(page_simple_validate_new((page_t*) page)); ut_ad(page_zip_simple_validate(page_zip)); ut_ad(page_zip_get_size(page_zip) > PAGE_DATA + page_zip_dir_size(page_zip)); ut_ad(rec_offs_comp(offsets)); ut_ad(rec_offs_validate(rec, NULL, offsets)); ut_ad(rec_offs_any_extern(offsets)); ut_ad(rec_offs_nth_extern(offsets, n)); ut_ad(page_zip->m_start >= PAGE_DATA); ut_ad(page_zip_header_cmp(page_zip, page)); ut_ad(page_is_leaf(page)); ut_ad(dict_index_is_clust(index)); UNIV_MEM_ASSERT_RW(page_zip->data, page_zip_get_size(page_zip)); UNIV_MEM_ASSERT_RW(rec, rec_offs_data_size(offsets)); UNIV_MEM_ASSERT_RW(rec - rec_offs_extra_size(offsets), rec_offs_extra_size(offsets)); blob_no = page_zip_get_n_prev_extern(page_zip, rec, index) + rec_get_n_extern_new(rec, index, n); ut_a(blob_no < page_zip->n_blobs); externs = page_zip->data + page_zip_get_size(page_zip) - (page_dir_get_n_heap(page) - PAGE_HEAP_NO_USER_LOW) * (PAGE_ZIP_DIR_SLOT_SIZE + DATA_TRX_ID_LEN + DATA_ROLL_PTR_LEN); field = rec_get_nth_field(rec, offsets, n, &len); externs -= (blob_no + 1) * BTR_EXTERN_FIELD_REF_SIZE; field += len - BTR_EXTERN_FIELD_REF_SIZE; memcpy(externs, field, BTR_EXTERN_FIELD_REF_SIZE); #ifdef UNIV_ZIP_DEBUG ut_a(page_zip_validate(page_zip, page, index)); #endif /* UNIV_ZIP_DEBUG */ if (mtr) { #ifndef UNIV_HOTBACKUP byte* log_ptr = mlog_open( mtr, 11 + 2 + 2 + BTR_EXTERN_FIELD_REF_SIZE); if (UNIV_UNLIKELY(!log_ptr)) { return; } log_ptr = mlog_write_initial_log_record_fast( (byte*) field, MLOG_ZIP_WRITE_BLOB_PTR, log_ptr, mtr); mach_write_to_2(log_ptr, page_offset(field)); log_ptr += 2; mach_write_to_2(log_ptr, externs - page_zip->data); log_ptr += 2; memcpy(log_ptr, externs, BTR_EXTERN_FIELD_REF_SIZE); log_ptr += BTR_EXTERN_FIELD_REF_SIZE; mlog_close(mtr, log_ptr); #endif /* !UNIV_HOTBACKUP */ } } /***********************************************************//** Parses a log record of writing the node pointer of a record. @return end of log record or NULL */ UNIV_INTERN byte* page_zip_parse_write_node_ptr( /*==========================*/ byte* ptr, /*!< in: redo log buffer */ byte* end_ptr,/*!< in: redo log buffer end */ page_t* page, /*!< in/out: uncompressed page */ page_zip_des_t* page_zip)/*!< in/out: compressed page */ { ulint offset; ulint z_offset; ut_ad(!page == !page_zip); if (UNIV_UNLIKELY(end_ptr < ptr + (2 + 2 + REC_NODE_PTR_SIZE))) { return(NULL); } offset = mach_read_from_2(ptr); z_offset = mach_read_from_2(ptr + 2); if (UNIV_UNLIKELY(offset < PAGE_ZIP_START) || UNIV_UNLIKELY(offset >= UNIV_PAGE_SIZE) || UNIV_UNLIKELY(z_offset >= UNIV_PAGE_SIZE)) { corrupt: recv_sys->found_corrupt_log = TRUE; return(NULL); } if (page) { byte* storage_end; byte* field; byte* storage; ulint heap_no; if (UNIV_UNLIKELY(!page_zip) || UNIV_UNLIKELY(page_is_leaf(page))) { goto corrupt; } #ifdef UNIV_ZIP_DEBUG ut_a(page_zip_validate(page_zip, page, NULL)); #endif /* UNIV_ZIP_DEBUG */ field = page + offset; storage = page_zip->data + z_offset; storage_end = page_zip_dir_start(page_zip); heap_no = 1 + (storage_end - storage) / REC_NODE_PTR_SIZE; if (UNIV_UNLIKELY((storage_end - storage) % REC_NODE_PTR_SIZE) || UNIV_UNLIKELY(heap_no < PAGE_HEAP_NO_USER_LOW) || UNIV_UNLIKELY(heap_no >= page_dir_get_n_heap(page))) { goto corrupt; } memcpy(field, ptr + 4, REC_NODE_PTR_SIZE); memcpy(storage, ptr + 4, REC_NODE_PTR_SIZE); #ifdef UNIV_ZIP_DEBUG ut_a(page_zip_validate(page_zip, page, NULL)); #endif /* UNIV_ZIP_DEBUG */ } return(ptr + (2 + 2 + REC_NODE_PTR_SIZE)); } /**********************************************************************//** Write the node pointer of a record on a non-leaf compressed page. */ UNIV_INTERN void page_zip_write_node_ptr( /*====================*/ page_zip_des_t* page_zip,/*!< in/out: compressed page */ byte* rec, /*!< in/out: record */ ulint size, /*!< in: data size of rec */ ulint ptr, /*!< in: node pointer */ mtr_t* mtr) /*!< in: mini-transaction, or NULL */ { byte* field; byte* storage; #ifdef UNIV_DEBUG page_t* page = page_align(rec); #endif /* UNIV_DEBUG */ ut_ad(PAGE_ZIP_MATCH(rec, page_zip)); ut_ad(page_simple_validate_new(page)); ut_ad(page_zip_simple_validate(page_zip)); ut_ad(page_zip_get_size(page_zip) > PAGE_DATA + page_zip_dir_size(page_zip)); ut_ad(page_rec_is_comp(rec)); ut_ad(page_zip->m_start >= PAGE_DATA); ut_ad(page_zip_header_cmp(page_zip, page)); ut_ad(!page_is_leaf(page)); UNIV_MEM_ASSERT_RW(page_zip->data, page_zip_get_size(page_zip)); UNIV_MEM_ASSERT_RW(rec, size); storage = page_zip_dir_start(page_zip) - (rec_get_heap_no_new(rec) - 1) * REC_NODE_PTR_SIZE; field = rec + size - REC_NODE_PTR_SIZE; #if defined UNIV_DEBUG || defined UNIV_ZIP_DEBUG ut_a(!memcmp(storage, field, REC_NODE_PTR_SIZE)); #endif /* UNIV_DEBUG || UNIV_ZIP_DEBUG */ #if REC_NODE_PTR_SIZE != 4 # error "REC_NODE_PTR_SIZE != 4" #endif mach_write_to_4(field, ptr); memcpy(storage, field, REC_NODE_PTR_SIZE); if (mtr) { #ifndef UNIV_HOTBACKUP byte* log_ptr = mlog_open(mtr, 11 + 2 + 2 + REC_NODE_PTR_SIZE); if (UNIV_UNLIKELY(!log_ptr)) { return; } log_ptr = mlog_write_initial_log_record_fast( field, MLOG_ZIP_WRITE_NODE_PTR, log_ptr, mtr); mach_write_to_2(log_ptr, page_offset(field)); log_ptr += 2; mach_write_to_2(log_ptr, storage - page_zip->data); log_ptr += 2; memcpy(log_ptr, field, REC_NODE_PTR_SIZE); log_ptr += REC_NODE_PTR_SIZE; mlog_close(mtr, log_ptr); #endif /* !UNIV_HOTBACKUP */ } } /**********************************************************************//** Write the trx_id and roll_ptr of a record on a B-tree leaf node page. */ UNIV_INTERN void page_zip_write_trx_id_and_roll_ptr( /*===============================*/ page_zip_des_t* page_zip,/*!< in/out: compressed page */ byte* rec, /*!< in/out: record */ const ulint* offsets,/*!< in: rec_get_offsets(rec, index) */ ulint trx_id_col,/*!< in: column number of TRX_ID in rec */ trx_id_t trx_id, /*!< in: transaction identifier */ roll_ptr_t roll_ptr)/*!< in: roll_ptr */ { byte* field; byte* storage; #ifdef UNIV_DEBUG page_t* page = page_align(rec); #endif /* UNIV_DEBUG */ ulint len; ut_ad(PAGE_ZIP_MATCH(rec, page_zip)); ut_ad(page_simple_validate_new(page)); ut_ad(page_zip_simple_validate(page_zip)); ut_ad(page_zip_get_size(page_zip) > PAGE_DATA + page_zip_dir_size(page_zip)); ut_ad(rec_offs_validate(rec, NULL, offsets)); ut_ad(rec_offs_comp(offsets)); ut_ad(page_zip->m_start >= PAGE_DATA); ut_ad(page_zip_header_cmp(page_zip, page)); ut_ad(page_is_leaf(page)); UNIV_MEM_ASSERT_RW(page_zip->data, page_zip_get_size(page_zip)); storage = page_zip_dir_start(page_zip) - (rec_get_heap_no_new(rec) - 1) * (DATA_TRX_ID_LEN + DATA_ROLL_PTR_LEN); #if DATA_TRX_ID + 1 != DATA_ROLL_PTR # error "DATA_TRX_ID + 1 != DATA_ROLL_PTR" #endif field = rec_get_nth_field(rec, offsets, trx_id_col, &len); ut_ad(len == DATA_TRX_ID_LEN); ut_ad(field + DATA_TRX_ID_LEN == rec_get_nth_field(rec, offsets, trx_id_col + 1, &len)); ut_ad(len == DATA_ROLL_PTR_LEN); #if defined UNIV_DEBUG || defined UNIV_ZIP_DEBUG ut_a(!memcmp(storage, field, DATA_TRX_ID_LEN + DATA_ROLL_PTR_LEN)); #endif /* UNIV_DEBUG || UNIV_ZIP_DEBUG */ #if DATA_TRX_ID_LEN != 6 # error "DATA_TRX_ID_LEN != 6" #endif mach_write_to_6(field, trx_id); #if DATA_ROLL_PTR_LEN != 7 # error "DATA_ROLL_PTR_LEN != 7" #endif mach_write_to_7(field + DATA_TRX_ID_LEN, roll_ptr); memcpy(storage, field, DATA_TRX_ID_LEN + DATA_ROLL_PTR_LEN); UNIV_MEM_ASSERT_RW(rec, rec_offs_data_size(offsets)); UNIV_MEM_ASSERT_RW(rec - rec_offs_extra_size(offsets), rec_offs_extra_size(offsets)); UNIV_MEM_ASSERT_RW(page_zip->data, page_zip_get_size(page_zip)); } /**********************************************************************//** Clear an area on the uncompressed and compressed page. Do not clear the data payload, as that would grow the modification log. */ static void page_zip_clear_rec( /*===============*/ page_zip_des_t* page_zip, /*!< in/out: compressed page */ byte* rec, /*!< in: record to clear */ const dict_index_t* index, /*!< in: index of rec */ const ulint* offsets) /*!< in: rec_get_offsets(rec, index) */ { ulint heap_no; page_t* page = page_align(rec); byte* storage; byte* field; ulint len; /* page_zip_validate() would fail here if a record containing externally stored columns is being deleted. */ ut_ad(rec_offs_validate(rec, index, offsets)); ut_ad(!page_zip_dir_find(page_zip, page_offset(rec))); ut_ad(page_zip_dir_find_free(page_zip, page_offset(rec))); ut_ad(page_zip_header_cmp(page_zip, page)); heap_no = rec_get_heap_no_new(rec); ut_ad(heap_no >= PAGE_HEAP_NO_USER_LOW); UNIV_MEM_ASSERT_RW(page_zip->data, page_zip_get_size(page_zip)); UNIV_MEM_ASSERT_RW(rec, rec_offs_data_size(offsets)); UNIV_MEM_ASSERT_RW(rec - rec_offs_extra_size(offsets), rec_offs_extra_size(offsets)); if (!page_is_leaf(page)) { /* Clear node_ptr. On the compressed page, there is an array of node_ptr immediately before the dense page directory, at the very end of the page. */ storage = page_zip_dir_start(page_zip); ut_ad(dict_index_get_n_unique_in_tree(index) == rec_offs_n_fields(offsets) - 1); field = rec_get_nth_field(rec, offsets, rec_offs_n_fields(offsets) - 1, &len); ut_ad(len == REC_NODE_PTR_SIZE); ut_ad(!rec_offs_any_extern(offsets)); memset(field, 0, REC_NODE_PTR_SIZE); memset(storage - (heap_no - 1) * REC_NODE_PTR_SIZE, 0, REC_NODE_PTR_SIZE); } else if (dict_index_is_clust(index)) { /* Clear trx_id and roll_ptr. On the compressed page, there is an array of these fields immediately before the dense page directory, at the very end of the page. */ const ulint trx_id_pos = dict_col_get_clust_pos( dict_table_get_sys_col( index->table, DATA_TRX_ID), index); storage = page_zip_dir_start(page_zip); field = rec_get_nth_field(rec, offsets, trx_id_pos, &len); ut_ad(len == DATA_TRX_ID_LEN); memset(field, 0, DATA_TRX_ID_LEN + DATA_ROLL_PTR_LEN); memset(storage - (heap_no - 1) * (DATA_TRX_ID_LEN + DATA_ROLL_PTR_LEN), 0, DATA_TRX_ID_LEN + DATA_ROLL_PTR_LEN); if (rec_offs_any_extern(offsets)) { ulint i; for (i = rec_offs_n_fields(offsets); i--; ) { /* Clear all BLOB pointers in order to make page_zip_validate() pass. */ if (rec_offs_nth_extern(offsets, i)) { field = rec_get_nth_field( rec, offsets, i, &len); ut_ad(len == BTR_EXTERN_FIELD_REF_SIZE); memset(field + len - BTR_EXTERN_FIELD_REF_SIZE, 0, BTR_EXTERN_FIELD_REF_SIZE); } } } } else { ut_ad(!rec_offs_any_extern(offsets)); } #ifdef UNIV_ZIP_DEBUG ut_a(page_zip_validate(page_zip, page, index)); #endif /* UNIV_ZIP_DEBUG */ } /**********************************************************************//** Write the "deleted" flag of a record on a compressed page. The flag must already have been written on the uncompressed page. */ UNIV_INTERN void page_zip_rec_set_deleted( /*=====================*/ page_zip_des_t* page_zip,/*!< in/out: compressed page */ const byte* rec, /*!< in: record on the uncompressed page */ ulint flag) /*!< in: the deleted flag (nonzero=TRUE) */ { byte* slot = page_zip_dir_find(page_zip, page_offset(rec)); ut_a(slot); UNIV_MEM_ASSERT_RW(page_zip->data, page_zip_get_size(page_zip)); if (flag) { *slot |= (PAGE_ZIP_DIR_SLOT_DEL >> 8); } else { *slot &= ~(PAGE_ZIP_DIR_SLOT_DEL >> 8); } #ifdef UNIV_ZIP_DEBUG ut_a(page_zip_validate(page_zip, page_align(rec), NULL)); #endif /* UNIV_ZIP_DEBUG */ } /**********************************************************************//** Write the "owned" flag of a record on a compressed page. The n_owned field must already have been written on the uncompressed page. */ UNIV_INTERN void page_zip_rec_set_owned( /*===================*/ page_zip_des_t* page_zip,/*!< in/out: compressed page */ const byte* rec, /*!< in: record on the uncompressed page */ ulint flag) /*!< in: the owned flag (nonzero=TRUE) */ { byte* slot = page_zip_dir_find(page_zip, page_offset(rec)); ut_a(slot); UNIV_MEM_ASSERT_RW(page_zip->data, page_zip_get_size(page_zip)); if (flag) { *slot |= (PAGE_ZIP_DIR_SLOT_OWNED >> 8); } else { *slot &= ~(PAGE_ZIP_DIR_SLOT_OWNED >> 8); } } /**********************************************************************//** Insert a record to the dense page directory. */ UNIV_INTERN void page_zip_dir_insert( /*================*/ page_zip_des_t* page_zip,/*!< in/out: compressed page */ const byte* prev_rec,/*!< in: record after which to insert */ const byte* free_rec,/*!< in: record from which rec was allocated, or NULL */ byte* rec) /*!< in: record to insert */ { ulint n_dense; byte* slot_rec; byte* slot_free; ut_ad(prev_rec != rec); ut_ad(page_rec_get_next((rec_t*) prev_rec) == rec); ut_ad(page_zip_simple_validate(page_zip)); UNIV_MEM_ASSERT_RW(page_zip->data, page_zip_get_size(page_zip)); if (page_rec_is_infimum(prev_rec)) { /* Use the first slot. */ slot_rec = page_zip->data + page_zip_get_size(page_zip); } else { byte* end = page_zip->data + page_zip_get_size(page_zip); byte* start = end - page_zip_dir_user_size(page_zip); if (UNIV_LIKELY(!free_rec)) { /* PAGE_N_RECS was already incremented in page_cur_insert_rec_zip(), but the dense directory slot at that position contains garbage. Skip it. */ start += PAGE_ZIP_DIR_SLOT_SIZE; } slot_rec = page_zip_dir_find_low(start, end, page_offset(prev_rec)); ut_a(slot_rec); } /* Read the old n_dense (n_heap may have been incremented). */ n_dense = page_dir_get_n_heap(page_zip->data) - (PAGE_HEAP_NO_USER_LOW + 1); if (UNIV_LIKELY_NULL(free_rec)) { /* The record was allocated from the free list. Shift the dense directory only up to that slot. Note that in this case, n_dense is actually off by one, because page_cur_insert_rec_zip() did not increment n_heap. */ ut_ad(rec_get_heap_no_new(rec) < n_dense + 1 + PAGE_HEAP_NO_USER_LOW); ut_ad(rec >= free_rec); slot_free = page_zip_dir_find(page_zip, page_offset(free_rec)); ut_ad(slot_free); slot_free += PAGE_ZIP_DIR_SLOT_SIZE; } else { /* The record was allocated from the heap. Shift the entire dense directory. */ ut_ad(rec_get_heap_no_new(rec) == n_dense + PAGE_HEAP_NO_USER_LOW); /* Shift to the end of the dense page directory. */ slot_free = page_zip->data + page_zip_get_size(page_zip) - PAGE_ZIP_DIR_SLOT_SIZE * n_dense; } /* Shift the dense directory to allocate place for rec. */ memmove(slot_free - PAGE_ZIP_DIR_SLOT_SIZE, slot_free, slot_rec - slot_free); /* Write the entry for the inserted record. The "owned" and "deleted" flags must be zero. */ mach_write_to_2(slot_rec - PAGE_ZIP_DIR_SLOT_SIZE, page_offset(rec)); } /**********************************************************************//** Shift the dense page directory and the array of BLOB pointers when a record is deleted. */ UNIV_INTERN void page_zip_dir_delete( /*================*/ page_zip_des_t* page_zip, /*!< in/out: compressed page */ byte* rec, /*!< in: deleted record */ const dict_index_t* index, /*!< in: index of rec */ const ulint* offsets, /*!< in: rec_get_offsets(rec) */ const byte* free) /*!< in: previous start of the free list */ { byte* slot_rec; byte* slot_free; ulint n_ext; page_t* page = page_align(rec); ut_ad(rec_offs_validate(rec, index, offsets)); ut_ad(rec_offs_comp(offsets)); UNIV_MEM_ASSERT_RW(page_zip->data, page_zip_get_size(page_zip)); UNIV_MEM_ASSERT_RW(rec, rec_offs_data_size(offsets)); UNIV_MEM_ASSERT_RW(rec - rec_offs_extra_size(offsets), rec_offs_extra_size(offsets)); slot_rec = page_zip_dir_find(page_zip, page_offset(rec)); ut_a(slot_rec); /* This could not be done before page_zip_dir_find(). */ page_header_set_field(page, page_zip, PAGE_N_RECS, (ulint)(page_get_n_recs(page) - 1)); if (UNIV_UNLIKELY(!free)) { /* Make the last slot the start of the free list. */ slot_free = page_zip->data + page_zip_get_size(page_zip) - PAGE_ZIP_DIR_SLOT_SIZE * (page_dir_get_n_heap(page_zip->data) - PAGE_HEAP_NO_USER_LOW); } else { slot_free = page_zip_dir_find_free(page_zip, page_offset(free)); ut_a(slot_free < slot_rec); /* Grow the free list by one slot by moving the start. */ slot_free += PAGE_ZIP_DIR_SLOT_SIZE; } if (UNIV_LIKELY(slot_rec > slot_free)) { memmove(slot_free + PAGE_ZIP_DIR_SLOT_SIZE, slot_free, slot_rec - slot_free); } /* Write the entry for the deleted record. The "owned" and "deleted" flags will be cleared. */ mach_write_to_2(slot_free, page_offset(rec)); if (!page_is_leaf(page) || !dict_index_is_clust(index)) { ut_ad(!rec_offs_any_extern(offsets)); goto skip_blobs; } n_ext = rec_offs_n_extern(offsets); if (UNIV_UNLIKELY(n_ext)) { /* Shift and zero fill the array of BLOB pointers. */ ulint blob_no; byte* externs; byte* ext_end; blob_no = page_zip_get_n_prev_extern(page_zip, rec, index); ut_a(blob_no + n_ext <= page_zip->n_blobs); externs = page_zip->data + page_zip_get_size(page_zip) - (page_dir_get_n_heap(page) - PAGE_HEAP_NO_USER_LOW) * (PAGE_ZIP_DIR_SLOT_SIZE + DATA_TRX_ID_LEN + DATA_ROLL_PTR_LEN); ext_end = externs - page_zip->n_blobs * BTR_EXTERN_FIELD_REF_SIZE; externs -= blob_no * BTR_EXTERN_FIELD_REF_SIZE; page_zip->n_blobs -= static_cast<unsigned>(n_ext); /* Shift and zero fill the array. */ memmove(ext_end + n_ext * BTR_EXTERN_FIELD_REF_SIZE, ext_end, (page_zip->n_blobs - blob_no) * BTR_EXTERN_FIELD_REF_SIZE); memset(ext_end, 0, n_ext * BTR_EXTERN_FIELD_REF_SIZE); } skip_blobs: /* The compression algorithm expects info_bits and n_owned to be 0 for deleted records. */ rec[-REC_N_NEW_EXTRA_BYTES] = 0; /* info_bits and n_owned */ page_zip_clear_rec(page_zip, rec, index, offsets); } /**********************************************************************//** Add a slot to the dense page directory. */ UNIV_INTERN void page_zip_dir_add_slot( /*==================*/ page_zip_des_t* page_zip, /*!< in/out: compressed page */ ulint is_clustered) /*!< in: nonzero for clustered index, zero for others */ { ulint n_dense; byte* dir; byte* stored; ut_ad(page_is_comp(page_zip->data)); UNIV_MEM_ASSERT_RW(page_zip->data, page_zip_get_size(page_zip)); /* Read the old n_dense (n_heap has already been incremented). */ n_dense = page_dir_get_n_heap(page_zip->data) - (PAGE_HEAP_NO_USER_LOW + 1); dir = page_zip->data + page_zip_get_size(page_zip) - PAGE_ZIP_DIR_SLOT_SIZE * n_dense; if (!page_is_leaf(page_zip->data)) { ut_ad(!page_zip->n_blobs); stored = dir - n_dense * REC_NODE_PTR_SIZE; } else if (is_clustered) { /* Move the BLOB pointer array backwards to make space for the roll_ptr and trx_id columns and the dense directory slot. */ byte* externs; stored = dir - n_dense * (DATA_TRX_ID_LEN + DATA_ROLL_PTR_LEN); externs = stored - page_zip->n_blobs * BTR_EXTERN_FIELD_REF_SIZE; ASSERT_ZERO(externs - (PAGE_ZIP_DIR_SLOT_SIZE + DATA_TRX_ID_LEN + DATA_ROLL_PTR_LEN), PAGE_ZIP_DIR_SLOT_SIZE + DATA_TRX_ID_LEN + DATA_ROLL_PTR_LEN); memmove(externs - (PAGE_ZIP_DIR_SLOT_SIZE + DATA_TRX_ID_LEN + DATA_ROLL_PTR_LEN), externs, stored - externs); } else { stored = dir - page_zip->n_blobs * BTR_EXTERN_FIELD_REF_SIZE; ASSERT_ZERO(stored - PAGE_ZIP_DIR_SLOT_SIZE, PAGE_ZIP_DIR_SLOT_SIZE); } /* Move the uncompressed area backwards to make space for one directory slot. */ memmove(stored - PAGE_ZIP_DIR_SLOT_SIZE, stored, dir - stored); } /***********************************************************//** Parses a log record of writing to the header of a page. @return end of log record or NULL */ UNIV_INTERN byte* page_zip_parse_write_header( /*========================*/ byte* ptr, /*!< in: redo log buffer */ byte* end_ptr,/*!< in: redo log buffer end */ page_t* page, /*!< in/out: uncompressed page */ page_zip_des_t* page_zip)/*!< in/out: compressed page */ { ulint offset; ulint len; ut_ad(ptr && end_ptr); ut_ad(!page == !page_zip); if (UNIV_UNLIKELY(end_ptr < ptr + (1 + 1))) { return(NULL); } offset = (ulint) *ptr++; len = (ulint) *ptr++; if (UNIV_UNLIKELY(!len) || UNIV_UNLIKELY(offset + len >= PAGE_DATA)) { corrupt: recv_sys->found_corrupt_log = TRUE; return(NULL); } if (UNIV_UNLIKELY(end_ptr < ptr + len)) { return(NULL); } if (page) { if (UNIV_UNLIKELY(!page_zip)) { goto corrupt; } #ifdef UNIV_ZIP_DEBUG ut_a(page_zip_validate(page_zip, page, NULL)); #endif /* UNIV_ZIP_DEBUG */ memcpy(page + offset, ptr, len); memcpy(page_zip->data + offset, ptr, len); #ifdef UNIV_ZIP_DEBUG ut_a(page_zip_validate(page_zip, page, NULL)); #endif /* UNIV_ZIP_DEBUG */ } return(ptr + len); } #ifndef UNIV_HOTBACKUP /**********************************************************************//** Write a log record of writing to the uncompressed header portion of a page. */ UNIV_INTERN void page_zip_write_header_log( /*======================*/ const byte* data, /*!< in: data on the uncompressed page */ ulint length, /*!< in: length of the data */ mtr_t* mtr) /*!< in: mini-transaction */ { byte* log_ptr = mlog_open(mtr, 11 + 1 + 1); ulint offset = page_offset(data); ut_ad(offset < PAGE_DATA); ut_ad(offset + length < PAGE_DATA); #if PAGE_DATA > 255 # error "PAGE_DATA > 255" #endif ut_ad(length < 256); /* If no logging is requested, we may return now */ if (UNIV_UNLIKELY(!log_ptr)) { return; } log_ptr = mlog_write_initial_log_record_fast( (byte*) data, MLOG_ZIP_WRITE_HEADER, log_ptr, mtr); *log_ptr++ = (byte) offset; *log_ptr++ = (byte) length; mlog_close(mtr, log_ptr); mlog_catenate_string(mtr, data, length); } #endif /* !UNIV_HOTBACKUP */ /**********************************************************************//** Reorganize and compress a page. This is a low-level operation for compressed pages, to be used when page_zip_compress() fails. On success, a redo log entry MLOG_ZIP_PAGE_COMPRESS will be written. The function btr_page_reorganize() should be preferred whenever possible. IMPORTANT: if page_zip_reorganize() is invoked on a leaf page of a non-clustered index, the caller must update the insert buffer free bits in the same mini-transaction in such a way that the modification will be redo-logged. @return TRUE on success, FALSE on failure; page_zip will be left intact on failure, but page will be overwritten. */ UNIV_INTERN ibool page_zip_reorganize( /*================*/ buf_block_t* block, /*!< in/out: page with compressed page; on the compressed page, in: size; out: data, n_blobs, m_start, m_end, m_nonempty */ dict_index_t* index, /*!< in: index of the B-tree node */ mtr_t* mtr) /*!< in: mini-transaction */ { #ifndef UNIV_HOTBACKUP buf_pool_t* buf_pool = buf_pool_from_block(block); #endif /* !UNIV_HOTBACKUP */ page_zip_des_t* page_zip = buf_block_get_page_zip(block); page_t* page = buf_block_get_frame(block); buf_block_t* temp_block; page_t* temp_page; ulint log_mode; ut_ad(mtr_memo_contains(mtr, block, MTR_MEMO_PAGE_X_FIX)); ut_ad(page_is_comp(page)); ut_ad(!dict_index_is_ibuf(index)); /* Note that page_zip_validate(page_zip, page, index) may fail here. */ UNIV_MEM_ASSERT_RW(page, UNIV_PAGE_SIZE); UNIV_MEM_ASSERT_RW(page_zip->data, page_zip_get_size(page_zip)); /* Disable logging */ log_mode = mtr_set_log_mode(mtr, MTR_LOG_NONE); #ifndef UNIV_HOTBACKUP temp_block = buf_block_alloc(buf_pool); btr_search_drop_page_hash_index(block); block->check_index_page_at_flush = TRUE; #else /* !UNIV_HOTBACKUP */ ut_ad(block == back_block1); temp_block = back_block2; #endif /* !UNIV_HOTBACKUP */ temp_page = temp_block->frame; /* Copy the old page to temporary space */ buf_frame_copy(temp_page, page); btr_blob_dbg_remove(page, index, "zip_reorg"); /* Recreate the page: note that global data on page (possible segment headers, next page-field, etc.) is preserved intact */ page_create(block, mtr, TRUE); /* Copy the records from the temporary space to the recreated page; do not copy the lock bits yet */ page_copy_rec_list_end_no_locks(block, temp_block, page_get_infimum_rec(temp_page), index, mtr); if (!dict_index_is_clust(index) && page_is_leaf(temp_page)) { /* Copy max trx id to recreated page */ trx_id_t max_trx_id = page_get_max_trx_id(temp_page); page_set_max_trx_id(block, NULL, max_trx_id, NULL); ut_ad(max_trx_id != 0); } /* Restore logging. */ mtr_set_log_mode(mtr, log_mode); if (!page_zip_compress(page_zip, page, index, page_zip_compression_flags, mtr)) { #ifndef UNIV_HOTBACKUP buf_block_free(temp_block); #endif /* !UNIV_HOTBACKUP */ return(FALSE); } lock_move_reorganize_page(block, temp_block); #ifndef UNIV_HOTBACKUP buf_block_free(temp_block); #endif /* !UNIV_HOTBACKUP */ return(TRUE); } #ifndef UNIV_HOTBACKUP /**********************************************************************//** Copy the records of a page byte for byte. Do not copy the page header or trailer, except those B-tree header fields that are directly related to the storage of records. Also copy PAGE_MAX_TRX_ID. NOTE: The caller must update the lock table and the adaptive hash index. */ UNIV_INTERN void page_zip_copy_recs( /*===============*/ page_zip_des_t* page_zip, /*!< out: copy of src_zip (n_blobs, m_start, m_end, m_nonempty, data[0..size-1]) */ page_t* page, /*!< out: copy of src */ const page_zip_des_t* src_zip, /*!< in: compressed page */ const page_t* src, /*!< in: page */ dict_index_t* index, /*!< in: index of the B-tree */ mtr_t* mtr) /*!< in: mini-transaction */ { ut_ad(mtr_memo_contains_page(mtr, page, MTR_MEMO_PAGE_X_FIX)); ut_ad(mtr_memo_contains_page(mtr, src, MTR_MEMO_PAGE_X_FIX)); ut_ad(!dict_index_is_ibuf(index)); #ifdef UNIV_ZIP_DEBUG /* The B-tree operations that call this function may set FIL_PAGE_PREV or PAGE_LEVEL, causing a temporary min_rec_flag mismatch. A strict page_zip_validate() will be executed later during the B-tree operations. */ ut_a(page_zip_validate_low(src_zip, src, index, TRUE)); #endif /* UNIV_ZIP_DEBUG */ ut_a(page_zip_get_size(page_zip) == page_zip_get_size(src_zip)); if (UNIV_UNLIKELY(src_zip->n_blobs)) { ut_a(page_is_leaf(src)); ut_a(dict_index_is_clust(index)); } /* The PAGE_MAX_TRX_ID must be set on leaf pages of secondary indexes. It does not matter on other pages. */ ut_a(dict_index_is_clust(index) || !page_is_leaf(src) || page_get_max_trx_id(src)); UNIV_MEM_ASSERT_W(page, UNIV_PAGE_SIZE); UNIV_MEM_ASSERT_W(page_zip->data, page_zip_get_size(page_zip)); UNIV_MEM_ASSERT_RW(src, UNIV_PAGE_SIZE); UNIV_MEM_ASSERT_RW(src_zip->data, page_zip_get_size(page_zip)); /* Copy those B-tree page header fields that are related to the records stored in the page. Also copy the field PAGE_MAX_TRX_ID. Skip the rest of the page header and trailer. On the compressed page, there is no trailer. */ #if PAGE_MAX_TRX_ID + 8 != PAGE_HEADER_PRIV_END # error "PAGE_MAX_TRX_ID + 8 != PAGE_HEADER_PRIV_END" #endif memcpy(PAGE_HEADER + page, PAGE_HEADER + src, PAGE_HEADER_PRIV_END); memcpy(PAGE_DATA + page, PAGE_DATA + src, UNIV_PAGE_SIZE - PAGE_DATA - FIL_PAGE_DATA_END); memcpy(PAGE_HEADER + page_zip->data, PAGE_HEADER + src_zip->data, PAGE_HEADER_PRIV_END); memcpy(PAGE_DATA + page_zip->data, PAGE_DATA + src_zip->data, page_zip_get_size(page_zip) - PAGE_DATA); /* Copy all fields of src_zip to page_zip, except the pointer to the compressed data page. */ { page_zip_t* data = page_zip->data; memcpy(page_zip, src_zip, sizeof *page_zip); page_zip->data = data; } ut_ad(page_zip_get_trailer_len(page_zip, dict_index_is_clust(index)) + page_zip->m_end < page_zip_get_size(page_zip)); if (!page_is_leaf(src) && UNIV_UNLIKELY(mach_read_from_4(src + FIL_PAGE_PREV) == FIL_NULL) && UNIV_LIKELY(mach_read_from_4(page + FIL_PAGE_PREV) != FIL_NULL)) { /* Clear the REC_INFO_MIN_REC_FLAG of the first user record. */ ulint offs = rec_get_next_offs(page + PAGE_NEW_INFIMUM, TRUE); if (UNIV_LIKELY(offs != PAGE_NEW_SUPREMUM)) { rec_t* rec = page + offs; ut_a(rec[-REC_N_NEW_EXTRA_BYTES] & REC_INFO_MIN_REC_FLAG); rec[-REC_N_NEW_EXTRA_BYTES] &= ~ REC_INFO_MIN_REC_FLAG; } } #ifdef UNIV_ZIP_DEBUG ut_a(page_zip_validate(page_zip, page, index)); #endif /* UNIV_ZIP_DEBUG */ btr_blob_dbg_add(page, index, "page_zip_copy_recs"); page_zip_compress_write_log(page_zip, page, index, mtr); } #endif /* !UNIV_HOTBACKUP */ /**********************************************************************//** Parses a log record of compressing an index page. @return end of log record or NULL */ UNIV_INTERN byte* page_zip_parse_compress( /*====================*/ byte* ptr, /*!< in: buffer */ byte* end_ptr,/*!< in: buffer end */ page_t* page, /*!< out: uncompressed page */ page_zip_des_t* page_zip)/*!< out: compressed page */ { ulint size; ulint trailer_size; ut_ad(ptr && end_ptr); ut_ad(!page == !page_zip); if (UNIV_UNLIKELY(ptr + (2 + 2) > end_ptr)) { return(NULL); } size = mach_read_from_2(ptr); ptr += 2; trailer_size = mach_read_from_2(ptr); ptr += 2; if (UNIV_UNLIKELY(ptr + 8 + size + trailer_size > end_ptr)) { return(NULL); } if (page) { if (UNIV_UNLIKELY(!page_zip) || UNIV_UNLIKELY(page_zip_get_size(page_zip) < size)) { corrupt: recv_sys->found_corrupt_log = TRUE; return(NULL); } memcpy(page_zip->data + FIL_PAGE_PREV, ptr, 4); memcpy(page_zip->data + FIL_PAGE_NEXT, ptr + 4, 4); memcpy(page_zip->data + FIL_PAGE_TYPE, ptr + 8, size); memset(page_zip->data + FIL_PAGE_TYPE + size, 0, page_zip_get_size(page_zip) - trailer_size - (FIL_PAGE_TYPE + size)); memcpy(page_zip->data + page_zip_get_size(page_zip) - trailer_size, ptr + 8 + size, trailer_size); if (UNIV_UNLIKELY(!page_zip_decompress(page_zip, page, TRUE))) { goto corrupt; } } return(ptr + 8 + size + trailer_size); } /**********************************************************************//** Calculate the compressed page checksum. @return page checksum */ UNIV_INTERN ulint page_zip_calc_checksum( /*===================*/ const void* data, /*!< in: compressed page */ ulint size, /*!< in: size of compressed page */ srv_checksum_algorithm_t algo) /*!< in: algorithm to use */ { uLong adler; ib_uint32_t crc32; const Bytef* s = static_cast<const byte*>(data); /* Exclude FIL_PAGE_SPACE_OR_CHKSUM, FIL_PAGE_LSN, and FIL_PAGE_FILE_FLUSH_LSN from the checksum. */ switch (algo) { case SRV_CHECKSUM_ALGORITHM_CRC32: case SRV_CHECKSUM_ALGORITHM_STRICT_CRC32: ut_ad(size > FIL_PAGE_ARCH_LOG_NO_OR_SPACE_ID); crc32 = ut_crc32(s + FIL_PAGE_OFFSET, FIL_PAGE_LSN - FIL_PAGE_OFFSET) ^ ut_crc32(s + FIL_PAGE_TYPE, 2) ^ ut_crc32(s + FIL_PAGE_ARCH_LOG_NO_OR_SPACE_ID, size - FIL_PAGE_ARCH_LOG_NO_OR_SPACE_ID); return((ulint) crc32); case SRV_CHECKSUM_ALGORITHM_INNODB: case SRV_CHECKSUM_ALGORITHM_STRICT_INNODB: ut_ad(size > FIL_PAGE_ARCH_LOG_NO_OR_SPACE_ID); adler = adler32(0L, s + FIL_PAGE_OFFSET, FIL_PAGE_LSN - FIL_PAGE_OFFSET); adler = adler32(adler, s + FIL_PAGE_TYPE, 2); adler = adler32( adler, s + FIL_PAGE_ARCH_LOG_NO_OR_SPACE_ID, static_cast<uInt>(size) - FIL_PAGE_ARCH_LOG_NO_OR_SPACE_ID); return((ulint) adler); case SRV_CHECKSUM_ALGORITHM_NONE: case SRV_CHECKSUM_ALGORITHM_STRICT_NONE: return(BUF_NO_CHECKSUM_MAGIC); /* no default so the compiler will emit a warning if new enum is added and not handled here */ } ut_error; return(0); } /**********************************************************************//** Verify a compressed page's checksum. @return TRUE if the stored checksum is valid according to the value of innodb_checksum_algorithm */ UNIV_INTERN ibool page_zip_verify_checksum( /*=====================*/ const void* data, /*!< in: compressed page */ ulint size) /*!< in: size of compressed page */ { ib_uint32_t stored; ib_uint32_t calc; ib_uint32_t crc32 = 0 /* silence bogus warning */; ib_uint32_t innodb = 0 /* silence bogus warning */; stored = static_cast<ib_uint32_t>(mach_read_from_4( static_cast<const unsigned char*>(data) + FIL_PAGE_SPACE_OR_CHKSUM)); /* declare empty pages non-corrupted */ if (stored == 0) { /* make sure that the page is really empty */ ulint i; for (i = 0; i < size; i++) { if (*((const char*) data + i) != 0) { return(FALSE); } } return(TRUE); } calc = static_cast<ib_uint32_t>(page_zip_calc_checksum( data, size, static_cast<srv_checksum_algorithm_t>( srv_checksum_algorithm))); if (stored == calc) { return(TRUE); } switch ((srv_checksum_algorithm_t) srv_checksum_algorithm) { case SRV_CHECKSUM_ALGORITHM_STRICT_CRC32: case SRV_CHECKSUM_ALGORITHM_STRICT_INNODB: case SRV_CHECKSUM_ALGORITHM_STRICT_NONE: return(stored == calc); case SRV_CHECKSUM_ALGORITHM_CRC32: if (stored == BUF_NO_CHECKSUM_MAGIC) { return(TRUE); } crc32 = calc; innodb = static_cast<ib_uint32_t>(page_zip_calc_checksum( data, size, SRV_CHECKSUM_ALGORITHM_INNODB)); break; case SRV_CHECKSUM_ALGORITHM_INNODB: if (stored == BUF_NO_CHECKSUM_MAGIC) { return(TRUE); } crc32 = static_cast<ib_uint32_t>(page_zip_calc_checksum( data, size, SRV_CHECKSUM_ALGORITHM_CRC32)); innodb = calc; break; case SRV_CHECKSUM_ALGORITHM_NONE: return(TRUE); /* no default so the compiler will emit a warning if new enum is added and not handled here */ } return(stored == crc32 || stored == innodb); }
laurynas-biveinis/webscalesql-5.6
storage/innobase/page/page0zip.cc
C++
gpl-2.0
146,875
/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ package pe.edu.upeu.modelo; import java.io.Serializable; import java.util.Collection; import java.util.Date; import javax.persistence.Basic; import javax.persistence.CascadeType; import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.GeneratedValue; import javax.persistence.GenerationType; import javax.persistence.Id; import javax.persistence.JoinColumn; import javax.persistence.ManyToOne; import javax.persistence.NamedQueries; import javax.persistence.NamedQuery; import javax.persistence.OneToMany; import javax.persistence.Table; import javax.persistence.Temporal; import javax.persistence.TemporalType; import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlTransient; /** * * @author hp */ @Entity @Table(name = "conf_periodo") @XmlRootElement @NamedQueries({ @NamedQuery(name = "ConfPeriodo.findAll", query = "SELECT c FROM ConfPeriodo c")}) public class ConfPeriodo implements Serializable { private static final long serialVersionUID = 1L; @Id @GeneratedValue(strategy = GenerationType.IDENTITY) @Basic(optional = false) @Column(name = "id_periodo") private Integer idPeriodo; @Basic(optional = false) @Column(name = "periodo") private String periodo; @Basic(optional = false) @Column(name = "descripcion") private String descripcion; @Basic(optional = false) @Column(name = "fecha_inicio") @Temporal(TemporalType.DATE) private Date fechaInicio; @Basic(optional = false) @Column(name = "fecha_fin") @Temporal(TemporalType.DATE) private Date fechaFin; @Basic(optional = false) @Column(name = "estado") private String estado; @OneToMany(cascade = CascadeType.ALL, mappedBy = "idPeriodo") private Collection<GloAreaEje> gloAreaEjeCollection; @OneToMany(cascade = CascadeType.ALL, mappedBy = "idPeriodo") private Collection<GloEstadoArea> gloEstadoAreaCollection; @OneToMany(cascade = CascadeType.ALL, mappedBy = "idPeriodo") private Collection<GloEstadoDepartamento> gloEstadoDepartamentoCollection; @OneToMany(cascade = CascadeType.ALL, mappedBy = "idPeriodo") private Collection<GloEstadoFilial> gloEstadoFilialCollection; @OneToMany(cascade = CascadeType.ALL, mappedBy = "idPeriodo") private Collection<GloDepartCoordinador> gloDepartCoordinadorCollection; @OneToMany(cascade = CascadeType.ALL, mappedBy = "idPeriodo") private Collection<GloMeta> gloMetaCollection; @OneToMany(cascade = CascadeType.ALL, mappedBy = "idPeriodo") private Collection<GloDepartareaCoordinador> gloDepartareaCoordinadorCollection; @OneToMany(cascade = CascadeType.ALL, mappedBy = "idPeriodo") private Collection<FinPartidapresupuestaria> finPartidapresupuestariaCollection; @JoinColumn(name = "id_temporada", referencedColumnName = "id_temporada") @ManyToOne(optional = false) private ConfTemporada idTemporada; public ConfPeriodo() { } public ConfPeriodo(Integer idPeriodo) { this.idPeriodo = idPeriodo; } public ConfPeriodo(Integer idPeriodo, String periodo, String descripcion, Date fechaInicio, Date fechaFin, String estado) { this.idPeriodo = idPeriodo; this.periodo = periodo; this.descripcion = descripcion; this.fechaInicio = fechaInicio; this.fechaFin = fechaFin; this.estado = estado; } public Integer getIdPeriodo() { return idPeriodo; } public void setIdPeriodo(Integer idPeriodo) { this.idPeriodo = idPeriodo; } public String getPeriodo() { return periodo; } public void setPeriodo(String periodo) { this.periodo = periodo; } public String getDescripcion() { return descripcion; } public void setDescripcion(String descripcion) { this.descripcion = descripcion; } public Date getFechaInicio() { return fechaInicio; } public void setFechaInicio(Date fechaInicio) { this.fechaInicio = fechaInicio; } public Date getFechaFin() { return fechaFin; } public void setFechaFin(Date fechaFin) { this.fechaFin = fechaFin; } public String getEstado() { return estado; } public void setEstado(String estado) { this.estado = estado; } @XmlTransient public Collection<GloAreaEje> getGloAreaEjeCollection() { return gloAreaEjeCollection; } public void setGloAreaEjeCollection(Collection<GloAreaEje> gloAreaEjeCollection) { this.gloAreaEjeCollection = gloAreaEjeCollection; } @XmlTransient public Collection<GloEstadoArea> getGloEstadoAreaCollection() { return gloEstadoAreaCollection; } public void setGloEstadoAreaCollection(Collection<GloEstadoArea> gloEstadoAreaCollection) { this.gloEstadoAreaCollection = gloEstadoAreaCollection; } @XmlTransient public Collection<GloEstadoDepartamento> getGloEstadoDepartamentoCollection() { return gloEstadoDepartamentoCollection; } public void setGloEstadoDepartamentoCollection(Collection<GloEstadoDepartamento> gloEstadoDepartamentoCollection) { this.gloEstadoDepartamentoCollection = gloEstadoDepartamentoCollection; } @XmlTransient public Collection<GloEstadoFilial> getGloEstadoFilialCollection() { return gloEstadoFilialCollection; } public void setGloEstadoFilialCollection(Collection<GloEstadoFilial> gloEstadoFilialCollection) { this.gloEstadoFilialCollection = gloEstadoFilialCollection; } @XmlTransient public Collection<GloDepartCoordinador> getGloDepartCoordinadorCollection() { return gloDepartCoordinadorCollection; } public void setGloDepartCoordinadorCollection(Collection<GloDepartCoordinador> gloDepartCoordinadorCollection) { this.gloDepartCoordinadorCollection = gloDepartCoordinadorCollection; } @XmlTransient public Collection<GloMeta> getGloMetaCollection() { return gloMetaCollection; } public void setGloMetaCollection(Collection<GloMeta> gloMetaCollection) { this.gloMetaCollection = gloMetaCollection; } @XmlTransient public Collection<GloDepartareaCoordinador> getGloDepartareaCoordinadorCollection() { return gloDepartareaCoordinadorCollection; } public void setGloDepartareaCoordinadorCollection(Collection<GloDepartareaCoordinador> gloDepartareaCoordinadorCollection) { this.gloDepartareaCoordinadorCollection = gloDepartareaCoordinadorCollection; } @XmlTransient public Collection<FinPartidapresupuestaria> getFinPartidapresupuestariaCollection() { return finPartidapresupuestariaCollection; } public void setFinPartidapresupuestariaCollection(Collection<FinPartidapresupuestaria> finPartidapresupuestariaCollection) { this.finPartidapresupuestariaCollection = finPartidapresupuestariaCollection; } public ConfTemporada getIdTemporada() { return idTemporada; } public void setIdTemporada(ConfTemporada idTemporada) { this.idTemporada = idTemporada; } @Override public int hashCode() { int hash = 0; hash += (idPeriodo != null ? idPeriodo.hashCode() : 0); return hash; } @Override public boolean equals(Object object) { // TODO: Warning - this method won't work in the case the id fields are not set if (!(object instanceof ConfPeriodo)) { return false; } ConfPeriodo other = (ConfPeriodo) object; if ((this.idPeriodo == null && other.idPeriodo != null) || (this.idPeriodo != null && !this.idPeriodo.equals(other.idPeriodo))) { return false; } return true; } @Override public String toString() { return "pe.edu.upeu.modelo.ConfPeriodo[ idPeriodo=" + idPeriodo + " ]"; } }
AngieChambi/ProFinal
WebSgeUPeU/src/java/pe/edu/upeu/modelo/ConfPeriodo.java
Java
gpl-2.0
8,395
package com.atlach.trafficdataloader; import java.util.ArrayList; /* Short Desc: Storage object for Trip info */ /* Trip Info > Trips > Routes */ public class TripInfo { private int tripCount = 0; public ArrayList<Trip> trips = null; public String date; public String origin; public String destination; public TripInfo() { trips = new ArrayList<Trip>(); } public int addTrip() { Trip temp = new Trip(); if (trips.add(temp) == false) { /* Failed */ return -1; } tripCount++; return trips.indexOf(temp); } public int addRouteToTrip(int tripId, String routeName, String mode, String dist, String agency, String start, String end, String points) { int result = -1; Trip temp = trips.get(tripId); if (temp != null) { result = temp.addRoute(routeName, mode, dist, agency, start, end, points); } return result; } public int getTripCount() { return tripCount; } public static class Trip { public double totalDist = 0.0; public double totalCost = 0.0; public int totalTraffic = 0; private int transfers = 0; public ArrayList<Route> routes = null; public Trip() { routes = new ArrayList<Route>(); }; public int addRoute(String routeName, String mode, String dist, String agency, String start, String end, String points) { Route temp = new Route(); temp.name = routeName; temp.mode = mode; temp.dist = dist; temp.agency = agency; temp.start = start; temp.end = end; temp.points = points; if (routes.add(temp) == false) { /* Failed */ return -1; } transfers++; return routes.indexOf(temp); } public int getTransfers() { return transfers; } } public static class Route { /* Object fields */ public String name = ""; public String mode = ""; public String dist = "0.0"; public String agency = ""; public String start = ""; public String end = ""; public String points = ""; public String cond = ""; //public String cost = "0.0"; public double costMatrix[] = {0.0, 0.0, 0.0, 0.0}; public double getRegularCost(boolean isDiscounted) { if (isDiscounted) { return costMatrix[1]; } return costMatrix[0]; } public double getSpecialCost(boolean isDiscounted) { if (isDiscounted) { return costMatrix[2]; } return costMatrix[3]; } } }
linusmotu/Viaje
ViajeUi/src/com/atlach/trafficdataloader/TripInfo.java
Java
gpl-2.0
2,363
package org.adastraeducation.liquiz.equation; import java.util.*; import java.util.regex.*; import org.adastraeducation.liquiz.*; /** * Present equations with random variables. * It has two ways to parse the equations in string[]. One is in infix, and the other is in the RPN. * @author Yingzhu Wang * */ public class Equation implements Displayable { private Expression func; private double correctAnswer; private HashMap<String,Var> variables; public Equation(String equation, HashMap<String,Var> variables){ this.variables=variables; ArrayList<String> equationSplit = this.parseQuestion(equation); this.func = this.parseInfix(equationSplit); correctAnswer = func.eval(); } public Equation(Expression func, HashMap<String,Var> variables){ this.func = func; this.variables = variables; correctAnswer=func.eval(); } public Equation(Expression func){ this.func = func; this.variables = new HashMap<String,Var>(); correctAnswer=func.eval(); } public void setExpression(Expression e){ this.func=e; correctAnswer=func.eval(); } public void setVariables(HashMap<String,Var> variables){ this.variables = variables; } public String getTagName() { return "Equation"; } public Expression parseInfix(ArrayList<String> s){ Tree t = new Tree(s); ArrayList<String> rpn = t.traverse(); return parseRPN(rpn); } // Precompile all regular expressions used in parsing private static final Pattern parseDigits = Pattern.compile("^[0-9]+$"); private static final Pattern wordPattern = Pattern.compile("[\\W]|([\\w]*)"); /*TODO: We can do much better than a switch statement, * but it would require a hash map and lots of little objects */ //TODO: Check if binary ops are backgwards? a b - ???? public Expression parseRPN(ArrayList<String> s) { Stack<Expression> stack = new Stack<Expression>(); for(int i = 0; i<s.size(); i++){ String temp = s.get(i); if (Functions.MATHFUNCTIONS.contains(temp)) { Expression op1 ; Expression op2 ; switch(temp){ case "+": op2=stack.pop(); op1=stack.pop(); stack.push(new Plus(op1,op2)); break; case "-": op2=stack.pop(); op1=stack.pop(); stack.push( new Minus(op1,op2)); break; case "*": op2=stack.pop(); op1=stack.pop(); stack.push( new Multi(op1,op2));break; case "/": op2=stack.pop(); op1=stack.pop(); stack.push( new Div(op1,op2));break; case "sin": op1=stack.pop(); stack.push(new Sin(op1));break; case "cos": op1=stack.pop(); stack.push(new Cos(op1));break; case "tan": op1=stack.pop(); stack.push(new Tan(op1));break; case "abs": op1=stack.pop(); stack.push(new Abs(op1));break; case "Asin": op1=stack.pop(); stack.push(new Asin(op1));break; case "Atan": op1=stack.pop(); stack.push(new Atan(op1));break; case "neg": op1=stack.pop(); stack.push(new Neg(op1));break; case "sqrt": op1=stack.pop(); stack.push(new Sqrt(op1));break; default:break; } } //deal with the space else if(temp.equals("")) ; else{ Matcher m = parseDigits.matcher(temp); if (m.matches()){ double x = Double.parseDouble(temp); stack.push(new Constant(x)); } else{ stack.push(variables.get(temp)); } } } return stack.pop(); } public ArrayList<String> parseQuestion(String question){ ArrayList<String> s = new ArrayList<String>(); Matcher m = wordPattern.matcher(question); while(m.find()){ s.add(m.group()); } return s; } // public ResultSet readDatabase(String sql){ // return DatabaseMgr.select(sql); // } // // public void writeDatabase(String sql){ // DatabaseMgr.update(sql); // } public Expression getExpression(){ return func; } public double getCorrectAnswer(){ return correctAnswer; } @Override public void writeHTML(StringBuilder b) { func.infixReplaceVar(b); } @Override public void writeXML(StringBuilder b) { b.append("<Equation question='"); func.infix(b); b.append("'></Equation>"); } @Override public void writeJS(StringBuilder b) { } }
hydrodog/LiquiZ
LiquiZ/src/org/adastraeducation/liquiz/equation/Equation.java
Java
gpl-2.0
4,219
package com.github.luksdlt92; import java.util.ArrayList; /* * DoubleJumpReload plugin * Made by luksdlt92 and Abdalion */ import org.bukkit.event.Listener; import org.bukkit.plugin.java.JavaPlugin; import com.github.luksdlt92.commands.DoubleJumpCommand; import com.github.luksdlt92.listeners.JumpListener; public class DoubleJumpReload extends JavaPlugin implements Listener { public ArrayList<String> _players = new ArrayList<String>(); public ArrayList<String> _playersDisableJump = new ArrayList<String>(); @Override public void onEnable() { new JumpListener(this); this.getCommand("jumpdelay").setExecutor(new DoubleJumpCommand(this)); } public ArrayList<String> getPlayers() { return _players; } public ArrayList<String> getPlayersDisableJump() { return _playersDisableJump; } }
luksdlt92/doublejumpreload
DoubleJumpReload/src/main/java/com/github/luksdlt92/DoubleJumpReload.java
Java
gpl-2.0
871
package org.vidogram.messenger.g.a; import java.io.ByteArrayOutputStream; public class j extends ByteArrayOutputStream { private final b a; public j(b paramb, int paramInt) { this.a = paramb; this.buf = this.a.a(Math.max(paramInt, 256)); } private void a(int paramInt) { if (this.count + paramInt <= this.buf.length) return; byte[] arrayOfByte = this.a.a((this.count + paramInt) * 2); System.arraycopy(this.buf, 0, arrayOfByte, 0, this.count); this.a.a(this.buf); this.buf = arrayOfByte; } public void close() { this.a.a(this.buf); this.buf = null; super.close(); } public void finalize() { this.a.a(this.buf); } public void write(int paramInt) { monitorenter; try { a(1); super.write(paramInt); monitorexit; return; } finally { localObject = finally; monitorexit; } throw localObject; } public void write(byte[] paramArrayOfByte, int paramInt1, int paramInt2) { monitorenter; try { a(paramInt2); super.write(paramArrayOfByte, paramInt1, paramInt2); monitorexit; return; } finally { paramArrayOfByte = finally; monitorexit; } throw paramArrayOfByte; } } /* Location: G:\programs\dex2jar-2.0\vidogram-dex2jar.jar * Qualified Name: org.vidogram.messenger.g.a.j * JD-Core Version: 0.6.0 */
Robert0Trebor/robert
TMessagesProj/src/main/java/org/vidogram/messenger/g/a/j.java
Java
gpl-2.0
1,439
using UnityEngine; using System.Collections; /* * Item to handle movements of rigibodies */ public class RigibodyMoveItem : MoveItem { public enum Type { ENEMY_SHIP_TYPE_1, LASER_RED, LASER_BLUE }; public static RigibodyMoveItem create(Type type) { switch (type) { case Type.ENEMY_SHIP_TYPE_1: return new EnemyShip1MoveItem(); case Type.LASER_RED: return new LaserRedMoveItem(); case Type.LASER_BLUE: return new LaserBlueMoveItem(); default: throw new System.ArgumentException("Incorrect RigibodyMoveItem.Type " + type.ToString()); } } }
adriwankenobi/space
Assets/Scripts/Level/Non Playable/Movement/Rigibody/RigibodyMoveItem.cs
C#
gpl-2.0
620
#ifndef __EDIV_QGRAPHICS_H_ #define __EDIV_QGRAPHICS_H_ #include "export.h" /* Flags de modos de video */ #define _FULLSCREEN 0x01 typedef struct { byte* buffer; // invisible buffer byte* colormap; // 256 * VID_GRADES size byte* alphamap; // 256 * 256 translucency map int width; int height; int bpp; int flags; } viddef_t; viddef_t vid; #endif /* __EDIV_QGRAPHICS_H_ */
vroman/edivc
dlls/src/qgraphics/qgraphics.h
C
gpl-2.0
434
package it.polito.nexa.pc; import com.hp.hpl.jena.rdf.model.Model; import com.hp.hpl.jena.rdf.model.Statement; import java.util.List; /** * Created by giuseppe on 19/05/15. */ public interface TriplesAdder { public Model addTriples(Model model, List<Statement> statementList); }
giuseppefutia/rdf-public-contracts
src/main/java/it/polito/nexa/pc/TriplesAdder.java
Java
gpl-2.0
290
/** * @file mqueue.h * * This file contains the definitions related to POSIX Message Queues. */ /* * COPYRIGHT (c) 1989-2011. * On-Line Applications Research Corporation (OAR). * * The license and distribution terms for this file may be * found in the file LICENSE in this distribution or at * http://www.rtems.com/license/LICENSE. */ #ifndef _MQUEUE_H #define _MQUEUE_H #include <unistd.h> #if defined(_POSIX_MESSAGE_PASSING) #include <sys/types.h> #include <rtems/system.h> #include <rtems/score/object.h> #ifdef __cplusplus extern "C" { #endif /* * 15.1.1 Data Structures, P1003.1b-1993, p. 271 */ /** * Message queue id type. * * @note Use uint32_t since all POSIX Ids are 32-bit currently. */ typedef uint32_t mqd_t; /** * This is the message queue attributes structure. */ struct mq_attr { /** This is the message queue flags */ long mq_flags; /** This is the maximum number of messages */ long mq_maxmsg; /** This is the maximum message size */ long mq_msgsize; /** This is the mumber of messages currently queued */ long mq_curmsgs; }; /** * 15.2.2 Open a Message Queue, P1003.1b-1993, p. 272 */ mqd_t mq_open( const char *name, int oflag, ... ); /** * 15.2.2 Close a Message Queue, P1003.1b-1993, p. 275 */ int mq_close( mqd_t mqdes ); /** * 15.2.2 Remove a Message Queue, P1003.1b-1993, p. 276 */ int mq_unlink( const char *name ); /** * 15.2.4 Send a Message to a Message Queue, P1003.1b-1993, p. 277 * * @note P1003.4b/D8, p. 45 adds mq_timedsend(). */ int mq_send( mqd_t mqdes, const char *msg_ptr, size_t msg_len, unsigned int msg_prio ); #if defined(_POSIX_TIMEOUTS) #include <time.h> int mq_timedsend( mqd_t mqdes, const char *msg_ptr, size_t msg_len, unsigned int msg_prio, const struct timespec *abstime ); #endif /* _POSIX_TIMEOUTS */ /* * 15.2.5 Receive a Message From a Message Queue, P1003.1b-1993, p. 279 * * NOTE: P1003.4b/D8, p. 45 adds mq_timedreceive(). */ ssize_t mq_receive( mqd_t mqdes, char *msg_ptr, size_t msg_len, unsigned int *msg_prio ); #if defined(_POSIX_TIMEOUTS) ssize_t mq_timedreceive( mqd_t mqdes, char *msg_ptr, size_t msg_len, unsigned int *msg_prio, const struct timespec *abstime ); #endif /* _POSIX_TIMEOUTS */ #if defined(_POSIX_REALTIME_SIGNALS) /* * 15.2.6 Notify Process that a Message is Available on a Queue, * P1003.1b-1993, p. 280 */ int mq_notify( mqd_t mqdes, const struct sigevent *notification ); #endif /* _POSIX_REALTIME_SIGNALS */ /* * 15.2.7 Set Message Queue Attributes, P1003.1b-1993, p. 281 */ int mq_setattr( mqd_t mqdes, const struct mq_attr *mqstat, struct mq_attr *omqstat ); /* * 15.2.8 Get Message Queue Attributes, P1003.1b-1993, p. 283 */ int mq_getattr( mqd_t mqdes, struct mq_attr *mqstat ); #ifdef __cplusplus } #endif #endif /* _POSIX_MESSAGE_PASSING */ #endif /* end of include file */
yangxi/omap4m3
cpukit/posix/include/mqueue.h
C
gpl-2.0
3,161
/* shades of grey */ /*@g1 : #5A6568;*/ /* b&w */ /* color specific to a player */ /*@id-color: #78BDE7;*/ /* fonts */ /* variable heights */ /*@player-controls-height:20px;*/ /* transistions */ .ez-trans { -webkit-transition: all 0.2s ease-in-out; -o-transition: all 0.2s ease-in-out; transition: all 0.2s ease-in-out; } /* effects */ .bs-none { -webkit-box-shadow: none; -moz-box-shadow: none; box-shadow: none; } #now-playing { height: 35px; color: #43464b; padding: 7px; } #now-playing::before { content: "now playing : "; color: #878a8f; } /* global */ html, body { height: 100%; } *:focus { outline: none; } body { background-color: #fff; margin-top: 0; margin-bottom: 0; font-family: "Lato", Helvetica, Arial, sans-serif; color: #262b2c; } iframe { border-style: none; } a { color: #262b2c; background-color: #65686d; } a:hover { color: white; background-color: #878a8f; } .container { width: 100%; height: 100%; padding-left: 0px; padding-right: 0px; } .glyphicon { margin-right: 4px; } /* popup */ .popup { position: relative; background: #65686d; padding: 20px; width: auto; max-width: 500px; margin: 20px auto; } .popup .btn { height: 35px; border-radius: 0; border-style: none; background-color: #878a8f; } .popup .btn:hover { background-color: #cbced3; } .popup .selected, .popup .selected:hover { color: white; background-color: #babd3c; } .popup .ti-container { margin-top: 20px; margin-bottom: 15px; } .popup .form-control { height: 40px; font-size: 18px; border-radius: 0; } .popup .delete-sco-message { margin-bottom: 15px; } /* header */ #player-head { height: 100px; background-color: #65686d; position: fixed; width: 100%; z-index: 1000; } .player-name { font-size: 65px; padding-left: 20px; padding-right: 20px; display: inline-block; /*width:100%;*/ height: 100%; background-color: #43464b; color: #dcdf5e; } .player-ip { position: absolute; left: 5px; bottom: 0px; color: #babd3c; } /* nav bar */ .navbar { position: fixed; top: 100px; /*min-height:@navbar-height;*/ margin-bottom: 0px; border-style: none; -webkit-box-shadow: 0 2px 3px 0 rgba(0, 0, 0, 0.2); -moz-box-shadow: 0 2px 3px 0 rgba(0, 0, 0, 0.2); box-shadow: 0 2px 3px 0 rgba(0, 0, 0, 0.2); } .navbar li, .navbar a { font-size: 18px; line-height: 1; -webkit-transition: all 0.2s ease-in-out; -o-transition: all 0.2s ease-in-out; transition: all 0.2s ease-in-out; } .navbar .nav-pills > li.active > a, .navbar .nav-pills > li.active > a:hover, .navbar .nav-pills > li.active > a:focus { color: white; background-color: #babd3c; } .navbar .nav-pills > li > a { height: 60px; padding-top: 21px; border-style: none; border-radius: 0; } /* tool bar */ .toolbar { /*line-height:@toolbar-height;*/ background: #cbced3; } .toolbar .row { margin: 0; } .toolbar .btn { height: 35px; border-radius: 0; border-style: none; background-color: #878a8f; } .toolbar .btn:hover { background-color: #cbced3; } .toolbar .caret { position: absolute; right: 10px; top: 17.5px; } .toolbar .dropdown-menu { border-radius: 0; border-style: none; width: 100%; margin: 0px; padding: 0px 0; max-height: 350px; overflow-y: scroll; -webkit-box-shadow: 0 2px 3px 0 rgba(0, 0, 0, 0.2); -moz-box-shadow: 0 2px 3px 0 rgba(0, 0, 0, 0.2); box-shadow: 0 2px 3px 0 rgba(0, 0, 0, 0.2); } .toolbar .dropdown-menu li a { background-color: #cbced3; } .toolbar .dropdown-menu li a:hover { background-color: #878a8f; } .toolbar .dropdown-menu li .divider { margin: 0px; background-color: #878a8f; } .toolbar .btn-warning { background-color: #dcdf5e; } .toolbar .btn-warning:focus { background-color: #babd3c; } /* progress-bar */ .progress-container { padding: 0px 10px; height: 32px; } .progress { margin-top: 8.5px; border-radius: 15px; height: 15px; } .progress-bar { background-color: #babd3c; -webkit-box-shadow: none; -moz-box-shadow: none; box-shadow: none; } /* media list */ .media-list table { margin: 0; height: 100%; } .media-list thead, .media-list tbody, .media-list tr, .media-list td, .media-list th { display: block; border-style: none; } .media-list tr:after { content: ' '; display: block; visibility: hidden; clear: both; } .media-list thead th { height: 40px; } .media-list tbody { height: calc(100% - 40px); overflow-y: auto; background-color: #cbced3; } .media-list thead { background-color: #cbced3; border-bottom-style: dashed; border-bottom-width: 1px; border-bottom-color: #878a8f; } .media-list tbody td, .media-list thead th { width: 25%; float: left; } .media-list .table-striped > tbody > tr:nth-child(odd) { background-color: #dcdfe4; } .media-list .table-striped > tbody > tr:nth-child(even) { background-color: #cbced3; } .media-list .table-striped > tbody > tr:last-child { -webkit-box-shadow: 0 2px 3px 0 rgba(0, 0, 0, 0.2); -moz-box-shadow: 0 2px 3px 0 rgba(0, 0, 0, 0.2); box-shadow: 0 2px 3px 0 rgba(0, 0, 0, 0.2); } .media-list .table-hover > tbody > tr:hover { background-color: #878a8f; color: white; } /* content section */ .content-section { background-color: #43464b; margin-top: 160px; height: calc(100% - 160px); } #scenario-section { overflow: hidden; /*height: calc(~"100% - "@player-head-height + @navbar-height + @toolbar-height);*/ } #blockly-frame-container { height: calc(100% - 35px); } #blockly-iframe { width: 100%; height: 100%; } #controls-section { /*height:calc(~"100% - "@player-head-height + @navbar-height + @toolbar-height);*/ } #controls-section .panel-group { height: 100%; margin-bottom: 0; background-color: #43464b; } #controls-section .panel { -webkit-box-shadow: none; -moz-box-shadow: none; box-shadow: none; border-style: none; border-radius: 0; margin-top: 0; } #controls-section .panel .panel-heading { height: 50px; -webkit-box-shadow: 0 2px 3px 0 rgba(0, 0, 0, 0.2); -moz-box-shadow: 0 2px 3px 0 rgba(0, 0, 0, 0.2); box-shadow: 0 2px 3px 0 rgba(0, 0, 0, 0.2); position: relative; color: #262b2c; background-color: #878a8f; border-radius: 0; padding: 0; } #controls-section .panel .panel-heading .panel-title > a { position: absolute; width: 100%; padding-left: 10px; text-decoration: none; background-color: #878a8f; line-height: 50px; } #controls-section .panel .panel-heading .panel-title > a:hover, #controls-section .panel .panel-heading .panel-title > a:focus { background-color: #65686d; color: white; } #controls-section .panel .panel-body { padding: 0; height: 100%; background-color: #cbced3; } #controls-section #media-player { overflow: hidden !important; } #controls-section #media-player .media-list { height: calc(100% - 34px); /* table { margin:0; height:100%; } thead, tbody, tr, td, th { display: block; border-style: none; } tr:after { content: ' '; display: block; visibility: hidden; clear: both; } thead th { height:@player-controls-th-height; } tbody { height: calc(~"100% - "@player-controls-th-height); overflow-y: auto; background-color: @g1-ppp; } thead { background-color: @g1-ppp; border-bottom-style: dashed; border-bottom-width:1px; border-bottom-color: @g1-pp; } tbody td, thead th { width: 25%; float: left; } .table-striped { > tbody > tr:nth-child(odd) { background-color: @g1-ppp+#111; } > tbody > tr:nth-child(even) { background-color: @g1-ppp; } > tbody > tr:last-child { .ds(0,2px,3px,0,0.2); } } .table-hover { > tbody > tr:hover { background-color: @g1-pp; color:@w; } }*/ } #controls-section #media-player #player-controls { width: 100%; height: 35px; background-color: #dcdfe4; border-top-style: dashed; border-top-width: 1px; border-top-color: #878a8f; } #controls-section #media-player #player-controls .btn-default { background-color: #cbced3; } #controls-section #media-player #player-controls .btn-default:hover { background-color: #878a8f; color: white; } #controls-section #media-player #player-controls .btn-warning { background-color: #dcdf5e; } #controls-section #media-player #player-controls .btn-warning:hover { background-color: #babd3c; } #controls-section #media-player #player-controls .slider-container { padding: 0px 10px; } #controls-section #media-player #player-controls .slider-container #volume-sli { margin-top: 8.5px; margin-bottom: 0; } #controls-section #media-player #player-controls .slider-container .ui-slider-range { background-color: #babd3c; } #controls-section #media-player #player-controls .slider-container .ui-slider-handle { background-color: #dcdf5e; } #controls-section #sensors #sensor-left-menu { height: 100%; } #controls-section #sensors #sensor-left-menu ul { height: 100%; border-style: none; padding: 0; } #controls-section #sensors #sensor-left-menu li { margin-bottom: 0; height: 33.33333333%; width: 100%; } #controls-section #sensors #sensor-left-menu a, #controls-section #sensors #sensor-left-menu a:hover, #controls-section #sensors #sensor-left-menu a:focus { border-style: none; border-radius: 0; height: 100%; /*line-height:200%;*/ text-align: center; } #controls-section #sensors #sensor-panes-container { background-color: #cbced3; height: 100%; } #controls-section #network #lonely-container { display: -webkit-flex; display: flex; height: 300px; } #controls-section #network #lonely { margin: auto; font-size: 4rem; } #media-section { background-color: #43464b; /*height:100%;*/ } #media-section #media-controls { -webkit-box-shadow: 0 2px 3px 0 rgba(0, 0, 0, 0.2); -moz-box-shadow: 0 2px 3px 0 rgba(0, 0, 0, 0.2); box-shadow: 0 2px 3px 0 rgba(0, 0, 0, 0.2); position: fixed; width: 100%; z-index: 1000; } #media-section .media-zone { height: 260px; padding: 40px; text-align: center; } #media-section .media-list { height: calc(100% - 60px); } #media-section #upload-zone, #media-section #upload-zone * { box-sizing: border-box; } #media-section #upload-zone { position: relative; } #media-section #upload-message { opacity: 0.15; font-size: 124px; color: #222; text-shadow: 0px 2px 3px #555; position: absolute; top: 60px; left: 50%; margin-left: -224px; } #media-section #upload-zone .dz-preview { position: relative; display: inline-block; width: 120px; margin: 0.5em; } #media-section #upload-zone .dz-preview .dz-progress { display: block; height: 15px; border: 1px solid #aaa; } #media-section #upload-zone .dz-preview .dz-progress .dz-upload { display: block; height: 100%; width: 0; background: #babd3c; } #media-section #upload-zone .dz-preview .dz-error-message { color: red; display: none; } #media-section #upload-zone .dz-preview.dz-error .dz-error-message, #media-section #upload-zone .dz-preview.dz-error .dz-error-mark { display: block; } #media-section #upload-zone .dz-preview.dz-success .dz-success-mark { display: block; } #media-section #upload-zone .dz-preview .dz-error-mark, #media-section #upload-zone .dz-preview .dz-success-mark { position: absolute; display: none; left: 30px; top: 30px; width: 54px; height: 58px; left: 50%; margin-left: -27px; } /*# sourceMappingURL=style.css.map */ /*# sourceMappingURL=style.css.map */
erasme/griotte
w/static/css/style.css
CSS
gpl-2.0
11,557
<!DOCTYPE html> <html lang="en-US"> <!-- Mirrored from www.w3schools.com/tags/tryit.asp?filename=tryhtml_img_border_css by HTTrack Website Copier/3.x [XR&CO'2014], Fri, 23 Jan 2015 08:23:38 GMT --> <head> <title>Tryit Editor v2.3</title> <meta id="viewport" name='viewport'> <script> (function() { if ( navigator.userAgent.match(/iPad/i) ) { document.getElementById('viewport').setAttribute("content", "width=device-width, initial-scale=0.9"); } }()); </script> <link rel="stylesheet" href="../trycss.css"> <!--[if lt IE 8]> <style> .textareacontainer, .iframecontainer {width:48%;} .textarea, .iframe {height:800px;} #textareaCode, #iframeResult {height:700px;} .menu img {display:none;} </style> <![endif]--> <script> (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){ (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o), m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m) })(window,document,'script','../../www.google-analytics.com/analytics.js','ga'); ga('create', 'UA-3855518-1', 'auto'); ga('require', 'displayfeatures'); ga('send', 'pageview'); </script> <script> var googletag = googletag || {}; googletag.cmd = googletag.cmd || []; (function() { var gads = document.createElement('script'); gads.async = true; gads.type = 'text/javascript'; var useSSL = 'https:' == document.location.protocol; gads.src = (useSSL ? 'https:' : 'http:') + '//www.googletagservices.com/tag/js/gpt.js'; var node = document.getElementsByTagName('script')[0]; node.parentNode.insertBefore(gads, node); })(); </script> <script> googletag.cmd.push(function() { googletag.defineSlot('/16833175/TryitLeaderboard', [[728, 90], [970, 90]], 'div-gpt-ad-1383036313516-0').addService(googletag.pubads()); googletag.pubads().setTargeting("content","trytags"); googletag.pubads().enableSingleRequest(); googletag.enableServices(); }); </script> <script type="text/javascript"> function submitTryit() { var t=document.getElementById("textareaCode").value; t=t.replace(/=/gi,"w3equalsign"); var pos=t.search(/script/i) while (pos>0) { t=t.substring(0,pos) + "w3" + t.substr(pos,3) + "w3" + t.substr(pos+3,3) + "tag" + t.substr(pos+6); pos=t.search(/script/i); } if ( navigator.userAgent.match(/Safari/i) ) { t=escape(t); document.getElementById("bt").value="1"; } document.getElementById("code").value=t; document.getElementById("tryitform").action="tryit_view52a0.html?x=" + Math.random(); validateForm(); document.getElementById("iframeResult").contentWindow.name = "view"; document.getElementById("tryitform").submit(); } function validateForm() { var code=document.getElementById("code").value; if (code.length>8000) { document.getElementById("code").value="<h1>Error</h1>"; } } </script> <style> </style> </head> <body> <div id="ads"> <div style="position:relative;width:100%;margin-top:0px;margin-bottom:0px;"> <div style="width:974px;height:94px;position:relative;margin:0px;margin-top:5px;margin-bottom:5px;margin-right:auto;margin-left:auto;padding:0px;overflow:hidden;"> <!-- TryitLeaderboard --> <div id='div-gpt-ad-1383036313516-0' style='width:970px; height:90px;'> <script type='text/javascript'> googletag.cmd.push(function() { googletag.display('div-gpt-ad-1383036313516-0'); }); </script> </div> <div style="clear:both"></div> </div> </div> </div> <div class="container"> <div class="textareacontainer"> <div class="textarea"> <div class="headerText" style="width:auto;float:left;">Edit This Code:</div> <div class="headerBtnDiv" style="width:auto;float:right;margin-top:8px;margin-right:2.4%;"><button class="submit" type="button" onclick="submitTryit()">See Result &raquo;</button></div> <div class="textareawrapper"> <textarea autocomplete="off" class="code_input" id="textareaCode" wrap="logical" xrows="30" xcols="50"><!DOCTYPE html> <html> <body> <img src="smiley.gif" alt="Smiley face" width="42" height="42" style="border:5px solid black"> </body> <!-- Mirrored from www.w3schools.com/tags/tryit.asp?filename=tryhtml_img_border_css by HTTrack Website Copier/3.x [XR&CO'2014], Fri, 23 Jan 2015 08:23:38 GMT --> </html> </textarea> <form autocomplete="off" style="margin:0px;display:none;" action="http://www.w3schools.com/tags/tryit_view.asp" method="post" target="view" id="tryitform" name="tryitform" onsubmit="validateForm();"> <input type="hidden" name="code" id="code" /> <input type="hidden" id="bt" name="bt" /> </form> </div> </div> </div> <div class="iframecontainer"> <div class="iframe"> <div class="headerText resultHeader">Result:</div> <div class="iframewrapper"> <iframe id="iframeResult" class="result_output" frameborder="0" name="view" xsrc="tryhtml_img_border_css.html"></iframe> </div> <div class="footerText">Try it Yourself - &copy; <a href="../index.html">w3schools.com</a></div> </div> </div> </div> <script>submitTryit()</script> </body> </html>
platinhom/ManualHom
Coding/W3School/W3Schools_Offline_2015/www.w3schools.com/tags/tryit0da5.html
HTML
gpl-2.0
5,065
using UnityEngine; using System.Collections; public class ButtonNextImage : MonoBehaviour { public GameObject nextImage; public bool lastImage; public string nextScene = ""; void OnMouseDown() { if(lastImage) { Application.LoadLevel(nextScene); return; } gameObject.SetActive (false); nextImage.SetActive (true); } }
aindong/RobberGame
Assets/Scripts/Helpers/ButtonNextImage.cs
C#
gpl-2.0
347
/** * Created by LPAC006013 on 23/11/14. */ /* * wiring Super fish to menu */ var sfvar = jQuery('div.menu'); var phoneSize = 600; jQuery(document).ready(function($) { //if screen size is bigger than phone's screen (Tablet,Desktop) if($(document).width() >= phoneSize) { // enable superfish sfvar.superfish({ delay: 500, speed: 'slow' }); jQuery("#menu-main-menu").addClass('clear'); var containerheight = jQuery("#menu-main-menu").height(); jQuery("#menu-main-menu").children().css("height",containerheight); } $(window).resize(function() { if($(document).width() >= phoneSize && !sfvar.hasClass('sf-js-enabled')) { sfvar.superfish({ delay: 500, speed: 'slow' }); } // phoneSize, disable superfish else if($(document).width() < phoneSize) { sfvar.superfish('destroy'); } }); });
dejanmarkovic/topcat-final
js/global.js
JavaScript
gpl-2.0
994
<?php /** * Multisite upgrade administration panel. * * @package WordPress * @subpackage Multisite * @since 3.0.0 */ /** Load WordPress Administration Bootstrap */ require_once(dirname(__FILE__) . '/admin.php'); if (!is_multisite()) wp_die(__('Multisite support is not enabled.')); require_once(ABSPATH . WPINC . '/http.php'); $title = __('Upgrade Network'); $parent_file = 'upgrade.php'; get_current_screen()->add_help_tab(array( 'id' => 'overview', 'title' => __('Overview'), 'content' => '<p>' . __('Only use this screen once you have updated to a new version of WordPress through Updates/Available Updates (via the Network Administration navigation menu or the Toolbar). Clicking the Upgrade Network button will step through each site in the network, five at a time, and make sure any database updates are applied.') . '</p>' . '<p>' . __('If a version update to core has not happened, clicking this button won&#8217;t affect anything.') . '</p>' . '<p>' . __('If this process fails for any reason, users logging in to their sites will force the same update.') . '</p>' )); get_current_screen()->set_help_sidebar( '<p><strong>' . __('For more information:') . '</strong></p>' . '<p>' . __('<a href="http://codex.wordpress.org/Network_Admin_Updates_Screen" target="_blank">Documentation on Upgrade Network</a>') . '</p>' . '<p>' . __('<a href="https://wordpress.org/support/" target="_blank">Support Forums</a>') . '</p>' ); require_once(ABSPATH . 'wp-admin/admin-header.php'); if (!current_user_can('manage_network')) wp_die(__('You do not have permission to access this page.')); echo '<div class="wrap">'; echo '<h2>' . __('Upgrade Network') . '</h2>'; $action = isset($_GET['action']) ? $_GET['action'] : 'show'; switch ($action) { case "upgrade": $n = (isset($_GET['n'])) ? intval($_GET['n']) : 0; if ($n < 5) { global $wp_db_version; update_site_option('wpmu_upgrade_site', $wp_db_version); } $blogs = $wpdb->get_results("SELECT blog_id FROM {$wpdb->blogs} WHERE site_id = '{$wpdb->siteid}' AND spam = '0' AND deleted = '0' AND archived = '0' ORDER BY registered DESC LIMIT {$n}, 5", ARRAY_A); if (empty($blogs)) { echo '<p>' . __('All done!') . '</p>'; break; } echo "<ul>"; foreach ((array)$blogs as $details) { switch_to_blog($details['blog_id']); $siteurl = site_url(); $upgrade_url = admin_url('upgrade.php?step=upgrade_db'); restore_current_blog(); echo "<li>$siteurl</li>"; $response = wp_remote_get($upgrade_url, array('timeout' => 120, 'httpversion' => '1.1')); if (is_wp_error($response)) wp_die(sprintf(__('Warning! Problem updating %1$s. Your server may not be able to connect to sites running on it. Error message: <em>%2$s</em>'), $siteurl, $response->get_error_message())); /** * Fires after the Multisite DB upgrade for each site is complete. * * @since MU * * @param array|WP_Error $response The upgrade response array or WP_Error on failure. */ do_action('after_mu_upgrade', $response); /** * Fires after each site has been upgraded. * * @since MU * * @param int $blog_id The id of the blog. */ do_action('wpmu_upgrade_site', $details['blog_id']); } echo "</ul>"; ?><p><?php _e('If your browser doesn&#8217;t start loading the next page automatically, click this link:'); ?> <a class="button" href="upgrade.php?action=upgrade&amp;n=<?php echo($n + 5) ?>"><?php _e("Next Sites"); ?></a> </p> <script type="text/javascript"> <!-- function nextpage() { location.href = "upgrade.php?action=upgrade&n=<?php echo ($n + 5) ?>"; } setTimeout("nextpage()", 250); //--> </script><?php break; case 'show': default: if (get_site_option('wpmu_upgrade_site') != $GLOBALS['wp_db_version']) : ?> <h3><?php _e('Database Upgrade Required'); ?></h3> <p><?php _e('WordPress has been updated! Before we send you on your way, we need to individually upgrade the sites in your network.'); ?></p> <?php endif; ?> <p><?php _e('The database upgrade process may take a little while, so please be patient.'); ?></p> <p><a class="button" href="upgrade.php?action=upgrade"><?php _e('Upgrade Network'); ?></a></p> <?php /** * Fires before the footer on the network upgrade screen. * * @since MU */ do_action('wpmu_upgrade_page'); break; } ?> </div> <?php include(ABSPATH . 'wp-admin/admin-footer.php'); ?>
JeremyCarlsten/WordpressWork
wp-admin/network/upgrade.php
PHP
gpl-2.0
4,987
<?xml version="1.0" encoding="utf-8"?> <rss version="2.0" xml:base="http://machines.plannedobsolescence.net/51-2008" xmlns:dc="http://purl.org/dc/elements/1.1/"> <channel> <title>intro to digital media studies - symbiosis</title> <link>http://machines.plannedobsolescence.net/51-2008/taxonomy/term/120/0</link> <description></description> <language>en</language> <item> <title>reading response 5</title> <link>http://machines.plannedobsolescence.net/51-2008/node/92</link> <description>&lt;p&gt;Both Nelson and Licklider saw it extremely fit for the relationship of man and computer to drastically become more interdependent on each other. Nelson speaks of the EFL and machines like that described by V.Bush(memex), where the computer will have all the information that one would ever need, all at a desk, and Licklider envisioned men to by this day and age have been even more dependent on computers and not only restricted to desks and office areas.&lt;/p&gt; &lt;p&gt;&lt;a href=&quot;http://machines.plannedobsolescence.net/51-2008/node/92&quot;&gt;read more&lt;/a&gt;&lt;/p&gt;</description> <comments>http://machines.plannedobsolescence.net/51-2008/node/92#comments</comments> <category domain="http://machines.plannedobsolescence.net/51-2008/taxonomy/term/122">computer</category> <category domain="http://machines.plannedobsolescence.net/51-2008/taxonomy/term/121">man</category> <category domain="http://machines.plannedobsolescence.net/51-2008/taxonomy/term/120">symbiosis</category> <pubDate>Sun, 17 Feb 2008 19:30:48 +0000</pubDate> <dc:creator>bungbang</dc:creator> <guid isPermaLink="false">92 at http://machines.plannedobsolescence.net/51-2008</guid> </item> </channel> </rss>
kfitz/machines
51-2008/taxonomy/term/120/0/feed/index.html
HTML
gpl-2.0
1,706
<html> <head> <link rel="stylesheet" href="../extjs/resources/css/ext-all.css" type="text/css" /> <script type="text/javascript" src="../extjs/ext-all.js"></script> <script type="text/javascript" src="sample.js"></script> </head> <body> </body> </html>
xhrist14n/sencha_extjs_samples
01_sample/sample.html
HTML
gpl-2.0
269
#!/usr/bin/ruby -w class T_002aac < Test def description return "mkvmerge / audio only / in(AAC)" end def run merge("data/simple/v.aac", 1) return hash_tmp end end
nmaier/mkvtoolnix
tests/test-002aac.rb
Ruby
gpl-2.0
186
// © 2016 and later: Unicode, Inc. and others. // License & terms of use: http://www.unicode.org/copyright.html // // file: rbbirb.cpp // // Copyright (C) 2002-2011, International Business Machines Corporation and others. // All Rights Reserved. // // This file contains the RBBIRuleBuilder class implementation. This is the main class for // building (compiling) break rules into the tables required by the runtime // RBBI engine. // #include "unicode/utypes.h" #if !UCONFIG_NO_BREAK_ITERATION #include "unicode/brkiter.h" #include "unicode/rbbi.h" #include "unicode/ubrk.h" #include "unicode/unistr.h" #include "unicode/uniset.h" #include "unicode/uchar.h" #include "unicode/uchriter.h" #include "unicode/parsepos.h" #include "unicode/parseerr.h" #include "cmemory.h" #include "cstring.h" #include "rbbirb.h" #include "rbbinode.h" #include "rbbiscan.h" #include "rbbisetb.h" #include "rbbitblb.h" #include "rbbidata.h" #include "uassert.h" U_NAMESPACE_BEGIN //---------------------------------------------------------------------------------------- // // Constructor. // //---------------------------------------------------------------------------------------- RBBIRuleBuilder::RBBIRuleBuilder(const UnicodeString &rules, UParseError *parseErr, UErrorCode &status) : fRules(rules), fStrippedRules(rules) { fStatus = &status; // status is checked below fParseError = parseErr; fDebugEnv = NULL; #ifdef RBBI_DEBUG fDebugEnv = getenv("U_RBBIDEBUG"); #endif fForwardTree = NULL; fReverseTree = NULL; fSafeFwdTree = NULL; fSafeRevTree = NULL; fDefaultTree = &fForwardTree; fForwardTable = NULL; fRuleStatusVals = NULL; fChainRules = FALSE; fLBCMNoChain = FALSE; fLookAheadHardBreak = FALSE; fUSetNodes = NULL; fRuleStatusVals = NULL; fScanner = NULL; fSetBuilder = NULL; if (parseErr) { uprv_memset(parseErr, 0, sizeof(UParseError)); } if (U_FAILURE(status)) { return; } fUSetNodes = new UVector(status); // bcos status gets overwritten here fRuleStatusVals = new UVector(status); fScanner = new RBBIRuleScanner(this); fSetBuilder = new RBBISetBuilder(this); if (U_FAILURE(status)) { return; } if(fSetBuilder == 0 || fScanner == 0 || fUSetNodes == 0 || fRuleStatusVals == 0) { status = U_MEMORY_ALLOCATION_ERROR; } } //---------------------------------------------------------------------------------------- // // Destructor // //---------------------------------------------------------------------------------------- RBBIRuleBuilder::~RBBIRuleBuilder() { int i; for (i=0; ; i++) { RBBINode *n = (RBBINode *)fUSetNodes->elementAt(i); if (n==NULL) { break; } delete n; } delete fUSetNodes; delete fSetBuilder; delete fForwardTable; delete fForwardTree; delete fReverseTree; delete fSafeFwdTree; delete fSafeRevTree; delete fScanner; delete fRuleStatusVals; } //---------------------------------------------------------------------------------------- // // flattenData() - Collect up the compiled RBBI rule data and put it into // the format for saving in ICU data files, // which is also the format needed by the RBBI runtime engine. // //---------------------------------------------------------------------------------------- static int32_t align8(int32_t i) {return (i+7) & 0xfffffff8;} RBBIDataHeader *RBBIRuleBuilder::flattenData() { int32_t i; if (U_FAILURE(*fStatus)) { return NULL; } // Remove whitespace from the rules to make it smaller. // The rule parser has already removed comments. fStrippedRules = fScanner->stripRules(fStrippedRules); // Calculate the size of each section in the data. // Sizes here are padded up to a multiple of 8 for better memory alignment. // Sections sizes actually stored in the header are for the actual data // without the padding. // int32_t headerSize = align8(sizeof(RBBIDataHeader)); int32_t forwardTableSize = align8(fForwardTable->getTableSize()); int32_t reverseTableSize = align8(fForwardTable->getSafeTableSize()); int32_t trieSize = align8(fSetBuilder->getTrieSize()); int32_t statusTableSize = align8(fRuleStatusVals->size() * sizeof(int32_t)); int32_t rulesSize = align8((fStrippedRules.length()+1) * sizeof(UChar)); int32_t totalSize = headerSize + forwardTableSize + reverseTableSize + statusTableSize + trieSize + rulesSize; RBBIDataHeader *data = (RBBIDataHeader *)uprv_malloc(totalSize); if (data == NULL) { *fStatus = U_MEMORY_ALLOCATION_ERROR; return NULL; } uprv_memset(data, 0, totalSize); data->fMagic = 0xb1a0; data->fFormatVersion[0] = RBBI_DATA_FORMAT_VERSION[0]; data->fFormatVersion[1] = RBBI_DATA_FORMAT_VERSION[1]; data->fFormatVersion[2] = RBBI_DATA_FORMAT_VERSION[2]; data->fFormatVersion[3] = RBBI_DATA_FORMAT_VERSION[3]; data->fLength = totalSize; data->fCatCount = fSetBuilder->getNumCharCategories(); data->fFTable = headerSize; data->fFTableLen = forwardTableSize; data->fRTable = data->fFTable + data->fFTableLen; data->fRTableLen = reverseTableSize; data->fTrie = data->fRTable + data->fRTableLen; data->fTrieLen = fSetBuilder->getTrieSize(); data->fStatusTable = data->fTrie + trieSize; data->fStatusTableLen= statusTableSize; data->fRuleSource = data->fStatusTable + statusTableSize; data->fRuleSourceLen = fStrippedRules.length() * sizeof(UChar); uprv_memset(data->fReserved, 0, sizeof(data->fReserved)); fForwardTable->exportTable((uint8_t *)data + data->fFTable); fForwardTable->exportSafeTable((uint8_t *)data + data->fRTable); fSetBuilder->serializeTrie ((uint8_t *)data + data->fTrie); int32_t *ruleStatusTable = (int32_t *)((uint8_t *)data + data->fStatusTable); for (i=0; i<fRuleStatusVals->size(); i++) { ruleStatusTable[i] = fRuleStatusVals->elementAti(i); } fStrippedRules.extract((UChar *)((uint8_t *)data+data->fRuleSource), rulesSize/2+1, *fStatus); return data; } //---------------------------------------------------------------------------------------- // // createRuleBasedBreakIterator construct from source rules that are passed in // in a UnicodeString // //---------------------------------------------------------------------------------------- BreakIterator * RBBIRuleBuilder::createRuleBasedBreakIterator( const UnicodeString &rules, UParseError *parseError, UErrorCode &status) { // // Read the input rules, generate a parse tree, symbol table, // and list of all Unicode Sets referenced by the rules. // RBBIRuleBuilder builder(rules, parseError, status); if (U_FAILURE(status)) { // status checked here bcos build below doesn't return NULL; } RBBIDataHeader *data = builder.build(status); if (U_FAILURE(status)) { return nullptr; } // // Create a break iterator from the compiled rules. // (Identical to creation from stored pre-compiled rules) // // status is checked after init in construction. RuleBasedBreakIterator *This = new RuleBasedBreakIterator(data, status); if (U_FAILURE(status)) { delete This; This = NULL; } else if(This == NULL) { // test for NULL status = U_MEMORY_ALLOCATION_ERROR; } return This; } RBBIDataHeader *RBBIRuleBuilder::build(UErrorCode &status) { if (U_FAILURE(status)) { return nullptr; } fScanner->parse(); if (U_FAILURE(status)) { return nullptr; } // // UnicodeSet processing. // Munge the Unicode Sets to create a set of character categories. // Generate the mapping tables (TRIE) from input code points to // the character categories. // fSetBuilder->buildRanges(); // // Generate the DFA state transition table. // fForwardTable = new RBBITableBuilder(this, &fForwardTree, status); if (fForwardTable == nullptr) { status = U_MEMORY_ALLOCATION_ERROR; return nullptr; } fForwardTable->buildForwardTable(); optimizeTables(); fForwardTable->buildSafeReverseTable(status); #ifdef RBBI_DEBUG if (fDebugEnv && uprv_strstr(fDebugEnv, "states")) { fForwardTable->printStates(); fForwardTable->printRuleStatusTable(); fForwardTable->printReverseTable(); } #endif fSetBuilder->buildTrie(); // // Package up the compiled data into a memory image // in the run-time format. // RBBIDataHeader *data = flattenData(); // returns NULL if error if (U_FAILURE(status)) { return nullptr; } return data; } void RBBIRuleBuilder::optimizeTables() { // Begin looking for duplicates with char class 3. // Classes 0, 1 and 2 are special; they are unused, {bof} and {eof} respectively, // and should not have other categories merged into them. IntPair duplPair = {3, 0}; while (fForwardTable->findDuplCharClassFrom(&duplPair)) { fSetBuilder->mergeCategories(duplPair); fForwardTable->removeColumn(duplPair.second); } fForwardTable->removeDuplicateStates(); } U_NAMESPACE_END #endif /* #if !UCONFIG_NO_BREAK_ITERATION */
teamfx/openjfx-8u-dev-rt
modules/web/src/main/native/Source/ThirdParty/icu/source/common/rbbirb.cpp
C++
gpl-2.0
9,976
/* Discovery of auto-inc and auto-dec instructions. Copyright (C) 2006-2015 Free Software Foundation, Inc. Contributed by Kenneth Zadeck <[email protected]> This file is part of GCC. GCC is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3, or (at your option) any later version. GCC is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with GCC; see the file COPYING3. If not see <http://www.gnu.org/licenses/>. */ #include "config.h" #include "system.h" #include "coretypes.h" #include "tm.h" #include "hash-set.h" #include "machmode.h" #include "vec.h" #include "double-int.h" #include "input.h" #include "alias.h" #include "symtab.h" #include "wide-int.h" #include "inchash.h" #include "tree.h" #include "rtl.h" #include "tm_p.h" #include "hard-reg-set.h" #include "predict.h" #include "vec.h" #include "hashtab.h" #include "hash-set.h" #include "machmode.h" #include "input.h" #include "function.h" #include "dominance.h" #include "cfg.h" #include "cfgrtl.h" #include "basic-block.h" #include "insn-config.h" #include "regs.h" #include "flags.h" #include "except.h" #include "diagnostic-core.h" #include "recog.h" #include "expr.h" #include "tree-pass.h" #include "df.h" #include "dbgcnt.h" #include "target.h" /* This pass was originally removed from flow.c. However there is almost nothing that remains of that code. There are (4) basic forms that are matched: (1) FORM_PRE_ADD a <- b + c ... *a becomes a <- b ... *(a += c) pre (2) FORM_PRE_INC a += c ... *a becomes *(a += c) pre (3) FORM_POST_ADD *a ... b <- a + c (For this case to be true, b must not be assigned or used between the *a and the assignment to b. B must also be a Pmode reg.) becomes b <- a ... *(b += c) post (4) FORM_POST_INC *a ... a <- a + c becomes *(a += c) post There are three types of values of c. 1) c is a constant equal to the width of the value being accessed by the pointer. This is useful for machines that have HAVE_PRE_INCREMENT, HAVE_POST_INCREMENT, HAVE_PRE_DECREMENT or HAVE_POST_DECREMENT defined. 2) c is a constant not equal to the width of the value being accessed by the pointer. This is useful for machines that have HAVE_PRE_MODIFY_DISP, HAVE_POST_MODIFY_DISP defined. 3) c is a register. This is useful for machines that have HAVE_PRE_MODIFY_REG, HAVE_POST_MODIFY_REG The is one special case: if a already had an offset equal to it +- its width and that offset is equal to -c when the increment was before the ref or +c if the increment was after the ref, then if we can do the combination but switch the pre/post bit. */ #ifdef AUTO_INC_DEC enum form { FORM_PRE_ADD, FORM_PRE_INC, FORM_POST_ADD, FORM_POST_INC, FORM_last }; /* The states of the second operands of mem refs and inc insns. If no second operand of the mem_ref was found, it is assumed to just be ZERO. SIZE is the size of the mode accessed in the memref. The ANY is used for constants that are not +-size or 0. REG is used if the forms are reg1 + reg2. */ enum inc_state { INC_ZERO, /* == 0 */ INC_NEG_SIZE, /* == +size */ INC_POS_SIZE, /* == -size */ INC_NEG_ANY, /* == some -constant */ INC_POS_ANY, /* == some +constant */ INC_REG, /* == some register */ INC_last }; /* The eight forms that pre/post inc/dec can take. */ enum gen_form { NOTHING, SIMPLE_PRE_INC, /* ++size */ SIMPLE_POST_INC, /* size++ */ SIMPLE_PRE_DEC, /* --size */ SIMPLE_POST_DEC, /* size-- */ DISP_PRE, /* ++con */ DISP_POST, /* con++ */ REG_PRE, /* ++reg */ REG_POST /* reg++ */ }; /* Tmp mem rtx for use in cost modeling. */ static rtx mem_tmp; static enum inc_state set_inc_state (HOST_WIDE_INT val, int size) { if (val == 0) return INC_ZERO; if (val < 0) return (val == -size) ? INC_NEG_SIZE : INC_NEG_ANY; else return (val == size) ? INC_POS_SIZE : INC_POS_ANY; } /* The DECISION_TABLE that describes what form, if any, the increment or decrement will take. It is a three dimensional table. The first index is the type of constant or register found as the second operand of the inc insn. The second index is the type of constant or register found as the second operand of the memory reference (if no second operand exists, 0 is used). The third index is the form and location (relative to the mem reference) of inc insn. */ static bool initialized = false; static enum gen_form decision_table[INC_last][INC_last][FORM_last]; static void init_decision_table (void) { enum gen_form value; if (HAVE_PRE_INCREMENT || HAVE_PRE_MODIFY_DISP) { /* Prefer the simple form if both are available. */ value = (HAVE_PRE_INCREMENT) ? SIMPLE_PRE_INC : DISP_PRE; decision_table[INC_POS_SIZE][INC_ZERO][FORM_PRE_ADD] = value; decision_table[INC_POS_SIZE][INC_ZERO][FORM_PRE_INC] = value; decision_table[INC_POS_SIZE][INC_POS_SIZE][FORM_POST_ADD] = value; decision_table[INC_POS_SIZE][INC_POS_SIZE][FORM_POST_INC] = value; } if (HAVE_POST_INCREMENT || HAVE_POST_MODIFY_DISP) { /* Prefer the simple form if both are available. */ value = (HAVE_POST_INCREMENT) ? SIMPLE_POST_INC : DISP_POST; decision_table[INC_POS_SIZE][INC_ZERO][FORM_POST_ADD] = value; decision_table[INC_POS_SIZE][INC_ZERO][FORM_POST_INC] = value; decision_table[INC_POS_SIZE][INC_NEG_SIZE][FORM_PRE_ADD] = value; decision_table[INC_POS_SIZE][INC_NEG_SIZE][FORM_PRE_INC] = value; } if (HAVE_PRE_DECREMENT || HAVE_PRE_MODIFY_DISP) { /* Prefer the simple form if both are available. */ value = (HAVE_PRE_DECREMENT) ? SIMPLE_PRE_DEC : DISP_PRE; decision_table[INC_NEG_SIZE][INC_ZERO][FORM_PRE_ADD] = value; decision_table[INC_NEG_SIZE][INC_ZERO][FORM_PRE_INC] = value; decision_table[INC_NEG_SIZE][INC_NEG_SIZE][FORM_POST_ADD] = value; decision_table[INC_NEG_SIZE][INC_NEG_SIZE][FORM_POST_INC] = value; } if (HAVE_POST_DECREMENT || HAVE_POST_MODIFY_DISP) { /* Prefer the simple form if both are available. */ value = (HAVE_POST_DECREMENT) ? SIMPLE_POST_DEC : DISP_POST; decision_table[INC_NEG_SIZE][INC_ZERO][FORM_POST_ADD] = value; decision_table[INC_NEG_SIZE][INC_ZERO][FORM_POST_INC] = value; decision_table[INC_NEG_SIZE][INC_POS_SIZE][FORM_PRE_ADD] = value; decision_table[INC_NEG_SIZE][INC_POS_SIZE][FORM_PRE_INC] = value; } if (HAVE_PRE_MODIFY_DISP) { decision_table[INC_POS_ANY][INC_ZERO][FORM_PRE_ADD] = DISP_PRE; decision_table[INC_POS_ANY][INC_ZERO][FORM_PRE_INC] = DISP_PRE; decision_table[INC_POS_ANY][INC_POS_ANY][FORM_POST_ADD] = DISP_PRE; decision_table[INC_POS_ANY][INC_POS_ANY][FORM_POST_INC] = DISP_PRE; decision_table[INC_NEG_ANY][INC_ZERO][FORM_PRE_ADD] = DISP_PRE; decision_table[INC_NEG_ANY][INC_ZERO][FORM_PRE_INC] = DISP_PRE; decision_table[INC_NEG_ANY][INC_NEG_ANY][FORM_POST_ADD] = DISP_PRE; decision_table[INC_NEG_ANY][INC_NEG_ANY][FORM_POST_INC] = DISP_PRE; } if (HAVE_POST_MODIFY_DISP) { decision_table[INC_POS_ANY][INC_ZERO][FORM_POST_ADD] = DISP_POST; decision_table[INC_POS_ANY][INC_ZERO][FORM_POST_INC] = DISP_POST; decision_table[INC_POS_ANY][INC_NEG_ANY][FORM_PRE_ADD] = DISP_POST; decision_table[INC_POS_ANY][INC_NEG_ANY][FORM_PRE_INC] = DISP_POST; decision_table[INC_NEG_ANY][INC_ZERO][FORM_POST_ADD] = DISP_POST; decision_table[INC_NEG_ANY][INC_ZERO][FORM_POST_INC] = DISP_POST; decision_table[INC_NEG_ANY][INC_POS_ANY][FORM_PRE_ADD] = DISP_POST; decision_table[INC_NEG_ANY][INC_POS_ANY][FORM_PRE_INC] = DISP_POST; } /* This is much simpler than the other cases because we do not look for the reg1-reg2 case. Note that we do not have a INC_POS_REG and INC_NEG_REG states. Most of the use of such states would be on a target that had an R1 - R2 update address form. There is the remote possibility that you could also catch a = a + b; *(a - b) as a postdecrement of (a + b). However, it is unclear if *(a - b) would ever be generated on a machine that did not have that kind of addressing mode. The IA-64 and RS6000 will not do this, and I cannot speak for any other. If any architecture does have an a-b update for, these cases should be added. */ if (HAVE_PRE_MODIFY_REG) { decision_table[INC_REG][INC_ZERO][FORM_PRE_ADD] = REG_PRE; decision_table[INC_REG][INC_ZERO][FORM_PRE_INC] = REG_PRE; decision_table[INC_REG][INC_REG][FORM_POST_ADD] = REG_PRE; decision_table[INC_REG][INC_REG][FORM_POST_INC] = REG_PRE; } if (HAVE_POST_MODIFY_REG) { decision_table[INC_REG][INC_ZERO][FORM_POST_ADD] = REG_POST; decision_table[INC_REG][INC_ZERO][FORM_POST_INC] = REG_POST; } initialized = true; } /* Parsed fields of an inc insn of the form "reg_res = reg0+reg1" or "reg_res = reg0+c". */ static struct inc_insn { rtx_insn *insn; /* The insn being parsed. */ rtx pat; /* The pattern of the insn. */ bool reg1_is_const; /* True if reg1 is const, false if reg1 is a reg. */ enum form form; rtx reg_res; rtx reg0; rtx reg1; enum inc_state reg1_state;/* The form of the const if reg1 is a const. */ HOST_WIDE_INT reg1_val;/* Value if reg1 is const. */ } inc_insn; /* Dump the parsed inc insn to FILE. */ static void dump_inc_insn (FILE *file) { const char *f = ((inc_insn.form == FORM_PRE_ADD) || (inc_insn.form == FORM_PRE_INC)) ? "pre" : "post"; dump_insn_slim (file, inc_insn.insn); switch (inc_insn.form) { case FORM_PRE_ADD: case FORM_POST_ADD: if (inc_insn.reg1_is_const) fprintf (file, "found %s add(%d) r[%d]=r[%d]+%d\n", f, INSN_UID (inc_insn.insn), REGNO (inc_insn.reg_res), REGNO (inc_insn.reg0), (int) inc_insn.reg1_val); else fprintf (file, "found %s add(%d) r[%d]=r[%d]+r[%d]\n", f, INSN_UID (inc_insn.insn), REGNO (inc_insn.reg_res), REGNO (inc_insn.reg0), REGNO (inc_insn.reg1)); break; case FORM_PRE_INC: case FORM_POST_INC: if (inc_insn.reg1_is_const) fprintf (file, "found %s inc(%d) r[%d]+=%d\n", f, INSN_UID (inc_insn.insn), REGNO (inc_insn.reg_res), (int) inc_insn.reg1_val); else fprintf (file, "found %s inc(%d) r[%d]+=r[%d]\n", f, INSN_UID (inc_insn.insn), REGNO (inc_insn.reg_res), REGNO (inc_insn.reg1)); break; default: break; } } /* Parsed fields of a mem ref of the form "*(reg0+reg1)" or "*(reg0+c)". */ static struct mem_insn { rtx_insn *insn; /* The insn being parsed. */ rtx pat; /* The pattern of the insn. */ rtx *mem_loc; /* The address of the field that holds the mem */ /* that is to be replaced. */ bool reg1_is_const; /* True if reg1 is const, false if reg1 is a reg. */ rtx reg0; rtx reg1; /* This is either a reg or a const depending on reg1_is_const. */ enum inc_state reg1_state;/* The form of the const if reg1 is a const. */ HOST_WIDE_INT reg1_val;/* Value if reg1 is const. */ } mem_insn; /* Dump the parsed mem insn to FILE. */ static void dump_mem_insn (FILE *file) { dump_insn_slim (file, mem_insn.insn); if (mem_insn.reg1_is_const) fprintf (file, "found mem(%d) *(r[%d]+%d)\n", INSN_UID (mem_insn.insn), REGNO (mem_insn.reg0), (int) mem_insn.reg1_val); else fprintf (file, "found mem(%d) *(r[%d]+r[%d])\n", INSN_UID (mem_insn.insn), REGNO (mem_insn.reg0), REGNO (mem_insn.reg1)); } /* The following three arrays contain pointers to instructions. They are indexed by REGNO. At any point in the basic block where we are looking these three arrays contain, respectively, the next insn that uses REGNO, the next inc or add insn that uses REGNO and the next insn that sets REGNO. The arrays are not cleared when we move from block to block so whenever an insn is retrieved from these arrays, it's block number must be compared with the current block. */ static rtx_insn **reg_next_use = NULL; static rtx_insn **reg_next_inc_use = NULL; static rtx_insn **reg_next_def = NULL; /* Move dead note that match PATTERN to TO_INSN from FROM_INSN. We do not really care about moving any other notes from the inc or add insn. Moving the REG_EQUAL and REG_EQUIV is clearly wrong and it does not appear that there are any other kinds of relevant notes. */ static void move_dead_notes (rtx_insn *to_insn, rtx_insn *from_insn, rtx pattern) { rtx note; rtx next_note; rtx prev_note = NULL; for (note = REG_NOTES (from_insn); note; note = next_note) { next_note = XEXP (note, 1); if ((REG_NOTE_KIND (note) == REG_DEAD) && pattern == XEXP (note, 0)) { XEXP (note, 1) = REG_NOTES (to_insn); REG_NOTES (to_insn) = note; if (prev_note) XEXP (prev_note, 1) = next_note; else REG_NOTES (from_insn) = next_note; } else prev_note = note; } } /* Create a mov insn DEST_REG <- SRC_REG and insert it before NEXT_INSN. */ static rtx_insn * insert_move_insn_before (rtx_insn *next_insn, rtx dest_reg, rtx src_reg) { rtx_insn *insns; start_sequence (); emit_move_insn (dest_reg, src_reg); insns = get_insns (); end_sequence (); emit_insn_before (insns, next_insn); return insns; } /* Change mem_insn.mem_loc so that uses NEW_ADDR which has an increment of INC_REG. To have reached this point, the change is a legitimate one from a dataflow point of view. The only questions are is this a valid change to the instruction and is this a profitable change to the instruction. */ static bool attempt_change (rtx new_addr, rtx inc_reg) { /* There are four cases: For the two cases that involve an add instruction, we are going to have to delete the add and insert a mov. We are going to assume that the mov is free. This is fairly early in the backend and there are a lot of opportunities for removing that move later. In particular, there is the case where the move may be dead, this is what dead code elimination passes are for. The two cases where we have an inc insn will be handled mov free. */ basic_block bb = BLOCK_FOR_INSN (mem_insn.insn); rtx_insn *mov_insn = NULL; int regno; rtx mem = *mem_insn.mem_loc; machine_mode mode = GET_MODE (mem); rtx new_mem; int old_cost = 0; int new_cost = 0; bool speed = optimize_bb_for_speed_p (bb); PUT_MODE (mem_tmp, mode); XEXP (mem_tmp, 0) = new_addr; old_cost = (set_src_cost (mem, speed) + set_rtx_cost (PATTERN (inc_insn.insn), speed)); new_cost = set_src_cost (mem_tmp, speed); /* The first item of business is to see if this is profitable. */ if (old_cost < new_cost) { if (dump_file) fprintf (dump_file, "cost failure old=%d new=%d\n", old_cost, new_cost); return false; } /* Jump through a lot of hoops to keep the attributes up to date. We do not want to call one of the change address variants that take an offset even though we know the offset in many cases. These assume you are changing where the address is pointing by the offset. */ new_mem = replace_equiv_address_nv (mem, new_addr); if (! validate_change (mem_insn.insn, mem_insn.mem_loc, new_mem, 0)) { if (dump_file) fprintf (dump_file, "validation failure\n"); return false; } /* From here to the end of the function we are committed to the change, i.e. nothing fails. Generate any necessary movs, move any regnotes, and fix up the reg_next_{use,inc_use,def}. */ switch (inc_insn.form) { case FORM_PRE_ADD: /* Replace the addition with a move. Do it at the location of the addition since the operand of the addition may change before the memory reference. */ mov_insn = insert_move_insn_before (inc_insn.insn, inc_insn.reg_res, inc_insn.reg0); move_dead_notes (mov_insn, inc_insn.insn, inc_insn.reg0); regno = REGNO (inc_insn.reg_res); reg_next_def[regno] = mov_insn; reg_next_use[regno] = NULL; regno = REGNO (inc_insn.reg0); reg_next_use[regno] = mov_insn; df_recompute_luids (bb); break; case FORM_POST_INC: regno = REGNO (inc_insn.reg_res); if (reg_next_use[regno] == reg_next_inc_use[regno]) reg_next_inc_use[regno] = NULL; /* Fallthru. */ case FORM_PRE_INC: regno = REGNO (inc_insn.reg_res); reg_next_def[regno] = mem_insn.insn; reg_next_use[regno] = NULL; break; case FORM_POST_ADD: mov_insn = insert_move_insn_before (mem_insn.insn, inc_insn.reg_res, inc_insn.reg0); move_dead_notes (mov_insn, inc_insn.insn, inc_insn.reg0); /* Do not move anything to the mov insn because the instruction pointer for the main iteration has not yet hit that. It is still pointing to the mem insn. */ regno = REGNO (inc_insn.reg_res); reg_next_def[regno] = mem_insn.insn; reg_next_use[regno] = NULL; regno = REGNO (inc_insn.reg0); reg_next_use[regno] = mem_insn.insn; if ((reg_next_use[regno] == reg_next_inc_use[regno]) || (reg_next_inc_use[regno] == inc_insn.insn)) reg_next_inc_use[regno] = NULL; df_recompute_luids (bb); break; case FORM_last: default: gcc_unreachable (); } if (!inc_insn.reg1_is_const) { regno = REGNO (inc_insn.reg1); reg_next_use[regno] = mem_insn.insn; if ((reg_next_use[regno] == reg_next_inc_use[regno]) || (reg_next_inc_use[regno] == inc_insn.insn)) reg_next_inc_use[regno] = NULL; } delete_insn (inc_insn.insn); if (dump_file && mov_insn) { fprintf (dump_file, "inserting mov "); dump_insn_slim (dump_file, mov_insn); } /* Record that this insn has an implicit side effect. */ add_reg_note (mem_insn.insn, REG_INC, inc_reg); if (dump_file) { fprintf (dump_file, "****success "); dump_insn_slim (dump_file, mem_insn.insn); } return true; } /* Try to combine the instruction in INC_INSN with the instruction in MEM_INSN. First the form is determined using the DECISION_TABLE and the results of parsing the INC_INSN and the MEM_INSN. Assuming the form is ok, a prototype new address is built which is passed to ATTEMPT_CHANGE for final processing. */ static bool try_merge (void) { enum gen_form gen_form; rtx mem = *mem_insn.mem_loc; rtx inc_reg = inc_insn.form == FORM_POST_ADD ? inc_insn.reg_res : mem_insn.reg0; /* The width of the mem being accessed. */ int size = GET_MODE_SIZE (GET_MODE (mem)); rtx_insn *last_insn = NULL; machine_mode reg_mode = GET_MODE (inc_reg); switch (inc_insn.form) { case FORM_PRE_ADD: case FORM_PRE_INC: last_insn = mem_insn.insn; break; case FORM_POST_INC: case FORM_POST_ADD: last_insn = inc_insn.insn; break; case FORM_last: default: gcc_unreachable (); } /* Cannot handle auto inc of the stack. */ if (inc_reg == stack_pointer_rtx) { if (dump_file) fprintf (dump_file, "cannot inc stack %d failure\n", REGNO (inc_reg)); return false; } /* Look to see if the inc register is dead after the memory reference. If it is, do not do the combination. */ if (find_regno_note (last_insn, REG_DEAD, REGNO (inc_reg))) { if (dump_file) fprintf (dump_file, "dead failure %d\n", REGNO (inc_reg)); return false; } mem_insn.reg1_state = (mem_insn.reg1_is_const) ? set_inc_state (mem_insn.reg1_val, size) : INC_REG; inc_insn.reg1_state = (inc_insn.reg1_is_const) ? set_inc_state (inc_insn.reg1_val, size) : INC_REG; /* Now get the form that we are generating. */ gen_form = decision_table [inc_insn.reg1_state][mem_insn.reg1_state][inc_insn.form]; if (dbg_cnt (auto_inc_dec) == false) return false; switch (gen_form) { default: case NOTHING: return false; case SIMPLE_PRE_INC: /* ++size */ if (dump_file) fprintf (dump_file, "trying SIMPLE_PRE_INC\n"); return attempt_change (gen_rtx_PRE_INC (reg_mode, inc_reg), inc_reg); break; case SIMPLE_POST_INC: /* size++ */ if (dump_file) fprintf (dump_file, "trying SIMPLE_POST_INC\n"); return attempt_change (gen_rtx_POST_INC (reg_mode, inc_reg), inc_reg); break; case SIMPLE_PRE_DEC: /* --size */ if (dump_file) fprintf (dump_file, "trying SIMPLE_PRE_DEC\n"); return attempt_change (gen_rtx_PRE_DEC (reg_mode, inc_reg), inc_reg); break; case SIMPLE_POST_DEC: /* size-- */ if (dump_file) fprintf (dump_file, "trying SIMPLE_POST_DEC\n"); return attempt_change (gen_rtx_POST_DEC (reg_mode, inc_reg), inc_reg); break; case DISP_PRE: /* ++con */ if (dump_file) fprintf (dump_file, "trying DISP_PRE\n"); return attempt_change (gen_rtx_PRE_MODIFY (reg_mode, inc_reg, gen_rtx_PLUS (reg_mode, inc_reg, inc_insn.reg1)), inc_reg); break; case DISP_POST: /* con++ */ if (dump_file) fprintf (dump_file, "trying POST_DISP\n"); return attempt_change (gen_rtx_POST_MODIFY (reg_mode, inc_reg, gen_rtx_PLUS (reg_mode, inc_reg, inc_insn.reg1)), inc_reg); break; case REG_PRE: /* ++reg */ if (dump_file) fprintf (dump_file, "trying PRE_REG\n"); return attempt_change (gen_rtx_PRE_MODIFY (reg_mode, inc_reg, gen_rtx_PLUS (reg_mode, inc_reg, inc_insn.reg1)), inc_reg); break; case REG_POST: /* reg++ */ if (dump_file) fprintf (dump_file, "trying POST_REG\n"); return attempt_change (gen_rtx_POST_MODIFY (reg_mode, inc_reg, gen_rtx_PLUS (reg_mode, inc_reg, inc_insn.reg1)), inc_reg); break; } } /* Return the next insn that uses (if reg_next_use is passed in NEXT_ARRAY) or defines (if reg_next_def is passed in NEXT_ARRAY) REGNO in BB. */ static rtx_insn * get_next_ref (int regno, basic_block bb, rtx_insn **next_array) { rtx_insn *insn = next_array[regno]; /* Lazy about cleaning out the next_arrays. */ if (insn && BLOCK_FOR_INSN (insn) != bb) { next_array[regno] = NULL; insn = NULL; } return insn; } /* Reverse the operands in a mem insn. */ static void reverse_mem (void) { rtx tmp = mem_insn.reg1; mem_insn.reg1 = mem_insn.reg0; mem_insn.reg0 = tmp; } /* Reverse the operands in a inc insn. */ static void reverse_inc (void) { rtx tmp = inc_insn.reg1; inc_insn.reg1 = inc_insn.reg0; inc_insn.reg0 = tmp; } /* Return true if INSN is of a form "a = b op c" where a and b are regs. op is + if c is a reg and +|- if c is a const. Fill in INC_INSN with what is found. This function is called in two contexts, if BEFORE_MEM is true, this is called for each insn in the basic block. If BEFORE_MEM is false, it is called for the instruction in the block that uses the index register for some memory reference that is currently being processed. */ static bool parse_add_or_inc (rtx_insn *insn, bool before_mem) { rtx pat = single_set (insn); if (!pat) return false; /* Result must be single reg. */ if (!REG_P (SET_DEST (pat))) return false; if ((GET_CODE (SET_SRC (pat)) != PLUS) && (GET_CODE (SET_SRC (pat)) != MINUS)) return false; if (!REG_P (XEXP (SET_SRC (pat), 0))) return false; inc_insn.insn = insn; inc_insn.pat = pat; inc_insn.reg_res = SET_DEST (pat); inc_insn.reg0 = XEXP (SET_SRC (pat), 0); if (rtx_equal_p (inc_insn.reg_res, inc_insn.reg0)) inc_insn.form = before_mem ? FORM_PRE_INC : FORM_POST_INC; else inc_insn.form = before_mem ? FORM_PRE_ADD : FORM_POST_ADD; if (CONST_INT_P (XEXP (SET_SRC (pat), 1))) { /* Process a = b + c where c is a const. */ inc_insn.reg1_is_const = true; if (GET_CODE (SET_SRC (pat)) == PLUS) { inc_insn.reg1 = XEXP (SET_SRC (pat), 1); inc_insn.reg1_val = INTVAL (inc_insn.reg1); } else { inc_insn.reg1_val = -INTVAL (XEXP (SET_SRC (pat), 1)); inc_insn.reg1 = GEN_INT (inc_insn.reg1_val); } return true; } else if ((HAVE_PRE_MODIFY_REG || HAVE_POST_MODIFY_REG) && (REG_P (XEXP (SET_SRC (pat), 1))) && GET_CODE (SET_SRC (pat)) == PLUS) { /* Process a = b + c where c is a reg. */ inc_insn.reg1 = XEXP (SET_SRC (pat), 1); inc_insn.reg1_is_const = false; if (inc_insn.form == FORM_PRE_INC || inc_insn.form == FORM_POST_INC) return true; else if (rtx_equal_p (inc_insn.reg_res, inc_insn.reg1)) { /* Reverse the two operands and turn *_ADD into *_INC since a = c + a. */ reverse_inc (); inc_insn.form = before_mem ? FORM_PRE_INC : FORM_POST_INC; return true; } else return true; } return false; } /* A recursive function that checks all of the mem uses in ADDRESS_OF_X to see if any single one of them is compatible with what has been found in inc_insn. -1 is returned for success. 0 is returned if nothing was found and 1 is returned for failure. */ static int find_address (rtx *address_of_x) { rtx x = *address_of_x; enum rtx_code code = GET_CODE (x); const char *const fmt = GET_RTX_FORMAT (code); int i; int value = 0; int tem; if (code == MEM && rtx_equal_p (XEXP (x, 0), inc_insn.reg_res)) { /* Match with *reg0. */ mem_insn.mem_loc = address_of_x; mem_insn.reg0 = inc_insn.reg_res; mem_insn.reg1_is_const = true; mem_insn.reg1_val = 0; mem_insn.reg1 = GEN_INT (0); return -1; } if (code == MEM && GET_CODE (XEXP (x, 0)) == PLUS && rtx_equal_p (XEXP (XEXP (x, 0), 0), inc_insn.reg_res)) { rtx b = XEXP (XEXP (x, 0), 1); mem_insn.mem_loc = address_of_x; mem_insn.reg0 = inc_insn.reg_res; mem_insn.reg1 = b; mem_insn.reg1_is_const = inc_insn.reg1_is_const; if (CONST_INT_P (b)) { /* Match with *(reg0 + reg1) where reg1 is a const. */ HOST_WIDE_INT val = INTVAL (b); if (inc_insn.reg1_is_const && (inc_insn.reg1_val == val || inc_insn.reg1_val == -val)) { mem_insn.reg1_val = val; return -1; } } else if (!inc_insn.reg1_is_const && rtx_equal_p (inc_insn.reg1, b)) /* Match with *(reg0 + reg1). */ return -1; } if (code == SIGN_EXTRACT || code == ZERO_EXTRACT) { /* If REG occurs inside a MEM used in a bit-field reference, that is unacceptable. */ if (find_address (&XEXP (x, 0))) return 1; } if (x == inc_insn.reg_res) return 1; /* Time for some deep diving. */ for (i = GET_RTX_LENGTH (code) - 1; i >= 0; i--) { if (fmt[i] == 'e') { tem = find_address (&XEXP (x, i)); /* If this is the first use, let it go so the rest of the insn can be checked. */ if (value == 0) value = tem; else if (tem != 0) /* More than one match was found. */ return 1; } else if (fmt[i] == 'E') { int j; for (j = XVECLEN (x, i) - 1; j >= 0; j--) { tem = find_address (&XVECEXP (x, i, j)); /* If this is the first use, let it go so the rest of the insn can be checked. */ if (value == 0) value = tem; else if (tem != 0) /* More than one match was found. */ return 1; } } } return value; } /* Once a suitable mem reference has been found and the MEM_INSN structure has been filled in, FIND_INC is called to see if there is a suitable add or inc insn that follows the mem reference and determine if it is suitable to merge. In the case where the MEM_INSN has two registers in the reference, this function may be called recursively. The first time looking for an add of the first register, and if that fails, looking for an add of the second register. The FIRST_TRY parameter is used to only allow the parameters to be reversed once. */ static bool find_inc (bool first_try) { rtx_insn *insn; basic_block bb = BLOCK_FOR_INSN (mem_insn.insn); rtx_insn *other_insn; df_ref def; /* Make sure this reg appears only once in this insn. */ if (count_occurrences (PATTERN (mem_insn.insn), mem_insn.reg0, 1) != 1) { if (dump_file) fprintf (dump_file, "mem count failure\n"); return false; } if (dump_file) dump_mem_insn (dump_file); /* Find the next use that is an inc. */ insn = get_next_ref (REGNO (mem_insn.reg0), BLOCK_FOR_INSN (mem_insn.insn), reg_next_inc_use); if (!insn) return false; /* Even though we know the next use is an add or inc because it came from the reg_next_inc_use, we must still reparse. */ if (!parse_add_or_inc (insn, false)) { /* Next use was not an add. Look for one extra case. It could be that we have: *(a + b) ...= a; ...= b + a if we reverse the operands in the mem ref we would find this. Only try it once though. */ if (first_try && !mem_insn.reg1_is_const) { reverse_mem (); return find_inc (false); } else return false; } /* Need to assure that none of the operands of the inc instruction are assigned to by the mem insn. */ FOR_EACH_INSN_DEF (def, mem_insn.insn) { unsigned int regno = DF_REF_REGNO (def); if ((regno == REGNO (inc_insn.reg0)) || (regno == REGNO (inc_insn.reg_res))) { if (dump_file) fprintf (dump_file, "inc conflicts with store failure.\n"); return false; } if (!inc_insn.reg1_is_const && (regno == REGNO (inc_insn.reg1))) { if (dump_file) fprintf (dump_file, "inc conflicts with store failure.\n"); return false; } } if (dump_file) dump_inc_insn (dump_file); if (inc_insn.form == FORM_POST_ADD) { /* Make sure that there is no insn that assigns to inc_insn.res between the mem_insn and the inc_insn. */ rtx_insn *other_insn = get_next_ref (REGNO (inc_insn.reg_res), BLOCK_FOR_INSN (mem_insn.insn), reg_next_def); if (other_insn != inc_insn.insn) { if (dump_file) fprintf (dump_file, "result of add is assigned to between mem and inc insns.\n"); return false; } other_insn = get_next_ref (REGNO (inc_insn.reg_res), BLOCK_FOR_INSN (mem_insn.insn), reg_next_use); if (other_insn && (other_insn != inc_insn.insn) && (DF_INSN_LUID (inc_insn.insn) > DF_INSN_LUID (other_insn))) { if (dump_file) fprintf (dump_file, "result of add is used between mem and inc insns.\n"); return false; } /* For the post_add to work, the result_reg of the inc must not be used in the mem insn since this will become the new index register. */ if (reg_overlap_mentioned_p (inc_insn.reg_res, PATTERN (mem_insn.insn))) { if (dump_file) fprintf (dump_file, "base reg replacement failure.\n"); return false; } } if (mem_insn.reg1_is_const) { if (mem_insn.reg1_val == 0) { if (!inc_insn.reg1_is_const) { /* The mem looks like *r0 and the rhs of the add has two registers. */ int luid = DF_INSN_LUID (inc_insn.insn); if (inc_insn.form == FORM_POST_ADD) { /* The trick is that we are not going to increment r0, we are going to increment the result of the add insn. For this trick to be correct, the result reg of the inc must be a valid addressing reg. */ addr_space_t as = MEM_ADDR_SPACE (*mem_insn.mem_loc); if (GET_MODE (inc_insn.reg_res) != targetm.addr_space.address_mode (as)) { if (dump_file) fprintf (dump_file, "base reg mode failure.\n"); return false; } /* We also need to make sure that the next use of inc result is after the inc. */ other_insn = get_next_ref (REGNO (inc_insn.reg1), bb, reg_next_use); if (other_insn && luid > DF_INSN_LUID (other_insn)) return false; if (!rtx_equal_p (mem_insn.reg0, inc_insn.reg0)) reverse_inc (); } other_insn = get_next_ref (REGNO (inc_insn.reg1), bb, reg_next_def); if (other_insn && luid > DF_INSN_LUID (other_insn)) return false; } } /* Both the inc/add and the mem have a constant. Need to check that the constants are ok. */ else if ((mem_insn.reg1_val != inc_insn.reg1_val) && (mem_insn.reg1_val != -inc_insn.reg1_val)) return false; } else { /* The mem insn is of the form *(a + b) where a and b are both regs. It may be that in order to match the add or inc we need to treat it as if it was *(b + a). It may also be that the add is of the form a + c where c does not match b and then we just abandon this. */ int luid = DF_INSN_LUID (inc_insn.insn); rtx_insn *other_insn; /* Make sure this reg appears only once in this insn. */ if (count_occurrences (PATTERN (mem_insn.insn), mem_insn.reg1, 1) != 1) return false; if (inc_insn.form == FORM_POST_ADD) { /* For this trick to be correct, the result reg of the inc must be a valid addressing reg. */ addr_space_t as = MEM_ADDR_SPACE (*mem_insn.mem_loc); if (GET_MODE (inc_insn.reg_res) != targetm.addr_space.address_mode (as)) { if (dump_file) fprintf (dump_file, "base reg mode failure.\n"); return false; } if (rtx_equal_p (mem_insn.reg0, inc_insn.reg0)) { if (!rtx_equal_p (mem_insn.reg1, inc_insn.reg1)) { /* See comment above on find_inc (false) call. */ if (first_try) { reverse_mem (); return find_inc (false); } else return false; } /* Need to check that there are no assignments to b before the add insn. */ other_insn = get_next_ref (REGNO (inc_insn.reg1), bb, reg_next_def); if (other_insn && luid > DF_INSN_LUID (other_insn)) return false; /* All ok for the next step. */ } else { /* We know that mem_insn.reg0 must equal inc_insn.reg1 or else we would not have found the inc insn. */ reverse_mem (); if (!rtx_equal_p (mem_insn.reg0, inc_insn.reg0)) { /* See comment above on find_inc (false) call. */ if (first_try) return find_inc (false); else return false; } /* To have gotten here know that. *(b + a) ... = (b + a) We also know that the lhs of the inc is not b or a. We need to make sure that there are no assignments to b between the mem ref and the inc. */ other_insn = get_next_ref (REGNO (inc_insn.reg0), bb, reg_next_def); if (other_insn && luid > DF_INSN_LUID (other_insn)) return false; } /* Need to check that the next use of the add result is later than add insn since this will be the reg incremented. */ other_insn = get_next_ref (REGNO (inc_insn.reg_res), bb, reg_next_use); if (other_insn && luid > DF_INSN_LUID (other_insn)) return false; } else /* FORM_POST_INC. There is less to check here because we know that operands must line up. */ { if (!rtx_equal_p (mem_insn.reg1, inc_insn.reg1)) /* See comment above on find_inc (false) call. */ { if (first_try) { reverse_mem (); return find_inc (false); } else return false; } /* To have gotten here know that. *(a + b) ... = (a + b) We also know that the lhs of the inc is not b. We need to make sure that there are no assignments to b between the mem ref and the inc. */ other_insn = get_next_ref (REGNO (inc_insn.reg1), bb, reg_next_def); if (other_insn && luid > DF_INSN_LUID (other_insn)) return false; } } if (inc_insn.form == FORM_POST_INC) { other_insn = get_next_ref (REGNO (inc_insn.reg0), bb, reg_next_use); /* When we found inc_insn, we were looking for the next add or inc, not the next insn that used the reg. Because we are going to increment the reg in this form, we need to make sure that there were no intervening uses of reg. */ if (inc_insn.insn != other_insn) return false; } return try_merge (); } /* A recursive function that walks ADDRESS_OF_X to find all of the mem uses in pat that could be used as an auto inc or dec. It then calls FIND_INC for each one. */ static bool find_mem (rtx *address_of_x) { rtx x = *address_of_x; enum rtx_code code = GET_CODE (x); const char *const fmt = GET_RTX_FORMAT (code); int i; if (code == MEM && REG_P (XEXP (x, 0))) { /* Match with *reg0. */ mem_insn.mem_loc = address_of_x; mem_insn.reg0 = XEXP (x, 0); mem_insn.reg1_is_const = true; mem_insn.reg1_val = 0; mem_insn.reg1 = GEN_INT (0); if (find_inc (true)) return true; } if (code == MEM && GET_CODE (XEXP (x, 0)) == PLUS && REG_P (XEXP (XEXP (x, 0), 0))) { rtx reg1 = XEXP (XEXP (x, 0), 1); mem_insn.mem_loc = address_of_x; mem_insn.reg0 = XEXP (XEXP (x, 0), 0); mem_insn.reg1 = reg1; if (CONST_INT_P (reg1)) { mem_insn.reg1_is_const = true; /* Match with *(reg0 + c) where c is a const. */ mem_insn.reg1_val = INTVAL (reg1); if (find_inc (true)) return true; } else if (REG_P (reg1)) { /* Match with *(reg0 + reg1). */ mem_insn.reg1_is_const = false; if (find_inc (true)) return true; } } if (code == SIGN_EXTRACT || code == ZERO_EXTRACT) { /* If REG occurs inside a MEM used in a bit-field reference, that is unacceptable. */ return false; } /* Time for some deep diving. */ for (i = GET_RTX_LENGTH (code) - 1; i >= 0; i--) { if (fmt[i] == 'e') { if (find_mem (&XEXP (x, i))) return true; } else if (fmt[i] == 'E') { int j; for (j = XVECLEN (x, i) - 1; j >= 0; j--) if (find_mem (&XVECEXP (x, i, j))) return true; } } return false; } /* Try to combine all incs and decs by constant values with memory references in BB. */ static void merge_in_block (int max_reg, basic_block bb) { rtx_insn *insn; rtx_insn *curr; int success_in_block = 0; if (dump_file) fprintf (dump_file, "\n\nstarting bb %d\n", bb->index); FOR_BB_INSNS_REVERSE_SAFE (bb, insn, curr) { bool insn_is_add_or_inc = true; if (!NONDEBUG_INSN_P (insn)) continue; /* This continue is deliberate. We do not want the uses of the jump put into reg_next_use because it is not considered safe to combine a preincrement with a jump. */ if (JUMP_P (insn)) continue; if (dump_file) dump_insn_slim (dump_file, insn); /* Does this instruction increment or decrement a register? */ if (parse_add_or_inc (insn, true)) { int regno = REGNO (inc_insn.reg_res); /* Cannot handle case where there are three separate regs before a mem ref. Too many moves would be needed to be profitable. */ if ((inc_insn.form == FORM_PRE_INC) || inc_insn.reg1_is_const) { mem_insn.insn = get_next_ref (regno, bb, reg_next_use); if (mem_insn.insn) { bool ok = true; if (!inc_insn.reg1_is_const) { /* We are only here if we are going to try a HAVE_*_MODIFY_REG type transformation. c is a reg and we must sure that the path from the inc_insn to the mem_insn.insn is both def and use clear of c because the inc insn is going to move into the mem_insn.insn. */ int luid = DF_INSN_LUID (mem_insn.insn); rtx_insn *other_insn = get_next_ref (REGNO (inc_insn.reg1), bb, reg_next_use); if (other_insn && luid > DF_INSN_LUID (other_insn)) ok = false; other_insn = get_next_ref (REGNO (inc_insn.reg1), bb, reg_next_def); if (other_insn && luid > DF_INSN_LUID (other_insn)) ok = false; } if (dump_file) dump_inc_insn (dump_file); if (ok && find_address (&PATTERN (mem_insn.insn)) == -1) { if (dump_file) dump_mem_insn (dump_file); if (try_merge ()) { success_in_block++; insn_is_add_or_inc = false; } } } } } else { insn_is_add_or_inc = false; mem_insn.insn = insn; if (find_mem (&PATTERN (insn))) success_in_block++; } /* If the inc insn was merged with a mem, the inc insn is gone and there is noting to update. */ if (df_insn_info *insn_info = DF_INSN_INFO_GET (insn)) { df_ref def, use; /* Need to update next use. */ FOR_EACH_INSN_INFO_DEF (def, insn_info) { reg_next_use[DF_REF_REGNO (def)] = NULL; reg_next_inc_use[DF_REF_REGNO (def)] = NULL; reg_next_def[DF_REF_REGNO (def)] = insn; } FOR_EACH_INSN_INFO_USE (use, insn_info) { reg_next_use[DF_REF_REGNO (use)] = insn; if (insn_is_add_or_inc) reg_next_inc_use[DF_REF_REGNO (use)] = insn; else reg_next_inc_use[DF_REF_REGNO (use)] = NULL; } } else if (dump_file) fprintf (dump_file, "skipping update of deleted insn %d\n", INSN_UID (insn)); } /* If we were successful, try again. There may have been several opportunities that were interleaved. This is rare but gcc.c-torture/compile/pr17273.c actually exhibits this. */ if (success_in_block) { /* In this case, we must clear these vectors since the trick of testing if the stale insn in the block will not work. */ memset (reg_next_use, 0, max_reg * sizeof (rtx)); memset (reg_next_inc_use, 0, max_reg * sizeof (rtx)); memset (reg_next_def, 0, max_reg * sizeof (rtx)); df_recompute_luids (bb); merge_in_block (max_reg, bb); } } #endif /* Discover auto-inc auto-dec instructions. */ namespace { const pass_data pass_data_inc_dec = { RTL_PASS, /* type */ "auto_inc_dec", /* name */ OPTGROUP_NONE, /* optinfo_flags */ TV_AUTO_INC_DEC, /* tv_id */ 0, /* properties_required */ 0, /* properties_provided */ 0, /* properties_destroyed */ 0, /* todo_flags_start */ TODO_df_finish, /* todo_flags_finish */ }; class pass_inc_dec : public rtl_opt_pass { public: pass_inc_dec (gcc::context *ctxt) : rtl_opt_pass (pass_data_inc_dec, ctxt) {} /* opt_pass methods: */ virtual bool gate (function *) { #ifdef AUTO_INC_DEC return (optimize > 0 && flag_auto_inc_dec); #else return false; #endif } unsigned int execute (function *); }; // class pass_inc_dec unsigned int pass_inc_dec::execute (function *fun ATTRIBUTE_UNUSED) { #ifdef AUTO_INC_DEC basic_block bb; int max_reg = max_reg_num (); if (!initialized) init_decision_table (); mem_tmp = gen_rtx_MEM (Pmode, NULL_RTX); df_note_add_problem (); df_analyze (); reg_next_use = XCNEWVEC (rtx_insn *, max_reg); reg_next_inc_use = XCNEWVEC (rtx_insn *, max_reg); reg_next_def = XCNEWVEC (rtx_insn *, max_reg); FOR_EACH_BB_FN (bb, fun) merge_in_block (max_reg, bb); free (reg_next_use); free (reg_next_inc_use); free (reg_next_def); mem_tmp = NULL; #endif return 0; } } // anon namespace rtl_opt_pass * make_pass_inc_dec (gcc::context *ctxt) { return new pass_inc_dec (ctxt); }
kito-cheng/gcc
gcc/auto-inc-dec.c
C
gpl-2.0
44,162
/* Copyright (c) 2004, 2005, 2006, 2007, 2008, 2009 Mark Aylett <[email protected]> This file is part of Aug written by Mark Aylett. Aug is released under the GPL with the additional exemption that compiling, linking, and/or using OpenSSL is allowed. Aug is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. Aug is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ #ifndef AUGUTIL_PWD_H #define AUGUTIL_PWD_H /** * @file augutil/pwd.h * * Password functions. */ #include "augutil/md5.h" #define AUG_MAXPASSWORD 128 typedef char aug_pwd_t[AUG_MAXPASSWORD + 1]; AUGUTIL_API char* aug_getpass(const char* prompt, char* buf, size_t len); AUGUTIL_API char* aug_digestpass(const char* username, const char* realm, const char* password, aug_md5base64_t base64); #endif /* AUGUTIL_PWD_H */
marayl/aug
src/c/augutil/pwd.h
C
gpl-2.0
1,396
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>Monroe puts in 24, Knicks defeat the Pistons 121 to 115</title> <link rel="stylesheet" type="text/css" href="../css/style.css"> </head> <body> <h1>Monroe puts in 24, Knicks defeat the Pistons 121 to 115</h1> </br> <h2 style="color:gray">by NBANLP Recap Generator</h2> </br></br> <img src="../img/08/01.jpg" alt="No image loaded" align="right" style="height:50%; width:50%;margin-left:20px;margin-bottom:20px;"> <p>Greg Monroe recorded 24 points for the Pistons. Andrea Bargnani contributed well to the Knicks total, recording 23 points. The Pistons largest lead was by 18 with 3 minutes remaining in the 2nd.</p> <p>Greg put up 24 points for the Pistons in a good scoring contribution. Monroe contributed 2 assists and 13 rebounds.</p> <p>Andrea made contributions in scoring with 23 points for the Knicks. Bargnani got 4 assists and 12 rebounds for the Knicks.</p> <p>The Pistons were up by as much as 18 points in the 2nd with a 51-33 lead.</p> <p>Drummond fouled out with 6:03 remaining in double overtime.</p> <p>Galloway recorded his last foul with 6:00 left in double overtime.</p> <p>Smith recorded his last foul with 6:00 remaining in double overtime.</p> <p>This result puts Pistons at 23-35 for the season, while the Knicks are 11-45. The Pistons have lost their last 2 games.</p> <p>Andre Drummond, Reggie Jackson, and Kentavious Caldwell-Pope combined for 46 points. Each scoring 15, 14, and 17 points respectively. Drummond recorded 1 assists and 15 rebounds for the Pistons. Jackson got 5 assists and 5 rebounds for the Pistons. Caldwell-Pope got 3 assists and 6 rebounds for the Pistons. Greg led the Pistons putting up 24 points, 2 assists, and 13 rebounds. Andrea led the Knicks putting up a total 23 points, 4 assists, and 12 rebounds.</p> </body> </html>
jacobbustamante/NBANLPRecap
web/2014_season/2015022708.html
HTML
gpl-2.0
1,900
<div class="clear left"> <div class="full-page-span33 home-island"> <div class="img-island isle1"> <h3>Isle Title 1</h3> <p class="tl"> Mei duis denique nostrum et, in pro choro</p> </div> <div> <p>Lorem ipsum Mei duis denique nostrum et, in pro choro consul, eam deterruisset definitionem te. Ne nam prima essent delicata, quie Sacto is. In fabellas technician.</p> </div> </div> <div class="full-page-span33 home-island"> <div class="img-island isle2"> <h3>Isle Title 2</h3> <p class="bl">Ne Nam Prima Essent Delicata</p> </div> <div> <p>Ot usu ut oblique senserit, ne usu saepe affert definitiones, mel euripidis persequeris id. Pri ad iudico conceptam, nostro apeirian no has Roseville.</p> </div> </div> <div class="full-page-span33 home-island"> <div class="img-island isle3"> <h3>Isle Title 3</h3> <p class="tr">Ut Oratio Moleskine Quo Prezi</p> </div> <div> <p> Ipsum cotidieque definitiones eos no, at dicant perfecto sea. At mollis definitionem duo, ludus primis sanctus id eam, an mei rebum debitis.</p> </div> </div> </div> <div class="clear left"> <div class="full-page-span33 home-facts"> <h3 class="med-body-headline">Our Services Include:</h3> <ul> <li>Fulli Assueverit</li> <li>Centrant Ailey Redactio Athasn</li> <li>Electric Oblique Senserit</li> <li>Nec Ro Aperiam</li> <li>At Mollis Definitionem Duo</li> <li>Radirum A Denique Adversarium namei</li> <ul> </div> <div class="full-page-span33 home-facts hf2nd-col"> <ul> <li>Tel Hasadipsci &#38; Ludis</li> <li>Respado Cotidieque &#38; Primus</li> <li>PAVT Monestatis</li> <li>Listaray, Billum &#38; Inlused</li> <li>24 Hour Elequist Sanktus</li> <li>Fresca Estinastos</li> <ul> </div> <div class="full-page-span33 home-facts hf2nd-col last-col"> <a href="#" class="frst-grn-btn tighten-text"><span class="subtext">Nov Ask Selen</span><br /> Falli Eloquentiam</a> <a href="#" class="lt-grn-btn tighten-text">Eleifend Asservated<br /><span class="subtext">Utom Requiem</span></a> </div> </div>
johnjlocke/rush-mechanical-theme
rush-mechanical/home-fw.php
PHP
gpl-2.0
2,288
/* * Copyright (C) 2003-2011 The Music Player Daemon Project * http://www.musicpd.org * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ #include "config.h" #include "pcm_volume.h" #include "pcm_utils.h" #include "audio_format.h" #include <glib.h> #include <stdint.h> #include <string.h> #undef G_LOG_DOMAIN #define G_LOG_DOMAIN "pcm_volume" static void pcm_volume_change_8(int8_t *buffer, const int8_t *end, int volume) { while (buffer < end) { int32_t sample = *buffer; sample = (sample * volume + pcm_volume_dither() + PCM_VOLUME_1 / 2) / PCM_VOLUME_1; *buffer++ = pcm_range(sample, 8); } } static void pcm_volume_change_16(int16_t *buffer, const int16_t *end, int volume) { while (buffer < end) { int32_t sample = *buffer; sample = (sample * volume + pcm_volume_dither() + PCM_VOLUME_1 / 2) / PCM_VOLUME_1; *buffer++ = pcm_range(sample, 16); } } #ifdef __i386__ /** * Optimized volume function for i386. Use the EDX:EAX 2*32 bit * multiplication result instead of emulating 64 bit multiplication. */ static inline int32_t pcm_volume_sample_24(int32_t sample, int32_t volume, G_GNUC_UNUSED int32_t dither) { int32_t result; asm(/* edx:eax = sample * volume */ "imul %2\n" /* "add %3, %1\n" dithering disabled for now, because we have no overflow check - is dithering really important here? */ /* eax = edx:eax / PCM_VOLUME_1 */ "sal $22, %%edx\n" "shr $10, %1\n" "or %%edx, %1\n" : "=a"(result) : "0"(sample), "r"(volume) /* , "r"(dither) */ : "edx" ); return result; } #endif static void pcm_volume_change_24(int32_t *buffer, const int32_t *end, int volume) { while (buffer < end) { #ifdef __i386__ /* assembly version for i386 */ int32_t sample = *buffer; sample = pcm_volume_sample_24(sample, volume, pcm_volume_dither()); #else /* portable version */ int64_t sample = *buffer; sample = (sample * volume + pcm_volume_dither() + PCM_VOLUME_1 / 2) / PCM_VOLUME_1; #endif *buffer++ = pcm_range(sample, 24); } } static void pcm_volume_change_32(int32_t *buffer, const int32_t *end, int volume) { while (buffer < end) { #ifdef __i386__ /* assembly version for i386 */ int32_t sample = *buffer; *buffer++ = pcm_volume_sample_24(sample, volume, 0); #else /* portable version */ int64_t sample = *buffer; sample = (sample * volume + pcm_volume_dither() + PCM_VOLUME_1 / 2) / PCM_VOLUME_1; *buffer++ = pcm_range_64(sample, 32); #endif } } static void pcm_volume_change_float(float *buffer, const float *end, float volume) { while (buffer < end) { float sample = *buffer; sample *= volume; *buffer++ = sample; } } bool pcm_volume(void *buffer, size_t length, enum sample_format format, int volume) { if (volume == PCM_VOLUME_1) return true; if (volume <= 0) { memset(buffer, 0, length); return true; } const void *end = pcm_end_pointer(buffer, length); switch (format) { case SAMPLE_FORMAT_UNDEFINED: case SAMPLE_FORMAT_S24: case SAMPLE_FORMAT_DSD: case SAMPLE_FORMAT_DSD_LSBFIRST: /* not implemented */ return false; case SAMPLE_FORMAT_S8: pcm_volume_change_8(buffer, end, volume); return true; case SAMPLE_FORMAT_S16: pcm_volume_change_16(buffer, end, volume); return true; case SAMPLE_FORMAT_S24_P32: pcm_volume_change_24(buffer, end, volume); return true; case SAMPLE_FORMAT_S32: pcm_volume_change_32(buffer, end, volume); return true; case SAMPLE_FORMAT_FLOAT: pcm_volume_change_float(buffer, end, pcm_volume_to_float(volume)); return true; } /* unreachable */ assert(false); return false; }
andrewrk/mpd
src/pcm_volume.c
C
gpl-2.0
4,334
<?php /* $Id$ osCmax e-Commerce http://www.oscmax.com Copyright 2000 - 2011 osCmax Released under the GNU General Public License */ define('HEADING_TITLE', 'Ch&egrave;ques cadeaux envoy&eacute;s'); define('TABLE_HEADING_SENDERS_NAME', 'Nom de l\'expéditeur'); define('TABLE_HEADING_VOUCHER_VALUE', 'Valeur du bon'); define('TABLE_HEADING_VOUCHER_CODE', 'Code du bon'); define('TABLE_HEADING_DATE_SENT', 'Date de l\'envoi'); define('TABLE_HEADING_ACTION', 'Action'); define('TEXT_INFO_SENDERS_ID', 'Identifiant de l\'exp&eacute;diteur :'); define('TEXT_INFO_AMOUNT_SENT', 'Montant envoy&eacute; :'); define('TEXT_INFO_DATE_SENT', 'Date de l\'envoi :'); define('TEXT_INFO_VOUCHER_CODE', 'Code du ch&egrave;que :'); define('TEXT_INFO_EMAIL_ADDRESS', 'Adresse email :'); define('TEXT_INFO_DATE_REDEEMED', 'Date de validation :'); define('TEXT_INFO_IP_ADDRESS', 'Adresse IP :'); define('TEXT_INFO_CUSTOMERS_ID', 'Identifiant du client :'); define('TEXT_INFO_NOT_REDEEMED', 'Non valid&eacute;'); ?>
osCmax/oscmax2
catalog/admin/includes/languages/french/gv_sent.php
PHP
gpl-2.0
1,035
# icprot Web application for displaying phylogeny and results of onekp.com data analysis
ozacas/icprot
README.md
Markdown
gpl-2.0
89
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <script src="/benchmark/js/jquery.min.js"></script> <script type="text/javascript" src="/benchmark/js/js.cookie.js"></script> <title>BenchmarkTest01209</title> </head> <body> <form action="/benchmark/sqli-02/BenchmarkTest01209" method="POST" id="FormBenchmarkTest01209"> <div><label>Please explain your answer:</label></div> <br/> <div><textarea rows="4" cols="50" id="BenchmarkTest01209Area" name="BenchmarkTest01209Area"></textarea></div> <div><label>Any additional note for the reviewer:</label></div> <div><input type="text" id="answer" name="answer"></input></div> <br/> <div><label>An AJAX request will be sent with a header named BenchmarkTest01209 and value:</label> <input type="text" id="BenchmarkTest01209" name="BenchmarkTest01209" value="bar" class="safe"></input></div> <div><input type="button" id="login-btn" value="Login" onclick="submitForm()" /></div> </form> <div id="ajax-form-msg1"><pre><code class="prettyprint" id="code"></code></pre></div> <script> $('.safe').keypress(function (e) { if (e.which == 13) { submitForm(); return false; } }); function submitForm() { var formData = $("#FormBenchmarkTest01209").serialize(); var URL = $("#FormBenchmarkTest01209").attr("action"); var text = $("#FormBenchmarkTest01209 input[id=BenchmarkTest01209]").val(); var xhr = new XMLHttpRequest(); xhr.open("POST", URL, true); xhr.setRequestHeader('BenchmarkTest01209', text ); xhr.onreadystatechange = function () { if (xhr.readyState == XMLHttpRequest.DONE && xhr.status == 200) { $("#code").html(xhr.responseText); } else { $("#code").html("Error " + xhr.status + " occurred."); } } xhr.send(formData); } function escapeRegExp(str) { return str.replace(/([.*+?^=!:${}()|\[\]\/\\])/g, "\\$1"); } function replaceAll(str, find, replace) { return str.replace(new RegExp(escapeRegExp(find), 'g'), replace); } String.prototype.decodeEscapeSequence = function() { var txt = replaceAll(this,";",""); txt = replaceAll(txt,"&#","\\"); return txt.replace(/\\x([0-9A-Fa-f]{2})/g, function() { return String.fromCharCode(parseInt(arguments[1], 16)); }); }; </script> </body> </html>
h3xstream/Benchmark
src/main/webapp/sqli-02/BenchmarkTest01209.html
HTML
gpl-2.0
2,428
/* * Copyright (C) 2008 by NXP Semiconductors * All rights reserved. * * @Author: Kevin Wells * @Descr: LPC3250 SLC NAND controller interface support functions * * See file CREDITS for list of people who contributed to this * project. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as * published by the Free Software Foundation; either version 2 of * the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, * MA 02111-1307 USA */ #include <common.h> #include "lpc3250.h" #include <nand.h> #include <asm/errno.h> #include <asm/io.h> #define NAND_ALE_OFFS 4 #define NAND_CLE_OFFS 8 #define NAND_LARGE_BLOCK_PAGE_SIZE 2048 #define NAND_SMALL_BLOCK_PAGE_SIZE 512 static struct nand_ecclayout lpc32xx_nand_oob_16 = { .eccbytes = 6, .eccpos = {10, 11, 12, 13, 14, 15}, .oobfree = { {.offset = 0, . length = 4}, {.offset = 6, . length = 4} } }; extern int nand_correct_data(struct mtd_info *mtd, u_char *dat, u_char *read_ecc, u_char *calc_ecc); /* * DMA Descriptors * For Large Block: 17 descriptors = ((16 Data and ECC Read) + 1 Spare Area) * For Small Block: 5 descriptors = ((4 Data and ECC Read) + 1 Spare Area) */ static dmac_ll_t dmalist[(CONFIG_SYS_NAND_ECCSIZE/256) * 2 + 1]; static uint32_t ecc_buffer[8]; /* MAX ECC size */ static int dmachan = -1; #define XFER_PENDING ((SLCNAND->slc_stat & SLCSTAT_DMA_FIFO) | SLCNAND->slc_tc) static void lpc32xx_nand_init(void) { /* Enable clocks to the SLC NAND controller */ CLKPWR->clkpwr_nand_clk_ctrl = (CLKPWR_NANDCLK_SEL_SLC | CLKPWR_NANDCLK_SLCCLK_EN); /* Reset SLC NAND controller & clear ECC */ SLCNAND->slc_ctrl = (SLCCTRL_SW_RESET | SLCCTRL_ECC_CLEAR); /* 8-bit bus, no DMA, CE normal */ SLCNAND->slc_cfg = 0; /* Interrupts disabled and cleared */ SLCNAND->slc_ien = 0; SLCNAND->slc_icr = (SLCSTAT_INT_TC | SLCSTAT_INT_RDY_EN); SLCNAND->slc_tac = LPC32XX_SLC_NAND_TIMING; } static void lpc32xx_nand_hwcontrol(struct mtd_info *mtd, int cmd, unsigned int ctrl) { struct nand_chip *this = mtd->priv; ulong IO_ADDR_W; if (ctrl & NAND_CTRL_CHANGE) { IO_ADDR_W = (ulong) this->IO_ADDR_W; IO_ADDR_W &= ~(NAND_CLE_OFFS | NAND_ALE_OFFS); if ( ctrl & NAND_CLE ) { IO_ADDR_W |= NAND_CLE_OFFS; } else if ( ctrl & NAND_ALE ) { IO_ADDR_W |= NAND_ALE_OFFS; } if ( ctrl & NAND_NCE ) { SLCNAND->slc_cfg |= SLCCFG_CE_LOW; } else { SLCNAND->slc_cfg &= ~SLCCFG_CE_LOW; } this->IO_ADDR_W = (void *) IO_ADDR_W; } if (cmd != NAND_CMD_NONE) { writel(cmd, this->IO_ADDR_W); } } static int lpc32xx_nand_ready(struct mtd_info *mtd) { /* Check the SLC NAND controller status */ return (SLCNAND->slc_stat & SLCSTAT_NAND_READY); } static u_char lpc32xx_read_byte(struct mtd_info *mtd) { struct nand_chip *this = mtd->priv; unsigned long *pReg = (unsigned long *) this->IO_ADDR_R; volatile unsigned long tmp32; tmp32 = *pReg; return (u_char) tmp32; } /* * lpc32xx_verify_buf - [DEFAULT] Verify chip data against buffer * mtd: MTD device structure * buf: buffer containing the data to compare * len: number of bytes to compare * * Default verify function for 8bit buswith */ static int lpc32xx_verify_buf(struct mtd_info *mtd, const u_char *buf, int len) { int i; struct nand_chip *this = mtd->priv; unsigned long *pReg = (unsigned long *) this->IO_ADDR_R; volatile unsigned long tmp32; for (i=0; i<len; i++) { tmp32 = *pReg; if (buf[i] != (u_char) tmp32) return -EFAULT; } return 0; } /* Prepares DMA descriptors for NAND RD/WR operations */ /* If the size is < 256 Bytes then it is assumed to be * an OOB transfer */ static void lpc32xx_nand_dma_configure(struct nand_chip *chip, const void * buffer, int size, int read) { uint32_t i, dmasrc, ctrl, ecc_ctrl, oob_ctrl, dmadst; void __iomem * base = chip->IO_ADDR_R; uint32_t *ecc_gen = ecc_buffer; /* * CTRL descriptor entry for reading ECC * Copy Multiple times to sync DMA with Flash Controller */ ecc_ctrl = (0x5 | DMAC_CHAN_SRC_BURST_1 | DMAC_CHAN_DEST_BURST_1 | DMAC_CHAN_SRC_WIDTH_32 | DMAC_CHAN_DEST_WIDTH_32 | DMAC_CHAN_DEST_AHB1); /* CTRL descriptor entry for reading/writing Data */ ctrl = 64 | /* 256/4 */ DMAC_CHAN_SRC_BURST_4 | DMAC_CHAN_DEST_BURST_4 | DMAC_CHAN_SRC_WIDTH_32 | DMAC_CHAN_DEST_WIDTH_32 | DMAC_CHAN_DEST_AHB1; /* CTRL descriptor entry for reading/writing Spare Area */ oob_ctrl = ((CONFIG_SYS_NAND_OOBSIZE / 4) | DMAC_CHAN_SRC_BURST_4 | DMAC_CHAN_DEST_BURST_4 | DMAC_CHAN_SRC_WIDTH_32 | DMAC_CHAN_DEST_WIDTH_32 | DMAC_CHAN_DEST_AHB1); if (read) { dmasrc = (uint32_t) (base + offsetof(SLCNAND_REGS_T, slc_dma_data)); dmadst = (uint32_t) (buffer); ctrl |= DMAC_CHAN_DEST_AUTOINC; } else { dmadst = (uint32_t) (base + offsetof(SLCNAND_REGS_T, slc_dma_data)); dmasrc = (uint32_t) (buffer); ctrl |= DMAC_CHAN_SRC_AUTOINC; } /* * Write Operation Sequence for Small Block NAND * ---------------------------------------------------------- * 1. X'fer 256 bytes of data from Memory to Flash. * 2. Copy generated ECC data from Register to Spare Area * 3. X'fer next 256 bytes of data from Memory to Flash. * 4. Copy generated ECC data from Register to Spare Area. * 5. X'fer 16 byets of Spare area from Memory to Flash. * Read Operation Sequence for Small Block NAND * ---------------------------------------------------------- * 1. X'fer 256 bytes of data from Flash to Memory. * 2. Copy generated ECC data from Register to ECC calc Buffer. * 3. X'fer next 256 bytes of data from Flash to Memory. * 4. Copy generated ECC data from Register to ECC calc Buffer. * 5. X'fer 16 bytes of Spare area from Flash to Memory. * Write Operation Sequence for Large Block NAND * ---------------------------------------------------------- * 1. Steps(1-4) of Write Operations repeate for four times * which generates 16 DMA descriptors to X'fer 2048 bytes of * data & 32 bytes of ECC data. * 2. X'fer 64 bytes of Spare area from Memory to Flash. * Read Operation Sequence for Large Block NAND * ---------------------------------------------------------- * 1. Steps(1-4) of Read Operations repeate for four times * which generates 16 DMA descriptors to X'fer 2048 bytes of * data & 32 bytes of ECC data. * 2. X'fer 64 bytes of Spare area from Flash to Memory. */ for (i = 0; i < size/256; i++) { dmalist[i*2].dma_src = (read ?(dmasrc) :(dmasrc + (i*256))); dmalist[i*2].dma_dest = (read ?(dmadst + (i*256)) :dmadst); dmalist[i*2].next_lli = (uint32_t) & dmalist[(i*2)+1]; dmalist[i*2].next_ctrl = ctrl; dmalist[(i*2) + 1].dma_src = (uint32_t) (base + offsetof(SLCNAND_REGS_T, slc_ecc)); dmalist[(i*2) + 1].dma_dest = (uint32_t) & ecc_gen[i]; dmalist[(i*2) + 1].next_lli = (uint32_t) & dmalist[(i*2)+2]; dmalist[(i*2) + 1].next_ctrl = ecc_ctrl; } if (i) { /* Data only transfer */ dmalist[(i*2) - 1].next_lli = 0; dmalist[(i*2) - 1].next_ctrl |= DMAC_CHAN_INT_TC_EN; return ; } /* OOB only transfer */ if (read) { dmasrc = (uint32_t) (base + offsetof(SLCNAND_REGS_T, slc_dma_data)); dmadst = (uint32_t) (buffer); oob_ctrl |= DMAC_CHAN_DEST_AUTOINC; } else { dmadst = (uint32_t) (base + offsetof(SLCNAND_REGS_T, slc_dma_data)); dmasrc = (uint32_t) (buffer); oob_ctrl |= DMAC_CHAN_SRC_AUTOINC; } /* Read/ Write Spare Area Data To/From Flash */ dmalist[i*2].dma_src = dmasrc; dmalist[i*2].dma_dest = dmadst; dmalist[i*2].next_lli = 0; dmalist[i*2].next_ctrl = (oob_ctrl | DMAC_CHAN_INT_TC_EN); } static void lpc32xx_nand_xfer(struct mtd_info *mtd, const u_char *buf, int len, int read) { struct nand_chip *chip = mtd->priv; uint32_t config; /* DMA Channel Configuration */ config = (read ? DMAC_CHAN_FLOW_D_P2M : DMAC_CHAN_FLOW_D_M2P) | (read ? DMAC_DEST_PERIP(0) : DMAC_DEST_PERIP(DMA_PERID_NAND1)) | (read ? DMAC_SRC_PERIP(DMA_PERID_NAND1) : DMAC_SRC_PERIP(0)) | DMAC_CHAN_ENABLE; /* Prepare DMA descriptors */ lpc32xx_nand_dma_configure(chip, buf, len, read); /* Setup SLC controller and start transfer */ if (read) SLCNAND->slc_cfg |= SLCCFG_DMA_DIR; else /* NAND_ECC_WRITE */ SLCNAND->slc_cfg &= ~SLCCFG_DMA_DIR; SLCNAND->slc_cfg |= SLCCFG_DMA_BURST; /* Write length for new transfers */ if (!XFER_PENDING) SLCNAND->slc_tc = len + (len != mtd->oobsize ? mtd->oobsize : 0); SLCNAND->slc_ctrl |= SLCCTRL_DMA_START; /* Start DMA transfers */ lpc32xx_dma_start_xfer(dmachan, dmalist, config); /* Wait for NAND to be ready */ while(!lpc32xx_nand_ready(mtd)); /* Wait till DMA transfer is DONE */ if (lpc32xx_dma_wait_status(dmachan)) { printk(KERN_ERR "NAND DMA transfer error!\r\n"); } /* Stop DMA & HW ECC */ SLCNAND->slc_ctrl &= ~SLCCTRL_DMA_START; SLCNAND->slc_cfg &= ~(SLCCFG_DMA_DIR | SLCCFG_DMA_BURST | SLCCFG_ECC_EN | SLCCFG_DMA_ECC); } static uint32_t slc_ecc_copy_to_buffer(uint8_t * spare, const uint32_t * ecc, int count) { int i; for (i = 0; i < (count * 3); i += 3) { uint32_t ce = ecc[i/3]; ce = ~(ce << 2) & 0xFFFFFF; spare[i+2] = (uint8_t)(ce & 0xFF); ce >>= 8; spare[i+1] = (uint8_t)(ce & 0xFF); ce >>= 8; spare[i] = (uint8_t)(ce & 0xFF); } return 0; } static int lpc32xx_ecc_calculate(struct mtd_info *mtd, const uint8_t *dat, uint8_t *ecc_code) { return slc_ecc_copy_to_buffer(ecc_code, ecc_buffer, CONFIG_SYS_NAND_ECCSIZE == NAND_LARGE_BLOCK_PAGE_SIZE ? 8 : 2); } /* * Enables and prepares SLC NAND controller * for doing data transfers with H/W ECC enabled. */ static void lpc32xx_hwecc_enable(struct mtd_info *mtd, int mode) { /* Clear ECC */ SLCNAND->slc_ctrl = SLCCTRL_ECC_CLEAR; /* Setup SLC controller for H/W ECC operations */ SLCNAND->slc_cfg |= (SLCCFG_ECC_EN | SLCCFG_DMA_ECC); } /* * lpc32xx_write_buf - [DEFAULT] write buffer to chip * mtd: MTD device structure * buf: data buffer * len: number of bytes to write * * Default write function for 8bit buswith */ static void lpc32xx_write_buf(struct mtd_info *mtd, const u_char *buf, int len) { lpc32xx_nand_xfer(mtd, buf, len, 0); } /* * lpc32xx_read_buf - [DEFAULT] read chip data into buffer * mtd: MTD device structure * buf: buffer to store date * len: number of bytes to read * * Default read function for 8bit buswith */ static void lpc32xx_read_buf(struct mtd_info *mtd, u_char *buf, int len) { lpc32xx_nand_xfer(mtd, buf, len, 1); } int board_nand_init(struct nand_chip *nand) { /* Initial NAND interface */ lpc32xx_nand_init(); /* Acquire a channel for our use */ dmachan = lpc32xx_dma_get_channel(); if (unlikely(dmachan < 0)){ printk(KERN_INFO "Unable to get a free DMA " "channel for NAND transfers\r\n"); return -1; } /* ECC mode and size */ nand->ecc.mode = NAND_ECC_HW; nand->ecc.bytes = CONFIG_SYS_NAND_ECCBYTES; nand->ecc.size = CONFIG_SYS_NAND_ECCSIZE; if(CONFIG_SYS_NAND_ECCSIZE != NAND_LARGE_BLOCK_PAGE_SIZE) nand->ecc.layout = &lpc32xx_nand_oob_16; nand->ecc.calculate = lpc32xx_ecc_calculate; nand->ecc.correct = nand_correct_data; nand->ecc.hwctl = lpc32xx_hwecc_enable; nand->cmd_ctrl = lpc32xx_nand_hwcontrol; nand->dev_ready = lpc32xx_nand_ready; nand->chip_delay = 2000; nand->read_buf = lpc32xx_read_buf; nand->write_buf = lpc32xx_write_buf; nand->read_byte = lpc32xx_read_byte; nand->verify_buf = lpc32xx_verify_buf; return 0; }
diverger/uboot-lpc32xx
drivers/mtd/nand/lpc32xx_nand.c
C
gpl-2.0
11,991
# ganada
bwyoon/ganada
README.md
Markdown
gpl-2.0
9
/* * Copyright (C) 2005-2013 MaNGOS <http://getmangos.com/> * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include "Common.h" #include "Database/DatabaseEnv.h" #include "WorldPacket.h" #include "WorldSession.h" #include "Opcodes.h" #include "Log.h" #include "UpdateMask.h" #include "World.h" #include "ObjectMgr.h" #include "SpellMgr.h" #include "Player.h" #include "Unit.h" #include "Spell.h" #include "DynamicObject.h" #include "Group.h" #include "UpdateData.h" #include "ObjectAccessor.h" #include "Policies/Singleton.h" #include "Totem.h" #include "Creature.h" #include "Formulas.h" #include "BattleGround/BattleGround.h" #include "OutdoorPvP/OutdoorPvP.h" #include "CreatureAI.h" #include "ScriptMgr.h" #include "Util.h" #include "GridNotifiers.h" #include "GridNotifiersImpl.h" #include "CellImpl.h" #include "MapManager.h" #define NULL_AURA_SLOT 0xFF pAuraHandler AuraHandler[TOTAL_AURAS] = { &Aura::HandleNULL, // 0 SPELL_AURA_NONE &Aura::HandleBindSight, // 1 SPELL_AURA_BIND_SIGHT &Aura::HandleModPossess, // 2 SPELL_AURA_MOD_POSSESS &Aura::HandlePeriodicDamage, // 3 SPELL_AURA_PERIODIC_DAMAGE &Aura::HandleAuraDummy, // 4 SPELL_AURA_DUMMY &Aura::HandleModConfuse, // 5 SPELL_AURA_MOD_CONFUSE &Aura::HandleModCharm, // 6 SPELL_AURA_MOD_CHARM &Aura::HandleModFear, // 7 SPELL_AURA_MOD_FEAR &Aura::HandlePeriodicHeal, // 8 SPELL_AURA_PERIODIC_HEAL &Aura::HandleModAttackSpeed, // 9 SPELL_AURA_MOD_ATTACKSPEED &Aura::HandleModThreat, // 10 SPELL_AURA_MOD_THREAT &Aura::HandleModTaunt, // 11 SPELL_AURA_MOD_TAUNT &Aura::HandleAuraModStun, // 12 SPELL_AURA_MOD_STUN &Aura::HandleModDamageDone, // 13 SPELL_AURA_MOD_DAMAGE_DONE &Aura::HandleNoImmediateEffect, // 14 SPELL_AURA_MOD_DAMAGE_TAKEN implemented in Unit::MeleeDamageBonusTaken and Unit::SpellBaseDamageBonusTaken &Aura::HandleNoImmediateEffect, // 15 SPELL_AURA_DAMAGE_SHIELD implemented in Unit::DealMeleeDamage &Aura::HandleModStealth, // 16 SPELL_AURA_MOD_STEALTH &Aura::HandleNoImmediateEffect, // 17 SPELL_AURA_MOD_STEALTH_DETECT implemented in Unit::isVisibleForOrDetect &Aura::HandleInvisibility, // 18 SPELL_AURA_MOD_INVISIBILITY &Aura::HandleInvisibilityDetect, // 19 SPELL_AURA_MOD_INVISIBILITY_DETECTION &Aura::HandleAuraModTotalHealthPercentRegen, // 20 SPELL_AURA_OBS_MOD_HEALTH &Aura::HandleAuraModTotalManaPercentRegen, // 21 SPELL_AURA_OBS_MOD_MANA &Aura::HandleAuraModResistance, // 22 SPELL_AURA_MOD_RESISTANCE &Aura::HandlePeriodicTriggerSpell, // 23 SPELL_AURA_PERIODIC_TRIGGER_SPELL &Aura::HandlePeriodicEnergize, // 24 SPELL_AURA_PERIODIC_ENERGIZE &Aura::HandleAuraModPacify, // 25 SPELL_AURA_MOD_PACIFY &Aura::HandleAuraModRoot, // 26 SPELL_AURA_MOD_ROOT &Aura::HandleAuraModSilence, // 27 SPELL_AURA_MOD_SILENCE &Aura::HandleNoImmediateEffect, // 28 SPELL_AURA_REFLECT_SPELLS implement in Unit::SpellHitResult &Aura::HandleAuraModStat, // 29 SPELL_AURA_MOD_STAT &Aura::HandleAuraModSkill, // 30 SPELL_AURA_MOD_SKILL &Aura::HandleAuraModIncreaseSpeed, // 31 SPELL_AURA_MOD_INCREASE_SPEED &Aura::HandleAuraModIncreaseMountedSpeed, // 32 SPELL_AURA_MOD_INCREASE_MOUNTED_SPEED &Aura::HandleAuraModDecreaseSpeed, // 33 SPELL_AURA_MOD_DECREASE_SPEED &Aura::HandleAuraModIncreaseHealth, // 34 SPELL_AURA_MOD_INCREASE_HEALTH &Aura::HandleAuraModIncreaseEnergy, // 35 SPELL_AURA_MOD_INCREASE_ENERGY &Aura::HandleAuraModShapeshift, // 36 SPELL_AURA_MOD_SHAPESHIFT &Aura::HandleAuraModEffectImmunity, // 37 SPELL_AURA_EFFECT_IMMUNITY &Aura::HandleAuraModStateImmunity, // 38 SPELL_AURA_STATE_IMMUNITY &Aura::HandleAuraModSchoolImmunity, // 39 SPELL_AURA_SCHOOL_IMMUNITY &Aura::HandleAuraModDmgImmunity, // 40 SPELL_AURA_DAMAGE_IMMUNITY &Aura::HandleAuraModDispelImmunity, // 41 SPELL_AURA_DISPEL_IMMUNITY &Aura::HandleAuraProcTriggerSpell, // 42 SPELL_AURA_PROC_TRIGGER_SPELL implemented in Unit::ProcDamageAndSpellFor and Unit::HandleProcTriggerSpell &Aura::HandleNoImmediateEffect, // 43 SPELL_AURA_PROC_TRIGGER_DAMAGE implemented in Unit::ProcDamageAndSpellFor &Aura::HandleAuraTrackCreatures, // 44 SPELL_AURA_TRACK_CREATURES &Aura::HandleAuraTrackResources, // 45 SPELL_AURA_TRACK_RESOURCES &Aura::HandleUnused, // 46 SPELL_AURA_46 &Aura::HandleAuraModParryPercent, // 47 SPELL_AURA_MOD_PARRY_PERCENT &Aura::HandleUnused, // 48 SPELL_AURA_48 &Aura::HandleAuraModDodgePercent, // 49 SPELL_AURA_MOD_DODGE_PERCENT &Aura::HandleUnused, // 50 SPELL_AURA_MOD_BLOCK_SKILL obsolete? &Aura::HandleAuraModBlockPercent, // 51 SPELL_AURA_MOD_BLOCK_PERCENT &Aura::HandleAuraModCritPercent, // 52 SPELL_AURA_MOD_CRIT_PERCENT &Aura::HandlePeriodicLeech, // 53 SPELL_AURA_PERIODIC_LEECH &Aura::HandleModHitChance, // 54 SPELL_AURA_MOD_HIT_CHANCE &Aura::HandleModSpellHitChance, // 55 SPELL_AURA_MOD_SPELL_HIT_CHANCE &Aura::HandleAuraTransform, // 56 SPELL_AURA_TRANSFORM &Aura::HandleModSpellCritChance, // 57 SPELL_AURA_MOD_SPELL_CRIT_CHANCE &Aura::HandleAuraModIncreaseSwimSpeed, // 58 SPELL_AURA_MOD_INCREASE_SWIM_SPEED &Aura::HandleNoImmediateEffect, // 59 SPELL_AURA_MOD_DAMAGE_DONE_CREATURE implemented in Unit::MeleeDamageBonusDone and Unit::SpellDamageBonusDone &Aura::HandleAuraModPacifyAndSilence, // 60 SPELL_AURA_MOD_PACIFY_SILENCE &Aura::HandleAuraModScale, // 61 SPELL_AURA_MOD_SCALE &Aura::HandlePeriodicHealthFunnel, // 62 SPELL_AURA_PERIODIC_HEALTH_FUNNEL &Aura::HandleUnused, // 63 SPELL_AURA_PERIODIC_MANA_FUNNEL obsolete? &Aura::HandlePeriodicManaLeech, // 64 SPELL_AURA_PERIODIC_MANA_LEECH &Aura::HandleModCastingSpeed, // 65 SPELL_AURA_MOD_CASTING_SPEED_NOT_STACK &Aura::HandleFeignDeath, // 66 SPELL_AURA_FEIGN_DEATH &Aura::HandleAuraModDisarm, // 67 SPELL_AURA_MOD_DISARM &Aura::HandleAuraModStalked, // 68 SPELL_AURA_MOD_STALKED &Aura::HandleSchoolAbsorb, // 69 SPELL_AURA_SCHOOL_ABSORB implemented in Unit::CalculateAbsorbAndResist &Aura::HandleUnused, // 70 SPELL_AURA_EXTRA_ATTACKS Useless, used by only one spell that has only visual effect &Aura::HandleModSpellCritChanceShool, // 71 SPELL_AURA_MOD_SPELL_CRIT_CHANCE_SCHOOL &Aura::HandleModPowerCostPCT, // 72 SPELL_AURA_MOD_POWER_COST_SCHOOL_PCT &Aura::HandleModPowerCost, // 73 SPELL_AURA_MOD_POWER_COST_SCHOOL &Aura::HandleNoImmediateEffect, // 74 SPELL_AURA_REFLECT_SPELLS_SCHOOL implemented in Unit::SpellHitResult &Aura::HandleNoImmediateEffect, // 75 SPELL_AURA_MOD_LANGUAGE implemented in WorldSession::HandleMessagechatOpcode &Aura::HandleFarSight, // 76 SPELL_AURA_FAR_SIGHT &Aura::HandleModMechanicImmunity, // 77 SPELL_AURA_MECHANIC_IMMUNITY &Aura::HandleAuraMounted, // 78 SPELL_AURA_MOUNTED &Aura::HandleModDamagePercentDone, // 79 SPELL_AURA_MOD_DAMAGE_PERCENT_DONE &Aura::HandleModPercentStat, // 80 SPELL_AURA_MOD_PERCENT_STAT &Aura::HandleNoImmediateEffect, // 81 SPELL_AURA_SPLIT_DAMAGE_PCT implemented in Unit::CalculateAbsorbAndResist &Aura::HandleWaterBreathing, // 82 SPELL_AURA_WATER_BREATHING &Aura::HandleModBaseResistance, // 83 SPELL_AURA_MOD_BASE_RESISTANCE &Aura::HandleModRegen, // 84 SPELL_AURA_MOD_REGEN &Aura::HandleModPowerRegen, // 85 SPELL_AURA_MOD_POWER_REGEN &Aura::HandleChannelDeathItem, // 86 SPELL_AURA_CHANNEL_DEATH_ITEM &Aura::HandleNoImmediateEffect, // 87 SPELL_AURA_MOD_DAMAGE_PERCENT_TAKEN implemented in Unit::MeleeDamageBonusTaken and Unit::SpellDamageBonusTaken &Aura::HandleNoImmediateEffect, // 88 SPELL_AURA_MOD_HEALTH_REGEN_PERCENT implemented in Player::RegenerateHealth &Aura::HandlePeriodicDamagePCT, // 89 SPELL_AURA_PERIODIC_DAMAGE_PERCENT &Aura::HandleUnused, // 90 SPELL_AURA_MOD_RESIST_CHANCE Useless &Aura::HandleNoImmediateEffect, // 91 SPELL_AURA_MOD_DETECT_RANGE implemented in Creature::GetAttackDistance &Aura::HandlePreventFleeing, // 92 SPELL_AURA_PREVENTS_FLEEING &Aura::HandleModUnattackable, // 93 SPELL_AURA_MOD_UNATTACKABLE &Aura::HandleNoImmediateEffect, // 94 SPELL_AURA_INTERRUPT_REGEN implemented in Player::RegenerateAll &Aura::HandleAuraGhost, // 95 SPELL_AURA_GHOST &Aura::HandleNoImmediateEffect, // 96 SPELL_AURA_SPELL_MAGNET implemented in Unit::SelectMagnetTarget &Aura::HandleManaShield, // 97 SPELL_AURA_MANA_SHIELD implemented in Unit::CalculateAbsorbAndResist &Aura::HandleAuraModSkill, // 98 SPELL_AURA_MOD_SKILL_TALENT &Aura::HandleAuraModAttackPower, // 99 SPELL_AURA_MOD_ATTACK_POWER &Aura::HandleUnused, //100 SPELL_AURA_AURAS_VISIBLE obsolete? all player can see all auras now &Aura::HandleModResistancePercent, //101 SPELL_AURA_MOD_RESISTANCE_PCT &Aura::HandleNoImmediateEffect, //102 SPELL_AURA_MOD_MELEE_ATTACK_POWER_VERSUS implemented in Unit::MeleeDamageBonusDone &Aura::HandleAuraModTotalThreat, //103 SPELL_AURA_MOD_TOTAL_THREAT &Aura::HandleAuraWaterWalk, //104 SPELL_AURA_WATER_WALK &Aura::HandleAuraFeatherFall, //105 SPELL_AURA_FEATHER_FALL &Aura::HandleAuraHover, //106 SPELL_AURA_HOVER &Aura::HandleAddModifier, //107 SPELL_AURA_ADD_FLAT_MODIFIER &Aura::HandleAddModifier, //108 SPELL_AURA_ADD_PCT_MODIFIER &Aura::HandleNoImmediateEffect, //109 SPELL_AURA_ADD_TARGET_TRIGGER &Aura::HandleModPowerRegenPCT, //110 SPELL_AURA_MOD_POWER_REGEN_PERCENT &Aura::HandleNoImmediateEffect, //111 SPELL_AURA_ADD_CASTER_HIT_TRIGGER implemented in Unit::SelectMagnetTarget &Aura::HandleNoImmediateEffect, //112 SPELL_AURA_OVERRIDE_CLASS_SCRIPTS implemented in diff functions. &Aura::HandleNoImmediateEffect, //113 SPELL_AURA_MOD_RANGED_DAMAGE_TAKEN implemented in Unit::MeleeDamageBonusTaken &Aura::HandleNoImmediateEffect, //114 SPELL_AURA_MOD_RANGED_DAMAGE_TAKEN_PCT implemented in Unit::MeleeDamageBonusTaken &Aura::HandleNoImmediateEffect, //115 SPELL_AURA_MOD_HEALING implemented in Unit::SpellBaseHealingBonusTaken &Aura::HandleNoImmediateEffect, //116 SPELL_AURA_MOD_REGEN_DURING_COMBAT imppemented in Player::RegenerateAll and Player::RegenerateHealth &Aura::HandleNoImmediateEffect, //117 SPELL_AURA_MOD_MECHANIC_RESISTANCE implemented in Unit::MagicSpellHitResult &Aura::HandleNoImmediateEffect, //118 SPELL_AURA_MOD_HEALING_PCT implemented in Unit::SpellHealingBonusTaken &Aura::HandleUnused, //119 SPELL_AURA_SHARE_PET_TRACKING useless &Aura::HandleAuraUntrackable, //120 SPELL_AURA_UNTRACKABLE &Aura::HandleAuraEmpathy, //121 SPELL_AURA_EMPATHY &Aura::HandleModOffhandDamagePercent, //122 SPELL_AURA_MOD_OFFHAND_DAMAGE_PCT &Aura::HandleModTargetResistance, //123 SPELL_AURA_MOD_TARGET_RESISTANCE &Aura::HandleAuraModRangedAttackPower, //124 SPELL_AURA_MOD_RANGED_ATTACK_POWER &Aura::HandleNoImmediateEffect, //125 SPELL_AURA_MOD_MELEE_DAMAGE_TAKEN implemented in Unit::MeleeDamageBonusTaken &Aura::HandleNoImmediateEffect, //126 SPELL_AURA_MOD_MELEE_DAMAGE_TAKEN_PCT implemented in Unit::MeleeDamageBonusTaken &Aura::HandleNoImmediateEffect, //127 SPELL_AURA_RANGED_ATTACK_POWER_ATTACKER_BONUS implemented in Unit::MeleeDamageBonusDone &Aura::HandleModPossessPet, //128 SPELL_AURA_MOD_POSSESS_PET &Aura::HandleAuraModIncreaseSpeed, //129 SPELL_AURA_MOD_SPEED_ALWAYS &Aura::HandleAuraModIncreaseMountedSpeed, //130 SPELL_AURA_MOD_MOUNTED_SPEED_ALWAYS &Aura::HandleNoImmediateEffect, //131 SPELL_AURA_MOD_RANGED_ATTACK_POWER_VERSUS implemented in Unit::MeleeDamageBonusDone &Aura::HandleAuraModIncreaseEnergyPercent, //132 SPELL_AURA_MOD_INCREASE_ENERGY_PERCENT &Aura::HandleAuraModIncreaseHealthPercent, //133 SPELL_AURA_MOD_INCREASE_HEALTH_PERCENT &Aura::HandleAuraModRegenInterrupt, //134 SPELL_AURA_MOD_MANA_REGEN_INTERRUPT &Aura::HandleModHealingDone, //135 SPELL_AURA_MOD_HEALING_DONE &Aura::HandleNoImmediateEffect, //136 SPELL_AURA_MOD_HEALING_DONE_PERCENT implemented in Unit::SpellHealingBonusDone &Aura::HandleModTotalPercentStat, //137 SPELL_AURA_MOD_TOTAL_STAT_PERCENTAGE &Aura::HandleModMeleeSpeedPct, //138 SPELL_AURA_MOD_MELEE_HASTE &Aura::HandleForceReaction, //139 SPELL_AURA_FORCE_REACTION &Aura::HandleAuraModRangedHaste, //140 SPELL_AURA_MOD_RANGED_HASTE &Aura::HandleRangedAmmoHaste, //141 SPELL_AURA_MOD_RANGED_AMMO_HASTE &Aura::HandleAuraModBaseResistancePCT, //142 SPELL_AURA_MOD_BASE_RESISTANCE_PCT &Aura::HandleAuraModResistanceExclusive, //143 SPELL_AURA_MOD_RESISTANCE_EXCLUSIVE &Aura::HandleAuraSafeFall, //144 SPELL_AURA_SAFE_FALL implemented in WorldSession::HandleMovementOpcodes &Aura::HandleUnused, //145 SPELL_AURA_CHARISMA obsolete? &Aura::HandleUnused, //146 SPELL_AURA_PERSUADED obsolete? &Aura::HandleModMechanicImmunityMask, //147 SPELL_AURA_MECHANIC_IMMUNITY_MASK implemented in Unit::IsImmuneToSpell and Unit::IsImmuneToSpellEffect (check part) &Aura::HandleAuraRetainComboPoints, //148 SPELL_AURA_RETAIN_COMBO_POINTS &Aura::HandleNoImmediateEffect, //149 SPELL_AURA_RESIST_PUSHBACK implemented in Spell::Delayed and Spell::DelayedChannel &Aura::HandleShieldBlockValue, //150 SPELL_AURA_MOD_SHIELD_BLOCKVALUE_PCT &Aura::HandleAuraTrackStealthed, //151 SPELL_AURA_TRACK_STEALTHED &Aura::HandleNoImmediateEffect, //152 SPELL_AURA_MOD_DETECTED_RANGE implemented in Creature::GetAttackDistance &Aura::HandleNoImmediateEffect, //153 SPELL_AURA_SPLIT_DAMAGE_FLAT implemented in Unit::CalculateAbsorbAndResist &Aura::HandleNoImmediateEffect, //154 SPELL_AURA_MOD_STEALTH_LEVEL implemented in Unit::isVisibleForOrDetect &Aura::HandleNoImmediateEffect, //155 SPELL_AURA_MOD_WATER_BREATHING implemented in Player::getMaxTimer &Aura::HandleNoImmediateEffect, //156 SPELL_AURA_MOD_REPUTATION_GAIN implemented in Player::CalculateReputationGain &Aura::HandleUnused, //157 SPELL_AURA_PET_DAMAGE_MULTI (single test like spell 20782, also single for 214 aura) &Aura::HandleShieldBlockValue, //158 SPELL_AURA_MOD_SHIELD_BLOCKVALUE &Aura::HandleNoImmediateEffect, //159 SPELL_AURA_NO_PVP_CREDIT implemented in Player::RewardHonor &Aura::HandleNoImmediateEffect, //160 SPELL_AURA_MOD_AOE_AVOIDANCE implemented in Unit::MagicSpellHitResult &Aura::HandleNoImmediateEffect, //161 SPELL_AURA_MOD_HEALTH_REGEN_IN_COMBAT implemented in Player::RegenerateAll and Player::RegenerateHealth &Aura::HandleAuraPowerBurn, //162 SPELL_AURA_POWER_BURN_MANA &Aura::HandleNoImmediateEffect, //163 SPELL_AURA_MOD_CRIT_DAMAGE_BONUS implemented in Unit::CalculateMeleeDamage and Unit::SpellCriticalDamageBonus &Aura::HandleUnused, //164 useless, only one test spell &Aura::HandleNoImmediateEffect, //165 SPELL_AURA_MELEE_ATTACK_POWER_ATTACKER_BONUS implemented in Unit::MeleeDamageBonusDone &Aura::HandleAuraModAttackPowerPercent, //166 SPELL_AURA_MOD_ATTACK_POWER_PCT &Aura::HandleAuraModRangedAttackPowerPercent, //167 SPELL_AURA_MOD_RANGED_ATTACK_POWER_PCT &Aura::HandleNoImmediateEffect, //168 SPELL_AURA_MOD_DAMAGE_DONE_VERSUS implemented in Unit::SpellDamageBonusDone, Unit::MeleeDamageBonusDone &Aura::HandleNoImmediateEffect, //169 SPELL_AURA_MOD_CRIT_PERCENT_VERSUS implemented in Unit::DealDamageBySchool, Unit::DoAttackDamage, Unit::SpellCriticalBonus &Aura::HandleDetectAmore, //170 SPELL_AURA_DETECT_AMORE only for Detect Amore spell &Aura::HandleAuraModIncreaseSpeed, //171 SPELL_AURA_MOD_SPEED_NOT_STACK &Aura::HandleAuraModIncreaseMountedSpeed, //172 SPELL_AURA_MOD_MOUNTED_SPEED_NOT_STACK &Aura::HandleUnused, //173 SPELL_AURA_ALLOW_CHAMPION_SPELLS only for Proclaim Champion spell &Aura::HandleModSpellDamagePercentFromStat, //174 SPELL_AURA_MOD_SPELL_DAMAGE_OF_STAT_PERCENT implemented in Unit::SpellBaseDamageBonusDone &Aura::HandleModSpellHealingPercentFromStat, //175 SPELL_AURA_MOD_SPELL_HEALING_OF_STAT_PERCENT implemented in Unit::SpellBaseHealingBonusDone &Aura::HandleSpiritOfRedemption, //176 SPELL_AURA_SPIRIT_OF_REDEMPTION only for Spirit of Redemption spell, die at aura end &Aura::HandleNULL, //177 SPELL_AURA_AOE_CHARM &Aura::HandleNoImmediateEffect, //178 SPELL_AURA_MOD_DEBUFF_RESISTANCE implemented in Unit::MagicSpellHitResult &Aura::HandleNoImmediateEffect, //179 SPELL_AURA_MOD_ATTACKER_SPELL_CRIT_CHANCE implemented in Unit::SpellCriticalBonus &Aura::HandleNoImmediateEffect, //180 SPELL_AURA_MOD_FLAT_SPELL_DAMAGE_VERSUS implemented in Unit::SpellDamageBonusDone &Aura::HandleUnused, //181 SPELL_AURA_MOD_FLAT_SPELL_CRIT_DAMAGE_VERSUS unused &Aura::HandleAuraModResistenceOfStatPercent, //182 SPELL_AURA_MOD_RESISTANCE_OF_STAT_PERCENT &Aura::HandleNoImmediateEffect, //183 SPELL_AURA_MOD_CRITICAL_THREAT only used in 28746, implemented in ThreatCalcHelper::CalcThreat &Aura::HandleNoImmediateEffect, //184 SPELL_AURA_MOD_ATTACKER_MELEE_HIT_CHANCE implemented in Unit::RollMeleeOutcomeAgainst &Aura::HandleNoImmediateEffect, //185 SPELL_AURA_MOD_ATTACKER_RANGED_HIT_CHANCE implemented in Unit::RollMeleeOutcomeAgainst &Aura::HandleNoImmediateEffect, //186 SPELL_AURA_MOD_ATTACKER_SPELL_HIT_CHANCE implemented in Unit::MagicSpellHitResult &Aura::HandleNoImmediateEffect, //187 SPELL_AURA_MOD_ATTACKER_MELEE_CRIT_CHANCE implemented in Unit::GetUnitCriticalChance &Aura::HandleNoImmediateEffect, //188 SPELL_AURA_MOD_ATTACKER_RANGED_CRIT_CHANCE implemented in Unit::GetUnitCriticalChance &Aura::HandleModRating, //189 SPELL_AURA_MOD_RATING &Aura::HandleNoImmediateEffect, //190 SPELL_AURA_MOD_FACTION_REPUTATION_GAIN implemented in Player::CalculateReputationGain &Aura::HandleAuraModUseNormalSpeed, //191 SPELL_AURA_USE_NORMAL_MOVEMENT_SPEED &Aura::HandleModMeleeRangedSpeedPct, //192 SPELL_AURA_MOD_MELEE_RANGED_HASTE &Aura::HandleModCombatSpeedPct, //193 SPELL_AURA_HASTE_ALL (in fact combat (any type attack) speed pct) &Aura::HandleUnused, //194 SPELL_AURA_MOD_DEPRICATED_1 not used now (old SPELL_AURA_MOD_SPELL_DAMAGE_OF_INTELLECT) &Aura::HandleUnused, //195 SPELL_AURA_MOD_DEPRICATED_2 not used now (old SPELL_AURA_MOD_SPELL_HEALING_OF_INTELLECT) &Aura::HandleNULL, //196 SPELL_AURA_MOD_COOLDOWN &Aura::HandleNoImmediateEffect, //197 SPELL_AURA_MOD_ATTACKER_SPELL_AND_WEAPON_CRIT_CHANCE implemented in Unit::SpellCriticalBonus Unit::GetUnitCriticalChance &Aura::HandleUnused, //198 SPELL_AURA_MOD_ALL_WEAPON_SKILLS &Aura::HandleNoImmediateEffect, //199 SPELL_AURA_MOD_INCREASES_SPELL_PCT_TO_HIT implemented in Unit::MagicSpellHitResult &Aura::HandleNoImmediateEffect, //200 SPELL_AURA_MOD_XP_PCT implemented in Player::GiveXP &Aura::HandleAuraAllowFlight, //201 SPELL_AURA_FLY this aura enable flight mode... &Aura::HandleNoImmediateEffect, //202 SPELL_AURA_IGNORE_COMBAT_RESULT implemented in Unit::MeleeSpellHitResult &Aura::HandleNoImmediateEffect, //203 SPELL_AURA_MOD_ATTACKER_MELEE_CRIT_DAMAGE implemented in Unit::CalculateMeleeDamage and Unit::SpellCriticalDamageBonus &Aura::HandleNoImmediateEffect, //204 SPELL_AURA_MOD_ATTACKER_RANGED_CRIT_DAMAGE implemented in Unit::CalculateMeleeDamage and Unit::SpellCriticalDamageBonus &Aura::HandleNoImmediateEffect, //205 SPELL_AURA_MOD_ATTACKER_SPELL_CRIT_DAMAGE implemented in Unit::SpellCriticalDamageBonus &Aura::HandleAuraModIncreaseFlightSpeed, //206 SPELL_AURA_MOD_FLIGHT_SPEED &Aura::HandleAuraModIncreaseFlightSpeed, //207 SPELL_AURA_MOD_FLIGHT_SPEED_MOUNTED &Aura::HandleAuraModIncreaseFlightSpeed, //208 SPELL_AURA_MOD_FLIGHT_SPEED_STACKING &Aura::HandleAuraModIncreaseFlightSpeed, //209 SPELL_AURA_MOD_FLIGHT_SPEED_MOUNTED_STACKING &Aura::HandleAuraModIncreaseFlightSpeed, //210 SPELL_AURA_MOD_FLIGHT_SPEED_NOT_STACKING &Aura::HandleAuraModIncreaseFlightSpeed, //211 SPELL_AURA_MOD_FLIGHT_SPEED_MOUNTED_NOT_STACKING &Aura::HandleAuraModRangedAttackPowerOfStatPercent, //212 SPELL_AURA_MOD_RANGED_ATTACK_POWER_OF_STAT_PERCENT &Aura::HandleNoImmediateEffect, //213 SPELL_AURA_MOD_RAGE_FROM_DAMAGE_DEALT implemented in Player::RewardRage &Aura::HandleNULL, //214 Tamed Pet Passive &Aura::HandleArenaPreparation, //215 SPELL_AURA_ARENA_PREPARATION &Aura::HandleModCastingSpeed, //216 SPELL_AURA_HASTE_SPELLS &Aura::HandleUnused, //217 unused &Aura::HandleAuraModRangedHaste, //218 SPELL_AURA_HASTE_RANGED &Aura::HandleModManaRegen, //219 SPELL_AURA_MOD_MANA_REGEN_FROM_STAT &Aura::HandleUnused, //220 SPELL_AURA_MOD_RATING_FROM_STAT &Aura::HandleNULL, //221 ignored &Aura::HandleUnused, //222 unused &Aura::HandleNULL, //223 Cold Stare &Aura::HandleUnused, //224 unused &Aura::HandleNoImmediateEffect, //225 SPELL_AURA_PRAYER_OF_MENDING &Aura::HandleAuraPeriodicDummy, //226 SPELL_AURA_PERIODIC_DUMMY &Aura::HandlePeriodicTriggerSpellWithValue, //227 SPELL_AURA_PERIODIC_TRIGGER_SPELL_WITH_VALUE &Aura::HandleNoImmediateEffect, //228 SPELL_AURA_DETECT_STEALTH &Aura::HandleNoImmediateEffect, //229 SPELL_AURA_MOD_AOE_DAMAGE_AVOIDANCE implemented in Unit::SpellDamageBonusTaken &Aura::HandleAuraModIncreaseMaxHealth, //230 Commanding Shout &Aura::HandleNoImmediateEffect, //231 SPELL_AURA_PROC_TRIGGER_SPELL_WITH_VALUE &Aura::HandleNoImmediateEffect, //232 SPELL_AURA_MECHANIC_DURATION_MOD implement in Unit::CalculateAuraDuration &Aura::HandleNULL, //233 set model id to the one of the creature with id m_modifier.m_miscvalue &Aura::HandleNoImmediateEffect, //234 SPELL_AURA_MECHANIC_DURATION_MOD_NOT_STACK implement in Unit::CalculateAuraDuration &Aura::HandleAuraModDispelResist, //235 SPELL_AURA_MOD_DISPEL_RESIST implement in Unit::MagicSpellHitResult &Aura::HandleUnused, //236 unused &Aura::HandleModSpellDamagePercentFromAttackPower, //237 SPELL_AURA_MOD_SPELL_DAMAGE_OF_ATTACK_POWER implemented in Unit::SpellBaseDamageBonusDone &Aura::HandleModSpellHealingPercentFromAttackPower, //238 SPELL_AURA_MOD_SPELL_HEALING_OF_ATTACK_POWER implemented in Unit::SpellBaseHealingBonusDone &Aura::HandleAuraModScale, //239 SPELL_AURA_MOD_SCALE_2 only in Noggenfogger Elixir (16595) before 2.3.0 aura 61 &Aura::HandleAuraModExpertise, //240 SPELL_AURA_MOD_EXPERTISE &Aura::HandleForceMoveForward, //241 Forces the caster to move forward &Aura::HandleUnused, //242 unused &Aura::HandleUnused, //243 used by two test spells &Aura::HandleComprehendLanguage, //244 SPELL_AURA_COMPREHEND_LANGUAGE &Aura::HandleUnused, //245 unused &Aura::HandleUnused, //246 unused &Aura::HandleAuraMirrorImage, //247 SPELL_AURA_MIRROR_IMAGE target to become a clone of the caster &Aura::HandleNoImmediateEffect, //248 SPELL_AURA_MOD_COMBAT_RESULT_CHANCE implemented in Unit::RollMeleeOutcomeAgainst &Aura::HandleNULL, //249 &Aura::HandleAuraModIncreaseHealth, //250 SPELL_AURA_MOD_INCREASE_HEALTH_2 &Aura::HandleNULL, //251 SPELL_AURA_MOD_ENEMY_DODGE &Aura::HandleUnused, //252 unused &Aura::HandleUnused, //253 unused &Aura::HandleUnused, //254 unused &Aura::HandleUnused, //255 unused &Aura::HandleUnused, //256 unused &Aura::HandleUnused, //257 unused &Aura::HandleUnused, //258 unused &Aura::HandleUnused, //259 unused &Aura::HandleUnused, //260 unused &Aura::HandleNULL //261 SPELL_AURA_261 some phased state (44856 spell) }; static AuraType const frozenAuraTypes[] = { SPELL_AURA_MOD_ROOT, SPELL_AURA_MOD_STUN, SPELL_AURA_NONE }; Aura::Aura(SpellEntry const* spellproto, SpellEffectIndex eff, int32* currentBasePoints, SpellAuraHolder* holder, Unit* target, Unit* caster, Item* castItem) : m_spellmod(NULL), m_periodicTimer(0), m_periodicTick(0), m_removeMode(AURA_REMOVE_BY_DEFAULT), m_effIndex(eff), m_positive(false), m_isPeriodic(false), m_isAreaAura(false), m_isPersistent(false), m_in_use(0), m_spellAuraHolder(holder) { MANGOS_ASSERT(target); MANGOS_ASSERT(spellproto && spellproto == sSpellStore.LookupEntry(spellproto->Id) && "`info` must be pointer to sSpellStore element"); m_currentBasePoints = currentBasePoints ? *currentBasePoints : spellproto->CalculateSimpleValue(eff); m_positive = IsPositiveEffect(spellproto, m_effIndex); m_applyTime = time(NULL); int32 damage; if (!caster) damage = m_currentBasePoints; else { damage = caster->CalculateSpellDamage(target, spellproto, m_effIndex, &m_currentBasePoints); if (!damage && castItem && castItem->GetItemSuffixFactor()) { ItemRandomSuffixEntry const* item_rand_suffix = sItemRandomSuffixStore.LookupEntry(abs(castItem->GetItemRandomPropertyId())); if (item_rand_suffix) { for (int k = 0; k < 3; ++k) { SpellItemEnchantmentEntry const* pEnchant = sSpellItemEnchantmentStore.LookupEntry(item_rand_suffix->enchant_id[k]); if (pEnchant) { for (int t = 0; t < 3; ++t) { if (pEnchant->spellid[t] != spellproto->Id) continue; damage = uint32((item_rand_suffix->prefix[k] * castItem->GetItemSuffixFactor()) / 10000); break; } } if (damage) break; } } } } DEBUG_FILTER_LOG(LOG_FILTER_SPELL_CAST, "Aura: construct Spellid : %u, Aura : %u Target : %d Damage : %d", spellproto->Id, spellproto->EffectApplyAuraName[eff], spellproto->EffectImplicitTargetA[eff], damage); SetModifier(AuraType(spellproto->EffectApplyAuraName[eff]), damage, spellproto->EffectAmplitude[eff], spellproto->EffectMiscValue[eff]); Player* modOwner = caster ? caster->GetSpellModOwner() : NULL; // Apply periodic time mod if (modOwner && m_modifier.periodictime) modOwner->ApplySpellMod(spellproto->Id, SPELLMOD_ACTIVATION_TIME, m_modifier.periodictime); // Start periodic on next tick or at aura apply if (!spellproto->HasAttribute(SPELL_ATTR_EX5_START_PERIODIC_AT_APPLY)) m_periodicTimer = m_modifier.periodictime; } Aura::~Aura() { } AreaAura::AreaAura(SpellEntry const* spellproto, SpellEffectIndex eff, int32* currentBasePoints, SpellAuraHolder* holder, Unit* target, Unit* caster, Item* castItem) : Aura(spellproto, eff, currentBasePoints, holder, target, caster, castItem) { m_isAreaAura = true; // caster==NULL in constructor args if target==caster in fact Unit* caster_ptr = caster ? caster : target; m_radius = GetSpellRadius(sSpellRadiusStore.LookupEntry(spellproto->EffectRadiusIndex[m_effIndex])); if (Player* modOwner = caster_ptr->GetSpellModOwner()) modOwner->ApplySpellMod(spellproto->Id, SPELLMOD_RADIUS, m_radius); switch (spellproto->Effect[eff]) { case SPELL_EFFECT_APPLY_AREA_AURA_PARTY: m_areaAuraType = AREA_AURA_PARTY; break; case SPELL_EFFECT_APPLY_AREA_AURA_FRIEND: m_areaAuraType = AREA_AURA_FRIEND; break; case SPELL_EFFECT_APPLY_AREA_AURA_ENEMY: m_areaAuraType = AREA_AURA_ENEMY; if (target == caster_ptr) m_modifier.m_auraname = SPELL_AURA_NONE; // Do not do any effect on self break; case SPELL_EFFECT_APPLY_AREA_AURA_PET: m_areaAuraType = AREA_AURA_PET; break; case SPELL_EFFECT_APPLY_AREA_AURA_OWNER: m_areaAuraType = AREA_AURA_OWNER; if (target == caster_ptr) m_modifier.m_auraname = SPELL_AURA_NONE; break; default: sLog.outError("Wrong spell effect in AreaAura constructor"); MANGOS_ASSERT(false); break; } // totems are immune to any kind of area auras if (target->GetTypeId() == TYPEID_UNIT && ((Creature*)target)->IsTotem()) m_modifier.m_auraname = SPELL_AURA_NONE; } AreaAura::~AreaAura() { } PersistentAreaAura::PersistentAreaAura(SpellEntry const* spellproto, SpellEffectIndex eff, int32* currentBasePoints, SpellAuraHolder* holder, Unit* target, Unit* caster, Item* castItem) : Aura(spellproto, eff, currentBasePoints, holder, target, caster, castItem) { m_isPersistent = true; } PersistentAreaAura::~PersistentAreaAura() { } SingleEnemyTargetAura::SingleEnemyTargetAura(SpellEntry const* spellproto, SpellEffectIndex eff, int32* currentBasePoints, SpellAuraHolder* holder, Unit* target, Unit* caster, Item* castItem) : Aura(spellproto, eff, currentBasePoints, holder, target, caster, castItem) { if (caster) m_castersTargetGuid = caster->GetTypeId() == TYPEID_PLAYER ? ((Player*)caster)->GetSelectionGuid() : caster->GetTargetGuid(); } SingleEnemyTargetAura::~SingleEnemyTargetAura() { } Unit* SingleEnemyTargetAura::GetTriggerTarget() const { return ObjectAccessor::GetUnit(*(m_spellAuraHolder->GetTarget()), m_castersTargetGuid); } Aura* CreateAura(SpellEntry const* spellproto, SpellEffectIndex eff, int32* currentBasePoints, SpellAuraHolder* holder, Unit* target, Unit* caster, Item* castItem) { if (IsAreaAuraEffect(spellproto->Effect[eff])) return new AreaAura(spellproto, eff, currentBasePoints, holder, target, caster, castItem); uint32 triggeredSpellId = spellproto->EffectTriggerSpell[eff]; if (SpellEntry const* triggeredSpellInfo = sSpellStore.LookupEntry(triggeredSpellId)) for (int i = 0; i < MAX_EFFECT_INDEX; ++i) if (triggeredSpellInfo->EffectImplicitTargetA[i] == TARGET_SINGLE_ENEMY) return new SingleEnemyTargetAura(spellproto, eff, currentBasePoints, holder, target, caster, castItem); return new Aura(spellproto, eff, currentBasePoints, holder, target, caster, castItem); } SpellAuraHolder* CreateSpellAuraHolder(SpellEntry const* spellproto, Unit* target, WorldObject* caster, Item* castItem) { return new SpellAuraHolder(spellproto, target, caster, castItem); } void Aura::SetModifier(AuraType t, int32 a, uint32 pt, int32 miscValue) { m_modifier.m_auraname = t; m_modifier.m_amount = a; m_modifier.m_miscvalue = miscValue; m_modifier.periodictime = pt; } void Aura::Update(uint32 diff) { if (m_isPeriodic) { m_periodicTimer -= diff; if (m_periodicTimer <= 0) // tick also at m_periodicTimer==0 to prevent lost last tick in case max m_duration == (max m_periodicTimer)*N { // update before applying (aura can be removed in TriggerSpell or PeriodicTick calls) m_periodicTimer += m_modifier.periodictime; ++m_periodicTick; // for some infinity auras in some cases can overflow and reset PeriodicTick(); } } } void AreaAura::Update(uint32 diff) { // update for the caster of the aura if (GetCasterGuid() == GetTarget()->GetObjectGuid()) { Unit* caster = GetTarget(); if (!caster->hasUnitState(UNIT_STAT_ISOLATED)) { Unit* owner = caster->GetCharmerOrOwner(); if (!owner) owner = caster; Spell::UnitList targets; switch (m_areaAuraType) { case AREA_AURA_PARTY: { Group* pGroup = NULL; if (owner->GetTypeId() == TYPEID_PLAYER) pGroup = ((Player*)owner)->GetGroup(); if (pGroup) { uint8 subgroup = ((Player*)owner)->GetSubGroup(); for (GroupReference* itr = pGroup->GetFirstMember(); itr != NULL; itr = itr->next()) { Player* Target = itr->getSource(); if (Target && Target->isAlive() && Target->GetSubGroup() == subgroup && caster->IsFriendlyTo(Target)) { if (caster->IsWithinDistInMap(Target, m_radius)) targets.push_back(Target); Pet* pet = Target->GetPet(); if (pet && pet->isAlive() && caster->IsWithinDistInMap(pet, m_radius)) targets.push_back(pet); } } } else { // add owner if (owner != caster && caster->IsWithinDistInMap(owner, m_radius)) targets.push_back(owner); // add caster's pet Unit* pet = caster->GetPet(); if (pet && caster->IsWithinDistInMap(pet, m_radius)) targets.push_back(pet); } break; } case AREA_AURA_FRIEND: { MaNGOS::AnyFriendlyUnitInObjectRangeCheck u_check(caster, m_radius); MaNGOS::UnitListSearcher<MaNGOS::AnyFriendlyUnitInObjectRangeCheck> searcher(targets, u_check); Cell::VisitAllObjects(caster, searcher, m_radius); break; } case AREA_AURA_ENEMY: { MaNGOS::AnyAoETargetUnitInObjectRangeCheck u_check(caster, m_radius); // No GetCharmer in searcher MaNGOS::UnitListSearcher<MaNGOS::AnyAoETargetUnitInObjectRangeCheck> searcher(targets, u_check); Cell::VisitAllObjects(caster, searcher, m_radius); break; } case AREA_AURA_OWNER: case AREA_AURA_PET: { if (owner != caster && caster->IsWithinDistInMap(owner, m_radius)) targets.push_back(owner); break; } } for (Spell::UnitList::iterator tIter = targets.begin(); tIter != targets.end(); ++tIter) { // flag for seelction is need apply aura to current iteration target bool apply = true; // we need ignore present caster self applied are auras sometime // in cases if this only auras applied for spell effect Unit::SpellAuraHolderBounds spair = (*tIter)->GetSpellAuraHolderBounds(GetId()); for (Unit::SpellAuraHolderMap::const_iterator i = spair.first; i != spair.second; ++i) { if (i->second->IsDeleted()) continue; Aura* aur = i->second->GetAuraByEffectIndex(m_effIndex); if (!aur) continue; switch (m_areaAuraType) { case AREA_AURA_ENEMY: // non caster self-casted auras (non stacked) if (aur->GetModifier()->m_auraname != SPELL_AURA_NONE) apply = false; break; default: // in generic case not allow stacking area auras apply = false; break; } if (!apply) break; } if (!apply) continue; // Skip some targets (TODO: Might require better checks, also unclear how the actual caster must/can be handled) if (GetSpellProto()->HasAttribute(SPELL_ATTR_EX3_TARGET_ONLY_PLAYER) && (*tIter)->GetTypeId() != TYPEID_PLAYER) continue; if (SpellEntry const* actualSpellInfo = sSpellMgr.SelectAuraRankForLevel(GetSpellProto(), (*tIter)->getLevel())) { int32 actualBasePoints = m_currentBasePoints; // recalculate basepoints for lower rank (all AreaAura spell not use custom basepoints?) if (actualSpellInfo != GetSpellProto()) actualBasePoints = actualSpellInfo->CalculateSimpleValue(m_effIndex); SpellAuraHolder* holder = (*tIter)->GetSpellAuraHolder(actualSpellInfo->Id, GetCasterGuid()); bool addedToExisting = true; if (!holder) { holder = CreateSpellAuraHolder(actualSpellInfo, (*tIter), caster); addedToExisting = false; } holder->SetAuraDuration(GetAuraDuration()); AreaAura* aur = new AreaAura(actualSpellInfo, m_effIndex, &actualBasePoints, holder, (*tIter), caster, NULL); holder->AddAura(aur, m_effIndex); if (addedToExisting) { (*tIter)->AddAuraToModList(aur); holder->SetInUse(true); aur->ApplyModifier(true, true); holder->SetInUse(false); } else (*tIter)->AddSpellAuraHolder(holder); } } } Aura::Update(diff); } else // aura at non-caster { Unit* caster = GetCaster(); Unit* target = GetTarget(); Aura::Update(diff); // remove aura if out-of-range from caster (after teleport for example) // or caster is isolated or caster no longer has the aura // or caster is (no longer) friendly bool needFriendly = (m_areaAuraType == AREA_AURA_ENEMY ? false : true); if (!caster || caster->hasUnitState(UNIT_STAT_ISOLATED) || !caster->IsWithinDistInMap(target, m_radius) || !caster->HasAura(GetId(), GetEffIndex()) || caster->IsFriendlyTo(target) != needFriendly ) { target->RemoveSingleAuraFromSpellAuraHolder(GetId(), GetEffIndex(), GetCasterGuid()); } else if (m_areaAuraType == AREA_AURA_PARTY) // check if in same sub group { // not check group if target == owner or target == pet if (caster->GetCharmerOrOwnerGuid() != target->GetObjectGuid() && caster->GetObjectGuid() != target->GetCharmerOrOwnerGuid()) { Player* check = caster->GetCharmerOrOwnerPlayerOrPlayerItself(); Group* pGroup = check ? check->GetGroup() : NULL; if (pGroup) { Player* checkTarget = target->GetCharmerOrOwnerPlayerOrPlayerItself(); if (!checkTarget || !pGroup->SameSubGroup(check, checkTarget)) target->RemoveSingleAuraFromSpellAuraHolder(GetId(), GetEffIndex(), GetCasterGuid()); } else target->RemoveSingleAuraFromSpellAuraHolder(GetId(), GetEffIndex(), GetCasterGuid()); } } else if (m_areaAuraType == AREA_AURA_PET || m_areaAuraType == AREA_AURA_OWNER) { if (target->GetObjectGuid() != caster->GetCharmerOrOwnerGuid()) target->RemoveSingleAuraFromSpellAuraHolder(GetId(), GetEffIndex(), GetCasterGuid()); } } } void PersistentAreaAura::Update(uint32 diff) { bool remove = false; // remove the aura if its caster or the dynamic object causing it was removed // or if the target moves too far from the dynamic object if (Unit* caster = GetCaster()) { DynamicObject* dynObj = caster->GetDynObject(GetId(), GetEffIndex()); if (dynObj) { if (!GetTarget()->IsWithinDistInMap(dynObj, dynObj->GetRadius())) { remove = true; dynObj->RemoveAffected(GetTarget()); // let later reapply if target return to range } } else remove = true; } else remove = true; Aura::Update(diff); if (remove) GetTarget()->RemoveAura(GetId(), GetEffIndex()); } void Aura::ApplyModifier(bool apply, bool Real) { AuraType aura = m_modifier.m_auraname; GetHolder()->SetInUse(true); SetInUse(true); if (aura < TOTAL_AURAS) (*this.*AuraHandler [aura])(apply, Real); SetInUse(false); GetHolder()->SetInUse(false); } bool Aura::isAffectedOnSpell(SpellEntry const* spell) const { if (m_spellmod) return m_spellmod->isAffectedOnSpell(spell); // Check family name if (spell->SpellFamilyName != GetSpellProto()->SpellFamilyName) return false; ClassFamilyMask mask = sSpellMgr.GetSpellAffectMask(GetId(), GetEffIndex()); return spell->IsFitToFamilyMask(mask); } bool Aura::CanProcFrom(SpellEntry const* spell, uint32 EventProcEx, uint32 procEx, bool active, bool useClassMask) const { // Check EffectClassMask (in pre-3.x stored in spell_affect in fact) ClassFamilyMask mask = sSpellMgr.GetSpellAffectMask(GetId(), GetEffIndex()); // if no class mask defined, or spell_proc_event has SpellFamilyName=0 - allow proc if (!useClassMask || !mask) { if (!(EventProcEx & PROC_EX_EX_TRIGGER_ALWAYS)) { // Check for extra req (if none) and hit/crit if (EventProcEx == PROC_EX_NONE) { // No extra req, so can trigger only for active (damage/healing present) and hit/crit if ((procEx & (PROC_EX_NORMAL_HIT | PROC_EX_CRITICAL_HIT)) && active) return true; else return false; } else // Passive spells hits here only if resist/reflect/immune/evade { // Passive spells can`t trigger if need hit (exclude cases when procExtra include non-active flags) if ((EventProcEx & (PROC_EX_NORMAL_HIT | PROC_EX_CRITICAL_HIT) & procEx) && !active) return false; } } return true; } else { // SpellFamilyName check is performed in SpellMgr::IsSpellProcEventCanTriggeredBy and it is done once for whole holder // note: SpellFamilyName is not checked if no spell_proc_event is defined return mask.IsFitToFamilyMask(spell->SpellFamilyFlags); } } void Aura::ReapplyAffectedPassiveAuras(Unit* target, bool owner_mode) { // we need store cast item guids for self casted spells // expected that not exist permanent auras from stackable auras from different items std::map<uint32, ObjectGuid> affectedSelf; std::set<uint32> affectedAuraCaster; for (Unit::SpellAuraHolderMap::const_iterator itr = target->GetSpellAuraHolderMap().begin(); itr != target->GetSpellAuraHolderMap().end(); ++itr) { // permanent passive or permanent area aura // passive spells can be affected only by own or owner spell mods) if ((itr->second->IsPermanent() && ((owner_mode && itr->second->IsPassive()) || itr->second->IsAreaAura())) && // non deleted and not same aura (any with same spell id) !itr->second->IsDeleted() && itr->second->GetId() != GetId() && // and affected by aura isAffectedOnSpell(itr->second->GetSpellProto())) { // only applied by self or aura caster if (itr->second->GetCasterGuid() == target->GetObjectGuid()) affectedSelf[itr->second->GetId()] = itr->second->GetCastItemGuid(); else if (itr->second->GetCasterGuid() == GetCasterGuid()) affectedAuraCaster.insert(itr->second->GetId()); } } if (!affectedSelf.empty()) { Player* pTarget = target->GetTypeId() == TYPEID_PLAYER ? (Player*)target : NULL; for (std::map<uint32, ObjectGuid>::const_iterator map_itr = affectedSelf.begin(); map_itr != affectedSelf.end(); ++map_itr) { Item* item = pTarget && map_itr->second ? pTarget->GetItemByGuid(map_itr->second) : NULL; target->RemoveAurasDueToSpell(map_itr->first); target->CastSpell(target, map_itr->first, true, item); } } if (!affectedAuraCaster.empty()) { Unit* caster = GetCaster(); for (std::set<uint32>::const_iterator set_itr = affectedAuraCaster.begin(); set_itr != affectedAuraCaster.end(); ++set_itr) { target->RemoveAurasDueToSpell(*set_itr); if (caster) caster->CastSpell(GetTarget(), *set_itr, true); } } } struct ReapplyAffectedPassiveAurasHelper { explicit ReapplyAffectedPassiveAurasHelper(Aura* _aura) : aura(_aura) {} void operator()(Unit* unit) const { aura->ReapplyAffectedPassiveAuras(unit, true); } Aura* aura; }; void Aura::ReapplyAffectedPassiveAuras() { // not reapply spell mods with charges (use original value because processed and at remove) if (GetSpellProto()->procCharges) return; // not reapply some spell mods ops (mostly speedup case) switch (m_modifier.m_miscvalue) { case SPELLMOD_DURATION: case SPELLMOD_CHARGES: case SPELLMOD_NOT_LOSE_CASTING_TIME: case SPELLMOD_CASTING_TIME: case SPELLMOD_COOLDOWN: case SPELLMOD_COST: case SPELLMOD_ACTIVATION_TIME: case SPELLMOD_CASTING_TIME_OLD: return; } // reapply talents to own passive persistent auras ReapplyAffectedPassiveAuras(GetTarget(), true); // re-apply talents/passives/area auras applied to pet/totems (it affected by player spellmods) GetTarget()->CallForAllControlledUnits(ReapplyAffectedPassiveAurasHelper(this), CONTROLLED_PET | CONTROLLED_TOTEMS); // re-apply talents/passives/area auras applied to group members (it affected by player spellmods) if (Group* group = ((Player*)GetTarget())->GetGroup()) for (GroupReference* itr = group->GetFirstMember(); itr != NULL; itr = itr->next()) if (Player* member = itr->getSource()) if (member != GetTarget() && member->IsInMap(GetTarget())) ReapplyAffectedPassiveAuras(member, false); } /*********************************************************/ /*** BASIC AURA FUNCTION ***/ /*********************************************************/ void Aura::HandleAddModifier(bool apply, bool Real) { if (GetTarget()->GetTypeId() != TYPEID_PLAYER || !Real) return; if (m_modifier.m_miscvalue >= MAX_SPELLMOD) return; if (apply) { SpellEntry const* spellProto = GetSpellProto(); // Add custom charges for some mod aura switch (spellProto->Id) { case 17941: // Shadow Trance case 22008: // Netherwind Focus case 34936: // Backlash GetHolder()->SetAuraCharges(1); break; } m_spellmod = new SpellModifier( SpellModOp(m_modifier.m_miscvalue), SpellModType(m_modifier.m_auraname), // SpellModType value == spell aura types m_modifier.m_amount, this, // prevent expire spell mods with (charges > 0 && m_stackAmount > 1) // all this spell expected expire not at use but at spell proc event check spellProto->StackAmount > 1 ? 0 : GetHolder()->GetAuraCharges()); } ((Player*)GetTarget())->AddSpellMod(m_spellmod, apply); ReapplyAffectedPassiveAuras(); } void Aura::TriggerSpell() { ObjectGuid casterGUID = GetCasterGuid(); Unit* triggerTarget = GetTriggerTarget(); if (!casterGUID || !triggerTarget) return; // generic casting code with custom spells and target/caster customs uint32 trigger_spell_id = GetSpellProto()->EffectTriggerSpell[m_effIndex]; SpellEntry const* triggeredSpellInfo = sSpellStore.LookupEntry(trigger_spell_id); SpellEntry const* auraSpellInfo = GetSpellProto(); uint32 auraId = auraSpellInfo->Id; Unit* target = GetTarget(); Unit* triggerCaster = triggerTarget; WorldObject* triggerTargetObject = NULL; // specific code for cases with no trigger spell provided in field if (triggeredSpellInfo == NULL) { switch (auraSpellInfo->SpellFamilyName) { case SPELLFAMILY_GENERIC: { switch (auraId) { // Firestone Passive (1-5 ranks) case 758: case 17945: case 17947: case 17949: case 27252: { if (triggerTarget->GetTypeId() != TYPEID_PLAYER) return; Item* item = ((Player*)triggerTarget)->GetWeaponForAttack(BASE_ATTACK); if (!item) return; uint32 enchant_id = 0; switch (GetId()) { case 758: enchant_id = 1803; break; // Rank 1 case 17945: enchant_id = 1823; break; // Rank 2 case 17947: enchant_id = 1824; break; // Rank 3 case 17949: enchant_id = 1825; break; // Rank 4 case 27252: enchant_id = 2645; break; // Rank 5 default: return; } // remove old enchanting before applying new ((Player*)triggerTarget)->ApplyEnchantment(item, TEMP_ENCHANTMENT_SLOT, false); item->SetEnchantment(TEMP_ENCHANTMENT_SLOT, enchant_id, m_modifier.periodictime + 1000, 0); // add new enchanting ((Player*)triggerTarget)->ApplyEnchantment(item, TEMP_ENCHANTMENT_SLOT, true); return; } case 812: // Periodic Mana Burn { trigger_spell_id = 25779; // Mana Burn if (GetTarget()->GetTypeId() != TYPEID_UNIT) return; triggerTarget = ((Creature*)GetTarget())->SelectAttackingTarget(ATTACKING_TARGET_TOPAGGRO, 0, trigger_spell_id, SELECT_FLAG_POWER_MANA); if (!triggerTarget) return; break; } // // Polymorphic Ray // case 6965: break; // // Fire Nova (1-7 ranks) // case 8350: // case 8508: // case 8509: // case 11312: // case 11313: // case 25540: // case 25544: // break; case 9712: // Thaumaturgy Channel trigger_spell_id = 21029; break; // // Egan's Blaster // case 17368: break; // // Haunted // case 18347: break; // // Ranshalla Waiting // case 18953: break; // // Inferno // case 19695: break; // // Frostwolf Muzzle DND // case 21794: break; // // Alterac Ram Collar DND // case 21866: break; // // Celebras Waiting // case 21916: break; case 23170: // Brood Affliction: Bronze { target->CastSpell(target, 23171, true, NULL, this); return; } case 23184: // Mark of Frost case 25041: // Mark of Nature case 37125: // Mark of Death { std::list<Player*> targets; // spells existed in 1.x.x; 23183 - mark of frost; 25042 - mark of nature; both had radius of 100.0 yards in 1.x.x DBC // spells are used by Azuregos and the Emerald dragons in order to put a stun debuff on the players which resurrect during the encounter // in order to implement the missing spells we need to make a grid search for hostile players and check their auras; if they are marked apply debuff // spell 37127 used for the Mark of Death, is used server side, so it needs to be implemented here uint32 markSpellId = 0; uint32 debuffSpellId = 0; switch (auraId) { case 23184: markSpellId = 23182; debuffSpellId = 23186; break; case 25041: markSpellId = 25040; debuffSpellId = 25043; break; case 37125: markSpellId = 37128; debuffSpellId = 37131; break; } MaNGOS::AnyPlayerInObjectRangeWithAuraCheck u_check(GetTarget(), 100.0f, markSpellId); MaNGOS::PlayerListSearcher<MaNGOS::AnyPlayerInObjectRangeWithAuraCheck > checker(targets, u_check); Cell::VisitWorldObjects(GetTarget(), checker, 100.0f); for (std::list<Player*>::iterator itr = targets.begin(); itr != targets.end(); ++itr) (*itr)->CastSpell((*itr), debuffSpellId, true, NULL, NULL, casterGUID); return; } case 23493: // Restoration { uint32 heal = triggerTarget->GetMaxHealth() / 10; triggerTarget->DealHeal(triggerTarget, heal, auraSpellInfo); if (int32 mana = triggerTarget->GetMaxPower(POWER_MANA)) { mana /= 10; triggerTarget->EnergizeBySpell(triggerTarget, 23493, mana, POWER_MANA); } return; } // // Stoneclaw Totem Passive TEST // case 23792: break; // // Axe Flurry // case 24018: break; case 24210: // Mark of Arlokk { // Replacement for (classic) spell 24211 (doesn't exist anymore) std::list<Creature*> lList; // Search for all Zulian Prowler in range MaNGOS::AllCreaturesOfEntryInRangeCheck check(triggerTarget, 15101, 15.0f); MaNGOS::CreatureListSearcher<MaNGOS::AllCreaturesOfEntryInRangeCheck> searcher(lList, check); Cell::VisitGridObjects(triggerTarget, searcher, 15.0f); for (std::list<Creature*>::const_iterator itr = lList.begin(); itr != lList.end(); ++itr) if ((*itr)->isAlive()) (*itr)->AddThreat(triggerTarget, float(5000)); return; } // // Restoration // case 24379: break; // // Happy Pet // case 24716: break; case 24780: // Dream Fog { // Note: In 1.12 triggered spell 24781 still exists, need to script dummy effect for this spell then // Select an unfriendly enemy in 100y range and attack it if (target->GetTypeId() != TYPEID_UNIT) return; ThreatList const& tList = target->getThreatManager().getThreatList(); for (ThreatList::const_iterator itr = tList.begin(); itr != tList.end(); ++itr) { Unit* pUnit = target->GetMap()->GetUnit((*itr)->getUnitGuid()); if (pUnit && target->getThreatManager().getThreat(pUnit)) target->getThreatManager().modifyThreatPercent(pUnit, -100); } if (Unit* pEnemy = target->SelectRandomUnfriendlyTarget(target->getVictim(), 100.0f)) ((Creature*)target)->AI()->AttackStart(pEnemy); return; } // // Cannon Prep // case 24832: break; case 24834: // Shadow Bolt Whirl { uint32 spellForTick[8] = { 24820, 24821, 24822, 24823, 24835, 24836, 24837, 24838 }; uint32 tick = (GetAuraTicks() + 7/*-1*/) % 8; // casted in left/right (but triggered spell have wide forward cone) float forward = target->GetOrientation(); if (tick <= 3) target->SetOrientation(forward + 0.75f * M_PI_F - tick * M_PI_F / 8); // Left else target->SetOrientation(forward - 0.75f * M_PI_F + (8 - tick) * M_PI_F / 8); // Right triggerTarget->CastSpell(triggerTarget, spellForTick[tick], true, NULL, this, casterGUID); target->SetOrientation(forward); return; } // // Stink Trap // case 24918: break; // // Agro Drones // case 25152: break; case 25371: // Consume { int32 bpDamage = triggerTarget->GetMaxHealth() * 10 / 100; triggerTarget->CastCustomSpell(triggerTarget, 25373, &bpDamage, NULL, NULL, true, NULL, this, casterGUID); return; } // // Pain Spike // case 25572: break; case 26009: // Rotate 360 case 26136: // Rotate -360 { float newAngle = target->GetOrientation(); if (auraId == 26009) newAngle += M_PI_F / 40; else newAngle -= M_PI_F / 40; newAngle = MapManager::NormalizeOrientation(newAngle); target->SetFacingTo(newAngle); target->CastSpell(target, 26029, true); return; } // // Consume // case 26196: break; // // Berserk // case 26615: break; // // Defile // case 27177: break; // // Teleport: IF/UC // case 27601: break; // // Five Fat Finger Exploding Heart Technique // case 27673: break; // // Nitrous Boost // case 27746: break; // // Steam Tank Passive // case 27747: break; case 27808: // Frost Blast { int32 bpDamage = triggerTarget->GetMaxHealth() * 26 / 100; triggerTarget->CastCustomSpell(triggerTarget, 29879, &bpDamage, NULL, NULL, true, NULL, this, casterGUID); return; } // Detonate Mana case 27819: { // 50% Mana Burn int32 bpDamage = (int32)triggerTarget->GetPower(POWER_MANA) * 0.5f; triggerTarget->ModifyPower(POWER_MANA, -bpDamage); triggerTarget->CastCustomSpell(triggerTarget, 27820, &bpDamage, NULL, NULL, true, NULL, this, triggerTarget->GetObjectGuid()); return; } // // Controller Timer // case 28095: break; // Stalagg Chain and Feugen Chain case 28096: case 28111: { // X-Chain is casted by Tesla to X, so: caster == Tesla, target = X Unit* pCaster = GetCaster(); if (pCaster && pCaster->GetTypeId() == TYPEID_UNIT && !pCaster->IsWithinDistInMap(target, 60.0f)) { pCaster->InterruptNonMeleeSpells(true); ((Creature*)pCaster)->SetInCombatWithZone(); // Stalagg Tesla Passive or Feugen Tesla Passive pCaster->CastSpell(pCaster, auraId == 28096 ? 28097 : 28109, true, NULL, NULL, target->GetObjectGuid()); } return; } // Stalagg Tesla Passive and Feugen Tesla Passive case 28097: case 28109: { // X-Tesla-Passive is casted by Tesla on Tesla with original caster X, so: caster = X, target = Tesla Unit* pCaster = GetCaster(); if (pCaster && pCaster->GetTypeId() == TYPEID_UNIT) { if (pCaster->getVictim() && !pCaster->IsWithinDistInMap(target, 60.0f)) { if (Unit* pTarget = ((Creature*)pCaster)->SelectAttackingTarget(ATTACKING_TARGET_RANDOM, 0)) target->CastSpell(pTarget, 28099, false);// Shock } else { // "Evade" target->RemoveAurasDueToSpell(auraId); target->DeleteThreatList(); target->CombatStop(true); // Recast chain (Stalagg Chain or Feugen Chain target->CastSpell(pCaster, auraId == 28097 ? 28096 : 28111, false); } } return; } // // Mark of Didier // case 28114: break; // // Communique Timer, camp // case 28346: break; // // Icebolt // case 28522: break; // // Silithyst // case 29519: break; case 29528: // Inoculate Nestlewood Owlkin // prevent error reports in case ignored player target if (triggerTarget->GetTypeId() != TYPEID_UNIT) return; break; // // Overload // case 29768: break; // // Return Fire // case 29788: break; // // Return Fire // case 29793: break; // // Return Fire // case 29794: break; // // Guardian of Icecrown Passive // case 29897: break; case 29917: // Feed Captured Animal trigger_spell_id = 29916; break; // // Flame Wreath // case 29946: break; // // Flame Wreath // case 29947: break; // // Mind Exhaustion Passive // case 30025: break; // // Nether Beam - Serenity // case 30401: break; case 30427: // Extract Gas { Unit* caster = GetCaster(); if (!caster) return; // move loot to player inventory and despawn target if (caster->GetTypeId() == TYPEID_PLAYER && triggerTarget->GetTypeId() == TYPEID_UNIT && ((Creature*)triggerTarget)->GetCreatureInfo()->type == CREATURE_TYPE_GAS_CLOUD) { Player* player = (Player*)caster; Creature* creature = (Creature*)triggerTarget; // missing lootid has been reported on startup - just return if (!creature->GetCreatureInfo()->SkinLootId) return; player->AutoStoreLoot(creature, creature->GetCreatureInfo()->SkinLootId, LootTemplates_Skinning, true); creature->ForcedDespawn(); } return; } case 30576: // Quake trigger_spell_id = 30571; break; // // Burning Maul // case 30598: break; // // Regeneration // case 30799: // case 30800: // case 30801: // break; // // Despawn Self - Smoke cloud // case 31269: break; // // Time Rift Periodic // case 31320: break; // // Corrupt Medivh // case 31326: break; case 31347: // Doom { target->CastSpell(target, 31350, true); target->DealDamage(target, target->GetHealth(), NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false); return; } case 31373: // Spellcloth { // Summon Elemental after create item triggerTarget->SummonCreature(17870, 0.0f, 0.0f, 0.0f, triggerTarget->GetOrientation(), TEMPSUMMON_DEAD_DESPAWN, 0); return; } // // Bloodmyst Tesla // case 31611: break; case 31944: // Doomfire { int32 damage = m_modifier.m_amount * ((GetAuraDuration() + m_modifier.periodictime) / GetAuraMaxDuration()); triggerTarget->CastCustomSpell(triggerTarget, 31969, &damage, NULL, NULL, true, NULL, this, casterGUID); return; } // // Teleport Test // case 32236: break; // // Earthquake // case 32686: break; // // Possess // case 33401: break; // // Draw Shadows // case 33563: break; // // Murmur's Touch // case 33711: break; case 34229: // Flame Quills { // cast 24 spells 34269-34289, 34314-34316 for (uint32 spell_id = 34269; spell_id != 34290; ++spell_id) triggerTarget->CastSpell(triggerTarget, spell_id, true, NULL, this, casterGUID); for (uint32 spell_id = 34314; spell_id != 34317; ++spell_id) triggerTarget->CastSpell(triggerTarget, spell_id, true, NULL, this, casterGUID); return; } // // Gravity Lapse // case 34480: break; // // Tornado // case 34683: break; // // Frostbite Rotate // case 34748: break; // // Arcane Flurry // case 34821: break; // // Interrupt Shutdown // case 35016: break; // // Interrupt Shutdown // case 35176: break; // // Inferno // case 35268: break; // // Salaadin's Tesla // case 35515: break; // // Ethereal Channel (Red) // case 35518: break; // // Nether Vapor // case 35879: break; // // Dark Portal Storm // case 36018: break; // // Burning Maul // case 36056: break; // // Living Grove Defender Lifespan // case 36061: break; // // Professor Dabiri Talks // case 36064: break; // // Kael Gaining Power // case 36091: break; // // They Must Burn Bomb Aura // case 36344: break; // // They Must Burn Bomb Aura (self) // case 36350: break; // // Stolen Ravenous Ravager Egg // case 36401: break; // // Activated Cannon // case 36410: break; // // Stolen Ravenous Ravager Egg // case 36418: break; // // Enchanted Weapons // case 36510: break; // // Cursed Scarab Periodic // case 36556: break; // // Cursed Scarab Despawn Periodic // case 36561: break; case 36573: // Vision Guide { if (GetAuraTicks() == 10 && target->GetTypeId() == TYPEID_PLAYER) { ((Player*)target)->AreaExploredOrEventHappens(10525); target->RemoveAurasDueToSpell(36573); } return; } // // Cannon Charging (platform) // case 36785: break; // // Cannon Charging (self) // case 36860: break; case 37027: // Remote Toy trigger_spell_id = 37029; break; // // Mark of Death // case 37125: break; // // Arcane Flurry // case 37268: break; case 37429: // Spout (left) case 37430: // Spout (right) { float newAngle = target->GetOrientation(); if (auraId == 37429) newAngle += 2 * M_PI_F / 100; else newAngle -= 2 * M_PI_F / 100; newAngle = MapManager::NormalizeOrientation(newAngle); target->SetFacingTo(newAngle); target->CastSpell(target, 37433, true); return; } // // Karazhan - Chess NPC AI, Snapshot timer // case 37440: break; // // Karazhan - Chess NPC AI, action timer // case 37504: break; // // Karazhan - Chess: Is Square OCCUPIED aura (DND) // case 39400: break; // // Banish // case 37546: break; // // Shriveling Gaze // case 37589: break; // // Fake Aggro Radius (2 yd) // case 37815: break; // // Corrupt Medivh // case 37853: break; case 38495: // Eye of Grillok { target->CastSpell(target, 38530, true); return; } case 38554: // Absorb Eye of Grillok (Zezzak's Shard) { if (target->GetTypeId() != TYPEID_UNIT) return; if (Unit* caster = GetCaster()) caster->CastSpell(caster, 38495, true, NULL, this); else return; Creature* creatureTarget = (Creature*)target; creatureTarget->ForcedDespawn(); return; } // // Magic Sucker Device timer // case 38672: break; // // Tomb Guarding Charging // case 38751: break; // // Murmur's Touch // case 38794: break; case 39105: // Activate Nether-wraith Beacon (31742 Nether-wraith Beacon item) { float fX, fY, fZ; triggerTarget->GetClosePoint(fX, fY, fZ, triggerTarget->GetObjectBoundingRadius(), 20.0f); triggerTarget->SummonCreature(22408, fX, fY, fZ, triggerTarget->GetOrientation(), TEMPSUMMON_DEAD_DESPAWN, 0); return; } // // Drain World Tree Visual // case 39140: break; // // Quest - Dustin's Undead Dragon Visual aura // case 39259: break; // // Hellfire - The Exorcism, Jules releases darkness, aura // case 39306: break; // // Inferno // case 39346: break; // // Enchanted Weapons // case 39489: break; // // Shadow Bolt Whirl // case 39630: break; // // Shadow Bolt Whirl // case 39634: break; // // Shadow Inferno // case 39645: break; case 39857: // Tear of Azzinoth Summon Channel - it's not really supposed to do anything,and this only prevents the console spam trigger_spell_id = 39856; break; // // Soulgrinder Ritual Visual (Smashed) // case 39974: break; // // Simon Game Pre-game timer // case 40041: break; // // Knockdown Fel Cannon: The Aggro Check Aura // case 40113: break; // // Spirit Lance // case 40157: break; case 40398: // Demon Transform 2 switch (GetAuraTicks()) { case 1: if (target->HasAura(40506)) target->RemoveAurasDueToSpell(40506); else trigger_spell_id = 40506; break; case 2: trigger_spell_id = 40510; break; } break; case 40511: // Demon Transform 1 trigger_spell_id = 40398; break; // // Ancient Flames // case 40657: break; // // Ethereal Ring Cannon: Cannon Aura // case 40734: break; // // Cage Trap // case 40760: break; // // Random Periodic // case 40867: break; // // Prismatic Shield // case 40879: break; // // Aura of Desire // case 41350: break; // // Dementia // case 41404: break; // // Chaos Form // case 41629: break; // // Alert Drums // case 42177: break; // // Spout // case 42581: break; // // Spout // case 42582: break; // // Return to the Spirit Realm // case 44035: break; // // Curse of Boundless Agony // case 45050: break; // // Earthquake // case 46240: break; case 46736: // Personalized Weather trigger_spell_id = 46737; break; // // Stay Submerged // case 46981: break; // // Dragonblight Ram // case 47015: break; // // Party G.R.E.N.A.D.E. // case 51510: break; default: break; } break; } case SPELLFAMILY_MAGE: { switch (auraId) { case 66: // Invisibility // Here need periodic trigger reducing threat spell (or do it manually) return; default: break; } break; } // case SPELLFAMILY_WARRIOR: // { // switch(auraId) // { // // Wild Magic // case 23410: break; // // Corrupted Totems // case 23425: break; // default: // break; // } // break; // } // case SPELLFAMILY_PRIEST: // { // switch(auraId) // { // // Blue Beam // case 32930: break; // // Fury of the Dreghood Elders // case 35460: break; // default: // break; // } // break; // } case SPELLFAMILY_DRUID: { switch (auraId) { case 768: // Cat Form // trigger_spell_id not set and unknown effect triggered in this case, ignoring for while return; case 22842: // Frenzied Regeneration case 22895: case 22896: case 26999: { int32 LifePerRage = GetModifier()->m_amount; int32 lRage = target->GetPower(POWER_RAGE); if (lRage > 100) // rage stored as rage*10 lRage = 100; target->ModifyPower(POWER_RAGE, -lRage); int32 FRTriggerBasePoints = int32(lRage * LifePerRage / 10); target->CastCustomSpell(target, 22845, &FRTriggerBasePoints, NULL, NULL, true, NULL, this); return; } default: break; } break; } // case SPELLFAMILY_HUNTER: // { // switch(auraId) // { // // Frost Trap Aura // case 13810: // return; // // Rizzle's Frost Trap // case 39900: // return; // // Tame spells // case 19597: // Tame Ice Claw Bear // case 19676: // Tame Snow Leopard // case 19677: // Tame Large Crag Boar // case 19678: // Tame Adult Plainstrider // case 19679: // Tame Prairie Stalker // case 19680: // Tame Swoop // case 19681: // Tame Dire Mottled Boar // case 19682: // Tame Surf Crawler // case 19683: // Tame Armored Scorpid // case 19684: // Tame Webwood Lurker // case 19685: // Tame Nightsaber Stalker // case 19686: // Tame Strigid Screecher // case 30100: // Tame Crazed Dragonhawk // case 30103: // Tame Elder Springpaw // case 30104: // Tame Mistbat // case 30647: // Tame Barbed Crawler // case 30648: // Tame Greater Timberstrider // case 30652: // Tame Nightstalker // return; // default: // break; // } // break; // } case SPELLFAMILY_SHAMAN: { switch (auraId) { case 28820: // Lightning Shield (The Earthshatterer set trigger after cast Lighting Shield) { // Need remove self if Lightning Shield not active Unit::SpellAuraHolderMap const& auras = triggerTarget->GetSpellAuraHolderMap(); for (Unit::SpellAuraHolderMap::const_iterator itr = auras.begin(); itr != auras.end(); ++itr) { SpellEntry const* spell = itr->second->GetSpellProto(); if (spell->SpellFamilyName == SPELLFAMILY_SHAMAN && (spell->SpellFamilyFlags & UI64LIT(0x0000000000000400))) return; } triggerTarget->RemoveAurasDueToSpell(28820); return; } case 38443: // Totemic Mastery (Skyshatter Regalia (Shaman Tier 6) - bonus) { if (triggerTarget->IsAllTotemSlotsUsed()) triggerTarget->CastSpell(triggerTarget, 38437, true, NULL, this); else triggerTarget->RemoveAurasDueToSpell(38437); return; } default: break; } break; } default: break; } // Reget trigger spell proto triggeredSpellInfo = sSpellStore.LookupEntry(trigger_spell_id); } else // initial triggeredSpellInfo != NULL { // for channeled spell cast applied from aura owner to channel target (persistent aura affects already applied to true target) // come periodic casts applied to targets, so need seelct proper caster (ex. 15790) if (IsChanneledSpell(GetSpellProto()) && GetSpellProto()->Effect[GetEffIndex()] != SPELL_EFFECT_PERSISTENT_AREA_AURA) { // interesting 2 cases: periodic aura at caster of channeled spell if (target->GetObjectGuid() == casterGUID) { triggerCaster = target; if (WorldObject* channelTarget = target->GetMap()->GetWorldObject(target->GetChannelObjectGuid())) { if (channelTarget->isType(TYPEMASK_UNIT)) triggerTarget = (Unit*)channelTarget; else triggerTargetObject = channelTarget; } } // or periodic aura at caster channel target else if (Unit* caster = GetCaster()) { if (target->GetObjectGuid() == caster->GetChannelObjectGuid()) { triggerCaster = caster; triggerTarget = target; } } } // Spell exist but require custom code switch (auraId) { case 9347: // Mortal Strike { if (target->GetTypeId() != TYPEID_UNIT) return; // expected selection current fight target triggerTarget = ((Creature*)target)->SelectAttackingTarget(ATTACKING_TARGET_TOPAGGRO, 0, triggeredSpellInfo); if (!triggerTarget) return; break; } case 1010: // Curse of Idiocy { // TODO: spell casted by result in correct way mostly // BUT: // 1) target show casting at each triggered cast: target don't must show casting animation for any triggered spell // but must show affect apply like item casting // 2) maybe aura must be replace by new with accumulative stat mods instead stacking // prevent cast by triggered auras if (casterGUID == triggerTarget->GetObjectGuid()) return; // stop triggering after each affected stats lost > 90 int32 intelectLoss = 0; int32 spiritLoss = 0; Unit::AuraList const& mModStat = triggerTarget->GetAurasByType(SPELL_AURA_MOD_STAT); for (Unit::AuraList::const_iterator i = mModStat.begin(); i != mModStat.end(); ++i) { if ((*i)->GetId() == 1010) { switch ((*i)->GetModifier()->m_miscvalue) { case STAT_INTELLECT: intelectLoss += (*i)->GetModifier()->m_amount; break; case STAT_SPIRIT: spiritLoss += (*i)->GetModifier()->m_amount; break; default: break; } } } if (intelectLoss <= -90 && spiritLoss <= -90) return; break; } case 16191: // Mana Tide { triggerTarget->CastCustomSpell(triggerTarget, trigger_spell_id, &m_modifier.m_amount, NULL, NULL, true, NULL, this); return; } case 33525: // Ground Slam triggerTarget->CastSpell(triggerTarget, trigger_spell_id, true, NULL, this, casterGUID); return; case 38736: // Rod of Purification - for quest 10839 (Veil Skith: Darkstone of Terokk) { if (Unit* caster = GetCaster()) caster->CastSpell(triggerTarget, trigger_spell_id, true, NULL, this); return; } case 44883: // Encapsulate { // Self cast spell, hence overwrite caster (only channeled spell where the triggered spell deals dmg to SELF) triggerCaster = triggerTarget; break; } } } // All ok cast by default case if (triggeredSpellInfo) { if (triggerTargetObject) triggerCaster->CastSpell(triggerTargetObject->GetPositionX(), triggerTargetObject->GetPositionY(), triggerTargetObject->GetPositionZ(), triggeredSpellInfo, true, NULL, this, casterGUID); else triggerCaster->CastSpell(triggerTarget, triggeredSpellInfo, true, NULL, this, casterGUID); } else { if (Unit* caster = GetCaster()) { if (triggerTarget->GetTypeId() != TYPEID_UNIT || !sScriptMgr.OnEffectDummy(caster, GetId(), GetEffIndex(), (Creature*)triggerTarget)) sLog.outError("Aura::TriggerSpell: Spell %u have 0 in EffectTriggered[%d], not handled custom case?", GetId(), GetEffIndex()); } } } void Aura::TriggerSpellWithValue() { ObjectGuid casterGuid = GetCasterGuid(); Unit* target = GetTriggerTarget(); if (!casterGuid || !target) return; // generic casting code with custom spells and target/caster customs uint32 trigger_spell_id = GetSpellProto()->EffectTriggerSpell[m_effIndex]; int32 basepoints0 = GetModifier()->m_amount; target->CastCustomSpell(target, trigger_spell_id, &basepoints0, NULL, NULL, true, NULL, this, casterGuid); } /*********************************************************/ /*** AURA EFFECTS ***/ /*********************************************************/ void Aura::HandleAuraDummy(bool apply, bool Real) { // spells required only Real aura add/remove if (!Real) return; Unit* target = GetTarget(); // AT APPLY if (apply) { switch (GetSpellProto()->SpellFamilyName) { case SPELLFAMILY_GENERIC: { switch (GetId()) { case 1515: // Tame beast // FIX_ME: this is 2.0.12 threat effect replaced in 2.1.x by dummy aura, must be checked for correctness if (target->CanHaveThreatList()) if (Unit* caster = GetCaster()) target->AddThreat(caster, 10.0f, false, GetSpellSchoolMask(GetSpellProto()), GetSpellProto()); return; case 7057: // Haunting Spirits // expected to tick with 30 sec period (tick part see in Aura::PeriodicTick) m_isPeriodic = true; m_modifier.periodictime = 30 * IN_MILLISECONDS; m_periodicTimer = m_modifier.periodictime; return; case 10255: // Stoned { if (Unit* caster = GetCaster()) { if (caster->GetTypeId() != TYPEID_UNIT) return; caster->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); caster->addUnitState(UNIT_STAT_ROOT); } return; } case 13139: // net-o-matic // root to self part of (root_target->charge->root_self sequence if (Unit* caster = GetCaster()) caster->CastSpell(caster, 13138, true, NULL, this); return; case 28832: // Mark of Korth'azz case 28833: // Mark of Blaumeux case 28834: // Mark of Rivendare case 28835: // Mark of Zeliek { int32 damage = 0; switch (GetStackAmount()) { case 1: return; case 2: damage = 500; break; case 3: damage = 1500; break; case 4: damage = 4000; break; case 5: damage = 12500; break; default: damage = 14000 + 1000 * GetStackAmount(); break; } if (Unit* caster = GetCaster()) caster->CastCustomSpell(target, 28836, &damage, NULL, NULL, true, NULL, this); return; } case 31606: // Stormcrow Amulet { CreatureInfo const* cInfo = ObjectMgr::GetCreatureTemplate(17970); // we must assume db or script set display id to native at ending flight (if not, target is stuck with this model) if (cInfo) target->SetDisplayId(Creature::ChooseDisplayId(cInfo)); return; } case 32045: // Soul Charge case 32051: case 32052: { // max duration is 2 minutes, but expected to be random duration // real time randomness is unclear, using max 30 seconds here // see further down for expire of this aura GetHolder()->SetAuraDuration(urand(1, 30)*IN_MILLISECONDS); return; } case 33326: // Stolen Soul Dispel { target->RemoveAurasDueToSpell(32346); return; } case 36587: // Vision Guide { target->CastSpell(target, 36573, true, NULL, this); return; } // Gender spells case 38224: // Illidari Agent Illusion case 37096: // Blood Elf Illusion case 46354: // Blood Elf Illusion { uint8 gender = target->getGender(); uint32 spellId; switch (GetId()) { case 38224: spellId = (gender == GENDER_MALE ? 38225 : 38227); break; case 37096: spellId = (gender == GENDER_MALE ? 37092 : 37094); break; case 46354: spellId = (gender == GENDER_MALE ? 46355 : 46356); break; default: return; } target->CastSpell(target, spellId, true, NULL, this); return; } case 39850: // Rocket Blast if (roll_chance_i(20)) // backfire stun target->CastSpell(target, 51581, true, NULL, this); return; case 43873: // Headless Horseman Laugh target->PlayDistanceSound(11965); return; case 46699: // Requires No Ammo if (target->GetTypeId() == TYPEID_PLAYER) // not use ammo and not allow use ((Player*)target)->RemoveAmmo(); return; case 48025: // Headless Horseman's Mount Spell::SelectMountByAreaAndSkill(target, GetSpellProto(), 51621, 48024, 51617, 48023, 0); return; } break; } case SPELLFAMILY_WARRIOR: { switch (GetId()) { case 41099: // Battle Stance { if (target->GetTypeId() != TYPEID_UNIT) return; // Stance Cooldown target->CastSpell(target, 41102, true, NULL, this); // Battle Aura target->CastSpell(target, 41106, true, NULL, this); // equipment ((Creature*)target)->SetVirtualItem(VIRTUAL_ITEM_SLOT_0, 32614); ((Creature*)target)->SetVirtualItem(VIRTUAL_ITEM_SLOT_1, 0); ((Creature*)target)->SetVirtualItem(VIRTUAL_ITEM_SLOT_2, 0); return; } case 41100: // Berserker Stance { if (target->GetTypeId() != TYPEID_UNIT) return; // Stance Cooldown target->CastSpell(target, 41102, true, NULL, this); // Berserker Aura target->CastSpell(target, 41107, true, NULL, this); // equipment ((Creature*)target)->SetVirtualItem(VIRTUAL_ITEM_SLOT_0, 32614); ((Creature*)target)->SetVirtualItem(VIRTUAL_ITEM_SLOT_1, 0); ((Creature*)target)->SetVirtualItem(VIRTUAL_ITEM_SLOT_2, 0); return; } case 41101: // Defensive Stance { if (target->GetTypeId() != TYPEID_UNIT) return; // Stance Cooldown target->CastSpell(target, 41102, true, NULL, this); // Defensive Aura target->CastSpell(target, 41105, true, NULL, this); // equipment ((Creature*)target)->SetVirtualItem(VIRTUAL_ITEM_SLOT_0, 32604); ((Creature*)target)->SetVirtualItem(VIRTUAL_ITEM_SLOT_1, 31467); ((Creature*)target)->SetVirtualItem(VIRTUAL_ITEM_SLOT_2, 0); return; } } break; } case SPELLFAMILY_SHAMAN: { // Earth Shield if ((GetSpellProto()->SpellFamilyFlags & UI64LIT(0x40000000000))) { // prevent double apply bonuses if (target->GetTypeId() != TYPEID_PLAYER || !((Player*)target)->GetSession()->PlayerLoading()) { if (Unit* caster = GetCaster()) { m_modifier.m_amount = caster->SpellHealingBonusDone(target, GetSpellProto(), m_modifier.m_amount, SPELL_DIRECT_DAMAGE); m_modifier.m_amount = target->SpellHealingBonusTaken(caster, GetSpellProto(), m_modifier.m_amount, SPELL_DIRECT_DAMAGE); } } return; } break; } } } // AT REMOVE else { if (IsQuestTameSpell(GetId()) && target->isAlive()) { Unit* caster = GetCaster(); if (!caster || !caster->isAlive()) return; uint32 finalSpellId = 0; switch (GetId()) { case 19548: finalSpellId = 19597; break; case 19674: finalSpellId = 19677; break; case 19687: finalSpellId = 19676; break; case 19688: finalSpellId = 19678; break; case 19689: finalSpellId = 19679; break; case 19692: finalSpellId = 19680; break; case 19693: finalSpellId = 19684; break; case 19694: finalSpellId = 19681; break; case 19696: finalSpellId = 19682; break; case 19697: finalSpellId = 19683; break; case 19699: finalSpellId = 19685; break; case 19700: finalSpellId = 19686; break; case 30646: finalSpellId = 30647; break; case 30653: finalSpellId = 30648; break; case 30654: finalSpellId = 30652; break; case 30099: finalSpellId = 30100; break; case 30102: finalSpellId = 30103; break; case 30105: finalSpellId = 30104; break; } if (finalSpellId) caster->CastSpell(target, finalSpellId, true, NULL, this); return; } switch (GetId()) { case 10255: // Stoned { if (Unit* caster = GetCaster()) { if (caster->GetTypeId() != TYPEID_UNIT) return; // see dummy effect of spell 10254 for removal of flags etc caster->CastSpell(caster, 10254, true); } return; } case 12479: // Hex of Jammal'an target->CastSpell(target, 12480, true, NULL, this); return; case 12774: // (DND) Belnistrasz Idol Shutdown Visual { if (m_removeMode == AURA_REMOVE_BY_DEATH) return; // Idom Rool Camera Shake <- wtf, don't drink while making spellnames? if (Unit* caster = GetCaster()) caster->CastSpell(caster, 12816, true); return; } case 28169: // Mutating Injection { // Mutagen Explosion target->CastSpell(target, 28206, true, NULL, this); // Poison Cloud target->CastSpell(target, 28240, true, NULL, this); return; } case 32045: // Soul Charge { if (m_removeMode == AURA_REMOVE_BY_EXPIRE) target->CastSpell(target, 32054, true, NULL, this); return; } case 32051: // Soul Charge { if (m_removeMode == AURA_REMOVE_BY_EXPIRE) target->CastSpell(target, 32057, true, NULL, this); return; } case 32052: // Soul Charge { if (m_removeMode == AURA_REMOVE_BY_EXPIRE) target->CastSpell(target, 32053, true, NULL, this); return; } case 32286: // Focus Target Visual { if (m_removeMode == AURA_REMOVE_BY_EXPIRE) target->CastSpell(target, 32301, true, NULL, this); return; } case 35079: // Misdirection, triggered buff { if (Unit* pCaster = GetCaster()) pCaster->RemoveAurasDueToSpell(34477); return; } case 36730: // Flame Strike { target->CastSpell(target, 36731, true, NULL, this); return; } case 41099: // Battle Stance { // Battle Aura target->RemoveAurasDueToSpell(41106); return; } case 41100: // Berserker Stance { // Berserker Aura target->RemoveAurasDueToSpell(41107); return; } case 41101: // Defensive Stance { // Defensive Aura target->RemoveAurasDueToSpell(41105); return; } case 42385: // Alcaz Survey Aura { target->CastSpell(target, 42316, true, NULL, this); return; } case 42454: // Captured Totem { if (m_removeMode == AURA_REMOVE_BY_DEFAULT) { if (target->getDeathState() != CORPSE) return; Unit* pCaster = GetCaster(); if (!pCaster) return; // Captured Totem Test Credit if (Player* pPlayer = pCaster->GetCharmerOrOwnerPlayerOrPlayerItself()) pPlayer->CastSpell(pPlayer, 42455, true); } return; } case 42517: // Beam to Zelfrax { // expecting target to be a dummy creature Creature* pSummon = target->SummonCreature(23864, 0.0f, 0.0f, 0.0f, target->GetOrientation(), TEMPSUMMON_DEAD_DESPAWN, 0); Unit* pCaster = GetCaster(); if (pSummon && pCaster) pSummon->GetMotionMaster()->MovePoint(0, pCaster->GetPositionX(), pCaster->GetPositionY(), pCaster->GetPositionZ()); return; } case 44191: // Flame Strike { if (target->GetMap()->IsDungeon()) { uint32 spellId = target->GetMap()->IsRegularDifficulty() ? 44190 : 46163; target->CastSpell(target, spellId, true, NULL, this); } return; } case 45934: // Dark Fiend { // Kill target if dispelled if (m_removeMode == AURA_REMOVE_BY_DISPEL) target->DealDamage(target, target->GetHealth(), NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false); return; } case 46308: // Burning Winds { // casted only at creatures at spawn target->CastSpell(target, 47287, true, NULL, this); return; } } } // AT APPLY & REMOVE switch (GetSpellProto()->SpellFamilyName) { case SPELLFAMILY_GENERIC: { switch (GetId()) { case 6606: // Self Visual - Sleep Until Cancelled (DND) { if (apply) { target->SetStandState(UNIT_STAND_STATE_SLEEP); target->addUnitState(UNIT_STAT_ROOT); } else { target->clearUnitState(UNIT_STAT_ROOT); target->SetStandState(UNIT_STAND_STATE_STAND); } return; } case 24658: // Unstable Power { if (apply) { Unit* caster = GetCaster(); if (!caster) return; caster->CastSpell(target, 24659, true, NULL, NULL, GetCasterGuid()); } else target->RemoveAurasDueToSpell(24659); return; } case 24661: // Restless Strength { if (apply) { Unit* caster = GetCaster(); if (!caster) return; caster->CastSpell(target, 24662, true, NULL, NULL, GetCasterGuid()); } else target->RemoveAurasDueToSpell(24662); return; } case 29266: // Permanent Feign Death case 31261: // Permanent Feign Death (Root) case 37493: // Feign Death { // Unclear what the difference really is between them. // Some has effect1 that makes the difference, however not all. // Some appear to be used depending on creature location, in water, at solid ground, in air/suspended, etc // For now, just handle all the same way if (target->GetTypeId() == TYPEID_UNIT) target->SetFeignDeath(apply); return; } case 32216: // Victorious if (target->getClass() == CLASS_WARRIOR) target->ModifyAuraState(AURA_STATE_WARRIOR_VICTORY_RUSH, apply); return; case 35356: // Spawn Feign Death case 35357: // Spawn Feign Death { if (target->GetTypeId() == TYPEID_UNIT) { // Flags not set like it's done in SetFeignDeath() // UNIT_DYNFLAG_DEAD does not appear with these spells. // All of the spells appear to be present at spawn and not used to feign in combat or similar. if (apply) { target->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_UNK_29); target->SetFlag(UNIT_FIELD_FLAGS_2, UNIT_FLAG2_FEIGN_DEATH); target->addUnitState(UNIT_STAT_DIED); } else { target->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_UNK_29); target->RemoveFlag(UNIT_FIELD_FLAGS_2, UNIT_FLAG2_FEIGN_DEATH); target->clearUnitState(UNIT_STAT_DIED); } } return; } case 40133: // Summon Fire Elemental { Unit* caster = GetCaster(); if (!caster) return; Unit* owner = caster->GetOwner(); if (owner && owner->GetTypeId() == TYPEID_PLAYER) { if (apply) owner->CastSpell(owner, 8985, true); else ((Player*)owner)->RemovePet(PET_SAVE_REAGENTS); } return; } case 40132: // Summon Earth Elemental { Unit* caster = GetCaster(); if (!caster) return; Unit* owner = caster->GetOwner(); if (owner && owner->GetTypeId() == TYPEID_PLAYER) { if (apply) owner->CastSpell(owner, 19704, true); else ((Player*)owner)->RemovePet(PET_SAVE_REAGENTS); } return; } case 40214: // Dragonmaw Illusion { if (apply) { target->CastSpell(target, 40216, true); target->CastSpell(target, 42016, true); } else { target->RemoveAurasDueToSpell(40216); target->RemoveAurasDueToSpell(42016); } return; } case 42515: // Jarl Beam { // aura animate dead (fainted) state for the duration, but we need to animate the death itself (correct way below?) if (Unit* pCaster = GetCaster()) pCaster->ApplyModFlag(UNIT_FIELD_FLAGS_2, UNIT_FLAG2_FEIGN_DEATH, apply); // Beam to Zelfrax at remove if (!apply) target->CastSpell(target, 42517, true); return; } case 27978: case 40131: if (apply) target->m_AuraFlags |= UNIT_AURAFLAG_ALIVE_INVISIBLE; else target->m_AuraFlags |= ~UNIT_AURAFLAG_ALIVE_INVISIBLE; return; } break; } case SPELLFAMILY_MAGE: { // Hypothermia if (GetId() == 41425) { target->ModifyAuraState(AURA_STATE_HYPOTHERMIA, apply); return; } break; } case SPELLFAMILY_DRUID: { switch (GetId()) { case 34246: // Idol of the Emerald Queen { if (target->GetTypeId() != TYPEID_PLAYER) return; if (apply) // dummy not have proper effectclassmask m_spellmod = new SpellModifier(SPELLMOD_DOT, SPELLMOD_FLAT, m_modifier.m_amount / 7, GetId(), UI64LIT(0x001000000000)); ((Player*)target)->AddSpellMod(m_spellmod, apply); return; } } // Lifebloom if (GetSpellProto()->SpellFamilyFlags & UI64LIT(0x1000000000)) { if (apply) { if (Unit* caster = GetCaster()) { // prevent double apply bonuses if (target->GetTypeId() != TYPEID_PLAYER || !((Player*)target)->GetSession()->PlayerLoading()) { // Lifebloom ignore stack amount m_modifier.m_amount /= GetStackAmount(); m_modifier.m_amount = caster->SpellHealingBonusDone(target, GetSpellProto(), m_modifier.m_amount, SPELL_DIRECT_DAMAGE); m_modifier.m_amount = target->SpellHealingBonusTaken(caster, GetSpellProto(), m_modifier.m_amount, SPELL_DIRECT_DAMAGE); } } } else { // Final heal on duration end if (m_removeMode != AURA_REMOVE_BY_EXPIRE) return; // final heal if (target->IsInWorld() && GetStackAmount() > 0) { // Lifebloom dummy store single stack amount always int32 amount = m_modifier.m_amount; target->CastCustomSpell(target, 33778, &amount, NULL, NULL, true, NULL, this, GetCasterGuid()); } } return; } // Predatory Strikes if (target->GetTypeId() == TYPEID_PLAYER && GetSpellProto()->SpellIconID == 1563) { ((Player*)target)->UpdateAttackPowerAndDamage(); return; } break; } case SPELLFAMILY_ROGUE: break; case SPELLFAMILY_HUNTER: { switch (GetId()) { // Improved Aspect of the Viper case 38390: { if (target->GetTypeId() == TYPEID_PLAYER) { if (apply) // + effect value for Aspect of the Viper m_spellmod = new SpellModifier(SPELLMOD_EFFECT1, SPELLMOD_FLAT, m_modifier.m_amount, GetId(), UI64LIT(0x4000000000000)); ((Player*)target)->AddSpellMod(m_spellmod, apply); } return; } } break; } case SPELLFAMILY_SHAMAN: { switch (GetId()) { case 6495: // Sentry Totem { if (target->GetTypeId() != TYPEID_PLAYER) return; Totem* totem = target->GetTotem(TOTEM_SLOT_AIR); if (totem && apply) ((Player*)target)->GetCamera().SetView(totem); else ((Player*)target)->GetCamera().ResetView(); return; } } // Improved Weapon Totems if (GetSpellProto()->SpellIconID == 57 && target->GetTypeId() == TYPEID_PLAYER) { if (apply) { switch (m_effIndex) { case 0: // Windfury Totem m_spellmod = new SpellModifier(SPELLMOD_EFFECT1, SPELLMOD_PCT, m_modifier.m_amount, GetId(), UI64LIT(0x00200000000)); break; case 1: // Flametongue Totem m_spellmod = new SpellModifier(SPELLMOD_EFFECT1, SPELLMOD_PCT, m_modifier.m_amount, GetId(), UI64LIT(0x00400000000)); break; default: return; } } ((Player*)target)->AddSpellMod(m_spellmod, apply); return; } break; } } // pet auras if (PetAura const* petSpell = sSpellMgr.GetPetAura(GetId())) { if (apply) target->AddPetAura(petSpell); else target->RemovePetAura(petSpell); return; } if (GetEffIndex() == EFFECT_INDEX_0 && target->GetTypeId() == TYPEID_PLAYER) { SpellAreaForAreaMapBounds saBounds = sSpellMgr.GetSpellAreaForAuraMapBounds(GetId()); if (saBounds.first != saBounds.second) { uint32 zone, area; target->GetZoneAndAreaId(zone, area); for (SpellAreaForAreaMap::const_iterator itr = saBounds.first; itr != saBounds.second; ++itr) { // some auras remove at aura remove if (!itr->second->IsFitToRequirements((Player*)target, zone, area)) target->RemoveAurasDueToSpell(itr->second->spellId); // some auras applied at aura apply else if (itr->second->autocast) { if (!target->HasAura(itr->second->spellId, EFFECT_INDEX_0)) target->CastSpell(target, itr->second->spellId, true); } } } } // script has to "handle with care", only use where data are not ok to use in the above code. if (target->GetTypeId() == TYPEID_UNIT) sScriptMgr.OnAuraDummy(this, apply); } void Aura::HandleAuraMounted(bool apply, bool Real) { // only at real add/remove aura if (!Real) return; Unit* target = GetTarget(); if (apply) { CreatureInfo const* ci = ObjectMgr::GetCreatureTemplate(m_modifier.m_miscvalue); if (!ci) { sLog.outErrorDb("AuraMounted: `creature_template`='%u' not found in database (only need it modelid)", m_modifier.m_miscvalue); return; } uint32 display_id = Creature::ChooseDisplayId(ci); CreatureModelInfo const* minfo = sObjectMgr.GetCreatureModelRandomGender(display_id); if (minfo) display_id = minfo->modelid; target->Mount(display_id, GetId()); } else { target->Unmount(true); } } void Aura::HandleAuraWaterWalk(bool apply, bool Real) { // only at real add/remove aura if (!Real) return; GetTarget()->SetWaterWalk(apply); } void Aura::HandleAuraFeatherFall(bool apply, bool Real) { // only at real add/remove aura if (!Real) return; Unit* target = GetTarget(); WorldPacket data; if (apply) data.Initialize(SMSG_MOVE_FEATHER_FALL, 8 + 4); else data.Initialize(SMSG_MOVE_NORMAL_FALL, 8 + 4); data << target->GetPackGUID(); data << uint32(0); target->SendMessageToSet(&data, true); // start fall from current height if (!apply && target->GetTypeId() == TYPEID_PLAYER) ((Player*)target)->SetFallInformation(0, target->GetPositionZ()); } void Aura::HandleAuraHover(bool apply, bool Real) { // only at real add/remove aura if (!Real) return; WorldPacket data; if (apply) data.Initialize(SMSG_MOVE_SET_HOVER, 8 + 4); else data.Initialize(SMSG_MOVE_UNSET_HOVER, 8 + 4); data << GetTarget()->GetPackGUID(); data << uint32(0); GetTarget()->SendMessageToSet(&data, true); } void Aura::HandleWaterBreathing(bool /*apply*/, bool /*Real*/) { // update timers in client if (GetTarget()->GetTypeId() == TYPEID_PLAYER) ((Player*)GetTarget())->UpdateMirrorTimers(); } void Aura::HandleAuraModShapeshift(bool apply, bool Real) { if (!Real) return; ShapeshiftForm form = ShapeshiftForm(m_modifier.m_miscvalue); SpellShapeshiftFormEntry const* ssEntry = sSpellShapeshiftFormStore.LookupEntry(form); if (!ssEntry) { sLog.outError("Unknown shapeshift form %u in spell %u", form, GetId()); return; } uint32 modelid = 0; Powers PowerType = POWER_MANA; Unit* target = GetTarget(); if (ssEntry->modelID_A) { // i will asume that creatures will always take the defined model from the dbc // since no field in creature_templates describes wether an alliance or // horde modelid should be used at shapeshifting if (target->GetTypeId() != TYPEID_PLAYER) modelid = ssEntry->modelID_A; else { // players are a bit different since the dbc has seldomly an horde modelid if (Player::TeamForRace(target->getRace()) == HORDE) { // get model for race ( in 2.2.4 no horde models in dbc field, only 0 in it modelid = sObjectMgr.GetModelForRace(ssEntry->modelID_A, target->getRaceMask()); } // nothing found in above, so use default if (!modelid) modelid = ssEntry->modelID_A; } } // remove polymorph before changing display id to keep new display id switch (form) { case FORM_CAT: case FORM_TREE: case FORM_TRAVEL: case FORM_AQUA: case FORM_BEAR: case FORM_DIREBEAR: case FORM_FLIGHT_EPIC: case FORM_FLIGHT: case FORM_MOONKIN: { // remove movement affects target->RemoveSpellsCausingAura(SPELL_AURA_MOD_ROOT, GetHolder()); Unit::AuraList const& slowingAuras = target->GetAurasByType(SPELL_AURA_MOD_DECREASE_SPEED); for (Unit::AuraList::const_iterator iter = slowingAuras.begin(); iter != slowingAuras.end();) { SpellEntry const* aurSpellInfo = (*iter)->GetSpellProto(); uint32 aurMechMask = GetAllSpellMechanicMask(aurSpellInfo); // If spell that caused this aura has Croud Control or Daze effect if ((aurMechMask & MECHANIC_NOT_REMOVED_BY_SHAPESHIFT) || // some Daze spells have these parameters instead of MECHANIC_DAZE (skip snare spells) (aurSpellInfo->SpellIconID == 15 && aurSpellInfo->Dispel == 0 && (aurMechMask & (1 << (MECHANIC_SNARE - 1))) == 0)) { ++iter; continue; } // All OK, remove aura now target->RemoveAurasDueToSpellByCancel(aurSpellInfo->Id); iter = slowingAuras.begin(); } // and polymorphic affects if (target->IsPolymorphed()) target->RemoveAurasDueToSpell(target->getTransForm()); break; } default: break; } if (apply) { // remove other shapeshift before applying a new one target->RemoveSpellsCausingAura(SPELL_AURA_MOD_SHAPESHIFT, GetHolder()); if (modelid > 0) target->SetDisplayId(modelid); // now only powertype must be set switch (form) { case FORM_CAT: PowerType = POWER_ENERGY; break; case FORM_BEAR: case FORM_DIREBEAR: case FORM_BATTLESTANCE: case FORM_BERSERKERSTANCE: case FORM_DEFENSIVESTANCE: PowerType = POWER_RAGE; break; default: break; } if (PowerType != POWER_MANA) { // reset power to default values only at power change if (target->getPowerType() != PowerType) target->setPowerType(PowerType); switch (form) { case FORM_CAT: case FORM_BEAR: case FORM_DIREBEAR: { // get furor proc chance int32 furorChance = 0; Unit::AuraList const& mDummy = target->GetAurasByType(SPELL_AURA_DUMMY); for (Unit::AuraList::const_iterator i = mDummy.begin(); i != mDummy.end(); ++i) { if ((*i)->GetSpellProto()->SpellIconID == 238) { furorChance = (*i)->GetModifier()->m_amount; break; } } if (m_modifier.m_miscvalue == FORM_CAT) { target->SetPower(POWER_ENERGY, 0); if (irand(1, 100) <= furorChance) target->CastSpell(target, 17099, true, NULL, this); } else { target->SetPower(POWER_RAGE, 0); if (irand(1, 100) <= furorChance) target->CastSpell(target, 17057, true, NULL, this); } break; } case FORM_BATTLESTANCE: case FORM_DEFENSIVESTANCE: case FORM_BERSERKERSTANCE: { uint32 Rage_val = 0; // Stance mastery + Tactical mastery (both passive, and last have aura only in defense stance, but need apply at any stance switch) if (target->GetTypeId() == TYPEID_PLAYER) { PlayerSpellMap const& sp_list = ((Player*)target)->GetSpellMap(); for (PlayerSpellMap::const_iterator itr = sp_list.begin(); itr != sp_list.end(); ++itr) { if (itr->second.state == PLAYERSPELL_REMOVED) continue; SpellEntry const* spellInfo = sSpellStore.LookupEntry(itr->first); if (spellInfo && spellInfo->SpellFamilyName == SPELLFAMILY_WARRIOR && spellInfo->SpellIconID == 139) Rage_val += target->CalculateSpellDamage(target, spellInfo, EFFECT_INDEX_0) * 10; } } if (target->GetPower(POWER_RAGE) > Rage_val) target->SetPower(POWER_RAGE, Rage_val); break; } default: break; } } target->SetShapeshiftForm(form); // a form can give the player a new castbar with some spells.. this is a clientside process.. // serverside just needs to register the new spells so that player isn't kicked as cheater if (target->GetTypeId() == TYPEID_PLAYER) for (uint32 i = 0; i < 8; ++i) if (ssEntry->spellId[i]) ((Player*)target)->addSpell(ssEntry->spellId[i], true, false, false, false); } else { if (modelid > 0) target->SetDisplayId(target->GetNativeDisplayId()); if (target->getClass() == CLASS_DRUID) target->setPowerType(POWER_MANA); target->SetShapeshiftForm(FORM_NONE); switch (form) { // Nordrassil Harness - bonus case FORM_BEAR: case FORM_DIREBEAR: case FORM_CAT: if (Aura* dummy = target->GetDummyAura(37315)) target->CastSpell(target, 37316, true, NULL, dummy); break; // Nordrassil Regalia - bonus case FORM_MOONKIN: if (Aura* dummy = target->GetDummyAura(37324)) target->CastSpell(target, 37325, true, NULL, dummy); break; default: break; } // look at the comment in apply-part if (target->GetTypeId() == TYPEID_PLAYER) for (uint32 i = 0; i < 8; ++i) if (ssEntry->spellId[i]) ((Player*)target)->removeSpell(ssEntry->spellId[i], false, false, false); } // adding/removing linked auras // add/remove the shapeshift aura's boosts HandleShapeshiftBoosts(apply); if (target->GetTypeId() == TYPEID_PLAYER) ((Player*)target)->InitDataForForm(); } void Aura::HandleAuraTransform(bool apply, bool Real) { Unit* target = GetTarget(); if (apply) { // special case (spell specific functionality) if (m_modifier.m_miscvalue == 0) { switch (GetId()) { case 16739: // Orb of Deception { uint32 orb_model = target->GetNativeDisplayId(); switch (orb_model) { // Troll Female case 1479: target->SetDisplayId(10134); break; // Troll Male case 1478: target->SetDisplayId(10135); break; // Tauren Male case 59: target->SetDisplayId(10136); break; // Human Male case 49: target->SetDisplayId(10137); break; // Human Female case 50: target->SetDisplayId(10138); break; // Orc Male case 51: target->SetDisplayId(10139); break; // Orc Female case 52: target->SetDisplayId(10140); break; // Dwarf Male case 53: target->SetDisplayId(10141); break; // Dwarf Female case 54: target->SetDisplayId(10142); break; // NightElf Male case 55: target->SetDisplayId(10143); break; // NightElf Female case 56: target->SetDisplayId(10144); break; // Undead Female case 58: target->SetDisplayId(10145); break; // Undead Male case 57: target->SetDisplayId(10146); break; // Tauren Female case 60: target->SetDisplayId(10147); break; // Gnome Male case 1563: target->SetDisplayId(10148); break; // Gnome Female case 1564: target->SetDisplayId(10149); break; // BloodElf Female case 15475: target->SetDisplayId(17830); break; // BloodElf Male case 15476: target->SetDisplayId(17829); break; // Dranei Female case 16126: target->SetDisplayId(17828); break; // Dranei Male case 16125: target->SetDisplayId(17827); break; default: break; } break; } case 42365: // Murloc costume target->SetDisplayId(21723); break; // case 44186: // Gossip NPC Appearance - All, Brewfest // break; // case 48305: // Gossip NPC Appearance - All, Spirit of Competition // break; case 50517: // Dread Corsair case 51926: // Corsair Costume { // expected for players uint32 race = target->getRace(); switch (race) { case RACE_HUMAN: target->SetDisplayId(target->getGender() == GENDER_MALE ? 25037 : 25048); break; case RACE_ORC: target->SetDisplayId(target->getGender() == GENDER_MALE ? 25039 : 25050); break; case RACE_DWARF: target->SetDisplayId(target->getGender() == GENDER_MALE ? 25034 : 25045); break; case RACE_NIGHTELF: target->SetDisplayId(target->getGender() == GENDER_MALE ? 25038 : 25049); break; case RACE_UNDEAD: target->SetDisplayId(target->getGender() == GENDER_MALE ? 25042 : 25053); break; case RACE_TAUREN: target->SetDisplayId(target->getGender() == GENDER_MALE ? 25040 : 25051); break; case RACE_GNOME: target->SetDisplayId(target->getGender() == GENDER_MALE ? 25035 : 25046); break; case RACE_TROLL: target->SetDisplayId(target->getGender() == GENDER_MALE ? 25041 : 25052); break; case RACE_GOBLIN: // not really player race (3.x), but model exist target->SetDisplayId(target->getGender() == GENDER_MALE ? 25036 : 25047); break; case RACE_BLOODELF: target->SetDisplayId(target->getGender() == GENDER_MALE ? 25032 : 25043); break; case RACE_DRAENEI: target->SetDisplayId(target->getGender() == GENDER_MALE ? 25033 : 25044); break; } break; } // case 50531: // Gossip NPC Appearance - All, Pirate Day // break; // case 51010: // Dire Brew // break; default: sLog.outError("Aura::HandleAuraTransform, spell %u does not have creature entry defined, need custom defined model.", GetId()); break; } } else // m_modifier.m_miscvalue != 0 { uint32 model_id; CreatureInfo const* ci = ObjectMgr::GetCreatureTemplate(m_modifier.m_miscvalue); if (!ci) { model_id = 16358; // pig pink ^_^ sLog.outError("Auras: unknown creature id = %d (only need its modelid) Form Spell Aura Transform in Spell ID = %d", m_modifier.m_miscvalue, GetId()); } else model_id = Creature::ChooseDisplayId(ci); // Will use the default model here target->SetDisplayId(model_id); // creature case, need to update equipment if additional provided if (ci && target->GetTypeId() == TYPEID_UNIT) ((Creature*)target)->LoadEquipment(ci->equipmentId, false); // Dragonmaw Illusion (set mount model also) if (GetId() == 42016 && target->GetMountID() && !target->GetAurasByType(SPELL_AURA_MOD_FLIGHT_SPEED_MOUNTED).empty()) target->SetUInt32Value(UNIT_FIELD_MOUNTDISPLAYID, 16314); } // update active transform spell only not set or not overwriting negative by positive case if (!target->getTransForm() || !IsPositiveSpell(GetId()) || IsPositiveSpell(target->getTransForm())) target->setTransForm(GetId()); // polymorph case if (Real && target->GetTypeId() == TYPEID_PLAYER && target->IsPolymorphed()) { // for players, start regeneration after 1s (in polymorph fast regeneration case) // only if caster is Player (after patch 2.4.2) if (GetCasterGuid().IsPlayer()) ((Player*)target)->setRegenTimer(1 * IN_MILLISECONDS); // dismount polymorphed target (after patch 2.4.2) if (target->IsMounted()) target->RemoveSpellsCausingAura(SPELL_AURA_MOUNTED, GetHolder()); } } else // !apply { // ApplyModifier(true) will reapply it if need target->setTransForm(0); target->SetDisplayId(target->GetNativeDisplayId()); // apply default equipment for creature case if (target->GetTypeId() == TYPEID_UNIT) ((Creature*)target)->LoadEquipment(((Creature*)target)->GetCreatureInfo()->equipmentId, true); // re-apply some from still active with preference negative cases Unit::AuraList const& otherTransforms = target->GetAurasByType(SPELL_AURA_TRANSFORM); if (!otherTransforms.empty()) { // look for other transform auras Aura* handledAura = *otherTransforms.begin(); for (Unit::AuraList::const_iterator i = otherTransforms.begin(); i != otherTransforms.end(); ++i) { // negative auras are preferred if (!IsPositiveSpell((*i)->GetSpellProto()->Id)) { handledAura = *i; break; } } handledAura->ApplyModifier(true); } // Dragonmaw Illusion (restore mount model) if (GetId() == 42016 && target->GetMountID() == 16314) { if (!target->GetAurasByType(SPELL_AURA_MOUNTED).empty()) { uint32 cr_id = target->GetAurasByType(SPELL_AURA_MOUNTED).front()->GetModifier()->m_miscvalue; if (CreatureInfo const* ci = ObjectMgr::GetCreatureTemplate(cr_id)) { uint32 display_id = Creature::ChooseDisplayId(ci); CreatureModelInfo const* minfo = sObjectMgr.GetCreatureModelRandomGender(display_id); if (minfo) display_id = minfo->modelid; target->SetUInt32Value(UNIT_FIELD_MOUNTDISPLAYID, display_id); } } } } } void Aura::HandleForceReaction(bool apply, bool Real) { if (GetTarget()->GetTypeId() != TYPEID_PLAYER) return; if (!Real) return; Player* player = (Player*)GetTarget(); uint32 faction_id = m_modifier.m_miscvalue; ReputationRank faction_rank = ReputationRank(m_modifier.m_amount); player->GetReputationMgr().ApplyForceReaction(faction_id, faction_rank, apply); player->GetReputationMgr().SendForceReactions(); // stop fighting if at apply forced rank friendly or at remove real rank friendly if ((apply && faction_rank >= REP_FRIENDLY) || (!apply && player->GetReputationRank(faction_id) >= REP_FRIENDLY)) player->StopAttackFaction(faction_id); } void Aura::HandleAuraModSkill(bool apply, bool /*Real*/) { if (GetTarget()->GetTypeId() != TYPEID_PLAYER) return; uint32 prot = GetSpellProto()->EffectMiscValue[m_effIndex]; int32 points = GetModifier()->m_amount; ((Player*)GetTarget())->ModifySkillBonus(prot, (apply ? points : -points), m_modifier.m_auraname == SPELL_AURA_MOD_SKILL_TALENT); if (prot == SKILL_DEFENSE) ((Player*)GetTarget())->UpdateDefenseBonusesMod(); } void Aura::HandleChannelDeathItem(bool apply, bool Real) { if (Real && !apply) { if (m_removeMode != AURA_REMOVE_BY_DEATH) return; // Item amount if (m_modifier.m_amount <= 0) return; SpellEntry const* spellInfo = GetSpellProto(); if (spellInfo->EffectItemType[m_effIndex] == 0) return; Unit* victim = GetTarget(); Unit* caster = GetCaster(); if (!caster || caster->GetTypeId() != TYPEID_PLAYER) return; // Soul Shard (target req.) if (spellInfo->EffectItemType[m_effIndex] == 6265) { // Only from non-grey units if (!((Player*)caster)->isHonorOrXPTarget(victim) || (victim->GetTypeId() == TYPEID_UNIT && !((Player*)caster)->isAllowedToLoot((Creature*)victim))) return; } // Adding items uint32 noSpaceForCount = 0; uint32 count = m_modifier.m_amount; ItemPosCountVec dest; InventoryResult msg = ((Player*)caster)->CanStoreNewItem(NULL_BAG, NULL_SLOT, dest, spellInfo->EffectItemType[m_effIndex], count, &noSpaceForCount); if (msg != EQUIP_ERR_OK) { count -= noSpaceForCount; ((Player*)caster)->SendEquipError(msg, NULL, NULL, spellInfo->EffectItemType[m_effIndex]); if (count == 0) return; } Item* newitem = ((Player*)caster)->StoreNewItem(dest, spellInfo->EffectItemType[m_effIndex], true); ((Player*)caster)->SendNewItem(newitem, count, true, true); } } void Aura::HandleBindSight(bool apply, bool /*Real*/) { Unit* caster = GetCaster(); if (!caster || caster->GetTypeId() != TYPEID_PLAYER) return; Camera& camera = ((Player*)caster)->GetCamera(); if (apply) camera.SetView(GetTarget()); else camera.ResetView(); } void Aura::HandleFarSight(bool apply, bool /*Real*/) { Unit* caster = GetCaster(); if (!caster || caster->GetTypeId() != TYPEID_PLAYER) return; Camera& camera = ((Player*)caster)->GetCamera(); if (apply) camera.SetView(GetTarget()); else camera.ResetView(); } void Aura::HandleAuraTrackCreatures(bool apply, bool /*Real*/) { if (GetTarget()->GetTypeId() != TYPEID_PLAYER) return; if (apply) GetTarget()->RemoveNoStackAurasDueToAuraHolder(GetHolder()); if (apply) GetTarget()->SetFlag(PLAYER_TRACK_CREATURES, uint32(1) << (m_modifier.m_miscvalue - 1)); else GetTarget()->RemoveFlag(PLAYER_TRACK_CREATURES, uint32(1) << (m_modifier.m_miscvalue - 1)); } void Aura::HandleAuraTrackResources(bool apply, bool /*Real*/) { if (GetTarget()->GetTypeId() != TYPEID_PLAYER) return; if (apply) GetTarget()->RemoveNoStackAurasDueToAuraHolder(GetHolder()); if (apply) GetTarget()->SetFlag(PLAYER_TRACK_RESOURCES, uint32(1) << (m_modifier.m_miscvalue - 1)); else GetTarget()->RemoveFlag(PLAYER_TRACK_RESOURCES, uint32(1) << (m_modifier.m_miscvalue - 1)); } void Aura::HandleAuraTrackStealthed(bool apply, bool /*Real*/) { if (GetTarget()->GetTypeId() != TYPEID_PLAYER) return; if (apply) GetTarget()->RemoveNoStackAurasDueToAuraHolder(GetHolder()); GetTarget()->ApplyModByteFlag(PLAYER_FIELD_BYTES, 0, PLAYER_FIELD_BYTE_TRACK_STEALTHED, apply); } void Aura::HandleAuraModScale(bool apply, bool /*Real*/) { GetTarget()->ApplyPercentModFloatValue(OBJECT_FIELD_SCALE_X, float(m_modifier.m_amount), apply); GetTarget()->UpdateModelData(); } void Aura::HandleModPossess(bool apply, bool Real) { if (!Real) return; Unit* target = GetTarget(); // not possess yourself if (GetCasterGuid() == target->GetObjectGuid()) return; Unit* caster = GetCaster(); if (!caster || caster->GetTypeId() != TYPEID_PLAYER) return; Player* p_caster = (Player*)caster; Camera& camera = p_caster->GetCamera(); if (apply) { target->addUnitState(UNIT_STAT_CONTROLLED); target->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PLAYER_CONTROLLED); target->SetCharmerGuid(p_caster->GetObjectGuid()); target->setFaction(p_caster->getFaction()); // target should became visible at SetView call(if not visible before): // otherwise client\p_caster will ignore packets from the target(SetClientControl for example) camera.SetView(target); p_caster->SetCharm(target); p_caster->SetClientControl(target, 1); p_caster->SetMover(target); target->CombatStop(true); target->DeleteThreatList(); target->getHostileRefManager().deleteReferences(); if (CharmInfo* charmInfo = target->InitCharmInfo(target)) { charmInfo->InitPossessCreateSpells(); charmInfo->SetReactState(REACT_PASSIVE); charmInfo->SetCommandState(COMMAND_STAY); } p_caster->PossessSpellInitialize(); if (target->GetTypeId() == TYPEID_UNIT) { ((Creature*)target)->AIM_Initialize(); } else if (target->GetTypeId() == TYPEID_PLAYER) { ((Player*)target)->SetClientControl(target, 0); } } else { p_caster->SetCharm(NULL); p_caster->SetClientControl(target, 0); p_caster->SetMover(NULL); // there is a possibility that target became invisible for client\p_caster at ResetView call: // it must be called after movement control unapplying, not before! the reason is same as at aura applying camera.ResetView(); p_caster->RemovePetActionBar(); // on delete only do caster related effects if (m_removeMode == AURA_REMOVE_BY_DELETE) return; target->clearUnitState(UNIT_STAT_CONTROLLED); target->CombatStop(true); target->DeleteThreatList(); target->getHostileRefManager().deleteReferences(); target->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PLAYER_CONTROLLED); target->SetCharmerGuid(ObjectGuid()); if (target->GetTypeId() == TYPEID_PLAYER) { ((Player*)target)->setFactionForRace(target->getRace()); ((Player*)target)->SetClientControl(target, 1); } else if (target->GetTypeId() == TYPEID_UNIT) { CreatureInfo const* cinfo = ((Creature*)target)->GetCreatureInfo(); target->setFaction(cinfo->faction_A); } if (target->GetTypeId() == TYPEID_UNIT) { ((Creature*)target)->AIM_Initialize(); target->AttackedBy(caster); } } } void Aura::HandleModPossessPet(bool apply, bool Real) { if (!Real) return; Unit* caster = GetCaster(); if (!caster || caster->GetTypeId() != TYPEID_PLAYER) return; Unit* target = GetTarget(); if (target->GetTypeId() != TYPEID_UNIT || !((Creature*)target)->IsPet()) return; Pet* pet = (Pet*)target; Player* p_caster = (Player*)caster; Camera& camera = p_caster->GetCamera(); if (apply) { pet->addUnitState(UNIT_STAT_CONTROLLED); // target should became visible at SetView call(if not visible before): // otherwise client\p_caster will ignore packets from the target(SetClientControl for example) camera.SetView(pet); p_caster->SetCharm(pet); p_caster->SetClientControl(pet, 1); ((Player*)caster)->SetMover(pet); pet->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PLAYER_CONTROLLED); pet->StopMoving(); pet->GetMotionMaster()->Clear(false); pet->GetMotionMaster()->MoveIdle(); } else { p_caster->SetCharm(NULL); p_caster->SetClientControl(pet, 0); p_caster->SetMover(NULL); // there is a possibility that target became invisible for client\p_caster at ResetView call: // it must be called after movement control unapplying, not before! the reason is same as at aura applying camera.ResetView(); // on delete only do caster related effects if (m_removeMode == AURA_REMOVE_BY_DELETE) return; pet->clearUnitState(UNIT_STAT_CONTROLLED); pet->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PLAYER_CONTROLLED); pet->AttackStop(); // out of range pet dismissed if (!pet->IsWithinDistInMap(p_caster, pet->GetMap()->GetVisibilityDistance())) { p_caster->RemovePet(PET_SAVE_REAGENTS); } else { pet->GetMotionMaster()->MoveFollow(caster, PET_FOLLOW_DIST, PET_FOLLOW_ANGLE); } } } void Aura::HandleModCharm(bool apply, bool Real) { if (!Real) return; Unit* target = GetTarget(); // not charm yourself if (GetCasterGuid() == target->GetObjectGuid()) return; Unit* caster = GetCaster(); if (!caster) return; if (apply) { // is it really need after spell check checks? target->RemoveSpellsCausingAura(SPELL_AURA_MOD_CHARM, GetHolder()); target->RemoveSpellsCausingAura(SPELL_AURA_MOD_POSSESS, GetHolder()); target->SetCharmerGuid(GetCasterGuid()); target->setFaction(caster->getFaction()); target->CastStop(target == caster ? GetId() : 0); caster->SetCharm(target); target->CombatStop(true); target->DeleteThreatList(); target->getHostileRefManager().deleteReferences(); if (target->GetTypeId() == TYPEID_UNIT) { ((Creature*)target)->AIM_Initialize(); CharmInfo* charmInfo = target->InitCharmInfo(target); charmInfo->InitCharmCreateSpells(); charmInfo->SetReactState(REACT_DEFENSIVE); if (caster->GetTypeId() == TYPEID_PLAYER && caster->getClass() == CLASS_WARLOCK) { CreatureInfo const* cinfo = ((Creature*)target)->GetCreatureInfo(); if (cinfo && cinfo->type == CREATURE_TYPE_DEMON) { // creature with pet number expected have class set if (target->GetByteValue(UNIT_FIELD_BYTES_0, 1) == 0) { if (cinfo->unit_class == 0) sLog.outErrorDb("Creature (Entry: %u) have unit_class = 0 but used in charmed spell, that will be result client crash.", cinfo->Entry); else sLog.outError("Creature (Entry: %u) have unit_class = %u but at charming have class 0!!! that will be result client crash.", cinfo->Entry, cinfo->unit_class); target->SetByteValue(UNIT_FIELD_BYTES_0, 1, CLASS_MAGE); } // just to enable stat window charmInfo->SetPetNumber(sObjectMgr.GeneratePetNumber(), true); // if charmed two demons the same session, the 2nd gets the 1st one's name target->SetUInt32Value(UNIT_FIELD_PET_NAME_TIMESTAMP, uint32(time(NULL))); } } } if (caster->GetTypeId() == TYPEID_PLAYER) ((Player*)caster)->CharmSpellInitialize(); } else { target->SetCharmerGuid(ObjectGuid()); if (target->GetTypeId() == TYPEID_PLAYER) ((Player*)target)->setFactionForRace(target->getRace()); else { CreatureInfo const* cinfo = ((Creature*)target)->GetCreatureInfo(); // restore faction if (((Creature*)target)->IsPet()) { if (Unit* owner = target->GetOwner()) target->setFaction(owner->getFaction()); else if (cinfo) target->setFaction(cinfo->faction_A); } else if (cinfo) // normal creature target->setFaction(cinfo->faction_A); // restore UNIT_FIELD_BYTES_0 if (cinfo && caster->GetTypeId() == TYPEID_PLAYER && caster->getClass() == CLASS_WARLOCK && cinfo->type == CREATURE_TYPE_DEMON) { // DB must have proper class set in field at loading, not req. restore, including workaround case at apply // m_target->SetByteValue(UNIT_FIELD_BYTES_0, 1, cinfo->unit_class); if (target->GetCharmInfo()) target->GetCharmInfo()->SetPetNumber(0, true); else sLog.outError("Aura::HandleModCharm: target (GUID: %u TypeId: %u) has a charm aura but no charm info!", target->GetGUIDLow(), target->GetTypeId()); } } caster->SetCharm(NULL); if (caster->GetTypeId() == TYPEID_PLAYER) ((Player*)caster)->RemovePetActionBar(); target->CombatStop(true); target->DeleteThreatList(); target->getHostileRefManager().deleteReferences(); if (target->GetTypeId() == TYPEID_UNIT) { ((Creature*)target)->AIM_Initialize(); target->AttackedBy(caster); } } } void Aura::HandleModConfuse(bool apply, bool Real) { if (!Real) return; GetTarget()->SetConfused(apply, GetCasterGuid(), GetId()); } void Aura::HandleModFear(bool apply, bool Real) { if (!Real) return; GetTarget()->SetFeared(apply, GetCasterGuid(), GetId()); } void Aura::HandleFeignDeath(bool apply, bool Real) { if (!Real) return; GetTarget()->SetFeignDeath(apply, GetCasterGuid(), GetId()); } void Aura::HandleAuraModDisarm(bool apply, bool Real) { if (!Real) return; Unit* target = GetTarget(); if (!apply && target->HasAuraType(GetModifier()->m_auraname)) return; target->ApplyModFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_DISARMED, apply); if (target->GetTypeId() != TYPEID_PLAYER) return; // main-hand attack speed already set to special value for feral form already and don't must change and reset at remove. if (target->IsInFeralForm()) return; if (apply) target->SetAttackTime(BASE_ATTACK, BASE_ATTACK_TIME); else ((Player*)target)->SetRegularAttackTime(); target->UpdateDamagePhysical(BASE_ATTACK); } void Aura::HandleAuraModStun(bool apply, bool Real) { if (!Real) return; Unit* target = GetTarget(); if (apply) { // Frost stun aura -> freeze/unfreeze target if (GetSpellSchoolMask(GetSpellProto()) & SPELL_SCHOOL_MASK_FROST) target->ModifyAuraState(AURA_STATE_FROZEN, apply); target->addUnitState(UNIT_STAT_STUNNED); target->SetTargetGuid(ObjectGuid()); target->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_STUNNED); target->CastStop(target->GetObjectGuid() == GetCasterGuid() ? GetId() : 0); // Creature specific if (target->GetTypeId() != TYPEID_PLAYER) target->StopMoving(); else { ((Player*)target)->m_movementInfo.SetMovementFlags(MOVEFLAG_NONE); target->SetStandState(UNIT_STAND_STATE_STAND);// in 1.5 client } target->SetRoot(true); // Summon the Naj'entus Spine GameObject on target if spell is Impaling Spine if (GetId() == 39837) { GameObject* pObj = new GameObject; if (pObj->Create(target->GetMap()->GenerateLocalLowGuid(HIGHGUID_GAMEOBJECT), 185584, target->GetMap(), target->GetPositionX(), target->GetPositionY(), target->GetPositionZ(), target->GetOrientation())) { pObj->SetRespawnTime(GetAuraDuration() / IN_MILLISECONDS); pObj->SetSpellId(GetId()); target->AddGameObject(pObj); target->GetMap()->Add(pObj); } else delete pObj; } } else { // Frost stun aura -> freeze/unfreeze target if (GetSpellSchoolMask(GetSpellProto()) & SPELL_SCHOOL_MASK_FROST) { bool found_another = false; for (AuraType const* itr = &frozenAuraTypes[0]; *itr != SPELL_AURA_NONE; ++itr) { Unit::AuraList const& auras = target->GetAurasByType(*itr); for (Unit::AuraList::const_iterator i = auras.begin(); i != auras.end(); ++i) { if (GetSpellSchoolMask((*i)->GetSpellProto()) & SPELL_SCHOOL_MASK_FROST) { found_another = true; break; } } if (found_another) break; } if (!found_another) target->ModifyAuraState(AURA_STATE_FROZEN, apply); } // Real remove called after current aura remove from lists, check if other similar auras active if (target->HasAuraType(SPELL_AURA_MOD_STUN)) return; target->clearUnitState(UNIT_STAT_STUNNED); target->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_STUNNED); if (!target->hasUnitState(UNIT_STAT_ROOT)) // prevent allow move if have also root effect { if (target->getVictim() && target->isAlive()) target->SetTargetGuid(target->getVictim()->GetObjectGuid()); target->SetRoot(false); } // Wyvern Sting if (GetSpellProto()->SpellFamilyName == SPELLFAMILY_HUNTER && GetSpellProto()->SpellFamilyFlags & UI64LIT(0x0000100000000000)) { Unit* caster = GetCaster(); if (!caster || caster->GetTypeId() != TYPEID_PLAYER) return; uint32 spell_id = 0; switch (GetId()) { case 19386: spell_id = 24131; break; case 24132: spell_id = 24134; break; case 24133: spell_id = 24135; break; case 27068: spell_id = 27069; break; default: sLog.outError("Spell selection called for unexpected original spell %u, new spell for this spell family?", GetId()); return; } SpellEntry const* spellInfo = sSpellStore.LookupEntry(spell_id); if (!spellInfo) return; caster->CastSpell(target, spellInfo, true, NULL, this); return; } } } void Aura::HandleModStealth(bool apply, bool Real) { Unit* target = GetTarget(); if (apply) { // drop flag at stealth in bg target->RemoveAurasWithInterruptFlags(AURA_INTERRUPT_FLAG_IMMUNE_OR_LOST_SELECTION); // only at real aura add if (Real) { target->SetStandFlags(UNIT_STAND_FLAGS_CREEP); if (target->GetTypeId() == TYPEID_PLAYER) target->SetByteFlag(PLAYER_FIELD_BYTES2, 1, PLAYER_FIELD_BYTE2_STEALTH); // apply only if not in GM invisibility (and overwrite invisibility state) if (target->GetVisibility() != VISIBILITY_OFF) { target->SetVisibility(VISIBILITY_GROUP_NO_DETECT); target->SetVisibility(VISIBILITY_GROUP_STEALTH); } // for RACE_NIGHTELF stealth if (target->GetTypeId() == TYPEID_PLAYER && GetId() == 20580) target->CastSpell(target, 21009, true, NULL, this); // apply full stealth period bonuses only at first stealth aura in stack if (target->GetAurasByType(SPELL_AURA_MOD_STEALTH).size() <= 1) { Unit::AuraList const& mDummyAuras = target->GetAurasByType(SPELL_AURA_DUMMY); for (Unit::AuraList::const_iterator i = mDummyAuras.begin(); i != mDummyAuras.end(); ++i) { // Master of Subtlety if ((*i)->GetSpellProto()->SpellIconID == 2114) { target->RemoveAurasDueToSpell(31666); int32 bp = (*i)->GetModifier()->m_amount; target->CastCustomSpell(target, 31665, &bp, NULL, NULL, true); break; } } } } } else { // for RACE_NIGHTELF stealth if (Real && target->GetTypeId() == TYPEID_PLAYER && GetId() == 20580) target->RemoveAurasDueToSpell(21009); // only at real aura remove of _last_ SPELL_AURA_MOD_STEALTH if (Real && !target->HasAuraType(SPELL_AURA_MOD_STEALTH)) { // if no GM invisibility if (target->GetVisibility() != VISIBILITY_OFF) { target->RemoveStandFlags(UNIT_STAND_FLAGS_CREEP); if (target->GetTypeId() == TYPEID_PLAYER) target->RemoveByteFlag(PLAYER_FIELD_BYTES2, 1, PLAYER_FIELD_BYTE2_STEALTH); // restore invisibility if any if (target->HasAuraType(SPELL_AURA_MOD_INVISIBILITY)) { target->SetVisibility(VISIBILITY_GROUP_NO_DETECT); target->SetVisibility(VISIBILITY_GROUP_INVISIBILITY); } else target->SetVisibility(VISIBILITY_ON); } // apply delayed talent bonus remover at last stealth aura remove Unit::AuraList const& mDummyAuras = target->GetAurasByType(SPELL_AURA_DUMMY); for (Unit::AuraList::const_iterator i = mDummyAuras.begin(); i != mDummyAuras.end(); ++i) { // Master of Subtlety if ((*i)->GetSpellProto()->SpellIconID == 2114) { target->CastSpell(target, 31666, true); break; } } } } } void Aura::HandleInvisibility(bool apply, bool Real) { Unit* target = GetTarget(); if (apply) { target->m_invisibilityMask |= (1 << m_modifier.m_miscvalue); target->RemoveAurasWithInterruptFlags(AURA_INTERRUPT_FLAG_IMMUNE_OR_LOST_SELECTION); if (Real && target->GetTypeId() == TYPEID_PLAYER) { // apply glow vision target->SetByteFlag(PLAYER_FIELD_BYTES2, 1, PLAYER_FIELD_BYTE2_INVISIBILITY_GLOW); } // apply only if not in GM invisibility and not stealth if (target->GetVisibility() == VISIBILITY_ON) { // Aura not added yet but visibility code expect temporary add aura target->SetVisibility(VISIBILITY_GROUP_NO_DETECT); target->SetVisibility(VISIBILITY_GROUP_INVISIBILITY); } } else { // recalculate value at modifier remove (current aura already removed) target->m_invisibilityMask = 0; Unit::AuraList const& auras = target->GetAurasByType(SPELL_AURA_MOD_INVISIBILITY); for (Unit::AuraList::const_iterator itr = auras.begin(); itr != auras.end(); ++itr) target->m_invisibilityMask |= (1 << (*itr)->GetModifier()->m_miscvalue); // only at real aura remove and if not have different invisibility auras. if (Real && target->m_invisibilityMask == 0) { // remove glow vision if (target->GetTypeId() == TYPEID_PLAYER) target->RemoveByteFlag(PLAYER_FIELD_BYTES2, 1, PLAYER_FIELD_BYTE2_INVISIBILITY_GLOW); // apply only if not in GM invisibility & not stealthed while invisible if (target->GetVisibility() != VISIBILITY_OFF) { // if have stealth aura then already have stealth visibility if (!target->HasAuraType(SPELL_AURA_MOD_STEALTH)) target->SetVisibility(VISIBILITY_ON); } } } } void Aura::HandleInvisibilityDetect(bool apply, bool Real) { Unit* target = GetTarget(); if (apply) { target->m_detectInvisibilityMask |= (1 << m_modifier.m_miscvalue); } else { // recalculate value at modifier remove (current aura already removed) target->m_detectInvisibilityMask = 0; Unit::AuraList const& auras = target->GetAurasByType(SPELL_AURA_MOD_INVISIBILITY_DETECTION); for (Unit::AuraList::const_iterator itr = auras.begin(); itr != auras.end(); ++itr) target->m_detectInvisibilityMask |= (1 << (*itr)->GetModifier()->m_miscvalue); } if (Real && target->GetTypeId() == TYPEID_PLAYER) ((Player*)target)->GetCamera().UpdateVisibilityForOwner(); } void Aura::HandleDetectAmore(bool apply, bool /*real*/) { GetTarget()->ApplyModByteFlag(PLAYER_FIELD_BYTES2, 1, (PLAYER_FIELD_BYTE2_DETECT_AMORE_0 << m_modifier.m_amount), apply); } void Aura::HandleAuraModRoot(bool apply, bool Real) { // only at real add/remove aura if (!Real) return; Unit* target = GetTarget(); if (apply) { // Frost root aura -> freeze/unfreeze target if (GetSpellSchoolMask(GetSpellProto()) & SPELL_SCHOOL_MASK_FROST) target->ModifyAuraState(AURA_STATE_FROZEN, apply); target->addUnitState(UNIT_STAT_ROOT); target->SetTargetGuid(ObjectGuid()); // Save last orientation if (target->getVictim()) target->SetOrientation(target->GetAngle(target->getVictim())); if (target->GetTypeId() == TYPEID_PLAYER) { target->SetRoot(true); // Clear unit movement flags ((Player*)target)->m_movementInfo.SetMovementFlags(MOVEFLAG_NONE); } else target->StopMoving(); } else { // Frost root aura -> freeze/unfreeze target if (GetSpellSchoolMask(GetSpellProto()) & SPELL_SCHOOL_MASK_FROST) { bool found_another = false; for (AuraType const* itr = &frozenAuraTypes[0]; *itr != SPELL_AURA_NONE; ++itr) { Unit::AuraList const& auras = target->GetAurasByType(*itr); for (Unit::AuraList::const_iterator i = auras.begin(); i != auras.end(); ++i) { if (GetSpellSchoolMask((*i)->GetSpellProto()) & SPELL_SCHOOL_MASK_FROST) { found_another = true; break; } } if (found_another) break; } if (!found_another) target->ModifyAuraState(AURA_STATE_FROZEN, apply); } // Real remove called after current aura remove from lists, check if other similar auras active if (target->HasAuraType(SPELL_AURA_MOD_ROOT)) return; target->clearUnitState(UNIT_STAT_ROOT); if (!target->hasUnitState(UNIT_STAT_STUNNED)) // prevent allow move if have also stun effect { if (target->getVictim() && target->isAlive()) target->SetTargetGuid(target->getVictim()->GetObjectGuid()); if (target->GetTypeId() == TYPEID_PLAYER) target->SetRoot(false); } } } void Aura::HandleAuraModSilence(bool apply, bool Real) { // only at real add/remove aura if (!Real) return; Unit* target = GetTarget(); if (apply) { target->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_SILENCED); // Stop cast only spells vs PreventionType == SPELL_PREVENTION_TYPE_SILENCE for (uint32 i = CURRENT_MELEE_SPELL; i < CURRENT_MAX_SPELL; ++i) if (Spell* spell = target->GetCurrentSpell(CurrentSpellTypes(i))) if (spell->m_spellInfo->PreventionType == SPELL_PREVENTION_TYPE_SILENCE) // Stop spells on prepare or casting state target->InterruptSpell(CurrentSpellTypes(i), false); switch (GetId()) { // Arcane Torrent (Energy) case 25046: { Unit* caster = GetCaster(); if (!caster) return; // Search Mana Tap auras on caster Aura* dummy = caster->GetDummyAura(28734); if (dummy) { int32 bp = dummy->GetStackAmount() * 10; caster->CastCustomSpell(caster, 25048, &bp, NULL, NULL, true); caster->RemoveAurasDueToSpell(28734); } } } } else { // Real remove called after current aura remove from lists, check if other similar auras active if (target->HasAuraType(SPELL_AURA_MOD_SILENCE)) return; target->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_SILENCED); } } void Aura::HandleModThreat(bool apply, bool Real) { // only at real add/remove aura if (!Real) return; Unit* target = GetTarget(); if (!target->isAlive()) return; int level_diff = 0; int multiplier = 0; switch (GetId()) { // Arcane Shroud case 26400: level_diff = target->getLevel() - 60; multiplier = 2; break; // The Eye of Diminution case 28862: level_diff = target->getLevel() - 60; multiplier = 1; break; } if (level_diff > 0) m_modifier.m_amount += multiplier * level_diff; if (target->GetTypeId() == TYPEID_PLAYER) for (int8 x = 0; x < MAX_SPELL_SCHOOL; ++x) if (m_modifier.m_miscvalue & int32(1 << x)) ApplyPercentModFloatVar(target->m_threatModifier[x], float(m_modifier.m_amount), apply); } void Aura::HandleAuraModTotalThreat(bool apply, bool Real) { // only at real add/remove aura if (!Real) return; Unit* target = GetTarget(); if (!target->isAlive() || target->GetTypeId() != TYPEID_PLAYER) return; Unit* caster = GetCaster(); if (!caster || !caster->isAlive()) return; float threatMod = apply ? float(m_modifier.m_amount) : float(-m_modifier.m_amount); target->getHostileRefManager().threatAssist(caster, threatMod, GetSpellProto()); } void Aura::HandleModTaunt(bool apply, bool Real) { // only at real add/remove aura if (!Real) return; Unit* target = GetTarget(); if (!target->isAlive() || !target->CanHaveThreatList()) return; Unit* caster = GetCaster(); if (!caster || !caster->isAlive()) return; if (apply) target->TauntApply(caster); else { // When taunt aura fades out, mob will switch to previous target if current has less than 1.1 * secondthreat target->TauntFadeOut(caster); } } /*********************************************************/ /*** MODIFY SPEED ***/ /*********************************************************/ void Aura::HandleAuraModIncreaseSpeed(bool /*apply*/, bool Real) { // all applied/removed only at real aura add/remove if (!Real) return; GetTarget()->UpdateSpeed(MOVE_RUN, true); } void Aura::HandleAuraModIncreaseMountedSpeed(bool /*apply*/, bool Real) { // all applied/removed only at real aura add/remove if (!Real) return; GetTarget()->UpdateSpeed(MOVE_RUN, true); } void Aura::HandleAuraModIncreaseFlightSpeed(bool apply, bool Real) { // all applied/removed only at real aura add/remove if (!Real) return; Unit* target = GetTarget(); // Enable Fly mode for flying mounts if (m_modifier.m_auraname == SPELL_AURA_MOD_FLIGHT_SPEED_MOUNTED) { WorldPacket data; if (apply) data.Initialize(SMSG_MOVE_SET_CAN_FLY, 12); else data.Initialize(SMSG_MOVE_UNSET_CAN_FLY, 12); data << target->GetPackGUID(); data << uint32(0); // unknown target->SendMessageToSet(&data, true); // Players on flying mounts must be immune to polymorph if (target->GetTypeId() == TYPEID_PLAYER) target->ApplySpellImmune(GetId(), IMMUNITY_MECHANIC, MECHANIC_POLYMORPH, apply); // Dragonmaw Illusion (overwrite mount model, mounted aura already applied) if (apply && target->HasAura(42016, EFFECT_INDEX_0) && target->GetMountID()) target->SetUInt32Value(UNIT_FIELD_MOUNTDISPLAYID, 16314); } target->UpdateSpeed(MOVE_FLIGHT, true); } void Aura::HandleAuraModIncreaseSwimSpeed(bool /*apply*/, bool Real) { // all applied/removed only at real aura add/remove if (!Real) return; GetTarget()->UpdateSpeed(MOVE_SWIM, true); } void Aura::HandleAuraModDecreaseSpeed(bool apply, bool Real) { // all applied/removed only at real aura add/remove if (!Real) return; Unit* target = GetTarget(); if (apply) { // Gronn Lord's Grasp, becomes stoned if (GetId() == 33572) { if (GetStackAmount() >= 5 && !target->HasAura(33652)) target->CastSpell(target, 33652, true); } } target->UpdateSpeed(MOVE_RUN, true); target->UpdateSpeed(MOVE_SWIM, true); target->UpdateSpeed(MOVE_FLIGHT, true); } void Aura::HandleAuraModUseNormalSpeed(bool /*apply*/, bool Real) { // all applied/removed only at real aura add/remove if (!Real) return; Unit* target = GetTarget(); target->UpdateSpeed(MOVE_RUN, true); target->UpdateSpeed(MOVE_SWIM, true); target->UpdateSpeed(MOVE_FLIGHT, true); } /*********************************************************/ /*** IMMUNITY ***/ /*********************************************************/ void Aura::HandleModMechanicImmunity(bool apply, bool /*Real*/) { uint32 misc = m_modifier.m_miscvalue; Unit* target = GetTarget(); if (apply && GetSpellProto()->HasAttribute(SPELL_ATTR_EX_DISPEL_AURAS_ON_IMMUNITY)) { uint32 mechanic = 1 << (misc - 1); // immune movement impairment and loss of control (spell data have special structure for mark this case) if (IsSpellRemoveAllMovementAndControlLossEffects(GetSpellProto())) mechanic = IMMUNE_TO_MOVEMENT_IMPAIRMENT_AND_LOSS_CONTROL_MASK; target->RemoveAurasAtMechanicImmunity(mechanic, GetId()); } target->ApplySpellImmune(GetId(), IMMUNITY_MECHANIC, misc, apply); // special cases switch (misc) { case MECHANIC_INVULNERABILITY: target->ModifyAuraState(AURA_STATE_FORBEARANCE, apply); break; case MECHANIC_SHIELD: target->ModifyAuraState(AURA_STATE_WEAKENED_SOUL, apply); break; } // Bestial Wrath if (GetSpellProto()->SpellFamilyName == SPELLFAMILY_HUNTER && GetSpellProto()->SpellIconID == 1680) { // The Beast Within cast on owner if talent present if (Unit* owner = target->GetOwner()) { // Search talent The Beast Within Unit::AuraList const& dummyAuras = owner->GetAurasByType(SPELL_AURA_DUMMY); for (Unit::AuraList::const_iterator i = dummyAuras.begin(); i != dummyAuras.end(); ++i) { if ((*i)->GetSpellProto()->SpellIconID == 2229) { if (apply) owner->CastSpell(owner, 34471, true, NULL, this); else owner->RemoveAurasDueToSpell(34471); break; } } } } } void Aura::HandleModMechanicImmunityMask(bool apply, bool /*Real*/) { uint32 mechanic = m_modifier.m_miscvalue; if (apply && GetSpellProto()->HasAttribute(SPELL_ATTR_EX_DISPEL_AURAS_ON_IMMUNITY)) GetTarget()->RemoveAurasAtMechanicImmunity(mechanic, GetId()); // check implemented in Unit::IsImmuneToSpell and Unit::IsImmuneToSpellEffect } // this method is called whenever we add / remove aura which gives m_target some imunity to some spell effect void Aura::HandleAuraModEffectImmunity(bool apply, bool /*Real*/) { Unit* target = GetTarget(); // when removing flag aura, handle flag drop if (!apply && target->GetTypeId() == TYPEID_PLAYER && (GetSpellProto()->AuraInterruptFlags & AURA_INTERRUPT_FLAG_IMMUNE_OR_LOST_SELECTION)) { Player* player = (Player*)target; if (BattleGround* bg = player->GetBattleGround()) bg->EventPlayerDroppedFlag(player); else if (OutdoorPvP* outdoorPvP = sOutdoorPvPMgr.GetScript(player->GetCachedZoneId())) outdoorPvP->HandleDropFlag(player, GetSpellProto()->Id); } target->ApplySpellImmune(GetId(), IMMUNITY_EFFECT, m_modifier.m_miscvalue, apply); } void Aura::HandleAuraModStateImmunity(bool apply, bool Real) { if (apply && Real && GetSpellProto()->HasAttribute(SPELL_ATTR_EX_DISPEL_AURAS_ON_IMMUNITY)) { Unit::AuraList const& auraList = GetTarget()->GetAurasByType(AuraType(m_modifier.m_miscvalue)); for (Unit::AuraList::const_iterator itr = auraList.begin(); itr != auraList.end();) { if (auraList.front() != this) // skip itself aura (it already added) { GetTarget()->RemoveAurasDueToSpell(auraList.front()->GetId()); itr = auraList.begin(); } else ++itr; } } GetTarget()->ApplySpellImmune(GetId(), IMMUNITY_STATE, m_modifier.m_miscvalue, apply); } void Aura::HandleAuraModSchoolImmunity(bool apply, bool Real) { Unit* target = GetTarget(); target->ApplySpellImmune(GetId(), IMMUNITY_SCHOOL, m_modifier.m_miscvalue, apply); // remove all flag auras (they are positive, but they must be removed when you are immune) if (GetSpellProto()->HasAttribute(SPELL_ATTR_EX_DISPEL_AURAS_ON_IMMUNITY) && GetSpellProto()->HasAttribute(SPELL_ATTR_EX2_DAMAGE_REDUCED_SHIELD)) target->RemoveAurasWithInterruptFlags(AURA_INTERRUPT_FLAG_IMMUNE_OR_LOST_SELECTION); // TODO: optimalize this cycle - use RemoveAurasWithInterruptFlags call or something else if (Real && apply && GetSpellProto()->HasAttribute(SPELL_ATTR_EX_DISPEL_AURAS_ON_IMMUNITY) && IsPositiveSpell(GetId())) // Only positive immunity removes auras { uint32 school_mask = m_modifier.m_miscvalue; Unit::SpellAuraHolderMap& Auras = target->GetSpellAuraHolderMap(); for (Unit::SpellAuraHolderMap::iterator iter = Auras.begin(), next; iter != Auras.end(); iter = next) { next = iter; ++next; SpellEntry const* spell = iter->second->GetSpellProto(); if ((GetSpellSchoolMask(spell) & school_mask) // Check for school mask && !spell->HasAttribute(SPELL_ATTR_UNAFFECTED_BY_INVULNERABILITY) // Spells unaffected by invulnerability && !iter->second->IsPositive() // Don't remove positive spells && spell->Id != GetId()) // Don't remove self { target->RemoveAurasDueToSpell(spell->Id); if (Auras.empty()) break; else next = Auras.begin(); } } } if (Real && GetSpellProto()->Mechanic == MECHANIC_BANISH) { if (apply) target->addUnitState(UNIT_STAT_ISOLATED); else target->clearUnitState(UNIT_STAT_ISOLATED); } } void Aura::HandleAuraModDmgImmunity(bool apply, bool /*Real*/) { GetTarget()->ApplySpellImmune(GetId(), IMMUNITY_DAMAGE, m_modifier.m_miscvalue, apply); } void Aura::HandleAuraModDispelImmunity(bool apply, bool Real) { // all applied/removed only at real aura add/remove if (!Real) return; GetTarget()->ApplySpellDispelImmunity(GetSpellProto(), DispelType(m_modifier.m_miscvalue), apply); } void Aura::HandleAuraProcTriggerSpell(bool apply, bool Real) { if (!Real) return; Unit* target = GetTarget(); switch (GetId()) { // some spell have charges by functionality not have its in spell data case 28200: // Ascendance (Talisman of Ascendance trinket) if (apply) GetHolder()->SetAuraCharges(6); break; default: break; } } void Aura::HandleAuraModStalked(bool apply, bool /*Real*/) { // used by spells: Hunter's Mark, Mind Vision, Syndicate Tracker (MURP) DND if (apply) GetTarget()->SetFlag(UNIT_DYNAMIC_FLAGS, UNIT_DYNFLAG_TRACK_UNIT); else GetTarget()->RemoveFlag(UNIT_DYNAMIC_FLAGS, UNIT_DYNFLAG_TRACK_UNIT); } /*********************************************************/ /*** PERIODIC ***/ /*********************************************************/ void Aura::HandlePeriodicTriggerSpell(bool apply, bool /*Real*/) { m_isPeriodic = apply; Unit* target = GetTarget(); if (!apply) { switch (GetId()) { case 66: // Invisibility if (m_removeMode == AURA_REMOVE_BY_EXPIRE) target->CastSpell(target, 32612, true, NULL, this); return; case 29213: // Curse of the Plaguebringer if (m_removeMode != AURA_REMOVE_BY_DISPEL) // Cast Wrath of the Plaguebringer if not dispelled target->CastSpell(target, 29214, true, 0, this); return; case 42783: // Wrath of the Astrom... if (m_removeMode == AURA_REMOVE_BY_EXPIRE && GetEffIndex() + 1 < MAX_EFFECT_INDEX) target->CastSpell(target, GetSpellProto()->CalculateSimpleValue(SpellEffectIndex(GetEffIndex() + 1)), true); return; default: break; } } } void Aura::HandlePeriodicTriggerSpellWithValue(bool apply, bool /*Real*/) { m_isPeriodic = apply; } void Aura::HandlePeriodicEnergize(bool apply, bool /*Real*/) { m_isPeriodic = apply; } void Aura::HandleAuraPowerBurn(bool apply, bool /*Real*/) { m_isPeriodic = apply; } void Aura::HandleAuraPeriodicDummy(bool apply, bool Real) { // spells required only Real aura add/remove if (!Real) return; Unit* target = GetTarget(); // For prevent double apply bonuses bool loading = (target->GetTypeId() == TYPEID_PLAYER && ((Player*)target)->GetSession()->PlayerLoading()); SpellEntry const* spell = GetSpellProto(); switch (spell->SpellFamilyName) { case SPELLFAMILY_ROGUE: { // Master of Subtlety if (spell->Id == 31666 && !apply) { target->RemoveAurasDueToSpell(31665); break; } break; } case SPELLFAMILY_HUNTER: { // Aspect of the Viper if (spell->SpellFamilyFlags & UI64LIT(0x0004000000000000)) { // Update regen on remove if (!apply && target->GetTypeId() == TYPEID_PLAYER) ((Player*)target)->UpdateManaRegen(); break; } break; } } m_isPeriodic = apply; } void Aura::HandlePeriodicHeal(bool apply, bool /*Real*/) { m_isPeriodic = apply; Unit* target = GetTarget(); // For prevent double apply bonuses bool loading = (target->GetTypeId() == TYPEID_PLAYER && ((Player*)target)->GetSession()->PlayerLoading()); // Custom damage calculation after if (apply) { if (loading) return; Unit* caster = GetCaster(); if (!caster) return; m_modifier.m_amount = caster->SpellHealingBonusDone(target, GetSpellProto(), m_modifier.m_amount, DOT, GetStackAmount()); } } void Aura::HandlePeriodicDamage(bool apply, bool Real) { // spells required only Real aura add/remove if (!Real) return; m_isPeriodic = apply; Unit* target = GetTarget(); SpellEntry const* spellProto = GetSpellProto(); // For prevent double apply bonuses bool loading = (target->GetTypeId() == TYPEID_PLAYER && ((Player*)target)->GetSession()->PlayerLoading()); // Custom damage calculation after if (apply) { if (loading) return; Unit* caster = GetCaster(); if (!caster) return; switch (spellProto->SpellFamilyName) { case SPELLFAMILY_WARRIOR: { // Rend if (spellProto->SpellFamilyFlags & UI64LIT(0x0000000000000020)) { // 0.00743*(($MWB+$mwb)/2+$AP/14*$MWS) bonus per tick float ap = caster->GetTotalAttackPowerValue(BASE_ATTACK); int32 mws = caster->GetAttackTime(BASE_ATTACK); float mwb_min = caster->GetWeaponDamageRange(BASE_ATTACK, MINDAMAGE); float mwb_max = caster->GetWeaponDamageRange(BASE_ATTACK, MAXDAMAGE); m_modifier.m_amount += int32(((mwb_min + mwb_max) / 2 + ap * mws / 14000) * 0.00743f); } break; } case SPELLFAMILY_DRUID: { // Rip if (spellProto->SpellFamilyFlags & UI64LIT(0x000000000000800000)) { if (caster->GetTypeId() != TYPEID_PLAYER) break; // $AP * min(0.06*$cp, 0.24)/6 [Yes, there is no difference, whether 4 or 5 CPs are being used] uint8 cp = ((Player*)caster)->GetComboPoints(); // Idol of Feral Shadows. Cant be handled as SpellMod in SpellAura:Dummy due its dependency from CPs Unit::AuraList const& dummyAuras = caster->GetAurasByType(SPELL_AURA_DUMMY); for (Unit::AuraList::const_iterator itr = dummyAuras.begin(); itr != dummyAuras.end(); ++itr) { if ((*itr)->GetId() == 34241) { m_modifier.m_amount += cp * (*itr)->GetModifier()->m_amount; break; } } if (cp > 4) cp = 4; m_modifier.m_amount += int32(caster->GetTotalAttackPowerValue(BASE_ATTACK) * cp / 100); } break; } case SPELLFAMILY_ROGUE: { // Rupture if (spellProto->SpellFamilyFlags & UI64LIT(0x000000000000100000)) { if (caster->GetTypeId() != TYPEID_PLAYER) break; // Dmg/tick = $AP*min(0.01*$cp, 0.03) [Like Rip: only the first three CP increase the contribution from AP] uint8 cp = ((Player*)caster)->GetComboPoints(); if (cp > 3) cp = 3; m_modifier.m_amount += int32(caster->GetTotalAttackPowerValue(BASE_ATTACK) * cp / 100); } break; } default: break; } if (m_modifier.m_auraname == SPELL_AURA_PERIODIC_DAMAGE) { // SpellDamageBonusDone for magic spells if (spellProto->DmgClass == SPELL_DAMAGE_CLASS_NONE || spellProto->DmgClass == SPELL_DAMAGE_CLASS_MAGIC) m_modifier.m_amount = caster->SpellDamageBonusDone(target, GetSpellProto(), m_modifier.m_amount, DOT, GetStackAmount()); // MeleeDamagebonusDone for weapon based spells else { WeaponAttackType attackType = GetWeaponAttackType(GetSpellProto()); m_modifier.m_amount = caster->MeleeDamageBonusDone(target, m_modifier.m_amount, attackType, GetSpellProto(), DOT, GetStackAmount()); } } } // remove time effects else { // Parasitic Shadowfiend - handle summoning of two Shadowfiends on DoT expire if (spellProto->Id == 41917) target->CastSpell(target, 41915, true); } } void Aura::HandlePeriodicDamagePCT(bool apply, bool /*Real*/) { m_isPeriodic = apply; } void Aura::HandlePeriodicLeech(bool apply, bool /*Real*/) { m_isPeriodic = apply; // For prevent double apply bonuses bool loading = (GetTarget()->GetTypeId() == TYPEID_PLAYER && ((Player*)GetTarget())->GetSession()->PlayerLoading()); // Custom damage calculation after if (apply) { if (loading) return; Unit* caster = GetCaster(); if (!caster) return; m_modifier.m_amount = caster->SpellDamageBonusDone(GetTarget(), GetSpellProto(), m_modifier.m_amount, DOT, GetStackAmount()); } } void Aura::HandlePeriodicManaLeech(bool apply, bool /*Real*/) { m_isPeriodic = apply; } void Aura::HandlePeriodicHealthFunnel(bool apply, bool /*Real*/) { m_isPeriodic = apply; // For prevent double apply bonuses bool loading = (GetTarget()->GetTypeId() == TYPEID_PLAYER && ((Player*)GetTarget())->GetSession()->PlayerLoading()); // Custom damage calculation after if (apply) { if (loading) return; Unit* caster = GetCaster(); if (!caster) return; m_modifier.m_amount = caster->SpellDamageBonusDone(GetTarget(), GetSpellProto(), m_modifier.m_amount, DOT, GetStackAmount()); } } /*********************************************************/ /*** MODIFY STATS ***/ /*********************************************************/ /********************************/ /*** RESISTANCE ***/ /********************************/ void Aura::HandleAuraModResistanceExclusive(bool apply, bool /*Real*/) { for (int8 x = SPELL_SCHOOL_NORMAL; x < MAX_SPELL_SCHOOL; ++x) { if (m_modifier.m_miscvalue & int32(1 << x)) { GetTarget()->HandleStatModifier(UnitMods(UNIT_MOD_RESISTANCE_START + x), BASE_VALUE, float(m_modifier.m_amount), apply); if (GetTarget()->GetTypeId() == TYPEID_PLAYER) GetTarget()->ApplyResistanceBuffModsMod(SpellSchools(x), m_positive, float(m_modifier.m_amount), apply); } } } void Aura::HandleAuraModResistance(bool apply, bool /*Real*/) { for (int8 x = SPELL_SCHOOL_NORMAL; x < MAX_SPELL_SCHOOL; ++x) { if (m_modifier.m_miscvalue & int32(1 << x)) { GetTarget()->HandleStatModifier(UnitMods(UNIT_MOD_RESISTANCE_START + x), TOTAL_VALUE, float(m_modifier.m_amount), apply); if (GetTarget()->GetTypeId() == TYPEID_PLAYER || ((Creature*)GetTarget())->IsPet()) GetTarget()->ApplyResistanceBuffModsMod(SpellSchools(x), m_positive, float(m_modifier.m_amount), apply); } } } void Aura::HandleAuraModBaseResistancePCT(bool apply, bool /*Real*/) { // only players have base stats if (GetTarget()->GetTypeId() != TYPEID_PLAYER) { // pets only have base armor if (((Creature*)GetTarget())->IsPet() && (m_modifier.m_miscvalue & SPELL_SCHOOL_MASK_NORMAL)) GetTarget()->HandleStatModifier(UNIT_MOD_ARMOR, BASE_PCT, float(m_modifier.m_amount), apply); } else { for (int8 x = SPELL_SCHOOL_NORMAL; x < MAX_SPELL_SCHOOL; ++x) { if (m_modifier.m_miscvalue & int32(1 << x)) GetTarget()->HandleStatModifier(UnitMods(UNIT_MOD_RESISTANCE_START + x), BASE_PCT, float(m_modifier.m_amount), apply); } } } void Aura::HandleModResistancePercent(bool apply, bool /*Real*/) { Unit* target = GetTarget(); for (int8 i = SPELL_SCHOOL_NORMAL; i < MAX_SPELL_SCHOOL; ++i) { if (m_modifier.m_miscvalue & int32(1 << i)) { target->HandleStatModifier(UnitMods(UNIT_MOD_RESISTANCE_START + i), TOTAL_PCT, float(m_modifier.m_amount), apply); if (target->GetTypeId() == TYPEID_PLAYER || ((Creature*)target)->IsPet()) { target->ApplyResistanceBuffModsPercentMod(SpellSchools(i), true, float(m_modifier.m_amount), apply); target->ApplyResistanceBuffModsPercentMod(SpellSchools(i), false, float(m_modifier.m_amount), apply); } } } } void Aura::HandleModBaseResistance(bool apply, bool /*Real*/) { // only players have base stats if (GetTarget()->GetTypeId() != TYPEID_PLAYER) { // only pets have base stats if (((Creature*)GetTarget())->IsPet() && (m_modifier.m_miscvalue & SPELL_SCHOOL_MASK_NORMAL)) GetTarget()->HandleStatModifier(UNIT_MOD_ARMOR, TOTAL_VALUE, float(m_modifier.m_amount), apply); } else { for (int i = SPELL_SCHOOL_NORMAL; i < MAX_SPELL_SCHOOL; ++i) if (m_modifier.m_miscvalue & (1 << i)) GetTarget()->HandleStatModifier(UnitMods(UNIT_MOD_RESISTANCE_START + i), TOTAL_VALUE, float(m_modifier.m_amount), apply); } } /********************************/ /*** STAT ***/ /********************************/ void Aura::HandleAuraModStat(bool apply, bool /*Real*/) { if (m_modifier.m_miscvalue < -2 || m_modifier.m_miscvalue > 4) { sLog.outError("WARNING: Spell %u effect %u have unsupported misc value (%i) for SPELL_AURA_MOD_STAT ", GetId(), GetEffIndex(), m_modifier.m_miscvalue); return; } for (int32 i = STAT_STRENGTH; i < MAX_STATS; ++i) { // -1 or -2 is all stats ( misc < -2 checked in function beginning ) if (m_modifier.m_miscvalue < 0 || m_modifier.m_miscvalue == i) { // m_target->ApplyStatMod(Stats(i), m_modifier.m_amount,apply); GetTarget()->HandleStatModifier(UnitMods(UNIT_MOD_STAT_START + i), TOTAL_VALUE, float(m_modifier.m_amount), apply); if (GetTarget()->GetTypeId() == TYPEID_PLAYER || ((Creature*)GetTarget())->IsPet()) GetTarget()->ApplyStatBuffMod(Stats(i), float(m_modifier.m_amount), apply); } } } void Aura::HandleModPercentStat(bool apply, bool /*Real*/) { if (m_modifier.m_miscvalue < -1 || m_modifier.m_miscvalue > 4) { sLog.outError("WARNING: Misc Value for SPELL_AURA_MOD_PERCENT_STAT not valid"); return; } // only players have base stats if (GetTarget()->GetTypeId() != TYPEID_PLAYER) return; for (int32 i = STAT_STRENGTH; i < MAX_STATS; ++i) { if (m_modifier.m_miscvalue == i || m_modifier.m_miscvalue == -1) GetTarget()->HandleStatModifier(UnitMods(UNIT_MOD_STAT_START + i), BASE_PCT, float(m_modifier.m_amount), apply); } } void Aura::HandleModSpellDamagePercentFromStat(bool /*apply*/, bool /*Real*/) { if (GetTarget()->GetTypeId() != TYPEID_PLAYER) return; // Magic damage modifiers implemented in Unit::SpellDamageBonusDone // This information for client side use only // Recalculate bonus ((Player*)GetTarget())->UpdateSpellDamageAndHealingBonus(); } void Aura::HandleModSpellHealingPercentFromStat(bool /*apply*/, bool /*Real*/) { if (GetTarget()->GetTypeId() != TYPEID_PLAYER) return; // Recalculate bonus ((Player*)GetTarget())->UpdateSpellDamageAndHealingBonus(); } void Aura::HandleAuraModDispelResist(bool apply, bool Real) { if (!Real || !apply) return; if (GetId() == 33206) GetTarget()->CastSpell(GetTarget(), 44416, true, NULL, this, GetCasterGuid()); } void Aura::HandleModSpellDamagePercentFromAttackPower(bool /*apply*/, bool /*Real*/) { if (GetTarget()->GetTypeId() != TYPEID_PLAYER) return; // Magic damage modifiers implemented in Unit::SpellDamageBonusDone // This information for client side use only // Recalculate bonus ((Player*)GetTarget())->UpdateSpellDamageAndHealingBonus(); } void Aura::HandleModSpellHealingPercentFromAttackPower(bool /*apply*/, bool /*Real*/) { if (GetTarget()->GetTypeId() != TYPEID_PLAYER) return; // Recalculate bonus ((Player*)GetTarget())->UpdateSpellDamageAndHealingBonus(); } void Aura::HandleModHealingDone(bool /*apply*/, bool /*Real*/) { if (GetTarget()->GetTypeId() != TYPEID_PLAYER) return; // implemented in Unit::SpellHealingBonusDone // this information is for client side only ((Player*)GetTarget())->UpdateSpellDamageAndHealingBonus(); } void Aura::HandleModTotalPercentStat(bool apply, bool /*Real*/) { if (m_modifier.m_miscvalue < -1 || m_modifier.m_miscvalue > 4) { sLog.outError("WARNING: Misc Value for SPELL_AURA_MOD_PERCENT_STAT not valid"); return; } Unit* target = GetTarget(); // save current and max HP before applying aura uint32 curHPValue = target->GetHealth(); uint32 maxHPValue = target->GetMaxHealth(); for (int32 i = STAT_STRENGTH; i < MAX_STATS; ++i) { if (m_modifier.m_miscvalue == i || m_modifier.m_miscvalue == -1) { target->HandleStatModifier(UnitMods(UNIT_MOD_STAT_START + i), TOTAL_PCT, float(m_modifier.m_amount), apply); if (target->GetTypeId() == TYPEID_PLAYER || ((Creature*)target)->IsPet()) target->ApplyStatPercentBuffMod(Stats(i), float(m_modifier.m_amount), apply); } } // recalculate current HP/MP after applying aura modifications (only for spells with 0x10 flag) if (m_modifier.m_miscvalue == STAT_STAMINA && maxHPValue > 0 && GetSpellProto()->HasAttribute(SPELL_ATTR_UNK4)) { // newHP = (curHP / maxHP) * newMaxHP = (newMaxHP * curHP) / maxHP -> which is better because no int -> double -> int conversion is needed uint32 newHPValue = (target->GetMaxHealth() * curHPValue) / maxHPValue; target->SetHealth(newHPValue); } } void Aura::HandleAuraModResistenceOfStatPercent(bool /*apply*/, bool /*Real*/) { if (GetTarget()->GetTypeId() != TYPEID_PLAYER) return; if (m_modifier.m_miscvalue != SPELL_SCHOOL_MASK_NORMAL) { // support required adding replace UpdateArmor by loop by UpdateResistence at intellect update // and include in UpdateResistence same code as in UpdateArmor for aura mod apply. sLog.outError("Aura SPELL_AURA_MOD_RESISTANCE_OF_STAT_PERCENT(182) need adding support for non-armor resistances!"); return; } // Recalculate Armor GetTarget()->UpdateArmor(); } /********************************/ /*** HEAL & ENERGIZE ***/ /********************************/ void Aura::HandleAuraModTotalHealthPercentRegen(bool apply, bool /*Real*/) { m_isPeriodic = apply; } void Aura::HandleAuraModTotalManaPercentRegen(bool apply, bool /*Real*/) { if (m_modifier.periodictime == 0) m_modifier.periodictime = 1000; m_periodicTimer = m_modifier.periodictime; m_isPeriodic = apply; } void Aura::HandleModRegen(bool apply, bool /*Real*/) // eating { if (m_modifier.periodictime == 0) m_modifier.periodictime = 5000; m_periodicTimer = 5000; m_isPeriodic = apply; } void Aura::HandleModPowerRegen(bool apply, bool Real) // drinking { if (!Real) return; Powers pt = GetTarget()->getPowerType(); if (m_modifier.periodictime == 0) { // Anger Management (only spell use this aura for rage) if (pt == POWER_RAGE) m_modifier.periodictime = 3000; else m_modifier.periodictime = 2000; } m_periodicTimer = 5000; if (GetTarget()->GetTypeId() == TYPEID_PLAYER && m_modifier.m_miscvalue == POWER_MANA) ((Player*)GetTarget())->UpdateManaRegen(); m_isPeriodic = apply; } void Aura::HandleModPowerRegenPCT(bool /*apply*/, bool Real) { // spells required only Real aura add/remove if (!Real) return; if (GetTarget()->GetTypeId() != TYPEID_PLAYER) return; // Update manaregen value if (m_modifier.m_miscvalue == POWER_MANA) ((Player*)GetTarget())->UpdateManaRegen(); } void Aura::HandleModManaRegen(bool /*apply*/, bool Real) { // spells required only Real aura add/remove if (!Real) return; if (GetTarget()->GetTypeId() != TYPEID_PLAYER) return; // Note: an increase in regen does NOT cause threat. ((Player*)GetTarget())->UpdateManaRegen(); } void Aura::HandleComprehendLanguage(bool apply, bool /*Real*/) { if (apply) GetTarget()->SetFlag(UNIT_FIELD_FLAGS_2, UNIT_FLAG2_COMPREHEND_LANG); else GetTarget()->RemoveFlag(UNIT_FIELD_FLAGS_2, UNIT_FLAG2_COMPREHEND_LANG); } void Aura::HandleAuraModIncreaseHealth(bool apply, bool Real) { Unit* target = GetTarget(); // Special case with temporary increase max/current health switch (GetId()) { case 12976: // Warrior Last Stand triggered spell case 28726: // Nightmare Seed ( Nightmare Seed ) case 34511: // Valor (Bulwark of Kings, Bulwark of the Ancient Kings) case 44055: // Tremendous Fortitude (Battlemaster's Alacrity) { if (Real) { if (apply) { target->HandleStatModifier(UNIT_MOD_HEALTH, TOTAL_VALUE, float(m_modifier.m_amount), apply); target->ModifyHealth(m_modifier.m_amount); } else { if (int32(target->GetHealth()) > m_modifier.m_amount) target->ModifyHealth(-m_modifier.m_amount); else target->SetHealth(1); target->HandleStatModifier(UNIT_MOD_HEALTH, TOTAL_VALUE, float(m_modifier.m_amount), apply); } } return; } } // generic case target->HandleStatModifier(UNIT_MOD_HEALTH, TOTAL_VALUE, float(m_modifier.m_amount), apply); } void Aura::HandleAuraModIncreaseMaxHealth(bool apply, bool /*Real*/) { Unit* target = GetTarget(); uint32 oldhealth = target->GetHealth(); double healthPercentage = (double)oldhealth / (double)target->GetMaxHealth(); target->HandleStatModifier(UNIT_MOD_HEALTH, TOTAL_VALUE, float(m_modifier.m_amount), apply); // refresh percentage if (oldhealth > 0) { uint32 newhealth = uint32(ceil((double)target->GetMaxHealth() * healthPercentage)); if (newhealth == 0) newhealth = 1; target->SetHealth(newhealth); } } void Aura::HandleAuraModIncreaseEnergy(bool apply, bool /*Real*/) { Unit* target = GetTarget(); Powers powerType = target->getPowerType(); if (int32(powerType) != m_modifier.m_miscvalue) return; UnitMods unitMod = UnitMods(UNIT_MOD_POWER_START + powerType); target->HandleStatModifier(unitMod, TOTAL_VALUE, float(m_modifier.m_amount), apply); } void Aura::HandleAuraModIncreaseEnergyPercent(bool apply, bool /*Real*/) { Powers powerType = GetTarget()->getPowerType(); if (int32(powerType) != m_modifier.m_miscvalue) return; UnitMods unitMod = UnitMods(UNIT_MOD_POWER_START + powerType); GetTarget()->HandleStatModifier(unitMod, TOTAL_PCT, float(m_modifier.m_amount), apply); } void Aura::HandleAuraModIncreaseHealthPercent(bool apply, bool /*Real*/) { GetTarget()->HandleStatModifier(UNIT_MOD_HEALTH, TOTAL_PCT, float(m_modifier.m_amount), apply); } /********************************/ /*** FIGHT ***/ /********************************/ void Aura::HandleAuraModParryPercent(bool /*apply*/, bool /*Real*/) { if (GetTarget()->GetTypeId() != TYPEID_PLAYER) return; ((Player*)GetTarget())->UpdateParryPercentage(); } void Aura::HandleAuraModDodgePercent(bool /*apply*/, bool /*Real*/) { if (GetTarget()->GetTypeId() != TYPEID_PLAYER) return; ((Player*)GetTarget())->UpdateDodgePercentage(); // sLog.outError("BONUS DODGE CHANCE: + %f", float(m_modifier.m_amount)); } void Aura::HandleAuraModBlockPercent(bool /*apply*/, bool /*Real*/) { if (GetTarget()->GetTypeId() != TYPEID_PLAYER) return; ((Player*)GetTarget())->UpdateBlockPercentage(); // sLog.outError("BONUS BLOCK CHANCE: + %f", float(m_modifier.m_amount)); } void Aura::HandleAuraModRegenInterrupt(bool /*apply*/, bool Real) { // spells required only Real aura add/remove if (!Real) return; if (GetTarget()->GetTypeId() != TYPEID_PLAYER) return; ((Player*)GetTarget())->UpdateManaRegen(); } void Aura::HandleAuraModCritPercent(bool apply, bool Real) { Unit* target = GetTarget(); if (target->GetTypeId() != TYPEID_PLAYER) return; // apply item specific bonuses for already equipped weapon if (Real) { for (int i = 0; i < MAX_ATTACK; ++i) if (Item* pItem = ((Player*)target)->GetWeaponForAttack(WeaponAttackType(i), true, false)) ((Player*)target)->_ApplyWeaponDependentAuraCritMod(pItem, WeaponAttackType(i), this, apply); } // mods must be applied base at equipped weapon class and subclass comparison // with spell->EquippedItemClass and EquippedItemSubClassMask and EquippedItemInventoryTypeMask // m_modifier.m_miscvalue comparison with item generated damage types if (GetSpellProto()->EquippedItemClass == -1) { ((Player*)target)->HandleBaseModValue(CRIT_PERCENTAGE, FLAT_MOD, float(m_modifier.m_amount), apply); ((Player*)target)->HandleBaseModValue(OFFHAND_CRIT_PERCENTAGE, FLAT_MOD, float(m_modifier.m_amount), apply); ((Player*)target)->HandleBaseModValue(RANGED_CRIT_PERCENTAGE, FLAT_MOD, float(m_modifier.m_amount), apply); } else { // done in Player::_ApplyWeaponDependentAuraMods } } void Aura::HandleModHitChance(bool apply, bool /*Real*/) { Unit* target = GetTarget(); if (target->GetTypeId() == TYPEID_PLAYER) { ((Player*)target)->UpdateMeleeHitChances(); ((Player*)target)->UpdateRangedHitChances(); } else { target->m_modMeleeHitChance += apply ? m_modifier.m_amount : (-m_modifier.m_amount); target->m_modRangedHitChance += apply ? m_modifier.m_amount : (-m_modifier.m_amount); } } void Aura::HandleModSpellHitChance(bool apply, bool /*Real*/) { if (GetTarget()->GetTypeId() == TYPEID_PLAYER) { ((Player*)GetTarget())->UpdateSpellHitChances(); } else { GetTarget()->m_modSpellHitChance += apply ? m_modifier.m_amount : (-m_modifier.m_amount); } } void Aura::HandleModSpellCritChance(bool apply, bool Real) { // spells required only Real aura add/remove if (!Real) return; if (GetTarget()->GetTypeId() == TYPEID_PLAYER) { ((Player*)GetTarget())->UpdateAllSpellCritChances(); } else { GetTarget()->m_baseSpellCritChance += apply ? m_modifier.m_amount : (-m_modifier.m_amount); } } void Aura::HandleModSpellCritChanceShool(bool /*apply*/, bool Real) { // spells required only Real aura add/remove if (!Real) return; if (GetTarget()->GetTypeId() != TYPEID_PLAYER) return; for (int school = SPELL_SCHOOL_NORMAL; school < MAX_SPELL_SCHOOL; ++school) if (m_modifier.m_miscvalue & (1 << school)) ((Player*)GetTarget())->UpdateSpellCritChance(school); } /********************************/ /*** ATTACK SPEED ***/ /********************************/ void Aura::HandleModCastingSpeed(bool apply, bool /*Real*/) { GetTarget()->ApplyCastTimePercentMod(float(m_modifier.m_amount), apply); } void Aura::HandleModMeleeRangedSpeedPct(bool apply, bool /*Real*/) { Unit* target = GetTarget(); target->ApplyAttackTimePercentMod(BASE_ATTACK, float(m_modifier.m_amount), apply); target->ApplyAttackTimePercentMod(OFF_ATTACK, float(m_modifier.m_amount), apply); target->ApplyAttackTimePercentMod(RANGED_ATTACK, float(m_modifier.m_amount), apply); } void Aura::HandleModCombatSpeedPct(bool apply, bool /*Real*/) { Unit* target = GetTarget(); target->ApplyCastTimePercentMod(float(m_modifier.m_amount), apply); target->ApplyAttackTimePercentMod(BASE_ATTACK, float(m_modifier.m_amount), apply); target->ApplyAttackTimePercentMod(OFF_ATTACK, float(m_modifier.m_amount), apply); target->ApplyAttackTimePercentMod(RANGED_ATTACK, float(m_modifier.m_amount), apply); } void Aura::HandleModAttackSpeed(bool apply, bool /*Real*/) { GetTarget()->ApplyAttackTimePercentMod(BASE_ATTACK, float(m_modifier.m_amount), apply); } void Aura::HandleModMeleeSpeedPct(bool apply, bool /*Real*/) { Unit* target = GetTarget(); target->ApplyAttackTimePercentMod(BASE_ATTACK, float(m_modifier.m_amount), apply); target->ApplyAttackTimePercentMod(OFF_ATTACK, float(m_modifier.m_amount), apply); } void Aura::HandleAuraModRangedHaste(bool apply, bool /*Real*/) { GetTarget()->ApplyAttackTimePercentMod(RANGED_ATTACK, float(m_modifier.m_amount), apply); } void Aura::HandleRangedAmmoHaste(bool apply, bool /*Real*/) { if (GetTarget()->GetTypeId() != TYPEID_PLAYER) return; GetTarget()->ApplyAttackTimePercentMod(RANGED_ATTACK, float(m_modifier.m_amount), apply); } /********************************/ /*** ATTACK POWER ***/ /********************************/ void Aura::HandleAuraModAttackPower(bool apply, bool /*Real*/) { GetTarget()->HandleStatModifier(UNIT_MOD_ATTACK_POWER, TOTAL_VALUE, float(m_modifier.m_amount), apply); } void Aura::HandleAuraModRangedAttackPower(bool apply, bool /*Real*/) { if ((GetTarget()->getClassMask() & CLASSMASK_WAND_USERS) != 0) return; GetTarget()->HandleStatModifier(UNIT_MOD_ATTACK_POWER_RANGED, TOTAL_VALUE, float(m_modifier.m_amount), apply); } void Aura::HandleAuraModAttackPowerPercent(bool apply, bool /*Real*/) { // UNIT_FIELD_ATTACK_POWER_MULTIPLIER = multiplier - 1 GetTarget()->HandleStatModifier(UNIT_MOD_ATTACK_POWER, TOTAL_PCT, float(m_modifier.m_amount), apply); } void Aura::HandleAuraModRangedAttackPowerPercent(bool apply, bool /*Real*/) { if ((GetTarget()->getClassMask() & CLASSMASK_WAND_USERS) != 0) return; // UNIT_FIELD_RANGED_ATTACK_POWER_MULTIPLIER = multiplier - 1 GetTarget()->HandleStatModifier(UNIT_MOD_ATTACK_POWER_RANGED, TOTAL_PCT, float(m_modifier.m_amount), apply); } void Aura::HandleAuraModRangedAttackPowerOfStatPercent(bool /*apply*/, bool Real) { // spells required only Real aura add/remove if (!Real) return; // Recalculate bonus if (GetTarget()->GetTypeId() == TYPEID_PLAYER && !(GetTarget()->getClassMask() & CLASSMASK_WAND_USERS)) ((Player*)GetTarget())->UpdateAttackPowerAndDamage(true); } /********************************/ /*** DAMAGE BONUS ***/ /********************************/ void Aura::HandleModDamageDone(bool apply, bool Real) { Unit* target = GetTarget(); // apply item specific bonuses for already equipped weapon if (Real && target->GetTypeId() == TYPEID_PLAYER) { for (int i = 0; i < MAX_ATTACK; ++i) if (Item* pItem = ((Player*)target)->GetWeaponForAttack(WeaponAttackType(i), true, false)) ((Player*)target)->_ApplyWeaponDependentAuraDamageMod(pItem, WeaponAttackType(i), this, apply); } // m_modifier.m_miscvalue is bitmask of spell schools // 1 ( 0-bit ) - normal school damage (SPELL_SCHOOL_MASK_NORMAL) // 126 - full bitmask all magic damages (SPELL_SCHOOL_MASK_MAGIC) including wands // 127 - full bitmask any damages // // mods must be applied base at equipped weapon class and subclass comparison // with spell->EquippedItemClass and EquippedItemSubClassMask and EquippedItemInventoryTypeMask // m_modifier.m_miscvalue comparison with item generated damage types if ((m_modifier.m_miscvalue & SPELL_SCHOOL_MASK_NORMAL) != 0) { // apply generic physical damage bonuses including wand case if (GetSpellProto()->EquippedItemClass == -1 || target->GetTypeId() != TYPEID_PLAYER) { target->HandleStatModifier(UNIT_MOD_DAMAGE_MAINHAND, TOTAL_VALUE, float(m_modifier.m_amount), apply); target->HandleStatModifier(UNIT_MOD_DAMAGE_OFFHAND, TOTAL_VALUE, float(m_modifier.m_amount), apply); target->HandleStatModifier(UNIT_MOD_DAMAGE_RANGED, TOTAL_VALUE, float(m_modifier.m_amount), apply); } else { // done in Player::_ApplyWeaponDependentAuraMods } if (target->GetTypeId() == TYPEID_PLAYER) { if (m_positive) target->ApplyModUInt32Value(PLAYER_FIELD_MOD_DAMAGE_DONE_POS, m_modifier.m_amount, apply); else target->ApplyModUInt32Value(PLAYER_FIELD_MOD_DAMAGE_DONE_NEG, m_modifier.m_amount, apply); } } // Skip non magic case for speedup if ((m_modifier.m_miscvalue & SPELL_SCHOOL_MASK_MAGIC) == 0) return; if (GetSpellProto()->EquippedItemClass != -1 || GetSpellProto()->EquippedItemInventoryTypeMask != 0) { // wand magic case (skip generic to all item spell bonuses) // done in Player::_ApplyWeaponDependentAuraMods // Skip item specific requirements for not wand magic damage return; } // Magic damage modifiers implemented in Unit::SpellDamageBonusDone // This information for client side use only if (target->GetTypeId() == TYPEID_PLAYER) { if (m_positive) { for (int i = SPELL_SCHOOL_HOLY; i < MAX_SPELL_SCHOOL; ++i) { if ((m_modifier.m_miscvalue & (1 << i)) != 0) target->ApplyModUInt32Value(PLAYER_FIELD_MOD_DAMAGE_DONE_POS + i, m_modifier.m_amount, apply); } } else { for (int i = SPELL_SCHOOL_HOLY; i < MAX_SPELL_SCHOOL; ++i) { if ((m_modifier.m_miscvalue & (1 << i)) != 0) target->ApplyModUInt32Value(PLAYER_FIELD_MOD_DAMAGE_DONE_NEG + i, m_modifier.m_amount, apply); } } Pet* pet = target->GetPet(); if (pet) pet->UpdateAttackPowerAndDamage(); } } void Aura::HandleModDamagePercentDone(bool apply, bool Real) { DEBUG_FILTER_LOG(LOG_FILTER_SPELL_CAST, "AURA MOD DAMAGE type:%u negative:%u", m_modifier.m_miscvalue, m_positive ? 0 : 1); Unit* target = GetTarget(); // apply item specific bonuses for already equipped weapon if (Real && target->GetTypeId() == TYPEID_PLAYER) { for (int i = 0; i < MAX_ATTACK; ++i) if (Item* pItem = ((Player*)target)->GetWeaponForAttack(WeaponAttackType(i), true, false)) ((Player*)target)->_ApplyWeaponDependentAuraDamageMod(pItem, WeaponAttackType(i), this, apply); } // m_modifier.m_miscvalue is bitmask of spell schools // 1 ( 0-bit ) - normal school damage (SPELL_SCHOOL_MASK_NORMAL) // 126 - full bitmask all magic damages (SPELL_SCHOOL_MASK_MAGIC) including wand // 127 - full bitmask any damages // // mods must be applied base at equipped weapon class and subclass comparison // with spell->EquippedItemClass and EquippedItemSubClassMask and EquippedItemInventoryTypeMask // m_modifier.m_miscvalue comparison with item generated damage types if ((m_modifier.m_miscvalue & SPELL_SCHOOL_MASK_NORMAL) != 0) { // apply generic physical damage bonuses including wand case if (GetSpellProto()->EquippedItemClass == -1 || target->GetTypeId() != TYPEID_PLAYER) { target->HandleStatModifier(UNIT_MOD_DAMAGE_MAINHAND, TOTAL_PCT, float(m_modifier.m_amount), apply); target->HandleStatModifier(UNIT_MOD_DAMAGE_OFFHAND, TOTAL_PCT, float(m_modifier.m_amount), apply); target->HandleStatModifier(UNIT_MOD_DAMAGE_RANGED, TOTAL_PCT, float(m_modifier.m_amount), apply); } else { // done in Player::_ApplyWeaponDependentAuraMods } // For show in client if (target->GetTypeId() == TYPEID_PLAYER) target->ApplyModSignedFloatValue(PLAYER_FIELD_MOD_DAMAGE_DONE_PCT, m_modifier.m_amount / 100.0f, apply); } // Skip non magic case for speedup if ((m_modifier.m_miscvalue & SPELL_SCHOOL_MASK_MAGIC) == 0) return; if (GetSpellProto()->EquippedItemClass != -1 || GetSpellProto()->EquippedItemInventoryTypeMask != 0) { // wand magic case (skip generic to all item spell bonuses) // done in Player::_ApplyWeaponDependentAuraMods // Skip item specific requirements for not wand magic damage return; } // Magic damage percent modifiers implemented in Unit::SpellDamageBonusDone // Send info to client if (target->GetTypeId() == TYPEID_PLAYER) for (int i = SPELL_SCHOOL_HOLY; i < MAX_SPELL_SCHOOL; ++i) target->ApplyModSignedFloatValue(PLAYER_FIELD_MOD_DAMAGE_DONE_PCT + i, m_modifier.m_amount / 100.0f, apply); } void Aura::HandleModOffhandDamagePercent(bool apply, bool Real) { // spells required only Real aura add/remove if (!Real) return; DEBUG_FILTER_LOG(LOG_FILTER_SPELL_CAST, "AURA MOD OFFHAND DAMAGE"); GetTarget()->HandleStatModifier(UNIT_MOD_DAMAGE_OFFHAND, TOTAL_PCT, float(m_modifier.m_amount), apply); } /********************************/ /*** POWER COST ***/ /********************************/ void Aura::HandleModPowerCostPCT(bool apply, bool Real) { // spells required only Real aura add/remove if (!Real) return; float amount = m_modifier.m_amount / 100.0f; for (int i = 0; i < MAX_SPELL_SCHOOL; ++i) if (m_modifier.m_miscvalue & (1 << i)) GetTarget()->ApplyModSignedFloatValue(UNIT_FIELD_POWER_COST_MULTIPLIER + i, amount, apply); } void Aura::HandleModPowerCost(bool apply, bool Real) { // spells required only Real aura add/remove if (!Real) return; for (int i = 0; i < MAX_SPELL_SCHOOL; ++i) if (m_modifier.m_miscvalue & (1 << i)) GetTarget()->ApplyModInt32Value(UNIT_FIELD_POWER_COST_MODIFIER + i, m_modifier.m_amount, apply); } /*********************************************************/ /*** OTHERS ***/ /*********************************************************/ void Aura::HandleShapeshiftBoosts(bool apply) { uint32 spellId1 = 0; uint32 spellId2 = 0; uint32 HotWSpellId = 0; ShapeshiftForm form = ShapeshiftForm(GetModifier()->m_miscvalue); Unit* target = GetTarget(); switch (form) { case FORM_CAT: spellId1 = 3025; HotWSpellId = 24900; break; case FORM_TREE: spellId1 = 5420; break; case FORM_TRAVEL: spellId1 = 5419; break; case FORM_AQUA: spellId1 = 5421; break; case FORM_BEAR: spellId1 = 1178; spellId2 = 21178; HotWSpellId = 24899; break; case FORM_DIREBEAR: spellId1 = 9635; spellId2 = 21178; HotWSpellId = 24899; break; case FORM_BATTLESTANCE: spellId1 = 21156; break; case FORM_DEFENSIVESTANCE: spellId1 = 7376; break; case FORM_BERSERKERSTANCE: spellId1 = 7381; break; case FORM_MOONKIN: spellId1 = 24905; break; case FORM_FLIGHT: spellId1 = 33948; spellId2 = 34764; break; case FORM_FLIGHT_EPIC: spellId1 = 40122; spellId2 = 40121; break; case FORM_SPIRITOFREDEMPTION: spellId1 = 27792; spellId2 = 27795; // must be second, this important at aura remove to prevent to early iterator invalidation. break; case FORM_GHOSTWOLF: case FORM_AMBIENT: case FORM_GHOUL: case FORM_SHADOW: case FORM_STEALTH: case FORM_CREATURECAT: case FORM_CREATUREBEAR: break; } if (apply) { if (spellId1) target->CastSpell(target, spellId1, true, NULL, this); if (spellId2) target->CastSpell(target, spellId2, true, NULL, this); if (target->GetTypeId() == TYPEID_PLAYER) { const PlayerSpellMap& sp_list = ((Player*)target)->GetSpellMap(); for (PlayerSpellMap::const_iterator itr = sp_list.begin(); itr != sp_list.end(); ++itr) { if (itr->second.state == PLAYERSPELL_REMOVED) continue; if (itr->first == spellId1 || itr->first == spellId2) continue; SpellEntry const* spellInfo = sSpellStore.LookupEntry(itr->first); if (!spellInfo || !IsNeedCastSpellAtFormApply(spellInfo, form)) continue; target->CastSpell(target, itr->first, true, NULL, this); } // Leader of the Pack if (((Player*)target)->HasSpell(17007)) { SpellEntry const* spellInfo = sSpellStore.LookupEntry(24932); if (spellInfo && spellInfo->Stances & (1 << (form - 1))) target->CastSpell(target, 24932, true, NULL, this); } // Heart of the Wild if (HotWSpellId) { Unit::AuraList const& mModTotalStatPct = target->GetAurasByType(SPELL_AURA_MOD_TOTAL_STAT_PERCENTAGE); for (Unit::AuraList::const_iterator i = mModTotalStatPct.begin(); i != mModTotalStatPct.end(); ++i) { if ((*i)->GetSpellProto()->SpellIconID == 240 && (*i)->GetModifier()->m_miscvalue == 3) { int32 HotWMod = (*i)->GetModifier()->m_amount; if (GetModifier()->m_miscvalue == FORM_CAT) HotWMod /= 2; target->CastCustomSpell(target, HotWSpellId, &HotWMod, NULL, NULL, true, NULL, this); break; } } } } } else { if (spellId1) target->RemoveAurasDueToSpell(spellId1); if (spellId2) target->RemoveAurasDueToSpell(spellId2); Unit::SpellAuraHolderMap& tAuras = target->GetSpellAuraHolderMap(); for (Unit::SpellAuraHolderMap::iterator itr = tAuras.begin(); itr != tAuras.end();) { if (itr->second->IsRemovedOnShapeLost()) { target->RemoveAurasDueToSpell(itr->second->GetId()); itr = tAuras.begin(); } else ++itr; } } } void Aura::HandleAuraEmpathy(bool apply, bool /*Real*/) { if (GetTarget()->GetTypeId() != TYPEID_UNIT) return; CreatureInfo const* ci = ObjectMgr::GetCreatureTemplate(GetTarget()->GetEntry()); if (ci && ci->type == CREATURE_TYPE_BEAST) GetTarget()->ApplyModUInt32Value(UNIT_DYNAMIC_FLAGS, UNIT_DYNFLAG_SPECIALINFO, apply); } void Aura::HandleAuraUntrackable(bool apply, bool /*Real*/) { if (apply) GetTarget()->SetByteFlag(UNIT_FIELD_BYTES_1, 3, UNIT_BYTE1_FLAG_UNTRACKABLE); else GetTarget()->RemoveByteFlag(UNIT_FIELD_BYTES_1, 3, UNIT_BYTE1_FLAG_UNTRACKABLE); } void Aura::HandleAuraModPacify(bool apply, bool /*Real*/) { if (apply) GetTarget()->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PACIFIED); else GetTarget()->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PACIFIED); } void Aura::HandleAuraModPacifyAndSilence(bool apply, bool Real) { HandleAuraModPacify(apply, Real); HandleAuraModSilence(apply, Real); } void Aura::HandleAuraGhost(bool apply, bool /*Real*/) { if (GetTarget()->GetTypeId() != TYPEID_PLAYER) return; if (apply) { GetTarget()->SetFlag(PLAYER_FLAGS, PLAYER_FLAGS_GHOST); } else { GetTarget()->RemoveFlag(PLAYER_FLAGS, PLAYER_FLAGS_GHOST); } } void Aura::HandleAuraAllowFlight(bool apply, bool Real) { // all applied/removed only at real aura add/remove if (!Real) return; // allow fly WorldPacket data; if (apply) data.Initialize(SMSG_MOVE_SET_CAN_FLY, 12); else data.Initialize(SMSG_MOVE_UNSET_CAN_FLY, 12); data << GetTarget()->GetPackGUID(); data << uint32(0); // unk GetTarget()->SendMessageToSet(&data, true); } void Aura::HandleModRating(bool apply, bool Real) { // spells required only Real aura add/remove if (!Real) return; if (GetTarget()->GetTypeId() != TYPEID_PLAYER) return; for (uint32 rating = 0; rating < MAX_COMBAT_RATING; ++rating) if (m_modifier.m_miscvalue & (1 << rating)) ((Player*)GetTarget())->ApplyRatingMod(CombatRating(rating), m_modifier.m_amount, apply); } void Aura::HandleForceMoveForward(bool apply, bool Real) { if (!Real) return; if (apply) GetTarget()->SetFlag(UNIT_FIELD_FLAGS_2, UNIT_FLAG2_FORCE_MOVE); else GetTarget()->RemoveFlag(UNIT_FIELD_FLAGS_2, UNIT_FLAG2_FORCE_MOVE); } void Aura::HandleAuraModExpertise(bool /*apply*/, bool /*Real*/) { if (GetTarget()->GetTypeId() != TYPEID_PLAYER) return; ((Player*)GetTarget())->UpdateExpertise(BASE_ATTACK); ((Player*)GetTarget())->UpdateExpertise(OFF_ATTACK); } void Aura::HandleModTargetResistance(bool apply, bool Real) { // spells required only Real aura add/remove if (!Real) return; Unit* target = GetTarget(); // applied to damage as HandleNoImmediateEffect in Unit::CalculateAbsorbAndResist and Unit::CalcArmorReducedDamage // show armor penetration if (target->GetTypeId() == TYPEID_PLAYER && (m_modifier.m_miscvalue & SPELL_SCHOOL_MASK_NORMAL)) target->ApplyModInt32Value(PLAYER_FIELD_MOD_TARGET_PHYSICAL_RESISTANCE, m_modifier.m_amount, apply); // show as spell penetration only full spell penetration bonuses (all resistances except armor and holy if (target->GetTypeId() == TYPEID_PLAYER && (m_modifier.m_miscvalue & SPELL_SCHOOL_MASK_SPELL) == SPELL_SCHOOL_MASK_SPELL) target->ApplyModInt32Value(PLAYER_FIELD_MOD_TARGET_RESISTANCE, m_modifier.m_amount, apply); } void Aura::HandleShieldBlockValue(bool apply, bool /*Real*/) { BaseModType modType = FLAT_MOD; if (m_modifier.m_auraname == SPELL_AURA_MOD_SHIELD_BLOCKVALUE_PCT) modType = PCT_MOD; if (GetTarget()->GetTypeId() == TYPEID_PLAYER) ((Player*)GetTarget())->HandleBaseModValue(SHIELD_BLOCK_VALUE, modType, float(m_modifier.m_amount), apply); } void Aura::HandleAuraRetainComboPoints(bool apply, bool Real) { // spells required only Real aura add/remove if (!Real) return; if (GetTarget()->GetTypeId() != TYPEID_PLAYER) return; Player* target = (Player*)GetTarget(); // combo points was added in SPELL_EFFECT_ADD_COMBO_POINTS handler // remove only if aura expire by time (in case combo points amount change aura removed without combo points lost) if (!apply && m_removeMode == AURA_REMOVE_BY_EXPIRE && target->GetComboTargetGuid()) if (Unit* unit = ObjectAccessor::GetUnit(*GetTarget(), target->GetComboTargetGuid())) target->AddComboPoints(unit, -m_modifier.m_amount); } void Aura::HandleModUnattackable(bool Apply, bool Real) { if (Real && Apply) { GetTarget()->CombatStop(); GetTarget()->RemoveAurasWithInterruptFlags(AURA_INTERRUPT_FLAG_IMMUNE_OR_LOST_SELECTION); } GetTarget()->ApplyModFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE, Apply); } void Aura::HandleSpiritOfRedemption(bool apply, bool Real) { // spells required only Real aura add/remove if (!Real) return; Unit* target = GetTarget(); // prepare spirit state if (apply) { if (target->GetTypeId() == TYPEID_PLAYER) { // disable breath/etc timers ((Player*)target)->StopMirrorTimers(); // set stand state (expected in this form) if (!target->IsStandState()) target->SetStandState(UNIT_STAND_STATE_STAND); } target->SetHealth(1); } // die at aura end else target->DealDamage(target, target->GetHealth(), NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, GetSpellProto(), false); } void Aura::HandleSchoolAbsorb(bool apply, bool Real) { if (!Real) return; Unit* caster = GetCaster(); if (!caster) return; Unit* target = GetTarget(); SpellEntry const* spellProto = GetSpellProto(); if (apply) { // prevent double apply bonuses if (target->GetTypeId() != TYPEID_PLAYER || !((Player*)target)->GetSession()->PlayerLoading()) { float DoneActualBenefit = 0.0f; switch (spellProto->SpellFamilyName) { case SPELLFAMILY_PRIEST: // Power Word: Shield if (spellProto->SpellFamilyFlags & UI64LIT(0x0000000000000001)) { //+30% from +healing bonus DoneActualBenefit = caster->SpellBaseHealingBonusDone(GetSpellSchoolMask(spellProto)) * 0.3f; break; } break; case SPELLFAMILY_MAGE: // Frost Ward, Fire Ward if (spellProto->IsFitToFamilyMask(UI64LIT(0x0000000100080108))) //+10% from +spell bonus DoneActualBenefit = caster->SpellBaseDamageBonusDone(GetSpellSchoolMask(spellProto)) * 0.1f; break; case SPELLFAMILY_WARLOCK: // Shadow Ward if (spellProto->SpellFamilyFlags == UI64LIT(0x00)) //+10% from +spell bonus DoneActualBenefit = caster->SpellBaseDamageBonusDone(GetSpellSchoolMask(spellProto)) * 0.1f; break; default: break; } DoneActualBenefit *= caster->CalculateLevelPenalty(GetSpellProto()); m_modifier.m_amount += (int32)DoneActualBenefit; } } } void Aura::PeriodicTick() { Unit* target = GetTarget(); SpellEntry const* spellProto = GetSpellProto(); switch (m_modifier.m_auraname) { case SPELL_AURA_PERIODIC_DAMAGE: case SPELL_AURA_PERIODIC_DAMAGE_PERCENT: { // don't damage target if not alive, possible death persistent effects if (!target->isAlive()) return; Unit* pCaster = GetCaster(); if (!pCaster) return; if (spellProto->Effect[GetEffIndex()] == SPELL_EFFECT_PERSISTENT_AREA_AURA && pCaster->SpellHitResult(target, spellProto, false) != SPELL_MISS_NONE) return; // Check for immune (not use charges) if (target->IsImmunedToDamage(GetSpellSchoolMask(spellProto))) return; // some auras remove at specific health level or more if (m_modifier.m_auraname == SPELL_AURA_PERIODIC_DAMAGE) { switch (GetId()) { case 43093: case 31956: case 38801: case 35321: case 38363: case 39215: case 48920: { if (target->GetHealth() == target->GetMaxHealth()) { target->RemoveAurasDueToSpell(GetId()); return; } break; } case 38772: { uint32 percent = GetEffIndex() < EFFECT_INDEX_2 && spellProto->Effect[GetEffIndex()] == SPELL_EFFECT_DUMMY ? pCaster->CalculateSpellDamage(target, spellProto, SpellEffectIndex(GetEffIndex() + 1)) : 100; if (target->GetHealth() * 100 >= target->GetMaxHealth() * percent) { target->RemoveAurasDueToSpell(GetId()); return; } break; } default: break; } } uint32 absorb = 0; uint32 resist = 0; CleanDamage cleanDamage = CleanDamage(0, BASE_ATTACK, MELEE_HIT_NORMAL); // ignore non positive values (can be result apply spellmods to aura damage uint32 amount = m_modifier.m_amount > 0 ? m_modifier.m_amount : 0; uint32 pdamage; if (m_modifier.m_auraname == SPELL_AURA_PERIODIC_DAMAGE) pdamage = amount; else pdamage = uint32(target->GetMaxHealth() * amount / 100); // SpellDamageBonus for magic spells if (spellProto->DmgClass == SPELL_DAMAGE_CLASS_NONE || spellProto->DmgClass == SPELL_DAMAGE_CLASS_MAGIC) pdamage = target->SpellDamageBonusTaken(pCaster, spellProto, pdamage, DOT, GetStackAmount()); // MeleeDamagebonus for weapon based spells else { WeaponAttackType attackType = GetWeaponAttackType(spellProto); pdamage = target->MeleeDamageBonusTaken(pCaster, pdamage, attackType, spellProto, DOT, GetStackAmount()); } // Calculate armor mitigation if it is a physical spell // But not for bleed mechanic spells if (GetSpellSchoolMask(spellProto) & SPELL_SCHOOL_MASK_NORMAL && GetEffectMechanic(spellProto, m_effIndex) != MECHANIC_BLEED) { uint32 pdamageReductedArmor = pCaster->CalcArmorReducedDamage(target, pdamage); cleanDamage.damage += pdamage - pdamageReductedArmor; pdamage = pdamageReductedArmor; } // Curse of Agony damage-per-tick calculation if (spellProto->SpellFamilyName == SPELLFAMILY_WARLOCK && (spellProto->SpellFamilyFlags & UI64LIT(0x0000000000000400)) && spellProto->SpellIconID == 544) { // 1..4 ticks, 1/2 from normal tick damage if (GetAuraTicks() <= 4) pdamage = pdamage / 2; // 9..12 ticks, 3/2 from normal tick damage else if (GetAuraTicks() >= 9) pdamage += (pdamage + 1) / 2; // +1 prevent 0.5 damage possible lost at 1..4 ticks // 5..8 ticks have normal tick damage } // As of 2.2 resilience reduces damage from DoT ticks as much as the chance to not be critically hit // Reduce dot damage from resilience for players if (target->GetTypeId() == TYPEID_PLAYER) pdamage -= ((Player*)target)->GetDotDamageReduction(pdamage); target->CalculateDamageAbsorbAndResist(pCaster, GetSpellSchoolMask(spellProto), DOT, pdamage, &absorb, &resist, !GetSpellProto()->HasAttribute(SPELL_ATTR_EX2_CANT_REFLECTED)); DETAIL_FILTER_LOG(LOG_FILTER_PERIODIC_AFFECTS, "PeriodicTick: %s attacked %s for %u dmg inflicted by %u", GetCasterGuid().GetString().c_str(), target->GetGuidStr().c_str(), pdamage, GetId()); pCaster->DealDamageMods(target, pdamage, &absorb); // Set trigger flag uint32 procAttacker = PROC_FLAG_ON_DO_PERIODIC; // | PROC_FLAG_SUCCESSFUL_HARMFUL_SPELL_HIT; uint32 procVictim = PROC_FLAG_ON_TAKE_PERIODIC;// | PROC_FLAG_TAKEN_HARMFUL_SPELL_HIT; pdamage = (pdamage <= absorb + resist) ? 0 : (pdamage - absorb - resist); SpellPeriodicAuraLogInfo pInfo(this, pdamage, absorb, resist, 0.0f); target->SendPeriodicAuraLog(&pInfo); if (pdamage) procVictim |= PROC_FLAG_TAKEN_ANY_DAMAGE; pCaster->ProcDamageAndSpell(target, procAttacker, procVictim, PROC_EX_NORMAL_HIT, pdamage, BASE_ATTACK, spellProto); pCaster->DealDamage(target, pdamage, &cleanDamage, DOT, GetSpellSchoolMask(spellProto), spellProto, true); break; } case SPELL_AURA_PERIODIC_LEECH: case SPELL_AURA_PERIODIC_HEALTH_FUNNEL: { // don't damage target if not alive, possible death persistent effects if (!target->isAlive()) return; Unit* pCaster = GetCaster(); if (!pCaster) return; if (!pCaster->isAlive()) return; if (spellProto->Effect[GetEffIndex()] == SPELL_EFFECT_PERSISTENT_AREA_AURA && pCaster->SpellHitResult(target, spellProto, false) != SPELL_MISS_NONE) return; // Check for immune if (target->IsImmunedToDamage(GetSpellSchoolMask(spellProto))) return; uint32 absorb = 0; uint32 resist = 0; CleanDamage cleanDamage = CleanDamage(0, BASE_ATTACK, MELEE_HIT_NORMAL); uint32 pdamage = m_modifier.m_amount > 0 ? m_modifier.m_amount : 0; // Calculate armor mitigation if it is a physical spell if (GetSpellSchoolMask(spellProto) & SPELL_SCHOOL_MASK_NORMAL) { uint32 pdamageReductedArmor = pCaster->CalcArmorReducedDamage(target, pdamage); cleanDamage.damage += pdamage - pdamageReductedArmor; pdamage = pdamageReductedArmor; } pdamage = target->SpellDamageBonusTaken(pCaster, spellProto, pdamage, DOT, GetStackAmount()); // As of 2.2 resilience reduces damage from DoT ticks as much as the chance to not be critically hit // Reduce dot damage from resilience for players if (target->GetTypeId() == TYPEID_PLAYER) pdamage -= ((Player*)target)->GetDotDamageReduction(pdamage); target->CalculateDamageAbsorbAndResist(pCaster, GetSpellSchoolMask(spellProto), DOT, pdamage, &absorb, &resist, !spellProto->HasAttribute(SPELL_ATTR_EX2_CANT_REFLECTED)); if (target->GetHealth() < pdamage) pdamage = uint32(target->GetHealth()); DETAIL_FILTER_LOG(LOG_FILTER_PERIODIC_AFFECTS, "PeriodicTick: %s health leech of %s for %u dmg inflicted by %u abs is %u", GetCasterGuid().GetString().c_str(), target->GetGuidStr().c_str(), pdamage, GetId(), absorb); pCaster->DealDamageMods(target, pdamage, &absorb); pCaster->SendSpellNonMeleeDamageLog(target, GetId(), pdamage, GetSpellSchoolMask(spellProto), absorb, resist, false, 0); float multiplier = spellProto->EffectMultipleValue[GetEffIndex()] > 0 ? spellProto->EffectMultipleValue[GetEffIndex()] : 1; // Set trigger flag uint32 procAttacker = PROC_FLAG_ON_DO_PERIODIC; // | PROC_FLAG_SUCCESSFUL_HARMFUL_SPELL_HIT; uint32 procVictim = PROC_FLAG_ON_TAKE_PERIODIC;// | PROC_FLAG_TAKEN_HARMFUL_SPELL_HIT; pdamage = (pdamage <= absorb + resist) ? 0 : (pdamage - absorb - resist); if (pdamage) procVictim |= PROC_FLAG_TAKEN_ANY_DAMAGE; pCaster->ProcDamageAndSpell(target, procAttacker, procVictim, PROC_EX_NORMAL_HIT, pdamage, BASE_ATTACK, spellProto); int32 new_damage = pCaster->DealDamage(target, pdamage, &cleanDamage, DOT, GetSpellSchoolMask(spellProto), spellProto, false); if (!target->isAlive() && pCaster->IsNonMeleeSpellCasted(false)) for (uint32 i = CURRENT_FIRST_NON_MELEE_SPELL; i < CURRENT_MAX_SPELL; ++i) if (Spell* spell = pCaster->GetCurrentSpell(CurrentSpellTypes(i))) if (spell->m_spellInfo->Id == GetId()) spell->cancel(); if (Player* modOwner = pCaster->GetSpellModOwner()) modOwner->ApplySpellMod(GetId(), SPELLMOD_MULTIPLE_VALUE, multiplier); uint32 heal = pCaster->SpellHealingBonusTaken(pCaster, spellProto, int32(new_damage * multiplier), DOT, GetStackAmount()); int32 gain = pCaster->DealHeal(pCaster, heal, spellProto); pCaster->getHostileRefManager().threatAssist(pCaster, gain * 0.5f * sSpellMgr.GetSpellThreatMultiplier(spellProto), spellProto); break; } case SPELL_AURA_PERIODIC_HEAL: case SPELL_AURA_OBS_MOD_HEALTH: { // don't heal target if not alive, mostly death persistent effects from items if (!target->isAlive()) return; Unit* pCaster = GetCaster(); if (!pCaster) return; // heal for caster damage (must be alive) if (target != pCaster && spellProto->SpellVisual == 163 && !pCaster->isAlive()) return; // ignore non positive values (can be result apply spellmods to aura damage uint32 amount = m_modifier.m_amount > 0 ? m_modifier.m_amount : 0; uint32 pdamage; if (m_modifier.m_auraname == SPELL_AURA_OBS_MOD_HEALTH) pdamage = uint32(target->GetMaxHealth() * amount / 100); else pdamage = amount; pdamage = target->SpellHealingBonusTaken(pCaster, spellProto, pdamage, DOT, GetStackAmount()); DETAIL_FILTER_LOG(LOG_FILTER_PERIODIC_AFFECTS, "PeriodicTick: %s heal of %s for %u health inflicted by %u", GetCasterGuid().GetString().c_str(), target->GetGuidStr().c_str(), pdamage, GetId()); int32 gain = target->ModifyHealth(pdamage); SpellPeriodicAuraLogInfo pInfo(this, pdamage, 0, 0, 0.0f); target->SendPeriodicAuraLog(&pInfo); // Set trigger flag uint32 procAttacker = PROC_FLAG_ON_DO_PERIODIC; uint32 procVictim = PROC_FLAG_ON_TAKE_PERIODIC; uint32 procEx = PROC_EX_NORMAL_HIT | PROC_EX_PERIODIC_POSITIVE; pCaster->ProcDamageAndSpell(target, procAttacker, procVictim, procEx, gain, BASE_ATTACK, spellProto); // add HoTs to amount healed in bgs if (pCaster->GetTypeId() == TYPEID_PLAYER) if (BattleGround* bg = ((Player*)pCaster)->GetBattleGround()) bg->UpdatePlayerScore(((Player*)pCaster), SCORE_HEALING_DONE, gain); target->getHostileRefManager().threatAssist(pCaster, float(gain) * 0.5f * sSpellMgr.GetSpellThreatMultiplier(spellProto), spellProto); // heal for caster damage if (target != pCaster && spellProto->SpellVisual == 163) { uint32 dmg = spellProto->manaPerSecond; if (pCaster->GetHealth() <= dmg && pCaster->GetTypeId() == TYPEID_PLAYER) { pCaster->RemoveAurasDueToSpell(GetId()); // finish current generic/channeling spells, don't affect autorepeat pCaster->FinishSpell(CURRENT_GENERIC_SPELL); pCaster->FinishSpell(CURRENT_CHANNELED_SPELL); } else { uint32 damage = gain; uint32 absorb = 0; pCaster->DealDamageMods(pCaster, damage, &absorb); pCaster->SendSpellNonMeleeDamageLog(pCaster, GetId(), damage, GetSpellSchoolMask(spellProto), absorb, 0, false, 0, false); CleanDamage cleanDamage = CleanDamage(0, BASE_ATTACK, MELEE_HIT_NORMAL); pCaster->DealDamage(pCaster, damage, &cleanDamage, NODAMAGE, GetSpellSchoolMask(spellProto), spellProto, true); } } break; } case SPELL_AURA_PERIODIC_MANA_LEECH: { // don't damage target if not alive, possible death persistent effects if (!target->isAlive()) return; if (m_modifier.m_miscvalue < 0 || m_modifier.m_miscvalue >= MAX_POWERS) return; Powers power = Powers(m_modifier.m_miscvalue); // power type might have changed between aura applying and tick (druid's shapeshift) if (target->getPowerType() != power) return; Unit* pCaster = GetCaster(); if (!pCaster) return; if (!pCaster->isAlive()) return; if (GetSpellProto()->Effect[GetEffIndex()] == SPELL_EFFECT_PERSISTENT_AREA_AURA && pCaster->SpellHitResult(target, spellProto, false) != SPELL_MISS_NONE) return; // Check for immune (not use charges) if (target->IsImmunedToDamage(GetSpellSchoolMask(spellProto))) return; // ignore non positive values (can be result apply spellmods to aura damage uint32 pdamage = m_modifier.m_amount > 0 ? m_modifier.m_amount : 0; DETAIL_FILTER_LOG(LOG_FILTER_PERIODIC_AFFECTS, "PeriodicTick: %s power leech of %s for %u dmg inflicted by %u", GetCasterGuid().GetString().c_str(), target->GetGuidStr().c_str(), pdamage, GetId()); int32 drain_amount = target->GetPower(power) > pdamage ? pdamage : target->GetPower(power); // resilience reduce mana draining effect at spell crit damage reduction (added in 2.4) if (power == POWER_MANA && target->GetTypeId() == TYPEID_PLAYER) drain_amount -= ((Player*)target)->GetSpellCritDamageReduction(drain_amount); target->ModifyPower(power, -drain_amount); float gain_multiplier = 0.0f; if (pCaster->GetMaxPower(power) > 0) { gain_multiplier = spellProto->EffectMultipleValue[GetEffIndex()]; if (Player* modOwner = pCaster->GetSpellModOwner()) modOwner->ApplySpellMod(GetId(), SPELLMOD_MULTIPLE_VALUE, gain_multiplier); } SpellPeriodicAuraLogInfo pInfo(this, drain_amount, 0, 0, gain_multiplier); target->SendPeriodicAuraLog(&pInfo); if (int32 gain_amount = int32(drain_amount * gain_multiplier)) { int32 gain = pCaster->ModifyPower(power, gain_amount); if (GetId() == 5138) // Drain Mana if (Aura* petPart = GetHolder()->GetAuraByEffectIndex(EFFECT_INDEX_1)) if (int pet_gain = gain_amount * petPart->GetModifier()->m_amount / 100) pCaster->CastCustomSpell(pCaster, 32554, &pet_gain, NULL, NULL, true); target->AddThreat(pCaster, float(gain) * 0.5f, false, GetSpellSchoolMask(spellProto), spellProto); } // Some special cases switch (GetId()) { case 32960: // Mark of Kazzak { if (target->GetTypeId() == TYPEID_PLAYER && target->getPowerType() == POWER_MANA) { // Drain 5% of target's mana pdamage = target->GetMaxPower(POWER_MANA) * 5 / 100; drain_amount = target->GetPower(POWER_MANA) > pdamage ? pdamage : target->GetPower(POWER_MANA); target->ModifyPower(POWER_MANA, -drain_amount); SpellPeriodicAuraLogInfo pInfo(this, drain_amount, 0, 0, 0.0f); target->SendPeriodicAuraLog(&pInfo); } // no break here } case 21056: // Mark of Kazzak case 31447: // Mark of Kaz'rogal { uint32 triggerSpell = 0; switch (GetId()) { case 21056: triggerSpell = 21058; break; case 31447: triggerSpell = 31463; break; case 32960: triggerSpell = 32961; break; } if (target->GetTypeId() == TYPEID_PLAYER && target->GetPower(power) == 0) { target->CastSpell(target, triggerSpell, true, NULL, this); target->RemoveAurasDueToSpell(GetId()); } break; } } break; } case SPELL_AURA_PERIODIC_ENERGIZE: { // don't energize target if not alive, possible death persistent effects if (!target->isAlive()) return; // ignore non positive values (can be result apply spellmods to aura damage uint32 pdamage = m_modifier.m_amount > 0 ? m_modifier.m_amount : 0; DETAIL_FILTER_LOG(LOG_FILTER_PERIODIC_AFFECTS, "PeriodicTick: %s energize %s for %u dmg inflicted by %u", GetCasterGuid().GetString().c_str(), target->GetGuidStr().c_str(), pdamage, GetId()); if (m_modifier.m_miscvalue < 0 || m_modifier.m_miscvalue >= MAX_POWERS) break; Powers power = Powers(m_modifier.m_miscvalue); if (target->GetMaxPower(power) == 0) break; SpellPeriodicAuraLogInfo pInfo(this, pdamage, 0, 0, 0.0f); target->SendPeriodicAuraLog(&pInfo); int32 gain = target->ModifyPower(power, pdamage); if (Unit* pCaster = GetCaster()) target->getHostileRefManager().threatAssist(pCaster, float(gain) * 0.5f * sSpellMgr.GetSpellThreatMultiplier(spellProto), spellProto); break; } case SPELL_AURA_OBS_MOD_MANA: { // don't energize target if not alive, possible death persistent effects if (!target->isAlive()) return; // ignore non positive values (can be result apply spellmods to aura damage uint32 amount = m_modifier.m_amount > 0 ? m_modifier.m_amount : 0; uint32 pdamage = uint32(target->GetMaxPower(POWER_MANA) * amount / 100); DETAIL_FILTER_LOG(LOG_FILTER_PERIODIC_AFFECTS, "PeriodicTick: %s energize %s for %u mana inflicted by %u", GetCasterGuid().GetString().c_str(), target->GetGuidStr().c_str(), pdamage, GetId()); if (target->GetMaxPower(POWER_MANA) == 0) break; SpellPeriodicAuraLogInfo pInfo(this, pdamage, 0, 0, 0.0f); target->SendPeriodicAuraLog(&pInfo); int32 gain = target->ModifyPower(POWER_MANA, pdamage); if (Unit* pCaster = GetCaster()) target->getHostileRefManager().threatAssist(pCaster, float(gain) * 0.5f * sSpellMgr.GetSpellThreatMultiplier(spellProto), spellProto); break; } case SPELL_AURA_POWER_BURN_MANA: { // don't mana burn target if not alive, possible death persistent effects if (!target->isAlive()) return; Unit* pCaster = GetCaster(); if (!pCaster) return; // Check for immune (not use charges) if (target->IsImmunedToDamage(GetSpellSchoolMask(spellProto))) return; int32 pdamage = m_modifier.m_amount > 0 ? m_modifier.m_amount : 0; Powers powerType = Powers(m_modifier.m_miscvalue); if (!target->isAlive() || target->getPowerType() != powerType) return; // resilience reduce mana draining effect at spell crit damage reduction (added in 2.4) if (powerType == POWER_MANA && target->GetTypeId() == TYPEID_PLAYER) pdamage -= ((Player*)target)->GetSpellCritDamageReduction(pdamage); uint32 gain = uint32(-target->ModifyPower(powerType, -pdamage)); gain = uint32(gain * spellProto->EffectMultipleValue[GetEffIndex()]); // maybe has to be sent different to client, but not by SMSG_PERIODICAURALOG SpellNonMeleeDamage damageInfo(pCaster, target, spellProto->Id, SpellSchoolMask(spellProto->SchoolMask)); pCaster->CalculateSpellDamage(&damageInfo, gain, spellProto); damageInfo.target->CalculateAbsorbResistBlock(pCaster, &damageInfo, spellProto); pCaster->DealDamageMods(damageInfo.target, damageInfo.damage, &damageInfo.absorb); pCaster->SendSpellNonMeleeDamageLog(&damageInfo); // Set trigger flag uint32 procAttacker = PROC_FLAG_ON_DO_PERIODIC; // | PROC_FLAG_SUCCESSFUL_HARMFUL_SPELL_HIT; uint32 procVictim = PROC_FLAG_ON_TAKE_PERIODIC;// | PROC_FLAG_TAKEN_HARMFUL_SPELL_HIT; uint32 procEx = createProcExtendMask(&damageInfo, SPELL_MISS_NONE); if (damageInfo.damage) procVictim |= PROC_FLAG_TAKEN_ANY_DAMAGE; pCaster->ProcDamageAndSpell(damageInfo.target, procAttacker, procVictim, procEx, damageInfo.damage, BASE_ATTACK, spellProto); pCaster->DealSpellDamage(&damageInfo, true); break; } case SPELL_AURA_MOD_REGEN: { // don't heal target if not alive, possible death persistent effects if (!target->isAlive()) return; int32 gain = target->ModifyHealth(m_modifier.m_amount); if (Unit* caster = GetCaster()) target->getHostileRefManager().threatAssist(caster, float(gain) * 0.5f * sSpellMgr.GetSpellThreatMultiplier(spellProto), spellProto); break; } case SPELL_AURA_MOD_POWER_REGEN: { // don't energize target if not alive, possible death persistent effects if (!target->isAlive()) return; Powers pt = target->getPowerType(); if (int32(pt) != m_modifier.m_miscvalue) return; if (spellProto->AuraInterruptFlags & AURA_INTERRUPT_FLAG_NOT_SEATED) { // eating anim target->HandleEmoteCommand(EMOTE_ONESHOT_EAT); } else if (GetId() == 20577) { // cannibalize anim target->HandleEmoteCommand(EMOTE_STATE_CANNIBALIZE); } // Anger Management // amount = 1+ 16 = 17 = 3,4*5 = 10,2*5/3 // so 17 is rounded amount for 5 sec tick grow ~ 1 range grow in 3 sec if (pt == POWER_RAGE) target->ModifyPower(pt, m_modifier.m_amount * 3 / 5); break; } // Here tick dummy auras case SPELL_AURA_DUMMY: // some spells have dummy aura case SPELL_AURA_PERIODIC_DUMMY: { PeriodicDummyTick(); break; } case SPELL_AURA_PERIODIC_TRIGGER_SPELL: { TriggerSpell(); break; } case SPELL_AURA_PERIODIC_TRIGGER_SPELL_WITH_VALUE: { TriggerSpellWithValue(); break; } default: break; } } void Aura::PeriodicDummyTick() { SpellEntry const* spell = GetSpellProto(); Unit* target = GetTarget(); switch (spell->SpellFamilyName) { case SPELLFAMILY_GENERIC: { switch (spell->Id) { // Forsaken Skills case 7054: { // Possibly need cast one of them (but // 7038 Forsaken Skill: Swords // 7039 Forsaken Skill: Axes // 7040 Forsaken Skill: Daggers // 7041 Forsaken Skill: Maces // 7042 Forsaken Skill: Staves // 7043 Forsaken Skill: Bows // 7044 Forsaken Skill: Guns // 7045 Forsaken Skill: 2H Axes // 7046 Forsaken Skill: 2H Maces // 7047 Forsaken Skill: 2H Swords // 7048 Forsaken Skill: Defense // 7049 Forsaken Skill: Fire // 7050 Forsaken Skill: Frost // 7051 Forsaken Skill: Holy // 7053 Forsaken Skill: Shadow return; } case 7057: // Haunting Spirits if (roll_chance_i(33)) target->CastSpell(target, m_modifier.m_amount, true, NULL, this); return; // // Panda // case 19230: break; // // Gossip NPC Periodic - Talk // case 33208: break; // // Gossip NPC Periodic - Despawn // case 33209: break; // // Steal Weapon // case 36207: break; // // Simon Game START timer, (DND) // case 39993: break; // // Harpooner's Mark // case 40084: break; // // Old Mount Spell // case 40154: break; // // Magnetic Pull // case 40581: break; // // Ethereal Ring: break; The Bolt Burst // case 40801: break; // // Crystal Prison // case 40846: break; // // Copy Weapon // case 41054: break; // // Ethereal Ring Visual, Lightning Aura // case 41477: break; // // Ethereal Ring Visual, Lightning Aura (Fork) // case 41525: break; // // Ethereal Ring Visual, Lightning Jumper Aura // case 41567: break; // // No Man's Land // case 41955: break; // // Headless Horseman - Fire // case 42074: break; // // Headless Horseman - Visual - Large Fire // case 42075: break; // // Headless Horseman - Start Fire, Periodic Aura // case 42140: break; // // Ram Speed Boost // case 42152: break; // // Headless Horseman - Fires Out Victory Aura // case 42235: break; // // Pumpkin Life Cycle // case 42280: break; // // Brewfest Request Chick Chuck Mug Aura // case 42537: break; // // Squashling // case 42596: break; // // Headless Horseman Climax, Head: Periodic // case 42603: break; case 42621: // Fire Bomb { // Cast the summon spells (42622 to 42627) with increasing chance uint32 rand = urand(0, 99); for (uint32 i = 1; i <= 6; ++i) { if (rand < i * (i + 1) / 2 * 5) { target->CastSpell(target, spell->Id + i, true); break; } } break; } // // Headless Horseman - Conflagrate, Periodic Aura // case 42637: break; // // Headless Horseman - Create Pumpkin Treats Aura // case 42774: break; // // Headless Horseman Climax - Summoning Rhyme Aura // case 42879: break; // // Tricky Treat // case 42919: break; // // Giddyup! // case 42924: break; // // Ram - Trot // case 42992: break; // // Ram - Canter // case 42993: break; // // Ram - Gallop // case 42994: break; // // Ram Level - Neutral // case 43310: break; // // Headless Horseman - Maniacal Laugh, Maniacal, Delayed 17 // case 43884: break; // // Headless Horseman - Maniacal Laugh, Maniacal, other, Delayed 17 // case 44000: break; // // Energy Feedback // case 44328: break; // // Romantic Picnic // case 45102: break; // // Romantic Picnic // case 45123: break; // // Looking for Love // case 45124: break; // // Kite - Lightning Strike Kite Aura // case 45197: break; // // Rocket Chicken // case 45202: break; // // Copy Offhand Weapon // case 45205: break; // // Upper Deck - Kite - Lightning Periodic Aura // case 45207: break; // // Kite -Sky Lightning Strike Kite Aura // case 45251: break; // // Ribbon Pole Dancer Check Aura // case 45390: break; // // Holiday - Midsummer, Ribbon Pole Periodic Visual // case 45406: break; // // Alliance Flag, Extra Damage Debuff // case 45898: break; // // Horde Flag, Extra Damage Debuff // case 45899: break; // // Ahune - Summoning Rhyme Aura // case 45926: break; // // Ahune - Slippery Floor // case 45945: break; // // Ahune's Shield // case 45954: break; // // Nether Vapor Lightning // case 45960: break; // // Darkness // case 45996: break; case 46041: // Summon Blood Elves Periodic target->CastSpell(target, 46037, true, NULL, this); target->CastSpell(target, roll_chance_i(50) ? 46038 : 46039, true, NULL, this); target->CastSpell(target, 46040, true, NULL, this); return; // // Transform Visual Missile Periodic // case 46205: break; // // Find Opening Beam End // case 46333: break; // // Ice Spear Control Aura // case 46371: break; // // Hailstone Chill // case 46458: break; // // Hailstone Chill, Internal // case 46465: break; // // Chill, Internal Shifter // case 46549: break; // // Summon Ice Spear Knockback Delayer // case 46878: break; // // Send Mug Control Aura // case 47369: break; // // Direbrew's Disarm (precast) // case 47407: break; // // Mole Machine Port Schedule // case 47489: break; // // Mole Machine Portal Schedule // case 49466: break; // // Drink Coffee // case 49472: break; // // Listening to Music // case 50493: break; // // Love Rocket Barrage // case 50530: break; // Exist more after, need add later default: break; } // Drink (item drink spells) if (GetEffIndex() > EFFECT_INDEX_0 && spell->EffectApplyAuraName[GetEffIndex()-1] == SPELL_AURA_MOD_POWER_REGEN) { if (target->GetTypeId() != TYPEID_PLAYER) return; // Search SPELL_AURA_MOD_POWER_REGEN aura for this spell and add bonus if (Aura* aura = GetHolder()->GetAuraByEffectIndex(SpellEffectIndex(GetEffIndex() - 1))) { aura->GetModifier()->m_amount = m_modifier.m_amount; ((Player*)target)->UpdateManaRegen(); // Disable continue m_isPeriodic = false; return; } return; } break; } case SPELLFAMILY_HUNTER: { // Aspect of the Viper switch (spell->Id) { case 34074: { if (target->GetTypeId() != TYPEID_PLAYER) return; // Should be manauser if (target->getPowerType() != POWER_MANA) return; Unit* caster = GetCaster(); if (!caster) return; // Regen amount is max (100% from spell) on 21% or less mana and min on 92.5% or greater mana (20% from spell) int mana = target->GetPower(POWER_MANA); int max_mana = target->GetMaxPower(POWER_MANA); int32 base_regen = caster->CalculateSpellDamage(target, GetSpellProto(), m_effIndex, &m_currentBasePoints); float regen_pct = 1.20f - 1.1f * mana / max_mana; if (regen_pct > 1.0f) regen_pct = 1.0f; else if (regen_pct < 0.2f) regen_pct = 0.2f; m_modifier.m_amount = int32(base_regen * regen_pct); ((Player*)target)->UpdateManaRegen(); return; } // // Knockdown Fel Cannon: break; The Aggro Burst // case 40119: break; } break; } default: break; } } void Aura::HandlePreventFleeing(bool apply, bool Real) { if (!Real) return; Unit::AuraList const& fearAuras = GetTarget()->GetAurasByType(SPELL_AURA_MOD_FEAR); if (!fearAuras.empty()) { if (apply) GetTarget()->SetFeared(false, fearAuras.front()->GetCasterGuid()); else GetTarget()->SetFeared(true); } } void Aura::HandleManaShield(bool apply, bool Real) { if (!Real) return; // prevent double apply bonuses if (apply && (GetTarget()->GetTypeId() != TYPEID_PLAYER || !((Player*)GetTarget())->GetSession()->PlayerLoading())) { if (Unit* caster = GetCaster()) { float DoneActualBenefit = 0.0f; switch (GetSpellProto()->SpellFamilyName) { case SPELLFAMILY_MAGE: if (GetSpellProto()->SpellFamilyFlags & UI64LIT(0x0000000000008000)) { // Mana Shield // +50% from +spd bonus DoneActualBenefit = caster->SpellBaseDamageBonusDone(GetSpellSchoolMask(GetSpellProto())) * 0.5f; break; } break; default: break; } DoneActualBenefit *= caster->CalculateLevelPenalty(GetSpellProto()); m_modifier.m_amount += (int32)DoneActualBenefit; } } } void Aura::HandleArenaPreparation(bool apply, bool Real) { if (!Real) return; Unit* target = GetTarget(); target->ApplyModFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PREPARATION, apply); if (apply) { // max regen powers at start preparation target->SetHealth(target->GetMaxHealth()); target->SetPower(POWER_MANA, target->GetMaxPower(POWER_MANA)); target->SetPower(POWER_ENERGY, target->GetMaxPower(POWER_ENERGY)); } else { // reset originally 0 powers at start/leave target->SetPower(POWER_RAGE, 0); } } void Aura::HandleAuraMirrorImage(bool apply, bool Real) { if (!Real) return; // Target of aura should always be creature (ref Spell::CheckCast) Creature* pCreature = (Creature*)GetTarget(); if (apply) { // Caster can be player or creature, the unit who pCreature will become an clone of. Unit* caster = GetCaster(); pCreature->SetByteValue(UNIT_FIELD_BYTES_0, 0, caster->getRace()); pCreature->SetByteValue(UNIT_FIELD_BYTES_0, 1, caster->getClass()); pCreature->SetByteValue(UNIT_FIELD_BYTES_0, 2, caster->getGender()); pCreature->SetByteValue(UNIT_FIELD_BYTES_0, 3, caster->getPowerType()); pCreature->SetFlag(UNIT_FIELD_FLAGS_2, UNIT_FLAG2_CLONED); pCreature->SetDisplayId(caster->GetNativeDisplayId()); } else { const CreatureInfo* cinfo = pCreature->GetCreatureInfo(); const CreatureModelInfo* minfo = sObjectMgr.GetCreatureModelInfo(pCreature->GetNativeDisplayId()); pCreature->SetByteValue(UNIT_FIELD_BYTES_0, 0, 0); pCreature->SetByteValue(UNIT_FIELD_BYTES_0, 1, cinfo->unit_class); pCreature->SetByteValue(UNIT_FIELD_BYTES_0, 2, minfo->gender); pCreature->SetByteValue(UNIT_FIELD_BYTES_0, 3, 0); pCreature->RemoveFlag(UNIT_FIELD_FLAGS_2, UNIT_FLAG2_CLONED); pCreature->SetDisplayId(pCreature->GetNativeDisplayId()); } } void Aura::HandleAuraSafeFall(bool Apply, bool Real) { // implemented in WorldSession::HandleMovementOpcodes // only special case if (Apply && Real && GetId() == 32474 && GetTarget()->GetTypeId() == TYPEID_PLAYER) ((Player*)GetTarget())->ActivateTaxiPathTo(506, GetId()); } bool Aura::IsLastAuraOnHolder() { for (int32 i = 0; i < MAX_EFFECT_INDEX; ++i) if (i != GetEffIndex() && GetHolder()->m_auras[i]) return false; return true; } bool Aura::HasMechanic(uint32 mechanic) const { return GetSpellProto()->Mechanic == mechanic || GetSpellProto()->EffectMechanic[m_effIndex] == mechanic; } SpellAuraHolder::SpellAuraHolder(SpellEntry const* spellproto, Unit* target, WorldObject* caster, Item* castItem) : m_spellProto(spellproto), m_target(target), m_castItemGuid(castItem ? castItem->GetObjectGuid() : ObjectGuid()), m_auraSlot(MAX_AURAS), m_auraLevel(1), m_procCharges(0), m_stackAmount(1), m_timeCla(1000), m_removeMode(AURA_REMOVE_BY_DEFAULT), m_AuraDRGroup(DIMINISHING_NONE), m_permanent(false), m_isRemovedOnShapeLost(true), m_deleted(false), m_in_use(0) { MANGOS_ASSERT(target); MANGOS_ASSERT(spellproto && spellproto == sSpellStore.LookupEntry(spellproto->Id) && "`info` must be pointer to sSpellStore element"); if (!caster) m_casterGuid = target->GetObjectGuid(); else { // remove this assert when not unit casters will be supported MANGOS_ASSERT(caster->isType(TYPEMASK_UNIT)) m_casterGuid = caster->GetObjectGuid(); } m_applyTime = time(NULL); m_isPassive = IsPassiveSpell(spellproto); m_isDeathPersist = IsDeathPersistentSpell(spellproto); m_trackedAuraType= IsSingleTargetSpell(spellproto) ? TRACK_AURA_TYPE_SINGLE_TARGET : TRACK_AURA_TYPE_NOT_TRACKED; m_procCharges = spellproto->procCharges; m_isRemovedOnShapeLost = (GetCasterGuid() == m_target->GetObjectGuid() && m_spellProto->Stances && !m_spellProto->HasAttribute(SPELL_ATTR_EX2_NOT_NEED_SHAPESHIFT) && !m_spellProto->HasAttribute(SPELL_ATTR_NOT_SHAPESHIFT)); Unit* unitCaster = caster && caster->isType(TYPEMASK_UNIT) ? (Unit*)caster : NULL; m_duration = m_maxDuration = CalculateSpellDuration(spellproto, unitCaster); if (m_maxDuration == -1 || (m_isPassive && spellproto->DurationIndex == 0)) m_permanent = true; if (unitCaster) { if (Player* modOwner = unitCaster->GetSpellModOwner()) modOwner->ApplySpellMod(GetId(), SPELLMOD_CHARGES, m_procCharges); } // some custom stack values at aura holder create switch (m_spellProto->Id) { // some auras applied with max stack case 24575: // Brittle Armor case 24659: // Unstable Power case 24662: // Restless Strength case 26464: // Mercurial Shield m_stackAmount = m_spellProto->StackAmount; break; } for (int32 i = 0; i < MAX_EFFECT_INDEX; ++i) m_auras[i] = NULL; } void SpellAuraHolder::AddAura(Aura* aura, SpellEffectIndex index) { m_auras[index] = aura; } void SpellAuraHolder::RemoveAura(SpellEffectIndex index) { m_auras[index] = NULL; } void SpellAuraHolder::ApplyAuraModifiers(bool apply, bool real) { for (int32 i = 0; i < MAX_EFFECT_INDEX && !IsDeleted(); ++i) if (Aura* aur = GetAuraByEffectIndex(SpellEffectIndex(i))) aur->ApplyModifier(apply, real); } void SpellAuraHolder::_AddSpellAuraHolder() { if (!GetId()) return; if (!m_target) return; // Try find slot for aura uint8 slot = NULL_AURA_SLOT; Unit* caster = GetCaster(); // Lookup free slot // will be < MAX_AURAS slot (if find free) with !secondaura if (IsNeedVisibleSlot(caster)) { if (IsPositive()) // empty positive slot { for (uint8 i = 0; i < MAX_POSITIVE_AURAS; i++) { if (m_target->GetUInt32Value((uint16)(UNIT_FIELD_AURA + i)) == 0) { slot = i; break; } } } else // empty negative slot { for (uint8 i = MAX_POSITIVE_AURAS; i < MAX_AURAS; i++) { if (m_target->GetUInt32Value((uint16)(UNIT_FIELD_AURA + i)) == 0) { slot = i; break; } } } } // set infinity cooldown state for spells if (caster && caster->GetTypeId() == TYPEID_PLAYER) { if (m_spellProto->HasAttribute(SPELL_ATTR_DISABLED_WHILE_ACTIVE)) { Item* castItem = m_castItemGuid ? ((Player*)caster)->GetItemByGuid(m_castItemGuid) : NULL; ((Player*)caster)->AddSpellAndCategoryCooldowns(m_spellProto, castItem ? castItem->GetEntry() : 0, NULL, true); } } SetAuraSlot(slot); // Not update fields for not first spell's aura, all data already in fields if (slot < MAX_AURAS) // slot found { SetAura(slot, false); SetAuraFlag(slot, true); SetAuraLevel(slot, caster ? caster->getLevel() : sWorld.getConfig(CONFIG_UINT32_MAX_PLAYER_LEVEL)); UpdateAuraApplication(); // update for out of range group members m_target->UpdateAuraForGroup(slot); UpdateAuraDuration(); } //***************************************************** // Update target aura state flag (at 1 aura apply) // TODO: Make it easer //***************************************************** // Sitdown on apply aura req seated if (m_spellProto->AuraInterruptFlags & AURA_INTERRUPT_FLAG_NOT_SEATED && !m_target->IsSitState()) m_target->SetStandState(UNIT_STAND_STATE_SIT); // register aura diminishing on apply if (getDiminishGroup() != DIMINISHING_NONE) m_target->ApplyDiminishingAura(getDiminishGroup(), true); // Update Seals information if (IsSealSpell(GetSpellProto())) m_target->ModifyAuraState(AURA_STATE_JUDGEMENT, true); // Conflagrate aura state if (GetSpellProto()->IsFitToFamily(SPELLFAMILY_WARLOCK, UI64LIT(0x0000000000000004))) m_target->ModifyAuraState(AURA_STATE_CONFLAGRATE, true); // Faerie Fire (druid versions) if (m_spellProto->IsFitToFamily(SPELLFAMILY_DRUID, UI64LIT(0x0000000000000400))) m_target->ModifyAuraState(AURA_STATE_FAERIE_FIRE, true); // Swiftmend state on Regrowth & Rejuvenation if (m_spellProto->IsFitToFamily(SPELLFAMILY_DRUID, UI64LIT(0x0000000000000050))) m_target->ModifyAuraState(AURA_STATE_SWIFTMEND, true); // Deadly poison aura state if (m_spellProto->IsFitToFamily(SPELLFAMILY_ROGUE, UI64LIT(0x0000000000010000))) m_target->ModifyAuraState(AURA_STATE_DEADLY_POISON, true); } void SpellAuraHolder::_RemoveSpellAuraHolder() { // Remove all triggered by aura spells vs unlimited duration // except same aura replace case if (m_removeMode != AURA_REMOVE_BY_STACK) CleanupTriggeredSpells(); Unit* caster = GetCaster(); if (caster && IsPersistent()) if (DynamicObject* dynObj = caster->GetDynObject(GetId())) dynObj->RemoveAffected(m_target); // remove at-store spell cast items (for all remove modes?) if (m_target->GetTypeId() == TYPEID_PLAYER && m_removeMode != AURA_REMOVE_BY_DEFAULT && m_removeMode != AURA_REMOVE_BY_DELETE) if (ObjectGuid castItemGuid = GetCastItemGuid()) if (Item* castItem = ((Player*)m_target)->GetItemByGuid(castItemGuid)) ((Player*)m_target)->DestroyItemWithOnStoreSpell(castItem, GetId()); // passive auras do not get put in slots - said who? ;) // Note: but totem can be not accessible for aura target in time remove (to far for find in grid) // if(m_isPassive && !(caster && caster->GetTypeId() == TYPEID_UNIT && ((Creature*)caster)->IsTotem())) // return; uint8 slot = GetAuraSlot(); if (slot >= MAX_AURAS) // slot not set return; if (m_target->GetUInt32Value((uint16)(UNIT_FIELD_AURA + slot)) == 0) return; // unregister aura diminishing (and store last time) if (getDiminishGroup() != DIMINISHING_NONE) m_target->ApplyDiminishingAura(getDiminishGroup(), false); SetAura(slot, true); SetAuraFlag(slot, false); SetAuraLevel(slot, caster ? caster->getLevel() : sWorld.getConfig(CONFIG_UINT32_MAX_PLAYER_LEVEL)); m_procCharges = 0; m_stackAmount = 1; UpdateAuraApplication(); if (m_removeMode != AURA_REMOVE_BY_DELETE) { // update for out of range group members m_target->UpdateAuraForGroup(slot); //***************************************************** // Update target aura state flag (at last aura remove) //***************************************************** uint32 removeState = 0; ClassFamilyMask removeFamilyFlag = m_spellProto->SpellFamilyFlags; switch (m_spellProto->SpellFamilyName) { case SPELLFAMILY_PALADIN: if (IsSealSpell(m_spellProto)) removeState = AURA_STATE_JUDGEMENT; // Update Seals information break; case SPELLFAMILY_WARLOCK: if (m_spellProto->IsFitToFamilyMask(UI64LIT(0x0000000000000004))) removeState = AURA_STATE_CONFLAGRATE; // Conflagrate aura state break; case SPELLFAMILY_DRUID: if (m_spellProto->IsFitToFamilyMask(UI64LIT(0x0000000000000400))) removeState = AURA_STATE_FAERIE_FIRE; // Faerie Fire (druid versions) else if (m_spellProto->IsFitToFamilyMask(UI64LIT(0x0000000000000050))) { removeFamilyFlag = ClassFamilyMask(UI64LIT(0x00000000000050)); removeState = AURA_STATE_SWIFTMEND; // Swiftmend aura state } break; case SPELLFAMILY_ROGUE: if (m_spellProto->IsFitToFamilyMask(UI64LIT(0x0000000000010000))) removeState = AURA_STATE_DEADLY_POISON; // Deadly poison aura state break; } // Remove state (but need check other auras for it) if (removeState) { bool found = false; Unit::SpellAuraHolderMap const& holders = m_target->GetSpellAuraHolderMap(); for (Unit::SpellAuraHolderMap::const_iterator i = holders.begin(); i != holders.end(); ++i) { SpellEntry const* auraSpellInfo = (*i).second->GetSpellProto(); if (auraSpellInfo->IsFitToFamily(SpellFamily(m_spellProto->SpellFamilyName), removeFamilyFlag)) { found = true; break; } } // this has been last aura if (!found) m_target->ModifyAuraState(AuraState(removeState), false); } // reset cooldown state for spells if (caster && caster->GetTypeId() == TYPEID_PLAYER) { if (GetSpellProto()->HasAttribute(SPELL_ATTR_DISABLED_WHILE_ACTIVE)) // note: item based cooldowns and cooldown spell mods with charges ignored (unknown existing cases) ((Player*)caster)->SendCooldownEvent(GetSpellProto()); } } } void SpellAuraHolder::CleanupTriggeredSpells() { for (int32 i = 0; i < MAX_EFFECT_INDEX; ++i) { if (!m_spellProto->EffectApplyAuraName[i]) continue; uint32 tSpellId = m_spellProto->EffectTriggerSpell[i]; if (!tSpellId) continue; SpellEntry const* tProto = sSpellStore.LookupEntry(tSpellId); if (!tProto) continue; if (GetSpellDuration(tProto) != -1) continue; // needed for spell 43680, maybe others // TODO: is there a spell flag, which can solve this in a more sophisticated way? if (m_spellProto->EffectApplyAuraName[i] == SPELL_AURA_PERIODIC_TRIGGER_SPELL && GetSpellDuration(m_spellProto) == int32(m_spellProto->EffectAmplitude[i])) continue; m_target->RemoveAurasDueToSpell(tSpellId); } } bool SpellAuraHolder::ModStackAmount(int32 num) { uint32 protoStackAmount = m_spellProto->StackAmount; // Can`t mod if (!protoStackAmount) return true; // Modify stack but limit it int32 stackAmount = m_stackAmount + num; if (stackAmount > (int32)protoStackAmount) stackAmount = protoStackAmount; else if (stackAmount <= 0) // Last aura from stack removed { m_stackAmount = 0; return true; // need remove aura } // Update stack amount SetStackAmount(stackAmount); return false; } void SpellAuraHolder::SetStackAmount(uint32 stackAmount) { Unit* target = GetTarget(); Unit* caster = GetCaster(); if (!target || !caster) return; bool refresh = stackAmount >= m_stackAmount; if (stackAmount != m_stackAmount) { m_stackAmount = stackAmount; UpdateAuraApplication(); for (int32 i = 0; i < MAX_EFFECT_INDEX; ++i) { if (Aura* aur = m_auras[i]) { int32 bp = aur->GetBasePoints(); int32 amount = m_stackAmount * caster->CalculateSpellDamage(target, m_spellProto, SpellEffectIndex(i), &bp); // Reapply if amount change if (amount != aur->GetModifier()->m_amount) { aur->ApplyModifier(false, true); aur->GetModifier()->m_amount = amount; aur->ApplyModifier(true, true); } } } } if (refresh) // Stack increased refresh duration RefreshHolder(); } Unit* SpellAuraHolder::GetCaster() const { if (GetCasterGuid() == m_target->GetObjectGuid()) return m_target; return ObjectAccessor::GetUnit(*m_target, m_casterGuid);// player will search at any maps } bool SpellAuraHolder::IsWeaponBuffCoexistableWith(SpellAuraHolder const* ref) const { // only item casted spells if (!GetCastItemGuid()) return false; // Exclude Debuffs if (!IsPositive()) return false; // Exclude Non-generic Buffs and Executioner-Enchant if (GetSpellProto()->SpellFamilyName != SPELLFAMILY_GENERIC || GetId() == 42976) return false; // Exclude Stackable Buffs [ie: Blood Reserve] if (GetSpellProto()->StackAmount) return false; // only self applied player buffs if (m_target->GetTypeId() != TYPEID_PLAYER || m_target->GetObjectGuid() != GetCasterGuid()) return false; Item* castItem = ((Player*)m_target)->GetItemByGuid(GetCastItemGuid()); if (!castItem) return false; // Limit to Weapon-Slots if (!castItem->IsEquipped() || (castItem->GetSlot() != EQUIPMENT_SLOT_MAINHAND && castItem->GetSlot() != EQUIPMENT_SLOT_OFFHAND)) return false; // form different weapons return ref->GetCastItemGuid() && ref->GetCastItemGuid() != GetCastItemGuid(); } bool SpellAuraHolder::IsNeedVisibleSlot(Unit const* caster) const { bool totemAura = caster && caster->GetTypeId() == TYPEID_UNIT && ((Creature*)caster)->IsTotem(); for (int i = 0; i < MAX_EFFECT_INDEX; ++i) { if (!m_auras[i]) continue; // special area auras cases switch (m_spellProto->Effect[i]) { case SPELL_EFFECT_APPLY_AREA_AURA_ENEMY: return m_target != caster; case SPELL_EFFECT_APPLY_AREA_AURA_PET: case SPELL_EFFECT_APPLY_AREA_AURA_OWNER: case SPELL_EFFECT_APPLY_AREA_AURA_FRIEND: case SPELL_EFFECT_APPLY_AREA_AURA_PARTY: // passive auras (except totem auras) do not get placed in caster slot return (m_target != caster || totemAura || !m_isPassive) && m_auras[i]->GetModifier()->m_auraname != SPELL_AURA_NONE; default: break; } } // passive auras (except totem auras) do not get placed in the slots return !m_isPassive || totemAura; } void SpellAuraHolder::HandleSpellSpecificBoosts(bool apply) { uint32 spellId1 = 0; uint32 spellId2 = 0; uint32 spellId3 = 0; uint32 spellId4 = 0; switch (GetSpellProto()->SpellFamilyName) { case SPELLFAMILY_MAGE: { switch (GetId()) { case 11189: // Frost Warding case 28332: { if (m_target->GetTypeId() == TYPEID_PLAYER && !apply) { // reflection chance (effect 1) of Frost Ward, applied in dummy effect if (SpellModifier* mod = ((Player*)m_target)->GetSpellMod(SPELLMOD_EFFECT2, GetId())) ((Player*)m_target)->AddSpellMod(mod, false); } return; } default: return; } break; } case SPELLFAMILY_WARRIOR: { if (!apply) { // Remove Blood Frenzy only if target no longer has any Deep Wound or Rend (applying is handled by procs) if (GetSpellProto()->Mechanic != MECHANIC_BLEED) return; // If target still has one of Warrior's bleeds, do nothing Unit::AuraList const& PeriodicDamage = m_target->GetAurasByType(SPELL_AURA_PERIODIC_DAMAGE); for (Unit::AuraList::const_iterator i = PeriodicDamage.begin(); i != PeriodicDamage.end(); ++i) if ((*i)->GetCasterGuid() == GetCasterGuid() && (*i)->GetSpellProto()->SpellFamilyName == SPELLFAMILY_WARRIOR && (*i)->GetSpellProto()->Mechanic == MECHANIC_BLEED) return; spellId1 = 30069; // Blood Frenzy (Rank 1) spellId2 = 30070; // Blood Frenzy (Rank 2) } else return; break; } case SPELLFAMILY_HUNTER: { switch (GetId()) { // The Beast Within and Bestial Wrath - immunity case 19574: case 34471: { spellId1 = 24395; spellId2 = 24396; spellId3 = 24397; spellId4 = 26592; break; } // Misdirection, main spell case 34477: { if (!apply) m_target->getHostileRefManager().ResetThreatRedirection(); return; } default: return; } break; } default: return; } // prevent aura deletion, specially in multi-boost case SetInUse(true); if (apply) { if (spellId1) m_target->CastSpell(m_target, spellId1, true, NULL, NULL, GetCasterGuid()); if (spellId2 && !IsDeleted()) m_target->CastSpell(m_target, spellId2, true, NULL, NULL, GetCasterGuid()); if (spellId3 && !IsDeleted()) m_target->CastSpell(m_target, spellId3, true, NULL, NULL, GetCasterGuid()); if (spellId4 && !IsDeleted()) m_target->CastSpell(m_target, spellId4, true, NULL, NULL, GetCasterGuid()); } else { if (spellId1) m_target->RemoveAurasByCasterSpell(spellId1, GetCasterGuid()); if (spellId2) m_target->RemoveAurasByCasterSpell(spellId2, GetCasterGuid()); if (spellId3) m_target->RemoveAurasByCasterSpell(spellId3, GetCasterGuid()); if (spellId4) m_target->RemoveAurasByCasterSpell(spellId4, GetCasterGuid()); } SetInUse(false); } SpellAuraHolder::~SpellAuraHolder() { // note: auras in delete list won't be affected since they clear themselves from holder when adding to deletedAuraslist for (int32 i = 0; i < MAX_EFFECT_INDEX; ++i) if (Aura* aur = m_auras[i]) delete aur; } void SpellAuraHolder::Update(uint32 diff) { if (m_duration > 0) { m_duration -= diff; if (m_duration < 0) m_duration = 0; m_timeCla -= diff; if (m_timeCla <= 0) { if (Unit* caster = GetCaster()) { Powers powertype = Powers(GetSpellProto()->powerType); int32 manaPerSecond = GetSpellProto()->manaPerSecond + GetSpellProto()->manaPerSecondPerLevel * caster->getLevel(); m_timeCla = 1 * IN_MILLISECONDS; if (manaPerSecond) { if (powertype == POWER_HEALTH) caster->ModifyHealth(-manaPerSecond); else caster->ModifyPower(powertype, -manaPerSecond); } } } } for (int32 i = 0; i < MAX_EFFECT_INDEX; ++i) if (Aura* aura = m_auras[i]) aura->UpdateAura(diff); // Channeled aura required check distance from caster if (IsChanneledSpell(m_spellProto) && GetCasterGuid() != m_target->GetObjectGuid()) { Unit* caster = GetCaster(); if (!caster) { m_target->RemoveAurasByCasterSpell(GetId(), GetCasterGuid()); return; } // need check distance for channeled target only if (caster->GetChannelObjectGuid() == m_target->GetObjectGuid()) { // Get spell range float max_range = GetSpellMaxRange(sSpellRangeStore.LookupEntry(m_spellProto->rangeIndex)); if (Player* modOwner = caster->GetSpellModOwner()) modOwner->ApplySpellMod(GetId(), SPELLMOD_RANGE, max_range, NULL); if (!caster->IsWithinDistInMap(m_target, max_range)) { caster->InterruptSpell(CURRENT_CHANNELED_SPELL); return; } } } } void SpellAuraHolder::RefreshHolder() { SetAuraDuration(GetAuraMaxDuration()); UpdateAuraDuration(); } void SpellAuraHolder::SetAuraMaxDuration(int32 duration) { m_maxDuration = duration; // possible overwrite persistent state if (duration > 0) { if (!(IsPassive() && GetSpellProto()->DurationIndex == 0)) SetPermanent(false); } } bool SpellAuraHolder::HasMechanic(uint32 mechanic) const { if (mechanic == m_spellProto->Mechanic) return true; for (int32 i = 0; i < MAX_EFFECT_INDEX; ++i) if (m_auras[i] && m_spellProto->EffectMechanic[i] == mechanic) return true; return false; } bool SpellAuraHolder::HasMechanicMask(uint32 mechanicMask) const { if (mechanicMask & (1 << (m_spellProto->Mechanic - 1))) return true; for (int32 i = 0; i < MAX_EFFECT_INDEX; ++i) if (m_auras[i] && m_spellProto->EffectMechanic[i] && ((1 << (m_spellProto->EffectMechanic[i] - 1)) & mechanicMask)) return true; return false; } bool SpellAuraHolder::IsPersistent() const { for (int32 i = 0; i < MAX_EFFECT_INDEX; ++i) if (Aura* aur = m_auras[i]) if (aur->IsPersistent()) return true; return false; } bool SpellAuraHolder::IsAreaAura() const { for (int32 i = 0; i < MAX_EFFECT_INDEX; ++i) if (Aura* aur = m_auras[i]) if (aur->IsAreaAura()) return true; return false; } bool SpellAuraHolder::IsPositive() const { for (int32 i = 0; i < MAX_EFFECT_INDEX; ++i) if (Aura* aur = m_auras[i]) if (!aur->IsPositive()) return false; return true; } bool SpellAuraHolder::IsEmptyHolder() const { for (int32 i = 0; i < MAX_EFFECT_INDEX; ++i) if (m_auras[i]) return false; return true; } void SpellAuraHolder::UnregisterAndCleanupTrackedAuras() { TrackedAuraType trackedType = GetTrackedAuraType(); if (!trackedType) return; if (trackedType == TRACK_AURA_TYPE_SINGLE_TARGET) { if (Unit* caster = GetCaster()) caster->GetTrackedAuraTargets(trackedType).erase(GetSpellProto()); } m_trackedAuraType = TRACK_AURA_TYPE_NOT_TRACKED; } void SpellAuraHolder::SetAuraFlag(uint32 slot, bool add) { uint32 index = slot / 4; uint32 byte = (slot % 4) * 8; uint32 val = m_target->GetUInt32Value(UNIT_FIELD_AURAFLAGS + index); val &= ~((uint32)AFLAG_MASK << byte); if (add) { if (IsPositive()) val |= ((uint32)AFLAG_POSITIVE << byte); else val |= ((uint32)AFLAG_NEGATIVE << byte); } m_target->SetUInt32Value(UNIT_FIELD_AURAFLAGS + index, val); } void SpellAuraHolder::SetAuraLevel(uint32 slot, uint32 level) { uint32 index = slot / 4; uint32 byte = (slot % 4) * 8; uint32 val = m_target->GetUInt32Value(UNIT_FIELD_AURALEVELS + index); val &= ~(0xFF << byte); val |= (level << byte); m_target->SetUInt32Value(UNIT_FIELD_AURALEVELS + index, val); } void SpellAuraHolder::UpdateAuraApplication() { if (m_auraSlot >= MAX_AURAS) return; uint32 stackCount = m_procCharges > 0 ? m_procCharges * m_stackAmount : m_stackAmount; uint32 index = m_auraSlot / 4; uint32 byte = (m_auraSlot % 4) * 8; uint32 val = m_target->GetUInt32Value(UNIT_FIELD_AURAAPPLICATIONS + index); val &= ~(0xFF << byte); // field expect count-1 for proper amount show, also prevent overflow at client side val |= ((uint8(stackCount <= 255 ? stackCount - 1 : 255 - 1)) << byte); m_target->SetUInt32Value(UNIT_FIELD_AURAAPPLICATIONS + index, val); } void SpellAuraHolder::UpdateAuraDuration() { if (GetAuraSlot() >= MAX_AURAS || m_isPassive) return; if (m_target->GetTypeId() == TYPEID_PLAYER) { WorldPacket data(SMSG_UPDATE_AURA_DURATION, 5); data << uint8(GetAuraSlot()); data << uint32(GetAuraDuration()); ((Player*)m_target)->SendDirectMessage(&data); data.Initialize(SMSG_SET_EXTRA_AURA_INFO, (8 + 1 + 4 + 4 + 4)); data << m_target->GetPackGUID(); data << uint8(GetAuraSlot()); data << uint32(GetId()); data << uint32(GetAuraMaxDuration()); data << uint32(GetAuraDuration()); ((Player*)m_target)->SendDirectMessage(&data); } // not send in case player loading (will not work anyway until player not added to map), sent in visibility change code if (m_target->GetTypeId() == TYPEID_PLAYER && ((Player*)m_target)->GetSession()->PlayerLoading()) return; Unit* caster = GetCaster(); if (caster && caster->GetTypeId() == TYPEID_PLAYER && caster != m_target) SendAuraDurationForCaster((Player*)caster); } void SpellAuraHolder::SendAuraDurationForCaster(Player* caster) { WorldPacket data(SMSG_SET_EXTRA_AURA_INFO_NEED_UPDATE, (8 + 1 + 4 + 4 + 4)); data << m_target->GetPackGUID(); data << uint8(GetAuraSlot()); data << uint32(GetId()); data << uint32(GetAuraMaxDuration()); // full data << uint32(GetAuraDuration()); // remain caster->GetSession()->SendPacket(&data); }
blueboy/portalone
src/game/SpellAuras.cpp
C++
gpl-2.0
309,536
# CMAKE generated file: DO NOT EDIT! # Generated by "Unix Makefiles" Generator, CMake Version 2.8 # The generator used is: SET(CMAKE_DEPENDS_GENERATOR "Unix Makefiles") # The top level Makefile was generated from the following files: SET(CMAKE_MAKEFILE_DEPENDS "CMakeCache.txt" "/home/guillaume/tf-cadence/gnuradio/zedboard/arm_cortex_a8_native.cmake" "../CMakeLists.txt" "../apps/CMakeLists.txt" "CMakeFiles/CMakeCCompiler.cmake" "CMakeFiles/CMakeCXXCompiler.cmake" "CMakeFiles/CMakeSystem.cmake" "../cmake/Modules/CMakeParseArgumentsCopy.cmake" "../cmake/Modules/FindCppUnit.cmake" "../cmake/Modules/FindGnuradioRuntime.cmake" "../cmake/Modules/GrMiscUtils.cmake" "../cmake/Modules/GrPlatform.cmake" "../cmake/Modules/GrPython.cmake" "../cmake/Modules/GrSwig.cmake" "../cmake/Modules/GrTest.cmake" "../cmake/cmake_uninstall.cmake.in" "../docs/CMakeLists.txt" "../grc/CMakeLists.txt" "../include/test1/CMakeLists.txt" "../lib/CMakeLists.txt" "../python/CMakeLists.txt" "../swig/CMakeLists.txt" "/usr/share/cmake-2.8/Modules/CMakeCCompiler.cmake.in" "/usr/share/cmake-2.8/Modules/CMakeCInformation.cmake" "/usr/share/cmake-2.8/Modules/CMakeCXXCompiler.cmake.in" "/usr/share/cmake-2.8/Modules/CMakeCXXInformation.cmake" "/usr/share/cmake-2.8/Modules/CMakeClDeps.cmake" "/usr/share/cmake-2.8/Modules/CMakeCommonLanguageInclude.cmake" "/usr/share/cmake-2.8/Modules/CMakeDetermineCCompiler.cmake" "/usr/share/cmake-2.8/Modules/CMakeDetermineCXXCompiler.cmake" "/usr/share/cmake-2.8/Modules/CMakeDetermineCompilerId.cmake" "/usr/share/cmake-2.8/Modules/CMakeDetermineSystem.cmake" "/usr/share/cmake-2.8/Modules/CMakeFindBinUtils.cmake" "/usr/share/cmake-2.8/Modules/CMakeFindFrameworks.cmake" "/usr/share/cmake-2.8/Modules/CMakeGenericSystem.cmake" "/usr/share/cmake-2.8/Modules/CMakeParseArguments.cmake" "/usr/share/cmake-2.8/Modules/CMakeSystem.cmake.in" "/usr/share/cmake-2.8/Modules/CMakeSystemSpecificInformation.cmake" "/usr/share/cmake-2.8/Modules/CMakeTestCCompiler.cmake" "/usr/share/cmake-2.8/Modules/CMakeTestCXXCompiler.cmake" "/usr/share/cmake-2.8/Modules/CMakeTestCompilerCommon.cmake" "/usr/share/cmake-2.8/Modules/CMakeUnixFindMake.cmake" "/usr/share/cmake-2.8/Modules/Compiler/GNU-C.cmake" "/usr/share/cmake-2.8/Modules/Compiler/GNU-CXX.cmake" "/usr/share/cmake-2.8/Modules/Compiler/GNU.cmake" "/usr/share/cmake-2.8/Modules/FindBoost.cmake" "/usr/share/cmake-2.8/Modules/FindDoxygen.cmake" "/usr/share/cmake-2.8/Modules/FindPackageHandleStandardArgs.cmake" "/usr/share/cmake-2.8/Modules/FindPackageMessage.cmake" "/usr/share/cmake-2.8/Modules/FindPkgConfig.cmake" "/usr/share/cmake-2.8/Modules/FindPythonInterp.cmake" "/usr/share/cmake-2.8/Modules/FindPythonLibs.cmake" "/usr/share/cmake-2.8/Modules/FindSWIG.cmake" "/usr/share/cmake-2.8/Modules/Platform/Linux-GNU-C.cmake" "/usr/share/cmake-2.8/Modules/Platform/Linux-GNU-CXX.cmake" "/usr/share/cmake-2.8/Modules/Platform/Linux-GNU.cmake" "/usr/share/cmake-2.8/Modules/Platform/Linux.cmake" "/usr/share/cmake-2.8/Modules/Platform/UnixPaths.cmake" "/usr/share/cmake-2.8/Modules/SelectLibraryConfigurations.cmake" "/usr/share/cmake-2.8/Modules/UseSWIG.cmake" ) # The corresponding makefile is: SET(CMAKE_MAKEFILE_OUTPUTS "Makefile" "CMakeFiles/cmake.check_cache" ) # Byproducts of CMake generate step: SET(CMAKE_MAKEFILE_PRODUCTS "CMakeFiles/CMakeDirectoryInformation.cmake" "include/test1/CMakeFiles/CMakeDirectoryInformation.cmake" "lib/CMakeFiles/CMakeDirectoryInformation.cmake" "swig/CMakeFiles/CMakeDirectoryInformation.cmake" "python/CMakeFiles/CMakeDirectoryInformation.cmake" "grc/CMakeFiles/CMakeDirectoryInformation.cmake" "apps/CMakeFiles/CMakeDirectoryInformation.cmake" "docs/CMakeFiles/CMakeDirectoryInformation.cmake" ) # Dependency information for all targets: SET(CMAKE_DEPEND_INFO_FILES "CMakeFiles/uninstall.dir/DependInfo.cmake" "lib/CMakeFiles/gnuradio-test1.dir/DependInfo.cmake" "lib/CMakeFiles/test-test1.dir/DependInfo.cmake" "swig/CMakeFiles/_test1_swig.dir/DependInfo.cmake" "swig/CMakeFiles/_test1_swig_swig_tag.dir/DependInfo.cmake" "swig/CMakeFiles/pygen_swig_104a7.dir/DependInfo.cmake" "python/CMakeFiles/pygen_python_30562.dir/DependInfo.cmake" "apps/CMakeFiles/pygen_apps_9a6dd.dir/DependInfo.cmake" )
guillaumeWBres/zynq7-sdr
gnuradio/fpga-src/build_cross/CMakeFiles/Makefile.cmake
CMake
gpl-2.0
4,368
<?php /* * * Copyright 2001-2012 Thomas Belliard, Laurent Delineau, Edouard Hue, Eric Lebrun * * This file is part of GEPI. * * GEPI is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * GEPI is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with GEPI; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ // On indique qu'il faut creer des variables non protégées (voir fonction cree_variables_non_protegees()) $variables_non_protegees = 'yes'; // Begin standart header $titre_page = "Saisie de commentaires-types"; // Initialisations files require_once("../lib/initialisations.inc.php"); // Resume session $resultat_session = $session_gepi->security_check(); if ($resultat_session == 'c') { header("Location: ../utilisateurs/mon_compte.php?change_mdp=yes"); die(); } else if ($resultat_session == '0') { header("Location: ../logout.php?auto=1"); die(); } // Check access // INSERT INTO droits VALUES ('/saisie/commentaires_types.php', 'V', 'V', 'V', 'V', 'F', 'F', 'V', 'Saisie de commentaires-types', ''); if (!checkAccess()) { header("Location: ../logout.php?auto=1"); die(); } //========================================== // End standart header require_once("../lib/header.inc.php"); if (!loadSettings()) { die("Erreur chargement settings"); } //========================================== $sql="CREATE TABLE IF NOT EXISTS `commentaires_types` ( `id` INT( 11 ) NOT NULL AUTO_INCREMENT PRIMARY KEY , `commentaire` TEXT NOT NULL , `num_periode` INT NOT NULL , `id_classe` INT NOT NULL ) ENGINE=MyISAM CHARACTER SET utf8 COLLATE utf8_general_ci;"; $resultat_creation_table=mysqli_query($GLOBALS["mysqli"], $sql); function get_classe_from_id($id){ //$sql="SELECT * FROM classes WHERE id='$id_classe[0]'"; $sql="SELECT * FROM classes WHERE id='$id'"; $resultat_classe=mysqli_query($GLOBALS["mysqli"], $sql); if(mysqli_num_rows($resultat_classe)!=1){ //echo "<p>ERREUR! La classe d'identifiant '$id_classe[0]' n'a pas pu être identifiée.</p>"; echo "<p>ERREUR! La classe d'identifiant '$id' n'a pas pu être identifiée.</p>"; } else{ $ligne_classe=mysqli_fetch_object($resultat_classe); $classe=$ligne_classe->classe; return $classe; } } ?> <p class="bold"><a href="../accueil.php">Retour</a> | <a href="commentaires_types.php">Saisir des commentaires</a> | <a href="commentaires_types.php?recopie=oui">Recopier des commentaires</a> </p> <?php /* if ((($_SESSION['statut']=='professeur') AND ((getSettingValue("GepiProfImprBul")!='yes') OR ((getSettingValue("GepiProfImprBul")=='yes') AND (getSettingValue("GepiProfImprBulSettings")!='yes')))) OR (($_SESSION['statut']=='scolarite') AND (getSettingValue("GepiScolImprBulSettings")!='yes')) OR (($_SESSION['statut']=='administrateur') AND (getSettingValue("GepiAdminImprBulSettings")!='yes'))) { die("Droits insuffisants pour effectuer cette opération"); } */ if ((($_SESSION['statut']=='professeur') AND (getSettingValue("CommentairesTypesPP")=='yes') AND (mysqli_num_rows(mysqli_query($GLOBALS["mysqli"], "SELECT 1=1 FROM j_eleves_professeurs WHERE professeur='".$_SESSION['login']."'"))>0)) OR (($_SESSION['statut']=='scolarite') AND (getSettingValue("CommentairesTypesScol")=='yes')) OR (($_SESSION['statut']=='cpe') AND (getSettingValue("CommentairesTypesCpe")=='yes')) ) { // Accès autorisé à la page } else{ die("Droits insuffisants pour effectuer cette opération"); } ?> <form name="formulaire" action="commentaires_types.php" method="post"> <?php echo add_token_field(); //echo "\$_GET['recopie']=".$_GET['recopie']."<br />"; $recopie=isset($_GET['recopie']) ? $_GET['recopie'] : (isset($_POST['recopie']) ? $_POST['recopie'] : ""); //echo "\$recopie=$recopie<br />"; if($recopie!="oui"){ // ============================================= // Définition/modification des commentaires-type // ============================================= if(!isset($_POST['id_classe'])){ // Choix de la classe //echo "<p>Pour quelle classe et quelles périodes souhaitez-vous définir/modifier les commentaires-type?</p>\n"; echo "<p>Pour quelle classe souhaitez-vous définir/modifier les commentaires-type?</p>\n"; echo "<blockquote>\n"; // A REVOIR: Il ne faut lister que les classes appropriées. //$sql="select distinct id,classe from classes order by classe"; // if ((($_SESSION['statut']=='professeur') AND (getSettingValue("CommentairesTypesPP")=='yes') AND (mysql_num_rows(mysql_query("SELECT 1=1 FROM j_eleves_professeurs WHERE professeur='".$_SESSION['login']."'"))>0)) // OR (($_SESSION['statut']=='scolarite') AND (getSettingValue("CommentairesTypesScol")=='yes'))) if($_SESSION['statut']=='professeur'){ $sql="SELECT DISTINCT c.id,c.classe FROM j_eleves_classes jec, classes c, j_eleves_professeurs jep WHERE jec.id_classe=c.id AND jec.login=jep.login AND jep.professeur='".$_SESSION['login']."' ORDER BY c.classe"; } elseif($_SESSION['statut']=='scolarite'){ $sql="SELECT DISTINCT c.id,c.classe FROM j_scol_classes jsc, classes c WHERE jsc.id_classe=c.id AND jsc.login='".$_SESSION['login']."' ORDER BY c.classe"; } elseif(($_SESSION['statut']=='cpe')&&(getSettingAOui('GepiRubConseilCpe'))) { $sql="SELECT DISTINCT c.id,c.classe FROM j_eleves_cpe jecpe, j_eleves_classes jec, classes c WHERE jec.id_classe=c.id AND jec.login=jecpe.e_login AND jecpe.cpe_login='".$_SESSION['login']."' ORDER BY c.classe"; } elseif(($_SESSION['statut']=='cpe')&&(getSettingAOui('GepiRubConseilCpeTous'))) { $sql="select distinct id,classe from classes order by classe"; } else { // CA NE DEVRAIT PAS ARRIVER... //$sql="select distinct id,classe from classes order by classe"; echo "<p>Statut incorrect.</p>\n"; die(); require("../lib/footer.inc.php"); } $resultat_classes=mysqli_query($GLOBALS["mysqli"], $sql); if(mysqli_num_rows($resultat_classes)==0){ echo "<p>Aucune classe n'est encore définie...</p>\n</form>\n</body>\n</html>\n"; exit(); } /* $cpt=0; while($ligne_classe=mysql_fetch_object($resultat_classes)){ if($cpt==0){ $checked="checked "; } else{ $checked=""; } //echo "<input type='radio' name='id_classe' value='$ligne_classe->id' $checked/> $ligne_classe->classe<br />\n"; echo "<input type='radio' name='id_classe' id='id_classe".$ligne_classe->id."' value='$ligne_classe->id' $checked/><label for='id_classe".$ligne_classe->id."' style='cursor: pointer;'> $ligne_classe->classe</label><br />\n"; $cpt++; } */ $nb_classes=mysqli_num_rows($resultat_classes); $nb_class_par_colonne=round($nb_classes/3); echo "<table width='100%'>\n"; echo "<tr valign='top' align='center'>\n"; $cpt=0; //echo "<td style='padding: 0 10px 0 10px'>\n"; echo "<td align='left'>\n"; while($ligne_classe=mysqli_fetch_object($resultat_classes)){ if(($cpt>0)&&(round($cpt/$nb_class_par_colonne)==$cpt/$nb_class_par_colonne)){ echo "</td>\n"; //echo "<td style='padding: 0 10px 0 10px'>\n"; echo "<td align='left'>\n"; } if($cpt==0){ $checked="checked "; } else{ $checked=""; } //echo "<input type='radio' name='id_classe' value='$ligne_classe->id' /> $ligne_classe->classe<br />\n"; echo "<input type='radio' name='id_classe' id='id_classe".$ligne_classe->id."' value='$ligne_classe->id' $checked/><label for='id_classe".$ligne_classe->id."' style='cursor: pointer;'> $ligne_classe->classe</label><br />\n"; $cpt++; } echo "</td>\n"; echo "</tr>\n"; echo "</table>\n"; echo "</blockquote>\n"; echo "<center><input type='submit' name='ok' value='Valider' /></center>\n"; } else{ if(!isset($_POST['num_periode'])){ // ================== // Choix des périodes // ================== // Récupération des variables: $id_classe=$_POST['id_classe']; //echo "\$id_classe=$id_classe<br />\n"; echo "<h2>Saisie/Modification des commentaires-types pour la classe de ".get_classe_from_id($id_classe)."</h2>\n"; // Rappel des commentaires-type saisis pour cette classe sur toutes les périodes définies: $sql="select * from periodes where id_classe='$id_classe' order by num_periode"; //echo "$sql<br />"; $resultat_num_periode=mysqli_query($GLOBALS["mysqli"], $sql); if(mysqli_num_rows($resultat_num_periode)==0){ echo "Aucune période n'est encore définie pour cette classe...<br />\n"; echo "</body>\n</html>\n"; exit(); } else{ echo "<p>Voici les commentaires-type actuellement saisis pour cette classe:</p>\n"; echo "<ul>\n"; while($ligne_periode=mysqli_fetch_object($resultat_num_periode)){ //for($i=0;$i<count($num_periode);$i++){ echo "<li>\n"; //$sql="select nom_periode from periodes where num_periode='$ligne_periode->num_periode'"; //$resultat_periode=mysql_query($sql); //$ligne_nom_periode=mysql_fetch_object($resultat_periode); //echo "<p><b>$ligne_nom_periode->nom_periode</b>:</p>\n"; echo "<p><b>$ligne_periode->nom_periode</b>:</p>\n"; // AFFICHER LES COMMENTAIRES-TYPE POUR CHAQUE PERIODE $sql="select * from commentaires_types where id_classe='$id_classe' and num_periode='$ligne_periode->num_periode' order by commentaire"; $resultat_commentaires=mysqli_query($GLOBALS["mysqli"], $sql); if(mysqli_num_rows($resultat_commentaires)>0){ echo "<ul>\n"; while($ligne_commentaires=mysqli_fetch_object($resultat_commentaires)){ echo "<li>".stripslashes(nl2br(trim($ligne_commentaires->commentaire)))."</li>\n"; } echo "</ul>\n"; } else{ echo "<p style='color:red;'>Aucun commentaire-type n'est saisi pour cette classe sur cette période.</p>\n"; } echo "</li>\n"; } echo "</ul>\n"; } // Choix des périodes: echo "<p>Pour quelles périodes souhaitez-vous définir/modifier les commentaires-type?</p>\n"; //echo "<p>\n"; echo "<input type='hidden' name='id_classe' value='$id_classe' />\n"; // Récupération du nom de la classe $sql="select * from classes where id='$id_classe'"; $resultat_classe=mysqli_query($GLOBALS["mysqli"], $sql); if(mysqli_num_rows($resultat_classe)==0){ echo "<p>L'identifiant de la classe semble erroné.</p>\n</form>\n</body>\n</html>\n"; exit(); } $ligne_classe=mysqli_fetch_object($resultat_classe); $classe_courante="$ligne_classe->classe"; echo "<p><b>$classe_courante</b>: "; $sql="select * from periodes where id_classe='$id_classe' order by num_periode"; //echo "$sql<br />"; $resultat_num_periode=mysqli_query($GLOBALS["mysqli"], $sql); if(mysqli_num_rows($resultat_num_periode)==0){ echo "Aucune période n'est encore définie pour cette classe...<br />\n"; } else{ /* $ligne_num_periode=mysql_fetch_object($resultat_num_periode); $sql="select * from periodes where num_periode='$ligne_num_periode->num_periode'"; $resultat_periode=mysql_query($sql); $ligne_periode=mysql_fetch_object($resultat_periode); //echo "<input type='checkbox' name='num_periode[]' value='$ligne_periode->num_periode'> $ligne_periode->nom_periode\n"; echo "<input type='checkbox' name='num_periode[]' id='num_periode_".$ligne_periode->num_periode."' value='$ligne_periode->num_periode' /><label for='num_periode_".$ligne_periode->num_periode."' style='cursor: pointer;'> $ligne_periode->nom_periode</label>\n"; while($ligne_num_periode=mysql_fetch_object($resultat_num_periode)){ //$cpt++; $sql="select * from periodes where num_periode='$ligne_num_periode->num_periode'"; $resultat_periode=mysql_query($sql); $ligne_periode=mysql_fetch_object($resultat_periode); //echo " &nbsp;&nbsp;&nbsp;- <input type='checkbox' name='num_periode[]' value='$ligne_periode->num_periode'> $ligne_periode->nom_periode\n"; echo " &nbsp;&nbsp;&nbsp;- <input type='checkbox' name='num_periode[]' id='num_periode_".$ligne_periode->num_periode."' value='$ligne_periode->num_periode' /><label for='num_periode_".$ligne_periode->num_periode."' style='cursor: pointer;'> $ligne_periode->nom_periode</label>\n"; } */ $cpt_per=0; while($ligne_num_periode=mysqli_fetch_object($resultat_num_periode)){ if($cpt_per>0) {echo " &nbsp;&nbsp;&nbsp;- ";} echo "<input type='checkbox' name='num_periode[]' id='num_periode_".$ligne_num_periode->num_periode."' value='$ligne_num_periode->num_periode' /><label for='num_periode_".$ligne_num_periode->num_periode."' style='cursor: pointer;'> $ligne_num_periode->nom_periode</label>\n"; $cpt_per++; } echo "<br />\n"; } echo "</p>\n"; echo "<center><input type='submit' name='ok' value='Valider' /></center>\n"; } else { check_token(false); // ============================================================== // Saisie, modification, suppression, validation des commentaires // ============================================================== // Récupération des variables: $id_classe=$_POST['id_classe']; $num_periode=$_POST['num_periode']; $suppr=isset($_POST['suppr']) ? $_POST['suppr'] : ""; /* $nom_log = "app_eleve_".$k."_".$i; //echo "\$nom_log=$nom_log<br />"; if (isset($NON_PROTECT[$nom_log])){ $app = traitement_magic_quotes(corriger_caracteres($NON_PROTECT[$nom_log])); } else{ $app = ""; } */ $compteur_nb_commentaires=isset($_POST['compteur_nb_commentaires']) ? $_POST['compteur_nb_commentaires'] : NULL; //if(isset($_POST['commentaire_1'])){ if(isset($compteur_nb_commentaires)){ //if(isset($_POST['commentaire'])){ // Récupération des variables: //$commentaire=$_POST['commentaire']; //$commentaire=html_entity_decode($_POST['commentaire']); // Nettoyage des commentaires déjà saisis pour cette classe et ces périodes: $sql="delete from commentaires_types where id_classe='$id_classe' and (num_periode='$num_periode[0]'"; for($i=1;$i<count($num_periode);$i++){ $sql=$sql." or num_periode='$num_periode[$i]'"; } $sql=$sql.")"; //echo "sql=$sql<br />"; $resultat_nettoyage=mysqli_query($GLOBALS["mysqli"], $sql); // Validation des saisies/modifs... //for($i=1;$i<=count($commentaire);$i++){ for($i=1;$i<=$compteur_nb_commentaires;$i++){ //echo "\$suppr[$i]=$suppr[$i]<br />"; //if(($suppr[$i]=="")&&($commentaire[$i]!="")){ //if((!isset($suppr[$i]))&&($commentaire[$i]!="")){ if(!isset($suppr[$i])) { $nom_log = "commentaire_".$i; if (isset($NON_PROTECT[$nom_log])){ $commentaire_courant = traitement_magic_quotes(corriger_caracteres($NON_PROTECT[$nom_log])); if($commentaire_courant!=""){ for($j=0;$j<count($num_periode);$j++){ //$sql="insert into commentaires_types values('','$commentaire[$i]','$num_periode[$j]','$id_classe')"; //========================= // MODIF: boireaus 20071121 //$sql="insert into commentaires_types values('','".html_entity_decode($commentaire[$i])."','$num_periode[$j]','$id_classe')"; //$tmp_commentaire=my_ereg_replace("&#039;","'",html_entity_decode($commentaire[$i])); //$sql="insert into commentaires_types values('','".addslashes($tmp_commentaire)."','$num_periode[$j]','$id_classe')"; //$sql="insert into commentaires_types values('','".addslashes($commentaire_courant)."','$num_periode[$j]','$id_classe')"; $sql="insert into commentaires_types values('','".$commentaire_courant."','$num_periode[$j]','$id_classe')"; //========================= //echo "sql=$sql<br />"; $resultat_insertion_commentaire=mysqli_query($GLOBALS["mysqli"], $sql); } } } } } } echo "<input type='hidden' name='id_classe' value='$id_classe' />\n"; /* echo "$id_classe: "; for($i=0;$i<count($num_periode);$i++){ echo "$num_periode[$i] -"; } echo "<br />"; */ // Récupération du nom de la classe $sql="select * from classes where id='$id_classe'"; $resultat_classe=mysqli_query($GLOBALS["mysqli"], $sql); if(mysqli_num_rows($resultat_classe)==0){ echo "<p>L'identifiant de la classe semble erroné.</p>\n</form>\n</body>\n</html>\n"; exit(); } $ligne_classe=mysqli_fetch_object($resultat_classe); $classe_courante="$ligne_classe->classe"; //echo "<p><b>Classe de $classe_courante</b></p>\n"; echo "<h2>Classe de $classe_courante</h2>\n"; // Recherche des commentaires déjà saisis: //$sql="select * from commentaires_types where id_classe='$id_classe' and (num_periode='$num_periode[0]'"; //$sql="select distinct commentaire,id from commentaires_types where id_classe='$id_classe' and (num_periode='$num_periode[0]'"; $sql="select distinct commentaire,id from commentaires_types where id_classe='$id_classe' and (num_periode='$num_periode[0]'"; echo "<input type='hidden' name='num_periode[0]' value='$num_periode[0]' />\n"; for($i=1;$i<count($num_periode);$i++){ $sql=$sql." or num_periode='$num_periode[$i]'"; echo "<input type='hidden' name='num_periode[$i]' value='$num_periode[$i]' />\n"; } //$sql=$sql.")"; $sql=$sql.") order by commentaire"; //echo "$sql"; $resultat_commentaires=mysqli_query($GLOBALS["mysqli"], $sql); $cpt=1; if(mysqli_num_rows($resultat_commentaires)!=0){ echo "<p>Voici la liste des commentaires-type existants pour la classe et la/les période(s) choisie(s):</p>\n"; echo "<blockquote>\n"; echo "<table class='boireaus' border='1'>\n"; echo "<tr style='text-align:center;'>\n"; echo "<th>Commentaire</th>\n"; echo "<th>Supprimer</th>\n"; echo "</tr>\n"; $precedent_commentaire=""; //$cpt=1; $alt=1; while($ligne_commentaire=mysqli_fetch_object($resultat_commentaires)){ if("$ligne_commentaire->commentaire"!="$precedent_commentaire"){ $alt=$alt*(-1); echo "<tr class='lig$alt' style='text-align:center;'>\n"; echo "<td>"; //echo "<textarea name='commentaire[$cpt]' cols='60'>".stripslashes($ligne_commentaire->commentaire)."</textarea>"; echo "<textarea name='no_anti_inject_commentaire_".$cpt."' cols='60' onchange='changement()'>".stripslashes($ligne_commentaire->commentaire)."</textarea>"; echo "</td>\n"; echo "<td><input type='checkbox' name='suppr[$cpt]' value='$ligne_commentaire->id' /></td>\n"; echo "</tr>\n"; $cpt++; $precedent_commentaire="$ligne_commentaire->commentaire"; } } echo "</table>\n"; echo "</blockquote>\n"; } echo "<p>Saisie d'un nouveau commentaire:</p>"; echo "<blockquote>\n"; //echo "<textarea name='commentaire[$cpt]' cols='60'></textarea><br />\n"; echo "<textarea name='no_anti_inject_commentaire_".$cpt."' id='no_anti_inject_commentaire_".$cpt."' cols='60' onchange='changement()'></textarea><br />\n"; echo "<input type='hidden' name='compteur_nb_commentaires' value='$cpt' />\n"; echo "<center><input type='submit' name='ok' value='Valider' /></center>\n"; echo "</blockquote>\n"; echo "<script type='text/javascript'> document.getElementById('no_anti_inject_commentaire_".$cpt."').focus(); </script>\n"; } } } else{ //================================================================== // ============================================================== // ============================ // Recopie de commentaires-type // ============================ echo "<input type='hidden' name='recopie' value='oui' />\n"; if(!isset($_POST['id_classe'])){ // ========================= // Choix de la classe modèle // ========================= echo "<p>De quelle classe souhaitez-vous recopier les commentaires-type?</p>\n"; echo "<blockquote>\n"; $sql="select distinct id,classe from classes order by classe"; $resultat_classes=mysqli_query($GLOBALS["mysqli"], $sql); if(mysqli_num_rows($resultat_classes)==0){ echo "<p>Aucune classe n'est encore définie...</p>\n</form>\n</body>\n</html>\n"; exit(); } $nb_classes=mysqli_num_rows($resultat_classes); $nb_class_par_colonne=round($nb_classes/3); echo "<table width='100%'>\n"; echo "<tr valign='top' align='center'>\n"; $cpt=0; //echo "<td style='padding: 0 10px 0 10px'>\n"; echo "<td align='left'>\n"; while($ligne_classe=mysqli_fetch_object($resultat_classes)){ if(($cpt>0)&&(round($cpt/$nb_class_par_colonne)==$cpt/$nb_class_par_colonne)){ echo "</td>\n"; //echo "<td style='padding: 0 10px 0 10px'>\n"; echo "<td align='left'>\n"; } //echo "<input type='radio' name='id_classe' value='$ligne_classe->id' /> $ligne_classe->classe<br />\n"; echo "<input type='radio' name='id_classe' id='id_classe".$ligne_classe->id."' value='$ligne_classe->id' /><label for='id_classe".$ligne_classe->id."' style='cursor: pointer;'> $ligne_classe->classe</label><br />\n"; $cpt++; } echo "</td>\n"; echo "</tr>\n"; echo "</table>\n"; echo "</blockquote>\n"; echo "<center><input type='submit' name='ok' value='Valider' /></center>\n"; } else{ // ============================ // La classe-modèle est choisie // ============================ // Récupération des variables: $id_classe=$_POST['id_classe']; echo "<h2>Recopie de commentaires-types</h2>\n"; /* echo "<p>Voici les commentaires-type saisis pour cette classe:</p>\n"; echo "<ul>\n"; for($i=0;$i<count($num_periode);$i++){ echo "<li>\n"; $sql="select nom_periode from periodes where num_periode='$num_periode[$i]'"; $resultat_periode=mysql_query($sql); $ligne_nom_periode=mysql_fetch_object($resultat_periode); echo "<p><b>$ligne_nom_periode->nom_periode</b>:</p>\n"; echo "<input type='hidden' name='num_periode[$i]' value='$num_periode[$i]'>\n"; // AFFICHER LES COMMENTAIRES-TYPE POUR CHAQUE PERIODE $sql="select * from commentaires_types where id_classe='$id_classe' and num_periode='$num_periode[$i]' order by commentaire"; $resultat_commentaires=mysql_query($sql); echo "<ul>\n"; while($ligne_commentaires=mysql_fetch_object($resultat_commentaires)){ echo "<li>".stripslashes(nl2br(trim($ligne_commentaires->commentaire)))."</li>\n"; } echo "</ul>\n"; echo "</li>\n"; } echo "</ul>\n"; */ echo "<input type='hidden' name='id_classe' value='$id_classe' />\n"; // Récupération du nom de la classe $sql="select * from classes where id='$id_classe'"; $resultat_classe=mysqli_query($GLOBALS["mysqli"], $sql); if(mysqli_num_rows($resultat_classe)==0){ echo "<p>L'identifiant de la classe semble erroné.</p>\n</form>\n</body>\n</html>\n"; exit(); } $ligne_classe=mysqli_fetch_object($resultat_classe); $classe_source="$ligne_classe->classe"; echo "<p><b>Classe modèle:</b> $classe_source</p>\n"; if(!isset($_POST['num_periode'])){ // ============================= // Choix des périodes à recopier // ============================= // Rappel des commentaires-type saisis pour cette classe sur toutes les périodes définies: $sql="select * from periodes where id_classe='$id_classe' order by num_periode"; //echo "$sql<br />"; $resultat_num_periode=mysqli_query($GLOBALS["mysqli"], $sql); if(mysqli_num_rows($resultat_num_periode)==0){ echo "Aucune période n'est encore définie pour cette classe...<br />\n"; echo "</body>\n</html>\n"; exit(); } else{ $compteur_commentaires=0; echo "<p>Voici les commentaires-type saisis pour cette classe:</p>\n"; echo "<ul>\n"; while($ligne_periode=mysqli_fetch_object($resultat_num_periode)){ //for($i=0;$i<count($num_periode);$i++){ echo "<li>\n"; //$sql="select nom_periode from periodes where num_periode='$ligne_periode->num_periode'"; //$resultat_periode=mysql_query($sql); //$ligne_nom_periode=mysql_fetch_object($resultat_periode); //echo "<p><b>$ligne_nom_periode->nom_periode</b>:</p>\n"; echo "<p><b>$ligne_periode->nom_periode</b>:</p>\n"; // AFFICHER LES COMMENTAIRES-TYPE POUR CHAQUE PERIODE $sql="select * from commentaires_types where id_classe='$id_classe' and num_periode='$ligne_periode->num_periode' order by commentaire"; $resultat_commentaires=mysqli_query($GLOBALS["mysqli"], $sql); if(mysqli_num_rows($resultat_commentaires)>0){ echo "<ul>\n"; while($ligne_commentaires=mysqli_fetch_object($resultat_commentaires)){ echo "<li>".stripslashes(nl2br(trim($ligne_commentaires->commentaire)))."</li>\n"; $compteur_commentaires++; } echo "</ul>\n"; } else{ echo "<p style='color:red;'>Aucun commentaire-type n'est saisi pour cette classe sur cette période.</p>\n"; //echo "</body>\n</html>\n"; //exit(); } echo "</li>\n"; } echo "</ul>\n"; if($compteur_commentaires==0){ echo "</body>\n</html>\n"; exit(); } } // Choix des périodes: echo "<p>Pour quelles périodes souhaitez-vous recopier les commentaires-type?</p>\n"; //echo "<p>\n"; //echo "<input type='hidden' name='id_classe' value='$id_classe'>\n"; //echo "<p><b>$classe_source</b>: "; $sql="select * from periodes where id_classe='$id_classe' order by num_periode"; //echo "$sql<br />"; $resultat_num_periode=mysqli_query($GLOBALS["mysqli"], $sql); if(mysqli_num_rows($resultat_num_periode)==0){ echo "<p>Aucune période n'est encore définie pour cette classe...</p>\n"; } else{ /* $ligne_num_periode=mysql_fetch_object($resultat_num_periode); $sql="select * from periodes where num_periode='$ligne_num_periode->num_periode'"; $resultat_periode=mysql_query($sql); $ligne_periode=mysql_fetch_object($resultat_periode); //echo "<input type='checkbox' name='num_periode[]' value='$ligne_periode->num_periode'> $ligne_periode->nom_periode\n"; echo "<input type='checkbox' name='num_periode[]' id='num_periode_".$ligne_periode->num_periode."' value='$ligne_periode->num_periode' /><label for='num_periode_".$ligne_periode->num_periode."' style='cursor: pointer;'> $ligne_periode->nom_periode</label>\n"; while($ligne_num_periode=mysql_fetch_object($resultat_num_periode)){ //$cpt++; $sql="select * from periodes where num_periode='$ligne_num_periode->num_periode'"; $resultat_periode=mysql_query($sql); $ligne_periode=mysql_fetch_object($resultat_periode); //echo " &nbsp;&nbsp;&nbsp;- <input type='checkbox' name='num_periode[]' value='$ligne_periode->num_periode'> $ligne_periode->nom_periode\n"; echo " &nbsp;&nbsp;&nbsp;- <input type='checkbox' name='num_periode[]' id='num_periode_".$ligne_periode->num_periode."' value='$ligne_periode->num_periode' /><label for='num_periode_".$ligne_periode->num_periode."' style='cursor: pointer;'> $ligne_periode->nom_periode</label>\n"; } */ $cpt_per=0; while($ligne_num_periode=mysqli_fetch_object($resultat_num_periode)){ if($cpt_per>0) {echo " &nbsp;&nbsp;&nbsp;- ";} echo "<input type='checkbox' name='num_periode[]' id='num_periode_".$ligne_num_periode->num_periode."' value='$ligne_num_periode->num_periode' /><label for='num_periode_".$ligne_num_periode->num_periode."' style='cursor: pointer;'> $ligne_num_periode->nom_periode</label>\n"; $cpt_per++; } echo "<br />\n"; echo "<center><input type='submit' name='ok' value='Valider' /></center>\n"; } //echo "</p>\n"; //echo "<input type='submit' name='ok' value='Valider'>\n"; } else{ // ========================================================= // La classe-modèle et les périodes à recopier sont choisies // ========================================================= // Récupération des variables: $num_periode=$_POST['num_periode']; /* echo "<p>Voici les commentaires-type saisis pour cette classe:</p>\n"; echo "<ul>\n"; for($i=0;$i<count($num_periode);$i++){ echo "<li>\n"; $sql="select nom_periode from periodes where num_periode='$num_periode[$i]'"; $resultat_periode=mysql_query($sql); $ligne_nom_periode=mysql_fetch_object($resultat_periode); echo "<p><b>$ligne_nom_periode->nom_periode</b>:</p>\n"; echo "<input type='hidden' name='num_periode[$i]' value='$num_periode[$i]'>\n"; // AFFICHER LES COMMENTAIRES-TYPE POUR CHAQUE PERIODE $sql="select * from commentaires_types where id_classe='$id_classe' and num_periode='$num_periode[$i]' order by commentaire"; $resultat_commentaires=mysql_query($sql); echo "<ul>\n"; while($ligne_commentaires=mysql_fetch_object($resultat_commentaires)){ echo "<li>".stripslashes(nl2br(trim($ligne_commentaires->commentaire)))."</li>\n"; } echo "</ul>\n"; echo "</li>\n"; } echo "</ul>\n"; */ if(!isset($_POST['id_dest_classe'])){ // ========================================================== // Choix des classes vers lesquelles la recopie doit se faire // ========================================================== echo "<p>Voici les commentaires-type saisis pour cette classe et les périodes choisies:</p>\n"; echo "<ul>\n"; for($i=0;$i<count($num_periode);$i++){ echo "<li>\n"; $sql="select nom_periode from periodes where num_periode='$num_periode[$i]'"; $resultat_periode=mysqli_query($GLOBALS["mysqli"], $sql); $ligne_nom_periode=mysqli_fetch_object($resultat_periode); echo "<p><b>$ligne_nom_periode->nom_periode</b>:</p>\n"; echo "<input type='hidden' name='num_periode[$i]' value='$num_periode[$i]' />\n"; // AFFICHER LES COMMENTAIRES-TYPE POUR CHAQUE PERIODE $sql="select * from commentaires_types where id_classe='$id_classe' and num_periode='$num_periode[$i]' order by commentaire"; $resultat_commentaires=mysqli_query($GLOBALS["mysqli"], $sql); echo "<ul>\n"; while($ligne_commentaires=mysqli_fetch_object($resultat_commentaires)){ echo "<li>".stripslashes(nl2br(trim($ligne_commentaires->commentaire)))."</li>\n"; } echo "</ul>\n"; echo "</li>\n"; } echo "</ul>\n"; echo "<p>Pour quelles classes souhaitez-vous supprimer les commentaires-type existant et les remplacer par ceux de $classe_source?</p>\n"; // AJOUTER UN JavaScript POUR 'Tout cocher' //$sql="select distinct id,classe from classes order by classe"; if($_SESSION['statut']=='professeur'){ $sql="SELECT DISTINCT c.id,c.classe FROM j_eleves_classes jec, classes c, j_eleves_professeurs jep WHERE jec.id_classe=c.id AND jec.login=jep.login AND jep.professeur='".$_SESSION['login']."' ORDER BY c.classe"; } elseif($_SESSION['statut']=='scolarite'){ $sql="SELECT DISTINCT c.id,c.classe FROM j_scol_classes jsc, classes c WHERE jsc.id_classe=c.id AND jsc.login='".$_SESSION['login']."' ORDER BY c.classe"; } else{ // CA NE DEVRAIT PAS ARRIVER... $sql="select distinct id,classe from classes order by classe"; } $resultat_classes=mysqli_query($GLOBALS["mysqli"], $sql); if(mysqli_num_rows($resultat_classes)==0){ echo "<p>Aucune classe n'est encore définie...</p>\n</form>\n</body>\n</html>\n"; exit(); } $cpt=0; while($ligne_classe=mysqli_fetch_object($resultat_classes)){ if("$ligne_classe->id"!="$id_classe"){ echo "<label for='id_dest_classe$cpt' style='cursor: pointer;'><input type='checkbox' name='id_dest_classe[]' id='id_dest_classe$cpt' value='$ligne_classe->id' /> $ligne_classe->classe</label><br />\n"; $cpt++; } } //echo "</blockquote>\n"; echo "<!--script language='JavaScript'--> <script language='JavaScript' type='text/javascript'> function tout_cocher(){ for(i=0;i<$cpt;i++){ document.getElementById('id_dest_classe'+i).checked=true; } } function tout_decocher(){ for(i=0;i<$cpt;i++){ document.getElementById('id_dest_classe'+i).checked=false; } } </script> "; echo "<input type='button' name='toutcocher' value='Tout cocher' onClick='tout_cocher();' /> - \n"; echo "<input type='button' name='toutdecocher' value='Tout décocher' onClick='tout_decocher();' />\n"; echo "<center><input type='submit' name='ok' value='Valider' /></center>\n"; } else { check_token(false); // ======================= // Recopie proprement dite // ======================= $id_dest_classe=$_POST['id_dest_classe']; //echo count($num_periode)."<br />"; //flush(); // Nettoyage des commentaires déjà saisis pour ces classes et ces périodes: for($i=0;$i<count($id_dest_classe);$i++){ $sql="delete from commentaires_types where id_classe='$id_dest_classe[$i]' and (num_periode='$num_periode[0]'"; //for($i=0;$i<count($num_periode);$i++){ for($j=1;$j<count($num_periode);$j++){ $sql=$sql." or num_periode='$num_periode[$j]'"; } $sql=$sql.")"; //echo "sql=$sql<br />"; $resultat_nettoyage=mysqli_query($GLOBALS["mysqli"], $sql); } /* $sql="select commentaire from commentaires_types where id_classe='$id_classe' and (num_periode='$num_periode[0]'"; for($i=1;$i<count($num_periode);$i++){ $sql=$sql." or num_periode='$num_periode[$i]'"; } $sql=$sql.") order by commentaire"; echo "sql=$sql<br />"; $resultat_commentaires_source=mysql_query($sql); if(mysql_num_rows($resultat_commentaires_source)==0){ echo "<p>C'est malin... il n'existe pas de commentaires-type pour la/les classe(s) et la/les période(s) choisie(s).<br />\nDe plus, les commentaires existants ont été supprimés...</p>\n"; } else{ while($ligne_commentaires_source=mysql_fetch_object($resultat_commentaires_source)){ } } */ for($i=0;$i<count($num_periode);$i++){ // Nom de la période courante: $sql="select nom_periode from periodes where num_periode='$num_periode[$i]'"; $resultat_periode=mysqli_query($GLOBALS["mysqli"], $sql); $ligne_nom_periode=mysqli_fetch_object($resultat_periode); echo "<p><b>$ligne_nom_periode->nom_periode</b>:</p>\n"; echo "<blockquote>\n"; // Récupération des commentaires à insérer: $sql="select commentaire from commentaires_types where id_classe='$id_classe' and num_periode='$num_periode[$i]' order by commentaire"; //echo "sql=$sql<br />"; $resultat_commentaires_source=mysqli_query($GLOBALS["mysqli"], $sql); if(mysqli_num_rows($resultat_commentaires_source)==0){ echo "<p>C'est malin... il n'existe pas de commentaires-type pour la classe modèle et la période choisie.<br />\nDe plus, les commentaires existants pour les classes destination ont été supprimés...</p>\n"; } else{ while($ligne_commentaires_source=mysqli_fetch_object($resultat_commentaires_source)){ echo "<table>\n"; for($j=0;$j<count($id_dest_classe);$j++){ // Récupération du nom de la classe: $sql="select classe from classes where id='$id_dest_classe[$j]'"; $resultat_classe_dest=mysqli_query($GLOBALS["mysqli"], $sql); $ligne_classe_dest=mysqli_fetch_object($resultat_classe_dest); //echo "<b>Insertion pour $ligne_classe_dest->classe:</b><br /> ".stripslashes(nl2br(trim($ligne_commentaires_source->commentaire)))."<br />\n"; echo "<tr valign=\"top\"><td><b>Insertion pour $ligne_classe_dest->classe:</b></td><td> ".stripslashes(nl2br(trim($ligne_commentaires_source->commentaire)))."</td></tr>\n"; //$sql="insert into commentaires_types values('','$ligne_commentaires_source->commentaire','$num_periode[$i]','$id_dest_classe[$j]')"; $commentaire_courant=traitement_magic_quotes(corriger_caracteres($ligne_commentaires_source->commentaire)); $sql="insert into commentaires_types values('','$commentaire_courant','$num_periode[$i]','$id_dest_classe[$j]')"; //echo "sql=$sql<br />"; $resultat_insertion_commentaire=mysqli_query($GLOBALS["mysqli"], $sql); } echo "</table>\n"; } echo "<p>Insertions terminées pour la période.</p>\n"; } echo "</blockquote>\n"; } /* // Validation des saisies/modifs... for($i=1;$i<=count($commentaire);$i++){ echo "\$suppr[$i]=$suppr[$i]<br />"; if(($suppr[$i]=="")&&($commentaire[$i]!="")){ for($j=0;$j<count($num_periode);$j++){ $sql="insert into commentaires_types values('','$commentaire[$i]','$num_periode[$j]','$id_classe')"; echo "sql=$sql<br />"; $resultat_insertion_commentaire=mysql_query($sql); } } } */ } } } } ?> </form> <p><br /></p> <?php require("../lib/footer.inc.php"); ?>
prunkdump/gepi
saisie/commentaires_types.php
PHP
gpl-2.0
38,738
# Makefile.in generated by automake 1.13.3 from Makefile.am. # Makefile. Generated from Makefile.in by configure. # Copyright (C) 1994-2013 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY, to the extent permitted by law; without # even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. ##### ##### am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)' am__make_running_with_option = \ case $${target_option-} in \ ?) ;; \ *) echo "am__make_running_with_option: internal error: invalid" \ "target option '$${target_option-}' specified" >&2; \ exit 1;; \ esac; \ has_opt=no; \ sane_makeflags=$$MAKEFLAGS; \ if $(am__is_gnu_make); then \ sane_makeflags=$$MFLAGS; \ else \ case $$MAKEFLAGS in \ *\\[\ \ ]*) \ bs=\\; \ sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ esac; \ fi; \ skip_next=no; \ strip_trailopt () \ { \ flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ }; \ for flg in $$sane_makeflags; do \ test $$skip_next = yes && { skip_next=no; continue; }; \ case $$flg in \ *=*|--*) continue;; \ -*I) strip_trailopt 'I'; skip_next=yes;; \ -*I?*) strip_trailopt 'I';; \ -*O) strip_trailopt 'O'; skip_next=yes;; \ -*O?*) strip_trailopt 'O';; \ -*l) strip_trailopt 'l'; skip_next=yes;; \ -*l?*) strip_trailopt 'l';; \ -[dEDm]) skip_next=yes;; \ -[JT]) skip_next=yes;; \ esac; \ case $$flg in \ *$$target_option*) has_opt=yes; break;; \ esac; \ done; \ test $$has_opt = yes am__make_dryrun = (target_option=n; $(am__make_running_with_option)) am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) pkgincludedir = $(includedir)/libtool pkglibdir = $(libdir)/libtool pkglibexecdir = $(libexecdir)/libtool am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd install_sh_DATA = $(install_sh) -c -m 644 install_sh_PROGRAM = $(install_sh) -c install_sh_SCRIPT = $(install_sh) -c INSTALL_HEADER = $(INSTALL_DATA) transform = $(program_transform_name) NORMAL_INSTALL = : PRE_INSTALL = : POST_INSTALL = : NORMAL_UNINSTALL = : PRE_UNINSTALL = : POST_UNINSTALL = : build_triplet = i686-pc-linux-gnu host_triplet = i686-pc-linux-gnu DIST_COMMON = $(srcdir)/libltdl/Makefile.inc INSTALL NEWS README \ AUTHORS ChangeLog $(srcdir)/Makefile.in $(srcdir)/Makefile.am \ $(top_srcdir)/configure $(am__configure_deps) \ $(srcdir)/config-h.in $(top_srcdir)/libltdl/lt__dirent.c \ $(top_srcdir)/libltdl/argz.c $(top_srcdir)/libltdl/lt__strl.c \ $(top_srcdir)/libltdl/config/depcomp $(doc_libtool_TEXINFOS) \ $(top_srcdir)/libltdl/config/mdate-sh \ $(srcdir)/doc/version.texi $(srcdir)/doc/stamp-vti \ $(top_srcdir)/libltdl/config/texinfo.tex $(dist_man1_MANS) \ $(am__include_HEADERS_DIST) $(am__ltdlinclude_HEADERS_DIST) \ $(top_srcdir)/libltdl/config/test-driver COPYING THANKS TODO \ libltdl/config/compile libltdl/config/config.guess \ libltdl/config/config.sub libltdl/config/depcomp \ libltdl/config/install-sh libltdl/config/mdate-sh \ libltdl/config/missing libltdl/config/texinfo.tex \ libltdl/config/ltmain.sh $(top_srcdir)/libltdl/config/compile \ $(top_srcdir)/libltdl/config/config.guess \ $(top_srcdir)/libltdl/config/config.sub \ $(top_srcdir)/libltdl/config/install-sh \ $(top_srcdir)/libltdl/config/ltmain.sh \ $(top_srcdir)/libltdl/config/missing am__append_1 = libltdl/ltdl.h am__append_2 = libltdl/libltdl.la #am__append_3 = libltdl/libltdlc.la am__append_4 = $(CXX_TESTS) # f77demo-static-exec.test might be interactive on MSYS. am__append_5 = $(F77_TESTS) am__append_6 = $(FC_TESTS) subdir = . SUBDIRS = ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/libltdl/m4/argz.m4 \ $(top_srcdir)/libltdl/m4/autobuild.m4 \ $(top_srcdir)/libltdl/m4/libtool.m4 \ $(top_srcdir)/libltdl/m4/ltdl.m4 \ $(top_srcdir)/libltdl/m4/ltoptions.m4 \ $(top_srcdir)/libltdl/m4/ltsugar.m4 \ $(top_srcdir)/libltdl/m4/ltversion.m4 \ $(top_srcdir)/libltdl/m4/lt~obsolete.m4 \ $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) am__CONFIG_DISTCLEAN_FILES = config.status config.cache config.log \ configure.lineno config.status.lineno mkinstalldirs = $(install_sh) -d CONFIG_HEADER = config.h CONFIG_CLEAN_FILES = CONFIG_CLEAN_VPATH_FILES = am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; am__vpath_adj = case $$p in \ $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ *) f=$$p;; \ esac; am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`; am__install_max = 40 am__nobase_strip_setup = \ srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'` am__nobase_strip = \ for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||" am__nobase_list = $(am__nobase_strip_setup); \ for p in $$list; do echo "$$p $$p"; done | \ sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \ $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \ if (++n[$$2] == $(am__install_max)) \ { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \ END { for (dir in files) print dir, files[dir] }' am__base_list = \ sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \ sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g' am__uninstall_files_from_dir = { \ test -z "$$files" \ || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \ || { echo " ( cd '$$dir' && rm -f" $$files ")"; \ $(am__cd) "$$dir" && rm -f $$files; }; \ } am__installdirs = "$(DESTDIR)$(libdir)" "$(DESTDIR)$(bindir)" \ "$(DESTDIR)$(infodir)" "$(DESTDIR)$(man1dir)" \ "$(DESTDIR)$(includedir)" "$(DESTDIR)$(ltdlincludedir)" LTLIBRARIES = $(lib_LTLIBRARIES) $(noinst_LTLIBRARIES) libltdl_dld_link_la_DEPENDENCIES = am__dirstamp = $(am__leading_dot)dirstamp am_libltdl_dld_link_la_OBJECTS = libltdl/loaders/dld_link.lo libltdl_dld_link_la_OBJECTS = $(am_libltdl_dld_link_la_OBJECTS) AM_V_lt = $(am__v_lt_$(V)) am__v_lt_ = $(am__v_lt_$(AM_DEFAULT_VERBOSITY)) am__v_lt_0 = --silent am__v_lt_1 = libltdl_dld_link_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC \ $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CCLD) \ $(AM_CFLAGS) $(CFLAGS) $(libltdl_dld_link_la_LDFLAGS) \ $(LDFLAGS) -o $@ am__DEPENDENCIES_1 = libltdl_dlopen_la_DEPENDENCIES = $(am__DEPENDENCIES_1) am_libltdl_dlopen_la_OBJECTS = libltdl/loaders/dlopen.lo libltdl_dlopen_la_OBJECTS = $(am_libltdl_dlopen_la_OBJECTS) libltdl_dlopen_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC \ $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CCLD) \ $(AM_CFLAGS) $(CFLAGS) $(libltdl_dlopen_la_LDFLAGS) $(LDFLAGS) \ -o $@ libltdl_dyld_la_LIBADD = am_libltdl_dyld_la_OBJECTS = libltdl/loaders/dyld.lo libltdl_dyld_la_OBJECTS = $(am_libltdl_dyld_la_OBJECTS) libltdl_dyld_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC \ $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CCLD) \ $(AM_CFLAGS) $(CFLAGS) $(libltdl_dyld_la_LDFLAGS) $(LDFLAGS) \ -o $@ LIBOBJDIR = libltdl/ am_libltdl_libltdl_la_OBJECTS = \ libltdl/loaders/libltdl_libltdl_la-preopen.lo \ libltdl/libltdl_libltdl_la-lt__alloc.lo \ libltdl/libltdl_libltdl_la-lt_dlloader.lo \ libltdl/libltdl_libltdl_la-lt_error.lo \ libltdl/libltdl_libltdl_la-ltdl.lo \ libltdl/libltdl_libltdl_la-slist.lo libltdl_libltdl_la_OBJECTS = $(am_libltdl_libltdl_la_OBJECTS) libltdl_libltdl_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC \ $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CCLD) \ $(AM_CFLAGS) $(CFLAGS) $(libltdl_libltdl_la_LDFLAGS) \ $(LDFLAGS) -o $@ am_libltdl_libltdl_la_rpath = -rpath $(libdir) am__objects_1 = libltdl/loaders/libltdl_libltdlc_la-preopen.lo \ libltdl/libltdl_libltdlc_la-lt__alloc.lo \ libltdl/libltdl_libltdlc_la-lt_dlloader.lo \ libltdl/libltdl_libltdlc_la-lt_error.lo \ libltdl/libltdl_libltdlc_la-ltdl.lo \ libltdl/libltdl_libltdlc_la-slist.lo am_libltdl_libltdlc_la_OBJECTS = $(am__objects_1) libltdl_libltdlc_la_OBJECTS = $(am_libltdl_libltdlc_la_OBJECTS) libltdl_libltdlc_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC \ $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CCLD) \ $(AM_CFLAGS) $(CFLAGS) $(libltdl_libltdlc_la_LDFLAGS) \ $(LDFLAGS) -o $@ #am_libltdl_libltdlc_la_rpath = libltdl_load_add_on_la_LIBADD = am_libltdl_load_add_on_la_OBJECTS = libltdl/loaders/load_add_on.lo libltdl_load_add_on_la_OBJECTS = $(am_libltdl_load_add_on_la_OBJECTS) libltdl_load_add_on_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC \ $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CCLD) \ $(AM_CFLAGS) $(CFLAGS) $(libltdl_load_add_on_la_LDFLAGS) \ $(LDFLAGS) -o $@ libltdl_loadlibrary_la_LIBADD = am_libltdl_loadlibrary_la_OBJECTS = libltdl/loaders/loadlibrary.lo libltdl_loadlibrary_la_OBJECTS = $(am_libltdl_loadlibrary_la_OBJECTS) libltdl_loadlibrary_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC \ $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CCLD) \ $(AM_CFLAGS) $(CFLAGS) $(libltdl_loadlibrary_la_LDFLAGS) \ $(LDFLAGS) -o $@ libltdl_shl_load_la_DEPENDENCIES = $(am__DEPENDENCIES_1) am_libltdl_shl_load_la_OBJECTS = libltdl/loaders/shl_load.lo libltdl_shl_load_la_OBJECTS = $(am_libltdl_shl_load_la_OBJECTS) libltdl_shl_load_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC \ $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CCLD) \ $(AM_CFLAGS) $(CFLAGS) $(libltdl_shl_load_la_LDFLAGS) \ $(LDFLAGS) -o $@ SCRIPTS = $(bin_SCRIPTS) AM_V_P = $(am__v_P_$(V)) am__v_P_ = $(am__v_P_$(AM_DEFAULT_VERBOSITY)) am__v_P_0 = false am__v_P_1 = : AM_V_GEN = $(am__v_GEN_$(V)) am__v_GEN_ = $(am__v_GEN_$(AM_DEFAULT_VERBOSITY)) am__v_GEN_0 = @echo " GEN " $@; am__v_GEN_1 = AM_V_at = $(am__v_at_$(V)) am__v_at_ = $(am__v_at_$(AM_DEFAULT_VERBOSITY)) am__v_at_0 = @ am__v_at_1 = DEFAULT_INCLUDES = -I. depcomp = $(SHELL) $(top_srcdir)/libltdl/config/depcomp am__depfiles_maybe = depfiles am__mv = mv -f COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \ $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ $(AM_CFLAGS) $(CFLAGS) AM_V_CC = $(am__v_CC_$(V)) am__v_CC_ = $(am__v_CC_$(AM_DEFAULT_VERBOSITY)) am__v_CC_0 = @echo " CC " $@; am__v_CC_1 = CCLD = $(CC) LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ $(AM_LDFLAGS) $(LDFLAGS) -o $@ AM_V_CCLD = $(am__v_CCLD_$(V)) am__v_CCLD_ = $(am__v_CCLD_$(AM_DEFAULT_VERBOSITY)) am__v_CCLD_0 = @echo " CCLD " $@; am__v_CCLD_1 = SOURCES = $(libltdl_dld_link_la_SOURCES) $(libltdl_dlopen_la_SOURCES) \ $(libltdl_dyld_la_SOURCES) $(libltdl_libltdl_la_SOURCES) \ $(libltdl_libltdlc_la_SOURCES) \ $(libltdl_load_add_on_la_SOURCES) \ $(libltdl_loadlibrary_la_SOURCES) \ $(libltdl_shl_load_la_SOURCES) DIST_SOURCES = $(libltdl_dld_link_la_SOURCES) \ $(libltdl_dlopen_la_SOURCES) $(libltdl_dyld_la_SOURCES) \ $(libltdl_libltdl_la_SOURCES) $(libltdl_libltdlc_la_SOURCES) \ $(libltdl_load_add_on_la_SOURCES) \ $(libltdl_loadlibrary_la_SOURCES) \ $(libltdl_shl_load_la_SOURCES) AM_V_DVIPS = $(am__v_DVIPS_$(V)) am__v_DVIPS_ = $(am__v_DVIPS_$(AM_DEFAULT_VERBOSITY)) am__v_DVIPS_0 = @echo " DVIPS " $@; am__v_DVIPS_1 = AM_V_MAKEINFO = $(am__v_MAKEINFO_$(V)) am__v_MAKEINFO_ = $(am__v_MAKEINFO_$(AM_DEFAULT_VERBOSITY)) am__v_MAKEINFO_0 = @echo " MAKEINFO" $@; am__v_MAKEINFO_1 = AM_V_INFOHTML = $(am__v_INFOHTML_$(V)) am__v_INFOHTML_ = $(am__v_INFOHTML_$(AM_DEFAULT_VERBOSITY)) am__v_INFOHTML_0 = @echo " INFOHTML" $@; am__v_INFOHTML_1 = AM_V_TEXI2DVI = $(am__v_TEXI2DVI_$(V)) am__v_TEXI2DVI_ = $(am__v_TEXI2DVI_$(AM_DEFAULT_VERBOSITY)) am__v_TEXI2DVI_0 = @echo " TEXI2DVI" $@; am__v_TEXI2DVI_1 = AM_V_TEXI2PDF = $(am__v_TEXI2PDF_$(V)) am__v_TEXI2PDF_ = $(am__v_TEXI2PDF_$(AM_DEFAULT_VERBOSITY)) am__v_TEXI2PDF_0 = @echo " TEXI2PDF" $@; am__v_TEXI2PDF_1 = AM_V_texinfo = $(am__v_texinfo_$(V)) am__v_texinfo_ = $(am__v_texinfo_$(AM_DEFAULT_VERBOSITY)) am__v_texinfo_0 = -q am__v_texinfo_1 = AM_V_texidevnull = $(am__v_texidevnull_$(V)) am__v_texidevnull_ = $(am__v_texidevnull_$(AM_DEFAULT_VERBOSITY)) am__v_texidevnull_0 = > /dev/null am__v_texidevnull_1 = INFO_DEPS = $(srcdir)/doc/libtool.info TEXINFO_TEX = $(top_srcdir)/libltdl/config/texinfo.tex am__TEXINFO_TEX_DIR = $(top_srcdir)/libltdl/config DVIS = doc/libtool.dvi PDFS = doc/libtool.pdf PSS = doc/libtool.ps HTMLS = doc/libtool.html TEXINFOS = doc/libtool.texi TEXI2DVI = texi2dvi TEXI2PDF = $(TEXI2DVI) --pdf --batch MAKEINFOHTML = $(MAKEINFO) --html AM_MAKEINFOHTMLFLAGS = $(AM_MAKEINFOFLAGS) DVIPS = dvips RECURSIVE_TARGETS = all-recursive check-recursive cscopelist-recursive \ ctags-recursive dvi-recursive html-recursive info-recursive \ install-data-recursive install-dvi-recursive \ install-exec-recursive install-html-recursive \ install-info-recursive install-pdf-recursive \ install-ps-recursive install-recursive installcheck-recursive \ installdirs-recursive pdf-recursive ps-recursive \ tags-recursive uninstall-recursive am__can_run_installinfo = \ case $$AM_UPDATE_INFO_DIR in \ n|no|NO) false;; \ *) (install-info --version) >/dev/null 2>&1;; \ esac man1dir = $(mandir)/man1 NROFF = nroff MANS = $(dist_man1_MANS) am__include_HEADERS_DIST = libltdl/ltdl.h am__ltdlinclude_HEADERS_DIST = libltdl/libltdl/lt_system.h \ libltdl/libltdl/lt_error.h libltdl/libltdl/lt_dlloader.h HEADERS = $(include_HEADERS) $(ltdlinclude_HEADERS) RECURSIVE_CLEAN_TARGETS = mostlyclean-recursive clean-recursive \ distclean-recursive maintainer-clean-recursive am__recursive_targets = \ $(RECURSIVE_TARGETS) \ $(RECURSIVE_CLEAN_TARGETS) \ $(am__extra_recursive_targets) AM_RECURSIVE_TARGETS = $(am__recursive_targets:-recursive=) TAGS CTAGS \ cscope check recheck distdir dist dist-all distcheck am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) \ $(LISP)config-h.in # Read a list of newline-separated strings from the standard input, # and print each of them once, without duplicates. Input order is # *not* preserved. am__uniquify_input = $(AWK) '\ BEGIN { nonempty = 0; } \ { items[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in items) print i; }; } \ ' # Make sure the list of sources is unique. This is necessary because, # e.g., the same source file might be shared among _SOURCES variables # for different programs/libraries. am__define_uniq_tagged_files = \ list='$(am__tagged_files)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | $(am__uniquify_input)` ETAGS = etags CTAGS = ctags CSCOPE = cscope am__tty_colors_dummy = \ mgn= red= grn= lgn= blu= brg= std=; \ am__color_tests=no am__tty_colors = { \ $(am__tty_colors_dummy); \ if test "X$(AM_COLOR_TESTS)" = Xno; then \ am__color_tests=no; \ elif test "X$(AM_COLOR_TESTS)" = Xalways; then \ am__color_tests=yes; \ elif test "X$$TERM" != Xdumb && { test -t 1; } 2>/dev/null; then \ am__color_tests=yes; \ fi; \ if test $$am__color_tests = yes; then \ red=''; \ grn=''; \ lgn=''; \ blu=''; \ mgn=''; \ brg=''; \ std=''; \ fi; \ } am__recheck_rx = ^[ ]*:recheck:[ ]* am__global_test_result_rx = ^[ ]*:global-test-result:[ ]* am__copy_in_global_log_rx = ^[ ]*:copy-in-global-log:[ ]* # A command that, given a newline-separated list of test names on the # standard input, print the name of the tests that are to be re-run # upon "make recheck". am__list_recheck_tests = $(AWK) '{ \ recheck = 1; \ while ((rc = (getline line < ($$0 ".trs"))) != 0) \ { \ if (rc < 0) \ { \ if ((getline line2 < ($$0 ".log")) < 0) \ recheck = 0; \ break; \ } \ else if (line ~ /$(am__recheck_rx)[nN][Oo]/) \ { \ recheck = 0; \ break; \ } \ else if (line ~ /$(am__recheck_rx)[yY][eE][sS]/) \ { \ break; \ } \ }; \ if (recheck) \ print $$0; \ close ($$0 ".trs"); \ close ($$0 ".log"); \ }' # A command that, given a newline-separated list of test names on the # standard input, create the global log from their .trs and .log files. am__create_global_log = $(AWK) ' \ function fatal(msg) \ { \ print "fatal: making $@: " msg | "cat >&2"; \ exit 1; \ } \ function rst_section(header) \ { \ print header; \ len = length(header); \ for (i = 1; i <= len; i = i + 1) \ printf "="; \ printf "\n\n"; \ } \ { \ copy_in_global_log = 1; \ global_test_result = "RUN"; \ while ((rc = (getline line < ($$0 ".trs"))) != 0) \ { \ if (rc < 0) \ fatal("failed to read from " $$0 ".trs"); \ if (line ~ /$(am__global_test_result_rx)/) \ { \ sub("$(am__global_test_result_rx)", "", line); \ sub("[ ]*$$", "", line); \ global_test_result = line; \ } \ else if (line ~ /$(am__copy_in_global_log_rx)[nN][oO]/) \ copy_in_global_log = 0; \ }; \ if (copy_in_global_log) \ { \ rst_section(global_test_result ": " $$0); \ while ((rc = (getline line < ($$0 ".log"))) != 0) \ { \ if (rc < 0) \ fatal("failed to read from " $$0 ".log"); \ print line; \ }; \ printf "\n"; \ }; \ close ($$0 ".trs"); \ close ($$0 ".log"); \ }' # Restructured Text title. am__rst_title = { sed 's/.*/ & /;h;s/./=/g;p;x;s/ *$$//;p;g' && echo; } # Solaris 10 'make', and several other traditional 'make' implementations, # pass "-e" to $(SHELL), and POSIX 2008 even requires this. Work around it # by disabling -e (using the XSI extension "set +e") if it's set. am__sh_e_setup = case $$- in *e*) set +e;; esac # Default flags passed to test drivers. am__common_driver_flags = \ --color-tests "$$am__color_tests" \ --enable-hard-errors "$$am__enable_hard_errors" \ --expect-failure "$$am__expect_failure" # To be inserted before the command running the test. Creates the # directory for the log if needed. Stores in $dir the directory # containing $f, in $tst the test, in $log the log. Executes the # developer- defined test setup AM_TESTS_ENVIRONMENT (if any), and # passes TESTS_ENVIRONMENT. Set up options for the wrapper that # will run the test scripts (or their associated LOG_COMPILER, if # thy have one). am__check_pre = \ $(am__sh_e_setup); \ $(am__vpath_adj_setup) $(am__vpath_adj) \ $(am__tty_colors); \ srcdir=$(srcdir); export srcdir; \ case "$@" in \ */*) am__odir=`echo "./$@" | sed 's|/[^/]*$$||'`;; \ *) am__odir=.;; \ esac; \ test "x$$am__odir" = x"." || test -d "$$am__odir" \ || $(MKDIR_P) "$$am__odir" || exit $$?; \ if test -f "./$$f"; then dir=./; \ elif test -f "$$f"; then dir=; \ else dir="$(srcdir)/"; fi; \ tst=$$dir$$f; log='$@'; \ if test -n '$(DISABLE_HARD_ERRORS)'; then \ am__enable_hard_errors=no; \ else \ am__enable_hard_errors=yes; \ fi; \ case " $(XFAIL_TESTS) " in \ *[\ \ ]$$f[\ \ ]* | *[\ \ ]$$dir$$f[\ \ ]*) \ am__expect_failure=yes;; \ *) \ am__expect_failure=no;; \ esac; \ $(AM_TESTS_ENVIRONMENT) $(TESTS_ENVIRONMENT) # A shell command to get the names of the tests scripts with any registered # extension removed (i.e., equivalently, the names of the test logs, with # the '.log' extension removed). The result is saved in the shell variable # '$bases'. This honors runtime overriding of TESTS and TEST_LOGS. Sadly, # we cannot use something simpler, involving e.g., "$(TEST_LOGS:.log=)", # since that might cause problem with VPATH rewrites for suffix-less tests. # See also 'test-harness-vpath-rewrite.sh' and 'test-trs-basic.sh'. am__set_TESTS_bases = \ bases='$(TEST_LOGS)'; \ bases=`for i in $$bases; do echo $$i; done | sed 's/\.log$$//'`; \ bases=`echo $$bases` RECHECK_LOGS = $(TEST_LOGS) TEST_SUITE_LOG = test-suite.log TEST_EXTENSIONS = .test am__test_logs1 = $(TESTS:=.log) am__test_logs2 = $(am__test_logs1:.log=.log) TEST_LOGS = $(am__test_logs2:.test.log=.log) TEST_LOG_DRIVER = $(SHELL) $(top_srcdir)/libltdl/config/test-driver TEST_LOG_COMPILE = $(TEST_LOG_COMPILER) $(AM_TEST_LOG_FLAGS) \ $(TEST_LOG_FLAGS) am__set_b = \ case '$@' in \ */*) \ case '$*' in \ */*) b='$*';; \ *) b=`echo '$@' | sed 's/\.log$$//'`; \ esac;; \ *) \ b='$*';; \ esac DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) distdir = $(PACKAGE)-$(VERSION) top_distdir = $(distdir) am__remove_distdir = \ if test -d "$(distdir)"; then \ find "$(distdir)" -type d ! -perm -200 -exec chmod u+w {} ';' \ && rm -rf "$(distdir)" \ || { sleep 5 && rm -rf "$(distdir)"; }; \ else :; fi am__post_remove_distdir = $(am__remove_distdir) am__relativize = \ dir0=`pwd`; \ sed_first='s,^\([^/]*\)/.*$$,\1,'; \ sed_rest='s,^[^/]*/*,,'; \ sed_last='s,^.*/\([^/]*\)$$,\1,'; \ sed_butlast='s,/*[^/]*$$,,'; \ while test -n "$$dir1"; do \ first=`echo "$$dir1" | sed -e "$$sed_first"`; \ if test "$$first" != "."; then \ if test "$$first" = ".."; then \ dir2=`echo "$$dir0" | sed -e "$$sed_last"`/"$$dir2"; \ dir0=`echo "$$dir0" | sed -e "$$sed_butlast"`; \ else \ first2=`echo "$$dir2" | sed -e "$$sed_first"`; \ if test "$$first2" = "$$first"; then \ dir2=`echo "$$dir2" | sed -e "$$sed_rest"`; \ else \ dir2="../$$dir2"; \ fi; \ dir0="$$dir0"/"$$first"; \ fi; \ fi; \ dir1=`echo "$$dir1" | sed -e "$$sed_rest"`; \ done; \ reldir="$$dir2" DIST_ARCHIVES = $(distdir).tar.gz $(distdir).tar.xz GZIP_ENV = --best DIST_TARGETS = dist-xz dist-gzip distuninstallcheck_listfiles = find . -type f -print am__distuninstallcheck_listfiles = $(distuninstallcheck_listfiles) \ | sed 's|^\./|$(prefix)/|' | grep -v '$(infodir)/dir$$' distcleancheck_listfiles = find . -type f -print pkgdatadir = ${datadir}/libtool ACLOCAL = ${SHELL} /usr/src/libtool/libtool/libltdl/config/missing aclocal-1.13 AMTAR = $${TAR-tar} AM_DEFAULT_VERBOSITY = 1 AR = ar ARGZ_H = AS = as AUTOCONF = ${SHELL} /usr/src/libtool/libtool/libltdl/config/missing autoconf AUTOHEADER = ${SHELL} /usr/src/libtool/libtool/libltdl/config/missing autoheader AUTOM4TE = autom4te AUTOMAKE = ${SHELL} /usr/src/libtool/libtool/libltdl/config/missing automake-1.13 AUTOTEST = $(AUTOM4TE) --language=autotest AWK = gawk CC = gcc CCDEPMODE = depmode=gcc3 CFLAGS = -g -O2 CONFIG_STATUS_DEPENDENCIES = $(top_srcdir)/ChangeLog CONF_SUBDIRS = tests/cdemo tests/demo tests/depdemo tests/f77demo tests/fcdemo tests/mdemo tests/mdemo2 tests/pdemo tests/tagdemo CPP = gcc -E CPPFLAGS = CXX = g++ CXXCPP = g++ -E CXXDEPMODE = depmode=gcc3 CXXFLAGS = -g -O2 CYGPATH_W = echo DEFS = -DHAVE_CONFIG_H DEPDIR = .deps DIST_MAKEFILE_LIST = tests/cdemo/Makefile tests/demo/Makefile tests/depdemo/Makefile tests/f77demo/Makefile tests/fcdemo/Makefile tests/mdemo/Makefile tests/mdemo2/Makefile tests/pdemo/Makefile tests/tagdemo/Makefile DLLTOOL = false DSYMUTIL = DUMPBIN = ECHO_C = ECHO_N = -n ECHO_T = EGREP = /usr/bin/grep -E EXEEXT = F77 = gfortran FC = gfortran FCFLAGS = -g -O2 FFLAGS = -g -O2 FGREP = /usr/bin/grep -F GCJ = gcj GCJFLAGS = -g -O2 GOC = gccgo GREP = /usr/bin/grep HELP2MAN = ${SHELL} /usr/src/libtool/libtool/libltdl/config/missing help2man INSTALL = /usr/bin/ginstall -c INSTALL_DATA = ${INSTALL} -m 644 INSTALL_PROGRAM = ${INSTALL} INSTALL_SCRIPT = ${INSTALL} INSTALL_STRIP_PROGRAM = $(install_sh) -c -s LASTRELEASE = 2.4.1 LD = /usr/i686-linux-gnu/bin/ld LDFLAGS = LIBADD_DL = -ldl LIBADD_DLD_LINK = LIBADD_DLOPEN = -ldl LIBADD_SHL_LOAD = LIBOBJS = ${LIBOBJDIR}lt__strl$U.o LIBS = -ldl LIBTOOL = $(SHELL) $(top_builddir)/libtool LIPO = LN_S = ln -s LTDLOPEN = libltdl LTLIBOBJS = ${LIBOBJDIR}lt__strl$U.lo LT_CONFIG_H = config.h LT_DLLOADERS = libltdl/dlopen.la LT_DLPREOPEN = -dlpreopen libltdl/dlopen.la M4SH = $(AUTOM4TE) --language=m4sh MAKEINFO = ${SHELL} /usr/src/libtool/libtool/libltdl/config/missing makeinfo MANIFEST_TOOL = : MKDIR_P = /usr/bin/mkdir -p NM = /usr/bin/nm -B NMEDIT = OBJDUMP = objdump OBJEXT = o ORDER = | OTOOL = OTOOL64 = PACKAGE = libtool PACKAGE_BUGREPORT = [email protected] PACKAGE_NAME = GNU Libtool PACKAGE_STRING = GNU Libtool 2.4.2 PACKAGE_TARNAME = libtool PACKAGE_URL = http://www.gnu.org/software/libtool/ PACKAGE_VERSION = 2.4.2 PATH_SEPARATOR = : RANLIB = ranlib RC = SED = /usr/bin/sed SET_MAKE = SHELL = /bin/sh STRIP = strip TIMESTAMP = VERSION = 2.4.2 abs_builddir = /usr/src/libtool/libtool abs_srcdir = /usr/src/libtool/libtool abs_top_builddir = /usr/src/libtool/libtool abs_top_srcdir = /usr/src/libtool/libtool ac_ct_AR = ar ac_ct_CC = gcc ac_ct_CXX = g++ ac_ct_DUMPBIN = ac_ct_F77 = gfortran ac_ct_FC = gfortran aclocaldir = ${datadir}/aclocal am__include = include am__leading_dot = . am__quote = am__tar = $${TAR-tar} chof - "$$tardir" am__untar = $${TAR-tar} xf - bindir = ${exec_prefix}/bin build = i686-pc-linux-gnu build_alias = build_cpu = i686 build_os = linux-gnu build_vendor = pc builddir = . datadir = ${datarootdir} datarootdir = ${prefix}/share docdir = ${datarootdir}/doc/${PACKAGE_TARNAME} dvidir = ${docdir} exec_prefix = ${prefix} host = i686-pc-linux-gnu host_alias = host_cpu = i686 host_os = linux-gnu host_vendor = pc htmldir = ${docdir} includedir = ${prefix}/include infodir = ${datarootdir}/info install_sh = ${SHELL} /usr/src/libtool/libtool/libltdl/config/install-sh libdir = ${exec_prefix}/lib libexecdir = ${exec_prefix}/libexec localedir = ${datarootdir}/locale localstatedir = ${prefix}/var mandir = ${datarootdir}/man mkdir_p = $(MKDIR_P) oldincludedir = /usr/include package_revision = 1.3337 pdfdir = ${docdir} prefix = /usr/local program_transform_name = s,x,x, psdir = ${docdir} sbindir = ${exec_prefix}/sbin sharedstatedir = ${prefix}/com srcdir = . sys_symbol_underscore = no sysconfdir = ${prefix}/etc target_alias = to_host_file_cmd = func_convert_file_noop to_tool_file_cmd = func_convert_file_noop top_build_prefix = top_builddir = . top_srcdir = . ACLOCAL_AMFLAGS = -I libltdl/m4 # -I$(srcdir) is needed for user that built libltdl with a sub-Automake # (not as a sub-package!) using 'nostdinc': AM_CPPFLAGS = -DLT_CONFIG_H='<$(LT_CONFIG_H)>' -DLTDL -I. -I$(srcdir) \ -Ilibltdl -I$(srcdir)/libltdl -I$(srcdir)/libltdl/libltdl AM_LDFLAGS = -no-undefined DIST_SUBDIRS = . $(CONF_SUBDIRS) # Use `$(srcdir)' for the benefit of non-GNU makes: this is # how libtoolize.in appears in our dependencies. EXTRA_DIST = bootstrap $(srcdir)/libtoolize.in $(auxdir)/ltmain.m4sh \ $(auxdir)/mkstamp $(sh_files) ChangeLog.1996 ChangeLog.1997 \ ChangeLog.1998 ChangeLog.1999 ChangeLog.2000 ChangeLog.2001 \ ChangeLog.2002 ChangeLog.2003 ChangeLog.2004 ChangeLog.2005 \ ChangeLog.2006 ChangeLog.2007 ChangeLog.2008 ChangeLog.2009 \ ChangeLog.2010 $(m4dir)/ltversion.in \ $(srcdir)/$(m4dir)/ltversion.m4 $(srcdir)/$(auxdir)/ltmain.sh \ libtoolize.m4sh libltdl/lt__dirent.c libltdl/lt__strl.c \ libltdl/COPYING.LIB libltdl/configure.ac libltdl/Makefile.am \ libltdl/aclocal.m4 libltdl/Makefile.in libltdl/configure \ libltdl/config-h.in libltdl/README libltdl/argz_.h \ libltdl/argz.c $(srcdir)/libltdl/stamp-mk \ $(m4dir)/lt~obsolete.m4 $(srcdir)/doc/notes.txt \ $(edit_readme_alpha) $(srcdir)/$(TESTSUITE) $(TESTSUITE_AT) \ $(srcdir)/tests/package.m4 $(srcdir)/tests/defs.in \ tests/defs.m4sh $(COMMON_TESTS) $(CXX_TESTS) $(F77_TESTS) \ $(FC_TESTS) $(INTERACTIVE_TESTS) BUILT_SOURCES = libtool libtoolize libltdl/$(ARGZ_H) CLEANFILES = libtool libtoolize libtoolize.tmp $(auxdir)/ltmain.tmp \ $(m4dir)/ltversion.tmp libltdl/libltdl.la libltdl/libltdlc.la \ libltdl/libdlloader.la $(LIBOBJS) $(LTLIBOBJS) MOSTLYCLEANFILES = libltdl/argz.h libltdl/argz.h-t DISTCLEANFILES = libtool.dvi tests/atconfig tests/defs MAINTAINERCLEANFILES = $(dist_man1_MANS) include_HEADERS = $(am__append_1) noinst_LTLIBRARIES = $(LT_DLLOADERS) $(am__append_3) lib_LTLIBRARIES = $(am__append_2) EXTRA_LTLIBRARIES = libltdl/dlopen.la libltdl/dld_link.la \ libltdl/dyld.la libltdl/load_add_on.la libltdl/loadlibrary.la \ libltdl/shl_load.la auxdir = libltdl/config m4dir = libltdl/m4 # Using `cd' in backquotes may print the directory name, use this instead: lt__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd MKSTAMP = $(SHELL) $(srcdir)/$(auxdir)/mkstamp timestamp = set dummy `$(MKSTAMP) $(srcdir)`; shift; \ case $(VERSION) in \ *[acegikmoqsuwy]) TIMESTAMP=" $$1 $$2" ;; \ *) TIMESTAMP="" ;; \ esac rebuild = rebuild=:; $(timestamp); correctver=$$1 # ---------- # # Bootstrap. # # ---------- # sh_files = $(auxdir)/general.m4sh $(auxdir)/getopt.m4sh bootstrap_edit = sed \ -e 's,@MACRO_VERSION\@,$(VERSION),g' \ -e "s,@MACRO_REVISION\@,$$correctver,g" \ -e "s,@MACRO_SERIAL\@,$$serial,g" \ -e 's,@PACKAGE\@,$(PACKAGE),g' \ -e 's,@PACKAGE_BUGREPORT\@,$(PACKAGE_BUGREPORT),g' \ -e 's,@PACKAGE_URL\@,$(PACKAGE_URL),g' \ -e 's,@PACKAGE_NAME\@,$(PACKAGE_NAME),g' \ -e "s,@package_revision\@,$$correctver,g" \ -e 's,@PACKAGE_STRING\@,$(PACKAGE_NAME) $(VERSION),g' \ -e 's,@PACKAGE_TARNAME\@,$(PACKAGE),g' \ -e 's,@PACKAGE_VERSION\@,$(VERSION),g' \ -e "s,@TIMESTAMP\@,$$TIMESTAMP,g" \ -e 's,@VERSION\@,$(VERSION),g' LTDL_BOOTSTRAP_DEPS = $(srcdir)/libltdl/aclocal.m4 \ $(srcdir)/libltdl/stamp-mk \ $(srcdir)/libltdl/configure \ $(srcdir)/libltdl/config-h.in configure_edit = sed \ -e 's,@aclocal_DATA\@,$(aclocalfiles),g' \ -e 's,@aclocaldir\@,$(aclocaldir),g' \ -e 's,@datadir\@,$(datadir),g' \ -e 's,@EGREP\@,$(EGREP),g' \ -e 's,@FGREP\@,$(FGREP),g' \ -e 's,@GREP\@,$(GREP),g' \ -e 's,@host_triplet\@,$(host_triplet),g' \ -e 's,@LN_S\@,$(LN_S),g' \ -e "s,@pkgconfig_files\@,$(auxfiles),g" \ -e 's,@pkgdatadir\@,$(pkgdatadir),g' \ -e "s,@pkgltdl_files\@,$(ltdldatafiles),g" \ -e 's,@prefix\@,$(prefix),g' \ -e 's,@SED\@,$(SED),g' # The libtool distributor and the standalone libtool script. bin_SCRIPTS = libtoolize libtool LTDL_VERSION_INFO = -version-info 10:0:3 ltdlincludedir = $(includedir)/libltdl ltdlinclude_HEADERS = libltdl/libltdl/lt_system.h \ libltdl/libltdl/lt_error.h \ libltdl/libltdl/lt_dlloader.h libltdl_libltdl_la_SOURCES = libltdl/libltdl/lt__alloc.h \ libltdl/libltdl/lt__dirent.h \ libltdl/libltdl/lt__glibc.h \ libltdl/libltdl/lt__private.h \ libltdl/libltdl/lt__strl.h \ libltdl/libltdl/lt_dlloader.h \ libltdl/libltdl/lt_error.h \ libltdl/libltdl/lt_system.h \ libltdl/libltdl/slist.h \ libltdl/loaders/preopen.c \ libltdl/lt__alloc.c \ libltdl/lt_dlloader.c \ libltdl/lt_error.c \ libltdl/ltdl.c \ libltdl/ltdl.h \ libltdl/slist.c libltdl_libltdl_la_CPPFLAGS = -DLTDLOPEN=$(LTDLOPEN) $(AM_CPPFLAGS) libltdl_libltdl_la_LDFLAGS = $(AM_LDFLAGS) $(LTDL_VERSION_INFO) $(LT_DLPREOPEN) libltdl_libltdl_la_LIBADD = $(LTLIBOBJS) libltdl_libltdl_la_DEPENDENCIES = $(LT_DLLOADERS) $(LTLIBOBJS) libltdl_libltdlc_la_SOURCES = $(libltdl_libltdl_la_SOURCES) libltdl_libltdlc_la_CPPFLAGS = -DLTDLOPEN=$(LTDLOPEN)c $(AM_CPPFLAGS) libltdl_libltdlc_la_LDFLAGS = $(AM_LDFLAGS) $(LT_DLPREOPEN) libltdl_libltdlc_la_LIBADD = $(libltdl_libltdl_la_LIBADD) libltdl_libltdlc_la_DEPENDENCIES = $(libltdl_libltdl_la_DEPENDENCIES) libltdl_dlopen_la_SOURCES = libltdl/loaders/dlopen.c libltdl_dlopen_la_LDFLAGS = -module -avoid-version libltdl_dlopen_la_LIBADD = $(LIBADD_DLOPEN) libltdl_dld_link_la_SOURCES = libltdl/loaders/dld_link.c libltdl_dld_link_la_LDFLAGS = -module -avoid-version libltdl_dld_link_la_LIBADD = -ldld libltdl_dyld_la_SOURCES = libltdl/loaders/dyld.c libltdl_dyld_la_LDFLAGS = -module -avoid-version libltdl_load_add_on_la_SOURCES = libltdl/loaders/load_add_on.c libltdl_load_add_on_la_LDFLAGS = -module -avoid-version libltdl_loadlibrary_la_SOURCES = libltdl/loaders/loadlibrary.c libltdl_loadlibrary_la_LDFLAGS = -module -avoid-version libltdl_shl_load_la_SOURCES = libltdl/loaders/shl_load.c libltdl_shl_load_la_LDFLAGS = -module -avoid-version libltdl_shl_load_la_LIBADD = $(LIBADD_SHL_LOAD) sub_aclocal_m4_deps = \ $(srcdir)/libltdl/configure.ac \ $(m4dir)/libtool.m4 \ $(m4dir)/ltoptions.m4 \ $(m4dir)/ltdl.m4 \ $(srcdir)/$(m4dir)/ltversion.m4 \ $(m4dir)/ltsugar.m4 \ $(m4dir)/argz.m4 \ $(m4dir)/lt~obsolete.m4 sub_configure_deps = $(sub_aclocal_m4_deps) $(srcdir)/libltdl/aclocal.m4 info_TEXINFOS = doc/libtool.texi doc_libtool_TEXINFOS = doc/PLATFORMS doc/fdl.texi doc/notes.texi dist_man1_MANS = $(srcdir)/doc/libtool.1 $(srcdir)/doc/libtoolize.1 update_mans = \ PATH=".$(PATH_SEPARATOR)$$PATH"; export PATH; \ $(HELP2MAN) --output=$@ # These are required by libtoolize and must be executable when installed. # The timestamps on these files must be preserved carefully so we install, # uninstall and set executable with custom rules here. auxexefiles = config/compile config/config.guess config/config.sub \ config/depcomp config/install-sh config/missing auxfiles = $(auxexefiles) config/ltmain.sh # Everything that gets picked up by aclocal is automatically distributed, # this is the list of macro files we install on the user's system. aclocalfiles = m4/argz.m4 m4/libtool.m4 m4/ltdl.m4 m4/ltoptions.m4 \ m4/ltsugar.m4 m4/ltversion.m4 m4/lt~obsolete.m4 ltdldatafiles = libltdl/COPYING.LIB \ libltdl/README \ libltdl/Makefile.inc \ libltdl/Makefile.am \ libltdl/configure.ac \ libltdl/aclocal.m4 \ libltdl/Makefile.in \ libltdl/config-h.in \ libltdl/configure \ libltdl/argz_.h \ libltdl/argz.c \ libltdl/loaders/dld_link.c \ libltdl/loaders/dlopen.c \ libltdl/loaders/dyld.c \ libltdl/loaders/load_add_on.c \ libltdl/loaders/loadlibrary.c \ libltdl/loaders/shl_load.c \ libltdl/lt__dirent.c \ libltdl/lt__strl.c \ $(libltdl_libltdl_la_SOURCES) edit_readme_alpha = $(auxdir)/edit-readme-alpha # The testsuite files are evaluated in the order given here. TESTSUITE = tests/testsuite TESTSUITE_AT = tests/testsuite.at \ tests/getopt-m4sh.at \ tests/libtoolize.at \ tests/help.at \ tests/duplicate_members.at \ tests/duplicate_conv.at \ tests/duplicate_deps.at \ tests/flags.at \ tests/inherited_flags.at \ tests/convenience.at \ tests/link-order.at \ tests/link-order2.at \ tests/fail.at \ tests/shlibpath.at \ tests/runpath-in-lalib.at \ tests/static.at \ tests/export.at \ tests/search-path.at \ tests/indirect_deps.at \ tests/archive-in-archive.at \ tests/exeext.at \ tests/execute-mode.at \ tests/bindir.at \ tests/cwrapper.at \ tests/deplib-in-subdir.at \ tests/infer-tag.at \ tests/localization.at \ tests/nocase.at \ tests/install.at \ tests/versioning.at \ tests/destdir.at \ tests/old-m4-iface.at \ tests/am-subdir.at \ tests/lt_dlexit.at \ tests/lt_dladvise.at \ tests/lt_dlopen.at \ tests/lt_dlopen_a.at \ tests/lt_dlopenext.at \ tests/ltdl-libdir.at \ tests/ltdl-api.at \ tests/dlloader-api.at \ tests/loadlibrary.at \ tests/lalib-syntax.at \ tests/resident.at \ tests/slist.at \ tests/need_lib_prefix.at \ tests/standalone.at \ tests/subproject.at \ tests/nonrecursive.at \ tests/recursive.at \ tests/template.at \ tests/ctor.at \ tests/exceptions.at \ tests/early-libtool.at \ tests/with-pic.at \ tests/no-executables.at \ tests/deplibs-ident.at \ tests/configure-iface.at \ tests/stresstest.at \ tests/cmdline_wrap.at \ tests/pic_flag.at \ tests/darwin.at \ tests/dumpbin-symbols.at \ tests/deplibs-mingw.at \ tests/sysroot.at # Be sure to reexport important environment variables: TESTS_ENVIRONMENT = MAKE="$(MAKE)" CC="$(CC)" CFLAGS="$(CFLAGS)" \ CPP="$(CPP)" CPPFLAGS="$(CPPFLAGS)" LD="$(LD)" LDFLAGS="$(LDFLAGS)" \ LIBS="$(LIBS)" LN_S="$(LN_S)" NM="$(NM)" RANLIB="$(RANLIB)" \ AR="$(AR)" \ M4SH="$(M4SH)" SED="$(SED)" STRIP="$(STRIP)" lt_INSTALL="$(INSTALL)" \ MANIFEST_TOOL="$(MANIFEST_TOOL)" \ OBJEXT="$(OBJEXT)" EXEEXT="$(EXEEXT)" \ SHELL="$(SHELL)" CONFIG_SHELL="$(SHELL)" \ CXX="$(CXX)" CXXFLAGS="$(CXXFLAGS)" CXXCPP="$(CXXCPP)" \ F77="$(F77)" FFLAGS="$(FFLAGS)" \ FC="$(FC)" FCFLAGS="$(FCFLAGS)" \ GCJ="$(GCJ)" GCJFLAGS="$(GCJFLAGS)" \ lt_cv_to_host_file_cmd="$(to_host_file_cmd)" \ lt_cv_to_tool_file_cmd="$(to_tool_file_cmd)" BUILDCHECK_ENVIRONMENT = _lt_pkgdatadir="$(abs_top_srcdir)" \ LIBTOOLIZE="$(abs_top_builddir)/libtoolize" \ LIBTOOL="$(abs_top_builddir)/libtool" \ tst_aclocaldir="$(abs_top_srcdir)/libltdl/m4" INSTALLCHECK_ENVIRONMENT = \ LIBTOOLIZE="$(bindir)/`echo libtoolize | sed '$(program_transform_name)'`" \ LIBTOOL="$(bindir)/`echo libtool | sed '$(program_transform_name)'`" \ LTDLINCL="-I$(includedir)" \ LIBLTDL="$(libdir)/libltdl.la" \ tst_aclocaldir="$(aclocaldir)" CD_TESTDIR = abs_srcdir=`$(lt__cd) $(srcdir) && pwd`; cd tests testsuite_deps = tests/atconfig $(srcdir)/$(TESTSUITE) testsuite_deps_uninstalled = $(testsuite_deps) libltdl/libltdlc.la \ $(bin_SCRIPTS) $(LTDL_BOOTSTRAP_DEPS) # !WARNING! Don't add any new tests here, we are migrating to an # Autotest driven framework, please add new test cases # using the new framework above. When the migration is # complete this section should be removed. CXX_TESTS = \ tests/tagdemo-static.test \ tests/tagdemo-static-make.test \ tests/tagdemo-static-exec.test \ tests/tagdemo-conf.test \ tests/tagdemo-make.test \ tests/tagdemo-exec.test \ tests/tagdemo-shared.test \ tests/tagdemo-shared-make.test \ tests/tagdemo-shared-exec.test \ tests/tagdemo-undef.test \ tests/tagdemo-undef-make.test \ tests/tagdemo-undef-exec.test F77_TESTS = \ tests/f77demo-static.test \ tests/f77demo-static-make.test \ tests/f77demo-static-exec.test \ tests/f77demo-conf.test \ tests/f77demo-make.test \ tests/f77demo-exec.test \ tests/f77demo-shared.test \ tests/f77demo-shared-make.test \ tests/f77demo-shared-exec.test FC_TESTS = \ tests/fcdemo-static.test \ tests/fcdemo-static-make.test \ tests/fcdemo-static-exec.test \ tests/fcdemo-conf.test \ tests/fcdemo-make.test \ tests/fcdemo-exec.test \ tests/fcdemo-shared.test \ tests/fcdemo-shared-make.test \ tests/fcdemo-shared-exec.test COMMON_TESTS = \ tests/link.test \ tests/link-2.test \ tests/nomode.test \ tests/objectlist.test \ tests/quote.test \ tests/sh.test \ tests/suffix.test \ tests/tagtrace.test \ tests/cdemo-static.test \ tests/cdemo-static-make.test \ tests/cdemo-static-exec.test \ tests/demo-static.test \ tests/demo-static-make.test \ tests/demo-static-exec.test \ tests/demo-static-inst.test \ tests/demo-static-unst.test \ tests/depdemo-static.test \ tests/depdemo-static-make.test \ tests/depdemo-static-exec.test \ tests/depdemo-static-inst.test \ tests/depdemo-static-unst.test \ tests/mdemo-static.test \ tests/mdemo-static-make.test \ tests/mdemo-static-exec.test \ tests/mdemo-static-inst.test \ tests/mdemo-static-unst.test \ tests/cdemo-conf.test \ tests/cdemo-make.test \ tests/cdemo-exec.test \ tests/demo-conf.test \ tests/demo-make.test \ tests/demo-exec.test \ tests/demo-inst.test \ tests/demo-unst.test \ tests/demo-deplibs.test \ tests/depdemo-conf.test \ tests/depdemo-make.test \ tests/depdemo-exec.test \ tests/depdemo-inst.test \ tests/depdemo-unst.test \ tests/mdemo-conf.test \ tests/mdemo-make.test \ tests/mdemo-exec.test \ tests/mdemo-inst.test \ tests/mdemo-unst.test \ tests/mdemo-dryrun.test \ tests/mdemo2-conf.test \ tests/mdemo2-make.test \ tests/mdemo2-exec.test \ tests/pdemo-conf.test \ tests/pdemo-make.test \ tests/pdemo-exec.test \ tests/pdemo-inst.test \ tests/demo-nofast.test \ tests/demo-nofast-make.test \ tests/demo-nofast-exec.test \ tests/demo-nofast-inst.test \ tests/demo-nofast-unst.test \ tests/depdemo-nofast.test \ tests/depdemo-nofast-make.test \ tests/depdemo-nofast-exec.test \ tests/depdemo-nofast-inst.test \ tests/depdemo-nofast-unst.test \ tests/demo-pic.test \ tests/demo-pic-make.test \ tests/demo-pic-exec.test \ tests/demo-nopic.test \ tests/demo-nopic-make.test \ tests/demo-nopic-exec.test \ tests/cdemo-shared.test \ tests/cdemo-shared-make.test \ tests/cdemo-shared-exec.test \ tests/mdemo-shared.test \ tests/mdemo-shared-make.test \ tests/mdemo-shared-exec.test \ tests/mdemo-shared-inst.test \ tests/mdemo-shared-unst.test \ tests/cdemo-undef.test \ tests/cdemo-undef-make.test \ tests/cdemo-undef-exec.test # Actually, only demo-relink and depdemo-relink require interaction, # but they depend on the other tests being run beforehand. INTERACTIVE_TESTS = tests/demo-shared.test tests/demo-shared-make.test \ tests/demo-shared-exec.test tests/demo-shared-inst.test \ tests/demo-hardcode.test tests/demo-relink.test \ tests/demo-noinst-link.test tests/demo-shared-unst.test \ tests/depdemo-shared.test tests/depdemo-shared-make.test \ tests/depdemo-shared-exec.test tests/depdemo-shared-inst.test \ tests/depdemo-relink.test tests/depdemo-shared-unst.test \ $(am__append_5) NONINTERACTIVE_TESTS = $(COMMON_TESTS) $(am__append_4) $(am__append_6) TESTS = $(NONINTERACTIVE_TESTS) $(INTERACTIVE_TESTS) # For distclean, we may have to fake Makefiles in the test directories # so that descending in DIST_SUBDIRS works. # Hide the additional dependency from automake so it still outputs the rule. distclean_recursive = distclean-recursive all: $(BUILT_SOURCES) config.h $(MAKE) $(AM_MAKEFLAGS) all-recursive .SUFFIXES: .SUFFIXES: .c .dvi .lo .log .o .obj .ps .test .test$(EXEEXT) .trs am--refresh: Makefile @: $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(srcdir)/libltdl/Makefile.inc $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ echo ' cd $(srcdir) && $(AUTOMAKE) --gnu'; \ $(am__cd) $(srcdir) && $(AUTOMAKE) --gnu \ && exit 0; \ exit 1;; \ esac; \ done; \ echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu Makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --gnu Makefile .PRECIOUS: Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ echo ' $(SHELL) ./config.status'; \ $(SHELL) ./config.status;; \ *) \ echo ' cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__depfiles_maybe)'; \ cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__depfiles_maybe);; \ esac; $(srcdir)/libltdl/Makefile.inc: $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) $(SHELL) ./config.status --recheck $(top_srcdir)/configure: $(am__configure_deps) $(am__cd) $(srcdir) && $(AUTOCONF) $(ACLOCAL_M4): $(am__aclocal_m4_deps) $(am__cd) $(srcdir) && $(ACLOCAL) $(ACLOCAL_AMFLAGS) $(am__aclocal_m4_deps): config.h: stamp-h1 @if test ! -f $@; then rm -f stamp-h1; else :; fi @if test ! -f $@; then $(MAKE) $(AM_MAKEFLAGS) stamp-h1; else :; fi stamp-h1: $(srcdir)/config-h.in $(top_builddir)/config.status @rm -f stamp-h1 cd $(top_builddir) && $(SHELL) ./config.status config.h $(srcdir)/config-h.in: $(am__configure_deps) ($(am__cd) $(top_srcdir) && $(AUTOHEADER)) rm -f stamp-h1 touch $@ distclean-hdr: -rm -f config.h stamp-h1 install-libLTLIBRARIES: $(lib_LTLIBRARIES) @$(NORMAL_INSTALL) @list='$(lib_LTLIBRARIES)'; test -n "$(libdir)" || list=; \ list2=; for p in $$list; do \ if test -f $$p; then \ list2="$$list2 $$p"; \ else :; fi; \ done; \ test -z "$$list2" || { \ echo " $(MKDIR_P) '$(DESTDIR)$(libdir)'"; \ $(MKDIR_P) "$(DESTDIR)$(libdir)" || exit 1; \ echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 '$(DESTDIR)$(libdir)'"; \ $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 "$(DESTDIR)$(libdir)"; \ } uninstall-libLTLIBRARIES: @$(NORMAL_UNINSTALL) @list='$(lib_LTLIBRARIES)'; test -n "$(libdir)" || list=; \ for p in $$list; do \ $(am__strip_dir) \ echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f '$(DESTDIR)$(libdir)/$$f'"; \ $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f "$(DESTDIR)$(libdir)/$$f"; \ done clean-libLTLIBRARIES: -test -z "$(lib_LTLIBRARIES)" || rm -f $(lib_LTLIBRARIES) @list='$(lib_LTLIBRARIES)'; \ locs=`for p in $$list; do echo $$p; done | \ sed 's|^[^/]*$$|.|; s|/[^/]*$$||; s|$$|/so_locations|' | \ sort -u`; \ test -z "$$locs" || { \ echo rm -f $${locs}; \ rm -f $${locs}; \ } clean-noinstLTLIBRARIES: -test -z "$(noinst_LTLIBRARIES)" || rm -f $(noinst_LTLIBRARIES) @list='$(noinst_LTLIBRARIES)'; \ locs=`for p in $$list; do echo $$p; done | \ sed 's|^[^/]*$$|.|; s|/[^/]*$$||; s|$$|/so_locations|' | \ sort -u`; \ test -z "$$locs" || { \ echo rm -f $${locs}; \ rm -f $${locs}; \ } libltdl/loaders/$(am__dirstamp): @$(MKDIR_P) libltdl/loaders @: > libltdl/loaders/$(am__dirstamp) libltdl/loaders/$(DEPDIR)/$(am__dirstamp): @$(MKDIR_P) libltdl/loaders/$(DEPDIR) @: > libltdl/loaders/$(DEPDIR)/$(am__dirstamp) libltdl/loaders/dld_link.lo: libltdl/loaders/$(am__dirstamp) \ libltdl/loaders/$(DEPDIR)/$(am__dirstamp) libltdl/$(am__dirstamp): @$(MKDIR_P) libltdl @: > libltdl/$(am__dirstamp) libltdl/dld_link.la: $(libltdl_dld_link_la_OBJECTS) $(libltdl_dld_link_la_DEPENDENCIES) $(EXTRA_libltdl_dld_link_la_DEPENDENCIES) libltdl/$(am__dirstamp) $(AM_V_CCLD)$(libltdl_dld_link_la_LINK) $(libltdl_dld_link_la_OBJECTS) $(libltdl_dld_link_la_LIBADD) $(LIBS) libltdl/loaders/dlopen.lo: libltdl/loaders/$(am__dirstamp) \ libltdl/loaders/$(DEPDIR)/$(am__dirstamp) libltdl/dlopen.la: $(libltdl_dlopen_la_OBJECTS) $(libltdl_dlopen_la_DEPENDENCIES) $(EXTRA_libltdl_dlopen_la_DEPENDENCIES) libltdl/$(am__dirstamp) $(AM_V_CCLD)$(libltdl_dlopen_la_LINK) $(libltdl_dlopen_la_OBJECTS) $(libltdl_dlopen_la_LIBADD) $(LIBS) libltdl/loaders/dyld.lo: libltdl/loaders/$(am__dirstamp) \ libltdl/loaders/$(DEPDIR)/$(am__dirstamp) libltdl/dyld.la: $(libltdl_dyld_la_OBJECTS) $(libltdl_dyld_la_DEPENDENCIES) $(EXTRA_libltdl_dyld_la_DEPENDENCIES) libltdl/$(am__dirstamp) $(AM_V_CCLD)$(libltdl_dyld_la_LINK) $(libltdl_dyld_la_OBJECTS) $(libltdl_dyld_la_LIBADD) $(LIBS) libltdl/loaders/libltdl_libltdl_la-preopen.lo: \ libltdl/loaders/$(am__dirstamp) \ libltdl/loaders/$(DEPDIR)/$(am__dirstamp) libltdl/$(DEPDIR)/$(am__dirstamp): @$(MKDIR_P) libltdl/$(DEPDIR) @: > libltdl/$(DEPDIR)/$(am__dirstamp) libltdl/libltdl_libltdl_la-lt__alloc.lo: libltdl/$(am__dirstamp) \ libltdl/$(DEPDIR)/$(am__dirstamp) libltdl/libltdl_libltdl_la-lt_dlloader.lo: libltdl/$(am__dirstamp) \ libltdl/$(DEPDIR)/$(am__dirstamp) libltdl/libltdl_libltdl_la-lt_error.lo: libltdl/$(am__dirstamp) \ libltdl/$(DEPDIR)/$(am__dirstamp) libltdl/libltdl_libltdl_la-ltdl.lo: libltdl/$(am__dirstamp) \ libltdl/$(DEPDIR)/$(am__dirstamp) libltdl/libltdl_libltdl_la-slist.lo: libltdl/$(am__dirstamp) \ libltdl/$(DEPDIR)/$(am__dirstamp) libltdl/libltdl.la: $(libltdl_libltdl_la_OBJECTS) $(libltdl_libltdl_la_DEPENDENCIES) $(EXTRA_libltdl_libltdl_la_DEPENDENCIES) libltdl/$(am__dirstamp) $(AM_V_CCLD)$(libltdl_libltdl_la_LINK) $(am_libltdl_libltdl_la_rpath) $(libltdl_libltdl_la_OBJECTS) $(libltdl_libltdl_la_LIBADD) $(LIBS) libltdl/loaders/libltdl_libltdlc_la-preopen.lo: \ libltdl/loaders/$(am__dirstamp) \ libltdl/loaders/$(DEPDIR)/$(am__dirstamp) libltdl/libltdl_libltdlc_la-lt__alloc.lo: libltdl/$(am__dirstamp) \ libltdl/$(DEPDIR)/$(am__dirstamp) libltdl/libltdl_libltdlc_la-lt_dlloader.lo: libltdl/$(am__dirstamp) \ libltdl/$(DEPDIR)/$(am__dirstamp) libltdl/libltdl_libltdlc_la-lt_error.lo: libltdl/$(am__dirstamp) \ libltdl/$(DEPDIR)/$(am__dirstamp) libltdl/libltdl_libltdlc_la-ltdl.lo: libltdl/$(am__dirstamp) \ libltdl/$(DEPDIR)/$(am__dirstamp) libltdl/libltdl_libltdlc_la-slist.lo: libltdl/$(am__dirstamp) \ libltdl/$(DEPDIR)/$(am__dirstamp) libltdl/libltdlc.la: $(libltdl_libltdlc_la_OBJECTS) $(libltdl_libltdlc_la_DEPENDENCIES) $(EXTRA_libltdl_libltdlc_la_DEPENDENCIES) libltdl/$(am__dirstamp) $(AM_V_CCLD)$(libltdl_libltdlc_la_LINK) $(am_libltdl_libltdlc_la_rpath) $(libltdl_libltdlc_la_OBJECTS) $(libltdl_libltdlc_la_LIBADD) $(LIBS) libltdl/loaders/load_add_on.lo: libltdl/loaders/$(am__dirstamp) \ libltdl/loaders/$(DEPDIR)/$(am__dirstamp) libltdl/load_add_on.la: $(libltdl_load_add_on_la_OBJECTS) $(libltdl_load_add_on_la_DEPENDENCIES) $(EXTRA_libltdl_load_add_on_la_DEPENDENCIES) libltdl/$(am__dirstamp) $(AM_V_CCLD)$(libltdl_load_add_on_la_LINK) $(libltdl_load_add_on_la_OBJECTS) $(libltdl_load_add_on_la_LIBADD) $(LIBS) libltdl/loaders/loadlibrary.lo: libltdl/loaders/$(am__dirstamp) \ libltdl/loaders/$(DEPDIR)/$(am__dirstamp) libltdl/loadlibrary.la: $(libltdl_loadlibrary_la_OBJECTS) $(libltdl_loadlibrary_la_DEPENDENCIES) $(EXTRA_libltdl_loadlibrary_la_DEPENDENCIES) libltdl/$(am__dirstamp) $(AM_V_CCLD)$(libltdl_loadlibrary_la_LINK) $(libltdl_loadlibrary_la_OBJECTS) $(libltdl_loadlibrary_la_LIBADD) $(LIBS) libltdl/loaders/shl_load.lo: libltdl/loaders/$(am__dirstamp) \ libltdl/loaders/$(DEPDIR)/$(am__dirstamp) libltdl/shl_load.la: $(libltdl_shl_load_la_OBJECTS) $(libltdl_shl_load_la_DEPENDENCIES) $(EXTRA_libltdl_shl_load_la_DEPENDENCIES) libltdl/$(am__dirstamp) $(AM_V_CCLD)$(libltdl_shl_load_la_LINK) $(libltdl_shl_load_la_OBJECTS) $(libltdl_shl_load_la_LIBADD) $(LIBS) install-binSCRIPTS: $(bin_SCRIPTS) @$(NORMAL_INSTALL) @list='$(bin_SCRIPTS)'; test -n "$(bindir)" || list=; \ if test -n "$$list"; then \ echo " $(MKDIR_P) '$(DESTDIR)$(bindir)'"; \ $(MKDIR_P) "$(DESTDIR)$(bindir)" || exit 1; \ fi; \ for p in $$list; do \ if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ if test -f "$$d$$p"; then echo "$$d$$p"; echo "$$p"; else :; fi; \ done | \ sed -e 'p;s,.*/,,;n' \ -e 'h;s|.*|.|' \ -e 'p;x;s,.*/,,;$(transform)' | sed 'N;N;N;s,\n, ,g' | \ $(AWK) 'BEGIN { files["."] = ""; dirs["."] = 1; } \ { d=$$3; if (dirs[d] != 1) { print "d", d; dirs[d] = 1 } \ if ($$2 == $$4) { files[d] = files[d] " " $$1; \ if (++n[d] == $(am__install_max)) { \ print "f", d, files[d]; n[d] = 0; files[d] = "" } } \ else { print "f", d "/" $$4, $$1 } } \ END { for (d in files) print "f", d, files[d] }' | \ while read type dir files; do \ if test "$$dir" = .; then dir=; else dir=/$$dir; fi; \ test -z "$$files" || { \ echo " $(INSTALL_SCRIPT) $$files '$(DESTDIR)$(bindir)$$dir'"; \ $(INSTALL_SCRIPT) $$files "$(DESTDIR)$(bindir)$$dir" || exit $$?; \ } \ ; done uninstall-binSCRIPTS: @$(NORMAL_UNINSTALL) @list='$(bin_SCRIPTS)'; test -n "$(bindir)" || exit 0; \ files=`for p in $$list; do echo "$$p"; done | \ sed -e 's,.*/,,;$(transform)'`; \ dir='$(DESTDIR)$(bindir)'; $(am__uninstall_files_from_dir) mostlyclean-compile: -rm -f *.$(OBJEXT) -rm -f libltdl/*.$(OBJEXT) -rm -f libltdl/*.lo -rm -f libltdl/loaders/*.$(OBJEXT) -rm -f libltdl/loaders/*.lo distclean-compile: -rm -f *.tab.c include libltdl/$(DEPDIR)/argz.Plo include libltdl/$(DEPDIR)/libltdl_libltdl_la-lt__alloc.Plo include libltdl/$(DEPDIR)/libltdl_libltdl_la-lt_dlloader.Plo include libltdl/$(DEPDIR)/libltdl_libltdl_la-lt_error.Plo include libltdl/$(DEPDIR)/libltdl_libltdl_la-ltdl.Plo include libltdl/$(DEPDIR)/libltdl_libltdl_la-slist.Plo include libltdl/$(DEPDIR)/libltdl_libltdlc_la-lt__alloc.Plo include libltdl/$(DEPDIR)/libltdl_libltdlc_la-lt_dlloader.Plo include libltdl/$(DEPDIR)/libltdl_libltdlc_la-lt_error.Plo include libltdl/$(DEPDIR)/libltdl_libltdlc_la-ltdl.Plo include libltdl/$(DEPDIR)/libltdl_libltdlc_la-slist.Plo include libltdl/$(DEPDIR)/lt__dirent.Plo include libltdl/$(DEPDIR)/lt__strl.Plo include libltdl/loaders/$(DEPDIR)/dld_link.Plo include libltdl/loaders/$(DEPDIR)/dlopen.Plo include libltdl/loaders/$(DEPDIR)/dyld.Plo include libltdl/loaders/$(DEPDIR)/libltdl_libltdl_la-preopen.Plo include libltdl/loaders/$(DEPDIR)/libltdl_libltdlc_la-preopen.Plo include libltdl/loaders/$(DEPDIR)/load_add_on.Plo include libltdl/loaders/$(DEPDIR)/loadlibrary.Plo include libltdl/loaders/$(DEPDIR)/shl_load.Plo .c.o: $(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.o$$||'`;\ $(COMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ $(am__mv) $$depbase.Tpo $$depbase.Po # $(AM_V_CC)source='$<' object='$@' libtool=no \ # DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) \ # $(AM_V_CC_no)$(COMPILE) -c -o $@ $< .c.obj: $(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.obj$$||'`;\ $(COMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ `$(CYGPATH_W) '$<'` &&\ $(am__mv) $$depbase.Tpo $$depbase.Po # $(AM_V_CC)source='$<' object='$@' libtool=no \ # DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) \ # $(AM_V_CC_no)$(COMPILE) -c -o $@ `$(CYGPATH_W) '$<'` .c.lo: $(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.lo$$||'`;\ $(LTCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ $(am__mv) $$depbase.Tpo $$depbase.Plo # $(AM_V_CC)source='$<' object='$@' libtool=yes \ # DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) \ # $(AM_V_CC_no)$(LTCOMPILE) -c -o $@ $< libltdl/loaders/libltdl_libltdl_la-preopen.lo: libltdl/loaders/preopen.c $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libltdl_libltdl_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libltdl/loaders/libltdl_libltdl_la-preopen.lo -MD -MP -MF libltdl/loaders/$(DEPDIR)/libltdl_libltdl_la-preopen.Tpo -c -o libltdl/loaders/libltdl_libltdl_la-preopen.lo `test -f 'libltdl/loaders/preopen.c' || echo '$(srcdir)/'`libltdl/loaders/preopen.c $(AM_V_at)$(am__mv) libltdl/loaders/$(DEPDIR)/libltdl_libltdl_la-preopen.Tpo libltdl/loaders/$(DEPDIR)/libltdl_libltdl_la-preopen.Plo # $(AM_V_CC)source='libltdl/loaders/preopen.c' object='libltdl/loaders/libltdl_libltdl_la-preopen.lo' libtool=yes \ # DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) \ # $(AM_V_CC_no)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libltdl_libltdl_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libltdl/loaders/libltdl_libltdl_la-preopen.lo `test -f 'libltdl/loaders/preopen.c' || echo '$(srcdir)/'`libltdl/loaders/preopen.c libltdl/libltdl_libltdl_la-lt__alloc.lo: libltdl/lt__alloc.c $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libltdl_libltdl_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libltdl/libltdl_libltdl_la-lt__alloc.lo -MD -MP -MF libltdl/$(DEPDIR)/libltdl_libltdl_la-lt__alloc.Tpo -c -o libltdl/libltdl_libltdl_la-lt__alloc.lo `test -f 'libltdl/lt__alloc.c' || echo '$(srcdir)/'`libltdl/lt__alloc.c $(AM_V_at)$(am__mv) libltdl/$(DEPDIR)/libltdl_libltdl_la-lt__alloc.Tpo libltdl/$(DEPDIR)/libltdl_libltdl_la-lt__alloc.Plo # $(AM_V_CC)source='libltdl/lt__alloc.c' object='libltdl/libltdl_libltdl_la-lt__alloc.lo' libtool=yes \ # DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) \ # $(AM_V_CC_no)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libltdl_libltdl_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libltdl/libltdl_libltdl_la-lt__alloc.lo `test -f 'libltdl/lt__alloc.c' || echo '$(srcdir)/'`libltdl/lt__alloc.c libltdl/libltdl_libltdl_la-lt_dlloader.lo: libltdl/lt_dlloader.c $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libltdl_libltdl_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libltdl/libltdl_libltdl_la-lt_dlloader.lo -MD -MP -MF libltdl/$(DEPDIR)/libltdl_libltdl_la-lt_dlloader.Tpo -c -o libltdl/libltdl_libltdl_la-lt_dlloader.lo `test -f 'libltdl/lt_dlloader.c' || echo '$(srcdir)/'`libltdl/lt_dlloader.c $(AM_V_at)$(am__mv) libltdl/$(DEPDIR)/libltdl_libltdl_la-lt_dlloader.Tpo libltdl/$(DEPDIR)/libltdl_libltdl_la-lt_dlloader.Plo # $(AM_V_CC)source='libltdl/lt_dlloader.c' object='libltdl/libltdl_libltdl_la-lt_dlloader.lo' libtool=yes \ # DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) \ # $(AM_V_CC_no)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libltdl_libltdl_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libltdl/libltdl_libltdl_la-lt_dlloader.lo `test -f 'libltdl/lt_dlloader.c' || echo '$(srcdir)/'`libltdl/lt_dlloader.c libltdl/libltdl_libltdl_la-lt_error.lo: libltdl/lt_error.c $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libltdl_libltdl_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libltdl/libltdl_libltdl_la-lt_error.lo -MD -MP -MF libltdl/$(DEPDIR)/libltdl_libltdl_la-lt_error.Tpo -c -o libltdl/libltdl_libltdl_la-lt_error.lo `test -f 'libltdl/lt_error.c' || echo '$(srcdir)/'`libltdl/lt_error.c $(AM_V_at)$(am__mv) libltdl/$(DEPDIR)/libltdl_libltdl_la-lt_error.Tpo libltdl/$(DEPDIR)/libltdl_libltdl_la-lt_error.Plo # $(AM_V_CC)source='libltdl/lt_error.c' object='libltdl/libltdl_libltdl_la-lt_error.lo' libtool=yes \ # DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) \ # $(AM_V_CC_no)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libltdl_libltdl_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libltdl/libltdl_libltdl_la-lt_error.lo `test -f 'libltdl/lt_error.c' || echo '$(srcdir)/'`libltdl/lt_error.c libltdl/libltdl_libltdl_la-ltdl.lo: libltdl/ltdl.c $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libltdl_libltdl_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libltdl/libltdl_libltdl_la-ltdl.lo -MD -MP -MF libltdl/$(DEPDIR)/libltdl_libltdl_la-ltdl.Tpo -c -o libltdl/libltdl_libltdl_la-ltdl.lo `test -f 'libltdl/ltdl.c' || echo '$(srcdir)/'`libltdl/ltdl.c $(AM_V_at)$(am__mv) libltdl/$(DEPDIR)/libltdl_libltdl_la-ltdl.Tpo libltdl/$(DEPDIR)/libltdl_libltdl_la-ltdl.Plo # $(AM_V_CC)source='libltdl/ltdl.c' object='libltdl/libltdl_libltdl_la-ltdl.lo' libtool=yes \ # DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) \ # $(AM_V_CC_no)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libltdl_libltdl_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libltdl/libltdl_libltdl_la-ltdl.lo `test -f 'libltdl/ltdl.c' || echo '$(srcdir)/'`libltdl/ltdl.c libltdl/libltdl_libltdl_la-slist.lo: libltdl/slist.c $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libltdl_libltdl_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libltdl/libltdl_libltdl_la-slist.lo -MD -MP -MF libltdl/$(DEPDIR)/libltdl_libltdl_la-slist.Tpo -c -o libltdl/libltdl_libltdl_la-slist.lo `test -f 'libltdl/slist.c' || echo '$(srcdir)/'`libltdl/slist.c $(AM_V_at)$(am__mv) libltdl/$(DEPDIR)/libltdl_libltdl_la-slist.Tpo libltdl/$(DEPDIR)/libltdl_libltdl_la-slist.Plo # $(AM_V_CC)source='libltdl/slist.c' object='libltdl/libltdl_libltdl_la-slist.lo' libtool=yes \ # DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) \ # $(AM_V_CC_no)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libltdl_libltdl_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libltdl/libltdl_libltdl_la-slist.lo `test -f 'libltdl/slist.c' || echo '$(srcdir)/'`libltdl/slist.c libltdl/loaders/libltdl_libltdlc_la-preopen.lo: libltdl/loaders/preopen.c $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libltdl_libltdlc_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libltdl/loaders/libltdl_libltdlc_la-preopen.lo -MD -MP -MF libltdl/loaders/$(DEPDIR)/libltdl_libltdlc_la-preopen.Tpo -c -o libltdl/loaders/libltdl_libltdlc_la-preopen.lo `test -f 'libltdl/loaders/preopen.c' || echo '$(srcdir)/'`libltdl/loaders/preopen.c $(AM_V_at)$(am__mv) libltdl/loaders/$(DEPDIR)/libltdl_libltdlc_la-preopen.Tpo libltdl/loaders/$(DEPDIR)/libltdl_libltdlc_la-preopen.Plo # $(AM_V_CC)source='libltdl/loaders/preopen.c' object='libltdl/loaders/libltdl_libltdlc_la-preopen.lo' libtool=yes \ # DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) \ # $(AM_V_CC_no)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libltdl_libltdlc_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libltdl/loaders/libltdl_libltdlc_la-preopen.lo `test -f 'libltdl/loaders/preopen.c' || echo '$(srcdir)/'`libltdl/loaders/preopen.c libltdl/libltdl_libltdlc_la-lt__alloc.lo: libltdl/lt__alloc.c $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libltdl_libltdlc_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libltdl/libltdl_libltdlc_la-lt__alloc.lo -MD -MP -MF libltdl/$(DEPDIR)/libltdl_libltdlc_la-lt__alloc.Tpo -c -o libltdl/libltdl_libltdlc_la-lt__alloc.lo `test -f 'libltdl/lt__alloc.c' || echo '$(srcdir)/'`libltdl/lt__alloc.c $(AM_V_at)$(am__mv) libltdl/$(DEPDIR)/libltdl_libltdlc_la-lt__alloc.Tpo libltdl/$(DEPDIR)/libltdl_libltdlc_la-lt__alloc.Plo # $(AM_V_CC)source='libltdl/lt__alloc.c' object='libltdl/libltdl_libltdlc_la-lt__alloc.lo' libtool=yes \ # DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) \ # $(AM_V_CC_no)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libltdl_libltdlc_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libltdl/libltdl_libltdlc_la-lt__alloc.lo `test -f 'libltdl/lt__alloc.c' || echo '$(srcdir)/'`libltdl/lt__alloc.c libltdl/libltdl_libltdlc_la-lt_dlloader.lo: libltdl/lt_dlloader.c $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libltdl_libltdlc_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libltdl/libltdl_libltdlc_la-lt_dlloader.lo -MD -MP -MF libltdl/$(DEPDIR)/libltdl_libltdlc_la-lt_dlloader.Tpo -c -o libltdl/libltdl_libltdlc_la-lt_dlloader.lo `test -f 'libltdl/lt_dlloader.c' || echo '$(srcdir)/'`libltdl/lt_dlloader.c $(AM_V_at)$(am__mv) libltdl/$(DEPDIR)/libltdl_libltdlc_la-lt_dlloader.Tpo libltdl/$(DEPDIR)/libltdl_libltdlc_la-lt_dlloader.Plo # $(AM_V_CC)source='libltdl/lt_dlloader.c' object='libltdl/libltdl_libltdlc_la-lt_dlloader.lo' libtool=yes \ # DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) \ # $(AM_V_CC_no)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libltdl_libltdlc_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libltdl/libltdl_libltdlc_la-lt_dlloader.lo `test -f 'libltdl/lt_dlloader.c' || echo '$(srcdir)/'`libltdl/lt_dlloader.c libltdl/libltdl_libltdlc_la-lt_error.lo: libltdl/lt_error.c $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libltdl_libltdlc_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libltdl/libltdl_libltdlc_la-lt_error.lo -MD -MP -MF libltdl/$(DEPDIR)/libltdl_libltdlc_la-lt_error.Tpo -c -o libltdl/libltdl_libltdlc_la-lt_error.lo `test -f 'libltdl/lt_error.c' || echo '$(srcdir)/'`libltdl/lt_error.c $(AM_V_at)$(am__mv) libltdl/$(DEPDIR)/libltdl_libltdlc_la-lt_error.Tpo libltdl/$(DEPDIR)/libltdl_libltdlc_la-lt_error.Plo # $(AM_V_CC)source='libltdl/lt_error.c' object='libltdl/libltdl_libltdlc_la-lt_error.lo' libtool=yes \ # DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) \ # $(AM_V_CC_no)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libltdl_libltdlc_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libltdl/libltdl_libltdlc_la-lt_error.lo `test -f 'libltdl/lt_error.c' || echo '$(srcdir)/'`libltdl/lt_error.c libltdl/libltdl_libltdlc_la-ltdl.lo: libltdl/ltdl.c $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libltdl_libltdlc_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libltdl/libltdl_libltdlc_la-ltdl.lo -MD -MP -MF libltdl/$(DEPDIR)/libltdl_libltdlc_la-ltdl.Tpo -c -o libltdl/libltdl_libltdlc_la-ltdl.lo `test -f 'libltdl/ltdl.c' || echo '$(srcdir)/'`libltdl/ltdl.c $(AM_V_at)$(am__mv) libltdl/$(DEPDIR)/libltdl_libltdlc_la-ltdl.Tpo libltdl/$(DEPDIR)/libltdl_libltdlc_la-ltdl.Plo # $(AM_V_CC)source='libltdl/ltdl.c' object='libltdl/libltdl_libltdlc_la-ltdl.lo' libtool=yes \ # DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) \ # $(AM_V_CC_no)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libltdl_libltdlc_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libltdl/libltdl_libltdlc_la-ltdl.lo `test -f 'libltdl/ltdl.c' || echo '$(srcdir)/'`libltdl/ltdl.c libltdl/libltdl_libltdlc_la-slist.lo: libltdl/slist.c $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libltdl_libltdlc_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libltdl/libltdl_libltdlc_la-slist.lo -MD -MP -MF libltdl/$(DEPDIR)/libltdl_libltdlc_la-slist.Tpo -c -o libltdl/libltdl_libltdlc_la-slist.lo `test -f 'libltdl/slist.c' || echo '$(srcdir)/'`libltdl/slist.c $(AM_V_at)$(am__mv) libltdl/$(DEPDIR)/libltdl_libltdlc_la-slist.Tpo libltdl/$(DEPDIR)/libltdl_libltdlc_la-slist.Plo # $(AM_V_CC)source='libltdl/slist.c' object='libltdl/libltdl_libltdlc_la-slist.lo' libtool=yes \ # DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) \ # $(AM_V_CC_no)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libltdl_libltdlc_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libltdl/libltdl_libltdlc_la-slist.lo `test -f 'libltdl/slist.c' || echo '$(srcdir)/'`libltdl/slist.c mostlyclean-libtool: -rm -f *.lo clean-libtool: -rm -rf .libs _libs -rm -rf libltdl/.libs libltdl/_libs -rm -rf libltdl/loaders/.libs libltdl/loaders/_libs distclean-libtool: -rm -f libtool config.lt doc/$(am__dirstamp): @$(MKDIR_P) doc @: > doc/$(am__dirstamp) $(srcdir)/doc/libtool.info: doc/libtool.texi $(srcdir)/doc/version.texi $(doc_libtool_TEXINFOS) $(AM_V_MAKEINFO)restore=: && backupdir="$(am__leading_dot)am$$$$" && \ am__cwd=`pwd` && $(am__cd) $(srcdir) && \ rm -rf $$backupdir && mkdir $$backupdir && \ if ($(MAKEINFO) --version) >/dev/null 2>&1; then \ for f in $@ $@-[0-9] $@-[0-9][0-9] $(@:.info=).i[0-9] $(@:.info=).i[0-9][0-9]; do \ if test -f $$f; then mv $$f $$backupdir; restore=mv; else :; fi; \ done; \ else :; fi && \ cd "$$am__cwd"; \ if $(MAKEINFO) $(AM_MAKEINFOFLAGS) $(MAKEINFOFLAGS) -I doc -I $(srcdir)/doc \ -o $@ $(srcdir)/doc/libtool.texi; \ then \ rc=0; \ $(am__cd) $(srcdir); \ else \ rc=$$?; \ $(am__cd) $(srcdir) && \ $$restore $$backupdir/* `echo "./$@" | sed 's|[^/]*$$||'`; \ fi; \ rm -rf $$backupdir; exit $$rc doc/libtool.dvi: doc/libtool.texi $(srcdir)/doc/version.texi $(doc_libtool_TEXINFOS) doc/$(am__dirstamp) $(AM_V_TEXI2DVI)TEXINPUTS="$(am__TEXINFO_TEX_DIR)$(PATH_SEPARATOR)$$TEXINPUTS" \ MAKEINFO='$(MAKEINFO) $(AM_MAKEINFOFLAGS) $(MAKEINFOFLAGS) -I doc -I $(srcdir)/doc' \ $(TEXI2DVI) $(AM_V_texinfo) --build-dir=$(@:.dvi=.t2d) -o $@ $(AM_V_texidevnull) \ `test -f 'doc/libtool.texi' || echo '$(srcdir)/'`doc/libtool.texi doc/libtool.pdf: doc/libtool.texi $(srcdir)/doc/version.texi $(doc_libtool_TEXINFOS) doc/$(am__dirstamp) $(AM_V_TEXI2PDF)TEXINPUTS="$(am__TEXINFO_TEX_DIR)$(PATH_SEPARATOR)$$TEXINPUTS" \ MAKEINFO='$(MAKEINFO) $(AM_MAKEINFOFLAGS) $(MAKEINFOFLAGS) -I doc -I $(srcdir)/doc' \ $(TEXI2PDF) $(AM_V_texinfo) --build-dir=$(@:.pdf=.t2p) -o $@ $(AM_V_texidevnull) \ `test -f 'doc/libtool.texi' || echo '$(srcdir)/'`doc/libtool.texi doc/libtool.html: doc/libtool.texi $(srcdir)/doc/version.texi $(doc_libtool_TEXINFOS) doc/$(am__dirstamp) $(AM_V_MAKEINFO)rm -rf $(@:.html=.htp) $(AM_V_at)if $(MAKEINFOHTML) $(AM_MAKEINFOHTMLFLAGS) $(MAKEINFOFLAGS) -I doc -I $(srcdir)/doc \ -o $(@:.html=.htp) `test -f 'doc/libtool.texi' || echo '$(srcdir)/'`doc/libtool.texi; \ then \ rm -rf $@; \ if test ! -d $(@:.html=.htp) && test -d $(@:.html=); then \ mv $(@:.html=) $@; else mv $(@:.html=.htp) $@; fi; \ else \ if test ! -d $(@:.html=.htp) && test -d $(@:.html=); then \ rm -rf $(@:.html=); else rm -Rf $(@:.html=.htp) $@; fi; \ exit 1; \ fi $(srcdir)/doc/version.texi: $(srcdir)/doc/stamp-vti $(srcdir)/doc/stamp-vti: doc/libtool.texi $(top_srcdir)/configure test -f doc/$(am__dirstamp) || $(MAKE) $(AM_MAKEFLAGS) doc/$(am__dirstamp) @(dir=.; test -f ./doc/libtool.texi || dir=$(srcdir); \ set `$(SHELL) $(top_srcdir)/libltdl/config/mdate-sh $$dir/doc/libtool.texi`; \ echo "@set UPDATED $$1 $$2 $$3"; \ echo "@set UPDATED-MONTH $$2 $$3"; \ echo "@set EDITION $(VERSION)"; \ echo "@set VERSION $(VERSION)") > vti.tmp @cmp -s vti.tmp $(srcdir)/doc/version.texi \ || (echo "Updating $(srcdir)/doc/version.texi"; \ cp vti.tmp $(srcdir)/doc/version.texi) -@rm -f vti.tmp @cp $(srcdir)/doc/version.texi $@ mostlyclean-vti: -rm -f vti.tmp maintainer-clean-vti: -rm -f $(srcdir)/doc/stamp-vti $(srcdir)/doc/version.texi .dvi.ps: $(AM_V_DVIPS)TEXINPUTS="$(am__TEXINFO_TEX_DIR)$(PATH_SEPARATOR)$$TEXINPUTS" \ $(DVIPS) $(AM_V_texinfo) -o $@ $< uninstall-dvi-am: @$(NORMAL_UNINSTALL) @list='$(DVIS)'; test -n "$(dvidir)" || list=; \ for p in $$list; do \ $(am__strip_dir) \ echo " rm -f '$(DESTDIR)$(dvidir)/$$f'"; \ rm -f "$(DESTDIR)$(dvidir)/$$f"; \ done uninstall-html-am: @$(NORMAL_UNINSTALL) @list='$(HTMLS)'; test -n "$(htmldir)" || list=; \ for p in $$list; do \ $(am__strip_dir) \ echo " rm -rf '$(DESTDIR)$(htmldir)/$$f'"; \ rm -rf "$(DESTDIR)$(htmldir)/$$f"; \ done uninstall-info-am: @$(PRE_UNINSTALL) @if test -d '$(DESTDIR)$(infodir)' && $(am__can_run_installinfo); then \ list='$(INFO_DEPS)'; \ for file in $$list; do \ relfile=`echo "$$file" | sed 's|^.*/||'`; \ echo " install-info --info-dir='$(DESTDIR)$(infodir)' --remove '$(DESTDIR)$(infodir)/$$relfile'"; \ if install-info --info-dir="$(DESTDIR)$(infodir)" --remove "$(DESTDIR)$(infodir)/$$relfile"; \ then :; else test ! -f "$(DESTDIR)$(infodir)/$$relfile" || exit 1; fi; \ done; \ else :; fi @$(NORMAL_UNINSTALL) @list='$(INFO_DEPS)'; \ for file in $$list; do \ relfile=`echo "$$file" | sed 's|^.*/||'`; \ relfile_i=`echo "$$relfile" | sed 's|\.info$$||;s|$$|.i|'`; \ (if test -d "$(DESTDIR)$(infodir)" && cd "$(DESTDIR)$(infodir)"; then \ echo " cd '$(DESTDIR)$(infodir)' && rm -f $$relfile $$relfile-[0-9] $$relfile-[0-9][0-9] $$relfile_i[0-9] $$relfile_i[0-9][0-9]"; \ rm -f $$relfile $$relfile-[0-9] $$relfile-[0-9][0-9] $$relfile_i[0-9] $$relfile_i[0-9][0-9]; \ else :; fi); \ done uninstall-pdf-am: @$(NORMAL_UNINSTALL) @list='$(PDFS)'; test -n "$(pdfdir)" || list=; \ for p in $$list; do \ $(am__strip_dir) \ echo " rm -f '$(DESTDIR)$(pdfdir)/$$f'"; \ rm -f "$(DESTDIR)$(pdfdir)/$$f"; \ done uninstall-ps-am: @$(NORMAL_UNINSTALL) @list='$(PSS)'; test -n "$(psdir)" || list=; \ for p in $$list; do \ $(am__strip_dir) \ echo " rm -f '$(DESTDIR)$(psdir)/$$f'"; \ rm -f "$(DESTDIR)$(psdir)/$$f"; \ done dist-info: $(INFO_DEPS) @srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \ list='$(INFO_DEPS)'; \ for base in $$list; do \ case $$base in \ $(srcdir)/*) base=`echo "$$base" | sed "s|^$$srcdirstrip/||"`;; \ esac; \ if test -f $$base; then d=.; else d=$(srcdir); fi; \ base_i=`echo "$$base" | sed 's|\.info$$||;s|$$|.i|'`; \ for file in $$d/$$base $$d/$$base-[0-9] $$d/$$base-[0-9][0-9] $$d/$$base_i[0-9] $$d/$$base_i[0-9][0-9]; do \ if test -f $$file; then \ relfile=`expr "$$file" : "$$d/\(.*\)"`; \ test -f "$(distdir)/$$relfile" || \ cp -p $$file "$(distdir)/$$relfile"; \ else :; fi; \ done; \ done mostlyclean-aminfo: -rm -rf doc/libtool.t2d doc/libtool.t2p clean-aminfo: -test -z "doc/libtool.dvi doc/libtool.pdf doc/libtool.ps doc/libtool.html" \ || rm -rf doc/libtool.dvi doc/libtool.pdf doc/libtool.ps doc/libtool.html maintainer-clean-aminfo: @list='$(INFO_DEPS)'; for i in $$list; do \ i_i=`echo "$$i" | sed 's|\.info$$||;s|$$|.i|'`; \ echo " rm -f $$i $$i-[0-9] $$i-[0-9][0-9] $$i_i[0-9] $$i_i[0-9][0-9]"; \ rm -f $$i $$i-[0-9] $$i-[0-9][0-9] $$i_i[0-9] $$i_i[0-9][0-9]; \ done install-man1: $(dist_man1_MANS) @$(NORMAL_INSTALL) @list1='$(dist_man1_MANS)'; \ list2=''; \ test -n "$(man1dir)" \ && test -n "`echo $$list1$$list2`" \ || exit 0; \ echo " $(MKDIR_P) '$(DESTDIR)$(man1dir)'"; \ $(MKDIR_P) "$(DESTDIR)$(man1dir)" || exit 1; \ { for i in $$list1; do echo "$$i"; done; \ if test -n "$$list2"; then \ for i in $$list2; do echo "$$i"; done \ | sed -n '/\.1[a-z]*$$/p'; \ fi; \ } | while read p; do \ if test -f $$p; then d=; else d="$(srcdir)/"; fi; \ echo "$$d$$p"; echo "$$p"; \ done | \ sed -e 'n;s,.*/,,;p;h;s,.*\.,,;s,^[^1][0-9a-z]*$$,1,;x' \ -e 's,\.[0-9a-z]*$$,,;$(transform);G;s,\n,.,' | \ sed 'N;N;s,\n, ,g' | { \ list=; while read file base inst; do \ if test "$$base" = "$$inst"; then list="$$list $$file"; else \ echo " $(INSTALL_DATA) '$$file' '$(DESTDIR)$(man1dir)/$$inst'"; \ $(INSTALL_DATA) "$$file" "$(DESTDIR)$(man1dir)/$$inst" || exit $$?; \ fi; \ done; \ for i in $$list; do echo "$$i"; done | $(am__base_list) | \ while read files; do \ test -z "$$files" || { \ echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(man1dir)'"; \ $(INSTALL_DATA) $$files "$(DESTDIR)$(man1dir)" || exit $$?; }; \ done; } uninstall-man1: @$(NORMAL_UNINSTALL) @list='$(dist_man1_MANS)'; test -n "$(man1dir)" || exit 0; \ files=`{ for i in $$list; do echo "$$i"; done; \ } | sed -e 's,.*/,,;h;s,.*\.,,;s,^[^1][0-9a-z]*$$,1,;x' \ -e 's,\.[0-9a-z]*$$,,;$(transform);G;s,\n,.,'`; \ dir='$(DESTDIR)$(man1dir)'; $(am__uninstall_files_from_dir) install-includeHEADERS: $(include_HEADERS) @$(NORMAL_INSTALL) @list='$(include_HEADERS)'; test -n "$(includedir)" || list=; \ if test -n "$$list"; then \ echo " $(MKDIR_P) '$(DESTDIR)$(includedir)'"; \ $(MKDIR_P) "$(DESTDIR)$(includedir)" || exit 1; \ fi; \ for p in $$list; do \ if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ echo "$$d$$p"; \ done | $(am__base_list) | \ while read files; do \ echo " $(INSTALL_HEADER) $$files '$(DESTDIR)$(includedir)'"; \ $(INSTALL_HEADER) $$files "$(DESTDIR)$(includedir)" || exit $$?; \ done uninstall-includeHEADERS: @$(NORMAL_UNINSTALL) @list='$(include_HEADERS)'; test -n "$(includedir)" || list=; \ files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \ dir='$(DESTDIR)$(includedir)'; $(am__uninstall_files_from_dir) install-ltdlincludeHEADERS: $(ltdlinclude_HEADERS) @$(NORMAL_INSTALL) @list='$(ltdlinclude_HEADERS)'; test -n "$(ltdlincludedir)" || list=; \ if test -n "$$list"; then \ echo " $(MKDIR_P) '$(DESTDIR)$(ltdlincludedir)'"; \ $(MKDIR_P) "$(DESTDIR)$(ltdlincludedir)" || exit 1; \ fi; \ for p in $$list; do \ if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ echo "$$d$$p"; \ done | $(am__base_list) | \ while read files; do \ echo " $(INSTALL_HEADER) $$files '$(DESTDIR)$(ltdlincludedir)'"; \ $(INSTALL_HEADER) $$files "$(DESTDIR)$(ltdlincludedir)" || exit $$?; \ done uninstall-ltdlincludeHEADERS: @$(NORMAL_UNINSTALL) @list='$(ltdlinclude_HEADERS)'; test -n "$(ltdlincludedir)" || list=; \ files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \ dir='$(DESTDIR)$(ltdlincludedir)'; $(am__uninstall_files_from_dir) # This directory's subdirectories are mostly independent; you can cd # into them and run 'make' without going through this Makefile. # To change the values of 'make' variables: instead of editing Makefiles, # (1) if the variable is set in 'config.status', edit 'config.status' # (which will cause the Makefiles to be regenerated when you run 'make'); # (2) otherwise, pass the desired values on the 'make' command line. $(am__recursive_targets): @fail=; \ if $(am__make_keepgoing); then \ failcom='fail=yes'; \ else \ failcom='exit 1'; \ fi; \ dot_seen=no; \ target=`echo $@ | sed s/-recursive//`; \ case "$@" in \ distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \ *) list='$(SUBDIRS)' ;; \ esac; \ for subdir in $$list; do \ echo "Making $$target in $$subdir"; \ if test "$$subdir" = "."; then \ dot_seen=yes; \ local_target="$$target-am"; \ else \ local_target="$$target"; \ fi; \ ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ || eval $$failcom; \ done; \ if test "$$dot_seen" = "no"; then \ $(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \ fi; test -z "$$fail" ID: $(am__tagged_files) $(am__define_uniq_tagged_files); mkid -fID $$unique tags: tags-recursive TAGS: tags tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) set x; \ here=`pwd`; \ if ($(ETAGS) --etags-include --version) >/dev/null 2>&1; then \ include_option=--etags-include; \ empty_fix=.; \ else \ include_option=--include; \ empty_fix=; \ fi; \ list='$(SUBDIRS)'; for subdir in $$list; do \ if test "$$subdir" = .; then :; else \ test ! -f $$subdir/TAGS || \ set "$$@" "$$include_option=$$here/$$subdir/TAGS"; \ fi; \ done; \ $(am__define_uniq_tagged_files); \ shift; \ if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ test -n "$$unique" || unique=$$empty_fix; \ if test $$# -gt 0; then \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ "$$@" $$unique; \ else \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ $$unique; \ fi; \ fi ctags: ctags-recursive CTAGS: ctags ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) $(am__define_uniq_tagged_files); \ test -z "$(CTAGS_ARGS)$$unique" \ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ $$unique GTAGS: here=`$(am__cd) $(top_builddir) && pwd` \ && $(am__cd) $(top_srcdir) \ && gtags -i $(GTAGS_ARGS) "$$here" cscope: cscope.files test ! -s cscope.files \ || $(CSCOPE) -b -q $(AM_CSCOPEFLAGS) $(CSCOPEFLAGS) -i cscope.files $(CSCOPE_ARGS) clean-cscope: -rm -f cscope.files cscope.files: clean-cscope cscopelist cscopelist: cscopelist-recursive cscopelist-am: $(am__tagged_files) list='$(am__tagged_files)'; \ case "$(srcdir)" in \ [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \ *) sdir=$(subdir)/$(srcdir) ;; \ esac; \ for i in $$list; do \ if test -f "$$i"; then \ echo "$(subdir)/$$i"; \ else \ echo "$$sdir/$$i"; \ fi; \ done >> $(top_builddir)/cscope.files distclean-tags: -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags -rm -f cscope.out cscope.in.out cscope.po.out cscope.files # Recover from deleted '.trs' file; this should ensure that # "rm -f foo.log; make foo.trs" re-run 'foo.test', and re-create # both 'foo.log' and 'foo.trs'. Break the recipe in two subshells # to avoid problems with "make -n". .log.trs: rm -f $< $@ $(MAKE) $(AM_MAKEFLAGS) $< # Leading 'am--fnord' is there to ensure the list of targets does not # expand to empty, as could happen e.g. with make check TESTS=''. am--fnord $(TEST_LOGS) $(TEST_LOGS:.log=.trs): $(am__force_recheck) am--force-recheck: @: $(TEST_SUITE_LOG): $(TEST_LOGS) @$(am__set_TESTS_bases); \ am__f_ok () { test -f "$$1" && test -r "$$1"; }; \ redo_bases=`for i in $$bases; do \ am__f_ok $$i.trs && am__f_ok $$i.log || echo $$i; \ done`; \ if test -n "$$redo_bases"; then \ redo_logs=`for i in $$redo_bases; do echo $$i.log; done`; \ redo_results=`for i in $$redo_bases; do echo $$i.trs; done`; \ if $(am__make_dryrun); then :; else \ rm -f $$redo_logs && rm -f $$redo_results || exit 1; \ fi; \ fi; \ if test -n "$$am__remaking_logs"; then \ echo "fatal: making $(TEST_SUITE_LOG): possible infinite" \ "recursion detected" >&2; \ else \ am__remaking_logs=yes $(MAKE) $(AM_MAKEFLAGS) $$redo_logs; \ fi; \ if $(am__make_dryrun); then :; else \ st=0; \ errmsg="fatal: making $(TEST_SUITE_LOG): failed to create"; \ for i in $$redo_bases; do \ test -f $$i.trs && test -r $$i.trs \ || { echo "$$errmsg $$i.trs" >&2; st=1; }; \ test -f $$i.log && test -r $$i.log \ || { echo "$$errmsg $$i.log" >&2; st=1; }; \ done; \ test $$st -eq 0 || exit 1; \ fi @$(am__sh_e_setup); $(am__tty_colors); $(am__set_TESTS_bases); \ ws='[ ]'; \ results=`for b in $$bases; do echo $$b.trs; done`; \ test -n "$$results" || results=/dev/null; \ all=` grep "^$$ws*:test-result:" $$results | wc -l`; \ pass=` grep "^$$ws*:test-result:$$ws*PASS" $$results | wc -l`; \ fail=` grep "^$$ws*:test-result:$$ws*FAIL" $$results | wc -l`; \ skip=` grep "^$$ws*:test-result:$$ws*SKIP" $$results | wc -l`; \ xfail=`grep "^$$ws*:test-result:$$ws*XFAIL" $$results | wc -l`; \ xpass=`grep "^$$ws*:test-result:$$ws*XPASS" $$results | wc -l`; \ error=`grep "^$$ws*:test-result:$$ws*ERROR" $$results | wc -l`; \ if test `expr $$fail + $$xpass + $$error` -eq 0; then \ success=true; \ else \ success=false; \ fi; \ br='==================='; br=$$br$$br$$br$$br; \ result_count () \ { \ if test x"$$1" = x"--maybe-color"; then \ maybe_colorize=yes; \ elif test x"$$1" = x"--no-color"; then \ maybe_colorize=no; \ else \ echo "$@: invalid 'result_count' usage" >&2; exit 4; \ fi; \ shift; \ desc=$$1 count=$$2; \ if test $$maybe_colorize = yes && test $$count -gt 0; then \ color_start=$$3 color_end=$$std; \ else \ color_start= color_end=; \ fi; \ echo "$${color_start}# $$desc $$count$${color_end}"; \ }; \ create_testsuite_report () \ { \ result_count $$1 "TOTAL:" $$all "$$brg"; \ result_count $$1 "PASS: " $$pass "$$grn"; \ result_count $$1 "SKIP: " $$skip "$$blu"; \ result_count $$1 "XFAIL:" $$xfail "$$lgn"; \ result_count $$1 "FAIL: " $$fail "$$red"; \ result_count $$1 "XPASS:" $$xpass "$$red"; \ result_count $$1 "ERROR:" $$error "$$mgn"; \ }; \ { \ echo "$(PACKAGE_STRING): $(subdir)/$(TEST_SUITE_LOG)" | \ $(am__rst_title); \ create_testsuite_report --no-color; \ echo; \ echo ".. contents:: :depth: 2"; \ echo; \ for b in $$bases; do echo $$b; done \ | $(am__create_global_log); \ } >$(TEST_SUITE_LOG).tmp || exit 1; \ mv $(TEST_SUITE_LOG).tmp $(TEST_SUITE_LOG); \ if $$success; then \ col="$$grn"; \ else \ col="$$red"; \ test x"$$VERBOSE" = x || cat $(TEST_SUITE_LOG); \ fi; \ echo "$${col}$$br$${std}"; \ echo "$${col}Testsuite summary for $(PACKAGE_STRING)$${std}"; \ echo "$${col}$$br$${std}"; \ create_testsuite_report --maybe-color; \ echo "$$col$$br$$std"; \ if $$success; then :; else \ echo "$${col}See $(subdir)/$(TEST_SUITE_LOG)$${std}"; \ if test -n "$(PACKAGE_BUGREPORT)"; then \ echo "$${col}Please report to $(PACKAGE_BUGREPORT)$${std}"; \ fi; \ echo "$$col$$br$$std"; \ fi; \ $$success || exit 1 check-TESTS: @list='$(RECHECK_LOGS)'; test -z "$$list" || rm -f $$list @list='$(RECHECK_LOGS:.log=.trs)'; test -z "$$list" || rm -f $$list @test -z "$(TEST_SUITE_LOG)" || rm -f $(TEST_SUITE_LOG) @set +e; $(am__set_TESTS_bases); \ log_list=`for i in $$bases; do echo $$i.log; done`; \ trs_list=`for i in $$bases; do echo $$i.trs; done`; \ log_list=`echo $$log_list`; trs_list=`echo $$trs_list`; \ $(MAKE) $(AM_MAKEFLAGS) $(TEST_SUITE_LOG) TEST_LOGS="$$log_list"; \ exit $$?; recheck: all @test -z "$(TEST_SUITE_LOG)" || rm -f $(TEST_SUITE_LOG) @set +e; $(am__set_TESTS_bases); \ bases=`for i in $$bases; do echo $$i; done \ | $(am__list_recheck_tests)` || exit 1; \ log_list=`for i in $$bases; do echo $$i.log; done`; \ log_list=`echo $$log_list`; \ $(MAKE) $(AM_MAKEFLAGS) $(TEST_SUITE_LOG) \ am__force_recheck=am--force-recheck \ TEST_LOGS="$$log_list"; \ exit $$? .test.log: @p='$<'; \ $(am__set_b); \ $(am__check_pre) $(TEST_LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_TEST_LOG_DRIVER_FLAGS) $(TEST_LOG_DRIVER_FLAGS) -- $(TEST_LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) #.test$(EXEEXT).log: # @p='$<'; \ # $(am__set_b); \ # $(am__check_pre) $(TEST_LOG_DRIVER) --test-name "$$f" \ # --log-file $$b.log --trs-file $$b.trs \ # $(am__common_driver_flags) $(AM_TEST_LOG_DRIVER_FLAGS) $(TEST_LOG_DRIVER_FLAGS) -- $(TEST_LOG_COMPILE) \ # "$$tst" $(AM_TESTS_FD_REDIRECT) distdir: $(DISTFILES) $(am__remove_distdir) test -d "$(distdir)" || mkdir "$(distdir)" @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ list='$(DISTFILES)'; \ dist_files=`for file in $$list; do echo $$file; done | \ sed -e "s|^$$srcdirstrip/||;t" \ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ case $$dist_files in \ */*) $(MKDIR_P) `echo "$$dist_files" | \ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ sort -u` ;; \ esac; \ for file in $$dist_files; do \ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ if test -d $$d/$$file; then \ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ if test -d "$(distdir)/$$file"; then \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ else \ test -f "$(distdir)/$$file" \ || cp -p $$d/$$file "$(distdir)/$$file" \ || exit 1; \ fi; \ done @list='$(DIST_SUBDIRS)'; for subdir in $$list; do \ if test "$$subdir" = .; then :; else \ $(am__make_dryrun) \ || test -d "$(distdir)/$$subdir" \ || $(MKDIR_P) "$(distdir)/$$subdir" \ || exit 1; \ dir1=$$subdir; dir2="$(distdir)/$$subdir"; \ $(am__relativize); \ new_distdir=$$reldir; \ dir1=$$subdir; dir2="$(top_distdir)"; \ $(am__relativize); \ new_top_distdir=$$reldir; \ echo " (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) top_distdir="$$new_top_distdir" distdir="$$new_distdir" \\"; \ echo " am__remove_distdir=: am__skip_length_check=: am__skip_mode_fix=: distdir)"; \ ($(am__cd) $$subdir && \ $(MAKE) $(AM_MAKEFLAGS) \ top_distdir="$$new_top_distdir" \ distdir="$$new_distdir" \ am__remove_distdir=: \ am__skip_length_check=: \ am__skip_mode_fix=: \ distdir) \ || exit 1; \ fi; \ done $(MAKE) $(AM_MAKEFLAGS) \ top_distdir="$(top_distdir)" distdir="$(distdir)" \ dist-info dist-hook -test -n "$(am__skip_mode_fix)" \ || find "$(distdir)" -type d ! -perm -755 \ -exec chmod u+rwx,go+rx {} \; -o \ ! -type d ! -perm -444 -links 1 -exec chmod a+r {} \; -o \ ! -type d ! -perm -400 -exec chmod a+r {} \; -o \ ! -type d ! -perm -444 -exec $(install_sh) -c -m a+r {} {} \; \ || chmod -R a+r "$(distdir)" dist-gzip: distdir tardir=$(distdir) && $(am__tar) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).tar.gz $(am__post_remove_distdir) dist-bzip2: distdir tardir=$(distdir) && $(am__tar) | BZIP2=$${BZIP2--9} bzip2 -c >$(distdir).tar.bz2 $(am__post_remove_distdir) dist-lzip: distdir tardir=$(distdir) && $(am__tar) | lzip -c $${LZIP_OPT--9} >$(distdir).tar.lz $(am__post_remove_distdir) dist-xz: distdir tardir=$(distdir) && $(am__tar) | XZ_OPT=$${XZ_OPT--e} xz -c >$(distdir).tar.xz $(am__post_remove_distdir) dist-tarZ: distdir tardir=$(distdir) && $(am__tar) | compress -c >$(distdir).tar.Z $(am__post_remove_distdir) dist-shar: distdir shar $(distdir) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).shar.gz $(am__post_remove_distdir) dist-zip: distdir -rm -f $(distdir).zip zip -rq $(distdir).zip $(distdir) $(am__post_remove_distdir) dist dist-all: $(MAKE) $(AM_MAKEFLAGS) $(DIST_TARGETS) am__post_remove_distdir='@:' $(am__post_remove_distdir) # This target untars the dist file and tries a VPATH configuration. Then # it guarantees that the distribution is self-contained by making another # tarfile. distcheck: dist case '$(DIST_ARCHIVES)' in \ *.tar.gz*) \ GZIP=$(GZIP_ENV) gzip -dc $(distdir).tar.gz | $(am__untar) ;;\ *.tar.bz2*) \ bzip2 -dc $(distdir).tar.bz2 | $(am__untar) ;;\ *.tar.lz*) \ lzip -dc $(distdir).tar.lz | $(am__untar) ;;\ *.tar.xz*) \ xz -dc $(distdir).tar.xz | $(am__untar) ;;\ *.tar.Z*) \ uncompress -c $(distdir).tar.Z | $(am__untar) ;;\ *.shar.gz*) \ GZIP=$(GZIP_ENV) gzip -dc $(distdir).shar.gz | unshar ;;\ *.zip*) \ unzip $(distdir).zip ;;\ esac chmod -R a-w $(distdir) chmod u+w $(distdir) mkdir $(distdir)/_build $(distdir)/_inst chmod a-w $(distdir) test -d $(distdir)/_build || exit 0; \ dc_install_base=`$(am__cd) $(distdir)/_inst && pwd | sed -e 's,^[^:\\/]:[\\/],/,'` \ && dc_destdir="$${TMPDIR-/tmp}/am-dc-$$$$/" \ && am__cwd=`pwd` \ && $(am__cd) $(distdir)/_build \ && ../configure --srcdir=.. --prefix="$$dc_install_base" \ $(AM_DISTCHECK_CONFIGURE_FLAGS) \ $(DISTCHECK_CONFIGURE_FLAGS) \ && $(MAKE) $(AM_MAKEFLAGS) \ && $(MAKE) $(AM_MAKEFLAGS) dvi \ && $(MAKE) $(AM_MAKEFLAGS) check \ && $(MAKE) $(AM_MAKEFLAGS) install \ && $(MAKE) $(AM_MAKEFLAGS) installcheck \ && $(MAKE) $(AM_MAKEFLAGS) uninstall \ && $(MAKE) $(AM_MAKEFLAGS) distuninstallcheck_dir="$$dc_install_base" \ distuninstallcheck \ && chmod -R a-w "$$dc_install_base" \ && ({ \ (cd ../.. && umask 077 && mkdir "$$dc_destdir") \ && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" install \ && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" uninstall \ && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" \ distuninstallcheck_dir="$$dc_destdir" distuninstallcheck; \ } || { rm -rf "$$dc_destdir"; exit 1; }) \ && rm -rf "$$dc_destdir" \ && $(MAKE) $(AM_MAKEFLAGS) dist \ && rm -rf $(DIST_ARCHIVES) \ && $(MAKE) $(AM_MAKEFLAGS) distcleancheck \ && cd "$$am__cwd" \ || exit 1 $(am__post_remove_distdir) @(echo "$(distdir) archives ready for distribution: "; \ list='$(DIST_ARCHIVES)'; for i in $$list; do echo $$i; done) | \ sed -e 1h -e 1s/./=/g -e 1p -e 1x -e '$$p' -e '$$x' distuninstallcheck: @test -n '$(distuninstallcheck_dir)' || { \ echo 'ERROR: trying to run $@ with an empty' \ '$$(distuninstallcheck_dir)' >&2; \ exit 1; \ }; \ $(am__cd) '$(distuninstallcheck_dir)' || { \ echo 'ERROR: cannot chdir into $(distuninstallcheck_dir)' >&2; \ exit 1; \ }; \ test `$(am__distuninstallcheck_listfiles) | wc -l` -eq 0 \ || { echo "ERROR: files left after uninstall:" ; \ if test -n "$(DESTDIR)"; then \ echo " (check DESTDIR support)"; \ fi ; \ $(distuninstallcheck_listfiles) ; \ exit 1; } >&2 distcleancheck: distclean @if test '$(srcdir)' = . ; then \ echo "ERROR: distcleancheck can only run from a VPATH build" ; \ exit 1 ; \ fi @test `$(distcleancheck_listfiles) | wc -l` -eq 0 \ || { echo "ERROR: files left in build directory after distclean:" ; \ $(distcleancheck_listfiles) ; \ exit 1; } >&2 check-am: all-am $(MAKE) $(AM_MAKEFLAGS) check-TESTS check-local check: $(BUILT_SOURCES) $(MAKE) $(AM_MAKEFLAGS) check-recursive all-am: Makefile $(INFO_DEPS) $(LTLIBRARIES) $(SCRIPTS) $(MANS) \ $(HEADERS) config.h all-local installdirs: installdirs-recursive installdirs-am: for dir in "$(DESTDIR)$(libdir)" "$(DESTDIR)$(bindir)" "$(DESTDIR)$(infodir)" "$(DESTDIR)$(man1dir)" "$(DESTDIR)$(includedir)" "$(DESTDIR)$(ltdlincludedir)"; do \ test -z "$$dir" || $(MKDIR_P) "$$dir"; \ done install: $(BUILT_SOURCES) $(MAKE) $(AM_MAKEFLAGS) install-recursive install-exec: install-exec-recursive install-data: install-data-recursive uninstall: uninstall-recursive install-am: all-am @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am installcheck: installcheck-recursive install-strip: if test -z '$(STRIP)'; then \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ install; \ else \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ fi mostlyclean-generic: -test -z "$(LIBOBJS)" || rm -f $(LIBOBJS) -test -z "$(LTLIBOBJS)" || rm -f $(LTLIBOBJS) -test -z "$(MOSTLYCLEANFILES)" || rm -f $(MOSTLYCLEANFILES) -test -z "$(TEST_LOGS)" || rm -f $(TEST_LOGS) -test -z "$(TEST_LOGS:.log=.trs)" || rm -f $(TEST_LOGS:.log=.trs) -test -z "$(TEST_SUITE_LOG)" || rm -f $(TEST_SUITE_LOG) clean-generic: -test -z "$(CLEANFILES)" || rm -f $(CLEANFILES) distclean-generic: -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) -rm -f doc/$(am__dirstamp) -rm -f libltdl/$(DEPDIR)/$(am__dirstamp) -rm -f libltdl/$(am__dirstamp) -rm -f libltdl/loaders/$(DEPDIR)/$(am__dirstamp) -rm -f libltdl/loaders/$(am__dirstamp) -test -z "$(DISTCLEANFILES)" || rm -f $(DISTCLEANFILES) maintainer-clean-generic: @echo "This command is intended for maintainers to use" @echo "it deletes files that may require special tools to rebuild." -test -z "$(BUILT_SOURCES)" || rm -f $(BUILT_SOURCES) -test -z "$(MAINTAINERCLEANFILES)" || rm -f $(MAINTAINERCLEANFILES) clean: clean-recursive clean-am: clean-aminfo clean-generic clean-libLTLIBRARIES \ clean-libtool clean-local clean-noinstLTLIBRARIES \ mostlyclean-am distclean: distclean-recursive -rm -f $(am__CONFIG_DISTCLEAN_FILES) -rm -rf libltdl/$(DEPDIR) libltdl/loaders/$(DEPDIR) -rm -f Makefile distclean-am: clean-am distclean-compile distclean-generic \ distclean-hdr distclean-libtool distclean-tags dvi: dvi-recursive dvi-am: $(DVIS) html: html-recursive html-am: $(HTMLS) info: info-recursive info-am: $(INFO_DEPS) install-data-am: install-data-local install-includeHEADERS \ install-info-am install-ltdlincludeHEADERS install-man install-dvi: install-dvi-recursive install-dvi-am: $(DVIS) @$(NORMAL_INSTALL) @list='$(DVIS)'; test -n "$(dvidir)" || list=; \ if test -n "$$list"; then \ echo " $(MKDIR_P) '$(DESTDIR)$(dvidir)'"; \ $(MKDIR_P) "$(DESTDIR)$(dvidir)" || exit 1; \ fi; \ for p in $$list; do \ if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ echo "$$d$$p"; \ done | $(am__base_list) | \ while read files; do \ echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(dvidir)'"; \ $(INSTALL_DATA) $$files "$(DESTDIR)$(dvidir)" || exit $$?; \ done install-exec-am: install-binSCRIPTS install-libLTLIBRARIES install-html: install-html-recursive install-html-am: $(HTMLS) @$(NORMAL_INSTALL) @list='$(HTMLS)'; list2=; test -n "$(htmldir)" || list=; \ if test -n "$$list"; then \ echo " $(MKDIR_P) '$(DESTDIR)$(htmldir)'"; \ $(MKDIR_P) "$(DESTDIR)$(htmldir)" || exit 1; \ fi; \ for p in $$list; do \ if test -f "$$p" || test -d "$$p"; then d=; else d="$(srcdir)/"; fi; \ $(am__strip_dir) \ d2=$$d$$p; \ if test -d "$$d2"; then \ echo " $(MKDIR_P) '$(DESTDIR)$(htmldir)/$$f'"; \ $(MKDIR_P) "$(DESTDIR)$(htmldir)/$$f" || exit 1; \ echo " $(INSTALL_DATA) '$$d2'/* '$(DESTDIR)$(htmldir)/$$f'"; \ $(INSTALL_DATA) "$$d2"/* "$(DESTDIR)$(htmldir)/$$f" || exit $$?; \ else \ list2="$$list2 $$d2"; \ fi; \ done; \ test -z "$$list2" || { echo "$$list2" | $(am__base_list) | \ while read files; do \ echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(htmldir)'"; \ $(INSTALL_DATA) $$files "$(DESTDIR)$(htmldir)" || exit $$?; \ done; } install-info: install-info-recursive install-info-am: $(INFO_DEPS) @$(NORMAL_INSTALL) @srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \ list='$(INFO_DEPS)'; test -n "$(infodir)" || list=; \ if test -n "$$list"; then \ echo " $(MKDIR_P) '$(DESTDIR)$(infodir)'"; \ $(MKDIR_P) "$(DESTDIR)$(infodir)" || exit 1; \ fi; \ for file in $$list; do \ case $$file in \ $(srcdir)/*) file=`echo "$$file" | sed "s|^$$srcdirstrip/||"`;; \ esac; \ if test -f $$file; then d=.; else d=$(srcdir); fi; \ file_i=`echo "$$file" | sed 's|\.info$$||;s|$$|.i|'`; \ for ifile in $$d/$$file $$d/$$file-[0-9] $$d/$$file-[0-9][0-9] \ $$d/$$file_i[0-9] $$d/$$file_i[0-9][0-9] ; do \ if test -f $$ifile; then \ echo "$$ifile"; \ else : ; fi; \ done; \ done | $(am__base_list) | \ while read files; do \ echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(infodir)'"; \ $(INSTALL_DATA) $$files "$(DESTDIR)$(infodir)" || exit $$?; done @$(POST_INSTALL) @if $(am__can_run_installinfo); then \ list='$(INFO_DEPS)'; test -n "$(infodir)" || list=; \ for file in $$list; do \ relfile=`echo "$$file" | sed 's|^.*/||'`; \ echo " install-info --info-dir='$(DESTDIR)$(infodir)' '$(DESTDIR)$(infodir)/$$relfile'";\ install-info --info-dir="$(DESTDIR)$(infodir)" "$(DESTDIR)$(infodir)/$$relfile" || :;\ done; \ else : ; fi install-man: install-man1 install-pdf: install-pdf-recursive install-pdf-am: $(PDFS) @$(NORMAL_INSTALL) @list='$(PDFS)'; test -n "$(pdfdir)" || list=; \ if test -n "$$list"; then \ echo " $(MKDIR_P) '$(DESTDIR)$(pdfdir)'"; \ $(MKDIR_P) "$(DESTDIR)$(pdfdir)" || exit 1; \ fi; \ for p in $$list; do \ if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ echo "$$d$$p"; \ done | $(am__base_list) | \ while read files; do \ echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(pdfdir)'"; \ $(INSTALL_DATA) $$files "$(DESTDIR)$(pdfdir)" || exit $$?; done install-ps: install-ps-recursive install-ps-am: $(PSS) @$(NORMAL_INSTALL) @list='$(PSS)'; test -n "$(psdir)" || list=; \ if test -n "$$list"; then \ echo " $(MKDIR_P) '$(DESTDIR)$(psdir)'"; \ $(MKDIR_P) "$(DESTDIR)$(psdir)" || exit 1; \ fi; \ for p in $$list; do \ if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ echo "$$d$$p"; \ done | $(am__base_list) | \ while read files; do \ echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(psdir)'"; \ $(INSTALL_DATA) $$files "$(DESTDIR)$(psdir)" || exit $$?; done installcheck-am: installcheck-local maintainer-clean: maintainer-clean-recursive -rm -f $(am__CONFIG_DISTCLEAN_FILES) -rm -rf $(top_srcdir)/autom4te.cache -rm -rf libltdl/$(DEPDIR) libltdl/loaders/$(DEPDIR) -rm -f Makefile maintainer-clean-am: distclean-am maintainer-clean-aminfo \ maintainer-clean-generic maintainer-clean-vti mostlyclean: mostlyclean-recursive mostlyclean-am: mostlyclean-aminfo mostlyclean-compile \ mostlyclean-generic mostlyclean-libtool mostlyclean-vti pdf: pdf-recursive pdf-am: $(PDFS) ps: ps-recursive ps-am: $(PSS) uninstall-am: uninstall-binSCRIPTS uninstall-dvi-am uninstall-html-am \ uninstall-includeHEADERS uninstall-info-am \ uninstall-libLTLIBRARIES uninstall-ltdlincludeHEADERS \ uninstall-man uninstall-pdf-am uninstall-ps-am @$(NORMAL_INSTALL) $(MAKE) $(AM_MAKEFLAGS) uninstall-hook uninstall-man: uninstall-man1 .MAKE: $(am__recursive_targets) all check check-am install install-am \ install-strip uninstall-am .PHONY: $(am__recursive_targets) CTAGS GTAGS TAGS all all-am all-local \ am--refresh check check-TESTS check-am check-local clean \ clean-aminfo clean-cscope clean-generic clean-libLTLIBRARIES \ clean-libtool clean-local clean-noinstLTLIBRARIES cscope \ cscopelist-am ctags ctags-am dist dist-all dist-bzip2 \ dist-gzip dist-hook dist-info dist-lzip dist-shar dist-tarZ \ dist-xz dist-zip distcheck distclean distclean-compile \ distclean-generic distclean-hdr distclean-libtool \ distclean-tags distcleancheck distdir distuninstallcheck dvi \ dvi-am html html-am info info-am install install-am \ install-binSCRIPTS install-data install-data-am \ install-data-local install-dvi install-dvi-am install-exec \ install-exec-am install-html install-html-am \ install-includeHEADERS install-info install-info-am \ install-libLTLIBRARIES install-ltdlincludeHEADERS install-man \ install-man1 install-pdf install-pdf-am install-ps \ install-ps-am install-strip installcheck installcheck-am \ installcheck-local installdirs installdirs-am maintainer-clean \ maintainer-clean-aminfo maintainer-clean-generic \ maintainer-clean-vti mostlyclean mostlyclean-aminfo \ mostlyclean-compile mostlyclean-generic mostlyclean-libtool \ mostlyclean-vti pdf pdf-am ps ps-am recheck tags tags-am \ uninstall uninstall-am uninstall-binSCRIPTS uninstall-dvi-am \ uninstall-hook uninstall-html-am uninstall-includeHEADERS \ uninstall-info-am uninstall-libLTLIBRARIES \ uninstall-ltdlincludeHEADERS uninstall-man uninstall-man1 \ uninstall-pdf-am uninstall-ps-am $(srcdir)/$(m4dir)/ltversion.m4: $(m4dir)/ltversion.in configure.ac ChangeLog @target='$(srcdir)/$(m4dir)/ltversion.m4'; $(rebuild); \ if test -f "$$target"; then \ set dummy `sed -n '/^# serial /p' "$$target"`; shift; \ actualver=1.$$3; \ test "$$actualver" = "$$correctver" && rebuild=false; \ fi; \ for prereq in $?; do \ case $$prereq in *ChangeLog | *configure.ac);; *) rebuild=:;; esac; \ done; \ if $$rebuild; then \ cd $(srcdir); \ rm -f $(m4dir)/ltversion.tmp; \ serial=`echo "$$correctver" | sed 's,^1[.],,g'`; \ echo $(bootstrap_edit) \ $(srcdir)/$(m4dir)/ltversion.in \> $(srcdir)/$(m4dir)/ltversion.m4; \ $(bootstrap_edit) \ $(m4dir)/ltversion.in > $(m4dir)/ltversion.tmp; \ chmod a-w $(m4dir)/ltversion.tmp; \ mv -f $(m4dir)/ltversion.tmp $(m4dir)/ltversion.m4; \ fi $(srcdir)/$(auxdir)/ltmain.sh: $(sh_files) $(auxdir)/ltmain.m4sh configure.ac ChangeLog @target='$(srcdir)/$(auxdir)/ltmain.sh'; $(rebuild); \ if test -f "$$target"; then \ eval `sed -n '/^package_revision=/p' "$$target"`; \ actualver=$$package_revision; \ test "$$actualver" = "$$correctver" && rebuild=false; \ fi; \ for prereq in $?; do \ case $$prereq in *ChangeLog);; *) rebuild=:;; esac; \ done; \ if $$rebuild; then \ cd $(srcdir); \ rm -f $(auxdir)/ltmain.in $(auxdir)/ltmain.tmp \ $(auxdir)/ltmain.sh; \ echo $(M4SH) -B $(auxdir) $(auxdir)/ltmain.m4sh \ \> $(auxdir)/ltmain.in; \ $(M4SH) -B $(auxdir) $(auxdir)/ltmain.m4sh \ > $(auxdir)/ltmain.in; \ echo $(bootstrap_edit) \ $(srcdir)/$(auxdir)/ltmain.in "> $$target"; \ $(bootstrap_edit) -e '/^: \$${.*="@.*@"}$$/d' \ $(auxdir)/ltmain.in > $(auxdir)/ltmain.tmp; \ rm -f $(auxdir)/ltmain.in; \ chmod a-w $(auxdir)/ltmain.tmp; \ mv -f $(auxdir)/ltmain.tmp $(auxdir)/ltmain.sh; \ fi $(srcdir)/libtoolize.in: $(sh_files) libtoolize.m4sh Makefile.am cd $(srcdir); \ rm -f libtoolize.in libtoolize.tmp; \ $(M4SH) -B $(auxdir) libtoolize.m4sh > libtoolize.tmp; \ $(bootstrap_edit) libtoolize.tmp > libtoolize.in; \ rm -f libtoolize.tmp $(srcdir)/libltdl/Makefile.am: $(srcdir)/libltdl/Makefile.inc cd $(srcdir); \ in=libltdl/Makefile.inc; out=libltdl/Makefile.am; \ rm -f $$out; \ ( $(SED) -n '1,/^.. DO NOT REMOVE THIS LINE -- /p' $$in; \ { echo 'ACLOCAL_AMFLAGS = -I m4'; \ echo 'AUTOMAKE_OPTIONS = foreign'; \ echo 'AM_CPPFLAGS ='; \ echo 'AM_LDFLAGS ='; \ echo 'BUILT_SOURCES ='; \ echo 'include_HEADERS ='; \ echo 'noinst_LTLIBRARIES ='; \ echo 'lib_LTLIBRARIES ='; \ echo 'EXTRA_LTLIBRARIES ='; \ echo 'EXTRA_DIST ='; \ echo 'CLEANFILES ='; \ echo 'MOSTLYCLEANFILES ='; \ }; \ $(SED) -n '/^.. DO NOT REMOVE THIS LINE -- /,$$p' $$in | \ $(SED) -e 's,libltdl_,,; s,libltdl/,,; s,: libltdl/,: ,' \ -e 's,\$$(libltdl_,$$(,' \ ) | \ $(SED) -e '/^.. DO NOT REMOVE THIS LINE -- /d' \ -e '1s,^\(.. Makefile.\)inc.*,\1am -- Process this file with automake to produce Makefile.in,' > $$out; chmod a-w $(srcdir)/libltdl/Makefile.am all-local: $(LTDL_BOOTSTRAP_DEPS) libtoolize: $(srcdir)/libtoolize.in $(top_builddir)/config.status rm -f libtoolize.tmp libtoolize $(configure_edit) \ $(srcdir)/libtoolize.in > libtoolize.tmp chmod a+x libtoolize.tmp chmod a-w libtoolize.tmp mv -f libtoolize.tmp libtoolize # We used to do this with a 'stamp-vcl' file, but non-gmake builds # would rerun configure on every invocation, so now we manually # check the version numbers from the build rule when necessary. libtool: $(top_builddir)/config.status $(srcdir)/$(auxdir)/ltmain.sh ChangeLog @target=libtool; $(rebuild); \ if test -f "$$target"; then \ set dummy `./$$target --version | sed 1q`; actualver="$$5"; \ test "$$actualver" = "$$correctver" && rebuild=false; \ fi; \ for prereq in $?; do \ case $$prereq in *ChangeLog);; *) rebuild=:;; esac; \ done; \ if $$rebuild; then \ echo $(SHELL) ./config.status $$target; \ cd $(top_builddir) && $(SHELL) ./config.status $$target; \ fi .PHONY: configure-subdirs configure-subdirs distdir: $(DIST_MAKEFILE_LIST) tests/cdemo/Makefile tests/demo/Makefile tests/depdemo/Makefile tests/f77demo/Makefile tests/fcdemo/Makefile tests/mdemo/Makefile tests/mdemo2/Makefile tests/pdemo/Makefile tests/tagdemo/Makefile : dir=`echo $@ | sed 's,^[^/]*$$,.,;s,/[^/]*$$,,'`; \ test -d $$dir || mkdir $$dir || exit 1; \ abs_srcdir=`$(lt__cd) $(srcdir) && pwd`; \ (cd $$dir && $$abs_srcdir/$$dir/configure --with-dist) || exit 1 # We need the following in order to create an <argz.h> when the system # doesn't have one that works with the given compiler. all-local $(lib_OBJECTS): libltdl/$(ARGZ_H) libltdl/argz.h: libltdl/argz_.h $(mkinstalldirs) . libltdl/ cp $(srcdir)/libltdl/argz_.h $@-t mv $@-t $@ $(srcdir)/libltdl/Makefile.in: $(srcdir)/libltdl/Makefile.am \ $(srcdir)/libltdl/aclocal.m4 cd $(srcdir)/libltdl && $(AUTOMAKE) Makefile $(srcdir)/libltdl/stamp-mk: $(srcdir)/libltdl/Makefile.in cd $(srcdir)/libltdl && \ sed -e 's,config/mdate-sh,,' -e 's,config/texinfo.tex,,' \ -e 's,config/mkinstalldirs,,' \ < Makefile.in > Makefile.inT && \ mv -f Makefile.inT Makefile.in echo stamp > $@ $(srcdir)/libltdl/aclocal.m4: $(sub_aclocal_m4_deps) cd $(srcdir)/libltdl && $(ACLOCAL) -I m4 $(srcdir)/libltdl/configure: $(sub_configure_deps) cd $(srcdir)/libltdl && $(AUTOCONF) $(srcdir)/libltdl/config-h.in: $(sub_configure_deps) cd $(srcdir)/libltdl && $(AUTOHEADER) touch $@ all-local: $(srcdir)/doc/notes.txt $(srcdir)/doc/notes.txt: $(srcdir)/doc/notes.texi cd $(srcdir)/doc && \ $(MAKEINFO) --no-headers $(MAKEINFOFLAGS) -o notes.txt notes.texi $(srcdir)/doc/libtool.1: $(srcdir)/$(auxdir)/ltmain.sh $(update_mans) --help-option=--help-all libtool $(srcdir)/doc/libtoolize.1: $(srcdir)/libtoolize.in $(update_mans) libtoolize install-data-local: libltdl/Makefile.in @$(NORMAL_INSTALL) -rm -rf $(DESTDIR)$(pkgdatadir)/* $(mkinstalldirs) $(DESTDIR)$(aclocaldir) @list='$(aclocalfiles)'; for p in $$list; do \ f=`echo "$$p" | sed 's|^.*/||'`; \ echo " $(INSTALL_DATA) '$(srcdir)/$(m4dir)/$$f' '$(DESTDIR)$(aclocaldir)/$$f'"; \ $(INSTALL_DATA) "$(srcdir)/$(m4dir)/$$f" "$(DESTDIR)$(aclocaldir)/$$f"; \ done $(mkinstalldirs) $(DESTDIR)$(pkgdatadir) $(mkinstalldirs) $(DESTDIR)$(pkgdatadir)/config @list='$(auxexefiles)' && for p in $$list; do \ echo " $(INSTALL_SCRIPT) '$(srcdir)/libltdl/$$p' '$(DESTDIR)$(pkgdatadir)/$$p'"; \ $(INSTALL_SCRIPT) "$(srcdir)/libltdl/$$p" "$(DESTDIR)$(pkgdatadir)/$$p"; \ done $(INSTALL_DATA) "$(srcdir)/libltdl/config/ltmain.sh" "$(DESTDIR)$(pkgdatadir)/config/ltmain.sh" $(mkinstalldirs) $(DESTDIR)$(pkgdatadir)/libltdl $(mkinstalldirs) $(DESTDIR)$(pkgdatadir)/libltdl/libltdl $(mkinstalldirs) $(DESTDIR)$(pkgdatadir)/libltdl/loaders @list='$(ltdldatafiles)' && for p in $$list; do \ echo " $(INSTALL_DATA) '$(srcdir)/$$p' '$(DESTDIR)$(pkgdatadir)/$$p'"; \ $(INSTALL_DATA) "$(srcdir)/$$p" "$(DESTDIR)$(pkgdatadir)/$$p"; \ done -chmod a+x $(DESTDIR)$(pkgdatadir)/libltdl/configure uninstall-hook: @$(NORMAL_UNINSTALL) @list='$(ltdldatafiles) $(auxfiles)'; for f in $$list; do \ echo " rm -f '$(DESTDIR)$(pkgdatadir)/$$f'"; \ rm -f "$(DESTDIR)$(pkgdatadir)/$$f"; \ done @for p in $(aclocalfiles); do \ f=`echo "$$p" | sed 's|^.*/||'`; \ echo " rm -f '$(DESTDIR)$(aclocaldir)/$$f'"; \ rm -f "$(DESTDIR)$(aclocaldir)/$$f"; \ done dist-hook: case $(VERSION) in \ *[a-z]) $(SHELL) $(srcdir)/$(edit_readme_alpha) $(distdir)/README ;; \ esac for macro in LT_INIT AC_PROG_LIBTOOL AM_PROG_LIBTOOL; do \ if grep $$macro $(srcdir)/aclocal.m4 $(srcdir)/libltdl/aclocal.m4; then \ echo "Bogus $$macro macro contents in an aclocal.m4 file." >&2; \ exit 1; \ else :; fi; \ done # Use `$(srcdir)' for the benefit of non-GNU makes: this is # how `testsuite' appears in our dependencies. $(srcdir)/$(TESTSUITE): $(srcdir)/tests/package.m4 $(TESTSUITE_AT) Makefile.am cd $(srcdir)/tests && \ $(AUTOTEST) `echo $(TESTSUITE_AT) | sed 's,tests/,,g'` -o testsuite.tmp && \ mv -f testsuite.tmp testsuite $(srcdir)/tests/package.m4: $(srcdir)/configure.ac Makefile.am { \ echo '# Signature of the current package.'; \ echo 'm4_define([AT_PACKAGE_NAME], [GNU Libtool])'; \ echo 'm4_define([AT_PACKAGE_TARNAME], [libtool])'; \ echo 'm4_define([AT_PACKAGE_VERSION], [2.4.2])'; \ echo 'm4_define([AT_PACKAGE_STRING], [GNU Libtool 2.4.2])'; \ echo 'm4_define([AT_PACKAGE_BUGREPORT], [[email protected]])'; \ echo 'm4_define([AT_PACKAGE_URL], [http://www.gnu.org/software/libtool/])'; \ } | $(bootstrap_edit) > $(srcdir)/tests/package.m4 tests/atconfig: $(top_builddir)/config.status $(SHELL) ./config.status tests/atconfig # Hook the test suite into the check rule check-local: $(testsuite_deps_uninstalled) $(CD_TESTDIR); \ CONFIG_SHELL="$(SHELL)" $(SHELL) $$abs_srcdir/$(TESTSUITE) \ $(TESTS_ENVIRONMENT) $(BUILDCHECK_ENVIRONMENT) $(TESTSUITEFLAGS) # Run the test suite on the *installed* tree. installcheck-local: $(testsuite_deps) $(CD_TESTDIR); \ CONFIG_SHELL="$(SHELL)" $(SHELL) $$abs_srcdir/$(TESTSUITE) \ $(TESTS_ENVIRONMENT) $(INSTALLCHECK_ENVIRONMENT) $(TESTSUITEFLAGS) \ AUTOTEST_PATH="$(exec_prefix)/bin" check-noninteractive-old: $(MAKE) $(AM_MAKEFLAGS) check-TESTS TESTS='$(NONINTERACTIVE_TESTS)' check-interactive-old: $(MAKE) $(AM_MAKEFLAGS) check-TESTS TESTS='$(INTERACTIVE_TESTS)' # Run only noninteractive parts of the new testsuite. check-noninteractive-new: $(testsuite_deps_uninstalled) $(CD_TESTDIR); \ CONFIG_SHELL="$(SHELL)" $(SHELL) $$abs_srcdir/$(TESTSUITE) \ $(TESTS_ENVIRONMENT) $(BUILDCHECK_ENVIRONMENT) \ -k !interactive INNER_TESTSUITEFLAGS=",!interactive" \ $(TESTSUITEFLAGS) # Run only interactive parts of the new testsuite. check-interactive-new: $(testsuite_deps_uninstalled) $(CD_TESTDIR); \ CONFIG_SHELL="$(SHELL)" $(SHELL) $$abs_srcdir/$(TESTSUITE) \ $(TESTS_ENVIRONMENT) $(BUILDCHECK_ENVIRONMENT) \ -k interactive -k recursive INNER_TESTSUITEFLAGS=",interactive" \ $(TESTSUITEFLAGS) check-interactive: check-interactive-old check-interactive-new check-noninteractive: check-noninteractive-old check-noninteractive-new # We need to remove any file droppings left behind by testsuite clean-local: clean-local-legacy -$(CD_TESTDIR); \ test -f $$abs_srcdir/$(TESTSUITE) && \ $(SHELL) $$abs_srcdir/$(TESTSUITE) --clean tests/tagdemo-undef-exec.log: tests/tagdemo-undef-make.log tests/tagdemo-undef-make.log: tests/tagdemo-undef.log tests/tagdemo-undef.log: tests/tagdemo-shared-exec.log tests/tagdemo-shared-exec.log: tests/tagdemo-shared-make.log tests/tagdemo-shared-make.log: tests/tagdemo-shared.log tests/tagdemo-shared.log: tests/tagdemo-exec.log tests/tagdemo-exec.log: tests/tagdemo-make.log tests/tagdemo-make.log: tests/tagdemo-conf.log tests/tagdemo-conf.log: tests/tagdemo-static-exec.log tests/tagdemo-static-exec.log: tests/tagdemo-static-make.log tests/tagdemo-static-make.log: tests/tagdemo-static.log tests/f77demo-shared-exec.log: tests/f77demo-shared-make.log tests/f77demo-shared-make.log: tests/f77demo-shared.log tests/f77demo-shared.log: tests/f77demo-exec.log tests/f77demo-exec.log: tests/f77demo-make.log tests/f77demo-make.log: tests/f77demo-conf.log tests/f77demo-conf.log: tests/f77demo-static-exec.log tests/f77demo-static-exec.log: tests/f77demo-static-make.log tests/f77demo-static-make.log: tests/f77demo-static.log tests/fcdemo-shared-exec.log: tests/fcdemo-shared-make.log tests/fcdemo-shared-make.log: tests/fcdemo-shared.log tests/fcdemo-shared.log: tests/fcdemo-exec.log tests/fcdemo-exec.log: tests/fcdemo-make.log tests/fcdemo-make.log: tests/fcdemo-conf.log tests/fcdemo-conf.log: tests/fcdemo-static-exec.log tests/fcdemo-static-exec.log: tests/fcdemo-static-make.log tests/fcdemo-static-make.log: tests/fcdemo-static.log tests/cdemo-undef-exec.log: tests/cdemo-undef-make.log tests/cdemo-undef-make.log: tests/cdemo-undef.log tests/cdemo-undef.log: | tests/cdemo-shared-exec.log tests/cdemo-shared-exec.log: tests/cdemo-shared-make.log tests/cdemo-shared-make.log: tests/cdemo-shared.log tests/cdemo-shared.log: | tests/cdemo-exec.log tests/cdemo-exec.log: tests/cdemo-make.log tests/cdemo-make.log: tests/cdemo-conf.log tests/cdemo-conf.log: | tests/cdemo-static-exec.log tests/cdemo-static-exec.log: tests/cdemo-static-make.log tests/cdemo-static-make.log: tests/cdemo-static.log tests/demo-shared-unst.log: tests/demo-noinst-link.log tests/demo-noinst-link.log: tests/demo-relink.log tests/demo-relink.log: tests/demo-hardcode.log tests/demo-hardcode.log: tests/demo-shared-inst.log tests/demo-shared-inst.log: tests/demo-shared-exec.log tests/demo-shared-exec.log: tests/demo-shared-make.log tests/demo-shared-make.log: tests/demo-shared.log tests/demo-shared.log: | tests/demo-nopic-exec.log tests/demo-nopic-exec.log: tests/demo-nopic-make.log tests/demo-nopic-make.log: tests/demo-nopic.log tests/demo-nopic.log: | tests/demo-pic-exec.log tests/demo-pic-exec.log: tests/demo-pic-make.log tests/demo-pic-make.log: tests/demo-pic.log tests/demo-pic.log: | tests/demo-nofast-unst.log tests/demo-nofast-unst.log: tests/demo-nofast-inst.log tests/demo-nofast-inst.log: tests/demo-nofast-exec.log tests/demo-nofast-exec.log: tests/demo-nofast-make.log tests/demo-nofast-make.log: tests/demo-nofast.log tests/demo-nofast.log: | tests/demo-deplibs.log tests/demo-deplibs.log: tests/demo-unst.log tests/demo-unst.log: tests/demo-inst.log tests/demo-inst.log: tests/demo-exec.log tests/demo-exec.log: tests/demo-make.log tests/demo-make.log: tests/demo-conf.log tests/demo-conf.log: | tests/demo-static-unst.log tests/demo-static-unst.log: tests/demo-static-inst.log tests/demo-static-inst.log: tests/demo-static-exec.log tests/demo-static-exec.log: tests/demo-static-make.log tests/demo-static-make.log: tests/demo-static.log tests/depdemo-shared-unst.log: tests/depdemo-relink.log tests/depdemo-relink.log: tests/depdemo-shared-inst.log tests/depdemo-shared-inst.log: tests/depdemo-shared-exec.log tests/depdemo-shared-exec.log: tests/depdemo-shared-make.log tests/depdemo-shared-make.log: tests/depdemo-shared.log tests/depdemo-shared.log: | tests/depdemo-nofast-unst.log tests/depdemo-nofast-unst.log: tests/depdemo-nofast-inst.log tests/depdemo-nofast-inst.log: tests/depdemo-nofast-exec.log tests/depdemo-nofast-exec.log: tests/depdemo-nofast-make.log tests/depdemo-nofast-make.log: tests/depdemo-nofast.log tests/depdemo-nofast.log: | tests/depdemo-unst.log tests/depdemo-unst.log: tests/depdemo-inst.log tests/depdemo-inst.log: tests/depdemo-exec.log tests/depdemo-exec.log: tests/depdemo-make.log tests/depdemo-make.log: tests/depdemo-conf.log tests/depdemo-conf.log: | tests/depdemo-static-unst.log tests/depdemo-static-unst.log: tests/depdemo-static-inst.log tests/depdemo-static-inst.log: tests/depdemo-static-exec.log tests/depdemo-static-exec.log: tests/depdemo-static-make.log tests/depdemo-static-make.log: tests/depdemo-static.log tests/mdemo-shared-unst.log: tests/mdemo-shared-inst.log tests/mdemo-shared-inst.log: tests/mdemo-shared-exec.log tests/mdemo-shared-exec.log: tests/mdemo-shared-make.log tests/mdemo-shared-make.log: tests/mdemo-shared.log tests/mdemo-shared.log: | tests/mdemo-dryrun.log \ tests/mdemo2-exec.log tests/mdemo-dryrun.log: tests/mdemo-unst.log tests/mdemo-unst.log: tests/mdemo-inst.log tests/mdemo-inst.log: tests/mdemo-exec.log tests/mdemo-exec.log: tests/mdemo-make.log tests/mdemo-make.log: tests/mdemo-conf.log tests/mdemo-conf.log: | tests/mdemo-static-unst.log tests/mdemo-static-unst.log: tests/mdemo-static-inst.log tests/mdemo-static-inst.log: tests/mdemo-static-exec.log tests/mdemo-static-exec.log: tests/mdemo-static-make.log tests/mdemo-static-make.log: tests/mdemo-static.log tests/mdemo2-exec.log: tests/mdemo2-make.log tests/mdemo2-make.log: tests/mdemo2-conf.log \ tests/mdemo-dryrun.log tests/pdemo-inst.log: tests/pdemo-exec.log tests/pdemo-exec.log: tests/pdemo-make.log tests/pdemo-make.log: tests/pdemo-conf.log # The defs script shouldn't be recreated whenever the Makefile is # regenerated since the source tree can be read-only. check-recursive: tests/defs tests/defs: $(srcdir)/tests/defs.in rm -f tests/defs.tmp tests/defs; \ $(configure_edit) $(srcdir)/tests/defs.in > tests/defs.tmp; \ mv -f tests/defs.tmp tests/defs # Use `$(srcdir)/tests' for the benefit of non-GNU makes: this is # how defs.in appears in our dependencies. $(srcdir)/tests/defs.in: $(auxdir)/general.m4sh tests/defs.m4sh Makefile.am cd $(srcdir); \ rm -f tests/defs.in; \ $(M4SH) -B $(auxdir) tests/defs.m4sh > tests/defs.in # We need to remove any files that the above tests created. clean-local-legacy: -for dir in $(CONF_SUBDIRS); do \ if test -f $$dir/Makefile; then \ (cd $$dir && $(MAKE) $(AM_MAKEFLAGS) distclean); \ else :; fi; \ done rm -rf _inst _inst-* $(distclean_recursive): fake-distclean-legacy .PHONY: fake-distclean-legacy fake-distclean-legacy: -for dir in $(CONF_SUBDIRS); do \ if test ! -f $$dir/Makefile; then \ $(mkinstalldirs) $$dir; \ echo 'distclean: ; rm -f Makefile' > $$dir/Makefile; \ else :; fi; \ done $(TESTS): tests/defs # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. .NOEXPORT:
Distrotech/libtool
Makefile
Makefile
gpl-2.0
119,331
#include <iomanip> #include <iostream> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); int n, p_i; cin >> n; double total = 0.0; for (size_t i = 0; i < n; i++) { cin >> p_i; total += p_i; } cout << setprecision(12) << fixed << (total / n) << endl; }
emanuelsaringan/codeforces
Drinks/main.cc
C++
gpl-2.0
314
<?php /** * @package SP Page Builder * @author JoomShaper http://www.joomshaper.com * @copyright Copyright (c) 2010 - 2016 JoomShaper * @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPLv2 or later */ //no direct accees defined ('_JEXEC') or die ('restricted access'); class SppagebuilderAddonTab extends SppagebuilderAddons { public function render() { $class = (isset($this->addon->settings->class) && $this->addon->settings->class) ? $this->addon->settings->class : ''; $style = (isset($this->addon->settings->style) && $this->addon->settings->style) ? $this->addon->settings->style : ''; $title = (isset($this->addon->settings->title) && $this->addon->settings->title) ? $this->addon->settings->title : ''; $heading_selector = (isset($this->addon->settings->heading_selector) && $this->addon->settings->heading_selector) ? $this->addon->settings->heading_selector : 'h3'; //Output $output = '<div class="sppb-addon sppb-addon-tab ' . $class . '">'; $output .= ($title) ? '<'.$heading_selector.' class="sppb-addon-title">' . $title . '</'.$heading_selector.'>' : ''; $output .= '<div class="sppb-addon-content sppb-tab">'; //Tab Title $output .='<ul class="sppb-nav sppb-nav-' . $style . '">'; foreach ($this->addon->settings->sp_tab_item as $key => $tab) { $title = (isset($tab->icon) && $tab->icon) ? '<i class="fa ' . $tab->icon . '"></i> ' . $tab->title : $tab->title; $output .='<li class="'. ( ($key==0) ? "active" : "").'"><a data-toggle="sppb-tab" href="#sppb-tab-'. ($this->addon->id + $key) .'">'. $title .'</a></li>'; } $output .='</ul>'; //Tab Contnet $output .='<div class="sppb-tab-content sppb-nav-' . $style . '-content">'; foreach ($this->addon->settings->sp_tab_item as $key => $tab) { $output .='<div id="sppb-tab-'. ($this->addon->id + $key) .'" class="sppb-tab-pane sppb-fade'. ( ($key==0) ? " active in" : "").'">' . $tab->content .'</div>'; } $output .='</div>'; $output .= '</div>'; $output .= '</div>'; return $output; } public function css() { $addon_id = '#sppb-addon-' . $this->addon->id; $tab_style = (isset($this->addon->settings->style) && $this->addon->settings->style) ? $this->addon->settings->style : ''; $style = (isset($this->addon->settings->active_tab_color) && $this->addon->settings->active_tab_color) ? 'color: ' . $this->addon->settings->active_tab_color . ';': ''; $css = ''; if($tab_style == 'pills') { $style .= (isset($this->addon->settings->active_tab_bg) && $this->addon->settings->active_tab_bg) ? 'background-color: ' . $this->addon->settings->active_tab_bg . ';': ''; if($style) { $css .= $addon_id . ' .sppb-nav-pills > li.active > a,' . $addon_id . ' .sppb-nav-pills > li.active > a:hover,' . $addon_id . ' .sppb-nav-pills > li.active > a:focus {'; $css .= $style; $css .= '}'; } } else if ($tab_style == 'lines') { $style .= (isset($this->addon->settings->active_tab_bg) && $this->addon->settings->active_tab_bg) ? 'border-bottom-color: ' . $this->addon->settings->active_tab_bg . ';': ''; if($style) { $css .= $addon_id . ' .sppb-nav-lines > li.active > a,' . $addon_id . ' .sppb-nav-lines > li.active > a:hover,' . $addon_id . ' .sppb-nav-lines > li.active > a:focus {'; $css .= $style; $css .= '}'; } } return $css; } }
hoangyen201201/TrienLamOnline
components/com_sppagebuilder/addons/tab/site.php
PHP
gpl-2.0
3,318
/* Copyright (C) 1997-2001 Id Software, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include "g_local.h" #ifdef IML_Q2_EXTENSIONS #include <stdio.h> #include "binmsg.h" #endif // IML_Q2_EXTENSIONS void InitTrigger (edict_t *self) { if (!VectorCompare (self->s.angles, vec3_origin)) G_SetMovedir (self->s.angles, self->movedir); self->solid = SOLID_TRIGGER; self->movetype = MOVETYPE_NONE; gi.setmodel (self, self->model); self->svflags = SVF_NOCLIENT; } // the wait time has passed, so set back up for another activation void multi_wait (edict_t *ent) { ent->nextthink = 0; } // the trigger was just activated // ent->activator should be set to the activator so it can be held through a delay // so wait for the delay time before firing void multi_trigger (edict_t *ent) { if (ent->nextthink) return; // already been triggered G_UseTargets (ent, ent->activator); if (ent->wait > 0) { ent->think = multi_wait; ent->nextthink = level.time + ent->wait; } else { // we can't just remove (self) here, because this is a touch function // called while looping through area links... ent->touch = NULL; ent->nextthink = level.time + FRAMETIME; ent->think = G_FreeEdict; } } void Use_Multi (edict_t *ent, edict_t *other, edict_t *activator) { ent->activator = activator; multi_trigger (ent); } void Touch_Multi (edict_t *self, edict_t *other, cplane_t *plane, csurface_t *surf) { if(other->client) { if (self->spawnflags & 2) return; } else if (other->svflags & SVF_MONSTER) { if (!(self->spawnflags & 1)) return; } else return; if (!VectorCompare(self->movedir, vec3_origin)) { vec3_t forward; AngleVectors(other->s.angles, forward, NULL, NULL); if (_DotProduct(forward, self->movedir) < 0) return; } self->activator = other; multi_trigger (self); } /*QUAKED trigger_multiple (.5 .5 .5) ? MONSTER NOT_PLAYER TRIGGERED Variable sized repeatable trigger. Must be targeted at one or more entities. If "delay" is set, the trigger waits some time after activating before firing. "wait" : Seconds between triggerings. (.2 default) sounds 1) secret 2) beep beep 3) large switch 4) set "message" to text string */ void trigger_enable (edict_t *self, edict_t *other, edict_t *activator) { self->solid = SOLID_TRIGGER; self->use = Use_Multi; gi.linkentity (self); } void SP_trigger_multiple (edict_t *ent) { if (ent->sounds == 1) ent->noise_index = gi.soundindex ("misc/secret.wav"); else if (ent->sounds == 2) ent->noise_index = gi.soundindex ("misc/talk.wav"); else if (ent->sounds == 3) ent->noise_index = gi.soundindex ("misc/trigger1.wav"); if (!ent->wait) ent->wait = 0.2; ent->touch = Touch_Multi; ent->movetype = MOVETYPE_NONE; ent->svflags |= SVF_NOCLIENT; if (ent->spawnflags & 4) { ent->solid = SOLID_NOT; ent->use = trigger_enable; } else { ent->solid = SOLID_TRIGGER; ent->use = Use_Multi; } if (!VectorCompare(ent->s.angles, vec3_origin)) G_SetMovedir (ent->s.angles, ent->movedir); gi.setmodel (ent, ent->model); gi.linkentity (ent); } /*QUAKED trigger_once (.5 .5 .5) ? x x TRIGGERED Triggers once, then removes itself. You must set the key "target" to the name of another object in the level that has a matching "targetname". If TRIGGERED, this trigger must be triggered before it is live. sounds 1) secret 2) beep beep 3) large switch 4) "message" string to be displayed when triggered */ void SP_trigger_once(edict_t *ent) { // make old maps work because I messed up on flag assignments here // triggered was on bit 1 when it should have been on bit 4 if (ent->spawnflags & 1) { vec3_t v; VectorMA (ent->mins, 0.5, ent->size, v); ent->spawnflags &= ~1; ent->spawnflags |= 4; gi.dprintf("fixed TRIGGERED flag on %s at %s\n", ent->classname, vtos(v)); } ent->wait = -1; SP_trigger_multiple (ent); } /*QUAKED trigger_relay (.5 .5 .5) (-8 -8 -8) (8 8 8) This fixed size trigger cannot be touched, it can only be fired by other events. */ void trigger_relay_use (edict_t *self, edict_t *other, edict_t *activator) { G_UseTargets (self, activator); } void SP_trigger_relay (edict_t *self) { self->use = trigger_relay_use; } /* ============================================================================== trigger_key ============================================================================== */ /*QUAKED trigger_key (.5 .5 .5) (-8 -8 -8) (8 8 8) A relay trigger that only fires it's targets if player has the proper key. Use "item" to specify the required key, for example "key_data_cd" */ void trigger_key_use (edict_t *self, edict_t *other, edict_t *activator) { int index; if (!self->item) return; if (!activator->client) return; index = ITEM_INDEX(self->item); if (!activator->client->pers.inventory[index]) { if (level.time < self->touch_debounce_time) return; self->touch_debounce_time = level.time + 5.0; gi.centerprintf (activator, "You need the %s", self->item->pickup_name); gi.sound (activator, CHAN_AUTO, gi.soundindex ("misc/keytry.wav"), 1, ATTN_NORM, 0); return; } gi.sound (activator, CHAN_AUTO, gi.soundindex ("misc/keyuse.wav"), 1, ATTN_NORM, 0); if (coop->value) { int player; edict_t *ent; if (strcmp(self->item->classname, "key_power_cube") == 0) { int cube; for (cube = 0; cube < 8; cube++) if (activator->client->pers.power_cubes & (1 << cube)) break; for (player = 1; player <= game.maxclients; player++) { ent = &g_edicts[player]; if (!ent->inuse) continue; if (!ent->client) continue; if (ent->client->pers.power_cubes & (1 << cube)) { ent->client->pers.inventory[index]--; ent->client->pers.power_cubes &= ~(1 << cube); } } } else { for (player = 1; player <= game.maxclients; player++) { ent = &g_edicts[player]; if (!ent->inuse) continue; if (!ent->client) continue; ent->client->pers.inventory[index] = 0; } } } else { activator->client->pers.inventory[index]--; } G_UseTargets (self, activator); self->use = NULL; } void SP_trigger_key (edict_t *self) { if (!st.item) { gi.dprintf("no key item for trigger_key at %s\n", vtos(self->s.origin)); return; } self->item = FindItemByClassname (st.item); if (!self->item) { gi.dprintf("item %s not found for trigger_key at %s\n", st.item, vtos(self->s.origin)); return; } if (!self->target) { gi.dprintf("%s at %s has no target\n", self->classname, vtos(self->s.origin)); return; } gi.soundindex ("misc/keytry.wav"); gi.soundindex ("misc/keyuse.wav"); self->use = trigger_key_use; } /* ============================================================================== trigger_counter ============================================================================== */ /*QUAKED trigger_counter (.5 .5 .5) ? nomessage Acts as an intermediary for an action that takes multiple inputs. If nomessage is not set, t will print "1 more.. " etc when triggered and "sequence complete" when finished. After the counter has been triggered "count" times (default 2), it will fire all of it's targets and remove itself. */ void trigger_counter_use(edict_t *self, edict_t *other, edict_t *activator) { if (self->count == 0) return; self->count--; if (self->count) { if (! (self->spawnflags & 1)) { gi.centerprintf(activator, "%i more to go...", self->count); gi.sound (activator, CHAN_AUTO, gi.soundindex ("misc/talk1.wav"), 1, ATTN_NORM, 0); } return; } if (! (self->spawnflags & 1)) { gi.centerprintf(activator, "Sequence completed!"); gi.sound (activator, CHAN_AUTO, gi.soundindex ("misc/talk1.wav"), 1, ATTN_NORM, 0); } self->activator = activator; multi_trigger (self); } void SP_trigger_counter (edict_t *self) { self->wait = -1; if (!self->count) self->count = 2; self->use = trigger_counter_use; } /* ============================================================================== trigger_always ============================================================================== */ /*QUAKED trigger_always (.5 .5 .5) (-8 -8 -8) (8 8 8) This trigger will always fire. It is activated by the world. */ void SP_trigger_always (edict_t *ent) { // we must have some delay to make sure our use targets are present if (ent->delay < 0.2) ent->delay = 0.2; G_UseTargets(ent, ent); } /* ============================================================================== trigger_push ============================================================================== */ #define PUSH_ONCE 1 static int windsound; void trigger_push_touch (edict_t *self, edict_t *other, cplane_t *plane, csurface_t *surf) { if (strcmp(other->classname, "grenade") == 0) { VectorScale (self->movedir, self->speed * 10, other->velocity); } else if (other->health > 0) { VectorScale (self->movedir, self->speed * 10, other->velocity); if (other->client) { // don't take falling damage immediately from this VectorCopy (other->velocity, other->client->oldvelocity); if (other->fly_sound_debounce_time < level.time) { other->fly_sound_debounce_time = level.time + 1.5; gi.sound (other, CHAN_AUTO, windsound, 1, ATTN_NORM, 0); } } } if (self->spawnflags & PUSH_ONCE) G_FreeEdict (self); } /*QUAKED trigger_push (.5 .5 .5) ? PUSH_ONCE Pushes the player "speed" defaults to 1000 */ void SP_trigger_push (edict_t *self) { InitTrigger (self); windsound = gi.soundindex ("misc/windfly.wav"); self->touch = trigger_push_touch; if (!self->speed) self->speed = 1000; gi.linkentity (self); } /* ============================================================================== trigger_hurt ============================================================================== */ /*QUAKED trigger_hurt (.5 .5 .5) ? START_OFF TOGGLE SILENT NO_PROTECTION SLOW Any entity that touches this will be hurt. It does dmg points of damage each server frame SILENT supresses playing the sound SLOW changes the damage rate to once per second NO_PROTECTION *nothing* stops the damage "dmg" default 5 (whole numbers only) */ void hurt_use (edict_t *self, edict_t *other, edict_t *activator) { if (self->solid == SOLID_NOT) self->solid = SOLID_TRIGGER; else self->solid = SOLID_NOT; gi.linkentity (self); if (!(self->spawnflags & 2)) self->use = NULL; } void hurt_touch (edict_t *self, edict_t *other, cplane_t *plane, csurface_t *surf) { int dflags; if (!other->takedamage) return; if (self->timestamp > level.time) return; if (self->spawnflags & 16) self->timestamp = level.time + 1; else self->timestamp = level.time + FRAMETIME; if (!(self->spawnflags & 4)) { if ((level.framenum % 10) == 0) gi.sound (other, CHAN_AUTO, self->noise_index, 1, ATTN_NORM, 0); } if (self->spawnflags & 8) dflags = DAMAGE_NO_PROTECTION; else dflags = 0; T_Damage (other, self, self, vec3_origin, other->s.origin, vec3_origin, self->dmg, self->dmg, dflags, MOD_TRIGGER_HURT); } void SP_trigger_hurt (edict_t *self) { InitTrigger (self); self->noise_index = gi.soundindex ("world/electro.wav"); self->touch = hurt_touch; if (!self->dmg) self->dmg = 5; if (self->spawnflags & 1) self->solid = SOLID_NOT; else self->solid = SOLID_TRIGGER; if (self->spawnflags & 2) self->use = hurt_use; gi.linkentity (self); } /* ============================================================================== trigger_gravity ============================================================================== */ /*QUAKED trigger_gravity (.5 .5 .5) ? Changes the touching entites gravity to the value of "gravity". 1.0 is standard gravity for the level. */ void trigger_gravity_touch (edict_t *self, edict_t *other, cplane_t *plane, csurface_t *surf) { other->gravity = self->gravity; } void SP_trigger_gravity (edict_t *self) { if (st.gravity == 0) { gi.dprintf("trigger_gravity without gravity set at %s\n", vtos(self->s.origin)); G_FreeEdict (self); return; } InitTrigger (self); self->gravity = atoi(st.gravity); self->touch = trigger_gravity_touch; } /* ============================================================================== trigger_monsterjump ============================================================================== */ /*QUAKED trigger_monsterjump (.5 .5 .5) ? Walking monsters that touch this will jump in the direction of the trigger's angle "speed" default to 200, the speed thrown forward "height" default to 200, the speed thrown upwards */ void trigger_monsterjump_touch (edict_t *self, edict_t *other, cplane_t *plane, csurface_t *surf) { if (other->flags & (FL_FLY | FL_SWIM) ) return; if (other->svflags & SVF_DEADMONSTER) return; if ( !(other->svflags & SVF_MONSTER)) return; // set XY even if not on ground, so the jump will clear lips other->velocity[0] = self->movedir[0] * self->speed; other->velocity[1] = self->movedir[1] * self->speed; if (!other->groundentity) return; other->groundentity = NULL; other->velocity[2] = self->movedir[2]; } void SP_trigger_monsterjump (edict_t *self) { if (!self->speed) self->speed = 200; if (!st.height) st.height = 200; if (self->s.angles[YAW] == 0) self->s.angles[YAW] = 360; InitTrigger (self); self->touch = trigger_monsterjump_touch; self->movedir[2] = st.height; } /* ============================================================================== trigger_region ============================================================================== */ #ifdef IML_Q2_EXTENSIONS static void AddRegion(edict_t *player, edict_t *region) { int i; for (i = 0; i < MAX_REGIONS; i++) { if (player->client->in_regions[i] == region) { break; } else if (player->client->in_regions[i] == NULL) { player->client->in_regions[i] = region; break; } } } void trigger_region_touch (edict_t *self, edict_t *other, cplane_t *plane, csurface_t *surf) { if (other->client) AddRegion(other, self); } void SP_trigger_region (edict_t *self) { InitTrigger (self); self->touch = &trigger_region_touch; } static qboolean EntityInList (edict_t *ent, edict_t **list, size_t items) { int i; for (i = 0; i < items; i++) if (list[i] == ent) return true; return false; } static void SendBinMsg_InRegion(edict_t *player, char *region_name, qboolean is_in_region) { char key[MAX_STRING_CHARS]; binmsg_byte buffer[BINMSG_MAX_SIZE]; binmsg_message msg; // Format our key name. _snprintf(key, sizeof(key), "in-region?/%s", region_name); key[MAX_STRING_CHARS-1] = '\0'; // Build and send the message. if (!binmsg_build(&msg, buffer, BINMSG_MAX_SIZE, "state")) return; if (!binmsg_add_string(&msg.args, key)) return; if (!binmsg_add_bool(&msg.args, is_in_region)) return; if (!binmsg_build_done(&msg)) return; SendBinMsg(player, msg.buffer, msg.buffer_size); } static void ExitRegion (edict_t *player, edict_t *region) { if (region->region_name) SendBinMsg_InRegion(player, region->region_name, false); if (region->exit_target) G_UseTargetsByName(region, region->exit_target, player); } static void EnterRegion (edict_t *player, edict_t *region) { if (region->region_name) SendBinMsg_InRegion(player, region->region_name, true); if (region->enter_target) G_UseTargetsByName(region, region->enter_target, player); } void CheckRegions (edict_t *player) { int i; // Send exit messages. for (i = 0; i < MAX_REGIONS; i++) if (!EntityInList(player->client->in_regions_old[i], player->client->in_regions, MAX_REGIONS)) ExitRegion(player, player->client->in_regions_old[i]); // Send enter messages. for (i = 0; i < MAX_REGIONS; i++) if (!EntityInList(player->client->in_regions[i], player->client->in_regions_old, MAX_REGIONS)) EnterRegion(player, player->client->in_regions[i]); // Move in_regions to in_regions_old and clear in_regions. memcpy(player->client->in_regions_old, player->client->in_regions, sizeof(edict_t*) * MAX_REGIONS); memset(player->client->in_regions, 0, sizeof(edict_t*) * MAX_REGIONS); } #endif // IML_Q2_EXTENSIONS
lambda/wxQuake2
game/g_trigger.c
C
gpl-2.0
17,071
#include "capwap.h" #include "capwap_element.h" /******************************************************************** 0 1 2 3 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Radio ID | MAC Address | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | MAC Address | QoS Sub-Element... | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 0 1 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Reserved|8021p|RSV| DSCP Tag | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ Type: 1043 for IEEE 802.11 Update Station QoS Length: 14 ********************************************************************/ /* */ static void capwap_80211_updatestationqos_element_create(void* data, capwap_message_elements_handle handle, struct capwap_write_message_elements_ops* func) { int i; struct capwap_80211_updatestationqos_element* element = (struct capwap_80211_updatestationqos_element*)data; ASSERT(data != NULL); func->write_u8(handle, element->radioid); func->write_block(handle, element->address, MACADDRESS_EUI48_LENGTH); for (i = 0; i < CAPWAP_UPDATE_STATION_QOS_SUBELEMENTS; i++) { func->write_u8(handle, element->qos[i].priority8021p & CAPWAP_UPDATE_STATION_QOS_PRIORIY_MASK); func->write_u8(handle, element->qos[i].dscp & CAPWAP_UPDATE_STATION_QOS_DSCP_MASK); } } /* */ static void* capwap_80211_updatestationqos_element_parsing(capwap_message_elements_handle handle, struct capwap_read_message_elements_ops* func) { int i; struct capwap_80211_updatestationqos_element* data; ASSERT(handle != NULL); ASSERT(func != NULL); if (func->read_ready(handle) != 14) { capwap_logging_debug("Invalid IEEE 802.11 Update Station QoS element"); return NULL; } /* */ data = (struct capwap_80211_updatestationqos_element*)capwap_alloc(sizeof(struct capwap_80211_updatestationqos_element)); memset(data, 0, sizeof(struct capwap_80211_updatestationqos_element)); /* Retrieve data */ func->read_u8(handle, &data->radioid); func->read_block(handle, data->address, MACADDRESS_EUI48_LENGTH); for (i = 0; i < CAPWAP_UPDATE_STATION_QOS_SUBELEMENTS; i++) { func->read_u8(handle, &data->qos[i].priority8021p); data->qos[i].priority8021p &= CAPWAP_UPDATE_STATION_QOS_PRIORIY_MASK; func->read_u8(handle, &data->qos[i].dscp); data->qos[i].dscp &= CAPWAP_UPDATE_STATION_QOS_DSCP_MASK; } return data; } /* */ static void* capwap_80211_updatestationqos_element_clone(void* data) { ASSERT(data != NULL); return capwap_clone(data, sizeof(struct capwap_80211_updatestationqos_element)); } /* */ static void capwap_80211_updatestationqos_element_free(void* data) { ASSERT(data != NULL); capwap_free(data); } /* */ struct capwap_message_elements_ops capwap_element_80211_updatestationqos_ops = { .create_message_element = capwap_80211_updatestationqos_element_create, .parsing_message_element = capwap_80211_updatestationqos_element_parsing, .clone_message_element = capwap_80211_updatestationqos_element_clone, .free_message_element = capwap_80211_updatestationqos_element_free };
alagoutte/smartcapwap
src/common/capwap_element_80211_updatestationqos.c
C
gpl-2.0
3,276
/* * This file is part of Libav. * * Libav is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * Libav is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with Libav; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ /** * @file * null audio source */ #include <inttypes.h> #include <stdio.h> #include "libavutil/channel_layout.h" #include "libavutil/internal.h" #include "avfilter.h" #include "internal.h" static int request_frame(AVFilterLink *link) { return AVERROR_EOF; } static const AVFilterPad avfilter_asrc_anullsrc_outputs[] = { { .name = "default", .type = AVMEDIA_TYPE_AUDIO, .request_frame = request_frame, }, { NULL } }; AVFilter avfilter_asrc_anullsrc = { .name = "anullsrc", .description = NULL_IF_CONFIG_SMALL("Null audio source, never return audio frames."), .inputs = NULL, .outputs = avfilter_asrc_anullsrc_outputs, };
DDTChen/CookieVLC
vlc/contrib/android/ffmpeg/libavfilter/asrc_anullsrc.c
C
gpl-2.0
1,481
var ajaxManager = (function() { $jq = jQuery.noConflict(); var requests = []; return { addReq: function(opt) { requests.push(opt); }, removeReq: function(opt) { if($jq.inArray(opt, requests) > -1) { requests.splice($jq.inArray(opt, requests), 1); } }, run: function() { var self = this, orgSuc; if(requests.length) { oriSuc = requests[0].complete; requests[0].complete = function() { if(typeof oriSuc === 'function') { oriSuc(); } requests.shift(); self.run.apply(self, []); }; $jq.ajax(requests[0]); } else { self.tid = setTimeout(function() { self.run.apply(self, []); }, 1000); } }, stop: function() { requests = []; clearTimeout(this.tid); } }; }()); ajaxManager.run(); (function($){ $(document).ready(function(){ $('.purAddToCart, .purAddToCartImage').click(function() { $(this).attr('disabled', 'disabled'); }) $('.Cart66AjaxWarning').hide(); // Added to remove error on double-click when add to cart is clicked $('.purAddToCart, .purAddToCartImage').click(function() { $(this).attr('disabled', 'disabled'); }) $('.ajax-button').click(function() { $(this).attr('disabled', true); var id = $(this).attr('id').replace('addToCart_', ''); $('#task_' + id).val('ajax'); var product = C66.products[id]; if(C66.trackInventory) { inventoryCheck(id, C66.ajaxurl, product.ajax, product.name, product.returnUrl, product.addingText); } else { if(product.ajax === 'no') { $('#task_' + id).val('addToCart'); $('#cartButtonForm_' + id).submit(); return false; } else if(product.ajax === 'yes' || product.ajax === 'true') { buttonTransform(id, C66.ajaxurl, product.name, product.returnUrl, product.addingText); } } return false; }); $('.modalClose').click(function() { $('.Cart66Unavailable, .Cart66Warning, .Cart66Error, .alert-message').fadeOut(800); }); $('#Cart66CancelPayPalSubscription').click(function() { return confirm('Are you sure you want to cancel your subscription?\n'); }); var original_methods = $('#shipping_method_id').html(); var selected_country = $('#shipping_country_code').val(); $('.methods-country').each(function() { if(!$(this).hasClass(selected_country) && !$(this).hasClass('all-countries') && !$(this).hasClass('select')) { $(this).remove(); } }); $('#shipping_country_code').change(function() { var selected_country = $(this).val(); $('#shipping_method_id').html(original_methods); $('.methods-country').each(function() { if(!$(this).hasClass(selected_country) && !$(this).hasClass('all-countries') && !$(this).hasClass('select')) { $(this).remove(); } }); $("#shipping_method_id option:eq(1)").attr('selected','selected').change(); }); $('#shipping_method_id').change(function() { $('#Cart66CartForm').submit(); }); $('#live_rates').change(function() { $('#Cart66CartForm').submit(); }); $('.showEntriesLink').click(function() { var panel = $(this).attr('rel'); $('#' + panel).toggle(); return false; }); $('#change_shipping_zip_link').click(function() { $('#set_shipping_zip_row').toggle(); return false; }); }) })(jQuery); function getCartButtonFormData(formId) { $jq = jQuery.noConflict(); var theForm = $jq('#' + formId); var str = ''; $jq('input:not([type=checkbox], :radio), input[type=checkbox]:checked, input:radio:checked, select, textarea', theForm).each( function() { var name = $jq(this).attr('name'); var val = $jq(this).val(); str += name + '=' + encodeURIComponent(val) + '&'; } ); return str.substring(0, str.length-1); } function inventoryCheck(formId, ajaxurl, useAjax, productName, productUrl, addingText) { $jq = jQuery.noConflict(); var mydata = getCartButtonFormData('cartButtonForm_' + formId); ajaxManager.addReq({ type: "POST", url: ajaxurl + '=1', data: mydata, dataType: 'json', success: function(response) { if(response[0]) { $jq('#task_' + formId).val('addToCart'); if(useAjax == 'no') { $jq('#cartButtonForm_' + formId).submit(); } else { buttonTransform(formId, ajaxurl, productName, productUrl, addingText); } } else { $jq('.modalClose').show(); $jq('#stock_message_box_' + formId).fadeIn(300); $jq('#stock_message_' + formId).html(response[1]); $jq('#addToCart_' + formId).removeAttr('disabled'); } }, error: function(xhr,err){ alert("readyState: "+xhr.readyState+"\nstatus: "+xhr.status); } }); } function addToCartAjax(formId, ajaxurl, productName, productUrl, buttonText) { $jq = jQuery.noConflict(); var options1 = $jq('#cartButtonForm_' + formId + ' .cart66Options.options_1').val(); var options2 = $jq('#cartButtonForm_' + formId + ' .cart66Options.options_2').val(); var itemQuantity = $jq('#Cart66UserQuantityInput_' + formId).val(); var itemUserPrice = $jq('#Cart66UserPriceInput_' + formId).val(); var cleanProductId = formId.split('_'); cleanProductId = cleanProductId[0]; var data = { cart66ItemId: cleanProductId, itemName: productName, options_1: options1, options_2: options2, item_quantity: itemQuantity, item_user_price: itemUserPrice, product_url: productUrl }; ajaxManager.addReq({ type: "POST", url: ajaxurl + '=2', data: data, dataType: 'json', success: function(response) { $jq('#addToCart_' + formId).removeAttr('disabled'); $jq('#addToCart_' + formId).removeClass('ajaxPurAddToCart'); $jq('#addToCart_' + formId).val(buttonText); $jq.hookExecute('addToCartAjaxHook', response); ajaxUpdateCartWidgets(ajaxurl); if($jq('.customAjaxAddToCartMessage').length > 0) { $jq('.customAjaxAddToCartMessage').show().html(response.msg); $jq.hookExecute('customAjaxAddToCartMessage', response); } else { if((response.msgId) == 0){ $jq('.success_' + formId).fadeIn(300); $jq('.success_message_' + formId).html(response.msg); if(typeof response.msgHeader !== 'undefined') { $jq('.success' + formId + ' .message-header').html(response.msgHeader); } $jq('.success_' + formId).delay(2000).fadeOut(300); } if((response.msgId) == -1){ $jq('.warning_' + formId).fadeIn(300); $jq('.warning_message_' + formId).html(response.msg); if(typeof response.msgHeader !== 'undefined') { $jq('.warning' + formId + ' .message-header').html(response.msgHeader); } } if((response.msgId) == -2){ $jq('.error_' + formId).fadeIn(300); $jq('.error_message_' + formId).html(response.msg); if(typeof response.msgHeader !== 'undefined') { $jq('.error_' + formId + ' .message-header').html(response.msgHeader); } } } } }) } function buttonTransform(formId, ajaxurl, productName, productUrl, addingText) { $jq = jQuery.noConflict(); var buttonText = $jq('#addToCart_' + formId).val(); $jq('#addToCart_' + formId).attr('disabled', 'disabled'); $jq('#addToCart_' + formId).addClass('ajaxPurAddToCart'); $jq('#addToCart_' + formId).val(addingText); addToCartAjax(formId, ajaxurl, productName, productUrl, buttonText); } function ajaxUpdateCartWidgets(ajaxurl) { $jq = jQuery.noConflict(); var widgetId = $jq('.Cart66CartWidget').attr('id'); var data = { action: "ajax_cart_elements" }; ajaxManager.addReq({ type: "POST", url: ajaxurl + '=3', data: data, dataType: 'json', success: function(response) { $jq.hookExecute('cartElementsAjaxHook', response); $jq('#Cart66AdvancedSidebarAjax, #Cart66WidgetCartContents').show(); $jq('.Cart66WidgetViewCartCheckoutEmpty, #Cart66WidgetCartEmpty').hide(); $jq('#Cart66WidgetCartLink').each(function(){ widgetContent = "<span id=\"Cart66WidgetCartCount\">" + response.summary.count + "</span>"; widgetContent += "<span id=\"Cart66WidgetCartCountText\">" + response.summary.items + "</span>"; widgetContent += "<span id=\"Cart66WidgetCartCountDash\"> – </span>" widgetContent += "<span id=\"Cart66WidgetCartPrice\">" + response.summary.amount + "</span>"; $jq(this).html(widgetContent).fadeIn('slow'); }); $jq('.Cart66RequireShipping').each(function(){ if(response.shipping == 1) { $jq(this).show(); } }) $jq('#Cart66WidgetCartEmptyAdvanced').each(function(){ widgetContent = C66.youHave + ' ' + response.summary.count + " " + response.summary.items + " (" + response.summary.amount + ") " + C66.inYourShoppingCart; $jq(this).html(widgetContent).fadeIn('slow'); }); $jq("#Cart66AdvancedWidgetCartTable .product_items").remove(); $jq.each(response.products.reverse(), function(index, array){ widgetContent = "<tr class=\"product_items\"><td>"; widgetContent += "<span class=\"Cart66ProductTitle\">" + array.productName + "</span>"; widgetContent += "<span class=\"Cart66QuanPrice\">"; widgetContent += "<span class=\"Cart66ProductQuantity\">" + array.productQuantity + "</span>"; widgetContent += "<span class=\"Cart66MetaSep\"> x </span>"; widgetContent += "<span class=\"Cart66ProductPrice\">" + array.productPrice + "</span>"; widgetContent += "</span>"; widgetContent += "</td><td class=\"Cart66ProductSubtotalColumn\">"; widgetContent += "<span class=\"Cart66ProductSubtotal\">" + array.productSubtotal + "</span>"; widgetContent += "</td></tr>"; $jq("#Cart66AdvancedWidgetCartTable tbody").prepend(widgetContent).fadeIn("slow"); }); $jq('.Cart66Subtotal').each(function(){ $jq(this).html(response.subtotal) }); $jq('.Cart66Shipping').each(function(){ $jq(this).html(response.shippingAmount) }); } }) } jQuery.extend({ hookExecute: function (function_name, response){ if (typeof window[function_name] == "function"){ window[function_name](response); return true; } else{ return false; } } });
rbredow/allyzabbacart
js/cart66-library.js
JavaScript
gpl-2.0
10,666
<?php session_start(); ob_start(); include ('connect.php'); if(($_SESSION['LOGIN'] == "NO") or (!$_SESSION['LOGIN'])) header('Location: index.php'); function cssifysize($img) { $dimensions = getimagesize($img); $dimensions = str_replace("=\"", ":", $dimensions['3']); $dimensions = str_replace("\"", "px;", $dimensions); return $dimensions; }; ?> <br /><br /><a href="index.php">RETURN</a><br /><br /> <form action="image_folder.php" method="POST" enctype="multipart/form-data"> <p> Image Name: <input type="text" name="name_image"> </p> <p>Locate Image: <input type="file" name="userfile" id="file"></p> <p><input type="submit" value="Upload"></p> </form> <br /><br /> <?php if(($_POST['name_image'])){ $nameimg = $_POST['name_image']; $uploaddir = 'img/'; $uploadfile = $uploaddir . $nameimg; //basename($_FILES['userfile']['name']); if (move_uploaded_file($_FILES['userfile']['tmp_name'], $uploadfile)) { $query=mysql_query("INSERT INTO IMG_NEWSLETTER (NAME_IMG, DELETED) VALUES ('$nameimg', 'NO') ") or die (mysql_error()) ; if($query) header('Location: image_folder?img_upload=success'); } else { echo "<br />Upload failed<br /><br />"; } }; $query=mysql_query("SELECT * FROM IMG_NEWSLETTER WHERE DELETED LIKE 'NO' ") or die (mysql_error()); $count = 0; while($array=mysql_fetch_array($query)){ $count++; ?> <?php $img = "img/".$array['NAME_IMG']; ?> <p><b>Real Size:</b> <?php echo cssifysize($img); ?></p> <p><b>Display below:</b> width:200px; height:150px; </p> <p><a href="<?php echo "img/".$array['NAME_IMG']; ?>" target="_blank" ><img src="<?php echo "img/".$array['NAME_IMG']; ?>" width="200" height="150"></a></p><p><b><font size="+2"> <?php echo $array['NAME_IMG']; ?></b></font><input type="button" value="DELETE" onClick="javascript: document.location.href = 'delimg.php?idimg=<?php echo $array['ID_IMG_NEWSLETTER']; ?>';" /></p> <br />-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=<br /> <?php }; if($count == 0 ) echo "No image found."; if($_GET['delete']) echo "<br />The Image has been deleted successfully."; if($_GET['img_upload']) echo "<br />The Image has been uploaded successfully."; ?> <br /><br /><a href="index.php">RETURN</a><br /><br />
somalitaekwondo/site
newsletter/image_folder.php
PHP
gpl-2.0
2,323
#include <stdio.h> #include <stdlib.h> #include <assert.h> #include <errno.h> #include <iostream> #include "ftfilemapper.h" //#define DEBUG_FILEMAPPER ftFileMapper::ftFileMapper(uint64_t file_size,uint32_t chunk_size) : _file_size(file_size),_chunk_size(chunk_size) { int nb_chunks = (int)(file_size / (uint64_t)chunk_size) + ( (file_size % chunk_size)==0 ?0:1 ) ; #ifdef DEBUG_FILEMAPPER std::cerr << "(DD) Creating ftFileMapper for file of size " << file_size << ", with " << nb_chunks << " chunks." << std::endl; #endif _first_free_chunk = 0 ; _mapped_chunks.clear() ; _mapped_chunks.resize(nb_chunks,-1) ; _data_chunks.clear() ; _data_chunks.resize(nb_chunks,-1) ; } bool ftFileMapper::computeStorageOffset(uint64_t offset,uint64_t& storage_offset) const { // Compute the chunk number for this offset // uint32_t cid = (uint32_t)(offset / (uint64_t)_chunk_size) ; // Check that the cid is in the allowed range. That should always be the case. // if(cid < _mapped_chunks.size() && _mapped_chunks[cid] >= 0) { storage_offset = _mapped_chunks[cid]*_chunk_size + (offset % (uint64_t)_chunk_size) ; return true ; } else { #ifdef DEBUG_FILEMAPPER std::cerr << "(DD) ftFileMapper::computeStorageOffset(): offset " << offset << " corresponds to chunk number " << cid << " which is not mapped!!" << std::endl; #endif return false ; } } bool ftFileMapper::writeData(uint64_t offset,uint32_t size,void *data,FILE *fd) const { if (0 != fseeko64(fd, offset, SEEK_SET)) { std::cerr << "(EE) ftFileMapper::ftFileMapper::writeData() Bad fseek at offset " << offset << ", fd=" << (void*)fd << ", size=" << size << ", errno=" << errno << std::endl; return false; } if (1 != fwrite(data, size, 1, fd)) { std::cerr << "(EE) ftFileMapper::ftFileCreator::addFileData() Bad fwrite." << std::endl; std::cerr << "ERRNO: " << errno << std::endl; return false; } fflush(fd) ; return true ; } bool ftFileMapper::storeData(void *data, uint32_t data_size, uint64_t offset,FILE *fd) { uint64_t real_offset = 0; #ifdef DEBUG_FILEMAPPER std::cerr << "(DD) ftFileMapper::storeData(): storing data size " << data_size << " for offset "<< offset << std::endl; #endif // we compute the real place of the data in the mapped file. Several cases: // // 1 - the place corresponds to a mapped place // => write there. // 2 - the place does not correspond to a mapped place. // 2.0 - we allocate a new chunk at the end of the file. // 2.0.1 - the chunk corresponds to a mapped chunk somewhere before // => we move it, and use the other chunk as writing position // 2.0.2 - the chunk does not correspond to a mapped chunk somewhere before // => we use it // 2.1 - the place is in the range of existing data // => we move the existing data at the end of the file, and update the mapping // 2.2 - the place is outside the range of existing data // => we allocate a new chunk at the end of the file, and write there. // 2.2.1 - we look for the first chunk that is not already mapped before. // if(!computeStorageOffset(offset,real_offset)) { uint32_t cid = (uint32_t)(offset / (uint64_t)_chunk_size) ; #ifdef DEBUG_FILEMAPPER std::cerr << "(DD) real offset unknown. chunk id is " << cid << std::endl; #endif uint32_t empty_chunk = allocateNewEmptyChunk(fd) ; #ifdef DEBUG_FILEMAPPER std::cerr << "(DD) allocated new empty chunk " << empty_chunk << std::endl; #endif if(cid < _first_free_chunk && cid != empty_chunk) // the place is already occupied by some data { #ifdef DEBUG_FILEMAPPER std::cerr << "(DD) chunk already in use. " << std::endl; std::cerr << "(DD) swapping with first free chunk: " << empty_chunk << std::endl; #endif if(!moveChunk(cid, empty_chunk,fd)) { std::cerr << "(EE) ftFileMapper::writeData(): cannot move chunk " << empty_chunk << " and " << cid << std::endl ; return false ; } // Get the old chunk id that was mapping to this place // int oid = _data_chunks[cid] ; if(oid < 0) { std::cerr << "(EE) ftFileMapper::writeData(): cannot find chunk that was previously mapped to place " << cid << std::endl ; return false ; } #ifdef DEBUG_FILEMAPPER std::cerr << "(DD) old chunk now pointing to: " << empty_chunk << std::endl; std::cerr << "(DD) new chunk now pointing to: " << cid << std::endl; #endif _mapped_chunks[cid] = cid ; // this one is in place, since we swapped it _mapped_chunks[oid] = empty_chunk ; _data_chunks[cid] = cid ; _data_chunks[empty_chunk] = oid ; } else // allocate a new chunk at end of the file. { #ifdef DEBUG_FILEMAPPER std::cerr << "(DD) allocating new storage place at first free chunk: " << empty_chunk << std::endl; #endif _mapped_chunks[cid] = empty_chunk ; _data_chunks[empty_chunk] = cid ; } real_offset = _mapped_chunks[cid]*_chunk_size + (offset % (uint64_t)_chunk_size) ; } #ifdef DEBUG_FILEMAPPER std::cerr << "(DD) real offset = " << real_offset << ", data size=" << data_size << std::endl; std::cerr << "(DD) writing data " << std::endl; #endif return writeData(real_offset,data_size,data,fd) ; } uint32_t ftFileMapper::allocateNewEmptyChunk(FILE *fd_out) { // look into _first_free_chunk. Is it the place of a chunk already mapped before? // #ifdef DEBUG_FILEMAPPER std::cerr << "(DD) ftFileMapper::getFirstEmptyChunk()" << std::endl; #endif if(_mapped_chunks[_first_free_chunk] >= 0 && _mapped_chunks[_first_free_chunk] < (int)_first_free_chunk) { uint32_t old_chunk = _mapped_chunks[_first_free_chunk] ; #ifdef DEBUG_FILEMAPPER std::cerr << "(DD) first free chunk " << _first_free_chunk << " is actually mapped to " << old_chunk << ". Moving it." << std::endl; #endif moveChunk(_mapped_chunks[_first_free_chunk],_first_free_chunk,fd_out) ; _mapped_chunks[_first_free_chunk] = _first_free_chunk ; _data_chunks[_first_free_chunk] = _first_free_chunk ; _first_free_chunk++ ; #ifdef DEBUG_FILEMAPPER std::cerr << "(DD) Returning " << old_chunk << std::endl; #endif return old_chunk ; } else { #ifdef DEBUG_FILEMAPPER std::cerr << "(DD) first free chunk is fine. Returning " << _first_free_chunk << ", and making room" << std::endl; #endif // We need to wipe the entire chunk, since it might be moved before beign completely written, which would cause // a fread error. // wipeChunk(_first_free_chunk,fd_out) ; return _first_free_chunk++ ; } } bool ftFileMapper::wipeChunk(uint32_t cid,FILE *fd) const { uint32_t size = (cid == _mapped_chunks.size()-1)?(_file_size - cid*_chunk_size) : _chunk_size ; void *buf = malloc(size) ; if(buf == NULL) { std::cerr << "(EE) ftFileMapper::wipeChunk(): cannot allocate temporary buf of size " << size << std::endl; return false ; } if(fseeko64(fd, cid*_chunk_size, SEEK_SET)!= 0) { std::cerr << "(EE) ftFileMapper::wipeChunk(): cannot fseek file at position " << cid*_chunk_size << std::endl; free(buf) ; return false ; } if(1 != fwrite(buf, size, 1, fd)) { std::cerr << "(EE) ftFileMapper::wipeChunk(): cannot write to file" << std::endl; free(buf) ; return false ; } free(buf) ; return true ; } bool ftFileMapper::moveChunk(uint32_t to_move, uint32_t new_place,FILE *fd_out) { // Read the old chunk, write at the new place assert(to_move != new_place) ; fflush(fd_out) ; #ifdef DEBUG_FILEMAPPER std::cerr << "(DD) ftFileMapper::moveChunk(): moving chunk " << to_move << " to place " << new_place << std::endl ; #endif uint32_t new_place_size = (new_place == _mapped_chunks.size()-1)?(_file_size - (_mapped_chunks.size()-1)*_chunk_size) : _chunk_size ; uint32_t to_move_size = (new_place == _mapped_chunks.size()-1)?(_file_size - (_mapped_chunks.size()-1)*_chunk_size) : _chunk_size ; uint32_t size = std::min(new_place_size,to_move_size) ; void *buff = malloc(size) ; if(buff == NULL) { std::cerr << "(EE) ftFileMapper::moveChunk(): cannot open temporary buffer. Out of memory??" << std::endl; return false ; } if(fseeko64(fd_out, to_move*_chunk_size, SEEK_SET) != 0) { std::cerr << "(EE) ftFileMapper::moveChunk(): cannot fseek file at position " << to_move*_chunk_size << std::endl; return false ; } size_t rd ; if(size != (rd = fread(buff, 1, size, fd_out))) { std::cerr << "(EE) ftFileMapper::moveChunk(): cannot read from file" << std::endl; std::cerr << "(EE) errno = " << errno << std::endl; std::cerr << "(EE) feof = " << feof(fd_out) << std::endl; std::cerr << "(EE) size = " << size << std::endl; std::cerr << "(EE) rd = " << rd << std::endl; return false ; } if(fseeko64(fd_out, new_place*_chunk_size, SEEK_SET)!= 0) { std::cerr << "(EE) ftFileMapper::moveChunk(): cannot fseek file at position " << new_place*_chunk_size << std::endl; return false ; } if(1 != fwrite(buff, size, 1, fd_out)) { std::cerr << "(EE) ftFileMapper::moveChunk(): cannot write to file" << std::endl; return false ; } free(buff) ; return true ; } void ftFileMapper::print() const { std::cerr << "ftFileMapper:: [ " ; for(uint32_t i=0;i<_mapped_chunks.size();++i) { std::cerr << _mapped_chunks[i] << " " ; } std::cerr << "] - ffc = " << _first_free_chunk << " - [ "; for(uint32_t i=0;i<_data_chunks.size();++i) std::cerr << _data_chunks[i] << " " ; std::cerr << " ] " << std::endl; }
RedCraig/retroshare
libretroshare/src/ft/ftfilemapper.cc
C++
gpl-2.0
9,367
# Endpoints for user to control the home. from datetime import datetime from flask import Blueprint, jsonify, request from services import elements_services, home_services home_api = Blueprint('/home_api', __name__) elements_services = elements_services.ElementsServices() home_services = home_services.HomeServices() @home_api.route('/profiles') def profiles(): """Gets all profiles for all elements for user application to display and manipulate elements""" return jsonify(home_services.get_profiles()) @home_api.route('/element', methods=['POST']) def update_element(): """Updates single element with all new values received from the user application""" received_element = request.get_json() home_services.update_element(received_element) return 'OK' @home_api.route('/elements', methods=['POST']) def update_elements(): """Updates all elements with all new values received from the user application""" received_elements = request.get_json() home_services.update_elements(received_elements) return 'OK' @home_api.route('/elementdelete', methods=['POST']) def delete_element(): """Deletes a single element with given hid""" element = request.get_json() home_services.delete_element(element['hid']) return 'OK' @home_api.route('/timerules', methods=['POST']) def timerules(): """Adds, Updates or deletes time rule for the given element""" rules = request.get_json() if len(rules) == 0: raise Exception("No elements in the list") for rule in rules: if 'id' not in rule: rule['id'] = None home_services.save_time_rules(rules) return 'OK' @home_api.route('/timerules/<string:hid>') def get_timerules(hid): """Gets list of timerules for given hid""" timerules= home_services.read_time_rules(hid) return jsonify(timerules)
igrlas/CentralHub
CHPackage/src/centralhub/server/home_endpoints.py
Python
gpl-2.0
1,856
#include "stdafx.h" #include "Utilities/Log.h" #include "Utilities/File.h" #include "git-version.h" #include "rpcs3/Ini.h" #include "Emu/Memory/Memory.h" #include "Emu/System.h" #include "Emu/GameInfo.h" #include "Emu/SysCalls/ModuleManager.h" #include "Emu/Cell/PPUThread.h" #include "Emu/Cell/SPUThread.h" #include "Emu/Cell/PPUInstrTable.h" #include "Emu/FS/vfsFile.h" #include "Emu/FS/vfsLocalFile.h" #include "Emu/FS/vfsDeviceLocalFile.h" #include "Emu/DbgCommand.h" #include "Emu/CPU/CPUThreadManager.h" #include "Emu/SysCalls/Callback.h" #include "Emu/IdManager.h" #include "Emu/Io/Pad.h" #include "Emu/Io/Keyboard.h" #include "Emu/Io/Mouse.h" #include "Emu/RSX/GSManager.h" #include "Emu/Audio/AudioManager.h" #include "Emu/FS/VFS.h" #include "Emu/Event.h" #include "Loader/PSF.h" #include "Loader/ELF64.h" #include "Loader/ELF32.h" #include "../Crypto/unself.h" #include <fstream> using namespace PPU_instr; static const std::string& BreakPointsDBName = "BreakPoints.dat"; static const u16 bpdb_version = 0x1000; extern std::atomic<u32> g_thread_count; extern u64 get_system_time(); extern void finalize_psv_modules(); Emulator::Emulator() : m_status(Stopped) , m_mode(DisAsm) , m_rsx_callback(0) , m_thread_manager(new CPUThreadManager()) , m_pad_manager(new PadManager()) , m_keyboard_manager(new KeyboardManager()) , m_mouse_manager(new MouseManager()) , m_gs_manager(new GSManager()) , m_audio_manager(new AudioManager()) , m_callback_manager(new CallbackManager()) , m_event_manager(new EventManager()) , m_module_manager(new ModuleManager()) , m_vfs(new VFS()) { m_loader.register_handler(new loader::handlers::elf32); m_loader.register_handler(new loader::handlers::elf64); } Emulator::~Emulator() { } void Emulator::Init() { } void Emulator::SetPath(const std::string& path, const std::string& elf_path) { m_path = path; m_elf_path = elf_path; } void Emulator::SetTitleID(const std::string& id) { m_title_id = id; } void Emulator::SetTitle(const std::string& title) { m_title = title; } bool Emulator::BootGame(const std::string& path, bool direct) { static const char* elf_path[6] = { "/PS3_GAME/USRDIR/BOOT.BIN", "/USRDIR/BOOT.BIN", "/BOOT.BIN", "/PS3_GAME/USRDIR/EBOOT.BIN", "/USRDIR/EBOOT.BIN", "/EBOOT.BIN" }; auto curpath = path; if (direct) { if (fs::is_file(curpath)) { SetPath(curpath); Load(); return true; } } for (int i = 0; i < sizeof(elf_path) / sizeof(*elf_path); i++) { curpath = path + elf_path[i]; if (fs::is_file(curpath)) { SetPath(curpath); Load(); return true; } } return false; } void Emulator::Load() { m_status = Ready; GetModuleManager().Init(); if (!fs::is_file(m_path)) { m_status = Stopped; return; } const std::string elf_dir = m_path.substr(0, m_path.find_last_of("/\\", std::string::npos, 2) + 1); if (IsSelf(m_path)) { const std::string full_name = m_path.substr(elf_dir.length()); const std::string base_name = full_name.substr(0, full_name.find_last_of('.', std::string::npos)); const std::string ext = full_name.substr(base_name.length()); if (fmt::toupper(full_name) == "EBOOT.BIN") { m_path = elf_dir + "BOOT.BIN"; } else if (fmt::toupper(ext) == ".SELF") { m_path = elf_dir + base_name + ".elf"; } else if (fmt::toupper(ext) == ".SPRX") { m_path = elf_dir + base_name + ".prx"; } else { m_path = elf_dir + base_name + ".decrypted" + ext; } LOG_NOTICE(LOADER, "Decrypting '%s%s'...", elf_dir, full_name); if (!DecryptSelf(m_path, elf_dir + full_name)) { m_status = Stopped; return; } } LOG_NOTICE(LOADER, "Loading '%s'...", m_path.c_str()); ResetInfo(); GetVFS().Init(elf_dir); // /dev_bdvd/ mounting vfsFile f("/app_home/../dev_bdvd.path"); if (f.IsOpened()) { // load specified /dev_bdvd/ directory and mount it std::string bdvd; bdvd.resize(f.GetSize()); f.Read(&bdvd[0], bdvd.size()); Emu.GetVFS().Mount("/dev_bdvd/", bdvd, new vfsDeviceLocalFile()); } else if (fs::is_file(elf_dir + "../../PS3_DISC.SFB")) // guess loading disc game { const auto dir_list = fmt::split(elf_dir, { "/", "\\" }); // check latest two directories if (dir_list.size() >= 2 && dir_list.back() == "USRDIR" && *(dir_list.end() - 2) == "PS3_GAME") { // mount detected /dev_bdvd/ directory Emu.GetVFS().Mount("/dev_bdvd/", elf_dir.substr(0, elf_dir.length() - 17), new vfsDeviceLocalFile()); } } LOG_NOTICE(LOADER, ""); LOG_NOTICE(LOADER, "Mount info:"); for (uint i = 0; i < GetVFS().m_devices.size(); ++i) { LOG_NOTICE(LOADER, "%s -> %s", GetVFS().m_devices[i]->GetPs3Path().c_str(), GetVFS().m_devices[i]->GetLocalPath().c_str()); } LOG_NOTICE(LOADER, ""); LOG_NOTICE(LOADER, "RPCS3 version: %s", RPCS3_GIT_VERSION); LOG_NOTICE(LOADER, ""); LOG_NOTICE(LOADER, "Settings:"); LOG_NOTICE(LOADER, "CPU: %s", Ini.CPUIdToString(Ini.CPUDecoderMode.GetValue())); LOG_NOTICE(LOADER, "SPU: %s", Ini.SPUIdToString(Ini.SPUDecoderMode.GetValue())); LOG_NOTICE(LOADER, "Renderer: %s", Ini.RendererIdToString(Ini.GSRenderMode.GetValue())); if (Ini.GSRenderMode.GetValue() == 2) { LOG_NOTICE(LOADER, "D3D Adapter: %s", Ini.AdapterIdToString(Ini.GSD3DAdaptater.GetValue())); } LOG_NOTICE(LOADER, "Resolution: %s", Ini.ResolutionIdToString(Ini.GSResolution.GetValue())); LOG_NOTICE(LOADER, "Write Depth Buffer: %s", Ini.GSDumpDepthBuffer.GetValue() ? "Yes" : "No"); LOG_NOTICE(LOADER, "Write Color Buffers: %s", Ini.GSDumpColorBuffers.GetValue() ? "Yes" : "No"); LOG_NOTICE(LOADER, "Read Color Buffer: %s", Ini.GSReadColorBuffer.GetValue() ? "Yes" : "No"); LOG_NOTICE(LOADER, "Audio Out: %s", Ini.AudioOutIdToString(Ini.AudioOutMode.GetValue())); LOG_NOTICE(LOADER, "Log Everything: %s", Ini.HLELogging.GetValue() ? "Yes" : "No"); LOG_NOTICE(LOADER, "RSX Logging: %s", Ini.RSXLogging.GetValue() ? "Yes" : "No"); LOG_NOTICE(LOADER, ""); f.Open("/app_home/../PARAM.SFO"); const PSFLoader psf(f); std::string title = psf.GetString("TITLE"); std::string title_id = psf.GetString("TITLE_ID"); LOG_NOTICE(LOADER, "Title: %s", title.c_str()); LOG_NOTICE(LOADER, "Serial: %s", title_id.c_str()); title.length() ? SetTitle(title) : SetTitle(m_path); SetTitleID(title_id); if (m_elf_path.empty()) { GetVFS().GetDeviceLocal(m_path, m_elf_path); LOG_NOTICE(LOADER, "Elf path: %s", m_elf_path); LOG_NOTICE(LOADER, ""); } f.Open(m_elf_path); if (!f.IsOpened()) { LOG_ERROR(LOADER, "Opening '%s' failed", m_path.c_str()); m_status = Stopped; return; } if (!m_loader.load(f)) { LOG_ERROR(LOADER, "Loading '%s' failed", m_path.c_str()); LOG_NOTICE(LOADER, ""); m_status = Stopped; vm::close(); return; } LoadPoints(BreakPointsDBName); GetGSManager().Init(); GetCallbackManager().Init(); GetAudioManager().Init(); GetEventManager().Init(); SendDbgCommand(DID_READY_EMU); } void Emulator::Run() { if (!IsReady()) { Load(); if(!IsReady()) return; } if (IsRunning()) Stop(); if (IsPaused()) { Resume(); return; } SendDbgCommand(DID_START_EMU); m_pause_start_time = 0; m_pause_amend_time = 0; m_status = Running; GetCPU().Exec(); SendDbgCommand(DID_STARTED_EMU); } void Emulator::Pause() { const u64 start = get_system_time(); // try to set Paused status if (!sync_bool_compare_and_swap(&m_status, Running, Paused)) { return; } // update pause start time if (m_pause_start_time.exchange(start)) { LOG_ERROR(GENERAL, "Emulator::Pause() error: concurrent access"); } SendDbgCommand(DID_PAUSE_EMU); for (auto& t : GetCPU().GetAllThreads()) { t->sleep(); // trigger status check } SendDbgCommand(DID_PAUSED_EMU); } void Emulator::Resume() { // get pause start time const u64 time = m_pause_start_time.exchange(0); // try to increment summary pause time if (time) { m_pause_amend_time += get_system_time() - time; } // try to resume if (!sync_bool_compare_and_swap(&m_status, Paused, Running)) { return; } if (!time) { LOG_ERROR(GENERAL, "Emulator::Resume() error: concurrent access"); } SendDbgCommand(DID_RESUME_EMU); for (auto& t : GetCPU().GetAllThreads()) { t->awake(); // untrigger status check and signal } SendDbgCommand(DID_RESUMED_EMU); } extern std::map<u32, std::string> g_armv7_dump; void Emulator::Stop() { LOG_NOTICE(GENERAL, "Stopping emulator..."); if (sync_lock_test_and_set(&m_status, Stopped) == Stopped) { return; } SendDbgCommand(DID_STOP_EMU); { LV2_LOCK; // notify all threads for (auto& t : GetCPU().GetAllThreads()) { std::lock_guard<std::mutex> lock(t->mutex); t->sleep(); // trigger status check t->cv.notify_one(); // signal } } LOG_NOTICE(GENERAL, "All threads signaled..."); while (g_thread_count) { std::this_thread::sleep_for(std::chrono::milliseconds(1)); } LOG_NOTICE(GENERAL, "All threads stopped..."); idm::clear(); fxm::clear(); LOG_NOTICE(GENERAL, "Objects cleared..."); finalize_psv_modules(); for (auto& v : decltype(g_armv7_dump)(std::move(g_armv7_dump))) { LOG_NOTICE(ARMv7, v.second); } m_rsx_callback = 0; // TODO: check finalization order SavePoints(BreakPointsDBName); m_break_points.clear(); m_marked_points.clear(); GetVFS().UnMountAll(); GetGSManager().Close(); GetAudioManager().Close(); GetEventManager().Clear(); GetCPU().Close(); GetPadManager().Close(); GetKeyboardManager().Close(); GetMouseManager().Close(); GetCallbackManager().Clear(); GetModuleManager().Close(); CurGameInfo.Reset(); RSXIOMem.Clear(); vm::close(); SendDbgCommand(DID_STOPPED_EMU); } void Emulator::SavePoints(const std::string& path) { std::ofstream f(path, std::ios::binary | std::ios::trunc); u32 break_count = (u32)m_break_points.size(); u32 marked_count = (u32)m_marked_points.size(); f.write((char*)(&bpdb_version), sizeof(bpdb_version)); f.write((char*)(&break_count), sizeof(break_count)); f.write((char*)(&marked_count), sizeof(marked_count)); if (break_count) { f.write((char*)(m_break_points.data()), sizeof(u64) * break_count); } if (marked_count) { f.write((char*)(m_marked_points.data()), sizeof(u64) * marked_count); } } bool Emulator::LoadPoints(const std::string& path) { if (!fs::is_file(path)) return false; std::ifstream f(path, std::ios::binary); if (!f.is_open()) return false; f.seekg(0, std::ios::end); u64 length = (u64)f.tellg(); f.seekg(0, std::ios::beg); u16 version; u32 break_count, marked_count; u64 expected_length = sizeof(bpdb_version) + sizeof(break_count) + sizeof(marked_count); if (length < expected_length) { LOG_ERROR(LOADER, "'%s' breakpoint db is broken (file is too short, length=0x%x)", path, length); return false; } f.read((char*)(&version), sizeof(version)); if (version != bpdb_version) { LOG_ERROR(LOADER, "'%s' breakpoint db version is unsupported (version=0x%x, length=0x%x)", path, version, length); return false; } f.read((char*)(&break_count), sizeof(break_count)); f.read((char*)(&marked_count), sizeof(marked_count)); expected_length += break_count * sizeof(u64) + marked_count * sizeof(u64); if (expected_length != length) { LOG_ERROR(LOADER, "'%s' breakpoint db format is incorrect " "(version=0x%x, break_count=0x%x, marked_count=0x%x, length=0x%x)", path, version, break_count, marked_count, length); return false; } if (break_count > 0) { m_break_points.resize(break_count); f.read((char*)(m_break_points.data()), sizeof(u64) * break_count); } if (marked_count > 0) { m_marked_points.resize(marked_count); f.read((char*)(m_marked_points.data()), sizeof(u64) * marked_count); } return true; } Emulator Emu; CallAfterCbType CallAfterCallback = nullptr; void CallAfter(std::function<void()> func) { CallAfterCallback(func); } void SetCallAfterCallback(CallAfterCbType cb) { CallAfterCallback = cb; }
thatguyehler/rpcs3
rpcs3/Emu/System.cpp
C++
gpl-2.0
11,861
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <html><head> <meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1"/> <meta name="keywords" content="TEMU, dynamic analysis, binary analysis, dynamic taint analysis"/> <meta name="description" content="C/C++/OCaml Source Code Documentation for the TEMU Project."/> <title>TEMU: xed-encoder-hl.h Source File</title> <link href="doxygen.css" rel="stylesheet" type="text/css"/> </head><body> <p class="title">TEMU: Dynamic Binary Analysis Platform</p> <!-- Generated by Doxygen 1.5.8 --> <div class="navigation" id="top"> <div class="tabs"> <ul> <li><a href="index.html"><span>Main&nbsp;Page</span></a></li> <li><a href="modules.html"><span>Modules</span></a></li> <li><a href="annotated.html"><span>Data&nbsp;Structures</span></a></li> <li class="current"><a href="files.html"><span>Files</span></a></li> <li><a href="dirs.html"><span>Directories</span></a></li> <li> <form action="search.php" method="get"> <table cellspacing="0" cellpadding="0" border="0"> <tr> <td><label>&nbsp;<u>S</u>earch&nbsp;for&nbsp;</label></td> <td><input type="text" name="query" value="" size="20" accesskey="s"/></td> </tr> </table> </form> </li> </ul> </div> <div class="tabs"> <ul> <li><a href="files.html"><span>File&nbsp;List</span></a></li> <li><a href="globals.html"><span>Globals</span></a></li> </ul> </div> <div class="navpath"><a class="el" href="dir_4f22f3fd3d3cce94a331ff7cdf0bf085.html">temu-1.0</a>&nbsp;&raquo&nbsp;<a class="el" href="dir_3b6767f6be6ef802b0654406f3e74d86.html">shared</a>&nbsp;&raquo&nbsp;<a class="el" href="dir_0277bd4601ee6c31034924754cae7495.html">xed2</a>&nbsp;&raquo&nbsp;<a class="el" href="dir_05e0ad34a2706acb4f73624c38c2a107.html">xed2-ia32</a>&nbsp;&raquo&nbsp;<a class="el" href="dir_f86fba19af9dbb3e8d51a2bdea785276.html">include</a> </div> </div> <div class="contents"> <h1>xed2-ia32/include/xed-encoder-hl.h</h1><a href="xed2-ia32_2include_2xed-encoder-hl_8h.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">/*BEGIN_LEGAL </span> <a name="l00002"></a>00002 <span class="comment">Intel Open Source License </span> <a name="l00003"></a>00003 <span class="comment"></span> <a name="l00004"></a>00004 <span class="comment">Copyright (c) 2002-2008 Intel Corporation </span> <a name="l00005"></a>00005 <span class="comment">All rights reserved. </span> <a name="l00006"></a>00006 <span class="comment">Redistribution and use in source and binary forms, with or without</span> <a name="l00007"></a>00007 <span class="comment">modification, are permitted provided that the following conditions are</span> <a name="l00008"></a>00008 <span class="comment">met:</span> <a name="l00009"></a>00009 <span class="comment"></span> <a name="l00010"></a>00010 <span class="comment">Redistributions of source code must retain the above copyright notice,</span> <a name="l00011"></a>00011 <span class="comment">this list of conditions and the following disclaimer. Redistributions</span> <a name="l00012"></a>00012 <span class="comment">in binary form must reproduce the above copyright notice, this list of</span> <a name="l00013"></a>00013 <span class="comment">conditions and the following disclaimer in the documentation and/or</span> <a name="l00014"></a>00014 <span class="comment">other materials provided with the distribution. Neither the name of</span> <a name="l00015"></a>00015 <span class="comment">the Intel Corporation nor the names of its contributors may be used to</span> <a name="l00016"></a>00016 <span class="comment">endorse or promote products derived from this software without</span> <a name="l00017"></a>00017 <span class="comment">specific prior written permission.</span> <a name="l00018"></a>00018 <span class="comment"> </span> <a name="l00019"></a>00019 <span class="comment">THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS</span> <a name="l00020"></a>00020 <span class="comment">``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT</span> <a name="l00021"></a>00021 <span class="comment">LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR</span> <a name="l00022"></a>00022 <span class="comment">A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE INTEL OR</span> <a name="l00023"></a>00023 <span class="comment">ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,</span> <a name="l00024"></a>00024 <span class="comment">SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT</span> <a name="l00025"></a>00025 <span class="comment">LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,</span> <a name="l00026"></a>00026 <span class="comment">DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY</span> <a name="l00027"></a>00027 <span class="comment">THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT</span> <a name="l00028"></a>00028 <span class="comment">(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE</span> <a name="l00029"></a>00029 <span class="comment">OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.</span> <a name="l00030"></a>00030 <span class="comment">END_LEGAL */</span> <a name="l00031"></a>00031 <a name="l00032"></a>00032 <span class="preprocessor">#ifndef _XED_ENCODER_HL_H_</span> <a name="l00033"></a>00033 <span class="preprocessor"></span><span class="preprocessor"># define _XED_ENCODER_HL_H_</span> <a name="l00034"></a>00034 <span class="preprocessor"></span><span class="preprocessor">#include "xed-types.h"</span> <a name="l00035"></a>00035 <span class="preprocessor">#include "xed-reg-enum.h"</span> <a name="l00036"></a>00036 <span class="preprocessor">#include "xed-state.h"</span> <a name="l00037"></a>00037 <span class="preprocessor">#include "xed-iclass-enum.h"</span> <a name="l00038"></a>00038 <span class="preprocessor">#include "xed-portability.h"</span> <a name="l00039"></a>00039 <span class="preprocessor">#include "xed-encode.h"</span> <a name="l00040"></a>00040 <a name="l00041"></a>00041 <a name="l00042"></a><a class="code" href="structxed__enc__displacement__t.html">00042</a> <span class="keyword">typedef</span> <span class="keyword">struct </span>{ <a name="l00043"></a><a class="code" href="structxed__enc__displacement__t.html#c983d8e2ceacd11fce421ac110c65bd8">00043</a> xed_uint64_t displacement; <a name="l00044"></a><a class="code" href="structxed__enc__displacement__t.html#3fd0ffc7c9929f49bfc795fe01bf1798">00044</a> xed_uint32_t displacement_width; <a name="l00045"></a>00045 } <a class="code" href="structxed__enc__displacement__t.html">xed_enc_displacement_t</a>; <span class="comment">/* fixme bad name */</span> <a name="l00046"></a>00046 <span class="comment"></span> <a name="l00047"></a>00047 <span class="comment">/// @name Memory Displacement</span> <a name="l00048"></a>00048 <span class="comment"></span><span class="comment">//@{</span> <a name="l00049"></a>00049 <span class="comment"></span><span class="comment">/// @ingroup ENCHL</span> <a name="l00050"></a>00050 <span class="comment"></span><span class="comment">/// a memory displacement (not for branches)</span> <a name="l00051"></a><a class="code" href="xed2-ia32_2include_2xed-encoder-hl_8h.html#c8a806e9c0ba578adcb5aa2ee7cdb394">00051</a> <span class="comment"></span>XED_INLINE <span class="keyword">static</span> <a class="code" href="structxed__enc__displacement__t.html">xed_enc_displacement_t</a> <a class="code" href="xed2-ia32_2include_2xed-encoder-hl_8h.html#c8a806e9c0ba578adcb5aa2ee7cdb394">xdisp</a>(xed_uint64_t displacement, <a name="l00052"></a>00052 xed_uint32_t displacement_width ) { <a name="l00053"></a>00053 <a class="code" href="structxed__enc__displacement__t.html">xed_enc_displacement_t</a> x; <a name="l00054"></a>00054 x.<a class="code" href="structxed__enc__displacement__t.html#c983d8e2ceacd11fce421ac110c65bd8">displacement</a> = displacement; <a name="l00055"></a>00055 x.<a class="code" href="structxed__enc__displacement__t.html#3fd0ffc7c9929f49bfc795fe01bf1798">displacement_width</a> = displacement_width; <a name="l00056"></a>00056 <span class="keywordflow">return</span> x; <a name="l00057"></a>00057 }<span class="comment"></span> <a name="l00058"></a>00058 <span class="comment">//@}</span> <a name="l00059"></a>00059 <span class="comment"></span> <a name="l00060"></a><a class="code" href="structxed__memop__t.html">00060</a> <span class="keyword">typedef</span> <span class="keyword">struct </span>{ <a name="l00061"></a><a class="code" href="structxed__memop__t.html#d07ef1ac72ff572e65e78b3653c43c1d">00061</a> <a class="code" href="xed2-ia32_2include_2xed-reg-enum_8h.html#f05c33c5a68e9304d1d8ac0408ae3f61">xed_reg_enum_t</a> seg; <a name="l00062"></a><a class="code" href="structxed__memop__t.html#b33f5fd03ddbc01a1795e85978b32c61">00062</a> <a class="code" href="xed2-ia32_2include_2xed-reg-enum_8h.html#f05c33c5a68e9304d1d8ac0408ae3f61">xed_reg_enum_t</a> base; <a name="l00063"></a><a class="code" href="structxed__memop__t.html#451ae2fcc3acdff8a10543b18f19f84e">00063</a> <a class="code" href="xed2-ia32_2include_2xed-reg-enum_8h.html#f05c33c5a68e9304d1d8ac0408ae3f61">xed_reg_enum_t</a> index; <a name="l00064"></a><a class="code" href="structxed__memop__t.html#d801bcd3961aa78d30caaca98489dd36">00064</a> xed_uint32_t scale; <a name="l00065"></a><a class="code" href="structxed__memop__t.html#1fd26bd97ff3565101e7e79ccf1d5a53">00065</a> <a class="code" href="structxed__enc__displacement__t.html">xed_enc_displacement_t</a> disp; <a name="l00066"></a>00066 } <a class="code" href="structxed__memop__t.html">xed_memop_t</a>; <a name="l00067"></a>00067 <a name="l00068"></a>00068 <a name="l00069"></a><a class="code" href="xed2-ia32_2include_2xed-encoder-hl_8h.html#7621255aeac26b5e78f7a0dc72d12638">00069</a> <span class="keyword">typedef</span> <span class="keyword">enum</span> { <a name="l00070"></a><a class="code" href="xed2-ia32_2include_2xed-encoder-hl_8h.html#7621255aeac26b5e78f7a0dc72d12638cbc8d93653c02e76eac8d019f449d88b">00070</a> <a class="code" href="xed2-ia32_2include_2xed-encoder-hl_8h.html#7621255aeac26b5e78f7a0dc72d12638cbc8d93653c02e76eac8d019f449d88b">XED_ENCODER_OPERAND_TYPE_INVALID</a>, <a name="l00071"></a><a class="code" href="xed2-ia32_2include_2xed-encoder-hl_8h.html#7621255aeac26b5e78f7a0dc72d126383bea84e3495457e582cd5533b3b67b43">00071</a> <a class="code" href="xed2-ia32_2include_2xed-encoder-hl_8h.html#7621255aeac26b5e78f7a0dc72d126383bea84e3495457e582cd5533b3b67b43">XED_ENCODER_OPERAND_TYPE_BRDISP</a>, <a name="l00072"></a><a class="code" href="xed2-ia32_2include_2xed-encoder-hl_8h.html#7621255aeac26b5e78f7a0dc72d12638c7e137bec55ec1ebaf1b3269cbf8d35b">00072</a> <a class="code" href="xed2-ia32_2include_2xed-encoder-hl_8h.html#7621255aeac26b5e78f7a0dc72d12638c7e137bec55ec1ebaf1b3269cbf8d35b">XED_ENCODER_OPERAND_TYPE_REG</a>, <a name="l00073"></a><a class="code" href="xed2-ia32_2include_2xed-encoder-hl_8h.html#7621255aeac26b5e78f7a0dc72d12638ec1aab94e9a39cad7281722d72f4c074">00073</a> <a class="code" href="xed2-ia32_2include_2xed-encoder-hl_8h.html#7621255aeac26b5e78f7a0dc72d12638ec1aab94e9a39cad7281722d72f4c074">XED_ENCODER_OPERAND_TYPE_IMM0</a>, <a name="l00074"></a><a class="code" href="xed2-ia32_2include_2xed-encoder-hl_8h.html#7621255aeac26b5e78f7a0dc72d126386010b70490d8deb87248988db4851991">00074</a> <a class="code" href="xed2-ia32_2include_2xed-encoder-hl_8h.html#7621255aeac26b5e78f7a0dc72d126386010b70490d8deb87248988db4851991">XED_ENCODER_OPERAND_TYPE_SIMM0</a>, <a name="l00075"></a><a class="code" href="xed2-ia32_2include_2xed-encoder-hl_8h.html#7621255aeac26b5e78f7a0dc72d1263839d2ecbd06732c86c9be27e5697513e4">00075</a> <a class="code" href="xed2-ia32_2include_2xed-encoder-hl_8h.html#7621255aeac26b5e78f7a0dc72d1263839d2ecbd06732c86c9be27e5697513e4">XED_ENCODER_OPERAND_TYPE_IMM1</a>, <a name="l00076"></a><a class="code" href="xed2-ia32_2include_2xed-encoder-hl_8h.html#7621255aeac26b5e78f7a0dc72d12638fb6bee5a0fcf154e71397defed76ed88">00076</a> <a class="code" href="xed2-ia32_2include_2xed-encoder-hl_8h.html#7621255aeac26b5e78f7a0dc72d12638fb6bee5a0fcf154e71397defed76ed88">XED_ENCODER_OPERAND_TYPE_MEM</a>, <a name="l00077"></a><a class="code" href="xed2-ia32_2include_2xed-encoder-hl_8h.html#7621255aeac26b5e78f7a0dc72d12638617ca23d3a043d05c07435199e768b88">00077</a> <a class="code" href="xed2-ia32_2include_2xed-encoder-hl_8h.html#7621255aeac26b5e78f7a0dc72d12638617ca23d3a043d05c07435199e768b88">XED_ENCODER_OPERAND_TYPE_PTR</a>, <a name="l00078"></a><a class="code" href="xed2-ia32_2include_2xed-encoder-hl_8h.html#7621255aeac26b5e78f7a0dc72d126385a7a43348b1552de102211c4d76ca72d">00078</a> <a class="code" href="xed2-ia32_2include_2xed-encoder-hl_8h.html#7621255aeac26b5e78f7a0dc72d126385a7a43348b1552de102211c4d76ca72d">XED_ENCODER_OPERAND_TYPE_SEG0</a>, <span class="comment">/* special for things with suppressed implicit memops */</span> <a name="l00079"></a><a class="code" href="xed2-ia32_2include_2xed-encoder-hl_8h.html#7621255aeac26b5e78f7a0dc72d12638acd0df30646ec7115ac403e2dc7bf2ff">00079</a> <a class="code" href="xed2-ia32_2include_2xed-encoder-hl_8h.html#7621255aeac26b5e78f7a0dc72d12638acd0df30646ec7115ac403e2dc7bf2ff">XED_ENCODER_OPERAND_TYPE_SEG1</a>, <span class="comment">/* special for things with suppressed implicit memops */</span> <a name="l00080"></a><a class="code" href="xed2-ia32_2include_2xed-encoder-hl_8h.html#7621255aeac26b5e78f7a0dc72d12638263eeedf98d73a93dd619bc0b2359d79">00080</a> <a class="code" href="xed2-ia32_2include_2xed-encoder-hl_8h.html#7621255aeac26b5e78f7a0dc72d12638263eeedf98d73a93dd619bc0b2359d79">XED_ENCODER_OPERAND_TYPE_OTHER</a> <span class="comment">/* specific operand storage fields -- must supply a name */</span> <a name="l00081"></a>00081 } <a class="code" href="xed2-ia32_2include_2xed-encoder-hl_8h.html#7621255aeac26b5e78f7a0dc72d12638">xed_encoder_operand_type_t</a>; <a name="l00082"></a>00082 <a name="l00083"></a><a class="code" href="structxed__encoder__operand__t.html">00083</a> <span class="keyword">typedef</span> <span class="keyword">struct </span>{ <a name="l00084"></a><a class="code" href="structxed__encoder__operand__t.html#15b522f5fb9447f7bbea3ae6baf328a9">00084</a> <a class="code" href="xed2-ia32_2include_2xed-encoder-hl_8h.html#7621255aeac26b5e78f7a0dc72d12638">xed_encoder_operand_type_t</a> type; <a name="l00085"></a>00085 <span class="keyword">union </span>{ <a name="l00086"></a><a class="code" href="structxed__encoder__operand__t.html#e5eeb0d5e528568c4335f3e1232b1c74">00086</a> <a class="code" href="xed2-ia32_2include_2xed-reg-enum_8h.html#f05c33c5a68e9304d1d8ac0408ae3f61">xed_reg_enum_t</a> reg; <a name="l00087"></a><a class="code" href="structxed__encoder__operand__t.html#248b7401faf495144a60aed3e033de28">00087</a> xed_int32_t brdisp; <a name="l00088"></a><a class="code" href="structxed__encoder__operand__t.html#5dce7d3756139b85189dad3a9156c082">00088</a> xed_uint64_t <a class="code" href="xed2-ia32_2include_2xed-encoder-hl_8h.html#e90462df43d77847591b28317121a7f0">imm0</a>; <a name="l00089"></a><a class="code" href="structxed__encoder__operand__t.html#14f433f92d67d3bed1e912dfaec7478c">00089</a> xed_uint8_t <a class="code" href="xed2-ia32_2include_2xed-encoder-hl_8h.html#c6d077d7c8bd6d603c46554caf4eac8b">imm1</a>; <a name="l00090"></a>00090 <span class="keyword">struct </span>{ <a name="l00091"></a><a class="code" href="structxed__encoder__operand__t.html#82618f4d775f0f34a11ff4374bcb8ce7">00091</a> <a class="code" href="xed2-ia32_2include_2xed-operand-enum_8h.html#09c2a35d8bb7bfe68bb3d34b0a5e011a">xed_operand_enum_t</a> operand_name; <a name="l00092"></a><a class="code" href="structxed__encoder__operand__t.html#676f6026a5ba7d95e2dd4ce2b730a48d">00092</a> xed_uint32_t value; <a name="l00093"></a>00093 } s; <a name="l00094"></a><a class="code" href="structxed__encoder__operand__t.html#7874f7a5284ff2064ba6b9bf032e25ff">00094</a> <a class="code" href="structxed__memop__t.html">xed_memop_t</a> mem; <a name="l00095"></a>00095 } u; <a name="l00096"></a><a class="code" href="structxed__encoder__operand__t.html#ea2d8c884cca697c2dbc9807dfbdd139">00096</a> xed_uint32_t width; <a name="l00097"></a>00097 } <a class="code" href="structxed__encoder__operand__t.html">xed_encoder_operand_t</a>; <a name="l00098"></a>00098 <span class="comment"></span> <a name="l00099"></a>00099 <span class="comment">/// @name Branch Displacement</span> <a name="l00100"></a>00100 <span class="comment"></span><span class="comment">//@{</span> <a name="l00101"></a>00101 <span class="comment"></span><span class="comment">/// @ingroup ENCHL</span> <a name="l00102"></a>00102 <span class="comment"></span><span class="comment">/// a relative branch displacement operand</span> <a name="l00103"></a><a class="code" href="xed2-ia32_2include_2xed-encoder-hl_8h.html#cdb37097d0759178bb58ed9a09def08d">00103</a> <span class="comment"></span>XED_INLINE <span class="keyword">static</span> <a class="code" href="structxed__encoder__operand__t.html">xed_encoder_operand_t</a> <a class="code" href="xed2-ia32_2include_2xed-encoder-hl_8h.html#cdb37097d0759178bb58ed9a09def08d">xrelbr</a>(xed_int32_t brdisp, <a class="code" href="xed2-ia32_2include_2xed-types_8h.html#0c92e8263b7ca02d8e4826ae5b79bb30">xed_uint_t</a> width) { <a name="l00104"></a>00104 <a class="code" href="structxed__encoder__operand__t.html">xed_encoder_operand_t</a> o; <a name="l00105"></a>00105 o.<a class="code" href="structxed__encoder__operand__t.html#15b522f5fb9447f7bbea3ae6baf328a9">type</a> = <a class="code" href="xed2-ia32_2include_2xed-encoder-hl_8h.html#7621255aeac26b5e78f7a0dc72d126383bea84e3495457e582cd5533b3b67b43">XED_ENCODER_OPERAND_TYPE_BRDISP</a>; <a name="l00106"></a>00106 o.<a class="code" href="structxed__encoder__operand__t.html#01d174f19e13511270eefe522bc61248">u</a>.<a class="code" href="structxed__encoder__operand__t.html#248b7401faf495144a60aed3e033de28">brdisp</a> = brdisp; <a name="l00107"></a>00107 o.<a class="code" href="structxed__encoder__operand__t.html#ea2d8c884cca697c2dbc9807dfbdd139">width</a> = width; <a name="l00108"></a>00108 <span class="keywordflow">return</span> o; <a name="l00109"></a>00109 }<span class="comment"></span> <a name="l00110"></a>00110 <span class="comment">//@}</span> <a name="l00111"></a>00111 <span class="comment"></span><span class="comment"></span> <a name="l00112"></a>00112 <span class="comment">/// @name Pointer Displacement</span> <a name="l00113"></a>00113 <span class="comment"></span><span class="comment">//@{</span> <a name="l00114"></a>00114 <span class="comment"></span><span class="comment">/// @ingroup ENCHL</span> <a name="l00115"></a>00115 <span class="comment"></span><span class="comment">/// a relative displacement for a PTR operand -- the subsequent imm0 holds the 16b selector</span> <a name="l00116"></a><a class="code" href="xed2-ia32_2include_2xed-encoder-hl_8h.html#ba429e1d2123dacf780e53c57b743ff6">00116</a> <span class="comment"></span>XED_INLINE <span class="keyword">static</span> <a class="code" href="structxed__encoder__operand__t.html">xed_encoder_operand_t</a> <a class="code" href="xed2-ia32_2include_2xed-encoder-hl_8h.html#ba429e1d2123dacf780e53c57b743ff6">xptr</a>(xed_int32_t brdisp, <a class="code" href="xed2-ia32_2include_2xed-types_8h.html#0c92e8263b7ca02d8e4826ae5b79bb30">xed_uint_t</a> width) { <a name="l00117"></a>00117 <a class="code" href="structxed__encoder__operand__t.html">xed_encoder_operand_t</a> o; <a name="l00118"></a>00118 o.<a class="code" href="structxed__encoder__operand__t.html#15b522f5fb9447f7bbea3ae6baf328a9">type</a> = <a class="code" href="xed2-ia32_2include_2xed-encoder-hl_8h.html#7621255aeac26b5e78f7a0dc72d12638617ca23d3a043d05c07435199e768b88">XED_ENCODER_OPERAND_TYPE_PTR</a>; <a name="l00119"></a>00119 o.<a class="code" href="structxed__encoder__operand__t.html#01d174f19e13511270eefe522bc61248">u</a>.<a class="code" href="structxed__encoder__operand__t.html#248b7401faf495144a60aed3e033de28">brdisp</a> = brdisp; <a name="l00120"></a>00120 o.<a class="code" href="structxed__encoder__operand__t.html#ea2d8c884cca697c2dbc9807dfbdd139">width</a> = width; <a name="l00121"></a>00121 <span class="keywordflow">return</span> o; <a name="l00122"></a>00122 }<span class="comment"></span> <a name="l00123"></a>00123 <span class="comment">//@}</span> <a name="l00124"></a>00124 <span class="comment"></span><span class="comment"></span> <a name="l00125"></a>00125 <span class="comment">/// @name Register and Immmediate Operands</span> <a name="l00126"></a>00126 <span class="comment"></span><span class="comment">//@{</span> <a name="l00127"></a>00127 <span class="comment"></span><span class="comment">/// @ingroup ENCHL</span> <a name="l00128"></a>00128 <span class="comment"></span><span class="comment">/// a register operand</span> <a name="l00129"></a><a class="code" href="xed2-ia32_2include_2xed-encoder-hl_8h.html#3ebdabca7dc139c49b31bcc86635298e">00129</a> <span class="comment"></span>XED_INLINE <span class="keyword">static</span> <a class="code" href="structxed__encoder__operand__t.html">xed_encoder_operand_t</a> <a class="code" href="xed2-ia32_2include_2xed-encoder-hl_8h.html#3ebdabca7dc139c49b31bcc86635298e">xreg</a>(<a class="code" href="xed2-ia32_2include_2xed-reg-enum_8h.html#f05c33c5a68e9304d1d8ac0408ae3f61">xed_reg_enum_t</a> reg) { <a name="l00130"></a>00130 <a class="code" href="structxed__encoder__operand__t.html">xed_encoder_operand_t</a> o; <a name="l00131"></a>00131 o.<a class="code" href="structxed__encoder__operand__t.html#15b522f5fb9447f7bbea3ae6baf328a9">type</a> = <a class="code" href="xed2-ia32_2include_2xed-encoder-hl_8h.html#7621255aeac26b5e78f7a0dc72d12638c7e137bec55ec1ebaf1b3269cbf8d35b">XED_ENCODER_OPERAND_TYPE_REG</a>; <a name="l00132"></a>00132 o.<a class="code" href="structxed__encoder__operand__t.html#01d174f19e13511270eefe522bc61248">u</a>.<a class="code" href="structxed__encoder__operand__t.html#e5eeb0d5e528568c4335f3e1232b1c74">reg</a> = reg; <a name="l00133"></a>00133 o.<a class="code" href="structxed__encoder__operand__t.html#ea2d8c884cca697c2dbc9807dfbdd139">width</a> = 0; <a name="l00134"></a>00134 <span class="keywordflow">return</span> o; <a name="l00135"></a>00135 } <a name="l00136"></a>00136 <span class="comment"></span> <a name="l00137"></a>00137 <span class="comment">/// @ingroup ENCHL</span> <a name="l00138"></a>00138 <span class="comment">/// a first immediate operand (known as IMM0)</span> <a name="l00139"></a><a class="code" href="xed2-ia32_2include_2xed-encoder-hl_8h.html#e90462df43d77847591b28317121a7f0">00139</a> <span class="comment"></span>XED_INLINE <span class="keyword">static</span> <a class="code" href="structxed__encoder__operand__t.html">xed_encoder_operand_t</a> <a class="code" href="xed2-ia32_2include_2xed-encoder-hl_8h.html#e90462df43d77847591b28317121a7f0">imm0</a>(xed_uint64_t v, <a class="code" href="xed2-ia32_2include_2xed-types_8h.html#0c92e8263b7ca02d8e4826ae5b79bb30">xed_uint_t</a> width) { <a name="l00140"></a>00140 <a class="code" href="structxed__encoder__operand__t.html">xed_encoder_operand_t</a> o; <a name="l00141"></a>00141 o.<a class="code" href="structxed__encoder__operand__t.html#15b522f5fb9447f7bbea3ae6baf328a9">type</a> = <a class="code" href="xed2-ia32_2include_2xed-encoder-hl_8h.html#7621255aeac26b5e78f7a0dc72d12638ec1aab94e9a39cad7281722d72f4c074">XED_ENCODER_OPERAND_TYPE_IMM0</a>; <a name="l00142"></a>00142 o.<a class="code" href="structxed__encoder__operand__t.html#01d174f19e13511270eefe522bc61248">u</a>.<a class="code" href="structxed__encoder__operand__t.html#5dce7d3756139b85189dad3a9156c082">imm0</a> = v; <a name="l00143"></a>00143 o.<a class="code" href="structxed__encoder__operand__t.html#ea2d8c884cca697c2dbc9807dfbdd139">width</a> = width; <a name="l00144"></a>00144 <span class="keywordflow">return</span> o; <a name="l00145"></a>00145 }<span class="comment"></span> <a name="l00146"></a>00146 <span class="comment">/// @ingroup ENCHL</span> <a name="l00147"></a>00147 <span class="comment">/// an 32b signed immediate operand</span> <a name="l00148"></a><a class="code" href="xed2-ia32_2include_2xed-encoder-hl_8h.html#224148173f630a050658a41d82e1806f">00148</a> <span class="comment"></span>XED_INLINE <span class="keyword">static</span> <a class="code" href="structxed__encoder__operand__t.html">xed_encoder_operand_t</a> <a class="code" href="xed2-ia32_2include_2xed-encoder-hl_8h.html#224148173f630a050658a41d82e1806f">simm0</a>(xed_int32_t v, <a class="code" href="xed2-ia32_2include_2xed-types_8h.html#0c92e8263b7ca02d8e4826ae5b79bb30">xed_uint_t</a> width) { <a name="l00149"></a>00149 <a class="code" href="structxed__encoder__operand__t.html">xed_encoder_operand_t</a> o; <a name="l00150"></a>00150 o.<a class="code" href="structxed__encoder__operand__t.html#15b522f5fb9447f7bbea3ae6baf328a9">type</a> = <a class="code" href="xed2-ia32_2include_2xed-encoder-hl_8h.html#7621255aeac26b5e78f7a0dc72d126386010b70490d8deb87248988db4851991">XED_ENCODER_OPERAND_TYPE_SIMM0</a>; <a name="l00151"></a>00151 <span class="comment">/* sign conversion: we store the int32 in an uint64. It gets sign</span> <a name="l00152"></a>00152 <span class="comment"> extended. Later we convert it to the right width for the</span> <a name="l00153"></a>00153 <span class="comment"> instruction. The maximum width of a signed immediate is currently</span> <a name="l00154"></a>00154 <span class="comment"> 32b. */</span> <a name="l00155"></a>00155 o.<a class="code" href="structxed__encoder__operand__t.html#01d174f19e13511270eefe522bc61248">u</a>.<a class="code" href="structxed__encoder__operand__t.html#5dce7d3756139b85189dad3a9156c082">imm0</a> = v; <a name="l00156"></a>00156 o.<a class="code" href="structxed__encoder__operand__t.html#ea2d8c884cca697c2dbc9807dfbdd139">width</a> = width; <a name="l00157"></a>00157 <span class="keywordflow">return</span> o; <a name="l00158"></a>00158 } <a name="l00159"></a>00159 <span class="comment"></span> <a name="l00160"></a>00160 <span class="comment">/// @ingroup ENCHL</span> <a name="l00161"></a>00161 <span class="comment">/// an second immediate operand (known as IMM1)</span> <a name="l00162"></a><a class="code" href="xed2-ia32_2include_2xed-encoder-hl_8h.html#c6d077d7c8bd6d603c46554caf4eac8b">00162</a> <span class="comment"></span>XED_INLINE <span class="keyword">static</span> <a class="code" href="structxed__encoder__operand__t.html">xed_encoder_operand_t</a> <a class="code" href="xed2-ia32_2include_2xed-encoder-hl_8h.html#c6d077d7c8bd6d603c46554caf4eac8b">imm1</a>(xed_uint8_t v) { <a name="l00163"></a>00163 <a class="code" href="structxed__encoder__operand__t.html">xed_encoder_operand_t</a> o; <a name="l00164"></a>00164 o.<a class="code" href="structxed__encoder__operand__t.html#15b522f5fb9447f7bbea3ae6baf328a9">type</a> = <a class="code" href="xed2-ia32_2include_2xed-encoder-hl_8h.html#7621255aeac26b5e78f7a0dc72d1263839d2ecbd06732c86c9be27e5697513e4">XED_ENCODER_OPERAND_TYPE_IMM1</a>; <a name="l00165"></a>00165 o.<a class="code" href="structxed__encoder__operand__t.html#01d174f19e13511270eefe522bc61248">u</a>.<a class="code" href="structxed__encoder__operand__t.html#14f433f92d67d3bed1e912dfaec7478c">imm1</a> = v; <a name="l00166"></a>00166 o.<a class="code" href="structxed__encoder__operand__t.html#ea2d8c884cca697c2dbc9807dfbdd139">width</a> = 8; <a name="l00167"></a>00167 <span class="keywordflow">return</span> o; <a name="l00168"></a>00168 } <a name="l00169"></a>00169 <a name="l00170"></a>00170 <span class="comment"></span> <a name="l00171"></a>00171 <span class="comment">/// @ingroup ENCHL</span> <a name="l00172"></a>00172 <span class="comment">/// an operand storage field name and value</span> <a name="l00173"></a><a class="code" href="xed2-ia32_2include_2xed-encoder-hl_8h.html#6e3a5790c41207ef4b7c1f2fb1153b46">00173</a> <span class="comment"></span>XED_INLINE <span class="keyword">static</span> <a class="code" href="structxed__encoder__operand__t.html">xed_encoder_operand_t</a> <a class="code" href="xed2-ia32_2include_2xed-encoder-hl_8h.html#6e3a5790c41207ef4b7c1f2fb1153b46">xother</a>(<a class="code" href="xed2-ia32_2include_2xed-operand-enum_8h.html#09c2a35d8bb7bfe68bb3d34b0a5e011a">xed_operand_enum_t</a> operand_name, <a name="l00174"></a>00174 xed_int32_t value) { <a name="l00175"></a>00175 <a class="code" href="structxed__encoder__operand__t.html">xed_encoder_operand_t</a> o; <a name="l00176"></a>00176 o.<a class="code" href="structxed__encoder__operand__t.html#15b522f5fb9447f7bbea3ae6baf328a9">type</a> = <a class="code" href="xed2-ia32_2include_2xed-encoder-hl_8h.html#7621255aeac26b5e78f7a0dc72d12638263eeedf98d73a93dd619bc0b2359d79">XED_ENCODER_OPERAND_TYPE_OTHER</a>; <a name="l00177"></a>00177 o.<a class="code" href="structxed__encoder__operand__t.html#01d174f19e13511270eefe522bc61248">u</a>.<a class="code" href="structxed__encoder__operand__t.html#e0848586a721bdf0be7381053b9e9925">s</a>.operand_name = operand_name; <a name="l00178"></a>00178 o.<a class="code" href="structxed__encoder__operand__t.html#01d174f19e13511270eefe522bc61248">u</a>.<a class="code" href="structxed__encoder__operand__t.html#e0848586a721bdf0be7381053b9e9925">s</a>.value = value; <a name="l00179"></a>00179 o.<a class="code" href="structxed__encoder__operand__t.html#ea2d8c884cca697c2dbc9807dfbdd139">width</a> = 0; <a name="l00180"></a>00180 <span class="keywordflow">return</span> o; <a name="l00181"></a>00181 }<span class="comment"></span> <a name="l00182"></a>00182 <span class="comment">//@}</span> <a name="l00183"></a>00183 <span class="comment"></span> <a name="l00184"></a>00184 <span class="comment"></span> <a name="l00185"></a>00185 <span class="comment">//@}</span> <a name="l00186"></a>00186 <span class="comment"></span><span class="comment"></span> <a name="l00187"></a>00187 <span class="comment">/// @name Memory and Segment-releated Operands</span> <a name="l00188"></a>00188 <span class="comment"></span><span class="comment">//@{</span> <a name="l00189"></a>00189 <span class="comment"></span><span class="comment"></span> <a name="l00190"></a>00190 <span class="comment">/// @ingroup ENCHL</span> <a name="l00191"></a>00191 <span class="comment">/// seg reg override for implicit suppressed memory ops</span> <a name="l00192"></a><a class="code" href="xed2-ia32_2include_2xed-encoder-hl_8h.html#793653db3198f72eb18d140e25dde653">00192</a> <span class="comment"></span>XED_INLINE <span class="keyword">static</span> <a class="code" href="structxed__encoder__operand__t.html">xed_encoder_operand_t</a> <a class="code" href="xed2-ia32_2include_2xed-encoder-hl_8h.html#793653db3198f72eb18d140e25dde653">xseg0</a>(<a class="code" href="xed2-ia32_2include_2xed-reg-enum_8h.html#f05c33c5a68e9304d1d8ac0408ae3f61">xed_reg_enum_t</a> seg0) { <a name="l00193"></a>00193 <a class="code" href="structxed__encoder__operand__t.html">xed_encoder_operand_t</a> o; <a name="l00194"></a>00194 o.<a class="code" href="structxed__encoder__operand__t.html#15b522f5fb9447f7bbea3ae6baf328a9">type</a> = <a class="code" href="xed2-ia32_2include_2xed-encoder-hl_8h.html#7621255aeac26b5e78f7a0dc72d126385a7a43348b1552de102211c4d76ca72d">XED_ENCODER_OPERAND_TYPE_SEG0</a>; <a name="l00195"></a>00195 o.<a class="code" href="structxed__encoder__operand__t.html#01d174f19e13511270eefe522bc61248">u</a>.<a class="code" href="structxed__encoder__operand__t.html#e5eeb0d5e528568c4335f3e1232b1c74">reg</a> = seg0; <a name="l00196"></a>00196 <span class="keywordflow">return</span> o; <a name="l00197"></a>00197 } <a name="l00198"></a>00198 <span class="comment"></span> <a name="l00199"></a>00199 <span class="comment">/// @ingroup ENCHL</span> <a name="l00200"></a>00200 <span class="comment">/// seg reg override for implicit suppressed memory ops</span> <a name="l00201"></a><a class="code" href="xed2-ia32_2include_2xed-encoder-hl_8h.html#b67610fd9da5d421558105f820cbd27b">00201</a> <span class="comment"></span>XED_INLINE <span class="keyword">static</span> <a class="code" href="structxed__encoder__operand__t.html">xed_encoder_operand_t</a> <a class="code" href="xed2-ia32_2include_2xed-encoder-hl_8h.html#b67610fd9da5d421558105f820cbd27b">xseg1</a>(<a class="code" href="xed2-ia32_2include_2xed-reg-enum_8h.html#f05c33c5a68e9304d1d8ac0408ae3f61">xed_reg_enum_t</a> seg1) { <a name="l00202"></a>00202 <a class="code" href="structxed__encoder__operand__t.html">xed_encoder_operand_t</a> o; <a name="l00203"></a>00203 o.<a class="code" href="structxed__encoder__operand__t.html#15b522f5fb9447f7bbea3ae6baf328a9">type</a> = <a class="code" href="xed2-ia32_2include_2xed-encoder-hl_8h.html#7621255aeac26b5e78f7a0dc72d12638acd0df30646ec7115ac403e2dc7bf2ff">XED_ENCODER_OPERAND_TYPE_SEG1</a>; <a name="l00204"></a>00204 o.<a class="code" href="structxed__encoder__operand__t.html#01d174f19e13511270eefe522bc61248">u</a>.<a class="code" href="structxed__encoder__operand__t.html#e5eeb0d5e528568c4335f3e1232b1c74">reg</a> = seg1; <a name="l00205"></a>00205 <span class="keywordflow">return</span> o; <a name="l00206"></a>00206 } <a name="l00207"></a>00207 <span class="comment"></span> <a name="l00208"></a>00208 <span class="comment">/// @ingroup ENCHL</span> <a name="l00209"></a>00209 <span class="comment">/// memory operand - base only </span> <a name="l00210"></a><a class="code" href="xed2-ia32_2include_2xed-encoder-hl_8h.html#7a36b028c6ec7d4e1dc84011cc6787d0">00210</a> <span class="comment"></span>XED_INLINE <span class="keyword">static</span> <a class="code" href="structxed__encoder__operand__t.html">xed_encoder_operand_t</a> <a class="code" href="xed2-ia32_2include_2xed-encoder-hl_8h.html#7a36b028c6ec7d4e1dc84011cc6787d0">xmem_b</a>(<a class="code" href="xed2-ia32_2include_2xed-reg-enum_8h.html#f05c33c5a68e9304d1d8ac0408ae3f61">xed_reg_enum_t</a> base, <a class="code" href="xed2-ia32_2include_2xed-types_8h.html#0c92e8263b7ca02d8e4826ae5b79bb30">xed_uint_t</a> width) { <a name="l00211"></a>00211 <a class="code" href="structxed__encoder__operand__t.html">xed_encoder_operand_t</a> o; <a name="l00212"></a>00212 o.<a class="code" href="structxed__encoder__operand__t.html#15b522f5fb9447f7bbea3ae6baf328a9">type</a> = <a class="code" href="xed2-ia32_2include_2xed-encoder-hl_8h.html#7621255aeac26b5e78f7a0dc72d12638fb6bee5a0fcf154e71397defed76ed88">XED_ENCODER_OPERAND_TYPE_MEM</a>; <a name="l00213"></a>00213 o.<a class="code" href="structxed__encoder__operand__t.html#01d174f19e13511270eefe522bc61248">u</a>.<a class="code" href="structxed__encoder__operand__t.html#7874f7a5284ff2064ba6b9bf032e25ff">mem</a>.<a class="code" href="structxed__memop__t.html#b33f5fd03ddbc01a1795e85978b32c61">base</a> = base; <a name="l00214"></a>00214 o.<a class="code" href="structxed__encoder__operand__t.html#01d174f19e13511270eefe522bc61248">u</a>.<a class="code" href="structxed__encoder__operand__t.html#7874f7a5284ff2064ba6b9bf032e25ff">mem</a>.<a class="code" href="structxed__memop__t.html#d07ef1ac72ff572e65e78b3653c43c1d">seg</a> = <a class="code" href="xed2-ia32_2include_2xed-reg-enum_8h.html#f05c33c5a68e9304d1d8ac0408ae3f61fac474058f0819d415285511086bf219">XED_REG_INVALID</a>; <a name="l00215"></a>00215 o.<a class="code" href="structxed__encoder__operand__t.html#01d174f19e13511270eefe522bc61248">u</a>.<a class="code" href="structxed__encoder__operand__t.html#7874f7a5284ff2064ba6b9bf032e25ff">mem</a>.<a class="code" href="structxed__memop__t.html#451ae2fcc3acdff8a10543b18f19f84e">index</a>= <a class="code" href="xed2-ia32_2include_2xed-reg-enum_8h.html#f05c33c5a68e9304d1d8ac0408ae3f61fac474058f0819d415285511086bf219">XED_REG_INVALID</a>; <a name="l00216"></a>00216 o.<a class="code" href="structxed__encoder__operand__t.html#01d174f19e13511270eefe522bc61248">u</a>.<a class="code" href="structxed__encoder__operand__t.html#7874f7a5284ff2064ba6b9bf032e25ff">mem</a>.<a class="code" href="structxed__memop__t.html#d801bcd3961aa78d30caaca98489dd36">scale</a> = 0; <a name="l00217"></a>00217 o.<a class="code" href="structxed__encoder__operand__t.html#01d174f19e13511270eefe522bc61248">u</a>.<a class="code" href="structxed__encoder__operand__t.html#7874f7a5284ff2064ba6b9bf032e25ff">mem</a>.<a class="code" href="structxed__memop__t.html#1fd26bd97ff3565101e7e79ccf1d5a53">disp</a>.<a class="code" href="structxed__enc__displacement__t.html#c983d8e2ceacd11fce421ac110c65bd8">displacement</a> = 0; <a name="l00218"></a>00218 o.<a class="code" href="structxed__encoder__operand__t.html#01d174f19e13511270eefe522bc61248">u</a>.<a class="code" href="structxed__encoder__operand__t.html#7874f7a5284ff2064ba6b9bf032e25ff">mem</a>.<a class="code" href="structxed__memop__t.html#1fd26bd97ff3565101e7e79ccf1d5a53">disp</a>.<a class="code" href="structxed__enc__displacement__t.html#3fd0ffc7c9929f49bfc795fe01bf1798">displacement_width</a> = 0; <a name="l00219"></a>00219 o.<a class="code" href="structxed__encoder__operand__t.html#ea2d8c884cca697c2dbc9807dfbdd139">width</a> = width; <a name="l00220"></a>00220 <span class="keywordflow">return</span> o; <a name="l00221"></a>00221 } <a name="l00222"></a>00222 <span class="comment"></span> <a name="l00223"></a>00223 <span class="comment">/// @ingroup ENCHL</span> <a name="l00224"></a>00224 <span class="comment">/// memory operand - base and displacement only </span> <a name="l00225"></a><a class="code" href="xed2-ia32_2include_2xed-encoder-hl_8h.html#6a7e5ee43079588be0649fc0af9f317e">00225</a> <span class="comment"></span>XED_INLINE <span class="keyword">static</span> <a class="code" href="structxed__encoder__operand__t.html">xed_encoder_operand_t</a> <a class="code" href="xed2-ia32_2include_2xed-encoder-hl_8h.html#6a7e5ee43079588be0649fc0af9f317e">xmem_bd</a>(<a class="code" href="xed2-ia32_2include_2xed-reg-enum_8h.html#f05c33c5a68e9304d1d8ac0408ae3f61">xed_reg_enum_t</a> base, <a name="l00226"></a>00226 <a class="code" href="structxed__enc__displacement__t.html">xed_enc_displacement_t</a> disp, <a name="l00227"></a>00227 <a class="code" href="xed2-ia32_2include_2xed-types_8h.html#0c92e8263b7ca02d8e4826ae5b79bb30">xed_uint_t</a> width) { <a name="l00228"></a>00228 <a class="code" href="structxed__encoder__operand__t.html">xed_encoder_operand_t</a> o; <a name="l00229"></a>00229 o.<a class="code" href="structxed__encoder__operand__t.html#15b522f5fb9447f7bbea3ae6baf328a9">type</a> = <a class="code" href="xed2-ia32_2include_2xed-encoder-hl_8h.html#7621255aeac26b5e78f7a0dc72d12638fb6bee5a0fcf154e71397defed76ed88">XED_ENCODER_OPERAND_TYPE_MEM</a>; <a name="l00230"></a>00230 o.<a class="code" href="structxed__encoder__operand__t.html#01d174f19e13511270eefe522bc61248">u</a>.<a class="code" href="structxed__encoder__operand__t.html#7874f7a5284ff2064ba6b9bf032e25ff">mem</a>.<a class="code" href="structxed__memop__t.html#b33f5fd03ddbc01a1795e85978b32c61">base</a> = base; <a name="l00231"></a>00231 o.<a class="code" href="structxed__encoder__operand__t.html#01d174f19e13511270eefe522bc61248">u</a>.<a class="code" href="structxed__encoder__operand__t.html#7874f7a5284ff2064ba6b9bf032e25ff">mem</a>.<a class="code" href="structxed__memop__t.html#d07ef1ac72ff572e65e78b3653c43c1d">seg</a> = <a class="code" href="xed2-ia32_2include_2xed-reg-enum_8h.html#f05c33c5a68e9304d1d8ac0408ae3f61fac474058f0819d415285511086bf219">XED_REG_INVALID</a>; <a name="l00232"></a>00232 o.<a class="code" href="structxed__encoder__operand__t.html#01d174f19e13511270eefe522bc61248">u</a>.<a class="code" href="structxed__encoder__operand__t.html#7874f7a5284ff2064ba6b9bf032e25ff">mem</a>.<a class="code" href="structxed__memop__t.html#451ae2fcc3acdff8a10543b18f19f84e">index</a>= <a class="code" href="xed2-ia32_2include_2xed-reg-enum_8h.html#f05c33c5a68e9304d1d8ac0408ae3f61fac474058f0819d415285511086bf219">XED_REG_INVALID</a>; <a name="l00233"></a>00233 o.<a class="code" href="structxed__encoder__operand__t.html#01d174f19e13511270eefe522bc61248">u</a>.<a class="code" href="structxed__encoder__operand__t.html#7874f7a5284ff2064ba6b9bf032e25ff">mem</a>.<a class="code" href="structxed__memop__t.html#d801bcd3961aa78d30caaca98489dd36">scale</a> = 0; <a name="l00234"></a>00234 o.<a class="code" href="structxed__encoder__operand__t.html#01d174f19e13511270eefe522bc61248">u</a>.<a class="code" href="structxed__encoder__operand__t.html#7874f7a5284ff2064ba6b9bf032e25ff">mem</a>.<a class="code" href="structxed__memop__t.html#1fd26bd97ff3565101e7e79ccf1d5a53">disp</a> =disp; <a name="l00235"></a>00235 o.<a class="code" href="structxed__encoder__operand__t.html#ea2d8c884cca697c2dbc9807dfbdd139">width</a> = width; <a name="l00236"></a>00236 <span class="keywordflow">return</span> o; <a name="l00237"></a>00237 } <a name="l00238"></a>00238 <span class="comment"></span> <a name="l00239"></a>00239 <span class="comment">/// @ingroup ENCHL</span> <a name="l00240"></a>00240 <span class="comment">/// memory operand - base, index, scale, displacement</span> <a name="l00241"></a><a class="code" href="xed2-ia32_2include_2xed-encoder-hl_8h.html#59d7b50dfd23d11b89be56686d6bdd63">00241</a> <span class="comment"></span>XED_INLINE <span class="keyword">static</span> <a class="code" href="structxed__encoder__operand__t.html">xed_encoder_operand_t</a> <a class="code" href="xed2-ia32_2include_2xed-encoder-hl_8h.html#59d7b50dfd23d11b89be56686d6bdd63">xmem_bisd</a>(<a class="code" href="xed2-ia32_2include_2xed-reg-enum_8h.html#f05c33c5a68e9304d1d8ac0408ae3f61">xed_reg_enum_t</a> base, <a name="l00242"></a>00242 <a class="code" href="xed2-ia32_2include_2xed-reg-enum_8h.html#f05c33c5a68e9304d1d8ac0408ae3f61">xed_reg_enum_t</a> index, <a name="l00243"></a>00243 <a class="code" href="xed2-ia32_2include_2xed-types_8h.html#0c92e8263b7ca02d8e4826ae5b79bb30">xed_uint_t</a> scale, <a name="l00244"></a>00244 <a class="code" href="structxed__enc__displacement__t.html">xed_enc_displacement_t</a> disp, <a name="l00245"></a>00245 <a class="code" href="xed2-ia32_2include_2xed-types_8h.html#0c92e8263b7ca02d8e4826ae5b79bb30">xed_uint_t</a> width) { <a name="l00246"></a>00246 <a class="code" href="structxed__encoder__operand__t.html">xed_encoder_operand_t</a> o; <a name="l00247"></a>00247 o.<a class="code" href="structxed__encoder__operand__t.html#15b522f5fb9447f7bbea3ae6baf328a9">type</a> = <a class="code" href="xed2-ia32_2include_2xed-encoder-hl_8h.html#7621255aeac26b5e78f7a0dc72d12638fb6bee5a0fcf154e71397defed76ed88">XED_ENCODER_OPERAND_TYPE_MEM</a>; <a name="l00248"></a>00248 o.<a class="code" href="structxed__encoder__operand__t.html#01d174f19e13511270eefe522bc61248">u</a>.<a class="code" href="structxed__encoder__operand__t.html#7874f7a5284ff2064ba6b9bf032e25ff">mem</a>.<a class="code" href="structxed__memop__t.html#b33f5fd03ddbc01a1795e85978b32c61">base</a> = base; <a name="l00249"></a>00249 o.<a class="code" href="structxed__encoder__operand__t.html#01d174f19e13511270eefe522bc61248">u</a>.<a class="code" href="structxed__encoder__operand__t.html#7874f7a5284ff2064ba6b9bf032e25ff">mem</a>.<a class="code" href="structxed__memop__t.html#d07ef1ac72ff572e65e78b3653c43c1d">seg</a> = <a class="code" href="xed2-ia32_2include_2xed-reg-enum_8h.html#f05c33c5a68e9304d1d8ac0408ae3f61fac474058f0819d415285511086bf219">XED_REG_INVALID</a>; <a name="l00250"></a>00250 o.<a class="code" href="structxed__encoder__operand__t.html#01d174f19e13511270eefe522bc61248">u</a>.<a class="code" href="structxed__encoder__operand__t.html#7874f7a5284ff2064ba6b9bf032e25ff">mem</a>.<a class="code" href="structxed__memop__t.html#451ae2fcc3acdff8a10543b18f19f84e">index</a>= index; <a name="l00251"></a>00251 o.<a class="code" href="structxed__encoder__operand__t.html#01d174f19e13511270eefe522bc61248">u</a>.<a class="code" href="structxed__encoder__operand__t.html#7874f7a5284ff2064ba6b9bf032e25ff">mem</a>.<a class="code" href="structxed__memop__t.html#d801bcd3961aa78d30caaca98489dd36">scale</a> = scale; <a name="l00252"></a>00252 o.<a class="code" href="structxed__encoder__operand__t.html#01d174f19e13511270eefe522bc61248">u</a>.<a class="code" href="structxed__encoder__operand__t.html#7874f7a5284ff2064ba6b9bf032e25ff">mem</a>.<a class="code" href="structxed__memop__t.html#1fd26bd97ff3565101e7e79ccf1d5a53">disp</a> = disp; <a name="l00253"></a>00253 o.<a class="code" href="structxed__encoder__operand__t.html#ea2d8c884cca697c2dbc9807dfbdd139">width</a> = width; <a name="l00254"></a>00254 <span class="keywordflow">return</span> o; <a name="l00255"></a>00255 } <a name="l00256"></a>00256 <a name="l00257"></a>00257 <span class="comment"></span> <a name="l00258"></a>00258 <span class="comment">/// @ingroup ENCHL</span> <a name="l00259"></a>00259 <span class="comment">/// memory operand - segment and base only</span> <a name="l00260"></a><a class="code" href="xed2-ia32_2include_2xed-encoder-hl_8h.html#03dcdbf44f52401301bf7e1f037a4ba0">00260</a> <span class="comment"></span>XED_INLINE <span class="keyword">static</span> <a class="code" href="structxed__encoder__operand__t.html">xed_encoder_operand_t</a> <a class="code" href="xed2-ia32_2include_2xed-encoder-hl_8h.html#03dcdbf44f52401301bf7e1f037a4ba0">xmem_gb</a>(<a class="code" href="xed2-ia32_2include_2xed-reg-enum_8h.html#f05c33c5a68e9304d1d8ac0408ae3f61">xed_reg_enum_t</a> seg, <a class="code" href="xed2-ia32_2include_2xed-reg-enum_8h.html#f05c33c5a68e9304d1d8ac0408ae3f61">xed_reg_enum_t</a> base, <a class="code" href="xed2-ia32_2include_2xed-types_8h.html#0c92e8263b7ca02d8e4826ae5b79bb30">xed_uint_t</a> width) { <a name="l00261"></a>00261 <a class="code" href="structxed__encoder__operand__t.html">xed_encoder_operand_t</a> o; <a name="l00262"></a>00262 o.<a class="code" href="structxed__encoder__operand__t.html#15b522f5fb9447f7bbea3ae6baf328a9">type</a> = <a class="code" href="xed2-ia32_2include_2xed-encoder-hl_8h.html#7621255aeac26b5e78f7a0dc72d12638fb6bee5a0fcf154e71397defed76ed88">XED_ENCODER_OPERAND_TYPE_MEM</a>; <a name="l00263"></a>00263 o.<a class="code" href="structxed__encoder__operand__t.html#01d174f19e13511270eefe522bc61248">u</a>.<a class="code" href="structxed__encoder__operand__t.html#7874f7a5284ff2064ba6b9bf032e25ff">mem</a>.<a class="code" href="structxed__memop__t.html#b33f5fd03ddbc01a1795e85978b32c61">base</a> = base; <a name="l00264"></a>00264 o.<a class="code" href="structxed__encoder__operand__t.html#01d174f19e13511270eefe522bc61248">u</a>.<a class="code" href="structxed__encoder__operand__t.html#7874f7a5284ff2064ba6b9bf032e25ff">mem</a>.<a class="code" href="structxed__memop__t.html#d07ef1ac72ff572e65e78b3653c43c1d">seg</a> = seg; <a name="l00265"></a>00265 o.<a class="code" href="structxed__encoder__operand__t.html#01d174f19e13511270eefe522bc61248">u</a>.<a class="code" href="structxed__encoder__operand__t.html#7874f7a5284ff2064ba6b9bf032e25ff">mem</a>.<a class="code" href="structxed__memop__t.html#451ae2fcc3acdff8a10543b18f19f84e">index</a>= <a class="code" href="xed2-ia32_2include_2xed-reg-enum_8h.html#f05c33c5a68e9304d1d8ac0408ae3f61fac474058f0819d415285511086bf219">XED_REG_INVALID</a>; <a name="l00266"></a>00266 o.<a class="code" href="structxed__encoder__operand__t.html#01d174f19e13511270eefe522bc61248">u</a>.<a class="code" href="structxed__encoder__operand__t.html#7874f7a5284ff2064ba6b9bf032e25ff">mem</a>.<a class="code" href="structxed__memop__t.html#d801bcd3961aa78d30caaca98489dd36">scale</a> = 0; <a name="l00267"></a>00267 o.<a class="code" href="structxed__encoder__operand__t.html#01d174f19e13511270eefe522bc61248">u</a>.<a class="code" href="structxed__encoder__operand__t.html#7874f7a5284ff2064ba6b9bf032e25ff">mem</a>.<a class="code" href="structxed__memop__t.html#1fd26bd97ff3565101e7e79ccf1d5a53">disp</a>.<a class="code" href="structxed__enc__displacement__t.html#c983d8e2ceacd11fce421ac110c65bd8">displacement</a> = 0; <a name="l00268"></a>00268 o.<a class="code" href="structxed__encoder__operand__t.html#01d174f19e13511270eefe522bc61248">u</a>.<a class="code" href="structxed__encoder__operand__t.html#7874f7a5284ff2064ba6b9bf032e25ff">mem</a>.<a class="code" href="structxed__memop__t.html#1fd26bd97ff3565101e7e79ccf1d5a53">disp</a>.<a class="code" href="structxed__enc__displacement__t.html#3fd0ffc7c9929f49bfc795fe01bf1798">displacement_width</a> = 0; <a name="l00269"></a>00269 o.<a class="code" href="structxed__encoder__operand__t.html#ea2d8c884cca697c2dbc9807dfbdd139">width</a> = width; <a name="l00270"></a>00270 <span class="keywordflow">return</span> o; <a name="l00271"></a>00271 } <a name="l00272"></a>00272 <span class="comment"></span> <a name="l00273"></a>00273 <span class="comment">/// @ingroup ENCHL</span> <a name="l00274"></a>00274 <span class="comment">/// memory operand - segment, base and displacement only</span> <a name="l00275"></a><a class="code" href="xed2-ia32_2include_2xed-encoder-hl_8h.html#1ec05f0acc4469fe82b3c2824c4a366d">00275</a> <span class="comment"></span>XED_INLINE <span class="keyword">static</span> <a class="code" href="structxed__encoder__operand__t.html">xed_encoder_operand_t</a> <a class="code" href="xed2-ia32_2include_2xed-encoder-hl_8h.html#1ec05f0acc4469fe82b3c2824c4a366d">xmem_gbd</a>(<a class="code" href="xed2-ia32_2include_2xed-reg-enum_8h.html#f05c33c5a68e9304d1d8ac0408ae3f61">xed_reg_enum_t</a> seg, <a class="code" href="xed2-ia32_2include_2xed-reg-enum_8h.html#f05c33c5a68e9304d1d8ac0408ae3f61">xed_reg_enum_t</a> base, <a name="l00276"></a>00276 <a class="code" href="structxed__enc__displacement__t.html">xed_enc_displacement_t</a> disp, <a name="l00277"></a>00277 <a class="code" href="xed2-ia32_2include_2xed-types_8h.html#0c92e8263b7ca02d8e4826ae5b79bb30">xed_uint_t</a> width) { <a name="l00278"></a>00278 <a class="code" href="structxed__encoder__operand__t.html">xed_encoder_operand_t</a> o; <a name="l00279"></a>00279 o.<a class="code" href="structxed__encoder__operand__t.html#15b522f5fb9447f7bbea3ae6baf328a9">type</a> = <a class="code" href="xed2-ia32_2include_2xed-encoder-hl_8h.html#7621255aeac26b5e78f7a0dc72d12638fb6bee5a0fcf154e71397defed76ed88">XED_ENCODER_OPERAND_TYPE_MEM</a>; <a name="l00280"></a>00280 o.<a class="code" href="structxed__encoder__operand__t.html#01d174f19e13511270eefe522bc61248">u</a>.<a class="code" href="structxed__encoder__operand__t.html#7874f7a5284ff2064ba6b9bf032e25ff">mem</a>.<a class="code" href="structxed__memop__t.html#b33f5fd03ddbc01a1795e85978b32c61">base</a> = base; <a name="l00281"></a>00281 o.<a class="code" href="structxed__encoder__operand__t.html#01d174f19e13511270eefe522bc61248">u</a>.<a class="code" href="structxed__encoder__operand__t.html#7874f7a5284ff2064ba6b9bf032e25ff">mem</a>.<a class="code" href="structxed__memop__t.html#d07ef1ac72ff572e65e78b3653c43c1d">seg</a> = seg; <a name="l00282"></a>00282 o.<a class="code" href="structxed__encoder__operand__t.html#01d174f19e13511270eefe522bc61248">u</a>.<a class="code" href="structxed__encoder__operand__t.html#7874f7a5284ff2064ba6b9bf032e25ff">mem</a>.<a class="code" href="structxed__memop__t.html#451ae2fcc3acdff8a10543b18f19f84e">index</a>= <a class="code" href="xed2-ia32_2include_2xed-reg-enum_8h.html#f05c33c5a68e9304d1d8ac0408ae3f61fac474058f0819d415285511086bf219">XED_REG_INVALID</a>; <a name="l00283"></a>00283 o.<a class="code" href="structxed__encoder__operand__t.html#01d174f19e13511270eefe522bc61248">u</a>.<a class="code" href="structxed__encoder__operand__t.html#7874f7a5284ff2064ba6b9bf032e25ff">mem</a>.<a class="code" href="structxed__memop__t.html#d801bcd3961aa78d30caaca98489dd36">scale</a> = 0; <a name="l00284"></a>00284 o.<a class="code" href="structxed__encoder__operand__t.html#01d174f19e13511270eefe522bc61248">u</a>.<a class="code" href="structxed__encoder__operand__t.html#7874f7a5284ff2064ba6b9bf032e25ff">mem</a>.<a class="code" href="structxed__memop__t.html#1fd26bd97ff3565101e7e79ccf1d5a53">disp</a> = disp; <a name="l00285"></a>00285 o.<a class="code" href="structxed__encoder__operand__t.html#ea2d8c884cca697c2dbc9807dfbdd139">width</a> = width; <a name="l00286"></a>00286 <span class="keywordflow">return</span> o; <a name="l00287"></a>00287 } <a name="l00288"></a>00288 <span class="comment"></span> <a name="l00289"></a>00289 <span class="comment">/// @ingroup ENCHL</span> <a name="l00290"></a>00290 <span class="comment">/// memory operand - segment and displacement only</span> <a name="l00291"></a><a class="code" href="xed2-ia32_2include_2xed-encoder-hl_8h.html#1515d8567dd24b840528e94ef45d5cd1">00291</a> <span class="comment"></span>XED_INLINE <span class="keyword">static</span> <a class="code" href="structxed__encoder__operand__t.html">xed_encoder_operand_t</a> <a class="code" href="xed2-ia32_2include_2xed-encoder-hl_8h.html#1515d8567dd24b840528e94ef45d5cd1">xmem_gd</a>(<a class="code" href="xed2-ia32_2include_2xed-reg-enum_8h.html#f05c33c5a68e9304d1d8ac0408ae3f61">xed_reg_enum_t</a> seg, <a name="l00292"></a>00292 <a class="code" href="structxed__enc__displacement__t.html">xed_enc_displacement_t</a> disp, <a name="l00293"></a>00293 <a class="code" href="xed2-ia32_2include_2xed-types_8h.html#0c92e8263b7ca02d8e4826ae5b79bb30">xed_uint_t</a> width) { <a name="l00294"></a>00294 <a class="code" href="structxed__encoder__operand__t.html">xed_encoder_operand_t</a> o; <a name="l00295"></a>00295 o.<a class="code" href="structxed__encoder__operand__t.html#15b522f5fb9447f7bbea3ae6baf328a9">type</a> = <a class="code" href="xed2-ia32_2include_2xed-encoder-hl_8h.html#7621255aeac26b5e78f7a0dc72d12638fb6bee5a0fcf154e71397defed76ed88">XED_ENCODER_OPERAND_TYPE_MEM</a>; <a name="l00296"></a>00296 o.<a class="code" href="structxed__encoder__operand__t.html#01d174f19e13511270eefe522bc61248">u</a>.<a class="code" href="structxed__encoder__operand__t.html#7874f7a5284ff2064ba6b9bf032e25ff">mem</a>.<a class="code" href="structxed__memop__t.html#b33f5fd03ddbc01a1795e85978b32c61">base</a> = <a class="code" href="xed2-ia32_2include_2xed-reg-enum_8h.html#f05c33c5a68e9304d1d8ac0408ae3f61fac474058f0819d415285511086bf219">XED_REG_INVALID</a>; <a name="l00297"></a>00297 o.<a class="code" href="structxed__encoder__operand__t.html#01d174f19e13511270eefe522bc61248">u</a>.<a class="code" href="structxed__encoder__operand__t.html#7874f7a5284ff2064ba6b9bf032e25ff">mem</a>.<a class="code" href="structxed__memop__t.html#d07ef1ac72ff572e65e78b3653c43c1d">seg</a> = seg; <a name="l00298"></a>00298 o.<a class="code" href="structxed__encoder__operand__t.html#01d174f19e13511270eefe522bc61248">u</a>.<a class="code" href="structxed__encoder__operand__t.html#7874f7a5284ff2064ba6b9bf032e25ff">mem</a>.<a class="code" href="structxed__memop__t.html#451ae2fcc3acdff8a10543b18f19f84e">index</a>= <a class="code" href="xed2-ia32_2include_2xed-reg-enum_8h.html#f05c33c5a68e9304d1d8ac0408ae3f61fac474058f0819d415285511086bf219">XED_REG_INVALID</a>; <a name="l00299"></a>00299 o.<a class="code" href="structxed__encoder__operand__t.html#01d174f19e13511270eefe522bc61248">u</a>.<a class="code" href="structxed__encoder__operand__t.html#7874f7a5284ff2064ba6b9bf032e25ff">mem</a>.<a class="code" href="structxed__memop__t.html#d801bcd3961aa78d30caaca98489dd36">scale</a> = 0; <a name="l00300"></a>00300 o.<a class="code" href="structxed__encoder__operand__t.html#01d174f19e13511270eefe522bc61248">u</a>.<a class="code" href="structxed__encoder__operand__t.html#7874f7a5284ff2064ba6b9bf032e25ff">mem</a>.<a class="code" href="structxed__memop__t.html#1fd26bd97ff3565101e7e79ccf1d5a53">disp</a> = disp; <a name="l00301"></a>00301 o.<a class="code" href="structxed__encoder__operand__t.html#ea2d8c884cca697c2dbc9807dfbdd139">width</a> = width; <a name="l00302"></a>00302 <span class="keywordflow">return</span> o; <a name="l00303"></a>00303 } <a name="l00304"></a>00304 <span class="comment"></span> <a name="l00305"></a>00305 <span class="comment">/// @ingroup ENCHL</span> <a name="l00306"></a>00306 <span class="comment">/// memory operand - segment, base, index, scale, and displacement</span> <a name="l00307"></a><a class="code" href="xed2-ia32_2include_2xed-encoder-hl_8h.html#00fc1e423b20d24b1843e502cc4d39a3">00307</a> <span class="comment"></span>XED_INLINE <span class="keyword">static</span> <a class="code" href="structxed__encoder__operand__t.html">xed_encoder_operand_t</a> <a class="code" href="xed2-ia32_2include_2xed-encoder-hl_8h.html#00fc1e423b20d24b1843e502cc4d39a3">xmem_gbisd</a>(<a class="code" href="xed2-ia32_2include_2xed-reg-enum_8h.html#f05c33c5a68e9304d1d8ac0408ae3f61">xed_reg_enum_t</a> seg, <a name="l00308"></a>00308 <a class="code" href="xed2-ia32_2include_2xed-reg-enum_8h.html#f05c33c5a68e9304d1d8ac0408ae3f61">xed_reg_enum_t</a> base, <a name="l00309"></a>00309 <a class="code" href="xed2-ia32_2include_2xed-reg-enum_8h.html#f05c33c5a68e9304d1d8ac0408ae3f61">xed_reg_enum_t</a> index, <a name="l00310"></a>00310 <a class="code" href="xed2-ia32_2include_2xed-types_8h.html#0c92e8263b7ca02d8e4826ae5b79bb30">xed_uint_t</a> scale, <a name="l00311"></a>00311 <a class="code" href="structxed__enc__displacement__t.html">xed_enc_displacement_t</a> disp, <a name="l00312"></a>00312 <a class="code" href="xed2-ia32_2include_2xed-types_8h.html#0c92e8263b7ca02d8e4826ae5b79bb30">xed_uint_t</a> width) { <a name="l00313"></a>00313 <a class="code" href="structxed__encoder__operand__t.html">xed_encoder_operand_t</a> o; <a name="l00314"></a>00314 o.<a class="code" href="structxed__encoder__operand__t.html#15b522f5fb9447f7bbea3ae6baf328a9">type</a> = <a class="code" href="xed2-ia32_2include_2xed-encoder-hl_8h.html#7621255aeac26b5e78f7a0dc72d12638fb6bee5a0fcf154e71397defed76ed88">XED_ENCODER_OPERAND_TYPE_MEM</a>; <a name="l00315"></a>00315 o.<a class="code" href="structxed__encoder__operand__t.html#01d174f19e13511270eefe522bc61248">u</a>.<a class="code" href="structxed__encoder__operand__t.html#7874f7a5284ff2064ba6b9bf032e25ff">mem</a>.<a class="code" href="structxed__memop__t.html#b33f5fd03ddbc01a1795e85978b32c61">base</a> = base; <a name="l00316"></a>00316 o.<a class="code" href="structxed__encoder__operand__t.html#01d174f19e13511270eefe522bc61248">u</a>.<a class="code" href="structxed__encoder__operand__t.html#7874f7a5284ff2064ba6b9bf032e25ff">mem</a>.<a class="code" href="structxed__memop__t.html#d07ef1ac72ff572e65e78b3653c43c1d">seg</a> = seg; <a name="l00317"></a>00317 o.<a class="code" href="structxed__encoder__operand__t.html#01d174f19e13511270eefe522bc61248">u</a>.<a class="code" href="structxed__encoder__operand__t.html#7874f7a5284ff2064ba6b9bf032e25ff">mem</a>.<a class="code" href="structxed__memop__t.html#451ae2fcc3acdff8a10543b18f19f84e">index</a>= index; <a name="l00318"></a>00318 o.<a class="code" href="structxed__encoder__operand__t.html#01d174f19e13511270eefe522bc61248">u</a>.<a class="code" href="structxed__encoder__operand__t.html#7874f7a5284ff2064ba6b9bf032e25ff">mem</a>.<a class="code" href="structxed__memop__t.html#d801bcd3961aa78d30caaca98489dd36">scale</a> = scale; <a name="l00319"></a>00319 o.<a class="code" href="structxed__encoder__operand__t.html#01d174f19e13511270eefe522bc61248">u</a>.<a class="code" href="structxed__encoder__operand__t.html#7874f7a5284ff2064ba6b9bf032e25ff">mem</a>.<a class="code" href="structxed__memop__t.html#1fd26bd97ff3565101e7e79ccf1d5a53">disp</a> = disp; <a name="l00320"></a>00320 o.<a class="code" href="structxed__encoder__operand__t.html#ea2d8c884cca697c2dbc9807dfbdd139">width</a> = width; <a name="l00321"></a>00321 <span class="keywordflow">return</span> o; <a name="l00322"></a>00322 }<span class="comment"></span> <a name="l00323"></a>00323 <span class="comment">//@}</span> <a name="l00324"></a>00324 <span class="comment"></span> <a name="l00325"></a><a class="code" href="unionxed__encoder__prefixes__t.html">00325</a> <span class="keyword">typedef</span> <span class="keyword">union </span>{ <a name="l00326"></a>00326 <span class="keyword">struct </span>{ <a name="l00327"></a><a class="code" href="unionxed__encoder__prefixes__t.html#c8dc70af0c2333374574b71ee91d66aa">00327</a> xed_uint32_t rep :1; <a name="l00328"></a><a class="code" href="unionxed__encoder__prefixes__t.html#d6e7f53ef6fc3cdd9cb45089e7978c86">00328</a> xed_uint32_t repne :1; <a name="l00329"></a><a class="code" href="unionxed__encoder__prefixes__t.html#045a7a7fb9c564bb2d14a71f22356a47">00329</a> xed_uint32_t lock :1; <a name="l00330"></a><a class="code" href="unionxed__encoder__prefixes__t.html#1f154d5ebf743d7d2220705a7d554a89">00330</a> xed_uint32_t br_hint_taken :1; <a name="l00331"></a><a class="code" href="unionxed__encoder__prefixes__t.html#bd09ac7e3aa0de912b2150a3f2000396">00331</a> xed_uint32_t br_hint_not_taken :1; <a name="l00332"></a>00332 } s; <a name="l00333"></a><a class="code" href="unionxed__encoder__prefixes__t.html#15762219ece938eca0db01a735121dbe">00333</a> xed_uint32_t i; <a name="l00334"></a>00334 } <a class="code" href="unionxed__encoder__prefixes__t.html">xed_encoder_prefixes_t</a>; <a name="l00335"></a>00335 <a name="l00336"></a>00336 <span class="preprocessor">#define XED_ENCODER_OPERANDS_MAX 5 </span><span class="comment">/* FIXME */</span> <a name="l00337"></a><a class="code" href="structxed__encoder__instruction__t.html">00337</a> <span class="keyword">typedef</span> <span class="keyword">struct </span>{ <a name="l00338"></a><a class="code" href="structxed__encoder__instruction__t.html#1647966dc2ac0f213f9674e6c1e7e336">00338</a> <a class="code" href="group__INIT.html#g58af142456a133c3df29c763216a85cf">xed_state_t</a> mode; <a name="l00339"></a><a class="code" href="structxed__encoder__instruction__t.html#bdc1758a5dc07d92701e95617d539909">00339</a> <a class="code" href="xed2-ia32_2include_2xed-iclass-enum_8h.html#d318511ae9cc50f102251b3c91a1ab9f">xed_iclass_enum_t</a> iclass; <span class="comment">/*FIXME: use iform instead? or allow either */</span> <a name="l00340"></a><a class="code" href="structxed__encoder__instruction__t.html#2b23c8d18171f9a4699744992b5cc026">00340</a> xed_uint32_t effective_operand_width; <a name="l00341"></a>00341 <a name="l00342"></a>00342 <span class="comment">/* the effective_address_width is only requires to be set for</span> <a name="l00343"></a>00343 <span class="comment"> * instructions * with implicit suppressed memops or memops with no</span> <a name="l00344"></a>00344 <span class="comment"> * base or index regs. When base or index regs are present, XED pick</span> <a name="l00345"></a>00345 <span class="comment"> * this up automatically from the register names.</span> <a name="l00346"></a>00346 <span class="comment"></span> <a name="l00347"></a>00347 <span class="comment"> * FIXME: make effective_address_width required by all encodes for</span> <a name="l00348"></a>00348 <span class="comment"> * unifority. Add to xed_inst[0123]() APIs??? */</span> <a name="l00349"></a><a class="code" href="structxed__encoder__instruction__t.html#d829df66320029ad521451b2896b18f3">00349</a> xed_uint32_t effective_address_width; <a name="l00350"></a>00350 <a name="l00351"></a><a class="code" href="structxed__encoder__instruction__t.html#76abfb9a09afa6474a8c673db06a3839">00351</a> <a class="code" href="unionxed__encoder__prefixes__t.html">xed_encoder_prefixes_t</a> prefixes; <a name="l00352"></a><a class="code" href="structxed__encoder__instruction__t.html#10c44c5cf064364003d1d4f6f4bbb7da">00352</a> xed_uint32_t noperands; <a name="l00353"></a><a class="code" href="structxed__encoder__instruction__t.html#0cc465ba90570b77abcc6e2833b43673">00353</a> <a class="code" href="structxed__encoder__operand__t.html">xed_encoder_operand_t</a> operands[XED_ENCODER_OPERANDS_MAX]; <a name="l00354"></a>00354 } <a class="code" href="structxed__encoder__instruction__t.html">xed_encoder_instruction_t</a>; <a name="l00355"></a>00355 <span class="comment"></span> <a name="l00356"></a>00356 <span class="comment">/// @name Instruction Properties and prefixes</span> <a name="l00357"></a>00357 <span class="comment"></span><span class="comment">//@{</span> <a name="l00358"></a>00358 <span class="comment"></span><span class="comment">/// @ingroup ENCHL</span> <a name="l00359"></a>00359 <span class="comment"></span><span class="comment">/// This is to specify effective address size different than the</span> <a name="l00360"></a>00360 <span class="comment"></span><span class="comment">/// default. For things with base or index regs, XED picks it up from the</span> <a name="l00361"></a>00361 <span class="comment"></span><span class="comment">/// registers. But for things that have implicit memops, or no base or index</span> <a name="l00362"></a>00362 <span class="comment"></span><span class="comment">/// reg, we must allow the user to set the address width directly.</span> <a name="l00363"></a><a class="code" href="xed2-ia32_2include_2xed-encoder-hl_8h.html#3dcef3e2652fa12f63eecd6fa29d2f48">00363</a> <span class="comment"></span>XED_INLINE <span class="keyword">static</span> <span class="keywordtype">void</span> <a class="code" href="xed2-ia32_2include_2xed-encoder-hl_8h.html#3dcef3e2652fa12f63eecd6fa29d2f48">xaddr</a>(<a class="code" href="structxed__encoder__instruction__t.html">xed_encoder_instruction_t</a>* x, <a name="l00364"></a>00364 <a class="code" href="xed2-ia32_2include_2xed-types_8h.html#0c92e8263b7ca02d8e4826ae5b79bb30">xed_uint_t</a> width) { <a name="l00365"></a>00365 x-&gt;<a class="code" href="structxed__encoder__instruction__t.html#d829df66320029ad521451b2896b18f3">effective_address_width</a> = width; <a name="l00366"></a>00366 } <a name="l00367"></a>00367 <a name="l00368"></a>00368 <span class="comment"></span> <a name="l00369"></a>00369 <span class="comment">/// @ingroup ENCHL</span> <a name="l00370"></a><a class="code" href="xed2-ia32_2include_2xed-encoder-hl_8h.html#089c068bfc4e04fe9571d1af267af068">00370</a> <span class="comment"></span>XED_INLINE <span class="keyword">static</span> <span class="keywordtype">void</span> <a class="code" href="xed2-ia32_2include_2xed-encoder-hl_8h.html#089c068bfc4e04fe9571d1af267af068">xrep</a>(<a class="code" href="structxed__encoder__instruction__t.html">xed_encoder_instruction_t</a>* x) { <a name="l00371"></a>00371 x-&gt;<a class="code" href="structxed__encoder__instruction__t.html#76abfb9a09afa6474a8c673db06a3839">prefixes</a>.<a class="code" href="unionxed__encoder__prefixes__t.html#2f01cb0ecd47fddfa9a0e4bc67d6f18c">s</a>.<a class="code" href="unionxed__encoder__prefixes__t.html#c8dc70af0c2333374574b71ee91d66aa">rep</a>=1; <a name="l00372"></a>00372 } <a name="l00373"></a>00373 <span class="comment"></span> <a name="l00374"></a>00374 <span class="comment">/// @ingroup ENCHL</span> <a name="l00375"></a><a class="code" href="xed2-ia32_2include_2xed-encoder-hl_8h.html#139f196ef758eabea56fc3c12bc04008">00375</a> <span class="comment"></span>XED_INLINE <span class="keyword">static</span> <span class="keywordtype">void</span> <a class="code" href="xed2-ia32_2include_2xed-encoder-hl_8h.html#139f196ef758eabea56fc3c12bc04008">xrepne</a>(<a class="code" href="structxed__encoder__instruction__t.html">xed_encoder_instruction_t</a>* x) { <a name="l00376"></a>00376 x-&gt;<a class="code" href="structxed__encoder__instruction__t.html#76abfb9a09afa6474a8c673db06a3839">prefixes</a>.<a class="code" href="unionxed__encoder__prefixes__t.html#2f01cb0ecd47fddfa9a0e4bc67d6f18c">s</a>.<a class="code" href="unionxed__encoder__prefixes__t.html#d6e7f53ef6fc3cdd9cb45089e7978c86">repne</a>=1; <a name="l00377"></a>00377 } <a name="l00378"></a>00378 <span class="comment"></span> <a name="l00379"></a>00379 <span class="comment">/// @ingroup ENCHL</span> <a name="l00380"></a><a class="code" href="xed2-ia32_2include_2xed-encoder-hl_8h.html#2bddb61d7cc4980ad081933603a98bf4">00380</a> <span class="comment"></span>XED_INLINE <span class="keyword">static</span> <span class="keywordtype">void</span> <a class="code" href="xed2-ia32_2include_2xed-encoder-hl_8h.html#2bddb61d7cc4980ad081933603a98bf4">xlock</a>(<a class="code" href="structxed__encoder__instruction__t.html">xed_encoder_instruction_t</a>* x) { <a name="l00381"></a>00381 x-&gt;<a class="code" href="structxed__encoder__instruction__t.html#76abfb9a09afa6474a8c673db06a3839">prefixes</a>.<a class="code" href="unionxed__encoder__prefixes__t.html#2f01cb0ecd47fddfa9a0e4bc67d6f18c">s</a>.<a class="code" href="unionxed__encoder__prefixes__t.html#045a7a7fb9c564bb2d14a71f22356a47">lock</a>=1; <a name="l00382"></a>00382 } <a name="l00383"></a>00383 <a name="l00384"></a>00384 <a name="l00385"></a>00385 <a name="l00386"></a>00386 <span class="comment"></span> <a name="l00387"></a>00387 <span class="comment">/// @ingroup ENCHL</span> <a name="l00388"></a>00388 <span class="comment">/// convert a #xed_encoder_instruction_t to a #xed_encoder_request_t for encoding</span> <a name="l00389"></a>00389 <span class="comment"></span><a class="code" href="xed2-ia32_2include_2xed-types_8h.html#d355c921b747945a82d62233a599c7b5">xed_bool_t</a> <a class="code" href="xed2-ia32_2include_2xed-encoder-hl_8h.html#22b6ec424e2b07c28f7094196c039172">xed_convert_to_encoder_request</a>(<a class="code" href="xed2-ia32_2include_2xed-encode_8h.html#6f914541ddfa1ffe609acebff72d0b5f">xed_encoder_request_t</a>* out, <a name="l00390"></a>00390 <a class="code" href="structxed__encoder__instruction__t.html">xed_encoder_instruction_t</a>* in); <a name="l00391"></a>00391 <span class="comment"></span> <a name="l00392"></a>00392 <span class="comment">//@}</span> <a name="l00393"></a>00393 <span class="comment"></span><span class="comment"></span> <a name="l00394"></a>00394 <span class="comment">////////////////////////////////////////////////////////////////////////////</span> <a name="l00395"></a>00395 <span class="comment"></span><span class="comment">/* FIXME: rather than return the xed_encoder_instruction_t I can make</span> <a name="l00396"></a>00396 <span class="comment"> * another version that returns a xed_encoder_request_t. Saves silly</span> <a name="l00397"></a>00397 <span class="comment"> * copying. Although the xed_encoder_instruction_t might be handy for</span> <a name="l00398"></a>00398 <span class="comment"> * having code templates that get customized &amp; passed to encoder later. */</span><span class="comment"></span> <a name="l00399"></a>00399 <span class="comment">////////////////////////////////////////////////////////////////////////////</span> <a name="l00400"></a>00400 <span class="comment">/// @name Creating instructions from operands</span> <a name="l00401"></a>00401 <span class="comment"></span><span class="comment">//@{</span> <a name="l00402"></a>00402 <span class="comment"></span><span class="comment"></span> <a name="l00403"></a>00403 <span class="comment">/// @ingroup ENCHL</span> <a name="l00404"></a>00404 <span class="comment">/// instruction with no operands</span> <a name="l00405"></a><a class="code" href="xed2-ia32_2include_2xed-encoder-hl_8h.html#8d463fe5834dfc1dd4e4664fbf897528">00405</a> <span class="comment"></span>XED_INLINE <span class="keyword">static</span> <span class="keywordtype">void</span> <a class="code" href="xed2-ia32_2include_2xed-encoder-hl_8h.html#8d463fe5834dfc1dd4e4664fbf897528">xed_inst0</a>( <a name="l00406"></a>00406 <a class="code" href="structxed__encoder__instruction__t.html">xed_encoder_instruction_t</a>* inst, <a name="l00407"></a>00407 <a class="code" href="group__INIT.html#g58af142456a133c3df29c763216a85cf">xed_state_t</a> mode, <a name="l00408"></a>00408 <a class="code" href="xed2-ia32_2include_2xed-iclass-enum_8h.html#d318511ae9cc50f102251b3c91a1ab9f">xed_iclass_enum_t</a> iclass, <a name="l00409"></a>00409 <a class="code" href="xed2-ia32_2include_2xed-types_8h.html#0c92e8263b7ca02d8e4826ae5b79bb30">xed_uint_t</a> effective_operand_width) { <a name="l00410"></a>00410 <a name="l00411"></a>00411 inst-&gt;<a class="code" href="structxed__encoder__instruction__t.html#1647966dc2ac0f213f9674e6c1e7e336">mode</a>=mode; <a name="l00412"></a>00412 inst-&gt;<a class="code" href="structxed__encoder__instruction__t.html#bdc1758a5dc07d92701e95617d539909">iclass</a> = iclass; <a name="l00413"></a>00413 inst-&gt;<a class="code" href="structxed__encoder__instruction__t.html#2b23c8d18171f9a4699744992b5cc026">effective_operand_width</a> = effective_operand_width; <a name="l00414"></a>00414 inst-&gt;<a class="code" href="structxed__encoder__instruction__t.html#d829df66320029ad521451b2896b18f3">effective_address_width</a> = 0; <a name="l00415"></a>00415 inst-&gt;<a class="code" href="structxed__encoder__instruction__t.html#76abfb9a09afa6474a8c673db06a3839">prefixes</a>.<a class="code" href="unionxed__encoder__prefixes__t.html#15762219ece938eca0db01a735121dbe">i</a> = 0; <a name="l00416"></a>00416 inst-&gt;<a class="code" href="structxed__encoder__instruction__t.html#10c44c5cf064364003d1d4f6f4bbb7da">noperands</a> = 0; <a name="l00417"></a>00417 } <a name="l00418"></a>00418 <span class="comment"></span> <a name="l00419"></a>00419 <span class="comment">/// @ingroup ENCHL</span> <a name="l00420"></a>00420 <span class="comment">/// instruction with one operand</span> <a name="l00421"></a><a class="code" href="xed2-ia32_2include_2xed-encoder-hl_8h.html#605a860a788e8ba6d7342783be23a093">00421</a> <span class="comment"></span>XED_INLINE <span class="keyword">static</span> <span class="keywordtype">void</span> <a class="code" href="xed2-ia32_2include_2xed-encoder-hl_8h.html#605a860a788e8ba6d7342783be23a093">xed_inst1</a>( <a name="l00422"></a>00422 <a class="code" href="structxed__encoder__instruction__t.html">xed_encoder_instruction_t</a>* inst, <a name="l00423"></a>00423 <a class="code" href="group__INIT.html#g58af142456a133c3df29c763216a85cf">xed_state_t</a> mode, <a name="l00424"></a>00424 <a class="code" href="xed2-ia32_2include_2xed-iclass-enum_8h.html#d318511ae9cc50f102251b3c91a1ab9f">xed_iclass_enum_t</a> iclass, <a name="l00425"></a>00425 <a class="code" href="xed2-ia32_2include_2xed-types_8h.html#0c92e8263b7ca02d8e4826ae5b79bb30">xed_uint_t</a> effective_operand_width, <a name="l00426"></a>00426 <a class="code" href="structxed__encoder__operand__t.html">xed_encoder_operand_t</a> op0) { <a name="l00427"></a>00427 <a name="l00428"></a>00428 inst-&gt;<a class="code" href="structxed__encoder__instruction__t.html#1647966dc2ac0f213f9674e6c1e7e336">mode</a>=mode; <a name="l00429"></a>00429 inst-&gt;<a class="code" href="structxed__encoder__instruction__t.html#bdc1758a5dc07d92701e95617d539909">iclass</a> = iclass; <a name="l00430"></a>00430 inst-&gt;<a class="code" href="structxed__encoder__instruction__t.html#2b23c8d18171f9a4699744992b5cc026">effective_operand_width</a> = effective_operand_width; <a name="l00431"></a>00431 inst-&gt;<a class="code" href="structxed__encoder__instruction__t.html#d829df66320029ad521451b2896b18f3">effective_address_width</a> = 0; <a name="l00432"></a>00432 inst-&gt;<a class="code" href="structxed__encoder__instruction__t.html#76abfb9a09afa6474a8c673db06a3839">prefixes</a>.<a class="code" href="unionxed__encoder__prefixes__t.html#15762219ece938eca0db01a735121dbe">i</a> = 0; <a name="l00433"></a>00433 inst-&gt;<a class="code" href="structxed__encoder__instruction__t.html#0cc465ba90570b77abcc6e2833b43673">operands</a>[0] = op0; <a name="l00434"></a>00434 inst-&gt;<a class="code" href="structxed__encoder__instruction__t.html#10c44c5cf064364003d1d4f6f4bbb7da">noperands</a> = 1; <a name="l00435"></a>00435 } <a name="l00436"></a>00436 <span class="comment"></span> <a name="l00437"></a>00437 <span class="comment">/// @ingroup ENCHL</span> <a name="l00438"></a>00438 <span class="comment">/// instruction with two operands</span> <a name="l00439"></a><a class="code" href="xed2-ia32_2include_2xed-encoder-hl_8h.html#d2669ef272ad5c97d0e5070b50cce5ec">00439</a> <span class="comment"></span>XED_INLINE <span class="keyword">static</span> <span class="keywordtype">void</span> <a class="code" href="xed2-ia32_2include_2xed-encoder-hl_8h.html#d2669ef272ad5c97d0e5070b50cce5ec">xed_inst2</a>( <a name="l00440"></a>00440 <a class="code" href="structxed__encoder__instruction__t.html">xed_encoder_instruction_t</a>* inst, <a name="l00441"></a>00441 <a class="code" href="group__INIT.html#g58af142456a133c3df29c763216a85cf">xed_state_t</a> mode, <a name="l00442"></a>00442 <a class="code" href="xed2-ia32_2include_2xed-iclass-enum_8h.html#d318511ae9cc50f102251b3c91a1ab9f">xed_iclass_enum_t</a> iclass, <a name="l00443"></a>00443 <a class="code" href="xed2-ia32_2include_2xed-types_8h.html#0c92e8263b7ca02d8e4826ae5b79bb30">xed_uint_t</a> effective_operand_width, <a name="l00444"></a>00444 <a class="code" href="structxed__encoder__operand__t.html">xed_encoder_operand_t</a> op0, <a name="l00445"></a>00445 <a class="code" href="structxed__encoder__operand__t.html">xed_encoder_operand_t</a> op1) { <a name="l00446"></a>00446 <a name="l00447"></a>00447 inst-&gt;<a class="code" href="structxed__encoder__instruction__t.html#1647966dc2ac0f213f9674e6c1e7e336">mode</a>=mode; <a name="l00448"></a>00448 inst-&gt;<a class="code" href="structxed__encoder__instruction__t.html#bdc1758a5dc07d92701e95617d539909">iclass</a> = iclass; <a name="l00449"></a>00449 inst-&gt;<a class="code" href="structxed__encoder__instruction__t.html#2b23c8d18171f9a4699744992b5cc026">effective_operand_width</a> = effective_operand_width; <a name="l00450"></a>00450 inst-&gt;<a class="code" href="structxed__encoder__instruction__t.html#d829df66320029ad521451b2896b18f3">effective_address_width</a> = 0; <a name="l00451"></a>00451 inst-&gt;<a class="code" href="structxed__encoder__instruction__t.html#76abfb9a09afa6474a8c673db06a3839">prefixes</a>.<a class="code" href="unionxed__encoder__prefixes__t.html#15762219ece938eca0db01a735121dbe">i</a> = 0; <a name="l00452"></a>00452 inst-&gt;<a class="code" href="structxed__encoder__instruction__t.html#0cc465ba90570b77abcc6e2833b43673">operands</a>[0] = op0; <a name="l00453"></a>00453 inst-&gt;<a class="code" href="structxed__encoder__instruction__t.html#0cc465ba90570b77abcc6e2833b43673">operands</a>[1] = op1; <a name="l00454"></a>00454 inst-&gt;<a class="code" href="structxed__encoder__instruction__t.html#10c44c5cf064364003d1d4f6f4bbb7da">noperands</a> = 2; <a name="l00455"></a>00455 } <a name="l00456"></a>00456 <span class="comment"></span> <a name="l00457"></a>00457 <span class="comment">/// @ingroup ENCHL</span> <a name="l00458"></a>00458 <span class="comment">/// instruction with three operands</span> <a name="l00459"></a><a class="code" href="xed2-ia32_2include_2xed-encoder-hl_8h.html#5bf8b6ae6bb2bfd07725c1acfea2ac2b">00459</a> <span class="comment"></span>XED_INLINE <span class="keyword">static</span> <span class="keywordtype">void</span> <a class="code" href="xed2-ia32_2include_2xed-encoder-hl_8h.html#5bf8b6ae6bb2bfd07725c1acfea2ac2b">xed_inst3</a>( <a name="l00460"></a>00460 <a class="code" href="structxed__encoder__instruction__t.html">xed_encoder_instruction_t</a>* inst, <a name="l00461"></a>00461 <a class="code" href="group__INIT.html#g58af142456a133c3df29c763216a85cf">xed_state_t</a> mode, <a name="l00462"></a>00462 <a class="code" href="xed2-ia32_2include_2xed-iclass-enum_8h.html#d318511ae9cc50f102251b3c91a1ab9f">xed_iclass_enum_t</a> iclass, <a name="l00463"></a>00463 <a class="code" href="xed2-ia32_2include_2xed-types_8h.html#0c92e8263b7ca02d8e4826ae5b79bb30">xed_uint_t</a> effective_operand_width, <a name="l00464"></a>00464 <a class="code" href="structxed__encoder__operand__t.html">xed_encoder_operand_t</a> op0, <a name="l00465"></a>00465 <a class="code" href="structxed__encoder__operand__t.html">xed_encoder_operand_t</a> op1, <a name="l00466"></a>00466 <a class="code" href="structxed__encoder__operand__t.html">xed_encoder_operand_t</a> op2) { <a name="l00467"></a>00467 <a name="l00468"></a>00468 inst-&gt;<a class="code" href="structxed__encoder__instruction__t.html#1647966dc2ac0f213f9674e6c1e7e336">mode</a>=mode; <a name="l00469"></a>00469 inst-&gt;<a class="code" href="structxed__encoder__instruction__t.html#bdc1758a5dc07d92701e95617d539909">iclass</a> = iclass; <a name="l00470"></a>00470 inst-&gt;<a class="code" href="structxed__encoder__instruction__t.html#2b23c8d18171f9a4699744992b5cc026">effective_operand_width</a> = effective_operand_width; <a name="l00471"></a>00471 inst-&gt;<a class="code" href="structxed__encoder__instruction__t.html#d829df66320029ad521451b2896b18f3">effective_address_width</a> = 0; <a name="l00472"></a>00472 inst-&gt;<a class="code" href="structxed__encoder__instruction__t.html#76abfb9a09afa6474a8c673db06a3839">prefixes</a>.<a class="code" href="unionxed__encoder__prefixes__t.html#15762219ece938eca0db01a735121dbe">i</a> = 0; <a name="l00473"></a>00473 inst-&gt;<a class="code" href="structxed__encoder__instruction__t.html#0cc465ba90570b77abcc6e2833b43673">operands</a>[0] = op0; <a name="l00474"></a>00474 inst-&gt;<a class="code" href="structxed__encoder__instruction__t.html#0cc465ba90570b77abcc6e2833b43673">operands</a>[1] = op1; <a name="l00475"></a>00475 inst-&gt;<a class="code" href="structxed__encoder__instruction__t.html#0cc465ba90570b77abcc6e2833b43673">operands</a>[2] = op2; <a name="l00476"></a>00476 inst-&gt;<a class="code" href="structxed__encoder__instruction__t.html#10c44c5cf064364003d1d4f6f4bbb7da">noperands</a> = 3; <a name="l00477"></a>00477 } <a name="l00478"></a>00478 <a name="l00479"></a>00479 <span class="comment"></span> <a name="l00480"></a>00480 <span class="comment">/// @ingroup ENCHL</span> <a name="l00481"></a>00481 <span class="comment">/// instruction with four operands</span> <a name="l00482"></a><a class="code" href="xed2-ia32_2include_2xed-encoder-hl_8h.html#49825c9af03114c82b10b61aefa8ce93">00482</a> <span class="comment"></span>XED_INLINE <span class="keyword">static</span> <span class="keywordtype">void</span> <a class="code" href="xed2-ia32_2include_2xed-encoder-hl_8h.html#49825c9af03114c82b10b61aefa8ce93">xed_inst4</a>( <a name="l00483"></a>00483 <a class="code" href="structxed__encoder__instruction__t.html">xed_encoder_instruction_t</a>* inst, <a name="l00484"></a>00484 <a class="code" href="group__INIT.html#g58af142456a133c3df29c763216a85cf">xed_state_t</a> mode, <a name="l00485"></a>00485 <a class="code" href="xed2-ia32_2include_2xed-iclass-enum_8h.html#d318511ae9cc50f102251b3c91a1ab9f">xed_iclass_enum_t</a> iclass, <a name="l00486"></a>00486 <a class="code" href="xed2-ia32_2include_2xed-types_8h.html#0c92e8263b7ca02d8e4826ae5b79bb30">xed_uint_t</a> effective_operand_width, <a name="l00487"></a>00487 <a class="code" href="structxed__encoder__operand__t.html">xed_encoder_operand_t</a> op0, <a name="l00488"></a>00488 <a class="code" href="structxed__encoder__operand__t.html">xed_encoder_operand_t</a> op1, <a name="l00489"></a>00489 <a class="code" href="structxed__encoder__operand__t.html">xed_encoder_operand_t</a> op2, <a name="l00490"></a>00490 <a class="code" href="structxed__encoder__operand__t.html">xed_encoder_operand_t</a> op3) { <a name="l00491"></a>00491 <a name="l00492"></a>00492 inst-&gt;<a class="code" href="structxed__encoder__instruction__t.html#1647966dc2ac0f213f9674e6c1e7e336">mode</a>=mode; <a name="l00493"></a>00493 inst-&gt;<a class="code" href="structxed__encoder__instruction__t.html#bdc1758a5dc07d92701e95617d539909">iclass</a> = iclass; <a name="l00494"></a>00494 inst-&gt;<a class="code" href="structxed__encoder__instruction__t.html#2b23c8d18171f9a4699744992b5cc026">effective_operand_width</a> = effective_operand_width; <a name="l00495"></a>00495 inst-&gt;<a class="code" href="structxed__encoder__instruction__t.html#d829df66320029ad521451b2896b18f3">effective_address_width</a> = 0; <a name="l00496"></a>00496 inst-&gt;<a class="code" href="structxed__encoder__instruction__t.html#76abfb9a09afa6474a8c673db06a3839">prefixes</a>.<a class="code" href="unionxed__encoder__prefixes__t.html#15762219ece938eca0db01a735121dbe">i</a> = 0; <a name="l00497"></a>00497 inst-&gt;<a class="code" href="structxed__encoder__instruction__t.html#0cc465ba90570b77abcc6e2833b43673">operands</a>[0] = op0; <a name="l00498"></a>00498 inst-&gt;<a class="code" href="structxed__encoder__instruction__t.html#0cc465ba90570b77abcc6e2833b43673">operands</a>[1] = op1; <a name="l00499"></a>00499 inst-&gt;<a class="code" href="structxed__encoder__instruction__t.html#0cc465ba90570b77abcc6e2833b43673">operands</a>[2] = op2; <a name="l00500"></a>00500 inst-&gt;<a class="code" href="structxed__encoder__instruction__t.html#0cc465ba90570b77abcc6e2833b43673">operands</a>[3] = op3; <a name="l00501"></a>00501 inst-&gt;<a class="code" href="structxed__encoder__instruction__t.html#10c44c5cf064364003d1d4f6f4bbb7da">noperands</a> = 4; <a name="l00502"></a>00502 } <a name="l00503"></a>00503 <span class="comment"></span> <a name="l00504"></a>00504 <span class="comment">/// @ingroup ENCHL</span> <a name="l00505"></a>00505 <span class="comment">/// instruction with five operands</span> <a name="l00506"></a><a class="code" href="xed2-ia32_2include_2xed-encoder-hl_8h.html#3a745d122221c6039c4aad0c2e61bc68">00506</a> <span class="comment"></span>XED_INLINE <span class="keyword">static</span> <span class="keywordtype">void</span> <a class="code" href="xed2-ia32_2include_2xed-encoder-hl_8h.html#3a745d122221c6039c4aad0c2e61bc68">xed_inst5</a>( <a name="l00507"></a>00507 <a class="code" href="structxed__encoder__instruction__t.html">xed_encoder_instruction_t</a>* inst, <a name="l00508"></a>00508 <a class="code" href="group__INIT.html#g58af142456a133c3df29c763216a85cf">xed_state_t</a> mode, <a name="l00509"></a>00509 <a class="code" href="xed2-ia32_2include_2xed-iclass-enum_8h.html#d318511ae9cc50f102251b3c91a1ab9f">xed_iclass_enum_t</a> iclass, <a name="l00510"></a>00510 <a class="code" href="xed2-ia32_2include_2xed-types_8h.html#0c92e8263b7ca02d8e4826ae5b79bb30">xed_uint_t</a> effective_operand_width, <a name="l00511"></a>00511 <a class="code" href="structxed__encoder__operand__t.html">xed_encoder_operand_t</a> op0, <a name="l00512"></a>00512 <a class="code" href="structxed__encoder__operand__t.html">xed_encoder_operand_t</a> op1, <a name="l00513"></a>00513 <a class="code" href="structxed__encoder__operand__t.html">xed_encoder_operand_t</a> op2, <a name="l00514"></a>00514 <a class="code" href="structxed__encoder__operand__t.html">xed_encoder_operand_t</a> op3, <a name="l00515"></a>00515 <a class="code" href="structxed__encoder__operand__t.html">xed_encoder_operand_t</a> op4) { <a name="l00516"></a>00516 <a name="l00517"></a>00517 inst-&gt;<a class="code" href="structxed__encoder__instruction__t.html#1647966dc2ac0f213f9674e6c1e7e336">mode</a>=mode; <a name="l00518"></a>00518 inst-&gt;<a class="code" href="structxed__encoder__instruction__t.html#bdc1758a5dc07d92701e95617d539909">iclass</a> = iclass; <a name="l00519"></a>00519 inst-&gt;<a class="code" href="structxed__encoder__instruction__t.html#2b23c8d18171f9a4699744992b5cc026">effective_operand_width</a> = effective_operand_width; <a name="l00520"></a>00520 inst-&gt;<a class="code" href="structxed__encoder__instruction__t.html#d829df66320029ad521451b2896b18f3">effective_address_width</a> = 0; <a name="l00521"></a>00521 inst-&gt;<a class="code" href="structxed__encoder__instruction__t.html#76abfb9a09afa6474a8c673db06a3839">prefixes</a>.<a class="code" href="unionxed__encoder__prefixes__t.html#15762219ece938eca0db01a735121dbe">i</a> = 0; <a name="l00522"></a>00522 inst-&gt;<a class="code" href="structxed__encoder__instruction__t.html#0cc465ba90570b77abcc6e2833b43673">operands</a>[0] = op0; <a name="l00523"></a>00523 inst-&gt;<a class="code" href="structxed__encoder__instruction__t.html#0cc465ba90570b77abcc6e2833b43673">operands</a>[1] = op1; <a name="l00524"></a>00524 inst-&gt;<a class="code" href="structxed__encoder__instruction__t.html#0cc465ba90570b77abcc6e2833b43673">operands</a>[2] = op2; <a name="l00525"></a>00525 inst-&gt;<a class="code" href="structxed__encoder__instruction__t.html#0cc465ba90570b77abcc6e2833b43673">operands</a>[3] = op3; <a name="l00526"></a>00526 inst-&gt;<a class="code" href="structxed__encoder__instruction__t.html#0cc465ba90570b77abcc6e2833b43673">operands</a>[4] = op4; <a name="l00527"></a>00527 inst-&gt;<a class="code" href="structxed__encoder__instruction__t.html#10c44c5cf064364003d1d4f6f4bbb7da">noperands</a> = 5; <a name="l00528"></a>00528 } <a name="l00529"></a>00529 <a name="l00530"></a>00530 <span class="comment"></span> <a name="l00531"></a>00531 <span class="comment">/// @ingroup ENCHL</span> <a name="l00532"></a>00532 <span class="comment">/// instruction with an array of operands. The maximum number is</span> <a name="l00533"></a>00533 <span class="comment">/// XED_ENCODER_OPERANDS_MAX. The array's contents are copied.</span> <a name="l00534"></a><a class="code" href="xed2-ia32_2include_2xed-encoder-hl_8h.html#0b2f5d72a7c89397c9eb011280d4b001">00534</a> <span class="comment"></span>XED_INLINE <span class="keyword">static</span> <span class="keywordtype">void</span> <a class="code" href="xed2-ia32_2include_2xed-encoder-hl_8h.html#0b2f5d72a7c89397c9eb011280d4b001">xed_inst</a>( <a name="l00535"></a>00535 <a class="code" href="structxed__encoder__instruction__t.html">xed_encoder_instruction_t</a>* inst, <a name="l00536"></a>00536 <a class="code" href="group__INIT.html#g58af142456a133c3df29c763216a85cf">xed_state_t</a> mode, <a name="l00537"></a>00537 <a class="code" href="xed2-ia32_2include_2xed-iclass-enum_8h.html#d318511ae9cc50f102251b3c91a1ab9f">xed_iclass_enum_t</a> iclass, <a name="l00538"></a>00538 <a class="code" href="xed2-ia32_2include_2xed-types_8h.html#0c92e8263b7ca02d8e4826ae5b79bb30">xed_uint_t</a> effective_operand_width, <a name="l00539"></a>00539 <a class="code" href="xed2-ia32_2include_2xed-types_8h.html#0c92e8263b7ca02d8e4826ae5b79bb30">xed_uint_t</a> number_of_operands, <a name="l00540"></a>00540 <span class="keyword">const</span> <a class="code" href="structxed__encoder__operand__t.html">xed_encoder_operand_t</a>* operand_array) { <a name="l00541"></a>00541 <a name="l00542"></a>00542 <a class="code" href="xed2-ia32_2include_2xed-types_8h.html#0c92e8263b7ca02d8e4826ae5b79bb30">xed_uint_t</a> i; <a name="l00543"></a>00543 inst-&gt;<a class="code" href="structxed__encoder__instruction__t.html#1647966dc2ac0f213f9674e6c1e7e336">mode</a>=mode; <a name="l00544"></a>00544 inst-&gt;<a class="code" href="structxed__encoder__instruction__t.html#bdc1758a5dc07d92701e95617d539909">iclass</a> = iclass; <a name="l00545"></a>00545 inst-&gt;<a class="code" href="structxed__encoder__instruction__t.html#2b23c8d18171f9a4699744992b5cc026">effective_operand_width</a> = effective_operand_width; <a name="l00546"></a>00546 inst-&gt;<a class="code" href="structxed__encoder__instruction__t.html#d829df66320029ad521451b2896b18f3">effective_address_width</a> = 0; <a name="l00547"></a>00547 inst-&gt;<a class="code" href="structxed__encoder__instruction__t.html#76abfb9a09afa6474a8c673db06a3839">prefixes</a>.<a class="code" href="unionxed__encoder__prefixes__t.html#15762219ece938eca0db01a735121dbe">i</a> = 0; <a name="l00548"></a>00548 xed_assert(number_of_operands &lt; XED_ENCODER_OPERANDS_MAX); <a name="l00549"></a>00549 <span class="keywordflow">for</span>(i=0;i&lt;number_of_operands;i++) { <a name="l00550"></a>00550 inst-&gt;<a class="code" href="structxed__encoder__instruction__t.html#0cc465ba90570b77abcc6e2833b43673">operands</a>[i] = operand_array[i]; <a name="l00551"></a>00551 } <a name="l00552"></a>00552 inst-&gt;<a class="code" href="structxed__encoder__instruction__t.html#10c44c5cf064364003d1d4f6f4bbb7da">noperands</a> = number_of_operands; <a name="l00553"></a>00553 } <a name="l00554"></a>00554 <span class="comment"></span> <a name="l00555"></a>00555 <span class="comment">//@}</span> <a name="l00556"></a>00556 <span class="comment"></span> <a name="l00557"></a>00557 <span class="comment">/*</span> <a name="l00558"></a>00558 <span class="comment"> xed_encoder_instruction_t x,y;</span> <a name="l00559"></a>00559 <span class="comment"></span> <a name="l00560"></a>00560 <span class="comment"> xed_inst2(&amp;x, state, XED_ICLASS_ADD, 32, </span> <a name="l00561"></a>00561 <span class="comment"> xreg(XED_REG_EAX), </span> <a name="l00562"></a>00562 <span class="comment"> xmem_bd(XED_REG_EDX, xdisp(0x11223344, 32), 32));</span> <a name="l00563"></a>00563 <span class="comment"> </span> <a name="l00564"></a>00564 <span class="comment"> xed_inst2(&amp;y, state, XED_ICLASS_ADD, 32, </span> <a name="l00565"></a>00565 <span class="comment"> xreg(XED_REG_EAX), </span> <a name="l00566"></a>00566 <span class="comment"> xmem_gbisd(XED_REG_FS, XED_REG_EAX, XED_REG_ESI,4, xdisp(0x11223344, 32), 32));</span> <a name="l00567"></a>00567 <span class="comment"></span> <a name="l00568"></a>00568 <span class="comment"> */</span> <a name="l00569"></a>00569 <a name="l00570"></a>00570 <span class="preprocessor">#endif</span> </pre></div></div> <hr> <p class="footer"> Generated on Fri Mar 30 16:18:24 2012 for <a href="http://bitblaze.cs.berkeley.edu/temu.html">TEMU</a> by <a href="http://www.doxygen.org"><img src="doxygen.png" alt="Doxygen" align="middle" border="0"/>1.5.8</a><br/> Copyright &copy; 2008-2009, BitBlaze Project. All Rights Reserved.</p> <hr> <!--#include virtual="/attrib.incl" --> </body> </html>
huydhn/Detector
docs/doxygen/html/xed2-ia32_2include_2xed-encoder-hl_8h-source.html
HTML
gpl-2.0
95,085
BoardConnetServer ================= server application that run on embedded linux based development boards ( Begalbone Bone, Beagleboard, Altera SocKit, Xilinx ZedBoard ) connects to android app
sandeshghimire/BoardConnetServer
README.md
Markdown
gpl-2.0
198
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/> <title>Luayats: src/src/bssrc.h Source File</title> <link href="tabs.css" rel="stylesheet" type="text/css"/> <link href="doxygen.css" rel="stylesheet" type="text/css"/> </head> <body> <!-- Generated by Doxygen 1.6.1 --> <div class="navigation" id="top"> <div class="tabs"> <ul> <li><a href="index.html"><span>Main&nbsp;Page</span></a></li> <li><a href="annotated.html"><span>Classes</span></a></li> <li class="current"><a href="files.html"><span>Files</span></a></li> </ul> </div> <div class="tabs"> <ul> <li><a href="files.html"><span>File&nbsp;List</span></a></li> <li><a href="globals.html"><span>File&nbsp;Members</span></a></li> </ul> </div> <h1>src/src/bssrc.h</h1><a href="bssrc_8h.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">/*************************************************************************</span> <a name="l00002"></a>00002 <span class="comment">*</span> <a name="l00003"></a>00003 <span class="comment">* YATS - Yet Another Tiny Simulator</span> <a name="l00004"></a>00004 <span class="comment">*</span> <a name="l00005"></a>00005 <span class="comment">**************************************************************************</span> <a name="l00006"></a>00006 <span class="comment">*</span> <a name="l00007"></a>00007 <span class="comment">* Copyright (C) 1995-1997 Chair for Telecommunications</span> <a name="l00008"></a>00008 <span class="comment">* Dresden University of Technology</span> <a name="l00009"></a>00009 <span class="comment">* D-01062 Dresden</span> <a name="l00010"></a>00010 <span class="comment">* Germany</span> <a name="l00011"></a>00011 <span class="comment">*</span> <a name="l00012"></a>00012 <span class="comment">**************************************************************************</span> <a name="l00013"></a>00013 <span class="comment">*</span> <a name="l00014"></a>00014 <span class="comment">* This program is free software; you can redistribute it and/or modify</span> <a name="l00015"></a>00015 <span class="comment">* it under the terms of the GNU General Public License as published by</span> <a name="l00016"></a>00016 <span class="comment">* the Free Software Foundation; either version 2 of the License, or</span> <a name="l00017"></a>00017 <span class="comment">* (at your option) any later version.</span> <a name="l00018"></a>00018 <span class="comment">*</span> <a name="l00019"></a>00019 <span class="comment">* This program is distributed in the hope that it will be useful,</span> <a name="l00020"></a>00020 <span class="comment">* but WITHOUT ANY WARRANTY; without even the implied warranty of</span> <a name="l00021"></a>00021 <span class="comment">* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the</span> <a name="l00022"></a>00022 <span class="comment">* GNU General Public License for more details.</span> <a name="l00023"></a>00023 <span class="comment">*</span> <a name="l00024"></a>00024 <span class="comment">* You should have received a copy of the GNU General Public License</span> <a name="l00025"></a>00025 <span class="comment">* along with this program; if not, write to the Free Software</span> <a name="l00026"></a>00026 <span class="comment">* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.</span> <a name="l00027"></a>00027 <span class="comment">*</span> <a name="l00028"></a>00028 <span class="comment">*************************************************************************/</span> <a name="l00029"></a>00029 <a name="l00030"></a>00030 <span class="comment">// changed 2004-10-15: included deterministic_behaviour variable.</span> <a name="l00031"></a>00031 <span class="comment">// If deterministic_behaviour is set to 1, the burst and silence</span> <a name="l00032"></a>00032 <span class="comment">// lengths are fix, not chosen from a distribution</span> <a name="l00033"></a>00033 <a name="l00034"></a>00034 <span class="preprocessor">#ifndef _BSSRC_H_</span> <a name="l00035"></a>00035 <span class="preprocessor"></span><span class="preprocessor">#define _BSSRC_H_</span> <a name="l00036"></a>00036 <span class="preprocessor"></span> <a name="l00037"></a>00037 <span class="preprocessor">#include &quot;<a class="code" href="in1out_8h.html">in1out.h</a>&quot;</span> <a name="l00038"></a>00038 <a name="l00039"></a>00039 <span class="comment">//tolua_begin</span> <a name="l00040"></a><a class="code" href="classbssrc.html">00040</a> <span class="keyword">class </span><a class="code" href="classbssrc.html">bssrc</a>: <span class="keyword">public</span> <a class="code" href="classin1out.html">in1out</a> { <a name="l00041"></a>00041 <span class="keyword">typedef</span> <a class="code" href="classin1out.html">in1out</a> <a class="code" href="classino.html">baseclass</a>; <a name="l00042"></a>00042 <a name="l00043"></a>00043 <span class="keyword">public</span>: <a name="l00044"></a>00044 <a class="code" href="classbssrc.html#a798d93c795807f551b5089105cc7f4ba">bssrc</a>(); <a name="l00045"></a>00045 <a class="code" href="classbssrc.html#ae3dea53e1cc3d34c19ee0b212d1a7903">~bssrc</a>(); <a name="l00046"></a>00046 <a name="l00047"></a>00047 <span class="keywordtype">void</span> <a class="code" href="classbssrc.html#a7125cf14df4e4eacf34134f9ddeec2dd">SetDeterministicEx</a>(<span class="keywordtype">int</span> det); <span class="comment">// included 2004-10-29</span> <a name="l00048"></a>00048 <span class="keywordtype">void</span> <a class="code" href="classbssrc.html#a999b5f13126c9a57815002241d1046fa">SetDeterministicEs</a>(<span class="keywordtype">int</span> det); <span class="comment">// included 2004-10-29</span> <a name="l00049"></a>00049 <a name="l00050"></a>00050 <span class="keywordtype">int</span> <a class="code" href="classbssrc.html#a042da540921e8918b2e3f6aa8a95e41b">act</a>(<span class="keywordtype">void</span>); <a name="l00051"></a>00051 <a name="l00052"></a><a class="code" href="classbssrc.html#a56cddf2f5d2321cfbd22689acc41dc30">00052</a> <span class="keywordtype">double</span> <a class="code" href="classbssrc.html#a56cddf2f5d2321cfbd22689acc41dc30">ex</a>; <a name="l00053"></a><a class="code" href="classbssrc.html#afa70bb6a8176a4e761f524ac6f9851d8">00053</a> <span class="keywordtype">double</span> <a class="code" href="classbssrc.html#afa70bb6a8176a4e761f524ac6f9851d8">es</a>; <a name="l00054"></a><a class="code" href="classbssrc.html#a39990a2f8d7eefaa07e793a264a1a444">00054</a> <span class="keywordtype">int</span> <a class="code" href="classbssrc.html#a39990a2f8d7eefaa07e793a264a1a444">delta</a>; <a name="l00055"></a><a class="code" href="classbssrc.html#afc8a6c1a6dff3b90684114fa96ac9c6c">00055</a> <span class="keywordtype">int</span> <a class="code" href="classbssrc.html#afc8a6c1a6dff3b90684114fa96ac9c6c">dist_burst</a>; <a name="l00056"></a><a class="code" href="classbssrc.html#a67611af2013faadc2ab2b6e475eb09dd">00056</a> <span class="keywordtype">int</span> <a class="code" href="classbssrc.html#a67611af2013faadc2ab2b6e475eb09dd">dist_silence</a>; <a name="l00057"></a><a class="code" href="classbssrc.html#a5653d81a51400e9a730882941c77f864">00057</a> <span class="keywordtype">int</span> <a class="code" href="classbssrc.html#a5653d81a51400e9a730882941c77f864">state</a>; <span class="comment">/* current state:</span> <a name="l00058"></a>00058 <span class="comment"> * is decremented with each sent cell. If</span> <a name="l00059"></a>00059 <span class="comment"> * state = 0, the current burst is finished</span> <a name="l00060"></a>00060 <span class="comment"> */</span> <a name="l00061"></a><a class="code" href="classbssrc.html#a7ec09a637098664b8759de51fc5f56f1">00061</a> <span class="keywordtype">int</span> <a class="code" href="classbssrc.html#a7ec09a637098664b8759de51fc5f56f1">deterministic_ex</a>; <span class="comment">// included 2004-10-15</span> <a name="l00062"></a><a class="code" href="classbssrc.html#a23ea6616e620b70f9b6283fdc0f7a6f2">00062</a> <span class="keywordtype">int</span> <a class="code" href="classbssrc.html#a23ea6616e620b70f9b6283fdc0f7a6f2">deterministic_es</a>; <span class="comment">// included 2004-10-15</span> <a name="l00063"></a>00063 <span class="comment">//tolua_end</span> <a name="l00064"></a>00064 <a name="l00065"></a>00065 <span class="keywordtype">void</span> <a class="code" href="classbssrc.html#ac90d250944f3fdcc7b7cda6ff917f9ea">early</a>(<a class="code" href="classevent.html">event</a> *); <a name="l00066"></a>00066 }; <span class="comment">//tolua_export</span> <a name="l00067"></a>00067 <a name="l00068"></a>00068 <span class="preprocessor">#endif // _BSSRC_H_</span> </pre></div></div> <hr size="1"/><address style="text-align: right;"><small>Generated on Sun Feb 14 12:31:42 2010 for Luayats by&nbsp; <a href="http://www.doxygen.org/index.html"> <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.6.1 </small></address> </body> </html>
hleuwer/luayats
doc/cpp/html/bssrc_8h_source.html
HTML
gpl-2.0
9,719