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
/** ******************************************************************************** \file ctrlkcal.h \brief Definitions for kernel ctrl CAL module This file contains the definitions for the kernel ctrl CAL module. *******************************************************************************/ /*------------------------------------------------------------------------------ Copyright (c) 2014, Bernecker+Rainer Industrie-Elektronik Ges.m.b.H. (B&R) All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * Neither the name of the copyright holders nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ------------------------------------------------------------------------------*/ #ifndef _INC_ctrlkcal_H_ #define _INC_ctrlkcal_H_ //------------------------------------------------------------------------------ // includes //------------------------------------------------------------------------------ #include <common/oplkinc.h> #include <common/ctrl.h> //------------------------------------------------------------------------------ // const defines //------------------------------------------------------------------------------ //------------------------------------------------------------------------------ // typedef //------------------------------------------------------------------------------ //------------------------------------------------------------------------------ // function prototypes //------------------------------------------------------------------------------ #ifdef __cplusplus extern "C" { #endif tOplkError ctrlkcal_init(void); void ctrlkcal_exit(void); tOplkError ctrlkcal_process(void); tOplkError ctrlkcal_getCmd(tCtrlCmdType* pCmd_p); void ctrlkcal_sendReturn(UINT16 retval_p); void ctrlkcal_setStatus(UINT16 status_p); UINT16 ctrlkcal_getStatus(void); void ctrlkcal_updateHeartbeat(UINT16 heartbeat_p); tOplkError ctrlkcal_readInitParam(tCtrlInitParam* pInitParam_p); void ctrlkcal_storeInitParam(tCtrlInitParam* pInitParam_p); #ifdef __cplusplus } #endif #endif /* _INC_ctrlkcal_H_ */
SylvainLesne/openPOWERLINK_V2
stack/include/kernel/ctrlkcal.h
C
gpl-2.0
3,399
<?php /** * Template to display the main page for the new forum * @access public */ $this->setLayoutTemplate('poll_layout_tpl.php'); echo $display.'<br />'; ?>
chisimba/modules
poll/templates/content/home_tpl.php
PHP
gpl-2.0
171
/* * Copyright (C) 2005-2009 MaNGOS <http://getmangos.com/> * * Copyright (C) 2008-2010 Trinity <http://www.trinitycore.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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include "Common.h" #include "WorldPacket.h" #include "Opcodes.h" #include "Log.h" #include "ObjectMgr.h" #include "SpellMgr.h" #include "Player.h" #include "Unit.h" #include "Spell.h" #include "SpellAuraEffects.h" #include "DynamicObject.h" #include "ObjectAccessor.h" #include "Util.h" #include "GridNotifiers.h" #include "GridNotifiersImpl.h" #include "CellImpl.h" AuraApplication::AuraApplication(Unit * target, Unit * caster, Aura * aura, uint8 effMask) : m_target(target), m_base(aura), m_slot(MAX_AURAS), m_flags(AFLAG_NONE), m_needClientUpdate(false) , m_removeMode(AURA_REMOVE_NONE), m_effectsToApply(effMask) { assert(GetTarget() && GetBase()); if (GetBase()->IsVisible()) { // Try find slot for aura uint8 slot = MAX_AURAS; // Lookup for auras already applied from spell if (AuraApplication * foundAura = m_target->GetAuraApplication(m_base->GetId(), m_base->GetCasterGUID())) { // allow use single slot only by auras from same caster slot = foundAura->GetSlot(); } else { Unit::VisibleAuraMap const * visibleAuras = m_target->GetVisibleAuras(); // lookup for free slots in units visibleAuras Unit::VisibleAuraMap::const_iterator itr = visibleAuras->find(0); for (uint32 freeSlot = 0; freeSlot < MAX_AURAS; ++itr , ++freeSlot) { if (itr == visibleAuras->end() || itr->first != freeSlot) { slot = freeSlot; break; } } } // Register Visible Aura if (slot < MAX_AURAS) { m_slot = slot; m_target->SetVisibleAura(slot, this); SetNeedClientUpdate(); sLog.outDebug("Aura: %u Effect: %d put to unit visible auras slot: %u", GetBase()->GetId(), GetEffectMask(), slot); } else sLog.outDebug("Aura: %u Effect: %d could not find empty unit visible slot", GetBase()->GetId(), GetEffectMask()); } m_flags |= (_CheckPositive(caster) ? AFLAG_POSITIVE : AFLAG_NEGATIVE) | (GetBase()->GetCasterGUID() == GetTarget()->GetGUID() ? AFLAG_CASTER : AFLAG_NONE); m_isNeedManyNegativeEffects = false; if (GetBase()->GetCasterGUID() == GetTarget()->GetGUID()) // caster == target - 1 negative effect is enough for aura to be negative m_isNeedManyNegativeEffects = false; else if (caster) m_isNeedManyNegativeEffects = caster->IsFriendlyTo(m_target); } void AuraApplication::_Remove() { uint8 slot = GetSlot(); if (slot >= MAX_AURAS) return; if (AuraApplication * foundAura = m_target->GetAuraApplication(GetBase()->GetId(), GetBase()->GetCasterGUID())) { // Reuse visible aura slot by aura which is still applied - prevent storing dead pointers if (slot == foundAura->GetSlot()) { if (GetTarget()->GetVisibleAura(slot) == this) { GetTarget()->SetVisibleAura(slot, foundAura); foundAura->SetNeedClientUpdate(); } // set not valid slot for aura - prevent removing other visible aura slot = MAX_AURAS; } } // update for out of range group members if (slot < MAX_AURAS) { GetTarget()->RemoveVisibleAura(slot); ClientUpdate(true); } } bool AuraApplication::_CheckPositive(Unit * caster) const { // Aura is positive when it is casted by friend and at least one aura is positive // or when it is casted by enemy and at least one aura is negative for (uint8 i = 0; i < MAX_SPELL_EFFECTS; ++i) { if ((1<<i & GetEffectMask())) { if (m_isNeedManyNegativeEffects == IsPositiveEffect(GetBase()->GetId(), i)) return m_isNeedManyNegativeEffects; } } return !m_isNeedManyNegativeEffects; } void AuraApplication::_HandleEffect(uint8 effIndex, bool apply) { AuraEffect * aurEff = GetBase()->GetEffect(effIndex); assert(aurEff); assert(HasEffect(effIndex) == (!apply)); assert((1<<effIndex) & m_effectsToApply); sLog.outDebug("AuraApplication::_HandleEffect: %u, apply: %u: amount: %u", aurEff->GetAuraType(), apply, aurEff->GetAmount()); Unit * caster = GetBase()->GetCaster(); m_flags &= ~(AFLAG_POSITIVE | AFLAG_NEGATIVE); if (apply) { m_flags |= 1<<effIndex; m_flags |=_CheckPositive(caster) ? AFLAG_POSITIVE : AFLAG_NEGATIVE; GetTarget()->_HandleAuraEffect(aurEff, true); aurEff->HandleEffect(this, AURA_EFFECT_HANDLE_REAL, true); } else { m_flags &= ~(1<<effIndex); m_flags |=_CheckPositive(caster) ? AFLAG_POSITIVE : AFLAG_NEGATIVE; // remove from list before mods removing (prevent cyclic calls, mods added before including to aura list - use reverse order) GetTarget()->_HandleAuraEffect(aurEff, false); aurEff->HandleEffect(this, AURA_EFFECT_HANDLE_REAL, false); // Remove all triggered by aura spells vs unlimited duration aurEff->CleanupTriggeredSpells(GetTarget()); } SetNeedClientUpdate(); } void AuraApplication::ClientUpdate(bool remove) { m_needClientUpdate = false; WorldPacket data(SMSG_AURA_UPDATE); data.append(GetTarget()->GetPackGUID()); data << uint8(m_slot); if (remove) { assert(!m_target->GetVisibleAura(m_slot)); data << uint32(0); sLog.outDebug("Aura %u removed slot %u",GetBase()->GetId(), m_slot); m_target->SendMessageToSet(&data, true); return; } assert(m_target->GetVisibleAura(m_slot)); Aura const * aura = GetBase(); data << uint32(aura->GetId()); uint32 flags = m_flags; if (aura->GetMaxDuration() > 0) flags |= AFLAG_DURATION; data << uint8(flags); data << uint8(aura->GetCasterLevel()); data << uint8(aura->GetStackAmount() > 1 ? aura->GetStackAmount() : (aura->GetCharges()) ? aura->GetCharges() : 1); if (!(flags & AFLAG_CASTER)) data.appendPackGUID(aura->GetCasterGUID()); if (flags & AFLAG_DURATION) { data << uint32(aura->GetMaxDuration()); data << uint32(aura->GetDuration()); } m_target->SendMessageToSet(&data, true); } Aura * Aura::TryCreate(SpellEntry const* spellproto, uint8 tryEffMask, WorldObject * owner, Unit * caster, int32 *baseAmount, Item * castItem, uint64 casterGUID) { assert(spellproto); assert(owner); assert(caster || casterGUID); assert(tryEffMask <= MAX_EFFECT_MASK); uint8 effMask = 0; switch(owner->GetTypeId()) { case TYPEID_UNIT: case TYPEID_PLAYER: for (uint8 i = 0; i< MAX_SPELL_EFFECTS; ++i) { if (IsUnitOwnedAuraEffect(spellproto->Effect[i])) effMask |= 1 << i; } break; case TYPEID_DYNAMICOBJECT: for (uint8 i = 0; i< MAX_SPELL_EFFECTS; ++i) { if (spellproto->Effect[i] == SPELL_EFFECT_PERSISTENT_AREA_AURA) effMask |= 1 << i; } break; } if (uint8 realMask = effMask & tryEffMask) return Create(spellproto,realMask,owner,caster,baseAmount,castItem,casterGUID); return NULL; } Aura * Aura::TryCreate(SpellEntry const* spellproto, WorldObject * owner, Unit * caster, int32 *baseAmount, Item * castItem, uint64 casterGUID) { assert(spellproto); assert(owner); assert(caster || casterGUID); uint8 effMask = 0; switch(owner->GetTypeId()) { case TYPEID_UNIT: case TYPEID_PLAYER: for (uint8 i = 0; i< MAX_SPELL_EFFECTS; ++i) { if (IsUnitOwnedAuraEffect(spellproto->Effect[i])) effMask |= 1 << i; } break; case TYPEID_DYNAMICOBJECT: for (uint8 i = 0; i< MAX_SPELL_EFFECTS; ++i) { if (spellproto->Effect[i] == SPELL_EFFECT_PERSISTENT_AREA_AURA) effMask |= 1 << i; } break; } if (effMask) return Create(spellproto,effMask,owner,caster,baseAmount,castItem,casterGUID); return NULL; } Aura * Aura::Create(SpellEntry const* spellproto, uint8 effMask, WorldObject * owner, Unit * caster, int32 *baseAmount, Item * castItem, uint64 casterGUID) { assert(effMask); assert(spellproto); assert(owner); assert(caster || casterGUID); assert(effMask <= MAX_EFFECT_MASK); // try to get caster of aura if (casterGUID) { if (owner->GetGUID() == casterGUID) caster = (Unit *)owner; else caster = ObjectAccessor::GetUnit(*owner, casterGUID); } Aura * aura = NULL; switch(owner->GetTypeId()) { case TYPEID_UNIT: case TYPEID_PLAYER: aura = new UnitAura(spellproto,effMask,owner,caster,baseAmount,castItem, casterGUID); break; case TYPEID_DYNAMICOBJECT: aura = new DynObjAura(spellproto,effMask,owner,caster,baseAmount,castItem, casterGUID); break; default: assert(false); return NULL; } // aura can be removed in Unit::_AddAura call if (aura->IsRemoved()) return NULL; return aura; } Aura::Aura(SpellEntry const* spellproto, uint8 effMask, WorldObject * owner, Unit * caster, int32 *baseAmount, Item * castItem, uint64 casterGUID) : m_spellProto(spellproto), m_owner(owner), m_casterGuid(casterGUID ? casterGUID : caster->GetGUID()), m_castItemGuid(castItem ? castItem->GetGUID() : 0), m_applyTime(time(NULL)), m_timeCla(0), m_isSingleTarget(false), m_updateTargetMapInterval(0), m_procCharges(0), m_stackAmount(1), m_isRemoved(false), m_casterLevel(caster ? caster->getLevel() : m_spellProto->spellLevel) { if (m_spellProto->manaPerSecond || m_spellProto->manaPerSecondPerLevel) m_timeCla = 1 * IN_MILISECONDS; Player* modOwner = NULL; if (caster) { modOwner = caster->GetSpellModOwner(); m_maxDuration = caster->CalcSpellDuration(m_spellProto); } else m_maxDuration = GetSpellDuration(m_spellProto); if (IsPassive() && m_spellProto->DurationIndex == 0) m_maxDuration = -1; if (!IsPermanent() && modOwner) modOwner->ApplySpellMod(GetId(), SPELLMOD_DURATION, m_maxDuration); m_duration = m_maxDuration; m_procCharges = m_spellProto->procCharges; if (modOwner) modOwner->ApplySpellMod(GetId(), SPELLMOD_CHARGES, m_procCharges); for (uint8 i=0 ; i<MAX_SPELL_EFFECTS; ++i) { if (effMask & (uint8(1) << i)) m_effects[i] = new AuraEffect(this, i, baseAmount ? baseAmount + i : NULL, caster); else m_effects[i] = NULL; } } Aura::~Aura() { // free effects memory for (uint8 i = 0 ; i < MAX_SPELL_EFFECTS; ++i) if (m_effects[i]) delete m_effects[i]; assert(m_applications.empty()); _DeleteRemovedApplications(); } Unit* Aura::GetCaster() const { if (GetOwner()->GetGUID() == GetCasterGUID()) return GetUnitOwner(); if (AuraApplication const * aurApp = GetApplicationOfTarget(GetCasterGUID())) return aurApp->GetTarget(); return ObjectAccessor::GetUnit(*GetOwner(), GetCasterGUID()); } AuraObjectType Aura::GetType() const { return (m_owner->GetTypeId() == TYPEID_DYNAMICOBJECT) ? DYNOBJ_AURA_TYPE : UNIT_AURA_TYPE; } void Aura::_ApplyForTarget(Unit * target, Unit * caster, AuraApplication * auraApp) { assert(target); assert(auraApp); // aura mustn't be already applied assert (m_applications.find(target->GetGUID()) == m_applications.end()); m_applications[target->GetGUID()] = auraApp; // set infinity cooldown state for spells if (caster && caster->GetTypeId() == TYPEID_PLAYER) { if (m_spellProto->Attributes & SPELL_ATTR_DISABLED_WHILE_ACTIVE) { Item* castItem = m_castItemGuid ? caster->ToPlayer()->GetItemByGuid(m_castItemGuid) : NULL; caster->ToPlayer()->AddSpellAndCategoryCooldowns(m_spellProto,castItem ? castItem->GetEntry() : 0, NULL,true); } } } void Aura::_UnapplyForTarget(Unit * target, Unit * caster, AuraApplication * auraApp) { assert(target); assert(auraApp->GetRemoveMode()); assert(auraApp); ApplicationMap::iterator itr = m_applications.find(target->GetGUID()); // aura has to be already applied assert(itr->second == auraApp); m_applications.erase(itr); m_removedApplications.push_back(auraApp); // reset cooldown state for spells if (caster && caster->GetTypeId() == TYPEID_PLAYER) { if (GetSpellProto()->Attributes & SPELL_ATTR_DISABLED_WHILE_ACTIVE) // note: item based cooldowns and cooldown spell mods with charges ignored (unknown existed cases) caster->ToPlayer()->SendCooldownEvent(GetSpellProto()); } } // removes aura from all targets // and marks aura as removed void Aura::_Remove(AuraRemoveMode removeMode) { assert (!m_isRemoved); m_isRemoved = true; ApplicationMap::iterator appItr = m_applications.begin(); while (!m_applications.empty()) { AuraApplication * aurApp = appItr->second; Unit * target = aurApp->GetTarget(); target->_UnapplyAura(aurApp, removeMode); appItr = m_applications.begin(); } } void Aura::UpdateTargetMap(Unit * caster, bool apply) { if (IsRemoved()) return; m_updateTargetMapInterval = UPDATE_TARGET_MAP_INTERVAL; // fill up to date target list // target, effMask std::map<Unit *, uint8> targets; FillTargetMap(targets, caster); UnitList targetsToRemove; // mark all auras as ready to remove for (ApplicationMap::iterator appIter = m_applications.begin(); appIter != m_applications.end();++appIter) { std::map<Unit *, uint8>::iterator existing = targets.find(appIter->second->GetTarget()); // not found in current area - remove the aura if (existing == targets.end()) targetsToRemove.push_back(appIter->second->GetTarget()); else { // needs readding - remove now, will be applied in next update cycle // (dbcs do not have auras which apply on same type of targets but have different radius, so this is not really needed) if (appIter->second->GetEffectMask() != existing->second) targetsToRemove.push_back(appIter->second->GetTarget()); // nothing todo - aura already applied // remove from auras to register list targets.erase(existing); } } // register auras for units for (std::map<Unit *, uint8>::iterator itr = targets.begin(); itr!= targets.end();) { bool addUnit = true; // check target immunities if (itr->first->IsImmunedToSpell(GetSpellProto())) addUnit = false; if (addUnit) { // persistent area aura does not hit flying targets if (GetType() == DYNOBJ_AURA_TYPE) { if (itr->first->isInFlight()) addUnit = false; } // unit auras can not stack with each other else // (GetType() == UNIT_AURA_TYPE) { // Allow to remove by stack when aura is going to be applied on owner if (itr->first != GetOwner()) { // check if not stacking aura already on target // this one prevents unwanted usefull buff loss because of stacking and prevents overriding auras periodicaly by 2 near area aura owners for (Unit::AuraApplicationMap::iterator iter = itr->first->GetAppliedAuras().begin(); iter != itr->first->GetAppliedAuras().end(); ++iter) { Aura const * aura = iter->second->GetBase(); if (!spellmgr.CanAurasStack(GetSpellProto(), aura->GetSpellProto(), aura->GetCasterGUID() == GetCasterGUID())) { addUnit = false; break; } } } } } if (!addUnit) targets.erase(itr++); else { // owner has to be in world, or effect has to be applied to self assert((!GetOwner()->IsInWorld() && GetOwner() == itr->first) || GetOwner()->IsInMap(itr->first)); itr->first->_CreateAuraApplication(this, itr->second); ++itr; } } // remove auras from units no longer needing them for (UnitList::iterator itr = targetsToRemove.begin(); itr != targetsToRemove.end();++itr) { if (AuraApplication * aurApp = GetApplicationOfTarget((*itr)->GetGUID())) (*itr)->_UnapplyAura(aurApp, AURA_REMOVE_BY_DEFAULT); } if (!apply) return; // apply aura effects for units for (std::map<Unit *, uint8>::iterator itr = targets.begin(); itr!= targets.end();++itr) { if (AuraApplication * aurApp = GetApplicationOfTarget(itr->first->GetGUID())) { // owner has to be in world, or effect has to be applied to self assert((!GetOwner()->IsInWorld() && GetOwner() == itr->first) || GetOwner()->IsInMap(itr->first)); itr->first->_ApplyAura(aurApp, itr->second); } } } // targets have to be registered and not have effect applied yet to use this function void Aura::_ApplyEffectForTargets(uint8 effIndex) { Unit * caster = GetCaster(); // prepare list of aura targets UnitList targetList; for (ApplicationMap::iterator appIter = m_applications.begin(); appIter != m_applications.end(); ++appIter) { if ((appIter->second->GetEffectsToApply() & (1<<effIndex)) && CheckTarget(appIter->second->GetTarget()) && !appIter->second->HasEffect(effIndex)) targetList.push_back(appIter->second->GetTarget()); } // apply effect to targets for (UnitList::iterator itr = targetList.begin(); itr != targetList.end(); ++itr) { if (GetApplicationOfTarget((*itr)->GetGUID())) { // owner has to be in world, or effect has to be applied to self assert((!GetOwner()->IsInWorld() && GetOwner() == *itr) || GetOwner()->IsInMap(*itr)); (*itr)->_ApplyAuraEffect(this, effIndex); } } } void Aura::UpdateOwner(uint32 diff, WorldObject * owner) { assert(owner == m_owner); Unit * caster = GetCaster(); // Apply spellmods for channeled auras // used for example when triggered spell of spell:10 is modded Spell * modSpell = NULL; Player * modOwner = NULL; if (caster) if ((modOwner = caster->GetSpellModOwner()) && (modSpell = modOwner->FindCurrentSpellBySpellId(GetId()))) modOwner->SetSpellModTakingSpell(modSpell, true); Update(diff, caster); if (m_updateTargetMapInterval <= diff) UpdateTargetMap(caster); else m_updateTargetMapInterval -= diff; // update aura effects for (uint8 i = 0; i < MAX_SPELL_EFFECTS; ++i) if (m_effects[i]) m_effects[i]->Update(diff, caster); // remove spellmods after effects update if (modSpell) modOwner->SetSpellModTakingSpell(modSpell, false); _DeleteRemovedApplications(); } void Aura::Update(uint32 diff, Unit * caster) { if (m_duration > 0) { m_duration -= diff; if (m_duration < 0) m_duration = 0; // handle manaPerSecond/manaPerSecondPerLevel if (m_timeCla) { if (m_timeCla > diff) m_timeCla -= diff; else if (caster) { if (int32 manaPerSecond = m_spellProto->manaPerSecond + m_spellProto->manaPerSecondPerLevel * caster->getLevel()) { m_timeCla += 1000 - diff; Powers powertype = Powers(m_spellProto->powerType); if (powertype == POWER_HEALTH) { if (caster->GetHealth() > manaPerSecond) caster->ModifyHealth(-manaPerSecond); else { Remove(); return; } } else { if (caster->GetPower(powertype) >= manaPerSecond) caster->ModifyPower(powertype, -manaPerSecond); else { Remove(); return; } } } } } } } bool Aura::CheckTarget(Unit *target) { // some special cases switch(GetId()) { case 45828: // AV Marshal's HP/DMG auras case 45829: case 45830: case 45821: case 45822: // AV Warmaster's HP/DMG auras case 45823: case 45824: case 45826: switch(target->GetEntry()) { // alliance case 14762: // Dun Baldar North Marshal case 14763: // Dun Baldar South Marshal case 14764: // Icewing Marshal case 14765: // Stonehearth Marshal case 11948: // Vandar Stormspike // horde case 14772: // East Frostwolf Warmaster case 14776: // Tower Point Warmaster case 14773: // Iceblood Warmaster case 14777: // West Frostwolf Warmaster case 11946: // Drek'thar return true; default: return false; break; } break; default: return true; break; } } void Aura::SetDuration(int32 duration, bool withMods) { if (withMods) { if (Unit * caster = GetCaster()) if (Player * modOwner = caster->GetSpellModOwner()) modOwner->ApplySpellMod(GetId(), SPELLMOD_DURATION, duration); } m_duration = duration; SetNeedClientUpdateForTargets(); } void Aura::RefreshDuration() { SetDuration(GetMaxDuration()); for (uint8 i = 0; i < MAX_SPELL_EFFECTS; ++i) if (m_effects[i]) m_effects[i]->ResetPeriodic(); if (m_spellProto->manaPerSecond || m_spellProto->manaPerSecondPerLevel) m_timeCla = 1 * IN_MILISECONDS; } void Aura::SetCharges(uint8 charges) { if (m_procCharges == charges) return; m_procCharges = charges; SetNeedClientUpdateForTargets(); } bool Aura::DropCharge() { if (m_procCharges) //auras without charges always have charge = 0 { if (--m_procCharges) // Send charge change SetNeedClientUpdateForTargets(); else // Last charge dropped { Remove(AURA_REMOVE_BY_EXPIRE); return true; } } return false; } void Aura::SetStackAmount(uint8 stackAmount, bool applied) { if (stackAmount != m_stackAmount) { m_stackAmount = stackAmount; RecalculateAmountOfEffects(); } SetNeedClientUpdateForTargets(); } bool Aura::ModStackAmount(int32 num) { // Can`t mod if (!m_spellProto->StackAmount || !GetStackAmount()) return true; // Modify stack but limit it int32 stackAmount = m_stackAmount + num; if (stackAmount > m_spellProto->StackAmount) stackAmount = m_spellProto->StackAmount; else if (stackAmount <= 0) // Last aura from stack removed { m_stackAmount = 0; return true; // need remove aura } bool refresh = stackAmount >= GetStackAmount(); // Update stack amount SetStackAmount(stackAmount); if (refresh) RefreshDuration(); SetNeedClientUpdateForTargets(); return false; } bool Aura::IsPassive() const { return IsPassiveSpell(GetSpellProto()); } bool Aura::IsDeathPersistent() const { return IsDeathPersistentSpell(GetSpellProto()); } bool Aura::CanBeSaved() const { if (IsPassive()) return false; if (GetCasterGUID() != GetOwner()->GetGUID()) if (IsSingleTargetSpell(GetSpellProto())) return false; // Can't be saved - aura handler relies on calculated amount and changes it if (HasEffectType(SPELL_AURA_CONVERT_RUNE)) return false; return true; } bool Aura::HasEffectType(AuraType type) const { for (uint8 i = 0; i < MAX_SPELL_EFFECTS; ++i) { if (m_effects[i] && m_effects[i]->GetAuraType() == type) return true; } return false; } void Aura::RecalculateAmountOfEffects() { assert (!IsRemoved()); Unit * caster = GetCaster(); for (uint8 i = 0; i < MAX_SPELL_EFFECTS; ++i) if (m_effects[i]) m_effects[i]->RecalculateAmount(caster); } void Aura::HandleAllEffects(AuraApplication const * aurApp, uint8 mode, bool apply) { assert (!IsRemoved()); for (uint8 i = 0; i < MAX_SPELL_EFFECTS; ++i) if (m_effects[i] && !IsRemoved()) m_effects[i]->HandleEffect(aurApp, mode, apply); } bool Aura::IsVisible() const { // Is this blizzlike? show totem passive auras if (GetOwner()->GetTypeId() == TYPEID_UNIT && m_owner->ToCreature()->isTotem() && IsPassive()) return true; return !IsPassive() || HasEffectType(SPELL_AURA_ABILITY_IGNORE_AURASTATE); } void Aura::UnregisterSingleTarget() { assert(m_isSingleTarget); Unit * caster = GetCaster(); caster->GetSingleCastAuras().remove(this); SetIsSingleTarget(false); } void Aura::SetLoadedState(int32 maxduration, int32 duration, int32 charges, uint8 stackamount, uint8 recalculateMask, int32 * amount) { m_maxDuration = maxduration; m_duration = duration; m_procCharges = charges; m_stackAmount = stackamount; Unit * caster = GetCaster(); for (uint8 i = 0; i < MAX_SPELL_EFFECTS; ++i) if (m_effects[i]) { m_effects[i]->SetAmount(amount[i]); m_effects[i]->SetCanBeRecalculated(recalculateMask & (1<<i)); m_effects[i]->CalculatePeriodic(caster); m_effects[i]->CalculateSpellMod(); m_effects[i]->RecalculateAmount(caster); } } // trigger effects on real aura apply/remove void Aura::HandleAuraSpecificMods(AuraApplication const * aurApp, Unit * caster, bool apply) { Unit * target = aurApp->GetTarget(); AuraRemoveMode removeMode = aurApp->GetRemoveMode(); // spell_area table SpellAreaForAreaMapBounds saBounds = spellmgr.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)) target->CastSpell(target,itr->second->spellId,true); } } } // mods at aura apply if (apply) { // Apply linked auras (On first aura apply) if (spellmgr.GetSpellCustomAttr(GetId()) & SPELL_ATTR_CU_LINK_AURA) { if (const std::vector<int32> *spell_triggered = spellmgr.GetSpellLinked(GetId() + SPELL_LINK_AURA)) for (std::vector<int32>::const_iterator itr = spell_triggered->begin(); itr != spell_triggered->end(); ++itr) { if (*itr < 0) target->ApplySpellImmune(GetId(), IMMUNITY_ID, -(*itr), true); else if (caster) caster->AddAura(*itr, target); } } switch (GetSpellProto()->SpellFamilyName) { case SPELLFAMILY_GENERIC: switch(GetId()) { case 32474: // Buffeting Winds of Susurrus if (target->GetTypeId() == TYPEID_PLAYER) target->ToPlayer()->ActivateTaxiPathTo(506, GetId()); break; case 33572: // Gronn Lord's Grasp, becomes stoned if (GetStackAmount() >= 5 && !target->HasAura(33652)) target->CastSpell(target, 33652, true); break; case 60970: // Heroic Fury (remove Intercept cooldown) if (target->GetTypeId() == TYPEID_PLAYER) target->ToPlayer()->RemoveSpellCooldown(20252, true); break; } break; case SPELLFAMILY_MAGE: if (!caster) break; if (GetSpellProto()->SpellFamilyFlags[0] & 0x00000001 && GetSpellProto()->SpellFamilyFlags[2] & 0x00000008) { // Glyph of Fireball if (caster->HasAura(56368)) SetDuration(0); } else if (GetSpellProto()->SpellFamilyFlags[0] & 0x00000020 && GetSpellProto()->SpellVisual[0] == 13) { // Glyph of Frostbolt if (caster->HasAura(56370)) SetDuration(0); } // Todo: This should be moved to similar function in spell::hit else if (GetSpellProto()->SpellFamilyFlags[0] & 0x01000000) { // Polymorph Sound - Sheep && Penguin if (GetSpellProto()->SpellIconID == 82 && GetSpellProto()->SpellVisual[0] == 12978) { // Glyph of the Penguin if (caster->HasAura(52648)) caster->CastSpell(target,61635,true); else caster->CastSpell(target,61634,true); } } switch(GetId()) { case 12536: // Clearcasting case 12043: // Presence of Mind // Arcane Potency if (AuraEffect const * aurEff = caster->GetAuraEffect(SPELL_AURA_DUMMY, SPELLFAMILY_MAGE, 2120, 0)) { if (roll_chance_i(aurEff->GetAmount())) { uint32 spellId = 0; switch (aurEff->GetId()) { case 31571: spellId = 57529; break; case 31572: spellId = 57531; break; default: sLog.outError("Aura::HandleAuraSpecificMods: Unknown rank of Arcane Potency (%d) found", aurEff->GetId()); } if (spellId) caster->CastSpell(caster, spellId, true); } } break; } break; case SPELLFAMILY_WARLOCK: switch(GetId()) { case 48020: // Demonic Circle if (target->GetTypeId() == TYPEID_PLAYER) if (GameObject* obj = target->GetGameObject(48018)) { target->ToPlayer()->TeleportTo(obj->GetMapId(),obj->GetPositionX(),obj->GetPositionY(),obj->GetPositionZ(),obj->GetOrientation()); target->ToPlayer()->RemoveMovementImpairingAuras(); } break; } break; case SPELLFAMILY_PRIEST: if (!caster) break; // Devouring Plague if (GetSpellProto()->SpellFamilyFlags[0] & 0x02000000 && GetEffect(0)) { // Improved Devouring Plague if (AuraEffect const * aurEff = caster->GetDummyAuraEffect(SPELLFAMILY_PRIEST, 3790, 1)) { int32 basepoints0 = aurEff->GetAmount() * GetEffect(0)->GetTotalTicks() * GetEffect(0)->GetAmount() / 100; caster->CastCustomSpell(target, 63675, &basepoints0, NULL, NULL, true, NULL, GetEffect(0)); } } // Renew else if (GetSpellProto()->SpellFamilyFlags[0] & 0x00000040 && GetEffect(0)) { // Empowered Renew if (AuraEffect const * aurEff = caster->GetDummyAuraEffect(SPELLFAMILY_PRIEST, 3021, 1)) { int32 basepoints0 = aurEff->GetAmount() * GetEffect(0)->GetTotalTicks() * caster->SpellHealingBonus(target, GetSpellProto(), GetEffect(0)->GetAmount(), HEAL) / 100; caster->CastCustomSpell(target, 63544, &basepoints0, NULL, NULL, true, NULL, GetEffect(0)); } } // Power Word: Shield else if (m_spellProto->SpellFamilyFlags[0] & 0x1 && m_spellProto->SpellFamilyFlags[2] & 0x400 && GetEffect(0)) { // Glyph of Power Word: Shield if (AuraEffect* glyph = caster->GetAuraEffect(55672,0)) { // instantly heal m_amount% of the absorb-value int32 heal = glyph->GetAmount() * GetEffect(0)->GetAmount()/100; caster->CastCustomSpell(GetUnitOwner(), 56160, &heal, NULL, NULL, true, 0, GetEffect(0)); } } break; case SPELLFAMILY_ROGUE: // Sprint (skip non player casted spells by category) if (GetSpellProto()->SpellFamilyFlags[0] & 0x40 && GetSpellProto()->Category == 44) // in official maybe there is only one icon? if (target->HasAura(58039)) // Glyph of Blurred Speed target->CastSpell(target, 61922, true); // Sprint (waterwalk) break; case SPELLFAMILY_DEATHKNIGHT: if (!caster) break; // Frost Fever and Blood Plague if (GetSpellProto()->SpellFamilyFlags[2] & 0x2) { // Can't proc on self if (GetCasterGUID() == target->GetGUID()) break; AuraEffect * aurEff = NULL; // Ebon Plaguebringer / Crypt Fever Unit::AuraEffectList const& TalentAuras = caster->GetAuraEffectsByType(SPELL_AURA_OVERRIDE_CLASS_SCRIPTS); for (Unit::AuraEffectList::const_iterator itr = TalentAuras.begin(); itr != TalentAuras.end(); ++itr) { if ((*itr)->GetMiscValue() == 7282) { aurEff = *itr; // Ebon Plaguebringer - end search if found if ((*itr)->GetSpellProto()->SpellIconID == 1766) break; } } if (aurEff) { uint32 spellId = 0; switch (aurEff->GetId()) { // Ebon Plague case 51161: spellId = 51735; break; case 51160: spellId = 51734; break; case 51099: spellId = 51726; break; // Crypt Fever case 49632: spellId = 50510; break; case 49631: spellId = 50509; break; case 49032: spellId = 50508; break; default: sLog.outError("Aura::HandleAuraSpecificMods: Unknown rank of Crypt Fever/Ebon Plague (%d) found", aurEff->GetId()); } caster->CastSpell(target, spellId, true, 0, GetEffect(0)); } } break; } } // mods at aura remove else { // Remove Linked Auras if (removeMode != AURA_REMOVE_BY_STACK && removeMode != AURA_REMOVE_BY_DEATH) { if (uint32 customAttr = spellmgr.GetSpellCustomAttr(GetId())) { if (customAttr & SPELL_ATTR_CU_LINK_REMOVE) { if (const std::vector<int32> *spell_triggered = spellmgr.GetSpellLinked(-(int32)GetId())) for (std::vector<int32>::const_iterator itr = spell_triggered->begin(); itr != spell_triggered->end(); ++itr) { if (*itr < 0) target->RemoveAurasDueToSpell(-(*itr)); else if (removeMode != AURA_REMOVE_BY_DEFAULT) target->CastSpell(target, *itr, true, 0, 0, GetCasterGUID()); } } if (customAttr & SPELL_ATTR_CU_LINK_AURA) { if (const std::vector<int32> *spell_triggered = spellmgr.GetSpellLinked(GetId() + SPELL_LINK_AURA)) for (std::vector<int32>::const_iterator itr = spell_triggered->begin(); itr != spell_triggered->end(); ++itr) { if (*itr < 0) target->ApplySpellImmune(GetId(), IMMUNITY_ID, -(*itr), false); else target->RemoveAurasDueToSpell(*itr); } } } } switch(GetSpellProto()->SpellFamilyName) { case SPELLFAMILY_GENERIC: // Remove the immunity shield marker on Avenging Wrath removal if Forbearance is not present if (GetId() == 61987 && target->HasAura(61988) && !target->HasAura(25771)) target->RemoveAura(61988); break; case SPELLFAMILY_MAGE: switch(GetId()) { case 66: // Invisibility if (removeMode != AURA_REMOVE_BY_EXPIRE) break; target->CastSpell(target, 32612, true, NULL, GetEffect(1)); break; } if (!caster) break; // Ice barrier - dispel/absorb remove if (removeMode == AURA_REMOVE_BY_ENEMY_SPELL && GetSpellProto()->SpellFamilyFlags[1] & 0x1) { // Shattered Barrier if (caster->GetDummyAuraEffect(SPELLFAMILY_MAGE, 2945, 0)) caster->CastSpell(target, 55080, true, NULL, GetEffect(0)); } break; case SPELLFAMILY_WARRIOR: if (!caster) break; // Spell Reflection if (GetSpellProto()->SpellFamilyFlags[1] & 0x2) { if (removeMode != AURA_REMOVE_BY_DEFAULT) { // Improved Spell Reflection if (caster->GetDummyAuraEffect(SPELLFAMILY_WARRIOR,1935, 1)) { // aura remove - remove auras from all party members std::list<Unit*> PartyMembers; target->GetPartyMembers(PartyMembers); for (std::list<Unit*>::iterator itr = PartyMembers.begin(); itr != PartyMembers.end(); ++itr) { if ((*itr)!= target) (*itr)->RemoveAurasWithFamily(SPELLFAMILY_WARRIOR, 0, 0x2, 0, GetCasterGUID()); } } } } break; case SPELLFAMILY_WARLOCK: if (!caster) break; // Curse of Doom if (GetSpellProto()->SpellFamilyFlags[1] & 0x02) { if (removeMode == AURA_REMOVE_BY_DEATH) { if (caster->GetTypeId() == TYPEID_PLAYER && caster->ToPlayer()->isHonorOrXPTarget(target)) caster->CastSpell(target, 18662, true, NULL, GetEffect(0)); } } // Improved Fear else if (GetSpellProto()->SpellFamilyFlags[1] & 0x00000400) { if (AuraEffect* aurEff = caster->GetAuraEffect(SPELL_AURA_DUMMY, SPELLFAMILY_WARLOCK, 98, 0)) { uint32 spellId = 0; switch (aurEff->GetId()) { case 53759: spellId = 60947; break; case 53754: spellId = 60946; break; default: sLog.outError("Aura::HandleAuraSpecificMods: Unknown rank of Improved Fear (%d) found", aurEff->GetId()); } if (spellId) caster->CastSpell(target, spellId, true); } } switch(GetId()) { case 48018: // Demonic Circle // Do not remove GO when aura is removed by stack // to prevent remove GO added by new spell // old one is already removed if (removeMode != AURA_REMOVE_BY_STACK) target->RemoveGameObject(GetId(), true); target->RemoveAura(62388); break; } break; case SPELLFAMILY_PRIEST: if (!caster) break; // Shadow word: Pain // Vampiric Touch if (removeMode == AURA_REMOVE_BY_ENEMY_SPELL && (GetSpellProto()->SpellFamilyFlags[0] & 0x00008000 || GetSpellProto()->SpellFamilyFlags[1] & 0x00000400)) { // Shadow Affinity if (AuraEffect const * aurEff = caster->GetDummyAuraEffect(SPELLFAMILY_PRIEST, 178, 1)) { int32 basepoints0 = aurEff->GetAmount() * caster->GetCreateMana() / 100; caster->CastCustomSpell(caster, 64103, &basepoints0, NULL, NULL, true, NULL, GetEffect(0)); } } // Power word: shield else if (removeMode == AURA_REMOVE_BY_ENEMY_SPELL && GetSpellProto()->SpellFamilyFlags[0] & 0x00000001) { // Rapture if (Aura const * aura = caster->GetAuraOfRankedSpell(47535)) { // check cooldown if (caster->GetTypeId() == TYPEID_PLAYER) { if (caster->ToPlayer()->HasSpellCooldown(aura->GetId())) break; // and add if needed caster->ToPlayer()->AddSpellCooldown(aura->GetId(), 0, uint32(time(NULL) + 12)); } // effect on caster if (AuraEffect const * aurEff = aura->GetEffect(0)) { float multiplier = aurEff->GetAmount(); if (aurEff->GetId() == 47535) multiplier -= 0.5f; else if (aurEff->GetId() == 47537) multiplier += 0.5f; int32 basepoints0 = (multiplier * caster->GetMaxPower(POWER_MANA) / 100); caster->CastCustomSpell(caster, 47755, &basepoints0, NULL, NULL, true); } // effect on aura target if (AuraEffect const * aurEff = aura->GetEffect(1)) { if (!roll_chance_i(aurEff->GetAmount())) break; int32 triggeredSpellId = 0; switch(target->getPowerType()) { case POWER_MANA: { int32 basepoints0 = 2 * (target->GetMaxPower(POWER_MANA) / 100); caster->CastCustomSpell(target, 63654, &basepoints0, NULL, NULL, true); break; } case POWER_RAGE: triggeredSpellId = 63653; break; case POWER_ENERGY: triggeredSpellId = 63655; break; case POWER_RUNIC_POWER: triggeredSpellId = 63652; break; } if (triggeredSpellId) caster->CastSpell(target, triggeredSpellId, true); } } } switch(GetId()) { case 47788: // Guardian Spirit if (removeMode != AURA_REMOVE_BY_EXPIRE) break; if (caster->GetTypeId() != TYPEID_PLAYER) break; Player *player = caster->ToPlayer(); // Glyph of Guardian Spirit if (AuraEffect * aurEff = player->GetAuraEffect(63231, 0)) { if (!player->HasSpellCooldown(47788)) break; player->RemoveSpellCooldown(GetSpellProto()->Id, true); player->AddSpellCooldown(GetSpellProto()->Id, 0, uint32(time(NULL) + aurEff->GetAmount())); WorldPacket data(SMSG_SPELL_COOLDOWN, 8+1+4+4); data << uint64(player->GetGUID()); data << uint8(0x0); // flags (0x1, 0x2) data << uint32(GetSpellProto()->Id); data << uint32(aurEff->GetAmount()*IN_MILISECONDS); player->SendDirectMessage(&data); } break; } break; case SPELLFAMILY_PALADIN: // Remove the immunity shield marker on Forbearance removal if AW marker is not present if (GetId() == 25771 && target->HasAura(61988) && !target->HasAura(61987)) target->RemoveAura(61988); break; case SPELLFAMILY_DEATHKNIGHT: // Blood of the North // Reaping // Death Rune Mastery if (GetSpellProto()->SpellIconID == 3041 || GetSpellProto()->SpellIconID == 22 || GetSpellProto()->SpellIconID == 2622) { if (!GetEffect(0) || GetEffect(0)->GetAuraType() != SPELL_AURA_PERIODIC_DUMMY) break; if (target->GetTypeId() != TYPEID_PLAYER) break; if (target->ToPlayer()->getClass() != CLASS_DEATH_KNIGHT) break; // aura removed - remove death runes target->ToPlayer()->RemoveRunesByAuraEffect(GetEffect(0)); } switch(GetId()) { case 50514: // Summon Gargoyle if (removeMode != AURA_REMOVE_BY_EXPIRE) break; target->CastSpell(target, GetEffect(0)->GetAmount(), true, NULL, GetEffect(0)); break; } break; } } // mods at aura apply or remove switch (GetSpellProto()->SpellFamilyName) { case SPELLFAMILY_ROGUE: // Stealth if (GetSpellProto()->SpellFamilyFlags[0] & 0x00400000) { // Master of subtlety if (AuraEffect const * aurEff = target->GetAuraEffectOfRankedSpell(31221, 0)) { if (!apply) target->CastSpell(target,31666,true); else { int32 basepoints0 = aurEff->GetAmount(); target->CastCustomSpell(target,31665, &basepoints0, NULL, NULL ,true); } } // Overkill if (target->HasAura(58426)) { if (!apply) target->CastSpell(target,58428,true); else target->CastSpell(target,58427,true); } break; } break; case SPELLFAMILY_HUNTER: switch(GetId()) { case 19574: // Bestial Wrath // The Beast Within cast on owner if talent present if (Unit* owner = target->GetOwner()) { // Search talent if (owner->HasAura(34692)) { if (apply) owner->CastSpell(owner, 34471, true, 0, GetEffect(0)); else owner->RemoveAurasDueToSpell(34471); } } break; } break; case SPELLFAMILY_PALADIN: switch(GetId()) { case 19746: case 31821: // Aura Mastery Triggered Spell Handler // If apply Concentration Aura -> trigger -> apply Aura Mastery Immunity // If remove Concentration Aura -> trigger -> remove Aura Mastery Immunity // If remove Aura Mastery -> trigger -> remove Aura Mastery Immunity // Do effects only on aura owner if (GetCasterGUID() != target->GetGUID()) break; if (apply) { if ((GetSpellProto()->Id == 31821 && target->HasAura(19746, GetCasterGUID())) || (GetSpellProto()->Id == 19746 && target->HasAura(31821))) target->CastSpell(target,64364,true); } else target->RemoveAurasDueToSpell(64364, GetCasterGUID()); break; } break; case SPELLFAMILY_DEATHKNIGHT: if (GetSpellSpecific(GetSpellProto()) == SPELL_SPECIFIC_PRESENCE) { AuraEffect *bloodPresenceAura=0; // healing by damage done AuraEffect *frostPresenceAura=0; // increased health AuraEffect *unholyPresenceAura=0; // increased movement speed, faster rune recovery // Improved Presences Unit::AuraEffectList const& vDummyAuras = target->GetAuraEffectsByType(SPELL_AURA_DUMMY); for (Unit::AuraEffectList::const_iterator itr = vDummyAuras.begin(); itr != vDummyAuras.end(); ++itr) { switch((*itr)->GetId()) { // Improved Blood Presence case 50365: case 50371: { bloodPresenceAura = (*itr); break; } // Improved Frost Presence case 50384: case 50385: { frostPresenceAura = (*itr); break; } // Improved Unholy Presence case 50391: case 50392: { unholyPresenceAura = (*itr); break; } } } uint32 presence=GetId(); if (apply) { // Blood Presence bonus if (presence == 48266) target->CastSpell(target, 63611, true); else if (bloodPresenceAura) { int32 basePoints1=bloodPresenceAura->GetAmount(); target->CastCustomSpell(target,63611,NULL,&basePoints1,NULL,true,0,bloodPresenceAura); } // Frost Presence bonus if (presence == 48263) target->CastSpell(target, 61261, true); else if (frostPresenceAura) { int32 basePoints0=frostPresenceAura->GetAmount(); target->CastCustomSpell(target,61261,&basePoints0,NULL,NULL,true,0,frostPresenceAura); } // Unholy Presence bonus if (presence == 48265) { if (unholyPresenceAura) { // Not listed as any effect, only base points set int32 basePoints0 = unholyPresenceAura->GetSpellProto()->EffectBasePoints[1]; target->CastCustomSpell(target,63622,&basePoints0 ,&basePoints0,&basePoints0,true,0,unholyPresenceAura); target->CastCustomSpell(target,65095,&basePoints0 ,NULL,NULL,true,0,unholyPresenceAura); } target->CastSpell(target,49772, true); } else if (unholyPresenceAura) { int32 basePoints0=unholyPresenceAura->GetAmount(); target->CastCustomSpell(target,49772,&basePoints0,NULL,NULL,true,0,unholyPresenceAura); } } else { // Remove passive auras if (presence == 48266 || bloodPresenceAura) target->RemoveAurasDueToSpell(63611); if (presence == 48263 || frostPresenceAura) target->RemoveAurasDueToSpell(61261); if (presence == 48265 || unholyPresenceAura) { if (presence == 48265 && unholyPresenceAura) { target->RemoveAurasDueToSpell(63622); target->RemoveAurasDueToSpell(65095); } target->RemoveAurasDueToSpell(49772); } } } break; case SPELLFAMILY_WARLOCK: // Drain Soul - If the target is at or below 25% health, Drain Soul causes four times the normal damage if (GetSpellProto()->SpellFamilyFlags[0] & 0x00004000) { if (!caster) break; if (apply) { if (target != caster && target->GetHealth() <= target->GetMaxHealth() / 4) caster->CastSpell(caster, 200000, true); } else { if (target != caster) caster->RemoveAurasDueToSpell(GetId()); else caster->RemoveAurasDueToSpell(200000); } } break; } } void Aura::SetNeedClientUpdateForTargets() const { for (ApplicationMap::const_iterator appIter = m_applications.begin(); appIter != m_applications.end(); ++appIter) appIter->second->SetNeedClientUpdate(); } void Aura::_DeleteRemovedApplications() { while (!m_removedApplications.empty()) { delete m_removedApplications.front(); m_removedApplications.pop_front(); } } UnitAura::UnitAura(SpellEntry const* spellproto, uint8 effMask, WorldObject * owner, Unit * caster, int32 *baseAmount, Item * castItem, uint64 casterGUID) : Aura(spellproto, effMask, owner, caster, baseAmount, castItem, casterGUID) { m_AuraDRGroup = DIMINISHING_NONE; GetUnitOwner()->_AddAura(this, caster); }; void UnitAura::_ApplyForTarget(Unit * target, Unit * caster, AuraApplication * aurApp) { Aura::_ApplyForTarget(target, caster, aurApp); // register aura diminishing on apply if (DiminishingGroup group = GetDiminishGroup()) target->ApplyDiminishingAura(group,true); } void UnitAura::_UnapplyForTarget(Unit * target, Unit * caster, AuraApplication * aurApp) { Aura::_UnapplyForTarget(target, caster, aurApp); // unregister aura diminishing (and store last time) if (DiminishingGroup group = GetDiminishGroup()) target->ApplyDiminishingAura(group,false); } void UnitAura::Remove(AuraRemoveMode removeMode) { if (IsRemoved()) return; GetUnitOwner()->RemoveOwnedAura(this, removeMode); } void UnitAura::FillTargetMap(std::map<Unit *, uint8> & targets, Unit * caster) { Player * modOwner = NULL; if (caster) modOwner = caster->GetSpellModOwner(); for (uint8 effIndex = 0; effIndex < MAX_SPELL_EFFECTS ; ++effIndex) { if (!HasEffect(effIndex)) continue; UnitList targetList; // non-area aura if (GetSpellProto()->Effect[effIndex] == SPELL_EFFECT_APPLY_AURA) { targetList.push_back(GetUnitOwner()); } else { float radius; if (GetSpellProto()->Effect[effIndex] == SPELL_EFFECT_APPLY_AREA_AURA_ENEMY) radius = GetSpellRadiusForHostile(sSpellRadiusStore.LookupEntry(GetSpellProto()->EffectRadiusIndex[effIndex])); else radius = GetSpellRadiusForFriend(sSpellRadiusStore.LookupEntry(GetSpellProto()->EffectRadiusIndex[effIndex])); if (modOwner) modOwner->ApplySpellMod(GetId(), SPELLMOD_RADIUS, radius); if (!GetUnitOwner()->hasUnitState(UNIT_STAT_ISOLATED)) { switch(GetSpellProto()->Effect[effIndex]) { case SPELL_EFFECT_APPLY_AREA_AURA_PARTY: targetList.push_back(GetUnitOwner()); GetUnitOwner()->GetPartyMemberInDist(targetList, radius); break; case SPELL_EFFECT_APPLY_AREA_AURA_RAID: targetList.push_back(GetUnitOwner()); GetUnitOwner()->GetRaidMember(targetList, radius); break; case SPELL_EFFECT_APPLY_AREA_AURA_FRIEND: { targetList.push_back(GetUnitOwner()); Trinity::AnyFriendlyUnitInObjectRangeCheck u_check(GetUnitOwner(), GetUnitOwner(), radius); Trinity::UnitListSearcher<Trinity::AnyFriendlyUnitInObjectRangeCheck> searcher(GetUnitOwner(), targetList, u_check); GetUnitOwner()->VisitNearbyObject(radius, searcher); break; } case SPELL_EFFECT_APPLY_AREA_AURA_ENEMY: { Trinity::AnyAoETargetUnitInObjectRangeCheck u_check(GetUnitOwner(), GetUnitOwner(), radius); // No GetCharmer in searcher Trinity::UnitListSearcher<Trinity::AnyAoETargetUnitInObjectRangeCheck> searcher(GetUnitOwner(), targetList, u_check); GetUnitOwner()->VisitNearbyObject(radius, searcher); break; } case SPELL_EFFECT_APPLY_AREA_AURA_PET: targetList.push_back(GetUnitOwner()); case SPELL_EFFECT_APPLY_AREA_AURA_OWNER: { if (Unit *owner = GetUnitOwner()->GetCharmerOrOwner()) if (GetUnitOwner()->IsWithinDistInMap(owner, radius)) targetList.push_back(owner); break; } } } } for (UnitList::iterator itr = targetList.begin(); itr!= targetList.end();++itr) { std::map<Unit *, uint8>::iterator existing = targets.find(*itr); if (existing != targets.end()) existing->second |= 1<<effIndex; else targets[*itr] = 1<<effIndex; } } } DynObjAura::DynObjAura(SpellEntry const* spellproto, uint8 effMask, WorldObject * owner, Unit * caster, int32 *baseAmount, Item * castItem, uint64 casterGUID) : Aura(spellproto, effMask, owner, caster, baseAmount, castItem, casterGUID) { GetDynobjOwner()->SetAura(this); } void DynObjAura::Remove(AuraRemoveMode removeMode) { if (IsRemoved()) return; _Remove(removeMode); } void DynObjAura::FillTargetMap(std::map<Unit *, uint8> & targets, Unit * caster) { Unit * dynObjOwnerCaster = GetDynobjOwner()->GetCaster(); float radius = GetDynobjOwner()->GetRadius(); for (uint8 effIndex = 0; effIndex < MAX_SPELL_EFFECTS; ++effIndex) { if (!HasEffect(effIndex)) continue; UnitList targetList; if (GetSpellProto()->EffectImplicitTargetB[effIndex] == TARGET_DEST_DYNOBJ_ALLY || GetSpellProto()->EffectImplicitTargetB[effIndex] == TARGET_UNIT_AREA_ALLY_DST) { Trinity::AnyFriendlyUnitInObjectRangeCheck u_check(GetDynobjOwner(), dynObjOwnerCaster, radius); Trinity::UnitListSearcher<Trinity::AnyFriendlyUnitInObjectRangeCheck> searcher(GetDynobjOwner(), targetList, u_check); GetDynobjOwner()->VisitNearbyObject(radius, searcher); } else { Trinity::AnyAoETargetUnitInObjectRangeCheck u_check(GetDynobjOwner(), dynObjOwnerCaster, radius); Trinity::UnitListSearcher<Trinity::AnyAoETargetUnitInObjectRangeCheck> searcher(GetDynobjOwner(), targetList, u_check); GetDynobjOwner()->VisitNearbyObject(radius, searcher); } for (UnitList::iterator itr = targetList.begin(); itr!= targetList.end();++itr) { std::map<Unit *, uint8>::iterator existing = targets.find(*itr); if (existing != targets.end()) existing->second |= 1<<effIndex; else targets[*itr] = 1<<effIndex; } } }
Muglackh/cejkaz-tc
src/game/SpellAuras.cpp
C++
gpl-2.0
65,021
/* SPDX-License-Identifier: LGPL-2.1-or-later */ #include "errno-util.h" #include "format-table.h" #include "hexdecoct.h" #include "homectl-pkcs11.h" #include "libcrypt-util.h" #include "memory-util.h" #include "openssl-util.h" #include "pkcs11-util.h" #include "random-util.h" #include "strv.h" struct pkcs11_callback_data { char *pin_used; X509 *cert; }; #if HAVE_P11KIT static void pkcs11_callback_data_release(struct pkcs11_callback_data *data) { erase_and_free(data->pin_used); X509_free(data->cert); } static int pkcs11_callback( CK_FUNCTION_LIST *m, CK_SESSION_HANDLE session, CK_SLOT_ID slot_id, const CK_SLOT_INFO *slot_info, const CK_TOKEN_INFO *token_info, P11KitUri *uri, void *userdata) { _cleanup_(erase_and_freep) char *pin_used = NULL; struct pkcs11_callback_data *data = userdata; CK_OBJECT_HANDLE object; int r; assert(m); assert(slot_info); assert(token_info); assert(uri); assert(data); /* Called for every token matching our URI */ r = pkcs11_token_login(m, session, slot_id, token_info, "home directory operation", "user-home", "pkcs11-pin", UINT64_MAX, &pin_used); if (r < 0) return r; r = pkcs11_token_find_x509_certificate(m, session, uri, &object); if (r < 0) return r; r = pkcs11_token_read_x509_certificate(m, session, object, &data->cert); if (r < 0) return r; /* Let's read some random data off the token and write it to the kernel pool before we generate our * random key from it. This way we can claim the quality of the RNG is at least as good as the * kernel's and the token's pool */ (void) pkcs11_token_acquire_rng(m, session); data->pin_used = TAKE_PTR(pin_used); return 1; } #endif static int acquire_pkcs11_certificate( const char *uri, X509 **ret_cert, char **ret_pin_used) { #if HAVE_P11KIT _cleanup_(pkcs11_callback_data_release) struct pkcs11_callback_data data = {}; int r; r = pkcs11_find_token(uri, pkcs11_callback, &data); if (r == -EAGAIN) /* pkcs11_find_token() doesn't log about this error, but all others */ return log_error_errno(SYNTHETIC_ERRNO(ENXIO), "Specified PKCS#11 token with URI '%s' not found.", uri); if (r < 0) return r; *ret_cert = TAKE_PTR(data.cert); *ret_pin_used = TAKE_PTR(data.pin_used); return 0; #else return log_error_errno(SYNTHETIC_ERRNO(EOPNOTSUPP), "PKCS#11 tokens not supported on this build."); #endif } static int encrypt_bytes( EVP_PKEY *pkey, const void *decrypted_key, size_t decrypted_key_size, void **ret_encrypt_key, size_t *ret_encrypt_key_size) { _cleanup_(EVP_PKEY_CTX_freep) EVP_PKEY_CTX *ctx = NULL; _cleanup_free_ void *b = NULL; size_t l; ctx = EVP_PKEY_CTX_new(pkey, NULL); if (!ctx) return log_error_errno(SYNTHETIC_ERRNO(EIO), "Failed to allocate public key context"); if (EVP_PKEY_encrypt_init(ctx) <= 0) return log_error_errno(SYNTHETIC_ERRNO(EIO), "Failed to initialize public key context"); if (EVP_PKEY_CTX_set_rsa_padding(ctx, RSA_PKCS1_PADDING) <= 0) return log_error_errno(SYNTHETIC_ERRNO(EIO), "Failed to configure PKCS#1 padding"); if (EVP_PKEY_encrypt(ctx, NULL, &l, decrypted_key, decrypted_key_size) <= 0) return log_error_errno(SYNTHETIC_ERRNO(EIO), "Failed to determine encrypted key size"); b = malloc(l); if (!b) return log_oom(); if (EVP_PKEY_encrypt(ctx, b, &l, decrypted_key, decrypted_key_size) <= 0) return log_error_errno(SYNTHETIC_ERRNO(EIO), "Failed to determine encrypted key size"); *ret_encrypt_key = TAKE_PTR(b); *ret_encrypt_key_size = l; return 0; } static int add_pkcs11_encrypted_key( JsonVariant **v, const char *uri, const void *encrypted_key, size_t encrypted_key_size, const void *decrypted_key, size_t decrypted_key_size) { _cleanup_(json_variant_unrefp) JsonVariant *l = NULL, *w = NULL, *e = NULL; _cleanup_(erase_and_freep) char *base64_encoded = NULL, *hashed = NULL; int r; assert(v); assert(uri); assert(encrypted_key); assert(encrypted_key_size > 0); assert(decrypted_key); assert(decrypted_key_size > 0); /* Before using UNIX hashing on the supplied key we base64 encode it, since crypt_r() and friends * expect a NUL terminated string, and we use a binary key */ r = base64mem(decrypted_key, decrypted_key_size, &base64_encoded); if (r < 0) return log_error_errno(r, "Failed to base64 encode secret key: %m"); r = hash_password(base64_encoded, &hashed); if (r < 0) return log_error_errno(errno_or_else(EINVAL), "Failed to UNIX hash secret key: %m"); r = json_build(&e, JSON_BUILD_OBJECT( JSON_BUILD_PAIR("uri", JSON_BUILD_STRING(uri)), JSON_BUILD_PAIR("data", JSON_BUILD_BASE64(encrypted_key, encrypted_key_size)), JSON_BUILD_PAIR("hashedPassword", JSON_BUILD_STRING(hashed)))); if (r < 0) return log_error_errno(r, "Failed to build encrypted JSON key object: %m"); w = json_variant_ref(json_variant_by_key(*v, "privileged")); l = json_variant_ref(json_variant_by_key(w, "pkcs11EncryptedKey")); r = json_variant_append_array(&l, e); if (r < 0) return log_error_errno(r, "Failed append PKCS#11 encrypted key: %m"); r = json_variant_set_field(&w, "pkcs11EncryptedKey", l); if (r < 0) return log_error_errno(r, "Failed to set PKCS#11 encrypted key: %m"); r = json_variant_set_field(v, "privileged", w); if (r < 0) return log_error_errno(r, "Failed to update privileged field: %m"); return 0; } static int add_pkcs11_token_uri(JsonVariant **v, const char *uri) { _cleanup_(json_variant_unrefp) JsonVariant *w = NULL; _cleanup_strv_free_ char **l = NULL; int r; assert(v); assert(uri); w = json_variant_ref(json_variant_by_key(*v, "pkcs11TokenUri")); if (w) { r = json_variant_strv(w, &l); if (r < 0) return log_error_errno(r, "Failed to parse PKCS#11 token list: %m"); if (strv_contains(l, uri)) return 0; } r = strv_extend(&l, uri); if (r < 0) return log_oom(); w = json_variant_unref(w); r = json_variant_new_array_strv(&w, l); if (r < 0) return log_error_errno(r, "Failed to create PKCS#11 token URI JSON: %m"); r = json_variant_set_field(v, "pkcs11TokenUri", w); if (r < 0) return log_error_errno(r, "Failed to update PKCS#11 token URI list: %m"); return 0; } int identity_add_token_pin(JsonVariant **v, const char *pin) { _cleanup_(json_variant_unrefp) JsonVariant *w = NULL, *l = NULL; _cleanup_(strv_free_erasep) char **pins = NULL; int r; assert(v); if (isempty(pin)) return 0; w = json_variant_ref(json_variant_by_key(*v, "secret")); l = json_variant_ref(json_variant_by_key(w, "tokenPin")); r = json_variant_strv(l, &pins); if (r < 0) return log_error_errno(r, "Failed to convert PIN array: %m"); if (strv_find(pins, pin)) return 0; r = strv_extend(&pins, pin); if (r < 0) return log_oom(); strv_uniq(pins); l = json_variant_unref(l); r = json_variant_new_array_strv(&l, pins); if (r < 0) return log_error_errno(r, "Failed to allocate new PIN array JSON: %m"); json_variant_sensitive(l); r = json_variant_set_field(&w, "tokenPin", l); if (r < 0) return log_error_errno(r, "Failed to update PIN field: %m"); r = json_variant_set_field(v, "secret", w); if (r < 0) return log_error_errno(r, "Failed to update secret object: %m"); return 1; } int identity_add_pkcs11_key_data(JsonVariant **v, const char *uri) { _cleanup_(erase_and_freep) void *decrypted_key = NULL, *encrypted_key = NULL; _cleanup_(erase_and_freep) char *pin = NULL; size_t decrypted_key_size, encrypted_key_size; _cleanup_(X509_freep) X509 *cert = NULL; EVP_PKEY *pkey; RSA *rsa; int bits; int r; assert(v); r = acquire_pkcs11_certificate(uri, &cert, &pin); if (r < 0) return r; pkey = X509_get0_pubkey(cert); if (!pkey) return log_error_errno(SYNTHETIC_ERRNO(EIO), "Failed to extract public key from X.509 certificate."); if (EVP_PKEY_base_id(pkey) != EVP_PKEY_RSA) return log_error_errno(SYNTHETIC_ERRNO(EBADMSG), "X.509 certificate does not refer to RSA key."); rsa = EVP_PKEY_get0_RSA(pkey); if (!rsa) return log_error_errno(SYNTHETIC_ERRNO(EIO), "Failed to acquire RSA public key from X.509 certificate."); bits = RSA_bits(rsa); log_debug("Bits in RSA key: %i", bits); /* We use PKCS#1 padding for the RSA cleartext, hence let's leave some extra space for it, hence only * generate a random key half the size of the RSA length */ decrypted_key_size = bits / 8 / 2; if (decrypted_key_size < 1) return log_error_errno(SYNTHETIC_ERRNO(EIO), "Uh, RSA key size too short?"); log_debug("Generating %zu bytes random key.", decrypted_key_size); decrypted_key = malloc(decrypted_key_size); if (!decrypted_key) return log_oom(); r = genuine_random_bytes(decrypted_key, decrypted_key_size, RANDOM_BLOCK); if (r < 0) return log_error_errno(r, "Failed to generate random key: %m"); r = encrypt_bytes(pkey, decrypted_key, decrypted_key_size, &encrypted_key, &encrypted_key_size); if (r < 0) return log_error_errno(r, "Failed to encrypt key: %m"); /* Add the token URI to the public part of the record. */ r = add_pkcs11_token_uri(v, uri); if (r < 0) return r; /* Include the encrypted version of the random key we just generated in the privileged part of the record */ r = add_pkcs11_encrypted_key( v, uri, encrypted_key, encrypted_key_size, decrypted_key, decrypted_key_size); if (r < 0) return r; /* If we acquired the PIN also include it in the secret section of the record, so that systemd-homed * can use it if it needs to, given that it likely needs to decrypt the key again to pass to LUKS or * fscrypt. */ r = identity_add_token_pin(v, pin); if (r < 0) return r; return 0; } #if HAVE_P11KIT static int list_callback( CK_FUNCTION_LIST *m, CK_SESSION_HANDLE session, CK_SLOT_ID slot_id, const CK_SLOT_INFO *slot_info, const CK_TOKEN_INFO *token_info, P11KitUri *uri, void *userdata) { _cleanup_free_ char *token_uri_string = NULL, *token_label = NULL, *token_manufacturer_id = NULL, *token_model = NULL; _cleanup_(p11_kit_uri_freep) P11KitUri *token_uri = NULL; Table *t = userdata; int uri_result, r; assert(slot_info); assert(token_info); /* We only care about hardware devices here with a token inserted. Let's filter everything else * out. (Note that the user can explicitly specify non-hardware tokens if they like, but during * enumeration we'll filter those, since software tokens are typically the system certificate store * and such, and it's typically not what people want to bind their home directories to.) */ if (!FLAGS_SET(token_info->flags, CKF_HW_SLOT|CKF_TOKEN_PRESENT)) return -EAGAIN; token_label = pkcs11_token_label(token_info); if (!token_label) return log_oom(); token_manufacturer_id = pkcs11_token_manufacturer_id(token_info); if (!token_manufacturer_id) return log_oom(); token_model = pkcs11_token_model(token_info); if (!token_model) return log_oom(); token_uri = uri_from_token_info(token_info); if (!token_uri) return log_oom(); uri_result = p11_kit_uri_format(token_uri, P11_KIT_URI_FOR_ANY, &token_uri_string); if (uri_result != P11_KIT_URI_OK) return log_warning_errno(SYNTHETIC_ERRNO(EAGAIN), "Failed to format slot URI: %s", p11_kit_uri_message(uri_result)); r = table_add_many( t, TABLE_STRING, token_uri_string, TABLE_STRING, token_label, TABLE_STRING, token_manufacturer_id, TABLE_STRING, token_model); if (r < 0) return table_log_add_error(r); return -EAGAIN; /* keep scanning */ } #endif int list_pkcs11_tokens(void) { #if HAVE_P11KIT _cleanup_(table_unrefp) Table *t = NULL; int r; t = table_new("uri", "label", "manufacturer", "model"); if (!t) return log_oom(); r = pkcs11_find_token(NULL, list_callback, t); if (r < 0 && r != -EAGAIN) return r; if (table_get_rows(t) <= 1) { log_info("No suitable PKCS#11 tokens found."); return 0; } r = table_print(t, stdout); if (r < 0) return log_error_errno(r, "Failed to show device table: %m"); return 0; #else return log_error_errno(SYNTHETIC_ERRNO(EOPNOTSUPP), "PKCS#11 tokens not supported on this build."); #endif } #if HAVE_P11KIT static int auto_callback( CK_FUNCTION_LIST *m, CK_SESSION_HANDLE session, CK_SLOT_ID slot_id, const CK_SLOT_INFO *slot_info, const CK_TOKEN_INFO *token_info, P11KitUri *uri, void *userdata) { _cleanup_(p11_kit_uri_freep) P11KitUri *token_uri = NULL; char **t = userdata; int uri_result; assert(slot_info); assert(token_info); if (!FLAGS_SET(token_info->flags, CKF_HW_SLOT|CKF_TOKEN_PRESENT)) return -EAGAIN; if (*t) return log_error_errno(SYNTHETIC_ERRNO(ENOTUNIQ), "More than one suitable PKCS#11 token found."); token_uri = uri_from_token_info(token_info); if (!token_uri) return log_oom(); uri_result = p11_kit_uri_format(token_uri, P11_KIT_URI_FOR_ANY, t); if (uri_result != P11_KIT_URI_OK) return log_warning_errno(SYNTHETIC_ERRNO(EAGAIN), "Failed to format slot URI: %s", p11_kit_uri_message(uri_result)); return 0; } #endif int find_pkcs11_token_auto(char **ret) { #if HAVE_P11KIT int r; r = pkcs11_find_token(NULL, auto_callback, ret); if (r == -EAGAIN) return log_error_errno(SYNTHETIC_ERRNO(ENODEV), "No suitable PKCS#11 tokens found."); if (r < 0) return r; return 0; #else return log_error_errno(SYNTHETIC_ERRNO(EOPNOTSUPP), "PKCS#11 tokens not supported on this build."); #endif }
endlessm/systemd
src/home/homectl-pkcs11.c
C
gpl-2.0
16,567
using OpenDBDiff.Abstractions.Schema; using OpenDBDiff.Abstractions.Schema.Model; using System; using System.Linq; namespace OpenDBDiff.SqlServer.Schema.Model { public class Columns<T> : SchemaList<Column, T> where T : ISchemaBase { public Columns(T parent) : base(parent) { } /// <summary> /// Clona el objeto Columns en una nueva instancia. /// </summary> public new Columns<T> Clone(T parentObject) { Columns<T> columns = new Columns<T>(parentObject); for (int index = 0; index < this.Count; index++) { columns.Add(this[index].Clone(parentObject)); } return columns; } public override string ToSql() { return string.Join ( ",\r\n", this .Where(c => !c.HasState(ObjectStatus.Drop)) .Select(c => "\t" + c.ToSql(true)) ); } public override SQLScriptList ToSqlDiff(System.Collections.Generic.ICollection<ISchemaBase> schemas) { string sqlDrop = ""; string sqlAdd = ""; string sqlCons = ""; string sqlBinds = ""; SQLScriptList list = new SQLScriptList(); if (Parent.Status != ObjectStatus.Rebuild) { this.ForEach(item => { bool isIncluded = schemas.Count == 0; if (!isIncluded) { foreach (var selectedSchema in schemas) { if (selectedSchema.Id == item.Id) { isIncluded = true; break; } } } if (isIncluded) { if (item.HasState(ObjectStatus.Drop)) { if (item.DefaultConstraint != null) list.Add(item.DefaultConstraint.Drop()); /*Si la columna formula debe ser eliminada y ya fue efectuada la operacion en otro momento, no * se borra nuevamente*/ if (!item.GetWasInsertInDiffList(ScriptAction.AlterColumnFormula)) sqlDrop += "[" + item.Name + "],"; } if (item.HasState(ObjectStatus.Create)) sqlAdd += "\r\n" + item.ToSql(true) + ","; if ((item.HasState(ObjectStatus.Alter) || (item.HasState(ObjectStatus.RebuildDependencies)))) { if ((!item.Parent.HasState(ObjectStatus.RebuildDependencies) || (!item.Parent.HasState(ObjectStatus.Rebuild)))) list.AddRange(item.RebuildSchemaBindingDependencies()); list.AddRange(item.RebuildConstraint(false)); list.AddRange(item.RebuildDependencies()); list.AddRange(item.Alter(ScriptAction.AlterTable)); } if (item.HasState(ObjectStatus.Update)) list.Add("UPDATE " + Parent.FullName + " SET [" + item.Name + "] = " + item.DefaultForceValue + " WHERE [" + item.Name + "] IS NULL\r\nGO\r\n", 0, ScriptAction.UpdateTable); if (item.HasState(ObjectStatus.Bind)) { if (item.Rule.Id != 0) sqlBinds += item.Rule.ToSQLAddBind(); if (item.Rule.Id == 0) sqlBinds += item.Rule.ToSQLAddUnBind(); } if (item.DefaultConstraint != null) list.AddRange(item.DefaultConstraint.ToSqlDiff(schemas)); } }); if (!String.IsNullOrEmpty(sqlDrop)) sqlDrop = "ALTER TABLE " + Parent.FullName + " DROP COLUMN " + sqlDrop.Substring(0, sqlDrop.Length - 1) + "\r\nGO\r\n"; if (!String.IsNullOrEmpty(sqlAdd)) sqlAdd = "ALTER TABLE " + Parent.FullName + " ADD " + sqlAdd.Substring(0, sqlAdd.Length - 1) + "\r\nGO\r\n"; if (!String.IsNullOrEmpty(sqlDrop + sqlAdd + sqlCons + sqlBinds)) list.Add(sqlDrop + sqlAdd + sqlBinds, 0, ScriptAction.AlterTable); } else { this.ForEach(item => { if (item.Status != ObjectStatus.Original) item.RootParent.ActionMessage[item.Parent.FullName].Add(item); }); } return list; } } }
OpenDBDiff/OpenDBDiff
OpenDBDiff.SqlServer.Schema/Model/Columns.cs
C#
gpl-2.0
4,997
#pragma once #include <obs.hpp> #include <map> const std::map<int, const char*> &GetAACEncoderBitrateMap(); const char *GetAACEncoderForBitrate(int bitrate); int FindClosestAvailableAACBitrate(int bitrate);
JohnnyLeone/obs-studio
UI/audio-encoders.hpp
C++
gpl-2.0
210
<?php /** * @package snow-monkey * @author inc2734 * @license GPL-2.0+ * @version 15.13.0 */ use Inc2734\WP_Customizer_Framework\Framework; use Framework\Helper; Framework::control( 'select', 'footer-widget-area-column-size', [ 'label' => __( 'Number of columns in the footer widget area on PC', 'snow-monkey' ), 'priority' => 110, 'default' => '1-4', 'choices' => [ '1-1' => __( '1 column', 'snow-monkey' ), '1-2' => __( '2 columns', 'snow-monkey' ), '1-3' => __( '3 columns', 'snow-monkey' ), '1-4' => __( '4 columns', 'snow-monkey' ), ], 'active_callback' => function() { return Helper::is_active_sidebar( 'footer-widget-area' ); }, ] ); if ( ! is_customize_preview() ) { return; } $panel = Framework::get_panel( 'design' ); $section = Framework::get_section( 'footer' ); $control = Framework::get_control( 'footer-widget-area-column-size' ); $control->join( $section )->join( $panel );
inc2734/snow-monkey
app/customizer/design/sections/footer/controls/footer-widget-area-column-size.php
PHP
gpl-2.0
968
// license:BSD-3-Clause // copyright-holders:Curt Coder /********************************************************************** Kempston Disk Interface emulation **********************************************************************/ #include "kempston_di.h" //************************************************************************** // DEVICE DEFINITIONS //************************************************************************** const device_type KEMPSTON_DISK_INTERFACE = &device_creator<kempston_disk_interface_t>; //------------------------------------------------- // ROM( kempston_disk_system ) //------------------------------------------------- ROM_START( kempston_disk_system ) ROM_REGION( 0x2000, "rom", 0 ) ROM_DEFAULT_BIOS("v114") ROM_SYSTEM_BIOS( 0, "v114", "v1.14" ) ROMX_LOAD( "kempston_disk_system_v1.14_1984.rom", 0x0000, 0x2000, CRC(0b70ad2e) SHA1(ff8158d25864d920f3f6df259167e91c2784692c), ROM_BIOS(1) ) ROM_END //------------------------------------------------- // rom_region - device-specific ROM region //------------------------------------------------- const tiny_rom_entry *kempston_disk_interface_t::device_rom_region() const { return ROM_NAME( kempston_disk_system ); } //************************************************************************** // LIVE DEVICE //************************************************************************** //------------------------------------------------- // kempston_disk_interface_t - constructor //------------------------------------------------- kempston_disk_interface_t::kempston_disk_interface_t(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) : device_t(mconfig, KEMPSTON_DISK_INTERFACE, "Kempston Disk Interface", tag, owner, clock, "ql_kdi", __FILE__), device_ql_expansion_card_interface(mconfig, *this) { } //------------------------------------------------- // device_start - device-specific startup //------------------------------------------------- void kempston_disk_interface_t::device_start() { } //------------------------------------------------- // read - //------------------------------------------------- UINT8 kempston_disk_interface_t::read(address_space &space, offs_t offset, UINT8 data) { return data; } //------------------------------------------------- // write - //------------------------------------------------- void kempston_disk_interface_t::write(address_space &space, offs_t offset, UINT8 data) { }
GiuseppeGorgoglione/mame
src/devices/bus/ql/kempston_di.cpp
C++
gpl-2.0
2,486
extern sf::Time deltaTime;
johan-bjareholt/spacesim-2d
include/main.h
C
gpl-2.0
28
//////////////////////////////////////////////////////////////////////////////// // // Copyright 2016 RWS Inc, All Rights Reserved // // This program is free software; you can redistribute it and/or modify // it under the terms of version 2 of the GNU General Public License as published by // the Free Software Foundation // // 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 // // fire.cpp // Project: Postal // // This module implements the CFire weapon class which is a burning flame // for several different effects and weapons. // // // History: // 01/17/97 BRH Started this weapon object. // // 01/23/97 BRH Updated the time to GetGameTime rather than using // real time.. // // 02/04/97 JMI Changed LoadDib() call to Load() (which now supports // loading of DIBs). // // 02/06/97 BRH Added RAnimSprite animation of the explosion for now. // We are going to do an Alpha effect on the explosion, so // there are two animations, one of the image and one of // the Alpha information stored as a BMP8 animation. When // the Alpha effect is ready, we will pass a frame from // each animation to a function to draw it. // // 02/06/97 BRH Fixed problem with timer. Since all Explosion objects // are using the same resource managed animation, they cannot // use the animation timer, they have to do the timing // themselves. // // 02/07/97 BRH Changed the sprite from CSprite2 to CSpriteAlpha2 for // the Alpha Blit effect. // // 02/09/97 BRH Started the Fire from Explode file since they are // similar. // // 02/10/97 JMI rspReleaseResource() now takes a ptr to a ptr. // // 02/11/97 BRH Changed the fire to start on a random frame number // so if you have many fires, they don't pulsate or all // burn in sync with each other. // // 02/14/97 BRH Changed from using the RAnimSprite to channel data. // // 02/17/97 BRH Now uses the resource manager to get the assets and starts // at a random time interval so the fire will be random again. // // 02/17/97 BRH Changed the lifetime to be time based rather than frame // based which was causing the fire to live on forever // since being switched from RAnimSprite to RChannel1. // // 02/18/97 BRH Now the fire changes to different Alpha channels as it // burns out during its time to live. // // 02/19/97 BRH Checks for collisions and sends messages. // // 02/19/97 BRH Added the ability to run both small and large fire // animations. Change the duration on the alpha layers // so that the initial alpha channel gets played for 80% // of the burning time. Also added bThick parameter to startup // which will start using the 0th Alpha channel which is // more opaque. If you want more Alpha, set to false which // will start on the next Alpha level down. // // 02/23/97 BRH Added static Preload() funciton which will be called // before play begins to cache a resource for this object. // // 02/24/97 JMI No longer sets the m_type member of the m_sprite b/c it // is set by m_sprite's constructor. // // 02/24/97 BRH Set the default state in ProcessMessages // // 02/24/97 BRH Added a timer for checkin collisions so it doesn't have // to check each time, but it was checking only when changing // alpha levels which was too long. // // 03/05/97 JMI Render()'s mapping from 3D to 2D had a typo (was adding m_dY // instead of subtracting). Now uses Map3Dto2D(). // // 03/13/97 JMI Load now takes a version number. // // 04/10/97 BRH Updated this to work with the new multi layer attribute // maps. // // 04/14/97 BRH Added CSmash::Item to the collide bits so that the fire // will send messages to barrels and other items. // // 04/21/97 BRH Added Smoke animation to the fire and the ability of the // fire to change to smoke. // // 02/22/97 BRH Adjusted the timer for the smoke effect to eliminate some // of the final frames so that the smoke wouldn't pulsate // like it did. // // 04/23/97 JMI Changed this item's m_smash bits from CSmash::Item to // CSmash::Fire. // Now affects Characters, Miscs, Mines, and Barrels. // // 04/24/97 BRH Added static wind direction variable that will get // adjusted slightly by each new creation of smoke which // calls WindDirectionUpdate() to randomly vary the wind // direction. // // 04/25/97 BRH Fixed problem with smoke that was created as smoke, // setting people on fire. Also fixed wall detection // and added an individual direction variable to each // instance of smoke that initially copies the wind // direction and uses it until it hits a wall, then it // rotates in one direction or the other until it is // free to move again. // // 05/09/97 JMI Update() now moves the smashatorium object when the CFire // is not Smoke. // // 05/29/97 JMI Removed ASSERT on m_pRealm->m_pAttribMap which no longer // exists. // // 06/11/97 BRH Pass along the m_u16ShooterID value in the Burn message. // // 06/15/97 BRH Fixed Smoke going past animation by 1 frame. // // 06/16/97 BRH Fixed smoke init of static wind direction. Now it // inits the wind direction on class load so that it doesn't // cause problems for the demo mode. // // 06/17/97 MJR Same as previous one for wind velocity. // // MJR Moved resetting of statics to Preload(), since in most // cases, fire or smoke are not Load()'ed. // // 06/18/97 BRH Changed over to using GetRandom() // // 06/26/97 BRH Added CSmash::AlmostDead to the include bits for fire so // that writhing guys can be killed by fire. // // 07/01/97 BRH Added small smoke animation. // // 07/04/97 BRH Added an auto alpha blend on the small smoke for the // rocket trails so they can blend into alpha based on // their time to live. May need to disable the // alpha channel for it to work correctly. // // 07/08/97 JMI Fixed Render() to distribute the homogeneous alpha level // better. Still needs tuning. // // 07/09/97 JMI Now uses m_pRealm->Make2dResPath() to get the fullpath // for 2D image components. // // 07/09/97 JMI Changed Preload() to take a pointer to the calling realm // as a parameter. // // 07/10/97 JMI Now uses alpha mask and level for animation. // // 07/13/97 BRH Changed the animations to use only 1 alpha mask and change // the alpha level based on time. // // 07/20/97 JMI Added some ASSERTs. // // 07/23/97 BRH Changed small fires to create small smokes rather than // large which slows down the game quite a bit. // // 07/27/97 JMI Changed to use Z position (i.e., X/Z plane) instead of // Y2 position (i.e., viewing plane) position for draw // priority. // // 08/11/97 BRH If alpha blending is turned off, as a performance option, // then don't even blit the smoke since without the alpha // effect, you can't see through it at all. // // 08/20/97 JMI Now does a range check on m_sCurrentAlphaLevel after // decrementing. // // 09/02/97 JMI Added m_u16FireStarterID. This is used for a special case // when the starter of the fire is not the thing using the // fire as a weapon (e.g., when a guy catches fire he can // use the fire on other people by running into them causing // them to catch on fire; however, if his own fire kills him // it is to the creator of the fire's credit that he dies). // //////////////////////////////////////////////////////////////////////////////// #define FIRE_CPP #include "RSPiX.h" #include <math.h> #include "fire.h" #include "dude.h" #include "game.h" #include "reality.h" //////////////////////////////////////////////////////////////////////////////// // Macros/types/etc. //////////////////////////////////////////////////////////////////////////////// #define AA_FILE "fire.aan" #define LARGE_FILE "fire.aan" #define SMALL_FILE "smallfire.aan" #define SMOKE_FILE "smoke.aan" #define SMALL_SMOKE_FILE "tinysmoke.aan" #define INIT_WIND_DIR 30 #define INIT_WIND_VEL 30 #define MAX_ALPHA 200 // Used for smoke trails #define THICK_ALPHA 255 // Start alpha level for thick fire #define THIN_ALPHA 200 // Start alpha level for thin fire #define DIEDOWN_ALPHA 100 // Point at which it looks like its dying down #define SMOLDER_ALPHA 30 // Point at which it is too weak to burn anyone #define BRIGHT_PERCENT 0.80 // Amount of the time it should be more opaque //////////////////////////////////////////////////////////////////////////////// // Variables/data //////////////////////////////////////////////////////////////////////////////// // Let this auto-init to 0 int16_t CFire::ms_sFileCount; int16_t CFire::ms_sLargeRadius = 20; int16_t CFire::ms_sSmallRadius = 8; int16_t CFire::ms_sWindDirection = INIT_WIND_DIR; // Start wind in this direction int32_t CFire::ms_lCollisionTime = 250; // Check for collisions this often int32_t CFire::ms_lSmokeTime = 10000; // Time to let smoke run double CFire::ms_dWindVelocity = INIT_WIND_VEL; // Pixels per second drift due to wind //////////////////////////////////////////////////////////////////////////////// // Load object (should call base class version!) //////////////////////////////////////////////////////////////////////////////// int16_t CFire::Load( // Returns 0 if successfull, non-zero otherwise RFile* pFile, // In: File to load from bool bEditMode, // In: True for edit mode, false otherwise int16_t sFileCount, // In: File count (unique per file, never 0) uint32_t ulFileVersion) // In: Version of file format to load. { int16_t sResult = CThing::Load(pFile, bEditMode, sFileCount, ulFileVersion); if (sResult == 0) { // Load common data just once per file (not with each object) if (ms_sFileCount != sFileCount) { ms_sFileCount = sFileCount; // Init the static wind direction and velocity when the class loads. ms_sWindDirection = INIT_WIND_DIR; ms_dWindVelocity = INIT_WIND_VEL; // Load static data. switch (ulFileVersion) { default: case 1: break; } } // Load instance data. switch (ulFileVersion) { default: case 1: pFile->Read(&m_eFireAnim); break; } // Make sure there were no file errors or format errors . . . if (!pFile->Error() && sResult == 0) { // Get resources sResult = GetResources(); } else { sResult = -1; TRACE("CFire::Load(): Error reading from file!\n"); } } else { TRACE("CFire::Load(): CThing::Load() failed.\n"); } return sResult; } //////////////////////////////////////////////////////////////////////////////// // Save object (should call base class version!) //////////////////////////////////////////////////////////////////////////////// int16_t CFire::Save( // Returns 0 if successfull, non-zero otherwise RFile* pFile, // In: File to save to int16_t sFileCount) // In: File count (unique per file, never 0) { int16_t sResult = CThing::Save(pFile, sFileCount); if (sResult == 0) { // Save common data just once per file (not with each object) if (ms_sFileCount != sFileCount) { ms_sFileCount = sFileCount; // Save static data } pFile->Write(&m_eFireAnim); } else { TRACE("CFire::Save(): CThing::Save() failed.\n"); } return sResult; } //////////////////////////////////////////////////////////////////////////////// // Startup object //////////////////////////////////////////////////////////////////////////////// int16_t CFire::Startup(void) // Returns 0 if successfull, non-zero otherwise { return Init(); } //////////////////////////////////////////////////////////////////////////////// // Shutdown object //////////////////////////////////////////////////////////////////////////////// int16_t CFire::Shutdown(void) // Returns 0 if successfull, non-zero otherwise { return 0; } //////////////////////////////////////////////////////////////////////////////// // Suspend object //////////////////////////////////////////////////////////////////////////////// void CFire::Suspend(void) { m_sSuspend++; } //////////////////////////////////////////////////////////////////////////////// // Resume object //////////////////////////////////////////////////////////////////////////////// void CFire::Resume(void) { m_sSuspend--; // If we're actually going to start updating again, we need to reset // the time so as to ignore any time that passed while we were suspended. // This method is far from precise, but I'm hoping it's good enough. if (m_sSuspend == 0) m_lPrevTime = m_pRealm->m_time.GetGameTime(); } //////////////////////////////////////////////////////////////////////////////// // Update object //////////////////////////////////////////////////////////////////////////////// void CFire::Update(void) { int32_t lThisTime; double dSeconds; double dDistance; double dNewX; double dNewZ; if (!m_sSuspend) { // See if we killed ourselves if (ProcessMessages() == State_Deleted) return; if (m_lTimer < m_lBurnUntil) { lThisTime = m_pRealm->m_time.GetGameTime(); m_lTimer += lThisTime - m_lPrevTime; // See if its time to change to the next alpha channel if (m_lTimer > m_lCurrentAlphaTimeout) { m_sCurrentAlphaLevel--; // Range check. if (m_sCurrentAlphaLevel < 0) m_sCurrentAlphaLevel = 0; else if (m_sCurrentAlphaLevel > 255) m_sCurrentAlphaLevel = 255; if (m_lTimer < m_lAlphaBreakPoint) m_lCurrentAlphaTimeout += m_lBrightAlphaInterval; else m_lCurrentAlphaTimeout += m_lDimAlphaInterval; } if (lThisTime > m_lCollisionTimer) { // If the fire is not smoldering out, then it has the ability // to set other things on fire and should check collisions // to see which things it should tell to burn. if (m_bSendMessages && m_sCurrentAlphaLevel > SMOLDER_ALPHA && m_eFireAnim != Smoke && m_eFireAnim != SmallSmoke) { CSmash* pSmashed = NULL; GameMessage msg; msg.msg_Burn.eType = typeBurn; msg.msg_Burn.sPriority = 0; msg.msg_Burn.sDamage = 10; msg.msg_Burn.u16ShooterID = m_u16ShooterID; m_pRealm->m_smashatorium.QuickCheckReset(&m_smash, m_u32CollideIncludeBits, m_u32CollideDontcareBits, m_u32CollideExcludeBits); while (m_pRealm->m_smashatorium.QuickCheckNext(&pSmashed)) { // Default to the standard case where credit is given to the // shooter. msg.msg_Burn.u16ShooterID = m_u16ShooterID; if ((m_bIsBurningDude) && (pSmashed->m_pThing->GetClassID() != CDudeID)) UnlockAchievement(ACHIEVEMENT_TOUCH_SOMEONE_WHILE_BURNING); // If the fire starter ID is set . . . if (m_u16FireStarterID != CIdBank::IdNil) { // If this is the shooter . . . if (pSmashed->m_pThing->GetInstanceID() == m_u16ShooterID) { // The shooter is damaged by his own fire with credit // given to the fire starter. msg.msg_Burn.u16ShooterID = m_u16FireStarterID; } } // Burn. SendThingMessage(&msg, pSmashed->m_pThing); } } // Reset collision timer for next time m_lCollisionTimer = lThisTime + ms_lCollisionTime; } // If this is smoke, make it drift in the wind direction if (m_eFireAnim == Smoke || m_eFireAnim == SmallSmoke) { // Update position using wind direction and velocity dSeconds = ((double) lThisTime - (double) m_lPrevTime) / 1000.0; // Apply internal velocity. dDistance = ms_dWindVelocity * dSeconds; dNewX = m_dX + COSQ[(int16_t) m_sRot] * dDistance; dNewZ = m_dZ - SINQ[(int16_t) m_sRot] * dDistance; // Check attribute map for walls, and if you hit a wall, // set the timer so you will die off next time around. int16_t sHeight = m_pRealm->GetHeight((int16_t) dNewX, (int16_t) dNewZ); // If it hits a wall taller than itself, then it will rotate in the // predetermined direction until it is free to move. if ((int16_t) m_dY < sHeight) { if (m_bTurnRight) m_sRot = rspMod360(m_sRot - 20); else m_sRot = rspMod360(m_sRot + 20); } else // else it is ok, so update its new position { m_dX = dNewX; m_dZ = dNewZ; } } else { // Update our smashatorium location. m_smash.m_sphere.sphere.X = m_dX; m_smash.m_sphere.sphere.Y = m_dY; m_smash.m_sphere.sphere.Z = m_dZ; // Update the smash. m_pRealm->m_smashatorium.Update(&m_smash); } m_lPrevTime = lThisTime; } else { // If its done smoking, then delete it if (m_eFireAnim == Smoke || m_eFireAnim == SmallSmoke) { delete this; } // Else change the fire to smoke else { if (Smokeout() != SUCCESS) delete this; } } } } //////////////////////////////////////////////////////////////////////////////// // Render object //////////////////////////////////////////////////////////////////////////////// void CFire::Render(void) { CAlphaAnim* pAnim; if (m_eFireAnim == Smoke || m_eFireAnim == SmallSmoke) { pAnim = (CAlphaAnim*) m_pAnimChannel->GetAtTime(m_lTimer); // For a performance gain, don't blit the smoke at all if alpha // blending is turned off - its impossible to see through when // alpha blending is off anyway. if (g_GameSettings.m_sAlphaBlend) m_sprite.m_sInFlags = 0; else m_sprite.m_sInFlags = CSprite::InHidden; } else { pAnim = (CAlphaAnim*) m_pAnimChannel->GetAtTime(m_lTimer % m_pAnimChannel->TotalTime()); } if (pAnim) { // Map from 3d to 2d coords Map3Dto2D(m_dX, m_dY, m_dZ, &(m_sprite.m_sX2), &(m_sprite.m_sY2) ); // Offset by animations 2D offsets. m_sprite.m_sX2 += pAnim->m_sX; m_sprite.m_sY2 += pAnim->m_sY; // Priority is based on our Z position. m_sprite.m_sPriority = m_dZ; // Layer should be based on info we get from attribute map. m_sprite.m_sLayer = CRealm::GetLayerViaAttrib(m_pRealm->GetLayer((int16_t) m_dX, (int16_t) m_dZ)); // Copy the color info and the alpha channel to the Alpha Sprite m_sprite.m_pImage = &(pAnim->m_imColor); // If its the tiny smoke (for trails) // Do the alpha based on the time to live. if (m_eFireAnim == SmallSmoke) { // Set the alpha level so it gets more translucent over time. m_sprite.m_sAlphaLevel = MAX_ALPHA - (MAX_ALPHA * (m_lTimer - m_lStartTime) ) / m_lTimeToLive ; // Do a range check. if (m_sprite.m_sAlphaLevel < 0) m_sprite.m_sAlphaLevel = 0; else if (m_sprite.m_sAlphaLevel > MAX_ALPHA) m_sprite.m_sAlphaLevel = MAX_ALPHA; } else { m_sprite.m_sAlphaLevel = m_sCurrentAlphaLevel; } // Now there is only one alpha mask m_sprite.m_pimAlpha = &(pAnim->m_pimAlphaArray[0]); ASSERT(m_sprite.m_sAlphaLevel <= 255); ASSERT(m_sprite.m_sAlphaLevel >= 0); // Update sprite in scene m_pRealm->m_scene.UpdateSprite(&m_sprite); } } //////////////////////////////////////////////////////////////////////////////// // Setup //////////////////////////////////////////////////////////////////////////////// int16_t CFire::Setup( // Returns 0 if successfull, non-zero otherwise int16_t sX, // In: New x coord int16_t sY, // In: New y coord int16_t sZ, // In: New z coord int32_t lTimeToLive, // In: Number of milliseconds to burn, default 1sec bool bThick, // In: Use thick fire (more opaque) default = true FireAnim eAnimType) // In: Animation type to use default = LargeFire { int16_t sResult = 0; // Use specified position m_dX = (double)sX; m_dY = (double)sY; m_dZ = (double)sZ; m_lPrevTime = m_pRealm->m_time.GetGameTime(); m_lCollisionTimer = m_lPrevTime + ms_lCollisionTime; m_eFireAnim = eAnimType; m_lTimeToLive = lTimeToLive; if (bThick) m_sCurrentAlphaLevel = THICK_ALPHA; else m_sCurrentAlphaLevel = THIN_ALPHA; // Load resources sResult = GetResources(); if (sResult == SUCCESS) sResult = Init(); m_sRot = ms_sWindDirection; m_bTurnRight = (GetRandom() & 0x01); return sResult; } //////////////////////////////////////////////////////////////////////////////// // Init //////////////////////////////////////////////////////////////////////////////// int16_t CFire::Init(void) { int16_t sResult = SUCCESS; CAlphaAnim* pAnim = NULL; if (m_pAnimChannel != NULL) { m_lTimer = GetRandom() % m_pAnimChannel->TotalTime(); m_lStartTime = m_lTimer; m_lBurnUntil = m_lTimer + m_lTimeToLive; m_lAlphaBreakPoint = m_lTimer + (m_lTimeToLive * BRIGHT_PERCENT); pAnim = (CAlphaAnim*) m_pAnimChannel->GetAtTime(0); ASSERT(pAnim != NULL); m_lBrightAlphaInterval = (m_lTimeToLive * BRIGHT_PERCENT) / MAX(1, m_sCurrentAlphaLevel - DIEDOWN_ALPHA); m_lDimAlphaInterval = (m_lTimeToLive * (100.0 - BRIGHT_PERCENT)) / MAX(1, DIEDOWN_ALPHA); m_lCurrentAlphaTimeout = m_lTimer + m_lBrightAlphaInterval; m_sTotalAlphaChannels = 1; } switch (m_eFireAnim) { case LargeFire: // Update sphere m_smash.m_sphere.sphere.X = m_dX; m_smash.m_sphere.sphere.Y = m_dY; m_smash.m_sphere.sphere.Z = m_dZ; m_smash.m_sphere.sphere.lRadius = ms_sLargeRadius; m_smash.m_bits = CSmash::Fire; m_smash.m_pThing = this; // Update the smash m_pRealm->m_smashatorium.Update(&m_smash); break; case SmallFire: // Update sphere m_smash.m_sphere.sphere.X = m_dX; m_smash.m_sphere.sphere.Y = m_dY; m_smash.m_sphere.sphere.Z = m_dZ; m_smash.m_sphere.sphere.lRadius = ms_sSmallRadius; m_smash.m_bits = CSmash::Fire; m_smash.m_pThing = this; // Update the smash m_pRealm->m_smashatorium.Update(&m_smash); break; case Smoke: m_smash.m_pThing = NULL; m_bSendMessages = false; break; case SmallSmoke: m_smash.m_pThing = NULL; m_bSendMessages = false; m_lStartTime = m_lTimer = GetRandom() % m_pAnimChannel->TotalTime() / 3; m_lBurnUntil = m_lTimer + m_lTimeToLive; break; } // Set the collision bits m_u32CollideIncludeBits = CSmash::Character | CSmash::Barrel | CSmash::Mine | CSmash::Misc | CSmash::AlmostDead; m_u32CollideDontcareBits = CSmash::Good | CSmash::Bad; m_u32CollideExcludeBits = 0; return sResult; } //////////////////////////////////////////////////////////////////////////////// // Smokeout - Change from fire to smoke //////////////////////////////////////////////////////////////////////////////// int16_t CFire::Smokeout(void) { int16_t sResult = SUCCESS; // Modify the wind direction slightly WindDirectionUpdate(); // Remove smash from the smashatorium if it was being used if (m_smash.m_pThing) m_pRealm->m_smashatorium.Remove(&m_smash); m_bSendMessages = false; // Release the fire animation and get the smoke animation FreeResources(); if (m_eFireAnim == SmallFire) m_eFireAnim = SmallSmoke; else m_eFireAnim = Smoke; sResult = GetResources(); // Reset timers CAlphaAnim* pAnim = NULL; if (m_pAnimChannel != NULL) { // Reset alpha level m_sCurrentAlphaLevel = THICK_ALPHA; pAnim = (CAlphaAnim*) m_pAnimChannel->GetAtTime(0); ASSERT(pAnim != NULL); // m_lTimeToLive = m_pAnimChannel->TotalTime(); // use same time to live as the original m_lStartTime = m_lTimer = 0; m_lBurnUntil = m_lTimer + m_lTimeToLive; m_lAlphaBreakPoint = m_lTimer + (m_lTimeToLive * BRIGHT_PERCENT); m_lBrightAlphaInterval = (m_lTimeToLive * BRIGHT_PERCENT) / MAX(1, m_sCurrentAlphaLevel - DIEDOWN_ALPHA); m_lDimAlphaInterval = (m_lTimeToLive * (1.0 - BRIGHT_PERCENT)) / MAX(1, DIEDOWN_ALPHA); m_lCurrentAlphaTimeout = m_lTimer + m_lBrightAlphaInterval; m_sTotalAlphaChannels = 1; } return sResult; } //////////////////////////////////////////////////////////////////////////////// // Called by editor to init new object at specified position //////////////////////////////////////////////////////////////////////////////// int16_t CFire::EditNew( // Returns 0 if successfull, non-zero otherwise int16_t sX, // In: New x coord int16_t sY, // In: New y coord int16_t sZ) // In: New z coord { int16_t sResult = 0; // Use specified position m_dX = (double)sX; m_dY = (double)sY; m_dZ = (double)sZ; m_lTimer = GetRandom(); //m_pRealm->m_time.GetGameTime() + 1000; m_lPrevTime = m_pRealm->m_time.GetGameTime(); // Load resources sResult = GetResources(); return sResult; } //////////////////////////////////////////////////////////////////////////////// // Called by editor to modify object //////////////////////////////////////////////////////////////////////////////// int16_t CFire::EditModify(void) { return 0; } //////////////////////////////////////////////////////////////////////////////// // Called by editor to move object to specified position //////////////////////////////////////////////////////////////////////////////// int16_t CFire::EditMove( // Returns 0 if successfull, non-zero otherwise int16_t sX, // In: New x coord int16_t sY, // In: New y coord int16_t sZ) // In: New z coord { m_dX = (double)sX; m_dY = (double)sY; m_dZ = (double)sZ; return 0; } //////////////////////////////////////////////////////////////////////////////// // Called by editor to update object //////////////////////////////////////////////////////////////////////////////// void CFire::EditUpdate(void) { } //////////////////////////////////////////////////////////////////////////////// // Called by editor to render object //////////////////////////////////////////////////////////////////////////////// void CFire::EditRender(void) { // In some cases, object's might need to do a special-case render in edit // mode because Startup() isn't called. In this case it doesn't matter, so // we can call the normal Render(). Render(); } //////////////////////////////////////////////////////////////////////////////// // Get all required resources //////////////////////////////////////////////////////////////////////////////// int16_t CFire::GetResources(void) // Returns 0 if successfull, non-zero otherwise { int16_t sResult = SUCCESS; switch (m_eFireAnim) { case LargeFire: sResult = rspGetResource(&g_resmgrGame, m_pRealm->Make2dResPath(LARGE_FILE), &m_pAnimChannel, RFile::LittleEndian); break; case SmallFire: sResult = rspGetResource(&g_resmgrGame, m_pRealm->Make2dResPath(SMALL_FILE), &m_pAnimChannel, RFile::LittleEndian); break; case Smoke: sResult = rspGetResource(&g_resmgrGame, m_pRealm->Make2dResPath(SMOKE_FILE), &m_pAnimChannel, RFile::LittleEndian); break; case SmallSmoke: sResult = rspGetResource(&g_resmgrGame, m_pRealm->Make2dResPath(SMALL_SMOKE_FILE), &m_pAnimChannel, RFile::LittleEndian); break; } if (sResult != 0) TRACE("CFire::GetResources - Error getting fire animation resource\n"); return sResult; } //////////////////////////////////////////////////////////////////////////////// // Free all resources //////////////////////////////////////////////////////////////////////////////// int16_t CFire::FreeResources(void) // Returns 0 if successfull, non-zero otherwise { int16_t sResult = 0; rspReleaseResource(&g_resmgrGame, &m_pAnimChannel); return sResult; } //////////////////////////////////////////////////////////////////////////////// // Preload - basically trick the resource manager into caching resources for fire // animations before play begins so that when a fire is set for // the first time, there won't be a delay while it loads. //////////////////////////////////////////////////////////////////////////////// int16_t CFire::Preload( CRealm* prealm) // In: Calling realm. { // Init the static wind direction and velocity when the class loads. ms_sWindDirection = INIT_WIND_DIR; ms_dWindVelocity = INIT_WIND_VEL; ChannelAA* pRes; int16_t sResult = rspGetResource(&g_resmgrGame, prealm->Make2dResPath(LARGE_FILE), &pRes, RFile::LittleEndian); rspReleaseResource(&g_resmgrGame, &pRes); sResult |= rspGetResource(&g_resmgrGame, prealm->Make2dResPath(SMALL_FILE), &pRes, RFile::LittleEndian); rspReleaseResource(&g_resmgrGame, &pRes); sResult |= rspGetResource(&g_resmgrGame, prealm->Make2dResPath(SMOKE_FILE), &pRes, RFile::LittleEndian); rspReleaseResource(&g_resmgrGame, &pRes); sResult |= rspGetResource(&g_resmgrGame, prealm->Make2dResPath(SMALL_SMOKE_FILE), &pRes, RFile::LittleEndian); rspReleaseResource(&g_resmgrGame, &pRes); return sResult; } //////////////////////////////////////////////////////////////////////////////// // ProcessMessages //////////////////////////////////////////////////////////////////////////////// CFire::CFireState CFire::ProcessMessages(void) { CFireState eNewState = State_Idle; GameMessage msg; if (m_MessageQueue.DeQ(&msg) == true) { switch(msg.msg_Generic.eType) { case typeObjectDelete: m_MessageQueue.Empty(); delete this; return CFire::State_Deleted; break; } } // Dump the rest of the messages m_MessageQueue.Empty(); return eNewState; } //////////////////////////////////////////////////////////////////////////////// // EOF ////////////////////////////////////////////////////////////////////////////////
PixelDevLabs/Ezia-Cleaner_Build-934afd57b26a
fire.cpp
C++
gpl-2.0
29,776
/* $Id: elsa_ser.c,v 1.1.1.1 2011/08/19 02:08:59 ronald Exp $ * * stuff for the serial modem on ELSA cards * * This software may be used and distributed according to the terms * of the GNU General Public License, incorporated herein by reference. * */ #include <linux/serial.h> #include <linux/serial_reg.h> #include <linux/slab.h> #define MAX_MODEM_BUF 256 #define WAKEUP_CHARS (MAX_MODEM_BUF/2) #define RS_ISR_PASS_LIMIT 256 #define BASE_BAUD ( 1843200 / 16 ) //#define SERIAL_DEBUG_OPEN 1 //#define SERIAL_DEBUG_INTR 1 //#define SERIAL_DEBUG_FLOW 1 #undef SERIAL_DEBUG_OPEN #undef SERIAL_DEBUG_INTR #undef SERIAL_DEBUG_FLOW #undef SERIAL_DEBUG_REG //#define SERIAL_DEBUG_REG 1 #ifdef SERIAL_DEBUG_REG static u_char deb[32]; const char *ModemIn[] = {"RBR","IER","IIR","LCR","MCR","LSR","MSR","SCR"}; const char *ModemOut[] = {"THR","IER","FCR","LCR","MCR","LSR","MSR","SCR"}; #endif static char *MInit_1 = "AT&F&C1E0&D2\r\0"; static char *MInit_2 = "ATL2M1S64=13\r\0"; static char *MInit_3 = "AT+FCLASS=0\r\0"; static char *MInit_4 = "ATV1S2=128X1\r\0"; static char *MInit_5 = "AT\\V8\\N3\r\0"; static char *MInit_6 = "ATL0M0&G0%E1\r\0"; static char *MInit_7 = "AT%L1%M0%C3\r\0"; static char *MInit_speed28800 = "AT%G0%B28800\r\0"; static char *MInit_dialout = "ATs7=60 x1 d\r\0"; static char *MInit_dialin = "ATs7=60 x1 a\r\0"; static inline unsigned int serial_in(struct IsdnCardState *cs, int offset) { #ifdef SERIAL_DEBUG_REG u_int val = inb(cs->hw.elsa.base + 8 + offset); debugl1(cs,"in %s %02x",ModemIn[offset], val); return(val); #else return inb(cs->hw.elsa.base + 8 + offset); #endif } static inline unsigned int serial_inp(struct IsdnCardState *cs, int offset) { #ifdef SERIAL_DEBUG_REG #ifdef ELSA_SERIAL_NOPAUSE_IO u_int val = inb(cs->hw.elsa.base + 8 + offset); debugl1(cs,"inp %s %02x",ModemIn[offset], val); #else u_int val = inb_p(cs->hw.elsa.base + 8 + offset); debugl1(cs,"inP %s %02x",ModemIn[offset], val); #endif return(val); #else #ifdef ELSA_SERIAL_NOPAUSE_IO return inb(cs->hw.elsa.base + 8 + offset); #else return inb_p(cs->hw.elsa.base + 8 + offset); #endif #endif } static inline void serial_out(struct IsdnCardState *cs, int offset, int value) { #ifdef SERIAL_DEBUG_REG debugl1(cs,"out %s %02x",ModemOut[offset], value); #endif outb(value, cs->hw.elsa.base + 8 + offset); } static inline void serial_outp(struct IsdnCardState *cs, int offset, int value) { #ifdef SERIAL_DEBUG_REG #ifdef ELSA_SERIAL_NOPAUSE_IO debugl1(cs,"outp %s %02x",ModemOut[offset], value); #else debugl1(cs,"outP %s %02x",ModemOut[offset], value); #endif #endif #ifdef ELSA_SERIAL_NOPAUSE_IO outb(value, cs->hw.elsa.base + 8 + offset); #else outb_p(value, cs->hw.elsa.base + 8 + offset); #endif } /* * This routine is called to set the UART divisor registers to match * the specified baud rate for a serial port. */ static void change_speed(struct IsdnCardState *cs, int baud) { int quot = 0, baud_base; unsigned cval, fcr = 0; int bits; /* byte size and parity */ cval = 0x03; bits = 10; /* Determine divisor based on baud rate */ baud_base = BASE_BAUD; quot = baud_base / baud; /* If the quotient is ever zero, default to 9600 bps */ if (!quot) quot = baud_base / 9600; /* Set up FIFO's */ if ((baud_base / quot) < 2400) fcr = UART_FCR_ENABLE_FIFO | UART_FCR_TRIGGER_1; else fcr = UART_FCR_ENABLE_FIFO | UART_FCR_TRIGGER_8; serial_outp(cs, UART_FCR, fcr); /* CTS flow control flag and modem status interrupts */ cs->hw.elsa.IER &= ~UART_IER_MSI; cs->hw.elsa.IER |= UART_IER_MSI; serial_outp(cs, UART_IER, cs->hw.elsa.IER); debugl1(cs,"modem quot=0x%x", quot); serial_outp(cs, UART_LCR, cval | UART_LCR_DLAB);/* set DLAB */ serial_outp(cs, UART_DLL, quot & 0xff); /* LS of divisor */ serial_outp(cs, UART_DLM, quot >> 8); /* MS of divisor */ serial_outp(cs, UART_LCR, cval); /* reset DLAB */ serial_inp(cs, UART_RX); } static int mstartup(struct IsdnCardState *cs) { int retval=0; /* * Clear the FIFO buffers and disable them * (they will be reenabled in change_speed()) */ serial_outp(cs, UART_FCR, (UART_FCR_CLEAR_RCVR | UART_FCR_CLEAR_XMIT)); /* * At this point there's no way the LSR could still be 0xFF; * if it is, then bail out, because there's likely no UART * here. */ if (serial_inp(cs, UART_LSR) == 0xff) { retval = -ENODEV; goto errout; } /* * Clear the interrupt registers. */ (void) serial_inp(cs, UART_RX); (void) serial_inp(cs, UART_IIR); (void) serial_inp(cs, UART_MSR); /* * Now, initialize the UART */ serial_outp(cs, UART_LCR, UART_LCR_WLEN8); /* reset DLAB */ cs->hw.elsa.MCR = 0; cs->hw.elsa.MCR = UART_MCR_DTR | UART_MCR_RTS | UART_MCR_OUT2; serial_outp(cs, UART_MCR, cs->hw.elsa.MCR); /* * Finally, enable interrupts */ cs->hw.elsa.IER = UART_IER_MSI | UART_IER_RLSI | UART_IER_RDI; serial_outp(cs, UART_IER, cs->hw.elsa.IER); /* enable interrupts */ /* * And clear the interrupt registers again for luck. */ (void)serial_inp(cs, UART_LSR); (void)serial_inp(cs, UART_RX); (void)serial_inp(cs, UART_IIR); (void)serial_inp(cs, UART_MSR); cs->hw.elsa.transcnt = cs->hw.elsa.transp = 0; cs->hw.elsa.rcvcnt = cs->hw.elsa.rcvp =0; /* * and set the speed of the serial port */ change_speed(cs, BASE_BAUD); cs->hw.elsa.MFlag = 1; errout: return retval; } /* * This routine will shutdown a serial port; interrupts are disabled, and * DTR is dropped if the hangup on close termio flag is on. */ static void mshutdown(struct IsdnCardState *cs) { #ifdef SERIAL_DEBUG_OPEN printk(KERN_DEBUG"Shutting down serial ...."); #endif /* * clear delta_msr_wait queue to avoid mem leaks: we may free the irq * here so the queue might never be waken up */ cs->hw.elsa.IER = 0; serial_outp(cs, UART_IER, 0x00); /* disable all intrs */ cs->hw.elsa.MCR &= ~UART_MCR_OUT2; /* disable break condition */ serial_outp(cs, UART_LCR, serial_inp(cs, UART_LCR) & ~UART_LCR_SBC); cs->hw.elsa.MCR &= ~(UART_MCR_DTR|UART_MCR_RTS); serial_outp(cs, UART_MCR, cs->hw.elsa.MCR); /* disable FIFO's */ serial_outp(cs, UART_FCR, (UART_FCR_CLEAR_RCVR | UART_FCR_CLEAR_XMIT)); serial_inp(cs, UART_RX); /* read data port to reset things */ #ifdef SERIAL_DEBUG_OPEN printk(" done\n"); #endif } static inline int write_modem(struct BCState *bcs) { int ret=0; struct IsdnCardState *cs = bcs->cs; int count, len, fp; if (!bcs->tx_skb) return 0; if (bcs->tx_skb->len <= 0) return 0; len = bcs->tx_skb->len; if (len > MAX_MODEM_BUF - cs->hw.elsa.transcnt) len = MAX_MODEM_BUF - cs->hw.elsa.transcnt; fp = cs->hw.elsa.transcnt + cs->hw.elsa.transp; fp &= (MAX_MODEM_BUF -1); count = len; if (count > MAX_MODEM_BUF - fp) { count = MAX_MODEM_BUF - fp; skb_copy_from_linear_data(bcs->tx_skb, cs->hw.elsa.transbuf + fp, count); skb_pull(bcs->tx_skb, count); cs->hw.elsa.transcnt += count; ret = count; count = len - count; fp = 0; } skb_copy_from_linear_data(bcs->tx_skb, cs->hw.elsa.transbuf + fp, count); skb_pull(bcs->tx_skb, count); cs->hw.elsa.transcnt += count; ret += count; if (cs->hw.elsa.transcnt && !(cs->hw.elsa.IER & UART_IER_THRI)) { cs->hw.elsa.IER |= UART_IER_THRI; serial_outp(cs, UART_IER, cs->hw.elsa.IER); } return(ret); } static inline void modem_fill(struct BCState *bcs) { if (bcs->tx_skb) { if (bcs->tx_skb->len) { write_modem(bcs); return; } else { if (test_bit(FLG_LLI_L1WAKEUP,&bcs->st->lli.flag) && (PACKET_NOACK != bcs->tx_skb->pkt_type)) { u_long flags; spin_lock_irqsave(&bcs->aclock, flags); bcs->ackcnt += bcs->hw.hscx.count; spin_unlock_irqrestore(&bcs->aclock, flags); schedule_event(bcs, B_ACKPENDING); } dev_kfree_skb_any(bcs->tx_skb); bcs->tx_skb = NULL; } } if ((bcs->tx_skb = skb_dequeue(&bcs->squeue))) { bcs->hw.hscx.count = 0; test_and_set_bit(BC_FLG_BUSY, &bcs->Flag); write_modem(bcs); } else { test_and_clear_bit(BC_FLG_BUSY, &bcs->Flag); schedule_event(bcs, B_XMTBUFREADY); } } static inline void receive_chars(struct IsdnCardState *cs, int *status) { unsigned char ch; struct sk_buff *skb; do { ch = serial_in(cs, UART_RX); if (cs->hw.elsa.rcvcnt >= MAX_MODEM_BUF) break; cs->hw.elsa.rcvbuf[cs->hw.elsa.rcvcnt++] = ch; #ifdef SERIAL_DEBUG_INTR printk("DR%02x:%02x...", ch, *status); #endif if (*status & (UART_LSR_BI | UART_LSR_PE | UART_LSR_FE | UART_LSR_OE)) { #ifdef SERIAL_DEBUG_INTR printk("handling exept...."); #endif } *status = serial_inp(cs, UART_LSR); } while (*status & UART_LSR_DR); if (cs->hw.elsa.MFlag == 2) { if (!(skb = dev_alloc_skb(cs->hw.elsa.rcvcnt))) printk(KERN_WARNING "ElsaSER: receive out of memory\n"); else { memcpy(skb_put(skb, cs->hw.elsa.rcvcnt), cs->hw.elsa.rcvbuf, cs->hw.elsa.rcvcnt); skb_queue_tail(& cs->hw.elsa.bcs->rqueue, skb); } schedule_event(cs->hw.elsa.bcs, B_RCVBUFREADY); } else { char tmp[128]; char *t = tmp; t += sprintf(t, "modem read cnt %d", cs->hw.elsa.rcvcnt); QuickHex(t, cs->hw.elsa.rcvbuf, cs->hw.elsa.rcvcnt); debugl1(cs, tmp); } cs->hw.elsa.rcvcnt = 0; } static inline void transmit_chars(struct IsdnCardState *cs, int *intr_done) { int count; debugl1(cs, "transmit_chars: p(%x) cnt(%x)", cs->hw.elsa.transp, cs->hw.elsa.transcnt); if (cs->hw.elsa.transcnt <= 0) { cs->hw.elsa.IER &= ~UART_IER_THRI; serial_out(cs, UART_IER, cs->hw.elsa.IER); return; } count = 16; do { serial_outp(cs, UART_TX, cs->hw.elsa.transbuf[cs->hw.elsa.transp++]); if (cs->hw.elsa.transp >= MAX_MODEM_BUF) cs->hw.elsa.transp=0; if (--cs->hw.elsa.transcnt <= 0) break; } while (--count > 0); if ((cs->hw.elsa.transcnt < WAKEUP_CHARS) && (cs->hw.elsa.MFlag==2)) modem_fill(cs->hw.elsa.bcs); #ifdef SERIAL_DEBUG_INTR printk("THRE..."); #endif if (intr_done) *intr_done = 0; if (cs->hw.elsa.transcnt <= 0) { cs->hw.elsa.IER &= ~UART_IER_THRI; serial_outp(cs, UART_IER, cs->hw.elsa.IER); } } static void rs_interrupt_elsa(struct IsdnCardState *cs) { int status, iir, msr; int pass_counter = 0; #ifdef SERIAL_DEBUG_INTR printk(KERN_DEBUG "rs_interrupt_single(%d)...", cs->irq); #endif do { status = serial_inp(cs, UART_LSR); debugl1(cs,"rs LSR %02x", status); #ifdef SERIAL_DEBUG_INTR printk("status = %x...", status); #endif if (status & UART_LSR_DR) receive_chars(cs, &status); if (status & UART_LSR_THRE) transmit_chars(cs, NULL); if (pass_counter++ > RS_ISR_PASS_LIMIT) { printk("rs_single loop break.\n"); break; } iir = serial_inp(cs, UART_IIR); debugl1(cs,"rs IIR %02x", iir); if ((iir & 0xf) == 0) { msr = serial_inp(cs, UART_MSR); debugl1(cs,"rs MSR %02x", msr); } } while (!(iir & UART_IIR_NO_INT)); #ifdef SERIAL_DEBUG_INTR printk("end.\n"); #endif } extern int open_hscxstate(struct IsdnCardState *cs, struct BCState *bcs); extern void modehscx(struct BCState *bcs, int mode, int bc); extern void hscx_l2l1(struct PStack *st, int pr, void *arg); static void close_elsastate(struct BCState *bcs) { modehscx(bcs, 0, bcs->channel); if (test_and_clear_bit(BC_FLG_INIT, &bcs->Flag)) { if (bcs->hw.hscx.rcvbuf) { if (bcs->mode != L1_MODE_MODEM) kfree(bcs->hw.hscx.rcvbuf); bcs->hw.hscx.rcvbuf = NULL; } skb_queue_purge(&bcs->rqueue); skb_queue_purge(&bcs->squeue); if (bcs->tx_skb) { dev_kfree_skb_any(bcs->tx_skb); bcs->tx_skb = NULL; test_and_clear_bit(BC_FLG_BUSY, &bcs->Flag); } } } static void modem_write_cmd(struct IsdnCardState *cs, u_char *buf, int len) { int count, fp; u_char *msg = buf; if (!len) return; if (len > (MAX_MODEM_BUF - cs->hw.elsa.transcnt)) { return; } fp = cs->hw.elsa.transcnt + cs->hw.elsa.transp; fp &= (MAX_MODEM_BUF -1); count = len; if (count > MAX_MODEM_BUF - fp) { count = MAX_MODEM_BUF - fp; memcpy(cs->hw.elsa.transbuf + fp, msg, count); cs->hw.elsa.transcnt += count; msg += count; count = len - count; fp = 0; } memcpy(cs->hw.elsa.transbuf + fp, msg, count); cs->hw.elsa.transcnt += count; if (cs->hw.elsa.transcnt && !(cs->hw.elsa.IER & UART_IER_THRI)) { cs->hw.elsa.IER |= UART_IER_THRI; serial_outp(cs, UART_IER, cs->hw.elsa.IER); } } static void modem_set_init(struct IsdnCardState *cs) { int timeout; #define RCV_DELAY 20 modem_write_cmd(cs, MInit_1, strlen(MInit_1)); timeout = 1000; while(timeout-- && cs->hw.elsa.transcnt) udelay(1000); debugl1(cs, "msi tout=%d", timeout); mdelay(RCV_DELAY); modem_write_cmd(cs, MInit_2, strlen(MInit_2)); timeout = 1000; while(timeout-- && cs->hw.elsa.transcnt) udelay(1000); debugl1(cs, "msi tout=%d", timeout); mdelay(RCV_DELAY); modem_write_cmd(cs, MInit_3, strlen(MInit_3)); timeout = 1000; while(timeout-- && cs->hw.elsa.transcnt) udelay(1000); debugl1(cs, "msi tout=%d", timeout); mdelay(RCV_DELAY); modem_write_cmd(cs, MInit_4, strlen(MInit_4)); timeout = 1000; while(timeout-- && cs->hw.elsa.transcnt) udelay(1000); debugl1(cs, "msi tout=%d", timeout); mdelay(RCV_DELAY); modem_write_cmd(cs, MInit_5, strlen(MInit_5)); timeout = 1000; while(timeout-- && cs->hw.elsa.transcnt) udelay(1000); debugl1(cs, "msi tout=%d", timeout); mdelay(RCV_DELAY); modem_write_cmd(cs, MInit_6, strlen(MInit_6)); timeout = 1000; while(timeout-- && cs->hw.elsa.transcnt) udelay(1000); debugl1(cs, "msi tout=%d", timeout); mdelay(RCV_DELAY); modem_write_cmd(cs, MInit_7, strlen(MInit_7)); timeout = 1000; while(timeout-- && cs->hw.elsa.transcnt) udelay(1000); debugl1(cs, "msi tout=%d", timeout); mdelay(RCV_DELAY); } static void modem_set_dial(struct IsdnCardState *cs, int outgoing) { int timeout; #define RCV_DELAY 20 modem_write_cmd(cs, MInit_speed28800, strlen(MInit_speed28800)); timeout = 1000; while(timeout-- && cs->hw.elsa.transcnt) udelay(1000); debugl1(cs, "msi tout=%d", timeout); mdelay(RCV_DELAY); if (outgoing) modem_write_cmd(cs, MInit_dialout, strlen(MInit_dialout)); else modem_write_cmd(cs, MInit_dialin, strlen(MInit_dialin)); timeout = 1000; while(timeout-- && cs->hw.elsa.transcnt) udelay(1000); debugl1(cs, "msi tout=%d", timeout); mdelay(RCV_DELAY); } static void modem_l2l1(struct PStack *st, int pr, void *arg) { struct BCState *bcs = st->l1.bcs; struct sk_buff *skb = arg; u_long flags; if (pr == (PH_DATA | REQUEST)) { spin_lock_irqsave(&bcs->cs->lock, flags); if (bcs->tx_skb) { skb_queue_tail(&bcs->squeue, skb); } else { bcs->tx_skb = skb; test_and_set_bit(BC_FLG_BUSY, &bcs->Flag); bcs->hw.hscx.count = 0; write_modem(bcs); } spin_unlock_irqrestore(&bcs->cs->lock, flags); } else if (pr == (PH_ACTIVATE | REQUEST)) { test_and_set_bit(BC_FLG_ACTIV, &bcs->Flag); st->l1.l1l2(st, PH_ACTIVATE | CONFIRM, NULL); set_arcofi(bcs->cs, st->l1.bc); mstartup(bcs->cs); modem_set_dial(bcs->cs, test_bit(FLG_ORIG, &st->l2.flag)); bcs->cs->hw.elsa.MFlag=2; } else if (pr == (PH_DEACTIVATE | REQUEST)) { test_and_clear_bit(BC_FLG_ACTIV, &bcs->Flag); bcs->cs->dc.isac.arcofi_bc = st->l1.bc; arcofi_fsm(bcs->cs, ARCOFI_START, &ARCOFI_XOP_0); interruptible_sleep_on(&bcs->cs->dc.isac.arcofi_wait); bcs->cs->hw.elsa.MFlag=1; } else { printk(KERN_WARNING"ElsaSer: unknown pr %x\n", pr); } } static int setstack_elsa(struct PStack *st, struct BCState *bcs) { bcs->channel = st->l1.bc; switch (st->l1.mode) { case L1_MODE_HDLC: case L1_MODE_TRANS: if (open_hscxstate(st->l1.hardware, bcs)) return (-1); st->l2.l2l1 = hscx_l2l1; break; case L1_MODE_MODEM: bcs->mode = L1_MODE_MODEM; if (!test_and_set_bit(BC_FLG_INIT, &bcs->Flag)) { bcs->hw.hscx.rcvbuf = bcs->cs->hw.elsa.rcvbuf; skb_queue_head_init(&bcs->rqueue); skb_queue_head_init(&bcs->squeue); } bcs->tx_skb = NULL; test_and_clear_bit(BC_FLG_BUSY, &bcs->Flag); bcs->event = 0; bcs->hw.hscx.rcvidx = 0; bcs->tx_cnt = 0; bcs->cs->hw.elsa.bcs = bcs; st->l2.l2l1 = modem_l2l1; break; } st->l1.bcs = bcs; setstack_manager(st); bcs->st = st; setstack_l1_B(st); return (0); } static void init_modem(struct IsdnCardState *cs) { cs->bcs[0].BC_SetStack = setstack_elsa; cs->bcs[1].BC_SetStack = setstack_elsa; cs->bcs[0].BC_Close = close_elsastate; cs->bcs[1].BC_Close = close_elsastate; if (!(cs->hw.elsa.rcvbuf = kmalloc(MAX_MODEM_BUF, GFP_ATOMIC))) { printk(KERN_WARNING "Elsa: No modem mem hw.elsa.rcvbuf\n"); return; } if (!(cs->hw.elsa.transbuf = kmalloc(MAX_MODEM_BUF, GFP_ATOMIC))) { printk(KERN_WARNING "Elsa: No modem mem hw.elsa.transbuf\n"); kfree(cs->hw.elsa.rcvbuf); cs->hw.elsa.rcvbuf = NULL; return; } if (mstartup(cs)) { printk(KERN_WARNING "Elsa: problem startup modem\n"); } modem_set_init(cs); } static void release_modem(struct IsdnCardState *cs) { cs->hw.elsa.MFlag = 0; if (cs->hw.elsa.transbuf) { if (cs->hw.elsa.rcvbuf) { mshutdown(cs); kfree(cs->hw.elsa.rcvbuf); cs->hw.elsa.rcvbuf = NULL; } kfree(cs->hw.elsa.transbuf); cs->hw.elsa.transbuf = NULL; } }
embeddedarm/linux-2.6.35-ts4800
drivers/isdn/hisax/elsa_ser.c
C
gpl-2.0
17,033
<?php namespace Themosis\Core\Console; use Illuminate\Console\Command; use Illuminate\Console\ConfirmableTrait; use Illuminate\Encryption\Encrypter; class KeyGenerateCommand extends Command { use ConfirmableTrait; /** * Name and signature of the console command. * * @var string */ protected $signature = 'key:generate {--show : Display the key instead of modifying files} {--force : Force the operation to run when in production}'; /** * Console command description. * * @var string */ protected $description = 'Set the application key'; /** * Execute the console command. */ public function handle() { $key = $this->generateRandomKey(); if ($this->option('show')) { $this->line('<comment>'.$key.'</comment>'); return; } // Next, we will replace the application key in the environment file so it is // automatically setup for this developer. This key gets generated using a // secure random byte generator and is later base64 encoded for storage. if (! $this->setKeyInEnvironmentFile($key)) { return; } $this->laravel['config']['app.key'] = $key; $this->info("Application key [$key] set successfully."); } /** * Generate a random key for the application. * * @return string */ protected function generateRandomKey() { return 'base64:'.base64_encode(Encrypter::generateKey($this->laravel['config']['app.cipher'])); } /** * Set the application key in the environment file. * * @param string $key * * @return bool */ protected function setKeyInEnvironmentFile(string $key) { $currentKey = $this->laravel['config']['app.key']; if (0 !== strlen($currentKey) && (! $this->confirmToProceed())) { return false; } $this->writeNewEnvironmentFileWith($key); return true; } /** * Write new environment file with the given key. * * @param string $key */ protected function writeNewEnvironmentFileWith(string $key) { file_put_contents( $this->laravel->environmentFilePath(), preg_replace( $this->keyReplacementPattern(), 'APP_KEY='.$key, file_get_contents($this->laravel->environmentFilePath()) ) ); } /** * Get a regex pattern that will match env APP_KEY with any random key. * * @return string */ protected function keyReplacementPattern() { $escaped = preg_quote('='.$this->laravel['config']['app.key'], '/'); return "/^APP_KEY{$escaped}/m"; } }
themosis/framework
src/Core/Console/KeyGenerateCommand.php
PHP
gpl-2.0
2,827
#!/bin/sh -e # Glen Pitt-Pladdy (ISC) . ./functions.sh depends_SLES() { echo >/dev/null } depends_RHEL() { [ -x /usr/bin/expect ] || yum install -y expect } trakapacheconf_SLES() { CONFDIR=/etc/apache2/conf.d CONF=$CONFDIR/t2016-$TRAKNS.conf echo $CONF } trakapacheconf_RHEL() { CONFDIR=/etc/httpd/conf.d CONF=$CONFDIR/t2016-$TRAKNS.conf echo $CONF } apacherestart_SLES() { [ -x /usr/sbin/httpd2 ] && service apache2 restart return 0 } apacherestart_RHEL() { [ -x /usr/sbin/httpd ] && service httpd restart return 0 } echo "########################################" INST=`instname $SITE $ENV DB$VER` TRAKNS=`traknamespace $SITE $ENV` TRAKPATH=`trakpath $SITE $ENV DB$VER` echo "Vanilla Trak $VER Install for $SITE : $ENV ($INST: $TRAKNS)" # check if we need to do this if [ -f ${TRAKPATH}/web/default.htm -a -f ${TRAKPATH}/db/data/CACHE.DAT ]; then echo "Already appears to be web and databases installed" exit 0 fi # get cache password if needed if [ -z "$CACHEPASS" ]; then getpass "Caché Password" CACHEPASS 1 fi # get Trak zip password if needed if [ -z "$TRAKZIPPASS" ]; then getpass "TrakCare .zip Password" TRAKZIPPASS 1 fi # find installer #installer=`locatefilestd $VER_*_R*_B*.zip` installer=/trak/iscbuild/installers/T2015_20150331_1957_ENXX_R0_FULL_B10.zip #installer=/trak/iscbuild/installers/2014_20140902_1034_R4ENXX_B32.zip #installer=/trak/iscbuild/installers/T2015_20150527_1736_DEV_ENXX_FULL_B231.zip echo $installer # check for target web/ directory if [ ! -d ${TRAKPATH}/web ]; then echo "FATAL - expecting \"${TRAKPATH}/web/\" to be created with appropriate permissions in advance" >&2 exit 1 fi # install dependancies osspecific depends # check that expect is available if [ ! -x /usr/bin/expect ]; then echo "FATAL - can't find executable /usr/bin/expect" >&2 exit 1 fi # check it's already installed if [ -f ${TRAKPATH}/web/default.htm ]; then echo "Install (web/default.htm) already exists - skipping" exit 0 fi # check we are root if [ `whoami` != 'root' ]; then echo "Being run as user `whoami` - should be run as root" exit 1 fi # install T2014 mkdir $TMPDIR/trakextract cp expect/TrakVanillaT2015_Install_install.expect $TMPDIR/trakextract chmod 755 $TMPDIR/trakextract/TrakVanillaT2015_Install_install.expect olddir=`pwd` cd $TMPDIR/trakextract ${olddir}/expect/TrakVanillaT2014_Install_unzip.expect $installer chown $CACHEUSR.$CACHEGRP $TMPDIR/trakextract -R $TMPDIR/trakextract/TrakVanillaT2015_Install_install.expect $INST $TMPDIR/trakextract $ENV $TRAKNS ${TRAKPATH} /trakcare cd ${olddir} rm -r $TMPDIR/trakextract # fix up database naming to UK convention ccontrol stop $INST nouser UCSITE=`echo $SITE | tr '[:lower:]' '[:upper:]'` sed -i "s/^$TRAKNS=$ENV-DATA,$ENV-APPSYS/$TRAKNS=$TRAKNS-DATA,$TRAKNS-APPSYS/" ${TRAKPATH}/hs/cache.cpf sed -i "s/^$ENV-/$TRAKNS-/" ${TRAKPATH}/hs/cache.cpf sed -i "s/\(Global_.*\|Routine_.*\|Package_.*\)=$ENV-/\1=$TRAKNS-/" ${TRAKPATH}/hs/cache.cpf ./expect/TrakVanillaT2014_Install_start.expect $INST # change web/ directory to use site code (and possibly create lc symlink) cd ${TRAKPATH}/web/custom/ mv $TRAKNS/ $SITE_UC #ln -s $SITE_UC $SITE_LC cd ${olddir} # change config in Configuration Manager ./expect/TrakVanillaT2014_Install_cleanup.expect $INST $TRAKNS $SITE_UC ${TRAKPATH}/web/custom/$SITE_UC/cdl # fix web/ permissions chown $CACHEUSR.$CACHEGRP ${TRAKPATH}/web -R find ${TRAKPATH}/web -type d -exec chmod 2770 {} \; find ${TRAKPATH}/web -type f -exec chmod 660 {} \; ## install the apache config #osspecific trakapacheconf ##apacheconf=`osspecific trakapacheconf` #if [ -d $CONFDIR -a -f /opt/cspgateway/bin/CSP.ini ]; then # apacheconf=$CONF # cp conffiles/apache-t2016.conf $apacheconf # chmod 644 $apacheconf # # apply custom settings # sed -i 's/TRAKWEBAPP/\/trakcare/g' $apacheconf # sed -i "s/TRAKWEBDIR/`path2regexp ${TRAKPATH}/web`/g" $apacheconf # # add in CSP config # ini_update.pl /opt/cspgateway/bin/CSP.ini \ # '[APP_PATH:/trakcare]GZIP_Compression=Enabled' \ # '[APP_PATH:/trakcare]GZIP_Exclude_File_Types=jpeg gif ico png' \ # '[APP_PATH:/trakcare]Response_Size_Notification=Chunked Transfer Encoding and Content Length' \ # '[APP_PATH:/trakcare]KeepAlive=No Action' \ # '[APP_PATH:/trakcare]Non_Parsed_Headers=Enabled' \ # '[APP_PATH:/trakcare]Alternative_Servers=Disabled' \ # "[APP_PATH:/trakcare]Alternative_Server_0=1~~~~~~$INST" \ # "[APP_PATH:/trakcare]Default_Server=$INST" \ # '[APP_PATH_INDEX]/trakcare=Enabled' #else # echo "Skipping Trak Config (no Apache and/or CSP)" #fi #osspecific apacherestart
casep/isc_coding
trakautomation/do_TrakVanillaT2015_Install.sh
Shell
gpl-2.0
4,564
<!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <link rel="stylesheet" type="text/css" href="style/style.css"> <link rel="stylesheet" type="text/css" media="only screen and (min-device-width: 360px)" href="style-compact.css"> <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-74917613-1', 'auto'); ga('send', 'pageview'); </script> </head> <body> <div class="dungeonBackgroundContainer"> <img class="dungeonFrame" src="../../BFStoryArchive/BFStoryArchive/dungeon_battle_collection/baseDungeonFrame.png" /> <img class="dungeonImage" src="../../BFStoryArchive/BFStoryArchive/dungeon_battle_collection/dungeon_battle_40700.jpg" /> </div> <div class="dialogueContainer"> <div class="facePortrait"> <img class="facePortraitFrame" src="../../BFStoryArchive/BFStoryArchive/navi_chara_collection/characterFrame.png" /> <img class="facePortraitImg" src="../../BFStoryArchive/BFStoryArchive/navi_chara_collection/navi_chara5_0.png" /> </div> <div class="speakerName"><a href="http://i.imgur.com/PZWh1tF.png">パリス</a></div> <div class="speakerMessage">…はい。グラントスは半覚醒状態ながらも すでに目覚めています。</div> </div> <br> <div class="dialogueContainer"> <div class="facePortrait"> <img class="facePortraitFrame" src="../../BFStoryArchive/BFStoryArchive/navi_chara_collection/characterFrame.png" /> <img class="facePortraitImg" src="../../BFStoryArchive/BFStoryArchive/navi_chara_collection/navi_chara5_0.png" /> </div> <div class="speakerName">パリス</div> <div class="speakerMessage">いえ、その件については 問題ありません。</div> </div> <br> <div class="dialogueContainer"> <div class="facePortrait"> <img class="facePortraitFrame" src="../../BFStoryArchive/BFStoryArchive/navi_chara_collection/characterFrame.png" /> <img class="facePortraitImg" src="../../BFStoryArchive/BFStoryArchive/navi_chara_collection/navi_chara5_0.png" /> </div> <div class="speakerName">パリス</div> <div class="speakerMessage">はい、わかりました。 任務を継続します。</div> </div> <br> <div class="dialogueContainer"> <div class="facePortrait"> <img class="facePortraitFrame" src="../../BFStoryArchive/BFStoryArchive/navi_chara_collection/characterFrame.png" /> <img class="facePortraitImg" src="../../BFStoryArchive/BFStoryArchive/navi_chara_collection/navi_chara4_5.png" /> </div> <div class="speakerName"><a href="http://i.imgur.com/OVgKa0l.png">ルジーナ</a></div> <div class="speakerMessage">おい、そこのクソ女!</div> </div> <br> <div class="dialogueContainer"> <div class="facePortrait"> <img class="facePortraitFrame" src="../../BFStoryArchive/BFStoryArchive/navi_chara_collection/characterFrame.png" /> <img class="facePortraitImg" src="../../BFStoryArchive/BFStoryArchive/navi_chara_collection/navi_chara4_5.png" /> </div> <div class="speakerName">ルジーナ</div> <div class="speakerMessage">何をボソボソと しゃべってやがる!</div> </div> <br> <div class="dialogueContainer"> <div class="facePortrait"> <img class="facePortraitFrame" src="../../BFStoryArchive/BFStoryArchive/navi_chara_collection/characterFrame.png" /> <img class="facePortraitImg" src="../../BFStoryArchive/BFStoryArchive/navi_chara_collection/navi_chara4_3.png" /> </div> <div class="speakerName">ルジーナ</div> <div class="speakerMessage">俺様を皇国のお偉いさんにでも 報告してるんでありますか?</div> </div> <br> <div class="dialogueContainer"> <div class="facePortrait"> <img class="facePortraitFrame" src="../../BFStoryArchive/BFStoryArchive/navi_chara_collection/characterFrame.png" /> <img class="facePortraitImg" src="../../BFStoryArchive/BFStoryArchive/navi_chara_collection/navi_chara5_1.png" /> </div> <div class="speakerName">パリス</div> <div class="speakerMessage">フフッ、よくわかったわね。</div> </div> <br> <div class="dialogueContainer"> <div class="facePortrait"> <img class="facePortraitFrame" src="../../BFStoryArchive/BFStoryArchive/navi_chara_collection/characterFrame.png" /> <img class="facePortraitImg" src="../../BFStoryArchive/BFStoryArchive/navi_chara_collection/navi_chara5_1.png" /> </div> <div class="speakerName">パリス</div> <div class="speakerMessage">優秀な召喚師の情報は皇国にとって、 とても有益なのよ。</div> </div> <br> <div class="dialogueContainer"> <div class="facePortrait"> <img class="facePortraitFrame" src="../../BFStoryArchive/BFStoryArchive/navi_chara_collection/characterFrame.png" /> <img class="facePortraitImg" src="../../BFStoryArchive/BFStoryArchive/navi_chara_collection/navi_chara4_4.png" /> </div> <div class="speakerName">ルジーナ</div> <div class="speakerMessage">ケッ! 胸クソ悪いー!</div> </div> <br> <div class="dialogueContainer"> <div class="facePortrait"> <img class="facePortraitFrame" src="../../BFStoryArchive/BFStoryArchive/navi_chara_collection/characterFrame.png" /> <img class="facePortraitImg" src="../../BFStoryArchive/BFStoryArchive/navi_chara_collection/navi_chara4_5.png" /> </div> <div class="speakerName">ルジーナ</div> <div class="speakerMessage">……!</div> </div> <br> <div class="dialogueContainer"> <div class="facePortrait"> <img class="facePortraitFrame" src="../../BFStoryArchive/BFStoryArchive/navi_chara_collection/characterFrame.png" /> <img class="facePortraitImg" src="../../BFStoryArchive/BFStoryArchive/navi_chara_collection/navi_chara4_1.png" /> </div> <div class="speakerName">ルジーナ</div> <div class="speakerMessage">おせーぞ! Shou-chan!</div> </div> <br> <div class="dialogueContainer"> <div class="facePortrait"> <img class="facePortraitFrame" src="../../BFStoryArchive/BFStoryArchive/navi_chara_collection/characterFrame.png" /> <img class="facePortraitImg" src="../../BFStoryArchive/BFStoryArchive/navi_chara_collection/navi_chara4_1.png" /> </div> <div class="speakerName">ルジーナ</div> <div class="speakerMessage">こんなヤベー時に チンタラしてんじゃねーよ!</div> </div> <br> <div class="dialogueContainer"> <div class="facePortrait"> <img class="facePortraitFrame" src="../../BFStoryArchive/BFStoryArchive/navi_chara_collection/characterFrame.png" /> <img class="facePortraitImg" src="../../BFStoryArchive/BFStoryArchive/navi_chara_collection/navi_chara5_1.png" /> </div> <div class="speakerName">パリス</div> <div class="speakerMessage">あら、それなら 待たずに先に行けばよかったのに。</div> </div> <br> <div class="dialogueContainer"> <div class="facePortrait"> <img class="facePortraitFrame" src="../../BFStoryArchive/BFStoryArchive/navi_chara_collection/characterFrame.png" /> <img class="facePortraitImg" src="../../BFStoryArchive/BFStoryArchive/navi_chara_collection/navi_chara4_5.png" /> </div> <div class="speakerName">ルジーナ</div> <div class="speakerMessage">雑魚には雑魚の使い道ってもんが あんだろうが!</div> </div> <br> <div class="dialogueContainer"> <div class="facePortrait"> <img class="facePortraitFrame" src="../../BFStoryArchive/BFStoryArchive/navi_chara_collection/characterFrame.png" /> <img class="facePortraitImg" src="../../BFStoryArchive/BFStoryArchive/navi_chara_collection/navi_chara4_5.png" /> </div> <div class="speakerName">ルジーナ</div> <div class="speakerMessage">まぁいい。</div> </div> <br> <div class="dialogueContainer"> <div class="facePortrait"> <img class="facePortraitFrame" src="../../BFStoryArchive/BFStoryArchive/navi_chara_collection/characterFrame.png" /> <img class="facePortraitImg" src="../../BFStoryArchive/BFStoryArchive/navi_chara_collection/navi_chara4_3.png" /> </div> <div class="speakerName">ルジーナ</div> <div class="speakerMessage">いいか、 俺様はこれから何百年も眠り続けてる</div> </div> <br> <div class="dialogueContainer"> <div class="facePortrait"> <img class="facePortraitFrame" src="../../BFStoryArchive/BFStoryArchive/navi_chara_collection/characterFrame.png" /> <img class="facePortraitImg" src="../../BFStoryArchive/BFStoryArchive/navi_chara_collection/navi_chara4_3.png" /> </div> <div class="speakerName">ルジーナ</div> <div class="speakerMessage">巨人どもの神、 『グラントス』をぶっ潰しに行く。</div> </div> <br> <div class="dialogueContainer"> <div class="facePortrait"> <img class="facePortraitFrame" src="../../BFStoryArchive/BFStoryArchive/navi_chara_collection/characterFrame.png" /> <img class="facePortraitImg" src="../../BFStoryArchive/BFStoryArchive/navi_chara_collection/navi_chara4_5.png" /> </div> <div class="speakerName">ルジーナ</div> <div class="speakerMessage">まあ、俺様が戦うからは ただのデクノボーにはちげーねーが、</div> </div> <br> <div class="dialogueContainer"> <div class="facePortrait"> <img class="facePortraitFrame" src="../../BFStoryArchive/BFStoryArchive/navi_chara_collection/characterFrame.png" /> <img class="facePortraitImg" src="../../BFStoryArchive/BFStoryArchive/navi_chara_collection/navi_chara4_5.png" /> </div> <div class="speakerName">ルジーナ</div> <div class="speakerMessage">さすがにヤツとの戦闘中に 他の魔物に邪魔されたら面倒だ。</div> </div> <br> <div class="dialogueContainer"> <div class="facePortrait"> <img class="facePortraitFrame" src="../../BFStoryArchive/BFStoryArchive/navi_chara_collection/characterFrame.png" /> <img class="facePortraitImg" src="../../BFStoryArchive/BFStoryArchive/navi_chara_collection/navi_chara4_3.png" /> </div> <div class="speakerName">ルジーナ</div> <div class="speakerMessage">そこで、俺が神を倒している間 お前らが魔物どもを引きつけておけ!</div> </div> <br> <div class="dialogueContainer"> <div class="facePortrait"> <img class="facePortraitFrame" src="../../BFStoryArchive/BFStoryArchive/navi_chara_collection/characterFrame.png" /> <img class="facePortraitImg" src="../../BFStoryArchive/BFStoryArchive/navi_chara_collection/navi_chara5_1.png" /> </div> <div class="speakerName">パリス</div> <div class="speakerMessage">あら、随分と優しいのね。 自分から強敵に挑むなんて。</div> </div> <br> <div class="dialogueContainer"> <div class="facePortrait"> <img class="facePortraitFrame" src="../../BFStoryArchive/BFStoryArchive/navi_chara_collection/characterFrame.png" /> <img class="facePortraitImg" src="../../BFStoryArchive/BFStoryArchive/navi_chara_collection/navi_chara4_2.png" /> </div> <div class="speakerName">ルジーナ</div> <div class="speakerMessage">あぁ!?</div> </div> <br> <div class="dialogueContainer"> <div class="facePortrait"> <img class="facePortraitFrame" src="../../BFStoryArchive/BFStoryArchive/navi_chara_collection/characterFrame.png" /> <img class="facePortraitImg" src="../../BFStoryArchive/BFStoryArchive/navi_chara_collection/navi_chara4_5.png" /> </div> <div class="speakerName">ルジーナ</div> <div class="speakerMessage">テメーらじゃ、まともに やりあうことなんざできねーだろーが。</div> </div> <br> <div class="dialogueContainer"> <div class="facePortrait"> <img class="facePortraitFrame" src="../../BFStoryArchive/BFStoryArchive/navi_chara_collection/characterFrame.png" /> <img class="facePortraitImg" src="../../BFStoryArchive/BFStoryArchive/navi_chara_collection/navi_chara4_5.png" /> </div> <div class="speakerName">ルジーナ</div> <div class="speakerMessage">グズどもが失敗した後始末するよか、 最初から俺様がやっちまった方がマシだ。</div> </div> <br> <div class="dialogueContainer"> <div class="facePortrait"> <img class="facePortraitFrame" src="../../BFStoryArchive/BFStoryArchive/navi_chara_collection/characterFrame.png" /> <img class="facePortraitImg" src="../../BFStoryArchive/BFStoryArchive/navi_chara_collection/navi_chara4_3.png" /> </div> <div class="speakerName">ルジーナ</div> <div class="speakerMessage">俺様の本当の力、見せてやるよ。</div> </div> <br> <div class="dialogueContainer"> <div class="facePortrait"> <img class="facePortraitFrame" src="../../BFStoryArchive/BFStoryArchive/navi_chara_collection/characterFrame.png" /> <img class="facePortraitImg" src="../../BFStoryArchive/BFStoryArchive/navi_chara_collection/navi_chara4_5.png" /> </div> <div class="speakerName">ルジーナ</div> <div class="speakerMessage">いいか、お前らはしっかり オトリとして魔物どもと戦ってろよ!</div> </div> <br> <div class="dialogueContainer"> <div class="facePortrait"> <img class="facePortraitFrame" src="../../BFStoryArchive/BFStoryArchive/navi_chara_collection/characterFrame.png" /> <img class="facePortraitImg" src="../../BFStoryArchive/BFStoryArchive/navi_chara_collection/navi_chara4_1.png" /> </div> <div class="speakerName">ルジーナ</div> <div class="speakerMessage">この程度の任務をしくじるようなら、 俺様が直接ぶっ殺してやるからな!</div> </div> <br> <div class="dialogueContainer"> <div class="facePortrait"> <img class="facePortraitFrame" src="../../BFStoryArchive/BFStoryArchive/navi_chara_collection/characterFrame.png" /> <img class="facePortraitImg" src="../../BFStoryArchive/BFStoryArchive/navi_chara_collection/navi_chara5_1.png" /> </div> <div class="speakerName">パリス</div> <div class="speakerMessage">フフッ、一応、名の通った 魔討隊のリーダーなだけはあるわね。</div> </div> <br> <div class="dialogueContainer"> <div class="facePortrait"> <img class="facePortraitFrame" src="../../BFStoryArchive/BFStoryArchive/navi_chara_collection/characterFrame.png" /> <img class="facePortraitImg" src="../../BFStoryArchive/BFStoryArchive/navi_chara_collection/navi_chara5_1.png" /> </div> <div class="speakerName">パリス</div> <div class="speakerMessage">言動は残念な感じだけど、</div> </div> <br> <div class="dialogueContainer"> <div class="facePortrait"> <img class="facePortraitFrame" src="../../BFStoryArchive/BFStoryArchive/navi_chara_collection/characterFrame.png" /> <img class="facePortraitImg" src="../../BFStoryArchive/BFStoryArchive/navi_chara_collection/navi_chara5_1.png" /> </div> <div class="speakerName">パリス</div> <div class="speakerMessage">知識と実力は それなりにあるということかしら。</div> </div> <br> <div class="dialogueContainer"> <div class="facePortrait"> <img class="facePortraitFrame" src="../../BFStoryArchive/BFStoryArchive/navi_chara_collection/characterFrame.png" /> <img class="facePortraitImg" src="../../BFStoryArchive/BFStoryArchive/navi_chara_collection/navi_chara5_1.png" /> </div> <div class="speakerName">パリス</div> <div class="speakerMessage">私の想像以上の情報を 集めていたようだしね…。</div> </div> <br> <div class="dialogueContainer"> <div class="facePortrait"> <img class="facePortraitFrame" src="../../BFStoryArchive/BFStoryArchive/navi_chara_collection/characterFrame.png" /> <img class="facePortraitImg" src="../../BFStoryArchive/BFStoryArchive/navi_chara_collection/navi_chara5_0.png" /> </div> <div class="speakerName">パリス</div> <div class="speakerMessage">とはいえ、私の調査だと</div> </div> <br> <div class="dialogueContainer"> <div class="facePortrait"> <img class="facePortraitFrame" src="../../BFStoryArchive/BFStoryArchive/navi_chara_collection/characterFrame.png" /> <img class="facePortraitImg" src="../../BFStoryArchive/BFStoryArchive/navi_chara_collection/navi_chara5_0.png" /> </div> <div class="speakerName">パリス</div> <div class="speakerMessage">グラントスは彼の手に負えるような 相手じゃなさそうだけど…。</div> </div> <br> <div class="dialogueContainer"> <div class="facePortrait"> <img class="facePortraitFrame" src="../../BFStoryArchive/BFStoryArchive/navi_chara_collection/characterFrame.png" /> <img class="facePortraitImg" src="../../BFStoryArchive/BFStoryArchive/navi_chara_collection/navi_chara5_0.png" /> </div> <div class="speakerName">パリス</div> <div class="speakerMessage">私も力を貸す必要がありそうね。</div> </div> <br> <div class="dialogueContainer"> <div class="facePortrait"> <img class="facePortraitFrame" src="../../BFStoryArchive/BFStoryArchive/navi_chara_collection/characterFrame.png" /> <img class="facePortraitImg" src="../../BFStoryArchive/BFStoryArchive/navi_chara_collection/navi_chara5_1.png" /> </div> <div class="speakerName">パリス</div> <div class="speakerMessage">もちろん、 あなたの力も貸してもらうわよ。</div> </div> <br> <div class="dialogueContainer"> <div class="facePortrait"> <img class="facePortraitFrame" src="../../BFStoryArchive/BFStoryArchive/navi_chara_collection/characterFrame.png" /> <img class="facePortraitImg" src="../../BFStoryArchive/BFStoryArchive/navi_chara_collection/navi_chara5_1.png" /> </div> <div class="speakerName">パリス</div> <div class="speakerMessage">あなたの実力、 しっかりと見せてもらうわ。</div> </div> <br> </body> </html> <!-- contact me at reddit /u/blackrobe199 -->
Blackrobe/blackrobe.github.io
BFJPStoryArchive/BFJPStoryArchive/map4-dungeon7.html
HTML
gpl-2.0
17,355
<?php require_once './includes/bootstrap.inc'; drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL); global $base_url; require_once ('tcpdf/pdfcss.php'); require_once('tcpdf/config/lang/eng.php'); require_once('tcpdf/tcpdf.php'); // create new PDF document $pdf = new TCPDF(L, PDF_UNIT, B4, true, 'UTF-8', false); // set document information $pdf->SetCreator(PDF_CREATOR); $pdf->SetAuthor('SC and ST'); $pdf->SetTitle('SC and ST'); $pdf->SetSubject('SC and ST'); $pdf->SetKeywords('SC and ST'); //$pdf->SetHeaderData('tcpdf/images/hpsc.png', PDF_HEADER_LOGO_WIDTH, PDF_HEADER_TITLE, PDF_HEADER_STRING); $pdf->SetHeaderData('tcpdf/images/hpsc.png', PDF_HEADER_LOGO_WIDTH, '',''); // set default header data //$pdf->SetHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, PDF_HEADER_TITLE, PDF_HEADER_STRING); // set header and footer fonts $pdf->setHeaderFont(Array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN)); $pdf->setFooterFont(Array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA)); // set default monospaced font $pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED); //set margins $pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT); $pdf->SetHeaderMargin(PDF_MARGIN_HEADER); $pdf->SetFooterMargin(PDF_MARGIN_FOOTER); //set auto page breaks $pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM); //set image scale factor $pdf->setImageScale(PDF_IMAGE_SCALE_RATIO); //set some language-dependent strings $pdf->setLanguageArray($l); // set font $pdf->SetFont('helvetica', '', 10); // add a page $pdf->AddPage(); if($_REQUEST['op'] == 'assetRegister_report'){ global $user, $base_url; $rid = $_REQUEST['rid']; $fromtime = $_REQUEST['fromtime']; $totime = $_REQUEST['totime']; $from = $fromtime; $to = $totime; //echo $fromtime.'jj';exit; $output =''; // define some HTML content with style $output .= <<<EOF <style> td.header_first{ color:111111; font-family:Verdana; font-size: 12pt; text-align:center; background-color:#ffffff; } td.header_report{ color:111111; font-family:Verdana; font-size: 16pt; text-align:center; font-weight:bold; background-color:#ffffff; } table{ width:1200px; } table.tbl_border{border:1px solid #a7c942; background-color:#a7c942; } td.header1 { color:#3b3c3c; background-color:#ffffff; font-family:Verdana; font-size: 11pt; font-weight: normal; } td.header2 { border-bottom-color:#FFFFFF; color: #ffffff; background-color:#a7c942; font-family:Verdana; font-size: 10pt; font-weight: bold; } td.header3 { color: #222222; background-color:#dddddd; font-family:Verdana; font-size: 11pt; font-weight: bold; } td.header4 { color: #222222; font-family:Verdana; font-size: 11pt; font-weight: bold; background-color:#eeeeee; } td.header4_1 { color:#222222; background-color:#ffffff; font-family:Verdana; font-size: 11pt; font-weight: normal; } td.header4_2 { color:#222222; background-color:#eaf2d3; font-family:Verdana; font-size: 11pt; font-weight: normal; } td.msg{ color:#FF0000; text-align:left; } </style> EOF; // Header Title $output .='<table cellpadding="0" cellspacing="0" border="0"> <tr><td class="header_report" colspan="5" align="center"> Asset Register</td></tr> <tr><td>&nbsp;</td></tr> </table>'; $append=''; if($fromtime){ if($fromtime !='1970-01-01' && $totime !='1970-01-01' ){ $append .= " date_amc BETWEEN '".$fromtime."' AND '".$totime."' AND "; } } $append .= " 1=1 "; $sql="select * from tbl_itassets where $append"; $output .='<table cellpadding="3" cellspacing="2" border="0">'; if($fromtime){ $output .='<tr><td class="header_first" align="left"> <b>From Date: </b>'.date('d-m-Y',strtotime($fromtime)).'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<b>To Date: </b>'.date('d-m-Y',strtotime($totime)).'</td></tr>'; } $output .='</table>'; $output .='<table cellpadding="2" cellspacing="2" border="0" class="tbl_border" style="width:1095px;"><tr> <td width="5%" colspan="1" class="header2">S. No.</td> <td width="6%" colspan="1" class="header2">Section</td> <td width="6%" colspan="1" class="header2">Asset Type</td> <td width="8%" colspan="1" class="header2">Quantity</td> <td width="5%" colspan="1" class="header2">Amount</td> <td width="5%" colspan="1" class="header2">Procurement Cost</td> <td width="9%" colspan="1" class="header2">Asset Details</td> <td width="9%" colspan="1" class="header2">Insurance Company</td> <td width="9%" colspan="1" class="header2">Sum Insured</td> <td width="9%" colspan="1" class="header2">Date of Renewal</td> <td width="5%" colspan="1" class="header2">Claim Details</td> <td width="9%" colspan="1" class="header2">AMC Vendor Name</td> <td width="9%" colspan="1" class="header2">AMC Date</td> <td width="5%" colspan="1" class="header2">AMC Amount</td> <td width="9%" colspan="1" class="header2">Contract Details</td> </tr>'; $res = db_query($sql); $counter=1; while($rs = db_fetch_object($res)){ $comp_name=ucwords($rs->company_name); if($comp_name==''){$comp_name='N/A';} $sum_insured=($rs->sum_insured); if($sum_insured==''){$sum_insured='N/A';} $date_renewal=date('d-m-Y',strtotime($rs->date_renewal)); if($date_renewal==''){$date_renewal='N/A';} $claim_det=ucwords($rs->claim_details); if($claim_det==''){$claim_det='N/A';} $vendor_name=ucwords($rs->vendor_name);if($vendor_name==''){$vendor_name='N/A';} $date_amc=date('d-m-Y',strtotime($rs->date_amc)); if($date_amc==''){$date_amc='N/A';} $amt_amc=$rs->amount_amc; if($amt_amc==''){$amt_amc='N/A';} $contract_det=ucwords($rs->contract_details);if($contract_det==''){$contract_det='N/A';} if($counter%2==0){ $class='header4_1';}else{$class='header4_2';} $output .='<tr> <td width="5%" class="'.$class.'" align="center">'.$counter.'</td> <td width="6%" class="'.$class.'" align="left">'.ucwords(getLookupName($rs->section)).'</td> <td width="6%" class="'.$class.'" align="left">'.ucwords(getLookupName($rs->asset_type)).'</td> <td width="8%" class="'.$class.'" align="left">'.ucwords($rs->quantity).'</td> <td width="5%" class="'.$class.'" align="right">'.round($rs->amount).'</td> <td width="5%" class="'.$class.'" align="right">'.round($rs->proc_cost).'</td> <td width="9%" class="'.$class.'" align="left">'.ucwords($rs->asset_details).'</td> <td width="9%" class="'.$class.'" align="left">'.$comp_name.'</td> <td width="9%" class="'.$class.'" align="right">'.round($sum_insured).'</td> <td width="9%" class="'.$class.'" align="center">'.$date_renewal.'</td> <td width="5%" class="'.$class.'" align="left">'.$claim_det.'</td> <td width="9%" class="'.$class.'" align="left">'.$vendor_name.'</td> <td width="9%" class="'.$class.'" align="center">'.$date_amc.'</td> <td width="5%" class="'.$class.'" align="right">'.round($amt_amc).'</td> <td width="9%" class="'.$class.'" align="left">'.$contract_det.'</td> </tr>'; $counter++; } $output .='</table>'; ob_end_clean(); // print a block of text using Write() $pdf->writeHTML($output, true,1, false, false); $pdf->Output('assetRegister_'.time().'.pdf', 'I'); }
himan5050/hpbc
assetRegisterpdf.php
PHP
gpl-2.0
7,049
/** * AshtavargaChartData.java * Created On 2006, Mar 31, 2006 5:12:23 PM * @author E. Rajasekar */ package app.astrosoft.beans; import java.util.EnumMap; import app.astrosoft.consts.AshtavargaName; import app.astrosoft.consts.AstrosoftTableColumn; import app.astrosoft.consts.Rasi; import app.astrosoft.core.Ashtavarga; import app.astrosoft.export.Exportable; import app.astrosoft.export.Exporter; import app.astrosoft.ui.table.ColumnMetaData; import app.astrosoft.ui.table.DefaultColumnMetaData; import app.astrosoft.ui.table.Table; import app.astrosoft.ui.table.TableData; import app.astrosoft.ui.table.TableRowData; public class AshtaVargaChartData extends AbstractChartData implements Exportable{ private EnumMap<Rasi, Integer> varga; public AshtaVargaChartData(AshtavargaName name, EnumMap<Rasi, Integer> varga) { super(); this.varga = varga; chartName = name.toString(); int count = Ashtavarga.getCount(name); if ( count != -1){ chartName = chartName + " ( " +String.valueOf(count) + " ) "; } } public Table getChartHouseTable(final Rasi rasi) { Table ashtavargaTable = new Table(){ public TableData<TableRowData> getTableData() { return new TableData<TableRowData>(){ public TableRowData getRow(final int index){ return new TableRowData(){ public Object getColumnData(AstrosoftTableColumn col) { return (index == 1) ? varga.get(rasi) : null; } }; } public int getRowCount() { return 2; } }; } public ColumnMetaData getColumnMetaData() { return colMetaData; } }; return ashtavargaTable; } @Override public DefaultColumnMetaData getHouseTableColMetaData() { return new DefaultColumnMetaData(AstrosoftTableColumn.C1){ @Override public Class getColumnClass(AstrosoftTableColumn col) { return Integer.class; } }; } public EnumMap<Rasi, Integer> getVarga() { return varga; } public void doExport(Exporter e) { e.export(this); } }
erajasekar/Astrosoft
src/app/astrosoft/beans/AshtaVargaChartData.java
Java
gpl-2.0
2,069
package mcmod.nxs.animalwarriors.lib; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.item.ItemArmor; public class ArmorHelper extends ItemArmor { public ArmorHelper(ArmorMaterial material, int type, int layer) { super(material, type, layer); } public ItemArmor setNameAndTab(String name, CreativeTabs tab) { this.setTextureName(ResourcePathHelper.getResourcesPath() + name); this.setUnlocalizedName(name); this.setCreativeTab(tab); return this; } }
AlphaSwittle-Team/AnimalWarriors
src/main/java/mcmod/nxs/animalwarriors/lib/ArmorHelper.java
Java
gpl-2.0
489
<!DOCTYPE html> <html lang="es"> <head> <meta charset="UTF-8"> <title> </title> <style> .municipios{ font-size:12px; font-family: 'helvetica','raleway'; padding:1em 1em; background-color:#2C85AF; color:#FFFFFF; } .direccion{ font-size:12px; font-family: 'helvetica','raleway'; padding:1em 4em; background-color:#2C85AF; color:#FFFFFF; } .rellenotabla{ font-size: 10px; padding:1em 1em; font-family: 'helvetica','raleway'; } .rellenotabla2{ font-size: 10px; padding:1em 3em; font-family: 'helvetica','raleway'; } .textocolspan{ font-size:10px; font-family: 'helvetica','raleway'; background-color:#5AAED0; color:#FFFFFF; text-align:left; padding: 0.5em 1em; text-shadow: 1px 1px #000000; } @font-face { font-family: 'helvetica'; src: url('fonts/helvetica-b.eot'); /* IE9 Compat Modes */ src: url('fonts/helvetica-b.eot?#iefix') format('embedded-opentype'), /* IE6-IE8 */ url('fonts/helveticaneue-webfont.woff') format('woff'), /* Modern Browsers */ url('fonts/HELVE6.ttf') format('truetype'), /* Safari, Android, iOS */ url('fonts/Helvetica_Neue_typeface_weights.svg#svgFontName') format('svg'); /* Legacy iOS */ } div.boton_ubicacion{ background-color: #035A9F; color: #FFFFFF; } div.boton_ubicacion:hover{ background-color: #E4E5E6; color: #035A9F; } div#terminales{ display:inline-block; background-color:#2C85AF; color:#FFFFFF; font-family: 'raleway'; font-size:14px;padding:5px 15px; cursor:pointer; cursor: hand; margin-right:-4px; } div#terminales:hover{ background-color: #E4E5E6; color: #035A9F; } div#centros{ display:inline-block; background-color:#2C85AF; color:#FFFFFF; font-family: 'raleway'; font-size:14px; padding:5px 15px; cursor:pointer; cursor: hand; margin-right:-4px; } div#centros:hover{ background-color: #E4E5E6; color: #035A9F; } div#agencias{ display:inline-block; background-color:#2C85AF; color:#FFFFFF; font-family: 'raleway'; font-size:14px; padding:5px 15px; cursor:pointer; cursor: hand; margin-right:-4px; } div#agencias:hover{ background-color: #E4E5E6; color: #035A9F; } div#oxxo{ display:inline-block; background-color:#2C85AF; color:#FFFFFF; font-family: 'raleway'; font-size:14px; padding:5px 15px; cursor:pointer; cursor: hand; margin-right:-4px; } div#oxxo:hover{ background-color: #E4E5E6; color: #035A9F; } </style> </head> <body> <div style="width:100%;border:1px solid #BDBDBD;text-align:center;overflow:hidden;float:right"> <div id="terminales" >Terminales y Centrales</div> <div id="centros" >Centros Comerciales</div> <div id="agencias" >Agencias de Viajes</div> <div id="oxxo" >Oxxo</div> <!-- ============================TERMINALES Y CENTRALES================================================================= --> <div id="mostrartermi" style="display:block"> <div style="display:inline-block;text-align:left;font-family: 'helvetica','raleway'"> <div style="display:inline-block"><img src="img/terminales.jpg" alt=""> </div> <div style="display:inline-block"><p style="font-size:12px">TERMINALES Y CENTRALES</p> <p style="color:#1959A0;font-weight:bold">SINALOA</p></div> </div> <div style="display:inline-block;width:100%;font-family: 'helvetica','raleway';"> <div style="display:inline-block;padding:10px;text-align:left"> <p style="font-weight:bold">•Mazatlán</p> <p>Calle Ferrusquilla s/n Interior <br> Edificio central de Autobuses <br> Colonia Palos Prietos <br> Tel: 01 (669) 981 46 59</p> </div> <div style="display:inline-block;padding:10px;text-align:left"> <p style="font-weight:bold">•Plaza San Ignacio</p> <p>Carretera Internacional Km. 1205 <br> Col. Fovisste en Playa Azul <br> Tel. 01 (669) 135 12 34</p> </div> <div style="display:inline-block;padding:10px;text-align:left"> <p style="font-weight:bold">•Culiacán</p> <p style="font-size:12px"><strong>CENTRAL DE AUTOBUSES CULIACÁN</strong> <br> en sala de primera y sala de segunda. <br> Blvd. Rolando Arjona # 2571 Norte y Blvd. <br> Culiacan Colonia Desarrollo Urbano 3 Rios. <br> Tel. 01 (667) 761 27 61</p> </div> <div style="display:inline-block;padding:10px;text-align:left"> <p style="font-weight:bold">•Guamuchil</p> <p>Nicolas Bravo y Adolfo Lopez Mateos # 479 <br> Colonia Morelos <br> Tel: 01 (673) 732 67 50</p> </div> <div style="display:inline-block;padding:10px;text-align:left"> <p style="font-weight:bold">•Guasave</p> <p >Blvd. 16 de Septiembre y 5 de Febrero S/n <br> Colonia <Centrobr></Centrobr> Tel. 01 (687) 872 98 45</p> </div> <div style="display:inline-block;padding:10px;text-align:left"> <p style="font-weight:bold">•Los Mochis</p> <p style="font-size:12px"><strong>TERMINAL</strong> <br> Blvd. Rosendo G. Castro y <br> Belisario Dominguez # 620 Sur <br> Colonia Bienestar <br> Tel: 01 (668) 817 59 07 <br> <strong>CENTRAL DE AUTOBUSES</strong> <br> Blvd. Rosendo G. Castro y Constitucion # 302 Oriente Col. Bienestar <br> Tel: 01 (668) 815 67 84</p> </div> </div> </div> <!-- ====================================CENTROS COMERCIALES============================================================ --> <div id="mostrarcentros" style="display:none"> <div style="display:block;text-align:center;font-family: 'helvetica','raleway'"> <div style="display:inline-block"><img src="img/comerciales.jpg" alt=""> </div> <div style="display:inline-block"><p style="font-size:12px">CENTROS COMERCIALES</p> <p style="color:#1959A0;font-weight:bold">SINALOA</p></div> </div> <div style="display:inline-block;font-family: 'helvetica',raleway';width:100%;text-align:center"> <div style="display:inline-block;font-size:15px;text-align:left;padding:10px"> <img style="width:100px" src="img/bodega_aurrera.png" alt=""> <p style="font-weight:bold;">•Estadio, Culiacán</p> <p>Blvd. Enrique Sáncez Alonso 2402 Nte. <br> Col. Desarrollo Urbano Tres Rios <br> C.P. 80030 <br> Tel. 01 (667) 146 61 60</p> </div> <div style="display:inline-block;font-size:15px;text-align:left;padding:10px"> <img style="width:100px" src="img/walmart.png" alt=""> <p style="font-weight:bold;"> •Los Mochis</p> <p>Blvd. Jiquilpan 1112 <br> Pte Local B <br> Col. Jiquilpan Ahome C.P. 81220 <br> Tel. 01 (668) 818 28 35</p> </div> <div style="display:inline-block;font-size:15px;text-align:left;padding:10px"> <img style="width:100px" src="img/walmart.png" alt=""> <p style="font-weight:bold;">•Culiacán</p> <p>Av. Regional 1330 Norte <br> Col. Sector V de la Primera del <br> Plan Parcial <br> (Tres Tios) C.P. 80000 <br> Tel. 01 (667) 750 95 42</p> </div> <div style="display:inline-block;font-size:15px;text-align:left;padding:10px"> <img style="width:100px" src="img/walmart.png" alt=""> <p style="font-weight:bold;">•Walmart 68, Culiacán</p> <p>Carretera Internacional 2017 <br> Col. Hacienda del Mar C.P. 82128 <br> Tel. 01 (669) 940 81 66</p> </div> <div style="display:inline-block;font-size:15px;text-align:left;padding:10px"> <img style="width:100px" src="img/walmart.png" alt=""> <p style="font-weight:bold;">•El Cochi, Mazatlán</p> <p>Av. Manuel J. Clouthier 4459 <br> Col. El Cochi C.P. 82139</p> </div> <div style="display:inline-block;font-size:15px;text-align:left;padding:10px"> <img style="width:100px" src="img/walmart.png" alt=""> <p style="font-weight:bold;">•Soriana Santa Rosa, Mazatlán</p> <p>Av. Luis Donaldo Colosio 17301 <br> Col. Fracc. Valle Dorado C.P. 82165 <br> Tel. 01 (669) 940 58 34</p> </div> </div> </div> <!-- ======================================AGENCIAS DE VIAJES==================================================== --> <div id="mostraragencias" style="display:none"> <div style="display:inline-block;text-align:left;font-family: 'helvetica','raleway'"> <div style="display:inline-block"><img src="img/agencias.jpg" alt=""> </div> <div style="display:inline-block"><p style="font-size:12px">AGENCIAS DE VIAJES</p> <p style="color:#1959A0;font-weight:bold">SINALOA</p></div> </div> <center><table> <tr> <td class="municipios">MUNICIPIO</td> <td class="municipios">COLONIA</td> <td class="direccion">DIRECCIÓN</td> <td class="municipios">TELÉFONO 1</td> <td class="municipios">TELÉFONO 2</td> </tr> <tr> <td class="textocolspan" colspan="5">Agencia: SERVICIOS Y VIAJES MICHEL</td> </tr> <tr> <td class="rellenotabla">CULIACAN</td> <td class="rellenotabla">ALMADA</td> <td class="rellenotabla2">LAZARO CARDENAS N198-G</td> <td class="rellenotabla">6677128033</td> <td class="rellenotabla">6677128711</td> </tr> <tr> <td class="textocolspan" colspan="5">Agencia: ROSEF & TURISMO</td> </tr> <tr> <td class="rellenotabla">CULIACAN</td> <td class="rellenotabla">CHAPULTEPEC</td> <td class="rellenotabla2">ALVARO OBREGON 1330 NTE</td> <td class="rellenotabla">6677127700</td> <td class="rellenotabla">6677127701</td> </tr> <tr> <td class="textocolspan" colspan="5">Agencia: AGENCIA DE VIAJES NERY TOURS</td> </tr> <tr> <td class="rellenotabla">CULIACAN</td> <td class="rellenotabla">FEDERALISMO</td> <td class="rellenotabla2">BLVD CULIACAN 450-10</td> <td class="rellenotabla">6677612992</td> <td class="rellenotabla"></td> </tr> <tr> <td class="textocolspan" colspan="5">Agencia: CULHUACAN TOURS</td> </tr> <tr> <td class="rellenotabla">CULIACAN</td> <td class="rellenotabla">LAS QUINTAS</td> <td class="rellenotabla2">PRESA BALSEQUILLOS N 13</td> <td class="rellenotabla">6677152606</td> <td class="rellenotabla">6677152603</td> </tr> <tr> <td class="textocolspan" colspan="5">Agencia: SULLIVAN TURISMO</td> </tr> <tr> <td class="rellenotabla">CULIACAN</td> <td class="rellenotabla">VALLADO</td> <td class="rellenotabla2">BLVD EMILIANO ZAPATA N 2151</td> <td class="rellenotabla">6677178364</td> <td class="rellenotabla">6677176350</td> </tr> <tr> <td class="textocolspan" colspan="5">Agencia: AGENCIA MORAGA</td> </tr> <tr> <td class="rellenotabla">GUAMUCHIL</td> <td class="rellenotabla">CENTRO</td> <td class="rellenotabla2">AGUSTINA RAMIREZ SUR NO. 671-A</td> <td class="rellenotabla">673 7322401</td> <td class="rellenotabla"></td> </tr> <tr> <td class="textocolspan" colspan="5">Agencia: VIAJES LUDACAR</td> </tr> <tr> <td class="rellenotabla">GUASAVE</td> <td class="rellenotabla">CENTRO</td> <td class="rellenotabla2">EMILIANO ZAPATA N 45</td> <td class="rellenotabla">6878714677</td> <td class="rellenotabla">6878714657</td> </tr> <tr> <td class="textocolspan" colspan="5">Agencia: SOLEITOURS</td> </tr> <tr> <td class="rellenotabla">LOS MOCHIS</td> <td class="rellenotabla">CENTRO</td> <td class="rellenotabla2">CARDENAS PONIENTE N.- 509</td> <td class="rellenotabla">6688123030</td> <td class="rellenotabla">018009676534</td> </tr> <tr> <td class="textocolspan" colspan="5">Agencia: VIAJES TRANVIA</td> </tr> <tr> <td class="rellenotabla">LOS MOCHIS</td> <td class="rellenotabla">CENTRO</td> <td class="rellenotabla2">CALLEJON TENOCHTITLAN PTE N.- 399</td> <td class="rellenotabla">6688123864</td> <td class="rellenotabla"></td> </tr> <tr> <td class="textocolspan" colspan="5">Agencia: SERVICIOS TURISTICOS CONELVA</td> </tr> <tr> <td class="rellenotabla">LOS MOCHIS</td> <td class="rellenotabla">CENTRO AHOME</td> <td class="rellenotabla2">GABRIEL LEYVA SOLANO 357 NTE</td> <td class="rellenotabla">6688152484</td> <td class="rellenotabla">6688158090</td> </tr> <tr> <td class="textocolspan" colspan="5">Agencia: VIAJES COPALA</td> </tr> <tr> <td class="rellenotabla">MAZATLAN</td> <td class="rellenotabla">C.C LA GRAN PLAZA</td> <td class="rellenotabla2">APOLO Y REFORMA L -F-4</td> <td class="rellenotabla">6699862120</td> <td class="rellenotabla"></td> </tr> <tr> <td class="textocolspan" colspan="5">Agencia: VIAJES MARLOPOS</td> </tr> <tr> <td class="rellenotabla">MAZATLAN</td> <td class="rellenotabla">CENTRO</td> <td class="rellenotabla2">AV OLAS ALTAS N 11</td> <td class="rellenotabla">6699811993</td> <td class="rellenotabla">6699811994</td> </tr> <tr> <td class="textocolspan" colspan="5">Agencia: VISTA TOURS MAZATLAN S.A DE C.V</td> </tr> <tr> <td class="rellenotabla">MAZATLAN</td> <td class="rellenotabla">LOMAS DE MAZATLAN</td> <td class="rellenotabla2">AV. CAMARON SABALO NO. 51 LOC. 2 Y 3</td> <td class="rellenotabla">(669) 9868610</td> <td class="rellenotabla"></td> </tr> <tr> <td class="textocolspan" colspan="5">Agencia: PROMOTOURS EL CID</td> </tr> <tr> <td class="rellenotabla">MAZATLAN</td> <td class="rellenotabla">ZONA DORADA</td> <td class="rellenotabla2">AV CAMARON SABALO S/N LOC. 18</td> <td class="rellenotabla"></td> <td class="rellenotabla"></td> </tr> <tr> <td class="textocolspan" colspan="5">Agencia: AGENCIA DE VIAJES NERY TOURS SUC NOVOLATO</td> </tr> <tr> <td class="rellenotabla">NAVOLATO</td> <td class="rellenotabla">CENTRO</td> <td class="rellenotabla2">AV NIÑOS HEROES 484-A</td> <td class="rellenotabla">6727271850</td> <td class="rellenotabla"></td> </tr> </table></center> </div> <!-- =================================================OXXO======================================================================== --> <div id="mostraroxxo" style="display:none"> <p style="font-family:'helvetica','raleway'">Adquiere tus boletos de autobus TAP en las tiendas Oxxo.</p> </div> </div> <script src="//ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script> <script> $(function(){ $('#oxxo').on('click', mostraroxo); function mostraroxo(){ $('#mostraroxxo').css('display', 'block'); $('#mostrartermi').css('display', 'none'); $('#mostraragencias').css('display', 'none'); $('#mostrarcentros').css('display', 'none'); } ; $('#agencias').on('click',mostraragen); function mostraragen(){ $('#mostraragencias').css('display', 'block'); $('#mostraroxxo').css('display', 'none'); $('#mostrartermi').css('display', 'none'); $('#mostrarcentros').css('display', 'none'); } ; $('#centros').on('click',mostrarcen); function mostrarcen(){ $('#mostrarcentros').css('display', 'block'); $('#mostraroxxo').css('display', 'none'); $('#mostrartermi').css('display', 'none'); $('#mostraragencias').css('display', 'none'); } ; $('#terminales').on('click',mostrarter); function mostrarter (){ $('#mostrartermi').css('display', 'block'); $('#mostraroxxo').css('display', 'none'); $('#mostraragencias').css('display', 'none'); $('#mostrarcentros').css('display', 'none'); } }); </script> </body> </html>
master777/tap
sinaloa.php
PHP
gpl-2.0
19,724
// float_digits(). // General includes. #include "base/cl_sysdep.h" // Specification. #include "cln/dfloat.h" // Implementation. #include "float/dfloat/cl_DF.h" namespace cln { CL_INLINE uintC CL_INLINE_DECL(float_digits) (const cl_DF& x) { unused x; return DF_mant_len+1; // 53 } } // namespace cln
ARudik/feelpp.cln
src/float/dfloat/misc/cl_DF_digits.cc
C++
gpl-2.0
311
package org.scada_lts.dao.model.multichangehistory; import java.util.Objects; /** * @author [email protected] on 16.10.2019 */ public class MultiChangeHistoryValues { private int id; private int userId; private String userName; private String viewAndCmpIdentyfication; private String interpretedState; private long timeStamp; private int valueId; private String value; private int dataPointId; private String xidPoint; public MultiChangeHistoryValues() {} public int getId() { return id; } public void setId(int id) { this.id = id; } public int getUserId() { return userId; } public void setUserId(int userId) { this.userId = userId; } public String getUserName() { return userName; } public void setUserName(String userName) { this.userName = userName; } public String getViewAndCmpIdentyfication() { return viewAndCmpIdentyfication; } public void setViewAndCmpIdentyfication(String viewAndCmpIdentyfication) { this.viewAndCmpIdentyfication = viewAndCmpIdentyfication; } public String getInterpretedState() { return interpretedState; } public void setInterpretedState(String interpretedState) { this.interpretedState = interpretedState; } public long getTimeStamp() { return timeStamp; } public void setTimeStamp(long timeStamp) { this.timeStamp = timeStamp; } public int getValueId() { return valueId; } public void setValueId(int valueId) { this.valueId = valueId; } public String getValue() { return value; } public void setValue(String value) { this.value = value; } public int getDataPointId() { return dataPointId; } public void setDataPointId(int dataPointId) { this.dataPointId = dataPointId; } public String getXidPoint() { return xidPoint; } public void setXidPoint(String xidPoint) { this.xidPoint = xidPoint; } @Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; MultiChangeHistoryValues that = (MultiChangeHistoryValues) o; return id == that.id && userId == that.userId && valueId == that.valueId && dataPointId == that.dataPointId && Objects.equals(userName, that.userName) && Objects.equals(viewAndCmpIdentyfication, that.viewAndCmpIdentyfication) && Objects.equals(interpretedState, that.interpretedState) && Objects.equals(timeStamp, that.timeStamp) && Objects.equals(value, that.value) && Objects.equals(xidPoint, that.xidPoint); } @Override public int hashCode() { return Objects.hash(id, userId, userName, viewAndCmpIdentyfication, interpretedState, timeStamp, valueId, value, dataPointId, xidPoint); } @Override public String toString() { return "MultiChangeHistoryValues{" + "id=" + id + ", userId=" + userId + ", userName='" + userName + '\'' + ", viewAndCmpIdentyfication='" + viewAndCmpIdentyfication + '\'' + ", interpretedState='" + interpretedState + '\'' + ", ts=" + timeStamp + ", valueId=" + valueId + ", value='" + value + '\'' + ", dataPointId=" + dataPointId + ", xidPoint='" + xidPoint + '\'' + '}'; } }
SCADA-LTS/Scada-LTS
src/org/scada_lts/dao/model/multichangehistory/MultiChangeHistoryValues.java
Java
gpl-2.0
3,725
<?php /** V4.50 6 July 2004 (c) 2000-2004 John Lim ([email protected]). All rights reserved. Released under both BSD license and Lesser GPL library license. Whenever there is any discrepancy between the two licenses, the BSD license will take precedence. Set tabs to 4 for best viewing. */ // security - hide paths if (!defined('ADODB_DIR')) die(); class ADODB2_ibase extends ADODB_DataDict { var $databaseType = 'ibase'; var $seqField = false; function ActualType($meta) { switch($meta) { case 'C': return 'VARCHAR'; case 'XL': case 'X': return 'VARCHAR(4000)'; case 'C2': return 'VARCHAR'; // up to 32K case 'X2': return 'VARCHAR(4000)'; case 'B': return 'BLOB'; case 'D': return 'DATE'; case 'T': return 'TIMESTAMP'; case 'L': return 'SMALLINT'; case 'I': return 'INTEGER'; case 'I1': return 'SMALLINT'; case 'I2': return 'SMALLINT'; case 'I4': return 'INTEGER'; case 'I8': return 'INTEGER'; case 'F': return 'DOUBLE PRECISION'; case 'N': return 'DECIMAL'; default: return $meta; } } function AlterColumnSQL($tabname, $flds) { if ($this->debug) ADOConnection::outp("AlterColumnSQL not supported"); return array(); } function DropColumnSQL($tabname, $flds) { if ($this->debug) ADOConnection::outp("DropColumnSQL not supported"); return array(); } } ?>
freemed/freemed-0.8.x
lib/acl/adodb/datadict/datadict-ibase.inc.php
PHP
gpl-2.0
1,369
# -*- coding: utf-8 -*- # ..#######.########.#######.##....#..######..######.########....###...########.#######.########..######. # .##.....#.##.....#.##......###...#.##....#.##....#.##.....#...##.##..##.....#.##......##.....#.##....## # .##.....#.##.....#.##......####..#.##......##......##.....#..##...##.##.....#.##......##.....#.##...... # .##.....#.########.######..##.##.#..######.##......########.##.....#.########.######..########..######. # .##.....#.##.......##......##..###.......#.##......##...##..########.##.......##......##...##........## # .##.....#.##.......##......##...##.##....#.##....#.##....##.##.....#.##.......##......##....##.##....## # ..#######.##.......#######.##....#..######..######.##.....#.##.....#.##.......#######.##.....#..######. ''' OpenScrapers 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 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/>. ''' import re from openscrapers.modules import cleantitle, source_utils, cfscrape class source: def __init__(self): self.priority = 1 self.language = ['en'] self.domains = ['coolmoviezone.online'] self.base_link = 'https://coolmoviezone.online' self.scraper = cfscrape.create_scraper() def movie(self, imdb, title, localtitle, aliases, year): try: title = cleantitle.geturl(title) url = self.base_link + '/%s-%s' % (title, year) return url except: return def sources(self, url, hostDict, hostprDict): try: sources = [] r = self.scraper.get(url).content match = re.compile('<td align="center"><strong><a href="(.+?)"').findall(r) for url in match: host = url.split('//')[1].replace('www.', '') host = host.split('/')[0].split('.')[0].title() quality = source_utils.check_sd_url(url) sources.append({'source': host, 'quality': quality, 'language': 'en', 'url': url, 'direct': False, 'debridonly': False}) except Exception: return return sources def resolve(self, url): return url
repotvsupertuga/tvsupertuga.repository
script.module.openscrapers/lib/openscrapers/sources_openscrapers/en/coolmoviezone.py
Python
gpl-2.0
2,749
/* * Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work * for additional information regarding copyright ownership. The ASF licenses this file to You under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations * under the License. */ package org.apache.fontbox.cff.charset; /** * This is specialized CFFCharset. It's used if the CharsetId of a font is set to 1. * * @author Villu Ruusmann * @version $Revision$ */ public class CFFExpertCharset extends CFFCharset { private CFFExpertCharset() { } /** * Returns an instance of the CFFExpertCharset class. * * @return an instance of CFFExpertCharset */ public static CFFExpertCharset getInstance() { return CFFExpertCharset.INSTANCE; } private static final CFFExpertCharset INSTANCE = new CFFExpertCharset(); static { INSTANCE.register(1, "space"); INSTANCE.register(13, "comma"); INSTANCE.register(14, "hyphen"); INSTANCE.register(15, "period"); INSTANCE.register(27, "colon"); INSTANCE.register(28, "semicolon"); INSTANCE.register(99, "fraction"); INSTANCE.register(109, "fi"); INSTANCE.register(110, "fl"); INSTANCE.register(150, "onesuperior"); INSTANCE.register(155, "onehalf"); INSTANCE.register(158, "onequarter"); INSTANCE.register(163, "threequarters"); INSTANCE.register(164, "twosuperior"); INSTANCE.register(169, "threesuperior"); INSTANCE.register(229, "exclamsmall"); INSTANCE.register(230, "Hungarumlautsmall"); INSTANCE.register(231, "dollaroldstyle"); INSTANCE.register(232, "dollarsuperior"); INSTANCE.register(233, "ampersandsmall"); INSTANCE.register(234, "Acutesmall"); INSTANCE.register(235, "parenleftsuperior"); INSTANCE.register(236, "parenrightsuperior"); INSTANCE.register(237, "twodotenleader"); INSTANCE.register(238, "onedotenleader"); INSTANCE.register(239, "zerooldstyle"); INSTANCE.register(240, "oneoldstyle"); INSTANCE.register(241, "twooldstyle"); INSTANCE.register(242, "threeoldstyle"); INSTANCE.register(243, "fouroldstyle"); INSTANCE.register(244, "fiveoldstyle"); INSTANCE.register(245, "sixoldstyle"); INSTANCE.register(246, "sevenoldstyle"); INSTANCE.register(247, "eightoldstyle"); INSTANCE.register(248, "nineoldstyle"); INSTANCE.register(249, "commasuperior"); INSTANCE.register(250, "threequartersemdash"); INSTANCE.register(251, "periodsuperior"); INSTANCE.register(252, "questionsmall"); INSTANCE.register(253, "asuperior"); INSTANCE.register(254, "bsuperior"); INSTANCE.register(255, "centsuperior"); INSTANCE.register(256, "dsuperior"); INSTANCE.register(257, "esuperior"); INSTANCE.register(258, "isuperior"); INSTANCE.register(259, "lsuperior"); INSTANCE.register(260, "msuperior"); INSTANCE.register(261, "nsuperior"); INSTANCE.register(262, "osuperior"); INSTANCE.register(263, "rsuperior"); INSTANCE.register(264, "ssuperior"); INSTANCE.register(265, "tsuperior"); INSTANCE.register(266, "ff"); INSTANCE.register(267, "ffi"); INSTANCE.register(268, "ffl"); INSTANCE.register(269, "parenleftinferior"); INSTANCE.register(270, "parenrightinferior"); INSTANCE.register(271, "Circumflexsmall"); INSTANCE.register(272, "hyphensuperior"); INSTANCE.register(273, "Gravesmall"); INSTANCE.register(274, "Asmall"); INSTANCE.register(275, "Bsmall"); INSTANCE.register(276, "Csmall"); INSTANCE.register(277, "Dsmall"); INSTANCE.register(278, "Esmall"); INSTANCE.register(279, "Fsmall"); INSTANCE.register(280, "Gsmall"); INSTANCE.register(281, "Hsmall"); INSTANCE.register(282, "Ismall"); INSTANCE.register(283, "Jsmall"); INSTANCE.register(284, "Ksmall"); INSTANCE.register(285, "Lsmall"); INSTANCE.register(286, "Msmall"); INSTANCE.register(287, "Nsmall"); INSTANCE.register(288, "Osmall"); INSTANCE.register(289, "Psmall"); INSTANCE.register(290, "Qsmall"); INSTANCE.register(291, "Rsmall"); INSTANCE.register(292, "Ssmall"); INSTANCE.register(293, "Tsmall"); INSTANCE.register(294, "Usmall"); INSTANCE.register(295, "Vsmall"); INSTANCE.register(296, "Wsmall"); INSTANCE.register(297, "Xsmall"); INSTANCE.register(298, "Ysmall"); INSTANCE.register(299, "Zsmall"); INSTANCE.register(300, "colonmonetary"); INSTANCE.register(301, "onefitted"); INSTANCE.register(302, "rupiah"); INSTANCE.register(303, "Tildesmall"); INSTANCE.register(304, "exclamdownsmall"); INSTANCE.register(305, "centoldstyle"); INSTANCE.register(306, "Lslashsmall"); INSTANCE.register(307, "Scaronsmall"); INSTANCE.register(308, "Zcaronsmall"); INSTANCE.register(309, "Dieresissmall"); INSTANCE.register(310, "Brevesmall"); INSTANCE.register(311, "Caronsmall"); INSTANCE.register(312, "Dotaccentsmall"); INSTANCE.register(313, "Macronsmall"); INSTANCE.register(314, "figuredash"); INSTANCE.register(315, "hypheninferior"); INSTANCE.register(316, "Ogoneksmall"); INSTANCE.register(317, "Ringsmall"); INSTANCE.register(318, "Cedillasmall"); INSTANCE.register(319, "questiondownsmall"); INSTANCE.register(320, "oneeighth"); INSTANCE.register(321, "threeeighths"); INSTANCE.register(322, "fiveeighths"); INSTANCE.register(323, "seveneighths"); INSTANCE.register(324, "onethird"); INSTANCE.register(325, "twothirds"); INSTANCE.register(326, "zerosuperior"); INSTANCE.register(327, "foursuperior"); INSTANCE.register(328, "fivesuperior"); INSTANCE.register(329, "sixsuperior"); INSTANCE.register(330, "sevensuperior"); INSTANCE.register(331, "eightsuperior"); INSTANCE.register(332, "ninesuperior"); INSTANCE.register(333, "zeroinferior"); INSTANCE.register(334, "oneinferior"); INSTANCE.register(335, "twoinferior"); INSTANCE.register(336, "threeinferior"); INSTANCE.register(337, "fourinferior"); INSTANCE.register(338, "fiveinferior"); INSTANCE.register(339, "sixinferior"); INSTANCE.register(340, "seveninferior"); INSTANCE.register(341, "eightinferior"); INSTANCE.register(342, "nineinferior"); INSTANCE.register(343, "centinferior"); INSTANCE.register(344, "dollarinferior"); INSTANCE.register(345, "periodinferior"); INSTANCE.register(346, "commainferior"); INSTANCE.register(347, "Agravesmall"); INSTANCE.register(348, "Aacutesmall"); INSTANCE.register(349, "Acircumflexsmall"); INSTANCE.register(350, "Atildesmall"); INSTANCE.register(351, "Adieresissmall"); INSTANCE.register(352, "Aringsmall"); INSTANCE.register(353, "AEsmall"); INSTANCE.register(354, "Ccedillasmall"); INSTANCE.register(355, "Egravesmall"); INSTANCE.register(356, "Eacutesmall"); INSTANCE.register(357, "Ecircumflexsmall"); INSTANCE.register(358, "Edieresissmall"); INSTANCE.register(359, "Igravesmall"); INSTANCE.register(360, "Iacutesmall"); INSTANCE.register(361, "Icircumflexsmall"); INSTANCE.register(362, "Idieresissmall"); INSTANCE.register(363, "Ethsmall"); INSTANCE.register(364, "Ntildesmall"); INSTANCE.register(365, "Ogravesmall"); INSTANCE.register(366, "Oacutesmall"); INSTANCE.register(367, "Ocircumflexsmall"); INSTANCE.register(368, "Otildesmall"); INSTANCE.register(369, "Odieresissmall"); INSTANCE.register(370, "OEsmall"); INSTANCE.register(371, "Oslashsmall"); INSTANCE.register(372, "Ugravesmall"); INSTANCE.register(373, "Uacutesmall"); INSTANCE.register(374, "Ucircumflexsmall"); INSTANCE.register(375, "Udieresissmall"); INSTANCE.register(376, "Yacutesmall"); INSTANCE.register(377, "Thornsmall"); INSTANCE.register(378, "Ydieresissmall"); } }
sencko/NALB
nalb2013/src/org/apache/fontbox/cff/charset/CFFExpertCharset.java
Java
gpl-2.0
8,359
</main> <div class="footer__break"></div> <footer id="footer" class="footer" role="contentinfo"> <div class="content__wrapper"> <?php get_template_part( 'template-parts/footer/newsletter' ); get_template_part( 'template-parts/footer/social' ); ?> </div> <?php get_template_part( 'template-parts/footer/copyright' ); ?> </footer> <?php get_template_part( 'template-parts/footer/bottom' ); ?> <?php wp_footer(); ?> </body> </html>
Fulcrum-Creatives/wordup
footer.php
PHP
gpl-2.0
454
package com.starfarers.dao; import java.util.List; public interface BaseDao<T> { public void create(T entity); public T save(T entity); public void save(List<T> entities); public void remove(T entity); public T find(Integer id); public List<T> findAll(); public <P> T findBy(String attribute, P parameter); }
Zweanslord/starfarers
src/main/java/com/starfarers/dao/BaseDao.java
Java
gpl-2.0
325
/* * YAFFS: Yet another Flash File System . A NAND-flash specific file system. * * Copyright (C) 2002-2007 Aleph One Ltd. * for Toby Churchill Ltd and Brightstar Engineering * * Created by Charles Manning <[email protected]> * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License version 2.1 as * published by the Free Software Foundation. * * Note: Only YAFFS headers are LGPL, YAFFS C code is covered by GPL. */ /* This is used to pack YAFFS2 tags, not YAFFS1tags. */ #ifndef __YAFFS_PACKEDTAGS2_H__ #define __YAFFS_PACKEDTAGS2_H__ #include "yaffs_guts.h" #include "yaffs_ecc.h" typedef struct { unsigned sequenceNumber; unsigned objectId; unsigned chunkId; unsigned byteCount; } yaffs_PackedTags2TagsPart; typedef struct{ yaffs_PackedTags2TagsPart t; yaffs_ECCOther ecc; } yaffs_PackedTags2; /* Full packed tags with ECC, used for oob tags */ void yaffs_PackTags2(yaffs_PackedTags2 * pt, const yaffs_ExtendedTags * t); void yaffs_UnpackTags2(yaffs_ExtendedTags * t, yaffs_PackedTags2 * pt); /* Only the tags part (no ECC for use with inband tags */ void yaffs_PackTags2TagsPart(yaffs_PackedTags2TagsPart * pt, const yaffs_ExtendedTags * t); void yaffs_UnpackTags2TagsPart(yaffs_ExtendedTags * t, yaffs_PackedTags2TagsPart * pt); #endif
xtreamerdev/linux-xtr
fs/yaffs2/yaffs_packedtags2.h
C
gpl-2.0
1,350
/* * Multiple format streaming server * Copyright (c) 2000, 2001, 2002 Fabrice Bellard * * This library 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 of the License, or (at your option) any later version. * * This library 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 this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #define HAVE_AV_CONFIG_H #include "avformat.h" #include <stdarg.h> #include <unistd.h> #include <fcntl.h> #include <sys/ioctl.h> #include <sys/poll.h> #include <errno.h> #include <sys/time.h> #undef time //needed because HAVE_AV_CONFIG_H is defined on top #include <time.h> #include <sys/types.h> #include <sys/socket.h> #include <sys/wait.h> #include <netinet/in.h> #include <arpa/inet.h> #include <netdb.h> #include <signal.h> #ifdef CONFIG_HAVE_DLFCN #include <dlfcn.h> #endif #include "ffserver.h" /* maximum number of simultaneous HTTP connections */ #define HTTP_MAX_CONNECTIONS 2000 enum HTTPState { HTTPSTATE_WAIT_REQUEST, HTTPSTATE_SEND_HEADER, HTTPSTATE_SEND_DATA_HEADER, HTTPSTATE_SEND_DATA, /* sending TCP or UDP data */ HTTPSTATE_SEND_DATA_TRAILER, HTTPSTATE_RECEIVE_DATA, HTTPSTATE_WAIT_FEED, /* wait for data from the feed */ HTTPSTATE_READY, RTSPSTATE_WAIT_REQUEST, RTSPSTATE_SEND_REPLY, RTSPSTATE_SEND_PACKET, }; const char *http_state[] = { "HTTP_WAIT_REQUEST", "HTTP_SEND_HEADER", "SEND_DATA_HEADER", "SEND_DATA", "SEND_DATA_TRAILER", "RECEIVE_DATA", "WAIT_FEED", "READY", "RTSP_WAIT_REQUEST", "RTSP_SEND_REPLY", "RTSP_SEND_PACKET", }; #define IOBUFFER_INIT_SIZE 8192 /* coef for exponential mean for bitrate estimation in statistics */ #define AVG_COEF 0.9 /* timeouts are in ms */ #define HTTP_REQUEST_TIMEOUT (15 * 1000) #define RTSP_REQUEST_TIMEOUT (3600 * 24 * 1000) #define SYNC_TIMEOUT (10 * 1000) typedef struct { int64_t count1, count2; long time1, time2; } DataRateData; /* context associated with one connection */ typedef struct HTTPContext { enum HTTPState state; int fd; /* socket file descriptor */ struct sockaddr_in from_addr; /* origin */ struct pollfd *poll_entry; /* used when polling */ long timeout; uint8_t *buffer_ptr, *buffer_end; int http_error; struct HTTPContext *next; int got_key_frame; /* stream 0 => 1, stream 1 => 2, stream 2=> 4 */ int64_t data_count; /* feed input */ int feed_fd; /* input format handling */ AVFormatContext *fmt_in; long start_time; /* In milliseconds - this wraps fairly often */ int64_t first_pts; /* initial pts value */ int64_t cur_pts; /* current pts value from the stream in us */ int64_t cur_frame_duration; /* duration of the current frame in us */ int cur_frame_bytes; /* output frame size, needed to compute the time at which we send each packet */ int pts_stream_index; /* stream we choose as clock reference */ int64_t cur_clock; /* current clock reference value in us */ /* output format handling */ struct FFStream *stream; /* -1 is invalid stream */ int feed_streams[MAX_STREAMS]; /* index of streams in the feed */ int switch_feed_streams[MAX_STREAMS]; /* index of streams in the feed */ int switch_pending; AVFormatContext fmt_ctx; /* instance of FFStream for one user */ int last_packet_sent; /* true if last data packet was sent */ int suppress_log; DataRateData datarate; int wmp_client_id; char protocol[16]; char method[16]; char url[128]; int buffer_size; uint8_t *buffer; int is_packetized; /* if true, the stream is packetized */ int packet_stream_index; /* current stream for output in state machine */ /* RTSP state specific */ uint8_t *pb_buffer; /* XXX: use that in all the code */ ByteIOContext *pb; int seq; /* RTSP sequence number */ /* RTP state specific */ enum RTSPProtocol rtp_protocol; char session_id[32]; /* session id */ AVFormatContext *rtp_ctx[MAX_STREAMS]; /* RTP/UDP specific */ URLContext *rtp_handles[MAX_STREAMS]; /* RTP/TCP specific */ struct HTTPContext *rtsp_c; uint8_t *packet_buffer, *packet_buffer_ptr, *packet_buffer_end; } HTTPContext; static AVFrame dummy_frame; /* each generated stream is described here */ enum StreamType { STREAM_TYPE_LIVE, STREAM_TYPE_STATUS, STREAM_TYPE_REDIRECT, }; enum IPAddressAction { IP_ALLOW = 1, IP_DENY, }; typedef struct IPAddressACL { struct IPAddressACL *next; enum IPAddressAction action; /* These are in host order */ struct in_addr first; struct in_addr last; } IPAddressACL; /* description of each stream of the ffserver.conf file */ typedef struct FFStream { enum StreamType stream_type; char filename[1024]; /* stream filename */ struct FFStream *feed; /* feed we are using (can be null if coming from file) */ AVFormatParameters *ap_in; /* input parameters */ AVInputFormat *ifmt; /* if non NULL, force input format */ AVOutputFormat *fmt; IPAddressACL *acl; int nb_streams; int prebuffer; /* Number of millseconds early to start */ long max_time; /* Number of milliseconds to run */ int send_on_key; AVStream *streams[MAX_STREAMS]; int feed_streams[MAX_STREAMS]; /* index of streams in the feed */ char feed_filename[1024]; /* file name of the feed storage, or input file name for a stream */ char author[512]; char title[512]; char copyright[512]; char comment[512]; pid_t pid; /* Of ffmpeg process */ time_t pid_start; /* Of ffmpeg process */ char **child_argv; struct FFStream *next; int bandwidth; /* bandwidth, in kbits/s */ /* RTSP options */ char *rtsp_option; /* multicast specific */ int is_multicast; struct in_addr multicast_ip; int multicast_port; /* first port used for multicast */ int multicast_ttl; int loop; /* if true, send the stream in loops (only meaningful if file) */ /* feed specific */ int feed_opened; /* true if someone is writing to the feed */ int is_feed; /* true if it is a feed */ int readonly; /* True if writing is prohibited to the file */ int conns_served; int64_t bytes_served; int64_t feed_max_size; /* maximum storage size */ int64_t feed_write_index; /* current write position in feed (it wraps round) */ int64_t feed_size; /* current size of feed */ struct FFStream *next_feed; } FFStream; typedef struct FeedData { long long data_count; float avg_frame_size; /* frame size averraged over last frames with exponential mean */ } FeedData; struct sockaddr_in my_http_addr; struct sockaddr_in my_rtsp_addr; char logfilename[1024]; HTTPContext *first_http_ctx; FFStream *first_feed; /* contains only feeds */ FFStream *first_stream; /* contains all streams, including feeds */ static void new_connection(int server_fd, int is_rtsp); static void close_connection(HTTPContext *c); /* HTTP handling */ static int handle_connection(HTTPContext *c); static int http_parse_request(HTTPContext *c); static int http_send_data(HTTPContext *c); static void compute_stats(HTTPContext *c); static int open_input_stream(HTTPContext *c, const char *info); static int http_start_receive_data(HTTPContext *c); static int http_receive_data(HTTPContext *c); /* RTSP handling */ static int rtsp_parse_request(HTTPContext *c); static void rtsp_cmd_describe(HTTPContext *c, const char *url); static void rtsp_cmd_options(HTTPContext *c, const char *url); static void rtsp_cmd_setup(HTTPContext *c, const char *url, RTSPHeader *h); static void rtsp_cmd_play(HTTPContext *c, const char *url, RTSPHeader *h); static void rtsp_cmd_pause(HTTPContext *c, const char *url, RTSPHeader *h); static void rtsp_cmd_teardown(HTTPContext *c, const char *url, RTSPHeader *h); /* SDP handling */ static int prepare_sdp_description(FFStream *stream, uint8_t **pbuffer, struct in_addr my_ip); /* RTP handling */ static HTTPContext *rtp_new_connection(struct sockaddr_in *from_addr, FFStream *stream, const char *session_id, enum RTSPProtocol rtp_protocol); static int rtp_new_av_stream(HTTPContext *c, int stream_index, struct sockaddr_in *dest_addr, HTTPContext *rtsp_c); static const char *my_program_name; static const char *my_program_dir; static int ffserver_debug; static int ffserver_daemon; static int no_launch; static int need_to_start_children; int nb_max_connections; int nb_connections; int max_bandwidth; int current_bandwidth; static long cur_time; // Making this global saves on passing it around everywhere static long gettime_ms(void) { struct timeval tv; gettimeofday(&tv,NULL); return (long long)tv.tv_sec * 1000 + (tv.tv_usec / 1000); } static FILE *logfile = NULL; static void __attribute__ ((format (printf, 1, 2))) http_log(const char *fmt, ...) { va_list ap; va_start(ap, fmt); if (logfile) { vfprintf(logfile, fmt, ap); fflush(logfile); } va_end(ap); } static char *ctime1(char *buf2) { time_t ti; char *p; ti = time(NULL); p = ctime(&ti); strcpy(buf2, p); p = buf2 + strlen(p) - 1; if (*p == '\n') *p = '\0'; return buf2; } static void log_connection(HTTPContext *c) { char buf2[32]; if (c->suppress_log) return; http_log("%s - - [%s] \"%s %s %s\" %d %lld\n", inet_ntoa(c->from_addr.sin_addr), ctime1(buf2), c->method, c->url, c->protocol, (c->http_error ? c->http_error : 200), c->data_count); } static void update_datarate(DataRateData *drd, int64_t count) { if (!drd->time1 && !drd->count1) { drd->time1 = drd->time2 = cur_time; drd->count1 = drd->count2 = count; } else { if (cur_time - drd->time2 > 5000) { drd->time1 = drd->time2; drd->count1 = drd->count2; drd->time2 = cur_time; drd->count2 = count; } } } /* In bytes per second */ static int compute_datarate(DataRateData *drd, int64_t count) { if (cur_time == drd->time1) return 0; return ((count - drd->count1) * 1000) / (cur_time - drd->time1); } static int get_longterm_datarate(DataRateData *drd, int64_t count) { /* You get the first 3 seconds flat out */ if (cur_time - drd->time1 < 3000) return 0; return compute_datarate(drd, count); } static void start_children(FFStream *feed) { if (no_launch) return; for (; feed; feed = feed->next) { if (feed->child_argv && !feed->pid) { feed->pid_start = time(0); feed->pid = fork(); if (feed->pid < 0) { fprintf(stderr, "Unable to create children\n"); exit(1); } if (!feed->pid) { /* In child */ char pathname[1024]; char *slash; int i; for (i = 3; i < 256; i++) { close(i); } if (!ffserver_debug) { i = open("/dev/null", O_RDWR); if (i) dup2(i, 0); dup2(i, 1); dup2(i, 2); if (i) close(i); } pstrcpy(pathname, sizeof(pathname), my_program_name); slash = strrchr(pathname, '/'); if (!slash) { slash = pathname; } else { slash++; } strcpy(slash, "ffmpeg"); /* This is needed to make relative pathnames work */ chdir(my_program_dir); signal(SIGPIPE, SIG_DFL); execvp(pathname, feed->child_argv); _exit(1); } } } } /* open a listening socket */ static int socket_open_listen(struct sockaddr_in *my_addr) { int server_fd, tmp; server_fd = socket(AF_INET,SOCK_STREAM,0); if (server_fd < 0) { perror ("socket"); return -1; } tmp = 1; setsockopt(server_fd, SOL_SOCKET, SO_REUSEADDR, &tmp, sizeof(tmp)); if (bind (server_fd, (struct sockaddr *) my_addr, sizeof (*my_addr)) < 0) { char bindmsg[32]; snprintf(bindmsg, sizeof(bindmsg), "bind(port %d)", ntohs(my_addr->sin_port)); perror (bindmsg); close(server_fd); return -1; } if (listen (server_fd, 5) < 0) { perror ("listen"); close(server_fd); return -1; } fcntl(server_fd, F_SETFL, O_NONBLOCK); return server_fd; } /* start all multicast streams */ static void start_multicast(void) { FFStream *stream; char session_id[32]; HTTPContext *rtp_c; struct sockaddr_in dest_addr; int default_port, stream_index; default_port = 6000; for(stream = first_stream; stream != NULL; stream = stream->next) { if (stream->is_multicast) { /* open the RTP connection */ snprintf(session_id, sizeof(session_id), "%08x%08x", (int)random(), (int)random()); /* choose a port if none given */ if (stream->multicast_port == 0) { stream->multicast_port = default_port; default_port += 100; } dest_addr.sin_family = AF_INET; dest_addr.sin_addr = stream->multicast_ip; dest_addr.sin_port = htons(stream->multicast_port); rtp_c = rtp_new_connection(&dest_addr, stream, session_id, RTSP_PROTOCOL_RTP_UDP_MULTICAST); if (!rtp_c) { continue; } if (open_input_stream(rtp_c, "") < 0) { fprintf(stderr, "Could not open input stream for stream '%s'\n", stream->filename); continue; } /* open each RTP stream */ for(stream_index = 0; stream_index < stream->nb_streams; stream_index++) { dest_addr.sin_port = htons(stream->multicast_port + 2 * stream_index); if (rtp_new_av_stream(rtp_c, stream_index, &dest_addr, NULL) < 0) { fprintf(stderr, "Could not open output stream '%s/streamid=%d'\n", stream->filename, stream_index); exit(1); } } /* change state to send data */ rtp_c->state = HTTPSTATE_SEND_DATA; } } } /* main loop of the http server */ static int http_server(void) { int server_fd, ret, rtsp_server_fd, delay, delay1; struct pollfd poll_table[HTTP_MAX_CONNECTIONS + 2], *poll_entry; HTTPContext *c, *c_next; server_fd = socket_open_listen(&my_http_addr); if (server_fd < 0) return -1; rtsp_server_fd = socket_open_listen(&my_rtsp_addr); if (rtsp_server_fd < 0) return -1; http_log("ffserver started.\n"); start_children(first_feed); first_http_ctx = NULL; nb_connections = 0; start_multicast(); for(;;) { poll_entry = poll_table; poll_entry->fd = server_fd; poll_entry->events = POLLIN; poll_entry++; poll_entry->fd = rtsp_server_fd; poll_entry->events = POLLIN; poll_entry++; /* wait for events on each HTTP handle */ c = first_http_ctx; delay = 1000; while (c != NULL) { int fd; fd = c->fd; switch(c->state) { case HTTPSTATE_SEND_HEADER: case RTSPSTATE_SEND_REPLY: case RTSPSTATE_SEND_PACKET: c->poll_entry = poll_entry; poll_entry->fd = fd; poll_entry->events = POLLOUT; poll_entry++; break; case HTTPSTATE_SEND_DATA_HEADER: case HTTPSTATE_SEND_DATA: case HTTPSTATE_SEND_DATA_TRAILER: if (!c->is_packetized) { /* for TCP, we output as much as we can (may need to put a limit) */ c->poll_entry = poll_entry; poll_entry->fd = fd; poll_entry->events = POLLOUT; poll_entry++; } else { /* when ffserver is doing the timing, we work by looking at which packet need to be sent every 10 ms */ delay1 = 10; /* one tick wait XXX: 10 ms assumed */ if (delay1 < delay) delay = delay1; } break; case HTTPSTATE_WAIT_REQUEST: case HTTPSTATE_RECEIVE_DATA: case HTTPSTATE_WAIT_FEED: case RTSPSTATE_WAIT_REQUEST: /* need to catch errors */ c->poll_entry = poll_entry; poll_entry->fd = fd; poll_entry->events = POLLIN;/* Maybe this will work */ poll_entry++; break; default: c->poll_entry = NULL; break; } c = c->next; } /* wait for an event on one connection. We poll at least every second to handle timeouts */ do { ret = poll(poll_table, poll_entry - poll_table, delay); if (ret < 0 && errno != EAGAIN && errno != EINTR) return -1; } while (ret <= 0); cur_time = gettime_ms(); if (need_to_start_children) { need_to_start_children = 0; start_children(first_feed); } /* now handle the events */ for(c = first_http_ctx; c != NULL; c = c_next) { c_next = c->next; if (handle_connection(c) < 0) { /* close and free the connection */ log_connection(c); close_connection(c); } } poll_entry = poll_table; /* new HTTP connection request ? */ if (poll_entry->revents & POLLIN) { new_connection(server_fd, 0); } poll_entry++; /* new RTSP connection request ? */ if (poll_entry->revents & POLLIN) { new_connection(rtsp_server_fd, 1); } } } /* start waiting for a new HTTP/RTSP request */ static void start_wait_request(HTTPContext *c, int is_rtsp) { c->buffer_ptr = c->buffer; c->buffer_end = c->buffer + c->buffer_size - 1; /* leave room for '\0' */ if (is_rtsp) { c->timeout = cur_time + RTSP_REQUEST_TIMEOUT; c->state = RTSPSTATE_WAIT_REQUEST; } else { c->timeout = cur_time + HTTP_REQUEST_TIMEOUT; c->state = HTTPSTATE_WAIT_REQUEST; } } static void new_connection(int server_fd, int is_rtsp) { struct sockaddr_in from_addr; int fd, len; HTTPContext *c = NULL; len = sizeof(from_addr); fd = accept(server_fd, (struct sockaddr *)&from_addr, &len); if (fd < 0) return; fcntl(fd, F_SETFL, O_NONBLOCK); /* XXX: should output a warning page when coming close to the connection limit */ if (nb_connections >= nb_max_connections) goto fail; /* add a new connection */ c = av_mallocz(sizeof(HTTPContext)); if (!c) goto fail; c->fd = fd; c->poll_entry = NULL; c->from_addr = from_addr; c->buffer_size = IOBUFFER_INIT_SIZE; c->buffer = av_malloc(c->buffer_size); if (!c->buffer) goto fail; c->next = first_http_ctx; first_http_ctx = c; nb_connections++; start_wait_request(c, is_rtsp); return; fail: if (c) { av_free(c->buffer); av_free(c); } close(fd); } static void close_connection(HTTPContext *c) { HTTPContext **cp, *c1; int i, nb_streams; AVFormatContext *ctx; URLContext *h; AVStream *st; /* remove connection from list */ cp = &first_http_ctx; while ((*cp) != NULL) { c1 = *cp; if (c1 == c) { *cp = c->next; } else { cp = &c1->next; } } /* remove references, if any (XXX: do it faster) */ for(c1 = first_http_ctx; c1 != NULL; c1 = c1->next) { if (c1->rtsp_c == c) c1->rtsp_c = NULL; } /* remove connection associated resources */ if (c->fd >= 0) close(c->fd); if (c->fmt_in) { /* close each frame parser */ for(i=0;i<c->fmt_in->nb_streams;i++) { st = c->fmt_in->streams[i]; if (st->codec.codec) { avcodec_close(&st->codec); } } av_close_input_file(c->fmt_in); } /* free RTP output streams if any */ nb_streams = 0; if (c->stream) nb_streams = c->stream->nb_streams; for(i=0;i<nb_streams;i++) { ctx = c->rtp_ctx[i]; if (ctx) { av_write_trailer(ctx); av_free(ctx); } h = c->rtp_handles[i]; if (h) { url_close(h); } } ctx = &c->fmt_ctx; if (!c->last_packet_sent) { if (ctx->oformat) { /* prepare header */ if (url_open_dyn_buf(&ctx->pb) >= 0) { av_write_trailer(ctx); url_close_dyn_buf(&ctx->pb, &c->pb_buffer); } } } for(i=0; i<ctx->nb_streams; i++) av_free(ctx->streams[i]) ; if (c->stream) current_bandwidth -= c->stream->bandwidth; av_freep(&c->pb_buffer); av_freep(&c->packet_buffer); av_free(c->buffer); av_free(c); nb_connections--; } static int handle_connection(HTTPContext *c) { int len, ret; switch(c->state) { case HTTPSTATE_WAIT_REQUEST: case RTSPSTATE_WAIT_REQUEST: /* timeout ? */ if ((c->timeout - cur_time) < 0) return -1; if (c->poll_entry->revents & (POLLERR | POLLHUP)) return -1; /* no need to read if no events */ if (!(c->poll_entry->revents & POLLIN)) return 0; /* read the data */ read_loop: len = read(c->fd, c->buffer_ptr, 1); if (len < 0) { if (errno != EAGAIN && errno != EINTR) return -1; } else if (len == 0) { return -1; } else { /* search for end of request. */ uint8_t *ptr; c->buffer_ptr += len; ptr = c->buffer_ptr; if ((ptr >= c->buffer + 2 && !memcmp(ptr-2, "\n\n", 2)) || (ptr >= c->buffer + 4 && !memcmp(ptr-4, "\r\n\r\n", 4))) { /* request found : parse it and reply */ if (c->state == HTTPSTATE_WAIT_REQUEST) { ret = http_parse_request(c); } else { ret = rtsp_parse_request(c); } if (ret < 0) return -1; } else if (ptr >= c->buffer_end) { /* request too long: cannot do anything */ return -1; } else goto read_loop; } break; case HTTPSTATE_SEND_HEADER: if (c->poll_entry->revents & (POLLERR | POLLHUP)) return -1; /* no need to write if no events */ if (!(c->poll_entry->revents & POLLOUT)) return 0; len = write(c->fd, c->buffer_ptr, c->buffer_end - c->buffer_ptr); if (len < 0) { if (errno != EAGAIN && errno != EINTR) { /* error : close connection */ av_freep(&c->pb_buffer); return -1; } } else { c->buffer_ptr += len; if (c->stream) c->stream->bytes_served += len; c->data_count += len; if (c->buffer_ptr >= c->buffer_end) { av_freep(&c->pb_buffer); /* if error, exit */ if (c->http_error) { return -1; } /* all the buffer was sent : synchronize to the incoming stream */ c->state = HTTPSTATE_SEND_DATA_HEADER; c->buffer_ptr = c->buffer_end = c->buffer; } } break; case HTTPSTATE_SEND_DATA: case HTTPSTATE_SEND_DATA_HEADER: case HTTPSTATE_SEND_DATA_TRAILER: /* for packetized output, we consider we can always write (the input streams sets the speed). It may be better to verify that we do not rely too much on the kernel queues */ if (!c->is_packetized) { if (c->poll_entry->revents & (POLLERR | POLLHUP)) return -1; /* no need to read if no events */ if (!(c->poll_entry->revents & POLLOUT)) return 0; } if (http_send_data(c) < 0) return -1; break; case HTTPSTATE_RECEIVE_DATA: /* no need to read if no events */ if (c->poll_entry->revents & (POLLERR | POLLHUP)) return -1; if (!(c->poll_entry->revents & POLLIN)) return 0; if (http_receive_data(c) < 0) return -1; break; case HTTPSTATE_WAIT_FEED: /* no need to read if no events */ if (c->poll_entry->revents & (POLLIN | POLLERR | POLLHUP)) return -1; /* nothing to do, we'll be waken up by incoming feed packets */ break; case RTSPSTATE_SEND_REPLY: if (c->poll_entry->revents & (POLLERR | POLLHUP)) { av_freep(&c->pb_buffer); return -1; } /* no need to write if no events */ if (!(c->poll_entry->revents & POLLOUT)) return 0; len = write(c->fd, c->buffer_ptr, c->buffer_end - c->buffer_ptr); if (len < 0) { if (errno != EAGAIN && errno != EINTR) { /* error : close connection */ av_freep(&c->pb_buffer); return -1; } } else { c->buffer_ptr += len; c->data_count += len; if (c->buffer_ptr >= c->buffer_end) { /* all the buffer was sent : wait for a new request */ av_freep(&c->pb_buffer); start_wait_request(c, 1); } } break; case RTSPSTATE_SEND_PACKET: if (c->poll_entry->revents & (POLLERR | POLLHUP)) { av_freep(&c->packet_buffer); return -1; } /* no need to write if no events */ if (!(c->poll_entry->revents & POLLOUT)) return 0; len = write(c->fd, c->packet_buffer_ptr, c->packet_buffer_end - c->packet_buffer_ptr); if (len < 0) { if (errno != EAGAIN && errno != EINTR) { /* error : close connection */ av_freep(&c->packet_buffer); return -1; } } else { c->packet_buffer_ptr += len; if (c->packet_buffer_ptr >= c->packet_buffer_end) { /* all the buffer was sent : wait for a new request */ av_freep(&c->packet_buffer); c->state = RTSPSTATE_WAIT_REQUEST; } } break; case HTTPSTATE_READY: /* nothing to do */ break; default: return -1; } return 0; } static int extract_rates(char *rates, int ratelen, const char *request) { const char *p; for (p = request; *p && *p != '\r' && *p != '\n'; ) { if (strncasecmp(p, "Pragma:", 7) == 0) { const char *q = p + 7; while (*q && *q != '\n' && isspace(*q)) q++; if (strncasecmp(q, "stream-switch-entry=", 20) == 0) { int stream_no; int rate_no; q += 20; memset(rates, 0xff, ratelen); while (1) { while (*q && *q != '\n' && *q != ':') q++; if (sscanf(q, ":%d:%d", &stream_no, &rate_no) != 2) { break; } stream_no--; if (stream_no < ratelen && stream_no >= 0) { rates[stream_no] = rate_no; } while (*q && *q != '\n' && !isspace(*q)) q++; } return 1; } } p = strchr(p, '\n'); if (!p) break; p++; } return 0; } static int find_stream_in_feed(FFStream *feed, AVCodecContext *codec, int bit_rate) { int i; int best_bitrate = 100000000; int best = -1; for (i = 0; i < feed->nb_streams; i++) { AVCodecContext *feed_codec = &feed->streams[i]->codec; if (feed_codec->codec_id != codec->codec_id || feed_codec->sample_rate != codec->sample_rate || feed_codec->width != codec->width || feed_codec->height != codec->height) { continue; } /* Potential stream */ /* We want the fastest stream less than bit_rate, or the slowest * faster than bit_rate */ if (feed_codec->bit_rate <= bit_rate) { if (best_bitrate > bit_rate || feed_codec->bit_rate > best_bitrate) { best_bitrate = feed_codec->bit_rate; best = i; } } else { if (feed_codec->bit_rate < best_bitrate) { best_bitrate = feed_codec->bit_rate; best = i; } } } return best; } static int modify_current_stream(HTTPContext *c, char *rates) { int i; FFStream *req = c->stream; int action_required = 0; /* Not much we can do for a feed */ if (!req->feed) return 0; for (i = 0; i < req->nb_streams; i++) { AVCodecContext *codec = &req->streams[i]->codec; switch(rates[i]) { case 0: c->switch_feed_streams[i] = req->feed_streams[i]; break; case 1: c->switch_feed_streams[i] = find_stream_in_feed(req->feed, codec, codec->bit_rate / 2); break; case 2: /* Wants off or slow */ c->switch_feed_streams[i] = find_stream_in_feed(req->feed, codec, codec->bit_rate / 4); #ifdef WANTS_OFF /* This doesn't work well when it turns off the only stream! */ c->switch_feed_streams[i] = -2; c->feed_streams[i] = -2; #endif break; } if (c->switch_feed_streams[i] >= 0 && c->switch_feed_streams[i] != c->feed_streams[i]) action_required = 1; } return action_required; } static void do_switch_stream(HTTPContext *c, int i) { if (c->switch_feed_streams[i] >= 0) { #ifdef PHILIP c->feed_streams[i] = c->switch_feed_streams[i]; #endif /* Now update the stream */ } c->switch_feed_streams[i] = -1; } /* XXX: factorize in utils.c ? */ /* XXX: take care with different space meaning */ static void skip_spaces(const char **pp) { const char *p; p = *pp; while (*p == ' ' || *p == '\t') p++; *pp = p; } static void get_word(char *buf, int buf_size, const char **pp) { const char *p; char *q; p = *pp; skip_spaces(&p); q = buf; while (!isspace(*p) && *p != '\0') { if ((q - buf) < buf_size - 1) *q++ = *p; p++; } if (buf_size > 0) *q = '\0'; *pp = p; } static int validate_acl(FFStream *stream, HTTPContext *c) { enum IPAddressAction last_action = IP_DENY; IPAddressACL *acl; struct in_addr *src = &c->from_addr.sin_addr; unsigned long src_addr = ntohl(src->s_addr); for (acl = stream->acl; acl; acl = acl->next) { if (src_addr >= acl->first.s_addr && src_addr <= acl->last.s_addr) { return (acl->action == IP_ALLOW) ? 1 : 0; } last_action = acl->action; } /* Nothing matched, so return not the last action */ return (last_action == IP_DENY) ? 1 : 0; } /* compute the real filename of a file by matching it without its extensions to all the stream filenames */ static void compute_real_filename(char *filename, int max_size) { char file1[1024]; char file2[1024]; char *p; FFStream *stream; /* compute filename by matching without the file extensions */ pstrcpy(file1, sizeof(file1), filename); p = strrchr(file1, '.'); if (p) *p = '\0'; for(stream = first_stream; stream != NULL; stream = stream->next) { pstrcpy(file2, sizeof(file2), stream->filename); p = strrchr(file2, '.'); if (p) *p = '\0'; if (!strcmp(file1, file2)) { pstrcpy(filename, max_size, stream->filename); break; } } } enum RedirType { REDIR_NONE, REDIR_ASX, REDIR_RAM, REDIR_ASF, REDIR_RTSP, REDIR_SDP, }; /* parse http request and prepare header */ static int http_parse_request(HTTPContext *c) { char *p; int post; enum RedirType redir_type; char cmd[32]; char info[1024], *filename; char url[1024], *q; char protocol[32]; char msg[1024]; const char *mime_type; FFStream *stream; int i; char ratebuf[32]; char *useragent = 0; p = c->buffer; get_word(cmd, sizeof(cmd), (const char **)&p); pstrcpy(c->method, sizeof(c->method), cmd); if (!strcmp(cmd, "GET")) post = 0; else if (!strcmp(cmd, "POST")) post = 1; else return -1; get_word(url, sizeof(url), (const char **)&p); pstrcpy(c->url, sizeof(c->url), url); get_word(protocol, sizeof(protocol), (const char **)&p); if (strcmp(protocol, "HTTP/1.0") && strcmp(protocol, "HTTP/1.1")) return -1; pstrcpy(c->protocol, sizeof(c->protocol), protocol); /* find the filename and the optional info string in the request */ p = url; if (*p == '/') p++; filename = p; p = strchr(p, '?'); if (p) { pstrcpy(info, sizeof(info), p); *p = '\0'; } else { info[0] = '\0'; } for (p = c->buffer; *p && *p != '\r' && *p != '\n'; ) { if (strncasecmp(p, "User-Agent:", 11) == 0) { useragent = p + 11; if (*useragent && *useragent != '\n' && isspace(*useragent)) useragent++; break; } p = strchr(p, '\n'); if (!p) break; p++; } redir_type = REDIR_NONE; if (match_ext(filename, "asx")) { redir_type = REDIR_ASX; filename[strlen(filename)-1] = 'f'; } else if (match_ext(filename, "asf") && (!useragent || strncasecmp(useragent, "NSPlayer", 8) != 0)) { /* if this isn't WMP or lookalike, return the redirector file */ redir_type = REDIR_ASF; } else if (match_ext(filename, "rpm,ram")) { redir_type = REDIR_RAM; strcpy(filename + strlen(filename)-2, "m"); } else if (match_ext(filename, "rtsp")) { redir_type = REDIR_RTSP; compute_real_filename(filename, sizeof(url) - 1); } else if (match_ext(filename, "sdp")) { redir_type = REDIR_SDP; compute_real_filename(filename, sizeof(url) - 1); } stream = first_stream; while (stream != NULL) { if (!strcmp(stream->filename, filename) && validate_acl(stream, c)) break; stream = stream->next; } if (stream == NULL) { snprintf(msg, sizeof(msg), "File '%s' not found", url); goto send_error; } c->stream = stream; memcpy(c->feed_streams, stream->feed_streams, sizeof(c->feed_streams)); memset(c->switch_feed_streams, -1, sizeof(c->switch_feed_streams)); if (stream->stream_type == STREAM_TYPE_REDIRECT) { c->http_error = 301; q = c->buffer; q += snprintf(q, q - (char *) c->buffer + c->buffer_size, "HTTP/1.0 301 Moved\r\n"); q += snprintf(q, q - (char *) c->buffer + c->buffer_size, "Location: %s\r\n", stream->feed_filename); q += snprintf(q, q - (char *) c->buffer + c->buffer_size, "Content-type: text/html\r\n"); q += snprintf(q, q - (char *) c->buffer + c->buffer_size, "\r\n"); q += snprintf(q, q - (char *) c->buffer + c->buffer_size, "<html><head><title>Moved</title></head><body>\r\n"); q += snprintf(q, q - (char *) c->buffer + c->buffer_size, "You should be <a href=\"%s\">redirected</a>.\r\n", stream->feed_filename); q += snprintf(q, q - (char *) c->buffer + c->buffer_size, "</body></html>\r\n"); /* prepare output buffer */ c->buffer_ptr = c->buffer; c->buffer_end = q; c->state = HTTPSTATE_SEND_HEADER; return 0; } /* If this is WMP, get the rate information */ if (extract_rates(ratebuf, sizeof(ratebuf), c->buffer)) { if (modify_current_stream(c, ratebuf)) { for (i = 0; i < sizeof(c->feed_streams) / sizeof(c->feed_streams[0]); i++) { if (c->switch_feed_streams[i] >= 0) do_switch_stream(c, i); } } } if (post == 0 && stream->stream_type == STREAM_TYPE_LIVE) { current_bandwidth += stream->bandwidth; } if (post == 0 && max_bandwidth < current_bandwidth) { c->http_error = 200; q = c->buffer; q += snprintf(q, q - (char *) c->buffer + c->buffer_size, "HTTP/1.0 200 Server too busy\r\n"); q += snprintf(q, q - (char *) c->buffer + c->buffer_size, "Content-type: text/html\r\n"); q += snprintf(q, q - (char *) c->buffer + c->buffer_size, "\r\n"); q += snprintf(q, q - (char *) c->buffer + c->buffer_size, "<html><head><title>Too busy</title></head><body>\r\n"); q += snprintf(q, q - (char *) c->buffer + c->buffer_size, "The server is too busy to serve your request at this time.<p>\r\n"); q += snprintf(q, q - (char *) c->buffer + c->buffer_size, "The bandwidth being served (including your stream) is %dkbit/sec, and this exceeds the limit of %dkbit/sec\r\n", current_bandwidth, max_bandwidth); q += snprintf(q, q - (char *) c->buffer + c->buffer_size, "</body></html>\r\n"); /* prepare output buffer */ c->buffer_ptr = c->buffer; c->buffer_end = q; c->state = HTTPSTATE_SEND_HEADER; return 0; } if (redir_type != REDIR_NONE) { char *hostinfo = 0; for (p = c->buffer; *p && *p != '\r' && *p != '\n'; ) { if (strncasecmp(p, "Host:", 5) == 0) { hostinfo = p + 5; break; } p = strchr(p, '\n'); if (!p) break; p++; } if (hostinfo) { char *eoh; char hostbuf[260]; while (isspace(*hostinfo)) hostinfo++; eoh = strchr(hostinfo, '\n'); if (eoh) { if (eoh[-1] == '\r') eoh--; if (eoh - hostinfo < sizeof(hostbuf) - 1) { memcpy(hostbuf, hostinfo, eoh - hostinfo); hostbuf[eoh - hostinfo] = 0; c->http_error = 200; q = c->buffer; switch(redir_type) { case REDIR_ASX: q += snprintf(q, q - (char *) c->buffer + c->buffer_size, "HTTP/1.0 200 ASX Follows\r\n"); q += snprintf(q, q - (char *) c->buffer + c->buffer_size, "Content-type: video/x-ms-asf\r\n"); q += snprintf(q, q - (char *) c->buffer + c->buffer_size, "\r\n"); q += snprintf(q, q - (char *) c->buffer + c->buffer_size, "<ASX Version=\"3\">\r\n"); //q += snprintf(q, q - (char *) c->buffer + c->buffer_size, "<!-- Autogenerated by ffserver -->\r\n"); q += snprintf(q, q - (char *) c->buffer + c->buffer_size, "<ENTRY><REF HREF=\"http://%s/%s%s\"/></ENTRY>\r\n", hostbuf, filename, info); q += snprintf(q, q - (char *) c->buffer + c->buffer_size, "</ASX>\r\n"); break; case REDIR_RAM: q += snprintf(q, q - (char *) c->buffer + c->buffer_size, "HTTP/1.0 200 RAM Follows\r\n"); q += snprintf(q, q - (char *) c->buffer + c->buffer_size, "Content-type: audio/x-pn-realaudio\r\n"); q += snprintf(q, q - (char *) c->buffer + c->buffer_size, "\r\n"); q += snprintf(q, q - (char *) c->buffer + c->buffer_size, "# Autogenerated by ffserver\r\n"); q += snprintf(q, q - (char *) c->buffer + c->buffer_size, "http://%s/%s%s\r\n", hostbuf, filename, info); break; case REDIR_ASF: q += snprintf(q, q - (char *) c->buffer + c->buffer_size, "HTTP/1.0 200 ASF Redirect follows\r\n"); q += snprintf(q, q - (char *) c->buffer + c->buffer_size, "Content-type: video/x-ms-asf\r\n"); q += snprintf(q, q - (char *) c->buffer + c->buffer_size, "\r\n"); q += snprintf(q, q - (char *) c->buffer + c->buffer_size, "[Reference]\r\n"); q += snprintf(q, q - (char *) c->buffer + c->buffer_size, "Ref1=http://%s/%s%s\r\n", hostbuf, filename, info); break; case REDIR_RTSP: { char hostname[256], *p; /* extract only hostname */ pstrcpy(hostname, sizeof(hostname), hostbuf); p = strrchr(hostname, ':'); if (p) *p = '\0'; q += snprintf(q, q - (char *) c->buffer + c->buffer_size, "HTTP/1.0 200 RTSP Redirect follows\r\n"); /* XXX: incorrect mime type ? */ q += snprintf(q, q - (char *) c->buffer + c->buffer_size, "Content-type: application/x-rtsp\r\n"); q += snprintf(q, q - (char *) c->buffer + c->buffer_size, "\r\n"); q += snprintf(q, q - (char *) c->buffer + c->buffer_size, "rtsp://%s:%d/%s\r\n", hostname, ntohs(my_rtsp_addr.sin_port), filename); } break; case REDIR_SDP: { uint8_t *sdp_data; int sdp_data_size, len; struct sockaddr_in my_addr; q += snprintf(q, q - (char *) c->buffer + c->buffer_size, "HTTP/1.0 200 OK\r\n"); q += snprintf(q, q - (char *) c->buffer + c->buffer_size, "Content-type: application/sdp\r\n"); q += snprintf(q, q - (char *) c->buffer + c->buffer_size, "\r\n"); len = sizeof(my_addr); getsockname(c->fd, (struct sockaddr *)&my_addr, &len); /* XXX: should use a dynamic buffer */ sdp_data_size = prepare_sdp_description(stream, &sdp_data, my_addr.sin_addr); if (sdp_data_size > 0) { memcpy(q, sdp_data, sdp_data_size); q += sdp_data_size; *q = '\0'; av_free(sdp_data); } } break; default: av_abort(); break; } /* prepare output buffer */ c->buffer_ptr = c->buffer; c->buffer_end = q; c->state = HTTPSTATE_SEND_HEADER; return 0; } } } snprintf(msg, sizeof(msg), "ASX/RAM file not handled"); goto send_error; } stream->conns_served++; /* XXX: add there authenticate and IP match */ if (post) { /* if post, it means a feed is being sent */ if (!stream->is_feed) { /* However it might be a status report from WMP! Lets log the data * as it might come in handy one day */ char *logline = 0; int client_id = 0; for (p = c->buffer; *p && *p != '\r' && *p != '\n'; ) { if (strncasecmp(p, "Pragma: log-line=", 17) == 0) { logline = p; break; } if (strncasecmp(p, "Pragma: client-id=", 18) == 0) { client_id = strtol(p + 18, 0, 10); } p = strchr(p, '\n'); if (!p) break; p++; } if (logline) { char *eol = strchr(logline, '\n'); logline += 17; if (eol) { if (eol[-1] == '\r') eol--; http_log("%.*s\n", (int) (eol - logline), logline); c->suppress_log = 1; } } #ifdef DEBUG_WMP http_log("\nGot request:\n%s\n", c->buffer); #endif if (client_id && extract_rates(ratebuf, sizeof(ratebuf), c->buffer)) { HTTPContext *wmpc; /* Now we have to find the client_id */ for (wmpc = first_http_ctx; wmpc; wmpc = wmpc->next) { if (wmpc->wmp_client_id == client_id) break; } if (wmpc) { if (modify_current_stream(wmpc, ratebuf)) { wmpc->switch_pending = 1; } } } snprintf(msg, sizeof(msg), "POST command not handled"); c->stream = 0; goto send_error; } if (http_start_receive_data(c) < 0) { snprintf(msg, sizeof(msg), "could not open feed"); goto send_error; } c->http_error = 0; c->state = HTTPSTATE_RECEIVE_DATA; return 0; } #ifdef DEBUG_WMP if (strcmp(stream->filename + strlen(stream->filename) - 4, ".asf") == 0) { http_log("\nGot request:\n%s\n", c->buffer); } #endif if (c->stream->stream_type == STREAM_TYPE_STATUS) goto send_stats; /* open input stream */ if (open_input_stream(c, info) < 0) { snprintf(msg, sizeof(msg), "Input stream corresponding to '%s' not found", url); goto send_error; } /* prepare http header */ q = c->buffer; q += snprintf(q, q - (char *) c->buffer + c->buffer_size, "HTTP/1.0 200 OK\r\n"); mime_type = c->stream->fmt->mime_type; if (!mime_type) mime_type = "application/x-octet_stream"; q += snprintf(q, q - (char *) c->buffer + c->buffer_size, "Pragma: no-cache\r\n"); /* for asf, we need extra headers */ if (!strcmp(c->stream->fmt->name,"asf_stream")) { /* Need to allocate a client id */ c->wmp_client_id = random() & 0x7fffffff; q += snprintf(q, q - (char *) c->buffer + c->buffer_size, "Server: Cougar 4.1.0.3923\r\nCache-Control: no-cache\r\nPragma: client-id=%d\r\nPragma: features=\"broadcast\"\r\n", c->wmp_client_id); } q += snprintf(q, q - (char *) c->buffer + c->buffer_size, "Content-Type: %s\r\n", mime_type); q += snprintf(q, q - (char *) c->buffer + c->buffer_size, "\r\n"); /* prepare output buffer */ c->http_error = 0; c->buffer_ptr = c->buffer; c->buffer_end = q; c->state = HTTPSTATE_SEND_HEADER; return 0; send_error: c->http_error = 404; q = c->buffer; q += snprintf(q, q - (char *) c->buffer + c->buffer_size, "HTTP/1.0 404 Not Found\r\n"); q += snprintf(q, q - (char *) c->buffer + c->buffer_size, "Content-type: %s\r\n", "text/html"); q += snprintf(q, q - (char *) c->buffer + c->buffer_size, "\r\n"); q += snprintf(q, q - (char *) c->buffer + c->buffer_size, "<HTML>\n"); q += snprintf(q, q - (char *) c->buffer + c->buffer_size, "<HEAD><TITLE>404 Not Found</TITLE></HEAD>\n"); q += snprintf(q, q - (char *) c->buffer + c->buffer_size, "<BODY>%s</BODY>\n", msg); q += snprintf(q, q - (char *) c->buffer + c->buffer_size, "</HTML>\n"); /* prepare output buffer */ c->buffer_ptr = c->buffer; c->buffer_end = q; c->state = HTTPSTATE_SEND_HEADER; return 0; send_stats: compute_stats(c); c->http_error = 200; /* horrible : we use this value to avoid going to the send data state */ c->state = HTTPSTATE_SEND_HEADER; return 0; } static void fmt_bytecount(ByteIOContext *pb, int64_t count) { static const char *suffix = " kMGTP"; const char *s; for (s = suffix; count >= 100000 && s[1]; count /= 1000, s++) { } url_fprintf(pb, "%lld%c", count, *s); } static void compute_stats(HTTPContext *c) { HTTPContext *c1; FFStream *stream; char *p; time_t ti; int i, len; ByteIOContext pb1, *pb = &pb1; if (url_open_dyn_buf(pb) < 0) { /* XXX: return an error ? */ c->buffer_ptr = c->buffer; c->buffer_end = c->buffer; return; } url_fprintf(pb, "HTTP/1.0 200 OK\r\n"); url_fprintf(pb, "Content-type: %s\r\n", "text/html"); url_fprintf(pb, "Pragma: no-cache\r\n"); url_fprintf(pb, "\r\n"); url_fprintf(pb, "<HEAD><TITLE>FFServer Status</TITLE>\n"); if (c->stream->feed_filename) { url_fprintf(pb, "<link rel=\"shortcut icon\" href=\"%s\">\n", c->stream->feed_filename); } url_fprintf(pb, "</HEAD>\n<BODY>"); url_fprintf(pb, "<H1>FFServer Status</H1>\n"); /* format status */ url_fprintf(pb, "<H2>Available Streams</H2>\n"); url_fprintf(pb, "<TABLE cellspacing=0 cellpadding=4>\n"); url_fprintf(pb, "<TR><Th valign=top>Path<th align=left>Served<br>Conns<Th><br>bytes<Th valign=top>Format<Th>Bit rate<br>kbits/s<Th align=left>Video<br>kbits/s<th><br>Codec<Th align=left>Audio<br>kbits/s<th><br>Codec<Th align=left valign=top>Feed\n"); stream = first_stream; while (stream != NULL) { char sfilename[1024]; char *eosf; if (stream->feed != stream) { pstrcpy(sfilename, sizeof(sfilename) - 10, stream->filename); eosf = sfilename + strlen(sfilename); if (eosf - sfilename >= 4) { if (strcmp(eosf - 4, ".asf") == 0) { strcpy(eosf - 4, ".asx"); } else if (strcmp(eosf - 3, ".rm") == 0) { strcpy(eosf - 3, ".ram"); } else if (stream->fmt == &rtp_mux) { /* generate a sample RTSP director if unicast. Generate an SDP redirector if multicast */ eosf = strrchr(sfilename, '.'); if (!eosf) eosf = sfilename + strlen(sfilename); if (stream->is_multicast) strcpy(eosf, ".sdp"); else strcpy(eosf, ".rtsp"); } } url_fprintf(pb, "<TR><TD><A HREF=\"/%s\">%s</A> ", sfilename, stream->filename); url_fprintf(pb, "<td align=right> %d <td align=right> ", stream->conns_served); fmt_bytecount(pb, stream->bytes_served); switch(stream->stream_type) { case STREAM_TYPE_LIVE: { int audio_bit_rate = 0; int video_bit_rate = 0; const char *audio_codec_name = ""; const char *video_codec_name = ""; const char *audio_codec_name_extra = ""; const char *video_codec_name_extra = ""; for(i=0;i<stream->nb_streams;i++) { AVStream *st = stream->streams[i]; AVCodec *codec = avcodec_find_encoder(st->codec.codec_id); switch(st->codec.codec_type) { case CODEC_TYPE_AUDIO: audio_bit_rate += st->codec.bit_rate; if (codec) { if (*audio_codec_name) audio_codec_name_extra = "..."; audio_codec_name = codec->name; } break; case CODEC_TYPE_VIDEO: video_bit_rate += st->codec.bit_rate; if (codec) { if (*video_codec_name) video_codec_name_extra = "..."; video_codec_name = codec->name; } break; case CODEC_TYPE_DATA: video_bit_rate += st->codec.bit_rate; break; default: av_abort(); } } url_fprintf(pb, "<TD align=center> %s <TD align=right> %d <TD align=right> %d <TD> %s %s <TD align=right> %d <TD> %s %s", stream->fmt->name, stream->bandwidth, video_bit_rate / 1000, video_codec_name, video_codec_name_extra, audio_bit_rate / 1000, audio_codec_name, audio_codec_name_extra); if (stream->feed) { url_fprintf(pb, "<TD>%s", stream->feed->filename); } else { url_fprintf(pb, "<TD>%s", stream->feed_filename); } url_fprintf(pb, "\n"); } break; default: url_fprintf(pb, "<TD align=center> - <TD align=right> - <TD align=right> - <td><td align=right> - <TD>\n"); break; } } stream = stream->next; } url_fprintf(pb, "</TABLE>\n"); stream = first_stream; while (stream != NULL) { if (stream->feed == stream) { url_fprintf(pb, "<h2>Feed %s</h2>", stream->filename); if (stream->pid) { url_fprintf(pb, "Running as pid %d.\n", stream->pid); #if defined(linux) && !defined(CONFIG_NOCUTILS) { FILE *pid_stat; char ps_cmd[64]; /* This is somewhat linux specific I guess */ snprintf(ps_cmd, sizeof(ps_cmd), "ps -o \"%%cpu,cputime\" --no-headers %d", stream->pid); pid_stat = popen(ps_cmd, "r"); if (pid_stat) { char cpuperc[10]; char cpuused[64]; if (fscanf(pid_stat, "%10s %64s", cpuperc, cpuused) == 2) { url_fprintf(pb, "Currently using %s%% of the cpu. Total time used %s.\n", cpuperc, cpuused); } fclose(pid_stat); } } #endif url_fprintf(pb, "<p>"); } url_fprintf(pb, "<table cellspacing=0 cellpadding=4><tr><th>Stream<th>type<th>kbits/s<th align=left>codec<th align=left>Parameters\n"); for (i = 0; i < stream->nb_streams; i++) { AVStream *st = stream->streams[i]; AVCodec *codec = avcodec_find_encoder(st->codec.codec_id); const char *type = "unknown"; char parameters[64]; parameters[0] = 0; switch(st->codec.codec_type) { case CODEC_TYPE_AUDIO: type = "audio"; break; case CODEC_TYPE_VIDEO: type = "video"; snprintf(parameters, sizeof(parameters), "%dx%d, q=%d-%d, fps=%d", st->codec.width, st->codec.height, st->codec.qmin, st->codec.qmax, st->codec.frame_rate / st->codec.frame_rate_base); break; default: av_abort(); } url_fprintf(pb, "<tr><td align=right>%d<td>%s<td align=right>%d<td>%s<td>%s\n", i, type, st->codec.bit_rate/1000, codec ? codec->name : "", parameters); } url_fprintf(pb, "</table>\n"); } stream = stream->next; } #if 0 { float avg; AVCodecContext *enc; char buf[1024]; /* feed status */ stream = first_feed; while (stream != NULL) { url_fprintf(pb, "<H1>Feed '%s'</H1>\n", stream->filename); url_fprintf(pb, "<TABLE>\n"); url_fprintf(pb, "<TR><TD>Parameters<TD>Frame count<TD>Size<TD>Avg bitrate (kbits/s)\n"); for(i=0;i<stream->nb_streams;i++) { AVStream *st = stream->streams[i]; FeedData *fdata = st->priv_data; enc = &st->codec; avcodec_string(buf, sizeof(buf), enc); avg = fdata->avg_frame_size * (float)enc->rate * 8.0; if (enc->codec->type == CODEC_TYPE_AUDIO && enc->frame_size > 0) avg /= enc->frame_size; url_fprintf(pb, "<TR><TD>%s <TD> %d <TD> %Ld <TD> %0.1f\n", buf, enc->frame_number, fdata->data_count, avg / 1000.0); } url_fprintf(pb, "</TABLE>\n"); stream = stream->next_feed; } } #endif /* connection status */ url_fprintf(pb, "<H2>Connection Status</H2>\n"); url_fprintf(pb, "Number of connections: %d / %d<BR>\n", nb_connections, nb_max_connections); url_fprintf(pb, "Bandwidth in use: %dk / %dk<BR>\n", current_bandwidth, max_bandwidth); url_fprintf(pb, "<TABLE>\n"); url_fprintf(pb, "<TR><th>#<th>File<th>IP<th>Proto<th>State<th>Target bits/sec<th>Actual bits/sec<th>Bytes transferred\n"); c1 = first_http_ctx; i = 0; while (c1 != NULL) { int bitrate; int j; bitrate = 0; if (c1->stream) { for (j = 0; j < c1->stream->nb_streams; j++) { if (!c1->stream->feed) { bitrate += c1->stream->streams[j]->codec.bit_rate; } else { if (c1->feed_streams[j] >= 0) { bitrate += c1->stream->feed->streams[c1->feed_streams[j]]->codec.bit_rate; } } } } i++; p = inet_ntoa(c1->from_addr.sin_addr); url_fprintf(pb, "<TR><TD><B>%d</B><TD>%s%s<TD>%s<TD>%s<TD>%s<td align=right>", i, c1->stream ? c1->stream->filename : "", c1->state == HTTPSTATE_RECEIVE_DATA ? "(input)" : "", p, c1->protocol, http_state[c1->state]); fmt_bytecount(pb, bitrate); url_fprintf(pb, "<td align=right>"); fmt_bytecount(pb, compute_datarate(&c1->datarate, c1->data_count) * 8); url_fprintf(pb, "<td align=right>"); fmt_bytecount(pb, c1->data_count); url_fprintf(pb, "\n"); c1 = c1->next; } url_fprintf(pb, "</TABLE>\n"); /* date */ ti = time(NULL); p = ctime(&ti); url_fprintf(pb, "<HR size=1 noshade>Generated at %s", p); url_fprintf(pb, "</BODY>\n</HTML>\n"); len = url_close_dyn_buf(pb, &c->pb_buffer); c->buffer_ptr = c->pb_buffer; c->buffer_end = c->pb_buffer + len; } /* check if the parser needs to be opened for stream i */ static void open_parser(AVFormatContext *s, int i) { AVStream *st = s->streams[i]; AVCodec *codec; if (!st->codec.codec) { codec = avcodec_find_decoder(st->codec.codec_id); if (codec && (codec->capabilities & CODEC_CAP_PARSE_ONLY)) { st->codec.parse_only = 1; if (avcodec_open(&st->codec, codec) < 0) { st->codec.parse_only = 0; } } } } static int open_input_stream(HTTPContext *c, const char *info) { char buf[128]; char input_filename[1024]; AVFormatContext *s; int buf_size, i; int64_t stream_pos; /* find file name */ if (c->stream->feed) { strcpy(input_filename, c->stream->feed->feed_filename); buf_size = FFM_PACKET_SIZE; /* compute position (absolute time) */ if (find_info_tag(buf, sizeof(buf), "date", info)) { stream_pos = parse_date(buf, 0); } else if (find_info_tag(buf, sizeof(buf), "buffer", info)) { int prebuffer = strtol(buf, 0, 10); stream_pos = av_gettime() - prebuffer * (int64_t)1000000; } else { stream_pos = av_gettime() - c->stream->prebuffer * (int64_t)1000; } } else { strcpy(input_filename, c->stream->feed_filename); buf_size = 0; /* compute position (relative time) */ if (find_info_tag(buf, sizeof(buf), "date", info)) { stream_pos = parse_date(buf, 1); } else { stream_pos = 0; } } if (input_filename[0] == '\0') return -1; #if 0 { time_t when = stream_pos / 1000000; http_log("Stream pos = %lld, time=%s", stream_pos, ctime(&when)); } #endif /* open stream */ if (av_open_input_file(&s, input_filename, c->stream->ifmt, buf_size, c->stream->ap_in) < 0) { http_log("%s not found", input_filename); return -1; } c->fmt_in = s; /* open each parser */ for(i=0;i<s->nb_streams;i++) open_parser(s, i); /* choose stream as clock source (we favorize video stream if present) for packet sending */ c->pts_stream_index = 0; for(i=0;i<c->stream->nb_streams;i++) { if (c->pts_stream_index == 0 && c->stream->streams[i]->codec.codec_type == CODEC_TYPE_VIDEO) { c->pts_stream_index = i; } } #if 0 if (c->fmt_in->iformat->read_seek) { c->fmt_in->iformat->read_seek(c->fmt_in, stream_pos); } #endif /* set the start time (needed for maxtime and RTP packet timing) */ c->start_time = cur_time; c->first_pts = AV_NOPTS_VALUE; return 0; } /* return the server clock (in us) */ static int64_t get_server_clock(HTTPContext *c) { /* compute current pts value from system time */ return (int64_t)(cur_time - c->start_time) * 1000LL; } /* return the estimated time at which the current packet must be sent (in us) */ static int64_t get_packet_send_clock(HTTPContext *c) { int bytes_left, bytes_sent, frame_bytes; frame_bytes = c->cur_frame_bytes; if (frame_bytes <= 0) { return c->cur_pts; } else { bytes_left = c->buffer_end - c->buffer_ptr; bytes_sent = frame_bytes - bytes_left; return c->cur_pts + (c->cur_frame_duration * bytes_sent) / frame_bytes; } } static int http_prepare_data(HTTPContext *c) { int i, len, ret; AVFormatContext *ctx; av_freep(&c->pb_buffer); switch(c->state) { case HTTPSTATE_SEND_DATA_HEADER: memset(&c->fmt_ctx, 0, sizeof(c->fmt_ctx)); pstrcpy(c->fmt_ctx.author, sizeof(c->fmt_ctx.author), c->stream->author); pstrcpy(c->fmt_ctx.comment, sizeof(c->fmt_ctx.comment), c->stream->comment); pstrcpy(c->fmt_ctx.copyright, sizeof(c->fmt_ctx.copyright), c->stream->copyright); pstrcpy(c->fmt_ctx.title, sizeof(c->fmt_ctx.title), c->stream->title); /* open output stream by using specified codecs */ c->fmt_ctx.oformat = c->stream->fmt; c->fmt_ctx.nb_streams = c->stream->nb_streams; for(i=0;i<c->fmt_ctx.nb_streams;i++) { AVStream *st; AVStream *src; st = av_mallocz(sizeof(AVStream)); c->fmt_ctx.streams[i] = st; /* if file or feed, then just take streams from FFStream struct */ if (!c->stream->feed || c->stream->feed == c->stream) src = c->stream->streams[i]; else src = c->stream->feed->streams[c->stream->feed_streams[i]]; *st = *src; st->priv_data = 0; st->codec.frame_number = 0; /* XXX: should be done in AVStream, not in codec */ /* I'm pretty sure that this is not correct... * However, without it, we crash */ st->codec.coded_frame = &dummy_frame; } c->got_key_frame = 0; /* prepare header and save header data in a stream */ if (url_open_dyn_buf(&c->fmt_ctx.pb) < 0) { /* XXX: potential leak */ return -1; } c->fmt_ctx.pb.is_streamed = 1; av_set_parameters(&c->fmt_ctx, NULL); av_write_header(&c->fmt_ctx); len = url_close_dyn_buf(&c->fmt_ctx.pb, &c->pb_buffer); c->buffer_ptr = c->pb_buffer; c->buffer_end = c->pb_buffer + len; c->state = HTTPSTATE_SEND_DATA; c->last_packet_sent = 0; break; case HTTPSTATE_SEND_DATA: /* find a new packet */ { AVPacket pkt; /* read a packet from the input stream */ if (c->stream->feed) { ffm_set_write_index(c->fmt_in, c->stream->feed->feed_write_index, c->stream->feed->feed_size); } if (c->stream->max_time && c->stream->max_time + c->start_time - cur_time < 0) { /* We have timed out */ c->state = HTTPSTATE_SEND_DATA_TRAILER; } else { redo: if (av_read_frame(c->fmt_in, &pkt) < 0) { if (c->stream->feed && c->stream->feed->feed_opened) { /* if coming from feed, it means we reached the end of the ffm file, so must wait for more data */ c->state = HTTPSTATE_WAIT_FEED; return 1; /* state changed */ } else { if (c->stream->loop) { av_close_input_file(c->fmt_in); c->fmt_in = NULL; if (open_input_stream(c, "") < 0) goto no_loop; goto redo; } else { no_loop: /* must send trailer now because eof or error */ c->state = HTTPSTATE_SEND_DATA_TRAILER; } } } else { /* update first pts if needed */ if (c->first_pts == AV_NOPTS_VALUE) { c->first_pts = pkt.dts; c->start_time = cur_time; } /* send it to the appropriate stream */ if (c->stream->feed) { /* if coming from a feed, select the right stream */ if (c->switch_pending) { c->switch_pending = 0; for(i=0;i<c->stream->nb_streams;i++) { if (c->switch_feed_streams[i] == pkt.stream_index) { if (pkt.flags & PKT_FLAG_KEY) { do_switch_stream(c, i); } } if (c->switch_feed_streams[i] >= 0) { c->switch_pending = 1; } } } for(i=0;i<c->stream->nb_streams;i++) { if (c->feed_streams[i] == pkt.stream_index) { pkt.stream_index = i; if (pkt.flags & PKT_FLAG_KEY) { c->got_key_frame |= 1 << i; } /* See if we have all the key frames, then * we start to send. This logic is not quite * right, but it works for the case of a * single video stream with one or more * audio streams (for which every frame is * typically a key frame). */ if (!c->stream->send_on_key || ((c->got_key_frame + 1) >> c->stream->nb_streams)) { goto send_it; } } } } else { AVCodecContext *codec; send_it: /* specific handling for RTP: we use several output stream (one for each RTP connection). XXX: need more abstract handling */ if (c->is_packetized) { AVStream *st; /* compute send time and duration */ st = c->fmt_in->streams[pkt.stream_index]; c->cur_pts = pkt.dts; if (st->start_time != AV_NOPTS_VALUE) c->cur_pts -= st->start_time; c->cur_frame_duration = pkt.duration; #if 0 printf("index=%d pts=%0.3f duration=%0.6f\n", pkt.stream_index, (double)c->cur_pts / AV_TIME_BASE, (double)c->cur_frame_duration / AV_TIME_BASE); #endif /* find RTP context */ c->packet_stream_index = pkt.stream_index; ctx = c->rtp_ctx[c->packet_stream_index]; if(!ctx) { av_free_packet(&pkt); break; } codec = &ctx->streams[0]->codec; /* only one stream per RTP connection */ pkt.stream_index = 0; } else { ctx = &c->fmt_ctx; /* Fudge here */ codec = &ctx->streams[pkt.stream_index]->codec; } codec->coded_frame->key_frame = ((pkt.flags & PKT_FLAG_KEY) != 0); if (c->is_packetized) { int max_packet_size; if (c->rtp_protocol == RTSP_PROTOCOL_RTP_TCP) max_packet_size = RTSP_TCP_MAX_PACKET_SIZE; else max_packet_size = url_get_max_packet_size(c->rtp_handles[c->packet_stream_index]); ret = url_open_dyn_packet_buf(&ctx->pb, max_packet_size); } else { ret = url_open_dyn_buf(&ctx->pb); } if (ret < 0) { /* XXX: potential leak */ return -1; } if (av_write_frame(ctx, &pkt)) { c->state = HTTPSTATE_SEND_DATA_TRAILER; } len = url_close_dyn_buf(&ctx->pb, &c->pb_buffer); c->cur_frame_bytes = len; c->buffer_ptr = c->pb_buffer; c->buffer_end = c->pb_buffer + len; codec->frame_number++; if (len == 0) goto redo; } av_free_packet(&pkt); } } } break; default: case HTTPSTATE_SEND_DATA_TRAILER: /* last packet test ? */ if (c->last_packet_sent || c->is_packetized) return -1; ctx = &c->fmt_ctx; /* prepare header */ if (url_open_dyn_buf(&ctx->pb) < 0) { /* XXX: potential leak */ return -1; } av_write_trailer(ctx); len = url_close_dyn_buf(&ctx->pb, &c->pb_buffer); c->buffer_ptr = c->pb_buffer; c->buffer_end = c->pb_buffer + len; c->last_packet_sent = 1; break; } return 0; } /* in bit/s */ #define SHORT_TERM_BANDWIDTH 8000000 /* should convert the format at the same time */ /* send data starting at c->buffer_ptr to the output connection (either UDP or TCP connection) */ static int http_send_data(HTTPContext *c) { int len, ret; for(;;) { if (c->buffer_ptr >= c->buffer_end) { ret = http_prepare_data(c); if (ret < 0) return -1; else if (ret != 0) { /* state change requested */ break; } } else { if (c->is_packetized) { /* RTP data output */ len = c->buffer_end - c->buffer_ptr; if (len < 4) { /* fail safe - should never happen */ fail1: c->buffer_ptr = c->buffer_end; return 0; } len = (c->buffer_ptr[0] << 24) | (c->buffer_ptr[1] << 16) | (c->buffer_ptr[2] << 8) | (c->buffer_ptr[3]); if (len > (c->buffer_end - c->buffer_ptr)) goto fail1; if ((get_packet_send_clock(c) - get_server_clock(c)) > 0) { /* nothing to send yet: we can wait */ return 0; } c->data_count += len; update_datarate(&c->datarate, c->data_count); if (c->stream) c->stream->bytes_served += len; if (c->rtp_protocol == RTSP_PROTOCOL_RTP_TCP) { /* RTP packets are sent inside the RTSP TCP connection */ ByteIOContext pb1, *pb = &pb1; int interleaved_index, size; uint8_t header[4]; HTTPContext *rtsp_c; rtsp_c = c->rtsp_c; /* if no RTSP connection left, error */ if (!rtsp_c) return -1; /* if already sending something, then wait. */ if (rtsp_c->state != RTSPSTATE_WAIT_REQUEST) { break; } if (url_open_dyn_buf(pb) < 0) goto fail1; interleaved_index = c->packet_stream_index * 2; /* RTCP packets are sent at odd indexes */ if (c->buffer_ptr[1] == 200) interleaved_index++; /* write RTSP TCP header */ header[0] = '$'; header[1] = interleaved_index; header[2] = len >> 8; header[3] = len; put_buffer(pb, header, 4); /* write RTP packet data */ c->buffer_ptr += 4; put_buffer(pb, c->buffer_ptr, len); size = url_close_dyn_buf(pb, &c->packet_buffer); /* prepare asynchronous TCP sending */ rtsp_c->packet_buffer_ptr = c->packet_buffer; rtsp_c->packet_buffer_end = c->packet_buffer + size; c->buffer_ptr += len; /* send everything we can NOW */ len = write(rtsp_c->fd, rtsp_c->packet_buffer_ptr, rtsp_c->packet_buffer_end - rtsp_c->packet_buffer_ptr); if (len > 0) { rtsp_c->packet_buffer_ptr += len; } if (rtsp_c->packet_buffer_ptr < rtsp_c->packet_buffer_end) { /* if we could not send all the data, we will send it later, so a new state is needed to "lock" the RTSP TCP connection */ rtsp_c->state = RTSPSTATE_SEND_PACKET; break; } else { /* all data has been sent */ av_freep(&c->packet_buffer); } } else { /* send RTP packet directly in UDP */ c->buffer_ptr += 4; url_write(c->rtp_handles[c->packet_stream_index], c->buffer_ptr, len); c->buffer_ptr += len; /* here we continue as we can send several packets per 10 ms slot */ } } else { /* TCP data output */ len = write(c->fd, c->buffer_ptr, c->buffer_end - c->buffer_ptr); if (len < 0) { if (errno != EAGAIN && errno != EINTR) { /* error : close connection */ return -1; } else { return 0; } } else { c->buffer_ptr += len; } c->data_count += len; update_datarate(&c->datarate, c->data_count); if (c->stream) c->stream->bytes_served += len; break; } } } /* for(;;) */ return 0; } static int http_start_receive_data(HTTPContext *c) { int fd; if (c->stream->feed_opened) return -1; /* Don't permit writing to this one */ if (c->stream->readonly) return -1; /* open feed */ fd = open(c->stream->feed_filename, O_RDWR); if (fd < 0) return -1; c->feed_fd = fd; c->stream->feed_write_index = ffm_read_write_index(fd); c->stream->feed_size = lseek(fd, 0, SEEK_END); lseek(fd, 0, SEEK_SET); /* init buffer input */ c->buffer_ptr = c->buffer; c->buffer_end = c->buffer + FFM_PACKET_SIZE; c->stream->feed_opened = 1; return 0; } static int http_receive_data(HTTPContext *c) { HTTPContext *c1; if (c->buffer_end > c->buffer_ptr) { int len; len = read(c->fd, c->buffer_ptr, c->buffer_end - c->buffer_ptr); if (len < 0) { if (errno != EAGAIN && errno != EINTR) { /* error : close connection */ goto fail; } } else if (len == 0) { /* end of connection : close it */ goto fail; } else { c->buffer_ptr += len; c->data_count += len; update_datarate(&c->datarate, c->data_count); } } if (c->buffer_ptr - c->buffer >= 2 && c->data_count > FFM_PACKET_SIZE) { if (c->buffer[0] != 'f' || c->buffer[1] != 'm') { http_log("Feed stream has become desynchronized -- disconnecting\n"); goto fail; } } if (c->buffer_ptr >= c->buffer_end) { FFStream *feed = c->stream; /* a packet has been received : write it in the store, except if header */ if (c->data_count > FFM_PACKET_SIZE) { // printf("writing pos=0x%Lx size=0x%Lx\n", feed->feed_write_index, feed->feed_size); /* XXX: use llseek or url_seek */ lseek(c->feed_fd, feed->feed_write_index, SEEK_SET); write(c->feed_fd, c->buffer, FFM_PACKET_SIZE); feed->feed_write_index += FFM_PACKET_SIZE; /* update file size */ if (feed->feed_write_index > c->stream->feed_size) feed->feed_size = feed->feed_write_index; /* handle wrap around if max file size reached */ if (feed->feed_write_index >= c->stream->feed_max_size) feed->feed_write_index = FFM_PACKET_SIZE; /* write index */ ffm_write_write_index(c->feed_fd, feed->feed_write_index); /* wake up any waiting connections */ for(c1 = first_http_ctx; c1 != NULL; c1 = c1->next) { if (c1->state == HTTPSTATE_WAIT_FEED && c1->stream->feed == c->stream->feed) { c1->state = HTTPSTATE_SEND_DATA; } } } else { /* We have a header in our hands that contains useful data */ AVFormatContext s; AVInputFormat *fmt_in; ByteIOContext *pb = &s.pb; int i; memset(&s, 0, sizeof(s)); url_open_buf(pb, c->buffer, c->buffer_end - c->buffer, URL_RDONLY); pb->buf_end = c->buffer_end; /* ?? */ pb->is_streamed = 1; /* use feed output format name to find corresponding input format */ fmt_in = av_find_input_format(feed->fmt->name); if (!fmt_in) goto fail; if (fmt_in->priv_data_size > 0) { s.priv_data = av_mallocz(fmt_in->priv_data_size); if (!s.priv_data) goto fail; } else s.priv_data = NULL; if (fmt_in->read_header(&s, 0) < 0) { av_freep(&s.priv_data); goto fail; } /* Now we have the actual streams */ if (s.nb_streams != feed->nb_streams) { av_freep(&s.priv_data); goto fail; } for (i = 0; i < s.nb_streams; i++) { memcpy(&feed->streams[i]->codec, &s.streams[i]->codec, sizeof(AVCodecContext)); } av_freep(&s.priv_data); } c->buffer_ptr = c->buffer; } return 0; fail: c->stream->feed_opened = 0; close(c->feed_fd); return -1; } /********************************************************************/ /* RTSP handling */ static void rtsp_reply_header(HTTPContext *c, enum RTSPStatusCode error_number) { const char *str; time_t ti; char *p; char buf2[32]; switch(error_number) { #define DEF(n, c, s) case c: str = s; break; #include "rtspcodes.h" #undef DEF default: str = "Unknown Error"; break; } url_fprintf(c->pb, "RTSP/1.0 %d %s\r\n", error_number, str); url_fprintf(c->pb, "CSeq: %d\r\n", c->seq); /* output GMT time */ ti = time(NULL); p = ctime(&ti); strcpy(buf2, p); p = buf2 + strlen(p) - 1; if (*p == '\n') *p = '\0'; url_fprintf(c->pb, "Date: %s GMT\r\n", buf2); } static void rtsp_reply_error(HTTPContext *c, enum RTSPStatusCode error_number) { rtsp_reply_header(c, error_number); url_fprintf(c->pb, "\r\n"); } static int rtsp_parse_request(HTTPContext *c) { const char *p, *p1, *p2; char cmd[32]; char url[1024]; char protocol[32]; char line[1024]; ByteIOContext pb1; int len; RTSPHeader header1, *header = &header1; c->buffer_ptr[0] = '\0'; p = c->buffer; get_word(cmd, sizeof(cmd), &p); get_word(url, sizeof(url), &p); get_word(protocol, sizeof(protocol), &p); pstrcpy(c->method, sizeof(c->method), cmd); pstrcpy(c->url, sizeof(c->url), url); pstrcpy(c->protocol, sizeof(c->protocol), protocol); c->pb = &pb1; if (url_open_dyn_buf(c->pb) < 0) { /* XXX: cannot do more */ c->pb = NULL; /* safety */ return -1; } /* check version name */ if (strcmp(protocol, "RTSP/1.0") != 0) { rtsp_reply_error(c, RTSP_STATUS_VERSION); goto the_end; } /* parse each header line */ memset(header, 0, sizeof(RTSPHeader)); /* skip to next line */ while (*p != '\n' && *p != '\0') p++; if (*p == '\n') p++; while (*p != '\0') { p1 = strchr(p, '\n'); if (!p1) break; p2 = p1; if (p2 > p && p2[-1] == '\r') p2--; /* skip empty line */ if (p2 == p) break; len = p2 - p; if (len > sizeof(line) - 1) len = sizeof(line) - 1; memcpy(line, p, len); line[len] = '\0'; rtsp_parse_line(header, line); p = p1 + 1; } /* handle sequence number */ c->seq = header->seq; if (!strcmp(cmd, "DESCRIBE")) { rtsp_cmd_describe(c, url); } else if (!strcmp(cmd, "OPTIONS")) { rtsp_cmd_options(c, url); } else if (!strcmp(cmd, "SETUP")) { rtsp_cmd_setup(c, url, header); } else if (!strcmp(cmd, "PLAY")) { rtsp_cmd_play(c, url, header); } else if (!strcmp(cmd, "PAUSE")) { rtsp_cmd_pause(c, url, header); } else if (!strcmp(cmd, "TEARDOWN")) { rtsp_cmd_teardown(c, url, header); } else { rtsp_reply_error(c, RTSP_STATUS_METHOD); } the_end: len = url_close_dyn_buf(c->pb, &c->pb_buffer); c->pb = NULL; /* safety */ if (len < 0) { /* XXX: cannot do more */ return -1; } c->buffer_ptr = c->pb_buffer; c->buffer_end = c->pb_buffer + len; c->state = RTSPSTATE_SEND_REPLY; return 0; } /* XXX: move that to rtsp.c, but would need to replace FFStream by AVFormatContext */ static int prepare_sdp_description(FFStream *stream, uint8_t **pbuffer, struct in_addr my_ip) { ByteIOContext pb1, *pb = &pb1; int i, payload_type, port, private_payload_type, j; const char *ipstr, *title, *mediatype; AVStream *st; if (url_open_dyn_buf(pb) < 0) return -1; /* general media info */ url_fprintf(pb, "v=0\n"); ipstr = inet_ntoa(my_ip); url_fprintf(pb, "o=- 0 0 IN IP4 %s\n", ipstr); title = stream->title; if (title[0] == '\0') title = "No Title"; url_fprintf(pb, "s=%s\n", title); if (stream->comment[0] != '\0') url_fprintf(pb, "i=%s\n", stream->comment); if (stream->is_multicast) { url_fprintf(pb, "c=IN IP4 %s\n", inet_ntoa(stream->multicast_ip)); } /* for each stream, we output the necessary info */ private_payload_type = RTP_PT_PRIVATE; for(i = 0; i < stream->nb_streams; i++) { st = stream->streams[i]; if (st->codec.codec_id == CODEC_ID_MPEG2TS) { mediatype = "video"; } else { switch(st->codec.codec_type) { case CODEC_TYPE_AUDIO: mediatype = "audio"; break; case CODEC_TYPE_VIDEO: mediatype = "video"; break; default: mediatype = "application"; break; } } /* NOTE: the port indication is not correct in case of unicast. It is not an issue because RTSP gives it */ payload_type = rtp_get_payload_type(&st->codec); if (payload_type < 0) payload_type = private_payload_type++; if (stream->is_multicast) { port = stream->multicast_port + 2 * i; } else { port = 0; } url_fprintf(pb, "m=%s %d RTP/AVP %d\n", mediatype, port, payload_type); if (payload_type >= RTP_PT_PRIVATE) { /* for private payload type, we need to give more info */ switch(st->codec.codec_id) { case CODEC_ID_MPEG4: { uint8_t *data; url_fprintf(pb, "a=rtpmap:%d MP4V-ES/%d\n", payload_type, 90000); /* we must also add the mpeg4 header */ data = st->codec.extradata; if (data) { url_fprintf(pb, "a=fmtp:%d config=", payload_type); for(j=0;j<st->codec.extradata_size;j++) { url_fprintf(pb, "%02x", data[j]); } url_fprintf(pb, "\n"); } } break; default: /* XXX: add other codecs ? */ goto fail; } } url_fprintf(pb, "a=control:streamid=%d\n", i); } return url_close_dyn_buf(pb, pbuffer); fail: url_close_dyn_buf(pb, pbuffer); av_free(*pbuffer); return -1; } static void rtsp_cmd_options(HTTPContext *c, const char *url) { // rtsp_reply_header(c, RTSP_STATUS_OK); url_fprintf(c->pb, "RTSP/1.0 %d %s\r\n", RTSP_STATUS_OK, "OK"); url_fprintf(c->pb, "CSeq: %d\r\n", c->seq); url_fprintf(c->pb, "Public: %s\r\n", "OPTIONS, DESCRIBE, SETUP, TEARDOWN, PLAY, PAUSE"); url_fprintf(c->pb, "\r\n"); } static void rtsp_cmd_describe(HTTPContext *c, const char *url) { FFStream *stream; char path1[1024]; const char *path; uint8_t *content; int content_length, len; struct sockaddr_in my_addr; /* find which url is asked */ url_split(NULL, 0, NULL, 0, NULL, 0, NULL, path1, sizeof(path1), url); path = path1; if (*path == '/') path++; for(stream = first_stream; stream != NULL; stream = stream->next) { if (!stream->is_feed && stream->fmt == &rtp_mux && !strcmp(path, stream->filename)) { goto found; } } /* no stream found */ rtsp_reply_error(c, RTSP_STATUS_SERVICE); /* XXX: right error ? */ return; found: /* prepare the media description in sdp format */ /* get the host IP */ len = sizeof(my_addr); getsockname(c->fd, (struct sockaddr *)&my_addr, &len); content_length = prepare_sdp_description(stream, &content, my_addr.sin_addr); if (content_length < 0) { rtsp_reply_error(c, RTSP_STATUS_INTERNAL); return; } rtsp_reply_header(c, RTSP_STATUS_OK); url_fprintf(c->pb, "Content-Type: application/sdp\r\n"); url_fprintf(c->pb, "Content-Length: %d\r\n", content_length); url_fprintf(c->pb, "\r\n"); put_buffer(c->pb, content, content_length); } static HTTPContext *find_rtp_session(const char *session_id) { HTTPContext *c; if (session_id[0] == '\0') return NULL; for(c = first_http_ctx; c != NULL; c = c->next) { if (!strcmp(c->session_id, session_id)) return c; } return NULL; } static RTSPTransportField *find_transport(RTSPHeader *h, enum RTSPProtocol protocol) { RTSPTransportField *th; int i; for(i=0;i<h->nb_transports;i++) { th = &h->transports[i]; if (th->protocol == protocol) return th; } return NULL; } static void rtsp_cmd_setup(HTTPContext *c, const char *url, RTSPHeader *h) { FFStream *stream; int stream_index, port; char buf[1024]; char path1[1024]; const char *path; HTTPContext *rtp_c; RTSPTransportField *th; struct sockaddr_in dest_addr; RTSPActionServerSetup setup; /* find which url is asked */ url_split(NULL, 0, NULL, 0, NULL, 0, NULL, path1, sizeof(path1), url); path = path1; if (*path == '/') path++; /* now check each stream */ for(stream = first_stream; stream != NULL; stream = stream->next) { if (!stream->is_feed && stream->fmt == &rtp_mux) { /* accept aggregate filenames only if single stream */ if (!strcmp(path, stream->filename)) { if (stream->nb_streams != 1) { rtsp_reply_error(c, RTSP_STATUS_AGGREGATE); return; } stream_index = 0; goto found; } for(stream_index = 0; stream_index < stream->nb_streams; stream_index++) { snprintf(buf, sizeof(buf), "%s/streamid=%d", stream->filename, stream_index); if (!strcmp(path, buf)) goto found; } } } /* no stream found */ rtsp_reply_error(c, RTSP_STATUS_SERVICE); /* XXX: right error ? */ return; found: /* generate session id if needed */ if (h->session_id[0] == '\0') { snprintf(h->session_id, sizeof(h->session_id), "%08x%08x", (int)random(), (int)random()); } /* find rtp session, and create it if none found */ rtp_c = find_rtp_session(h->session_id); if (!rtp_c) { /* always prefer UDP */ th = find_transport(h, RTSP_PROTOCOL_RTP_UDP); if (!th) { th = find_transport(h, RTSP_PROTOCOL_RTP_TCP); if (!th) { rtsp_reply_error(c, RTSP_STATUS_TRANSPORT); return; } } rtp_c = rtp_new_connection(&c->from_addr, stream, h->session_id, th->protocol); if (!rtp_c) { rtsp_reply_error(c, RTSP_STATUS_BANDWIDTH); return; } /* open input stream */ if (open_input_stream(rtp_c, "") < 0) { rtsp_reply_error(c, RTSP_STATUS_INTERNAL); return; } } /* test if stream is OK (test needed because several SETUP needs to be done for a given file) */ if (rtp_c->stream != stream) { rtsp_reply_error(c, RTSP_STATUS_SERVICE); return; } /* test if stream is already set up */ if (rtp_c->rtp_ctx[stream_index]) { rtsp_reply_error(c, RTSP_STATUS_STATE); return; } /* check transport */ th = find_transport(h, rtp_c->rtp_protocol); if (!th || (th->protocol == RTSP_PROTOCOL_RTP_UDP && th->client_port_min <= 0)) { rtsp_reply_error(c, RTSP_STATUS_TRANSPORT); return; } /* setup default options */ setup.transport_option[0] = '\0'; dest_addr = rtp_c->from_addr; dest_addr.sin_port = htons(th->client_port_min); /* add transport option if needed */ if (ff_rtsp_callback) { setup.ipaddr = ntohl(dest_addr.sin_addr.s_addr); if (ff_rtsp_callback(RTSP_ACTION_SERVER_SETUP, rtp_c->session_id, (char *)&setup, sizeof(setup), stream->rtsp_option) < 0) { rtsp_reply_error(c, RTSP_STATUS_TRANSPORT); return; } dest_addr.sin_addr.s_addr = htonl(setup.ipaddr); } /* setup stream */ if (rtp_new_av_stream(rtp_c, stream_index, &dest_addr, c) < 0) { rtsp_reply_error(c, RTSP_STATUS_TRANSPORT); return; } /* now everything is OK, so we can send the connection parameters */ rtsp_reply_header(c, RTSP_STATUS_OK); /* session ID */ url_fprintf(c->pb, "Session: %s\r\n", rtp_c->session_id); switch(rtp_c->rtp_protocol) { case RTSP_PROTOCOL_RTP_UDP: port = rtp_get_local_port(rtp_c->rtp_handles[stream_index]); url_fprintf(c->pb, "Transport: RTP/AVP/UDP;unicast;" "client_port=%d-%d;server_port=%d-%d", th->client_port_min, th->client_port_min + 1, port, port + 1); break; case RTSP_PROTOCOL_RTP_TCP: url_fprintf(c->pb, "Transport: RTP/AVP/TCP;interleaved=%d-%d", stream_index * 2, stream_index * 2 + 1); break; default: break; } if (setup.transport_option[0] != '\0') { url_fprintf(c->pb, ";%s", setup.transport_option); } url_fprintf(c->pb, "\r\n"); url_fprintf(c->pb, "\r\n"); } /* find an rtp connection by using the session ID. Check consistency with filename */ static HTTPContext *find_rtp_session_with_url(const char *url, const char *session_id) { HTTPContext *rtp_c; char path1[1024]; const char *path; char buf[1024]; int s; rtp_c = find_rtp_session(session_id); if (!rtp_c) return NULL; /* find which url is asked */ url_split(NULL, 0, NULL, 0, NULL, 0, NULL, path1, sizeof(path1), url); path = path1; if (*path == '/') path++; if(!strcmp(path, rtp_c->stream->filename)) return rtp_c; for(s=0; s<rtp_c->stream->nb_streams; ++s) { snprintf(buf, sizeof(buf), "%s/streamid=%d", rtp_c->stream->filename, s); if(!strncmp(path, buf, sizeof(buf))) { // XXX: Should we reply with RTSP_STATUS_ONLY_AGGREGATE if nb_streams>1? return rtp_c; } } return NULL; } static void rtsp_cmd_play(HTTPContext *c, const char *url, RTSPHeader *h) { HTTPContext *rtp_c; rtp_c = find_rtp_session_with_url(url, h->session_id); if (!rtp_c) { rtsp_reply_error(c, RTSP_STATUS_SESSION); return; } if (rtp_c->state != HTTPSTATE_SEND_DATA && rtp_c->state != HTTPSTATE_WAIT_FEED && rtp_c->state != HTTPSTATE_READY) { rtsp_reply_error(c, RTSP_STATUS_STATE); return; } #if 0 /* XXX: seek in stream */ if (h->range_start != AV_NOPTS_VALUE) { printf("range_start=%0.3f\n", (double)h->range_start / AV_TIME_BASE); av_seek_frame(rtp_c->fmt_in, -1, h->range_start); } #endif rtp_c->state = HTTPSTATE_SEND_DATA; /* now everything is OK, so we can send the connection parameters */ rtsp_reply_header(c, RTSP_STATUS_OK); /* session ID */ url_fprintf(c->pb, "Session: %s\r\n", rtp_c->session_id); url_fprintf(c->pb, "\r\n"); } static void rtsp_cmd_pause(HTTPContext *c, const char *url, RTSPHeader *h) { HTTPContext *rtp_c; rtp_c = find_rtp_session_with_url(url, h->session_id); if (!rtp_c) { rtsp_reply_error(c, RTSP_STATUS_SESSION); return; } if (rtp_c->state != HTTPSTATE_SEND_DATA && rtp_c->state != HTTPSTATE_WAIT_FEED) { rtsp_reply_error(c, RTSP_STATUS_STATE); return; } rtp_c->state = HTTPSTATE_READY; rtp_c->first_pts = AV_NOPTS_VALUE; /* now everything is OK, so we can send the connection parameters */ rtsp_reply_header(c, RTSP_STATUS_OK); /* session ID */ url_fprintf(c->pb, "Session: %s\r\n", rtp_c->session_id); url_fprintf(c->pb, "\r\n"); } static void rtsp_cmd_teardown(HTTPContext *c, const char *url, RTSPHeader *h) { HTTPContext *rtp_c; rtp_c = find_rtp_session_with_url(url, h->session_id); if (!rtp_c) { rtsp_reply_error(c, RTSP_STATUS_SESSION); return; } /* abort the session */ close_connection(rtp_c); if (ff_rtsp_callback) { ff_rtsp_callback(RTSP_ACTION_SERVER_TEARDOWN, rtp_c->session_id, NULL, 0, rtp_c->stream->rtsp_option); } /* now everything is OK, so we can send the connection parameters */ rtsp_reply_header(c, RTSP_STATUS_OK); /* session ID */ url_fprintf(c->pb, "Session: %s\r\n", rtp_c->session_id); url_fprintf(c->pb, "\r\n"); } /********************************************************************/ /* RTP handling */ static HTTPContext *rtp_new_connection(struct sockaddr_in *from_addr, FFStream *stream, const char *session_id, enum RTSPProtocol rtp_protocol) { HTTPContext *c = NULL; const char *proto_str; /* XXX: should output a warning page when coming close to the connection limit */ if (nb_connections >= nb_max_connections) goto fail; /* add a new connection */ c = av_mallocz(sizeof(HTTPContext)); if (!c) goto fail; c->fd = -1; c->poll_entry = NULL; c->from_addr = *from_addr; c->buffer_size = IOBUFFER_INIT_SIZE; c->buffer = av_malloc(c->buffer_size); if (!c->buffer) goto fail; nb_connections++; c->stream = stream; pstrcpy(c->session_id, sizeof(c->session_id), session_id); c->state = HTTPSTATE_READY; c->is_packetized = 1; c->rtp_protocol = rtp_protocol; /* protocol is shown in statistics */ switch(c->rtp_protocol) { case RTSP_PROTOCOL_RTP_UDP_MULTICAST: proto_str = "MCAST"; break; case RTSP_PROTOCOL_RTP_UDP: proto_str = "UDP"; break; case RTSP_PROTOCOL_RTP_TCP: proto_str = "TCP"; break; default: proto_str = "???"; break; } pstrcpy(c->protocol, sizeof(c->protocol), "RTP/"); pstrcat(c->protocol, sizeof(c->protocol), proto_str); current_bandwidth += stream->bandwidth; c->next = first_http_ctx; first_http_ctx = c; return c; fail: if (c) { av_free(c->buffer); av_free(c); } return NULL; } /* add a new RTP stream in an RTP connection (used in RTSP SETUP command). If RTP/TCP protocol is used, TCP connection 'rtsp_c' is used. */ static int rtp_new_av_stream(HTTPContext *c, int stream_index, struct sockaddr_in *dest_addr, HTTPContext *rtsp_c) { AVFormatContext *ctx; AVStream *st; char *ipaddr; URLContext *h; uint8_t *dummy_buf; char buf2[32]; int max_packet_size; /* now we can open the relevant output stream */ ctx = av_alloc_format_context(); if (!ctx) return -1; ctx->oformat = &rtp_mux; st = av_mallocz(sizeof(AVStream)); if (!st) goto fail; ctx->nb_streams = 1; ctx->streams[0] = st; if (!c->stream->feed || c->stream->feed == c->stream) { memcpy(st, c->stream->streams[stream_index], sizeof(AVStream)); } else { memcpy(st, c->stream->feed->streams[c->stream->feed_streams[stream_index]], sizeof(AVStream)); } /* build destination RTP address */ ipaddr = inet_ntoa(dest_addr->sin_addr); switch(c->rtp_protocol) { case RTSP_PROTOCOL_RTP_UDP: case RTSP_PROTOCOL_RTP_UDP_MULTICAST: /* RTP/UDP case */ /* XXX: also pass as parameter to function ? */ if (c->stream->is_multicast) { int ttl; ttl = c->stream->multicast_ttl; if (!ttl) ttl = 16; snprintf(ctx->filename, sizeof(ctx->filename), "rtp://%s:%d?multicast=1&ttl=%d", ipaddr, ntohs(dest_addr->sin_port), ttl); } else { snprintf(ctx->filename, sizeof(ctx->filename), "rtp://%s:%d", ipaddr, ntohs(dest_addr->sin_port)); } if (url_open(&h, ctx->filename, URL_WRONLY) < 0) goto fail; c->rtp_handles[stream_index] = h; max_packet_size = url_get_max_packet_size(h); break; case RTSP_PROTOCOL_RTP_TCP: /* RTP/TCP case */ c->rtsp_c = rtsp_c; max_packet_size = RTSP_TCP_MAX_PACKET_SIZE; break; default: goto fail; } http_log("%s:%d - - [%s] \"PLAY %s/streamid=%d %s\"\n", ipaddr, ntohs(dest_addr->sin_port), ctime1(buf2), c->stream->filename, stream_index, c->protocol); /* normally, no packets should be output here, but the packet size may be checked */ if (url_open_dyn_packet_buf(&ctx->pb, max_packet_size) < 0) { /* XXX: close stream */ goto fail; } av_set_parameters(ctx, NULL); if (av_write_header(ctx) < 0) { fail: if (h) url_close(h); av_free(ctx); return -1; } url_close_dyn_buf(&ctx->pb, &dummy_buf); av_free(dummy_buf); c->rtp_ctx[stream_index] = ctx; return 0; } /********************************************************************/ /* ffserver initialization */ static AVStream *add_av_stream1(FFStream *stream, AVCodecContext *codec) { AVStream *fst; fst = av_mallocz(sizeof(AVStream)); if (!fst) return NULL; fst->priv_data = av_mallocz(sizeof(FeedData)); memcpy(&fst->codec, codec, sizeof(AVCodecContext)); fst->codec.coded_frame = &dummy_frame; fst->index = stream->nb_streams; av_set_pts_info(fst, 33, 1, 90000); stream->streams[stream->nb_streams++] = fst; return fst; } /* return the stream number in the feed */ static int add_av_stream(FFStream *feed, AVStream *st) { AVStream *fst; AVCodecContext *av, *av1; int i; av = &st->codec; for(i=0;i<feed->nb_streams;i++) { st = feed->streams[i]; av1 = &st->codec; if (av1->codec_id == av->codec_id && av1->codec_type == av->codec_type && av1->bit_rate == av->bit_rate) { switch(av->codec_type) { case CODEC_TYPE_AUDIO: if (av1->channels == av->channels && av1->sample_rate == av->sample_rate) goto found; break; case CODEC_TYPE_VIDEO: if (av1->width == av->width && av1->height == av->height && av1->frame_rate == av->frame_rate && av1->frame_rate_base == av->frame_rate_base && av1->gop_size == av->gop_size) goto found; break; default: av_abort(); } } } fst = add_av_stream1(feed, av); if (!fst) return -1; return feed->nb_streams - 1; found: return i; } static void remove_stream(FFStream *stream) { FFStream **ps; ps = &first_stream; while (*ps != NULL) { if (*ps == stream) { *ps = (*ps)->next; } else { ps = &(*ps)->next; } } } /* specific mpeg4 handling : we extract the raw parameters */ static void extract_mpeg4_header(AVFormatContext *infile) { int mpeg4_count, i, size; AVPacket pkt; AVStream *st; const uint8_t *p; mpeg4_count = 0; for(i=0;i<infile->nb_streams;i++) { st = infile->streams[i]; if (st->codec.codec_id == CODEC_ID_MPEG4 && st->codec.extradata_size == 0) { mpeg4_count++; } } if (!mpeg4_count) return; printf("MPEG4 without extra data: trying to find header in %s\n", infile->filename); while (mpeg4_count > 0) { if (av_read_packet(infile, &pkt) < 0) break; st = infile->streams[pkt.stream_index]; if (st->codec.codec_id == CODEC_ID_MPEG4 && st->codec.extradata_size == 0) { av_freep(&st->codec.extradata); /* fill extradata with the header */ /* XXX: we make hard suppositions here ! */ p = pkt.data; while (p < pkt.data + pkt.size - 4) { /* stop when vop header is found */ if (p[0] == 0x00 && p[1] == 0x00 && p[2] == 0x01 && p[3] == 0xb6) { size = p - pkt.data; // av_hex_dump(pkt.data, size); st->codec.extradata = av_malloc(size); st->codec.extradata_size = size; memcpy(st->codec.extradata, pkt.data, size); break; } p++; } mpeg4_count--; } av_free_packet(&pkt); } } /* compute the needed AVStream for each file */ static void build_file_streams(void) { FFStream *stream, *stream_next; AVFormatContext *infile; int i; /* gather all streams */ for(stream = first_stream; stream != NULL; stream = stream_next) { stream_next = stream->next; if (stream->stream_type == STREAM_TYPE_LIVE && !stream->feed) { /* the stream comes from a file */ /* try to open the file */ /* open stream */ stream->ap_in = av_mallocz(sizeof(AVFormatParameters)); if (stream->fmt == &rtp_mux) { /* specific case : if transport stream output to RTP, we use a raw transport stream reader */ stream->ap_in->mpeg2ts_raw = 1; stream->ap_in->mpeg2ts_compute_pcr = 1; } if (av_open_input_file(&infile, stream->feed_filename, stream->ifmt, 0, stream->ap_in) < 0) { http_log("%s not found", stream->feed_filename); /* remove stream (no need to spend more time on it) */ fail: remove_stream(stream); } else { /* find all the AVStreams inside and reference them in 'stream' */ if (av_find_stream_info(infile) < 0) { http_log("Could not find codec parameters from '%s'", stream->feed_filename); av_close_input_file(infile); goto fail; } extract_mpeg4_header(infile); for(i=0;i<infile->nb_streams;i++) { add_av_stream1(stream, &infile->streams[i]->codec); } av_close_input_file(infile); } } } } /* compute the needed AVStream for each feed */ static void build_feed_streams(void) { FFStream *stream, *feed; int i; /* gather all streams */ for(stream = first_stream; stream != NULL; stream = stream->next) { feed = stream->feed; if (feed) { if (!stream->is_feed) { /* we handle a stream coming from a feed */ for(i=0;i<stream->nb_streams;i++) { stream->feed_streams[i] = add_av_stream(feed, stream->streams[i]); } } } } /* gather all streams */ for(stream = first_stream; stream != NULL; stream = stream->next) { feed = stream->feed; if (feed) { if (stream->is_feed) { for(i=0;i<stream->nb_streams;i++) { stream->feed_streams[i] = i; } } } } /* create feed files if needed */ for(feed = first_feed; feed != NULL; feed = feed->next_feed) { int fd; if (url_exist(feed->feed_filename)) { /* See if it matches */ AVFormatContext *s; int matches = 0; if (av_open_input_file(&s, feed->feed_filename, NULL, FFM_PACKET_SIZE, NULL) >= 0) { /* Now see if it matches */ if (s->nb_streams == feed->nb_streams) { matches = 1; for(i=0;i<s->nb_streams;i++) { AVStream *sf, *ss; sf = feed->streams[i]; ss = s->streams[i]; if (sf->index != ss->index || sf->id != ss->id) { printf("Index & Id do not match for stream %d (%s)\n", i, feed->feed_filename); matches = 0; } else { AVCodecContext *ccf, *ccs; ccf = &sf->codec; ccs = &ss->codec; #define CHECK_CODEC(x) (ccf->x != ccs->x) if (CHECK_CODEC(codec) || CHECK_CODEC(codec_type)) { printf("Codecs do not match for stream %d\n", i); matches = 0; } else if (CHECK_CODEC(bit_rate) || CHECK_CODEC(flags)) { printf("Codec bitrates do not match for stream %d\n", i); matches = 0; } else if (ccf->codec_type == CODEC_TYPE_VIDEO) { if (CHECK_CODEC(frame_rate) || CHECK_CODEC(frame_rate_base) || CHECK_CODEC(width) || CHECK_CODEC(height)) { printf("Codec width, height and framerate do not match for stream %d\n", i); matches = 0; } } else if (ccf->codec_type == CODEC_TYPE_AUDIO) { if (CHECK_CODEC(sample_rate) || CHECK_CODEC(channels) || CHECK_CODEC(frame_size)) { printf("Codec sample_rate, channels, frame_size do not match for stream %d\n", i); matches = 0; } } else { printf("Unknown codec type\n"); matches = 0; } } if (!matches) { break; } } } else { printf("Deleting feed file '%s' as stream counts differ (%d != %d)\n", feed->feed_filename, s->nb_streams, feed->nb_streams); } av_close_input_file(s); } else { printf("Deleting feed file '%s' as it appears to be corrupt\n", feed->feed_filename); } if (!matches) { if (feed->readonly) { printf("Unable to delete feed file '%s' as it is marked readonly\n", feed->feed_filename); exit(1); } unlink(feed->feed_filename); } } if (!url_exist(feed->feed_filename)) { AVFormatContext s1, *s = &s1; if (feed->readonly) { printf("Unable to create feed file '%s' as it is marked readonly\n", feed->feed_filename); exit(1); } /* only write the header of the ffm file */ if (url_fopen(&s->pb, feed->feed_filename, URL_WRONLY) < 0) { fprintf(stderr, "Could not open output feed file '%s'\n", feed->feed_filename); exit(1); } s->oformat = feed->fmt; s->nb_streams = feed->nb_streams; for(i=0;i<s->nb_streams;i++) { AVStream *st; st = feed->streams[i]; s->streams[i] = st; } av_set_parameters(s, NULL); av_write_header(s); /* XXX: need better api */ av_freep(&s->priv_data); url_fclose(&s->pb); } /* get feed size and write index */ fd = open(feed->feed_filename, O_RDONLY); if (fd < 0) { fprintf(stderr, "Could not open output feed file '%s'\n", feed->feed_filename); exit(1); } feed->feed_write_index = ffm_read_write_index(fd); feed->feed_size = lseek(fd, 0, SEEK_END); /* ensure that we do not wrap before the end of file */ if (feed->feed_max_size < feed->feed_size) feed->feed_max_size = feed->feed_size; close(fd); } } /* compute the bandwidth used by each stream */ static void compute_bandwidth(void) { int bandwidth, i; FFStream *stream; for(stream = first_stream; stream != NULL; stream = stream->next) { bandwidth = 0; for(i=0;i<stream->nb_streams;i++) { AVStream *st = stream->streams[i]; switch(st->codec.codec_type) { case CODEC_TYPE_AUDIO: case CODEC_TYPE_VIDEO: bandwidth += st->codec.bit_rate; break; default: break; } } stream->bandwidth = (bandwidth + 999) / 1000; } } static void get_arg(char *buf, int buf_size, const char **pp) { const char *p; char *q; int quote; p = *pp; while (isspace(*p)) p++; q = buf; quote = 0; if (*p == '\"' || *p == '\'') quote = *p++; for(;;) { if (quote) { if (*p == quote) break; } else { if (isspace(*p)) break; } if (*p == '\0') break; if ((q - buf) < buf_size - 1) *q++ = *p; p++; } *q = '\0'; if (quote && *p == quote) p++; *pp = p; } /* add a codec and set the default parameters */ static void add_codec(FFStream *stream, AVCodecContext *av) { AVStream *st; /* compute default parameters */ switch(av->codec_type) { case CODEC_TYPE_AUDIO: if (av->bit_rate == 0) av->bit_rate = 64000; if (av->sample_rate == 0) av->sample_rate = 22050; if (av->channels == 0) av->channels = 1; break; case CODEC_TYPE_VIDEO: if (av->bit_rate == 0) av->bit_rate = 64000; if (av->frame_rate == 0){ av->frame_rate = 5; av->frame_rate_base = 1; } if (av->width == 0 || av->height == 0) { av->width = 160; av->height = 128; } /* Bitrate tolerance is less for streaming */ if (av->bit_rate_tolerance == 0) av->bit_rate_tolerance = av->bit_rate / 4; if (av->qmin == 0) av->qmin = 3; if (av->qmax == 0) av->qmax = 31; if (av->max_qdiff == 0) av->max_qdiff = 3; av->qcompress = 0.5; av->qblur = 0.5; if (!av->rc_eq) av->rc_eq = "tex^qComp"; if (!av->i_quant_factor) av->i_quant_factor = -0.8; if (!av->b_quant_factor) av->b_quant_factor = 1.25; if (!av->b_quant_offset) av->b_quant_offset = 1.25; if (!av->rc_max_rate) av->rc_max_rate = av->bit_rate * 2; break; default: av_abort(); } st = av_mallocz(sizeof(AVStream)); if (!st) return; stream->streams[stream->nb_streams++] = st; memcpy(&st->codec, av, sizeof(AVCodecContext)); } static int opt_audio_codec(const char *arg) { AVCodec *p; p = first_avcodec; while (p) { if (!strcmp(p->name, arg) && p->type == CODEC_TYPE_AUDIO) break; p = p->next; } if (p == NULL) { return CODEC_ID_NONE; } return p->id; } static int opt_video_codec(const char *arg) { AVCodec *p; p = first_avcodec; while (p) { if (!strcmp(p->name, arg) && p->type == CODEC_TYPE_VIDEO) break; p = p->next; } if (p == NULL) { return CODEC_ID_NONE; } return p->id; } /* simplistic plugin support */ #ifdef CONFIG_HAVE_DLOPEN void load_module(const char *filename) { void *dll; void (*init_func)(void); dll = dlopen(filename, RTLD_NOW); if (!dll) { fprintf(stderr, "Could not load module '%s' - %s\n", filename, dlerror()); return; } init_func = dlsym(dll, "ffserver_module_init"); if (!init_func) { fprintf(stderr, "%s: init function 'ffserver_module_init()' not found\n", filename); dlclose(dll); } init_func(); } #endif static int parse_ffconfig(const char *filename) { FILE *f; char line[1024]; char cmd[64]; char arg[1024]; const char *p; int val, errors, line_num; FFStream **last_stream, *stream, *redirect; FFStream **last_feed, *feed; AVCodecContext audio_enc, video_enc; int audio_id, video_id; f = fopen(filename, "r"); if (!f) { perror(filename); return -1; } errors = 0; line_num = 0; first_stream = NULL; last_stream = &first_stream; first_feed = NULL; last_feed = &first_feed; stream = NULL; feed = NULL; redirect = NULL; audio_id = CODEC_ID_NONE; video_id = CODEC_ID_NONE; for(;;) { if (fgets(line, sizeof(line), f) == NULL) break; line_num++; p = line; while (isspace(*p)) p++; if (*p == '\0' || *p == '#') continue; get_arg(cmd, sizeof(cmd), &p); if (!strcasecmp(cmd, "Port")) { get_arg(arg, sizeof(arg), &p); my_http_addr.sin_port = htons (atoi(arg)); } else if (!strcasecmp(cmd, "BindAddress")) { get_arg(arg, sizeof(arg), &p); if (!inet_aton(arg, &my_http_addr.sin_addr)) { fprintf(stderr, "%s:%d: Invalid IP address: %s\n", filename, line_num, arg); errors++; } } else if (!strcasecmp(cmd, "NoDaemon")) { ffserver_daemon = 0; } else if (!strcasecmp(cmd, "RTSPPort")) { get_arg(arg, sizeof(arg), &p); my_rtsp_addr.sin_port = htons (atoi(arg)); } else if (!strcasecmp(cmd, "RTSPBindAddress")) { get_arg(arg, sizeof(arg), &p); if (!inet_aton(arg, &my_rtsp_addr.sin_addr)) { fprintf(stderr, "%s:%d: Invalid IP address: %s\n", filename, line_num, arg); errors++; } } else if (!strcasecmp(cmd, "MaxClients")) { get_arg(arg, sizeof(arg), &p); val = atoi(arg); if (val < 1 || val > HTTP_MAX_CONNECTIONS) { fprintf(stderr, "%s:%d: Invalid MaxClients: %s\n", filename, line_num, arg); errors++; } else { nb_max_connections = val; } } else if (!strcasecmp(cmd, "MaxBandwidth")) { get_arg(arg, sizeof(arg), &p); val = atoi(arg); if (val < 10 || val > 100000) { fprintf(stderr, "%s:%d: Invalid MaxBandwidth: %s\n", filename, line_num, arg); errors++; } else { max_bandwidth = val; } } else if (!strcasecmp(cmd, "CustomLog")) { get_arg(logfilename, sizeof(logfilename), &p); } else if (!strcasecmp(cmd, "<Feed")) { /*********************************************/ /* Feed related options */ char *q; if (stream || feed) { fprintf(stderr, "%s:%d: Already in a tag\n", filename, line_num); } else { feed = av_mallocz(sizeof(FFStream)); /* add in stream list */ *last_stream = feed; last_stream = &feed->next; /* add in feed list */ *last_feed = feed; last_feed = &feed->next_feed; get_arg(feed->filename, sizeof(feed->filename), &p); q = strrchr(feed->filename, '>'); if (*q) *q = '\0'; feed->fmt = guess_format("ffm", NULL, NULL); /* defaut feed file */ snprintf(feed->feed_filename, sizeof(feed->feed_filename), "/tmp/%s.ffm", feed->filename); feed->feed_max_size = 5 * 1024 * 1024; feed->is_feed = 1; feed->feed = feed; /* self feeding :-) */ } } else if (!strcasecmp(cmd, "Launch")) { if (feed) { int i; feed->child_argv = (char **) av_mallocz(64 * sizeof(char *)); feed->child_argv[0] = av_malloc(7); strcpy(feed->child_argv[0], "ffmpeg"); for (i = 1; i < 62; i++) { char argbuf[256]; get_arg(argbuf, sizeof(argbuf), &p); if (!argbuf[0]) break; feed->child_argv[i] = av_malloc(strlen(argbuf) + 1); strcpy(feed->child_argv[i], argbuf); } feed->child_argv[i] = av_malloc(30 + strlen(feed->filename)); snprintf(feed->child_argv[i], 256, "http://127.0.0.1:%d/%s", ntohs(my_http_addr.sin_port), feed->filename); } } else if (!strcasecmp(cmd, "ReadOnlyFile")) { if (feed) { get_arg(feed->feed_filename, sizeof(feed->feed_filename), &p); feed->readonly = 1; } else if (stream) { get_arg(stream->feed_filename, sizeof(stream->feed_filename), &p); } } else if (!strcasecmp(cmd, "File")) { if (feed) { get_arg(feed->feed_filename, sizeof(feed->feed_filename), &p); } else if (stream) { get_arg(stream->feed_filename, sizeof(stream->feed_filename), &p); } } else if (!strcasecmp(cmd, "FileMaxSize")) { if (feed) { const char *p1; double fsize; get_arg(arg, sizeof(arg), &p); p1 = arg; fsize = strtod(p1, (char **)&p1); switch(toupper(*p1)) { case 'K': fsize *= 1024; break; case 'M': fsize *= 1024 * 1024; break; case 'G': fsize *= 1024 * 1024 * 1024; break; } feed->feed_max_size = (int64_t)fsize; } } else if (!strcasecmp(cmd, "</Feed>")) { if (!feed) { fprintf(stderr, "%s:%d: No corresponding <Feed> for </Feed>\n", filename, line_num); errors++; #if 0 } else { /* Make sure that we start out clean */ if (unlink(feed->feed_filename) < 0 && errno != ENOENT) { fprintf(stderr, "%s:%d: Unable to clean old feed file '%s': %s\n", filename, line_num, feed->feed_filename, strerror(errno)); errors++; } #endif } feed = NULL; } else if (!strcasecmp(cmd, "<Stream")) { /*********************************************/ /* Stream related options */ char *q; if (stream || feed) { fprintf(stderr, "%s:%d: Already in a tag\n", filename, line_num); } else { stream = av_mallocz(sizeof(FFStream)); *last_stream = stream; last_stream = &stream->next; get_arg(stream->filename, sizeof(stream->filename), &p); q = strrchr(stream->filename, '>'); if (*q) *q = '\0'; stream->fmt = guess_stream_format(NULL, stream->filename, NULL); memset(&audio_enc, 0, sizeof(AVCodecContext)); memset(&video_enc, 0, sizeof(AVCodecContext)); audio_id = CODEC_ID_NONE; video_id = CODEC_ID_NONE; if (stream->fmt) { audio_id = stream->fmt->audio_codec; video_id = stream->fmt->video_codec; } } } else if (!strcasecmp(cmd, "Feed")) { get_arg(arg, sizeof(arg), &p); if (stream) { FFStream *sfeed; sfeed = first_feed; while (sfeed != NULL) { if (!strcmp(sfeed->filename, arg)) break; sfeed = sfeed->next_feed; } if (!sfeed) { fprintf(stderr, "%s:%d: feed '%s' not defined\n", filename, line_num, arg); } else { stream->feed = sfeed; } } } else if (!strcasecmp(cmd, "Format")) { get_arg(arg, sizeof(arg), &p); if (!strcmp(arg, "status")) { stream->stream_type = STREAM_TYPE_STATUS; stream->fmt = NULL; } else { stream->stream_type = STREAM_TYPE_LIVE; /* jpeg cannot be used here, so use single frame jpeg */ if (!strcmp(arg, "jpeg")) strcpy(arg, "singlejpeg"); stream->fmt = guess_stream_format(arg, NULL, NULL); if (!stream->fmt) { fprintf(stderr, "%s:%d: Unknown Format: %s\n", filename, line_num, arg); errors++; } } if (stream->fmt) { audio_id = stream->fmt->audio_codec; video_id = stream->fmt->video_codec; } } else if (!strcasecmp(cmd, "InputFormat")) { stream->ifmt = av_find_input_format(arg); if (!stream->ifmt) { fprintf(stderr, "%s:%d: Unknown input format: %s\n", filename, line_num, arg); } } else if (!strcasecmp(cmd, "FaviconURL")) { if (stream && stream->stream_type == STREAM_TYPE_STATUS) { get_arg(stream->feed_filename, sizeof(stream->feed_filename), &p); } else { fprintf(stderr, "%s:%d: FaviconURL only permitted for status streams\n", filename, line_num); errors++; } } else if (!strcasecmp(cmd, "Author")) { if (stream) { get_arg(stream->author, sizeof(stream->author), &p); } } else if (!strcasecmp(cmd, "Comment")) { if (stream) { get_arg(stream->comment, sizeof(stream->comment), &p); } } else if (!strcasecmp(cmd, "Copyright")) { if (stream) { get_arg(stream->copyright, sizeof(stream->copyright), &p); } } else if (!strcasecmp(cmd, "Title")) { if (stream) { get_arg(stream->title, sizeof(stream->title), &p); } } else if (!strcasecmp(cmd, "Preroll")) { get_arg(arg, sizeof(arg), &p); if (stream) { stream->prebuffer = atof(arg) * 1000; } } else if (!strcasecmp(cmd, "StartSendOnKey")) { if (stream) { stream->send_on_key = 1; } } else if (!strcasecmp(cmd, "AudioCodec")) { get_arg(arg, sizeof(arg), &p); audio_id = opt_audio_codec(arg); if (audio_id == CODEC_ID_NONE) { fprintf(stderr, "%s:%d: Unknown AudioCodec: %s\n", filename, line_num, arg); errors++; } } else if (!strcasecmp(cmd, "VideoCodec")) { get_arg(arg, sizeof(arg), &p); video_id = opt_video_codec(arg); if (video_id == CODEC_ID_NONE) { fprintf(stderr, "%s:%d: Unknown VideoCodec: %s\n", filename, line_num, arg); errors++; } } else if (!strcasecmp(cmd, "MaxTime")) { get_arg(arg, sizeof(arg), &p); if (stream) { stream->max_time = atof(arg) * 1000; } } else if (!strcasecmp(cmd, "AudioBitRate")) { get_arg(arg, sizeof(arg), &p); if (stream) { audio_enc.bit_rate = atoi(arg) * 1000; } } else if (!strcasecmp(cmd, "AudioChannels")) { get_arg(arg, sizeof(arg), &p); if (stream) { audio_enc.channels = atoi(arg); } } else if (!strcasecmp(cmd, "AudioSampleRate")) { get_arg(arg, sizeof(arg), &p); if (stream) { audio_enc.sample_rate = atoi(arg); } } else if (!strcasecmp(cmd, "AudioQuality")) { get_arg(arg, sizeof(arg), &p); if (stream) { // audio_enc.quality = atof(arg) * 1000; } } else if (!strcasecmp(cmd, "VideoBitRateRange")) { if (stream) { int minrate, maxrate; get_arg(arg, sizeof(arg), &p); if (sscanf(arg, "%d-%d", &minrate, &maxrate) == 2) { video_enc.rc_min_rate = minrate * 1000; video_enc.rc_max_rate = maxrate * 1000; } else { fprintf(stderr, "%s:%d: Incorrect format for VideoBitRateRange -- should be <min>-<max>: %s\n", filename, line_num, arg); errors++; } } } else if (!strcasecmp(cmd, "VideoBufferSize")) { if (stream) { get_arg(arg, sizeof(arg), &p); video_enc.rc_buffer_size = atoi(arg) * 1024; } } else if (!strcasecmp(cmd, "VideoBitRateTolerance")) { if (stream) { get_arg(arg, sizeof(arg), &p); video_enc.bit_rate_tolerance = atoi(arg) * 1000; } } else if (!strcasecmp(cmd, "VideoBitRate")) { get_arg(arg, sizeof(arg), &p); if (stream) { video_enc.bit_rate = atoi(arg) * 1000; } } else if (!strcasecmp(cmd, "VideoSize")) { get_arg(arg, sizeof(arg), &p); if (stream) { parse_image_size(&video_enc.width, &video_enc.height, arg); if ((video_enc.width % 16) != 0 || (video_enc.height % 16) != 0) { fprintf(stderr, "%s:%d: Image size must be a multiple of 16\n", filename, line_num); errors++; } } } else if (!strcasecmp(cmd, "VideoFrameRate")) { get_arg(arg, sizeof(arg), &p); if (stream) { video_enc.frame_rate_base= DEFAULT_FRAME_RATE_BASE; video_enc.frame_rate = (int)(strtod(arg, NULL) * video_enc.frame_rate_base); } } else if (!strcasecmp(cmd, "VideoGopSize")) { get_arg(arg, sizeof(arg), &p); if (stream) { video_enc.gop_size = atoi(arg); } } else if (!strcasecmp(cmd, "VideoIntraOnly")) { if (stream) { video_enc.gop_size = 1; } } else if (!strcasecmp(cmd, "VideoHighQuality")) { if (stream) { video_enc.mb_decision = FF_MB_DECISION_BITS; } } else if (!strcasecmp(cmd, "Video4MotionVector")) { if (stream) { video_enc.mb_decision = FF_MB_DECISION_BITS; //FIXME remove video_enc.flags |= CODEC_FLAG_4MV; } } else if (!strcasecmp(cmd, "VideoQDiff")) { get_arg(arg, sizeof(arg), &p); if (stream) { video_enc.max_qdiff = atoi(arg); if (video_enc.max_qdiff < 1 || video_enc.max_qdiff > 31) { fprintf(stderr, "%s:%d: VideoQDiff out of range\n", filename, line_num); errors++; } } } else if (!strcasecmp(cmd, "VideoQMax")) { get_arg(arg, sizeof(arg), &p); if (stream) { video_enc.qmax = atoi(arg); if (video_enc.qmax < 1 || video_enc.qmax > 31) { fprintf(stderr, "%s:%d: VideoQMax out of range\n", filename, line_num); errors++; } } } else if (!strcasecmp(cmd, "VideoQMin")) { get_arg(arg, sizeof(arg), &p); if (stream) { video_enc.qmin = atoi(arg); if (video_enc.qmin < 1 || video_enc.qmin > 31) { fprintf(stderr, "%s:%d: VideoQMin out of range\n", filename, line_num); errors++; } } } else if (!strcasecmp(cmd, "LumaElim")) { get_arg(arg, sizeof(arg), &p); if (stream) { video_enc.luma_elim_threshold = atoi(arg); } } else if (!strcasecmp(cmd, "ChromaElim")) { get_arg(arg, sizeof(arg), &p); if (stream) { video_enc.chroma_elim_threshold = atoi(arg); } } else if (!strcasecmp(cmd, "LumiMask")) { get_arg(arg, sizeof(arg), &p); if (stream) { video_enc.lumi_masking = atof(arg); } } else if (!strcasecmp(cmd, "DarkMask")) { get_arg(arg, sizeof(arg), &p); if (stream) { video_enc.dark_masking = atof(arg); } } else if (!strcasecmp(cmd, "NoVideo")) { video_id = CODEC_ID_NONE; } else if (!strcasecmp(cmd, "NoAudio")) { audio_id = CODEC_ID_NONE; } else if (!strcasecmp(cmd, "ACL")) { IPAddressACL acl; struct hostent *he; get_arg(arg, sizeof(arg), &p); if (strcasecmp(arg, "allow") == 0) { acl.action = IP_ALLOW; } else if (strcasecmp(arg, "deny") == 0) { acl.action = IP_DENY; } else { fprintf(stderr, "%s:%d: ACL action '%s' is not ALLOW or DENY\n", filename, line_num, arg); errors++; } get_arg(arg, sizeof(arg), &p); he = gethostbyname(arg); if (!he) { fprintf(stderr, "%s:%d: ACL refers to invalid host or ip address '%s'\n", filename, line_num, arg); errors++; } else { /* Only take the first */ acl.first.s_addr = ntohl(((struct in_addr *) he->h_addr_list[0])->s_addr); acl.last = acl.first; } get_arg(arg, sizeof(arg), &p); if (arg[0]) { he = gethostbyname(arg); if (!he) { fprintf(stderr, "%s:%d: ACL refers to invalid host or ip address '%s'\n", filename, line_num, arg); errors++; } else { /* Only take the first */ acl.last.s_addr = ntohl(((struct in_addr *) he->h_addr_list[0])->s_addr); } } if (!errors) { IPAddressACL *nacl = (IPAddressACL *) av_mallocz(sizeof(*nacl)); IPAddressACL **naclp = 0; *nacl = acl; nacl->next = 0; if (stream) { naclp = &stream->acl; } else if (feed) { naclp = &feed->acl; } else { fprintf(stderr, "%s:%d: ACL found not in <stream> or <feed>\n", filename, line_num); errors++; } if (naclp) { while (*naclp) naclp = &(*naclp)->next; *naclp = nacl; } } } else if (!strcasecmp(cmd, "RTSPOption")) { get_arg(arg, sizeof(arg), &p); if (stream) { av_freep(&stream->rtsp_option); /* XXX: av_strdup ? */ stream->rtsp_option = av_malloc(strlen(arg) + 1); if (stream->rtsp_option) { strcpy(stream->rtsp_option, arg); } } } else if (!strcasecmp(cmd, "MulticastAddress")) { get_arg(arg, sizeof(arg), &p); if (stream) { if (!inet_aton(arg, &stream->multicast_ip)) { fprintf(stderr, "%s:%d: Invalid IP address: %s\n", filename, line_num, arg); errors++; } stream->is_multicast = 1; stream->loop = 1; /* default is looping */ } } else if (!strcasecmp(cmd, "MulticastPort")) { get_arg(arg, sizeof(arg), &p); if (stream) { stream->multicast_port = atoi(arg); } } else if (!strcasecmp(cmd, "MulticastTTL")) { get_arg(arg, sizeof(arg), &p); if (stream) { stream->multicast_ttl = atoi(arg); } } else if (!strcasecmp(cmd, "NoLoop")) { if (stream) { stream->loop = 0; } } else if (!strcasecmp(cmd, "</Stream>")) { if (!stream) { fprintf(stderr, "%s:%d: No corresponding <Stream> for </Stream>\n", filename, line_num); errors++; } if (stream->feed && stream->fmt && strcmp(stream->fmt->name, "ffm") != 0) { if (audio_id != CODEC_ID_NONE) { audio_enc.codec_type = CODEC_TYPE_AUDIO; audio_enc.codec_id = audio_id; add_codec(stream, &audio_enc); } if (video_id != CODEC_ID_NONE) { video_enc.codec_type = CODEC_TYPE_VIDEO; video_enc.codec_id = video_id; if (!video_enc.rc_buffer_size) { video_enc.rc_buffer_size = 40 * 1024; } add_codec(stream, &video_enc); } } stream = NULL; } else if (!strcasecmp(cmd, "<Redirect")) { /*********************************************/ char *q; if (stream || feed || redirect) { fprintf(stderr, "%s:%d: Already in a tag\n", filename, line_num); errors++; } else { redirect = av_mallocz(sizeof(FFStream)); *last_stream = redirect; last_stream = &redirect->next; get_arg(redirect->filename, sizeof(redirect->filename), &p); q = strrchr(redirect->filename, '>'); if (*q) *q = '\0'; redirect->stream_type = STREAM_TYPE_REDIRECT; } } else if (!strcasecmp(cmd, "URL")) { if (redirect) { get_arg(redirect->feed_filename, sizeof(redirect->feed_filename), &p); } } else if (!strcasecmp(cmd, "</Redirect>")) { if (!redirect) { fprintf(stderr, "%s:%d: No corresponding <Redirect> for </Redirect>\n", filename, line_num); errors++; } if (!redirect->feed_filename[0]) { fprintf(stderr, "%s:%d: No URL found for <Redirect>\n", filename, line_num); errors++; } redirect = NULL; } else if (!strcasecmp(cmd, "LoadModule")) { get_arg(arg, sizeof(arg), &p); #ifdef CONFIG_HAVE_DLOPEN load_module(arg); #else fprintf(stderr, "%s:%d: Module support not compiled into this version: '%s'\n", filename, line_num, arg); errors++; #endif } else { fprintf(stderr, "%s:%d: Incorrect keyword: '%s'\n", filename, line_num, cmd); errors++; } } fclose(f); if (errors) return -1; else return 0; } #if 0 static void write_packet(FFCodec *ffenc, uint8_t *buf, int size) { PacketHeader hdr; AVCodecContext *enc = &ffenc->enc; uint8_t *wptr; mk_header(&hdr, enc, size); wptr = http_fifo.wptr; fifo_write(&http_fifo, (uint8_t *)&hdr, sizeof(hdr), &wptr); fifo_write(&http_fifo, buf, size, &wptr); /* atomic modification of wptr */ http_fifo.wptr = wptr; ffenc->data_count += size; ffenc->avg_frame_size = ffenc->avg_frame_size * AVG_COEF + size * (1.0 - AVG_COEF); } #endif static void show_banner(void) { printf("ffserver version " FFMPEG_VERSION ", Copyright (c) 2000-2003 Fabrice Bellard\n"); } static void show_help(void) { show_banner(); printf("usage: ffserver [-L] [-h] [-f configfile]\n" "Hyper fast multi format Audio/Video streaming server\n" "\n" "-L : print the LICENSE\n" "-h : this help\n" "-f configfile : use configfile instead of /etc/ffserver.conf\n" ); } static void show_license(void) { show_banner(); printf( "This library is free software; you can redistribute it and/or\n" "modify it under the terms of the GNU Lesser General Public\n" "License as published by the Free Software Foundation; either\n" "version 2 of the License, or (at your option) any later version.\n" "\n" "This library is distributed in the hope that it will be useful,\n" "but WITHOUT ANY WARRANTY; without even the implied warranty of\n" "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\n" "Lesser General Public License for more details.\n" "\n" "You should have received a copy of the GNU Lesser General Public\n" "License along with this library; if not, write to the Free Software\n" "Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\n" ); } static void handle_child_exit(int sig) { pid_t pid; int status; while ((pid = waitpid(-1, &status, WNOHANG)) > 0) { FFStream *feed; for (feed = first_feed; feed; feed = feed->next) { if (feed->pid == pid) { int uptime = time(0) - feed->pid_start; feed->pid = 0; fprintf(stderr, "%s: Pid %d exited with status %d after %d seconds\n", feed->filename, pid, status, uptime); if (uptime < 30) { /* Turn off any more restarts */ feed->child_argv = 0; } } } } need_to_start_children = 1; } int main(int argc, char **argv) { const char *config_filename; int c; struct sigaction sigact; av_register_all(); config_filename = "/etc/ffserver.conf"; my_program_name = argv[0]; my_program_dir = getcwd(0, 0); ffserver_daemon = 1; for(;;) { c = getopt(argc, argv, "ndLh?f:"); if (c == -1) break; switch(c) { case 'L': show_license(); exit(1); case '?': case 'h': show_help(); exit(1); case 'n': no_launch = 1; break; case 'd': ffserver_debug = 1; ffserver_daemon = 0; break; case 'f': config_filename = optarg; break; default: exit(2); } } putenv("http_proxy"); /* Kill the http_proxy */ srandom(gettime_ms() + (getpid() << 16)); /* address on which the server will handle HTTP connections */ my_http_addr.sin_family = AF_INET; my_http_addr.sin_port = htons (8080); my_http_addr.sin_addr.s_addr = htonl (INADDR_ANY); /* address on which the server will handle RTSP connections */ my_rtsp_addr.sin_family = AF_INET; my_rtsp_addr.sin_port = htons (5454); my_rtsp_addr.sin_addr.s_addr = htonl (INADDR_ANY); nb_max_connections = 5; max_bandwidth = 1000; first_stream = NULL; logfilename[0] = '\0'; memset(&sigact, 0, sizeof(sigact)); sigact.sa_handler = handle_child_exit; sigact.sa_flags = SA_NOCLDSTOP | SA_RESTART; sigaction(SIGCHLD, &sigact, 0); if (parse_ffconfig(config_filename) < 0) { fprintf(stderr, "Incorrect config file - exiting.\n"); exit(1); } build_file_streams(); build_feed_streams(); compute_bandwidth(); /* put the process in background and detach it from its TTY */ if (ffserver_daemon) { int pid; pid = fork(); if (pid < 0) { perror("fork"); exit(1); } else if (pid > 0) { /* parent : exit */ exit(0); } else { /* child */ setsid(); chdir("/"); close(0); open("/dev/null", O_RDWR); if (strcmp(logfilename, "-") != 0) { close(1); dup(0); } close(2); dup(0); } } /* signal init */ signal(SIGPIPE, SIG_IGN); /* open log file if needed */ if (logfilename[0] != '\0') { if (!strcmp(logfilename, "-")) logfile = stdout; else logfile = fopen(logfilename, "w"); } if (http_server() < 0) { fprintf(stderr, "Could not start server\n"); exit(1); } return 0; }
sofian/drone
lib/ffmpeg/ffserver.c
C
gpl-2.0
152,555
''' Ohm's law is a simple equation describing electrical circuits. It states that the voltage V through a resistor is equal to the current (I) times the resistance: V = I * R The units of these are volts, ampheres (or "amps"), and ohms, respectively. In real circuits, often R is actually measured in kiloohms (10**3 ohms) and I in milliamps (10**-3 amps). Let's create a Resistor class that models this behavior. The constructor takes two arguments - the resistance in ohms, and the voltage in volts: >>> resistor = Resistor(800, 5.5) >>> resistor.resistance 800 >>> resistor.voltage 5.5 The current is derived from these two using Ohm's law: (Hint: use @property) >>> resistor.current 0.006875 Since we may want the value in milliamps, let's make another property to provide that: >>> resistor.current_in_milliamps 6.875 Let's set it up so that we can change the current, and doing so will correspondingly modify the voltage (but keep the resistance constant). >>> resistor.current_in_milliamps = 3.5 >>> resistor.resistance 800 >>> round(resistor.voltage, 2) 2.8 >>> resistor.current = .006875 >>> round(resistor.voltage, 2) 5.5 >>> resistor.resistance 800 Also, we've made a design decision that a Resistor cannot change its resistance value once created: >>> resistor.resistance = 8200 Traceback (most recent call last): AttributeError: can't set attribute ''' # Write your code here: class Resistor: def __init__(self, resistance, voltage): self._resistance = resistance self.voltage = voltage @property def resistance(self): return self._resistance @property def current(self): return self.voltage / self.resistance @current.setter def current(self, value): self.voltage = self.resistance * value @property def current_in_milliamps(self): return self.current * 1000 @current_in_milliamps.setter def current_in_milliamps(self, value): self.current = value / 1000 # Do not edit any code below this line! if __name__ == '__main__': import doctest count, _ = doctest.testmod() if count == 0: print('*** ALL TESTS PASS ***\nGive someone a HIGH FIVE!') # Copyright 2015-2018 Aaron Maxwell. All rights reserved.
ketan-analytics/learnpython
Safaribookonline-Python/courseware-btb/solutions/py3/patterns/properties_extra.py
Python
gpl-2.0
2,255
--- layout: post title: 从垃圾回收算法到Object Pool description: "Just about everything you'll need to style in the theme: headings, paragraphs, blockquotes, tables, code blocks, and more." modified: 2014-02-28 tags: [javascript, GC] image: feature: abstract-3.jpg credit: dargadgetz creditlink: http://www.dargadgetz.com/ios-7-abstract-wallpaper-pack-for-iphone-5-and-ipod-touch-retina/ comments: true share: true --- 前言:这本是一篇InfoQ的投稿,编辑给我的修改意见是把前半部分的GC算法的去掉。因为这些算法在JVM和其它平台的几乎是一致,甚至只是子集(事实确实如此,这篇文章参考了的文章大部分是Javas虚拟机的GC算法)。但还是暂时保留下来作为1.0 版本吧,将来打算和其它的优化内容合在一起,重新发布。 ------ 浏览器的脚本引擎有一个不足之处是,你无法通过javascript语法强制让脚本引擎进行垃圾回收(Garbage Collection,在文中以GC代替)和内存释放。虽然你可以在脚本中执行 `delete someVariable` 或者 `someVariable = null` 又或者 `someVariable = void 0`。但事实上你做的都只是删除了变量对某个对象的引用而已,至于被删除引用的对象是否能够被回收,又何时能否被回收,这就只能由脚本引擎说得算了。 这会留下一个性能上的隐患,因为GC也是要消耗浏览器资源的。理想的状态应该是在浏览器进程空闲的时候进行GC,相反如果GC发生的同时也有许多脚本需要处理,这务必会影响程序的性能。为了保证良好的用户体验,我们要尽可能让程序的刷新率靠近每秒60帧。换而言之,你必须在16.7ms之内执行完每一帧的所有脚本。 这篇文章主要分为两部分,一是关于浏览器的脚本引擎如何进行垃圾回收;二是如何使用Object Pool解决GC引起性能问题。 ## 脚本引擎的垃圾回收算法 ### Reference Counting 早在Javascript 1.1版本和Netscape 3中(甚至在早期火狐中),一个对象是否被回收是由这个对象的被引用次数决定的。对象一旦被创建并被一个变量引用,那么它的引用次数便是1,如果该对象又被赋值给了另一个变量,那么引用便增为2.一旦某变量删除了对该对象的引用或者另被赋值,那么该对象的引用便又降为1.理论上来说,当一个对象的被引用次数降为0时,表示没有任何变量在引用该对象了,它已经毫无用处可以被回收从内存中释放了。 但是这个算法有一个缺陷,比如当存在如下图循环引用的情况时: {% highlight javascript %} A<-------| C----->X | | D----->Y |------->B E----->Z {% endhighlight %} A与B互相引用,A和B的被引用次数都不为0,按照算法规则是不会被垃圾回收。但实际情况是A与B成了座“孤岛”,没有任何以外的变量引用他们。他们不会被回收,又不会再被发现和引用,这便造成了内存泄露。 实际的例子是在IE6、7中,DOM对象的回收使用的就是Reference Counting算法,比如下面这个例子 {% highlight javascript %} var div = document.createElement("div"); div.onclick = function handler(){ doSomething(); }; {% endhighlight %} 引用的情况是: - div通过onclick属性对函数handler进行引用 - 函数对div也进行了引用,因为在handler的作用域中可以访问div 这样的循环会导致两个对象都没有办法被垃圾回收,引起内存泄露。 ### Mark-and-Sweep 目前大部分浏览器使用的是这一个垃圾回收算法,或是在这个算法上的变形。这个算法以图的形式将所有的对象连接起来,就像算法名称所示,回收过程分为两个阶段: 1. 标记(Mark):它首先假设存在一些根(root)节点(比如Javascript中的全局对象),从根节点出发,试图去访问其它的每一个与它相连的节点。在Javascript中,如果访问到的节点是基本数据类型(Primitive type),则对这个节点进行标记,如果不是基本数据类型,也就是Object或者Array,则对这个非基本类型递归这一过程,直到访问到所有节点。 2. 清除(Sweep):经过上面的步骤之后,那么那些存在但没有被标记的对象,则进行回收。 ![Alt text](http://www.html5rocks.com/en/tutorials/memory/effectivemanagement/images/image03.png) 如果说Reference Counting的回收条件是“当某个对象不再被需要”,那么Mark-and-Sweep的回收条件则是“当某个对象不再能被访问”。 同时我们再回过头来看在前一个算法中会造成内存泄露的例子,很明显如果将算法换成Mark-and-Sweep,即使A与B互相引用,但是从根节点出发无法被访问,那么还是会对他们进行回收。 ### V8 实际情况会比我们想象的复杂的多,比如V8引擎就一共使用了三种垃圾回收算法。 #### Two Generational Collector(分代收集算法) 分代收集算法实际只能算三色标记算法(Tri-color marking)的一种策略。该算法的依据是:根据对大量计算机程序进行统计,发现最新被分配内存空间的对象通常活的时间都不会太长。这也被称作“弱代假说”(infant mortality or the generational hypothesis)。 这个算法将内存空间分为两代(generation),年青一代(young generation)和老一代(old generation)。在年青一代区域内存的分配和回收频繁并且迅速,老一代的区域内存的分配缓慢并且次数较少。一个对象被划分为“年青”和“老”的依据是,它从出生到存活至今被分配的字节数。 V8引擎的最外层使用的是这个算法,但是在年青一代和老一代的内存空间中又有独立的垃圾回收算法。年青一代使用的是切尼算法(Cheney's algorithm),而老一代使用的是标记压缩(Mark-compact)算法。 #### Cheney's algorithm(切尼算法) 切尼算法将堆(heap)分为相等的两个空间,分别命名为from和to,新增对象的内存空间分配是从名为to的那一部分开始的。当to空间的内存不够分配时,年青一代的GC便被触发。首先GC会交换from和to,并对新的from空间(原来的to)进行扫描,所有“活着”的对象都面临着选择:是被复制到to空间还是被分配到老一代内存中。一般来说这样一个过程不会超过10毫秒。 假设我们已经将from和to空间互相交换过了,接下来需要做的如何找到“活着”的对象,并且将活着的对象转移到新的to空间上去: - 算法依次扫描被栈(stack)引用的堆(heap) 上的对象(至于栈和堆的关系,可以参考C#:在C#中数据类型被分为两种,值类型和引用类型,值类型只需要一段单独的内存,用于存储实际的数据,存储在栈上;引用类型需要两段内存,第一段存储实际的数据,它总是位于堆上,第二段是一个引用指向数据在堆中存放的位置,位于栈上): - 如果对象还没有被转移到新的to空间上,那么就在to空间创建一份拷贝,并且将当前from空间的该对象修改为一个指向to空间拷贝的指针。并更新栈上引用,指向新的拷贝; - 如果对象已经被转移到了新的to空间上,那么把栈上指向from的指针改为指向to上的新拷贝即可 - 算法依次扫描已经转移到to上的对象,并且检查它们在from空间上的引用,重复上面的步骤 #### Mark-compact algorithm(标记压缩算法) 标记压缩算法是标记清除算法的一种变形,它主要解决的是标记清除之后内存空间空间碎片化不连续的问题。以基于表(Table-based)的标记压缩算法为例: 1. 标记与清除过程与Mark-and-sweep算法相同 2. 压缩过程从堆的底部(低位)向头部(高位)进行,每当扫描到一个被标记的对象,将它转移至第一个可用低位。并且将当前的移动记录插入至表(break table)中,该记录包括对象重置的位置,以及重置位置与原位置的差别。表的位置就放在压缩的堆中,但是该位置对其他对象来说是未被使用的。 3. 随着压缩的进行,被标记的对象不断的向低位移动,因此表占用的空间可会被征用,需要转移到新的空间 4. 等到压缩完毕,堆中幸存的对象需要根据表的记录,来更新对其他对象的指针引用 需要注意的是,表可能是不连续的(break),因此在第三步中表可能只是某一部分在堆中移动。这样会导致表里的记录不是按堆中对象的顺序排列的。所以在压缩之后,需要对表进行一次排序。 为了更好的理解压缩过程,可以将堆比作书架的一格,其中一部分放满了不同厚度的图书。空闲空间就是图书之间的空隙。压缩就是将所有图书朝一个方向推移,以弥合所有空隙。它从最靠近隔板的图书开始,将它推向隔板,然后将离隔板第二近的图书推向第一本图书,接着将第三本图书推向第二本图书,依此类推。最后,所有图书在一端,所有空闲空间在另一端。 ## Object Pool 在文章的开头,我提到GC也是会占用资源影响到性能的。让我们来看一个实际的例子。 首先我来模拟一个场景,想象一个街机平面射击游戏,玩家控制飞船不断的发射子弹攻击BOSS,每一轮发射10000颗子弹,同时每一轮发射的时候只有10%的子弹会击中BOSS而损失掉: {% highlight javascript %} // 子弹 var Bullet = function () {}; var gun = []; // 射击 var shoot = function () { var num = 100 * 100; for (var i = 0; i < num; i++) { gun.push(new Bullet()); } }; var shootAgain = function () { // 每次射击都会损失10%的子弹 for (var i = 0, len = parseInt(gun.length * 0.1); i < len ;i++) { gun.shift(); } shoot(); console.log("TOTAL LEN------>", gun.length); }; // 无限执行下去 (function repeat() { setTimeout(function () { shootAgain(); repeat(); }, 100); })(); {% endhighlight %} 如果你在Chrome中执行代码,并且在devtools中timeline中查看内存(memory标签下)的使用情况,你会看到类似于下图的锯齿图: ![Alt text](http://www.html5rocks.com/en/tutorials/speed/static-mem-pools/fig1.jpg) 每一次峰值意味着使用的内存不断的增长,同时峰值之后的回落意味着一个GC的发生,将无用的内存进行回收。 ![Alt text](http://www.html5rocks.com/en/tutorials/speed/static-mem-pools/fig2.jpg) 就像开头说的那样,GC会影响你的性能,如何运行GC是由引擎自己决定的,你没有控制权,GC可以发生在代码执行的任何时候,并且会中断你的代码执行知道GC完成。 如上图那样锯齿状的原因是因为频繁的创建和销毁对象,为了阻止这样的事情发生,其中一个办法就是延长对象的寿命,尽可能的不去触发GC。因此我们可以利用Object Pool模式。 Object Pool采取的是这样一种策略,在程序初始化时一次性创建相当数量的对象,存放在“池(pool)”中,当需要使用时不是在创建新的对象,而是从池中获取,当对象使用完毕后,还回池中,以上面的子弹代码为例,我们可以增加两个关于“池”的方法: {% highlight javascript %} // 使用中的子弹 var activeBullets = []; // 池子 object pool var bulletPool = []; // 初始化创建20颗子弹,存入池中 for (var i=0; i < 20; i++) bulletPool.push( new Bullet() ); // 获得子弹 function getNewBullet() { var b = null; if (bulletPool.length > 0) b = bulletPool.pop(); else // 如果池中对象不够用了,再增加新的对象 b = new Bullet(); // 使用子弹 activeBullets.push(b); return b; } // 释放对象,还回池中 function freeBullet(b) { for (var i=0, l=activeBullets.length; i < l; i++) if (activeBullets[i] == b) array.slice(i, 1); bulletPool.push(b); } {% endhighlight %} 我们可以进一步的将Object Pool模式抽象出来,封装成一个lib: {% highlight javascript %} var ObjectPool = (function() { var ObjectPool = function(Cls) { // 池子里的对象必须是同一类, // 所以你首先要传入一个构造函数 this.cls = Cls; // metrics用于记录pool的当前状态 // 比如 totalalloc(总已分配数)、 totalfree(可用) this.metrics = {}; // 重置池子 this._clearMetrics(); this._objpool = []; }; ObjectPool.prototype = { // 分配 alloc: function () { var obj; // 如果池中已无对象可供分配 if (this._objpool.length == 0) { obj = new this.cls(); this.metrics.totalalloc++; } else { obj = this._objpool.pop(); this.metrics.totalfree--; } obj.init.apply(obj, arguments); return obj; }, // 释放对象 free: function(obj) { var k; this._objpool.push(obj); this.metrics.totalfree++; // 对象还回池中后, // 还需要对对象进行清理,清除脏数据 for (k in obj) { delete obj[k]; } // 重新初始化 obj.init.call(obj); }, // 垃圾回收 // 在Object Pool模式下,垃圾回收便显得多余了 // 如果有需求的话,还是提供这样一个接口 collect: function () { this._objpool = []; var inUse = this.metrics.totalalloc - this.metrics.totalfree; // 记录下当前未被回收但已分配的个数 this._clearMetrics(inUse); }, _clearMetrics: function (allocated) { this.metrics.totalalloc = allocated || 0; this.metrics.totalfree = 0; } } return ObjectPool })(); {% endhighlight %} 有了上面的类库,我的子弹代码可以继续改进: {% highlight javascript %} // 子弹类 var Bullet = function () {}; // 创建 Object Pool var bulletPool = new ObjectPool(Bullet); // 新的子弹 var bullet = bulletPool.alloc(); // 销毁子弹 bullPool.free(bullet) {% endhighlight %} 最后要说明的是Object Pool并非万能。如果对于一些性能要求较高的大型应用,预先的一次性创建大批对象同样是一种代价;而对于小型应用,因为Object Pool基本不会对内存进行回收,所以会长时间大量占用内存,这同样是值得商榷的。使用Object Pool之后内存的使用情况应该如下图所示: ![Alt text](http://www.html5rocks.com/en/tutorials/speed/static-mem-pools/fig3.jpg) 参考资料 - [Effectively managing memory at Gmail scale - HTML5 Rocks](http://www.html5rocks.com/en/tutorials/memory/effectivemanagement/) - [Static Memory Javascript with Object Pools - HTML5 Rocks](http://www.html5rocks.com/en/tutorials/speed/static-mem-pools/) - [High-Performance, Garbage-Collector-Friendly Code - Build New Games](http://buildnewgames.com/garbage-collector-friendly-code/) - [Garbage Collection (JavaScript: The Definitive Guide, 4th Edition)](http://docstore.mik.ua/orelly/webprog/jscript/ch11_03.htm) - [Mark-compact algorithm - Wikipedia, the free encyclopedia](http://en.wikipedia.org/wiki/Mark-compact_algorithm) - [Cheney's algorithm - Wikipedia, the free encyclopedia](http://en.wikipedia.org/wiki/Cheney%27s_algorithm) - [Garbage collection (computer science) - Wikipedia, the free encyclopedia](http://en.wikipedia.org/wiki/Garbage_collection_(computer_science)) - [Memory Management - JavaScript](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Memory_Management)
hh54188/jekyll-blog
_posts/2014-02-28-from-GC-algorithm-to-ObjectPool.md
Markdown
gpl-2.0
16,139
set(PROCESSORS 4) set(CMAKE_RELEASE_DIRECTORY /Users/kitware/CMakeReleaseDirectory) # set(USER_OVERRIDE "set(CMAKE_CXX_LINK_EXECUTABLE \\\"gcc <FLAGS> <CMAKE_CXX_LINK_FLAGS> <LINK_FLAGS> <OBJECTS> -o <TARGET> <LINK_LIBRARIES> -shared-libgcc -lstdc++-static\\\")") set(INSTALL_PREFIX /) set(HOST dashmacmini5) set(MAKE_PROGRAM "make") set(MAKE "${MAKE_PROGRAM} -j5") set(CPACK_BINARY_GENERATORS "PackageMaker TGZ TZ") set(CPACK_SOURCE_GENERATORS "TGZ TZ") set(INITIAL_CACHE " CMAKE_BUILD_TYPE:STRING=Release CMAKE_OSX_ARCHITECTURES:STRING=x86_64;i386 CMAKE_OSX_DEPLOYMENT_TARGET:STRING=10.5 CMAKE_SKIP_BOOTSTRAP_TEST:STRING=TRUE CPACK_SYSTEM_NAME:STRING=Darwin64-universal BUILD_QtDialog:BOOL=TRUE QT_QMAKE_EXECUTABLE:FILEPATH=/Users/kitware/Support/qt-4.7.4/install/bin/qmake ") get_filename_component(path "${CMAKE_CURRENT_LIST_FILE}" PATH) include(${path}/release_cmake.cmake)
DDTChen/CookieVLC
vlc/extras/tools/cmake/Utilities/Release/dashmacmini5_release.cmake
CMake
gpl-2.0
882
@(contestId: Long, form: Form[org.iatoki.judgels.uriel.forms.ContestAnnouncementUpsertForm]) @import play.i18n.Messages @import org.iatoki.judgels.uriel.controllers.routes @import org.iatoki.judgels.play.views.html.formErrorView @import org.iatoki.judgels.uriel.views.html.contest.announcement.upsertAnnouncementView @import org.iatoki.judgels.uriel.views.html.contest.supervisorjs @implicitFieldConstructor = @{ b3.horizontal.fieldConstructor("col-md-3", "col-md-9") } @formErrorView(form) @b3.form(routes.ContestAnnouncementController.postCreateAnnouncement(contestId)) { @upsertAnnouncementView(form) @b3.submit('class -> "btn btn-primary") { @Messages.get("commons.create") } } @supervisorjs(contestId)
ia-toki/judgels-uriel
app/org/iatoki/judgels/uriel/views/contest/announcement/createAnnouncementView.scala.html
HTML
gpl-2.0
721
using UnityEngine; using System.Collections; public class Metrics : MonoBehaviour { // Use this for initialization void Start () { } // Update is called once per frame void Update () { } }
JoeProgram/monster
Assets/Scripts/Metrics.cs
C#
gpl-2.0
206
<?php declare(strict_types=1); namespace PoPCMSSchema\QueriedObject\TypeResolvers\InterfaceType; use PoP\ComponentModel\TypeResolvers\InterfaceType\AbstractInterfaceTypeResolver; class QueryableInterfaceTypeResolver extends AbstractInterfaceTypeResolver { public function getTypeName(): string { return 'Queryable'; } public function getTypeDescription(): ?string { return $this->__('Entities that can be queried through an URL', 'queriedobject'); } }
leoloso/PoP
layers/CMSSchema/packages/queriedobject/src/TypeResolvers/InterfaceType/QueryableInterfaceTypeResolver.php
PHP
gpl-2.0
497
*, *:before, *:after { -webkit-box-sizing: border-box; -moz-box-sizing: border-box; box-sizing: border-box; } span.grid_module { width: 10em; overflow: hidden; display: inline-block; vertical-align: bottom; text-overflow: ellipsis; } #tblda th,#tblda td { display: block; text-align: left; } #tblda th.thda { font-family: font_strong; font-size: 24px; color: #322F31; text-transform: uppercase; font-weight: normal; margin-bottom: 10px; } #blsd_padding table td { white-space: pre-wrap; } div#login-box { background-color: #fff; height: 235px; width: 380px; font-size: 14px; overflow: hidden; position: absolute; z-index: 99999; top: 25%; left: 35%; display: none; } .menu .tinnhan { padding: 10px; } .menu li h4 { margin-top: 0; } .clearfix::after { visibility: hidden; display: block; font-size: 0; content: " "; clear: both; height: 0; } * html .clearfix { zoom: 1; } /* IE6 */ *:first-child + html .clearfix { zoom: 1; } /* IE7 */ body { font-family: 'Open Sans', sans-serif; font-size: 13px; /* color: #322F31; */ min-width: 970px; line-height: 20px; margin: 0px; background-color: #f4f4f4; -webkit-font-smoothing: antialiased; } .cddt { position: relative; height: 100%; } ul li { list-style: none; } ul.menu { line-height: initial; /* margin-right: 2px; */ } .menu p { line-height: initial; } ul { padding: 0; margin: 0; } ul#top-subject li:nth-child(odd) { background-color: white; } ul#top-subject li:nth-child(even) { background-color: #faf8f1; } ul#top-subject -child {} ul#top-subject li:first-child,ul#top-subject li:last-child { background-color: white; } li.header { text-align: center; line-height: 50px; border-bottom: 1px solid #fff; } @font-face { font-family: font_strong; src: url('fonts/utm_bebas.ttf') format('truetype'), url('fonts/utm_bebas.eot#iefix') format('embedded-opentype'), url('fonts/utm_bebas.woff') format('woff'); font-weight: normal; font-style: normal; } @font-face { font-family: font_hvt; src: url('fonts/HelveticaWorld-Regular.eot'); font-weight: normal; font-style: normal; } /* Webkit override Scrollbar with CSS3 */ .box-left table { max-width: 100%; width: 100%; } .line2 { height: 1px; background: #322F31; } .line { height: 1px; background: #f4f4f4; } .linefix::before { content: ""; position: absolute; width: 100%; border-bottom: 1px solid #EEE; } .line_orn { height: 4px; background: #f4f4f4; margin-bottom: -4px; z-index: 99; position: relative; } .line_orn2 { height: 4px; background: url('/Images/orn2.png') repeat-x; } .clear { clear: both; } .main { margin: 0 auto; overflow: hidden; padding: 0; min-width: 1030px; max-width: 1030px; width: 100%; } .main2 { margin: 0 auto; /* overflow: hidden; */ padding: 0; min-width: 1030px; max-width: 1030px; width: 100%; height: 100%; } .title_path { height: 50px; background: #fff; border-radius: 0px; width: 100%; margin-top: 0px; border-bottom: 1px solid #f4f4f4; } .tileh3 { margin-top: 0px; position: absolute; color: #322F31; font-size: 18px; padding-left: 65px; line-height: 54px; float: left; font-weight: normal; background: url('/Images/iBooks-S3-icon.png') no-repeat 25px center; background-size: 30px auto; text-transform: uppercase; } /*========================Header===========================*/ .head_box { height: 60px; background: url(../Images/white95.png); z-index: 9999; position: fixed; left: 0px !important; margin: 0 auto; width: 100%; } .head_logo { width: 40px; height: 40px; background-image: url('/Images/hlogo.png'); background-size: 40px 40px; margin-top: 13px; float: left; } .head_username_box { margin-top: -3px; } .head_username_info:hover { text-decoration: none; } .head_username_info { font-size: 11px; font-weight: normal; color: #fff; text-decoration: none; } a.Link_orange:hover { color: #eee; text-decoration: none; } .head_menu_beak { background: #ddd; float: left; width: 0px; height: 20px; margin-top: 15px; } .head_menu { float: left; font-size: 22px; text-align: center; margin-top: 5px; margin-left: 20px; text-transform: uppercase; } .head_menu_item { float: left; margin-top: 15px; padding: 0px 5px; } .head_menu_text { color: #322F31; padding: 0 8px; text-decoration: none; font-family: font_strong; } a.head_menu_text:hover { color: #f7922a; } /*========================Slide + Tìm Kiếm===========================*/ input#searchinput { height: 27px; width: 220px; border: none; padding-left: 10px; outline: none; } input.search_button { position: absolute; right: 0px; top: 0px; background: url('/Images/ic_search_white_24dp.png') no-repeat 10px center #70b4de; border-left: 1px solid #eee; color: #fff; border-right: 0px; border-bottom: 0px; height: 30px; border-top: 0px; width: 100px; padding-left: 30px; cursor: pointer; } #camera_wrap { width: 100%; min-width: 1030px; display: block; margin: 0 auto; float: none; border-radius: 0px; max-height: 321px; height: 100%; min-height: 321px; background: url('/Images/ofical_banner.png') center center no-repeat #fff; z-index: -1; /* bottom: 0; */ position: absolute; margin-top: 60px; left: 0; - webkit - transition: all 1.0s ease; - moz - transition: all 1.0s ease; transition: all 1.0s ease; /* background-size: 100% auto; */ } .footer { width: 100%; min-width: 1030px; } .nddalg { z-index: 1; position: relative; margin-bottom: 55px; height: 55px; width: 230px; margin-left: -50px; } /*========================Cột bên phải===========================*/ .box_right { width: 300px; float: right; padding: 1px 1px; } .bg_right { position: relative; background-color: #fff; border-radius: 0px; border: 0px solid #eee; overflow: hidden; } .bg_title_category { background: url('/Images/iconTabArrow.gif') no-repeat 31px bottom; height: 50px; padding-left: 25px; padding-top: 18px; font-size: 18px; color: #f7922a; text-transform: uppercase; border-bottom: 1px solid #f7922a } a#tab-1 { text-indent: -9999; display: inline-block; text-indent: -9999px; background: url('/images/ic_folder_white_24dp2.png') no-repeat 0px center; width: 35px; text-decoration: none; } a#tab-2 { text-indent: -9999; display: inline-block; text-indent: -9999px; background: url('/images/ic_star_white_24dp.png') no-repeat 0px 98px; width: 35px; padding-top: 100px; text-decoration: none; margin-top: -100px; } .bg_title_category2 { background: url('/Images/ic_local_offer_white_24dp.png') no-repeat 10px center #70b4de; height: 32px; width: 265px; padding-left: 45px; padding-top: 13px; font-size: 18px; color: white; text-transform: uppercase; } .cate_link { color: #322F31; display: block; text-decoration: none; } .cate_item:hover { color: #f7922a; background-image: url('/Images/iconArrowRight_on.gif'); } .cate_item { font-weight: normal; padding: 13px 40px 13px 25px; background-image: url('/Images/iconArrowRight.gif'); background-position: right 25px top 16px; background-repeat: no-repeat; font-size: 16px; margin: 0px; } .bg_title_top { background: url('/Images/iconTabArrow.gif') no-repeat 31px bottom; height: 50px; padding-left: 25px; padding-top: 15px; font-size: 18px; color: #f7922a; text-transform: uppercase; border-bottom: 1px solid #f7922a; } .top_item { height: 120px; padding: 0 15px; border-bottom: 1px solid #f4f4f4; } .top_item:nth-child(2n) { height: 120px; width: 250px; /* padding: 0 25px; */ background-color: #fff; border-bottom: 1px solid #f4f4f4; } .top_viewall { height: 35px; text-align: right; padding: 10px 25px 0 0; } .top_img { width: auto; height: 65px; font-size: 12px; vertical-align: middle; } .anhtopdoan { width: 81px; height: 65px; float: left; overflow: hidden; background: #fff; margin-top: 15px; border-radius: 2px; border: 1px solid #f4f4f4; } .top_title_link { color: #322F31; text-decoration: none; } .top_title { overflow: hidden; white-space: nowrap; margin-top: 15px; text-overflow: ellipsis; width: 12em; height: 65px; line-height: 18px; font-weight: normal; float: right; font-size: 15px; /* margin-bottom: 0px; */ position: relative; } a.top_title_link :hover { text-decoration: none; color: #ff8401; } .top_cate { height: 20px; overflow: hidden; float: left; color: #ff8401; text-decoration: none; font-style: italic; padding-right: 5px; padding-top: 2px; width: 150px; white-space: nowrap; text-overflow: ellipsis; overflow: hidden; } .top_view { height: 20px; overflow: hidden; float: right; color: #babcbc; padding-top: 2px; } .top_view:after { content: 'views'; color: #babcbc; } .link_bullet_next { font-style: italic; color: #babcbc; background-image: url('/Images/glyphCategoryArrow.png'); background-position: right 0px top 4px; background-repeat: no-repeat; text-decoration: none; padding-right: 15px; } a.link_bullet_next:hover { text-decoration: none; background-image: url('/Images/glyphCategoryArrow_hv.png'); color: #ff8401; } /*--================================FOOTER ==========================================*/ .footer_box { height: 285px; background: #202020; padding-top: 20px; margin-top: 50px; } .footer_logo { width: 285px; float: left; margin-top: 5px; } .footer_logo_menu { margin-top: 5px; display: inline-block; color: #f7922a; } .link_bullet_bold { background-position: right 0px top 3px; background-repeat: no-repeat; text-decoration: none; padding-right: 10px; font-size: 13px; text-transform: uppercase; color: #fff; font-weight: bold; } .footer_company { margin-left: 50px; margin-top: 6px; width: 420px; float: left; } .footer_title { font-size: 23px; color: #f7922a; margin-bottom: 30px; font-family: font_strong; font-weight: 200; word-spacing: 2px; } .footer_item { margin-top: 20px; overflow: hidden; } .footer_img { width: 65px; height: 65px; border-radius: 0px; float: left; margin-right: 15px; } .footer_text { width: 330px; float: left; color: #fff; font-weight: bold; } .footer_link { width: 275px; float: left; color: #cbcccc; margin-top: 3px; text-decoration: none; } .footer_address { margin-left: 40px; margin-top: 6px; width: 210px; float: right; color: #cbcccc; } .footer_email a { text-decoration: none !important; } .footer_address_text { margin-top: 20px; font-weight: bold; margin-bottom: 10px; color: #fff; } .footer_email { background: url('/Images/ic_email.png') no-repeat 0 5px; padding-left: 22px; color: #ff8401; margin-top: 15px; } .diachi { background: url('../Images/bg_icon_address.png') no-repeat 0px 4px; padding-left: 20px; } .footer_logo2 { background: url('/Images/hlogo.png') no-repeat 0px 0px; width: 100%; height: 40px; background-size: 40px 40px; float: left; text-align: left; font-size: 45px; color: #f7922a; margin-bottom: 15px; font-family: font_strong; font-weight: 200; word-spacing: 2px; text-decoration: none; } a.footer_logo2 { padding-top: 6px; padding-left: 50px; padding-bottom: 0px; margin-bottom: 10px; } .footer_logo p { color: #cbcccc; text-align: left; padding: 0; } a#to-top { width: 28px; height: 28px; display: block; position: fixed; bottom: 20px; right: 20px; text-indent: -9999px; border-radius: 3px; background: url(http://rgb.vn/ideas/wp-content/themes/rgb2014/images/iconArrowTop.png) no-repeat #d9d9d9; opacity: .5; filter: alpha(opacity=50); } .bottom_box { height: 73px; background: #f4f4f4; color: #322F31; font-size: 14px; } .bottom_copyright { margin-top: 18px; width: 100%; text-align: center; } .bottom_copyright p { color: #8a8a8a; margin: 0; } .bottom_author { margin-top: 15px; width: 370px; float: right; text-align: right; font-size: 11px; color: #D52026; } .bottom_link { color: #D52026; text-decoration: none; } /*--================================ CỘT BÊN TRÁI===========================================*/ .box_left { width: 690px; display: block; float: left; padding: 1px; margin: 0; margin-top: 110px; } .title_box { background-color: #fff; border-radius: 0px; height: 45px; border-bottom: 1px solid #f4f4f4; padding: 0px 5px; display: none; } /*===================================Trang chủ=================================*/ /*1. trang chu. tuy chon*/ .option_view { border-radius: 0px; border: 1px solid #70b4de; height: 30px; width: 330px; float: left; margin-top: 7px; background-color: white; margin-left: 20px; position: relative; } .option_view_small { border-radius: 0px; height: 30px; width: 60px; float: right; margin-top: 7px; background-color: white; margin-right: 20px; } .option_sort { line-height: 54px; width: 180px; float: right; margin-right: 25px; } .option_base { color: #FFB82E; background: url('/Images/ic_base1.png') 15px 7px no-repeat; width: 100px; height: 30px; border: none; padding-left: 30px; font-size: 14px; float: left; border-radius: 0px 0 0 0px; } .option_base:hover { cursor: pointer; color: white; background: url('/Images/ic_base2.png') 15px 8px no-repeat #FFB82E; } .option_base_select { color: white; background: url('/Images/ic_base2.png') 15px 7px no-repeat #FFB82E; width: 100px; height: 30px; border: none; padding-left: 30px; font-size: 14px; float: left; border-radius: 0px 0 0 0px; } .option_detail { color: #322F31; background: url('/Images/ic_detail1.png') 15px 8px no-repeat #f4f4f4; width: 100px; height: 30px; border: none; padding-left: 30px; font-size: 14px; border-radius: 0 0px 0px 0; } .option_detail:hover { cursor: pointer; color: white; background: url('/Images/ic_detail2.png') 15px 8px no-repeat #FFB82E; } .option_detail_select { color: white; background: url('/Images/ic_detail2.png') 15px 8px no-repeat #FFB82E; width: 100px; height: 30px; border: none; padding-left: 30px; font-size: 14px; border-radius: 0 0px 0px 0; } /*option small*/ .option_base_small { background: url('/Images/ic_base1.png') 8px 8px no-repeat; width: 30px; height: 30px; border: none; float: left; border-radius: 0px 0 0 0px; } .option_base_small:hover { cursor: pointer; background: url('/Images/ic_base2.png') 8px 8px no-repeat #322F31; } .option_base_select_small { background: url('/Images/ic_base2.png') 8px 8px no-repeat #322F31; width: 30px; height: 30px; border: none; float: left; border-radius: 0px 0 0 0px; } .option_detail_small { background: url('/Images/ic_detail1.png') 6px 8px no-repeat; width: 30px; height: 30px; border: none; border-radius: 0 0px 0px 0; } .option_detail_small:hover { cursor: pointer; background: url('/Images/ic_detail2.png') 6px 8px no-repeat #322F31; } .option_detail_select_small { background: url('/Images/ic_detail2.png') 6px 8px no-repeat #322F31; width: 30px; height: 30px; border: none; float: left; border-radius: 0 0px 0px 0; } /*================================Common. Control=====================================*/ /* CSS FOR dropdownlist */ .lable { padding-top: 5px; float: left; white-space: nowrap; color: #322F31; } .select_label { position: relative; } .select_label:before { right: 7px; top: -1px; background: #fff; width: 20px; height: 20px; content: ''; position: absolute; pointer-events: none; display: block; } .select_label:after { content: ''; font: 25px "Consolas", monospace; color: #babcbc; right: 10px; bottom: -3px; width: 20px; height: 20px; position: absolute; pointer-events: none; background: url('/Images/iconArrow.png') no-repeat 0px 0px #fff; } select { padding-right: 18px; } select { padding: 5px 5px 5px 15px; margin: 0; width: 50%; font-size: 15px; -webkit-border-radius: 5px; -moz-border-radius: 5px; border-radius: 5px; background: #fff; color: #babcbc; outline: none; cursor: pointer; border: 1px solid #f4f4f4; } select .dropDown { position: absolute; top: 40px; left: 0; width: 100%; border: 1px solid #32333b; border-width: 0 1px 1px; list-style: none; -moz-box-sizing: border-box; -webkit-box-sizing: border-box; box-sizing: border-box; } /*end dropdownlist*/ /*3.control.gridview*/ .grid_box { margin: 20px 0; padding: 0px 25px; } #blsd { border: 0px solid #eee; border-radius: 0px; background: #fff; border-top: 0px solid #f9994c; } /*================CHI TIẾT ĐỒ ÁN BEGIN===================================*/ #blsd_padding { padding: 10px 25px 25px 25px; font-size: 16px; word-wrap: break-word; } #blsd_padding tr { display: list-item; list-style: none; padding-top: 20px; } tr.trdssvbc * { white-space: initial !important; } #tblda #trHome td { display: inline-block; } #tblda tr.success th,#tblda tr.success td { display: inline-block; } textarea#Content { width: 600px; height: 100px; border: 1px solid #ddd; font-size: 16px; font-family: 'Open Sans', sans-serif; padding: 10px; border-radius: 3px; } fieldset { border: 1px solid #ddd; } input[type="file"] { /* background: #fff !important; */ opacity: 0.8; padding: 5px 0px; } #trHome { display: inline-block; color: #322F31; width: 635px; height: 50px; /* padding: 0px; */ /* margin: 0px; */ overflow: hidden; /* padding-left: 45px; */ font-weight: normal; /* background: url('/Images/iBooks-S3-icon.png') no-repeat 0px 20px; */ background-size: 30px auto; border-bottom: 1px solid #eee; margin-top: -13px; } tr#trHome a { text-decoration: none; color: #322F31; white-space: nowrap; } tr#trHome a:hover { text-decoration: none; color: #f7922a; } td#tdmon { width: 220px; overflow: hidden; max-width: 220px; padding-left: 30px; white-space: nowrap; text-overflow: ellipsis !important; background: url("/Images/ic_tab_white_18dp.png") no-repeat 0px center; background-size: 20px 20px; } td#tdgv { width: 150px; overflow: hidden; max-width: 150px; white-space: nowrap; text-overflow: ellipsis !important; background: url("/Images/ic_perm_contact_cal_white_18dp.png") no-repeat 0px center; background-size: 20px 20px; padding-left: 30px; } td#nbd { /* width: 175px; */ /* max-width: 175px; */ overflow: hidden; white-space: nowrap; text-overflow: ellipsis !important; background: url("/Images/ic_query_builder_white_18dp.png") no-repeat 0px center; background-size: 20px 20px; padding-left: 30px; } td#tdtendoan { font-size: 25px; color: #f7922a; font-family: font_strong; text-transform: uppercase; font-weight: 200; /* word-spacing: 2px; */ line-height: 1.2; /* margin-top: -30px !important; */ margin-bottom: 18px; } td#tdnoidung:before { content: '1.Nội Dung'; display: list-item; text-transform: uppercase; font-family: font_strong; font-size: 24px; color: #322F31; padding-bottom: 3px; margin-bottom: 15px; } td#tdyeucau:before { content: '2.Mục tiêu'; display: list-item; text-transform: uppercase; font-family: font_strong; font-size: 24px; color: #322F31; padding-bottom: 3px; margin-bottom: 15px; } td#tdketqua:before { content: '3.Kết Quả'; display: list-item; text-transform: uppercase; font-family: font_strong; font-size: 24px; color: #322F31; padding-bottom: 3px; margin-bottom: 15px; } td#tdghichu:before { content: '4.Ghi Chú'; display: list-item; text-transform: uppercase; font-family: font_strong; font-size: 24px; color: #322F31; padding-bottom: 3px; margin-bottom: 15px; } /*==================CHI TIẾT ĐỒ ÁN END*/ /*base*/ .grid_base_item { height: 170px; padding: 15px 0; overflow: hidden; position: relative; border-bottom: 3px dashed #f0e5f5; /* background: url('/Images/iconArrowRight_on.gif') no-repeat right 20px; */ } .anhdoan { width: 180px; height: 145px; border-radius: 2px; background: #fff; float: left; margin-right: 20px; overflow: hidden; border: 1px solid #f4f4f4; } .grid_base_img { width: auto; height: 145px; border-radius: 0px; background-color: white; float: left; vertical-align: middle; } .grid_base_title_link { color: #ff8401; text-decoration: none; display: block; } .grid_base_title { width: 25em; white-space: nowrap; text-overflow: ellipsis; overflow: hidden; font-weight: bold; font-size: 17px; vertical-align: middle; margin-top: 15px; } .grid_base_title:hover { text-decoration: none; color: #ff8401; } .grid_detail_col2 { width: 190px; float: right; overflow: hidden; position: absolute; bottom: 15px; right: 0px; list-style: none; /* background: #9c0; */ text-align: left; padding: 0px 0px; color: #babcbc; } ul.grid_detail_col2.clearfix li { padding: 2px 0px; white-space: nowrap; text-overflow: ellipsis; overflow: hidden; } .grid_detail_col1 { width: 235px; float: left; overflow: hidden; position: absolute; bottom: 15px; left: 225px; list-style: none; /* background: #c20000; */ padding: 0px 0px; text-align: left; color: #babcbc; } ul.grid_detail_col1.clearfix li { padding: 2px 0px; white-space: nowrap; text-overflow: ellipsis; overflow: hidden; } /* .grid_base_item:hover > .grid_base_info{ opacity: 0; -webkit-transition: opacity .25s ease-in-out; -moz-transition: opactiy .25s ease-in-out; -ms-transition: opacity .25s ease-in-out; -o-transition: opacity .25s ease-in-out; transition: opacity .25s ease-in-out; } */ .grid_base_img:hover { opacity: 0.5; -webkit-transition: opacity .25s ease-in-out; -moz-transition: opactiy .25s ease-in-out; -ms-transition: opacity .25s ease-in-out; -o-transition: opacity .25s ease-in-out; transition: opacity .25s ease-in-out; } .top_img:hover { opacity: 0.5; -webkit-transition: opacity .25s ease-in-out; -moz-transition: opactiy .25s ease-in-out; -ms-transition: opacity .25s ease-in-out; -o-transition: opacity .25s ease-in-out; transition: opacity .25s ease-in-out; } .nddalg:hover { opacity: 0.7; -webkit-transition: opacity .25s ease-in-out; -moz-transition: opactiy .25s ease-in-out; -ms-transition: opacity .25s ease-in-out; -o-transition: opacity .25s ease-in-out; transition: opacity .25s ease-in-out; } .grid_base_info { /* width: 135px; */ display: block; float: right; margin-top: 0px; /* height: 45px; */ background: #fff; } .grid_base_cate { height: 20px; overflow: hidden; color: #ff8401; text-decoration: none; font-style: italic; padding-right: 4px; position: absolute; right: 0px; white-space: nowrap; text-overflow: ellipsis; width: 190px; text-align: right; } .grid_base_view { height: 20px; overflow: hidden; float: right; color: #babcbc; margin-bottom: 5px; } .grid_base_view:after { content: ' views'; color: #babcbc; } span.grid_base_cate a { color: #ff8401; text-decoration: none; } span.grid_base_cate a:hover { color: #322F31; } /*detail*/ .grid_detai_item { overflow: hidden; padding-top: 7px; } .grid_detai_item:hover .Hover_likesave { display: block; } .grid_detail_left { width: 120px; float: left; } .grid_detail_right { width: 490px; float: right; } ul.grid_detail_col1.clearfix li a { text-decoration: none; position: relative; color: #f7922a; } ul.grid_detail_col1.clearfix li a:hover { text-decoration: none; color: #babcbc; } .grid_detail_img { width: 120px; height: 90px; margin: 10px 0; border-radius: 0px; float: left; background-image: url('/Images/img_code.jpg'); overflow: hidden; } .grid_detail_downview { width: 118px; height: 48px; border-radius: 0px; border: 1px solid #f4f4f4; color: #322F31; margin-bottom: 15px; } .grid_detail_down { width: 59px; height: 28px; font-weight: bold; background: url('/Images/ic_down.png') no-repeat 24px 7px; text-align: center; padding-top: 23px; float: left; } .grid_detail_view { width: 59px; height: 28px; font-weight: bold; background: url('/Images/ic_view.png') no-repeat 22px 9px; text-align: center; padding-top: 23px; float: right; } .grid_detail_title_link { color: #ff8401; text-decoration: none; } .grid_detail_title { margin-top: 10px; width: 490px; height: 45px; overflow: hidden; font-weight: bold; float: left; font-size: 14px; overflow: hidden; line-height: 22px; margin-bottom: 15px; } .grid_detail_title:hover { text-decoration: none; } .grid_detail_cate2 { background: url('/Images/ic_cate.png') no-repeat 2px 4px; padding-left: 20px; height: 25px; overflow: hidden; color: #d5c6ae; } .grid_detail_lang2 { background: url('/Images/ic_lang.png') no-repeat 0px 5px; padding-left: 20px; height: 25px; overflow: hidden; color: #d5c6ae; clear: both; } .grid_detail_user2 { padding-left: 20px; height: 25px; overflow: hidden; color: #d5c6ae; } .grid_detail_img2 { width: 85px; height: 85px; float: left; margin: 5px 0px 15px 0px; border-radius: 0px; box-shadow: 1px 1px 3px #ac8f79; } .grid_detail_acc { width: 150px; float: right; margin-top: 10px; } .grid_detail_acc .info { margin-top: 5px; } .grid_detail_acc .username { color: #84c52c; font-size: 15px; font-weight: bold; text-decoration: none; } .grid_detail_acc .username:hover { text-decoration: none; } .grid_detail_copyright2 { background: url('/Images/ic_copyright.png') no-repeat 0 3px; padding-left: 20px; height: 25px; overflow: hidden; color: #d5c6ae; } .grid_detail_type2 { background: url('/Images/ic_type.png') no-repeat 1px 4px; padding-left: 20px; height: 25px; overflow: hidden; color: #d5c6ae; } .grid_detail_size2 { background: url('/Images/ic_size.png') no-repeat 1px 7px; padding-left: 20px; height: 25px; overflow: hidden; color: #d5c6ae; } .grid_detail_date2 { background: url('/Images/ic_date.png') no-repeat 0 4px; padding-left: 20px; height: 25px; overflow: hidden; color: #d5c6ae; } .grid_detail_like2 { background: url('/Images/ic_like.png') no-repeat 0 6px; padding-left: 20px; height: 25px; overflow: hidden; color: #d5c6ae; } .grid_detail_cate { padding-left: 20px; height: 25px; overflow: hidden; color: #d5c6ae; } .grid_detail_user { padding-left: 20px; height: 25px; overflow: hidden; color: #d5c6ae; } .grid_detail_copyright { padding-left: 20px; height: 25px; overflow: hidden; color: #d5c6ae; } .grid_detail_type { padding-left: 20px; height: 25px; overflow: hidden; color: #d5c6ae; } .grid_detail_date { padding-left: 20px; height: 25px; overflow: hidden; color: #d5c6ae; } .grid_detail_like { padding-left: 20px; height: 25px; overflow: hidden; color: #d5c6ae; } .grid_detail_cate a, .grid_detail_user a, .grid_detail_cate2 a, .grid_detail_lang2 a, .grid_detail_user2 a { width: 140px; float: right; color: #ff8401; text-decoration: none; } .grid_detail_cate a:hover, .grid_detail_user a:hover, .grid_detail_cate2 a:hover, .grid_detail_lang2 a:hover, .grid_detail_user2 a:hover { text-decoration: none; } .grid_detail_copyright span, .grid_detail_date span, .grid_detail_type span, .grid_detail_like span { width: 140px; float: right; color: #322F31; } /*==========================================pager- phân trang==========================================================*/ .pagination { display: inline-block; padding-left: 0; margin: 30px 0; border-radius: 0px; float: right; width: 100%; background: #fff; height: 43px; max-width: 689px; border: 1px solid #dfdfdf; position: relative; display: inline-flex; } .pagination > li { display: inline; } .pagination > li > a, .pagination > li > span { position: relative; float: left; font-size: 15px; padding: 0px 10px; line-height: 43px; text-decoration: none; } .ul2 > li { display: inline-flex; } .ul2 > li > a, .ul2 > li > span { position: relative; padding: 10px 10px; font-size: 15px; text-decoration: none; } ul.ul2 { background: #fff; width: 100%; margin-right: 40px; margin-left: 10px; list-style: none; font-size: 15px; text-align: center; } .pagination > li:first-child > a, .pagination > li:first-child > span { /* border-right: 1px solid #dcdcdc; */ width: 15px; height: 43px; background: url('/Images/iconArrowLeft.gif') no-repeat center center; } .pagination > li:first-child > a:hover, .pagination > li:first-child > span:hover { /* border-right: 1px solid #dcdcdc; */ width: 15px; height: 43px; background: url('/Images/iconArrowLeft_on.gif') no-repeat center center; } /*==??==*/ .pagination > li:last-child > a, .pagination > li:last-child > span { /* border-left: 1px solid #dcdcdc; */ width: 15px; height: 43px; background: url('/Images/iconArrowRight.gif') no-repeat center center; position: absolute; right: 0px; } .pagination > li:last-child > a:hover, .pagination > li:last-child > span:hover { /* border-left: 1px solid #dcdcdc; */ width: 15px; height: 43px; background: url('/Images/iconArrowRight_on.gif') no-repeat center center; position: absolute; right: 0px; } /*===???==*/ .ul2 > li > a, .ul2 > li > span { color: #babcbc; background-color: #fff; border-color: #ddd; } .ul2 > li > a:hover, .ul2 > li > span:hover, .ul2 > li > a:focus, .ul2 > li > span:focus { color: #322F31f; background-color: #fff; border-color: #ddd; } .ul2 > .active > a, .ul2 > .active > span { z-index: 2; color: #ff8401; cursor: default; background-color: #fff; } .ul2 > .active > a:hover, .ul2 > .active > span:hover, .ul2 > .active > a:focus, .ul2 > .active > span:focus { z-index: 2; color: #ff8401; cursor: default; background-color: #fff; } .ul2 > .disabled > span, .ul2 > .disabled > a { color: #babcbc; cursor: not-allowed; background-color: #fff; } .ul2 > .disabled > span:hover, .ul2 > .disabled > span:focus, .ul2 > .disabled > a:hover, .ul2 > .disabled > a:focus { color: #322F31; cursor: not-allowed; background-color: #fff; } /*==???==*/ .pagination-lg > li > a, .pagination-lg > li > span { padding: 10px 16px; font-size: 15px; } .pagination-lg > li:first-child > a, .pagination-lg > li:first-child > span { border-top-left-radius: 6px; border-bottom-left-radius: 6px; } .pagination-lg > li:last-child > a, .pagination-lg > li:last-child > span { border-top-right-radius: 6px; border-bottom-right-radius: 6px; } .pagination-sm > li > a, .pagination-sm > li > span { padding: 5px 10px; font-size: 12px; } .pagination-sm > li:first-child > a, .pagination-sm > li:first-child > span { border-top-left-radius: 3px; border-bottom-left-radius: 3px; } .pagination-sm > li:last-child > a, .pagination-sm > li:last-child > span { border-top-right-radius: 3px; border-bottom-right-radius: 3px; } /*=================== Nút đăng đề tài ========================*/ .uploadbtn { height: 47px; border-radius: 0px; width: 300px; position: relative; background: #ff8401; display: block; } #uploadbtnlink { background: url("/Images/icm_upload2.png") no-repeat 10px 6px,url("/Images/bg_orange.jpg") repeat-x 0px 5px; color: #fff; float: left; height: 31px; width: 300px; padding-top: 15px; padding-left: 85px; text-decoration: none; font-size: 17px; border-radius: 0px; } #uploadbtnlink:hover { background: url("/Images/icm_upload2.png") no-repeat 10px 6px,url("/Images/uphv.png") no-repeat 0px 5px; } /*==============breadcrumbs=========*/ .breadcrumbs { height: 45px; width: 100%; background: #fff; border-bottom: 1px solid #eee; display: none; } ul.navigate-content { height: 45px; position: relative; display: inline-block; zoom: 1; padding: 0px 5px; width: 98%; overflow: hidden; margin-top: 0px; line-height: 45px; } ul.navigate-content li:first-child { background: none; padding-left: 0; } ul.navigate-content li { float: left; padding: 0 10px 0 30px; font-size: 111%; text-transform: uppercase; background: url("/Images/bull_navigation.png") no-repeat 10px 15px; white-space: nowrap; text-overflow: ellipsis; overflow: hidden; position: relative; margin: 0px 0; line-height: 45px; overflow: hidden; font-family: arial, sans-serif; } ul.navigate-content li a { text-transform: uppercase; position: relative; color: #322F31; font-weight: 400; display: block; text-decoration: none; } ul.navigate-content li:hover a { color: #000; } ul.navigate-content li.active a { font-weight: bold; color: #474747; } /*DAng De Tai*/ .thumbnail { display: block; width: 150px; height: 200px; cursor: pointer; background-color: rgba(0,178,178,.7); } .thumbnail-icon { margin: 0 auto; } /*DSSV THAM GIA*/ ul.dssvtg { list-style: none; margin-left: 0px; padding-left: 0px; } a.btn.btn-primary.btn-sm.btn-flat { color: #f7922a; text-decoration: none; } a.btn.btn-primary.btn-sm.btn-flat:hover { color: #322F31; text-decoration: underline; } /*MENU BEN PHAI*/ .menubenphai { position: relative; float: right; z-index: 9999; text-align: center; font-size: 20px; color: #f7922a; min-height: 100%; display: block; right: 0; } ul.menubenphai { margin: 0; padding: 0; height: 100%; position: relative; } .menubenphai>ul { /* margin-top: 25px; */ padding: 0; margin: 0; height: 100%; /* display: block; */ } ul.menubenphai>li { display: inline-block; margin: 0 5px; height: 100%; } ul.menubenphai > li { /* display: none; */ margin: 0 5px; /* height: 60px; */ line-height: 60px; float: left; } li.userprofile img { width: 100px; height: 100px; position: relative; top: 15px; box-sizing: border-box; border-radius: 50%; text-align: center; border: 8px solid #DD770E; } li.userprofile h3 { /* float: right; */ text-decoration: none; /* margin: 0; */ margin-top: 0; } li.userprofile h2 { margin-bottom: 0; } input#dropdown-user:checked ~ .dropdown-menu { display: block; margin-top: -2px; padding-top: 0; } label[for="dropdown-user"] { cursor: pointer; } .ntk { /* position: absolute; */ /* width: 205px; */ /* right: 0px; */ z-index: 9999; /* display: none; */ } ul.dropdown-menu li.anhviet { margin-top: 5px; line-height: initial; } .anhviet a { text-decoration: none; color: #f7922a; padding: 5px 5px; } /*TIMKIEM*/ input { outline: none; } input[type=search] { -webkit-appearance: textfield; -webkit-box-sizing: content-box; font-family: inherit; font-size: 100%; } input::-webkit-search-decoration, input::-webkit-search-cancel-button { display: none; } input[type=search] { background: url('/Images/iconSearch.png') no-repeat 9px center; border: solid 1px transparent; padding: 9px 10px 9px 35px; width: 55px; -webkit-border-radius: 6px; -moz-border-radius: 6px; border-radius: 6px; -webkit-transition: all .5s; -moz-transition: all .5s; transition: all .5s; } input[type=search]:focus { width: 130px; border: 1px solid #f7922a; } input:-moz-placeholder { color: #babcbc; } input::-webkit-input-placeholder { color: #babcbc; } /* Demo 2 */ .menubenphai input[type=search] { width: 0px; color: transparent; cursor: pointer; position: absolute; right: -32px; top: 8px; /* margin-left: 30px; */ } .menubenphai input[type=search]:hover { background-color: #fff; } .menubenphai input[type=search]:focus { width: 250px; padding-right: 35px; color: #babcbc; background-color: #fff; cursor: auto; } .menubenphai input:-moz-placeholder { color: #babcbc; } .menubenphai input::-webkit-input-placeholder { color: #babcbc; } /*đăng nhập*/ #over { display: none; background: #000; position: fixed; left: 0; top: 0; width: 100%; height: 100%; opacity: 0.8; z-index: 999; } li.login { display: inline; } li.login a { display: inline; } .login .textdangnhap { font-size: 20px; padding-left: 130px; line-height: 50px; font-family: 'Open Sans', sans-serif; color: #f7922a; text-transform: uppercase; } .login .login_title { color: white; font-size: 16px; padding: 8px 0 5px 8px; text-align: left; } .login-content label { display: block; padding-bottom: 14px; } .login-content span { display: block; } .login-content .username span { padding-bottom: 7px; } .login-content .password span { padding-bottom: 7px; } .login-content { margin-left: 0px; margin-right: 0px; margin-bottom: 0px; margin-top: 5px; overflow: hidden; height: 180px; position: relative; } .login2 { margin: 0px 25px; overflow: hidden; } .img-close { float: right; margin-top: 10px; margin-right: 10px } .button { display: inline-block; width: 46px; text-align: center; color: #444; font-size: 14px; font-weight: bold; height: 36px; padding: 0px 8px; line-height: 36px; border-radius: 4px; transition: all 0.218s ease 0s; border: 1px solid #DCDCDC; background-color: #F5F5F5; background-image: -moz-linear-gradient(center top , #F5F5F5, #F1F1F1); cursor: pointer; margin-left: 120px !important; } .button:hover { border: 1px solid #DCDCDC; text-decoration: none; -moz-box-shadow: 0 1px 1px rgba(0,0,0,0.1); -webkit-box-shadow: 0 1px 1px rgba(0,0,0,0.1); box-shadow: 0 2px 2px rgba(0,0,0,0.1); } .login input { border: 1px solid #f4f4f4; color: black; height: 40px; padding: 0px 15px; word-spacing: 0.1em; width: 298px; font-size: 15px; margin: 5px 0px; } .submit-button { display: inline-block; padding: auto; margin: 15px 75px; width: 150px; } input.nutdn { position: absolute; bottom: 0px; left: 0px; margin: 0; padding: 0; width: 100%; background: #f7922a; height: 50px; border: none; color: #fff; font-size: 16px; cursor: pointer; } input.nutdn:hover { background: #f7822a } .login-content ul { list-style: none; margin: 0 auto; padding-left: 140px !important; } .login-content ul li { float: left; padding-right: 35px; } .login-content ul li a { text-decoration: none; color: #f7922a; } .login-content ul li a:hover { color: #322F31; } a.login-window { /* position: absolute; */ /* right: 0px; */ /* top: 3px; */ text-decoration: none; color: #f7922a; background: url('/Images/ic_account_circle_white_18dp.png') no-repeat 0px center; background-size: 19px; line-height: 30px; padding-left: 30px; font-size: 15px; } /*đăng nhập*/ td.action a { color: #fff; background: #f7922a; padding: 10px 40px; border-radius: 3px; text-decoration: none; font-weight: bold; margin-right: 20px; } td.action a:hover { background: #f75000; } input[type="button"] { width: 377px; background: #f7922a; padding: 0px; margin: 20px 0px; line-height: 40px; height: 40px; color: #fff; font-weight: bold; font-size: 14px; cursor: pointer; } li.lithoat { /* position: absolute; */ /* top: 10px; */ /* right: 0px; */ } .taikhoan { /* background: #9c0; */ position: relative; /* right: 0px; */ /* top: 0; */ color: #f7922a; margin-top: 3px; } .taikhoan a { text-decoration: none; color: #f7922a; font-size: 15px; line-height: 24px; } #liusername .username img { border-radius: 50%; width: 2em; height: 2em; position: relative; top: 11px; /* bottom: 30px; */ vertical-align: top; } #liusername .username strong { display: inline-block; vertical-align: middle; } .taikhoan ul { margin: 0; padding: 0; list-style: none; float: left; } .taikhoan ul li { /* display: inline-block; */ line-height: 30px; } #dropdown-messager:checked ~ .dropdown-menu { display: block; } ul.dropdown-menu.dropdown-menu-right li { border-bottom: 1px solid #fff; color: white; box-sizing: border-box; } .noactive h4, .noactive p { color: #333333; } .menu li.noactive { background-color: rgb(253, 239, 216); } ul.dropdown-menu { color: white; background-color: rgb(246, 162, 21); margin: 0; padding: 0; line-height: initial; } label[for="dropdown-messager"] { cursor: pointer; position: relative; display: block; color: #f7922a; } span#ms-count { border-radius: 50%; background-color: #5cb85c; position: absolute; top: 10px; font-size: 10px; font-weight: normal; width: 15px; height: 15px; line-height: 1em; text-align: center; padding: 2px; color: white; box-sizing: border-box; } .dssvtg ul li { list-style: none; } li.userprofile { list-style: none; /* margin-right: 20px; */ /* margin-top: 20px; */ /* float: left; */ text-align: center; background-color: #f7922a; } ul.dssvtg { list-style: none; padding-left: 0px; } ul.dssvtg li { display: inline-block; } td.tddssvbc { padding: 0; margin: 0; } tr.trdssvbc { /* background: #9c0; */ /* margin-top: -30px; */ /* display: block; */ } /*them moi*/ img.img-circle { border-radius: 50%; } input.btn.btn-default { border: 1px solid #f7922a; padding: 8px 30px; border-radius: 2px; cursor: pointer; background: #f7922a; color: #fff; font-weight: bold; } input.btn.btn-default:hover { background: #f7722a; color: #fff; } ul.list-group { list-style: none; margin-left: 0px; padding-left: 0px; /* background: #9c0; */ } li.panel.panel-default { background: #fff; border: 1px solid #eee; margin: 30px 0px; border-radius: 2px; } span.vote_td a { text-decoration: none; } header.panel-heading.clearfix { background: #f7f7f7; padding: 5px 0px; } .pull-left { float: left; padding: 5px 10px; } .pull-right { float: right; /* padding: 5px 20px; */ } .pull-right span strong { font-weight: normal; } section.panel-body { padding: 5px 20px; border-top: 1px solid #f4f4f4; } section.panel-body p { /* white-space: pre-wrap; */ word-wrap: break-word; } footer.panel-footer { background: #f7f7f7; padding: 5px 20px; } div#baocaowg { margin-top: 40px; } .pull-left strong { color: #322F31; font-weight: normal; } .hscn { padding: 20px 10px; } .dangdoanmoi legend { display: none; } .suadoanmoi fieldset,.dangdoanmoi fieldset { border: none; margin-top: 5px; margin: 0px; padding: 0px; overflow: hidden; } .suadoanmoi legend ,.dangdoanmoi legend { display: none; } img.img-thumbnail { border: 1px solid #f4f4f4; } .dangdoanmoi .editor-label,.suadoanmoi .editor-label { padding: 5px 0px; margin-top: 20px; color: #f7922a; font-weight: bold; font-size: 16px; text-transform: uppercase; } .dangdoanmoi .editor-field input,.suadoanmoi .editor-field input { /* background: #9c0; */ height: 25px; border: 1px solid #f4f4f4; width: 50%; } .dangdoanmoi input#Title,.suadoanmoi input#Title { width: 615px; padding: 5px 10px; border-radius: 2px; border: 1px solid #f4f4f4; } .dangdoanmoi img.img-thumbnail,.suadoanmoi img.img-thumbnail { border: 1px solid #f4f4f4; width: 180px; height: 145px; border-radius: 3px; } .dangdoanmoi input[type="submit"],.suadoanmoi input[type="submit"] { background: #f7922a; border: 1px solid #f7922a; color: #fff; padding: 10px 40px; border-radius: 3px; font-size: 15px; font-weight: bold; margin-top: 20px; cursor: pointer; } .dangdoanmoi input[type="submit"]:hover,.suadoanmoi input[type="submit"]:hover { background: #f7722a; } .dangdoanmoi textarea,.suadoanmoi textarea { border: 1px solid #f4f4f4; width: 615px; height: 100px; padding: 10px; font-size: 15px; border-radius: 2px; font-family: 'Open Sans', sans-serif; } .dangdoanmoi a { color: #f7922a; text-decoration: none; } .suadoanmoi a { color: #f7922a; text-decoration: none; } .hscn .display-label { color: #f7922a; margin: 5px 0px; font-weight: bold; } .hscn img.avatar.img-rounded { border-radius: 70px; } .clwbc { margin-left: -25px; margin-right: -25px; background: #f9f9f9; border-bottom: 1px solid #f0f0f0; border-top: 1px solid #f0f0f0; padding: 20px 25px; } .clwbc fieldset { border: none; padding: 0; margin: 0; } .clwbc textarea#Content { width: 620px; } .clwbc h3 { color: #f7922a; text-transform: uppercase; font-family: font_strong; font-size: 26px; font-weight: normal; } div#baocaowg h3 { color: #f7922a; text-transform: uppercase; font-family: font_strong; font-size: 26px; font-weight: normal; } .hsgvgv h3,.hshshs h3 { margin-top: -5px; color: #322F31; font-size: 18px; padding-left: 40px; line-height: 48px; font-weight: normal; background: url('/Images/ic_account_circle_white_18dp.png') no-repeat 0px center; background-size: 30px auto; text-transform: uppercase; border-bottom: 1px solid #f4f4f4; } .dangdoanmoi h3 { margin-top: -5px; color: #322F31; font-size: 18px; padding-left: 40px; line-height: 48px; font-weight: normal; background: url('/Images/ic_cloud_upload_grey600_24dp.png') no-repeat 0px center; background-size: 28px auto; text-transform: uppercase; border-bottom: 1px solid #f4f4f4; } .suadoanmoi h3 { margin-top: -5px; color: #322F31; font-size: 18px; padding-left: 40px; line-height: 48px; font-weight: normal; background: url('/Images/ic_mode_edit_grey600_36dp.png') no-repeat 0px center; background-size: 24px auto; text-transform: uppercase; border-bottom: 1px solid #f4f4f4; } footer.panel-footer a { text-decoration: none; color: #f7922a; /* background: url('/Images/ic_attachment_black_18dp.png') no-repeat 0px center; */ /* padding-left: 25px; */ } .ghtdkht { width: 600px; overflow: hidden; height: 20px; white-space: nowrap; text-overflow: ellipsis; color: #f7922a; } .trolaict:hover { background: #f7722a; } .trolaict { margin-top: -40px; background: #f7922a; width: 112px; height: 40px; line-height: 40px; padding: 0px 30px; border-radius: 2px; margin-left: 135px; color: #fff; } .trolaict a { color: #fff; font-weight: bold; font-size: 15px; display: inline; } a.username { display: block; height: 60px; position: relative; line-height: 60px; text-decoration: none; color: #f7922a; } li#liusername { float: left; position: relative; } a.halo { background: url('/images/logoff.png') no-repeat 0px 0px; width: 17px; background-size: 17px; /* line-height: 38px; */ /* margin-top: -10px !important; */ /* margin-left: 5px; */ /* text-indent: -9999px; */ display: inline-block; } .center-block { display: block; margin-right: auto; margin-left: auto; } .pull-right { float: right !important; } .btn-xacnhan a { padding: 0 20px 20px 0; } .pull-left { float: left !important; } .hide { display: none !important; } .show { display: block !important; } .invisible { visibility: hidden; } .text-hide { font: 0/0 a; color: transparent; text-shadow: none; background-color: transparent; border: 0; } .hidden { display: none; } .affix { position: fixed; } /*THONG BAO + TIN NHAN*/ .dropup, .dropdown { position: relative; } .dropdown-toggle:focus { outline: 0; } .dropdown-menu { position: absolute; top: 100%; left: 0; z-index: 1000; display: none; float: left; min-width: 160px; padding: 5px 0; margin: 2px 0 0; font-size: 14px; text-align: left; list-style: none; background-color: #fff; -webkit-background-clip: padding-box; background-clip: padding-box; /* border: 1px solid #ccc; */ /* border: 1px solid rgba(0, 0, 0, .15); */ /* border-radius: 4px; */ -webkit-box-shadow: 0 6px 12px rgba(0, 0, 0, .175); box-shadow: 0 6px 12px rgba(0, 0, 0, .175); } .dropdown-menu:after { bottom: 100%; right: 10px; border: solid transparent; content: " "; height: 0; width: 0; position: absolute; pointer-events: none; border-color: rgba(255, 255, 255, 0); border-bottom-color: rgb(247, 146, 42); border-width: 10px; margin-left: -10px; } #liusername .dropdown-menu:after { right: 20%; } #messager .dropdown-menu:after { right: 2px; } .dropdown-menu.pull-right { right: 0; left: auto; } .dropdown-menu .divider { height: 1px; margin: 9px 0; overflow: hidden; background-color: #e5e5e5; } .dropdown-menu > li > a { display: block; padding: 3px 20px; clear: both; font-weight: normal; line-height: 1.42857143; color: #333; white-space: nowrap; position: relative; text-decoration: none; } .userprofile h2, .userprofile h3 { color: #ddd; } li.anhviet a { display: inline; clear: none; } a.anh { float: right; } a.viet { float: left; /* width: 50%; */ } a.viet img { /* width: 100%; */ /* height: 100%; */ } .dropdown-menu > li > a:hover, .dropdown-menu > li > a:focus { color: #262626; text-decoration: none; /* background-color: #f5f5f5; */ } .dropdown-menu > li.profile > a:hover, .dropdown-menu > li.profile > a:focus { background-color: transparent; } .dropdown-menu > .active > a, .dropdown-menu > .active > a:hover, .dropdown-menu > .active > a:focus { color: #fff; text-decoration: none; background-color: #337ab7; outline: 0; } .dropdown-menu > .disabled > a, .dropdown-menu > .disabled > a:hover, .dropdown-menu > .disabled > a:focus { color: #777; } .dropdown-menu > .disabled > a:hover, .dropdown-menu > .disabled > a:focus { text-decoration: none; cursor: not-allowed; background-color: transparent; background-image: none; filter: progid:DXImageTransform.Microsoft.gradient(enabled = false); } .open > .dropdown-menu { display: block; } .open > a { outline: 0; } .dropdown-menu-right { right: 0; left: auto; } .dropdown-menu-left { right: auto; left: 0; } .dropdown-header { display: block; padding: 3px 20px; font-size: 12px; line-height: 1.42857143; color: #777; white-space: nowrap; } .dropdown-backdrop { position: fixed; top: 0; right: 0; bottom: 0; left: 0; z-index: 990; } .pull-right > .dropdown-menu { right: 0; left: auto; } .dropup .caret, .navbar-fixed-bottom .dropdown .caret { content: ""; border-top: 0; border-bottom: 4px solid; } .dropup .dropdown-menu, .navbar-fixed-bottom .dropdown .dropdown-menu { top: auto; bottom: 100%; margin-bottom: 2px; } @media (min-width: 768px) { .navbar-right .dropdown-menu { right: 0; left: auto; } .navbar-right .dropdown-menu-left { right: auto; left: 0; } } @font-face { font-family: 'Glyphicons Halflings'; src: url('../fonts/glyphicons-halflings-regular.eot'); src: url('../fonts/glyphicons-halflings-regular.eot?#iefix') format('embedded-opentype'), url('../fonts/glyphicons-halflings-regular.woff2') format('woff2'), url('../fonts/glyphicons-halflings-regular.woff') format('woff'), url('../fonts/glyphicons-halflings-regular.ttf') format('truetype'), url('../fonts/glyphicons-halflings-regular.svg#glyphicons_halflingsregular') format('svg'); } .glyphicon { position: relative; top: 1px; display: inline-block; font-family: 'Glyphicons Halflings'; font-style: normal; font-weight: normal; line-height: 1; -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; } span.glyphicon.glyphicon-time { margin-right: 3px; } #liusername span.glyphicon { color: white; } .thoat span.glyphicon { font-size: x-large; top: 0; } .thoat { text-align: center; } .thoat { } .glyphicon-asterisk:before { content: "\2a"; } .glyphicon-plus:before { content: "\2b"; } .glyphicon-euro:before, .glyphicon-eur:before { content: "\20ac"; } .glyphicon-minus:before { content: "\2212"; } .glyphicon-cloud:before { content: "\2601"; } .glyphicon-envelope:before { content: "\2709"; } .glyphicon-pencil:before { content: "\270f"; } .glyphicon-glass:before { content: "\e001"; } .glyphicon-music:before { content: "\e002"; } .glyphicon-search:before { content: "\e003"; } .glyphicon-heart:before { content: "\e005"; } .glyphicon-star:before { content: "\e006"; } .glyphicon-star-empty:before { content: "\e007"; } .glyphicon-user:before { content: "\e008"; } .glyphicon-film:before { content: "\e009"; } .glyphicon-th-large:before { content: "\e010"; } .glyphicon-th:before { content: "\e011"; } .glyphicon-th-list:before { content: "\e012"; } .glyphicon-ok:before { content: "\e013"; } .glyphicon-remove:before { content: "\e014"; } .glyphicon-zoom-in:before { content: "\e015"; } .glyphicon-zoom-out:before { content: "\e016"; } .glyphicon-off:before { content: "\e017"; } .glyphicon-signal:before { content: "\e018"; } .glyphicon-cog:before { content: "\e019"; } .glyphicon-trash:before { content: "\e020"; } .glyphicon-home:before { content: "\e021"; } .glyphicon-file:before { content: "\e022"; } .glyphicon-time:before { content: "\e023"; } .glyphicon-road:before { content: "\e024"; } .glyphicon-download-alt:before { content: "\e025"; } .glyphicon-download:before { content: "\e026"; } .glyphicon-upload:before { content: "\e027"; } .glyphicon-inbox:before { content: "\e028"; } .glyphicon-play-circle:before { content: "\e029"; } .glyphicon-repeat:before { content: "\e030"; } .glyphicon-refresh:before { content: "\e031"; } .glyphicon-list-alt:before { content: "\e032"; } .glyphicon-lock:before { content: "\e033"; } .glyphicon-flag:before { content: "\e034"; } .glyphicon-headphones:before { content: "\e035"; } .glyphicon-volume-off:before { content: "\e036"; } .glyphicon-volume-down:before { content: "\e037"; } .glyphicon-volume-up:before { content: "\e038"; } .glyphicon-qrcode:before { content: "\e039"; } .glyphicon-barcode:before { content: "\e040"; } .glyphicon-tag:before { content: "\e041"; } .glyphicon-tags:before { content: "\e042"; } .glyphicon-book:before { content: "\e043"; } .glyphicon-bookmark:before { content: "\e044"; } .glyphicon-print:before { content: "\e045"; } .glyphicon-camera:before { content: "\e046"; } .glyphicon-font:before { content: "\e047"; } .glyphicon-bold:before { content: "\e048"; } .glyphicon-italic:before { content: "\e049"; } .glyphicon-text-height:before { content: "\e050"; } .glyphicon-text-width:before { content: "\e051"; } .glyphicon-align-left:before { content: "\e052"; } .glyphicon-align-center:before { content: "\e053"; } .glyphicon-align-right:before { content: "\e054"; } .glyphicon-align-justify:before { content: "\e055"; } .glyphicon-list:before { content: "\e056"; } .glyphicon-indent-left:before { content: "\e057"; } .glyphicon-indent-right:before { content: "\e058"; } .glyphicon-facetime-video:before { content: "\e059"; } .glyphicon-picture:before { content: "\e060"; } .glyphicon-map-marker:before { content: "\e062"; } .glyphicon-adjust:before { content: "\e063"; } .glyphicon-tint:before { content: "\e064"; } .glyphicon-edit:before { content: "\e065"; } .glyphicon-share:before { content: "\e066"; } .glyphicon-check:before { content: "\e067"; } .glyphicon-move:before { content: "\e068"; } .glyphicon-step-backward:before { content: "\e069"; } .glyphicon-fast-backward:before { content: "\e070"; } .glyphicon-backward:before { content: "\e071"; } .glyphicon-play:before { content: "\e072"; } .glyphicon-pause:before { content: "\e073"; } .glyphicon-stop:before { content: "\e074"; } .glyphicon-forward:before { content: "\e075"; } .glyphicon-fast-forward:before { content: "\e076"; } .glyphicon-step-forward:before { content: "\e077"; } .glyphicon-eject:before { content: "\e078"; } .glyphicon-chevron-left:before { content: "\e079"; } .glyphicon-chevron-right:before { content: "\e080"; } .glyphicon-plus-sign:before { content: "\e081"; } .glyphicon-minus-sign:before { content: "\e082"; } .glyphicon-remove-sign:before { content: "\e083"; } .glyphicon-ok-sign:before { content: "\e084"; } .glyphicon-question-sign:before { content: "\e085"; } .glyphicon-info-sign:before { content: "\e086"; } .glyphicon-screenshot:before { content: "\e087"; } .glyphicon-remove-circle:before { content: "\e088"; } .glyphicon-ok-circle:before { content: "\e089"; } .glyphicon-ban-circle:before { content: "\e090"; } .glyphicon-arrow-left:before { content: "\e091"; } .glyphicon-arrow-right:before { content: "\e092"; } .glyphicon-arrow-up:before { content: "\e093"; } .glyphicon-arrow-down:before { content: "\e094"; } .glyphicon-share-alt:before { content: "\e095"; } .glyphicon-resize-full:before { content: "\e096"; } .glyphicon-resize-small:before { content: "\e097"; } .glyphicon-exclamation-sign:before { content: "\e101"; } .glyphicon-gift:before { content: "\e102"; } .glyphicon-leaf:before { content: "\e103"; } .glyphicon-fire:before { content: "\e104"; } .glyphicon-eye-open:before { content: "\e105"; } .glyphicon-eye-close:before { content: "\e106"; } .glyphicon-warning-sign:before { content: "\e107"; } .glyphicon-plane:before { content: "\e108"; } .glyphicon-calendar:before { content: "\e109"; } .glyphicon-random:before { content: "\e110"; } .glyphicon-comment:before { content: "\e111"; } .glyphicon-magnet:before { content: "\e112"; } .glyphicon-chevron-up:before { content: "\e113"; } .glyphicon-chevron-down:before { content: "\e114"; } .glyphicon-retweet:before { content: "\e115"; } .glyphicon-shopping-cart:before { content: "\e116"; } .glyphicon-folder-close:before { content: "\e117"; } .glyphicon-folder-open:before { content: "\e118"; } .glyphicon-resize-vertical:before { content: "\e119"; } .glyphicon-resize-horizontal:before { content: "\e120"; } .glyphicon-hdd:before { content: "\e121"; } .glyphicon-bullhorn:before { content: "\e122"; } .glyphicon-bell:before { content: "\e123"; } .glyphicon-certificate:before { content: "\e124"; } .glyphicon-thumbs-up:before { content: "\e125"; } .glyphicon-thumbs-down:before { content: "\e126"; } .glyphicon-hand-right:before { content: "\e127"; } .glyphicon-hand-left:before { content: "\e128"; } .glyphicon-hand-up:before { content: "\e129"; } .glyphicon-hand-down:before { content: "\e130"; } .glyphicon-circle-arrow-right:before { content: "\e131"; } .glyphicon-circle-arrow-left:before { content: "\e132"; } .glyphicon-circle-arrow-up:before { content: "\e133"; } .glyphicon-circle-arrow-down:before { content: "\e134"; } .glyphicon-globe:before { content: "\e135"; } .glyphicon-wrench:before { content: "\e136"; } .glyphicon-tasks:before { content: "\e137"; } .glyphicon-filter:before { content: "\e138"; } .glyphicon-briefcase:before { content: "\e139"; } .glyphicon-fullscreen:before { content: "\e140"; } .glyphicon-dashboard:before { content: "\e141"; } .glyphicon-paperclip:before { content: "\e142"; } .glyphicon-heart-empty:before { content: "\e143"; } .glyphicon-link:before { content: "\e144"; } .glyphicon-phone:before { content: "\e145"; } .glyphicon-pushpin:before { content: "\e146"; } .glyphicon-usd:before { content: "\e148"; } .glyphicon-gbp:before { content: "\e149"; } .glyphicon-sort:before { content: "\e150"; } .glyphicon-sort-by-alphabet:before { content: "\e151"; } .glyphicon-sort-by-alphabet-alt:before { content: "\e152"; } .glyphicon-sort-by-order:before { content: "\e153"; } .glyphicon-sort-by-order-alt:before { content: "\e154"; } .glyphicon-sort-by-attributes:before { content: "\e155"; } .glyphicon-sort-by-attributes-alt:before { content: "\e156"; } .glyphicon-unchecked:before { content: "\e157"; } .glyphicon-expand:before { content: "\e158"; } .glyphicon-collapse-down:before { content: "\e159"; } .glyphicon-collapse-up:before { content: "\e160"; } .glyphicon-log-in:before { content: "\e161"; } .glyphicon-flash:before { content: "\e162"; } .glyphicon-log-out:before { content: "\e163"; } .glyphicon-new-window:before { content: "\e164"; } .glyphicon-record:before { content: "\e165"; } .glyphicon-save:before { content: "\e166"; } .glyphicon-open:before { content: "\e167"; } .glyphicon-saved:before { content: "\e168"; } .glyphicon-import:before { content: "\e169"; } .glyphicon-export:before { content: "\e170"; } .glyphicon-send:before { content: "\e171"; } .glyphicon-floppy-disk:before { content: "\e172"; } .glyphicon-floppy-saved:before { content: "\e173"; } .glyphicon-floppy-remove:before { content: "\e174"; } .glyphicon-floppy-save:before { content: "\e175"; } .glyphicon-floppy-open:before { content: "\e176"; } .glyphicon-credit-card:before { content: "\e177"; } .glyphicon-transfer:before { content: "\e178"; } .glyphicon-cutlery:before { content: "\e179"; } .glyphicon-header:before { content: "\e180"; } .glyphicon-compressed:before { content: "\e181"; } .glyphicon-earphone:before { content: "\e182"; } .glyphicon-phone-alt:before { content: "\e183"; } .glyphicon-tower:before { content: "\e184"; } .glyphicon-stats:before { content: "\e185"; } .glyphicon-sd-video:before { content: "\e186"; } .glyphicon-hd-video:before { content: "\e187"; } .glyphicon-subtitles:before { content: "\e188"; } .glyphicon-sound-stereo:before { content: "\e189"; } .glyphicon-sound-dolby:before { content: "\e190"; } .glyphicon-sound-5-1:before { content: "\e191"; } .glyphicon-sound-6-1:before { content: "\e192"; } .glyphicon-sound-7-1:before { content: "\e193"; } .glyphicon-copyright-mark:before { content: "\e194"; } .glyphicon-registration-mark:before { content: "\e195"; } .glyphicon-cloud-download:before { content: "\e197"; } .glyphicon-cloud-upload:before { content: "\e198"; } .glyphicon-tree-conifer:before { content: "\e199"; } .glyphicon-tree-deciduous:before { content: "\e200"; } .glyphicon-cd:before { content: "\e201"; } .glyphicon-save-file:before { content: "\e202"; } .glyphicon-open-file:before { content: "\e203"; } .glyphicon-level-up:before { content: "\e204"; } .glyphicon-copy:before { content: "\e205"; } .glyphicon-paste:before { content: "\e206"; } .glyphicon-alert:before { content: "\e209"; } .glyphicon-equalizer:before { content: "\e210"; } .glyphicon-king:before { content: "\e211"; } .glyphicon-queen:before { content: "\e212"; } .glyphicon-pawn:before { content: "\e213"; } .glyphicon-bishop:before { content: "\e214"; } .glyphicon-knight:before { content: "\e215"; } .glyphicon-baby-formula:before { content: "\e216"; } .glyphicon-tent:before { content: "\26fa"; } .glyphicon-blackboard:before { content: "\e218"; } .glyphicon-bed:before { content: "\e219"; } .glyphicon-apple:before { content: "\f8ff"; } .glyphicon-erase:before { content: "\e221"; } .glyphicon-hourglass:before { content: "\231b"; } .glyphicon-lamp:before { content: "\e223"; } .glyphicon-duplicate:before { content: "\e224"; } .glyphicon-piggy-bank:before { content: "\e225"; } .glyphicon-scissors:before { content: "\e226"; } .glyphicon-bitcoin:before { content: "\e227"; } .glyphicon-btc:before { content: "\e227"; } .glyphicon-xbt:before { content: "\e227"; } .glyphicon-yen:before { content: "\00a5"; } .glyphicon-jpy:before { content: "\00a5"; } .glyphicon-ruble:before { content: "\20bd"; } .glyphicon-rub:before { content: "\20bd"; } .glyphicon-scale:before { content: "\e230"; } .glyphicon-ice-lolly:before { content: "\e231"; } .glyphicon-ice-lolly-tasted:before { content: "\e232"; } .glyphicon-education:before { content: "\e233"; } .glyphicon-option-horizontal:before { content: "\e234"; } .glyphicon-option-vertical:before { content: "\e235"; } .glyphicon-menu-hamburger:before { content: "\e236"; } .glyphicon-modal-window:before { content: "\e237"; } .glyphicon-oil:before { content: "\e238"; } .glyphicon-grain:before { content: "\e239"; } .glyphicon-sunglasses:before { content: "\e240"; } .glyphicon-text-size:before { content: "\e241"; } .glyphicon-text-color:before { content: "\e242"; } .glyphicon-text-background:before { content: "\e243"; } .glyphicon-object-align-top:before { content: "\e244"; } .glyphicon-object-align-bottom:before { content: "\e245"; } .glyphicon-object-align-horizontal:before { content: "\e246"; } .glyphicon-object-align-left:before { content: "\e247"; } .glyphicon-object-align-vertical:before { content: "\e248"; } .glyphicon-object-align-right:before { content: "\e249"; } .glyphicon-triangle-right:before { content: "\e250"; } .glyphicon-triangle-left:before { content: "\e251"; } .glyphicon-triangle-bottom:before { content: "\e252"; } .glyphicon-triangle-top:before { content: "\e253"; } .glyphicon-console:before { content: "\e254"; } .glyphicon-superscript:before { content: "\e255"; } .glyphicon-subscript:before { content: "\e256"; } .glyphicon-menu-left:before { content: "\e257"; } .glyphicon-menu-right:before { content: "\e258"; } .glyphicon-menu-down:before { content: "\e259"; } .glyphicon-menu-up:before { content: "\e260"; }
ltlam93/UNETI.FIT
UNETI.FIT/Content/Main.css
CSS
gpl-2.0
69,740
/* * Copyright (C) 2014-2017 StormCore * * 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, see <http://www.gnu.org/licenses/>. */ #ifndef TRINITYCORE_TOTEM_H #define TRINITYCORE_TOTEM_H #include "TemporarySummon.h" enum TotemType { TOTEM_PASSIVE = 0, TOTEM_ACTIVE = 1, TOTEM_STATUE = 2 // copied straight from MaNGOS, may need more implementation to work }; class TC_GAME_API Totem : public Minion { public: Totem(SummonPropertiesEntry const* properties, Unit* owner); virtual ~Totem() { } void Update(uint32 time) override; void InitStats(uint32 duration) override; void InitSummon() override; void UnSummon(uint32 msTime = 0) override; uint32 GetSpell(uint8 slot = 0) const { return m_spells[slot]; } uint32 GetTotemDuration() const { return m_duration; } void SetTotemDuration(uint32 duration) { m_duration = duration; } TotemType GetTotemType() const { return m_type; } bool UpdateStats(Stats /*stat*/) override { return true; } bool UpdateAllStats() override { return true; } void UpdateResistances(uint32 /*school*/) override { } void UpdateArmor() override { } void UpdateMaxHealth() override { } void UpdateMaxPower(Powers /*power*/) override { } void UpdateAttackPowerAndDamage(bool /*ranged*/) override { } void UpdateDamagePhysical(WeaponAttackType /*attType*/) override { } bool IsImmunedToSpellEffect(SpellInfo const* spellInfo, uint32 index) const override; protected: TotemType m_type; uint32 m_duration; }; #endif
Ragebones/StormCore
src/server/game/Entities/Totem/Totem.h
C
gpl-2.0
2,197
#!/usr/bin/perl -w # # This script generates a C header file that maps the target device (as # indicated via the sdcc generated -Dpic18fxxx macro) to its device # family and the device families to their respective style of ADC and # USART programming for use in the SDCC PIC16 I/O library. # # Copyright 2010 Raphael Neider <rneider AT web.de> # # This file is part of SDCC. # # SDCC 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. # # SDCC 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 SDCC. If not, see <http://www.gnu.org/licenses/>. # # # Usage: perl pic18fam-h-gen.pl # # This will create pic18fam.h.gen in your current directory. # Check sanity of the file and move it to .../include/pic16/pic18fam.h. # If you assigned new I/O styles, implement them in # .../include/pic16/{adc,i2c,usart}.h and # .../lib/pic16/libio/*/*.c # use strict; my $head = '__SDCC_PIC'; my %families = (); my %adc = (); my %usart = (); my $update = "Please update your pic16/pic18fam.h manually and/or inform the maintainer."; while (<DATA>) { chomp; s/\s*#.*$//; # remove comments s/\s*//g; # strip whitespace next if (/^\s*$/); # ignore empty lines my $line = $_; my @fields = split(/:/, $line); die "Invalid record >$line<" if (4 != scalar @fields); my ($id, $memberlist, $adcstyle, $usartstyle) = @fields; # extract numeric family id $id = 0+$id; # extract family members my @arr = split(/,/, $memberlist); @arr = sort(map { uc($_); } @arr); $families{$id} = \@arr; # ADC style per device family $adcstyle = 0+$adcstyle; if (not defined $adc{$adcstyle}) { $adc{$adcstyle} = []; } # if push @{$adc{$adcstyle}}, $id; # (E)USART style per device family $usartstyle = 0+$usartstyle; if (not defined $usart{$usartstyle}) { $usart{$usartstyle} = []; } # if push @{$usart{$usartstyle}}, $id; } my $fname = "pic18fam.h.gen"; open(FH, ">", "$fname") or die "Could not open >$fname<"; print FH <<EOT /* * pic18fam.h - PIC16 families * * This file is has been generated using $0 . */ #ifndef __SDCC_PIC18FAM_H__ #define __SDCC_PIC18FAM_H__ 1 /* * Define device families. */ #undef __SDCC_PIC16_FAMILY EOT ; my $pp = "#if "; for my $id (sort keys %families) { my $list = $families{$id}; my $memb = "defined($head" . join(") \\\n || defined($head", @$list) . ")"; print FH <<EOT ${pp} ${memb} #define __SDCC_PIC16_FAMILY ${id} EOT ; $pp = "#elif "; } # for print FH <<EOT #else #warning No family associated with the target device. ${update} #endif /* * Define ADC style per device family. */ #undef __SDCC_ADC_STYLE EOT ; $pp = "#if "; for my $s (sort keys %adc) { my $fams = join (" \\\n || ", map { "(__SDCC_PIC16_FAMILY == $_)" } sort @{$adc{$s}}); print FH <<EOT ${pp} ${fams} #define __SDCC_ADC_STYLE ${s} EOT ; $pp = "#elif "; } # for print FH <<EOT #else #warning No ADC style associated with the target device. ${update} #endif /* * Define (E)USART style per device family. */ #undef __SDCC_USART_STYLE EOT ; $pp = "#if "; for my $s (sort keys %usart) { my $fams = join (" \\\n || ", map { "(__SDCC_PIC16_FAMILY == $_)" } sort @{$usart{$s}}); print FH <<EOT ${pp} ${fams} #define __SDCC_USART_STYLE ${s} EOT ; $pp = "#elif "; } # for print FH <<EOT #else #warning No (E)USART style associated with the target device. ${update} #endif EOT ; print FH <<EOT #endif /* !__SDCC_PIC18FAM_H__ */ EOT ; __END__ # # <id>:<head>{,<member>}:<adc>:<usart> # # Each line provides a colon separated list of # * a numeric family name, derived from the first family member as follows: # - 18F<num> -> printf("18%04d0", <num>) # - 18F<num1>J<num2> -> printf("18%02d%02d1", <num1>, <num2>) # - 18F<num1>K<num2> -> printf("18%02d%02d2", <num1>, <num2>) # * a comma-separated list of members of a device family, # where a family comprises all devices that share a single data sheet, # * the ADC style (numeric family name or 0, if not applicable) # * the USART style (numeric family name or 0, if not applicable) # # This data has been gathered manually from data sheets published by # Microchip Technology Inc. # 1812200:18f1220,18f1320:1812200:1812200 1812300:18f1230,18f1330:1812300:1812300 1813502:18f13k50,18f14k50:1813502:1813502 1822200:18f2220,18f2320,18f4220,18f4320:1822200:1822200 1822210:18f2221,18f2321,18f4221,18f4321:1822200:1822210 1823310:18f2331,18f2431,18f4331,18f4431:0:1822210 1823202:18f23k20,18f24k20,18f25k20,18f26k20,18f43k20,18f44k20,18f45k20,18f46k20:1822200:1822210 1823222:18f23k22,18f24k22,18f25k22,18f26k22,18f43k22,18f44k22,18f45k22,18f46k22:1823222:1822210 1824100:18f2410,18f2510,18f2515,18f2610,18f4410,18f4510,18f4515,18f4610:1822200:1822210 1802420:18f242,18f252,18f442,18f452:1802420:1822200 # TODO: verify family members and USART 1824200:18f2420,18f2520,18f4420,18f4520:1822200:1822210 1824230:18f2423,18f2523,18f4423,18f4523:1822200:1822210 1824500:18f2450,18f4450:1822200:1824500 1824550:18f2455,18f2550,18f4455,18f4550:1822200:1822210 1802480:18f248,18f258,18f448,18f458:1802420:1822200 # TODO: verify family members and USART 1824800:18f2480,18f2580,18f4480,18f4580:1822200:1824500 1824101:18f24j10,18f25j10,18f44j10,18f45j10:1822200:1822210 1824501:18f24j50,18f25j50,18f26j50,18f44j50,18f45j50,18f46j50:1824501:1824501 1825250:18f2525,18f2620,18f4525,18f4620:1822200:1822210 1825850:18f2585,18f2680,18f4585,18f4680:1822200:1824500 1826820:18f2682,18f2685,18f4682,18f4685:1822200:1824500 1865200:18f6520,18f6620,18f6720,18f8520,18f8620,18f8720:1822200:1865200 1865270:18f6527,18f6622,18f6627,18f6722,18f8527,18f8622,18f8627,18f8722:1822200:1824501 1865850:18f6585,18f6680,18f8585,18f8680:1822200:1822200 # TODO: verify family members and USART 1865501:18f65j50,18f66j50,18f66j55,18f67j50,18f85j50,18f86j50,18f86j55,18f87j50:1865501:1824501 1866601:18f66j60,18f66j65,18f67j60,18f86j60,18f86j65,18f87j60,18f96j60,18f96j65,18f97j60:1822200:1824501
atsidaev/sdcc-z80-gas
support/scripts/pic18fam-h-gen.pl
Perl
gpl-2.0
6,558
<?php /** * ifeelweb.de WordPress Plugin Framework * For more information see http://www.ifeelweb.de/wp-plugin-framework * * Adapter to use ZendFramework as admin application * * @author Timo Reith <[email protected]> * @copyright Copyright (c) ifeelweb.de * @version $Id: ZendFw.php 911603 2014-05-10 10:58:23Z worschtebrot $ * @package IfwPsn_Wp_Plugin_Application */ require_once dirname(__FILE__) . '/Interface.php'; class IfwPsn_Wp_Plugin_Application_Adapter_ZendFw implements IfwPsn_Wp_Plugin_Application_Adapter_Interface { /** * @var IfwPsn_Wp_Plugin_Manager */ protected $_pm; /** * @var IfwPsn_Zend_Application */ protected $_application; /** * @var string */ protected $_output; /** * The default error reporting level * @var int */ protected $_errorReporting; /** * @param IfwPsn_Wp_Plugin_Manager $pm */ public function __construct (IfwPsn_Wp_Plugin_Manager $pm) { $this->_pm = $pm; } /** * Loads the admin application */ public function load() { $this->_registerAutostart(); require_once $this->_pm->getPathinfo()->getRootLib() . 'IfwPsn/Zend/Application.php'; $this->_application = new IfwPsn_Zend_Application($this->_pm->getEnv()->getEnvironmet()); // set the dynamic options from php config file $this->_application->setOptions($this->_getApplicationOptions()); // run the application bootstrap $this->_pm->getLogger()->logPrefixed('Bootstrapping application...'); $this->_application->bootstrap(); } /** * */ protected function _registerAutostart() { require_once $this->_pm->getPathinfo()->getRootLib() . 'IfwPsn/Wp/Plugin/Application/Adapter/ZendFw/Autostart/EnqueueScripts.php'; require_once $this->_pm->getPathinfo()->getRootLib() . 'IfwPsn/Wp/Plugin/Application/Adapter/ZendFw/Autostart/StripSlashes.php'; require_once $this->_pm->getPathinfo()->getRootLib() . 'IfwPsn/Wp/Plugin/Application/Adapter/ZendFw/Autostart/ZendFormTranslation.php'; $result = array( new IfwPsn_Wp_Plugin_Application_Adapter_ZendFw_Autostart_EnqueueScripts($this), new IfwPsn_Wp_Plugin_Application_Adapter_ZendFw_Autostart_StripSlashes($this), new IfwPsn_Wp_Plugin_Application_Adapter_ZendFw_Autostart_ZendFormTranslation($this), ); foreach($result as $autostart) { $autostart->execute(); } } /** * Retrieves the application options * @return array */ protected function _getApplicationOptions() { $options = include $this->_pm->getPathinfo()->getRootAdminMenu() . 'configs/application.php'; if ($this->_pm->getEnv()->getEnvironmet() == 'development') { $options['resources']['FrontController']['params']['displayExceptions'] = 1; $options['phpSettings']['error_reporting'] = 6143; // E_ALL & ~E_STRICT $options['phpSettings']['display_errors'] = 1; $options['phpSettings']['display_startup_errors'] = 1; } return $options; } /** * @param $controllerName * @param string $module */ public function overwriteController($controllerName, $module = 'default') { $front = IfwPsn_Zend_Controller_Front::getInstance(); $request = new IfwPsn_Vendor_Zend_Controller_Request_Http(); $request->setParam('controller', $controllerName); $request->setParam('mod', $module); $front->setRequest($request); } /** * Inits the controller */ public function init() { $this->_activateErrorReporting(); try { // init the controller object to add actions before load-{page-id} action $this->_application->initController(); } catch (Exception $e) { $this->_handleException($e); } $this->_deactivateErrorReporting(); } /** * @return mixed|void */ public function render() { $this->_activateErrorReporting(); try { $this->_output = $this->_application->run(); } catch (Exception $e) { $this->_handleException($e); } $this->_deactivateErrorReporting(); } /** * @return mixed|void */ public function display() { $this->_activateErrorReporting(); try { echo $this->_output; } catch (Exception $e) { $this->_handleException($e); } $this->_deactivateErrorReporting(); } /** * Activates the error reporting in dev mode */ protected function _activateErrorReporting() { // store the default error level $this->_errorReporting = error_reporting(); if ($this->_pm->getEnv()->getEnvironmet() == 'development' || $this->_pm->getConfig()->debug->show_errors == '1') { // E_ALL & ~E_STRICT error_reporting(6143); } } /** * Resets the error reporting to default in dev mode */ protected function _deactivateErrorReporting() { if ($this->_pm->getEnv()->getEnvironmet() == 'development' || $this->_pm->getConfig()->debug->show_errors == '1') { error_reporting($this->_errorReporting); } } /** * @param Exception $e */ protected function _handleException(Exception $e) { $this->_pm->getLogger()->error($e->getMessage()); $request = IfwPsn_Zend_Controller_Front::getInstance()->getRequest(); // Repoint the request to the default error handler // $request->setModuleName('default'); // $request->setControllerName('Psn-ewrror'); // $request->setActionName('error'); // Set up the error handler $error = new IfwPsn_Vendor_Zend_Controller_Plugin_ErrorHandler(array( 'controller' => $this->_pm->getAbbrLower() . '-error' )); $error->type = IfwPsn_Vendor_Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_CONTROLLER; $error->request = clone($request); $error->exception = $e; $request->setParam('error_handler', $error); } /** * @return IfwPsn_Wp_Plugin_Manager */ public function getPluginManager() { return $this->_pm; } }
brasadesign/wpecotemporadas
wp-content/plugins/post-status-notifier-lite/lib/IfwPsn/Wp/Plugin/Application/Adapter/ZendFw.php
PHP
gpl-2.0
6,435
#ifndef _FFNet_Pattern_h_ #define _FFNet_Pattern_h_ /* FFNet_Pattern.h * * Copyright (C) 1997-2011, 2015 David Weenink * * 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., 675 Mass Ave, Cambridge, MA 02139, USA. */ /* djmw 19950113 djmw 20020712 GPL header djmw 20110307 Latest modification */ #include "Pattern.h" #include "FFNet.h" void FFNet_Pattern_drawActivation( FFNet me, Pattern pattern, Graphics g, long ipattern ); #endif /* _FFNet_Pattern_h_ */
motiz88/praat
FFNet/FFNet_Pattern.h
C
gpl-2.0
1,073
/*************************************************************************** * Project TUPITUBE DESK * * Project Contact: [email protected] * * Project Website: http://www.maefloresta.com * * Project Leader: Gustav Gonzalez <[email protected]> * * * * Developers: * * 2010: * * Gustavo Gonzalez / xtingray * * * * KTooN's versions: * * * * 2006: * * David Cuadrado * * Jorge Cuadrado * * 2003: * * Fernado Roldan * * Simena Dinas * * * * Copyright (C) 2010 Gustav Gonzalez - http://www.maefloresta.com * * License: * * 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, see <http://www.gnu.org/licenses/>. * ***************************************************************************/ #ifndef TUPSOUNDPLAYER_H #define TUPSOUNDPLAYER_H #include "tglobal.h" #include "timagebutton.h" #include "tapplicationproperties.h" #include "tuplibraryobject.h" #include <QFrame> #include <QBoxLayout> #include <QSlider> #include <QLabel> #include <QSpinBox> #include <QMediaPlayer> #include <QUrl> #include <QTime> #include <QCheckBox> /** * @author Gustav Gonzalez **/ class TUPITUBE_EXPORT TupSoundPlayer : public QFrame { Q_OBJECT public: TupSoundPlayer(QWidget *parent = nullptr); ~TupSoundPlayer(); QSize sizeHint() const; void setSoundParams(TupLibraryObject *sound); void stopFile(); bool isPlaying(); void reset(); QString getSoundID() const; void updateInitFrame(int frame); void enableLipSyncInterface(bool enabled, int frame); signals: void frameUpdated(int frame); void muteEnabled(bool mute); private slots: void playFile(); void startPlayer(); void positionChanged(qint64 value); void durationChanged(qint64 value); void stateChanged(QMediaPlayer::State state); void updateSoundPos(int pos); void updateLoopState(); void muteAction(); private: QLabel *frameLabel; QMediaPlayer *player; QSlider *slider; QLabel *timer; TImageButton *playButton; TImageButton *muteButton; bool playing; qint64 duration; QTime soundTotalTime; QString totalTime; QCheckBox *loopBox; bool loop; bool mute; QSpinBox *frameBox; QWidget *frameWidget; QString soundID; }; #endif
xtingray/tupitube.desk
src/components/library/tupsoundplayer.h
C
gpl-2.0
4,307
/* * arch/arm/mach-tegra/baseband-xmm-power.c * * Copyright (C) 2011 NVIDIA Corporation * * This software is licensed under the terms of the GNU General Public * License version 2, as published by the Free Software Foundation, and * may be copied, distributed, and modified under those terms. * * 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 <linux/kernel.h> #include <linux/init.h> #include <linux/module.h> #include <linux/moduleparam.h> #include <linux/platform_device.h> #include <linux/gpio.h> #include <linux/interrupt.h> #include <linux/workqueue.h> #include <linux/slab.h> #include <linux/delay.h> #include <linux/fs.h> #include <linux/uaccess.h> #include <linux/wakelock.h> #include <linux/spinlock.h> #include <linux/usb.h> #include <linux/pm_runtime.h> #include <linux/suspend.h> #include <mach/usb_phy.h> #include "board.h" #include "devices.h" #include <mach/board_htc.h> #include <linux/pm_qos_params.h> #include <asm/mach-types.h> #include "gpio-names.h" #include "baseband-xmm-power.h" MODULE_LICENSE("GPL"); unsigned long modem_ver = XMM_MODEM_VER_1130; /* * HTC: version history * * v04 - bert_lin - 20111025 * 1. remove completion & wait for probe race, use nv solution instead * 2. add a attribute for host usb debugging * v05 - bert_lin - 20111026 * 1. sync patch from nv michael. re-arrange the first_time var * after flight off, device cant goes to L2 suspend * 2. modify the files to meet the coding style * v06 - bert_lin - 20111026 * 1. item 12: L0 -> flight -> suspend fail because of wakelock holding * check wakelock in L3 and release it if neccessary * v07 - bert_lin - 20111104 * workaround for item 18, AP L2->L0 fail! submit urb return -113 * add more logs on usb_chr for modem download issue * v08 - bert_lin - 20111125 * workaround, origin l3 -> host_wake -> deepsleep * after: L3 -> host_wakeup -> noirq suspend fail -> resume * v09 - bert_lin - 20111214 * autopm * v10 - bert_lin - 20111226 * log reduce */ /* HTC: macro, variables */ #include <mach/htc_hostdbg.h> #define MODULE_NAME "[XMM_v15]" unsigned int host_dbg_flag = 0; EXPORT_SYMBOL(host_dbg_flag); /* HTC: provide interface for user space to enable usb host debugging */ static ssize_t host_dbg_show(struct device *dev, struct device_attribute *attr, char *buf); static ssize_t host_dbg_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t size); static DEVICE_ATTR(host_dbg, 0664, host_dbg_show, host_dbg_store); /* HTC: Create attribute for host debug purpose */ static ssize_t host_dbg_show(struct device *dev, struct device_attribute *attr, char *buf) { int ret = -EINVAL; ret = sprintf(buf, "%x\n", host_dbg_flag); return ret; } /** * HTC: get the runtime debug flags from user. * * @buf: user strings * @size: user strings plus one 0x0a char */ static ssize_t host_dbg_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t size) { const int hedge = 2 + 8 + 1; /* hedge: "0x" 2 chars, max: 8 chars, plus one 0x0a char */ pr_info(MODULE_NAME "%s size = %d\n", __func__, size); if (size > hedge) { pr_info(MODULE_NAME "%s size > hedge:%d, return\n", __func__, hedge); return size; } host_dbg_flag = simple_strtoul(buf, NULL, 16); pr_info(MODULE_NAME "%s set host_dbg_flag as 0x%08x\n", __func__, host_dbg_flag); return size; } /*============================================================*/ struct pm_qos_request_list modem_boost_cpu_freq_req; EXPORT_SYMBOL_GPL(modem_boost_cpu_freq_req); #define BOOST_CPU_FREQ_MIN 1500000 EXPORT_SYMBOL(modem_ver); unsigned long modem_flash; EXPORT_SYMBOL(modem_flash); unsigned long modem_pm = 1; EXPORT_SYMBOL(modem_pm); unsigned long autosuspend_delay = 3000; /* 5000 msec */ EXPORT_SYMBOL(autosuspend_delay); unsigned long enum_delay_ms = 1000; /* ignored if !modem_flash */ module_param(modem_ver, ulong, 0644); MODULE_PARM_DESC(modem_ver, "baseband xmm power - modem software version"); module_param(modem_flash, ulong, 0644); MODULE_PARM_DESC(modem_flash, "baseband xmm power - modem flash (1 = flash, 0 = flashless)"); module_param(modem_pm, ulong, 0644); MODULE_PARM_DESC(modem_pm, "baseband xmm power - modem power management (1 = pm, 0 = no pm)"); module_param(enum_delay_ms, ulong, 0644); MODULE_PARM_DESC(enum_delay_ms, "baseband xmm power - delay in ms between modem on and enumeration"); module_param(autosuspend_delay, ulong, 0644); MODULE_PARM_DESC(autosuspend_delay, "baseband xmm power - autosuspend delay for autopm"); #define auto_sleep(x) \ if (in_interrupt() || in_atomic())\ mdelay(x);\ else\ msleep(x); static bool short_autosuspend; static int short_autosuspend_delay = 100; static struct usb_device_id xmm_pm_ids[] = { { USB_DEVICE(VENDOR_ID, PRODUCT_ID), .driver_info = 0 }, {} }; //for power on modem static struct gpio tegra_baseband_gpios[] = { { -1, GPIOF_OUT_INIT_LOW, "BB_RSTn" }, { -1, GPIOF_OUT_INIT_LOW, "BB_ON" }, { -1, GPIOF_OUT_INIT_LOW, "IPC_BB_WAKE" }, { -1, GPIOF_IN, "IPC_AP_WAKE" }, { -1, GPIOF_OUT_INIT_HIGH, "IPC_HSIC_ACTIVE" }, { -1, GPIOF_OUT_INIT_LOW, "IPC_HSIC_SUS_REQ" }, { -1, GPIOF_OUT_INIT_LOW, "BB_VDD_EN" }, { -1, GPIOF_OUT_INIT_LOW, "AP2BB_RST_PWRDWNn" }, { -1, GPIOF_IN, "BB2AP_RST2" }, }; /*HTC*/ //for power consumation , power off modem static struct gpio tegra_baseband_gpios_power_off_modem[] = { { -1, GPIOF_OUT_INIT_LOW, "BB_RSTn" }, { -1, GPIOF_OUT_INIT_LOW, "BB_ON" }, { -1, GPIOF_OUT_INIT_LOW, "IPC_BB_WAKE" }, { -1, GPIOF_OUT_INIT_LOW, "IPC_AP_WAKE" }, { -1, GPIOF_OUT_INIT_LOW, "IPC_HSIC_ACTIVE" }, { -1, GPIOF_OUT_INIT_LOW, "IPC_HSIC_SUS_REQ" }, { -1, GPIOF_OUT_INIT_LOW, "BB_VDD_EN" }, { -1, GPIOF_OUT_INIT_LOW, "AP2BB_RST_PWRDWNn" }, { -1, GPIOF_OUT_INIT_LOW, "BB2AP_RST2" }, }; static enum { IPC_AP_WAKE_UNINIT, IPC_AP_WAKE_IRQ_READY, IPC_AP_WAKE_INIT1, IPC_AP_WAKE_INIT2, IPC_AP_WAKE_L, IPC_AP_WAKE_H, } ipc_ap_wake_state = IPC_AP_WAKE_INIT2; enum baseband_xmm_powerstate_t baseband_xmm_powerstate; static struct workqueue_struct *workqueue; static struct work_struct init1_work; static struct work_struct init2_work; static struct work_struct L2_resume_work; //static struct delayed_work init4_work; static struct baseband_power_platform_data *baseband_power_driver_data; static int waiting_falling_flag = 0; static bool register_hsic_device; static struct wake_lock wakelock; static struct usb_device *usbdev; static bool CP_initiated_L2toL0; static bool modem_power_on; static bool first_time = true; static int power_onoff; static void baseband_xmm_power_L2_resume(void); static DEFINE_MUTEX(baseband_xmm_onoff_lock); #ifndef CONFIG_REMOVE_HSIC_L3_STATE static int baseband_xmm_power_driver_handle_resume( struct baseband_power_platform_data *data); #endif static bool wakeup_pending; static int uart_pin_pull_state=1; // 1 for UART, 0 for GPIO static bool modem_sleep_flag = false; //static struct regulator *endeavor_dsi_reg = NULL;//for avdd_csi_dsi static spinlock_t xmm_lock; static bool system_suspending; static int reenable_autosuspend; //ICS only static int htcpcbid=0; static struct workqueue_struct *workqueue_susp; static struct work_struct work_shortsusp, work_defaultsusp; static struct workqueue_struct *workqueue_debug; static struct work_struct work_reset_host_active; static int s_sku_id = 0; static const int SKU_ID_ENRC2_GLOBAL = 0x00034600; static const int SKU_ID_ENRC2_TMO = 0x00032900; static const int SKU_ID_ENDEAVORU = 0x0002F300; static struct kset *silent_reset_kset; static struct kobject *silent_reset_kobj; #ifndef MIN static inline int MIN( int x, int y ) { return x > y ? y : x; } #endif ssize_t debug_handler(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) { if( !strncmp( buf, "0", MIN( count, strlen("0") ) ) ) { debug_gpio_dump(); } else if( !strncmp( buf, "1", MIN( count, strlen("1") ) ) ) { debug_gpio_dump(); trigger_radio_fatal_get_coredump(); } else if( !strncmp( buf, "2", MIN( count, strlen("2") ) ) ) { trigger_silent_reset("From User Space"); } else { pr_info("%s: do nothing\n", __func__); } return count; } EXPORT_SYMBOL_GPL(debug_handler); #define PRINT_GPIO(gpio,name) pr_info( "PRINT_GPIO %s <%d>", name, gpio_get_value(gpio) ) int debug_gpio_dump() { PRINT_GPIO( TEGRA_GPIO_PM4, "BB_VDD_EN" ); PRINT_GPIO( TEGRA_GPIO_PC1, "AP2BB_RST_PWRDWNn" ); PRINT_GPIO( TEGRA_GPIO_PN0, "AP2BB_RSTn" ); PRINT_GPIO( TEGRA_GPIO_PN3, "AP2BB_PWRON" ); PRINT_GPIO( TEGRA_GPIO_PN2, "BB2AP_RADIO_FATAL" ); PRINT_GPIO( TEGRA_GPIO_PN1, "IPC_HSIC_ACTIVE" ); PRINT_GPIO( TEGRA_GPIO_PV0, "HSIC_SUS_REQ" ); PRINT_GPIO( TEGRA_GPIO_PC6, "IPC_BB_WAKE" ); PRINT_GPIO( TEGRA_GPIO_PS2, "IPC_AP_WAKE" ); if(SKU_ID_ENDEAVORU != s_sku_id) { PRINT_GPIO( TEGRA_GPIO_PS5, "BB2AP_RST2" ); } return true; } EXPORT_SYMBOL_GPL(debug_gpio_dump); int trigger_radio_fatal_get_coredump(void) { #if 0 if (!reason) reason = "No Reason"; pr_info("Trigger Modem Fatal!! reason <%s>", reason); /*set BB2AP_SUSPEND_REQ Pin (TEGRA_GPIO_PV0) to OutPut High to trigger Modem fatal*/ int ret=gpio_direction_output(TEGRA_GPIO_PV0,1); if (ret < 0) pr_err("%s: set BB2AP_SUSPEND_REQ Pin to Output error", __func__); /* reset HOST_ACTIVE to notify modem since suspend req is not a wakeup source of modem. */ queue_work( workqueue_debug, &work_reset_host_active ); #else pr_info("Didn't trigger fatal for better user experience"); #endif return 0; } EXPORT_SYMBOL_GPL(trigger_radio_fatal_get_coredump); int trigger_silent_reset(char *reason) { #define MSIZE 30 char message[MSIZE] = "ResetReason="; char *envp[] = { message, NULL }; int left_size = MSIZE -1 -strlen(message); if (!reason) reason = "No Reason"; strncat(message, reason, MIN(strlen(reason),left_size)); pr_info("%s: message<%s>", __func__, message); if(silent_reset_kobj) { kobject_uevent_env( silent_reset_kobj, KOBJ_ADD, envp); } else { pr_err("%s: kobj is NULL.", __func__); } return 0; } EXPORT_SYMBOL_GPL(trigger_silent_reset); static DEVICE_ATTR(debug_handler, S_IRUSR | S_IWUSR | S_IRGRP, NULL, debug_handler); int Modem_is_6360() { return s_sku_id == SKU_ID_ENRC2_TMO; } EXPORT_SYMBOL_GPL(Modem_is_6360); int Modem_is_6260() { return ( s_sku_id == SKU_ID_ENRC2_GLOBAL || s_sku_id == SKU_ID_ENDEAVORU ); } EXPORT_SYMBOL_GPL(Modem_is_6260); int Modem_is_IMC(void) { return ( machine_is_enrc2b() || machine_is_endeavoru() || machine_is_enrc2u() ); } EXPORT_SYMBOL_GPL(Modem_is_IMC); static irqreturn_t radio_reset_irq(int irq, void *dev_id) { pr_err("%s: Radio reset detected!", __func__); debug_gpio_dump(); return IRQ_HANDLED; } #if 0 int enable_avdd_dsi_csi_power() { pr_info(MODULE_NAME "[xmm]%s\n",__func__); int ret=0; if (endeavor_dsi_reg == NULL) { endeavor_dsi_reg = regulator_get(NULL, "avdd_dsi_csi"); pr_info(MODULE_NAME "[xmm]%s regulator_getED\n",__func__); if (IS_ERR_OR_NULL(endeavor_dsi_reg)) { pr_err("dsi: Could not get regulator avdd_dsi_csi\n"); endeavor_dsi_reg = NULL; return PTR_ERR(endeavor_dsi_reg); } } ret = regulator_enable(endeavor_dsi_reg); if (ret < 0) { printk(KERN_ERR "DSI regulator avdd_dsi_csi couldn't be enabled\n",ret); } return ret; } int disable_avdd_dsi_csi_power() { pr_info(MODULE_NAME "[xmm]%s\n",__func__); int ret=0; if (endeavor_dsi_reg == NULL) { endeavor_dsi_reg = regulator_get(NULL, "avdd_dsi_csi"); pr_info(MODULE_NAME "[xmm]%s regulator_getED\n",__func__); if (IS_ERR_OR_NULL(endeavor_dsi_reg)) { pr_err("dsi: Could not get regulator avdd_dsi_csi\n"); endeavor_dsi_reg = NULL; return PTR_ERR(endeavor_dsi_reg); } } ret = regulator_disable(endeavor_dsi_reg); if (ret < 0) { printk(KERN_ERR "DSI regulator avdd_dsi_csi couldn't be disabled\n",ret); } endeavor_dsi_reg=NULL; return ret; } #endif int gpio_config_only_one(unsigned gpio, unsigned long flags, const char *label) { int err=0; if (flags & GPIOF_DIR_IN) err = gpio_direction_input(gpio); else err = gpio_direction_output(gpio, (flags & GPIOF_INIT_HIGH) ? 1 : 0); return err; } int gpio_config_only_array(struct gpio *array, size_t num) { int i, err=0; for (i = 0; i < num; i++, array++) { if( array->gpio != -1 ) { err = gpio_config_only_one(array->gpio, array->flags, array->label); if (err) goto err_free; } } return 0; err_free: //while (i--) //gpio_free((--array)->gpio); return err; } int gpio_request_only_one(unsigned gpio,const char *label) { int err = gpio_request(gpio, label); if (err) return err; else return 0; } int gpio_request_only_array(struct gpio *array, size_t num) { int i, err=0; for (i = 0; i < num; i++, array++) { if( array->gpio != -1 ) { err = gpio_request_only_one(array->gpio, array->label); if (err) goto err_free; } } return 0; err_free: while (i--) gpio_free((--array)->gpio); return err; } static int gpio_o_l_uart(int gpio, char* name) { int ret=0; pr_info(MODULE_NAME "%s ,name=%s gpio=%d\n", __func__,name,gpio); ret = gpio_direction_output(gpio, 0); if (ret < 0) { pr_err(" %s: gpio_direction_output failed %d\n", __func__, ret); gpio_free(gpio); return ret; } tegra_gpio_enable(gpio); gpio_export(gpio, true); return ret; } void modem_on_for_uart_config(void) { pr_info(MODULE_NAME "%s ,first_time=%s uart_pin_pull_low=%d\n", __func__,first_time?"true":"false",uart_pin_pull_state); if(uart_pin_pull_state==0){ //if uart pin pull low, then we put back to normal pr_info(MODULE_NAME "%s tegra_gpio_disable for UART\n", __func__); tegra_gpio_disable(TEGRA_GPIO_PJ7); tegra_gpio_disable(TEGRA_GPIO_PK7); tegra_gpio_disable(TEGRA_GPIO_PB0); tegra_gpio_disable(TEGRA_GPIO_PB1); uart_pin_pull_state=1;//set back to UART } } int modem_off_for_uart_config(void) { int err=0; pr_info(MODULE_NAME "%s uart_pin_pull_low=%d\n", __func__,uart_pin_pull_state); if(uart_pin_pull_state==1){ //if uart pin not pull low yet, then we pull them low+enable err=gpio_o_l_uart(TEGRA_GPIO_PJ7, "IMC_UART_TX"); err=gpio_o_l_uart(TEGRA_GPIO_PK7, "IMC_UART_RTS"); err=gpio_o_l_uart(TEGRA_GPIO_PB0 ,"IMC_UART_RX"); err=gpio_o_l_uart(TEGRA_GPIO_PB1, "IMC_UART_CTS"); uart_pin_pull_state=0;//chagne to gpio } return err; } int modem_off_for_usb_config(struct gpio *array, size_t num) { //pr_info(MODULE_NAME "%s 1219_01\n", __func__); int err=0; err = gpio_config_only_array(tegra_baseband_gpios_power_off_modem, ARRAY_SIZE(tegra_baseband_gpios_power_off_modem)); if (err < 0) { pr_err("%s - gpio_config_array gpio(s) for modem off failed\n", __func__); return -ENODEV; } return err; } #if 0 int modem_on_for_usb_config(struct gpio *array, size_t num) { pr_info(MODULE_NAME "%s \n", __func__); int err=0; err = gpio_config_only_array(tegra_baseband_gpios, ARRAY_SIZE(tegra_baseband_gpios)); if (err < 0) { pr_err("%s - gpio_config_array gpio(s) for modem off failed\n", __func__); return -ENODEV; } return err; } #endif int config_gpio_for_power_off(void) { int err=0; pr_info(MODULE_NAME "%s for power consumation 4st \n", __func__); #if 1 /* config baseband gpio(s) for modem off */ err = modem_off_for_usb_config(tegra_baseband_gpios_power_off_modem, ARRAY_SIZE(tegra_baseband_gpios_power_off_modem)); if (err < 0) { pr_err("%s - gpio_config_array gpio(s) for modem off failed\n", __func__); return -ENODEV; } #endif /* config uart gpio(s) for modem off */ err=modem_off_for_uart_config(); if (err < 0) { pr_err("%s - modem_off_for_uart_config gpio(s)\n", __func__); return -ENODEV; } return err; } #if 0 int config_gpio_for_power_on() { int err=0; pr_info(MODULE_NAME "%s for power consumation 4st \n", __func__); #if 1 /* config baseband gpio(s) for modem off */ err = modem_on_for_usb_config(tegra_baseband_gpios, ARRAY_SIZE(tegra_baseband_gpios)); if (err < 0) { pr_err("%s - gpio_config_array gpio(s) for modem off failed\n", __func__); return -ENODEV; } #endif /* config uart gpio(s) for modem off */ modem_on_for_uart_config(); return err; } #endif /*HTC--*/ extern void platfrom_set_flight_mode_onoff(bool mode_on); static int baseband_modem_power_on(struct baseband_power_platform_data *data) { /* HTC: called in atomic context */ int ret=0, i=0; pr_info("%s VP: 07/05 22.52{\n", __func__); if (!data) { pr_err("%s: data is NULL\n", __func__); return -1; } /* reset / power on sequence */ gpio_set_value(data->modem.xmm.bb_vdd_en, 1); /* give modem power */ auto_sleep(1); gpio_set_value(data->modem.xmm.bb_rst, 0); /* set to low first */ //pr_info("%s(%d)\n", __func__, __LINE__); for (i = 0; i < 7; i++) /* 5 ms BB_RST low */ udelay(1000); ret = gpio_get_value(data->modem.xmm.bb_rst_pwrdn); //pr_info("%s(%d) get AP2BB_RST_PWRDWNn=%d \n", __func__, __LINE__, ret); //pr_info("%s(%d) set AP2BB_RST_PWRDWNn=1\n", __func__, __LINE__); gpio_set_value(data->modem.xmm.bb_rst_pwrdn, 1); /* 20 ms RST_PWRDWNn high */ auto_sleep(25); /* need 20 but 40 is more safe */ //steven markded //pr_info("%s(%d) set modem.xmm.bb_rst=1\n", __func__, __LINE__); gpio_set_value(data->modem.xmm.bb_rst, 1); /* 1 ms BB_RST high */ auto_sleep(40); /* need 20 but 40 is more safe */ /* Use RST2 to identify if modem is powered on into boot rom. */ /* Fix issue of power leakage in ENRC2. */ if (machine_is_enrc2b() || machine_is_enrc2u()) { gpio_direction_input(data->modem.xmm.bb_rst2); } gpio_direction_input(data->modem.xmm.ipc_ap_wake); gpio_direction_input(TEGRA_GPIO_PN2); //pr_info("%s(%d) set modem.xmm.bb_on=1 duration is 60us\n", __func__, __LINE__); gpio_set_value(data->modem.xmm.bb_on, 1); /* power on sequence */ udelay(60); gpio_set_value(data->modem.xmm.bb_on, 0); //pr_info("%s(%d) set modem.xmm.bb_on=0\n", __func__, __LINE__); auto_sleep(10); //pr_info("%s:VP pm qos request CPU 1.5GHz\n", __func__); //pm_qos_update_request(&modem_boost_cpu_freq_req, (s32)BOOST_CPU_FREQ_MIN); /* Use RST2 to identify if modem is powered on into boot rom. */ /* Fix issue of power leakage in ENRC2. */ if (machine_is_enrc2b() || machine_is_enrc2u()) { int counter = 0; const int max_retry = 10; while (!gpio_get_value(data->modem.xmm.bb_rst2) && counter < max_retry) { counter++; mdelay(3); } if(counter == max_retry) pr_info("%s: Wait BB2AP_RST2 timeout.", __func__); } gpio_direction_output(data->modem.xmm.ipc_hsic_active, 1); modem_on_for_uart_config(); pr_info("%s }\n", __func__); return 0; } static int baseband_xmm_power_on(struct platform_device *device) { struct baseband_power_platform_data *data = (struct baseband_power_platform_data *) device->dev.platform_data; int ret; /* HTC: ENR#U wakeup src fix */ //int value; pr_info(MODULE_NAME "%s{\n", __func__); /* check for platform data */ if (!data) { pr_err("%s: !data\n", __func__); return -EINVAL; } if (baseband_xmm_powerstate != BBXMM_PS_UNINIT) { pr_err("%s: baseband_xmm_powerstate != BBXMM_PS_UNINIT\n", __func__); return -EINVAL; } #if 0 /*HTC*/ pr_info(MODULE_NAME " htc_get_pcbid_info= %d\n",htcpcbid ); if(htcpcbid < PROJECT_PHASE_XE) { enable_avdd_dsi_csi_power(); } #endif /* reset the state machine */ baseband_xmm_powerstate = BBXMM_PS_INIT; first_time = true; modem_sleep_flag = false; /* HTC use IPC_AP_WAKE_INIT2 */ if (modem_ver < XMM_MODEM_VER_1130) ipc_ap_wake_state = IPC_AP_WAKE_INIT1; else ipc_ap_wake_state = IPC_AP_WAKE_INIT2; /* pr_info("%s - %d\n", __func__, __LINE__); */ /* register usb host controller */ if (!modem_flash) { /* pr_info("%s - %d\n", __func__, __LINE__); */ /* register usb host controller only once */ if (register_hsic_device) { pr_info("%s(%d)register usb host controller\n", __func__, __LINE__); modem_power_on = true; if (data->hsic_register) data->modem.xmm.hsic_device = data->hsic_register(); else pr_err("%s: hsic_register is missing\n", __func__); register_hsic_device = false; } else { /* register usb host controller */ if (data->hsic_register) data->modem.xmm.hsic_device = data->hsic_register(); /* turn on modem */ pr_info("%s call baseband_modem_power_on\n", __func__); baseband_modem_power_on(data); } } if (machine_is_enrc2b() || machine_is_enrc2u()) { pr_info("%s: register BB2AP_RST2 handler", __func__); ret = request_irq( gpio_to_irq(TEGRA_GPIO_PS5), radio_reset_irq, IRQF_TRIGGER_FALLING, "RADIO_RESET", NULL ); if (ret < 0) pr_err("%s: register BB2AP_RST2 handler err <%d>", __func__, ret); } pr_info("%s: before enable irq wake", __func__); ret = enable_irq_wake(gpio_to_irq(data->modem.xmm.ipc_ap_wake)); if (ret < 0) pr_err("%s: enable_irq_wake ap_wake err <%d>", __func__, ret); ret = enable_irq_wake(gpio_to_irq(TEGRA_GPIO_PN2)); if (ret < 0) pr_err("%s: enable_irq_wake radio_fatal err <%d>", __func__, ret); if (machine_is_enrc2b() || machine_is_enrc2u()) { ret = enable_irq_wake(gpio_to_irq(TEGRA_GPIO_PS5)); if (ret < 0) pr_err("%s: enable_irq_wake radio_reset err <%d>", __func__, ret); } pr_info("%s }\n", __func__); return 0; } static int baseband_xmm_power_off(struct platform_device *device) { struct baseband_power_platform_data *data; int ret; /* HTC: ENR#U wakeup src fix */ unsigned long flags; pr_info("%s {\n", __func__); if (baseband_xmm_powerstate == BBXMM_PS_UNINIT) { pr_err("%s: baseband_xmm_powerstate != BBXMM_PS_UNINIT\n", __func__); return -EINVAL; } /* check for device / platform data */ if (!device) { pr_err("%s: !device\n", __func__); return -EINVAL; } data = (struct baseband_power_platform_data *) device->dev.platform_data; if (!data) { pr_err("%s: !data\n", __func__); return -EINVAL; } ipc_ap_wake_state = IPC_AP_WAKE_UNINIT; /* Set this flag to have proper flash-less first enumearation */ register_hsic_device = true; pr_info("%s: before disable irq wake", __func__); ret = disable_irq_wake(gpio_to_irq(data->modem.xmm.ipc_ap_wake)); if (ret < 0) pr_err("%s: disable_irq_wake ap_wake err <%d>", __func__, ret); ret = disable_irq_wake(gpio_to_irq(TEGRA_GPIO_PN2)); if (ret < 0) pr_err("%s: disable_irq_wake radio_fatal err <%d>", __func__, ret); if (machine_is_enrc2b() || machine_is_enrc2u()) { ret = disable_irq_wake(gpio_to_irq(TEGRA_GPIO_PS5)); if (ret < 0) pr_err("%s: disable_irq_wake radio_reset err <%d>", __func__, ret); pr_info("%s: before free radio_reset irq", __func__); free_irq( gpio_to_irq(TEGRA_GPIO_PS5), NULL ); if (ret < 0) pr_err("%s: free_irq radio_reset err <%d>", __func__, ret); } /* unregister usb host controller */ pr_info("%s: hsic device: %x\n", __func__, (unsigned int)data->modem.xmm.hsic_device); if (data->hsic_unregister && data->modem.xmm.hsic_device) { data->hsic_unregister(data->modem.xmm.hsic_device); data->modem.xmm.hsic_device = NULL; } else pr_err("%s: hsic_unregister is missing\n", __func__); /* set IPC_HSIC_ACTIVE low */ gpio_set_value(baseband_power_driver_data-> modem.xmm.ipc_hsic_active, 0); /* wait 20 ms */ msleep(20); /* drive bb_rst low */ //Sophia:0118:modem power down sequence: don't need to clear BB_RST //gpio_set_value(data->modem.xmm.bb_rst, 0); #ifdef BB_XMM_OEM1 //msleep(1); msleep(20); /* turn off the modem power */ gpio_set_value(baseband_power_driver_data->modem.xmm.bb_vdd_en, 0); msleep(68);//for IMC Modem discharge. #else /* !BB_XMM_OEM1 */ msleep(1); #endif /* !BB_XMM_OEM1 */ #if 1/*HTC*/ //for power consumation pr_info("%s config_gpio_for_power_off\n", __func__); config_gpio_for_power_off(); //err=config_gpio_for_power_off(); //if (err < 0) { // pr_err("%s - config_gpio_for_power_off gpio(s)\n", __func__); // return -ENODEV; //} #endif /* HTC: remove platfrom_set_flight_mode_onoff for ENR */ /* platfrom_set_flight_mode_onoff(true); */ baseband_xmm_powerstate = BBXMM_PS_UNINIT; modem_sleep_flag = false; CP_initiated_L2toL0 = false; spin_lock_irqsave(&xmm_lock, flags); wakeup_pending = false; system_suspending = false; spin_unlock_irqrestore(&xmm_lock, flags); register_hsic_device = true; //start reg process again for xmm on #if 0 /*HTC*/ pr_info(MODULE_NAME " htc_get_pcbid_info= %d\n", htcpcbid); if(htcpcbid< PROJECT_PHASE_XE) { disable_avdd_dsi_csi_power(); } #endif /*set Radio fatal Pin to OutPut Low*/ ret=gpio_direction_output(TEGRA_GPIO_PN2,0); if (ret < 0) pr_err("%s: set Radio fatal Pin to Output error\n", __func__); /*set BB2AP_SUSPEND_REQ Pin (TEGRA_GPIO_PV0) to OutPut Low*/ ret=gpio_direction_output(TEGRA_GPIO_PV0,0); if (ret < 0) pr_err("%s: set BB2AP_SUSPEND_REQ Pin to Output error\n", __func__); pr_info("%s }\n", __func__); return 0; } static ssize_t baseband_xmm_onoff(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) { //int size; struct platform_device *device = to_platform_device(dev); mutex_lock(&baseband_xmm_onoff_lock); /* check input */ if (buf == NULL) { pr_err("%s: buf NULL\n", __func__); mutex_unlock(&baseband_xmm_onoff_lock); return -EINVAL; } /* pr_info("%s: count=%d\n", __func__, count); */ /* parse input */ #ifdef BB_XMM_OEM1 if (buf[0] == 0x01 || buf[0] == '1') { /* pr_info("%s: buf[0] = 0x%x\n", __func__, buf[0]); */ power_onoff = 1; } else power_onoff = 0; #else /* !BB_XMM_OEM1 */ size = sscanf(buf, "%d", &power_onoff); if (size != 1) { pr_err("%s: size=%d -EINVAL\n", __func__, size); mutex_unlock(&baseband_xmm_onoff_lock); return -EINVAL; } #endif /* !BB_XMM_OEM1 */ pr_info("%s power_onoff=%d count=%d, buf[0]=0x%x\n", __func__, power_onoff, count, buf[0]); if (power_onoff == 0) baseband_xmm_power_off(device); else if (power_onoff == 1) baseband_xmm_power_on(device); mutex_unlock(&baseband_xmm_onoff_lock); return count; } static DEVICE_ATTR(xmm_onoff, S_IRUSR | S_IWUSR | S_IRGRP, NULL, baseband_xmm_onoff); void baseband_xmm_set_power_status(unsigned int status) { struct baseband_power_platform_data *data = baseband_power_driver_data; //int value = 0; unsigned long flags; if (baseband_xmm_powerstate == status) return; pr_info(MODULE_NAME"%s{ status=%d\n", __func__,status); switch (status) { case BBXMM_PS_L0: if (modem_sleep_flag) { #ifdef CONFIG_REMOVE_HSIC_L3_STATE pr_info("%s, resume to L0 with modem_sleep_flag", __func__ ); #else pr_info("%s Resume from L3 without calling resume function\n", __func__); baseband_xmm_power_driver_handle_resume(data); #endif } pr_info("L0\n"); baseband_xmm_powerstate = status; /* HTC: don't hold the wakelock multiple times */ if (!wake_lock_active(&wakelock)) { pr_info("%s: wake_lock [%s] in L0\n", __func__, wakelock.name); #ifdef CONFIG_REMOVE_HSIC_L3_STATE wake_lock_timeout(&wakelock, HZ*2); #else wake_lock(&wakelock); //wake_lock_timeout(&wakelock, HZ * 5); #endif } if (modem_power_on) { modem_power_on = false; baseband_modem_power_on(data); } //pr_info("gpio host active high->\n"); /* hack to restart autosuspend after exiting LP0 * (aka re-entering L0 from L3) */ #if 0 //remove on 0305 if (usbdev) { struct usb_interface *intf; intf = usb_ifnum_to_if(usbdev, 0); //pr_info("%s - autopm_get - usbdev = %d - %d {\n", __func__, usbdev, __LINE__); //pr_info("%s: cnt %d intf=%p &intf->dev=%p kobje=%s\n", //__func__, atomic_read(&intf->dev.power.usage_count),intf,&intf->dev,kobject_name(&intf->dev.kobj)); if (usb_autopm_get_interface_async(intf) >= 0) { pr_info("get_interface_async succeeded" " - call put_interface\n"); //pr_info("%s - usb_put - usbdev = %d - %d {\n", __func__, usbdev, __LINE__); usb_autopm_put_interface_async(intf); //pr_info("%s - usb_put - usbdev = %d - %d {\n", __func__, usbdev, __LINE__); } else { pr_info("get_interface_async failed" " - do not call put_interface\n"); } } #endif break; case BBXMM_PS_L2: pr_info("L2 wake_unlock[%s]\n", wakelock.name); baseband_xmm_powerstate = status; spin_lock_irqsave(&xmm_lock, flags); if (wakeup_pending) { spin_unlock_irqrestore(&xmm_lock, flags); #ifdef CONFIG_REMOVE_HSIC_L3_STATE pr_info("%s: wakeup pending\n", __func__); #endif baseband_xmm_power_L2_resume(); } else { spin_unlock_irqrestore(&xmm_lock, flags); wake_unlock(&wakelock); modem_sleep_flag = true; } if (short_autosuspend && (&usbdev->dev)) { pr_info("autosuspend delay %d ms,disable short_autosuspend\n", (int)autosuspend_delay); queue_work(workqueue_susp, &work_defaultsusp); short_autosuspend = false; } #if 0 if (usbdev) { struct usb_interface *intf; intf = usb_ifnum_to_if(usbdev, 0); pr_info("%s: cnt %d intf=%p &intf->dev=%p kobje=%s\n", __func__, atomic_read(&intf->dev.power.usage_count),intf,&intf->dev,kobject_name(&intf->dev.kobj)); } #endif break; #ifndef CONFIG_REMOVE_HSIC_L3_STATE case BBXMM_PS_L3: if (baseband_xmm_powerstate == BBXMM_PS_L2TOL0) { pr_info("%s: baseband_xmm_powerstate == BBXMM_PS_L2TOL0\n", __func__); if (!gpio_get_value(data->modem.xmm.ipc_ap_wake)) { spin_lock_irqsave(&xmm_lock, flags); wakeup_pending = true; spin_unlock_irqrestore(&xmm_lock, flags); pr_info("%s: L2 race condition-CP wakeup pending\n", __func__); } } pr_info("L3\n"); baseband_xmm_powerstate = status; spin_lock_irqsave(&xmm_lock, flags); system_suspending = false; spin_unlock_irqrestore(&xmm_lock, flags); if (wake_lock_active(&wakelock)) { pr_info("L3 --- wake_unlock[%s]\n", wakelock.name); wake_unlock(&wakelock); } if (wakeup_pending == false) { gpio_set_value(data->modem.xmm.ipc_hsic_active, 0); waiting_falling_flag = 0; pr_info("gpio host active low->\n"); } break; #endif case BBXMM_PS_L2TOL0: pr_info("L2->L0\n"); spin_lock_irqsave(&xmm_lock, flags); system_suspending = false; wakeup_pending = false; spin_unlock_irqrestore(&xmm_lock, flags); /* do this only from L2 state */ if (baseband_xmm_powerstate == BBXMM_PS_L2) { baseband_xmm_powerstate = status; //pr_info("BB XMM POWER STATE = %d\n", status); baseband_xmm_power_L2_resume(); } else goto exit_without_state_change; default: break; } baseband_xmm_powerstate = status; pr_info("BB XMM POWER STATE = %d\n", status); return; exit_without_state_change: pr_info("BB XMM POWER STATE = %d (not change to %d)\n", baseband_xmm_powerstate, status); return; } EXPORT_SYMBOL_GPL(baseband_xmm_set_power_status); irqreturn_t baseband_xmm_power_ipc_ap_wake_irq(int irq, void *dev_id) { int value; struct baseband_power_platform_data *data = baseband_power_driver_data; /* pr_info("%s\n", __func__); */ value = gpio_get_value(data->modem.xmm.ipc_ap_wake); if (ipc_ap_wake_state < IPC_AP_WAKE_IRQ_READY) { pr_err("%s - spurious irq\n", __func__); } else if (ipc_ap_wake_state == IPC_AP_WAKE_IRQ_READY) { if (!value) { pr_info("%s - IPC_AP_WAKE_INIT1" " - got falling edge\n", __func__); if (waiting_falling_flag == 0) { pr_info("%s return because irq must get the rising event at first\n", __func__); return IRQ_HANDLED; } /* go to IPC_AP_WAKE_INIT1 state */ ipc_ap_wake_state = IPC_AP_WAKE_INIT1; /* queue work */ queue_work(workqueue, &init1_work); } else { pr_info("%s - IPC_AP_WAKE_INIT1" " - wait for falling edge\n", __func__); waiting_falling_flag = 1; } } else if (ipc_ap_wake_state == IPC_AP_WAKE_INIT1) { if (!value) { pr_info("%s - IPC_AP_WAKE_INIT2" " - wait for rising edge\n", __func__); } else { pr_info("%s - IPC_AP_WAKE_INIT2" " - got rising edge\n", __func__); /* go to IPC_AP_WAKE_INIT2 state */ ipc_ap_wake_state = IPC_AP_WAKE_INIT2; /* queue work */ queue_work(workqueue, &init2_work); } } else { if (!value) { pr_info("%s - falling\n", __func__); /* First check it a CP ack or CP wake */ if (data->pin_state == 0) { /* AP L2 to L0 wakeup */ pr_info("VP: received rising wakeup ap l2->l0\n"); data->pin_state = 1; wake_up_interruptible(&data->bb_wait); } value = gpio_get_value (data->modem.xmm.ipc_bb_wake); if (value) { pr_info("cp ack for bb_wake\n"); ipc_ap_wake_state = IPC_AP_WAKE_L; return IRQ_HANDLED; } spin_lock(&xmm_lock); wakeup_pending = true; if (system_suspending) { spin_unlock(&xmm_lock); pr_info("system_suspending=1, Just set wakup_pending flag=true\n"); } else { #ifndef CONFIG_REMOVE_HSIC_L3_STATE if (baseband_xmm_powerstate == BBXMM_PS_L3) { spin_unlock(&xmm_lock); pr_info(" CP L3 -> L0\n"); pr_info("set wakeup_pending=true, wait for no-irq-resuem if you are not under LP0 yet !.\n"); pr_info("set wakeup_pending=true, wait for system resume if you already under LP0.\n"); } else #endif if (baseband_xmm_powerstate == BBXMM_PS_L2) { CP_initiated_L2toL0 = true; spin_unlock(&xmm_lock); baseband_xmm_set_power_status (BBXMM_PS_L2TOL0); } else { CP_initiated_L2toL0 = true; spin_unlock(&xmm_lock); pr_info(" CP wakeup pending- new race condition"); } } /* save gpio state */ ipc_ap_wake_state = IPC_AP_WAKE_L; } else { pr_info("%s - rising\n", __func__); value = gpio_get_value (data->modem.xmm.ipc_hsic_active); if (!value) { pr_info("host active low: ignore request\n"); ipc_ap_wake_state = IPC_AP_WAKE_H; return IRQ_HANDLED; } value = gpio_get_value (data->modem.xmm.ipc_bb_wake); if (value) { /* Clear the slave wakeup request */ gpio_set_value (data->modem.xmm.ipc_bb_wake, 0); pr_info("set gpio slave wakeup low done ->\n"); } if (reenable_autosuspend && usbdev) { struct usb_interface *intf; reenable_autosuspend = false; intf = usb_ifnum_to_if(usbdev, 0); if( NULL != intf ){ if (usb_autopm_get_interface_async(intf) >= 0) { pr_info("get_interface_async succeeded" " - call put_interface\n"); usb_autopm_put_interface_async(intf); } else { pr_info("get_interface_async failed" " - do not call put_interface\n"); } } } if (short_autosuspend&& (&usbdev->dev)) { pr_info("set autosuspend delay %d ms\n", short_autosuspend_delay); queue_work(workqueue_susp, &work_shortsusp); } modem_sleep_flag = false; baseband_xmm_set_power_status(BBXMM_PS_L0); /* save gpio state */ ipc_ap_wake_state = IPC_AP_WAKE_H; } } return IRQ_HANDLED; } EXPORT_SYMBOL(baseband_xmm_power_ipc_ap_wake_irq); static void baseband_xmm_power_reset_host_active_work(struct work_struct *work) { /* set host_active for interrupt modem */ int value = gpio_get_value(TEGRA_GPIO_PN1); pr_info("Oringial IPC_HSIC_ACTIVE =%d", value); gpio_set_value(TEGRA_GPIO_PN1,!value); msleep(100); gpio_set_value(TEGRA_GPIO_PN1,value); } static void baseband_xmm_power_init1_work(struct work_struct *work) { int value; pr_info("%s {\n", __func__); /* check if IPC_HSIC_ACTIVE high */ value = gpio_get_value(baseband_power_driver_data-> modem.xmm.ipc_hsic_active); if (value != 1) { pr_err("%s - expected IPC_HSIC_ACTIVE high!\n", __func__); return; } /* wait 100 ms */ msleep(100); /* set IPC_HSIC_ACTIVE low */ gpio_set_value(baseband_power_driver_data-> modem.xmm.ipc_hsic_active, 0); /* wait 10 ms */ msleep(10); /* set IPC_HSIC_ACTIVE high */ gpio_set_value(baseband_power_driver_data-> modem.xmm.ipc_hsic_active, 1); /* wait 20 ms */ msleep(20); #ifdef BB_XMM_OEM1 /* set IPC_HSIC_ACTIVE low */ gpio_set_value(baseband_power_driver_data-> modem.xmm.ipc_hsic_active, 0); printk(KERN_INFO"%s merge need check set IPC_HSIC_ACTIVE low\n", __func__); #endif /* BB_XMM_OEM1 */ pr_info("%s }\n", __func__); } static void baseband_xmm_power_init2_work(struct work_struct *work) { struct baseband_power_platform_data *data = baseband_power_driver_data; pr_info("%s\n", __func__); /* check input */ if (!data) return; /* register usb host controller only once */ if (register_hsic_device) { if (data->hsic_register) data->modem.xmm.hsic_device = data->hsic_register(); else pr_err("%s: hsic_register is missing\n", __func__); register_hsic_device = false; } } /* Do the work for AP/CP initiated L2->L0 */ static void baseband_xmm_power_L2_resume(void) { struct baseband_power_platform_data *data = baseband_power_driver_data; int value; unsigned long flags; pr_info("%s\n", __func__); if (!baseband_power_driver_data) return; /* claim the wakelock here to avoid any system suspend */ if (!wake_lock_active(&wakelock)) #ifdef CONFIG_REMOVE_HSIC_L3_STATE wake_lock_timeout(&wakelock, HZ*2); #else wake_lock(&wakelock); #endif modem_sleep_flag = false; spin_lock_irqsave(&xmm_lock, flags); wakeup_pending = false; spin_unlock_irqrestore(&xmm_lock, flags); if (CP_initiated_L2toL0) { pr_info("CP L2->L0\n"); CP_initiated_L2toL0 = false; queue_work(workqueue, &L2_resume_work); #if 0 if (usbdev) { struct usb_interface *intf; intf = usb_ifnum_to_if(usbdev, 0); pr_info("%s: cnt %d intf=%p &intf->dev=%p kobje=%s\n", __func__, atomic_read(&intf->dev.power.usage_count),intf,&intf->dev,kobject_name(&intf->dev.kobj)); } #endif } else { /* set the slave wakeup request */ #ifdef CONFIG_REMOVE_HSIC_L3_STATE pr_info("AP/CP L2->L0\n"); #else pr_info("AP L2->L0\n"); #endif value = gpio_get_value(data->modem.xmm.ipc_ap_wake); if (value) { int ret=0, cptrycount=0, eresyscount=0; const int delay=200, MAXTRY=5, eredelay=3, MAX_ERETRY=100; unsigned long target_jiffies=0; data->pin_state = 0; retry_cpwake: if(cptrycount) { gpio_set_value(data->modem.xmm.ipc_bb_wake, 0); mdelay(1); debug_gpio_dump(); } target_jiffies = jiffies + msecs_to_jiffies(delay); /* wake bb */ gpio_set_value(data->modem.xmm.ipc_bb_wake, 1); retry: /* wait for cp */ pr_info("waiting for host wakeup from CP... <%d,%d>\n", cptrycount, eresyscount); ret = wait_event_interruptible_timeout( data->bb_wait, data->pin_state == 1 || (gpio_get_value(data->modem.xmm.ipc_ap_wake) == 0), MIN( (target_jiffies-jiffies), msecs_to_jiffies(delay) ) ); if (ret == 0) { pr_info("%s: wait for cp ack %d times\n", __func__, cptrycount); debug_gpio_dump(); cptrycount++; if(cptrycount == MAXTRY) { pr_err("!!AP L2->L0 Failed\n"); trigger_radio_fatal_get_coredump(); return; } goto retry_cpwake; } if (ret == -ERESTARTSYS ) { eresyscount++; pr_info("%s: caught signal, sleep and retry %d times\n", __func__, eresyscount); if(eresyscount == MAX_ERETRY) { pr_err("too many ERESTARTSYS <%d>, abort\n", eresyscount); debug_gpio_dump(); trigger_radio_fatal_get_coredump(); return; } msleep(eredelay); goto retry; } pr_info("Get gpio host wakeup low <-\n"); } else { pr_info("CP already ready\n"); } } } static void baseband_xmm_power_shortsusp(struct work_struct *work) { if (!usbdev || !&usbdev->dev) { pr_err("%s usbdev is invalid\n", __func__); return; } pm_runtime_set_autosuspend_delay(&usbdev->dev, short_autosuspend_delay); pr_info("%s set_autosuspend_delay <%d>", __func__, short_autosuspend_delay); } static void baseband_xmm_power_defaultsusp(struct work_struct *work) { if (!usbdev || !&usbdev->dev) { pr_err("%s usbdev is invalid\n", __func__); return; } pm_runtime_set_autosuspend_delay(&usbdev->dev, autosuspend_delay); //pr_info("%s set_autosuspend_delay <%d>", __func__, autosuspend_delay); } /* Do the work for CP initiated L2->L0 */ static void baseband_xmm_power_L2_resume_work(struct work_struct *work) { struct usb_interface *intf; pr_info("%s {\n", __func__); if (!usbdev) { pr_info("%s - !usbdev\n", __func__); return; } usb_lock_device(usbdev); intf = usb_ifnum_to_if(usbdev, 0); if( NULL != intf ){ if (usb_autopm_get_interface(intf) == 0) usb_autopm_put_interface(intf); } usb_unlock_device(usbdev); pr_info("} %s\n", __func__); } static void baseband_xmm_power_reset_on(void) { /* reset / power on sequence */ msleep(40); gpio_set_value(baseband_power_driver_data->modem.xmm.bb_rst, 1); msleep(1); gpio_set_value(baseband_power_driver_data->modem.xmm.bb_on, 1); udelay(40); gpio_set_value(baseband_power_driver_data->modem.xmm.bb_on, 0); } static struct baseband_xmm_power_work_t *baseband_xmm_power_work; static void baseband_xmm_power_work_func(struct work_struct *work) { struct baseband_xmm_power_work_t *bbxmm_work = (struct baseband_xmm_power_work_t *) work; pr_info("%s - work->sate=%d\n", __func__, bbxmm_work->state); switch (bbxmm_work->state) { case BBXMM_WORK_UNINIT: pr_info("BBXMM_WORK_UNINIT\n"); break; case BBXMM_WORK_INIT: pr_info("BBXMM_WORK_INIT\n"); /* go to next state */ bbxmm_work->state = (modem_flash && !modem_pm) ? BBXMM_WORK_INIT_FLASH_STEP1 : (modem_flash && modem_pm) ? BBXMM_WORK_INIT_FLASH_PM_STEP1 : (!modem_flash && modem_pm) ? BBXMM_WORK_INIT_FLASHLESS_PM_STEP1 : BBXMM_WORK_UNINIT; pr_info("Go to next state %d\n", bbxmm_work->state); queue_work(workqueue, work); break; case BBXMM_WORK_INIT_FLASH_STEP1: //pr_info("BBXMM_WORK_INIT_FLASH_STEP1\n"); /* register usb host controller */ pr_info("%s: register usb host controller\n", __func__); if (baseband_power_driver_data->hsic_register) baseband_power_driver_data->modem.xmm.hsic_device = baseband_power_driver_data->hsic_register(); else pr_err("%s: hsic_register is missing\n", __func__); break; case BBXMM_WORK_INIT_FLASH_PM_STEP1: //pr_info("BBXMM_WORK_INIT_FLASH_PM_STEP1\n"); /* [modem ver >= 1130] start with IPC_HSIC_ACTIVE low */ if (modem_ver >= XMM_MODEM_VER_1130) { pr_info("%s: ver > 1130:" " ipc_hsic_active -> 0\n", __func__); gpio_set_value(baseband_power_driver_data-> modem.xmm.ipc_hsic_active, 0); } /* reset / power on sequence */ baseband_xmm_power_reset_on(); /* set power status as on */ power_onoff = 1; /* optional delay * 0 = flashless * ==> causes next step to enumerate modem boot rom * (058b / 0041) * some delay > boot rom timeout * ==> causes next step to enumerate modem software * (1519 / 0020) * (requires modem to be flash version, not flashless * version) */ if (enum_delay_ms) msleep(enum_delay_ms); /* register usb host controller */ pr_info("%s: register usb host controller\n", __func__); if (baseband_power_driver_data->hsic_register) baseband_power_driver_data->modem.xmm.hsic_device = baseband_power_driver_data->hsic_register(); else pr_err("%s: hsic_register is missing\n", __func__); /* go to next state */ bbxmm_work->state = (modem_ver < XMM_MODEM_VER_1130) ? BBXMM_WORK_INIT_FLASH_PM_VER_LT_1130_STEP1 : BBXMM_WORK_INIT_FLASH_PM_VER_GE_1130_STEP1; queue_work(workqueue, work); pr_info("Go to next state %d\n", bbxmm_work->state); break; case BBXMM_WORK_INIT_FLASH_PM_VER_LT_1130_STEP1: pr_info("BBXMM_WORK_INIT_FLASH_PM_VER_LT_1130_STEP1\n"); break; case BBXMM_WORK_INIT_FLASH_PM_VER_GE_1130_STEP1: pr_info("BBXMM_WORK_INIT_FLASH_PM_VER_GE_1130_STEP1\n"); break; case BBXMM_WORK_INIT_FLASHLESS_PM_STEP1: //pr_info("BBXMM_WORK_INIT_FLASHLESS_PM_STEP1\n"); /* go to next state */ bbxmm_work->state = (modem_ver < XMM_MODEM_VER_1130) ? BBXMM_WORK_INIT_FLASHLESS_PM_VER_LT_1130_WAIT_IRQ : BBXMM_WORK_INIT_FLASHLESS_PM_VER_GE_1130_STEP1; queue_work(workqueue, work); break; case BBXMM_WORK_INIT_FLASHLESS_PM_VER_LT_1130_STEP1: pr_info("BBXMM_WORK_INIT_FLASHLESS_PM_VER_LT_1130_STEP1\n"); break; case BBXMM_WORK_INIT_FLASHLESS_PM_VER_GE_1130_STEP1: //pr_info("BBXMM_WORK_INIT_FLASHLESS_PM_VER_GE_1130_STEP1\n"); break; default: break; } } static void baseband_xmm_device_add_handler(struct usb_device *udev) { struct usb_interface *intf = usb_ifnum_to_if(udev, 0); const struct usb_device_id *id; pr_info("%s \n",__func__); if (intf == NULL) return; id = usb_match_id(intf, xmm_pm_ids); if (id) { pr_info("persist_enabled: %u\n", udev->persist_enabled); pr_info("Add device %d <%s %s>\n", udev->devnum, udev->manufacturer, udev->product); usbdev = udev; pm_runtime_set_autosuspend_delay(&udev->dev, autosuspend_delay);//for ICS 39kernel usb_enable_autosuspend(udev); // pr_info("enable autosuspend, timer <%d>", autosuspend_delay); } } static void baseband_xmm_device_remove_handler(struct usb_device *udev) { if (usbdev == udev) { pr_info("Remove device %d <%s %s>\n", udev->devnum, udev->manufacturer, udev->product); usbdev = 0; } } static int usb_xmm_notify(struct notifier_block *self, unsigned long action, void *blob) { switch (action) { case USB_DEVICE_ADD: baseband_xmm_device_add_handler(blob); break; case USB_DEVICE_REMOVE: baseband_xmm_device_remove_handler(blob); break; } return NOTIFY_OK; } static struct notifier_block usb_xmm_nb = { .notifier_call = usb_xmm_notify, }; static int baseband_xmm_power_pm_notifier_event(struct notifier_block *this, unsigned long event, void *ptr) { struct baseband_power_platform_data *data = baseband_power_driver_data; unsigned long flags; if (!data) return NOTIFY_DONE; pr_info("%s: event %ld\n", __func__, event); switch (event) { case PM_SUSPEND_PREPARE: pr_info("%s : PM_SUSPEND_PREPARE\n", __func__); if (wake_lock_active(&wakelock)) { pr_info("%s: wakelock was active, aborting suspend\n",__func__); return NOTIFY_STOP; } spin_lock_irqsave(&xmm_lock, flags); if (wakeup_pending) { wakeup_pending = false; spin_unlock_irqrestore(&xmm_lock, flags); pr_info("%s : XMM busy : Abort system suspend\n", __func__); return NOTIFY_STOP; } system_suspending = true; spin_unlock_irqrestore(&xmm_lock, flags); return NOTIFY_OK; case PM_POST_SUSPEND: pr_info("%s : PM_POST_SUSPEND\n", __func__); spin_lock_irqsave(&xmm_lock, flags); system_suspending = false; if (wakeup_pending && (baseband_xmm_powerstate == BBXMM_PS_L2)) { wakeup_pending = false; spin_unlock_irqrestore(&xmm_lock, flags); pr_info("%s : Service Pending CP wakeup\n", __func__); CP_initiated_L2toL0 = true; baseband_xmm_set_power_status (BBXMM_PS_L2TOL0); return NOTIFY_OK; } wakeup_pending = false; spin_unlock_irqrestore(&xmm_lock, flags); return NOTIFY_OK; } return NOTIFY_DONE; } static struct notifier_block baseband_xmm_power_pm_notifier = { .notifier_call = baseband_xmm_power_pm_notifier_event, }; static int baseband_xmm_power_driver_probe(struct platform_device *device) { struct baseband_power_platform_data *data = (struct baseband_power_platform_data *) device->dev.platform_data; struct device *dev = &device->dev; unsigned long flags; int err, ret=0; pr_info(MODULE_NAME"%s 0705 - xmm_wake_pin_miss. \n", __func__); // pr_info(MODULE_NAME"enum_delay_ms=%d\n", enum_delay_ms); htcpcbid=htc_get_pcbid_info(); pr_info(MODULE_NAME"htcpcbid=%d\n", htcpcbid); /* check for platform data */ if (!data) return -ENODEV; /* check if supported modem */ if (data->baseband_type != BASEBAND_XMM) { pr_err("unsuppported modem\n"); return -ENODEV; } /* save platform data */ baseband_power_driver_data = data; /* init wait queue */ data->pin_state = 1; init_waitqueue_head(&data->bb_wait); /* create device file */ err = device_create_file(dev, &dev_attr_xmm_onoff); if (err < 0) { pr_err("%s - device_create_file failed\n", __func__); return -ENODEV; } err = device_create_file(dev, &dev_attr_debug_handler); if (err < 0) { pr_err("%s - device_create_file failed\n", __func__); return -ENODEV; } /* HTC: create device file for host debugging */ if (device_create_file(dev,&dev_attr_host_dbg)) pr_info(MODULE_NAME"Warning: host attribute can't be created\n"); /* init wake lock */ wake_lock_init(&wakelock, WAKE_LOCK_SUSPEND, "baseband_xmm_power"); /* init spin lock */ spin_lock_init(&xmm_lock); /* request baseband gpio(s) */ tegra_baseband_gpios[0].gpio = baseband_power_driver_data ->modem.xmm.bb_rst; tegra_baseband_gpios[1].gpio = baseband_power_driver_data ->modem.xmm.bb_on; tegra_baseband_gpios[2].gpio = baseband_power_driver_data ->modem.xmm.ipc_bb_wake; tegra_baseband_gpios[3].gpio = baseband_power_driver_data ->modem.xmm.ipc_ap_wake; tegra_baseband_gpios[4].gpio = baseband_power_driver_data ->modem.xmm.ipc_hsic_active; tegra_baseband_gpios[5].gpio = baseband_power_driver_data ->modem.xmm.ipc_hsic_sus_req; tegra_baseband_gpios[6].gpio = baseband_power_driver_data ->modem.xmm.bb_vdd_en; tegra_baseband_gpios[7].gpio = baseband_power_driver_data ->modem.xmm.bb_rst_pwrdn; tegra_baseband_gpios[8].gpio = baseband_power_driver_data ->modem.xmm.bb_rst2; /*HTC request these gpio on probe only, config them when running power_on/off function*/ err = gpio_request_only_array(tegra_baseband_gpios, ARRAY_SIZE(tegra_baseband_gpios)); if (err < 0) { pr_err("%s - request gpio(s) failed\n", __func__); return -ENODEV; } #if 1/*HTC*/ //assing for usb tegra_baseband_gpios_power_off_modem[0].gpio = baseband_power_driver_data ->modem.xmm.bb_rst; tegra_baseband_gpios_power_off_modem[1].gpio = baseband_power_driver_data ->modem.xmm.bb_on; tegra_baseband_gpios_power_off_modem[2].gpio = baseband_power_driver_data ->modem.xmm.ipc_bb_wake; tegra_baseband_gpios_power_off_modem[3].gpio = baseband_power_driver_data ->modem.xmm.ipc_ap_wake; tegra_baseband_gpios_power_off_modem[4].gpio = baseband_power_driver_data ->modem.xmm.ipc_hsic_active; tegra_baseband_gpios_power_off_modem[5].gpio = baseband_power_driver_data ->modem.xmm.ipc_hsic_sus_req; tegra_baseband_gpios_power_off_modem[6].gpio = baseband_power_driver_data ->modem.xmm.bb_vdd_en; tegra_baseband_gpios_power_off_modem[7].gpio = baseband_power_driver_data ->modem.xmm.bb_rst_pwrdn; tegra_baseband_gpios_power_off_modem[8].gpio = baseband_power_driver_data ->modem.xmm.bb_rst2; //request UART pr_info("%s request UART\n", __func__); err =gpio_request(TEGRA_GPIO_PJ7, "IMC_UART_TX"); err =gpio_request(TEGRA_GPIO_PK7, "IMC_UART_RTS"); err =gpio_request(TEGRA_GPIO_PB0 ,"IMC_UART_RX"); err =gpio_request(TEGRA_GPIO_PB1, "IMC_UART_CTS"); pr_info("%s pull UART o d\n", __func__); //for power consumation //all the needed config put on power_on function pr_info("%s config_gpio_for_power_off\n", __func__); err=config_gpio_for_power_off(); if (err < 0) { pr_err("%s - config_gpio_for_power_off gpio(s)\n", __func__); return -ENODEV; } #endif/*HTC*/ /* request baseband irq(s) */ if (modem_flash && modem_pm) { pr_info("%s: request_irq IPC_AP_WAKE_IRQ\n", __func__); ipc_ap_wake_state = IPC_AP_WAKE_UNINIT; err = request_threaded_irq( gpio_to_irq(data->modem.xmm.ipc_ap_wake), baseband_xmm_power_ipc_ap_wake_irq, NULL, IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING, "IPC_AP_WAKE_IRQ", NULL); if (err < 0) { pr_err("%s - request irq IPC_AP_WAKE_IRQ failed\n", __func__); return err; } ipc_ap_wake_state = IPC_AP_WAKE_IRQ_READY; if (modem_ver >= XMM_MODEM_VER_1130) { pr_info("%s: ver > 1130: AP_WAKE_INIT1\n", __func__); /* ver 1130 or later starts in INIT1 state */ ipc_ap_wake_state = IPC_AP_WAKE_INIT1; } } /* init work queue */ workqueue = create_singlethread_workqueue("baseband_xmm_power_workqueue"); if (!workqueue) { pr_err("cannot create workqueue\n"); return -1; } workqueue_susp = alloc_workqueue("baseband_xmm_power_autosusp", WQ_UNBOUND | WQ_HIGHPRI | WQ_NON_REENTRANT, 1); if (!workqueue_susp) { pr_err("cannot create workqueue_susp\n"); return -1; } workqueue_debug = create_singlethread_workqueue("baseband_xmm_power_debug"); if (!workqueue_debug) { pr_err("cannot create workqueue_debug\n"); return -1; } baseband_xmm_power_work = (struct baseband_xmm_power_work_t *) kmalloc(sizeof(struct baseband_xmm_power_work_t), GFP_KERNEL); if (!baseband_xmm_power_work) { pr_err("cannot allocate baseband_xmm_power_work\n"); return -1; } INIT_WORK((struct work_struct *) baseband_xmm_power_work, baseband_xmm_power_work_func); baseband_xmm_power_work->state = BBXMM_WORK_INIT; queue_work(workqueue, (struct work_struct *) baseband_xmm_power_work); /* init work objects */ INIT_WORK(&init1_work, baseband_xmm_power_init1_work); INIT_WORK(&init2_work, baseband_xmm_power_init2_work); INIT_WORK(&L2_resume_work, baseband_xmm_power_L2_resume_work); INIT_WORK(&work_shortsusp, baseband_xmm_power_shortsusp); INIT_WORK(&work_defaultsusp, baseband_xmm_power_defaultsusp); INIT_WORK(&work_reset_host_active, baseband_xmm_power_reset_host_active_work); /* init state variables */ register_hsic_device = true; CP_initiated_L2toL0 = false; baseband_xmm_powerstate = BBXMM_PS_UNINIT; spin_lock_irqsave(&xmm_lock, flags); wakeup_pending = false; system_suspending = false; spin_unlock_irqrestore(&xmm_lock, flags); usb_register_notify(&usb_xmm_nb); register_pm_notifier(&baseband_xmm_power_pm_notifier); /*HTC*/ /*set Radio fatal Pin PN2 to OutPut Low*/ ret=gpio_direction_output(TEGRA_GPIO_PN2,0); if (ret < 0) pr_err("%s: set Radio fatal Pin to Output error\n", __func__); /*set BB2AP_SUSPEND_REQ Pin (TEGRA_GPIO_PV0) to OutPut Low*/ ret=gpio_direction_output(TEGRA_GPIO_PV0,0); if (ret < 0) pr_err("%s: set BB2AP_SUSPEND_REQ Pin to Output error\n", __func__); //Request SIM det to wakeup Source wahtever in flight mode on/off /*For SIM det*/ pr_info("%s: request enable irq wake SIM det to wakeup source\n", __func__); ret = enable_irq_wake(gpio_to_irq(TEGRA_GPIO_PI5)); if (ret < 0) pr_err("%s: enable_irq_wake error\n", __func__); pr_info("%s: init kobj for silent reset", __func__); silent_reset_kset = kset_create_and_add("SilentResetKset", NULL, NULL); if(!silent_reset_kset) { pr_err("%s: silent_reset_kset create failure.", __func__); } else { silent_reset_kobj = kobject_create_and_add("SilentResetTrigger", kobject_get(&dev->kobj)); if(!silent_reset_kobj) { pr_err("%s: silent_reset_kobj create failure.", __func__); kset_unregister(silent_reset_kset); silent_reset_kset = NULL; } else silent_reset_kobj->kset = silent_reset_kset; } pr_info("%s }\n", __func__); return 0; } static int baseband_xmm_power_driver_remove(struct platform_device *device) { struct baseband_power_platform_data *data = (struct baseband_power_platform_data *) device->dev.platform_data; struct device *dev = &device->dev; pr_info("%s\n", __func__); /* check for platform data */ if (!data) return 0; unregister_pm_notifier(&baseband_xmm_power_pm_notifier); usb_unregister_notify(&usb_xmm_nb); /* free work structure */ kfree(baseband_xmm_power_work); baseband_xmm_power_work = (struct baseband_xmm_power_work_t *) 0; /* free baseband irq(s) */ if (modem_flash && modem_pm) { free_irq(gpio_to_irq(baseband_power_driver_data ->modem.xmm.ipc_ap_wake), NULL); } /* free baseband gpio(s) */ gpio_free_array(tegra_baseband_gpios, ARRAY_SIZE(tegra_baseband_gpios)); /* destroy wake lock */ wake_lock_destroy(&wakelock); /* delete device file */ device_remove_file(dev, &dev_attr_xmm_onoff); device_remove_file(dev, &dev_attr_debug_handler); /* HTC: delete device file */ device_remove_file(dev, &dev_attr_host_dbg); /* destroy wake lock */ destroy_workqueue(workqueue_susp); destroy_workqueue(workqueue); if(silent_reset_kset) { kset_unregister(silent_reset_kset); silent_reset_kset = NULL; } if(silent_reset_kobj) { kobject_put(silent_reset_kobj); kobject_put(&dev->kobj); } /* unregister usb host controller */ if (data->hsic_unregister && data->modem.xmm.hsic_device) { data->hsic_unregister(data->modem.xmm.hsic_device); data->modem.xmm.hsic_device = NULL; } else pr_err("%s: hsic_unregister is missing\n", __func__); return 0; } #ifndef CONFIG_REMOVE_HSIC_L3_STATE static int baseband_xmm_power_driver_handle_resume( struct baseband_power_platform_data *data) { int value; unsigned long flags; unsigned long timeout; int delay = 10000; /* maxmum delay in msec */ //pr_info("%s\n", __func__); /* check for platform data */ if (!data) return 0; /* check if modem is on */ if (power_onoff == 0) { pr_info("%s - flight mode - nop\n", __func__); return 0; } modem_sleep_flag = false; spin_lock_irqsave(&xmm_lock, flags); /* Clear wakeup pending flag */ wakeup_pending = false; spin_unlock_irqrestore(&xmm_lock, flags); /* L3->L0 */ baseband_xmm_set_power_status(BBXMM_PS_L3TOL0); value = gpio_get_value(data->modem.xmm.ipc_ap_wake); if (value) { pr_info("AP L3 -> L0\n"); pr_info("waiting for host wakeup...\n"); timeout = jiffies + msecs_to_jiffies(delay); /* wake bb */ gpio_set_value(data->modem.xmm.ipc_bb_wake, 1); pr_info("Set bb_wake high ->\n"); do { udelay(100); value = gpio_get_value(data->modem.xmm.ipc_ap_wake); if (!value) break; } while (time_before(jiffies, timeout)); if (!value) { pr_info("gpio host wakeup low <-\n"); pr_info("%s enable short_autosuspend\n", __func__); short_autosuspend = true; } else pr_info("!!AP L3->L0 Failed\n"); } else { pr_info("CP L3 -> L0\n"); } reenable_autosuspend = true; return 0; } #endif #ifdef CONFIG_PM #ifdef CONFIG_REMOVE_HSIC_L3_STATE static int baseband_xmm_power_driver_suspend(struct device *dev) { // int delay = 10000; /* maxmum delay in msec */ // struct platform_device *pdev = to_platform_device(dev); //struct baseband_power_platform_data *pdata = pdev->dev.platform_data; //pr_info("%s\n", __func__); /* check if modem is on */ if (power_onoff == 0) { pr_info("%s - flight mode - nop\n", __func__); return 0; } /* PMC is driving hsic bus * tegra_baseband_rail_off(); */ return 0; } #else static int baseband_xmm_power_driver_suspend(struct device *dev) { pr_info("%s\n", __func__); return 0; } #endif /* CONFIG_REMOVE_HSIC_L3_STATE */ static int baseband_xmm_power_driver_resume(struct device *dev) { //struct platform_device *pdev = to_platform_device(dev); //struct baseband_power_platform_data *data // = (struct baseband_power_platform_data *) // pdev->dev.platform_data; pr_info("%s\n", __func__); #ifdef CONFIG_REMOVE_HSIC_L3_STATE /* check if modem is on */ if (power_onoff == 0) { pr_info("%s - flight mode - nop\n", __func__); return 0; } /* PMC is driving hsic bus * tegra_baseband_rail_on(); */ reenable_autosuspend = true; #else baseband_xmm_power_driver_handle_resume(data); #endif return 0; } static int baseband_xmm_power_suspend_noirq(struct device *dev) { unsigned long flags; pr_info("%s\n", __func__); spin_lock_irqsave(&xmm_lock, flags); system_suspending = false; if (wakeup_pending) { wakeup_pending = false; spin_unlock_irqrestore(&xmm_lock, flags); pr_info("%s:**Abort Suspend: reason CP WAKEUP**\n", __func__); return -EBUSY; } spin_unlock_irqrestore(&xmm_lock, flags); return 0; } static int baseband_xmm_power_resume_noirq(struct device *dev) { pr_info("%s\n", __func__); return 0; } static const struct dev_pm_ops baseband_xmm_power_dev_pm_ops = { .suspend_noirq = baseband_xmm_power_suspend_noirq, .resume_noirq = baseband_xmm_power_resume_noirq, .suspend = baseband_xmm_power_driver_suspend, .resume = baseband_xmm_power_driver_resume, }; #endif static struct platform_driver baseband_power_driver = { .probe = baseband_xmm_power_driver_probe, .remove = baseband_xmm_power_driver_remove, .driver = { .name = "baseband_xmm_power", #ifdef CONFIG_PM .pm = &baseband_xmm_power_dev_pm_ops, #endif }, }; static int __init baseband_xmm_power_init(void) { /* HTC */ int mfg_mode = board_mfg_mode(); host_dbg_flag = 0; //pr_info("%s - host_dbg_flag<0x%x>, modem_ver<0x%x>, mfg_mode<%d>" // , __func__, host_dbg_flag, modem_ver, mfg_mode); if( mfg_mode ) { autosuspend_delay = 365*86400; short_autosuspend_delay = 365*86400; //pr_info("In MFG mode, autosuspend_delay <%d>, short_autosuspend_delay <%d>" // , autosuspend_delay, short_autosuspend_delay ); } s_sku_id = board_get_sku_tag(); pr_info("SKU_ID is 0x%x", s_sku_id); //printk("%s:VP adding pm qos request removed\n", __func__); //pm_qos_add_request(&modem_boost_cpu_freq_req, PM_QOS_CPU_FREQ_MIN, (s32)PM_QOS_CPU_FREQ_MIN_DEFAULT_VALUE); return platform_driver_register(&baseband_power_driver); } static void __exit baseband_xmm_power_exit(void) { pr_info("%s\n", __func__); platform_driver_unregister(&baseband_power_driver); //pm_qos_remove_request(&modem_boost_cpu_freq_req); } module_init(baseband_xmm_power_init) module_exit(baseband_xmm_power_exit)
bedalus/hxore
arch/arm/mach-tegra/baseband-xmm-power.c
C
gpl-2.0
61,756
include ../../../Makefile.inc CLC_ROOT = ../../../inc all: exe_src exe_src_m2s exe_bin amd_compile m2c_compile run_m2s run_native check_result exe_src: @-$(CC) $(CC_FLAG) *src.c -o exe_src $(CC_INC) $(CC_LIB) > isgreaterequal_floatfloat.exe_src.log 2>&1 exe_src_m2s: @-$(CC) $(CC_FLAG) -m32 *src.c -o exe_src_m2s $(CC_INC) $(M2S_LIB) > isgreaterequal_floatfloat.exe_src_m2s.log 2>&1 exe_bin: @-$(CC) $(CC_FLAG) *bin.c -o exe_bin $(CC_INC) $(CC_LIB) > isgreaterequal_floatfloat.exe_bin.log 2>&1 amd_compile: @-$(AMD_CC) --amd --amd-dump-all --amd-device 11 isgreaterequal_floatfloat.cl > isgreaterequal_floatfloat.amdcc.log 2>&1 @-rm -rf /tmp/*.clp && rm -rf /tmp/*_amd_files m2c_compile: @-python compile.py run_m2s: @-M2S_OPENCL_BINARY=./isgreaterequal_floatfloat.opt.bin $(M2S) --si-sim functional ./exe_src_m2s > m2s.log 2>&1 run_native: @-./exe_src > native.log 2>&1 check_result: @-diff exe_src.result exe_src_m2s.result > check.log 2>&1 clean: rm -rf exe_src exe_src_m2s exe_bin *.ll *.log *files *bin *.s *.bc *.result
xianggong/m2c_unit_test
test/relational/isgreaterequal_floatfloat/Makefile
Makefile
gpl-2.0
1,047
# coding=utf-8 # --------------------------------------------------------------- # Desenvolvedor: Arannã Sousa Santos # Mês: 12 # Ano: 2015 # Projeto: pagseguro_xml # e-mail: [email protected] # --------------------------------------------------------------- import logging from pagseguro_xml.notificacao import ApiPagSeguroNotificacao_v3, CONST_v3 logger = logging.basicConfig(level=logging.DEBUG) PAGSEGURO_API_AMBIENTE = u'sandbox' PAGSEGURO_API_EMAIL = u'[email protected]' PAGSEGURO_API_TOKEN_PRODUCAO = u'' PAGSEGURO_API_TOKEN_SANDBOX = u'' CHAVE_NOTIFICACAO = u'AA0000-AA00A0A0AA00-AA00AA000000-AA0000' # ela éh de producao api = ApiPagSeguroNotificacao_v3(ambiente=CONST_v3.AMBIENTE.SANDBOX) PAGSEGURO_API_TOKEN = PAGSEGURO_API_TOKEN_PRODUCAO ok, retorno = api.consulta_notificacao_transacao_v3(PAGSEGURO_API_EMAIL, PAGSEGURO_API_TOKEN, CHAVE_NOTIFICACAO) if ok: print u'-' * 50 print retorno.xml print u'-' * 50 for a in retorno.alertas: print a else: print u'Motivo do erro:', retorno
arannasousa/pagseguro_xml
exemplos/testes_notificacao.py
Python
gpl-2.0
1,090
<?php /** * @package Mambo * @author Mambo Foundation Inc see README.php * @copyright Mambo Foundation Inc. * See COPYRIGHT.php for copyright notices and details. * @license GNU/GPL Version 2, see LICENSE.php * Mambo 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. */ /** ensure this file is being included by a parent file */ defined( '_VALID_MOS' ) or die( 'Direct Access to this location is not allowed.' ); /** * AWSTATS BROWSERS DATABASE * If you want to add a Browser to extend AWStats database detection capabilities, * you must add an entry in BrowsersSearchIDOrder and in BrowsersHashIDLib. * * * BrowsersSearchIDOrder * This list is used to know in which order to search Browsers IDs (Most * frequent one are first in this list to increase detect speed). * It contains all matching criteria to search for in log fields. * Note: Browsers IDs are in lower case and ' ' and '+' are changed into '_' */ $browserSearchOrder = array ( // Most frequent standard web browsers are first in this list "icab", "go!zilla", "konqueror", "links", "lynx", "omniweb", "opera", "msie 6\.0", "apachebench", "wget", // Other standard web browsers "22acidownload", "aol\\-iweng", "amaya", "amigavoyager", "aweb", "bpftp", "chimera", "cyberdog", "dillo", "dreamcast", "downloadagent", "ecatch", "emailsiphon", "encompass", "friendlyspider", "fresco", "galeon", "getright", "headdump", "hotjava", "ibrowse", "intergo", "k-meleon", "linemodebrowser", "lotus-notes", "macweb", "multizilla", "ncsa_mosaic", "netpositive", "nutscrape", "msfrontpageexpress", "phoenix", "firebird", "firefox", "safari", "tzgeturl", "viking", "webfetcher", "webexplorer", "webmirror", "webvcr", // Site grabbers "teleport", "webcapture", "webcopier", // Music only browsers "real", "winamp", // Works for winampmpeg and winamp3httprdr "windows-media-player", "audion", "freeamp", "itunes", "jetaudio", "mint_audio", "mpg123", "nsplayer", "sonique", "uplayer", "xmms", "xaudio", // PDA/Phonecell browsers "alcatel", // Alcatel "mot-", // Motorola "nokia", // Nokia "panasonic", // Panasonic "philips", // Philips "sonyericsson", // SonyEricsson "ericsson", // Ericsson (must be after sonyericsson "mmef", "mspie", "wapalizer", "wapsilon", "webcollage", "up\.", // Works for UP.Browser and UP.Link // PDA/Phonecell I-Mode browsers "docomo", "portalmmm", // Others (TV) "webtv", // Other kind of browsers "csscheck", "w3m", "w3c_css_validator", "w3c_validator", "wdg_validator", "webzip", "staroffice", "mozilla", // Must be at end because a lot of browsers contains mozilla in string "libwww" // Must be at end because some browser have both "browser id" and "libwww" ); $browsersAlias = array ( // Common web browsers text (IE and Netscape must not be in this list) "icab"=>"iCab", "go!zilla"=>"Go!Zilla", "konqueror"=>"Konqueror", "links"=>"Links", "lynx"=>"Lynx", "omniweb"=>"OmniWeb", "opera"=>"Opera", "msie 6\.0"=>"Microsoft Internet Explorer 6.0", "apachebench"=>"ApacheBench", "wget"=>"Wget", "22acidownload"=>"22AciDownload", "aol\\-iweng"=>"AOL-Iweng", "amaya"=>"Amaya", "amigavoyager"=>"AmigaVoyager", "aweb"=>"AWeb", "bpftp"=>"BPFTP", "chimera"=>"Chimera", "cyberdog"=>"Cyberdog", "dillo"=>"Dillo", "dreamcast"=>"Dreamcast", "downloadagent"=>"DownloadAgent", "ecatch", "eCatch", "emailsiphon"=>"EmailSiphon", "encompass"=>"Encompass", "friendlyspider"=>"FriendlySpider", "fresco"=>"ANT Fresco", "galeon"=>"Galeon", "getright"=>"GetRight", "headdump"=>"HeadDump", "hotjava"=>"Sun HotJava", "ibrowse"=>"IBrowse", "intergo"=>"InterGO", "k-meleon"=>"K-Meleon", "linemodebrowser"=>"W3C Line Mode Browser", "lotus-notes"=>"Lotus Notes web client", "macweb"=>"MacWeb", "multizilla"=>"MultiZilla", "ncsa_mosaic"=>"NCSA Mosaic", "netpositive"=>"NetPositive", "nutscrape", "Nutscrape", "msfrontpageexpress"=>"MS FrontPage Express", "phoenix"=>"Phoenix", "firebird"=>"Mozilla Firebird", "firefox"=>"Mozilla Firefox", "safari"=>"Safari", "tzgeturl"=>"TzGetURL", "viking"=>"Viking", "webfetcher"=>"WebFetcher", "webexplorer"=>"IBM-WebExplorer", "webmirror"=>"WebMirror", "webvcr"=>"WebVCR", // Site grabbers "teleport"=>"TelePort Pro", "webcapture"=>"Acrobat", "webcopier", "WebCopier", // Music only browsers "real"=>"RealAudio or compatible (media player)", "winamp"=>"WinAmp (media player)", // Works for winampmpeg and winamp3httprdr "windows-media-player"=>"Windows Media Player (media player)", "audion"=>"Audion (media player)", "freeamp"=>"FreeAmp (media player)", "itunes"=>"Apple iTunes (media player)", "jetaudio"=>"JetAudio (media player)", "mint_audio"=>"Mint Audio (media player)", "mpg123"=>"mpg123 (media player)", "nsplayer"=>"NetShow Player (media player)", "sonique"=>"Sonique (media player)", "uplayer"=>"Ultra Player (media player)", "xmms"=>"XMMS (media player)", "xaudio"=>"Some XAudio Engine based MPEG player (media player)", // PDA/Phonecell browsers "alcatel"=>"Alcatel Browser (PDA/Phone browser)", "ericsson"=>"Ericsson Browser (PDA/Phone browser)", "mot-"=>"Motorola Browser (PDA/Phone browser)", "nokia"=>"Nokia Browser (PDA/Phone browser)", "panasonic"=>"Panasonic Browser (PDA/Phone browser)", "philips"=>"Philips Browser (PDA/Phone browser)", "sonyericsson"=>"Sony/Ericsson Browser (PDA/Phone browser)", "mmef"=>"Microsoft Mobile Explorer (PDA/Phone browser)", "mspie"=>"MS Pocket Internet Explorer (PDA/Phone browser)", "wapalizer"=>"WAPalizer (PDA/Phone browser)", "wapsilon"=>"WAPsilon (PDA/Phone browser)", "webcollage"=>"WebCollage (PDA/Phone browser)", "up\."=>"UP.Browser (PDA/Phone browser)", // Works for UP.Browser and UP.Link // PDA/Phonecell I-Mode browsers "docomo"=>"I-Mode phone (PDA/Phone browser)", "portalmmm"=>"I-Mode phone (PDA/Phone browser)", // Others (TV) "webtv"=>"WebTV browser", // Other kind of browsers "csscheck"=>"WDG CSS Validator", "w3m"=>"w3m", "w3c_css_validator"=>"W3C CSS Validator", "w3c_validator"=>"W3C HTML Validator", "wdg_validator"=>"WDG HTML Validator", "webzip"=>"WebZIP", "staroffice"=>"StarOffice", "mozilla"=>"Mozilla", "libwww"=>"LibWWW", ); // BrowsersHashAreGrabber // Put here an entry for each browser in BrowsersSearchIDOrder that are grabber // browsers. //--------------------------------------------------------------------------- $BrowsersHereAreGrabbers = array ( "teleport"=>"1", "webcapture"=>"1", "webcopier"=>"1", ); // BrowsersHashIcon // Each Browsers Search ID is associated to a string that is the name of icon // file for this browser. //--------------------------------------------------------------------------- $BrowsersHashIcon = array ( // Standard web browsers "msie"=>"msie", "netscape"=>"netscape", "icab"=>"icab", "go!zilla"=>"gozilla", "konqueror"=>"konqueror", "links"=>"notavailable", "lynx"=>"lynx", "omniweb"=>"omniweb", "opera"=>"opera", "wget"=>"notavailable", "22acidownload"=>"notavailable", "aol\\-iweng"=>"notavailable", "amaya"=>"amaya", "amigavoyager"=>"notavailable", "aweb"=>"notavailable", "bpftp"=>"notavailable", "chimera"=>"chimera", "cyberdog"=>"notavailable", "dillo"=>"notavailable", "dreamcast"=>"dreamcast", "downloadagent"=>"notavailable", "ecatch"=>"notavailable", "emailsiphon"=>"notavailable", "encompass"=>"notavailable", "friendlyspider"=>"notavailable", "fresco"=>"notavailable", "galeon"=>"galeon", "getright"=>"getright", "headdump"=>"notavailable", "hotjava"=>"notavailable", "ibrowse"=>"ibrowse", "intergo"=>"notavailable", "k-meleon"=>"kmeleon", "linemodebrowser"=>"notavailable", "lotus-notes"=>"notavailable", "macweb"=>"notavailable", "multizilla"=>"multizilla", "ncsa_mosaic"=>"notavailable", "netpositive"=>"netpositive", "nutscrape"=>"notavailable", "msfrontpageexpress"=>"notavailable", "phoenix"=>"phoenix", "firebird"=>"firebird", "safari"=>"safari", "tzgeturl"=>"notavailable", "viking"=>"notavailable", "webfetcher"=>"notavailable", "webexplorer"=>"notavailable", "webmirror"=>"notavailable", "webvcr"=>"notavailable", // Site grabbers "teleport"=>"teleport", "webcapture"=>"adobe", "webcopier"=>"webcopier", // Music only browsers "real"=>"mediaplayer", "winamp"=>"mediaplayer", // Works for winampmpeg and winamp3httprdr "windows-media-player"=>"mediaplayer", "audion"=>"mediaplayer", "freeamp"=>"mediaplayer", "itunes"=>"mediaplayer", "jetaudio"=>"mediaplayer", "mint_audio"=>"mediaplayer", "mpg123"=>"mediaplayer", "nsplayer"=>"mediaplayer", "sonique"=>"mediaplayer", "uplayer"=>"mediaplayer", "xmms"=>"mediaplayer", "xaudio"=>"mediaplayer", // PDA/Phonecell browsers "alcatel"=>"pdaphone", // Alcatel "ericsson"=>"pdaphone", // Ericsson "mot-"=>"pdaphone", // Motorola "nokia"=>"pdaphone", // Nokia "panasonic"=>"pdaphone", // Panasonic "philips"=>"pdaphone", // Philips "sonyericsson"=>"pdaphone", // Sony/Ericsson "mmef"=>"pdaphone", "mspie"=>"pdaphone", "wapalizer"=>"pdaphone", "wapsilon"=>"pdaphone", "webcollage"=>"pdaphone", "up\."=>"pdaphone", // Works for UP.Browser and UP.Link // PDA/Phonecell I-Mode browsers "docomo"=>"pdaphone", "portalmmm"=>"pdaphone", // Others (TV) "webtv"=>"webtv", // Other kind of browsers "csscheck"=>"notavailable", "w3m"=>"notavailable", "w3c_css_validator"=>"notavailable", "w3c_validator"=>"notavailable", "wdg_validator"=>"notavailable", "webzip"=>"webzip", "staroffice"=>"staroffice", "mozilla"=>"mozilla", "libwww"=>"notavailable" ); // TODO // Add Gecko category -> IE / Netscape / Gecko(except Netscape) / Other // IE (based on Mosaic) // Netscape family // Gecko except Netscape (Mozilla, Firebird (was Phoenix), Galeon, AmiZilla, Dino, and few others) // Opera (Opera 6/7) // KHTML (Konqueror, Safari) ?>
chanhong/mambo
includes/agent_browser.php
PHP
gpl-2.0
9,696
<style type="text/css"> .ppsAdminMainLeftSide { width: 56%; float: left; } .ppsAdminMainRightSide { width: <?php echo (empty($this->optsDisplayOnMainPage) ? 100 : 40)?>%; float: left; text-align: center; } #ppsMainOccupancy { box-shadow: none !important; } </style> <section> <div class="supsystic-item supsystic-panel"> <div id="containerWrapper"> <?php _e('Main page Go here!!!!', PPS_LANG_CODE)?> </div> <div style="clear: both;"></div> </div> </section>
Sciado/whitelabelheros.com
wp-content/plugins/popup-by-supsystic/modules/options/views/tpl/optionsAdminMain.php
PHP
gpl-2.0
486
/*************************************************************************** * * Copyright (c) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, * 2010, 2011 BalaBit IT Ltd, Budapest, Hungary * * This program 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. * * Note that this permission is granted for only version 2 of the GPL. * * As an additional exemption you are allowed to compile & link against the * OpenSSL libraries as published by the OpenSSL project. See the file * COPYING for details. * * 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., 675 Mass Ave, Cambridge, MA 02139, USA. * * Author : Panther * Auditor : * Last audited version: * Notes: * ***************************************************************************/ #ifndef ZORP_ZORPADDR_H_INCLUDED #define ZORP_ZORPADDR_H_INCLUDED #include "ifcfg.h" #include "zshmem.h" #include "cfg.h" #include "stats.h" #endif
kkovaacs/zorp
zorpaddr/zorpaddr.h
C
gpl-2.0
1,392
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN"> <!--NewPage--> <HTML> <HEAD> <!-- Generated by javadoc on Sat Aug 06 17:04:40 EDT 2005 --> <TITLE> Xalan-Java 2.7.0: Uses of Class org.apache.xml.serializer.utils.SystemIDResolver </TITLE> <LINK REL ="stylesheet" TYPE="text/css" HREF="../../../../../../stylesheet.css" TITLE="Style"> </HEAD> <BODY BGCOLOR="white"> <!-- ========== START OF NAVBAR ========== --> <A NAME="navbar_top"><!-- --></A> <TABLE BORDER="0" WIDTH="100%" CELLPADDING="1" CELLSPACING="0"> <TR> <TD COLSPAN=2 BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A NAME="navbar_top_firstrow"><!-- --></A> <TABLE BORDER="0" CELLPADDING="0" CELLSPACING="3"> <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/apache/xml/serializer/utils/SystemIDResolver.html"><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" TARGET="_top"><B>FRAMES</B></A> &nbsp; &nbsp;<A HREF="SystemIDResolver.html" TARGET="_top"><B>NO FRAMES</B></A></FONT></TD> </TR> </TABLE> <!-- =========== END OF NAVBAR =========== --> <HR> <CENTER> <H2> <B>Uses of Class<br>org.apache.xml.serializer.utils.SystemIDResolver</B></H2> </CENTER> No usage of org.apache.xml.serializer.utils.SystemIDResolver <P> <HR> <!-- ========== START OF NAVBAR ========== --> <A NAME="navbar_bottom"><!-- --></A> <TABLE BORDER="0" WIDTH="100%" CELLPADDING="1" CELLSPACING="0"> <TR> <TD COLSPAN=2 BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A NAME="navbar_bottom_firstrow"><!-- --></A> <TABLE BORDER="0" CELLPADDING="0" CELLSPACING="3"> <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/apache/xml/serializer/utils/SystemIDResolver.html"><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" TARGET="_top"><B>FRAMES</B></A> &nbsp; &nbsp;<A HREF="SystemIDResolver.html" TARGET="_top"><B>NO FRAMES</B></A></FONT></TD> </TR> </TABLE> <!-- =========== END OF NAVBAR =========== --> <HR> Copyright © 2005 Apache XML Project. All Rights Reserved. </BODY> </HTML>
MrStaticVoid/iriverter
lib/xalan-j_2_7_0/docs/apidocs/org/apache/xml/serializer/utils/class-use/SystemIDResolver.html
HTML
gpl-2.0
4,673
/* * Copyright (C) 2008-2014 TrinityCore <http://www.trinitycore.org/> * Copyright (C) 2006-2009 ScriptDev2 <https://scriptdev2.svn.sourceforge.net/> * * 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, see <http://www.gnu.org/licenses/>. */ /* ScriptData SDName: Npc_Taxi SD%Complete: 0% SDComment: To be used for taxi NPCs that are located globally. SDCategory: NPCs EndScriptData */ #include "ScriptMgr.h" #include "ScriptedCreature.h" #include "ScriptedGossip.h" #include "Player.h" #include "WorldSession.h" #define GOSSIP_SUSURRUS "I am ready." #define GOSSIP_NETHER_DRAKE "I'm ready to fly! Take me up, dragon!" #define GOSSIP_BRAZEN "I am ready to go to Durnholde Keep." #define GOSSIP_IRONWING "I'd like to take a flight around Stormwind Harbor." #define GOSSIP_DABIREE1 "Fly me to Murketh and Shaadraz Gateways" #define GOSSIP_DABIREE2 "Fly me to Shatter Point" #define GOSSIP_WINDBELLOW1 "Fly me to The Abyssal Shelf" #define GOSSIP_WINDBELLOW2 "Fly me to Honor Point" #define GOSSIP_BRACK1 "Fly me to Murketh and Shaadraz Gateways" #define GOSSIP_BRACK2 "Fly me to The Abyssal Shelf" #define GOSSIP_BRACK3 "Fly me to Spinebreaker Post" #define GOSSIP_IRENA "Fly me to Skettis please" #define GOSSIP_CLOUDBREAKER1 "Speaking of action, I've been ordered to undertake an air strike." #define GOSSIP_CLOUDBREAKER2 "I need to intercept the Dawnblade reinforcements." #define GOSSIP_DRAGONHAWK "<Ride the dragonhawk to Sun's Reach>" #define GOSSIP_VERONIA "Fly me to Manaforge Coruu please" #define GOSSIP_DEESAK "Fly me to Ogri'la please" #define GOSSIP_AFRASASTRASZ1 "I would like to take a flight to the ground, Lord Of Afrasastrasz." #define GOSSIP_AFRASASTRASZ2 "My Lord, I must go to the upper floor of the temple." #define GOSSIP_TARIOLSTRASZ1 "My Lord, I must go to the upper floor of the temple." #define GOSSIP_TARIOLSTRASZ2 "Can you spare a drake to travel to Lord Of Afrasastrasz, in the middle of the temple?" #define GOSSIP_TORASTRASZA1 "I would like to see Lord Of Afrasastrasz, in the middle of the temple." #define GOSSIP_TORASTRASZA2 "Yes, Please. I would like to return to the ground floor of the temple." #define GOSSIP_CRIMSONWING "<Ride the gryphons to Survey Alcaz Island>" #define GOSSIP_WILLIAMKEILAR1 "Take me to Northpass Tower." #define GOSSIP_WILLIAMKEILAR2 "Take me to Eastwall Tower." #define GOSSIP_WILLIAMKEILAR3 "Take me to Crown Guard Tower." class npc_taxi : public CreatureScript { public: npc_taxi() : CreatureScript("npc_taxi") { } bool OnGossipHello(Player* player, Creature* creature) override { if (creature->IsQuestGiver()) player->PrepareQuestMenu(creature->GetGUID()); switch (creature->GetEntry()) { case 17435: // Azuremyst Isle - Susurrus if (player->HasItemCount(23843, 1, true)) player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_SUSURRUS, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF); break; case 20903: // Netherstorm - Protectorate Nether Drake if (player->GetQuestStatus(10438) == QUEST_STATUS_INCOMPLETE && player->HasItemCount(29778)) player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_NETHER_DRAKE, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 1); break; case 18725: // Old Hillsbrad Foothills - Brazen player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_BRAZEN, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 2); break; case 29154: // Stormwind City - Thargold Ironwing player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_IRONWING, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 3); break; case 19409: // Hellfire Peninsula - Wing Commander Dabir'ee //Mission: The Murketh and Shaadraz Gateways if (player->GetQuestStatus(10146) == QUEST_STATUS_INCOMPLETE) player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_DABIREE1, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 4); //Shatter Point if (!player->GetQuestRewardStatus(10340)) player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_DABIREE2, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 5); break; case 20235: // Hellfire Peninsula - Gryphoneer Windbellow //Mission: The Abyssal Shelf || Return to the Abyssal Shelf if (player->GetQuestStatus(10163) == QUEST_STATUS_INCOMPLETE || player->GetQuestStatus(10346) == QUEST_STATUS_INCOMPLETE) player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_WINDBELLOW1, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 6); //Go to the Front if (player->GetQuestStatus(10382) != QUEST_STATUS_NONE && !player->GetQuestRewardStatus(10382)) player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_WINDBELLOW2, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 7); break; case 19401: // Hellfire Peninsula - Wing Commander Brack //Mission: The Murketh and Shaadraz Gateways if (player->GetQuestStatus(10129) == QUEST_STATUS_INCOMPLETE) player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_BRACK1, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 8); //Mission: The Abyssal Shelf || Return to the Abyssal Shelf if (player->GetQuestStatus(10162) == QUEST_STATUS_INCOMPLETE || player->GetQuestStatus(10347) == QUEST_STATUS_INCOMPLETE) player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_BRACK2, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 9); //Spinebreaker Post if (player->GetQuestStatus(10242) == QUEST_STATUS_COMPLETE) player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_BRACK3, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 10); break; case 23413: // Blade's Edge Mountains - Skyguard Handler Irena if (player->GetReputationRank(1031) >= REP_HONORED) player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_IRENA, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 11); break; case 25059: // Isle of Quel'Danas - Ayren Cloudbreaker if (player->GetQuestStatus(11532) == QUEST_STATUS_INCOMPLETE || player->GetQuestStatus(11533) == QUEST_STATUS_INCOMPLETE) player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_CLOUDBREAKER1, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 12); if (player->GetQuestStatus(11542) == QUEST_STATUS_INCOMPLETE || player->GetQuestStatus(11543) == QUEST_STATUS_INCOMPLETE) player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_CLOUDBREAKER2, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 13); break; case 25236: // Isle of Quel'Danas - Unrestrained Dragonhawk if (player->GetQuestStatus(11542) == QUEST_STATUS_COMPLETE || player->GetQuestStatus(11543) == QUEST_STATUS_COMPLETE) player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_DRAGONHAWK, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 14); break; case 20162: // Netherstorm - Veronia //Behind Enemy Lines if (player->GetQuestStatus(10652) != QUEST_STATUS_REWARDED) player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_VERONIA, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 15); break; case 23415: // Terokkar Forest - Skyguard Handler Deesak if (player->GetReputationRank(1031) >= REP_HONORED) player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_DEESAK, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 16); break; case 27575: // Dragonblight - Lord Afrasastrasz // middle -> ground player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_AFRASASTRASZ1, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 17); // middle -> top player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_AFRASASTRASZ2, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 18); break; case 26443: // Dragonblight - Tariolstrasz //need to check if quests are required before gossip available (12123, 12124) // ground -> top player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_TARIOLSTRASZ1, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 19); // ground -> middle player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_TARIOLSTRASZ2, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 20); break; case 26949: // Dragonblight - Torastrasza // top -> middle player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_TORASTRASZA1, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 21); // top -> ground player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_TORASTRASZA2, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 22); break; case 23704: // Dustwallow Marsh - Cassa Crimsonwing if (player->GetQuestStatus(11142) == QUEST_STATUS_INCOMPLETE) player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_CRIMSONWING, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+25); break; case 17209: player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_WILLIAMKEILAR1, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 28); player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_WILLIAMKEILAR2, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 29); player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_WILLIAMKEILAR3, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 30); break; } player->SEND_GOSSIP_MENU(player->GetGossipTextId(creature), creature->GetGUID()); return true; } bool OnGossipSelect(Player* player, Creature* creature, uint32 /*sender*/, uint32 action) override { player->PlayerTalkClass->ClearMenus(); switch (action) { case GOSSIP_ACTION_INFO_DEF: //spellId is correct, however it gives flight a somewhat funny effect //TaxiPath 506. player->CLOSE_GOSSIP_MENU(); player->CastSpell(player, 32474, true); break; case GOSSIP_ACTION_INFO_DEF + 1: player->CLOSE_GOSSIP_MENU(); player->ActivateTaxiPathTo(627); //TaxiPath 627 (possibly 627+628(152->153->154->155)) break; case GOSSIP_ACTION_INFO_DEF + 2: if (!player->HasItemCount(25853)) player->SEND_GOSSIP_MENU(9780, creature->GetGUID()); else { player->CLOSE_GOSSIP_MENU(); player->ActivateTaxiPathTo(534); //TaxiPath 534 } break; case GOSSIP_ACTION_INFO_DEF + 3: player->CLOSE_GOSSIP_MENU(); player->CastSpell(player, 53335, true); //TaxiPath 1041 (Stormwind Harbor) break; case GOSSIP_ACTION_INFO_DEF + 4: player->CLOSE_GOSSIP_MENU(); player->CastSpell(player, 33768, true); //TaxiPath 585 (Gateways Murket and Shaadraz) break; case GOSSIP_ACTION_INFO_DEF + 5: player->CLOSE_GOSSIP_MENU(); player->CastSpell(player, 35069, true); //TaxiPath 612 (Taxi - Hellfire Peninsula - Expedition Point to Shatter Point) break; case GOSSIP_ACTION_INFO_DEF + 6: player->CLOSE_GOSSIP_MENU(); player->CastSpell(player, 33899, true); //TaxiPath 589 (Aerial Assault Flight (Alliance)) break; case GOSSIP_ACTION_INFO_DEF + 7: player->CLOSE_GOSSIP_MENU(); player->CastSpell(player, 35065, true); //TaxiPath 607 (Taxi - Hellfire Peninsula - Shatter Point to Beach Head) break; case GOSSIP_ACTION_INFO_DEF + 8: player->CLOSE_GOSSIP_MENU(); player->CastSpell(player, 33659, true); //TaxiPath 584 (Gateways Murket and Shaadraz) break; case GOSSIP_ACTION_INFO_DEF + 9: player->CLOSE_GOSSIP_MENU(); player->CastSpell(player, 33825, true); //TaxiPath 587 (Aerial Assault Flight (Horde)) break; case GOSSIP_ACTION_INFO_DEF + 10: player->CLOSE_GOSSIP_MENU(); player->CastSpell(player, 34578, true); //TaxiPath 604 (Taxi - Reaver's Fall to Spinebreaker Ridge) break; case GOSSIP_ACTION_INFO_DEF + 11: player->CLOSE_GOSSIP_MENU(); player->CastSpell(player, 41278, true); //TaxiPath 706 break; case GOSSIP_ACTION_INFO_DEF + 12: player->CLOSE_GOSSIP_MENU(); player->CastSpell(player, 45071, true); //TaxiPath 779 break; case GOSSIP_ACTION_INFO_DEF + 13: player->CLOSE_GOSSIP_MENU(); player->CastSpell(player, 45113, true); //TaxiPath 784 break; case GOSSIP_ACTION_INFO_DEF + 14: player->CLOSE_GOSSIP_MENU(); player->CastSpell(player, 45353, true); //TaxiPath 788 break; case GOSSIP_ACTION_INFO_DEF + 15: player->CLOSE_GOSSIP_MENU(); player->CastSpell(player, 34905, true); //TaxiPath 606 break; case GOSSIP_ACTION_INFO_DEF + 16: player->CLOSE_GOSSIP_MENU(); player->CastSpell(player, 41279, true); //TaxiPath 705 (Taxi - Skettis to Skyguard Outpost) break; case GOSSIP_ACTION_INFO_DEF + 17: player->CLOSE_GOSSIP_MENU(); player->ActivateTaxiPathTo(882); break; case GOSSIP_ACTION_INFO_DEF + 18: player->CLOSE_GOSSIP_MENU(); player->ActivateTaxiPathTo(881); break; case GOSSIP_ACTION_INFO_DEF + 19: player->CLOSE_GOSSIP_MENU(); player->ActivateTaxiPathTo(878); break; case GOSSIP_ACTION_INFO_DEF + 20: player->CLOSE_GOSSIP_MENU(); player->ActivateTaxiPathTo(883); break; case GOSSIP_ACTION_INFO_DEF + 21: player->CLOSE_GOSSIP_MENU(); player->ActivateTaxiPathTo(880); break; case GOSSIP_ACTION_INFO_DEF + 22: player->CLOSE_GOSSIP_MENU(); player->ActivateTaxiPathTo(879); break; case GOSSIP_ACTION_INFO_DEF + 23: player->CLOSE_GOSSIP_MENU(); player->CastSpell(player, 43074, true); //TaxiPath 736 break; case GOSSIP_ACTION_INFO_DEF + 24: player->CLOSE_GOSSIP_MENU(); //player->ActivateTaxiPathTo(738); player->CastSpell(player, 43136, false); break; case GOSSIP_ACTION_INFO_DEF + 25: player->CLOSE_GOSSIP_MENU(); player->CastSpell(player, 42295, true); break; case GOSSIP_ACTION_INFO_DEF + 26: player->CLOSE_GOSSIP_MENU(); player->ActivateTaxiPathTo(494); break; case GOSSIP_ACTION_INFO_DEF + 27: player->CLOSE_GOSSIP_MENU(); player->ActivateTaxiPathTo(495); break; case GOSSIP_ACTION_INFO_DEF + 28: player->CLOSE_GOSSIP_MENU(); player->ActivateTaxiPathTo(496); break; } return true; } }; void AddSC_npc_taxi() { new npc_taxi; }
madisodr/legacy-core
src/server/scripts/World/npc_taxi.cpp
C++
gpl-2.0
16,513
/** * UGENE - Integrated Bioinformatics Tools. * Copyright (C) 2008-2022 UniPro <[email protected]> * http://ugene.net * * 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 "ScriptEditorWidget.h" #include <QBoxLayout> #include <QLineEdit> #include <QSplitter> #include <QTextEdit> #include "ScriptHighlighter.h" const char* SCRIPT_TEXT_PROPERTY_NAME = "script text"; namespace U2 { ScriptEditorWidget::ScriptEditorWidget(QWidget* parent, ScriptEditorType typeOfField) : QWidget(parent) { scriptContainer = new QSplitter(Qt::Vertical, this); scriptContainer->setFocusPolicy(Qt::NoFocus); QBoxLayout* layout = new QBoxLayout(QBoxLayout::TopToBottom, this); layout->setMargin(0); layout->addWidget(scriptContainer); variablesEdit = new QTextEdit(scriptContainer); variablesEdit->setReadOnly(true); new ScriptHighlighter(variablesEdit->document()); scriptEdit = AbstractScriptEditorDelegate::createInstance(scriptContainer, typeOfField); scriptEdit->installScriptHighlighter(); connect(scriptEdit, SIGNAL(si_textChanged()), SIGNAL(si_textChanged())); connect(scriptEdit, SIGNAL(si_cursorPositionChanged()), SIGNAL(si_cursorPositionChanged())); } void ScriptEditorWidget::setVariablesText(const QString& variablesText) { variablesEdit->setText(variablesText); } QString ScriptEditorWidget::variablesText() const { return variablesEdit->toPlainText(); } void ScriptEditorWidget::setScriptText(const QString& text) { scriptEdit->setText(text); } QString ScriptEditorWidget::scriptText() const { return scriptEdit->text(); } int ScriptEditorWidget::scriptEditCursorLineNumber() const { return scriptEdit->cursorLineNumber(); } } // namespace U2
ugeneunipro/ugene
src/corelibs/U2Gui/src/util/ScriptEditorWidget.cpp
C++
gpl-2.0
2,409
/* YUI 3.7.3 (build 5687) Copyright 2012 Yahoo! Inc. All rights reserved. Licensed under the BSD License. http://yuilibrary.com/license/ */ YUI.add('dom-class', function(Y) { var addClass, hasClass, removeClass; Y.mix(Y.DOM, { /** * Determines whether a DOM element has the given className. * @method hasClass * @for DOM * @param {HTMLElement} element The DOM element. * @param {String} className the class name to search for * @return {Boolean} Whether or not the element has the given class. */ hasClass: function(node, className) { var re = Y.DOM._getRegExp('(?:^|\\s+)' + className + '(?:\\s+|$)'); return re.test(node.className); }, /** * Adds a class name to a given DOM element. * @method addClass * @for DOM * @param {HTMLElement} element The DOM element. * @param {String} className the class name to add to the class attribute */ addClass: function(node, className) { if (!Y.DOM.hasClass(node, className)) { // skip if already present node.className = Y.Lang.trim([node.className, className].join(' ')); } }, /** * Removes a class name from a given element. * @method removeClass * @for DOM * @param {HTMLElement} element The DOM element. * @param {String} className the class name to remove from the class attribute */ removeClass: function(node, className) { if (className && hasClass(node, className)) { node.className = Y.Lang.trim(node.className.replace(Y.DOM._getRegExp('(?:^|\\s+)' + className + '(?:\\s+|$)'), ' ')); if ( hasClass(node, className) ) { // in case of multiple adjacent removeClass(node, className); } } }, /** * Replace a class with another class for a given element. * If no oldClassName is present, the newClassName is simply added. * @method replaceClass * @for DOM * @param {HTMLElement} element The DOM element * @param {String} oldClassName the class name to be replaced * @param {String} newClassName the class name that will be replacing the old class name */ replaceClass: function(node, oldC, newC) { //Y.log('replaceClass replacing ' + oldC + ' with ' + newC, 'info', 'Node'); removeClass(node, oldC); // remove first in case oldC === newC addClass(node, newC); }, /** * If the className exists on the node it is removed, if it doesn't exist it is added. * @method toggleClass * @for DOM * @param {HTMLElement} element The DOM element * @param {String} className the class name to be toggled * @param {Boolean} addClass optional boolean to indicate whether class * should be added or removed regardless of current state */ toggleClass: function(node, className, force) { var add = (force !== undefined) ? force : !(hasClass(node, className)); if (add) { addClass(node, className); } else { removeClass(node, className); } } }); hasClass = Y.DOM.hasClass; removeClass = Y.DOM.removeClass; addClass = Y.DOM.addClass; }, '3.7.3' ,{requires:['dom-core']});
artefactual-labs/trac
sites/all/libraries/yui/build/dom-class/dom-class-debug.js
JavaScript
gpl-2.0
3,423
import { Injectable } from '@angular/core'; import { of } from 'rxjs'; import { Resolve, ActivatedRouteSnapshot } from '@angular/router'; import { catchError } from 'rxjs/operators'; import { CatalogoService } from './catalogo.service'; @Injectable() export class EdicaoNovoResolverService implements Resolve<any> { constructor(private catalogoService: CatalogoService) {} resolve(snapshot: ActivatedRouteSnapshot) { const params = snapshot.queryParams; return this.catalogoService.getModelo(params['id']) .pipe(catchError((error) => of({error: error}))); } }
lexml/madoc
ui/src/app/service/edicao-novo.resolver.service.ts
TypeScript
gpl-2.0
589
package agaroyun.view; import java.awt.Graphics; import java.awt.Graphics2D; import java.awt.event.KeyEvent; import java.awt.event.KeyListener; import java.util.ArrayList; import javax.swing.JPanel; import agaroyun.Model.GameObject; import agaroyun.Model.Player; /** * draws GameObjects to panel * @author varyok * @version 1.0 */ public class GamePanel extends JPanel { private ArrayList<GameObject> gameObjects; /** * Keeps gameObjects ArrayList * @param gameObjects */ public GamePanel(ArrayList<GameObject> gameObjects) { this.gameObjects=gameObjects; } /** * draws GameObjects to panel */ @Override protected synchronized void paintComponent(Graphics g) { super.paintComponent(g); Graphics2D g2d=(Graphics2D)g; //Graphics 2d daha fazla özellik sağlayabilir. daha kolaydır for (GameObject gameObject : gameObjects) { gameObject.draw(g2d); } } }
by-waryoq/LYKJava2017Basics
src/agaroyun/view/GamePanel.java
Java
gpl-2.0
916
package net.sf.memoranda.util; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import net.sf.memoranda.ui.AppFrame; /** * <p> * Title: * </p> * <p> * Description: * </p> * <p> * Copyright: Copyright (c) 2002 * </p> * <p> * Company: * </p> * * @author unascribed * @version 1.0 */ /* $Id: Context.java,v 1.3 2004/01/30 12:17:42 alexeya Exp $ */ public class Context { public static LoadableProperties context = new LoadableProperties(); static { CurrentStorage.get().restoreContext(); AppFrame.addExitListener(new ActionListener() { public void actionPerformed(ActionEvent e) { CurrentStorage.get().storeContext(); } }); } public static Object get(Object key) { return context.get(key); } public static void put(Object key, Object value) { context.put(key, value); } }
cst316/spring16project-Fortran
src/net/sf/memoranda/util/Context.java
Java
gpl-2.0
845
## 1.8.0 (September 2015) - New MATERIAL DESIGN theme - Updated FILE TYPE ICONS - Preview TXT files within the app - COPY files & folders - Preview the full file/folder name from the long press menu - Set a file as FAVORITE (kept-in-sync) from the CONTEXT MENU - Updated CONFLICT RESOLUTION dialog (wording) - Images with TRANSPARENT background are previewed correctly - Hidden files are not taken into account for enforcing or not the list VIEW - Several bugs fixed ## 1.7.2 (July 2015) - New navigation drawer - Improved Passcode - Automatic grid view just for folders full of images - More characters allowed in file names - Support for servers in same domain, different path - Bugs fixed: + Frequent crashes in folder with several images + Sync error in servers with huge quota and external storage enable + Share by link error + Some other crashes and minor bugs ## 1.7.1 (April 2015) - Share link even with password enforced by server - Get the app ready for oc 8.1 servers - Added option to create new folder in uploads from external apps - Improved management of deleted users - Bugs fixed + Fixed crash on Android 2.x devices + Improvements on uploads ## 1.7.0 (February 2015) - Download full folders - Grid view for images - Remote thumbnails (OC Server 8.0+) - Added number of files and folders at the end of the list - "Open with" in contextual menu - Downloads added to Media Provider - Uploads: + Local thumbnails in section "Files" + Multiple selection in "Content from other apps" (Android 4.3+) - Gallery: + proper handling of EXIF + obey sorting in the list of files - Settings view updated - Improved subjects in e-mails - Bugs fixed
maduhu/android
CHANGELOG.md
Markdown
gpl-2.0
1,684
joomla_wisco_p ============== joomla .wisco.templates
pyyxx123/joomla_wisco_p
README.md
Markdown
gpl-2.0
55
#ifndef SPRINGLOBBY_HEADERGUARD_USER_H #define SPRINGLOBBY_HEADERGUARD_USER_H #include <wx/string.h> #include <wx/colour.h> #include "utils/mixins.hh" class Server; const unsigned int SYNC_UNKNOWN = 0; const unsigned int SYNC_SYNCED = 1; const unsigned int SYNC_UNSYNCED = 2; //! @brief Struct used to store a client's status. struct UserStatus { enum RankContainer { RANK_1, RANK_2, RANK_3, RANK_4, RANK_5, RANK_6, RANK_7, RANK_8 }; bool in_game; bool away; RankContainer rank; bool moderator; bool bot; UserStatus(): in_game(false), away(false), rank(RANK_1), moderator(false), bot(false) {} wxString GetDiffString ( const UserStatus& other ) const; }; struct UserPosition { int x; int y; UserPosition(): x(-1), y(-1) {} }; struct UserBattleStatus { //!!! when adding something to this struct, also modify User::UpdateBattleStatus() !! // total 17 members here int team; int ally; wxColour colour; int color_index; int handicap; int side; unsigned int sync; bool spectator; bool ready; bool isfromdemo; UserPosition pos; // for startpos = 4 // bot-only stuff wxString owner; wxString aishortname; wxString airawname; wxString aiversion; int aitype; // for nat holepunching wxString ip; unsigned int udpport; wxString scriptPassword; bool IsBot() const { return !aishortname.IsEmpty(); } UserBattleStatus(): team(0),ally(0),colour(wxColour(0,0,0)),color_index(-1),handicap(0),side(0),sync(SYNC_UNKNOWN),spectator(false),ready(false), isfromdemo(false), aitype(-1), udpport(0) {} bool operator == ( const UserBattleStatus& s ) const { return ( ( team == s.team ) && ( colour == s.colour ) && ( handicap == s.handicap ) && ( side == s.side ) && ( sync == s.sync ) && ( spectator == s.spectator ) && ( ready == s.ready ) && ( owner == s.owner ) && ( aishortname == s.aishortname ) && ( isfromdemo == s.isfromdemo ) && ( aitype == s.aitype ) ); } bool operator != ( const UserBattleStatus& s ) const { return ( ( team != s.team ) || ( colour != s.colour ) || ( handicap != s.handicap ) || ( side != s.side ) || ( sync != s.sync ) || ( spectator != s.spectator ) || ( ready != s.ready ) || ( owner != s.owner ) || ( aishortname != s.aishortname ) || ( isfromdemo != s.isfromdemo ) || ( aitype != s.aitype ) ); } }; class ChatPanel; class Battle; struct UiUserData { UiUserData(): panel(0) {} ChatPanel* panel; }; //! parent class leaving out server related functionality class CommonUser { public: CommonUser(const wxString& nick, const wxString& country, const int& cpu) : m_nick(wxString(nick)), m_country(wxString(country)), m_cpu(cpu) {} virtual ~CommonUser(){} const wxString& GetNick() const { return m_nick; } virtual void SetNick( const wxString& nick ) { m_nick = nick; } const wxString& GetCountry() const { return m_country; } virtual void SetCountry( const wxString& country ) { m_country = country; } int GetCpu() const { return m_cpu; } void SetCpu( const int& cpu ) { m_cpu = cpu; } const wxString& GetID() const { return m_id; } void SetID( const wxString& id ) { m_id = id; } UserStatus& Status() { return m_status; } UserStatus GetStatus() const { return m_status; } virtual void SetStatus( const UserStatus& status ); UserBattleStatus& BattleStatus() { return m_bstatus; } UserBattleStatus GetBattleStatus() const { return m_bstatus; } /** Read-only variant of BattleStatus() above. */ const UserBattleStatus& BattleStatus() const { return m_bstatus; } //void SetBattleStatus( const UserBattleStatus& status );/// dont use this to avoid overwriting data like ip and port, use following method. void UpdateBattleStatus( const UserBattleStatus& status ); /* void SetUserData( void* userdata ) { m_data = userdata; } void* GetUserData() { return m_data; }*/ bool Equals( const CommonUser& other ) const { return ( m_nick == other.GetNick() ); } protected: wxString m_nick; wxString m_country; wxString m_id; int m_cpu; UserStatus m_status; UserBattleStatus m_bstatus; //void* m_data; }; //! Class containing all the information about a user class User : public CommonUser { public: mutable UiUserData uidata; User( Server& serv ); User( const wxString& nick, Server& serv ); User( const wxString& nick, const wxString& country, const int& cpu, Server& serv); User( const wxString& nick ); User( const wxString& nick, const wxString& country, const int& cpu ); User(); virtual ~User(); // User interface Server& GetServer() const { return *m_serv; } void Said( const wxString& message ) const; void Say( const wxString& message ) const; void DoAction( const wxString& message ) const; Battle* GetBattle() const; void SetBattle( Battle* battle ); void SendMyUserStatus() const; void SetStatus( const UserStatus& status ); void SetCountry( const wxString& country ); bool ExecuteSayCommand( const wxString& cmd ) const; static wxString GetRankName(UserStatus::RankContainer rank); float GetBalanceRank(); UserStatus::RankContainer GetRank(); wxString GetClan(); int GetFlagIconIndex() const { return m_flagicon_idx; } int GetRankIconIndex() const { return m_rankicon_idx; } int GetStatusIconIndex() const { return m_statusicon_idx; } //bool operator< ( const User& other ) const { return m_nick < other.GetNick() ; } //User& operator= ( const User& other ); int GetSideiconIndex() const { return m_sideicon_idx; } void SetSideiconIndex( const int idx ) { m_sideicon_idx = idx; } protected: // User variables Server* m_serv; Battle* m_battle; int m_flagicon_idx; int m_rankicon_idx; int m_statusicon_idx; int m_sideicon_idx; //! copy-semantics? }; #endif // SPRINGLOBBY_HEADERGUARD_USER_H /** This file is part of SpringLobby, Copyright (C) 2007-2011 SpringLobby 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. SpringLobby 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 SpringLobby. If not, see <http://www.gnu.org/licenses/>. **/
N2maniac/springlobby-join-fork
src/user.h
C
gpl-2.0
6,758
<?php /** * * * Created on Jan 4, 2008 * * Copyright © 2008 Yuri Astrakhan <Firstname><Lastname>@gmail.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., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * http://www.gnu.org/copyleft/gpl.html * * @file */ /** * API module to allow users to watch a page * * @ingroup API */ class ApiWatch extends ApiBase { public function __construct( $main, $action ) { parent::__construct( $main, $action ); } public function execute() { $user = $this->getUser(); if ( !$user->isLoggedIn() ) { $this->dieUsage( 'You must be logged-in to have a watchlist', 'notloggedin' ); } $params = $this->extractRequestParams(); $title = Title::newFromText( $params['title'] ); if ( !$title || $title->getNamespace() < 0 ) { $this->dieUsageMsg( array( 'invalidtitle', $params['title'] ) ); } $res = array( 'title' => $title->getPrefixedText() ); if ( $params['unwatch'] ) { $res['unwatched'] = ''; $res['message'] = wfMsgExt( 'removedwatchtext', array( 'parse' ), $title->getPrefixedText() ); $success = UnwatchAction::doUnwatch( $title, $user ); } else { $res['watched'] = ''; $res['message'] = wfMsgExt( 'addedwatchtext', array( 'parse' ), $title->getPrefixedText() ); $success = WatchAction::doWatch( $title, $user ); } if ( !$success ) { $this->dieUsageMsg( 'hookaborted' ); } $this->getResult()->addValue( null, $this->getModuleName(), $res ); } public function mustBePosted() { return true; } public function isWriteMode() { return true; } public function needsToken() { return true; } public function getTokenSalt() { return 'watch'; } public function getAllowedParams() { return array( 'title' => array( ApiBase::PARAM_TYPE => 'string', ApiBase::PARAM_REQUIRED => true ), 'unwatch' => false, 'token' => null, ); } public function getParamDescription() { return array( 'title' => 'The page to (un)watch', 'unwatch' => 'If set the page will be unwatched rather than watched', 'token' => 'A token previously acquired via prop=info', ); } public function getDescription() { return 'Add or remove a page from/to the current user\'s watchlist'; } public function getPossibleErrors() { return array_merge( parent::getPossibleErrors(), array( array( 'code' => 'notloggedin', 'info' => 'You must be logged-in to have a watchlist' ), array( 'invalidtitle', 'title' ), array( 'hookaborted' ), ) ); } public function getExamples() { return array( 'api.php?action=watch&title=Main_Page' => 'Watch the page "Main Page"', 'api.php?action=watch&title=Main_Page&unwatch=' => 'Unwatch the page "Main Page"', ); } public function getHelpUrls() { return 'https://www.mediawiki.org/wiki/API:Watch'; } public function getVersion() { return __CLASS__ . ': $Id$'; } }
ezc/mediawiki
includes/api/ApiWatch.php
PHP
gpl-2.0
3,488
/* -*- c -*- */ /* $Id: sha.h 6172 2011-03-27 12:40:30Z cher $ */ #ifndef __SHA_H__ #define __SHA_H__ 1 /* * 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 */ /* This file is taken from textutils-2.1. Cher. */ /* sha.h - Declaration of functions and datatypes for SHA1 sum computing library functions. Copyright (C) 1999, Scott G. Miller */ #include "reuse_integral.h" #include <stdio.h> /* Structure to save state of computation between the single steps. */ struct sha_ctx { ruint32_t A; ruint32_t B; ruint32_t C; ruint32_t D; ruint32_t E; ruint32_t total[2]; ruint32_t buflen; char buffer[128]; }; /* Starting with the result of former calls of this function (or the initialization function update the context for the next LEN bytes starting at BUFFER. It is necessary that LEN is a multiple of 64!!! */ void sha_process_block(const void *buffer, size_t len, struct sha_ctx *ctx); /* Starting with the result of former calls of this function (or the initialization function update the context for the next LEN bytes starting at BUFFER. It is NOT required that LEN is a multiple of 64. */ void sha_process_bytes(const void *buffer, size_t len, struct sha_ctx *ctx); /* Initialize structure containing state of computation. */ void sha_init_ctx(struct sha_ctx *ctx); /* Process the remaining bytes in the buffer and put result from CTX in first 20 bytes following RESBUF. The result is always in little endian byte order, so that a byte-wise output yields to the wanted ASCII representation of the message digest. IMPORTANT: On some systems it is required that RESBUF is correctly aligned for a 32 bits value. */ void *sha_finish_ctx(struct sha_ctx *ctx, void *resbuf); /* Put result from CTX in first 20 bytes following RESBUF. The result is always in little endian byte order, so that a byte-wise output yields to the wanted ASCII representation of the message digest. IMPORTANT: On some systems it is required that RESBUF is correctly aligned for a 32 bits value. */ void *sha_read_ctx(const struct sha_ctx *ctx, void *resbuf); /* Compute SHA1 message digest for bytes read from STREAM. The resulting message digest number will be written into the 20 bytes beginning at RESBLOCK. */ int sha_stream(FILE *stream, void *resblock); /* Compute SHA1 message digest for LEN bytes beginning at BUFFER. The result is always in little endian byte order, so that a byte-wise output yields to the wanted ASCII representation of the message digest. */ void *sha_buffer(const char *buffer, size_t len, void *resblock); #endif /* __SHA_H__ */
stden/ejudge
sha.h
C
gpl-2.0
3,310
/* SET.C - performing :set - command * * NOTE: Edit this file with tabstop=4 ! * * 1996-02-29 created; * 1998-03-14 V 1.0.1 * 1999-01-14 V 1.1.0 * 1999-03-17 V 1.1.1 * 1999-07-02 V 1.2.0 beta * 1999-08-14 V 1.2.0 final * 2000-07-15 V 1.3.0 final * 2001-10-10 V 1.3.1 * 2003-07-03 V 1.3.2 * * Copyright 1996-2003 by Gerhard Buergmann * [email protected] * * 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, 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. * * See file COPYING for information on distribution conditions. */ #include "bvi.h" #include "set.h" extern struct BLOCK_ data_block[BLK_COUNT]; static int from_file = 0; static FILE *ffp; static char fbuf[256]; static char buf[64]; struct { short r; short g; short b; } original_colors[8]; struct { short f; short b; } original_colorpairs[8]; struct param params[] = { {"autowrite", "aw", FALSE, "", P_BOOL}, {"columns", "cm", 16, "", P_NUM}, {"errorbells", "eb", FALSE, "", P_BOOL}, {"ignorecase", "ic", FALSE, "", P_BOOL}, {"magic", "ma", TRUE, "", P_BOOL}, {"memmove", "mm", FALSE, "", P_BOOL}, {"offset", "of", 0, "", P_NUM}, {"readonly", "ro", FALSE, "", P_BOOL}, {"scroll", "scroll", 12, "", P_NUM}, {"showmode", "mo", TRUE, "", P_BOOL}, {"term", "term", 0, "", P_TEXT}, {"terse", "terse", FALSE, "", P_BOOL}, {"unixstyle", "us", FALSE, "", P_BOOL}, {"window", "window", 25, "", P_NUM}, {"wordlength", "wl", 4, "", P_NUM}, {"wrapscan", "ws", TRUE, "", P_BOOL}, {"", "", 0, "", 0,} /* end marker */ }; struct color colors[] = { /* RGB definitions and default value, if have no support of 256 colors */ {"background", "bg", 50, 50, 50, COLOR_BLACK}, {"addresses", "addr", 335, 506, 700, COLOR_BLUE}, {"hex", "hex", 600, 600, 600, COLOR_MAGENTA}, {"data", "data", 0, 800, 400, COLOR_GREEN}, {"error", "err", 999, 350, 0, COLOR_RED}, {"status", "stat", 255, 255, 255, COLOR_WHITE}, {"command", "comm", 255, 255, 255, COLOR_WHITE}, {"window", "win", 0, 800, 900, COLOR_YELLOW}, {"addrbg", "addrbg", 0, 0, 0, COLOR_CYAN}, {"", "", 0, 0, 0, 0} /* end marker */ }; int doset(arg) char *arg; /* parameter string */ { int i; char *s; int did_window = FALSE; int state = TRUE; /* new state of boolean parms. */ char string[80]; if (arg == NULL) { showparms(FALSE); return 0; } if (!strcmp(arg, "all")) { showparms(TRUE); return 0; } if (!strncmp(arg, "no", 2)) { state = FALSE; arg += 2; } /* extract colors section */ if (!strncmp(arg, "color", 5)) { arg = substr(arg, 6, -1); for (i = 0; colors[i].fullname[0] != '\0'; i++) { s = colors[i].fullname; if (strncmp(arg, s, strlen(s)) == 0) break; s = colors[i].shortname; if (strncmp(arg, s, strlen(s)) == 0) break; } if (i == 0) { emsg("Wrong color name!"); return 0; } else { colors[i].r = atoi(substr(arg, strlen(s) + 1, 3)); colors[i].g = atoi(substr(arg, strlen(s) + 5, 3)); colors[i].b = atoi(substr(arg, strlen(s) + 9, 3)); set_palette(); repaint(); } return 0; } else { emsg(arg); return 1; } for (i = 0; params[i].fullname[0] != '\0'; i++) { s = params[i].fullname; if (strncmp(arg, s, strlen(s)) == 0) /* matched full name */ break; s = params[i].shortname; if (strncmp(arg, s, strlen(s)) == 0) /* matched short name */ break; } if (params[i].fullname[0] != '\0') { /* found a match */ if (arg[strlen(s)] == '?') { if (params[i].flags & P_BOOL) sprintf(buf, " %s%s", (params[i].nvalue ? " " : "no"), params[i].fullname); else if (params[i].flags & P_TEXT) sprintf(buf, " %s=%s", params[i].fullname, params[i].svalue); else sprintf(buf, " %s=%ld", params[i].fullname, params[i].nvalue); msg(buf); return 0; } if (!strcmp(params[i].fullname, "term")) { emsg("Can't change type of terminal from within bvi"); return 1; } if (params[i].flags & P_NUM) { if ((i == P_LI) || (i == P_OF)) did_window++; if (arg[strlen(s)] != '=' || state == FALSE) { sprintf(string, "Option %s is not a toggle", params[i].fullname); emsg(string); return 1; } else { s = arg + strlen(s) + 1; if (*s == '0') { params[i].nvalue = strtol(s, &s, 16); } else { params[i].nvalue = strtol(s, &s, 10); } params[i].flags |= P_CHANGED; if (i == P_CM) { if (((COLS - AnzAdd - 1) / 4) >= P(P_CM)) { COLUMNS_DATA = P(P_CM); } else { COLUMNS_DATA = P(P_CM) = ((COLS - AnzAdd - 1) / 4); } maxx = COLUMNS_DATA * 4 + AnzAdd + 1; COLUMNS_HEX = COLUMNS_DATA * 3; status = COLUMNS_HEX + COLUMNS_DATA - 17; screen = COLUMNS_DATA * (maxy - 1); did_window++; stuffin("H"); /* set cursor at HOME */ } } } else { /* boolean */ if (arg[strlen(s)] == '=') { emsg("Invalid set of boolean parameter"); return 1; } else { params[i].nvalue = state; params[i].flags |= P_CHANGED; } } } else { emsg("No such option@- `set all' gives all option values"); return 1; } if (did_window) { maxy = P(P_LI) - 1; new_screen(); } return 0; } /* show ALL parameters */ void showparms(all) int all; { struct param *p; int n; n = 2; msg("Parameters:\n"); for (p = &params[0]; p->fullname[0] != '\0'; p++) { if (!all && ((p->flags & P_CHANGED) == 0)) continue; if (p->flags & P_BOOL) sprintf(buf, " %s%s\n", (p->nvalue ? " " : "no"), p->fullname); else if (p->flags & P_TEXT) sprintf(buf, " %s=%s\n", p->fullname, p->svalue); else sprintf(buf, " %s=%ld\n", p->fullname, p->nvalue); msg(buf); n++; if (n == params[P_LI].nvalue) { if (wait_return(FALSE)) return; n = 1; } } wait_return(TRUE); } void save_orig_palette() { int i; for (i = 0; colors[i].fullname[0] != '\0'; i++) { color_content(colors[i].short_value, &original_colors[i].r, &original_colors[i].g, &original_colors[i].b); } for (i = 1; i < 8; i++) { pair_content(i, &original_colorpairs[i].f, &original_colorpairs[i].b); } } void load_orig_palette() { int i; for (i = 0; colors[i].fullname[0] != '\0'; i++) { init_color(colors[i].short_value, original_colors[i].r, original_colors[i].g, original_colors[i].b); } for (i = 1; i < 8; i++) { init_pair(i, original_colorpairs[i].f, original_colorpairs[i].b); } } void set_palette() { int i; if (can_change_color()) { for (i = 0; colors[i].fullname[0] != '\0'; i++) { if (init_color (colors[i].short_value, C_r(i), C_g(i), C_b(i)) == ERR) fprintf(stderr, "Failed to set [%d] color!\n", i); if (C_s(i) <= 7) { init_pair(i + 1, C_s(i), C_s(0)); } else { colors[i].short_value = COLOR_WHITE; init_pair(i + 1, C_s(i), C_s(0)); } } init_pair(C_AD + 1, C_s(C_AD), COLOR_CYAN); } else { /* if have no support of changing colors */ for (i = 0; colors[i].fullname[0] != '\0'; i++) { if (C_s(i) <= 7) { init_pair(i + 1, C_s(i), C_s(0)); } else { colors[i].short_value = COLOR_WHITE; init_pair(i + 1, C_s(i), C_s(0)); } } } } /* reads the init file (.bvirc) */ int read_rc(fn) char *fn; { if ((ffp = fopen(fn, "r")) == NULL) return -1; from_file = 1; while (fgets(fbuf, 255, ffp) != NULL) { strtok(fbuf, "\n\r"); docmdline(fbuf); } fclose(ffp); from_file = 0; return 0; } int do_logic(mode, str) int mode; char *str; { int a, b; int value; size_t n; char *err_str = "Invalid value@for bit manipulation"; if (mode == LSHIFT || mode == RSHIFT || mode == LROTATE || mode == RROTATE) { value = atoi(str); if (value < 1 || value > 8) { emsg(err_str); return 1; } } else { if (strlen(str) == 8) { value = strtol(str, NULL, 2); for (n = 0; n < 8; n++) { if (str[n] != '0' && str[n] != '1') { value = -1; break; } } } else if (str[0] == 'b' || str[0] == 'B') { value = strtol(str + 1, NULL, 2); } else if (str[0] == '0') { value = strtol(str, NULL, 16); for (n = 0; n < strlen(str); n++) { if (!isxdigit(str[n])) { value = -1; break; } } } else { value = atoi(str); } if (value < 0 || value > 255) { emsg(err_str); return 1; } } if ((undo_count = alloc_buf((off_t) (end_addr - start_addr + 1), &undo_buf))) { memcpy(undo_buf, start_addr, undo_count); } undo_start = start_addr; edits = U_EDIT; while (start_addr <= end_addr) { a = *start_addr; a &= 0xff; switch (mode) { case LSHIFT: a <<= value; break; case RSHIFT: a >>= value; break; case LROTATE: a <<= value; b = a >> 8; a |= b; break; case RROTATE: b = a << 8; a |= b; a >>= value; /* b = a << (8 - value); a >>= value; a |= b; */ break; case AND: a &= value; break; case OR: a |= value; break; case XOR: case NOT: a ^= value; break; case NEG: a ^= value; a++; /* Is this true */ break; } *start_addr++ = (char)(a & 0xff); } repaint(); return (0); } int do_logic_block(mode, str, block_number) int mode; char *str; int block_number; { int a, b; int value; size_t n; char *err_str = "Invalid value@for bit manipulation"; if ((block_number >= BLK_COUNT) & (!(data_block[block_number].pos_start < data_block[block_number].pos_end))) { emsg("Invalid block for bit manipulation!"); return 1; } if (mode == LSHIFT || mode == RSHIFT || mode == LROTATE || mode == RROTATE) { value = atoi(str); if (value < 1 || value > 8) { emsg(err_str); return 1; } } else { if (strlen(str) == 8) { value = strtol(str, NULL, 2); for (n = 0; n < 8; n++) { if (str[n] != '0' && str[n] != '1') { value = -1; break; } } } else if (str[0] == 'b' || str[0] == 'B') { value = strtol(str + 1, NULL, 2); } else if (str[0] == '0') { value = strtol(str, NULL, 16); for (n = 0; n < strlen(str); n++) { if (!isxdigit(str[n])) { value = -1; break; } } } else { value = atoi(str); } if (value < 0 || value > 255) { emsg(err_str); return 1; } } if ((undo_count = alloc_buf((off_t) (data_block[block_number].pos_end - data_block[block_number].pos_start + 1), &undo_buf))) { memcpy(undo_buf, start_addr + data_block[block_number].pos_start, undo_count); } undo_start = start_addr + data_block[block_number].pos_start; edits = U_EDIT; start_addr = start_addr + data_block[block_number].pos_start; end_addr = start_addr + data_block[block_number].pos_end - data_block[block_number].pos_start; while (start_addr <= end_addr) { a = *start_addr; a &= 0xff; switch (mode) { case LSHIFT: a <<= value; break; case RSHIFT: a >>= value; break; case LROTATE: a <<= value; b = a >> 8; a |= b; break; case RROTATE: b = a << 8; a |= b; a >>= value; /* b = a << (8 - value); a >>= value; a |= b; */ break; case AND: a &= value; break; case OR: a |= value; break; case XOR: case NOT: a ^= value; break; case NEG: a ^= value; a++; /* Is this true */ break; } *start_addr++ = (char)(a & 0xff); } repaint(); return (0); } int getcmdstr(p, x) char *p; int x; { int c; int n; char *buff, *q; attron(COLOR_PAIR(C_CM + 1)); if (from_file) { if (fgets(p, 255, ffp) != NULL) { strtok(p, "\n\r"); return 0; } else { return 1; } } signal(SIGINT, jmpproc); buff = p; move(maxy, x); do { switch (c = vgetc()) { case BVICTRL('H'): case KEY_BACKSPACE: case KEY_LEFT: if (p > buff) { p--; move(maxy, x); n = x; for (q = buff; q < p; q++) { addch(*q); n++; } addch(' '); move(maxy, n); } else { *buff = '\0'; msg(""); attroff(COLOR_PAIR(C_CM + 1)); signal(SIGINT, SIG_IGN); return 1; } break; case ESC: /* abandon command */ *buff = '\0'; msg(""); attroff(COLOR_PAIR(C_CM + 1)); signal(SIGINT, SIG_IGN); return 1; #if NL != KEY_ENTER case NL: #endif #if CR != KEY_ENTER case CR: #endif case KEY_ENTER: break; default: /* a normal character */ addch(c); *p++ = c; break; } refresh(); } while (c != NL && c != CR && c != KEY_ENTER); attroff(COLOR_PAIR(C_CM + 1)); *p = '\0'; signal(SIGINT, SIG_IGN); return 0; }
XVilka/bvim
set.c
C
gpl-2.0
12,671
local keywordHandler = KeywordHandler:new() local npcHandler = NpcHandler:new(keywordHandler) NpcSystem.parseParameters(npcHandler) function onCreatureAppear(cid) npcHandler:onCreatureAppear(cid) end function onCreatureDisappear(cid) npcHandler:onCreatureDisappear(cid) end function onCreatureSay(cid, type, msg) npcHandler:onCreatureSay(cid, type, msg) end local lastSound = 0 function onThink() if lastSound < os.time() then lastSound = (os.time() + 5) if math.random(100) < 25 then Npc():say("Come into my tavern and share some stories!", TALKTYPE_SAY) end end npcHandler:onThink() end npcHandler:setMessage(MESSAGE_GREET, "Welcome to Frodo's Hut. You heard about the {news}?") npcHandler:setMessage(MESSAGE_FAREWELL, "Please come back from time to time.") npcHandler:setMessage(MESSAGE_WALKAWAY, "Please come back from time to time.") npcHandler:addModule(FocusModule:new())
Tatuy/UAServer
data/npc/FORGOTTENSERVER-ORTS/scripts/Frodo.lua
Lua
gpl-2.0
904
/* coff object file format Copyright 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2009 Free Software Foundation, Inc. This file is part of GAS. GAS 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. GAS 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 GAS; see the file COPYING. If not, write to the Free Software Foundation, 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef OBJ_FORMAT_H #define OBJ_FORMAT_H #define OBJ_COFF 1 #include "targ-cpu.h" /* This internal_lineno crap is to stop namespace pollution from the bfd internal coff headerfile. */ #define internal_lineno bfd_internal_lineno #include "coff/internal.h" #undef internal_lineno /* CPU-specific setup: */ #ifdef TC_ARM #include "coff/arm.h" #ifndef TARGET_FORMAT #define TARGET_FORMAT "coff-arm" #endif #endif #ifdef TC_PPC #ifdef TE_PE #include "coff/powerpc.h" #else #include "coff/rs6000.h" #endif #endif #ifdef TC_SPARC #include "coff/sparc.h" #endif #ifdef TC_I386 #ifdef TE_PEP #include "coff/x86_64.h" #else #include "coff/i386.h" #endif #ifndef TARGET_FORMAT #ifdef TE_PEP #define TARGET_FORMAT "coff-x86-64" #else #define TARGET_FORMAT "coff-i386" #endif #endif #endif #ifdef TC_M68K #include "coff/m68k.h" #ifndef TARGET_FORMAT #define TARGET_FORMAT "coff-m68k" #endif #endif #ifdef TC_OR32 #include "coff/or32.h" #define TARGET_FORMAT "coff-or32-big" #endif #ifdef TC_I960 #include "coff/i960.h" #define TARGET_FORMAT "coff-Intel-little" #endif #ifdef TC_Z80 #include "coff/z80.h" #define TARGET_FORMAT "coff-z80" #endif #ifdef TC_Z8K #include "coff/z8k.h" #define TARGET_FORMAT "coff-z8k" #endif #ifdef TC_H8300 #include "coff/h8300.h" #define TARGET_FORMAT "coff-h8300" #endif #ifdef TC_H8500 #include "coff/h8500.h" #define TARGET_FORMAT "coff-h8500" #endif #ifdef TC_SH #ifdef TE_PE #define COFF_WITH_PE #endif #include "coff/sh.h" #ifdef TE_PE #define TARGET_FORMAT "pe-shl" #else #define TARGET_FORMAT \ (!target_big_endian \ ? (sh_small ? "coff-shl-small" : "coff-shl") \ : (sh_small ? "coff-sh-small" : "coff-sh")) #endif #endif #ifdef TC_MIPS #define COFF_WITH_PE #include "coff/mipspe.h" #undef TARGET_FORMAT #define TARGET_FORMAT "pe-mips" #endif #ifdef TC_TIC30 #include "coff/tic30.h" #define TARGET_FORMAT "coff-tic30" #endif #ifdef TC_TIC4X #include "coff/tic4x.h" #define TARGET_FORMAT "coff2-tic4x" #endif #ifdef TC_TIC54X #include "coff/tic54x.h" #define TARGET_FORMAT "coff1-c54x" #endif #ifdef TC_TIC6X #include "coff/tic6x.h" //#define TARGET_FORMAT "coff2-c6x" #endif #ifdef TC_MCORE #include "coff/mcore.h" #ifndef TARGET_FORMAT #define TARGET_FORMAT "pe-mcore" #endif #endif #ifdef TE_PE #define obj_set_weak_hook pecoff_obj_set_weak_hook #define obj_clear_weak_hook pecoff_obj_clear_weak_hook #endif #ifndef OBJ_COFF_MAX_AUXENTRIES #define OBJ_COFF_MAX_AUXENTRIES 1 #endif #define obj_symbol_new_hook coff_obj_symbol_new_hook #define obj_symbol_clone_hook coff_obj_symbol_clone_hook #define obj_read_begin_hook coff_obj_read_begin_hook #include "bfd/libcoff.h" #define OUTPUT_FLAVOR bfd_target_coff_flavour /* Alter the field names, for now, until we've fixed up the other references to use the new name. */ #ifdef TC_I960 #define TC_SYMFIELD_TYPE symbolS * #define sy_tc bal #endif #define OBJ_SYMFIELD_TYPE unsigned long #define sy_obj sy_obj_flags /* We can't use the predefined section symbols in bfd/section.c, as COFF symbols have extra fields. See bfd/libcoff.h:coff_symbol_type. */ #ifndef obj_sec_sym_ok_for_reloc #define obj_sec_sym_ok_for_reloc(SEC) ((SEC)->owner != 0) #endif #define SYM_AUXENT(S) \ (&coffsymbol (symbol_get_bfdsym (S))->native[1].u.auxent) #define SYM_AUXINFO(S) \ (&coffsymbol (symbol_get_bfdsym (S))->native[1]) /* The number of auxiliary entries. */ #define S_GET_NUMBER_AUXILIARY(s) \ (coffsymbol (symbol_get_bfdsym (s))->native->u.syment.n_numaux) /* The number of auxiliary entries. */ #define S_SET_NUMBER_AUXILIARY(s, v) (S_GET_NUMBER_AUXILIARY (s) = (v)) /* True if a symbol name is in the string table, i.e. its length is > 8. */ #define S_IS_STRING(s) (strlen (S_GET_NAME (s)) > 8 ? 1 : 0) /* Auxiliary entry macros. SA_ stands for symbol auxiliary. */ /* Omit the tv related fields. */ /* Accessors. */ #define SA_GET_SYM_TAGNDX(s) (SYM_AUXENT (s)->x_sym.x_tagndx.l) #define SA_GET_SYM_LNNO(s) (SYM_AUXENT (s)->x_sym.x_misc.x_lnsz.x_lnno) #define SA_GET_SYM_SIZE(s) (SYM_AUXENT (s)->x_sym.x_misc.x_lnsz.x_size) #define SA_GET_SYM_FSIZE(s) (SYM_AUXENT (s)->x_sym.x_misc.x_fsize) #define SA_GET_SYM_LNNOPTR(s) (SYM_AUXENT (s)->x_sym.x_fcnary.x_fcn.x_lnnoptr) #define SA_GET_SYM_ENDNDX(s) (SYM_AUXENT (s)->x_sym.x_fcnary.x_fcn.x_endndx) #define SA_GET_SYM_DIMEN(s,i) (SYM_AUXENT (s)->x_sym.x_fcnary.x_ary.x_dimen[(i)]) #define SA_GET_FILE_FNAME(s) (SYM_AUXENT (s)->x_file.x_fname) #define SA_GET_SCN_SCNLEN(s) (SYM_AUXENT (s)->x_scn.x_scnlen) #define SA_GET_SCN_NRELOC(s) (SYM_AUXENT (s)->x_scn.x_nreloc) #define SA_GET_SCN_NLINNO(s) (SYM_AUXENT (s)->x_scn.x_nlinno) #define SA_SET_SYM_LNNO(s,v) (SYM_AUXENT (s)->x_sym.x_misc.x_lnsz.x_lnno = (v)) #define SA_SET_SYM_SIZE(s,v) (SYM_AUXENT (s)->x_sym.x_misc.x_lnsz.x_size = (v)) #define SA_SET_SYM_FSIZE(s,v) (SYM_AUXENT (s)->x_sym.x_misc.x_fsize = (v)) #define SA_SET_SYM_LNNOPTR(s,v) (SYM_AUXENT (s)->x_sym.x_fcnary.x_fcn.x_lnnoptr = (v)) #define SA_SET_SYM_DIMEN(s,i,v) (SYM_AUXENT (s)->x_sym.x_fcnary.x_ary.x_dimen[(i)] = (v)) #define SA_SET_FILE_FNAME(s,v) strncpy (SYM_AUXENT (s)->x_file.x_fname, (v), FILNMLEN) #define SA_SET_SCN_SCNLEN(s,v) (SYM_AUXENT (s)->x_scn.x_scnlen = (v)) #define SA_SET_SCN_NRELOC(s,v) (SYM_AUXENT (s)->x_scn.x_nreloc = (v)) #define SA_SET_SCN_NLINNO(s,v) (SYM_AUXENT (s)->x_scn.x_nlinno = (v)) /* Internal use only definitions. SF_ stands for symbol flags. These values can be assigned to sy_symbol.ost_flags field of a symbolS. You'll break i960 if you shift the SYSPROC bits anywhere else. for more on the balname/callname hack, see tc-i960.h. b.out is done differently. */ #define SF_I960_MASK 0x000001ff /* Bits 0-8 are used by the i960 port. */ #define SF_SYSPROC 0x0000003f /* bits 0-5 are used to store the sysproc number. */ #define SF_IS_SYSPROC 0x00000040 /* bit 6 marks symbols that are sysprocs. */ #define SF_BALNAME 0x00000080 /* bit 7 marks BALNAME symbols. */ #define SF_CALLNAME 0x00000100 /* bit 8 marks CALLNAME symbols. */ #define SF_NORMAL_MASK 0x0000ffff /* bits 12-15 are general purpose. */ #define SF_STATICS 0x00001000 /* Mark the .text & all symbols. */ #define SF_DEFINED 0x00002000 /* Symbol is defined in this file. */ #define SF_STRING 0x00004000 /* Symbol name length > 8. */ #define SF_LOCAL 0x00008000 /* Symbol must not be emitted. */ #define SF_DEBUG_MASK 0xffff0000 /* bits 16-31 are debug info. */ #define SF_FUNCTION 0x00010000 /* The symbol is a function. */ #define SF_PROCESS 0x00020000 /* Process symbol before write. */ #define SF_TAGGED 0x00040000 /* Is associated with a tag. */ #define SF_TAG 0x00080000 /* Is a tag. */ #define SF_DEBUG 0x00100000 /* Is in debug or abs section. */ #define SF_GET_SEGMENT 0x00200000 /* Get the section of the forward symbol. */ /* All other bits are unused. */ /* Accessors. */ #define SF_GET(s) (* symbol_get_obj (s)) #define SF_GET_DEBUG(s) (symbol_get_bfdsym (s)->flags & BSF_DEBUGGING) #define SF_SET_DEBUG(s) (symbol_get_bfdsym (s)->flags |= BSF_DEBUGGING) #define SF_GET_NORMAL_FIELD(s) (SF_GET (s) & SF_NORMAL_MASK) #define SF_GET_DEBUG_FIELD(s) (SF_GET (s) & SF_DEBUG_MASK) #define SF_GET_FILE(s) (SF_GET (s) & SF_FILE) #define SF_GET_STATICS(s) (SF_GET (s) & SF_STATICS) #define SF_GET_DEFINED(s) (SF_GET (s) & SF_DEFINED) #define SF_GET_STRING(s) (SF_GET (s) & SF_STRING) #define SF_GET_LOCAL(s) (SF_GET (s) & SF_LOCAL) #define SF_GET_FUNCTION(s) (SF_GET (s) & SF_FUNCTION) #define SF_GET_PROCESS(s) (SF_GET (s) & SF_PROCESS) #define SF_GET_TAGGED(s) (SF_GET (s) & SF_TAGGED) #define SF_GET_TAG(s) (SF_GET (s) & SF_TAG) #define SF_GET_GET_SEGMENT(s) (SF_GET (s) & SF_GET_SEGMENT) #define SF_GET_I960(s) (SF_GET (s) & SF_I960_MASK) /* Used by i960. */ #define SF_GET_BALNAME(s) (SF_GET (s) & SF_BALNAME) /* Used by i960. */ #define SF_GET_CALLNAME(s) (SF_GET (s) & SF_CALLNAME) /* Used by i960. */ #define SF_GET_IS_SYSPROC(s) (SF_GET (s) & SF_IS_SYSPROC) /* Used by i960. */ #define SF_GET_SYSPROC(s) (SF_GET (s) & SF_SYSPROC) /* Used by i960. */ /* Modifiers. */ #define SF_SET(s,v) (SF_GET (s) = (v)) #define SF_SET_NORMAL_FIELD(s,v)(SF_GET (s) |= ((v) & SF_NORMAL_MASK)) #define SF_SET_DEBUG_FIELD(s,v) (SF_GET (s) |= ((v) & SF_DEBUG_MASK)) #define SF_SET_FILE(s) (SF_GET (s) |= SF_FILE) #define SF_SET_STATICS(s) (SF_GET (s) |= SF_STATICS) #define SF_SET_DEFINED(s) (SF_GET (s) |= SF_DEFINED) #define SF_SET_STRING(s) (SF_GET (s) |= SF_STRING) #define SF_SET_LOCAL(s) (SF_GET (s) |= SF_LOCAL) #define SF_CLEAR_LOCAL(s) (SF_GET (s) &= ~SF_LOCAL) #define SF_SET_FUNCTION(s) (SF_GET (s) |= SF_FUNCTION) #define SF_SET_PROCESS(s) (SF_GET (s) |= SF_PROCESS) #define SF_SET_TAGGED(s) (SF_GET (s) |= SF_TAGGED) #define SF_SET_TAG(s) (SF_GET (s) |= SF_TAG) #define SF_SET_GET_SEGMENT(s) (SF_GET (s) |= SF_GET_SEGMENT) #define SF_SET_I960(s,v) (SF_GET (s) |= ((v) & SF_I960_MASK)) /* Used by i960. */ #define SF_SET_BALNAME(s) (SF_GET (s) |= SF_BALNAME) /* Used by i960. */ #define SF_SET_CALLNAME(s) (SF_GET (s) |= SF_CALLNAME) /* Used by i960. */ #define SF_SET_IS_SYSPROC(s) (SF_GET (s) |= SF_IS_SYSPROC) /* Used by i960. */ #define SF_SET_SYSPROC(s,v) (SF_GET (s) |= ((v) & SF_SYSPROC)) /* Used by i960. */ /* Line number handling. */ extern int text_lineno_number; extern int coff_line_base; extern int coff_n_line_nos; extern symbolS *coff_last_function; #define obj_emit_lineno(WHERE, LINE, FILE_START) abort () #define obj_app_file(name, app) c_dot_file_symbol (name, app) #define obj_frob_symbol(S,P) coff_frob_symbol (S, & P) #define obj_frob_section(S) coff_frob_section (S) #define obj_frob_file_after_relocs() coff_frob_file_after_relocs () #ifndef obj_adjust_symtab #define obj_adjust_symtab() coff_adjust_symtab () #endif /* Forward the segment of a forwarded symbol, handle assignments that just copy symbol values, etc. */ #ifndef OBJ_COPY_SYMBOL_ATTRIBUTES #ifndef TE_I386AIX #define OBJ_COPY_SYMBOL_ATTRIBUTES(dest, src) \ (SF_GET_GET_SEGMENT (dest) \ ? (S_SET_SEGMENT (dest, S_GET_SEGMENT (src)), 0) \ : 0) #else #define OBJ_COPY_SYMBOL_ATTRIBUTES(dest, src) \ (SF_GET_GET_SEGMENT (dest) && S_GET_SEGMENT (dest) == SEG_UNKNOWN \ ? (S_SET_SEGMENT (dest, S_GET_SEGMENT (src)), 0) \ : 0) #endif #endif /* Sanity check. */ #ifdef TC_I960 #ifndef C_LEAFSTAT hey ! Where is the C_LEAFSTAT definition ? i960 - coff support is depending on it. #endif /* no C_LEAFSTAT */ #endif /* TC_I960 */ extern const pseudo_typeS coff_pseudo_table[]; #ifndef obj_pop_insert #define obj_pop_insert() pop_insert (coff_pseudo_table) #endif /* In COFF, if a symbol is defined using .def/.val SYM/.endef, it's OK to redefine the symbol later on. This can happen if C symbols use a prefix, and a symbol is defined both with and without the prefix, as in start/_start/__start in gcc/libgcc1-test.c. */ #define RESOLVE_SYMBOL_REDEFINITION(sym) \ (SF_GET_GET_SEGMENT (sym) \ ? (sym->sy_frag = frag_now, \ S_SET_VALUE (sym, frag_now_fix ()), \ S_SET_SEGMENT (sym, now_seg), \ 0) \ : 0) /* Stabs in a coff file go into their own section. */ #define SEPARATE_STAB_SECTIONS 1 /* We need 12 bytes at the start of the section to hold some initial information. */ #define INIT_STAB_SECTION(seg) obj_coff_init_stab_section (seg) /* Store the number of relocations in the section aux entry. */ #define SET_SECTION_RELOCS(sec, relocs, n) \ SA_SET_SCN_NRELOC (section_symbol (sec), n) #define obj_app_file(name, app) c_dot_file_symbol (name, app) extern int S_SET_DATA_TYPE (symbolS *, int); extern int S_SET_STORAGE_CLASS (symbolS *, int); extern int S_GET_STORAGE_CLASS (symbolS *); extern void SA_SET_SYM_ENDNDX (symbolS *, symbolS *); extern void coff_add_linesym (symbolS *); extern void c_dot_file_symbol (const char *, int); extern void coff_frob_symbol (symbolS *, int *); extern void coff_adjust_symtab (void); extern void coff_frob_section (segT); extern void coff_adjust_section_syms (bfd *, asection *, void *); extern void coff_frob_file_after_relocs (void); extern void coff_obj_symbol_new_hook (symbolS *); extern void coff_obj_symbol_clone_hook (symbolS *, symbolS *); extern void coff_obj_read_begin_hook (void); #ifdef TE_PE extern void pecoff_obj_set_weak_hook (symbolS *); extern void pecoff_obj_clear_weak_hook (symbolS *); #endif extern void obj_coff_section (int); extern segT obj_coff_add_segment (const char *); extern void obj_coff_section (int); extern void c_dot_file_symbol (const char *, int); extern segT s_get_segment (symbolS *); #ifndef tc_coff_symbol_emit_hook extern void tc_coff_symbol_emit_hook (symbolS *); #endif extern void obj_coff_pe_handle_link_once (void); extern void obj_coff_init_stab_section (segT); extern void c_section_header (struct internal_scnhdr *, char *, long, long, long, long, long, long, long, long); extern void obj_coff_seh_do_final (void); #ifndef obj_coff_generate_pdata #define obj_coff_generate_pdata obj_coff_seh_do_final #endif #endif /* OBJ_FORMAT_H */
WojciechMigda/binutils
gas/config/obj-coff.h
C
gpl-2.0
14,188
/************************************************************** * Copyright (C) 2010 STMicroelectronics. All Rights Reserved. * This file is part of the latest release of the Multicom4 project. This release * is fully functional and provides all of the original MME functionality.This * release is now considered stable and ready for integration with other software * components. * Multicom4 is a 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. * Multicom4 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 Multicom4; * see the file COPYING. If not, write to the Free Software Foundation, 59 Temple Place - * Suite 330, Boston, MA 02111-1307, USA. * Written by Multicom team at STMicroelectronics in November 2010. * Contact [email protected]. **************************************************************/ /* * */ /* * sti7200 ST231 Video1 */ #include <bsp/_bsp.h> const char *bsp_cpu_name = "video1"; /* * Local Variables: * tab-width: 8 * c-indent-level: 2 * c-basic-offset: 2 * End: */
project-magpie/tdt-driver
multicom-4.0.6/src/bsp/stx7200/st231/video1/name.c
C
gpl-2.0
1,425
<!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_18) on Tue Nov 02 13:16:47 CET 2010 --> <TITLE> Filter </TITLE> <META NAME="date" CONTENT="2010-11-02"> <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="Filter"; } } </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="#FFFFFF" CLASS="NavBarCell1Rev"> &nbsp;<FONT CLASS="NavBarFont1Rev"><B>Class</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;<A HREF="../../../../../../com/redhat/rhn/domain/monitoring/notification/Criteria.html" title="class in com.redhat.rhn.domain.monitoring.notification"><B>PREV CLASS</B></A>&nbsp; &nbsp;<A HREF="../../../../../../com/redhat/rhn/domain/monitoring/notification/FilterType.html" title="class in com.redhat.rhn.domain.monitoring.notification"><B>NEXT CLASS</B></A></FONT></TD> <TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2"> <A HREF="../../../../../../index.html?com/redhat/rhn/domain/monitoring/notification/Filter.html" target="_top"><B>FRAMES</B></A> &nbsp; &nbsp;<A HREF="Filter.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> <TR> <TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2"> SUMMARY:&nbsp;NESTED&nbsp;|&nbsp;FIELD&nbsp;|&nbsp;<A HREF="#constructor_summary">CONSTR</A>&nbsp;|&nbsp;<A HREF="#method_summary">METHOD</A></FONT></TD> <TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2"> DETAIL:&nbsp;FIELD&nbsp;|&nbsp;<A HREF="#constructor_detail">CONSTR</A>&nbsp;|&nbsp;<A HREF="#method_detail">METHOD</A></FONT></TD> </TR> </TABLE> <A NAME="skip-navbar_top"></A> <!-- ========= END OF TOP NAVBAR ========= --> <HR> <!-- ======== START OF CLASS DATA ======== --> <H2> <FONT SIZE="-1"> com.redhat.rhn.domain.monitoring.notification</FONT> <BR> Class Filter</H2> <PRE> java.lang.Object <IMG SRC="../../../../../../resources/inherit.gif" ALT="extended by "><B>com.redhat.rhn.domain.monitoring.notification.Filter</B> </PRE> <HR> <DL> <DT><PRE>public class <B>Filter</B><DT>extends java.lang.Object</DL> </PRE> <P> Filter - Class representation of the table rhn_redirects. <P> <P> <HR> <P> <!-- ======== CONSTRUCTOR SUMMARY ======== --> <A NAME="constructor_summary"><!-- --></A> <TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY=""> <TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor"> <TH ALIGN="left" COLSPAN="2"><FONT SIZE="+2"> <B>Constructor Summary</B></FONT></TH> </TR> <TR BGCOLOR="white" CLASS="TableRowColor"> <TD><CODE><B><A HREF="../../../../../../com/redhat/rhn/domain/monitoring/notification/Filter.html#Filter()">Filter</A></B>()</CODE> <BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</TD> </TR> </TABLE> &nbsp; <!-- ========== METHOD SUMMARY =========== --> <A NAME="method_summary"><!-- --></A> <TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY=""> <TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor"> <TH ALIGN="left" COLSPAN="2"><FONT SIZE="+2"> <B>Method Summary</B></FONT></TH> </TR> <TR BGCOLOR="white" CLASS="TableRowColor"> <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> <CODE>&nbsp;<A HREF="../../../../../../com/redhat/rhn/domain/monitoring/notification/Criteria.html" title="class in com.redhat.rhn.domain.monitoring.notification">Criteria</A></CODE></FONT></TD> <TD><CODE><B><A HREF="../../../../../../com/redhat/rhn/domain/monitoring/notification/Filter.html#addCriteria(com.redhat.rhn.domain.monitoring.notification.MatchType, java.lang.String)">addCriteria</A></B>(<A HREF="../../../../../../com/redhat/rhn/domain/monitoring/notification/MatchType.html" title="class in com.redhat.rhn.domain.monitoring.notification">MatchType</A>&nbsp;matchType, java.lang.String&nbsp;value)</CODE> <BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Add a match criteria of the given type that matches against <code>value</code></TD> </TR> <TR BGCOLOR="white" CLASS="TableRowColor"> <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> <CODE>&nbsp;java.util.Set</CODE></FONT></TD> <TD><CODE><B><A HREF="../../../../../../com/redhat/rhn/domain/monitoring/notification/Filter.html#getCriteria()">getCriteria</A></B>()</CODE> <BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</TD> </TR> <TR BGCOLOR="white" CLASS="TableRowColor"> <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> <CODE>&nbsp;java.lang.String</CODE></FONT></TD> <TD><CODE><B><A HREF="../../../../../../com/redhat/rhn/domain/monitoring/notification/Filter.html#getDescription()">getDescription</A></B>()</CODE> <BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Getter for description</TD> </TR> <TR BGCOLOR="white" CLASS="TableRowColor"> <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> <CODE>&nbsp;java.util.Set</CODE></FONT></TD> <TD><CODE><B><A HREF="../../../../../../com/redhat/rhn/domain/monitoring/notification/Filter.html#getEmailAddresses()">getEmailAddresses</A></B>()</CODE> <BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</TD> </TR> <TR BGCOLOR="white" CLASS="TableRowColor"> <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> <CODE>&nbsp;java.util.Date</CODE></FONT></TD> <TD><CODE><B><A HREF="../../../../../../com/redhat/rhn/domain/monitoring/notification/Filter.html#getExpiration()">getExpiration</A></B>()</CODE> <BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Getter for expiration</TD> </TR> <TR BGCOLOR="white" CLASS="TableRowColor"> <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> <CODE>&nbsp;java.lang.Long</CODE></FONT></TD> <TD><CODE><B><A HREF="../../../../../../com/redhat/rhn/domain/monitoring/notification/Filter.html#getId()">getId</A></B>()</CODE> <BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</TD> </TR> <TR BGCOLOR="white" CLASS="TableRowColor"> <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> <CODE>&nbsp;java.util.Date</CODE></FONT></TD> <TD><CODE><B><A HREF="../../../../../../com/redhat/rhn/domain/monitoring/notification/Filter.html#getLastUpdateDate()">getLastUpdateDate</A></B>()</CODE> <BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Getter for lastUpdateDate</TD> </TR> <TR BGCOLOR="white" CLASS="TableRowColor"> <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> <CODE>&nbsp;java.lang.String</CODE></FONT></TD> <TD><CODE><B><A HREF="../../../../../../com/redhat/rhn/domain/monitoring/notification/Filter.html#getLastUpdateUser()">getLastUpdateUser</A></B>()</CODE> <BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Getter for lastUpdateUser</TD> </TR> <TR BGCOLOR="white" CLASS="TableRowColor"> <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> <CODE>&nbsp;<A HREF="../../../../../../com/redhat/rhn/domain/org/Org.html" title="class in com.redhat.rhn.domain.org">Org</A></CODE></FONT></TD> <TD><CODE><B><A HREF="../../../../../../com/redhat/rhn/domain/monitoring/notification/Filter.html#getOrg()">getOrg</A></B>()</CODE> <BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</TD> </TR> <TR BGCOLOR="white" CLASS="TableRowColor"> <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> <CODE>&nbsp;java.lang.String</CODE></FONT></TD> <TD><CODE><B><A HREF="../../../../../../com/redhat/rhn/domain/monitoring/notification/Filter.html#getReason()">getReason</A></B>()</CODE> <BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Getter for reason</TD> </TR> <TR BGCOLOR="white" CLASS="TableRowColor"> <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> <CODE>&nbsp;java.lang.Boolean</CODE></FONT></TD> <TD><CODE><B><A HREF="../../../../../../com/redhat/rhn/domain/monitoring/notification/Filter.html#getRecurring()">getRecurring</A></B>()</CODE> <BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</TD> </TR> <TR BGCOLOR="white" CLASS="TableRowColor"> <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> <CODE>&nbsp;java.lang.Long</CODE></FONT></TD> <TD><CODE><B><A HREF="../../../../../../com/redhat/rhn/domain/monitoring/notification/Filter.html#getRecurringDuration()">getRecurringDuration</A></B>()</CODE> <BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Get the number of minutes we want the recurring filter to run for.</TD> </TR> <TR BGCOLOR="white" CLASS="TableRowColor"> <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> <CODE>&nbsp;java.lang.Long</CODE></FONT></TD> <TD><CODE><B><A HREF="../../../../../../com/redhat/rhn/domain/monitoring/notification/Filter.html#getRecurringDurationType()">getRecurringDurationType</A></B>()</CODE> <BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</TD> </TR> <TR BGCOLOR="white" CLASS="TableRowColor"> <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> <CODE>&nbsp;java.lang.Long</CODE></FONT></TD> <TD><CODE><B><A HREF="../../../../../../com/redhat/rhn/domain/monitoring/notification/Filter.html#getRecurringFrequency()">getRecurringFrequency</A></B>()</CODE> <BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;How often this Filter recurrs.</TD> </TR> <TR BGCOLOR="white" CLASS="TableRowColor"> <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> <CODE>&nbsp;java.util.Date</CODE></FONT></TD> <TD><CODE><B><A HREF="../../../../../../com/redhat/rhn/domain/monitoring/notification/Filter.html#getStartDate()">getStartDate</A></B>()</CODE> <BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Getter for startDate</TD> </TR> <TR BGCOLOR="white" CLASS="TableRowColor"> <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> <CODE>&nbsp;<A HREF="../../../../../../com/redhat/rhn/domain/monitoring/notification/FilterType.html" title="class in com.redhat.rhn.domain.monitoring.notification">FilterType</A></CODE></FONT></TD> <TD><CODE><B><A HREF="../../../../../../com/redhat/rhn/domain/monitoring/notification/Filter.html#getType()">getType</A></B>()</CODE> <BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</TD> </TR> <TR BGCOLOR="white" CLASS="TableRowColor"> <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> <CODE>&nbsp;<A HREF="../../../../../../com/redhat/rhn/domain/user/User.html" title="interface in com.redhat.rhn.domain.user">User</A></CODE></FONT></TD> <TD><CODE><B><A HREF="../../../../../../com/redhat/rhn/domain/monitoring/notification/Filter.html#getUser()">getUser</A></B>()</CODE> <BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</TD> </TR> <TR BGCOLOR="white" CLASS="TableRowColor"> <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> <CODE>&nbsp;void</CODE></FONT></TD> <TD><CODE><B><A HREF="../../../../../../com/redhat/rhn/domain/monitoring/notification/Filter.html#setDescription(java.lang.String)">setDescription</A></B>(java.lang.String&nbsp;descriptionIn)</CODE> <BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Setter for description</TD> </TR> <TR BGCOLOR="white" CLASS="TableRowColor"> <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> <CODE>&nbsp;void</CODE></FONT></TD> <TD><CODE><B><A HREF="../../../../../../com/redhat/rhn/domain/monitoring/notification/Filter.html#setExpiration(java.util.Date)">setExpiration</A></B>(java.util.Date&nbsp;expirationIn)</CODE> <BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Setter for expiration</TD> </TR> <TR BGCOLOR="white" CLASS="TableRowColor"> <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> <CODE>&nbsp;void</CODE></FONT></TD> <TD><CODE><B><A HREF="../../../../../../com/redhat/rhn/domain/monitoring/notification/Filter.html#setId(java.lang.Long)">setId</A></B>(java.lang.Long&nbsp;idIn)</CODE> <BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</TD> </TR> <TR BGCOLOR="white" CLASS="TableRowColor"> <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> <CODE>&nbsp;void</CODE></FONT></TD> <TD><CODE><B><A HREF="../../../../../../com/redhat/rhn/domain/monitoring/notification/Filter.html#setLastUpdateDate(java.util.Date)">setLastUpdateDate</A></B>(java.util.Date&nbsp;lastUpdateDateIn)</CODE> <BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Setter for lastUpdateDate</TD> </TR> <TR BGCOLOR="white" CLASS="TableRowColor"> <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> <CODE>&nbsp;void</CODE></FONT></TD> <TD><CODE><B><A HREF="../../../../../../com/redhat/rhn/domain/monitoring/notification/Filter.html#setLastUpdateUser(java.lang.String)">setLastUpdateUser</A></B>(java.lang.String&nbsp;lastUpdateUserIn)</CODE> <BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Setter for lastUpdateUser</TD> </TR> <TR BGCOLOR="white" CLASS="TableRowColor"> <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> <CODE>&nbsp;void</CODE></FONT></TD> <TD><CODE><B><A HREF="../../../../../../com/redhat/rhn/domain/monitoring/notification/Filter.html#setOrg(com.redhat.rhn.domain.org.Org)">setOrg</A></B>(<A HREF="../../../../../../com/redhat/rhn/domain/org/Org.html" title="class in com.redhat.rhn.domain.org">Org</A>&nbsp;orgIn)</CODE> <BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</TD> </TR> <TR BGCOLOR="white" CLASS="TableRowColor"> <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> <CODE>&nbsp;void</CODE></FONT></TD> <TD><CODE><B><A HREF="../../../../../../com/redhat/rhn/domain/monitoring/notification/Filter.html#setReason(java.lang.String)">setReason</A></B>(java.lang.String&nbsp;reasonIn)</CODE> <BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Setter for reason</TD> </TR> <TR BGCOLOR="white" CLASS="TableRowColor"> <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> <CODE>&nbsp;void</CODE></FONT></TD> <TD><CODE><B><A HREF="../../../../../../com/redhat/rhn/domain/monitoring/notification/Filter.html#setRecurring(java.lang.Boolean)">setRecurring</A></B>(java.lang.Boolean&nbsp;recurringIn)</CODE> <BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</TD> </TR> <TR BGCOLOR="white" CLASS="TableRowColor"> <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> <CODE>&nbsp;void</CODE></FONT></TD> <TD><CODE><B><A HREF="../../../../../../com/redhat/rhn/domain/monitoring/notification/Filter.html#setRecurringDuration(java.lang.Long)">setRecurringDuration</A></B>(java.lang.Long&nbsp;recurringDurationIn)</CODE> <BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Set the number of minutes we want the recurring filter to run for.</TD> </TR> <TR BGCOLOR="white" CLASS="TableRowColor"> <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> <CODE>&nbsp;void</CODE></FONT></TD> <TD><CODE><B><A HREF="../../../../../../com/redhat/rhn/domain/monitoring/notification/Filter.html#setRecurringDurationType(java.lang.Long)">setRecurringDurationType</A></B>(java.lang.Long&nbsp;recurringDurationTypeIn)</CODE> <BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</TD> </TR> <TR BGCOLOR="white" CLASS="TableRowColor"> <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> <CODE>&nbsp;void</CODE></FONT></TD> <TD><CODE><B><A HREF="../../../../../../com/redhat/rhn/domain/monitoring/notification/Filter.html#setRecurringFrequency(java.lang.Long)">setRecurringFrequency</A></B>(java.lang.Long&nbsp;recurringFrequencyIn)</CODE> <BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;How often this Filter recurrs.</TD> </TR> <TR BGCOLOR="white" CLASS="TableRowColor"> <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> <CODE>&nbsp;void</CODE></FONT></TD> <TD><CODE><B><A HREF="../../../../../../com/redhat/rhn/domain/monitoring/notification/Filter.html#setStartDate(java.util.Date)">setStartDate</A></B>(java.util.Date&nbsp;startDateIn)</CODE> <BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Setter for startDate</TD> </TR> <TR BGCOLOR="white" CLASS="TableRowColor"> <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> <CODE>&nbsp;void</CODE></FONT></TD> <TD><CODE><B><A HREF="../../../../../../com/redhat/rhn/domain/monitoring/notification/Filter.html#setType(com.redhat.rhn.domain.monitoring.notification.FilterType)">setType</A></B>(<A HREF="../../../../../../com/redhat/rhn/domain/monitoring/notification/FilterType.html" title="class in com.redhat.rhn.domain.monitoring.notification">FilterType</A>&nbsp;typeIn)</CODE> <BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</TD> </TR> <TR BGCOLOR="white" CLASS="TableRowColor"> <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> <CODE>&nbsp;void</CODE></FONT></TD> <TD><CODE><B><A HREF="../../../../../../com/redhat/rhn/domain/monitoring/notification/Filter.html#setUser(com.redhat.rhn.domain.user.User)">setUser</A></B>(<A HREF="../../../../../../com/redhat/rhn/domain/user/User.html" title="interface in com.redhat.rhn.domain.user">User</A>&nbsp;userIn)</CODE> <BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</TD> </TR> </TABLE> &nbsp;<A NAME="methods_inherited_from_class_java.lang.Object"><!-- --></A> <TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY=""> <TR BGCOLOR="#EEEEFF" CLASS="TableSubHeadingColor"> <TH ALIGN="left"><B>Methods inherited from class java.lang.Object</B></TH> </TR> <TR BGCOLOR="white" CLASS="TableRowColor"> <TD><CODE>clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait</CODE></TD> </TR> </TABLE> &nbsp; <P> <!-- ========= CONSTRUCTOR DETAIL ======== --> <A NAME="constructor_detail"><!-- --></A> <TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY=""> <TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor"> <TH ALIGN="left" COLSPAN="1"><FONT SIZE="+2"> <B>Constructor Detail</B></FONT></TH> </TR> </TABLE> <A NAME="Filter()"><!-- --></A><H3> Filter</H3> <PRE> public <B>Filter</B>()</PRE> <DL> </DL> <!-- ============ METHOD DETAIL ========== --> <A NAME="method_detail"><!-- --></A> <TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY=""> <TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor"> <TH ALIGN="left" COLSPAN="1"><FONT SIZE="+2"> <B>Method Detail</B></FONT></TH> </TR> </TABLE> <A NAME="addCriteria(com.redhat.rhn.domain.monitoring.notification.MatchType, java.lang.String)"><!-- --></A><H3> addCriteria</H3> <PRE> public <A HREF="../../../../../../com/redhat/rhn/domain/monitoring/notification/Criteria.html" title="class in com.redhat.rhn.domain.monitoring.notification">Criteria</A> <B>addCriteria</B>(<A HREF="../../../../../../com/redhat/rhn/domain/monitoring/notification/MatchType.html" title="class in com.redhat.rhn.domain.monitoring.notification">MatchType</A>&nbsp;matchType, java.lang.String&nbsp;value)</PRE> <DL> <DD>Add a match criteria of the given type that matches against <code>value</code> <P> <DD><DL> <DT><B>Parameters:</B><DD><CODE>matchType</CODE> - the type of match for the criteria<DD><CODE>value</CODE> - the value to match against <DT><B>Returns:</B><DD>the new criteria that has been added to this filter</DL> </DD> </DL> <HR> <A NAME="getId()"><!-- --></A><H3> getId</H3> <PRE> public java.lang.Long <B>getId</B>()</PRE> <DL> <DD><DL> <DT><B>Returns:</B><DD>Returns the id.</DL> </DD> </DL> <HR> <A NAME="setId(java.lang.Long)"><!-- --></A><H3> setId</H3> <PRE> public void <B>setId</B>(java.lang.Long&nbsp;idIn)</PRE> <DL> <DD><DL> <DT><B>Parameters:</B><DD><CODE>idIn</CODE> - The id to set.</DL> </DD> </DL> <HR> <A NAME="getDescription()"><!-- --></A><H3> getDescription</H3> <PRE> public java.lang.String <B>getDescription</B>()</PRE> <DL> <DD>Getter for description <P> <DD><DL> <DT><B>Returns:</B><DD>String to get</DL> </DD> </DL> <HR> <A NAME="setDescription(java.lang.String)"><!-- --></A><H3> setDescription</H3> <PRE> public void <B>setDescription</B>(java.lang.String&nbsp;descriptionIn)</PRE> <DL> <DD>Setter for description <P> <DD><DL> <DT><B>Parameters:</B><DD><CODE>descriptionIn</CODE> - to set</DL> </DD> </DL> <HR> <A NAME="getReason()"><!-- --></A><H3> getReason</H3> <PRE> public java.lang.String <B>getReason</B>()</PRE> <DL> <DD>Getter for reason <P> <DD><DL> <DT><B>Returns:</B><DD>String to get</DL> </DD> </DL> <HR> <A NAME="setReason(java.lang.String)"><!-- --></A><H3> setReason</H3> <PRE> public void <B>setReason</B>(java.lang.String&nbsp;reasonIn)</PRE> <DL> <DD>Setter for reason <P> <DD><DL> <DT><B>Parameters:</B><DD><CODE>reasonIn</CODE> - to set</DL> </DD> </DL> <HR> <A NAME="getExpiration()"><!-- --></A><H3> getExpiration</H3> <PRE> public java.util.Date <B>getExpiration</B>()</PRE> <DL> <DD>Getter for expiration <P> <DD><DL> <DT><B>Returns:</B><DD>Date to get</DL> </DD> </DL> <HR> <A NAME="setExpiration(java.util.Date)"><!-- --></A><H3> setExpiration</H3> <PRE> public void <B>setExpiration</B>(java.util.Date&nbsp;expirationIn)</PRE> <DL> <DD>Setter for expiration <P> <DD><DL> <DT><B>Parameters:</B><DD><CODE>expirationIn</CODE> - to set</DL> </DD> </DL> <HR> <A NAME="getLastUpdateUser()"><!-- --></A><H3> getLastUpdateUser</H3> <PRE> public java.lang.String <B>getLastUpdateUser</B>()</PRE> <DL> <DD>Getter for lastUpdateUser <P> <DD><DL> <DT><B>Returns:</B><DD>String to get</DL> </DD> </DL> <HR> <A NAME="setLastUpdateUser(java.lang.String)"><!-- --></A><H3> setLastUpdateUser</H3> <PRE> public void <B>setLastUpdateUser</B>(java.lang.String&nbsp;lastUpdateUserIn)</PRE> <DL> <DD>Setter for lastUpdateUser <P> <DD><DL> <DT><B>Parameters:</B><DD><CODE>lastUpdateUserIn</CODE> - to set</DL> </DD> </DL> <HR> <A NAME="getLastUpdateDate()"><!-- --></A><H3> getLastUpdateDate</H3> <PRE> public java.util.Date <B>getLastUpdateDate</B>()</PRE> <DL> <DD>Getter for lastUpdateDate <P> <DD><DL> <DT><B>Returns:</B><DD>Date to get</DL> </DD> </DL> <HR> <A NAME="setLastUpdateDate(java.util.Date)"><!-- --></A><H3> setLastUpdateDate</H3> <PRE> public void <B>setLastUpdateDate</B>(java.util.Date&nbsp;lastUpdateDateIn)</PRE> <DL> <DD>Setter for lastUpdateDate <P> <DD><DL> <DT><B>Parameters:</B><DD><CODE>lastUpdateDateIn</CODE> - to set</DL> </DD> </DL> <HR> <A NAME="getStartDate()"><!-- --></A><H3> getStartDate</H3> <PRE> public java.util.Date <B>getStartDate</B>()</PRE> <DL> <DD>Getter for startDate <P> <DD><DL> <DT><B>Returns:</B><DD>Date to get</DL> </DD> </DL> <HR> <A NAME="setStartDate(java.util.Date)"><!-- --></A><H3> setStartDate</H3> <PRE> public void <B>setStartDate</B>(java.util.Date&nbsp;startDateIn)</PRE> <DL> <DD>Setter for startDate <P> <DD><DL> <DT><B>Parameters:</B><DD><CODE>startDateIn</CODE> - to set</DL> </DD> </DL> <HR> <A NAME="getRecurring()"><!-- --></A><H3> getRecurring</H3> <PRE> public java.lang.Boolean <B>getRecurring</B>()</PRE> <DL> <DD><DL> <DT><B>Returns:</B><DD>Returns the recurring.</DL> </DD> </DL> <HR> <A NAME="setRecurring(java.lang.Boolean)"><!-- --></A><H3> setRecurring</H3> <PRE> public void <B>setRecurring</B>(java.lang.Boolean&nbsp;recurringIn)</PRE> <DL> <DD><DL> <DT><B>Parameters:</B><DD><CODE>recurringIn</CODE> - The recurring to set.</DL> </DD> </DL> <HR> <A NAME="getRecurringDuration()"><!-- --></A><H3> getRecurringDuration</H3> <PRE> public java.lang.Long <B>getRecurringDuration</B>()</PRE> <DL> <DD>Get the number of minutes we want the recurring filter to run for. So, if we say the filter is for 30 minutes then each time it runs, it will run for 30 minutes. <P> <DD><DL> <DT><B>Returns:</B><DD>Returns the recurringDuration.</DL> </DD> </DL> <HR> <A NAME="setRecurringDuration(java.lang.Long)"><!-- --></A><H3> setRecurringDuration</H3> <PRE> public void <B>setRecurringDuration</B>(java.lang.Long&nbsp;recurringDurationIn)</PRE> <DL> <DD>Set the number of minutes we want the recurring filter to run for. So, if we say the filter is for 30 minutes then each time it runs, it will run for 30 minutes. <P> <DD><DL> <DT><B>Parameters:</B><DD><CODE>recurringDurationIn</CODE> - The recurringDuration to set.</DL> </DD> </DL> <HR> <A NAME="getRecurringDurationType()"><!-- --></A><H3> getRecurringDurationType</H3> <PRE> public java.lang.Long <B>getRecurringDurationType</B>()</PRE> <DL> <DD><DL> <DT><B>Returns:</B><DD>Returns the recurringDurationType.</DL> </DD> </DL> <HR> <A NAME="setRecurringDurationType(java.lang.Long)"><!-- --></A><H3> setRecurringDurationType</H3> <PRE> public void <B>setRecurringDurationType</B>(java.lang.Long&nbsp;recurringDurationTypeIn)</PRE> <DL> <DD><DL> <DT><B>Parameters:</B><DD><CODE>recurringDurationTypeIn</CODE> - The recurringDurationType to set.</DL> </DD> </DL> <HR> <A NAME="getRecurringFrequency()"><!-- --></A><H3> getRecurringFrequency</H3> <PRE> public java.lang.Long <B>getRecurringFrequency</B>()</PRE> <DL> <DD>How often this Filter recurrs. These values correspond to the constants defined in java.util.Calendar: public final static int DAY_OF_YEAR = 6; public final static int WEEK_OF_YEAR = 3; public final static int MONTH = 2; <P> <DD><DL> <DT><B>Returns:</B><DD>Returns the recurringFrequency.</DL> </DD> </DL> <HR> <A NAME="setRecurringFrequency(java.lang.Long)"><!-- --></A><H3> setRecurringFrequency</H3> <PRE> public void <B>setRecurringFrequency</B>(java.lang.Long&nbsp;recurringFrequencyIn)</PRE> <DL> <DD>How often this Filter recurrs. These values correspond to the constants defined in java.util.Calendar: public final static int DAY_OF_YEAR = 6; public final static int WEEK_OF_YEAR = 3; public final static int MONTH = 2; <P> <DD><DL> <DT><B>Parameters:</B><DD><CODE>recurringFrequencyIn</CODE> - The recurringFrequency to set.</DL> </DD> </DL> <HR> <A NAME="getOrg()"><!-- --></A><H3> getOrg</H3> <PRE> public <A HREF="../../../../../../com/redhat/rhn/domain/org/Org.html" title="class in com.redhat.rhn.domain.org">Org</A> <B>getOrg</B>()</PRE> <DL> <DD><DL> <DT><B>Returns:</B><DD>Returns the org.</DL> </DD> </DL> <HR> <A NAME="setOrg(com.redhat.rhn.domain.org.Org)"><!-- --></A><H3> setOrg</H3> <PRE> public void <B>setOrg</B>(<A HREF="../../../../../../com/redhat/rhn/domain/org/Org.html" title="class in com.redhat.rhn.domain.org">Org</A>&nbsp;orgIn)</PRE> <DL> <DD><DL> <DT><B>Parameters:</B><DD><CODE>orgIn</CODE> - The org to set.</DL> </DD> </DL> <HR> <A NAME="getUser()"><!-- --></A><H3> getUser</H3> <PRE> public <A HREF="../../../../../../com/redhat/rhn/domain/user/User.html" title="interface in com.redhat.rhn.domain.user">User</A> <B>getUser</B>()</PRE> <DL> <DD><DL> <DT><B>Returns:</B><DD>Returns the user.</DL> </DD> </DL> <HR> <A NAME="setUser(com.redhat.rhn.domain.user.User)"><!-- --></A><H3> setUser</H3> <PRE> public void <B>setUser</B>(<A HREF="../../../../../../com/redhat/rhn/domain/user/User.html" title="interface in com.redhat.rhn.domain.user">User</A>&nbsp;userIn)</PRE> <DL> <DD><DL> <DT><B>Parameters:</B><DD><CODE>userIn</CODE> - The user to set.</DL> </DD> </DL> <HR> <A NAME="getType()"><!-- --></A><H3> getType</H3> <PRE> public <A HREF="../../../../../../com/redhat/rhn/domain/monitoring/notification/FilterType.html" title="class in com.redhat.rhn.domain.monitoring.notification">FilterType</A> <B>getType</B>()</PRE> <DL> <DD><DL> <DT><B>Returns:</B><DD>Returns the type.</DL> </DD> </DL> <HR> <A NAME="setType(com.redhat.rhn.domain.monitoring.notification.FilterType)"><!-- --></A><H3> setType</H3> <PRE> public void <B>setType</B>(<A HREF="../../../../../../com/redhat/rhn/domain/monitoring/notification/FilterType.html" title="class in com.redhat.rhn.domain.monitoring.notification">FilterType</A>&nbsp;typeIn)</PRE> <DL> <DD><DL> <DT><B>Parameters:</B><DD><CODE>typeIn</CODE> - The type to set.</DL> </DD> </DL> <HR> <A NAME="getCriteria()"><!-- --></A><H3> getCriteria</H3> <PRE> public java.util.Set <B>getCriteria</B>()</PRE> <DL> <DD><DL> <DT><B>Returns:</B><DD>Returns the criteria.</DL> </DD> </DL> <HR> <A NAME="getEmailAddresses()"><!-- --></A><H3> getEmailAddresses</H3> <PRE> public java.util.Set <B>getEmailAddresses</B>()</PRE> <DL> <DD><DL> <DT><B>Returns:</B><DD>Returns the emailAddresses.</DL> </DD> </DL> <!-- ========= END OF CLASS DATA ========= --> <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="#FFFFFF" CLASS="NavBarCell1Rev"> &nbsp;<FONT CLASS="NavBarFont1Rev"><B>Class</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;<A HREF="../../../../../../com/redhat/rhn/domain/monitoring/notification/Criteria.html" title="class in com.redhat.rhn.domain.monitoring.notification"><B>PREV CLASS</B></A>&nbsp; &nbsp;<A HREF="../../../../../../com/redhat/rhn/domain/monitoring/notification/FilterType.html" title="class in com.redhat.rhn.domain.monitoring.notification"><B>NEXT CLASS</B></A></FONT></TD> <TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2"> <A HREF="../../../../../../index.html?com/redhat/rhn/domain/monitoring/notification/Filter.html" target="_top"><B>FRAMES</B></A> &nbsp; &nbsp;<A HREF="Filter.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> <TR> <TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2"> SUMMARY:&nbsp;NESTED&nbsp;|&nbsp;FIELD&nbsp;|&nbsp;<A HREF="#constructor_summary">CONSTR</A>&nbsp;|&nbsp;<A HREF="#method_summary">METHOD</A></FONT></TD> <TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2"> DETAIL:&nbsp;FIELD&nbsp;|&nbsp;<A HREF="#constructor_detail">CONSTR</A>&nbsp;|&nbsp;<A HREF="#method_detail">METHOD</A></FONT></TD> </TR> </TABLE> <A NAME="skip-navbar_bottom"></A> <!-- ======== END OF BOTTOM NAVBAR ======= --> <HR> </BODY> </HTML>
colloquium/spacewalk
documentation/javadoc/com/redhat/rhn/domain/monitoring/notification/Filter.html
HTML
gpl-2.0
33,065
<?php /** * @version $Id: #component#.php 125 2012-10-09 11:09:48Z michel $ 1 2014-05-11Z FT $ * @package Kepviselojeloltek * @copyright Copyright (C) 2014, Fogler Tibor. All rights reserved. * @license #GNU/GPL */ //--No direct access defined('_JEXEC') or die('=;)'); // DS has removed from J 3.0 if(!defined('DS')) { define('DS','/'); } // Require the base controller require_once( JPATH_COMPONENT.'/controller.php' ); jimport('joomla.application.component.model'); require_once( JPATH_COMPONENT.'/models/model.php' ); jimport('joomla.application.component.helper'); JHTML::addIncludePath(JPATH_COMPONENT_ADMINISTRATOR.'/helpers' ); //set the default view $task = JRequest::getWord('task'); $config =& JComponentHelper::getParams( 'com_kepviselojeloltek' ); $controller = JRequest::getWord('view', 'kepviselojeloltek'); $ControllerConfig = array(); // Require specific controller if requested if ($controller) { $path = JPATH_COMPONENT.'/controllers/'.$controller.'.php'; $ControllerConfig = array('viewname'=>strtolower($controller),'mainmodel'=>strtolower($controller),'itemname'=>ucfirst(strtolower($controller))); if (file_exists($path)) { require_once $path; } else { $controller = ''; } } // Create the controller $classname = 'KepviselojeloltekController'.$controller; $controller = new $classname($ControllerConfig ); // Perform the Request task $controller->execute( JRequest::getVar( 'task' ) ); // Redirect if set by the controller $controller->redirect();
utopszkij/li-de
componens_telepitok/com_kepviselojeltek/site/kepviselojeloltek.php
PHP
gpl-2.0
1,527
package org.emulinker.kaillera.controller.v086.action; import java.util.*; import org.apache.commons.logging.*; import org.emulinker.kaillera.access.AccessManager; import org.emulinker.kaillera.controller.messaging.MessageFormatException; import org.emulinker.kaillera.controller.v086.V086Controller; import org.emulinker.kaillera.controller.v086.protocol.*; import org.emulinker.kaillera.model.exception.ActionException; import org.emulinker.kaillera.model.impl.*; import org.emulinker.kaillera.model.*; import org.emulinker.util.EmuLang; import org.emulinker.util.WildcardStringPattern; public class GameOwnerCommandAction implements V086Action { public static final String COMMAND_HELP = "/help"; //$NON-NLS-1$ public static final String COMMAND_DETECTAUTOFIRE = "/detectautofire"; //$NON-NLS-1$ private static Log log = LogFactory.getLog(GameOwnerCommandAction.class); private static final String desc = "GameOwnerCommandAction"; //$NON-NLS-1$ private static GameOwnerCommandAction singleton = new GameOwnerCommandAction(); public static GameOwnerCommandAction getInstance() { return singleton; } private int actionCount = 0; private GameOwnerCommandAction() { } public int getActionPerformedCount() { return actionCount; } public String toString() { return desc; } public void performAction(V086Message message, V086Controller.V086ClientHandler clientHandler) throws FatalActionException { GameChat chatMessage = (GameChat) message; String chat = chatMessage.getMessage(); KailleraUserImpl user = (KailleraUserImpl) clientHandler.getUser(); KailleraGameImpl game = user.getGame(); if(game == null) { throw new FatalActionException("GameOwner Command Failed: Not in a game: " + chat); //$NON-NLS-1$ } if(!user.equals(game.getOwner())) { log.warn("GameOwner Command Denied: Not game owner: " + game + ": " + user + ": " + chat); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ return; } try { if (chat.startsWith(COMMAND_HELP)) { processHelp(chat, game, user, clientHandler); } else if (chat.startsWith(COMMAND_DETECTAUTOFIRE)) { processDetectAutoFire(chat, game, user, clientHandler); } else { log.info("Unknown GameOwner Command: " + game + ": " + user + ": " + chat); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ } } catch (ActionException e) { log.info("GameOwner Command Failed: " + game + ": " + user + ": " + chat); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ game.announce(EmuLang.getString("GameOwnerCommandAction.CommandFailed", e.getMessage())); //$NON-NLS-1$ } catch (MessageFormatException e) { log.error("Failed to contruct message: " + e.getMessage(), e); //$NON-NLS-1$ } } private void processHelp(String message, KailleraGameImpl game, KailleraUserImpl admin, V086Controller.V086ClientHandler clientHandler) throws ActionException, MessageFormatException { game.announce(EmuLang.getString("GameOwnerCommandAction.AvailableCommands")); //$NON-NLS-1$ game.announce(EmuLang.getString("GameOwnerCommandAction.SetAutofireDetection")); //$NON-NLS-1$ } private void autoFireHelp(KailleraGameImpl game) { int cur = game.getAutoFireDetector().getSensitivity(); game.announce(EmuLang.getString("GameOwnerCommandAction.HelpSensitivity")); //$NON-NLS-1$ game.announce(EmuLang.getString("GameOwnerCommandAction.HelpDisable")); //$NON-NLS-1$ game.announce(EmuLang.getString("GameOwnerCommandAction.HelpCurrentSensitivity", cur) + (cur == 0 ? (EmuLang.getString("GameOwnerCommandAction.HelpDisabled")) : "")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ } private void processDetectAutoFire(String message, KailleraGameImpl game, KailleraUserImpl admin, V086Controller.V086ClientHandler clientHandler) throws ActionException, MessageFormatException { if(game.getStatus() != KailleraGame.STATUS_WAITING) { game.announce(EmuLang.getString("GameOwnerCommandAction.AutoFireChangeDeniedInGame")); //$NON-NLS-1$ return; } StringTokenizer st = new StringTokenizer(message, " "); //$NON-NLS-1$ if(st.countTokens() != 2) { autoFireHelp(game); return; } String command = st.nextToken(); String sensitivityStr = st.nextToken(); int sensitivity = -1; try { sensitivity = Integer.parseInt(sensitivityStr); } catch(NumberFormatException e) {} if(sensitivity > 5 || sensitivity < 0) { autoFireHelp(game); return; } game.getAutoFireDetector().setSensitivity(sensitivity); game.announce(EmuLang.getString("GameOwnerCommandAction.HelpCurrentSensitivity", sensitivity) + (sensitivity == 0 ? (EmuLang.getString("GameOwnerCommandAction.HelpDisabled")) : "")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ } }
monospacesoftware/emulinker
src/org/emulinker/kaillera/controller/v086/action/GameOwnerCommandAction.java
Java
gpl-2.0
4,749
<?php /** * Manages the social plugins. * * @copyright 2009-2019 Vanilla Forums Inc. * @license GPL-2.0-only * @package Dashboard * @since 2.1 */ /** * Handles /social endpoint, so it must be an extrovert. */ class SocialController extends DashboardController { /** @var array Models to automatically instantiate. */ public $Uses = ['Form', 'Database']; /** * Runs before every call to this controller. */ public function initialize() { parent::initialize(); Gdn_Theme::section('Settings'); } /** * Default method. */ public function index() { redirectTo('social/manage'); } /** * Settings page. */ public function manage() { $this->permission('Garden.Settings.Manage'); $this->title("Social Connect Addons"); $this->setHighlightRoute('/social/manage'); $connections = $this->getConnections(); $this->setData('Connections', $connections); $this->render(); } /** * Find available social plugins. * * @return array|mixed * @throws Exception */ protected function getConnections() { $this->fireEvent('GetConnections'); $connections = []; $addons = Gdn::addonManager()->lookupAllByType(\Vanilla\Addon::TYPE_ADDON); foreach ($addons as $addonName => $addon) { /* @var \Vanilla\Addon $addon */ $addonInfo = $addon->getInfo(); // Limit to designated social addons. if (!array_key_exists('socialConnect', $addonInfo)) { continue; } // See if addon is enabled. $isEnabled = Gdn::addonManager()->isEnabled($addonName, \Vanilla\Addon::TYPE_ADDON); setValue('enabled', $addonInfo, $isEnabled); if (!$isEnabled && !empty($addonInfo['hidden'])) { // Don't show hidden addons unless they are enabled. continue; } // See if we can detect whether connection is configured. $isConfigured = null; if ($isEnabled) { $pluginInstance = Gdn::pluginManager()->getPluginInstance($addonName, Gdn_PluginManager::ACCESS_PLUGINNAME); if (method_exists($pluginInstance, 'isConfigured')) { $isConfigured = $pluginInstance->isConfigured(); } } setValue('configured', $addonInfo, $isConfigured); // Add the connection. $connections[$addonName] = $addonInfo; } return $connections; } }
vanilla/vanilla
applications/dashboard/controllers/class.socialcontroller.php
PHP
gpl-2.0
2,628
<?php // if( isset( $_POST ) ) { // echo '<code><pre>'; // var_dump( $_POST ); // echo '</pre></code>'; // } class SpeoOptions { /** * Holds the values to be used in the fields callbacks */ private $options; /** * Start up */ public function __construct() { add_action( 'admin_menu', array( $this, 'add_plugin_page' ) ); add_action( 'admin_init', array( $this, 'page_init' ) ); } /** * Add options page */ public function add_plugin_page() { // This page will be under "Settings" add_options_page( 'Settings Admin', 'Exiftool Options', 'manage_options', 'speo_exif_options', array( $this, 'create_admin_page' ) ); } /** * Options page callback */ public function create_admin_page() { // Set class property $this->options = get_option( 'speo_options' ); ?> <div class="wrap"> <?php screen_icon(); ?> <h2>Exiftools Settings</h2> <form method="post" action="options.php"> <?php // This prints out all hidden setting fields settings_fields( 'speo_options_group' ); do_settings_sections( 'speo_exif_options' ); echo '</ol>'; submit_button(); ?> </form> </div> <?php } /** * Register and add settings */ public function page_init() { register_setting( 'speo_options_group', // Option group 'speo_options', // Option name array( $this, 'sanitize' ) // Sanitize ); add_settings_section( 'speo_options_all', // ID 'Options', // Title array( $this, 'print_section_info' ), // Callback 'speo_exif_options' // Page ); //get the blog language $this_lang = get_locale(); //get the values from the list.xml $xmldoc = new DOMDocument(); $xmldoc->load( plugin_dir_path( __FILE__ ) . 'list.xml' ); $xpathvar = new Domxpath($xmldoc); $queryResult = $xpathvar->query('//tag/@name'); $possible_values = array(); foreach( $queryResult as $result ){ if( substr( $result->textContent, 0, 9 ) === 'MakerNote' ) continue; $possible_values[ $result->textContent ] = 0; ksort( $possible_values ); } foreach( $possible_values as $value => $bool ) { // $xpath = new Domxpath($xmldoc); // $descs = $xpath->query('//tag[@name="' . $value . '"]/desc[@lang="en"]'); // $titles = $xpath->query('//tag[@name="' . $value . '"]/desc[@lang="' . substr( $this_lang, 0, 2 ) . '"]'); // foreach( $descs as $desc ) { // $i=1; // $opt_title = '<li>' . $value; // foreach( $titles as $title ) { // if( $i > 1 ) // continue; // $opt_title .= '<br />(' . $title->textContent . ')'; // $i++; // } // $opt_title .= '</li>'; //add the actual setting add_settings_field( 'speo_exif_' . $value, // ID $value, // Title array( $this, 'speo_callback' ), // Callback 'speo_exif_options', // Page 'speo_options_all', // Section $value //args ); // } } } /** * Sanitize each setting field as needed * * @param array $input Contains all settings fields as array keys */ public function sanitize( $inputs ) { return $inputs; } /** * Print the Section text */ public function print_section_info() { print 'Check the values you want to retreive from images:<ol>'; } /** * Get the settings option array and print one of its values */ public function speo_callback( $value ) { // echo '<code><pre>'; // var_dump($this->options); // echo '</pre></code>'; printf( '<input type="checkbox" id="speo_exif_' . $value . '" name="speo_options[' . $value . ']" %s />', checked( isset( $this->options[$value] ), true, false ) // ( isset( $this->options[$value] ) ? $this->options[$value] : 'none' ) ); } } if( is_admin() ) $my_settings_page = new SpeoOptions();
alpipego/speo-exiftool
speo-options.php
PHP
gpl-2.0
4,439
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Management; using ProductMan.Utilities; using ProductMan.Win32; using System.Reflection; namespace ProductMan { public class WMIVendor : IDisposable { protected static WMIVendor instance; protected ManagementScope scope; protected ConnectionOptions conn; protected ComputerSystem computer; protected NetworkAdapterConfiguration networkAdapterConfig; protected ProductMan.Win32.OperatingSystem os; protected static volatile object syncRoot = new object(); private WMIVendor() { conn = new ConnectionOptions(); scope = new ManagementScope("\\\\localhost", conn); scope.Options.Impersonation = ImpersonationLevel.Impersonate; } public ComputerSystem GetComputerSystem() { if (computer != null) return computer; computer = new ComputerSystem(); try { ManagementObjectCollection res = Query("select * from win32_ComputerSystem"); FieldInfo[] fields = typeof(ComputerSystem).GetFields(); foreach (ManagementObject item in res) { foreach (FieldInfo info in fields) { try { info.SetValue(computer, item[info.Name]); } catch { } } break; } } catch (Exception ex) { LoggerBase.Instance.Error(ex.ToString()); } return computer; } public NetworkAdapterConfiguration GetNetworkConfig() { if (networkAdapterConfig != null) return networkAdapterConfig; networkAdapterConfig = new NetworkAdapterConfiguration(); try { ManagementObjectCollection res = Query("select * from win32_NetworkAdapterConfiguration WHERE IPEnabled = 'TRUE'"); FieldInfo[] fields = typeof(NetworkAdapterConfiguration).GetFields(); foreach (ManagementObject item in res) { foreach (FieldInfo info in fields) { try { info.SetValue(networkAdapterConfig, item[info.Name]); } catch { } } break; } } catch (Exception ex) { LoggerBase.Instance.Error(ex.ToString()); } return networkAdapterConfig; } public ProductMan.Win32.OperatingSystem GetOS() { if (os != null) return os; os = new ProductMan.Win32.OperatingSystem(); try { ManagementObjectCollection res = Query("select * from win32_OperatingSystem"); FieldInfo[] fields = typeof(ProductMan.Win32.OperatingSystem).GetFields(); foreach (ManagementObject item in res) { foreach (FieldInfo info in fields) { try { info.SetValue(os, item[info.Name]); } catch { } } break; } } catch (Exception ex) { LoggerBase.Instance.Error(ex.ToString()); } return os; } private ManagementObjectCollection Query(string queryString) { try { ObjectQuery query = new ObjectQuery(queryString); ManagementObjectSearcher searcher = new ManagementObjectSearcher(scope, query); return searcher.Get(); } catch (Exception ex) { LoggerBase.Instance.Error(ex.ToString()); } return null; } public static WMIVendor Instance { get { if (instance == null) { lock (syncRoot) { if (instance == null) instance = new WMIVendor(); } } return instance; } } #region IDisposable Members public void Dispose() { //TODO } #endregion } }
CecleCW/ProductMan
ProductMan/ProductMan/WMIVendor.cs
C#
gpl-2.0
4,918
/* * linux/drivers/mmc/core/core.c * * Copyright (C) 2003-2004 Russell King, All Rights Reserved. * SD support Copyright (C) 2004 Ian Molton, All Rights Reserved. * Copyright (C) 2005-2008 Pierre Ossman, All Rights Reserved. * MMCv4 support Copyright (C) 2006 Philip Langdale, All Rights Reserved. * * This program 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. */ #include <linux/module.h> #include <linux/init.h> #include <linux/interrupt.h> #include <linux/completion.h> #include <linux/device.h> #include <linux/delay.h> #include <linux/pagemap.h> #include <linux/err.h> #include <linux/leds.h> #include <linux/scatterlist.h> #include <linux/log2.h> #include <linux/regulator/consumer.h> #include <linux/pm_runtime.h> #include <linux/suspend.h> #include <linux/fault-inject.h> #include <linux/random.h> #include <linux/wakelock.h> #include <linux/pm.h> #include <linux/slab.h> #include <linux/jiffies.h> #include <linux/mmc/card.h> #include <linux/mmc/host.h> #include <linux/mmc/mmc.h> #include <linux/mmc/sd.h> #include "core.h" #include "bus.h" #include "host.h" #include "sdio_bus.h" #include "mmc_ops.h" #include "sd_ops.h" #include "sdio_ops.h" #define CREATE_TRACE_POINTS #include <trace/events/mmc.h> /* If the device is not responding */ #define MMC_CORE_TIMEOUT_MS (10 * 60 * 1000) /* 10 minute timeout */ static void mmc_clk_scaling(struct mmc_host *host, bool from_wq); /* * Background operations can take a long time, depending on the housekeeping * operations the card has to perform. */ #define MMC_BKOPS_MAX_TIMEOUT (30 * 1000) /* max time to wait in ms */ /* Flushing a large amount of cached data may take a long time. */ #define MMC_FLUSH_REQ_TIMEOUT_MS 30000 /* msec */ static struct workqueue_struct *workqueue; /* * Enabling software CRCs on the data blocks can be a significant (30%) * performance cost, and for other reasons may not always be desired. * So we allow it it to be disabled. */ bool use_spi_crc = 0; module_param(use_spi_crc, bool, 0755); /* * We normally treat cards as removed during suspend if they are not * known to be on a non-removable bus, to avoid the risk of writing * back data to a different card after resume. Allow this to be * overridden if necessary. */ #ifdef CONFIG_MMC_UNSAFE_RESUME bool mmc_assume_removable; #else bool mmc_assume_removable = 1; #endif EXPORT_SYMBOL(mmc_assume_removable); module_param_named(removable, mmc_assume_removable, bool, 0644); MODULE_PARM_DESC( removable, "MMC/SD cards are removable and may be removed during suspend"); /* * Internal function. Schedule delayed work in the MMC work queue. */ static int mmc_schedule_delayed_work(struct delayed_work *work, unsigned long delay) { return queue_delayed_work(workqueue, work, delay); } /* * Internal function. Flush all scheduled work from the MMC work queue. */ static void mmc_flush_scheduled_work(void) { flush_workqueue(workqueue); } #ifdef CONFIG_FAIL_MMC_REQUEST /* * Internal function. Inject random data errors. * If mmc_data is NULL no errors are injected. */ static void mmc_should_fail_request(struct mmc_host *host, struct mmc_request *mrq) { struct mmc_command *cmd = mrq->cmd; struct mmc_data *data = mrq->data; static const int data_errors[] = { -ETIMEDOUT, -EILSEQ, -EIO, }; if (!data) return; if (cmd->error || data->error || !should_fail(&host->fail_mmc_request, data->blksz * data->blocks)) return; data->error = data_errors[random32() % ARRAY_SIZE(data_errors)]; data->bytes_xfered = (random32() % (data->bytes_xfered >> 9)) << 9; data->fault_injected = true; } #else /* CONFIG_FAIL_MMC_REQUEST */ static inline void mmc_should_fail_request(struct mmc_host *host, struct mmc_request *mrq) { } #endif /* CONFIG_FAIL_MMC_REQUEST */ /** * mmc_request_done - finish processing an MMC request * @host: MMC host which completed request * @mrq: MMC request which request * * MMC drivers should call this function when they have completed * their processing of a request. */ void mmc_request_done(struct mmc_host *host, struct mmc_request *mrq) { struct mmc_command *cmd = mrq->cmd; int err = cmd->error; #ifdef CONFIG_MMC_PERF_PROFILING ktime_t diff; #endif if (host->card && host->clk_scaling.enable) host->clk_scaling.busy_time_us += ktime_to_us(ktime_sub(ktime_get(), host->clk_scaling.start_busy)); if (err && cmd->retries && mmc_host_is_spi(host)) { if (cmd->resp[0] & R1_SPI_ILLEGAL_COMMAND) cmd->retries = 0; } if (err && cmd->retries && !mmc_card_removed(host->card)) { /* * Request starter must handle retries - see * mmc_wait_for_req_done(). */ if (mrq->done) mrq->done(mrq); } else { mmc_should_fail_request(host, mrq); led_trigger_event(host->led, LED_OFF); pr_debug("%s: req done (CMD%u): %d: %08x %08x %08x %08x\n", mmc_hostname(host), cmd->opcode, err, cmd->resp[0], cmd->resp[1], cmd->resp[2], cmd->resp[3]); if (mrq->data) { #ifdef CONFIG_MMC_PERF_PROFILING if (host->perf_enable) { diff = ktime_sub(ktime_get(), host->perf.start); if (mrq->data->flags == MMC_DATA_READ) { host->perf.rbytes_drv += mrq->data->bytes_xfered; host->perf.rtime_drv = ktime_add(host->perf.rtime_drv, diff); } else { host->perf.wbytes_drv += mrq->data->bytes_xfered; host->perf.wtime_drv = ktime_add(host->perf.wtime_drv, diff); } } #endif pr_debug("%s: %d bytes transferred: %d\n", mmc_hostname(host), mrq->data->bytes_xfered, mrq->data->error); } if (mrq->stop) { pr_debug("%s: (CMD%u): %d: %08x %08x %08x %08x\n", mmc_hostname(host), mrq->stop->opcode, mrq->stop->error, mrq->stop->resp[0], mrq->stop->resp[1], mrq->stop->resp[2], mrq->stop->resp[3]); } if (mrq->done) mrq->done(mrq); mmc_host_clk_release(host); } } EXPORT_SYMBOL(mmc_request_done); static void mmc_start_request(struct mmc_host *host, struct mmc_request *mrq) { #ifdef CONFIG_MMC_DEBUG unsigned int i, sz; struct scatterlist *sg; #endif if (mrq->sbc) { pr_debug("<%s: starting CMD%u arg %08x flags %08x>\n", mmc_hostname(host), mrq->sbc->opcode, mrq->sbc->arg, mrq->sbc->flags); } pr_debug("%s: starting CMD%u arg %08x flags %08x\n", mmc_hostname(host), mrq->cmd->opcode, mrq->cmd->arg, mrq->cmd->flags); if (mrq->data) { pr_debug("%s: blksz %d blocks %d flags %08x " "tsac %d ms nsac %d\n", mmc_hostname(host), mrq->data->blksz, mrq->data->blocks, mrq->data->flags, mrq->data->timeout_ns / 1000000, mrq->data->timeout_clks); } if (mrq->stop) { pr_debug("%s: CMD%u arg %08x flags %08x\n", mmc_hostname(host), mrq->stop->opcode, mrq->stop->arg, mrq->stop->flags); } WARN_ON(!host->claimed); mrq->cmd->error = 0; mrq->cmd->mrq = mrq; if (mrq->data) { BUG_ON(mrq->data->blksz > host->max_blk_size); BUG_ON(mrq->data->blocks > host->max_blk_count); BUG_ON(mrq->data->blocks * mrq->data->blksz > host->max_req_size); #ifdef CONFIG_MMC_DEBUG sz = 0; for_each_sg(mrq->data->sg, sg, mrq->data->sg_len, i) sz += sg->length; BUG_ON(sz != mrq->data->blocks * mrq->data->blksz); #endif mrq->cmd->data = mrq->data; mrq->data->error = 0; mrq->data->mrq = mrq; if (mrq->stop) { mrq->data->stop = mrq->stop; mrq->stop->error = 0; mrq->stop->mrq = mrq; } #ifdef CONFIG_MMC_PERF_PROFILING if (host->perf_enable) host->perf.start = ktime_get(); #endif } mmc_host_clk_hold(host); led_trigger_event(host->led, LED_FULL); if (host->card && host->clk_scaling.enable) { /* * Check if we need to scale the clocks. Clocks * will be scaled up immediately if necessary * conditions are satisfied. Scaling down the * frequency will be done after current thread * releases host. */ mmc_clk_scaling(host, false); host->clk_scaling.start_busy = ktime_get(); } host->ops->request(host, mrq); } /** * mmc_start_delayed_bkops() - Start a delayed work to check for * the need of non urgent BKOPS * * @card: MMC card to start BKOPS on */ void mmc_start_delayed_bkops(struct mmc_card *card) { if (!card || !card->ext_csd.bkops_en || mmc_card_doing_bkops(card)) return; if (card->bkops_info.sectors_changed < card->bkops_info.min_sectors_to_queue_delayed_work) return; pr_debug("%s: %s: queueing delayed_bkops_work\n", mmc_hostname(card->host), __func__); /* * cancel_delayed_bkops_work will prevent a race condition between * fetching a request by the mmcqd and the delayed work, in case * it was removed from the queue work but not started yet */ card->bkops_info.cancel_delayed_work = false; queue_delayed_work(system_nrt_wq, &card->bkops_info.dw, msecs_to_jiffies( card->bkops_info.delay_ms)); } EXPORT_SYMBOL(mmc_start_delayed_bkops); /** * mmc_start_bkops - start BKOPS for supported cards * @card: MMC card to start BKOPS * @from_exception: A flag to indicate if this function was * called due to an exception raised by the card * * Start background operations whenever requested. * When the urgent BKOPS bit is set in a R1 command response * then background operations should be started immediately. */ void mmc_start_bkops(struct mmc_card *card, bool from_exception) { int err; BUG_ON(!card); if (!card->ext_csd.bkops_en) return; if ((card->bkops_info.cancel_delayed_work) && !from_exception) { pr_debug("%s: %s: cancel_delayed_work was set, exit\n", mmc_hostname(card->host), __func__); card->bkops_info.cancel_delayed_work = false; return; } /* In case of delayed bkops we might be in race with suspend. */ if (!mmc_try_claim_host(card->host)) return; /* * Since the cancel_delayed_work can be changed while we are waiting * for the lock we will to re-check it */ if ((card->bkops_info.cancel_delayed_work) && !from_exception) { pr_debug("%s: %s: cancel_delayed_work was set, exit\n", mmc_hostname(card->host), __func__); card->bkops_info.cancel_delayed_work = false; goto out; } if (mmc_card_doing_bkops(card)) { pr_debug("%s: %s: already doing bkops, exit\n", mmc_hostname(card->host), __func__); goto out; } if (from_exception && mmc_card_need_bkops(card)) goto out; /* * If the need BKOPS flag is set, there is no need to check if BKOPS * is needed since we already know that it does */ if (!mmc_card_need_bkops(card)) { err = mmc_read_bkops_status(card); if (err) { pr_err("%s: %s: Failed to read bkops status: %d\n", mmc_hostname(card->host), __func__, err); goto out; } if (!card->ext_csd.raw_bkops_status) goto out; pr_info("%s: %s: raw_bkops_status=0x%x, from_exception=%d\n", mmc_hostname(card->host), __func__, card->ext_csd.raw_bkops_status, from_exception); } /* * If the function was called due to exception, BKOPS will be performed * after handling the last pending request */ if (from_exception) { pr_debug("%s: %s: Level %d from exception, exit", mmc_hostname(card->host), __func__, card->ext_csd.raw_bkops_status); mmc_card_set_need_bkops(card); goto out; } pr_info("%s: %s: Starting bkops\n", mmc_hostname(card->host), __func__); err = __mmc_switch(card, EXT_CSD_CMD_SET_NORMAL, EXT_CSD_BKOPS_START, 1, 0, false, false); if (err) { pr_warn("%s: Error %d starting bkops\n", mmc_hostname(card->host), err); goto out; } mmc_card_clr_need_bkops(card); mmc_card_set_doing_bkops(card); out: mmc_release_host(card->host); } EXPORT_SYMBOL(mmc_start_bkops); /** * mmc_start_idle_time_bkops() - check if a non urgent BKOPS is * needed * @work: The idle time BKOPS work */ void mmc_start_idle_time_bkops(struct work_struct *work) { struct mmc_card *card = container_of(work, struct mmc_card, bkops_info.dw.work); /* * Prevent a race condition between mmc_stop_bkops and the delayed * BKOPS work in case the delayed work is executed on another CPU */ if (card->bkops_info.cancel_delayed_work) return; mmc_start_bkops(card, false); } EXPORT_SYMBOL(mmc_start_idle_time_bkops); static void mmc_wait_done(struct mmc_request *mrq) { complete(&mrq->completion); } static int __mmc_start_req(struct mmc_host *host, struct mmc_request *mrq) { init_completion(&mrq->completion); mrq->done = mmc_wait_done; if (mmc_card_removed(host->card)) { mrq->cmd->error = -ENOMEDIUM; complete(&mrq->completion); return -ENOMEDIUM; } mmc_start_request(host, mrq); return 0; } static void mmc_wait_for_req_done(struct mmc_host *host, struct mmc_request *mrq) { struct mmc_command *cmd; while (1) { wait_for_completion_io(&mrq->completion); cmd = mrq->cmd; /* * If host has timed out waiting for the commands which can be * HPIed then let the caller handle the timeout error as it may * want to send the HPI command to bring the card out of * programming state. */ if (cmd->ignore_timeout && cmd->error == -ETIMEDOUT) break; if (!cmd->error || !cmd->retries || mmc_card_removed(host->card)) break; pr_debug("%s: req failed (CMD%u): %d, retrying...\n", mmc_hostname(host), cmd->opcode, cmd->error); cmd->retries--; cmd->error = 0; host->ops->request(host, mrq); } } /** * mmc_pre_req - Prepare for a new request * @host: MMC host to prepare command * @mrq: MMC request to prepare for * @is_first_req: true if there is no previous started request * that may run in parellel to this call, otherwise false * * mmc_pre_req() is called in prior to mmc_start_req() to let * host prepare for the new request. Preparation of a request may be * performed while another request is running on the host. */ static void mmc_pre_req(struct mmc_host *host, struct mmc_request *mrq, bool is_first_req) { if (host->ops->pre_req) { mmc_host_clk_hold(host); host->ops->pre_req(host, mrq, is_first_req); mmc_host_clk_release(host); } } /** * mmc_post_req - Post process a completed request * @host: MMC host to post process command * @mrq: MMC request to post process for * @err: Error, if non zero, clean up any resources made in pre_req * * Let the host post process a completed request. Post processing of * a request may be performed while another reuqest is running. */ static void mmc_post_req(struct mmc_host *host, struct mmc_request *mrq, int err) { if (host->ops->post_req) { mmc_host_clk_hold(host); host->ops->post_req(host, mrq, err); mmc_host_clk_release(host); } } /** * mmc_start_req - start a non-blocking request * @host: MMC host to start command * @areq: async request to start * @error: out parameter returns 0 for success, otherwise non zero * * Start a new MMC custom command request for a host. * If there is on ongoing async request wait for completion * of that request and start the new one and return. * Does not wait for the new request to complete. * * Returns the completed request, NULL in case of none completed. * Wait for the an ongoing request (previoulsy started) to complete and * return the completed request. If there is no ongoing request, NULL * is returned without waiting. NULL is not an error condition. */ struct mmc_async_req *mmc_start_req(struct mmc_host *host, struct mmc_async_req *areq, int *error) { int err = 0; int start_err = 0; struct mmc_async_req *data = host->areq; /* Prepare a new request */ if (areq) mmc_pre_req(host, areq->mrq, !host->areq); if (host->areq) { mmc_wait_for_req_done(host, host->areq->mrq); err = host->areq->err_check(host->card, host->areq); /* * Check BKOPS urgency for each R1 response */ if (host->card && mmc_card_mmc(host->card) && ((mmc_resp_type(host->areq->mrq->cmd) == MMC_RSP_R1) || (mmc_resp_type(host->areq->mrq->cmd) == MMC_RSP_R1B)) && (host->areq->mrq->cmd->resp[0] & R1_EXCEPTION_EVENT)) mmc_start_bkops(host->card, true); } if (!err && areq) start_err = __mmc_start_req(host, areq->mrq); if (host->areq) mmc_post_req(host, host->areq->mrq, 0); /* Cancel a prepared request if it was not started. */ if ((err || start_err) && areq) mmc_post_req(host, areq->mrq, -EINVAL); if (err) host->areq = NULL; else host->areq = areq; if (error) *error = err; return data; } EXPORT_SYMBOL(mmc_start_req); /** * mmc_wait_for_req - start a request and wait for completion * @host: MMC host to start command * @mrq: MMC request to start * * Start a new MMC custom command request for a host, and wait * for the command to complete. Does not attempt to parse the * response. */ void mmc_wait_for_req(struct mmc_host *host, struct mmc_request *mrq) { __mmc_start_req(host, mrq); mmc_wait_for_req_done(host, mrq); } EXPORT_SYMBOL(mmc_wait_for_req); bool mmc_card_is_prog_state(struct mmc_card *card) { bool rc; struct mmc_command cmd; mmc_claim_host(card->host); memset(&cmd, 0, sizeof(struct mmc_command)); cmd.opcode = MMC_SEND_STATUS; if (!mmc_host_is_spi(card->host)) cmd.arg = card->rca << 16; cmd.flags = MMC_RSP_R1 | MMC_CMD_AC; rc = mmc_wait_for_cmd(card->host, &cmd, 0); if (rc) { pr_err("%s: Get card status fail. rc=%d\n", mmc_hostname(card->host), rc); rc = false; goto out; } if (R1_CURRENT_STATE(cmd.resp[0]) == R1_STATE_PRG) rc = true; else rc = false; out: mmc_release_host(card->host); return rc; } EXPORT_SYMBOL(mmc_card_is_prog_state); /** * mmc_interrupt_hpi - Issue for High priority Interrupt * @card: the MMC card associated with the HPI transfer * * Issued High Priority Interrupt, and check for card status * until out-of prg-state. */ int mmc_interrupt_hpi(struct mmc_card *card) { int err; u32 status; BUG_ON(!card); if (!card->ext_csd.hpi_en) { pr_info("%s: HPI enable bit unset\n", mmc_hostname(card->host)); return 1; } mmc_claim_host(card->host); err = mmc_send_status(card, &status); if (err) { pr_err("%s: Get card status fail\n", mmc_hostname(card->host)); goto out; } /* * If the card status is in PRG-state, we can send the HPI command. */ if (R1_CURRENT_STATE(status) == R1_STATE_PRG) { do { /* * We don't know when the HPI command will finish * processing, so we need to resend HPI until out * of prg-state, and keep checking the card status * with SEND_STATUS. If a timeout error occurs when * sending the HPI command, we are already out of * prg-state. */ err = mmc_send_hpi_cmd(card, &status); if (err) pr_debug("%s: abort HPI (%d error)\n", mmc_hostname(card->host), err); err = mmc_send_status(card, &status); if (err) break; } while (R1_CURRENT_STATE(status) == R1_STATE_PRG); } else pr_debug("%s: Left prg-state\n", mmc_hostname(card->host)); out: mmc_release_host(card->host); return err; } EXPORT_SYMBOL(mmc_interrupt_hpi); /** * mmc_wait_for_cmd - start a command and wait for completion * @host: MMC host to start command * @cmd: MMC command to start * @retries: maximum number of retries * * Start a new MMC command for a host, and wait for the command * to complete. Return any error that occurred while the command * was executing. Do not attempt to parse the response. */ int mmc_wait_for_cmd(struct mmc_host *host, struct mmc_command *cmd, int retries) { struct mmc_request mrq = {NULL}; WARN_ON(!host->claimed); memset(cmd->resp, 0, sizeof(cmd->resp)); cmd->retries = retries; mrq.cmd = cmd; cmd->data = NULL; mmc_wait_for_req(host, &mrq); return cmd->error; } EXPORT_SYMBOL(mmc_wait_for_cmd); /** * mmc_stop_bkops - stop ongoing BKOPS * @card: MMC card to check BKOPS * * Send HPI command to stop ongoing background operations to * allow rapid servicing of foreground operations, e.g. read/ * writes. Wait until the card comes out of the programming state * to avoid errors in servicing read/write requests. * * The function should be called with host claimed. */ int mmc_stop_bkops(struct mmc_card *card) { int err = 0; BUG_ON(!card); /* * Notify the delayed work to be cancelled, in case it was already * removed from the queue, but was not started yet */ card->bkops_info.cancel_delayed_work = true; if (delayed_work_pending(&card->bkops_info.dw)) cancel_delayed_work_sync(&card->bkops_info.dw); if (!mmc_card_doing_bkops(card)) goto out; /* * If idle time bkops is running on the card, let's not get into * suspend. */ if (mmc_card_doing_bkops(card) && (card->host->parent->power.runtime_status == RPM_SUSPENDING) && mmc_card_is_prog_state(card)) { err = -EBUSY; goto out; } err = mmc_interrupt_hpi(card); /* * If err is EINVAL, we can't issue an HPI. * It should complete the BKOPS. */ if (!err || (err == -EINVAL)) { mmc_card_clr_doing_bkops(card); err = 0; } out: return err; } EXPORT_SYMBOL(mmc_stop_bkops); int mmc_read_bkops_status(struct mmc_card *card) { int err; u8 *ext_csd; /* * In future work, we should consider storing the entire ext_csd. */ ext_csd = kmalloc(512, GFP_KERNEL); if (!ext_csd) { pr_err("%s: could not allocate buffer to receive the ext_csd.\n", mmc_hostname(card->host)); return -ENOMEM; } mmc_claim_host(card->host); err = mmc_send_ext_csd(card, ext_csd); mmc_release_host(card->host); if (err) goto out; card->ext_csd.raw_bkops_status = ext_csd[EXT_CSD_BKOPS_STATUS]; card->ext_csd.raw_exception_status = ext_csd[EXT_CSD_EXP_EVENTS_STATUS]; out: kfree(ext_csd); return err; } EXPORT_SYMBOL(mmc_read_bkops_status); /** * mmc_set_data_timeout - set the timeout for a data command * @data: data phase for command * @card: the MMC card associated with the data transfer * * Computes the data timeout parameters according to the * correct algorithm given the card type. */ void mmc_set_data_timeout(struct mmc_data *data, const struct mmc_card *card) { unsigned int mult; /* * SDIO cards only define an upper 1 s limit on access. */ if (mmc_card_sdio(card)) { data->timeout_ns = 1000000000; data->timeout_clks = 0; return; } /* * SD cards use a 100 multiplier rather than 10 */ mult = mmc_card_sd(card) ? 100 : 10; /* * Scale up the multiplier (and therefore the timeout) by * the r2w factor for writes. */ if (data->flags & MMC_DATA_WRITE) mult <<= card->csd.r2w_factor; data->timeout_ns = card->csd.tacc_ns * mult; data->timeout_clks = card->csd.tacc_clks * mult; /* * SD cards also have an upper limit on the timeout. */ if (mmc_card_sd(card)) { unsigned int timeout_us, limit_us; timeout_us = data->timeout_ns / 1000; if (mmc_host_clk_rate(card->host)) timeout_us += data->timeout_clks * 1000 / (mmc_host_clk_rate(card->host) / 1000); if (data->flags & MMC_DATA_WRITE) /* * The MMC spec "It is strongly recommended * for hosts to implement more than 500ms * timeout value even if the card indicates * the 250ms maximum busy length." Even the * previous value of 300ms is known to be * insufficient for some cards. */ limit_us = 3000000; else limit_us = 100000; /* * SDHC cards always use these fixed values. */ if (timeout_us > limit_us || mmc_card_blockaddr(card)) { data->timeout_ns = limit_us * 1000; data->timeout_clks = 0; } } /* * Some cards require longer data read timeout than indicated in CSD. * Address this by setting the read timeout to a "reasonably high" * value. For the cards tested, 300ms has proven enough. If necessary, * this value can be increased if other problematic cards require this. */ if (mmc_card_long_read_time(card) && data->flags & MMC_DATA_READ) { data->timeout_ns = 300000000; data->timeout_clks = 0; } /* * Some cards need very high timeouts if driven in SPI mode. * The worst observed timeout was 900ms after writing a * continuous stream of data until the internal logic * overflowed. */ if (mmc_host_is_spi(card->host)) { if (data->flags & MMC_DATA_WRITE) { if (data->timeout_ns < 1000000000) data->timeout_ns = 1000000000; /* 1s */ } else { if (data->timeout_ns < 100000000) data->timeout_ns = 100000000; /* 100ms */ } } /* Increase the timeout values for some bad INAND MCP devices */ if (card->quirks & MMC_QUIRK_INAND_DATA_TIMEOUT) { data->timeout_ns = 4000000000u; /* 4s */ data->timeout_clks = 0; } } EXPORT_SYMBOL(mmc_set_data_timeout); /** * mmc_align_data_size - pads a transfer size to a more optimal value * @card: the MMC card associated with the data transfer * @sz: original transfer size * * Pads the original data size with a number of extra bytes in * order to avoid controller bugs and/or performance hits * (e.g. some controllers revert to PIO for certain sizes). * * Returns the improved size, which might be unmodified. * * Note that this function is only relevant when issuing a * single scatter gather entry. */ unsigned int mmc_align_data_size(struct mmc_card *card, unsigned int sz) { /* * FIXME: We don't have a system for the controller to tell * the core about its problems yet, so for now we just 32-bit * align the size. */ sz = ((sz + 3) / 4) * 4; return sz; } EXPORT_SYMBOL(mmc_align_data_size); /** * __mmc_claim_host - exclusively claim a host * @host: mmc host to claim * @abort: whether or not the operation should be aborted * * Claim a host for a set of operations. If @abort is non null and * dereference a non-zero value then this will return prematurely with * that non-zero value without acquiring the lock. Returns zero * with the lock held otherwise. */ int __mmc_claim_host(struct mmc_host *host, atomic_t *abort) { DECLARE_WAITQUEUE(wait, current); unsigned long flags; int stop; might_sleep(); add_wait_queue(&host->wq, &wait); spin_lock_irqsave(&host->lock, flags); while (1) { set_current_state(TASK_UNINTERRUPTIBLE); stop = abort ? atomic_read(abort) : 0; if (stop || !host->claimed || host->claimer == current) break; spin_unlock_irqrestore(&host->lock, flags); schedule(); spin_lock_irqsave(&host->lock, flags); } set_current_state(TASK_RUNNING); if (!stop) { host->claimed = 1; host->claimer = current; host->claim_cnt += 1; } else wake_up(&host->wq); spin_unlock_irqrestore(&host->lock, flags); remove_wait_queue(&host->wq, &wait); if (host->ops->enable && !stop && host->claim_cnt == 1) host->ops->enable(host); return stop; } EXPORT_SYMBOL(__mmc_claim_host); /** * mmc_try_claim_host - try exclusively to claim a host * @host: mmc host to claim * * Returns %1 if the host is claimed, %0 otherwise. */ int mmc_try_claim_host(struct mmc_host *host) { int claimed_host = 0; unsigned long flags; spin_lock_irqsave(&host->lock, flags); if (!host->claimed || host->claimer == current) { host->claimed = 1; host->claimer = current; host->claim_cnt += 1; claimed_host = 1; } spin_unlock_irqrestore(&host->lock, flags); if (host->ops->enable && claimed_host && host->claim_cnt == 1) host->ops->enable(host); return claimed_host; } EXPORT_SYMBOL(mmc_try_claim_host); /** * mmc_release_host - release a host * @host: mmc host to release * * Release a MMC host, allowing others to claim the host * for their operations. */ void mmc_release_host(struct mmc_host *host) { unsigned long flags; WARN_ON(!host->claimed); if (host->ops->disable && host->claim_cnt == 1) host->ops->disable(host); spin_lock_irqsave(&host->lock, flags); if (--host->claim_cnt) { /* Release for nested claim */ spin_unlock_irqrestore(&host->lock, flags); } else { host->claimed = 0; host->claimer = NULL; spin_unlock_irqrestore(&host->lock, flags); wake_up(&host->wq); } } EXPORT_SYMBOL(mmc_release_host); /* * Internal function that does the actual ios call to the host driver, * optionally printing some debug output. */ void mmc_set_ios(struct mmc_host *host) { struct mmc_ios *ios = &host->ios; pr_debug("%s: clock %uHz busmode %u powermode %u cs %u Vdd %u " "width %u timing %u\n", mmc_hostname(host), ios->clock, ios->bus_mode, ios->power_mode, ios->chip_select, ios->vdd, ios->bus_width, ios->timing); if (ios->clock > 0) mmc_set_ungated(host); host->ops->set_ios(host, ios); if (ios->old_rate != ios->clock) { if (likely(ios->clk_ts)) { char trace_info[80]; snprintf(trace_info, 80, "%s: freq_KHz %d --> %d | t = %d", mmc_hostname(host), ios->old_rate / 1000, ios->clock / 1000, jiffies_to_msecs( (long)jiffies - (long)ios->clk_ts)); trace_mmc_clk(trace_info); } ios->old_rate = ios->clock; ios->clk_ts = jiffies; } } EXPORT_SYMBOL(mmc_set_ios); /* * Control chip select pin on a host. */ void mmc_set_chip_select(struct mmc_host *host, int mode) { mmc_host_clk_hold(host); host->ios.chip_select = mode; mmc_set_ios(host); mmc_host_clk_release(host); } /* * Sets the host clock to the highest possible frequency that * is below "hz". */ static void __mmc_set_clock(struct mmc_host *host, unsigned int hz) { WARN_ON(hz < host->f_min); if (hz > host->f_max) hz = host->f_max; host->ios.clock = hz; mmc_set_ios(host); } void mmc_set_clock(struct mmc_host *host, unsigned int hz) { mmc_host_clk_hold(host); __mmc_set_clock(host, hz); mmc_host_clk_release(host); } #ifdef CONFIG_MMC_CLKGATE /* * This gates the clock by setting it to 0 Hz. */ void mmc_gate_clock(struct mmc_host *host) { unsigned long flags; WARN_ON(!host->ios.clock); spin_lock_irqsave(&host->clk_lock, flags); host->clk_old = host->ios.clock; host->ios.clock = 0; host->clk_gated = true; spin_unlock_irqrestore(&host->clk_lock, flags); mmc_set_ios(host); } /* * This restores the clock from gating by using the cached * clock value. */ void mmc_ungate_clock(struct mmc_host *host) { /* * We should previously have gated the clock, so the clock shall * be 0 here! The clock may however be 0 during initialization, * when some request operations are performed before setting * the frequency. When ungate is requested in that situation * we just ignore the call. */ if (host->clk_old) { WARN_ON(host->ios.clock); /* This call will also set host->clk_gated to false */ __mmc_set_clock(host, host->clk_old); } } void mmc_set_ungated(struct mmc_host *host) { unsigned long flags; /* * We've been given a new frequency while the clock is gated, * so make sure we regard this as ungating it. */ spin_lock_irqsave(&host->clk_lock, flags); host->clk_gated = false; spin_unlock_irqrestore(&host->clk_lock, flags); } #else void mmc_set_ungated(struct mmc_host *host) { } #endif /* * Change the bus mode (open drain/push-pull) of a host. */ void mmc_set_bus_mode(struct mmc_host *host, unsigned int mode) { mmc_host_clk_hold(host); host->ios.bus_mode = mode; mmc_set_ios(host); mmc_host_clk_release(host); } /* * Change data bus width of a host. */ void mmc_set_bus_width(struct mmc_host *host, unsigned int width) { mmc_host_clk_hold(host); host->ios.bus_width = width; mmc_set_ios(host); mmc_host_clk_release(host); } /** * mmc_vdd_to_ocrbitnum - Convert a voltage to the OCR bit number * @vdd: voltage (mV) * @low_bits: prefer low bits in boundary cases * * This function returns the OCR bit number according to the provided @vdd * value. If conversion is not possible a negative errno value returned. * * Depending on the @low_bits flag the function prefers low or high OCR bits * on boundary voltages. For example, * with @low_bits = true, 3300 mV translates to ilog2(MMC_VDD_32_33); * with @low_bits = false, 3300 mV translates to ilog2(MMC_VDD_33_34); * * Any value in the [1951:1999] range translates to the ilog2(MMC_VDD_20_21). */ static int mmc_vdd_to_ocrbitnum(int vdd, bool low_bits) { const int max_bit = ilog2(MMC_VDD_35_36); int bit; if (vdd < 1650 || vdd > 3600) return -EINVAL; if (vdd >= 1650 && vdd <= 1950) return ilog2(MMC_VDD_165_195); if (low_bits) vdd -= 1; /* Base 2000 mV, step 100 mV, bit's base 8. */ bit = (vdd - 2000) / 100 + 8; if (bit > max_bit) return max_bit; return bit; } /** * mmc_vddrange_to_ocrmask - Convert a voltage range to the OCR mask * @vdd_min: minimum voltage value (mV) * @vdd_max: maximum voltage value (mV) * * This function returns the OCR mask bits according to the provided @vdd_min * and @vdd_max values. If conversion is not possible the function returns 0. * * Notes wrt boundary cases: * This function sets the OCR bits for all boundary voltages, for example * [3300:3400] range is translated to MMC_VDD_32_33 | MMC_VDD_33_34 | * MMC_VDD_34_35 mask. */ u32 mmc_vddrange_to_ocrmask(int vdd_min, int vdd_max) { u32 mask = 0; if (vdd_max < vdd_min) return 0; /* Prefer high bits for the boundary vdd_max values. */ vdd_max = mmc_vdd_to_ocrbitnum(vdd_max, false); if (vdd_max < 0) return 0; /* Prefer low bits for the boundary vdd_min values. */ vdd_min = mmc_vdd_to_ocrbitnum(vdd_min, true); if (vdd_min < 0) return 0; /* Fill the mask, from max bit to min bit. */ while (vdd_max >= vdd_min) mask |= 1 << vdd_max--; return mask; } EXPORT_SYMBOL(mmc_vddrange_to_ocrmask); #ifdef CONFIG_REGULATOR /** * mmc_regulator_get_ocrmask - return mask of supported voltages * @supply: regulator to use * * This returns either a negative errno, or a mask of voltages that * can be provided to MMC/SD/SDIO devices using the specified voltage * regulator. This would normally be called before registering the * MMC host adapter. */ int mmc_regulator_get_ocrmask(struct regulator *supply) { int result = 0; int count; int i; count = regulator_count_voltages(supply); if (count < 0) return count; for (i = 0; i < count; i++) { int vdd_uV; int vdd_mV; vdd_uV = regulator_list_voltage(supply, i); if (vdd_uV <= 0) continue; vdd_mV = vdd_uV / 1000; result |= mmc_vddrange_to_ocrmask(vdd_mV, vdd_mV); } return result; } EXPORT_SYMBOL(mmc_regulator_get_ocrmask); /** * mmc_regulator_set_ocr - set regulator to match host->ios voltage * @mmc: the host to regulate * @supply: regulator to use * @vdd_bit: zero for power off, else a bit number (host->ios.vdd) * * Returns zero on success, else negative errno. * * MMC host drivers may use this to enable or disable a regulator using * a particular supply voltage. This would normally be called from the * set_ios() method. */ int mmc_regulator_set_ocr(struct mmc_host *mmc, struct regulator *supply, unsigned short vdd_bit) { int result = 0; int min_uV, max_uV; if (vdd_bit) { int tmp; int voltage; /* REVISIT mmc_vddrange_to_ocrmask() may have set some * bits this regulator doesn't quite support ... don't * be too picky, most cards and regulators are OK with * a 0.1V range goof (it's a small error percentage). */ tmp = vdd_bit - ilog2(MMC_VDD_165_195); if (tmp == 0) { min_uV = 1650 * 1000; max_uV = 1950 * 1000; } else { min_uV = 1900 * 1000 + tmp * 100 * 1000; max_uV = min_uV + 100 * 1000; } /* avoid needless changes to this voltage; the regulator * might not allow this operation */ voltage = regulator_get_voltage(supply); if (mmc->caps2 & MMC_CAP2_BROKEN_VOLTAGE) min_uV = max_uV = voltage; if (voltage < 0) result = voltage; else if (voltage < min_uV || voltage > max_uV) result = regulator_set_voltage(supply, min_uV, max_uV); else result = 0; if (result == 0 && !mmc->regulator_enabled) { result = regulator_enable(supply); if (!result) mmc->regulator_enabled = true; } } else if (mmc->regulator_enabled) { result = regulator_disable(supply); if (result == 0) mmc->regulator_enabled = false; } if (result) dev_err(mmc_dev(mmc), "could not set regulator OCR (%d)\n", result); return result; } EXPORT_SYMBOL(mmc_regulator_set_ocr); #endif /* CONFIG_REGULATOR */ /* * Mask off any voltages we don't support and select * the lowest voltage */ u32 mmc_select_voltage(struct mmc_host *host, u32 ocr) { int bit; ocr &= host->ocr_avail; bit = ffs(ocr); if (bit) { bit -= 1; ocr &= 3 << bit; mmc_host_clk_hold(host); host->ios.vdd = bit; mmc_set_ios(host); mmc_host_clk_release(host); } else { pr_warning("%s: host doesn't support card's voltages\n", mmc_hostname(host)); ocr = 0; } return ocr; } int mmc_set_signal_voltage(struct mmc_host *host, int signal_voltage, bool cmd11) { struct mmc_command cmd = {0}; int err = 0; BUG_ON(!host); /* * Send CMD11 only if the request is to switch the card to * 1.8V signalling. */ if ((signal_voltage != MMC_SIGNAL_VOLTAGE_330) && cmd11) { cmd.opcode = SD_SWITCH_VOLTAGE; cmd.arg = 0; cmd.flags = MMC_RSP_R1 | MMC_CMD_AC; err = mmc_wait_for_cmd(host, &cmd, 0); if (err) return err; if (!mmc_host_is_spi(host) && (cmd.resp[0] & R1_ERROR)) return -EIO; } host->ios.signal_voltage = signal_voltage; if (host->ops->start_signal_voltage_switch) { mmc_host_clk_hold(host); err = host->ops->start_signal_voltage_switch(host, &host->ios); mmc_host_clk_release(host); } return err; } /* * Select timing parameters for host. */ void mmc_set_timing(struct mmc_host *host, unsigned int timing) { mmc_host_clk_hold(host); host->ios.timing = timing; mmc_set_ios(host); mmc_host_clk_release(host); } /* * Select appropriate driver type for host. */ void mmc_set_driver_type(struct mmc_host *host, unsigned int drv_type) { mmc_host_clk_hold(host); host->ios.drv_type = drv_type; mmc_set_ios(host); mmc_host_clk_release(host); } /* * Apply power to the MMC stack. This is a two-stage process. * First, we enable power to the card without the clock running. * We then wait a bit for the power to stabilise. Finally, * enable the bus drivers and clock to the card. * * We must _NOT_ enable the clock prior to power stablising. * * If a host does all the power sequencing itself, ignore the * initial MMC_POWER_UP stage. */ void mmc_power_up(struct mmc_host *host) { int bit; mmc_host_clk_hold(host); /* If ocr is set, we use it */ if (host->ocr) bit = ffs(host->ocr) - 1; else bit = fls(host->ocr_avail) - 1; host->ios.vdd = bit; if (mmc_host_is_spi(host)) host->ios.chip_select = MMC_CS_HIGH; else { host->ios.chip_select = MMC_CS_DONTCARE; host->ios.bus_mode = MMC_BUSMODE_OPENDRAIN; } host->ios.power_mode = MMC_POWER_UP; host->ios.bus_width = MMC_BUS_WIDTH_1; host->ios.timing = MMC_TIMING_LEGACY; mmc_set_ios(host); /* * This delay should be sufficient to allow the power supply * to reach the minimum voltage. */ mmc_delay(10); host->ios.clock = host->f_init; host->ios.power_mode = MMC_POWER_ON; mmc_set_ios(host); /* * This delay must be at least 74 clock sizes, or 1 ms, or the * time required to reach a stable voltage. */ mmc_delay(10); mmc_host_clk_release(host); } void mmc_power_off(struct mmc_host *host) { mmc_host_clk_hold(host); host->ios.clock = 0; host->ios.vdd = 0; /* * Reset ocr mask to be the highest possible voltage supported for * this mmc host. This value will be used at next power up. */ host->ocr = 1 << (fls(host->ocr_avail) - 1); if (!mmc_host_is_spi(host)) { host->ios.bus_mode = MMC_BUSMODE_OPENDRAIN; host->ios.chip_select = MMC_CS_DONTCARE; } host->ios.power_mode = MMC_POWER_OFF; host->ios.bus_width = MMC_BUS_WIDTH_1; host->ios.timing = MMC_TIMING_LEGACY; mmc_set_ios(host); /* * Some configurations, such as the 802.11 SDIO card in the OLPC * XO-1.5, require a short delay after poweroff before the card * can be successfully turned on again. */ mmc_delay(1); mmc_host_clk_release(host); } /* * Cleanup when the last reference to the bus operator is dropped. */ static void __mmc_release_bus(struct mmc_host *host) { BUG_ON(!host); BUG_ON(host->bus_refs); BUG_ON(!host->bus_dead); host->bus_ops = NULL; } /* * Increase reference count of bus operator */ static inline void mmc_bus_get(struct mmc_host *host) { unsigned long flags; spin_lock_irqsave(&host->lock, flags); host->bus_refs++; spin_unlock_irqrestore(&host->lock, flags); } /* * Decrease reference count of bus operator and free it if * it is the last reference. */ static inline void mmc_bus_put(struct mmc_host *host) { unsigned long flags; spin_lock_irqsave(&host->lock, flags); host->bus_refs--; if ((host->bus_refs == 0) && host->bus_ops) __mmc_release_bus(host); spin_unlock_irqrestore(&host->lock, flags); } int mmc_resume_bus(struct mmc_host *host) { unsigned long flags; if (!mmc_bus_needs_resume(host)) return -EINVAL; printk("%s: Starting deferred resume\n", mmc_hostname(host)); spin_lock_irqsave(&host->lock, flags); host->bus_resume_flags &= ~MMC_BUSRESUME_NEEDS_RESUME; host->rescan_disable = 0; spin_unlock_irqrestore(&host->lock, flags); mmc_bus_get(host); if (host->bus_ops && !host->bus_dead) { mmc_power_up(host); BUG_ON(!host->bus_ops->resume); host->bus_ops->resume(host); } if (host->bus_ops->detect && !host->bus_dead) host->bus_ops->detect(host); mmc_bus_put(host); printk("%s: Deferred resume completed\n", mmc_hostname(host)); return 0; } EXPORT_SYMBOL(mmc_resume_bus); /* * Assign a mmc bus handler to a host. Only one bus handler may control a * host at any given time. */ void mmc_attach_bus(struct mmc_host *host, const struct mmc_bus_ops *ops) { unsigned long flags; BUG_ON(!host); BUG_ON(!ops); WARN_ON(!host->claimed); spin_lock_irqsave(&host->lock, flags); BUG_ON(host->bus_ops); BUG_ON(host->bus_refs); host->bus_ops = ops; host->bus_refs = 1; host->bus_dead = 0; spin_unlock_irqrestore(&host->lock, flags); } /* * Remove the current bus handler from a host. */ void mmc_detach_bus(struct mmc_host *host) { unsigned long flags; BUG_ON(!host); WARN_ON(!host->claimed); WARN_ON(!host->bus_ops); spin_lock_irqsave(&host->lock, flags); host->bus_dead = 1; spin_unlock_irqrestore(&host->lock, flags); mmc_bus_put(host); } /** * mmc_detect_change - process change of state on a MMC socket * @host: host which changed state. * @delay: optional delay to wait before detection (jiffies) * * MMC drivers should call this when they detect a card has been * inserted or removed. The MMC layer will confirm that any * present card is still functional, and initialize any newly * inserted. */ void mmc_detect_change(struct mmc_host *host, unsigned long delay) { #ifdef CONFIG_MMC_DEBUG unsigned long flags; spin_lock_irqsave(&host->lock, flags); WARN_ON(host->removed); spin_unlock_irqrestore(&host->lock, flags); #endif host->detect_change = 1; wake_lock(&host->detect_wake_lock); mmc_schedule_delayed_work(&host->detect, delay); } EXPORT_SYMBOL(mmc_detect_change); void mmc_init_erase(struct mmc_card *card) { unsigned int sz; if (is_power_of_2(card->erase_size)) card->erase_shift = ffs(card->erase_size) - 1; else card->erase_shift = 0; /* * It is possible to erase an arbitrarily large area of an SD or MMC * card. That is not desirable because it can take a long time * (minutes) potentially delaying more important I/O, and also the * timeout calculations become increasingly hugely over-estimated. * Consequently, 'pref_erase' is defined as a guide to limit erases * to that size and alignment. * * For SD cards that define Allocation Unit size, limit erases to one * Allocation Unit at a time. For MMC cards that define High Capacity * Erase Size, whether it is switched on or not, limit to that size. * Otherwise just have a stab at a good value. For modern cards it * will end up being 4MiB. Note that if the value is too small, it * can end up taking longer to erase. */ if (mmc_card_sd(card) && card->ssr.au) { card->pref_erase = card->ssr.au; card->erase_shift = ffs(card->ssr.au) - 1; } else if (card->ext_csd.hc_erase_size) { card->pref_erase = card->ext_csd.hc_erase_size; } else { sz = (card->csd.capacity << (card->csd.read_blkbits - 9)) >> 11; if (sz < 128) card->pref_erase = 512 * 1024 / 512; else if (sz < 512) card->pref_erase = 1024 * 1024 / 512; else if (sz < 1024) card->pref_erase = 2 * 1024 * 1024 / 512; else card->pref_erase = 4 * 1024 * 1024 / 512; if (card->pref_erase < card->erase_size) card->pref_erase = card->erase_size; else { sz = card->pref_erase % card->erase_size; if (sz) card->pref_erase += card->erase_size - sz; } } } static unsigned int mmc_mmc_erase_timeout(struct mmc_card *card, unsigned int arg, unsigned int qty) { unsigned int erase_timeout; if (arg == MMC_DISCARD_ARG || (arg == MMC_TRIM_ARG && card->ext_csd.rev >= 6)) { erase_timeout = card->ext_csd.trim_timeout; } else if (card->ext_csd.erase_group_def & 1) { /* High Capacity Erase Group Size uses HC timeouts */ if (arg == MMC_TRIM_ARG) erase_timeout = card->ext_csd.trim_timeout; else erase_timeout = card->ext_csd.hc_erase_timeout; } else { /* CSD Erase Group Size uses write timeout */ unsigned int mult = (10 << card->csd.r2w_factor); unsigned int timeout_clks = card->csd.tacc_clks * mult; unsigned int timeout_us; /* Avoid overflow: e.g. tacc_ns=80000000 mult=1280 */ if (card->csd.tacc_ns < 1000000) timeout_us = (card->csd.tacc_ns * mult) / 1000; else timeout_us = (card->csd.tacc_ns / 1000) * mult; /* * ios.clock is only a target. The real clock rate might be * less but not that much less, so fudge it by multiplying by 2. */ timeout_clks <<= 1; timeout_us += (timeout_clks * 1000) / (mmc_host_clk_rate(card->host) / 1000); erase_timeout = timeout_us / 1000; /* * Theoretically, the calculation could underflow so round up * to 1ms in that case. */ if (!erase_timeout) erase_timeout = 1; } /* Multiplier for secure operations */ if (arg & MMC_SECURE_ARGS) { if (arg == MMC_SECURE_ERASE_ARG) erase_timeout *= card->ext_csd.sec_erase_mult; else erase_timeout *= card->ext_csd.sec_trim_mult; } erase_timeout *= qty; /* * Ensure at least a 1 second timeout for SPI as per * 'mmc_set_data_timeout()' */ if (mmc_host_is_spi(card->host) && erase_timeout < 1000) erase_timeout = 1000; return erase_timeout; } static unsigned int mmc_sd_erase_timeout(struct mmc_card *card, unsigned int arg, unsigned int qty) { unsigned int erase_timeout; if (card->ssr.erase_timeout) { /* Erase timeout specified in SD Status Register (SSR) */ erase_timeout = card->ssr.erase_timeout * qty + card->ssr.erase_offset; } else { /* * Erase timeout not specified in SD Status Register (SSR) so * use 250ms per write block. */ erase_timeout = 250 * qty; } /* Must not be less than 1 second */ if (erase_timeout < 1000) erase_timeout = 1000; return erase_timeout; } static unsigned int mmc_erase_timeout(struct mmc_card *card, unsigned int arg, unsigned int qty) { if (mmc_card_sd(card)) return mmc_sd_erase_timeout(card, arg, qty); else return mmc_mmc_erase_timeout(card, arg, qty); } static int mmc_do_erase(struct mmc_card *card, unsigned int from, unsigned int to, unsigned int arg) { struct mmc_command cmd = {0}; unsigned int qty = 0; unsigned long timeout; int err; /* * qty is used to calculate the erase timeout which depends on how many * erase groups (or allocation units in SD terminology) are affected. * We count erasing part of an erase group as one erase group. * For SD, the allocation units are always a power of 2. For MMC, the * erase group size is almost certainly also power of 2, but it does not * seem to insist on that in the JEDEC standard, so we fall back to * division in that case. SD may not specify an allocation unit size, * in which case the timeout is based on the number of write blocks. * * Note that the timeout for secure trim 2 will only be correct if the * number of erase groups specified is the same as the total of all * preceding secure trim 1 commands. Since the power may have been * lost since the secure trim 1 commands occurred, it is generally * impossible to calculate the secure trim 2 timeout correctly. */ if (card->erase_shift) qty += ((to >> card->erase_shift) - (from >> card->erase_shift)) + 1; else if (mmc_card_sd(card)) qty += to - from + 1; else qty += ((to / card->erase_size) - (from / card->erase_size)) + 1; if (!mmc_card_blockaddr(card)) { from <<= 9; to <<= 9; } if (mmc_card_sd(card)) cmd.opcode = SD_ERASE_WR_BLK_START; else cmd.opcode = MMC_ERASE_GROUP_START; cmd.arg = from; cmd.flags = MMC_RSP_SPI_R1 | MMC_RSP_R1 | MMC_CMD_AC; err = mmc_wait_for_cmd(card->host, &cmd, 0); if (err) { pr_err("mmc_erase: group start error %d, " "status %#x\n", err, cmd.resp[0]); err = -EIO; goto out; } memset(&cmd, 0, sizeof(struct mmc_command)); if (mmc_card_sd(card)) cmd.opcode = SD_ERASE_WR_BLK_END; else cmd.opcode = MMC_ERASE_GROUP_END; cmd.arg = to; cmd.flags = MMC_RSP_SPI_R1 | MMC_RSP_R1 | MMC_CMD_AC; err = mmc_wait_for_cmd(card->host, &cmd, 0); if (err) { pr_err("mmc_erase: group end error %d, status %#x\n", err, cmd.resp[0]); err = -EIO; goto out; } memset(&cmd, 0, sizeof(struct mmc_command)); cmd.opcode = MMC_ERASE; cmd.arg = arg; cmd.flags = MMC_RSP_SPI_R1B | MMC_RSP_R1B | MMC_CMD_AC; cmd.cmd_timeout_ms = mmc_erase_timeout(card, arg, qty); err = mmc_wait_for_cmd(card->host, &cmd, 0); if (err) { pr_err("mmc_erase: erase error %d, status %#x\n", err, cmd.resp[0]); err = -EIO; goto out; } if (mmc_host_is_spi(card->host)) goto out; timeout = jiffies + msecs_to_jiffies(MMC_CORE_TIMEOUT_MS); do { memset(&cmd, 0, sizeof(struct mmc_command)); cmd.opcode = MMC_SEND_STATUS; cmd.arg = card->rca << 16; cmd.flags = MMC_RSP_R1 | MMC_CMD_AC; /* Do not retry else we can't see errors */ err = mmc_wait_for_cmd(card->host, &cmd, 0); if (err || (cmd.resp[0] & 0xFDF92000)) { pr_err("error %d requesting status %#x\n", err, cmd.resp[0]); err = -EIO; goto out; } /* Timeout if the device never becomes ready for data and * never leaves the program state. */ if (time_after(jiffies, timeout)) { pr_err("%s: Card stuck in programming state! %s\n", mmc_hostname(card->host), __func__); err = -EIO; goto out; } } while (!(cmd.resp[0] & R1_READY_FOR_DATA) || (R1_CURRENT_STATE(cmd.resp[0]) == R1_STATE_PRG)); out: return err; } /** * mmc_erase - erase sectors. * @card: card to erase * @from: first sector to erase * @nr: number of sectors to erase * @arg: erase command argument (SD supports only %MMC_ERASE_ARG) * * Caller must claim host before calling this function. */ int mmc_erase(struct mmc_card *card, unsigned int from, unsigned int nr, unsigned int arg) { unsigned int rem, to = from + nr; if (!(card->host->caps & MMC_CAP_ERASE) || !(card->csd.cmdclass & CCC_ERASE)) return -EOPNOTSUPP; if (!card->erase_size) return -EOPNOTSUPP; if (mmc_card_sd(card) && arg != MMC_ERASE_ARG) return -EOPNOTSUPP; if ((arg & MMC_SECURE_ARGS) && !(card->ext_csd.sec_feature_support & EXT_CSD_SEC_ER_EN)) return -EOPNOTSUPP; if ((arg & MMC_TRIM_ARGS) && !(card->ext_csd.sec_feature_support & EXT_CSD_SEC_GB_CL_EN)) return -EOPNOTSUPP; if (arg == MMC_SECURE_ERASE_ARG) { if (from % card->erase_size || nr % card->erase_size) return -EINVAL; } if (arg == MMC_ERASE_ARG) { rem = from % card->erase_size; if (rem) { rem = card->erase_size - rem; from += rem; if (nr > rem) nr -= rem; else return 0; } rem = nr % card->erase_size; if (rem) nr -= rem; } if (nr == 0) return 0; to = from + nr; if (to <= from) return -EINVAL; /* 'from' and 'to' are inclusive */ to -= 1; return mmc_do_erase(card, from, to, arg); } EXPORT_SYMBOL(mmc_erase); int mmc_can_erase(struct mmc_card *card) { if ((card->host->caps & MMC_CAP_ERASE) && (card->csd.cmdclass & CCC_ERASE) && card->erase_size) return 1; return 0; } EXPORT_SYMBOL(mmc_can_erase); int mmc_can_trim(struct mmc_card *card) { if (card->ext_csd.sec_feature_support & EXT_CSD_SEC_GB_CL_EN) return 1; return 0; } EXPORT_SYMBOL(mmc_can_trim); int mmc_can_discard(struct mmc_card *card) { /* * As there's no way to detect the discard support bit at v4.5 * use the s/w feature support filed. */ if (card->ext_csd.feature_support & MMC_DISCARD_FEATURE) return 1; return 0; } EXPORT_SYMBOL(mmc_can_discard); int mmc_can_sanitize(struct mmc_card *card) { if (!mmc_can_trim(card) && !mmc_can_erase(card)) return 0; if (card->ext_csd.sec_feature_support & EXT_CSD_SEC_SANITIZE) return 1; return 0; } EXPORT_SYMBOL(mmc_can_sanitize); int mmc_can_secure_erase_trim(struct mmc_card *card) { if (card->ext_csd.sec_feature_support & EXT_CSD_SEC_ER_EN) return 1; return 0; } EXPORT_SYMBOL(mmc_can_secure_erase_trim); int mmc_erase_group_aligned(struct mmc_card *card, unsigned int from, unsigned int nr) { if (!card->erase_size) return 0; if (from % card->erase_size || nr % card->erase_size) return 0; return 1; } EXPORT_SYMBOL(mmc_erase_group_aligned); static unsigned int mmc_do_calc_max_discard(struct mmc_card *card, unsigned int arg) { struct mmc_host *host = card->host; unsigned int max_discard, x, y, qty = 0, max_qty, timeout; unsigned int last_timeout = 0; if (card->erase_shift) max_qty = UINT_MAX >> card->erase_shift; else if (mmc_card_sd(card)) max_qty = UINT_MAX; else max_qty = UINT_MAX / card->erase_size; /* Find the largest qty with an OK timeout */ do { y = 0; for (x = 1; x && x <= max_qty && max_qty - x >= qty; x <<= 1) { timeout = mmc_erase_timeout(card, arg, qty + x); if (timeout > host->max_discard_to) break; if (timeout < last_timeout) break; last_timeout = timeout; y = x; } qty += y; } while (y); if (!qty) return 0; if (qty == 1) return 1; /* Convert qty to sectors */ if (card->erase_shift) max_discard = --qty << card->erase_shift; else if (mmc_card_sd(card)) max_discard = qty; else max_discard = --qty * card->erase_size; return max_discard; } unsigned int mmc_calc_max_discard(struct mmc_card *card) { struct mmc_host *host = card->host; unsigned int max_discard, max_trim; if (!host->max_discard_to) return UINT_MAX; /* * Without erase_group_def set, MMC erase timeout depends on clock * frequence which can change. In that case, the best choice is * just the preferred erase size. */ if (mmc_card_mmc(card) && !(card->ext_csd.erase_group_def & 1)) return card->pref_erase; max_discard = mmc_do_calc_max_discard(card, MMC_ERASE_ARG); if (mmc_can_trim(card)) { max_trim = mmc_do_calc_max_discard(card, MMC_TRIM_ARG); if (max_trim < max_discard) max_discard = max_trim; } else if (max_discard < card->erase_size) { max_discard = 0; } pr_debug("%s: calculated max. discard sectors %u for timeout %u ms\n", mmc_hostname(host), max_discard, host->max_discard_to); return max_discard; } EXPORT_SYMBOL(mmc_calc_max_discard); int mmc_set_blocklen(struct mmc_card *card, unsigned int blocklen) { struct mmc_command cmd = {0}; if (mmc_card_blockaddr(card) || mmc_card_ddr_mode(card)) return 0; cmd.opcode = MMC_SET_BLOCKLEN; cmd.arg = blocklen; cmd.flags = MMC_RSP_SPI_R1 | MMC_RSP_R1 | MMC_CMD_AC; return mmc_wait_for_cmd(card->host, &cmd, 5); } EXPORT_SYMBOL(mmc_set_blocklen); static void mmc_hw_reset_for_init(struct mmc_host *host) { if (!(host->caps & MMC_CAP_HW_RESET) || !host->ops->hw_reset) return; mmc_host_clk_hold(host); host->ops->hw_reset(host); mmc_host_clk_release(host); } int mmc_can_reset(struct mmc_card *card) { u8 rst_n_function; if (mmc_card_sdio(card)) return 0; if (mmc_card_mmc(card)) { rst_n_function = card->ext_csd.rst_n_function; if ((rst_n_function & EXT_CSD_RST_N_EN_MASK) != EXT_CSD_RST_N_ENABLED) return 0; } return 1; } EXPORT_SYMBOL(mmc_can_reset); static int mmc_do_hw_reset(struct mmc_host *host, int check) { struct mmc_card *card = host->card; if (!host->bus_ops->power_restore) return -EOPNOTSUPP; if (!(host->caps & MMC_CAP_HW_RESET) || !host->ops->hw_reset) return -EOPNOTSUPP; if (!card) return -EINVAL; if (!mmc_can_reset(card)) return -EOPNOTSUPP; mmc_host_clk_hold(host); mmc_set_clock(host, host->f_init); host->ops->hw_reset(host); /* If the reset has happened, then a status command will fail */ if (check) { struct mmc_command cmd = {0}; int err; cmd.opcode = MMC_SEND_STATUS; if (!mmc_host_is_spi(card->host)) cmd.arg = card->rca << 16; cmd.flags = MMC_RSP_SPI_R2 | MMC_RSP_R1 | MMC_CMD_AC; err = mmc_wait_for_cmd(card->host, &cmd, 0); if (!err) { mmc_host_clk_release(host); return -ENOSYS; } } host->card->state &= ~(MMC_STATE_HIGHSPEED | MMC_STATE_HIGHSPEED_DDR); if (mmc_host_is_spi(host)) { host->ios.chip_select = MMC_CS_HIGH; host->ios.bus_mode = MMC_BUSMODE_PUSHPULL; } else { host->ios.chip_select = MMC_CS_DONTCARE; host->ios.bus_mode = MMC_BUSMODE_OPENDRAIN; } host->ios.bus_width = MMC_BUS_WIDTH_1; host->ios.timing = MMC_TIMING_LEGACY; mmc_set_ios(host); mmc_host_clk_release(host); return host->bus_ops->power_restore(host); } int mmc_hw_reset(struct mmc_host *host) { return mmc_do_hw_reset(host, 0); } EXPORT_SYMBOL(mmc_hw_reset); int mmc_hw_reset_check(struct mmc_host *host) { return mmc_do_hw_reset(host, 1); } EXPORT_SYMBOL(mmc_hw_reset_check); /** * mmc_reset_clk_scale_stats() - reset clock scaling statistics * @host: pointer to mmc host structure */ void mmc_reset_clk_scale_stats(struct mmc_host *host) { host->clk_scaling.busy_time_us = 0; host->clk_scaling.window_time = jiffies; } EXPORT_SYMBOL_GPL(mmc_reset_clk_scale_stats); /** * mmc_get_max_frequency() - get max. frequency supported * @host: pointer to mmc host structure * * Returns max. frequency supported by card/host. If the * timing mode is SDR50/SDR104/HS200/DDR50 return appropriate * max. frequency in these modes else, use the current frequency. * Also, allow host drivers to overwrite the frequency in case * they support "get_max_frequency" host ops. */ unsigned long mmc_get_max_frequency(struct mmc_host *host) { unsigned long freq; if (host->ops && host->ops->get_max_frequency) { freq = host->ops->get_max_frequency(host); goto out; } switch (host->ios.timing) { case MMC_TIMING_UHS_SDR50: freq = UHS_SDR50_MAX_DTR; break; case MMC_TIMING_UHS_SDR104: freq = UHS_SDR104_MAX_DTR; break; case MMC_TIMING_MMC_HS200: freq = MMC_HS200_MAX_DTR; break; case MMC_TIMING_UHS_DDR50: freq = UHS_DDR50_MAX_DTR; break; default: mmc_host_clk_hold(host); freq = host->ios.clock; mmc_host_clk_release(host); break; } out: return freq; } EXPORT_SYMBOL_GPL(mmc_get_max_frequency); /** * mmc_get_min_frequency() - get min. frequency supported * @host: pointer to mmc host structure * * Returns min. frequency supported by card/host which doesn't impair * performance for most usecases. If the timing mode is SDR50/SDR104/HS200 * return 50MHz value. If timing mode is DDR50 return 25MHz so that * throughput would be equivalent to SDR50/SDR104 in 50MHz. Also, allow * host drivers to overwrite the frequency in case they support * "get_min_frequency" host ops. */ static unsigned long mmc_get_min_frequency(struct mmc_host *host) { unsigned long freq; if (host->ops && host->ops->get_min_frequency) { freq = host->ops->get_min_frequency(host); goto out; } switch (host->ios.timing) { case MMC_TIMING_UHS_SDR50: case MMC_TIMING_UHS_SDR104: freq = UHS_SDR25_MAX_DTR; break; case MMC_TIMING_MMC_HS200: freq = MMC_HIGH_52_MAX_DTR; break; case MMC_TIMING_UHS_DDR50: freq = UHS_DDR50_MAX_DTR / 2; break; default: mmc_host_clk_hold(host); freq = host->ios.clock; mmc_host_clk_release(host); break; } out: return freq; } /* * Scale down clocks to minimum frequency supported. * The delayed work re-arms itself in case it cannot * claim the host. */ static void mmc_clk_scale_work(struct work_struct *work) { struct mmc_host *host = container_of(work, struct mmc_host, clk_scaling.work.work); if (!host->card || !host->bus_ops || !host->bus_ops->change_bus_speed || !host->clk_scaling.enable || !host->ios.clock) goto out; if (!mmc_try_claim_host(host)) { /* retry after a timer tick */ queue_delayed_work(system_nrt_wq, &host->clk_scaling.work, 1); goto out; } mmc_clk_scaling(host, true); mmc_release_host(host); out: return; } static bool mmc_is_vaild_state_for_clk_scaling(struct mmc_host *host) { struct mmc_card *card = host->card; u32 status; bool ret = false; if (!card) goto out; if (mmc_send_status(card, &status)) { pr_err("%s: Get card status fail\n", mmc_hostname(card->host)); goto out; } switch (R1_CURRENT_STATE(status)) { case R1_STATE_TRAN: ret = true; break; default: break; } out: return ret; } static int mmc_clk_update_freq(struct mmc_host *host, unsigned long freq, enum mmc_load state) { int err = 0; if (host->ops->notify_load) { err = host->ops->notify_load(host, state); if (err) goto out; } if (freq != host->clk_scaling.curr_freq) { if (!mmc_is_vaild_state_for_clk_scaling(host)) { err = -EAGAIN; goto error; } err = host->bus_ops->change_bus_speed(host, &freq); if (!err) host->clk_scaling.curr_freq = freq; else pr_err("%s: %s: failed (%d) at freq=%lu\n", mmc_hostname(host), __func__, err, freq); } error: if (err) { /* restore previous state */ if (host->ops->notify_load) host->ops->notify_load(host, host->clk_scaling.state); } out: return err; } /** * mmc_clk_scaling() - clock scaling decision algorithm * @host: pointer to mmc host structure * @from_wq: variable that specifies the context in which * mmc_clk_scaling() is called. * * Calculate load percentage based on host busy time * and total sampling interval and decide clock scaling * based on scale up/down thresholds. * If load is greater than up threshold increase the * frequency to maximum as supported by host. Else, * if load is less than down threshold, scale down the * frequency to minimum supported by the host. Otherwise, * retain current frequency and do nothing. */ static void mmc_clk_scaling(struct mmc_host *host, bool from_wq) { int err = 0; struct mmc_card *card = host->card; unsigned long total_time_ms = 0; unsigned long busy_time_ms = 0; unsigned long freq; unsigned int up_threshold = host->clk_scaling.up_threshold; unsigned int down_threshold = host->clk_scaling.down_threshold; bool queue_scale_down_work = false; enum mmc_load state; if (!card || !host->bus_ops || !host->bus_ops->change_bus_speed) { pr_err("%s: %s: invalid entry\n", mmc_hostname(host), __func__); goto out; } /* Check if the clocks are already gated. */ if (!host->ios.clock) goto out; if (time_is_after_jiffies(host->clk_scaling.window_time + msecs_to_jiffies(host->clk_scaling.polling_delay_ms))) goto out; /* handle time wrap */ total_time_ms = jiffies_to_msecs((long)jiffies - (long)host->clk_scaling.window_time); /* Check if we re-enter during clock switching */ if (unlikely(host->clk_scaling.in_progress)) goto out; host->clk_scaling.in_progress = true; busy_time_ms = host->clk_scaling.busy_time_us / USEC_PER_MSEC; freq = host->clk_scaling.curr_freq; state = host->clk_scaling.state; /* * Note that the max. and min. frequency should be based * on the timing modes that the card and host handshake * during initialization. */ if ((busy_time_ms * 100 > total_time_ms * up_threshold)) { freq = mmc_get_max_frequency(host); state = MMC_LOAD_HIGH; } else if ((busy_time_ms * 100 < total_time_ms * down_threshold)) { if (!from_wq) queue_scale_down_work = true; freq = mmc_get_min_frequency(host); state = MMC_LOAD_LOW; } if (state != host->clk_scaling.state) { if (!queue_scale_down_work) { if (!from_wq) cancel_delayed_work_sync( &host->clk_scaling.work); err = mmc_clk_update_freq(host, freq, state); if (!err) host->clk_scaling.state = state; else if (err == -EAGAIN) goto no_reset_stats; } else { /* * We hold claim host while queueing the scale down * work, so delay atleast one timer tick to release * host and re-claim while scaling down the clocks. */ queue_delayed_work(system_nrt_wq, &host->clk_scaling.work, 1); goto no_reset_stats; } } mmc_reset_clk_scale_stats(host); no_reset_stats: host->clk_scaling.in_progress = false; out: return; } /** * mmc_disable_clk_scaling() - Disable clock scaling * @host: pointer to mmc host structure * * Disables clock scaling temporarily by setting enable * property to false. To disable completely, one also * need to set 'initialized' variable to false. */ void mmc_disable_clk_scaling(struct mmc_host *host) { cancel_delayed_work_sync(&host->clk_scaling.work); host->clk_scaling.enable = false; } EXPORT_SYMBOL_GPL(mmc_disable_clk_scaling); /** * mmc_can_scale_clk() - Check if clock scaling is initialized * @host: pointer to mmc host structure */ bool mmc_can_scale_clk(struct mmc_host *host) { return host->clk_scaling.initialized; } EXPORT_SYMBOL_GPL(mmc_can_scale_clk); /** * mmc_init_clk_scaling() - Initialize clock scaling * @host: pointer to mmc host structure * * Initialize clock scaling for supported hosts. * It is assumed that the caller ensure clock is * running at maximum possible frequency before * calling this function. */ void mmc_init_clk_scaling(struct mmc_host *host) { if (!host->card || !(host->caps2 & MMC_CAP2_CLK_SCALE)) return; INIT_DELAYED_WORK(&host->clk_scaling.work, mmc_clk_scale_work); host->clk_scaling.curr_freq = mmc_get_max_frequency(host); if (host->ops->notify_load) host->ops->notify_load(host, MMC_LOAD_HIGH); host->clk_scaling.state = MMC_LOAD_HIGH; mmc_reset_clk_scale_stats(host); host->clk_scaling.enable = true; host->clk_scaling.initialized = true; pr_debug("%s: clk scaling enabled\n", mmc_hostname(host)); } EXPORT_SYMBOL_GPL(mmc_init_clk_scaling); /** * mmc_exit_clk_scaling() - Disable clock scaling * @host: pointer to mmc host structure * * Disable clock scaling permanently. */ void mmc_exit_clk_scaling(struct mmc_host *host) { cancel_delayed_work_sync(&host->clk_scaling.work); memset(&host->clk_scaling, 0, sizeof(host->clk_scaling)); } EXPORT_SYMBOL_GPL(mmc_exit_clk_scaling); static int mmc_rescan_try_freq(struct mmc_host *host, unsigned freq) { host->f_init = freq; #ifdef CONFIG_MMC_DEBUG pr_info("%s: %s: trying to init card at %u Hz\n", mmc_hostname(host), __func__, host->f_init); #endif mmc_power_up(host); /* * Some eMMCs (with VCCQ always on) may not be reset after power up, so * do a hardware reset if possible. */ mmc_hw_reset_for_init(host); /* Initialization should be done at 3.3 V I/O voltage. */ mmc_set_signal_voltage(host, MMC_SIGNAL_VOLTAGE_330, 0); /* * sdio_reset sends CMD52 to reset card. Since we do not know * if the card is being re-initialized, just send it. CMD52 * should be ignored by SD/eMMC cards. */ sdio_reset(host); mmc_go_idle(host); mmc_send_if_cond(host, host->ocr_avail); /* Order's important: probe SDIO, then SD, then MMC */ if (!mmc_attach_sdio(host)) return 0; if (!host->ios.vdd) mmc_power_up(host); if (!mmc_attach_sd(host)) return 0; if (!host->ios.vdd) mmc_power_up(host); if (!mmc_attach_mmc(host)) return 0; mmc_power_off(host); return -EIO; } int _mmc_detect_card_removed(struct mmc_host *host) { int ret; if ((host->caps & MMC_CAP_NONREMOVABLE) || !host->bus_ops->alive) return 0; if (!host->card || mmc_card_removed(host->card)) return 1; ret = host->bus_ops->alive(host); if (ret) { mmc_card_set_removed(host->card); pr_debug("%s: card remove detected\n", mmc_hostname(host)); } return ret; } int mmc_detect_card_removed(struct mmc_host *host) { struct mmc_card *card = host->card; int ret; WARN_ON(!host->claimed); if (!card) return 1; ret = mmc_card_removed(card); /* * The card will be considered unchanged unless we have been asked to * detect a change or host requires polling to provide card detection. */ if (!host->detect_change && !(host->caps & MMC_CAP_NEEDS_POLL) && !(host->caps2 & MMC_CAP2_DETECT_ON_ERR)) return ret; host->detect_change = 0; if (!ret) { ret = _mmc_detect_card_removed(host); if (ret && (host->caps2 & MMC_CAP2_DETECT_ON_ERR)) { /* * Schedule a detect work as soon as possible to let a * rescan handle the card removal. */ cancel_delayed_work(&host->detect); mmc_detect_change(host, 0); } } return ret; } EXPORT_SYMBOL(mmc_detect_card_removed); void mmc_rescan(struct work_struct *work) { struct mmc_host *host = container_of(work, struct mmc_host, detect.work); bool extend_wakelock = false; if (host->rescan_disable) return; mmc_bus_get(host); /* * if there is a _removable_ card registered, check whether it is * still present */ if (host->bus_ops && host->bus_ops->detect && !host->bus_dead && !(host->caps & MMC_CAP_NONREMOVABLE)) host->bus_ops->detect(host); host->detect_change = 0; /* If the card was removed the bus will be marked * as dead - extend the wakelock so userspace * can respond */ if (host->bus_dead) extend_wakelock = 1; /* If the card was removed the bus will be marked * as dead - extend the wakelock so userspace * can respond */ if (host->bus_dead) extend_wakelock = 1; /* * Let mmc_bus_put() free the bus/bus_ops if we've found that * the card is no longer present. */ mmc_bus_put(host); mmc_bus_get(host); /* if there still is a card present, stop here */ if (host->bus_ops != NULL) { mmc_bus_put(host); goto out; } /* * Only we can add a new handler, so it's safe to * release the lock here. */ mmc_bus_put(host); if (host->ops->get_cd && host->ops->get_cd(host) == 0) goto out; mmc_claim_host(host); if (!mmc_rescan_try_freq(host, host->f_min)) extend_wakelock = true; mmc_release_host(host); out: if (extend_wakelock) wake_lock_timeout(&host->detect_wake_lock, HZ / 2); else wake_unlock(&host->detect_wake_lock); if (host->caps & MMC_CAP_NEEDS_POLL) { wake_lock(&host->detect_wake_lock); mmc_schedule_delayed_work(&host->detect, HZ); } } void mmc_start_host(struct mmc_host *host) { mmc_power_off(host); mmc_detect_change(host, 0); } void mmc_stop_host(struct mmc_host *host) { #ifdef CONFIG_MMC_DEBUG unsigned long flags; spin_lock_irqsave(&host->lock, flags); host->removed = 1; spin_unlock_irqrestore(&host->lock, flags); #endif if (cancel_delayed_work_sync(&host->detect)) wake_unlock(&host->detect_wake_lock); mmc_flush_scheduled_work(); /* clear pm flags now and let card drivers set them as needed */ host->pm_flags = 0; mmc_bus_get(host); if (host->bus_ops && !host->bus_dead) { /* Calling bus_ops->remove() with a claimed host can deadlock */ if (host->bus_ops->remove) host->bus_ops->remove(host); mmc_claim_host(host); mmc_detach_bus(host); mmc_power_off(host); mmc_release_host(host); mmc_bus_put(host); return; } mmc_bus_put(host); BUG_ON(host->card); mmc_power_off(host); } int mmc_power_save_host(struct mmc_host *host) { int ret = 0; #ifdef CONFIG_MMC_DEBUG pr_info("%s: %s: powering down\n", mmc_hostname(host), __func__); #endif mmc_bus_get(host); if (!host->bus_ops || host->bus_dead || !host->bus_ops->power_restore) { mmc_bus_put(host); return -EINVAL; } if (host->bus_ops->power_save) ret = host->bus_ops->power_save(host); mmc_bus_put(host); mmc_power_off(host); return ret; } EXPORT_SYMBOL(mmc_power_save_host); int mmc_power_restore_host(struct mmc_host *host) { int ret; #ifdef CONFIG_MMC_DEBUG pr_info("%s: %s: powering up\n", mmc_hostname(host), __func__); #endif mmc_bus_get(host); if (!host->bus_ops || host->bus_dead || !host->bus_ops->power_restore) { mmc_bus_put(host); return -EINVAL; } mmc_power_up(host); ret = host->bus_ops->power_restore(host); mmc_bus_put(host); return ret; } EXPORT_SYMBOL(mmc_power_restore_host); int mmc_card_awake(struct mmc_host *host) { int err = -ENOSYS; if (host->caps2 & MMC_CAP2_NO_SLEEP_CMD) return 0; mmc_bus_get(host); if (host->bus_ops && !host->bus_dead && host->bus_ops->awake) err = host->bus_ops->awake(host); mmc_bus_put(host); return err; } EXPORT_SYMBOL(mmc_card_awake); int mmc_card_sleep(struct mmc_host *host) { int err = -ENOSYS; if (host->caps2 & MMC_CAP2_NO_SLEEP_CMD) return 0; mmc_bus_get(host); if (host->bus_ops && !host->bus_dead && host->bus_ops->sleep) err = host->bus_ops->sleep(host); mmc_bus_put(host); return err; } EXPORT_SYMBOL(mmc_card_sleep); int mmc_card_can_sleep(struct mmc_host *host) { struct mmc_card *card = host->card; if (card && mmc_card_mmc(card) && card->ext_csd.rev >= 3) return 1; return 0; } EXPORT_SYMBOL(mmc_card_can_sleep); /* * Flush the cache to the non-volatile storage. */ int mmc_flush_cache(struct mmc_card *card) { struct mmc_host *host = card->host; int err = 0, rc; if (!(host->caps2 & MMC_CAP2_CACHE_CTRL)) return err; if (mmc_card_mmc(card) && (card->ext_csd.cache_size > 0) && (card->ext_csd.cache_ctrl & 1)) { err = mmc_switch_ignore_timeout(card, EXT_CSD_CMD_SET_NORMAL, EXT_CSD_FLUSH_CACHE, 1, MMC_FLUSH_REQ_TIMEOUT_MS); if (err == -ETIMEDOUT) { pr_debug("%s: cache flush timeout\n", mmc_hostname(card->host)); rc = mmc_interrupt_hpi(card); if (rc) pr_err("%s: mmc_interrupt_hpi() failed (%d)\n", mmc_hostname(host), rc); } else if (err) { pr_err("%s: cache flush error %d\n", mmc_hostname(card->host), err); } } return err; } EXPORT_SYMBOL(mmc_flush_cache); /* * Turn the cache ON/OFF. * Turning the cache OFF shall trigger flushing of the data * to the non-volatile storage. * This function should be called with host claimed */ int mmc_cache_ctrl(struct mmc_host *host, u8 enable) { struct mmc_card *card = host->card; unsigned int timeout = card->ext_csd.generic_cmd6_time; int err = 0, rc; if (!(host->caps2 & MMC_CAP2_CACHE_CTRL) || mmc_card_is_removable(host)) return err; if (card && mmc_card_mmc(card) && (card->ext_csd.cache_size > 0)) { enable = !!enable; if (card->ext_csd.cache_ctrl ^ enable) { if (!enable) timeout = MMC_FLUSH_REQ_TIMEOUT_MS; err = mmc_switch_ignore_timeout(card, EXT_CSD_CMD_SET_NORMAL, EXT_CSD_CACHE_CTRL, enable, timeout); if (err == -ETIMEDOUT && !enable) { pr_debug("%s:cache disable operation timeout\n", mmc_hostname(card->host)); rc = mmc_interrupt_hpi(card); if (rc) pr_err("%s: mmc_interrupt_hpi() failed (%d)\n", mmc_hostname(host), rc); } else if (err) { pr_err("%s: cache %s error %d\n", mmc_hostname(card->host), enable ? "on" : "off", err); } else { card->ext_csd.cache_ctrl = enable; } } } return err; } EXPORT_SYMBOL(mmc_cache_ctrl); #ifdef CONFIG_PM /** * mmc_suspend_host - suspend a host * @host: mmc host */ int mmc_suspend_host(struct mmc_host *host) { int err = 0; if (mmc_bus_needs_resume(host)) return 0; mmc_bus_get(host); if (host->bus_ops && !host->bus_dead) { /* * A long response time is not acceptable for device drivers * when doing suspend. Prevent mmc_claim_host in the suspend * sequence, to potentially wait "forever" by trying to * pre-claim the host. * * Skip try claim host for SDIO cards, doing so fixes deadlock * conditions. The function driver suspend may again call into * SDIO driver within a different context for enabling power * save mode in the card and hence wait in mmc_claim_host * causing deadlock. */ if (!(host->card && mmc_card_sdio(host->card))) if (!mmc_try_claim_host(host)) err = -EBUSY; if (!err) { if (host->bus_ops->suspend) { err = mmc_stop_bkops(host->card); if (err) goto stop_bkops_err; err = host->bus_ops->suspend(host); } if (!(host->card && mmc_card_sdio(host->card))) mmc_release_host(host); if (err == -ENOSYS || !host->bus_ops->resume) { /* * We simply "remove" the card in this case. * It will be redetected on resume. (Calling * bus_ops->remove() with a claimed host can * deadlock.) * It will be redetected on resume. */ if (host->bus_ops->remove) host->bus_ops->remove(host); mmc_claim_host(host); mmc_detach_bus(host); mmc_power_off(host); mmc_release_host(host); host->pm_flags = 0; err = 0; } } } mmc_bus_put(host); if (!err && !mmc_card_keep_power(host)) mmc_power_off(host); return err; stop_bkops_err: if (!(host->card && mmc_card_sdio(host->card))) mmc_release_host(host); return err; } EXPORT_SYMBOL(mmc_suspend_host); /** * mmc_resume_host - resume a previously suspended host * @host: mmc host */ int mmc_resume_host(struct mmc_host *host) { int err = 0; mmc_bus_get(host); if (mmc_bus_manual_resume(host)) { host->bus_resume_flags |= MMC_BUSRESUME_NEEDS_RESUME; mmc_bus_put(host); return 0; } if (host->bus_ops && !host->bus_dead) { if (!mmc_card_keep_power(host)) { mmc_power_up(host); mmc_select_voltage(host, host->ocr); /* * Tell runtime PM core we just powered up the card, * since it still believes the card is powered off. * Note that currently runtime PM is only enabled * for SDIO cards that are MMC_CAP_POWER_OFF_CARD */ if (mmc_card_sdio(host->card) && (host->caps & MMC_CAP_POWER_OFF_CARD)) { pm_runtime_disable(&host->card->dev); pm_runtime_set_active(&host->card->dev); pm_runtime_enable(&host->card->dev); } } BUG_ON(!host->bus_ops->resume); err = host->bus_ops->resume(host); if (err) { pr_warning("%s: error %d during resume " "(card was removed?)\n", mmc_hostname(host), err); err = 0; } } host->pm_flags &= ~MMC_PM_KEEP_POWER; mmc_bus_put(host); return err; } EXPORT_SYMBOL(mmc_resume_host); /* Do the card removal on suspend if card is assumed removeable * Do that in pm notifier while userspace isn't yet frozen, so we will be able to sync the card. */ int mmc_pm_notify(struct notifier_block *notify_block, unsigned long mode, void *unused) { struct mmc_host *host = container_of( notify_block, struct mmc_host, pm_notify); unsigned long flags; int err = 0; switch (mode) { case PM_HIBERNATION_PREPARE: case PM_SUSPEND_PREPARE: if (host->card && mmc_card_mmc(host->card)) { mmc_claim_host(host); err = mmc_stop_bkops(host->card); mmc_release_host(host); if (err) { pr_err("%s: didn't stop bkops\n", mmc_hostname(host)); return err; } } spin_lock_irqsave(&host->lock, flags); if (mmc_bus_needs_resume(host)) { spin_unlock_irqrestore(&host->lock, flags); break; } host->rescan_disable = 1; spin_unlock_irqrestore(&host->lock, flags); if (cancel_delayed_work_sync(&host->detect)) wake_unlock(&host->detect_wake_lock); if (!host->bus_ops || host->bus_ops->suspend) break; /* Calling bus_ops->remove() with a claimed host can deadlock */ if (host->bus_ops->remove) host->bus_ops->remove(host); mmc_claim_host(host); mmc_detach_bus(host); mmc_power_off(host); mmc_release_host(host); host->pm_flags = 0; break; case PM_POST_SUSPEND: case PM_POST_HIBERNATION: case PM_POST_RESTORE: spin_lock_irqsave(&host->lock, flags); if (mmc_bus_manual_resume(host)) { spin_unlock_irqrestore(&host->lock, flags); break; } host->rescan_disable = 0; spin_unlock_irqrestore(&host->lock, flags); mmc_detect_change(host, 0); } return 0; } #endif #ifdef CONFIG_MMC_EMBEDDED_SDIO void mmc_set_embedded_sdio_data(struct mmc_host *host, struct sdio_cis *cis, struct sdio_cccr *cccr, struct sdio_embedded_func *funcs, int num_funcs) { host->embedded_sdio_data.cis = cis; host->embedded_sdio_data.cccr = cccr; host->embedded_sdio_data.funcs = funcs; host->embedded_sdio_data.num_funcs = num_funcs; } EXPORT_SYMBOL(mmc_set_embedded_sdio_data); #endif static int __init mmc_init(void) { int ret; workqueue = alloc_ordered_workqueue("kmmcd", 0); if (!workqueue) return -ENOMEM; ret = mmc_register_bus(); if (ret) goto destroy_workqueue; ret = mmc_register_host_class(); if (ret) goto unregister_bus; ret = sdio_register_bus(); if (ret) goto unregister_host_class; return 0; unregister_host_class: mmc_unregister_host_class(); unregister_bus: mmc_unregister_bus(); destroy_workqueue: destroy_workqueue(workqueue); return ret; } static void __exit mmc_exit(void) { sdio_unregister_bus(); mmc_unregister_host_class(); mmc_unregister_bus(); destroy_workqueue(workqueue); } subsys_initcall(mmc_init); module_exit(mmc_exit); MODULE_LICENSE("GPL");
VilleEvitaCake/android_kernel_htc_msm8960
drivers/mmc/core/core.c
C
gpl-2.0
80,989
var options={}; options.login=true; LoginRadius_SocialLogin.util.ready(function () { $ui = LoginRadius_SocialLogin.lr_login_settings; $ui.interfacesize = Drupal.settings.lrsociallogin.interfacesize; $ui.lrinterfacebackground=Drupal.settings.lrsociallogin.lrinterfacebackground; $ui.noofcolumns= Drupal.settings.lrsociallogin.noofcolumns; $ui.apikey = Drupal.settings.lrsociallogin.apikey; $ui.is_access_token=true; $ui.callback=Drupal.settings.lrsociallogin.location; $ui.lrinterfacecontainer ="interfacecontainerdiv"; LoginRadius_SocialLogin.init(options); }); LoginRadiusSDK.setLoginCallback(function () { var token = LoginRadiusSDK.getToken(); var form = document.createElement('form'); form.action = Drupal.settings.lrsociallogin.location; form.method = 'POST'; var hiddenToken = document.createElement('input'); hiddenToken.type = 'hidden'; hiddenToken.value = token; hiddenToken.name = 'token'; form.appendChild(hiddenToken); document.body.appendChild(form); form.submit(); });
bedesign323/aimhigh
sites/all/modules/contrib/sociallogin/js/sociallogin_interface.js
JavaScript
gpl-2.0
1,057
<?php namespace Drupal\materialize\Plugin\Setting\General\Tables; use Drupal\materialize\Annotation\MaterializeSetting; use Drupal\materialize\Plugin\Setting\SettingBase; use Drupal\Core\Annotation\Translation; /** * The "table_bordered" theme setting. * * @ingroup plugins_setting * * @MaterializeSetting( * id = "table_bordered", * type = "checkbox", * title = @Translation("Bordered table"), * description = @Translation("Add borders on all sides of the table and cells."), * defaultValue = 0, * groups = { * "general" = @Translation("General"), * "tables" = @Translation("Tables"), * }, * ) */ class TableBordered extends SettingBase {}
sunlight25/d8
web/themes/contrib/materialize/src/Plugin/Setting/General/Tables/TableBordered.php
PHP
gpl-2.0
682
package net.senmori.customtextures.events; import net.senmori.customtextures.util.MovementType; import org.bukkit.entity.Player; import org.bukkit.event.player.PlayerEvent; import com.sk89q.worldguard.protection.regions.ProtectedRegion; /** * event that is triggered after a player entered a WorldGuard region * @author mewin<[email protected]> */ public class RegionEnteredEvent extends RegionEvent { /** * creates a new RegionEnteredEvent * @param region the region the player entered * @param player the player who triggered the event * @param movement the type of movement how the player entered the region */ public RegionEnteredEvent(ProtectedRegion region, Player player, MovementType movement, PlayerEvent parent) { super(player, region, parent, movement); } }
Senmori/CustomTextures
src/main/java/net/senmori/customtextures/events/RegionEnteredEvent.java
Java
gpl-2.0
851
<?php /* * @package Joomla.Framework * @copyright Copyright (C) 2005 - 2010 Open Source Matters, Inc. All rights reserved. * @license GNU General Public License version 2 or later; see LICENSE.txt * * @component Phoca Component * @copyright Copyright (C) Jan Pavelka www.phoca.cz * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License version 2 or later; */ defined('_JEXEC') or die(); jimport('joomla.application.component.modeladmin'); phocagalleryimport('phocagallery.tag.tag'); class PhocaGalleryCpModelPhocaGalleryImg extends JModelAdmin { protected $option = 'com_phocagallery'; protected $text_prefix = 'com_phocagallery'; protected function canDelete($record) { $user = JFactory::getUser(); if ($record->catid) { return $user->authorise('core.delete', 'com_phocagallery.phocagalleryimg.'.(int) $record->catid); } else { return parent::canDelete($record); } } protected function canEditState($record) { $user = JFactory::getUser(); if ($record->catid) { return $user->authorise('core.edit.state', 'com_phocagallery.phocagalleryimg.'.(int) $record->catid); } else { return parent::canEditState($record); } } public function getTable($type = 'PhocaGallery', $prefix = 'Table', $config = array()) { return JTable::getInstance($type, $prefix, $config); } public function getForm($data = array(), $loadData = true) { $app = JFactory::getApplication(); $form = $this->loadForm('com_phocagallery.phocagalleryimg', 'phocagalleryimg', array('control' => 'jform', 'load_data' => $loadData)); if (empty($form)) { return false; } return $form; } protected function loadFormData() { // Check the session for previously entered form data. $data = JFactory::getApplication()->getUserState('com_phocagallery.edit.phocagallery.data', array()); if (empty($data)) { $data = $this->getItem(); } return $data; } public function getItem($pk = null) { if ($item = parent::getItem($pk)) { // Convert the params field to an array. $registry = new JRegistry; $registry->loadJSON($item->metadata); $item->metadata = $registry->toArray(); } return $item; } protected function prepareTable(&$table) { jimport('joomla.filter.output'); $date = JFactory::getDate(); $user = JFactory::getUser(); $table->title = htmlspecialchars_decode($table->title, ENT_QUOTES); $table->alias = JApplication::stringURLSafe($table->alias); if (empty($table->alias)) { $table->alias = JApplication::stringURLSafe($table->title); } if (empty($table->id)) { // Set the values //$table->created = $date->toMySQL(); // Set ordering to the last item if not set if (empty($table->ordering)) { $db = JFactory::getDbo(); $db->setQuery('SELECT MAX(ordering) FROM #__phocagallery WHERE catid = '.(int)$table->catid); $max = $db->loadResult(); $table->ordering = $max+1; } } else { // Set the values //$table->modified = $date->toMySQL(); //$table->modified_by = $user->get('id'); } } protected function getReorderConditions($table = null) { $condition = array(); $condition[] = 'catid = '. (int) $table->catid; //$condition[] = 'state >= 0'; return $condition; } function approve(&$pks, $value = 1) { // Initialise variables. $dispatcher = JDispatcher::getInstance(); $user = JFactory::getUser(); $table = $this->getTable('phocagallery'); $pks = (array) $pks; // Include the content plugins for the change of state event. JPluginHelper::importPlugin('content'); // Access checks. foreach ($pks as $i => $pk) { if ($table->load($pk)) { if (!$this->canEditState($table)) { // Prune items that you can't change. unset($pks[$i]); JError::raiseWarning(403, JText::_('JLIB_APPLICATION_ERROR_EDIT_STATE_NOT_PERMITTED')); } } } // Attempt to change the state of the records. if (!$table->approve($pks, $value, $user->get('id'))) { $this->setError($table->getError()); return false; } $context = $this->option.'.'.$this->name; // Trigger the onContentChangeState event. /*$result = $dispatcher->trigger($this->event_change_state, array($context, $pks, $value)); if (in_array(false, $result, true)) { $this->setError($table->getError()); return false; }*/ return true; } function save($data) { $params = &JComponentHelper::getParams( 'com_phocagallery' ); $clean_thumbnails = $params->get( 'clean_thumbnails', 0 ); $fileOriginalNotExist = 0; if ((int)$data['extid'] > 0) { $data['imgorigsize'] = 0; if ($data['title'] == '') { $data['title'] = 'External Image'; } } else { //If this file doesn't exists don't save it if (!PhocaGalleryFile::existsFileOriginal($data['filename'])) { //$this->setError('Original File does not exist'); //return false; $fileOriginalNotExist = 1; $errorMsg = JText::_('COM_PHOCAGALLERY_ORIGINAL_IMAGE_NOT_EXIST'); } $data['imgorigsize'] = PhocaGalleryFile::getFileSize($data['filename'], 0); //If there is no title and no alias, use filename as title and alias if ($data['title'] == '') { $data['title'] = PhocaGalleryFile::getTitleFromFile($data['filename']); } } if ($data['extlink1link'] != '') { $extlink1 = str_replace('http://','', $data['extlink1link']); $data['extlink1'] = $extlink1 . '|'.$data['extlink1title'].'|'.$data['extlink1target'].'|'.$data['extlink1icon']; } else { $data['extlink1'] = $data['extlink1link'] . '|'.$data['extlink1title'].'|'.$data['extlink1target'].'|'.$data['extlink1icon']; } if ($data['extlink2link'] != '') { $extlink2 = str_replace('http://','', $data['extlink2link']); $data['extlink2'] = $extlink2 . '|'.$data['extlink2title'].'|'.$data['extlink2target'].'|'.$data['extlink2icon']; } else { $data['extlink2'] = $data['extlink2link'] . '|'.$data['extlink2title'].'|'.$data['extlink2target'].'|'.$data['extlink2icon']; } // Geo if($data['longitude'] == '' || $data['latitude'] == '') { phocagalleryimport('phocagallery.geo.geo'); $coords = PhocaGalleryGeo::getGeoCoords($data['filename']); if ($data['longitude'] == '' ){ $data['longitude'] = $coords['longitude']; } if ($data['latitude'] == '' ){ $data['latitude'] = $coords['latitude']; } if ($data['latitude'] != '' && $data['longitude'] != '' && $data['zoom'] == ''){ $data['zoom'] = PhocaGallerySettings::getAdvancedSettings('geozoom'); } } if ($data['alias'] == '') { $data['alias'] = $data['title']; } //clean alias name (no bad characters) //$data['alias'] = PhocaGalleryText::getAliasName($data['alias']); // if new item, order last in appropriate group //if (!$row->id) { // $where = 'catid = ' . (int) $row->catid ; // $row->ordering = $row->getNextOrder( $where ); //} // = = = = = = = = = = // Initialise variables; $dispatcher = JDispatcher::getInstance(); $table = $this->getTable(); $pk = (!empty($data['id'])) ? $data['id'] : (int)$this->getState($this->getName().'.id'); $isNew = true; // Include the content plugins for the on save events. JPluginHelper::importPlugin('content'); // Load the row if saving an existing record. if ($pk > 0) { $table->load($pk); $isNew = false; } // Bind the data. if (!$table->bind($data)) { $this->setError($table->getError()); return false; } if(intval($table->date) == 0) { $table->date = JFactory::getDate()->toMySQL(); } // Prepare the row for saving $this->prepareTable($table); // Check the data. if (!$table->check()) { $this->setError($table->getError()); return false; } // Trigger the onContentBeforeSave event. /*$result = $dispatcher->trigger($this->event_before_save, array($this->option.'.'.$this->name, $table, $isNew)); if (in_array(false, $result, true)) { $this->setError($table->getError()); return false; }*/ // Store the data. if (!$table->store()) { $this->setError($table->getError()); return false; } // Store to ref table if (!isset($data['tags'])) { $data['tags'] = array(); } if ((int)$table->id > 0) { PhocaGalleryTag::storeTags($data['tags'], (int)$table->id); } // Clean the cache. $cache = JFactory::getCache($this->option); $cache->clean(); // Trigger the onContentAfterSave event. //$dispatcher->trigger($this->event_after_save, array($this->option.'.'.$this->name, $table, $isNew)); $pkName = $table->getKeyName(); if (isset($table->$pkName)) { $this->setState($this->getName().'.id', $table->$pkName); } $this->setState($this->getName().'.new', $isNew); // = = = = = = $task = JRequest::getVar('task'); if (isset($table->$pkName)) { $id = $table->$pkName; } if ((int)$data['extid'] > 0 || $fileOriginalNotExist == 1) { } else { // - - - - - - - - - - - - - - - - - - //Create thumbnail small, medium, large //file - abc.img, file_no - folder/abc.img //Get folder variables from Helper //Create thumbnails small, medium, large $refresh_url = 'index.php?option=com_phocagallery&task=phocagalleryimg.thumbs'; $task = JRequest::getVar('task'); if (isset($table->$pkName) && $task == 'apply') { $id = $table->$pkName; $refresh_url = 'index.php?option=com_phocagallery&task=phocagalleryimg.edit&id='.(int)$id; } if ($task = 'save2new') { // Don't create automatically thumbnails in case, we are going to add new image } else { $file_thumb = PhocaGalleryFileThumbnail::getOrCreateThumbnail($data['filename'], $refresh_url, 1, 1, 1); } //Clean Thumbs Folder if there are thumbnail files but not original file if ($clean_thumbnails == 1) { phocagalleryimport('phocagallery.file.filefolder'); PhocaGalleryFileFolder::cleanThumbsFolder(); } // - - - - - - - - - - - - - - - - - - - - - } return true; } function delete($cid = array()) { $params = &JComponentHelper::getParams( 'com_phocagallery' ); $clean_thumbnails = $params->get( 'clean_thumbnails', 0 ); $result = false; if (count( $cid )) { JArrayHelper::toInteger($cid); $cids = implode( ',', $cid ); // - - - - - - - - - - - - - // Get all filenames we want to delete from database, we delete all thumbnails from server of this file $queryd = 'SELECT filename as filename FROM #__phocagallery WHERE id IN ( '.$cids.' )'; $this->_db->setQuery($queryd); $fileObject = $this->_db->loadObjectList(); // - - - - - - - - - - - - - //Delete it from DB $query = 'DELETE FROM #__phocagallery' . ' WHERE id IN ( '.$cids.' )'; $this->_db->setQuery( $query ); if(!$this->_db->query()) { $this->setError($this->_db->getErrorMsg()); return false; } // - - - - - - - - - - - - - - // Delete thumbnails - medium and large, small from server // All id we want to delete - gel all filenames foreach ($fileObject as $key => $value) { //The file can be stored in other category - don't delete it from server because other category use it $querys = "SELECT id as id FROM #__phocagallery WHERE filename='".$value->filename."' "; $this->_db->setQuery($queryd); $sameFileObject = $this->_db->loadObject(); // same file in other category doesn't exist - we can delete it if (!$sameFileObject) { PhocaGalleryFileThumbnail::deleteFileThumbnail($value->filename, 1, 1, 1); } } // Clean Thumbs Folder if there are thumbnail files but not original file if ($clean_thumbnails == 1) { phocagalleryimport('phocagallery.file.filefolder'); PhocaGalleryFileFolder::cleanThumbsFolder(); } // - - - - - - - - - - - - - - } return true; } function recreate($cid = array(), &$message) { if (count( $cid )) { JArrayHelper::toInteger($cid); $cids = implode( ',', $cid ); $query = 'SELECT a.filename, a.extid'. ' FROM #__phocagallery AS a' . ' WHERE a.id IN ( '.$cids.' )'; $this->_db->setQuery($query); $files = $this->_db->loadObjectList(); if (isset($files) && count($files)) { foreach($files as $key => $value) { if (isset($value->extid) && ((int)$value->extid > 0)) { // Picasa cannot be recreated $message = JText::_('COM_PHOCAGALLERY_ERROR_EXT_IMG_NOT_RECREATE'); return false; } else if (isset($value->filename) && $value->filename != '') { $original = PhocaGalleryFile::existsFileOriginal($value->filename); if (!$original) { // Original does not exist - cannot generate new thumbnail $message = JText::_('COM_PHOCAGALLERY_FILEORIGINAL_NOT_EXISTS'); return false; } // Delete old thumbnails $deleteThubms = PhocaGalleryFileThumbnail::deleteFileThumbnail($value->filename, 1, 1, 1); } else { $message = JText::_('COM_PHOCAGALLERY_FILENAME_NOT_EXISTS'); return false; } if (!$deleteThubms) { $message = JText::_('COM_PHOCAGALLERY_ERROR_DELETE_THUMBNAIL'); return false; } } } else { $message = JText::_('COM_PHOCAGALLERY_ERROR_LOADING_DATA_DB'); return false; } } else { $message = JText::_('COM_PHOCAGALLERY_ERROR_ITEM_NOT_SELECTED'); return false; } return true; } /* function deletethumbs($id) { if ($id > 0) { $query = 'SELECT a.filename as filename'. ' FROM #__phocagallery AS a' . ' WHERE a.id = '.(int) $id; $this->_db->setQuery($query); $file = $this->_db->loadObject(); if (isset($file->filename) && $file->filename != '') { $deleteThubms = PhocaGalleryFileThumbnail::deleteFileThumbnail($file->filename, 1, 1, 1); if ($deleteThubms) { return true; } else { return false; } } return false; } return false; }*/ public function disableThumbs() { $component = 'com_phocagallery'; $paramsC = JComponentHelper::getParams($component) ; $paramsC->setValue('enable_thumb_creation', 0); $data['params'] = $paramsC->toArray(); $table = JTable::getInstance('extension'); $idCom = $table->find( array('element' => $component )); $table->load($idCom); if (!$table->bind($data)) { JError::raiseWarning( 500, 'Not a valid component' ); return false; } // pre-save checks if (!$table->check()) { JError::raiseWarning( 500, $table->getError('Check Problem') ); return false; } // save the changes if (!$table->store()) { JError::raiseWarning( 500, $table->getError('Store Problem') ); return false; } return true; } function rotate($id, $angle, &$errorMsg) { phocagalleryimport('phocagallery.image.imagerotate'); if ($id > 0 && $angle !='') { $query = 'SELECT a.filename as filename'. ' FROM #__phocagallery AS a' . ' WHERE a.id = '.(int) $id; $this->_db->setQuery($query); $file = $this->_db->loadObject(); if (isset($file->filename) && $file->filename != '') { $thumbNameL = PhocaGalleryFileThumbnail::getThumbnailName ($file->filename, 'large'); $thumbNameM = PhocaGalleryFileThumbnail::getThumbnailName ($file->filename, 'medium'); $thumbNameS = PhocaGalleryFileThumbnail::getThumbnailName ($file->filename, 'small'); $errorMsg = $errorMsgS = $errorMsgM = $errorMsgL =''; PhocaGalleryImageRotate::rotateImage($thumbNameL, 'large', $angle, $errorMsgS); if ($errorMsgS != '') { $errorMsg = $errorMsgS; return false; } PhocaGalleryImageRotate::rotateImage($thumbNameM, 'medium', $angle, $errorMsgM); if ($errorMsgM != '') { $errorMsg = $errorMsgM; return false; } PhocaGalleryImageRotate::rotateImage($thumbNameS, 'small', $angle, $errorMsgL); if ($errorMsgL != '') { $errorMsg = $errorMsgL; return false; } if ($errorMsgL == '' && $errorMsgM == '' && $errorMsgS == '' ) { return true; } else { $errorMsg = ' ('.$errorMsg.')'; return false; } } $errorMsg = JText::_('COM_PHOCAGALLERY_FILENAME_NOT_EXISTS'); return false; } $errorMsg = JText::_('COM_PHOCAGALLERY_ERROR_ITEM_NOT_SELECTED'); return false; } function deletethumbs($id) { if ($id > 0) { $query = 'SELECT a.filename as filename'. ' FROM #__phocagallery AS a' . ' WHERE a.id = '.(int) $id; $this->_db->setQuery($query); $file = $this->_db->loadObject(); if (isset($file->filename) && $file->filename != '') { $deleteThubms = PhocaGalleryFileThumbnail::deleteFileThumbnail($file->filename, 1, 1, 1); if ($deleteThubms) { return true; } else { return false; } } return false; } return false; } protected function batchCopy($value, $pks, $contexts) { $categoryId = (int) $value; $table = $this->getTable(); $db = $this->getDbo(); // Check that the category exists if ($categoryId) { $categoryTable = JTable::getInstance('PhocaGalleryC', 'Table'); if (!$categoryTable->load($categoryId)) { if ($error = $categoryTable->getError()) { // Fatal error $this->setError($error); return false; } else { $this->setError(JText::_('JLIB_APPLICATION_ERROR_BATCH_MOVE_CATEGORY_NOT_FOUND')); return false; } } } if (empty($categoryId)) { $this->setError(JText::_('JLIB_APPLICATION_ERROR_BATCH_MOVE_CATEGORY_NOT_FOUND')); return false; } // Check that the user has create permission for the component $extension = JRequest::getCmd('option'); $user = JFactory::getUser(); if (!$user->authorise('core.create', $extension)) { $this->setError(JText::_('JLIB_APPLICATION_ERROR_BATCH_CANNOT_CREATE')); return false; } //NEW $i = 0; //ENDNEW // Parent exists so we let's proceed while (!empty($pks)) { // Pop the first ID off the stack $pk = array_shift($pks); $table->reset(); // Check that the row actually exists if (!$table->load($pk)) { if ($error = $table->getError()) { // Fatal error $this->setError($error); return false; } else { // Not fatal error $this->setError(JText::sprintf('JLIB_APPLICATION_ERROR_BATCH_MOVE_ROW_NOT_FOUND', $pk)); continue; } } // Alter the title & alias $data = $this->generateNewTitle($categoryId, $table->alias, $table->title); $table->title = $data['0']; $table->alias = $data['1']; // Reset the ID because we are making a copy $table->id = 0; // New category ID $table->catid = $categoryId; // Ordering $table->ordering = $this->increaseOrdering($categoryId); $table->hits = 0; // Check the row. if (!$table->check()) { $this->setError($table->getError()); return false; } // Store the row. if (!$table->store()) { $this->setError($table->getError()); return false; } //NEW // Get the new item ID $newId = $table->get('id'); // Add the new ID to the array $newIds[$i] = $newId; $i++; //ENDNEW } // Clean the cache $this->cleanCache(); //NEW return $newIds; //END NEW } /** * Batch move articles to a new category * * @param integer $value The new category ID. * @param array $pks An array of row IDs. * * @return booelan True if successful, false otherwise and internal error is set. * * @since 11.1 */ protected function batchMove($value, $pks, $contexts) { $categoryId = (int) $value; $table = $this->getTable(); //$db = $this->getDbo(); // Check that the category exists if ($categoryId) { $categoryTable = JTable::getInstance('PhocaGalleryC', 'Table'); if (!$categoryTable->load($categoryId)) { if ($error = $categoryTable->getError()) { // Fatal error $this->setError($error); return false; } else { $this->setError(JText::_('JLIB_APPLICATION_ERROR_BATCH_MOVE_CATEGORY_NOT_FOUND')); return false; } } } if (empty($categoryId)) { $this->setError(JText::_('JLIB_APPLICATION_ERROR_BATCH_MOVE_CATEGORY_NOT_FOUND')); return false; } // Check that user has create and edit permission for the component $extension = JRequest::getCmd('option'); $user = JFactory::getUser(); if (!$user->authorise('core.create', $extension)) { $this->setError(JText::_('JLIB_APPLICATION_ERROR_BATCH_CANNOT_CREATE')); return false; } if (!$user->authorise('core.edit', $extension)) { $this->setError(JText::_('JLIB_APPLICATION_ERROR_BATCH_CANNOT_EDIT')); return false; } // Parent exists so we let's proceed foreach ($pks as $pk) { // Check that the row actually exists if (!$table->load($pk)) { if ($error = $table->getError()) { // Fatal error $this->setError($error); return false; } else { // Not fatal error $this->setError(JText::sprintf('JLIB_APPLICATION_ERROR_BATCH_MOVE_ROW_NOT_FOUND', $pk)); continue; } } // Set the new category ID $table->catid = $categoryId; // Check the row. if (!$table->check()) { $this->setError($table->getError()); return false; } // Store the row. if (!$table->store()) { $this->setError($table->getError()); return false; } } // Clean the cache $this->cleanCache(); return true; } protected function batchTag($value, $pks, $contexts) { foreach ($value as $categoryId){ foreach ($pks as $pk) { $query = 'DELETE FROM #__phocagallery_tags_ref' . ' WHERE imgid ='.$pk .' and tagid = '.$categoryId; $this->_db->setQuery( $query ); if(!$this->_db->query()) { $this->setError($this->_db->getErrorMsg()); return false; } $query = 'insert into #__phocagallery_tags_ref(imgid,tagid) values(' . $pk .', '.$categoryId.')'; $this->_db->setQuery( $query ); if(!$this->_db->query()) { $this->setError($this->_db->getErrorMsg()); return false; } } } return true; } public function increaseOrdering($categoryId) { $ordering = 1; $this->_db->setQuery('SELECT MAX(ordering) FROM #__phocagallery WHERE catid='.(int)$categoryId); $max = $this->_db->loadResult(); $ordering = $max + 1; return $ordering; } } ?>
LuxitoHD/mmall-chen
administrator/components/com_phocagallery/models/phocagalleryimg.php
PHP
gpl-2.0
22,198
#include "config.h" #include <arki/tests/tests.h> #include <arki/iotrace.h> namespace { using namespace std; using namespace arki; using namespace arki::tests; class Tests : public TestCase { using TestCase::TestCase; void register_tests() override; } test("arki_iotrace"); void Tests::register_tests() { add_method("empty", [] { }); } }
ARPA-SIMC/arkimet
arki/iotrace-test.cc
C++
gpl-2.0
353
<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <title>widget-locale - YUI 3</title> <link rel="stylesheet" href="http:&#x2F;&#x2F;yui.yahooapis.com&#x2F;3.5.0pr4&#x2F;build&#x2F;cssgrids&#x2F;cssgrids-min.css"> <link rel="stylesheet" href="..&#x2F;assets/vendor/prettify/prettify-min.css"> <link rel="stylesheet" href="..&#x2F;assets/css/main.css" id="site_styles"> <script src="http:&#x2F;&#x2F;yui.yahooapis.com&#x2F;3.5.0pr4&#x2F;build&#x2F;yui&#x2F;yui-min.js"></script> </head> <body class="yui3-skin-sam"> <div id="doc"> <div id="hd" class="yui3-g header"> <div class="yui3-u-3-4"> <h1><img src="..&#x2F;assets/css/logo.png" title="YUI 3"></h1> </div> <div class="yui3-u-1-4 version"> <em>API Docs for: 3.5.0</em> </div> </div> <div id="bd" class="yui3-g"> <div class="yui3-u-1-4"> <div id="docs-sidebar" class="sidebar apidocs"> <div id="api-list"> <h2 class="off-left">APIs</h2> <div id="api-tabview" class="tabview"> <ul class="tabs"> <li><a href="#api-classes">Classes</a></li> <li><a href="#api-modules">Modules</a></li> </ul> <div id="api-tabview-filter"> <input type="search" id="api-filter" placeholder="Type to filter APIs"> </div> <div id="api-tabview-panel"> <ul id="api-classes" class="apis classes"> <li><a href="..&#x2F;classes/Anim.html">Anim</a></li> <li><a href="..&#x2F;classes/App.html">App</a></li> <li><a href="..&#x2F;classes/App.Base.html">App.Base</a></li> <li><a href="..&#x2F;classes/App.Transitions.html">App.Transitions</a></li> <li><a href="..&#x2F;classes/App.TransitionsNative.html">App.TransitionsNative</a></li> <li><a href="..&#x2F;classes/AreaSeries.html">AreaSeries</a></li> <li><a href="..&#x2F;classes/AreaSplineSeries.html">AreaSplineSeries</a></li> <li><a href="..&#x2F;classes/Array.html">Array</a></li> <li><a href="..&#x2F;classes/ArrayList.html">ArrayList</a></li> <li><a href="..&#x2F;classes/ArraySort.html">ArraySort</a></li> <li><a href="..&#x2F;classes/AsyncQueue.html">AsyncQueue</a></li> <li><a href="..&#x2F;classes/Attribute.html">Attribute</a></li> <li><a href="..&#x2F;classes/AttributeCore.html">AttributeCore</a></li> <li><a href="..&#x2F;classes/AttributeEvents.html">AttributeEvents</a></li> <li><a href="..&#x2F;classes/AttributeExtras.html">AttributeExtras</a></li> <li><a href="..&#x2F;classes/AttributeLite.html">AttributeLite</a></li> <li><a href="..&#x2F;classes/AutoComplete.html">AutoComplete</a></li> <li><a href="..&#x2F;classes/AutoCompleteBase.html">AutoCompleteBase</a></li> <li><a href="..&#x2F;classes/AutoCompleteFilters.html">AutoCompleteFilters</a></li> <li><a href="..&#x2F;classes/AutoCompleteHighlighters.html">AutoCompleteHighlighters</a></li> <li><a href="..&#x2F;classes/AutoCompleteList.html">AutoCompleteList</a></li> <li><a href="..&#x2F;classes/Axis.html">Axis</a></li> <li><a href="..&#x2F;classes/AxisType.html">AxisType</a></li> <li><a href="..&#x2F;classes/BarSeries.html">BarSeries</a></li> <li><a href="..&#x2F;classes/Base.html">Base</a></li> <li><a href="..&#x2F;classes/BaseCore.html">BaseCore</a></li> <li><a href="..&#x2F;classes/BottomAxisLayout.html">BottomAxisLayout</a></li> <li><a href="..&#x2F;classes/Button.html">Button</a></li> <li><a href="..&#x2F;classes/ButtonCore.html">ButtonCore</a></li> <li><a href="..&#x2F;classes/ButtonGroup.html">ButtonGroup</a></li> <li><a href="..&#x2F;classes/ButtonPlugin.html">ButtonPlugin</a></li> <li><a href="..&#x2F;classes/Cache.html">Cache</a></li> <li><a href="..&#x2F;classes/CacheOffline.html">CacheOffline</a></li> <li><a href="..&#x2F;classes/Calendar.html">Calendar</a></li> <li><a href="..&#x2F;classes/CalendarBase.html">CalendarBase</a></li> <li><a href="..&#x2F;classes/CanvasCircle.html">CanvasCircle</a></li> <li><a href="..&#x2F;classes/CanvasDrawing.html">CanvasDrawing</a></li> <li><a href="..&#x2F;classes/CanvasEllipse.html">CanvasEllipse</a></li> <li><a href="..&#x2F;classes/CanvasGraphic.html">CanvasGraphic</a></li> <li><a href="..&#x2F;classes/CanvasPath.html">CanvasPath</a></li> <li><a href="..&#x2F;classes/CanvasPieSlice.html">CanvasPieSlice</a></li> <li><a href="..&#x2F;classes/CanvasRect.html">CanvasRect</a></li> <li><a href="..&#x2F;classes/CanvasShape.html">CanvasShape</a></li> <li><a href="..&#x2F;classes/CartesianChart.html">CartesianChart</a></li> <li><a href="..&#x2F;classes/CartesianSeries.html">CartesianSeries</a></li> <li><a href="..&#x2F;classes/CategoryAxis.html">CategoryAxis</a></li> <li><a href="..&#x2F;classes/Chart.html">Chart</a></li> <li><a href="..&#x2F;classes/ChartBase.html">ChartBase</a></li> <li><a href="..&#x2F;classes/ChartLegend.html">ChartLegend</a></li> <li><a href="..&#x2F;classes/Circle.html">Circle</a></li> <li><a href="..&#x2F;classes/ClassNameManager.html">ClassNameManager</a></li> <li><a href="..&#x2F;classes/ClickableRail.html">ClickableRail</a></li> <li><a href="..&#x2F;classes/ColumnSeries.html">ColumnSeries</a></li> <li><a href="..&#x2F;classes/ComboSeries.html">ComboSeries</a></li> <li><a href="..&#x2F;classes/ComboSplineSeries.html">ComboSplineSeries</a></li> <li><a href="..&#x2F;classes/config.html">config</a></li> <li><a href="..&#x2F;classes/Console.html">Console</a></li> <li><a href="..&#x2F;classes/Controller.html">Controller</a></li> <li><a href="..&#x2F;classes/Cookie.html">Cookie</a></li> <li><a href="..&#x2F;classes/CurveUtil.html">CurveUtil</a></li> <li><a href="..&#x2F;classes/CustomEvent.html">CustomEvent</a></li> <li><a href="..&#x2F;classes/DataSchema.Array.html">DataSchema.Array</a></li> <li><a href="..&#x2F;classes/DataSchema.Base.html">DataSchema.Base</a></li> <li><a href="..&#x2F;classes/DataSchema.JSON.html">DataSchema.JSON</a></li> <li><a href="..&#x2F;classes/DataSchema.Text.html">DataSchema.Text</a></li> <li><a href="..&#x2F;classes/DataSchema.XML.html">DataSchema.XML</a></li> <li><a href="..&#x2F;classes/DataSource.Function.html">DataSource.Function</a></li> <li><a href="..&#x2F;classes/DataSource.Get.html">DataSource.Get</a></li> <li><a href="..&#x2F;classes/DataSource.IO.html">DataSource.IO</a></li> <li><a href="..&#x2F;classes/DataSource.Local.html">DataSource.Local</a></li> <li><a href="..&#x2F;classes/DataSourceArraySchema.html">DataSourceArraySchema</a></li> <li><a href="..&#x2F;classes/DataSourceCache.html">DataSourceCache</a></li> <li><a href="..&#x2F;classes/DataSourceCacheExtension.html">DataSourceCacheExtension</a></li> <li><a href="..&#x2F;classes/DataSourceJSONSchema.html">DataSourceJSONSchema</a></li> <li><a href="..&#x2F;classes/DataSourceTextSchema.html">DataSourceTextSchema</a></li> <li><a href="..&#x2F;classes/DataSourceXMLSchema.html">DataSourceXMLSchema</a></li> <li><a href="..&#x2F;classes/DataTable.html">DataTable</a></li> <li><a href="..&#x2F;classes/DataTable.Base.html">DataTable.Base</a></li> <li><a href="..&#x2F;classes/DataTable.BodyView.html">DataTable.BodyView</a></li> <li><a href="..&#x2F;classes/DataTable.ColumnWidths.html">DataTable.ColumnWidths</a></li> <li><a href="..&#x2F;classes/DataTable.Core.html">DataTable.Core</a></li> <li><a href="..&#x2F;classes/DataTable.HeaderView.html">DataTable.HeaderView</a></li> <li><a href="..&#x2F;classes/DataTable.Message.html">DataTable.Message</a></li> <li><a href="..&#x2F;classes/DataTable.Mutable.html">DataTable.Mutable</a></li> <li><a href="..&#x2F;classes/DataTable.Scrollable.html">DataTable.Scrollable</a></li> <li><a href="..&#x2F;classes/DataTable.Sortable.html">DataTable.Sortable</a></li> <li><a href="..&#x2F;classes/DataType.Date.html">DataType.Date</a></li> <li><a href="..&#x2F;classes/DataType.Date.Locale.html">DataType.Date.Locale</a></li> <li><a href="..&#x2F;classes/DataType.Number.html">DataType.Number</a></li> <li><a href="..&#x2F;classes/DataType.XML.html">DataType.XML</a></li> <li><a href="..&#x2F;classes/DD.DDM.html">DD.DDM</a></li> <li><a href="..&#x2F;classes/DD.Delegate.html">DD.Delegate</a></li> <li><a href="..&#x2F;classes/DD.Drag.html">DD.Drag</a></li> <li><a href="..&#x2F;classes/DD.Drop.html">DD.Drop</a></li> <li><a href="..&#x2F;classes/DD.Plugin.DDWindowScroll.html">DD.Plugin.DDWindowScroll</a></li> <li><a href="..&#x2F;classes/DD.Scroll.html">DD.Scroll</a></li> <li><a href="..&#x2F;classes/Dial.html">Dial</a></li> <li><a href="..&#x2F;classes/Do.html">Do</a></li> <li><a href="..&#x2F;classes/Do.AlterArgs.html">Do.AlterArgs</a></li> <li><a href="..&#x2F;classes/Do.AlterReturn.html">Do.AlterReturn</a></li> <li><a href="..&#x2F;classes/Do.Error.html">Do.Error</a></li> <li><a href="..&#x2F;classes/Do.Halt.html">Do.Halt</a></li> <li><a href="..&#x2F;classes/Do.Method.html">Do.Method</a></li> <li><a href="..&#x2F;classes/Do.Prevent.html">Do.Prevent</a></li> <li><a href="..&#x2F;classes/DOM.html">DOM</a></li> <li><a href="..&#x2F;classes/DOMEventFacade.html">DOMEventFacade</a></li> <li><a href="..&#x2F;classes/Drawing.html">Drawing</a></li> <li><a href="..&#x2F;classes/Easing.html">Easing</a></li> <li><a href="..&#x2F;classes/EditorBase.html">EditorBase</a></li> <li><a href="..&#x2F;classes/EditorSelection.html">EditorSelection</a></li> <li><a href="..&#x2F;classes/Ellipse.html">Ellipse</a></li> <li><a href="..&#x2F;classes/EllipseGroup.html">EllipseGroup</a></li> <li><a href="..&#x2F;classes/Escape.html">Escape</a></li> <li><a href="..&#x2F;classes/Event.html">Event</a></li> <li><a href="..&#x2F;classes/EventFacade.html">EventFacade</a></li> <li><a href="..&#x2F;classes/EventHandle.html">EventHandle</a></li> <li><a href="..&#x2F;classes/EventTarget.html">EventTarget</a></li> <li><a href="..&#x2F;classes/ExecCommand.html">ExecCommand</a></li> <li><a href="..&#x2F;classes/Features.html">Features</a></li> <li><a href="..&#x2F;classes/File.html">File</a></li> <li><a href="..&#x2F;classes/FileFlash.html">FileFlash</a></li> <li><a href="..&#x2F;classes/FileHTML5.html">FileHTML5</a></li> <li><a href="..&#x2F;classes/Fills.html">Fills</a></li> <li><a href="..&#x2F;classes/Frame.html">Frame</a></li> <li><a href="..&#x2F;classes/Get.html">Get</a></li> <li><a href="..&#x2F;classes/Get.Transaction.html">Get.Transaction</a></li> <li><a href="..&#x2F;classes/GetNodeJS.html">GetNodeJS</a></li> <li><a href="..&#x2F;classes/Graph.html">Graph</a></li> <li><a href="..&#x2F;classes/Graphic.html">Graphic</a></li> <li><a href="..&#x2F;classes/GraphicBase.html">GraphicBase</a></li> <li><a href="..&#x2F;classes/Gridlines.html">Gridlines</a></li> <li><a href="..&#x2F;classes/GroupCircle.html">GroupCircle</a></li> <li><a href="..&#x2F;classes/GroupDiamond.html">GroupDiamond</a></li> <li><a href="..&#x2F;classes/GroupRect.html">GroupRect</a></li> <li><a href="..&#x2F;classes/Handlebars.html">Handlebars</a></li> <li><a href="..&#x2F;classes/Highlight.html">Highlight</a></li> <li><a href="..&#x2F;classes/Histogram.html">Histogram</a></li> <li><a href="..&#x2F;classes/HistoryBase.html">HistoryBase</a></li> <li><a href="..&#x2F;classes/HistoryHash.html">HistoryHash</a></li> <li><a href="..&#x2F;classes/HistoryHTML5.html">HistoryHTML5</a></li> <li><a href="..&#x2F;classes/HorizontalLegendLayout.html">HorizontalLegendLayout</a></li> <li><a href="..&#x2F;classes/ImgLoadGroup.html">ImgLoadGroup</a></li> <li><a href="..&#x2F;classes/ImgLoadImgObj.html">ImgLoadImgObj</a></li> <li><a href="..&#x2F;classes/Intl.html">Intl</a></li> <li><a href="..&#x2F;classes/IO.html">IO</a></li> <li><a href="..&#x2F;classes/json.html">json</a></li> <li><a href="..&#x2F;classes/JSONPRequest.html">JSONPRequest</a></li> <li><a href="..&#x2F;classes/Lang.html">Lang</a></li> <li><a href="..&#x2F;classes/LeftAxisLayout.html">LeftAxisLayout</a></li> <li><a href="..&#x2F;classes/Lines.html">Lines</a></li> <li><a href="..&#x2F;classes/LineSeries.html">LineSeries</a></li> <li><a href="..&#x2F;classes/Loader.html">Loader</a></li> <li><a href="..&#x2F;classes/MarkerSeries.html">MarkerSeries</a></li> <li><a href="..&#x2F;classes/Matrix.html">Matrix</a></li> <li><a href="..&#x2F;classes/Model.html">Model</a></li> <li><a href="..&#x2F;classes/ModelList.html">ModelList</a></li> <li><a href="..&#x2F;classes/Node.html">Node</a></li> <li><a href="..&#x2F;classes/NodeList.html">NodeList</a></li> <li><a href="..&#x2F;classes/NumericAxis.html">NumericAxis</a></li> <li><a href="..&#x2F;classes/Object.html">Object</a></li> <li><a href="..&#x2F;classes/Overlay.html">Overlay</a></li> <li><a href="..&#x2F;classes/Panel.html">Panel</a></li> <li><a href="..&#x2F;classes/Parallel.html">Parallel</a></li> <li><a href="..&#x2F;classes/Path.html">Path</a></li> <li><a href="..&#x2F;classes/PieChart.html">PieChart</a></li> <li><a href="..&#x2F;classes/PieSeries.html">PieSeries</a></li> <li><a href="..&#x2F;classes/Pjax.html">Pjax</a></li> <li><a href="..&#x2F;classes/PjaxBase.html">PjaxBase</a></li> <li><a href="..&#x2F;classes/Plots.html">Plots</a></li> <li><a href="..&#x2F;classes/Plugin.Align.html">Plugin.Align</a></li> <li><a href="..&#x2F;classes/Plugin.AutoComplete.html">Plugin.AutoComplete</a></li> <li><a href="..&#x2F;classes/Plugin.Base.html">Plugin.Base</a></li> <li><a href="..&#x2F;classes/Plugin.Cache.html">Plugin.Cache</a></li> <li><a href="..&#x2F;classes/Plugin.CalendarNavigator.html">Plugin.CalendarNavigator</a></li> <li><a href="..&#x2F;classes/Plugin.ConsoleFilters.html">Plugin.ConsoleFilters</a></li> <li><a href="..&#x2F;classes/Plugin.CreateLinkBase.html">Plugin.CreateLinkBase</a></li> <li><a href="..&#x2F;classes/Plugin.DataTableDataSource.html">Plugin.DataTableDataSource</a></li> <li><a href="..&#x2F;classes/Plugin.DDConstrained.html">Plugin.DDConstrained</a></li> <li><a href="..&#x2F;classes/Plugin.DDNodeScroll.html">Plugin.DDNodeScroll</a></li> <li><a href="..&#x2F;classes/Plugin.DDProxy.html">Plugin.DDProxy</a></li> <li><a href="..&#x2F;classes/Plugin.Drag.html">Plugin.Drag</a></li> <li><a href="..&#x2F;classes/Plugin.Drop.html">Plugin.Drop</a></li> <li><a href="..&#x2F;classes/Plugin.EditorBidi.html">Plugin.EditorBidi</a></li> <li><a href="..&#x2F;classes/Plugin.EditorBR.html">Plugin.EditorBR</a></li> <li><a href="..&#x2F;classes/Plugin.EditorLists.html">Plugin.EditorLists</a></li> <li><a href="..&#x2F;classes/Plugin.EditorPara.html">Plugin.EditorPara</a></li> <li><a href="..&#x2F;classes/Plugin.EditorParaBase.html">Plugin.EditorParaBase</a></li> <li><a href="..&#x2F;classes/Plugin.EditorParaIE.html">Plugin.EditorParaIE</a></li> <li><a href="..&#x2F;classes/Plugin.EditorTab.html">Plugin.EditorTab</a></li> <li><a href="..&#x2F;classes/Plugin.ExecCommand.html">Plugin.ExecCommand</a></li> <li><a href="..&#x2F;classes/Plugin.Flick.html">Plugin.Flick</a></li> <li><a href="..&#x2F;classes/Plugin.Host.html">Plugin.Host</a></li> <li><a href="..&#x2F;classes/plugin.NodeFocusManager.html">plugin.NodeFocusManager</a></li> <li><a href="..&#x2F;classes/Plugin.NodeFX.html">Plugin.NodeFX</a></li> <li><a href="..&#x2F;classes/plugin.NodeMenuNav.html">plugin.NodeMenuNav</a></li> <li><a href="..&#x2F;classes/Plugin.Pjax.html">Plugin.Pjax</a></li> <li><a href="..&#x2F;classes/Plugin.Resize.html">Plugin.Resize</a></li> <li><a href="..&#x2F;classes/Plugin.ResizeConstrained.html">Plugin.ResizeConstrained</a></li> <li><a href="..&#x2F;classes/Plugin.ResizeProxy.html">Plugin.ResizeProxy</a></li> <li><a href="..&#x2F;classes/Plugin.ScrollViewList.html">Plugin.ScrollViewList</a></li> <li><a href="..&#x2F;classes/Plugin.ScrollViewPaginator.html">Plugin.ScrollViewPaginator</a></li> <li><a href="..&#x2F;classes/Plugin.ScrollViewScrollbars.html">Plugin.ScrollViewScrollbars</a></li> <li><a href="..&#x2F;classes/Plugin.Shim.html">Plugin.Shim</a></li> <li><a href="..&#x2F;classes/Plugin.SortScroll.html">Plugin.SortScroll</a></li> <li><a href="..&#x2F;classes/Plugin.WidgetAnim.html">Plugin.WidgetAnim</a></li> <li><a href="..&#x2F;classes/Pollable.html">Pollable</a></li> <li><a href="..&#x2F;classes/Profiler.html">Profiler</a></li> <li><a href="..&#x2F;classes/QueryString.html">QueryString</a></li> <li><a href="..&#x2F;classes/Queue.html">Queue</a></li> <li><a href="..&#x2F;classes/Record.html">Record</a></li> <li><a href="..&#x2F;classes/Recordset.html">Recordset</a></li> <li><a href="..&#x2F;classes/RecordsetFilter.html">RecordsetFilter</a></li> <li><a href="..&#x2F;classes/RecordsetIndexer.html">RecordsetIndexer</a></li> <li><a href="..&#x2F;classes/RecordsetSort.html">RecordsetSort</a></li> <li><a href="..&#x2F;classes/Rect.html">Rect</a></li> <li><a href="..&#x2F;classes/Renderer.html">Renderer</a></li> <li><a href="..&#x2F;classes/Resize.html">Resize</a></li> <li><a href="..&#x2F;classes/RightAxisLayout.html">RightAxisLayout</a></li> <li><a href="..&#x2F;classes/Router.html">Router</a></li> <li><a href="..&#x2F;classes/ScrollView.html">ScrollView</a></li> <li><a href="..&#x2F;classes/Selector.html">Selector</a></li> <li><a href="..&#x2F;classes/Shape.html">Shape</a></li> <li><a href="..&#x2F;classes/ShapeGroup.html">ShapeGroup</a></li> <li><a href="..&#x2F;classes/Slider.html">Slider</a></li> <li><a href="..&#x2F;classes/SliderBase.html">SliderBase</a></li> <li><a href="..&#x2F;classes/SliderValueRange.html">SliderValueRange</a></li> <li><a href="..&#x2F;classes/Sortable.html">Sortable</a></li> <li><a href="..&#x2F;classes/SplineSeries.html">SplineSeries</a></li> <li><a href="..&#x2F;classes/StackedAreaSeries.html">StackedAreaSeries</a></li> <li><a href="..&#x2F;classes/StackedAreaSplineSeries.html">StackedAreaSplineSeries</a></li> <li><a href="..&#x2F;classes/StackedAxis.html">StackedAxis</a></li> <li><a href="..&#x2F;classes/StackedBarSeries.html">StackedBarSeries</a></li> <li><a href="..&#x2F;classes/StackedColumnSeries.html">StackedColumnSeries</a></li> <li><a href="..&#x2F;classes/StackedComboSeries.html">StackedComboSeries</a></li> <li><a href="..&#x2F;classes/StackedComboSplineSeries.html">StackedComboSplineSeries</a></li> <li><a href="..&#x2F;classes/StackedLineSeries.html">StackedLineSeries</a></li> <li><a href="..&#x2F;classes/StackedMarkerSeries.html">StackedMarkerSeries</a></li> <li><a href="..&#x2F;classes/StackedSplineSeries.html">StackedSplineSeries</a></li> <li><a href="..&#x2F;classes/StackingUtil.html">StackingUtil</a></li> <li><a href="..&#x2F;classes/State.html">State</a></li> <li><a href="..&#x2F;classes/StyleSheet.html">StyleSheet</a></li> <li><a href="..&#x2F;classes/Subscriber.html">Subscriber</a></li> <li><a href="..&#x2F;classes/SVGCircle.html">SVGCircle</a></li> <li><a href="..&#x2F;classes/SVGDrawing.html">SVGDrawing</a></li> <li><a href="..&#x2F;classes/SVGEllipse.html">SVGEllipse</a></li> <li><a href="..&#x2F;classes/SVGGraphic.html">SVGGraphic</a></li> <li><a href="..&#x2F;classes/SVGPath.html">SVGPath</a></li> <li><a href="..&#x2F;classes/SVGPieSlice.html">SVGPieSlice</a></li> <li><a href="..&#x2F;classes/SVGRect.html">SVGRect</a></li> <li><a href="..&#x2F;classes/SVGShape.html">SVGShape</a></li> <li><a href="..&#x2F;classes/SWF.html">SWF</a></li> <li><a href="..&#x2F;classes/SWFDetect.html">SWFDetect</a></li> <li><a href="..&#x2F;classes/SyntheticEvent.html">SyntheticEvent</a></li> <li><a href="..&#x2F;classes/SyntheticEvent.Notifier.html">SyntheticEvent.Notifier</a></li> <li><a href="..&#x2F;classes/SynthRegistry.html">SynthRegistry</a></li> <li><a href="..&#x2F;classes/Tab.html">Tab</a></li> <li><a href="..&#x2F;classes/TabView.html">TabView</a></li> <li><a href="..&#x2F;classes/Test.html">Test</a></li> <li><a href="..&#x2F;classes/Test.ArrayAssert.html">Test.ArrayAssert</a></li> <li><a href="..&#x2F;classes/Test.Assert.html">Test.Assert</a></li> <li><a href="..&#x2F;classes/Test.AssertionError.html">Test.AssertionError</a></li> <li><a href="..&#x2F;classes/Test.ComparisonFailure.html">Test.ComparisonFailure</a></li> <li><a href="..&#x2F;classes/Test.Console.html">Test.Console</a></li> <li><a href="..&#x2F;classes/Test.CoverageFormat.CoverageFormat.html">Test.CoverageFormat.CoverageFormat</a></li> <li><a href="..&#x2F;classes/Test.DateAssert.html">Test.DateAssert</a></li> <li><a href="..&#x2F;classes/Test.EventTarget.html">Test.EventTarget</a></li> <li><a href="..&#x2F;classes/Test.Mock.Mock.html">Test.Mock.Mock</a></li> <li><a href="..&#x2F;classes/Test.Mock.Value.html">Test.Mock.Value</a></li> <li><a href="..&#x2F;classes/Test.ObjectAssert.html">Test.ObjectAssert</a></li> <li><a href="..&#x2F;classes/Test.Reporter.html">Test.Reporter</a></li> <li><a href="..&#x2F;classes/Test.Results.html">Test.Results</a></li> <li><a href="..&#x2F;classes/Test.Runner.html">Test.Runner</a></li> <li><a href="..&#x2F;classes/Test.ShouldError.html">Test.ShouldError</a></li> <li><a href="..&#x2F;classes/Test.ShouldFail.html">Test.ShouldFail</a></li> <li><a href="..&#x2F;classes/Test.TestCase.html">Test.TestCase</a></li> <li><a href="..&#x2F;classes/Test.TestFormat.html">Test.TestFormat</a></li> <li><a href="..&#x2F;classes/Test.TestNode.html">Test.TestNode</a></li> <li><a href="..&#x2F;classes/Test.TestRunner.html">Test.TestRunner</a></li> <li><a href="..&#x2F;classes/Test.TestSuite.html">Test.TestSuite</a></li> <li><a href="..&#x2F;classes/Test.UnexpectedError.html">Test.UnexpectedError</a></li> <li><a href="..&#x2F;classes/Test.UnexpectedValue.html">Test.UnexpectedValue</a></li> <li><a href="..&#x2F;classes/Test.Wait.html">Test.Wait</a></li> <li><a href="..&#x2F;classes/Text.AccentFold.html">Text.AccentFold</a></li> <li><a href="..&#x2F;classes/Text.WordBreak.html">Text.WordBreak</a></li> <li><a href="..&#x2F;classes/TimeAxis.html">TimeAxis</a></li> <li><a href="..&#x2F;classes/ToggleButton.html">ToggleButton</a></li> <li><a href="..&#x2F;classes/TopAxisLayout.html">TopAxisLayout</a></li> <li><a href="..&#x2F;classes/Transition.html">Transition</a></li> <li><a href="..&#x2F;classes/UA.html">UA</a></li> <li><a href="..&#x2F;classes/Uploader.html">Uploader</a></li> <li><a href="..&#x2F;classes/Uploader.Queue.html">Uploader.Queue</a></li> <li><a href="..&#x2F;classes/UploaderFlash.html">UploaderFlash</a></li> <li><a href="..&#x2F;classes/UploaderHTML5.html">UploaderHTML5</a></li> <li><a href="..&#x2F;classes/ValueChange.html">ValueChange</a></li> <li><a href="..&#x2F;classes/VerticalLegendLayout.html">VerticalLegendLayout</a></li> <li><a href="..&#x2F;classes/View.html">View</a></li> <li><a href="..&#x2F;classes/View.NodeMap.html">View.NodeMap</a></li> <li><a href="..&#x2F;classes/VMLCircle.html">VMLCircle</a></li> <li><a href="..&#x2F;classes/VMLDrawing.html">VMLDrawing</a></li> <li><a href="..&#x2F;classes/VMLEllipse.html">VMLEllipse</a></li> <li><a href="..&#x2F;classes/VMLGraphic.html">VMLGraphic</a></li> <li><a href="..&#x2F;classes/VMLPath.html">VMLPath</a></li> <li><a href="..&#x2F;classes/VMLPieSlice.html">VMLPieSlice</a></li> <li><a href="..&#x2F;classes/VMLRect.html">VMLRect</a></li> <li><a href="..&#x2F;classes/VMLShape.html">VMLShape</a></li> <li><a href="..&#x2F;classes/Widget.html">Widget</a></li> <li><a href="..&#x2F;classes/WidgetAutohide.html">WidgetAutohide</a></li> <li><a href="..&#x2F;classes/WidgetButtons.html">WidgetButtons</a></li> <li><a href="..&#x2F;classes/WidgetChild.html">WidgetChild</a></li> <li><a href="..&#x2F;classes/WidgetModality.html">WidgetModality</a></li> <li><a href="..&#x2F;classes/WidgetParent.html">WidgetParent</a></li> <li><a href="..&#x2F;classes/WidgetPosition.html">WidgetPosition</a></li> <li><a href="..&#x2F;classes/WidgetPositionAlign.html">WidgetPositionAlign</a></li> <li><a href="..&#x2F;classes/WidgetPositionConstrain.html">WidgetPositionConstrain</a></li> <li><a href="..&#x2F;classes/WidgetStack.html">WidgetStack</a></li> <li><a href="..&#x2F;classes/WidgetStdMod.html">WidgetStdMod</a></li> <li><a href="..&#x2F;classes/YQL.html">YQL</a></li> <li><a href="..&#x2F;classes/YQLRequest.html">YQLRequest</a></li> <li><a href="..&#x2F;classes/YUI.html">YUI</a></li> <li><a href="..&#x2F;classes/YUI~substitute.html">YUI~substitute</a></li> </ul> <ul id="api-modules" class="apis modules"> <li><a href="..&#x2F;modules/align-plugin.html">align-plugin</a></li> <li><a href="..&#x2F;modules/anim.html">anim</a></li> <li><a href="..&#x2F;modules/anim-base.html">anim-base</a></li> <li><a href="..&#x2F;modules/anim-color.html">anim-color</a></li> <li><a href="..&#x2F;modules/anim-curve.html">anim-curve</a></li> <li><a href="..&#x2F;modules/anim-easing.html">anim-easing</a></li> <li><a href="..&#x2F;modules/anim-node-plugin.html">anim-node-plugin</a></li> <li><a href="..&#x2F;modules/anim-scroll.html">anim-scroll</a></li> <li><a href="..&#x2F;modules/anim-xy.html">anim-xy</a></li> <li><a href="..&#x2F;modules/app.html">app</a></li> <li><a href="..&#x2F;modules/app-base.html">app-base</a></li> <li><a href="..&#x2F;modules/app-transitions.html">app-transitions</a></li> <li><a href="..&#x2F;modules/app-transitions-native.html">app-transitions-native</a></li> <li><a href="..&#x2F;modules/array-extras.html">array-extras</a></li> <li><a href="..&#x2F;modules/array-invoke.html">array-invoke</a></li> <li><a href="..&#x2F;modules/arraylist.html">arraylist</a></li> <li><a href="..&#x2F;modules/arraylist-add.html">arraylist-add</a></li> <li><a href="..&#x2F;modules/arraylist-filter.html">arraylist-filter</a></li> <li><a href="..&#x2F;modules/arraysort.html">arraysort</a></li> <li><a href="..&#x2F;modules/async-queue.html">async-queue</a></li> <li><a href="..&#x2F;modules/attribute.html">attribute</a></li> <li><a href="..&#x2F;modules/attribute-base.html">attribute-base</a></li> <li><a href="..&#x2F;modules/attribute-complex.html">attribute-complex</a></li> <li><a href="..&#x2F;modules/attribute-core.html">attribute-core</a></li> <li><a href="..&#x2F;modules/attribute-events.html">attribute-events</a></li> <li><a href="..&#x2F;modules/attribute-extras.html">attribute-extras</a></li> <li><a href="..&#x2F;modules/autocomplete.html">autocomplete</a></li> <li><a href="..&#x2F;modules/autocomplete-base.html">autocomplete-base</a></li> <li><a href="..&#x2F;modules/autocomplete-filters.html">autocomplete-filters</a></li> <li><a href="..&#x2F;modules/autocomplete-filters-accentfold.html">autocomplete-filters-accentfold</a></li> <li><a href="..&#x2F;modules/autocomplete-highlighters.html">autocomplete-highlighters</a></li> <li><a href="..&#x2F;modules/autocomplete-highlighters-accentfold.html">autocomplete-highlighters-accentfold</a></li> <li><a href="..&#x2F;modules/autocomplete-list.html">autocomplete-list</a></li> <li><a href="..&#x2F;modules/autocomplete-list-keys.html">autocomplete-list-keys</a></li> <li><a href="..&#x2F;modules/autocomplete-plugin.html">autocomplete-plugin</a></li> <li><a href="..&#x2F;modules/autocomplete-sources.html">autocomplete-sources</a></li> <li><a href="..&#x2F;modules/base.html">base</a></li> <li><a href="..&#x2F;modules/base-base.html">base-base</a></li> <li><a href="..&#x2F;modules/base-build.html">base-build</a></li> <li><a href="..&#x2F;modules/base-core.html">base-core</a></li> <li><a href="..&#x2F;modules/base-pluginhost.html">base-pluginhost</a></li> <li><a href="..&#x2F;modules/button.html">button</a></li> <li><a href="..&#x2F;modules/button-core.html">button-core</a></li> <li><a href="..&#x2F;modules/button-group.html">button-group</a></li> <li><a href="..&#x2F;modules/button-plugin.html">button-plugin</a></li> <li><a href="..&#x2F;modules/cache.html">cache</a></li> <li><a href="..&#x2F;modules/cache-base.html">cache-base</a></li> <li><a href="..&#x2F;modules/cache-offline.html">cache-offline</a></li> <li><a href="..&#x2F;modules/cache-plugin.html">cache-plugin</a></li> <li><a href="..&#x2F;modules/calendar.html">calendar</a></li> <li><a href="..&#x2F;modules/calendar-base.html">calendar-base</a></li> <li><a href="..&#x2F;modules/calendarnavigator.html">calendarnavigator</a></li> <li><a href="..&#x2F;modules/charts.html">charts</a></li> <li><a href="..&#x2F;modules/charts-legend.html">charts-legend</a></li> <li><a href="..&#x2F;modules/classnamemanager.html">classnamemanager</a></li> <li><a href="..&#x2F;modules/clickable-rail.html">clickable-rail</a></li> <li><a href="..&#x2F;modules/collection.html">collection</a></li> <li><a href="..&#x2F;modules/console.html">console</a></li> <li><a href="..&#x2F;modules/console-filters.html">console-filters</a></li> <li><a href="..&#x2F;modules/cookie.html">cookie</a></li> <li><a href="..&#x2F;modules/createlink-base.html">createlink-base</a></li> <li><a href="..&#x2F;modules/dataschema.html">dataschema</a></li> <li><a href="..&#x2F;modules/dataschema-array.html">dataschema-array</a></li> <li><a href="..&#x2F;modules/dataschema-base.html">dataschema-base</a></li> <li><a href="..&#x2F;modules/dataschema-json.html">dataschema-json</a></li> <li><a href="..&#x2F;modules/dataschema-text.html">dataschema-text</a></li> <li><a href="..&#x2F;modules/dataschema-xml.html">dataschema-xml</a></li> <li><a href="..&#x2F;modules/datasource.html">datasource</a></li> <li><a href="..&#x2F;modules/datasource-arrayschema.html">datasource-arrayschema</a></li> <li><a href="..&#x2F;modules/datasource-cache.html">datasource-cache</a></li> <li><a href="..&#x2F;modules/datasource-function.html">datasource-function</a></li> <li><a href="..&#x2F;modules/datasource-get.html">datasource-get</a></li> <li><a href="..&#x2F;modules/datasource-io.html">datasource-io</a></li> <li><a href="..&#x2F;modules/datasource-jsonschema.html">datasource-jsonschema</a></li> <li><a href="..&#x2F;modules/datasource-local.html">datasource-local</a></li> <li><a href="..&#x2F;modules/datasource-polling.html">datasource-polling</a></li> <li><a href="..&#x2F;modules/datasource-textschema.html">datasource-textschema</a></li> <li><a href="..&#x2F;modules/datasource-xmlschema.html">datasource-xmlschema</a></li> <li><a href="..&#x2F;modules/datatable.html">datatable</a></li> <li><a href="..&#x2F;modules/datatable-base.html">datatable-base</a></li> <li><a href="..&#x2F;modules/datatable-base-deprecated.html">datatable-base-deprecated</a></li> <li><a href="..&#x2F;modules/datatable-body.html">datatable-body</a></li> <li><a href="..&#x2F;modules/datatable-column-widths.html">datatable-column-widths</a></li> <li><a href="..&#x2F;modules/datatable-core.html">datatable-core</a></li> <li><a href="..&#x2F;modules/datatable-datasource.html">datatable-datasource</a></li> <li><a href="..&#x2F;modules/datatable-datasource-deprecated.html">datatable-datasource-deprecated</a></li> <li><a href="..&#x2F;modules/datatable-deprecated.html">datatable-deprecated</a></li> <li><a href="..&#x2F;modules/datatable-head.html">datatable-head</a></li> <li><a href="..&#x2F;modules/datatable-message.html">datatable-message</a></li> <li><a href="..&#x2F;modules/datatable-mutable.html">datatable-mutable</a></li> <li><a href="..&#x2F;modules/datatable-scroll.html">datatable-scroll</a></li> <li><a href="..&#x2F;modules/datatable-scroll-deprecated.html">datatable-scroll-deprecated</a></li> <li><a href="..&#x2F;modules/datatable-sort.html">datatable-sort</a></li> <li><a href="..&#x2F;modules/datatable-sort-deprecated.html">datatable-sort-deprecated</a></li> <li><a href="..&#x2F;modules/datatype.html">datatype</a></li> <li><a href="..&#x2F;modules/datatype-date.html">datatype-date</a></li> <li><a href="..&#x2F;modules/datatype-date-format.html">datatype-date-format</a></li> <li><a href="..&#x2F;modules/datatype-date-math.html">datatype-date-math</a></li> <li><a href="..&#x2F;modules/datatype-date-parse.html">datatype-date-parse</a></li> <li><a href="..&#x2F;modules/datatype-number.html">datatype-number</a></li> <li><a href="..&#x2F;modules/datatype-number-format.html">datatype-number-format</a></li> <li><a href="..&#x2F;modules/datatype-number-parse.html">datatype-number-parse</a></li> <li><a href="..&#x2F;modules/datatype-xml.html">datatype-xml</a></li> <li><a href="..&#x2F;modules/datatype-xml-format.html">datatype-xml-format</a></li> <li><a href="..&#x2F;modules/datatype-xml-parse.html">datatype-xml-parse</a></li> <li><a href="..&#x2F;modules/dd.html">dd</a></li> <li><a href="..&#x2F;modules/dd-constrain.html">dd-constrain</a></li> <li><a href="..&#x2F;modules/dd-ddm.html">dd-ddm</a></li> <li><a href="..&#x2F;modules/dd-ddm-base.html">dd-ddm-base</a></li> <li><a href="..&#x2F;modules/dd-ddm-drop.html">dd-ddm-drop</a></li> <li><a href="..&#x2F;modules/dd-delegate.html">dd-delegate</a></li> <li><a href="..&#x2F;modules/dd-drag.html">dd-drag</a></li> <li><a href="..&#x2F;modules/dd-drop.html">dd-drop</a></li> <li><a href="..&#x2F;modules/dd-drop-plugin.html">dd-drop-plugin</a></li> <li><a href="..&#x2F;modules/dd-plugin.html">dd-plugin</a></li> <li><a href="..&#x2F;modules/dd-proxy.html">dd-proxy</a></li> <li><a href="..&#x2F;modules/dd-scroll.html">dd-scroll</a></li> <li><a href="..&#x2F;modules/dial.html">dial</a></li> <li><a href="..&#x2F;modules/dom.html">dom</a></li> <li><a href="..&#x2F;modules/dom-base.html">dom-base</a></li> <li><a href="..&#x2F;modules/dom-screen.html">dom-screen</a></li> <li><a href="..&#x2F;modules/dom-style.html">dom-style</a></li> <li><a href="..&#x2F;modules/dump.html">dump</a></li> <li><a href="..&#x2F;modules/editor.html">editor</a></li> <li><a href="..&#x2F;modules/editor-base.html">editor-base</a></li> <li><a href="..&#x2F;modules/editor-bidi.html">editor-bidi</a></li> <li><a href="..&#x2F;modules/editor-br.html">editor-br</a></li> <li><a href="..&#x2F;modules/editor-lists.html">editor-lists</a></li> <li><a href="..&#x2F;modules/editor-para.html">editor-para</a></li> <li><a href="..&#x2F;modules/editor-para-base.html">editor-para-base</a></li> <li><a href="..&#x2F;modules/editor-para-ie.html">editor-para-ie</a></li> <li><a href="..&#x2F;modules/editor-tab.html">editor-tab</a></li> <li><a href="..&#x2F;modules/escape.html">escape</a></li> <li><a href="..&#x2F;modules/event.html">event</a></li> <li><a href="..&#x2F;modules/event-base.html">event-base</a></li> <li><a href="..&#x2F;modules/event-contextmenu.html">event-contextmenu</a></li> <li><a href="..&#x2F;modules/event-custom.html">event-custom</a></li> <li><a href="..&#x2F;modules/event-custom-base.html">event-custom-base</a></li> <li><a href="..&#x2F;modules/event-custom-complex.html">event-custom-complex</a></li> <li><a href="..&#x2F;modules/event-delegate.html">event-delegate</a></li> <li><a href="..&#x2F;modules/event-flick.html">event-flick</a></li> <li><a href="..&#x2F;modules/event-focus.html">event-focus</a></li> <li><a href="..&#x2F;modules/event-gestures.html">event-gestures</a></li> <li><a href="..&#x2F;modules/event-hover.html">event-hover</a></li> <li><a href="..&#x2F;modules/event-key.html">event-key</a></li> <li><a href="..&#x2F;modules/event-mouseenter.html">event-mouseenter</a></li> <li><a href="..&#x2F;modules/event-mousewheel.html">event-mousewheel</a></li> <li><a href="..&#x2F;modules/event-move.html">event-move</a></li> <li><a href="..&#x2F;modules/event-outside.html">event-outside</a></li> <li><a href="..&#x2F;modules/event-resize.html">event-resize</a></li> <li><a href="..&#x2F;modules/event-simulate.html">event-simulate</a></li> <li><a href="..&#x2F;modules/event-synthetic.html">event-synthetic</a></li> <li><a href="..&#x2F;modules/event-touch.html">event-touch</a></li> <li><a href="..&#x2F;modules/event-valuechange.html">event-valuechange</a></li> <li><a href="..&#x2F;modules/exec-command.html">exec-command</a></li> <li><a href="..&#x2F;modules/features.html">features</a></li> <li><a href="..&#x2F;modules/file.html">file</a></li> <li><a href="..&#x2F;modules/file-flash.html">file-flash</a></li> <li><a href="..&#x2F;modules/file-html5.html">file-html5</a></li> <li><a href="..&#x2F;modules/frame.html">frame</a></li> <li><a href="..&#x2F;modules/get.html">get</a></li> <li><a href="..&#x2F;modules/get-nodejs.html">get-nodejs</a></li> <li><a href="..&#x2F;modules/graphics.html">graphics</a></li> <li><a href="..&#x2F;modules/handlebars.html">handlebars</a></li> <li><a href="..&#x2F;modules/handlebars-base.html">handlebars-base</a></li> <li><a href="..&#x2F;modules/handlebars-compiler.html">handlebars-compiler</a></li> <li><a href="..&#x2F;modules/highlight.html">highlight</a></li> <li><a href="..&#x2F;modules/highlight-accentfold.html">highlight-accentfold</a></li> <li><a href="..&#x2F;modules/highlight-base.html">highlight-base</a></li> <li><a href="..&#x2F;modules/history.html">history</a></li> <li><a href="..&#x2F;modules/history-base.html">history-base</a></li> <li><a href="..&#x2F;modules/history-hash.html">history-hash</a></li> <li><a href="..&#x2F;modules/history-hash-ie.html">history-hash-ie</a></li> <li><a href="..&#x2F;modules/history-html5.html">history-html5</a></li> <li><a href="..&#x2F;modules/imageloader.html">imageloader</a></li> <li><a href="..&#x2F;modules/intl.html">intl</a></li> <li><a href="..&#x2F;modules/io.html">io</a></li> <li><a href="..&#x2F;modules/io-base.html">io-base</a></li> <li><a href="..&#x2F;modules/io-form.html">io-form</a></li> <li><a href="..&#x2F;modules/io-queue.html">io-queue</a></li> <li><a href="..&#x2F;modules/io-upload-iframe.html">io-upload-iframe</a></li> <li><a href="..&#x2F;modules/io-xdr.html">io-xdr</a></li> <li><a href="..&#x2F;modules/json.html">json</a></li> <li><a href="..&#x2F;modules/json-parse.html">json-parse</a></li> <li><a href="..&#x2F;modules/json-stringify.html">json-stringify</a></li> <li><a href="..&#x2F;modules/jsonp.html">jsonp</a></li> <li><a href="..&#x2F;modules/jsonp-url.html">jsonp-url</a></li> <li><a href="..&#x2F;modules/loader.html">loader</a></li> <li><a href="..&#x2F;modules/loader-base.html">loader-base</a></li> <li><a href="..&#x2F;modules/matrix.html">matrix</a></li> <li><a href="..&#x2F;modules/model.html">model</a></li> <li><a href="..&#x2F;modules/model-list.html">model-list</a></li> <li><a href="..&#x2F;modules/node.html">node</a></li> <li><a href="..&#x2F;modules/node-base.html">node-base</a></li> <li><a href="..&#x2F;modules/node-core.html">node-core</a></li> <li><a href="..&#x2F;modules/node-data.html">node-data</a></li> <li><a href="..&#x2F;modules/node-deprecated.html">node-deprecated</a></li> <li><a href="..&#x2F;modules/node-event-delegate.html">node-event-delegate</a></li> <li><a href="..&#x2F;modules/node-event-html5.html">node-event-html5</a></li> <li><a href="..&#x2F;modules/node-event-simulate.html">node-event-simulate</a></li> <li><a href="..&#x2F;modules/node-flick.html">node-flick</a></li> <li><a href="..&#x2F;modules/node-focusmanager.html">node-focusmanager</a></li> <li><a href="..&#x2F;modules/node-load.html">node-load</a></li> <li><a href="..&#x2F;modules/node-menunav.html">node-menunav</a></li> <li><a href="..&#x2F;modules/node-pluginhost.html">node-pluginhost</a></li> <li><a href="..&#x2F;modules/node-screen.html">node-screen</a></li> <li><a href="..&#x2F;modules/node-style.html">node-style</a></li> <li><a href="..&#x2F;modules/oop.html">oop</a></li> <li><a href="..&#x2F;modules/overlay.html">overlay</a></li> <li><a href="..&#x2F;modules/panel.html">panel</a></li> <li><a href="..&#x2F;modules/parallel.html">parallel</a></li> <li><a href="..&#x2F;modules/pjax.html">pjax</a></li> <li><a href="..&#x2F;modules/pjax-base.html">pjax-base</a></li> <li><a href="..&#x2F;modules/pjax-plugin.html">pjax-plugin</a></li> <li><a href="..&#x2F;modules/plugin.html">plugin</a></li> <li><a href="..&#x2F;modules/pluginhost.html">pluginhost</a></li> <li><a href="..&#x2F;modules/pluginhost-base.html">pluginhost-base</a></li> <li><a href="..&#x2F;modules/pluginhost-config.html">pluginhost-config</a></li> <li><a href="..&#x2F;modules/profiler.html">profiler</a></li> <li><a href="..&#x2F;modules/querystring.html">querystring</a></li> <li><a href="..&#x2F;modules/querystring-parse.html">querystring-parse</a></li> <li><a href="..&#x2F;modules/querystring-parse-simple.html">querystring-parse-simple</a></li> <li><a href="..&#x2F;modules/querystring-stringify.html">querystring-stringify</a></li> <li><a href="..&#x2F;modules/querystring-stringify-simple.html">querystring-stringify-simple</a></li> <li><a href="..&#x2F;modules/queue-promote.html">queue-promote</a></li> <li><a href="..&#x2F;modules/range-slider.html">range-slider</a></li> <li><a href="..&#x2F;modules/recordset.html">recordset</a></li> <li><a href="..&#x2F;modules/recordset-base.html">recordset-base</a></li> <li><a href="..&#x2F;modules/recordset-filter.html">recordset-filter</a></li> <li><a href="..&#x2F;modules/recordset-indexer.html">recordset-indexer</a></li> <li><a href="..&#x2F;modules/recordset-sort.html">recordset-sort</a></li> <li><a href="..&#x2F;modules/resize.html">resize</a></li> <li><a href="..&#x2F;modules/resize-contrain.html">resize-contrain</a></li> <li><a href="..&#x2F;modules/resize-plugin.html">resize-plugin</a></li> <li><a href="..&#x2F;modules/resize-proxy.html">resize-proxy</a></li> <li><a href="..&#x2F;modules/rollup.html">rollup</a></li> <li><a href="..&#x2F;modules/router.html">router</a></li> <li><a href="..&#x2F;modules/scrollview.html">scrollview</a></li> <li><a href="..&#x2F;modules/scrollview-base.html">scrollview-base</a></li> <li><a href="..&#x2F;modules/scrollview-base-ie.html">scrollview-base-ie</a></li> <li><a href="..&#x2F;modules/scrollview-list.html">scrollview-list</a></li> <li><a href="..&#x2F;modules/scrollview-paginator.html">scrollview-paginator</a></li> <li><a href="..&#x2F;modules/scrollview-scrollbars.html">scrollview-scrollbars</a></li> <li><a href="..&#x2F;modules/selection.html">selection</a></li> <li><a href="..&#x2F;modules/selector-css2.html">selector-css2</a></li> <li><a href="..&#x2F;modules/selector-css3.html">selector-css3</a></li> <li><a href="..&#x2F;modules/selector-native.html">selector-native</a></li> <li><a href="..&#x2F;modules/shim-plugin.html">shim-plugin</a></li> <li><a href="..&#x2F;modules/slider.html">slider</a></li> <li><a href="..&#x2F;modules/slider-base.html">slider-base</a></li> <li><a href="..&#x2F;modules/slider-value-range.html">slider-value-range</a></li> <li><a href="..&#x2F;modules/sortable.html">sortable</a></li> <li><a href="..&#x2F;modules/sortable-scroll.html">sortable-scroll</a></li> <li><a href="..&#x2F;modules/stylesheet.html">stylesheet</a></li> <li><a href="..&#x2F;modules/substitute.html">substitute</a></li> <li><a href="..&#x2F;modules/swf.html">swf</a></li> <li><a href="..&#x2F;modules/swfdetect.html">swfdetect</a></li> <li><a href="..&#x2F;modules/tabview.html">tabview</a></li> <li><a href="..&#x2F;modules/test.html">test</a></li> <li><a href="..&#x2F;modules/test-console.html">test-console</a></li> <li><a href="..&#x2F;modules/text.html">text</a></li> <li><a href="..&#x2F;modules/text-accentfold.html">text-accentfold</a></li> <li><a href="..&#x2F;modules/text-wordbreak.html">text-wordbreak</a></li> <li><a href="..&#x2F;modules/transition.html">transition</a></li> <li><a href="..&#x2F;modules/uploader.html">uploader</a></li> <li><a href="..&#x2F;modules/uploader-deprecated.html">uploader-deprecated</a></li> <li><a href="..&#x2F;modules/uploader-flash.html">uploader-flash</a></li> <li><a href="..&#x2F;modules/uploader-html5.html">uploader-html5</a></li> <li><a href="..&#x2F;modules/uploader-queue.html">uploader-queue</a></li> <li><a href="..&#x2F;modules/view.html">view</a></li> <li><a href="..&#x2F;modules/view-node-map.html">view-node-map</a></li> <li><a href="..&#x2F;modules/widget.html">widget</a></li> <li><a href="..&#x2F;modules/widget-anim.html">widget-anim</a></li> <li><a href="..&#x2F;modules/widget-autohide.html">widget-autohide</a></li> <li><a href="..&#x2F;modules/widget-base.html">widget-base</a></li> <li><a href="..&#x2F;modules/widget-base-ie.html">widget-base-ie</a></li> <li><a href="..&#x2F;modules/widget-buttons.html">widget-buttons</a></li> <li><a href="..&#x2F;modules/widget-child.html">widget-child</a></li> <li><a href="..&#x2F;modules/widget-htmlparser.html">widget-htmlparser</a></li> <li><a href="..&#x2F;modules/widget-locale.html">widget-locale</a></li> <li><a href="..&#x2F;modules/widget-modality.html">widget-modality</a></li> <li><a href="..&#x2F;modules/widget-parent.html">widget-parent</a></li> <li><a href="..&#x2F;modules/widget-position.html">widget-position</a></li> <li><a href="..&#x2F;modules/widget-position-align.html">widget-position-align</a></li> <li><a href="..&#x2F;modules/widget-position-constrain.html">widget-position-constrain</a></li> <li><a href="..&#x2F;modules/widget-skin.html">widget-skin</a></li> <li><a href="..&#x2F;modules/widget-stack.html">widget-stack</a></li> <li><a href="..&#x2F;modules/widget-stdmod.html">widget-stdmod</a></li> <li><a href="..&#x2F;modules/widget-uievents.html">widget-uievents</a></li> <li><a href="..&#x2F;modules/yql.html">yql</a></li> <li><a href="..&#x2F;modules/yui.html">yui</a></li> <li><a href="..&#x2F;modules/yui-base.html">yui-base</a></li> <li><a href="..&#x2F;modules/yui-later.html">yui-later</a></li> <li><a href="..&#x2F;modules/yui-log.html">yui-log</a></li> <li><a href="..&#x2F;modules/yui-throttle.html">yui-throttle</a></li> <li><a href="..&#x2F;modules/yui3.html">yui3</a></li> </ul> </div> </div> </div> </div> </div> <div class="yui3-u-3-4"> <div id="api-options"> Show: <label for="api-show-inherited"> <input type="checkbox" id="api-show-inherited" checked> Inherited </label> <label for="api-show-protected"> <input type="checkbox" id="api-show-protected"> Protected </label> <label for="api-show-private"> <input type="checkbox" id="api-show-private"> Private </label> </div> <div class="apidocs"> <div id="docs-main"> <div class="content"> <h1>widget-locale Module</h1> <div class="box clearfix meta"> <a class="button link-docs" href="/yui/docs/widget">User Guide &amp; Examples</a> <div class="foundat"> Defined in: <a href="..&#x2F;files&#x2F;widget_js_WidgetLocale.js.html#l1"><code>widget&#x2F;js&#x2F;WidgetLocale.js:1</code></a> </div> </div> <div class="box deprecated"> <p> <strong>Deprecated:</strong> This module has been deprecated. It&#x27;s replaced by the &quot;intl&quot; module which provides generic internationalization and BCP 47 language tag support with externalization. </p> </div> <div class="box intro"> <p>Provides string support for widget with BCP 47 language tag lookup. This module has been deprecated. It's replaced by the "intl" module which provides generic internationalization and BCP 47 language tag support with externalization.</p> </div> <div class="yui3-g"> <div class="yui3-u-1-2"> </div> <div class="yui3-u-1-2"> </div> </div> </div> </div> </div> </div> </div> </div> <script src="..&#x2F;assets/vendor/prettify/prettify-min.js"></script> <script>prettyPrint();</script> <script src="..&#x2F;assets/js/yui-prettify.js"></script> <script src="..&#x2F;assets/../api.js"></script> <script src="..&#x2F;assets/js/api-filter.js"></script> <script src="..&#x2F;assets/js/api-list.js"></script> <script src="..&#x2F;assets/js/api-search.js"></script> <script src="..&#x2F;assets/js/apidocs.js"></script> </body> </html>
dkist/t-h-inker
sites/all/libraries/yui/api/modules/widget-locale.html
HTML
gpl-2.0
66,604
/* * Xiphos Bible Study Tool * sword.cc - glue * * Copyright (C) 2000-2020 Xiphos Developer Team * * 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 Library 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. */ #ifdef HAVE_CONFIG_H #include <config.h> #endif #include <gtk/gtk.h> #include <glib.h> #include <glib/gstdio.h> #include <swmgr.h> #include <swmodule.h> #include <stringmgr.h> #include <localemgr.h> extern "C" { #include "gui/bibletext.h" #include "main/gtk_compat.h" } #include <ctype.h> #include <time.h> #include "gui/main_window.h" #include "gui/font_dialog.h" #include "gui/widgets.h" #include "gui/commentary.h" #include "gui/dialog.h" #include "gui/parallel_dialog.h" #include "gui/parallel_tab.h" #include "gui/parallel_view.h" #include "gui/tabbed_browser.h" #include "gui/xiphos.h" #include "gui/sidebar.h" #include "gui/utilities.h" #include "gui/cipher_key_dialog.h" #include "gui/main_menu.h" #include "main/biblesync_glue.h" #include "main/display.hh" #include "main/lists.h" #include "main/navbar.h" #include "main/navbar_book.h" #include "main/search_sidebar.h" #include "main/previewer.h" #include "main/settings.h" #include "main/sidebar.h" #include "main/sword.h" #include "main/url.hh" #include "main/xml.h" #include "main/parallel_view.h" #include "main/modulecache.hh" #include "backend/sword_main.hh" #include "backend/gs_stringmgr.h" #include "biblesync/biblesync.hh" #include "gui/debug_glib_null.h" #ifdef HAVE_DBUS #include "gui/ipc.h" #endif extern BibleSync *biblesync; using namespace sword; char *sword_locale = NULL; gboolean companion_activity = FALSE; /* Unicode collation necessities. */ UCollator* collator; UErrorCode collator_status; extern gboolean valid_scripture_key; // these track together. when one changes, so does the other. static std::map<string, string> abbrev_name2abbrev, abbrev_abbrev2name; typedef std::map<string, string>::iterator abbrev_iter; /****************************************************************************** * Name * main_add_abbreviation * * Synopsis * #include "main/sword.h" * * void main_add_abbreviation(char *name, char *abbreviation) * * Description * adds an element to each of the abbreviation maps. * * Return value * void */ void main_add_abbreviation(const char *name, const char *abbreviation) { // let's not be stupid about abbreviations chosen, ok? if (!strchr(abbreviation, '(')) { abbrev_name2abbrev[name] = abbreviation; abbrev_abbrev2name[abbreviation] = name; } } /****************************************************************************** * Name * main_get_abbreviation * * Synopsis * #include "main/sword.h" * * const char * main_get_abbreviation(const char *name) * * Description * gets abbreviation from real module, if available. * * Return value * const char * */ const char *main_get_abbreviation(const char *name) { if (name == NULL) return NULL; abbrev_iter it = abbrev_name2abbrev.find(name); if (it != abbrev_name2abbrev.end()) { return it->second.c_str(); } return NULL; } /****************************************************************************** * Name * main_get_name * * Synopsis * #include "main/sword.h" * * const char * main_get_name(const char *abbreviation) * * Description * gets real module name from abbreviation, if available. * * Return value * const char * */ const char *main_get_name(const char *abbreviation) { if (abbreviation == NULL) return NULL; abbrev_iter it = abbrev_abbrev2name.find(abbreviation); if (it != abbrev_abbrev2name.end()) { return it->second.c_str(); } return NULL; } /****************************************************************************** * Name * main_book_heading * * Synopsis * #include "main/sword.h" * * void main_book_heading(char * mod_name) * * Description * * * Return value * void */ void main_book_heading(char *mod_name) { VerseKey *vkey; SWMgr *mgr = backend->get_mgr(); backend->display_mod = mgr->Modules[mod_name]; vkey = (VerseKey *)(SWKey *)(*backend->display_mod); vkey->setIntros(1); vkey->setAutoNormalize(0); vkey->setChapter(0); vkey->setVerse(0); backend->display_mod->display(); } /****************************************************************************** * Name * main_chapter_heading * * Synopsis * #include "main/module_dialogs.h" * * void main_chapter_heading(char * mod_name) * * Description * * * Return value * void */ void main_chapter_heading(char *mod_name) { VerseKey *vkey; SWMgr *mgr = backend->get_mgr(); backend->display_mod = mgr->Modules[mod_name]; backend->display_mod->setKey(settings.currentverse); vkey = (VerseKey *)(SWKey *)(*backend->display_mod); vkey->setIntros(1); vkey->setAutoNormalize(0); vkey->setVerse(0); backend->display_mod->display(); } /****************************************************************************** * Name * main_save_note * * Synopsis * #include "main/sword.h" * * void main_save_note(const gchar * module_name, * const gchar * key_str , * const gchar * note_str ) * * Description * * * Return value * void */ void main_save_note(const gchar *module_name, const gchar *key_str, const gchar *note_str) { // Massage encoded spaces ("%20") back to real spaces. // This is a sick. unreliable hack that should be removed // after the underlying problem is fixed in Sword. gchar *rework; for (rework = (char *)strstr(note_str, "%20"); rework; rework = strstr(rework + 1, "%20")) { *rework = ' '; (void)strcpy(rework + 1, rework + 3); } XI_message(("note module %s\nnote key %s\nnote text%s", module_name, key_str, note_str)); backend->save_note_entry(module_name, key_str, note_str); main_display_commentary(module_name, settings.currentverse); } /****************************************************************************** * Name * main_delete_note * * Synopsis * #include "main/sword.h" * * void main_delete_note(DIALOG_DATA * d) * * Description * * * Return value * void */ void main_delete_note(const gchar *module_name, const gchar *key_str) { backend->set_module_key(module_name, key_str); XI_message(("note module %s\nnote key %s\n", module_name, key_str)); backend->delete_entry(); if ((!strcmp(settings.CommWindowModule, module_name)) && (!strcmp(settings.currentverse, key_str))) main_display_commentary(module_name, key_str); } /****************************************************************************** * Name * set_module_unlocked * * Synopsis * #include "bibletext.h" * * void set_module_unlocked(char *mod_name, char *key) * * Description * unlocks locked module - * * Return value * void */ void main_set_module_unlocked(const char *mod_name, char *key) { SWMgr *mgr = backend->get_mgr(); mgr->setCipherKey(mod_name, key); } /****************************************************************************** * Name * main_save_module_key * * Synopsis * #include "main/configs.h" * * void main_save_module_key(gchar * mod_name, gchar * key) * * Description * to unlock locked modules * * Return value * void */ void main_save_module_key(const char *mod_name, char *key) { backend->save_module_key((char *)mod_name, key); } /****************************************************************************** * Name * main_getText * * Synopsis * #include "main/sword.h" * void main_getText(gchar * key) * * Description * get unabbreviated key * * Return value * char * */ char *main_getText(char *key) { VerseKey vkey(key); return strdup((char *)vkey.getText()); } /****************************************************************************** * Name * main_getShortText * * Synopsis * #include "main/sword.h" * void main_getShortText(gchar * key) * * Description * get short-name key * * Return value * char * */ char *main_getShortText(char *key) { VerseKey vkey(key); return strdup((char *)vkey.getShortText()); } /****************************************************************************** * Name * main_update_nav_controls * * Synopsis * #include "toolbar_nav.h" * * gchar *main_update_nav_controls(const gchar * key) * * Description * updates the nav toolbar controls * * Return value * gchar * */ gchar *main_update_nav_controls(const char *module_name, const gchar *key) { char *val_key = backend->get_valid_key(module_name, key); // we got a valid key. but was it really a valid key within v11n? // for future use in determining whether to show normal navbar content. navbar_versekey.valid_key = main_is_Bible_key(module_name, key); /* * remember verse */ xml_set_value("Xiphos", "keys", "verse", val_key); settings.currentverse = xml_get_value("keys", "verse"); settings.apply_change = FALSE; navbar_versekey.module_name = g_string_assign(navbar_versekey.module_name, settings.MainWindowModule); navbar_versekey.key = g_string_assign(navbar_versekey.key, val_key); main_navbar_versekey_set(navbar_versekey, val_key); settings.apply_change = TRUE; #ifdef HAVE_DBUS IpcObject *ipc = ipc_get_main_ipc(); if (ipc) ipc_object_navigation_signal(ipc, (const gchar *)val_key, NULL); #endif return val_key; } /****************************************************************************** * Name * get_module_key * * Synopsis * #include "main/module.h" * * char *get_module_key(void) * * Description * returns module key * * Return value * char * */ char *main_get_active_pane_key(void) { if (settings.havebible) { switch (settings.whichwindow) { case MAIN_TEXT_WINDOW: case COMMENTARY_WINDOW: return (char *)settings.currentverse; break; case DICTIONARY_WINDOW: return (char *)settings.dictkey; break; case parallel_WINDOW: return (char *)settings.cvparallel; break; case BOOK_WINDOW: return (char *)settings.book_key; break; } } return NULL; } /****************************************************************************** * Name * get_module_name * * Synopsis * #include "main/module.h" * * char *get_module_name(void) * * Description * returns module name * * Return value * char * */ char *main_get_active_pane_module(void) { if (settings.havebible) { switch (settings.whichwindow) { case MAIN_TEXT_WINDOW: return (char *)xml_get_value("modules", "bible"); break; case COMMENTARY_WINDOW: return (char *)xml_get_value("modules", "comm"); break; case DICTIONARY_WINDOW: return (char *)settings.DictWindowModule; break; case BOOK_WINDOW: return (char *)settings.book_mod; break; } } return NULL; } /****************************************************************************** * Name * module_name_from_description * * Synopsis * #include ".h" * * void module_name_from_description(gchar *mod_name, gchar *description) * * Description * * * Return value * void */ char *main_module_name_from_description(char *description) { return backend->module_name_from_description(description); } /****************************************************************************** * Name * main_get_sword_version * * Synopsis * #include "sword.h" * * const char *main_get_sword_version(void) * * Description * * * Return value * const char * */ const char *main_get_sword_version(void) { return backend->get_sword_version(); } /****************************************************************************** * Name * get_search_results_text * * Synopsis * #include "sword.h" * * char *get_search_results_text(char * mod_name, char * key) * * Description * * * Return value * char * */ char *main_get_search_results_text(char *mod_name, char *key) { return backend->get_render_text((char *)mod_name, (char *)key); } /****************************************************************************** * Name * main_get_path_to_mods * * Synopsis * #include "sword.h" * * gchar *main_get_path_to_mods(void) * * Description * returns the path to the sword modules * * Return value * gchar * */ char *main_get_path_to_mods(void) { SWMgr *mgr = backend->get_mgr(); char *path = mgr->prefixPath; return (path ? g_strdup(path) : NULL); } /****************************************************************************** * Name * main_init_language_map * * Synopsis * #include "sword.h" * * void main_init_language_map(void) * * Description * initializes the hard-coded abbrev->name mapping. * * Return value * void */ typedef std::map<SWBuf, SWBuf> ModLanguageMap; ModLanguageMap languageMap; void main_init_language_map() { gchar *language_file; FILE *language; gchar *s, *end, *abbrev, *name, *newline; gchar *mapspace; size_t length; if ((language_file = gui_general_user_file("languages", FALSE)) == NULL) { gui_generic_warning(_("Xiphos's file for language\nabbreviations is missing.")); return; } XI_message(("%s", language_file)); if ((language = g_fopen(language_file, "r")) == NULL) { gui_generic_warning(_("Xiphos's language abbreviation\nfile cannot be opened.")); g_free(language_file); return; } g_free(language_file); (void)fseek(language, 0L, SEEK_END); length = ftell(language); rewind(language); if ((length == 0) || (mapspace = (gchar *)g_malloc(length + 2)) == NULL) { fclose(language); gui_generic_warning(_("Xiphos cannot allocate space\nfor language abbreviations.")); return; } if (fread(mapspace, 1, length, language) != length) { fclose(language); g_free(mapspace); gui_generic_warning(_("Xiphos cannot read the\nlanguage abbreviation file.")); return; } fclose(language); end = length + mapspace; *end = '\0'; for (s = mapspace; s < end; ++s) { if ((newline = strchr(s, '\n')) == NULL) { XI_message(("incomplete last line in languages")); break; } *newline = '\0'; if ((*s == '#') || (s == newline)) { s = newline; // comment or empty line. continue; } abbrev = s; if ((name = strchr(s, '\t')) == NULL) { XI_message(("tab-less line in languages")); break; } *(name++) = '\0'; // NUL-terminate abbrev, mark name. languageMap[SWBuf(abbrev)] = SWBuf(name); s = newline; } g_free(mapspace); } const char *main_get_language_map(const char *language) { if (language == NULL) return "Unknown"; return languageMap[language].c_str(); } char **main_get_module_language_list(void) { return backend->get_module_language_list(); } /****************************************************************************** * Name * set_sword_locale * * Synopsis * #include "main/sword.h" * * char *set_sword_locale(const char *sys_locale) * * Description * set sword's idea of the locale in which the user operates * * Return value * char * */ char *set_sword_locale(const char *sys_locale) { if (sys_locale) { SWBuf locale; StringList localelist = LocaleMgr::getSystemLocaleMgr()->getAvailableLocales(); StringList::iterator it; int ncmp[3] = {100, 5, 2}; // fixed data // length-limited match for (int i = 0; i < 3; ++i) { for (it = localelist.begin(); it != localelist.end(); ++it) { locale = *it; if (!strncmp(sys_locale, locale.c_str(), ncmp[i])) { LocaleMgr::getSystemLocaleMgr()->setDefaultLocaleName(locale.c_str()); return g_strdup(locale.c_str()); } } } } // either we were given a null sys_locale, or it didn't match anything. char *err = g_strdup_printf(_("No matching locale found for `%s'.\n%s"), sys_locale, _("Book names and menus may not be translated.")); gui_generic_warning(err); g_free(err); return NULL; } /****************************************************************************** * Name * backend_init * * Synopsis * #include "main/sword.h" * * void main_init_backend(void) * * Description * start sword * * Return value * void */ void main_init_backend(void) { StringMgr::setSystemStringMgr(new GS_StringMgr()); const char *lang = getenv("LANG"); if (!lang) lang = "C"; sword_locale = set_sword_locale(lang); collator = ucol_open(sword_locale, &collator_status); lang = LocaleMgr::getSystemLocaleMgr()->getDefaultLocaleName(); backend = new BackEnd(); backend->init_SWORD(0); settings.path_to_mods = main_get_path_to_mods(); //#ifndef DEBUG g_chdir(settings.path_to_mods); //#else // XI_warning(("no chdir(SWORD_PATH) => modmgr 'archive' may not work")); //#endif XI_print(("%s sword-%s\n", "Starting", backend->get_sword_version())); XI_print(("%s\n", "Initiating SWORD")); XI_print(("%s: %s\n", "path to sword", settings.path_to_mods)); XI_print(("%s %s\n", "SWORD locale is", lang)); XI_print(("%s\n", "Checking for SWORD Modules")); settings.spell_language = strdup(lang); main_init_lists(); // // BibleSync backend startup. identify the user by name. // biblesync = new BibleSync("Xiphos", VERSION, #ifdef WIN32 // in win32 glib, get_real_name and get_user_name are the same. (string)g_get_real_name() #else (string)g_get_real_name() + " (" + g_get_user_name() + ")" #endif ); } /****************************************************************************** * Name * shutdown_sword * * Synopsis * #include "sword.h" * * void shutdown_sword(void) * * Description * close down sword by deleting backend; * * Return value * void */ void main_shutdown_backend(void) { if (sword_locale) free((char *)sword_locale); sword_locale = NULL; if (backend) delete backend; backend = NULL; XI_print(("%s\n", "SWORD is shutdown")); } /****************************************************************************** * Name * main_dictionary_entry_changed * * Synopsis * #include "main/sword.h" * * void main_dictionary_entry_changed(char * mod_name) * * Description * text in the dictionary entry has changed and the entry activated * * Return value * void */ void main_dictionary_entry_changed(char *mod_name) { gchar *key = NULL; if (!mod_name) return; if (strcmp(settings.DictWindowModule, mod_name)) { xml_set_value("Xiphos", "modules", "dict", mod_name); settings.DictWindowModule = xml_get_value("modules", "dict"); } key = g_strdup((gchar *)gtk_entry_get_text(GTK_ENTRY(widgets.entry_dict))); backend->set_module_key(mod_name, key); g_free(key); key = backend->get_module_key(); xml_set_value("Xiphos", "keys", "dictionary", key); settings.dictkey = xml_get_value("keys", "dictionary"); main_check_unlock(mod_name, TRUE); backend->set_module_key(mod_name, key); backend->display_mod->display(); gtk_entry_set_text(GTK_ENTRY(widgets.entry_dict), key); g_free(key); } static void dict_key_list_select(GtkMenuItem *menuitem, gpointer user_data) { gtk_entry_set_text(GTK_ENTRY(widgets.entry_dict), (gchar *)user_data); gtk_widget_activate(widgets.entry_dict); } /****************************************************************************** * Name * * * Synopsis * #include "main/sword.h" * * * * Description * text in the dictionary entry has changed and the entry activated * * Return value * void */ GtkWidget *main_dictionary_drop_down_new(char *mod_name, char *old_key) { gint count = 9, i; gchar *new_key; gchar *key = NULL; GtkWidget *menu; menu = gtk_menu_new(); if (!settings.havedict || !mod_name) return NULL; if (strcmp(settings.DictWindowModule, mod_name)) { xml_set_value("Xiphos", "modules", "dict", mod_name); settings.DictWindowModule = xml_get_value( "modules", "dict"); } key = g_strdup((gchar *)gtk_entry_get_text(GTK_ENTRY(widgets.entry_dict))); XI_message(("\nold_key: %s\nkey: %s", old_key, key)); backend->set_module_key(mod_name, key); g_free(key); key = backend->get_module_key(); xml_set_value("Xiphos", "keys", "dictionary", key); settings.dictkey = xml_get_value("keys", "dictionary"); main_check_unlock(mod_name, TRUE); backend->set_module_key(mod_name, key); backend->display_mod->display(); new_key = g_strdup((char *)backend->display_mod->getKeyText()); for (i = 0; i < (count / 2) + 1; i++) { (*backend->display_mod)--; } for (i = 0; i < count; i++) { free(new_key); (*backend->display_mod)++; new_key = g_strdup((char *)backend->display_mod->getKeyText()); /* add menu item */ GtkWidget *item = gtk_menu_item_new_with_label((gchar *)new_key); gtk_widget_show(item); g_signal_connect(G_OBJECT(item), "activate", G_CALLBACK(dict_key_list_select), g_strdup(new_key)); gtk_container_add(GTK_CONTAINER(menu), item); } free(new_key); g_free(key); return menu; } /****************************************************************************** * Name * main_dictionary_button_clicked * * Synopsis * #include "main/sword.h" * * void main_dictionary_button_clicked(gint direction) * * Description * The back or foward dictinary key button was clicked. * the module key is set to the current dictkey. * then the module is incremented or decremented. * the new key is returned from the module and the dictionary entry is set * to the new key. The entry is then activated. * * Return value * void */ void main_dictionary_button_clicked(gint direction) { gchar *key = NULL; if (!settings.havedict || !settings.DictWindowModule) return; backend->set_module_key(settings.DictWindowModule, settings.dictkey); if (direction == 0) (*backend->display_mod)--; else (*backend->display_mod)++; key = g_strdup((char *)backend->display_mod->getKeyText()); gtk_entry_set_text(GTK_ENTRY(widgets.entry_dict), key); gtk_widget_activate(widgets.entry_dict); g_free(key); } void main_display_book(const char *mod_name, const char *key) { if (!settings.havebook || !mod_name) return; if (key == NULL) key = "0"; XI_message(("main_display_book\nmod_name: %s\nkey: %s", mod_name, key)); if (!backend->is_module(mod_name)) return; if (!settings.book_mod) settings.book_mod = g_strdup((char *)mod_name); if (strcmp(settings.book_mod, mod_name)) { xml_set_value("Xiphos", "modules", "book", mod_name); gui_reassign_strdup(&settings.book_mod, (gchar *)mod_name); } if (!isdigit(key[0])) { xml_set_value("Xiphos", "keys", "book", key); settings.book_key = xml_get_value("keys", "book"); backend->set_module(mod_name); backend->set_treekey(0); settings.book_offset = backend->treekey_set_key((char *)key); } else { settings.book_offset = atol(key); if (settings.book_offset < 4) settings.book_offset = 4; xml_set_value("Xiphos", "keys", "book", key); settings.book_key = xml_get_value("keys", "book"); xml_set_value("Xiphos", "keys", "offset", key); backend->set_module(mod_name); backend->set_treekey(settings.book_offset); } main_check_unlock(mod_name, TRUE); backend->display_mod->display(); main_setup_navbar_book(settings.book_mod, settings.book_offset); //if (settings.browsing) gui_update_tab_struct(NULL, NULL, NULL, mod_name, NULL, key, FALSE, settings.showtexts, settings.showpreview, settings.showcomms, settings.showdicts); } void main_display_commentary(const char *mod_name, const char *key) { if (!settings.havecomm || !settings.comm_showing) return; if (!mod_name) mod_name = ((settings.browsing && (cur_passage_tab != NULL)) ? g_strdup(cur_passage_tab->commentary_mod) : xml_get_value("modules", "comm")); if (!mod_name || !backend->is_module(mod_name)) return; int modtype = backend->module_type(mod_name); if ((modtype != COMMENTARY_TYPE) && (modtype != PERCOM_TYPE)) return; // what are we doing here? if (!settings.CommWindowModule) settings.CommWindowModule = g_strdup((gchar *)mod_name); settings.comm_showing = TRUE; settings.whichwindow = COMMENTARY_WINDOW; if (strcmp(settings.CommWindowModule, mod_name)) { xml_set_value("Xiphos", "modules", "comm", mod_name); gui_reassign_strdup(&settings.CommWindowModule, (gchar *)mod_name); // handle a conf directive "Companion=This,That,TheOther" char *companion = main_get_mod_config_entry(mod_name, "Companion"); gchar **name_set = (companion ? g_strsplit(companion, ",", -1) : NULL); if (companion && (!companion_activity) && name_set[0] && *name_set[0] && backend->is_module(name_set[0]) && ((settings.MainWindowModule == NULL) || strcmp(name_set[0], settings.MainWindowModule))) { companion_activity = TRUE; gint name_length = g_strv_length(name_set); char *companion_question = g_strdup_printf(_("Module %s has companion modules:\n%s.\n" "Would you like to open these as well?%s"), mod_name, companion, ((name_length > 1) ? _("\n\nThe first will open in the main window\n" "and others in separate windows.") : "")); if (gui_yes_no_dialog(companion_question, NULL)) { main_display_bible(name_set[0], key); for (int i = 1; i < name_length; i++) { main_dialogs_open(name_set[i], key, FALSE); } } g_free(companion_question); companion_activity = FALSE; } if (name_set) g_strfreev(name_set); if (companion) g_free(companion); } main_check_unlock(mod_name, TRUE); valid_scripture_key = main_is_Bible_key(mod_name, key); backend->set_module_key(mod_name, key); backend->display_mod->display(); valid_scripture_key = TRUE; // leave nice for future use. //if (settings.browsing) gui_update_tab_struct(NULL, mod_name, NULL, NULL, NULL, NULL, TRUE, settings.showtexts, settings.showpreview, settings.showcomms, settings.showdicts); } void main_display_dictionary(const char *mod_name, const char *key) { const gchar *old_key, *feature; // for devotional use. gchar buf[10]; if (!settings.havedict || !mod_name) return; XI_message(("main_display_dictionary\nmod_name: %s\nkey: %s", mod_name, key)); if (!backend->is_module(mod_name)) return; if (!settings.DictWindowModule) settings.DictWindowModule = g_strdup((gchar *)mod_name); if (key == NULL) key = (char *)"Grace"; feature = (char *)backend->get_mgr()->getModule(mod_name)->getConfigEntry("Feature"); // turn on "all strong's" iff we have that kind of dictionary. if (feature && (!strcmp(feature, "HebrewDef") || !strcmp(feature, "GreekDef"))) gtk_widget_show(widgets.all_strongs); else gtk_widget_hide(widgets.all_strongs); if (strcmp(settings.DictWindowModule, mod_name)) { // new dict -- is it actually a devotional? time_t curtime; if (feature && !strcmp(feature, "DailyDevotion")) { if ((strlen(key) != 5) || // blunt tests. (key[0] < '0') || (key[0] > '9') || (key[1] < '0') || (key[1] > '9') || (key[2] != '.') || (key[3] < '0') || (key[3] > '9') || (key[4] < '0') || (key[4] > '9')) { // not MM.DD struct tm *loctime; curtime = time(NULL); loctime = localtime(&curtime); strftime(buf, 10, "%m.%d", loctime); key = buf; } } xml_set_value("Xiphos", "modules", "dict", mod_name); gui_reassign_strdup(&settings.DictWindowModule, (gchar *)mod_name); } // old_key is uppercase key = g_utf8_strup(key, -1); old_key = gtk_entry_get_text(GTK_ENTRY(widgets.entry_dict)); if (!strcmp(old_key, key)) main_dictionary_entry_changed(settings.DictWindowModule); else { gtk_entry_set_text(GTK_ENTRY(widgets.entry_dict), key); gtk_widget_activate(widgets.entry_dict); } //if (settings.browsing) gui_update_tab_struct(NULL, NULL, mod_name, NULL, key, NULL, settings.comm_showing, settings.showtexts, settings.showpreview, settings.showcomms, settings.showdicts); } void main_display_bible(const char *mod_name, const char *key) { gchar *bs_key = g_strdup(key); // avoid tab data corruption problem. /* keeps us out of a crash causing loop */ extern guint scroll_adj_signal; extern GtkAdjustment *adjustment; if (adjustment) g_signal_handler_block(adjustment, scroll_adj_signal); if (!gtk_widget_get_realized(GTK_WIDGET(widgets.html_text))) return; if (!mod_name) mod_name = ((settings.browsing && (cur_passage_tab != NULL)) ? g_strdup(cur_passage_tab->text_mod) : xml_get_value("modules", "bible")); if (!settings.havebible || !mod_name) return; if (!backend->is_module(mod_name)) return; int modtype = backend->module_type(mod_name); if (modtype != TEXT_TYPE) return; // what are we doing here? if (!settings.MainWindowModule) settings.MainWindowModule = g_strdup((gchar *)mod_name); if (strcmp(settings.currentverse, key)) { xml_set_value("Xiphos", "keys", "verse", key); settings.currentverse = xml_get_value( "keys", "verse"); } if (strcmp(settings.MainWindowModule, mod_name)) { xml_set_value("Xiphos", "modules", "bible", mod_name); gui_reassign_strdup(&settings.MainWindowModule, (gchar *)mod_name); // handle a conf directive "Companion=This,That,TheOther" char *companion = main_get_mod_config_entry(mod_name, "Companion"); gchar **name_set = (companion ? g_strsplit(companion, ",", -1) : NULL); if (companion && (!companion_activity) && name_set[0] && *name_set[0] && backend->is_module(name_set[0]) && ((settings.CommWindowModule == NULL) || strcmp(name_set[0], settings.CommWindowModule))) { companion_activity = TRUE; gint name_length = g_strv_length(name_set); char *companion_question = g_strdup_printf(_("Module %s has companion modules:\n%s.\n" "Would you like to open these as well?%s"), mod_name, companion, ((name_length > 1) ? _("\n\nThe first will open in the main window\n" "and others in separate windows.") : "")); if (gui_yes_no_dialog(companion_question, NULL)) { main_display_commentary(name_set[0], key); for (int i = 1; i < name_length; i++) { main_dialogs_open(name_set[i], key, FALSE); } } g_free(companion_question); companion_activity = FALSE; } if (name_set) g_strfreev(name_set); if (companion) g_free(companion); navbar_versekey.module_name = g_string_assign(navbar_versekey.module_name, settings.MainWindowModule); navbar_versekey.key = g_string_assign(navbar_versekey.key, settings.currentverse); main_search_sidebar_fill_bounds_combos(); } settings.whichwindow = MAIN_TEXT_WINDOW; main_check_unlock(mod_name, TRUE); valid_scripture_key = main_is_Bible_key(mod_name, key); if (backend->module_has_testament(mod_name, backend->get_key_testament(mod_name, key))) { backend->set_module_key(mod_name, key); backend->display_mod->display(); } else { gchar *val_key = NULL; if (backend->get_key_testament(mod_name, key) == 1) val_key = main_update_nav_controls(mod_name, "Matthew 1:1"); else val_key = main_update_nav_controls(mod_name, "Genesis 1:1"); backend->set_module_key(mod_name, val_key); backend->display_mod->display(); g_free(val_key); } valid_scripture_key = TRUE; // leave nice for future use. XI_message(("mod_name = %s", mod_name)); //if (settings.browsing) { gui_update_tab_struct(mod_name, NULL, NULL, NULL, NULL, NULL, settings.comm_showing, settings.showtexts, settings.showpreview, settings.showcomms, settings.showdicts); gui_set_tab_label(settings.currentverse, FALSE); //} gui_change_window_title(settings.MainWindowModule); // (called _after_ tab data updated so not overwritten with old tab) /* * change parallel verses */ if (settings.dockedInt) main_update_parallel_page(); else { if (settings.showparatab) gui_keep_parallel_tab_in_sync(); else gui_keep_parallel_dialog_in_sync(); } // multicast now, iff user has not asked for keyboard-only xmit. if (!settings.bs_keyboard) biblesync_prep_and_xmit(mod_name, bs_key); g_free(bs_key); if (adjustment) g_signal_handler_unblock(adjustment, scroll_adj_signal); } /****************************************************************************** * Name * main_display_devotional * * Synopsis * #include "main/sword.h" * * void main_display_devotional(void) * * Description * * * Return value * void */ void main_display_devotional(void) { gchar buf[10]; gchar *prettybuf; time_t curtime; struct tm *loctime; gchar *text; /* * This makes sense only if you've installed & defined one. */ if (settings.devotionalmod == NULL) { GList *glist = get_list(DEVOTION_LIST); if (g_list_length(glist) != 0) { xml_set_value("Xiphos", "modules", "devotional", (char *)glist->data); gui_reassign_strdup(&settings.devotionalmod, (gchar *)glist->data); } else { gui_generic_warning(_("Daily devotional was requested, but there are none installed.")); } } /* * Get the current time, converted to local time. */ curtime = time(NULL); loctime = localtime(&curtime); strftime(buf, 10, "%m.%d", loctime); prettybuf = g_strdup_printf("<b>%s %d</b>", gettext(month_names[loctime->tm_mon]), loctime->tm_mday); text = backend->get_render_text(settings.devotionalmod, buf); if (text) { main_entry_display(settings.show_previewer_in_sidebar ? sidebar.html_viewer_widget : widgets.html_previewer_text, settings.devotionalmod, text, prettybuf, TRUE); g_free(text); } g_free(prettybuf); } void main_setup_displays(void) { backend->textDisplay = new GTKChapDisp(widgets.html_text, backend); backend->commDisplay = new GTKEntryDisp(widgets.html_comm, backend); backend->bookDisplay = new GTKEntryDisp(widgets.html_book, backend); backend->dictDisplay = new GTKEntryDisp(widgets.html_dict, backend); } const char *main_get_module_language(const char *module_name) { return backend->module_get_language(module_name); } /****************************************************************************** * Name * main_check_for_option * * Synopsis * #include ".h" * * gint main_check_for_option(const gchar * mod_name, const gchar * key, const gchar * option) * * Description * get any option for a module * * Return value * gint */ gint main_check_for_option(const gchar *mod_name, const gchar *key, const gchar *option) { return backend->has_option(mod_name, key, option); } /****************************************************************************** * Name * main_check_for_global_option * * Synopsis * #include ".h" * * gint main_check_for_global_option(const gchar * mod_name, const gchar * option) * * Description * get global options for a module * * Return value * gint */ gint main_check_for_global_option(const gchar *mod_name, const gchar *option) { return backend->has_global_option(mod_name, option); } /****************************************************************************** * Name * main_is_module * * Synopsis * #include "main/module.h" * * int main_is_module(char * mod_name) * * Description * check for presents of a module by name * * Return value * int */ int main_is_module(char *mod_name) { return backend->is_module(mod_name); } /****************************************************************************** * Name * main_has_search_framework * * Synopsis * #include "main/module.h" * * int main_has_search_framework(char * mod_name) * * Description * tells us whether CLucene is available * * Return value * int (boolean) */ int main_has_search_framework(char *mod_name) { SWMgr *mgr = backend->get_mgr(); SWModule *mod = mgr->getModule(mod_name); return (mod && mod->hasSearchFramework()); } /****************************************************************************** * Name * main_optimal_search * * Synopsis * #include "main/module.h" * * int main_optimal_search(char * mod_name) * * Description * tells us whether a CLucene index exists * * Return value * int (boolean) */ int main_optimal_search(char *mod_name) { SWMgr *mgr = backend->get_mgr(); SWModule *mod = mgr->Modules.find(mod_name)->second; return mod->isSearchOptimallySupported("God", -4, 0, 0); } char *main_get_mod_config_entry(const char *module_name, const char *entry) { return backend->get_config_entry((char *)module_name, (char *)entry); } char *main_get_mod_config_file(const char *module_name, const char *moddir) { #ifdef SWORD_SHOULD_HAVE_A_WAY_TO_GET_A_CONF_FILENAME_FROM_A_MODNAME return backend->get_config_file((char *)module_name, (char *)moddir); #else GDir *dir; SWBuf name; name = moddir; name += "/mods.d"; if ((dir = g_dir_open(name, 0, NULL))) { const gchar *ent; g_dir_rewind(dir); while ((ent = g_dir_read_name(dir))) { name = moddir; name += "/mods.d/"; name += ent; SWConfig *config = new SWConfig(name.c_str()); if (config->getSections().find(module_name) != config->getSections().end()) { gchar *ret_name = g_strdup(ent); g_dir_close(dir); delete config; return ret_name; } else delete config; } g_dir_close(dir); } return NULL; #endif } int main_is_mod_rtol(const char *module_name) { char *direction = backend->get_config_entry((char *)module_name, (char *)"Direction"); return (direction && !strcmp(direction, "RtoL")); } /****************************************************************************** * Name * main_has_cipher_tag * * Synopsis * #include "main/.h" * * int main_has_cipher_tag(char *mod_name) * * Description * * * Return value * int */ int main_has_cipher_tag(char *mod_name) { gchar *cipherkey = backend->get_config_entry(mod_name, (char *)"CipherKey"); int retval = (cipherkey != NULL); g_free(cipherkey); return retval; } #define CIPHER_INTRO \ _("<b>Locked Module.</b>\n\n<u>You are opening a module which requires a <i>key</i>.</u>\n\nThe module is locked, meaning that the content is encrypted by its publisher, and you must enter its key in order for the content to become useful. This key should have been received by you on the web page which confirmed your purchase, or perhaps sent via email after purchase.\n\nPlease enter the key in the dialog.") /****************************************************************************** * Name * main_check_unlock * * Synopsis * #include "main/.h" * * int main_check_unlock(const char *mod_name) * * Description * * * Return value * int */ void main_check_unlock(const char *mod_name, gboolean conditional) { gchar *cipher_old = main_get_mod_config_entry(mod_name, "CipherKey"); /* if forced by the unlock menu item, or it's present but empty... */ if (!conditional || ((cipher_old != NULL) && (*cipher_old == '\0'))) { if (conditional) { GtkWidget *dialog; dialog = gtk_message_dialog_new_with_markup(NULL, /* no need for a parent window */ GTK_DIALOG_DESTROY_WITH_PARENT, GTK_MESSAGE_INFO, GTK_BUTTONS_OK, CIPHER_INTRO); g_signal_connect_swapped(dialog, "response", G_CALLBACK(gtk_widget_destroy), dialog); gtk_widget_show(dialog); } gchar *cipher_key = gui_add_cipher_key(mod_name, cipher_old); if (cipher_key) { ModuleCacheErase(mod_name); redisplay_to_realign(); g_free(cipher_key); } } g_free(cipher_old); } /****************************************************************************** * Name * main_get_striptext * * Synopsis * #include "main/sword.h" * * char *main_get_striptext(char *module_name, char *key) * * Description * * * Return value * char * */ char *main_get_striptext(char *module_name, char *key) { return backend->get_strip_text(module_name, key); } /****************************************************************************** * Name * main_get_rendered_text * * Synopsis * #include "main/sword.h" * * char *main_get_rendered_text(char *module_name, char *key) * * Description * * * Return value * char * */ char *main_get_rendered_text(const char *module_name, const char *key) { return backend->get_render_text(module_name, key); } /****************************************************************************** * Name * main_get_raw_text * * Synopsis * #include "main/sword.h" * * char *main_get_raw_text(char *module_name, char *key) * * Description * * * Return value * char * */ char *main_get_raw_text(char *module_name, char *key) { return backend->get_raw_text(module_name, key); } /****************************************************************************** * Name * main_get_mod_type * * Synopsis * #include "main/module.h" * * int main_get_mod_type(char * mod_name) * * Description * * * Return value * int */ int main_get_mod_type(char *mod_name) { return backend->module_type(mod_name); } /****************************************************************************** * Name * main_get_module_description * * Synopsis * #include "main/module.h" * * gchar *main_get_module_description(gchar * module_name) * * Description * * * Return value * gchar * */ const char *main_get_module_description(const char *module_name) { return backend->module_description(module_name); } /****************************************************************************** * Name * main_format_number * * Synopsis * #include "main/sword.h" * char *main_format_number(int x) * * Description * returns a digit string in either "latinate arabic" (normal) or * farsi characters. * re_encode_digits is chosen at startup in settings.c. * caller must free allocated string space when finished with it. * * Return value * char * */ int re_encode_digits = FALSE; char * main_format_number(int x) { char *digits = g_strdup_printf("%d", x); if (re_encode_digits) { // // "\333\260" is farsi "zero". // char *d, *f, *farsi = g_new(char, 2 * (strlen(digits) + 1)); // 2 "chars" per farsi-displayed digit + slop. for (d = digits, f = farsi; *d; ++d) { *(f++) = '\333'; *(f++) = '\260' + ((*d) - '0'); } *f = '\0'; g_free(digits); return farsi; } return digits; } /****************************************************************************** * Name * main_flush_widgets_content * * Synopsis * #include "main/sword.h" * void main_flush_widgets_content() * * Description * cleans content from all subwindow widgets. * * Return value * int */ void main_flush_widgets_content(void) { GString *blank_html_content = g_string_new(NULL); g_string_printf(blank_html_content, "<html><head></head><body bgcolor=\"%s\" text=\"%s\"> </body></html>", settings.bible_bg_color, settings.bible_text_color); if (gtk_widget_get_realized(GTK_WIDGET(widgets.html_text))) HtmlOutput(blank_html_content->str, widgets.html_text, NULL, NULL); if (gtk_widget_get_realized(GTK_WIDGET(widgets.html_comm))) HtmlOutput(blank_html_content->str, widgets.html_comm, NULL, NULL); if (gtk_widget_get_realized(GTK_WIDGET(widgets.html_dict))) HtmlOutput(blank_html_content->str, widgets.html_dict, NULL, NULL); if (gtk_widget_get_realized(GTK_WIDGET(widgets.html_book))) HtmlOutput(blank_html_content->str, widgets.html_book, NULL, NULL); g_string_free(blank_html_content, TRUE); } /****************************************************************************** * Name * main_is_Bible_key * * Synopsis * #include "main/sword.h" * void main_is_Bible_key() * * Description * returns boolean status of whether input is a legit Bible key. * * Return value * gboolean */ gboolean main_is_Bible_key(const gchar *name, const gchar *key) { return (gboolean)(backend->is_Bible_key(name, key, settings.currentverse) != 0); } /****************************************************************************** * Name * main_get_osisref_from_key * * Synopsis * #include "main/sword.h" * void main_get_osisref_from_key() * * Description * returns OSISRef-formatted key value. * * Return value * const char * */ const char * main_get_osisref_from_key(const char *module, const char *key) { return backend->get_osisref_from_key(module, key); }
crosswire/xiphos
src/main/sword.cc
C++
gpl-2.0
45,237
<?php global $PPT,$PPTDesign; PremiumPress_Header(); ?> <div id="premiumpress_box1" class="premiumpress_box premiumpress_box-100"><div class="premiumpress_boxin"><div class="header"> <h3><img src="<?php echo $GLOBALS['template_url']; ?>/images/premiumpress/h-ico/GeneralPreferences.png" align="middle"> Display Setup</h3> <ul> <li><a rel="premiumpress_tab1" href="#" class="active">Layout</a></li> <li><a rel="premiumpress_tab6" href="#">Home</a></li> <!--<li><a rel="premiumpress_tab2" href="#">Search</a></li>--> <li><a rel="premiumpress_tab3" href="#">Sidebar</a></li> <li><a rel="premiumpress_tab4" href="#">Coupon Page</a></li> <li><a rel="premiumpress_tab5" href="#">Sliders</a></li> </ul> </div> <style> select { border-radius: 0px; -webkit-border-radius: 0px; -moz-border-radius: 0px; } </style> <form method="post" name="directorypress" target="_self" > <input name="admin_page" type="hidden" value="directorypress_setup" /> <input name="submitted" type="hidden" value="yes" /> <input name="setup" type="hidden" value="1" /> <input name="featured" type="hidden" value="1" /> <input name="featured1" type="hidden" value="1" /> <input name="listbox" type="hidden" value="yes" /> <input name="featuredstores" type="hidden" value="yes" /> <div id="premiumpress_tab1" class="content"> <table class="maintable" style="background:white;"> <tr class="mainrow"> <td></td> <td class="forminp"> <p><b>Coupon Display</b></p> <select name="adminArray[system]" class="small-input" style="width: 240px; font-size:14px;"> <option value="clicktoreveal" <?php if(get_option("system") == "clicktoreveal"){ echo "selected='selected'"; } ?>>Click To Reveal</option> <option value="normal" <?php if(get_option("system") == "normal"){ echo "selected='selected'"; } ?>>Click To Copy</option> <option value="link" <?php if(get_option("system") == "link"){ echo "selected='selected'"; } ?>>Link Display</option> </select> <br /> <small>Select which type of coupon display you wish to use.</small> </td> <td class="forminp"><img src="<?php echo IMAGE_PATH; ?>/help1/c3.png"> </td> </tr> <tr class="mainrow"><td></td><td class="forminp"> <b>Select theme layout (2 or 3 columns)</b> <table width="100%" border="1"> <tr> <td style="width:150px;"><img src="<?php echo $GLOBALS['template_url']; ?>/PPT/img/layout2.gif" /><br /><center> <input name="display_themecolumns" type="radio" value="2" <?php if(get_option("display_themecolumns") =="2" || get_option("display_themecolumns") =="" ){ print "checked";} ?> />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</center></td> <td style="width:150px;"><img src="<?php echo $GLOBALS['template_url']; ?>/PPT/img/layout3.gif" /><br /><center> <input name="display_themecolumns" type="radio" value="3" <?php if(get_option("display_themecolumns") =="3"){ print "checked";} ?> />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</center> </td> </tr> </table> </td><td class="forminp"><img src="<?php echo IMAGE_PATH; ?>/help1/c4.png"></td></tr> <?php /***************************************** */ ?> <tr class="mainrow"><td></td> <td class="forminp"> <p><b>Footer Text</b></p> <textarea name="adminArray[footer_text]" type="text" style="width:240px;height:150px;"><?php echo stripslashes(get_option("footer_text")); ?></textarea><br /> <small>This will be added to the bottom of your website.</small> </td><td class="forminp"><img src="<?php echo IMAGE_PATH; ?>/help1/a16.png"></td></tr> <?php /***************************************** */ ?> <tr> <td colspan="3"><p><input class="premiumpress_button" type="submit" value="<?php _e('Save changes','cp')?>" style="color:white;" /></p></td> </tr> </table> </div> <div id="premiumpress_tab6" class="content"> <table class="maintable" style="background:white;"> <?php /***************************************** */ ?> <tr class="mainrow"><td></td><td class="forminp"> <p><b>Website Categories Box</b></p> <select name="adminArray[display_homecats]" style="width: 240px; font-size:14px;"> <option value="yes" <?php if(get_option("display_homecats") =="yes"){ print "selected";} ?>>Show</option> <option value="no" <?php if(get_option("display_homecats") =="no"){ print "selected";} ?>>Hide</option> </select><br /> <small>Show/Hide the home page categories area.</small> </td><td class="forminp"><img src="<?php echo IMAGE_PATH; ?>/help1/a1.png"></td></tr> <?php /***************************************** */ ?> <?php if(get_option("display_homecats") =="yes"){ ?> <tr class="mainrow"><td></td><td class="forminp"> <p><b>Order Categories By </b></p> <select name="adminArray[display_homecats_orderby]" style="width: 240px; font-size:14px;"> <option value="id" <?php if(get_option("display_homecats_orderby") =="id"){ print "selected";} ?>>ID (Ascending Order)</option> <option value="id&order=desc" <?php if(get_option("display_homecats_orderby") =="id&order=desc"){ print "selected";} ?>>ID (Descending Order)</option> <option value="name" <?php if(get_option("display_homecats_orderby") =="name"){ print "selected";} ?>>Name (Ascending Order)</option> <option value="name&order=desc" <?php if(get_option("display_homecats_orderby") =="name&order=desc"){ print "selected";} ?>>Name (Descending Order)</option> <option value="slug" <?php if(get_option("display_homecats_orderby") =="slug"){ print "selected";} ?>>Slug (Ascending Order)</option> <option value="slug&order=desc" <?php if(get_option("display_homecats_orderby") =="slug&order=desc"){ print "selected";} ?>>Slug (Descending Order)</option> <option value="count" <?php if(get_option("display_homecats_orderby") =="count"){ print "selected";} ?>>Count (Ascending Order)</option> <option value="count&order=desc" <?php if(get_option("display_homecats_orderby") =="count&order=desc"){ print "selected";} ?>>Count (Descending Order)</option> <!-- <option value="group" <?php if(get_option("display_homecats_orderby") =="group"){ print "selected";} ?>>Group (Ascending Order)</option> <option value="group&order=desc" <?php if(get_option("display_homecats_orderby") =="group&order=desc"){ print "selected";} ?>>Group (Descending Order)</option>--> </select><br /> <small>select in what order to display the categories.</small> </td><td class="forminp"><img src="<?php echo IMAGE_PATH; ?>/help1/a2.png"></td></tr> <?php /***************************************** */ ?> <tr class="mainrow"> <td></td> <td class="forminp"> <p><b>Display Sub Categories</b></p> <select name="adminArray[display_50_subcategories]" style="width: 240px; font-size:14px;"> <option value="yes" <?php if(get_option("display_50_subcategories") =="yes"){ print "selected";} ?>>Show</option> <option value="no" <?php if(get_option("display_50_subcategories") =="no"){ print "selected";} ?>>Hide</option> </select><br /> <small>Show/Hide the list of sub categories under the main category link.</small> </td><td class="forminp"><img src="<?php echo IMAGE_PATH; ?>/help1/a3.png"></td></tr> <?php } ?> <tr class="mainrow"><td></td><td class="forminp"> <b>Home Page Image</b> <p style="width: 240px;"><input type="checkbox" class="checkbox" name="display_featured_image_enable" value="1" <?php if(get_option("display_featured_image_enable") =="1"){ print "checked";} ?> /> Enable Featured Image</p><br /> <small>Add your own image to the front page</small> <?php if(get_option("display_featured_image_enable") =="1"){ ?> <b>Featured Image URL</b><br /> <input name="adminArray[display_featured_image_url]" type="text" style="width: 240px; font-size:14px;" value="<?php echo get_option("display_featured_image_url"); ?>" /><br /> <small>Enter the full URL for the image you would like to display.</small> <br /><b>Featured Image Link URL</b><br /> <input name="adminArray[display_featured_image_link]" type="text" style="width: 240px; font-size:14px;" value="<?php echo get_option("display_featured_image_link"); ?>" /><br /> <small>Enter the link you would like to have when someone clicks on the image.</small> <?php } ?> </td><td class="forminp"><img src="<?php echo IMAGE_PATH; ?>/help1/a0.png"></td></tr> <tr> <td colspan="3"><p><input class="premiumpress_button" type="submit" value="<?php _e('Save changes','cp')?>" style="color:white;" /></p></td> </tr> </table> </div> <div id="premiumpress_tab2" class="content"> <table class="maintable" style="background:white;"> <tr> <td colspan="4"><p><input class="premiumpress_button" type="submit" value="<?php _e('Save changes','cp')?>" style="color:white;" /></p></td> </tr> </table> </div> <div id="premiumpress_tab3" class="content"> <table class="maintable" style="background:white;"> <?php /***************************************** */ ?> <tr class="mainrow"> <td></td> <td class="forminp"> <p><b>Display Recent Articles</b></p> <select name="adminArray[display_sidebar_articles]" style="width: 240px; font-size:14px;"> <option value="yes" <?php if(get_option("display_sidebar_articles") =="yes"){ print "selected";} ?>>Show</option> <option value="no" <?php if(get_option("display_sidebar_articles") =="no"){ print "selected";} ?>>Hide</option> </select><br /><small>Show/Hide the sidebar articles box.</small> <br /> <input name="adminArray[display_sidebar_articles_count]" value="<?php echo get_option("display_sidebar_articles_count"); ?>" class="txt" style="width:50px; font-size:14px;" type="text"> # Articles </td><td class="forminp"><img src="<?php echo IMAGE_PATH; ?>/help1/a7.png"></td></tr> <?php /***************************************** */ ?> <tr class="mainrow"> <td class="titledesc" valign="top">Featured Stores <br /><br /> <small>Select the stores you wish to be displayed as featured on your sidebar. </small> </td> <td class="forminp" valign="top"> <?php $Maincategories= get_categories('use_desc_for_title=1&hide_empty=0&hierarchical=1'); $Maincatcount = count($Maincategories); $SAVED_DISPLAY = get_option("featured_stores"); $i=0; foreach ($Maincategories as $Maincat) { if($Maincat->parent !=0){ print '<div style="background:#efefef; padding:8px; border:1px solid #ddd; font-size:12px; font-weight:bold; float:left; width:270px; margin-right:10px; "> <input name="featured_stores['.$i.'][ID]" type="checkbox" value="'.$Maincat->cat_ID.'"'; if( isset($SAVED_DISPLAY[$i][ID]) ){ print 'checked="checked"'; } print 'style="margin-right:10px;">' . $Maincat->cat_name.' '; print '<br><small>Order: <input name="featured_stores['.$i.'][ORDER]" type="text" value="'; if(isset($SAVED_DISPLAY[$i][ORDER]) && is_numeric($SAVED_DISPLAY[$i][ORDER]) ){ print $SAVED_DISPLAY[$i][ORDER]; } print '" style="width:30px;font-size:11px;"> </small>'; print ' </div> '; $i++; } } ?> </td> </tr> <tr class="mainrow"><td colspan="3"> <center><a href="widgets.php"><img src="<?php echo $GLOBALS['template_url']; ?>/template_couponpress/images/help1/a23.png"></a></center> </td> <tr> <tr> <td colspan="3"><p><input class="premiumpress_button" type="submit" value="<?php _e('Save changes','cp')?>" style="color:white;" /></p></td> </tr> </table> </div> <div id="premiumpress_tab4" class="content"> <table class="maintable" style="background:white;"> <tr class="mainrow"> <td></td> <td class="forminp"> <p><b>Member information box</b></p> <select name="adminArray[display_sidebar_memberinfo]" style="width: 240px; font-size:14px;"> <option value="yes" <?php if(get_option("display_sidebar_memberinfo") =="yes"){ print "selected";} ?>>Show</option> <option value="no" <?php if(get_option("display_sidebar_memberinfo") =="no"){ print "selected";} ?>>Hide</option> </select><br /><small>Show/Hide the sidebar member information box.</small> <br /> </td><td class="forminp"><img src="<?php echo IMAGE_PATH; ?>/help1/c1.png"></td></tr> <tr class="mainrow"> <td></td> <td class="forminp"> <p><b>Related Coupons</b></p> <select name="adminArray[display_related_coupons]" style="width: 240px; font-size:14px;"> <option value="yes" <?php if(get_option("display_related_coupons") =="yes"){ print "selected";} ?>>Show</option> <option value="no" <?php if(get_option("display_related_coupons") =="no"){ print "selected";} ?>>Hide</option> </select><br /><small>Show/Hide the related coupons on the coupon page.</small> <br /> </td><td class="forminp"><img src="<?php echo IMAGE_PATH; ?>/help1/c4.png"></td></tr> <?php /***************************************** */ ?> <tr class="mainrow"> <td></td><td class="forminp"> <p><b> Google Maps Box</b></p> <select name="adminArray[display_googlemaps]" style="width: 240px; font-size:14px;"> <option value="yes2" <?php if(get_option("display_googlemaps") =="yes2"){ print "selected";} ?>>Show - Interactive Map</option> <option value="no" <?php if(get_option("display_googlemaps") =="no"){ print "selected";} ?>>Hide Google Maps</option> </select><br /> <small><b>Remember</b>Google maps will only display for listings that have a map_location custom field value entered. The interative map requires long/Lat coordinates and isnt recommended for unexperienced users.</small> </td><td class="forminp"><img src="<?php echo IMAGE_PATH; ?>/help1/c2.png"></td></tr> <?php /***************************************** */ ?> <tr> <td colspan="3"><p><input class="premiumpress_button" type="submit" value="Save Changes" style="color:white;" /></p></td> </tr> </table> </div> <div id="premiumpress_tab5" class="content"> <table class="maintable" style="background:white;"> <?php /***************************************** */ ?> <tr class="mainrow"> <td></td><td class="forminp"> <p><b> Enable Home Page Slider </b></p> <select name="adminArray[PPT_slider]" style="width: 240px; font-size:14px;"> <option value="off" <?php if(get_option("PPT_slider") =="off"){ print "selected";} ?>>Disable All Sliders</option> <option value="s1" <?php if(get_option("PPT_slider") =="s1"){ print "selected";} ?>>Featured Content Slider (Full Width)</option> <option value="s2" <?php if(get_option("PPT_slider") =="s2"){ print "selected";} ?>>Half Content Slider</option> </select> <p><b> Slider Style</b></p> <select name="adminArray[PPT_slider_style]" style="width: 240px; font-size:14px;"> <option value="1" <?php if(get_option("PPT_slider_style") =="1"){ print "selected";} ?>>Style 1 (image size: 650x X 265px)</option> <option value="2" <?php if(get_option("PPT_slider_style") =="2"){ print "selected";} ?>>Style 2 (image size: 960x X 360px)</option> <option value="3" <?php if(get_option("PPT_slider_style") =="3"){ print "selected";} ?>>Style 3 (image size: 960x X 360px)</option> <option value="4" <?php if(get_option("PPT_slider_style") =="4"){ print "selected";} ?>>Style 4 (image size: 960x X 360px)</option> <option value="5" <?php if(get_option("PPT_slider_style") =="5"){ print "selected";} ?>>Style 5 (image size: 960x X 360px)</option> </select><br /> <p><b> Slider Content Source</b></p> <select name="adminArray[PPT_slider_items]" style="width: 240px; font-size:14px;"> <option value="manual" <?php if(get_option("PPT_slider_items") =="manual"){ print "selected";} ?>>Manually Configure Slides</option> <option value="featured" <?php if(get_option("PPT_slider_items") =="featured"){ print "selected";} ?>>Use Featured Posts</option> </select><br /> </td><td class="forminp"><img src="<?php echo IMAGE_PATH; ?>/help1/a21.png"></td></tr> <?php /***************************************** */ ?> <tr> <td colspan="3"><p><input class="premiumpress_button" type="submit" value="<?php _e('Save changes','cp')?>" style="color:white;" /></p></td> </tr> </table> </form> <div id="DisplayImages" style="display:none;"></div><input type="hidden" id="searchBox1" name="searchBox1" value="" /> <div id="PPT-sliderbox"></div> <div id="PPT-sliderboxAdd" style="margin-left:20px;display:none"> <form method="post" target="_self" > <input name="admin_slider" type="hidden" value="slider" /> <input type="hidden" id="ppsedit" value="0"> <table width="100%" border="0"> <tr> <td valign="top"><b>Slider Title</b> <br /> <input type="text" name="s1" id="pps1" style="width: 200px; font-size:14px;" class="txt" /> </td> <td><b>Title Description</b> <small>(max. 10 words)</small> <br /> <textarea name="s3" id="pps3" style="width: 200px; font-size:14px; height:70px;" class="txt"></textarea> </td> <td><b>Main Description</b> <small>(max. 250 words)</small> <br /> <textarea name="s4" id="pps4" style="width: 200px; font-size:14px; height:70px;" class="txt"></textarea></td> </tr> <tr> <td><b>Slider Image</b> <br/> <input type="text" name="s2" id="pps2" style="width: 200px; font-size:14px;" class="txt" /> <br/><br/> <input type="hidden" value="" name="imgIdblock" id="imgIdblock" /> <script type="text/javascript"> function ChangeImgBlock(divname){ document.getElementById("imgIdblock").value = divname; } jQuery(document).ready(function() { jQuery('#upload_sliderimage').click(function() { ChangeImgBlock('pps2'); formfield = jQuery('#pps2').attr('name'); tb_show('', <?php if(defined('MULTISITE') && MULTISITE != false){ ?>'admin.php?page=images&amp;tab=nw&amp;TB_iframe=true'<?php }else{ ?>'media-upload.php?type=image&amp;TB_iframe=true'<?php } ?>); return false; }); window.send_to_editor = function(html) { imgurl = jQuery('img',html).attr('src'); jQuery('#'+document.getElementById("imgIdblock").value).val(imgurl); tb_remove(); } }); </script> <input id="upload_sliderimage" type="button" size="36" name="upload_sliderimage" value="Upload Image" /> <input onClick="toggleLayer('DisplayImages'); add_image_next(0,'<?php echo get_option("imagestorage_path"); ?>','<?php echo get_option("imagestorage_link"); ?>','pps2');" type="button" value="View Images" /> </td> <td valign="top"><b>Slider Clickable Link</b> <br /> <input type="text" name="s5" id="pps5" style="width: 200px; font-size:14px;" class="txt" value="http://" /> </td> <td valign="top"><b>Display Order</b><br /><select id="pps6" name="s6" style="width: 100px; font-size:14px;"><?php $i=1; while($i<20){ echo '<option>'.$i.'</option>'; $i++; } ?></select></td> </tr> <tr> <td colspan="3"><p><input class="premiumpress_button" type="submit" value="Create New Slide" style="color:white;" /></p></td> </tr> </table> </form> </div> <div id="addBtn1" style="display:visible"><a href="javascript:void();" onClick="jQuery('#PPT-sliderboxAdd').show();jQuery('#addBtn1').hide();" class="premiumpress_button" style=" float:right; margin-right:10px;" >Add Slider Item</a></div> <h2 style="margin-left:10px;">Website Slider Items</h2> <p style="margin-left:10px;">Here you can setup and create new items for your website slider.</p> <?php $sliderData = get_option("slider_array"); if(is_array($sliderData) && count($sliderData) > 0 ){ ?> <table id="ct"><thead><tr id="ct_sort"> <th width="90" class="first">Title</th> <th width="100">Short Description</th> <th width="40"class="last">Display Order</th> <th width="40"class="last">Actions</th> </tr></thead><tbody> <?php $sortedSlider = $PPTDesign->array_sort($sliderData, 'order', SORT_ASC); $i=-1; foreach($sortedSlider as $hh => $slide){ ?> <tr id="srow<?php echo $i; ?>"> <td width="90" class="first"><?php echo $slide['s1']; ?></td> <td width="80"><?php echo $slide['s3']; ?></td> <td width="50"><?php echo $slide['order']; ?></td> <td width="80" class="last"> <a href='#' Onclick="EditsliderItem('<?php echo $hh; ?>');jQuery('#PPT-sliderbox').show();" style="padding:5px; background:#dcffe1; border:1px solid #57b564; color:green;"><img src="<?php echo $GLOBALS['template_url']; ?>/images/premiumpress/led-ico/find.png" align="middle"> Edit &nbsp;&nbsp;</a> - <a href='#' Onclick="DeleteSliderItem('<?php echo $hh; ?>');jQuery('#PPT-sliderbox').show();jQuery('#srow<?php echo $i; ?>').hide();" style="padding:5px; background:#ffb9ba; border:1px solid #bd2e2f; color:red;"><img src="<?php echo $GLOBALS['template_url']; ?>/images/premiumpress/led-ico/delete.png" align="middle"> Delete&nbsp;</a></td> </tr> <?php $i++; } ?> </tbody> </table> <br /> <form method="post" target="_self" > <input name="admin_slider" type="hidden" value="reset" /> <input class="premiumpress_button" type="submit" value="Reset Slider (Delete All Slides)" style="color:white;" /> </form> <?php } ?> </div>
magictortoise/voucheroffer
wp-content/themes/couponpress/admin/_ad_couponpress_1.php
PHP
gpl-2.0
22,576
# 考勤 ---- 考勤信息查询 <br> http://yun.kqapi.com/Default/Index/index
FlyingRunSnail/myHelloWorld
notebook/vnote/日常工作记录/考勤.md
Markdown
gpl-2.0
78
/** * AuthenticationUserLibraryPortType.java * * This file was auto-generated from WSDL * by the Apache Axis 1.4 Apr 22, 2006 (06:55:48 PDT) WSDL2Java emitter. */ package it.depositolegale.www.webservice_authenticationUserLibrary; public interface AuthenticationUserLibraryPortType extends java.rmi.Remote { public it.depositolegale.www.authenticationUserOutput.AuthenticationUserOutput authenticationUserLibraryOperation(it.depositolegale.www.authenticationUserInput.AuthenticationUserInput authenticationUserInput) throws java.rmi.RemoteException; }
MagazziniDigitali/Magazzini-Digitali-Client
MagazziniDigitaliServicesClient/src/main/java/it/depositolegale/www/webservice_authenticationUserLibrary/AuthenticationUserLibraryPortType.java
Java
gpl-2.0
563
/* * linux/arch/arm/kernel/traps.c * * Copyright (C) 1995-2009 Russell King * Fragments that appear the same as linux/arch/i386/kernel/traps.c (C) Linus Torvalds * * This program 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. * * 'traps.c' handles hardware exceptions after we have saved some state in * 'linux/arch/arm/lib/traps.S'. Mostly a debugging aid, but will probably * kill the offending process. */ #include <linux/module.h> #include <linux/signal.h> #include <linux/spinlock.h> #include <linux/personality.h> #include <linux/kallsyms.h> #include <linux/delay.h> #include <linux/hardirq.h> #include <linux/init.h> #include <linux/uaccess.h> #include <asm/atomic.h> #include <asm/cacheflush.h> #include <asm/system.h> #include <asm/unistd.h> #include <asm/traps.h> #include <asm/unwind.h> #include "ptrace.h" #include "signal.h" static const char *handler[]= { "prefetch abort", "data abort", "address exception", "interrupt" }; void *vectors_page; #ifdef CONFIG_DEBUG_USER unsigned int user_debug; static int __init user_debug_setup(char *str) { get_option(&str, &user_debug); return 1; } __setup("user_debug=", user_debug_setup); #endif static void dump_mem(const char *, const char *, unsigned long, unsigned long); void dump_backtrace_entry(unsigned long where, unsigned long from, unsigned long frame) { #ifdef CONFIG_KALLSYMS char sym1[KSYM_SYMBOL_LEN], sym2[KSYM_SYMBOL_LEN]; sprint_symbol(sym1, where); sprint_symbol(sym2, from); printk("[<%08lx>] (%s) from [<%08lx>] (%s)\n", where, sym1, from, sym2); #else printk("Function entered at [<%08lx>] from [<%08lx>]\n", where, from); #endif if (in_exception_text(where)) dump_mem("", "Exception stack", frame + 4, frame + 4 + sizeof(struct pt_regs)); } #ifndef CONFIG_ARM_UNWIND /* * Stack pointers should always be within the kernels view of * physical memory. If it is not there, then we can't dump * out any information relating to the stack. */ static int verify_stack(unsigned long sp) { if (sp < PAGE_OFFSET || (sp > (unsigned long)high_memory && high_memory != NULL)) return -EFAULT; return 0; } #endif /* * Dump out the contents of some memory nicely... */ static void dump_mem(const char *lvl, const char *str, unsigned long bottom, unsigned long top) { unsigned long first; mm_segment_t fs; int i; /* * We need to switch to kernel mode so that we can use __get_user * to safely read from kernel space. Note that we now dump the * code first, just in case the backtrace kills us. */ fs = get_fs(); set_fs(KERNEL_DS); printk("%s%s(0x%08lx to 0x%08lx)\n", lvl, str, bottom, top); for (first = bottom & ~31; first < top; first += 32) { unsigned long p; char str[sizeof(" 12345678") * 8 + 1]; memset(str, ' ', sizeof(str)); str[sizeof(str) - 1] = '\0'; for (p = first, i = 0; i < 8 && p < top; i++, p += 4) { if (p >= bottom && p < top) { unsigned long val; if (__get_user(val, (unsigned long *)p) == 0) sprintf(str + i * 9, " %08lx", val); else sprintf(str + i * 9, " ????????"); } } printk("%s%04lx:%s\n", lvl, first & 0xffff, str); } set_fs(fs); } static void dump_instr(const char *lvl, struct pt_regs *regs) { unsigned long addr = instruction_pointer(regs); const int thumb = thumb_mode(regs); const int width = thumb ? 4 : 8; mm_segment_t fs; char str[sizeof("00000000 ") * 5 + 2 + 1], *p = str; int i; /* * We need to switch to kernel mode so that we can use __get_user * to safely read from kernel space. Note that we now dump the * code first, just in case the backtrace kills us. */ fs = get_fs(); set_fs(KERNEL_DS); for (i = -4; i < 1; i++) { unsigned int val, bad; if (thumb) bad = __get_user(val, &((u16 *)addr)[i]); else bad = __get_user(val, &((u32 *)addr)[i]); if (!bad) p += sprintf(p, i == 0 ? "(%0*x) " : "%0*x ", width, val); else { p += sprintf(p, "bad PC value"); break; } } printk("%sCode: %s\n", lvl, str); set_fs(fs); } #ifdef CONFIG_ARM_UNWIND static inline void dump_backtrace(struct pt_regs *regs, struct task_struct *tsk) { unwind_backtrace(regs, tsk); } #else static void dump_backtrace(struct pt_regs *regs, struct task_struct *tsk) { unsigned int fp, mode; int ok = 1; printk("Backtrace: "); if (!tsk) tsk = current; if (regs) { fp = regs->ARM_fp; mode = processor_mode(regs); } else if (tsk != current) { fp = thread_saved_fp(tsk); mode = 0x10; } else { asm("mov %0, fp" : "=r" (fp) : : "cc"); mode = 0x10; } if (!fp) { printk("no frame pointer"); ok = 0; } else if (verify_stack(fp)) { printk("invalid frame pointer 0x%08x", fp); ok = 0; } else if (fp < (unsigned long)end_of_stack(tsk)) printk("frame pointer underflow"); printk("\n"); if (ok) c_backtrace(fp, mode); } #endif void dump_stack(void) { dump_backtrace(NULL, NULL); } EXPORT_SYMBOL(dump_stack); void show_stack(struct task_struct *tsk, unsigned long *sp) { dump_backtrace(NULL, tsk); barrier(); } #ifdef CONFIG_PREEMPT #define S_PREEMPT " PREEMPT" #else #define S_PREEMPT "" #endif #ifdef CONFIG_SMP #define S_SMP " SMP" #else #define S_SMP "" #endif static void __die(const char *str, int err, struct thread_info *thread, struct pt_regs *regs) { struct task_struct *tsk = thread->task; static int die_counter; #if defined(CONFIG_MACH_STAR) set_default_loglevel(); /* 20100916 set default loglevel */ #endif printk(KERN_EMERG "Internal error: %s: %x [#%d]" S_PREEMPT S_SMP "\n", str, err, ++die_counter); sysfs_printk_last_file(); print_modules(); __show_regs(regs); printk(KERN_EMERG "Process %.*s (pid: %d, stack limit = 0x%p)\n", TASK_COMM_LEN, tsk->comm, task_pid_nr(tsk), thread + 1); if (!user_mode(regs) || in_interrupt()) { dump_mem(KERN_EMERG, "Stack: ", regs->ARM_sp, THREAD_SIZE + (unsigned long)task_stack_page(tsk)); dump_backtrace(regs, tsk); dump_instr(KERN_EMERG, regs); } } DEFINE_SPINLOCK(die_lock); /* * This function is protected against re-entrancy. */ NORET_TYPE void die(const char *str, struct pt_regs *regs, int err) { struct thread_info *thread = current_thread_info(); oops_enter(); spin_lock_irq(&die_lock); console_verbose(); bust_spinlocks(1); __die(str, err, thread, regs); bust_spinlocks(0); add_taint(TAINT_DIE); spin_unlock_irq(&die_lock); oops_exit(); if (in_interrupt()) panic("Fatal exception in interrupt"); if (panic_on_oops) panic("Fatal exception"); do_exit(SIGSEGV); } void arm_notify_die(const char *str, struct pt_regs *regs, struct siginfo *info, unsigned long err, unsigned long trap) { if (user_mode(regs)) { current->thread.error_code = err; current->thread.trap_no = trap; force_sig_info(info->si_signo, info, current); } else { die(str, regs, err); } } static LIST_HEAD(undef_hook); static DEFINE_SPINLOCK(undef_lock); void register_undef_hook(struct undef_hook *hook) { unsigned long flags; spin_lock_irqsave(&undef_lock, flags); list_add(&hook->node, &undef_hook); spin_unlock_irqrestore(&undef_lock, flags); } void unregister_undef_hook(struct undef_hook *hook) { unsigned long flags; spin_lock_irqsave(&undef_lock, flags); list_del(&hook->node); spin_unlock_irqrestore(&undef_lock, flags); } static int call_undef_hook(struct pt_regs *regs, unsigned int instr) { struct undef_hook *hook; unsigned long flags; int (*fn)(struct pt_regs *regs, unsigned int instr) = NULL; spin_lock_irqsave(&undef_lock, flags); list_for_each_entry(hook, &undef_hook, node) if ((instr & hook->instr_mask) == hook->instr_val && (regs->ARM_cpsr & hook->cpsr_mask) == hook->cpsr_val) fn = hook->fn; spin_unlock_irqrestore(&undef_lock, flags); return fn ? fn(regs, instr) : 1; } asmlinkage void __exception do_undefinstr(struct pt_regs *regs) { unsigned int correction = thumb_mode(regs) ? 2 : 4; unsigned int instr; siginfo_t info; void __user *pc; /* * According to the ARM ARM, PC is 2 or 4 bytes ahead, * depending whether we're in Thumb mode or not. * Correct this offset. */ regs->ARM_pc -= correction; pc = (void __user *)instruction_pointer(regs); if (processor_mode(regs) == SVC_MODE) { instr = *(u32 *) pc; } else if (thumb_mode(regs)) { get_user(instr, (u16 __user *)pc); } else { get_user(instr, (u32 __user *)pc); } if (call_undef_hook(regs, instr) == 0) return; #ifdef CONFIG_DEBUG_USER if (user_debug & UDBG_UNDEFINED) { printk(KERN_INFO "%s (%d): undefined instruction: pc=%p\n", current->comm, task_pid_nr(current), pc); dump_instr(KERN_INFO, regs); } #endif info.si_signo = SIGILL; info.si_errno = 0; info.si_code = ILL_ILLOPC; info.si_addr = pc; arm_notify_die("Oops - undefined instruction", regs, &info, 0, 6); } asmlinkage void do_unexp_fiq (struct pt_regs *regs) { printk("Hmm. Unexpected FIQ received, but trying to continue\n"); printk("You may have a hardware problem...\n"); } /* * bad_mode handles the impossible case in the vectors. If you see one of * these, then it's extremely serious, and could mean you have buggy hardware. * It never returns, and never tries to sync. We hope that we can at least * dump out some state information... */ asmlinkage void bad_mode(struct pt_regs *regs, int reason) { console_verbose(); printk(KERN_CRIT "Bad mode in %s handler detected\n", handler[reason]); die("Oops - bad mode", regs, 0); local_irq_disable(); panic("bad mode"); } static int bad_syscall(int n, struct pt_regs *regs) { struct thread_info *thread = current_thread_info(); siginfo_t info; if (current->personality != PER_LINUX && current->personality != PER_LINUX_32BIT && thread->exec_domain->handler) { thread->exec_domain->handler(n, regs); return regs->ARM_r0; } #ifdef CONFIG_DEBUG_USER if (user_debug & UDBG_SYSCALL) { printk(KERN_ERR "[%d] %s: obsolete system call %08x.\n", task_pid_nr(current), current->comm, n); dump_instr(KERN_ERR, regs); } #endif info.si_signo = SIGILL; info.si_errno = 0; info.si_code = ILL_ILLTRP; info.si_addr = (void __user *)instruction_pointer(regs) - (thumb_mode(regs) ? 2 : 4); arm_notify_die("Oops - bad syscall", regs, &info, n, 0); return regs->ARM_r0; } static inline void do_cache_op(unsigned long start, unsigned long end, int flags) { struct mm_struct *mm = current->active_mm; struct vm_area_struct *vma; if (end < start || flags) return; down_read(&mm->mmap_sem); vma = find_vma(mm, start); if (vma && vma->vm_start < end) { if (start < vma->vm_start) start = vma->vm_start; if (end > vma->vm_end) end = vma->vm_end; up_read(&mm->mmap_sem); flush_cache_user_range(start, end); return; } up_read(&mm->mmap_sem); } /* * Handle all unrecognised system calls. * 0x9f0000 - 0x9fffff are some more esoteric system calls */ #define NR(x) ((__ARM_NR_##x) - __ARM_NR_BASE) asmlinkage int arm_syscall(int no, struct pt_regs *regs) { struct thread_info *thread = current_thread_info(); siginfo_t info; if ((no >> 16) != (__ARM_NR_BASE>> 16)) return bad_syscall(no, regs); switch (no & 0xffff) { case 0: /* branch through 0 */ info.si_signo = SIGSEGV; info.si_errno = 0; info.si_code = SEGV_MAPERR; info.si_addr = NULL; arm_notify_die("branch through zero", regs, &info, 0, 0); return 0; case NR(breakpoint): /* SWI BREAK_POINT */ regs->ARM_pc -= thumb_mode(regs) ? 2 : 4; ptrace_break(current, regs); return regs->ARM_r0; /* * Flush a region from virtual address 'r0' to virtual address 'r1' * _exclusive_. There is no alignment requirement on either address; * user space does not need to know the hardware cache layout. * * r2 contains flags. It should ALWAYS be passed as ZERO until it * is defined to be something else. For now we ignore it, but may * the fires of hell burn in your belly if you break this rule. ;) * * (at a later date, we may want to allow this call to not flush * various aspects of the cache. Passing '0' will guarantee that * everything necessary gets flushed to maintain consistency in * the specified region). */ case NR(cacheflush): do_cache_op(regs->ARM_r0, regs->ARM_r1, regs->ARM_r2); return 0; case NR(usr26): if (!(elf_hwcap & HWCAP_26BIT)) break; regs->ARM_cpsr &= ~MODE32_BIT; return regs->ARM_r0; case NR(usr32): if (!(elf_hwcap & HWCAP_26BIT)) break; regs->ARM_cpsr |= MODE32_BIT; return regs->ARM_r0; case NR(set_tls): thread->tp_value = regs->ARM_r0; #if defined(CONFIG_HAS_TLS_REG) #if defined(CONFIG_TEGRA_ERRATA_657451) BUG_ON(regs->ARM_r0 & 0x1); asm ("mcr p15, 0, %0, c13, c0, 3" : : "r" ((regs->ARM_r0) | ((regs->ARM_r0>>20) & 0x1))); #else asm ("mcr p15, 0, %0, c13, c0, 3" : : "r" (regs->ARM_r0) ); #endif #elif !defined(CONFIG_TLS_REG_EMUL) /* * User space must never try to access this directly. * Expect your app to break eventually if you do so. * The user helper at 0xffff0fe0 must be used instead. * (see entry-armv.S for details) */ *((unsigned int *)0xffff0ff0) = regs->ARM_r0; #endif return 0; #ifdef CONFIG_NEEDS_SYSCALL_FOR_CMPXCHG /* * Atomically store r1 in *r2 if *r2 is equal to r0 for user space. * Return zero in r0 if *MEM was changed or non-zero if no exchange * happened. Also set the user C flag accordingly. * If access permissions have to be fixed up then non-zero is * returned and the operation has to be re-attempted. * * *NOTE*: This is a ghost syscall private to the kernel. Only the * __kuser_cmpxchg code in entry-armv.S should be aware of its * existence. Don't ever use this from user code. */ case NR(cmpxchg): for (;;) { extern void do_DataAbort(unsigned long addr, unsigned int fsr, struct pt_regs *regs); unsigned long val; unsigned long addr = regs->ARM_r2; struct mm_struct *mm = current->mm; pgd_t *pgd; pmd_t *pmd; pte_t *pte; spinlock_t *ptl; regs->ARM_cpsr &= ~PSR_C_BIT; down_read(&mm->mmap_sem); pgd = pgd_offset(mm, addr); if (!pgd_present(*pgd)) goto bad_access; pmd = pmd_offset(pgd, addr); if (!pmd_present(*pmd)) goto bad_access; pte = pte_offset_map_lock(mm, pmd, addr, &ptl); if (!pte_present(*pte) || !pte_dirty(*pte)) { pte_unmap_unlock(pte, ptl); goto bad_access; } val = *(unsigned long *)addr; val -= regs->ARM_r0; if (val == 0) { *(unsigned long *)addr = regs->ARM_r1; regs->ARM_cpsr |= PSR_C_BIT; } pte_unmap_unlock(pte, ptl); up_read(&mm->mmap_sem); return val; bad_access: up_read(&mm->mmap_sem); /* simulate a write access fault */ do_DataAbort(addr, 15 + (1 << 11), regs); } #endif default: /* Calls 9f00xx..9f07ff are defined to return -ENOSYS if not implemented, rather than raising SIGILL. This way the calling program can gracefully determine whether a feature is supported. */ if ((no & 0xffff) <= 0x7ff) return -ENOSYS; break; } #ifdef CONFIG_DEBUG_USER /* * experience shows that these seem to indicate that * something catastrophic has happened */ if (user_debug & UDBG_SYSCALL) { printk("[%d] %s: arm syscall %d\n", task_pid_nr(current), current->comm, no); dump_instr("", regs); if (user_mode(regs)) { __show_regs(regs); c_backtrace(regs->ARM_fp, processor_mode(regs)); } } #endif info.si_signo = SIGILL; info.si_errno = 0; info.si_code = ILL_ILLTRP; info.si_addr = (void __user *)instruction_pointer(regs) - (thumb_mode(regs) ? 2 : 4); arm_notify_die("Oops - bad syscall(2)", regs, &info, no, 0); return 0; } #ifdef CONFIG_TLS_REG_EMUL /* * We might be running on an ARMv6+ processor which should have the TLS * register but for some reason we can't use it, or maybe an SMP system * using a pre-ARMv6 processor (there are apparently a few prototypes like * that in existence) and therefore access to that register must be * emulated. */ static int get_tp_trap(struct pt_regs *regs, unsigned int instr) { int reg = (instr >> 12) & 15; if (reg == 15) return 1; regs->uregs[reg] = current_thread_info()->tp_value; regs->ARM_pc += 4; return 0; } static struct undef_hook arm_mrc_hook = { .instr_mask = 0x0fff0fff, .instr_val = 0x0e1d0f70, .cpsr_mask = PSR_T_BIT, .cpsr_val = 0, .fn = get_tp_trap, }; static int __init arm_mrc_hook_init(void) { register_undef_hook(&arm_mrc_hook); return 0; } late_initcall(arm_mrc_hook_init); #endif void __bad_xchg(volatile void *ptr, int size) { printk("xchg: bad data size: pc 0x%p, ptr 0x%p, size %d\n", __builtin_return_address(0), ptr, size); BUG(); } EXPORT_SYMBOL(__bad_xchg); /* * A data abort trap was taken, but we did not handle the instruction. * Try to abort the user program, or panic if it was the kernel. */ asmlinkage void baddataabort(int code, unsigned long instr, struct pt_regs *regs) { unsigned long addr = instruction_pointer(regs); siginfo_t info; #ifdef CONFIG_DEBUG_USER if (user_debug & UDBG_BADABORT) { printk(KERN_ERR "[%d] %s: bad data abort: code %d instr 0x%08lx\n", task_pid_nr(current), current->comm, code, instr); dump_instr(KERN_ERR, regs); show_pte(current->mm, addr); } #endif info.si_signo = SIGILL; info.si_errno = 0; info.si_code = ILL_ILLOPC; info.si_addr = (void __user *)addr; arm_notify_die("unknown data abort code", regs, &info, instr, 0); } void __attribute__((noreturn)) __bug(const char *file, int line) { printk(KERN_CRIT"kernel BUG at %s:%d!\n", file, line); *(int *)0 = 0; /* Avoid "noreturn function does return" */ for (;;); } EXPORT_SYMBOL(__bug); void __readwrite_bug(const char *fn) { printk("%s called, but not implemented\n", fn); BUG(); } EXPORT_SYMBOL(__readwrite_bug); void __pte_error(const char *file, int line, unsigned long val) { printk("%s:%d: bad pte %08lx.\n", file, line, val); } void __pmd_error(const char *file, int line, unsigned long val) { printk("%s:%d: bad pmd %08lx.\n", file, line, val); } void __pgd_error(const char *file, int line, unsigned long val) { printk("%s:%d: bad pgd %08lx.\n", file, line, val); } asmlinkage void __div0(void) { printk("Division by zero in kernel.\n"); dump_stack(); } EXPORT_SYMBOL(__div0); void abort(void) { BUG(); /* if that doesn't kill us, halt */ panic("Oops failed to kill thread"); } EXPORT_SYMBOL(abort); void __init trap_init(void) { return; } void __init early_trap_init(void) { #if defined(CONFIG_CPU_USE_DOMAINS) unsigned long vectors = CONFIG_VECTORS_BASE; #else unsigned long vectors = (unsigned long)vectors_page; #endif extern char __stubs_start[], __stubs_end[]; extern char __vectors_start[], __vectors_end[]; extern char __kuser_helper_start[], __kuser_helper_end[]; int kuser_sz = __kuser_helper_end - __kuser_helper_start; /* * Copy the vectors, stubs and kuser helpers (in entry-armv.S) * into the vector page, mapped at 0xffff0000, and ensure these * are visible to the instruction stream. */ memcpy((void *)vectors, __vectors_start, __vectors_end - __vectors_start); memcpy((void *)vectors + 0x200, __stubs_start, __stubs_end - __stubs_start); memcpy((void *)vectors + 0x1000 - kuser_sz, __kuser_helper_start, kuser_sz); /* * Copy signal return handlers into the vector page, and * set sigreturn to be a pointer to these. */ memcpy((void *)(vectors + KERN_SIGRETURN_CODE - CONFIG_VECTORS_BASE), sigreturn_codes, sizeof(sigreturn_codes)); memcpy((void *)(vectors + KERN_RESTART_CODE - CONFIG_VECTORS_BASE), syscall_restart_code, sizeof(syscall_restart_code)); flush_icache_range(vectors, vectors + PAGE_SIZE); modify_domain(DOMAIN_USER, DOMAIN_CLIENT); }
Mazout360/lge-kernel-gb
arch/arm/kernel/traps.c
C
gpl-2.0
19,685
/* Theme Name: Metaspace Mobile Theme URI: http://metaspace.co Description: Metaspace for Dettol MHSD Version: 1 Author: Metaspace Author URI: http://metaspace.co */
ariniastari/mhsd_dettol
wp-content/themes/metaspace mobile/style.css
CSS
gpl-2.0
165
<?php /** * @copyright Ilch 2.0 * @package ilch */ namespace Modules\Admin\Models; /** * The layout model class. */ class Layout extends \Ilch\Model { /** * Key of the layout. * * @var string */ protected $key; /** * Name of the layout. * * @var string */ protected $name; /** * Author of the layout. * * @var string */ protected $author; /** * Link of the layout. * * @var string */ protected $link; /** * Description of the layout. * * @var string */ protected $desc; /** * Module of the layout. * * @var string */ protected $modulekey; /** * Gets the key. * * @return string */ public function getKey() { return $this->key; } /** * Sets the key. * * @param string $key */ public function setKey($key) { $this->key = (string)$key; } /** * Gets the name. * * @return string */ public function getName() { return $this->name; } /** * Sets the name. * * @param string $key */ public function setName($name) { $this->name = (string)$name; } /** * Gets the author. * * @return string */ public function getAuthor() { return $this->author; } /** * Sets the author. * * @param string $author */ public function setAuthor($author) { $this->author = (string)$author; } /** * Gets the link. * * @return string */ public function getLink() { return $this->link; } /** * Sets the link. * * @param string $link */ public function setLink($link) { $this->link = (string)$link; } /** * Gets the desc. * * @return string */ public function getDesc() { return $this->desc; } /** * Sets the author. * * @param string $desc */ public function setDesc($desc) { $this->desc = (string)$desc; } /** * Gets the modulekey. * * @return string */ public function getModulekey() { return $this->modulekey; } /** * Sets the modulekey. * * @param string $modulekey */ public function setModulekey($modulekey) { $this->modulekey = (string)$modulekey; } }
jurri/Ilch-2.0
application/modules/admin/models/Layout.php
PHP
gpl-2.0
2,550
.NoInherit { font-style: oblique; opacity: 0.5; } .AccessTableHeading { padding-top: 0.5em; padding-bottom: 0.25em; font-weight: bold; } .AccessTable th { white-space: nowrap; } .AccessTable .GroupName { width: 40%; } .AccessTable .Narrow { width: 10%; }
apeisa/UserGroups
UserGroupsHooks.css
CSS
gpl-2.0
263
# # # (C) Copyright 2001 The Internet (Aust) Pty Ltd # ACN: 082 081 472 ABN: 83 082 081 472 # All Rights Reserved # # THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE # ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF # SUCH DAMAGE. # # Author: Andrew Milton <[email protected]> # $Id: Plugins.py,v 1.5 2004/11/10 14:15:33 akm Exp $ import App, Globals, OFS import string import time from Globals import ImageFile, HTMLFile, HTML, MessageDialog, package_home from OFS.Folder import Folder class PluginRegister: def __init__(self, name, description, pluginClass, pluginStartForm, pluginStartMethod, pluginEditForm=None, pluginEditMethod=None): self.name=name #No Spaces please... self.description=description self.plugin=pluginClass self.manage_addForm=pluginStartForm self.manage_addMethod=pluginStartMethod self.manage_editForm=pluginEditForm self.manage_editMethod=pluginEditMethod class CryptoPluginRegister: def __init__(self, name, crypto, description, pluginMethod): self.name = name #No Spaces please... self.cryptoMethod = crypto self.description = description self.plugin = pluginMethod
denys-duchier/Scolar
ZopeProducts/exUserFolder/Plugins.py
Python
gpl-2.0
1,784
<!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=ISO-8859-1"> <script src="js/jquery.min.js"></script> <script type="text/javascript" src="js/js.cookie.js"></script> <title>BenchmarkTest00199</title> </head> <body> <form action="/benchmark/BenchmarkTest00199" method="POST" id="FormBenchmarkTest00199"> <div><label>Please explain your answer:</label></div> <br/> <div><textarea rows="4" cols="50" id="vectorArea" name="vectorArea"></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 vector and value:</label> <input type="text" id="vector" name="vector" value="bar" class="safe"></input></div> <div><input type="button" id="login-btn" value="Login" /></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) { $('#login-btn').trigger('click'); return false; } }); $("#login-btn").click(function(){ var formData = $("#FormBenchmarkTest00199").serializeArray(); var URL = $("#FormBenchmarkTest00199").attr("action"); var text = $("#FormBenchmarkTest00199 input[id=vector]").val(); $.ajax({ url : URL, headers: { 'vector': text }, type: "POST", data : formData, success: function(data, textStatus, jqXHR){ $("#code").text(data); }, error: function (jqXHR, textStatus, errorThrown){ console.error(errorThrown);} }); }); </script> </body> </html>
thc202/Benchmark
src/main/webapp/BenchmarkTest00199.html
HTML
gpl-2.0
1,755
/* BGP-4, BGP-4+ daemon program Copyright (C) 1996, 97, 98, 99, 2000 Kunihiro Ishiguro This file is part of GNU Kroute. GNU Kroute 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. GNU Kroute 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 GNU Kroute; see the file COPYING. If not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include <kroute.h> #include "prefix.h" #include "thread.h" #include "buffer.h" #include "stream.h" #include "command.h" #include "sockunion.h" #include "network.h" #include "memory.h" #include "filter.h" #include "routemap.h" #include "str.h" #include "log.h" #include "plist.h" #include "linklist.h" #include "workqueue.h" #include "bgpd/bgpd.h" #include "bgpd/bgp_table.h" #include "bgpd/bgp_aspath.h" #include "bgpd/bgp_route.h" #include "bgpd/bgp_dump.h" #include "bgpd/bgp_debug.h" #include "bgpd/bgp_community.h" #include "bgpd/bgp_attr.h" #include "bgpd/bgp_regex.h" #include "bgpd/bgp_clist.h" #include "bgpd/bgp_fsm.h" #include "bgpd/bgp_packet.h" #include "bgpd/bgp_kroute.h" #include "bgpd/bgp_open.h" #include "bgpd/bgp_filter.h" #include "bgpd/bgp_nexthop.h" #include "bgpd/bgp_damp.h" #include "bgpd/bgp_mplsvpn.h" #include "bgpd/bgp_advertise.h" #include "bgpd/bgp_network.h" #include "bgpd/bgp_vty.h" #include "bgpd/bgp_mpath.h" #ifdef HAVE_SNMP #include "bgpd/bgp_snmp.h" #endif /* HAVE_SNMP */ /* BGP process wide configuration. */ static struct bgp_master bgp_master; extern struct in_addr router_id_kroute; /* BGP process wide configuration pointer to export. */ struct bgp_master *bm; /* BGP community-list. */ struct community_list_handler *bgp_clist; /* BGP global flag manipulation. */ int bgp_option_set (int flag) { switch (flag) { case BGP_OPT_NO_FIB: case BGP_OPT_MULTIPLE_INSTANCE: case BGP_OPT_CONFIG_CISCO: SET_FLAG (bm->options, flag); break; default: return BGP_ERR_INVALID_FLAG; } return 0; } int bgp_option_unset (int flag) { switch (flag) { case BGP_OPT_MULTIPLE_INSTANCE: if (listcount (bm->bgp) > 1) return BGP_ERR_MULTIPLE_INSTANCE_USED; /* Fall through. */ case BGP_OPT_NO_FIB: case BGP_OPT_CONFIG_CISCO: UNSET_FLAG (bm->options, flag); break; default: return BGP_ERR_INVALID_FLAG; } return 0; } int bgp_option_check (int flag) { return CHECK_FLAG (bm->options, flag); } /* BGP flag manipulation. */ int bgp_flag_set (struct bgp *bgp, int flag) { SET_FLAG (bgp->flags, flag); return 0; } int bgp_flag_unset (struct bgp *bgp, int flag) { UNSET_FLAG (bgp->flags, flag); return 0; } int bgp_flag_check (struct bgp *bgp, int flag) { return CHECK_FLAG (bgp->flags, flag); } /* Internal function to set BGP structure configureation flag. */ static void bgp_config_set (struct bgp *bgp, int config) { SET_FLAG (bgp->config, config); } static void bgp_config_unset (struct bgp *bgp, int config) { UNSET_FLAG (bgp->config, config); } static int bgp_config_check (struct bgp *bgp, int config) { return CHECK_FLAG (bgp->config, config); } /* Set BGP router identifier. */ int bgp_router_id_set (struct bgp *bgp, struct in_addr *id) { struct peer *peer; struct listnode *node, *nnode; if (bgp_config_check (bgp, BGP_CONFIG_ROUTER_ID) && IPV4_ADDR_SAME (&bgp->router_id, id)) return 0; IPV4_ADDR_COPY (&bgp->router_id, id); bgp_config_set (bgp, BGP_CONFIG_ROUTER_ID); /* Set all peer's local identifier with this value. */ for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer)) { IPV4_ADDR_COPY (&peer->local_id, id); if (peer->status == Established) { peer->last_reset = PEER_DOWN_RID_CHANGE; bgp_notify_send (peer, BGP_NOTIFY_CEASE, BGP_NOTIFY_CEASE_CONFIG_CHANGE); } } return 0; } /* BGP's cluster-id control. */ int bgp_cluster_id_set (struct bgp *bgp, struct in_addr *cluster_id) { struct peer *peer; struct listnode *node, *nnode; if (bgp_config_check (bgp, BGP_CONFIG_CLUSTER_ID) && IPV4_ADDR_SAME (&bgp->cluster_id, cluster_id)) return 0; IPV4_ADDR_COPY (&bgp->cluster_id, cluster_id); bgp_config_set (bgp, BGP_CONFIG_CLUSTER_ID); /* Clear all IBGP peer. */ for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer)) { if (peer_sort (peer) != BGP_PEER_IBGP) continue; if (peer->status == Established) { peer->last_reset = PEER_DOWN_CLID_CHANGE; bgp_notify_send (peer, BGP_NOTIFY_CEASE, BGP_NOTIFY_CEASE_CONFIG_CHANGE); } } return 0; } int bgp_cluster_id_unset (struct bgp *bgp) { struct peer *peer; struct listnode *node, *nnode; if (! bgp_config_check (bgp, BGP_CONFIG_CLUSTER_ID)) return 0; bgp->cluster_id.s_addr = 0; bgp_config_unset (bgp, BGP_CONFIG_CLUSTER_ID); /* Clear all IBGP peer. */ for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer)) { if (peer_sort (peer) != BGP_PEER_IBGP) continue; if (peer->status == Established) { peer->last_reset = PEER_DOWN_CLID_CHANGE; bgp_notify_send (peer, BGP_NOTIFY_CEASE, BGP_NOTIFY_CEASE_CONFIG_CHANGE); } } return 0; } /* time_t value that is monotonicly increasing * and uneffected by adjustments to system clock */ time_t bgp_clock (void) { struct timeval tv; bane_gettime(BANE_CLK_MONOTONIC, &tv); return tv.tv_sec; } /* BGP timer configuration. */ int bgp_timers_set (struct bgp *bgp, u_int32_t keepalive, u_int32_t holdtime) { bgp->default_keepalive = (keepalive < holdtime / 3 ? keepalive : holdtime / 3); bgp->default_holdtime = holdtime; return 0; } int bgp_timers_unset (struct bgp *bgp) { bgp->default_keepalive = BGP_DEFAULT_KEEPALIVE; bgp->default_holdtime = BGP_DEFAULT_HOLDTIME; return 0; } /* BGP confederation configuration. */ int bgp_confederation_id_set (struct bgp *bgp, as_t as) { struct peer *peer; struct listnode *node, *nnode; int already_confed; if (as == 0) return BGP_ERR_INVALID_AS; /* Remember - were we doing confederation before? */ already_confed = bgp_config_check (bgp, BGP_CONFIG_CONFEDERATION); bgp->confed_id = as; bgp_config_set (bgp, BGP_CONFIG_CONFEDERATION); /* If we were doing confederation already, this is just an external AS change. Just Reset EBGP sessions, not CONFED sessions. If we were not doing confederation before, reset all EBGP sessions. */ for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer)) { /* We're looking for peers who's AS is not local or part of our confederation. */ if (already_confed) { if (peer_sort (peer) == BGP_PEER_EBGP) { peer->local_as = as; if (peer->status == Established) { peer->last_reset = PEER_DOWN_CONFED_ID_CHANGE; bgp_notify_send (peer, BGP_NOTIFY_CEASE, BGP_NOTIFY_CEASE_CONFIG_CHANGE); } else BGP_EVENT_ADD (peer, BGP_Stop); } } else { /* Not doign confederation before, so reset every non-local session */ if (peer_sort (peer) != BGP_PEER_IBGP) { /* Reset the local_as to be our EBGP one */ if (peer_sort (peer) == BGP_PEER_EBGP) peer->local_as = as; if (peer->status == Established) { peer->last_reset = PEER_DOWN_CONFED_ID_CHANGE; bgp_notify_send (peer, BGP_NOTIFY_CEASE, BGP_NOTIFY_CEASE_CONFIG_CHANGE); } else BGP_EVENT_ADD (peer, BGP_Stop); } } } return 0; } int bgp_confederation_id_unset (struct bgp *bgp) { struct peer *peer; struct listnode *node, *nnode; bgp->confed_id = 0; bgp_config_unset (bgp, BGP_CONFIG_CONFEDERATION); for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer)) { /* We're looking for peers who's AS is not local */ if (peer_sort (peer) != BGP_PEER_IBGP) { peer->local_as = bgp->as; if (peer->status == Established) { peer->last_reset = PEER_DOWN_CONFED_ID_CHANGE; bgp_notify_send (peer, BGP_NOTIFY_CEASE, BGP_NOTIFY_CEASE_CONFIG_CHANGE); } else BGP_EVENT_ADD (peer, BGP_Stop); } } return 0; } /* Is an AS part of the confed or not? */ int bgp_confederation_peers_check (struct bgp *bgp, as_t as) { int i; if (! bgp) return 0; for (i = 0; i < bgp->confed_peers_cnt; i++) if (bgp->confed_peers[i] == as) return 1; return 0; } /* Add an AS to the confederation set. */ int bgp_confederation_peers_add (struct bgp *bgp, as_t as) { struct peer *peer; struct listnode *node, *nnode; if (! bgp) return BGP_ERR_INVALID_BGP; if (bgp->as == as) return BGP_ERR_INVALID_AS; if (bgp_confederation_peers_check (bgp, as)) return -1; if (bgp->confed_peers) bgp->confed_peers = XREALLOC (MTYPE_BGP_CONFED_LIST, bgp->confed_peers, (bgp->confed_peers_cnt + 1) * sizeof (as_t)); else bgp->confed_peers = XMALLOC (MTYPE_BGP_CONFED_LIST, (bgp->confed_peers_cnt + 1) * sizeof (as_t)); bgp->confed_peers[bgp->confed_peers_cnt] = as; bgp->confed_peers_cnt++; if (bgp_config_check (bgp, BGP_CONFIG_CONFEDERATION)) { for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer)) { if (peer->as == as) { peer->local_as = bgp->as; if (peer->status == Established) { peer->last_reset = PEER_DOWN_CONFED_PEER_CHANGE; bgp_notify_send (peer, BGP_NOTIFY_CEASE, BGP_NOTIFY_CEASE_CONFIG_CHANGE); } else BGP_EVENT_ADD (peer, BGP_Stop); } } } return 0; } /* Delete an AS from the confederation set. */ int bgp_confederation_peers_remove (struct bgp *bgp, as_t as) { int i; int j; struct peer *peer; struct listnode *node, *nnode; if (! bgp) return -1; if (! bgp_confederation_peers_check (bgp, as)) return -1; for (i = 0; i < bgp->confed_peers_cnt; i++) if (bgp->confed_peers[i] == as) for(j = i + 1; j < bgp->confed_peers_cnt; j++) bgp->confed_peers[j - 1] = bgp->confed_peers[j]; bgp->confed_peers_cnt--; if (bgp->confed_peers_cnt == 0) { if (bgp->confed_peers) XFREE (MTYPE_BGP_CONFED_LIST, bgp->confed_peers); bgp->confed_peers = NULL; } else bgp->confed_peers = XREALLOC (MTYPE_BGP_CONFED_LIST, bgp->confed_peers, bgp->confed_peers_cnt * sizeof (as_t)); /* Now reset any peer who's remote AS has just been removed from the CONFED */ if (bgp_config_check (bgp, BGP_CONFIG_CONFEDERATION)) { for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer)) { if (peer->as == as) { peer->local_as = bgp->confed_id; if (peer->status == Established) { peer->last_reset = PEER_DOWN_CONFED_PEER_CHANGE; bgp_notify_send (peer, BGP_NOTIFY_CEASE, BGP_NOTIFY_CEASE_CONFIG_CHANGE); } else BGP_EVENT_ADD (peer, BGP_Stop); } } } return 0; } /* Local preference configuration. */ int bgp_default_local_preference_set (struct bgp *bgp, u_int32_t local_pref) { if (! bgp) return -1; bgp->default_local_pref = local_pref; return 0; } int bgp_default_local_preference_unset (struct bgp *bgp) { if (! bgp) return -1; bgp->default_local_pref = BGP_DEFAULT_LOCAL_PREF; return 0; } /* If peer is RSERVER_CLIENT in at least one address family and is not member of a peer_group for that family, return 1. Used to check wether the peer is included in list bgp->rsclient. */ int peer_rsclient_active (struct peer *peer) { int i; int j; for (i=AFI_IP; i < AFI_MAX; i++) for (j=SAFI_UNICAST; j < SAFI_MAX; j++) if (CHECK_FLAG(peer->af_flags[i][j], PEER_FLAG_RSERVER_CLIENT) && ! peer->af_group[i][j]) return 1; return 0; } /* Peer comparison function for sorting. */ static int peer_cmp (struct peer *p1, struct peer *p2) { return sockunion_cmp (&p1->su, &p2->su); } int peer_af_flag_check (struct peer *peer, afi_t afi, safi_t safi, u_int32_t flag) { return CHECK_FLAG (peer->af_flags[afi][safi], flag); } /* Reset all address family specific configuration. */ static void peer_af_flag_reset (struct peer *peer, afi_t afi, safi_t safi) { int i; struct bgp_filter *filter; char orf_name[BUFSIZ]; filter = &peer->filter[afi][safi]; /* Clear neighbor filter and route-map */ for (i = FILTER_IN; i < FILTER_MAX; i++) { if (filter->dlist[i].name) { free (filter->dlist[i].name); filter->dlist[i].name = NULL; } if (filter->plist[i].name) { free (filter->plist[i].name); filter->plist[i].name = NULL; } if (filter->aslist[i].name) { free (filter->aslist[i].name); filter->aslist[i].name = NULL; } } for (i = RMAP_IN; i < RMAP_MAX; i++) { if (filter->map[i].name) { free (filter->map[i].name); filter->map[i].name = NULL; } } /* Clear unsuppress map. */ if (filter->usmap.name) free (filter->usmap.name); filter->usmap.name = NULL; filter->usmap.map = NULL; /* Clear neighbor's all address family flags. */ peer->af_flags[afi][safi] = 0; /* Clear neighbor's all address family sflags. */ peer->af_sflags[afi][safi] = 0; /* Clear neighbor's all address family capabilities. */ peer->af_cap[afi][safi] = 0; /* Clear ORF info */ peer->orf_plist[afi][safi] = NULL; sprintf (orf_name, "%s.%d.%d", peer->host, afi, safi); prefix_bgp_orf_remove_all (orf_name); /* Set default neighbor send-community. */ if (! bgp_option_check (BGP_OPT_CONFIG_CISCO)) { SET_FLAG (peer->af_flags[afi][safi], PEER_FLAG_SEND_COMMUNITY); SET_FLAG (peer->af_flags[afi][safi], PEER_FLAG_SEND_EXT_COMMUNITY); } /* Clear neighbor default_originate_rmap */ if (peer->default_rmap[afi][safi].name) free (peer->default_rmap[afi][safi].name); peer->default_rmap[afi][safi].name = NULL; peer->default_rmap[afi][safi].map = NULL; /* Clear neighbor maximum-prefix */ peer->pmax[afi][safi] = 0; peer->pmax_threshold[afi][safi] = MAXIMUM_PREFIX_THRESHOLD_DEFAULT; } /* peer global config reset */ static void peer_global_config_reset (struct peer *peer) { peer->weight = 0; peer->change_local_as = 0; peer->ttl = (peer_sort (peer) == BGP_PEER_IBGP ? 255 : 1); if (peer->update_source) { sockunion_free (peer->update_source); peer->update_source = NULL; } if (peer->update_if) { XFREE (MTYPE_PEER_UPDATE_SOURCE, peer->update_if); peer->update_if = NULL; } if (peer_sort (peer) == BGP_PEER_IBGP) peer->v_routeadv = BGP_DEFAULT_IBGP_ROUTEADV; else peer->v_routeadv = BGP_DEFAULT_EBGP_ROUTEADV; peer->flags = 0; peer->config = 0; peer->holdtime = 0; peer->keepalive = 0; peer->connect = 0; peer->v_connect = BGP_DEFAULT_CONNECT_RETRY; } /* Check peer's AS number and determin is this peer IBGP or EBGP */ int peer_sort (struct peer *peer) { struct bgp *bgp; bgp = peer->bgp; /* Peer-group */ if (CHECK_FLAG (peer->sflags, PEER_STATUS_GROUP)) { if (peer->as) return (bgp->as == peer->as ? BGP_PEER_IBGP : BGP_PEER_EBGP); else { struct peer *peer1; peer1 = listnode_head (peer->group->peer); if (peer1) return (peer1->local_as == peer1->as ? BGP_PEER_IBGP : BGP_PEER_EBGP); } return BGP_PEER_INTERNAL; } /* Normal peer */ if (bgp && CHECK_FLAG (bgp->config, BGP_CONFIG_CONFEDERATION)) { if (peer->local_as == 0) return BGP_PEER_INTERNAL; if (peer->local_as == peer->as) { if (peer->local_as == bgp->confed_id) return BGP_PEER_EBGP; else return BGP_PEER_IBGP; } if (bgp_confederation_peers_check (bgp, peer->as)) return BGP_PEER_CONFED; return BGP_PEER_EBGP; } else { return (peer->local_as == 0 ? BGP_PEER_INTERNAL : peer->local_as == peer->as ? BGP_PEER_IBGP : BGP_PEER_EBGP); } } static void peer_free (struct peer *peer) { assert (peer->status == Deleted); bgp_unlock(peer->bgp); /* this /ought/ to have been done already through bgp_stop earlier, * but just to be sure.. */ bgp_timer_set (peer); BGP_READ_OFF (peer->t_read); BGP_WRITE_OFF (peer->t_write); BGP_EVENT_FLUSH (peer); if (peer->desc) XFREE (MTYPE_PEER_DESC, peer->desc); /* Free allocated host character. */ if (peer->host) XFREE (MTYPE_BGP_PEER_HOST, peer->host); /* Update source configuration. */ if (peer->update_source) sockunion_free (peer->update_source); if (peer->update_if) XFREE (MTYPE_PEER_UPDATE_SOURCE, peer->update_if); if (peer->clear_node_queue) work_queue_free (peer->clear_node_queue); bgp_sync_delete (peer); memset (peer, 0, sizeof (struct peer)); XFREE (MTYPE_BGP_PEER, peer); } /* increase reference count on a struct peer */ struct peer * peer_lock (struct peer *peer) { assert (peer && (peer->lock >= 0)); peer->lock++; return peer; } /* decrease reference count on a struct peer * struct peer is freed and NULL returned if last reference */ struct peer * peer_unlock (struct peer *peer) { assert (peer && (peer->lock > 0)); peer->lock--; if (peer->lock == 0) { #if 0 zlog_debug ("unlocked and freeing"); zlog_backtrace (LOG_DEBUG); #endif peer_free (peer); return NULL; } #if 0 if (peer->lock == 1) { zlog_debug ("unlocked to 1"); zlog_backtrace (LOG_DEBUG); } #endif return peer; } /* Allocate new peer object, implicitely locked. */ static struct peer * peer_new (struct bgp *bgp) { afi_t afi; safi_t safi; struct peer *peer; struct servent *sp; /* bgp argument is absolutely required */ assert (bgp); if (!bgp) return NULL; /* Allocate new peer. */ peer = XCALLOC (MTYPE_BGP_PEER, sizeof (struct peer)); /* Set default value. */ peer->fd = -1; peer->v_start = BGP_INIT_START_TIMER; peer->v_connect = BGP_DEFAULT_CONNECT_RETRY; peer->v_asorig = BGP_DEFAULT_ASORIGINATE; peer->status = Idle; peer->ostatus = Idle; peer->weight = 0; peer->password = NULL; peer->bgp = bgp; peer = peer_lock (peer); /* initial reference */ bgp_lock (bgp); /* Set default flags. */ for (afi = AFI_IP; afi < AFI_MAX; afi++) for (safi = SAFI_UNICAST; safi < SAFI_MAX; safi++) { if (! bgp_option_check (BGP_OPT_CONFIG_CISCO)) { SET_FLAG (peer->af_flags[afi][safi], PEER_FLAG_SEND_COMMUNITY); SET_FLAG (peer->af_flags[afi][safi], PEER_FLAG_SEND_EXT_COMMUNITY); } peer->orf_plist[afi][safi] = NULL; } SET_FLAG (peer->sflags, PEER_STATUS_CAPABILITY_OPEN); /* Create buffers. */ peer->ibuf = stream_new (BGP_MAX_PACKET_SIZE); peer->obuf = stream_fifo_new (); peer->work = stream_new (BGP_MAX_PACKET_SIZE); bgp_sync_init (peer); /* Get service port number. */ sp = getservbyname ("bgp", "tcp"); peer->port = (sp == NULL) ? BGP_PORT_DEFAULT : ntohs (sp->s_port); return peer; } /* Create new BGP peer. */ static struct peer * peer_create (union sockunion *su, struct bgp *bgp, as_t local_as, as_t remote_as, afi_t afi, safi_t safi) { int active; struct peer *peer; char buf[SU_ADDRSTRLEN]; peer = peer_new (bgp); peer->su = *su; peer->local_as = local_as; peer->as = remote_as; peer->local_id = bgp->router_id; peer->v_holdtime = bgp->default_holdtime; peer->v_keepalive = bgp->default_keepalive; if (peer_sort (peer) == BGP_PEER_IBGP) peer->v_routeadv = BGP_DEFAULT_IBGP_ROUTEADV; else peer->v_routeadv = BGP_DEFAULT_EBGP_ROUTEADV; peer = peer_lock (peer); /* bgp peer list reference */ listnode_add_sort (bgp->peer, peer); active = peer_active (peer); if (afi && safi) peer->afc[afi][safi] = 1; /* Last read and reset time set */ peer->readtime = peer->resettime = bgp_clock (); /* Default TTL set. */ peer->ttl = (peer_sort (peer) == BGP_PEER_IBGP ? 255 : 1); /* Make peer's address string. */ sockunion2str (su, buf, SU_ADDRSTRLEN); peer->host = XSTRDUP (MTYPE_BGP_PEER_HOST, buf); /* Set up peer's events and timers. */ if (! active && peer_active (peer)) bgp_timer_set (peer); return peer; } /* Make accept BGP peer. Called from bgp_accept (). */ struct peer * peer_create_accept (struct bgp *bgp) { struct peer *peer; peer = peer_new (bgp); peer = peer_lock (peer); /* bgp peer list reference */ listnode_add_sort (bgp->peer, peer); return peer; } /* Change peer's AS number. */ static void peer_as_change (struct peer *peer, as_t as) { int type; /* Stop peer. */ if (! CHECK_FLAG (peer->sflags, PEER_STATUS_GROUP)) { if (peer->status == Established) { peer->last_reset = PEER_DOWN_REMOTE_AS_CHANGE; bgp_notify_send (peer, BGP_NOTIFY_CEASE, BGP_NOTIFY_CEASE_CONFIG_CHANGE); } else BGP_EVENT_ADD (peer, BGP_Stop); } type = peer_sort (peer); peer->as = as; if (bgp_config_check (peer->bgp, BGP_CONFIG_CONFEDERATION) && ! bgp_confederation_peers_check (peer->bgp, as) && peer->bgp->as != as) peer->local_as = peer->bgp->confed_id; else peer->local_as = peer->bgp->as; /* Advertisement-interval reset */ if (peer_sort (peer) == BGP_PEER_IBGP) peer->v_routeadv = BGP_DEFAULT_IBGP_ROUTEADV; else peer->v_routeadv = BGP_DEFAULT_EBGP_ROUTEADV; /* TTL reset */ if (peer_sort (peer) == BGP_PEER_IBGP) peer->ttl = 255; else if (type == BGP_PEER_IBGP) peer->ttl = 1; /* reflector-client reset */ if (peer_sort (peer) != BGP_PEER_IBGP) { UNSET_FLAG (peer->af_flags[AFI_IP][SAFI_UNICAST], PEER_FLAG_REFLECTOR_CLIENT); UNSET_FLAG (peer->af_flags[AFI_IP][SAFI_MULTICAST], PEER_FLAG_REFLECTOR_CLIENT); UNSET_FLAG (peer->af_flags[AFI_IP][SAFI_MPLS_VPN], PEER_FLAG_REFLECTOR_CLIENT); UNSET_FLAG (peer->af_flags[AFI_IP6][SAFI_UNICAST], PEER_FLAG_REFLECTOR_CLIENT); UNSET_FLAG (peer->af_flags[AFI_IP6][SAFI_MULTICAST], PEER_FLAG_REFLECTOR_CLIENT); } /* local-as reset */ if (peer_sort (peer) != BGP_PEER_EBGP) { peer->change_local_as = 0; UNSET_FLAG (peer->flags, PEER_FLAG_LOCAL_AS_NO_PREPEND); } } /* If peer does not exist, create new one. If peer already exists, set AS number to the peer. */ int peer_remote_as (struct bgp *bgp, union sockunion *su, as_t *as, afi_t afi, safi_t safi) { struct peer *peer; as_t local_as; peer = peer_lookup (bgp, su); if (peer) { /* When this peer is a member of peer-group. */ if (peer->group) { if (peer->group->conf->as) { /* Return peer group's AS number. */ *as = peer->group->conf->as; return BGP_ERR_PEER_GROUP_MEMBER; } if (peer_sort (peer->group->conf) == BGP_PEER_IBGP) { if (bgp->as != *as) { *as = peer->as; return BGP_ERR_PEER_GROUP_PEER_TYPE_DIFFERENT; } } else { if (bgp->as == *as) { *as = peer->as; return BGP_ERR_PEER_GROUP_PEER_TYPE_DIFFERENT; } } } /* Existing peer's AS number change. */ if (peer->as != *as) peer_as_change (peer, *as); } else { /* If the peer is not part of our confederation, and its not an iBGP peer then spoof the source AS */ if (bgp_config_check (bgp, BGP_CONFIG_CONFEDERATION) && ! bgp_confederation_peers_check (bgp, *as) && bgp->as != *as) local_as = bgp->confed_id; else local_as = bgp->as; /* If this is IPv4 unicast configuration and "no bgp default ipv4-unicast" is specified. */ if (bgp_flag_check (bgp, BGP_FLAG_NO_DEFAULT_IPV4) && afi == AFI_IP && safi == SAFI_UNICAST) peer = peer_create (su, bgp, local_as, *as, 0, 0); else peer = peer_create (su, bgp, local_as, *as, afi, safi); } return 0; } /* Activate the peer or peer group for specified AFI and SAFI. */ int peer_activate (struct peer *peer, afi_t afi, safi_t safi) { int active; if (peer->afc[afi][safi]) return 0; /* Activate the address family configuration. */ if (CHECK_FLAG (peer->sflags, PEER_STATUS_GROUP)) peer->afc[afi][safi] = 1; else { active = peer_active (peer); peer->afc[afi][safi] = 1; if (! active && peer_active (peer)) bgp_timer_set (peer); else { if (peer->status == Established) { if (CHECK_FLAG (peer->cap, PEER_CAP_DYNAMIC_RCV)) { peer->afc_adv[afi][safi] = 1; bgp_capability_send (peer, afi, safi, CAPABILITY_CODE_MP, CAPABILITY_ACTION_SET); if (peer->afc_recv[afi][safi]) { peer->afc_nego[afi][safi] = 1; bgp_announce_route (peer, afi, safi); } } else { peer->last_reset = PEER_DOWN_AF_ACTIVATE; bgp_notify_send (peer, BGP_NOTIFY_CEASE, BGP_NOTIFY_CEASE_CONFIG_CHANGE); } } } } return 0; } int peer_deactivate (struct peer *peer, afi_t afi, safi_t safi) { struct peer_group *group; struct peer *peer1; struct listnode *node, *nnode; if (CHECK_FLAG (peer->sflags, PEER_STATUS_GROUP)) { group = peer->group; for (ALL_LIST_ELEMENTS (group->peer, node, nnode, peer1)) { if (peer1->af_group[afi][safi]) return BGP_ERR_PEER_GROUP_MEMBER_EXISTS; } } else { if (peer->af_group[afi][safi]) return BGP_ERR_PEER_BELONGS_TO_GROUP; } if (! peer->afc[afi][safi]) return 0; /* De-activate the address family configuration. */ peer->afc[afi][safi] = 0; peer_af_flag_reset (peer, afi, safi); if (! CHECK_FLAG (peer->sflags, PEER_STATUS_GROUP)) { if (peer->status == Established) { if (CHECK_FLAG (peer->cap, PEER_CAP_DYNAMIC_RCV)) { peer->afc_adv[afi][safi] = 0; peer->afc_nego[afi][safi] = 0; if (peer_active_nego (peer)) { bgp_capability_send (peer, afi, safi, CAPABILITY_CODE_MP, CAPABILITY_ACTION_UNSET); bgp_clear_route (peer, afi, safi, BGP_CLEAR_ROUTE_NORMAL); peer->pcount[afi][safi] = 0; } else { peer->last_reset = PEER_DOWN_NEIGHBOR_DELETE; bgp_notify_send (peer, BGP_NOTIFY_CEASE, BGP_NOTIFY_CEASE_CONFIG_CHANGE); } } else { peer->last_reset = PEER_DOWN_NEIGHBOR_DELETE; bgp_notify_send (peer, BGP_NOTIFY_CEASE, BGP_NOTIFY_CEASE_CONFIG_CHANGE); } } } return 0; } static void peer_nsf_stop (struct peer *peer) { afi_t afi; safi_t safi; UNSET_FLAG (peer->sflags, PEER_STATUS_NSF_WAIT); UNSET_FLAG (peer->sflags, PEER_STATUS_NSF_MODE); for (afi = AFI_IP ; afi < AFI_MAX ; afi++) for (safi = SAFI_UNICAST ; safi < SAFI_RESERVED_3 ; safi++) peer->nsf[afi][safi] = 0; if (peer->t_gr_restart) { BGP_TIMER_OFF (peer->t_gr_restart); if (BGP_DEBUG (events, EVENTS)) zlog_debug ("%s graceful restart timer stopped", peer->host); } if (peer->t_gr_stale) { BGP_TIMER_OFF (peer->t_gr_stale); if (BGP_DEBUG (events, EVENTS)) zlog_debug ("%s graceful restart stalepath timer stopped", peer->host); } bgp_clear_route_all (peer); } /* Delete peer from confguration. * * The peer is moved to a dead-end "Deleted" neighbour-state, to allow * it to "cool off" and refcounts to hit 0, at which state it is freed. * * This function /should/ take care to be idempotent, to guard against * it being called multiple times through stray events that come in * that happen to result in this function being called again. That * said, getting here for a "Deleted" peer is a bug in the neighbour * FSM. */ int peer_delete (struct peer *peer) { int i; afi_t afi; safi_t safi; struct bgp *bgp; struct bgp_filter *filter; struct listnode *pn; assert (peer->status != Deleted); bgp = peer->bgp; if (CHECK_FLAG (peer->sflags, PEER_STATUS_NSF_WAIT)) peer_nsf_stop (peer); /* If this peer belongs to peer group, clear up the relationship. */ if (peer->group) { if ((pn = listnode_lookup (peer->group->peer, peer))) { peer = peer_unlock (peer); /* group->peer list reference */ list_delete_node (peer->group->peer, pn); } peer->group = NULL; } /* Withdraw all information from routing table. We can not use * BGP_EVENT_ADD (peer, BGP_Stop) at here. Because the event is * executed after peer structure is deleted. */ peer->last_reset = PEER_DOWN_NEIGHBOR_DELETE; bgp_stop (peer); bgp_fsm_change_status (peer, Deleted); /* Password configuration */ if (peer->password) { XFREE (MTYPE_PEER_PASSWORD, peer->password); peer->password = NULL; if (! CHECK_FLAG (peer->sflags, PEER_STATUS_GROUP)) bgp_md5_set (peer); } bgp_timer_set (peer); /* stops all timers for Deleted */ /* Delete from all peer list. */ if (! CHECK_FLAG (peer->sflags, PEER_STATUS_GROUP) && (pn = listnode_lookup (bgp->peer, peer))) { peer_unlock (peer); /* bgp peer list reference */ list_delete_node (bgp->peer, pn); } if (peer_rsclient_active (peer) && (pn = listnode_lookup (bgp->rsclient, peer))) { peer_unlock (peer); /* rsclient list reference */ list_delete_node (bgp->rsclient, pn); /* Clear our own rsclient ribs. */ for (afi = AFI_IP; afi < AFI_MAX; afi++) for (safi = SAFI_UNICAST; safi < SAFI_MAX; safi++) if (CHECK_FLAG(peer->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT)) bgp_clear_route (peer, afi, safi, BGP_CLEAR_ROUTE_MY_RSCLIENT); } /* Free RIB for any family in which peer is RSERVER_CLIENT, and is not member of a peer_group. */ for (afi = AFI_IP; afi < AFI_MAX; afi++) for (safi = SAFI_UNICAST; safi < SAFI_MAX; safi++) if (peer->rib[afi][safi] && ! peer->af_group[afi][safi]) bgp_table_finish (&peer->rib[afi][safi]); /* Buffers. */ if (peer->ibuf) stream_free (peer->ibuf); if (peer->obuf) stream_fifo_free (peer->obuf); if (peer->work) stream_free (peer->work); peer->obuf = NULL; peer->work = peer->ibuf = NULL; /* Local and remote addresses. */ if (peer->su_local) sockunion_free (peer->su_local); if (peer->su_remote) sockunion_free (peer->su_remote); peer->su_local = peer->su_remote = NULL; /* Free filter related memory. */ for (afi = AFI_IP; afi < AFI_MAX; afi++) for (safi = SAFI_UNICAST; safi < SAFI_MAX; safi++) { filter = &peer->filter[afi][safi]; for (i = FILTER_IN; i < FILTER_MAX; i++) { if (filter->dlist[i].name) free (filter->dlist[i].name); if (filter->plist[i].name) free (filter->plist[i].name); if (filter->aslist[i].name) free (filter->aslist[i].name); filter->dlist[i].name = NULL; filter->plist[i].name = NULL; filter->aslist[i].name = NULL; } for (i = RMAP_IN; i < RMAP_MAX; i++) { if (filter->map[i].name) free (filter->map[i].name); filter->map[i].name = NULL; } if (filter->usmap.name) free (filter->usmap.name); if (peer->default_rmap[afi][safi].name) free (peer->default_rmap[afi][safi].name); filter->usmap.name = NULL; peer->default_rmap[afi][safi].name = NULL; } peer_unlock (peer); /* initial reference */ return 0; } static int peer_group_cmp (struct peer_group *g1, struct peer_group *g2) { return strcmp (g1->name, g2->name); } /* If peer is configured at least one address family return 1. */ static int peer_group_active (struct peer *peer) { if (peer->af_group[AFI_IP][SAFI_UNICAST] || peer->af_group[AFI_IP][SAFI_MULTICAST] || peer->af_group[AFI_IP][SAFI_MPLS_VPN] || peer->af_group[AFI_IP6][SAFI_UNICAST] || peer->af_group[AFI_IP6][SAFI_MULTICAST]) return 1; return 0; } /* Peer group cofiguration. */ static struct peer_group * peer_group_new (void) { return (struct peer_group *) XCALLOC (MTYPE_PEER_GROUP, sizeof (struct peer_group)); } static void peer_group_free (struct peer_group *group) { XFREE (MTYPE_PEER_GROUP, group); } struct peer_group * peer_group_lookup (struct bgp *bgp, const char *name) { struct peer_group *group; struct listnode *node, *nnode; for (ALL_LIST_ELEMENTS (bgp->group, node, nnode, group)) { if (strcmp (group->name, name) == 0) return group; } return NULL; } struct peer_group * peer_group_get (struct bgp *bgp, const char *name) { struct peer_group *group; group = peer_group_lookup (bgp, name); if (group) return group; group = peer_group_new (); group->bgp = bgp; group->name = strdup (name); group->peer = list_new (); group->conf = peer_new (bgp); if (! bgp_flag_check (bgp, BGP_FLAG_NO_DEFAULT_IPV4)) group->conf->afc[AFI_IP][SAFI_UNICAST] = 1; group->conf->host = XSTRDUP (MTYPE_BGP_PEER_HOST, name); group->conf->group = group; group->conf->as = 0; group->conf->ttl = 1; group->conf->gtsm_hops = 0; group->conf->v_routeadv = BGP_DEFAULT_EBGP_ROUTEADV; UNSET_FLAG (group->conf->config, PEER_CONFIG_TIMER); UNSET_FLAG (group->conf->config, PEER_CONFIG_CONNECT); group->conf->keepalive = 0; group->conf->holdtime = 0; group->conf->connect = 0; SET_FLAG (group->conf->sflags, PEER_STATUS_GROUP); listnode_add_sort (bgp->group, group); return 0; } static void peer_group2peer_config_copy (struct peer_group *group, struct peer *peer, afi_t afi, safi_t safi) { int in = FILTER_IN; int out = FILTER_OUT; struct peer *conf; struct bgp_filter *pfilter; struct bgp_filter *gfilter; conf = group->conf; pfilter = &peer->filter[afi][safi]; gfilter = &conf->filter[afi][safi]; /* remote-as */ if (conf->as) peer->as = conf->as; /* remote-as */ if (conf->change_local_as) peer->change_local_as = conf->change_local_as; /* TTL */ peer->ttl = conf->ttl; /* GTSM hops */ peer->gtsm_hops = conf->gtsm_hops; /* Weight */ peer->weight = conf->weight; /* peer flags apply */ peer->flags = conf->flags; /* peer af_flags apply */ peer->af_flags[afi][safi] = conf->af_flags[afi][safi]; /* peer config apply */ peer->config = conf->config; /* peer timers apply */ peer->holdtime = conf->holdtime; peer->keepalive = conf->keepalive; peer->connect = conf->connect; if (CHECK_FLAG (conf->config, PEER_CONFIG_CONNECT)) peer->v_connect = conf->connect; else peer->v_connect = BGP_DEFAULT_CONNECT_RETRY; /* advertisement-interval reset */ if (peer_sort (peer) == BGP_PEER_IBGP) peer->v_routeadv = BGP_DEFAULT_IBGP_ROUTEADV; else peer->v_routeadv = BGP_DEFAULT_EBGP_ROUTEADV; /* password apply */ if (peer->password) XFREE (MTYPE_PEER_PASSWORD, peer->password); if (conf->password) peer->password = XSTRDUP (MTYPE_PEER_PASSWORD, conf->password); else peer->password = NULL; bgp_md5_set (peer); /* maximum-prefix */ peer->pmax[afi][safi] = conf->pmax[afi][safi]; peer->pmax_threshold[afi][safi] = conf->pmax_threshold[afi][safi]; peer->pmax_restart[afi][safi] = conf->pmax_restart[afi][safi]; /* allowas-in */ peer->allowas_in[afi][safi] = conf->allowas_in[afi][safi]; /* route-server-client */ if (CHECK_FLAG(conf->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT)) { /* Make peer's RIB point to group's RIB. */ peer->rib[afi][safi] = group->conf->rib[afi][safi]; /* Import policy. */ if (pfilter->map[RMAP_IMPORT].name) free (pfilter->map[RMAP_IMPORT].name); if (gfilter->map[RMAP_IMPORT].name) { pfilter->map[RMAP_IMPORT].name = strdup (gfilter->map[RMAP_IMPORT].name); pfilter->map[RMAP_IMPORT].map = gfilter->map[RMAP_IMPORT].map; } else { pfilter->map[RMAP_IMPORT].name = NULL; pfilter->map[RMAP_IMPORT].map = NULL; } /* Export policy. */ if (gfilter->map[RMAP_EXPORT].name && ! pfilter->map[RMAP_EXPORT].name) { pfilter->map[RMAP_EXPORT].name = strdup (gfilter->map[RMAP_EXPORT].name); pfilter->map[RMAP_EXPORT].map = gfilter->map[RMAP_EXPORT].map; } } /* default-originate route-map */ if (conf->default_rmap[afi][safi].name) { if (peer->default_rmap[afi][safi].name) free (peer->default_rmap[afi][safi].name); peer->default_rmap[afi][safi].name = strdup (conf->default_rmap[afi][safi].name); peer->default_rmap[afi][safi].map = conf->default_rmap[afi][safi].map; } /* update-source apply */ if (conf->update_source) { if (peer->update_source) sockunion_free (peer->update_source); if (peer->update_if) { XFREE (MTYPE_PEER_UPDATE_SOURCE, peer->update_if); peer->update_if = NULL; } peer->update_source = sockunion_dup (conf->update_source); } else if (conf->update_if) { if (peer->update_if) XFREE (MTYPE_PEER_UPDATE_SOURCE, peer->update_if); if (peer->update_source) { sockunion_free (peer->update_source); peer->update_source = NULL; } peer->update_if = XSTRDUP (MTYPE_PEER_UPDATE_SOURCE, conf->update_if); } /* inbound filter apply */ if (gfilter->dlist[in].name && ! pfilter->dlist[in].name) { if (pfilter->dlist[in].name) free (pfilter->dlist[in].name); pfilter->dlist[in].name = strdup (gfilter->dlist[in].name); pfilter->dlist[in].alist = gfilter->dlist[in].alist; } if (gfilter->plist[in].name && ! pfilter->plist[in].name) { if (pfilter->plist[in].name) free (pfilter->plist[in].name); pfilter->plist[in].name = strdup (gfilter->plist[in].name); pfilter->plist[in].plist = gfilter->plist[in].plist; } if (gfilter->aslist[in].name && ! pfilter->aslist[in].name) { if (pfilter->aslist[in].name) free (pfilter->aslist[in].name); pfilter->aslist[in].name = strdup (gfilter->aslist[in].name); pfilter->aslist[in].aslist = gfilter->aslist[in].aslist; } if (gfilter->map[RMAP_IN].name && ! pfilter->map[RMAP_IN].name) { if (pfilter->map[RMAP_IN].name) free (pfilter->map[RMAP_IN].name); pfilter->map[RMAP_IN].name = strdup (gfilter->map[RMAP_IN].name); pfilter->map[RMAP_IN].map = gfilter->map[RMAP_IN].map; } /* outbound filter apply */ if (gfilter->dlist[out].name) { if (pfilter->dlist[out].name) free (pfilter->dlist[out].name); pfilter->dlist[out].name = strdup (gfilter->dlist[out].name); pfilter->dlist[out].alist = gfilter->dlist[out].alist; } else { if (pfilter->dlist[out].name) free (pfilter->dlist[out].name); pfilter->dlist[out].name = NULL; pfilter->dlist[out].alist = NULL; } if (gfilter->plist[out].name) { if (pfilter->plist[out].name) free (pfilter->plist[out].name); pfilter->plist[out].name = strdup (gfilter->plist[out].name); pfilter->plist[out].plist = gfilter->plist[out].plist; } else { if (pfilter->plist[out].name) free (pfilter->plist[out].name); pfilter->plist[out].name = NULL; pfilter->plist[out].plist = NULL; } if (gfilter->aslist[out].name) { if (pfilter->aslist[out].name) free (pfilter->aslist[out].name); pfilter->aslist[out].name = strdup (gfilter->aslist[out].name); pfilter->aslist[out].aslist = gfilter->aslist[out].aslist; } else { if (pfilter->aslist[out].name) free (pfilter->aslist[out].name); pfilter->aslist[out].name = NULL; pfilter->aslist[out].aslist = NULL; } if (gfilter->map[RMAP_OUT].name) { if (pfilter->map[RMAP_OUT].name) free (pfilter->map[RMAP_OUT].name); pfilter->map[RMAP_OUT].name = strdup (gfilter->map[RMAP_OUT].name); pfilter->map[RMAP_OUT].map = gfilter->map[RMAP_OUT].map; } else { if (pfilter->map[RMAP_OUT].name) free (pfilter->map[RMAP_OUT].name); pfilter->map[RMAP_OUT].name = NULL; pfilter->map[RMAP_OUT].map = NULL; } /* RS-client's import/export route-maps. */ if (gfilter->map[RMAP_IMPORT].name) { if (pfilter->map[RMAP_IMPORT].name) free (pfilter->map[RMAP_IMPORT].name); pfilter->map[RMAP_IMPORT].name = strdup (gfilter->map[RMAP_IMPORT].name); pfilter->map[RMAP_IMPORT].map = gfilter->map[RMAP_IMPORT].map; } else { if (pfilter->map[RMAP_IMPORT].name) free (pfilter->map[RMAP_IMPORT].name); pfilter->map[RMAP_IMPORT].name = NULL; pfilter->map[RMAP_IMPORT].map = NULL; } if (gfilter->map[RMAP_EXPORT].name && ! pfilter->map[RMAP_EXPORT].name) { if (pfilter->map[RMAP_EXPORT].name) free (pfilter->map[RMAP_EXPORT].name); pfilter->map[RMAP_EXPORT].name = strdup (gfilter->map[RMAP_EXPORT].name); pfilter->map[RMAP_EXPORT].map = gfilter->map[RMAP_EXPORT].map; } if (gfilter->usmap.name) { if (pfilter->usmap.name) free (pfilter->usmap.name); pfilter->usmap.name = strdup (gfilter->usmap.name); pfilter->usmap.map = gfilter->usmap.map; } else { if (pfilter->usmap.name) free (pfilter->usmap.name); pfilter->usmap.name = NULL; pfilter->usmap.map = NULL; } } /* Peer group's remote AS configuration. */ int peer_group_remote_as (struct bgp *bgp, const char *group_name, as_t *as) { struct peer_group *group; struct peer *peer; struct listnode *node, *nnode; group = peer_group_lookup (bgp, group_name); if (! group) return -1; if (group->conf->as == *as) return 0; /* When we setup peer-group AS number all peer group member's AS number must be updated to same number. */ peer_as_change (group->conf, *as); for (ALL_LIST_ELEMENTS (group->peer, node, nnode, peer)) { if (peer->as != *as) peer_as_change (peer, *as); } return 0; } int peer_group_delete (struct peer_group *group) { struct bgp *bgp; struct peer *peer; struct listnode *node, *nnode; bgp = group->bgp; for (ALL_LIST_ELEMENTS (group->peer, node, nnode, peer)) { peer->group = NULL; peer_delete (peer); } list_delete (group->peer); free (group->name); group->name = NULL; group->conf->group = NULL; peer_delete (group->conf); /* Delete from all peer_group list. */ listnode_delete (bgp->group, group); peer_group_free (group); return 0; } int peer_group_remote_as_delete (struct peer_group *group) { struct peer *peer; struct listnode *node, *nnode; if (! group->conf->as) return 0; for (ALL_LIST_ELEMENTS (group->peer, node, nnode, peer)) { peer->group = NULL; peer_delete (peer); } list_delete_all_node (group->peer); group->conf->as = 0; return 0; } /* Bind specified peer to peer group. */ int peer_group_bind (struct bgp *bgp, union sockunion *su, struct peer_group *group, afi_t afi, safi_t safi, as_t *as) { struct peer *peer; int first_member = 0; /* Check peer group's address family. */ if (! group->conf->afc[afi][safi]) return BGP_ERR_PEER_GROUP_AF_UNCONFIGURED; /* Lookup the peer. */ peer = peer_lookup (bgp, su); /* Create a new peer. */ if (! peer) { if (! group->conf->as) return BGP_ERR_PEER_GROUP_NO_REMOTE_AS; peer = peer_create (su, bgp, bgp->as, group->conf->as, afi, safi); peer->group = group; peer->af_group[afi][safi] = 1; peer = peer_lock (peer); /* group->peer list reference */ listnode_add (group->peer, peer); peer_group2peer_config_copy (group, peer, afi, safi); return 0; } /* When the peer already belongs to peer group, check the consistency. */ if (peer->af_group[afi][safi]) { if (strcmp (peer->group->name, group->name) != 0) return BGP_ERR_PEER_GROUP_CANT_CHANGE; return 0; } /* Check current peer group configuration. */ if (peer_group_active (peer) && strcmp (peer->group->name, group->name) != 0) return BGP_ERR_PEER_GROUP_MISMATCH; if (! group->conf->as) { if (peer_sort (group->conf) != BGP_PEER_INTERNAL && peer_sort (group->conf) != peer_sort (peer)) { if (as) *as = peer->as; return BGP_ERR_PEER_GROUP_PEER_TYPE_DIFFERENT; } if (peer_sort (group->conf) == BGP_PEER_INTERNAL) first_member = 1; } peer->af_group[afi][safi] = 1; peer->afc[afi][safi] = 1; if (! peer->group) { peer->group = group; peer = peer_lock (peer); /* group->peer list reference */ listnode_add (group->peer, peer); } else assert (group && peer->group == group); if (first_member) { /* Advertisement-interval reset */ if (peer_sort (group->conf) == BGP_PEER_IBGP) group->conf->v_routeadv = BGP_DEFAULT_IBGP_ROUTEADV; else group->conf->v_routeadv = BGP_DEFAULT_EBGP_ROUTEADV; /* ebgp-multihop reset */ if (peer_sort (group->conf) == BGP_PEER_IBGP) group->conf->ttl = 255; /* local-as reset */ if (peer_sort (group->conf) != BGP_PEER_EBGP) { group->conf->change_local_as = 0; UNSET_FLAG (peer->flags, PEER_FLAG_LOCAL_AS_NO_PREPEND); } } if (CHECK_FLAG(peer->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT)) { struct listnode *pn; /* If it's not configured as RSERVER_CLIENT in any other address family, without being member of a peer_group, remove it from list bgp->rsclient.*/ if (! peer_rsclient_active (peer) && (pn = listnode_lookup (bgp->rsclient, peer))) { peer_unlock (peer); /* peer rsclient reference */ list_delete_node (bgp->rsclient, pn); /* Clear our own rsclient rib for this afi/safi. */ bgp_clear_route (peer, afi, safi, BGP_CLEAR_ROUTE_MY_RSCLIENT); } bgp_table_finish (&peer->rib[afi][safi]); /* Import policy. */ if (peer->filter[afi][safi].map[RMAP_IMPORT].name) { free (peer->filter[afi][safi].map[RMAP_IMPORT].name); peer->filter[afi][safi].map[RMAP_IMPORT].name = NULL; peer->filter[afi][safi].map[RMAP_IMPORT].map = NULL; } /* Export policy. */ if (! CHECK_FLAG(group->conf->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT) && peer->filter[afi][safi].map[RMAP_EXPORT].name) { free (peer->filter[afi][safi].map[RMAP_EXPORT].name); peer->filter[afi][safi].map[RMAP_EXPORT].name = NULL; peer->filter[afi][safi].map[RMAP_EXPORT].map = NULL; } } peer_group2peer_config_copy (group, peer, afi, safi); if (peer->status == Established) { peer->last_reset = PEER_DOWN_RMAP_BIND; bgp_notify_send (peer, BGP_NOTIFY_CEASE, BGP_NOTIFY_CEASE_CONFIG_CHANGE); } else BGP_EVENT_ADD (peer, BGP_Stop); return 0; } int peer_group_unbind (struct bgp *bgp, struct peer *peer, struct peer_group *group, afi_t afi, safi_t safi) { if (! peer->af_group[afi][safi]) return 0; if (group != peer->group) return BGP_ERR_PEER_GROUP_MISMATCH; peer->af_group[afi][safi] = 0; peer->afc[afi][safi] = 0; peer_af_flag_reset (peer, afi, safi); if (peer->rib[afi][safi]) peer->rib[afi][safi] = NULL; if (! peer_group_active (peer)) { assert (listnode_lookup (group->peer, peer)); peer_unlock (peer); /* peer group list reference */ listnode_delete (group->peer, peer); peer->group = NULL; if (group->conf->as) { peer_delete (peer); return 0; } peer_global_config_reset (peer); } if (peer->status == Established) { peer->last_reset = PEER_DOWN_RMAP_UNBIND; bgp_notify_send (peer, BGP_NOTIFY_CEASE, BGP_NOTIFY_CEASE_CONFIG_CHANGE); } else BGP_EVENT_ADD (peer, BGP_Stop); return 0; } /* BGP instance creation by `router bgp' commands. */ static struct bgp * bgp_create (as_t *as, const char *name) { struct bgp *bgp; afi_t afi; safi_t safi; if ( (bgp = XCALLOC (MTYPE_BGP, sizeof (struct bgp))) == NULL) return NULL; bgp_lock (bgp); bgp->peer_self = peer_new (bgp); bgp->peer_self->host = XSTRDUP (MTYPE_BGP_PEER_HOST, "Static announcement"); bgp->peer = list_new (); bgp->peer->cmp = (int (*)(void *, void *)) peer_cmp; bgp->group = list_new (); bgp->group->cmp = (int (*)(void *, void *)) peer_group_cmp; bgp->rsclient = list_new (); bgp->rsclient->cmp = (int (*)(void*, void*)) peer_cmp; for (afi = AFI_IP; afi < AFI_MAX; afi++) for (safi = SAFI_UNICAST; safi < SAFI_MAX; safi++) { bgp->route[afi][safi] = bgp_table_init (afi, safi); bgp->aggregate[afi][safi] = bgp_table_init (afi, safi); bgp->rib[afi][safi] = bgp_table_init (afi, safi); bgp->maxpaths[afi][safi].maxpaths_ebgp = BGP_DEFAULT_MAXPATHS; bgp->maxpaths[afi][safi].maxpaths_ibgp = BGP_DEFAULT_MAXPATHS; } bgp->default_local_pref = BGP_DEFAULT_LOCAL_PREF; bgp->default_holdtime = BGP_DEFAULT_HOLDTIME; bgp->default_keepalive = BGP_DEFAULT_KEEPALIVE; bgp->restart_time = BGP_DEFAULT_RESTART_TIME; bgp->stalepath_time = BGP_DEFAULT_STALEPATH_TIME; bgp->as = *as; if (name) bgp->name = strdup (name); return bgp; } /* Return first entry of BGP. */ struct bgp * bgp_get_default (void) { if (bm->bgp->head) return (listgetdata (listhead (bm->bgp))); return NULL; } /* Lookup BGP entry. */ struct bgp * bgp_lookup (as_t as, const char *name) { struct bgp *bgp; struct listnode *node, *nnode; for (ALL_LIST_ELEMENTS (bm->bgp, node, nnode, bgp)) if (bgp->as == as && ((bgp->name == NULL && name == NULL) || (bgp->name && name && strcmp (bgp->name, name) == 0))) return bgp; return NULL; } /* Lookup BGP structure by view name. */ struct bgp * bgp_lookup_by_name (const char *name) { struct bgp *bgp; struct listnode *node, *nnode; for (ALL_LIST_ELEMENTS (bm->bgp, node, nnode, bgp)) if ((bgp->name == NULL && name == NULL) || (bgp->name && name && strcmp (bgp->name, name) == 0)) return bgp; return NULL; } /* Called from VTY commands. */ int bgp_get (struct bgp **bgp_val, as_t *as, const char *name) { struct bgp *bgp; /* Multiple instance check. */ if (bgp_option_check (BGP_OPT_MULTIPLE_INSTANCE)) { if (name) bgp = bgp_lookup_by_name (name); else bgp = bgp_get_default (); /* Already exists. */ if (bgp) { if (bgp->as != *as) { *as = bgp->as; return BGP_ERR_INSTANCE_MISMATCH; } *bgp_val = bgp; return 0; } } else { /* BGP instance name can not be specified for single instance. */ if (name) return BGP_ERR_MULTIPLE_INSTANCE_NOT_SET; /* Get default BGP structure if exists. */ bgp = bgp_get_default (); if (bgp) { if (bgp->as != *as) { *as = bgp->as; return BGP_ERR_AS_MISMATCH; } *bgp_val = bgp; return 0; } } bgp = bgp_create (as, name); bgp_router_id_set(bgp, &router_id_kroute); *bgp_val = bgp; /* Create BGP server socket, if first instance. */ if (list_isempty(bm->bgp)) { if (bgp_socket (bm->port, bm->address) < 0) return BGP_ERR_INVALID_VALUE; } listnode_add (bm->bgp, bgp); return 0; } /* Delete BGP instance. */ int bgp_delete (struct bgp *bgp) { struct peer *peer; struct peer_group *group; struct listnode *node; struct listnode *next; afi_t afi; int i; /* Delete static route. */ bgp_static_delete (bgp); /* Unset redistribution. */ for (afi = AFI_IP; afi < AFI_MAX; afi++) for (i = 0; i < KROUTE_ROUTE_MAX; i++) if (i != KROUTE_ROUTE_BGP) bgp_redistribute_unset (bgp, afi, i); for (ALL_LIST_ELEMENTS (bgp->peer, node, next, peer)) peer_delete (peer); for (ALL_LIST_ELEMENTS (bgp->group, node, next, group)) peer_group_delete (group); assert (listcount (bgp->rsclient) == 0); if (bgp->peer_self) { peer_delete(bgp->peer_self); bgp->peer_self = NULL; } /* Remove visibility via the master list - there may however still be * routes to be processed still referencing the struct bgp. */ listnode_delete (bm->bgp, bgp); if (list_isempty(bm->bgp)) bgp_close (); bgp_unlock(bgp); /* initial reference */ return 0; } static void bgp_free (struct bgp *); void bgp_lock (struct bgp *bgp) { ++bgp->lock; } void bgp_unlock(struct bgp *bgp) { assert(bgp->lock > 0); if (--bgp->lock == 0) bgp_free (bgp); } static void bgp_free (struct bgp *bgp) { afi_t afi; safi_t safi; list_delete (bgp->group); list_delete (bgp->peer); list_delete (bgp->rsclient); if (bgp->name) free (bgp->name); for (afi = AFI_IP; afi < AFI_MAX; afi++) for (safi = SAFI_UNICAST; safi < SAFI_MAX; safi++) { if (bgp->route[afi][safi]) bgp_table_finish (&bgp->route[afi][safi]); if (bgp->aggregate[afi][safi]) bgp_table_finish (&bgp->aggregate[afi][safi]) ; if (bgp->rib[afi][safi]) bgp_table_finish (&bgp->rib[afi][safi]); } XFREE (MTYPE_BGP, bgp); } struct peer * peer_lookup (struct bgp *bgp, union sockunion *su) { struct peer *peer; struct listnode *node, *nnode; if (bgp != NULL) { for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer)) if (sockunion_same (&peer->su, su) && ! CHECK_FLAG (peer->sflags, PEER_STATUS_ACCEPT_PEER)) return peer; } else if (bm->bgp != NULL) { struct listnode *bgpnode, *nbgpnode; for (ALL_LIST_ELEMENTS (bm->bgp, bgpnode, nbgpnode, bgp)) for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer)) if (sockunion_same (&peer->su, su) && ! CHECK_FLAG (peer->sflags, PEER_STATUS_ACCEPT_PEER)) return peer; } return NULL; } struct peer * peer_lookup_with_open (union sockunion *su, as_t remote_as, struct in_addr *remote_id, int *as) { struct peer *peer; struct listnode *node; struct listnode *bgpnode; struct bgp *bgp; if (! bm->bgp) return NULL; for (ALL_LIST_ELEMENTS_RO (bm->bgp, bgpnode, bgp)) { for (ALL_LIST_ELEMENTS_RO (bgp->peer, node, peer)) { if (sockunion_same (&peer->su, su) && ! CHECK_FLAG (peer->sflags, PEER_STATUS_ACCEPT_PEER)) { if (peer->as == remote_as && peer->remote_id.s_addr == remote_id->s_addr) return peer; if (peer->as == remote_as) *as = 1; } } for (ALL_LIST_ELEMENTS_RO (bgp->peer, node, peer)) { if (sockunion_same (&peer->su, su) && ! CHECK_FLAG (peer->sflags, PEER_STATUS_ACCEPT_PEER)) { if (peer->as == remote_as && peer->remote_id.s_addr == 0) return peer; if (peer->as == remote_as) *as = 1; } } } return NULL; } /* If peer is configured at least one address family return 1. */ int peer_active (struct peer *peer) { if (peer->afc[AFI_IP][SAFI_UNICAST] || peer->afc[AFI_IP][SAFI_MULTICAST] || peer->afc[AFI_IP][SAFI_MPLS_VPN] || peer->afc[AFI_IP6][SAFI_UNICAST] || peer->afc[AFI_IP6][SAFI_MULTICAST]) return 1; return 0; } /* If peer is negotiated at least one address family return 1. */ int peer_active_nego (struct peer *peer) { if (peer->afc_nego[AFI_IP][SAFI_UNICAST] || peer->afc_nego[AFI_IP][SAFI_MULTICAST] || peer->afc_nego[AFI_IP][SAFI_MPLS_VPN] || peer->afc_nego[AFI_IP6][SAFI_UNICAST] || peer->afc_nego[AFI_IP6][SAFI_MULTICAST]) return 1; return 0; } /* peer_flag_change_type. */ enum peer_change_type { peer_change_none, peer_change_reset, peer_change_reset_in, peer_change_reset_out, }; static void peer_change_action (struct peer *peer, afi_t afi, safi_t safi, enum peer_change_type type) { if (CHECK_FLAG (peer->sflags, PEER_STATUS_GROUP)) return; if (type == peer_change_reset) bgp_notify_send (peer, BGP_NOTIFY_CEASE, BGP_NOTIFY_CEASE_CONFIG_CHANGE); else if (type == peer_change_reset_in) { if (CHECK_FLAG (peer->cap, PEER_CAP_REFRESH_OLD_RCV) || CHECK_FLAG (peer->cap, PEER_CAP_REFRESH_NEW_RCV)) bgp_route_refresh_send (peer, afi, safi, 0, 0, 0); else bgp_notify_send (peer, BGP_NOTIFY_CEASE, BGP_NOTIFY_CEASE_CONFIG_CHANGE); } else if (type == peer_change_reset_out) bgp_announce_route (peer, afi, safi); } struct peer_flag_action { /* Peer's flag. */ u_int32_t flag; /* This flag can be set for peer-group member. */ u_char not_for_member; /* Action when the flag is changed. */ enum peer_change_type type; /* Peer down cause */ u_char peer_down; }; static const struct peer_flag_action peer_flag_action_list[] = { { PEER_FLAG_PASSIVE, 0, peer_change_reset }, { PEER_FLAG_SHUTDOWN, 0, peer_change_reset }, { PEER_FLAG_DONT_CAPABILITY, 0, peer_change_none }, { PEER_FLAG_OVERRIDE_CAPABILITY, 0, peer_change_none }, { PEER_FLAG_STRICT_CAP_MATCH, 0, peer_change_none }, { PEER_FLAG_DYNAMIC_CAPABILITY, 0, peer_change_reset }, { PEER_FLAG_DISABLE_CONNECTED_CHECK, 0, peer_change_reset }, { 0, 0, 0 } }; static const struct peer_flag_action peer_af_flag_action_list[] = { { PEER_FLAG_NEXTHOP_SELF, 1, peer_change_reset_out }, { PEER_FLAG_SEND_COMMUNITY, 1, peer_change_reset_out }, { PEER_FLAG_SEND_EXT_COMMUNITY, 1, peer_change_reset_out }, { PEER_FLAG_SOFT_RECONFIG, 0, peer_change_reset_in }, { PEER_FLAG_REFLECTOR_CLIENT, 1, peer_change_reset }, { PEER_FLAG_RSERVER_CLIENT, 1, peer_change_reset }, { PEER_FLAG_AS_PATH_UNCHANGED, 1, peer_change_reset_out }, { PEER_FLAG_NEXTHOP_UNCHANGED, 1, peer_change_reset_out }, { PEER_FLAG_MED_UNCHANGED, 1, peer_change_reset_out }, { PEER_FLAG_REMOVE_PRIVATE_AS, 1, peer_change_reset_out }, { PEER_FLAG_ALLOWAS_IN, 0, peer_change_reset_in }, { PEER_FLAG_ORF_PREFIX_SM, 1, peer_change_reset }, { PEER_FLAG_ORF_PREFIX_RM, 1, peer_change_reset }, { PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED, 0, peer_change_reset_out }, { 0, 0, 0 } }; /* Proper action set. */ static int peer_flag_action_set (const struct peer_flag_action *action_list, int size, struct peer_flag_action *action, u_int32_t flag) { int i; int found = 0; int reset_in = 0; int reset_out = 0; const struct peer_flag_action *match = NULL; /* Check peer's frag action. */ for (i = 0; i < size; i++) { match = &action_list[i]; if (match->flag == 0) break; if (match->flag & flag) { found = 1; if (match->type == peer_change_reset_in) reset_in = 1; if (match->type == peer_change_reset_out) reset_out = 1; if (match->type == peer_change_reset) { reset_in = 1; reset_out = 1; } if (match->not_for_member) action->not_for_member = 1; } } /* Set peer clear type. */ if (reset_in && reset_out) action->type = peer_change_reset; else if (reset_in) action->type = peer_change_reset_in; else if (reset_out) action->type = peer_change_reset_out; else action->type = peer_change_none; return found; } static void peer_flag_modify_action (struct peer *peer, u_int32_t flag) { if (flag == PEER_FLAG_SHUTDOWN) { if (CHECK_FLAG (peer->flags, flag)) { if (CHECK_FLAG (peer->sflags, PEER_STATUS_NSF_WAIT)) peer_nsf_stop (peer); UNSET_FLAG (peer->sflags, PEER_STATUS_PREFIX_OVERFLOW); if (peer->t_pmax_restart) { BGP_TIMER_OFF (peer->t_pmax_restart); if (BGP_DEBUG (events, EVENTS)) zlog_debug ("%s Maximum-prefix restart timer canceled", peer->host); } if (CHECK_FLAG (peer->sflags, PEER_STATUS_NSF_WAIT)) peer_nsf_stop (peer); if (peer->status == Established) bgp_notify_send (peer, BGP_NOTIFY_CEASE, BGP_NOTIFY_CEASE_ADMIN_SHUTDOWN); else BGP_EVENT_ADD (peer, BGP_Stop); } else { peer->v_start = BGP_INIT_START_TIMER; BGP_EVENT_ADD (peer, BGP_Stop); } } else if (peer->status == Established) { if (flag == PEER_FLAG_DYNAMIC_CAPABILITY) peer->last_reset = PEER_DOWN_CAPABILITY_CHANGE; else if (flag == PEER_FLAG_PASSIVE) peer->last_reset = PEER_DOWN_PASSIVE_CHANGE; else if (flag == PEER_FLAG_DISABLE_CONNECTED_CHECK) peer->last_reset = PEER_DOWN_MULTIHOP_CHANGE; bgp_notify_send (peer, BGP_NOTIFY_CEASE, BGP_NOTIFY_CEASE_CONFIG_CHANGE); } else BGP_EVENT_ADD (peer, BGP_Stop); } /* Change specified peer flag. */ static int peer_flag_modify (struct peer *peer, u_int32_t flag, int set) { int found; int size; struct peer_group *group; struct listnode *node, *nnode; struct peer_flag_action action; memset (&action, 0, sizeof (struct peer_flag_action)); size = sizeof peer_flag_action_list / sizeof (struct peer_flag_action); found = peer_flag_action_set (peer_flag_action_list, size, &action, flag); /* No flag action is found. */ if (! found) return BGP_ERR_INVALID_FLAG; /* Not for peer-group member. */ if (action.not_for_member && peer_group_active (peer)) return BGP_ERR_INVALID_FOR_PEER_GROUP_MEMBER; /* When unset the peer-group member's flag we have to check peer-group configuration. */ if (! set && peer_group_active (peer)) if (CHECK_FLAG (peer->group->conf->flags, flag)) { if (flag == PEER_FLAG_SHUTDOWN) return BGP_ERR_PEER_GROUP_SHUTDOWN; else return BGP_ERR_PEER_GROUP_HAS_THE_FLAG; } /* Flag conflict check. */ if (set && CHECK_FLAG (peer->flags | flag, PEER_FLAG_STRICT_CAP_MATCH) && CHECK_FLAG (peer->flags | flag, PEER_FLAG_OVERRIDE_CAPABILITY)) return BGP_ERR_PEER_FLAG_CONFLICT; if (! CHECK_FLAG (peer->sflags, PEER_STATUS_GROUP)) { if (set && CHECK_FLAG (peer->flags, flag) == flag) return 0; if (! set && ! CHECK_FLAG (peer->flags, flag)) return 0; } if (set) SET_FLAG (peer->flags, flag); else UNSET_FLAG (peer->flags, flag); if (! CHECK_FLAG (peer->sflags, PEER_STATUS_GROUP)) { if (action.type == peer_change_reset) peer_flag_modify_action (peer, flag); return 0; } /* peer-group member updates. */ group = peer->group; for (ALL_LIST_ELEMENTS (group->peer, node, nnode, peer)) { if (set && CHECK_FLAG (peer->flags, flag) == flag) continue; if (! set && ! CHECK_FLAG (peer->flags, flag)) continue; if (set) SET_FLAG (peer->flags, flag); else UNSET_FLAG (peer->flags, flag); if (action.type == peer_change_reset) peer_flag_modify_action (peer, flag); } return 0; } int peer_flag_set (struct peer *peer, u_int32_t flag) { return peer_flag_modify (peer, flag, 1); } int peer_flag_unset (struct peer *peer, u_int32_t flag) { return peer_flag_modify (peer, flag, 0); } static int peer_is_group_member (struct peer *peer, afi_t afi, safi_t safi) { if (peer->af_group[afi][safi]) return 1; return 0; } static int peer_af_flag_modify (struct peer *peer, afi_t afi, safi_t safi, u_int32_t flag, int set) { int found; int size; struct listnode *node, *nnode; struct peer_group *group; struct peer_flag_action action; memset (&action, 0, sizeof (struct peer_flag_action)); size = sizeof peer_af_flag_action_list / sizeof (struct peer_flag_action); found = peer_flag_action_set (peer_af_flag_action_list, size, &action, flag); /* No flag action is found. */ if (! found) return BGP_ERR_INVALID_FLAG; /* Adress family must be activated. */ if (! peer->afc[afi][safi]) return BGP_ERR_PEER_INACTIVE; /* Not for peer-group member. */ if (action.not_for_member && peer_is_group_member (peer, afi, safi)) return BGP_ERR_INVALID_FOR_PEER_GROUP_MEMBER; /* Spcecial check for reflector client. */ if (flag & PEER_FLAG_REFLECTOR_CLIENT && peer_sort (peer) != BGP_PEER_IBGP) return BGP_ERR_NOT_INTERNAL_PEER; /* Spcecial check for remove-private-AS. */ if (flag & PEER_FLAG_REMOVE_PRIVATE_AS && peer_sort (peer) == BGP_PEER_IBGP) return BGP_ERR_REMOVE_PRIVATE_AS; /* When unset the peer-group member's flag we have to check peer-group configuration. */ if (! set && peer->af_group[afi][safi]) if (CHECK_FLAG (peer->group->conf->af_flags[afi][safi], flag)) return BGP_ERR_PEER_GROUP_HAS_THE_FLAG; /* When current flag configuration is same as requested one. */ if (! CHECK_FLAG (peer->sflags, PEER_STATUS_GROUP)) { if (set && CHECK_FLAG (peer->af_flags[afi][safi], flag) == flag) return 0; if (! set && ! CHECK_FLAG (peer->af_flags[afi][safi], flag)) return 0; } if (set) SET_FLAG (peer->af_flags[afi][safi], flag); else UNSET_FLAG (peer->af_flags[afi][safi], flag); /* Execute action when peer is established. */ if (! CHECK_FLAG (peer->sflags, PEER_STATUS_GROUP) && peer->status == Established) { if (! set && flag == PEER_FLAG_SOFT_RECONFIG) bgp_clear_adj_in (peer, afi, safi); else { if (flag == PEER_FLAG_REFLECTOR_CLIENT) peer->last_reset = PEER_DOWN_RR_CLIENT_CHANGE; else if (flag == PEER_FLAG_RSERVER_CLIENT) peer->last_reset = PEER_DOWN_RS_CLIENT_CHANGE; else if (flag == PEER_FLAG_ORF_PREFIX_SM) peer->last_reset = PEER_DOWN_CAPABILITY_CHANGE; else if (flag == PEER_FLAG_ORF_PREFIX_RM) peer->last_reset = PEER_DOWN_CAPABILITY_CHANGE; peer_change_action (peer, afi, safi, action.type); } } /* Peer group member updates. */ if (CHECK_FLAG (peer->sflags, PEER_STATUS_GROUP)) { group = peer->group; for (ALL_LIST_ELEMENTS (group->peer, node, nnode, peer)) { if (! peer->af_group[afi][safi]) continue; if (set && CHECK_FLAG (peer->af_flags[afi][safi], flag) == flag) continue; if (! set && ! CHECK_FLAG (peer->af_flags[afi][safi], flag)) continue; if (set) SET_FLAG (peer->af_flags[afi][safi], flag); else UNSET_FLAG (peer->af_flags[afi][safi], flag); if (peer->status == Established) { if (! set && flag == PEER_FLAG_SOFT_RECONFIG) bgp_clear_adj_in (peer, afi, safi); else { if (flag == PEER_FLAG_REFLECTOR_CLIENT) peer->last_reset = PEER_DOWN_RR_CLIENT_CHANGE; else if (flag == PEER_FLAG_RSERVER_CLIENT) peer->last_reset = PEER_DOWN_RS_CLIENT_CHANGE; else if (flag == PEER_FLAG_ORF_PREFIX_SM) peer->last_reset = PEER_DOWN_CAPABILITY_CHANGE; else if (flag == PEER_FLAG_ORF_PREFIX_RM) peer->last_reset = PEER_DOWN_CAPABILITY_CHANGE; peer_change_action (peer, afi, safi, action.type); } } } } return 0; } int peer_af_flag_set (struct peer *peer, afi_t afi, safi_t safi, u_int32_t flag) { return peer_af_flag_modify (peer, afi, safi, flag, 1); } int peer_af_flag_unset (struct peer *peer, afi_t afi, safi_t safi, u_int32_t flag) { return peer_af_flag_modify (peer, afi, safi, flag, 0); } /* EBGP multihop configuration. */ int peer_ebgp_multihop_set (struct peer *peer, int ttl) { struct peer_group *group; struct listnode *node, *nnode; struct peer *peer1; if (peer_sort (peer) == BGP_PEER_IBGP) return 0; /* see comment in peer_ttl_security_hops_set() */ if (ttl != MAXTTL) { if (CHECK_FLAG (peer->sflags, PEER_STATUS_GROUP)) { group = peer->group; if (group->conf->gtsm_hops != 0) return BGP_ERR_NO_EBGP_MULTIHOP_WITH_TTLHACK; for (ALL_LIST_ELEMENTS (group->peer, node, nnode, peer1)) { if (peer_sort (peer1) == BGP_PEER_IBGP) continue; if (peer1->gtsm_hops != 0) return BGP_ERR_NO_EBGP_MULTIHOP_WITH_TTLHACK; } } else { if (peer->gtsm_hops != 0) return BGP_ERR_NO_EBGP_MULTIHOP_WITH_TTLHACK; } } peer->ttl = ttl; if (! CHECK_FLAG (peer->sflags, PEER_STATUS_GROUP)) { if (peer->fd >= 0 && peer_sort (peer) != BGP_PEER_IBGP) sockopt_ttl (peer->su.sa.sa_family, peer->fd, peer->ttl); } else { group = peer->group; for (ALL_LIST_ELEMENTS (group->peer, node, nnode, peer)) { if (peer_sort (peer) == BGP_PEER_IBGP) continue; peer->ttl = group->conf->ttl; if (peer->fd >= 0) sockopt_ttl (peer->su.sa.sa_family, peer->fd, peer->ttl); } } return 0; } int peer_ebgp_multihop_unset (struct peer *peer) { struct peer_group *group; struct listnode *node, *nnode; if (peer_sort (peer) == BGP_PEER_IBGP) return 0; if (peer->gtsm_hops != 0 && peer->ttl != MAXTTL) return BGP_ERR_NO_EBGP_MULTIHOP_WITH_TTLHACK; if (peer_group_active (peer)) peer->ttl = peer->group->conf->ttl; else peer->ttl = 1; if (! CHECK_FLAG (peer->sflags, PEER_STATUS_GROUP)) { if (peer->fd >= 0 && peer_sort (peer) != BGP_PEER_IBGP) sockopt_ttl (peer->su.sa.sa_family, peer->fd, peer->ttl); } else { group = peer->group; for (ALL_LIST_ELEMENTS (group->peer, node, nnode, peer)) { if (peer_sort (peer) == BGP_PEER_IBGP) continue; peer->ttl = 1; if (peer->fd >= 0) sockopt_ttl (peer->su.sa.sa_family, peer->fd, peer->ttl); } } return 0; } /* Neighbor description. */ int peer_description_set (struct peer *peer, char *desc) { if (peer->desc) XFREE (MTYPE_PEER_DESC, peer->desc); peer->desc = XSTRDUP (MTYPE_PEER_DESC, desc); return 0; } int peer_description_unset (struct peer *peer) { if (peer->desc) XFREE (MTYPE_PEER_DESC, peer->desc); peer->desc = NULL; return 0; } /* Neighbor update-source. */ int peer_update_source_if_set (struct peer *peer, const char *ifname) { struct peer_group *group; struct listnode *node, *nnode; if (peer->update_if) { if (! CHECK_FLAG (peer->sflags, PEER_STATUS_GROUP) && strcmp (peer->update_if, ifname) == 0) return 0; XFREE (MTYPE_PEER_UPDATE_SOURCE, peer->update_if); peer->update_if = NULL; } if (peer->update_source) { sockunion_free (peer->update_source); peer->update_source = NULL; } peer->update_if = XSTRDUP (MTYPE_PEER_UPDATE_SOURCE, ifname); if (! CHECK_FLAG (peer->sflags, PEER_STATUS_GROUP)) { if (peer->status == Established) { peer->last_reset = PEER_DOWN_UPDATE_SOURCE_CHANGE; bgp_notify_send (peer, BGP_NOTIFY_CEASE, BGP_NOTIFY_CEASE_CONFIG_CHANGE); } else BGP_EVENT_ADD (peer, BGP_Stop); return 0; } /* peer-group member updates. */ group = peer->group; for (ALL_LIST_ELEMENTS (group->peer, node, nnode, peer)) { if (peer->update_if) { if (strcmp (peer->update_if, ifname) == 0) continue; XFREE (MTYPE_PEER_UPDATE_SOURCE, peer->update_if); peer->update_if = NULL; } if (peer->update_source) { sockunion_free (peer->update_source); peer->update_source = NULL; } peer->update_if = XSTRDUP (MTYPE_PEER_UPDATE_SOURCE, ifname); if (peer->status == Established) { peer->last_reset = PEER_DOWN_UPDATE_SOURCE_CHANGE; bgp_notify_send (peer, BGP_NOTIFY_CEASE, BGP_NOTIFY_CEASE_CONFIG_CHANGE); } else BGP_EVENT_ADD (peer, BGP_Stop); } return 0; } int peer_update_source_addr_set (struct peer *peer, union sockunion *su) { struct peer_group *group; struct listnode *node, *nnode; if (peer->update_source) { if (! CHECK_FLAG (peer->sflags, PEER_STATUS_GROUP) && sockunion_cmp (peer->update_source, su) == 0) return 0; sockunion_free (peer->update_source); peer->update_source = NULL; } if (peer->update_if) { XFREE (MTYPE_PEER_UPDATE_SOURCE, peer->update_if); peer->update_if = NULL; } peer->update_source = sockunion_dup (su); if (! CHECK_FLAG (peer->sflags, PEER_STATUS_GROUP)) { if (peer->status == Established) { peer->last_reset = PEER_DOWN_UPDATE_SOURCE_CHANGE; bgp_notify_send (peer, BGP_NOTIFY_CEASE, BGP_NOTIFY_CEASE_CONFIG_CHANGE); } else BGP_EVENT_ADD (peer, BGP_Stop); return 0; } /* peer-group member updates. */ group = peer->group; for (ALL_LIST_ELEMENTS (group->peer, node, nnode, peer)) { if (peer->update_source) { if (sockunion_cmp (peer->update_source, su) == 0) continue; sockunion_free (peer->update_source); peer->update_source = NULL; } if (peer->update_if) { XFREE (MTYPE_PEER_UPDATE_SOURCE, peer->update_if); peer->update_if = NULL; } peer->update_source = sockunion_dup (su); if (peer->status == Established) { peer->last_reset = PEER_DOWN_UPDATE_SOURCE_CHANGE; bgp_notify_send (peer, BGP_NOTIFY_CEASE, BGP_NOTIFY_CEASE_CONFIG_CHANGE); } else BGP_EVENT_ADD (peer, BGP_Stop); } return 0; } int peer_update_source_unset (struct peer *peer) { union sockunion *su; struct peer_group *group; struct listnode *node, *nnode; if (! CHECK_FLAG (peer->sflags, PEER_STATUS_GROUP) && ! peer->update_source && ! peer->update_if) return 0; if (peer->update_source) { sockunion_free (peer->update_source); peer->update_source = NULL; } if (peer->update_if) { XFREE (MTYPE_PEER_UPDATE_SOURCE, peer->update_if); peer->update_if = NULL; } if (peer_group_active (peer)) { group = peer->group; if (group->conf->update_source) { su = sockunion_dup (group->conf->update_source); peer->update_source = su; } else if (group->conf->update_if) peer->update_if = XSTRDUP (MTYPE_PEER_UPDATE_SOURCE, group->conf->update_if); } if (! CHECK_FLAG (peer->sflags, PEER_STATUS_GROUP)) { if (peer->status == Established) { peer->last_reset = PEER_DOWN_UPDATE_SOURCE_CHANGE; bgp_notify_send (peer, BGP_NOTIFY_CEASE, BGP_NOTIFY_CEASE_CONFIG_CHANGE); } else BGP_EVENT_ADD (peer, BGP_Stop); return 0; } /* peer-group member updates. */ group = peer->group; for (ALL_LIST_ELEMENTS (group->peer, node, nnode, peer)) { if (! peer->update_source && ! peer->update_if) continue; if (peer->update_source) { sockunion_free (peer->update_source); peer->update_source = NULL; } if (peer->update_if) { XFREE (MTYPE_PEER_UPDATE_SOURCE, peer->update_if); peer->update_if = NULL; } if (peer->status == Established) { peer->last_reset = PEER_DOWN_UPDATE_SOURCE_CHANGE; bgp_notify_send (peer, BGP_NOTIFY_CEASE, BGP_NOTIFY_CEASE_CONFIG_CHANGE); } else BGP_EVENT_ADD (peer, BGP_Stop); } return 0; } int peer_default_originate_set (struct peer *peer, afi_t afi, safi_t safi, const char *rmap) { struct peer_group *group; struct listnode *node, *nnode; /* Adress family must be activated. */ if (! peer->afc[afi][safi]) return BGP_ERR_PEER_INACTIVE; /* Default originate can't be used for peer group memeber. */ if (peer_is_group_member (peer, afi, safi)) return BGP_ERR_INVALID_FOR_PEER_GROUP_MEMBER; if (! CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_DEFAULT_ORIGINATE) || (rmap && ! peer->default_rmap[afi][safi].name) || (rmap && strcmp (rmap, peer->default_rmap[afi][safi].name) != 0)) { SET_FLAG (peer->af_flags[afi][safi], PEER_FLAG_DEFAULT_ORIGINATE); if (rmap) { if (peer->default_rmap[afi][safi].name) free (peer->default_rmap[afi][safi].name); peer->default_rmap[afi][safi].name = strdup (rmap); peer->default_rmap[afi][safi].map = route_map_lookup_by_name (rmap); } } if (! CHECK_FLAG (peer->sflags, PEER_STATUS_GROUP)) { if (peer->status == Established && peer->afc_nego[afi][safi]) bgp_default_originate (peer, afi, safi, 0); return 0; } /* peer-group member updates. */ group = peer->group; for (ALL_LIST_ELEMENTS (group->peer, node, nnode, peer)) { SET_FLAG (peer->af_flags[afi][safi], PEER_FLAG_DEFAULT_ORIGINATE); if (rmap) { if (peer->default_rmap[afi][safi].name) free (peer->default_rmap[afi][safi].name); peer->default_rmap[afi][safi].name = strdup (rmap); peer->default_rmap[afi][safi].map = route_map_lookup_by_name (rmap); } if (peer->status == Established && peer->afc_nego[afi][safi]) bgp_default_originate (peer, afi, safi, 0); } return 0; } int peer_default_originate_unset (struct peer *peer, afi_t afi, safi_t safi) { struct peer_group *group; struct listnode *node, *nnode; /* Adress family must be activated. */ if (! peer->afc[afi][safi]) return BGP_ERR_PEER_INACTIVE; /* Default originate can't be used for peer group memeber. */ if (peer_is_group_member (peer, afi, safi)) return BGP_ERR_INVALID_FOR_PEER_GROUP_MEMBER; if (CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_DEFAULT_ORIGINATE)) { UNSET_FLAG (peer->af_flags[afi][safi], PEER_FLAG_DEFAULT_ORIGINATE); if (peer->default_rmap[afi][safi].name) free (peer->default_rmap[afi][safi].name); peer->default_rmap[afi][safi].name = NULL; peer->default_rmap[afi][safi].map = NULL; } if (! CHECK_FLAG (peer->sflags, PEER_STATUS_GROUP)) { if (peer->status == Established && peer->afc_nego[afi][safi]) bgp_default_originate (peer, afi, safi, 1); return 0; } /* peer-group member updates. */ group = peer->group; for (ALL_LIST_ELEMENTS (group->peer, node, nnode, peer)) { UNSET_FLAG (peer->af_flags[afi][safi], PEER_FLAG_DEFAULT_ORIGINATE); if (peer->default_rmap[afi][safi].name) free (peer->default_rmap[afi][safi].name); peer->default_rmap[afi][safi].name = NULL; peer->default_rmap[afi][safi].map = NULL; if (peer->status == Established && peer->afc_nego[afi][safi]) bgp_default_originate (peer, afi, safi, 1); } return 0; } int peer_port_set (struct peer *peer, u_int16_t port) { peer->port = port; return 0; } int peer_port_unset (struct peer *peer) { peer->port = BGP_PORT_DEFAULT; return 0; } /* neighbor weight. */ int peer_weight_set (struct peer *peer, u_int16_t weight) { struct peer_group *group; struct listnode *node, *nnode; SET_FLAG (peer->config, PEER_CONFIG_WEIGHT); peer->weight = weight; if (! CHECK_FLAG (peer->sflags, PEER_STATUS_GROUP)) return 0; /* peer-group member updates. */ group = peer->group; for (ALL_LIST_ELEMENTS (group->peer, node, nnode, peer)) { peer->weight = group->conf->weight; } return 0; } int peer_weight_unset (struct peer *peer) { struct peer_group *group; struct listnode *node, *nnode; /* Set default weight. */ if (peer_group_active (peer)) peer->weight = peer->group->conf->weight; else peer->weight = 0; UNSET_FLAG (peer->config, PEER_CONFIG_WEIGHT); if (! CHECK_FLAG (peer->sflags, PEER_STATUS_GROUP)) return 0; /* peer-group member updates. */ group = peer->group; for (ALL_LIST_ELEMENTS (group->peer, node, nnode, peer)) { peer->weight = 0; } return 0; } int peer_timers_set (struct peer *peer, u_int32_t keepalive, u_int32_t holdtime) { struct peer_group *group; struct listnode *node, *nnode; /* Not for peer group memeber. */ if (peer_group_active (peer)) return BGP_ERR_INVALID_FOR_PEER_GROUP_MEMBER; /* keepalive value check. */ if (keepalive > 65535) return BGP_ERR_INVALID_VALUE; /* Holdtime value check. */ if (holdtime > 65535) return BGP_ERR_INVALID_VALUE; /* Holdtime value must be either 0 or greater than 3. */ if (holdtime < 3 && holdtime != 0) return BGP_ERR_INVALID_VALUE; /* Set value to the configuration. */ SET_FLAG (peer->config, PEER_CONFIG_TIMER); peer->holdtime = holdtime; peer->keepalive = (keepalive < holdtime / 3 ? keepalive : holdtime / 3); if (! CHECK_FLAG (peer->sflags, PEER_STATUS_GROUP)) return 0; /* peer-group member updates. */ group = peer->group; for (ALL_LIST_ELEMENTS (group->peer, node, nnode, peer)) { SET_FLAG (peer->config, PEER_CONFIG_TIMER); peer->holdtime = group->conf->holdtime; peer->keepalive = group->conf->keepalive; } return 0; } int peer_timers_unset (struct peer *peer) { struct peer_group *group; struct listnode *node, *nnode; if (peer_group_active (peer)) return BGP_ERR_INVALID_FOR_PEER_GROUP_MEMBER; /* Clear configuration. */ UNSET_FLAG (peer->config, PEER_CONFIG_TIMER); peer->keepalive = 0; peer->holdtime = 0; if (! CHECK_FLAG (peer->sflags, PEER_STATUS_GROUP)) return 0; /* peer-group member updates. */ group = peer->group; for (ALL_LIST_ELEMENTS (group->peer, node, nnode, peer)) { UNSET_FLAG (peer->config, PEER_CONFIG_TIMER); peer->holdtime = 0; peer->keepalive = 0; } return 0; } int peer_timers_connect_set (struct peer *peer, u_int32_t connect) { if (peer_group_active (peer)) return BGP_ERR_INVALID_FOR_PEER_GROUP_MEMBER; if (connect > 65535) return BGP_ERR_INVALID_VALUE; /* Set value to the configuration. */ SET_FLAG (peer->config, PEER_CONFIG_CONNECT); peer->connect = connect; /* Set value to timer setting. */ peer->v_connect = connect; return 0; } int peer_timers_connect_unset (struct peer *peer) { if (peer_group_active (peer)) return BGP_ERR_INVALID_FOR_PEER_GROUP_MEMBER; /* Clear configuration. */ UNSET_FLAG (peer->config, PEER_CONFIG_CONNECT); peer->connect = 0; /* Set timer setting to default value. */ peer->v_connect = BGP_DEFAULT_CONNECT_RETRY; return 0; } int peer_advertise_interval_set (struct peer *peer, u_int32_t routeadv) { if (peer_group_active (peer)) return BGP_ERR_INVALID_FOR_PEER_GROUP_MEMBER; if (routeadv > 600) return BGP_ERR_INVALID_VALUE; SET_FLAG (peer->config, PEER_CONFIG_ROUTEADV); peer->routeadv = routeadv; peer->v_routeadv = routeadv; return 0; } int peer_advertise_interval_unset (struct peer *peer) { if (peer_group_active (peer)) return BGP_ERR_INVALID_FOR_PEER_GROUP_MEMBER; UNSET_FLAG (peer->config, PEER_CONFIG_ROUTEADV); peer->routeadv = 0; if (peer_sort (peer) == BGP_PEER_IBGP) peer->v_routeadv = BGP_DEFAULT_IBGP_ROUTEADV; else peer->v_routeadv = BGP_DEFAULT_EBGP_ROUTEADV; return 0; } /* neighbor interface */ int peer_interface_set (struct peer *peer, const char *str) { if (peer->ifname) free (peer->ifname); peer->ifname = strdup (str); return 0; } int peer_interface_unset (struct peer *peer) { if (peer->ifname) free (peer->ifname); peer->ifname = NULL; return 0; } /* Allow-as in. */ int peer_allowas_in_set (struct peer *peer, afi_t afi, safi_t safi, int allow_num) { struct peer_group *group; struct listnode *node, *nnode; if (allow_num < 1 || allow_num > 10) return BGP_ERR_INVALID_VALUE; if (peer->allowas_in[afi][safi] != allow_num) { peer->allowas_in[afi][safi] = allow_num; SET_FLAG (peer->af_flags[afi][safi], PEER_FLAG_ALLOWAS_IN); peer_change_action (peer, afi, safi, peer_change_reset_in); } if (! CHECK_FLAG (peer->sflags, PEER_STATUS_GROUP)) return 0; group = peer->group; for (ALL_LIST_ELEMENTS (group->peer, node, nnode, peer)) { if (peer->allowas_in[afi][safi] != allow_num) { peer->allowas_in[afi][safi] = allow_num; SET_FLAG (peer->af_flags[afi][safi], PEER_FLAG_ALLOWAS_IN); peer_change_action (peer, afi, safi, peer_change_reset_in); } } return 0; } int peer_allowas_in_unset (struct peer *peer, afi_t afi, safi_t safi) { struct peer_group *group; struct listnode *node, *nnode; if (CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_ALLOWAS_IN)) { peer->allowas_in[afi][safi] = 0; peer_af_flag_unset (peer, afi, safi, PEER_FLAG_ALLOWAS_IN); } if (! CHECK_FLAG (peer->sflags, PEER_STATUS_GROUP)) return 0; group = peer->group; for (ALL_LIST_ELEMENTS (group->peer, node, nnode, peer)) { if (CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_ALLOWAS_IN)) { peer->allowas_in[afi][safi] = 0; peer_af_flag_unset (peer, afi, safi, PEER_FLAG_ALLOWAS_IN); } } return 0; } int peer_local_as_set (struct peer *peer, as_t as, int no_prepend) { struct bgp *bgp = peer->bgp; struct peer_group *group; struct listnode *node, *nnode; if (peer_sort (peer) != BGP_PEER_EBGP && peer_sort (peer) != BGP_PEER_INTERNAL) return BGP_ERR_LOCAL_AS_ALLOWED_ONLY_FOR_EBGP; if (bgp->as == as) return BGP_ERR_CANNOT_HAVE_LOCAL_AS_SAME_AS; if (peer_group_active (peer)) return BGP_ERR_INVALID_FOR_PEER_GROUP_MEMBER; if (peer->change_local_as == as && ((CHECK_FLAG (peer->flags, PEER_FLAG_LOCAL_AS_NO_PREPEND) && no_prepend) || (! CHECK_FLAG (peer->flags, PEER_FLAG_LOCAL_AS_NO_PREPEND) && ! no_prepend))) return 0; peer->change_local_as = as; if (no_prepend) SET_FLAG (peer->flags, PEER_FLAG_LOCAL_AS_NO_PREPEND); else UNSET_FLAG (peer->flags, PEER_FLAG_LOCAL_AS_NO_PREPEND); if (! CHECK_FLAG (peer->sflags, PEER_STATUS_GROUP)) { if (peer->status == Established) { peer->last_reset = PEER_DOWN_LOCAL_AS_CHANGE; bgp_notify_send (peer, BGP_NOTIFY_CEASE, BGP_NOTIFY_CEASE_CONFIG_CHANGE); } else BGP_EVENT_ADD (peer, BGP_Stop); return 0; } group = peer->group; for (ALL_LIST_ELEMENTS (group->peer, node, nnode, peer)) { peer->change_local_as = as; if (no_prepend) SET_FLAG (peer->flags, PEER_FLAG_LOCAL_AS_NO_PREPEND); else UNSET_FLAG (peer->flags, PEER_FLAG_LOCAL_AS_NO_PREPEND); if (peer->status == Established) { peer->last_reset = PEER_DOWN_LOCAL_AS_CHANGE; bgp_notify_send (peer, BGP_NOTIFY_CEASE, BGP_NOTIFY_CEASE_CONFIG_CHANGE); } else BGP_EVENT_ADD (peer, BGP_Stop); } return 0; } int peer_local_as_unset (struct peer *peer) { struct peer_group *group; struct listnode *node, *nnode; if (peer_group_active (peer)) return BGP_ERR_INVALID_FOR_PEER_GROUP_MEMBER; if (! peer->change_local_as) return 0; peer->change_local_as = 0; UNSET_FLAG (peer->flags, PEER_FLAG_LOCAL_AS_NO_PREPEND); if (! CHECK_FLAG (peer->sflags, PEER_STATUS_GROUP)) { if (peer->status == Established) { peer->last_reset = PEER_DOWN_LOCAL_AS_CHANGE; bgp_notify_send (peer, BGP_NOTIFY_CEASE, BGP_NOTIFY_CEASE_CONFIG_CHANGE); } else BGP_EVENT_ADD (peer, BGP_Stop); return 0; } group = peer->group; for (ALL_LIST_ELEMENTS (group->peer, node, nnode, peer)) { peer->change_local_as = 0; UNSET_FLAG (peer->flags, PEER_FLAG_LOCAL_AS_NO_PREPEND); if (peer->status == Established) { peer->last_reset = PEER_DOWN_LOCAL_AS_CHANGE; bgp_notify_send (peer, BGP_NOTIFY_CEASE, BGP_NOTIFY_CEASE_CONFIG_CHANGE); } else BGP_EVENT_ADD (peer, BGP_Stop); } return 0; } /* Set password for authenticating with the peer. */ int peer_password_set (struct peer *peer, const char *password) { struct listnode *nn, *nnode; int len = password ? strlen(password) : 0; int ret = BGP_SUCCESS; if ((len < PEER_PASSWORD_MINLEN) || (len > PEER_PASSWORD_MAXLEN)) return BGP_ERR_INVALID_VALUE; if (peer->password && strcmp (peer->password, password) == 0 && ! CHECK_FLAG (peer->sflags, PEER_STATUS_GROUP)) return 0; if (peer->password) XFREE (MTYPE_PEER_PASSWORD, peer->password); peer->password = XSTRDUP (MTYPE_PEER_PASSWORD, password); if (! CHECK_FLAG (peer->sflags, PEER_STATUS_GROUP)) { if (peer->status == Established) bgp_notify_send (peer, BGP_NOTIFY_CEASE, BGP_NOTIFY_CEASE_CONFIG_CHANGE); else BGP_EVENT_ADD (peer, BGP_Stop); return (bgp_md5_set (peer) >= 0) ? BGP_SUCCESS : BGP_ERR_TCPSIG_FAILED; } for (ALL_LIST_ELEMENTS (peer->group->peer, nn, nnode, peer)) { if (peer->password && strcmp (peer->password, password) == 0) continue; if (peer->password) XFREE (MTYPE_PEER_PASSWORD, peer->password); peer->password = XSTRDUP(MTYPE_PEER_PASSWORD, password); if (peer->status == Established) bgp_notify_send (peer, BGP_NOTIFY_CEASE, BGP_NOTIFY_CEASE_CONFIG_CHANGE); else BGP_EVENT_ADD (peer, BGP_Stop); if (bgp_md5_set (peer) < 0) ret = BGP_ERR_TCPSIG_FAILED; } return ret; } int peer_password_unset (struct peer *peer) { struct listnode *nn, *nnode; if (!peer->password && !CHECK_FLAG (peer->sflags, PEER_STATUS_GROUP)) return 0; if (!CHECK_FLAG (peer->sflags, PEER_STATUS_GROUP)) { if (peer_group_active (peer) && peer->group->conf->password && strcmp (peer->group->conf->password, peer->password) == 0) return BGP_ERR_PEER_GROUP_HAS_THE_FLAG; if (peer->status == Established) bgp_notify_send (peer, BGP_NOTIFY_CEASE, BGP_NOTIFY_CEASE_CONFIG_CHANGE); else BGP_EVENT_ADD (peer, BGP_Stop); if (peer->password) XFREE (MTYPE_PEER_PASSWORD, peer->password); peer->password = NULL; bgp_md5_set (peer); return 0; } XFREE (MTYPE_PEER_PASSWORD, peer->password); peer->password = NULL; for (ALL_LIST_ELEMENTS (peer->group->peer, nn, nnode, peer)) { if (!peer->password) continue; if (peer->status == Established) bgp_notify_send (peer, BGP_NOTIFY_CEASE, BGP_NOTIFY_CEASE_CONFIG_CHANGE); else BGP_EVENT_ADD (peer, BGP_Stop); XFREE (MTYPE_PEER_PASSWORD, peer->password); peer->password = NULL; bgp_md5_set (peer); } return 0; } /* Set distribute list to the peer. */ int peer_distribute_set (struct peer *peer, afi_t afi, safi_t safi, int direct, const char *name) { struct bgp_filter *filter; struct peer_group *group; struct listnode *node, *nnode; if (! peer->afc[afi][safi]) return BGP_ERR_PEER_INACTIVE; if (direct != FILTER_IN && direct != FILTER_OUT) return BGP_ERR_INVALID_VALUE; if (direct == FILTER_OUT && peer_is_group_member (peer, afi, safi)) return BGP_ERR_INVALID_FOR_PEER_GROUP_MEMBER; filter = &peer->filter[afi][safi]; if (filter->plist[direct].name) return BGP_ERR_PEER_FILTER_CONFLICT; if (filter->dlist[direct].name) free (filter->dlist[direct].name); filter->dlist[direct].name = strdup (name); filter->dlist[direct].alist = access_list_lookup (afi, name); if (! CHECK_FLAG (peer->sflags, PEER_STATUS_GROUP)) return 0; group = peer->group; for (ALL_LIST_ELEMENTS (group->peer, node, nnode, peer)) { filter = &peer->filter[afi][safi]; if (! peer->af_group[afi][safi]) continue; if (filter->dlist[direct].name) free (filter->dlist[direct].name); filter->dlist[direct].name = strdup (name); filter->dlist[direct].alist = access_list_lookup (afi, name); } return 0; } int peer_distribute_unset (struct peer *peer, afi_t afi, safi_t safi, int direct) { struct bgp_filter *filter; struct bgp_filter *gfilter; struct peer_group *group; struct listnode *node, *nnode; if (! peer->afc[afi][safi]) return BGP_ERR_PEER_INACTIVE; if (direct != FILTER_IN && direct != FILTER_OUT) return BGP_ERR_INVALID_VALUE; if (direct == FILTER_OUT && peer_is_group_member (peer, afi, safi)) return BGP_ERR_INVALID_FOR_PEER_GROUP_MEMBER; filter = &peer->filter[afi][safi]; /* apply peer-group filter */ if (peer->af_group[afi][safi]) { gfilter = &peer->group->conf->filter[afi][safi]; if (gfilter->dlist[direct].name) { if (filter->dlist[direct].name) free (filter->dlist[direct].name); filter->dlist[direct].name = strdup (gfilter->dlist[direct].name); filter->dlist[direct].alist = gfilter->dlist[direct].alist; return 0; } } if (filter->dlist[direct].name) free (filter->dlist[direct].name); filter->dlist[direct].name = NULL; filter->dlist[direct].alist = NULL; if (! CHECK_FLAG (peer->sflags, PEER_STATUS_GROUP)) return 0; group = peer->group; for (ALL_LIST_ELEMENTS (group->peer, node, nnode, peer)) { filter = &peer->filter[afi][safi]; if (! peer->af_group[afi][safi]) continue; if (filter->dlist[direct].name) free (filter->dlist[direct].name); filter->dlist[direct].name = NULL; filter->dlist[direct].alist = NULL; } return 0; } /* Update distribute list. */ static void peer_distribute_update (struct access_list *access) { afi_t afi; safi_t safi; int direct; struct listnode *mnode, *mnnode; struct listnode *node, *nnode; struct bgp *bgp; struct peer *peer; struct peer_group *group; struct bgp_filter *filter; for (ALL_LIST_ELEMENTS (bm->bgp, mnode, mnnode, bgp)) { for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer)) { for (afi = AFI_IP; afi < AFI_MAX; afi++) for (safi = SAFI_UNICAST; safi < SAFI_MAX; safi++) { filter = &peer->filter[afi][safi]; for (direct = FILTER_IN; direct < FILTER_MAX; direct++) { if (filter->dlist[direct].name) filter->dlist[direct].alist = access_list_lookup (afi, filter->dlist[direct].name); else filter->dlist[direct].alist = NULL; } } } for (ALL_LIST_ELEMENTS (bgp->group, node, nnode, group)) { for (afi = AFI_IP; afi < AFI_MAX; afi++) for (safi = SAFI_UNICAST; safi < SAFI_MAX; safi++) { filter = &group->conf->filter[afi][safi]; for (direct = FILTER_IN; direct < FILTER_MAX; direct++) { if (filter->dlist[direct].name) filter->dlist[direct].alist = access_list_lookup (afi, filter->dlist[direct].name); else filter->dlist[direct].alist = NULL; } } } } } /* Set prefix list to the peer. */ int peer_prefix_list_set (struct peer *peer, afi_t afi, safi_t safi, int direct, const char *name) { struct bgp_filter *filter; struct peer_group *group; struct listnode *node, *nnode; if (! peer->afc[afi][safi]) return BGP_ERR_PEER_INACTIVE; if (direct != FILTER_IN && direct != FILTER_OUT) return BGP_ERR_INVALID_VALUE; if (direct == FILTER_OUT && peer_is_group_member (peer, afi, safi)) return BGP_ERR_INVALID_FOR_PEER_GROUP_MEMBER; filter = &peer->filter[afi][safi]; if (filter->dlist[direct].name) return BGP_ERR_PEER_FILTER_CONFLICT; if (filter->plist[direct].name) free (filter->plist[direct].name); filter->plist[direct].name = strdup (name); filter->plist[direct].plist = prefix_list_lookup (afi, name); if (! CHECK_FLAG (peer->sflags, PEER_STATUS_GROUP)) return 0; group = peer->group; for (ALL_LIST_ELEMENTS (group->peer, node, nnode, peer)) { filter = &peer->filter[afi][safi]; if (! peer->af_group[afi][safi]) continue; if (filter->plist[direct].name) free (filter->plist[direct].name); filter->plist[direct].name = strdup (name); filter->plist[direct].plist = prefix_list_lookup (afi, name); } return 0; } int peer_prefix_list_unset (struct peer *peer, afi_t afi, safi_t safi, int direct) { struct bgp_filter *filter; struct bgp_filter *gfilter; struct peer_group *group; struct listnode *node, *nnode; if (! peer->afc[afi][safi]) return BGP_ERR_PEER_INACTIVE; if (direct != FILTER_IN && direct != FILTER_OUT) return BGP_ERR_INVALID_VALUE; if (direct == FILTER_OUT && peer_is_group_member (peer, afi, safi)) return BGP_ERR_INVALID_FOR_PEER_GROUP_MEMBER; filter = &peer->filter[afi][safi]; /* apply peer-group filter */ if (peer->af_group[afi][safi]) { gfilter = &peer->group->conf->filter[afi][safi]; if (gfilter->plist[direct].name) { if (filter->plist[direct].name) free (filter->plist[direct].name); filter->plist[direct].name = strdup (gfilter->plist[direct].name); filter->plist[direct].plist = gfilter->plist[direct].plist; return 0; } } if (filter->plist[direct].name) free (filter->plist[direct].name); filter->plist[direct].name = NULL; filter->plist[direct].plist = NULL; if (! CHECK_FLAG (peer->sflags, PEER_STATUS_GROUP)) return 0; group = peer->group; for (ALL_LIST_ELEMENTS (group->peer, node, nnode, peer)) { filter = &peer->filter[afi][safi]; if (! peer->af_group[afi][safi]) continue; if (filter->plist[direct].name) free (filter->plist[direct].name); filter->plist[direct].name = NULL; filter->plist[direct].plist = NULL; } return 0; } /* Update prefix-list list. */ static void peer_prefix_list_update (struct prefix_list *plist) { struct listnode *mnode, *mnnode; struct listnode *node, *nnode; struct bgp *bgp; struct peer *peer; struct peer_group *group; struct bgp_filter *filter; afi_t afi; safi_t safi; int direct; for (ALL_LIST_ELEMENTS (bm->bgp, mnode, mnnode, bgp)) { for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer)) { for (afi = AFI_IP; afi < AFI_MAX; afi++) for (safi = SAFI_UNICAST; safi < SAFI_MAX; safi++) { filter = &peer->filter[afi][safi]; for (direct = FILTER_IN; direct < FILTER_MAX; direct++) { if (filter->plist[direct].name) filter->plist[direct].plist = prefix_list_lookup (afi, filter->plist[direct].name); else filter->plist[direct].plist = NULL; } } } for (ALL_LIST_ELEMENTS (bgp->group, node, nnode, group)) { for (afi = AFI_IP; afi < AFI_MAX; afi++) for (safi = SAFI_UNICAST; safi < SAFI_MAX; safi++) { filter = &group->conf->filter[afi][safi]; for (direct = FILTER_IN; direct < FILTER_MAX; direct++) { if (filter->plist[direct].name) filter->plist[direct].plist = prefix_list_lookup (afi, filter->plist[direct].name); else filter->plist[direct].plist = NULL; } } } } } int peer_aslist_set (struct peer *peer, afi_t afi, safi_t safi, int direct, const char *name) { struct bgp_filter *filter; struct peer_group *group; struct listnode *node, *nnode; if (! peer->afc[afi][safi]) return BGP_ERR_PEER_INACTIVE; if (direct != FILTER_IN && direct != FILTER_OUT) return BGP_ERR_INVALID_VALUE; if (direct == FILTER_OUT && peer_is_group_member (peer, afi, safi)) return BGP_ERR_INVALID_FOR_PEER_GROUP_MEMBER; filter = &peer->filter[afi][safi]; if (filter->aslist[direct].name) free (filter->aslist[direct].name); filter->aslist[direct].name = strdup (name); filter->aslist[direct].aslist = as_list_lookup (name); if (! CHECK_FLAG (peer->sflags, PEER_STATUS_GROUP)) return 0; group = peer->group; for (ALL_LIST_ELEMENTS (group->peer, node, nnode, peer)) { filter = &peer->filter[afi][safi]; if (! peer->af_group[afi][safi]) continue; if (filter->aslist[direct].name) free (filter->aslist[direct].name); filter->aslist[direct].name = strdup (name); filter->aslist[direct].aslist = as_list_lookup (name); } return 0; } int peer_aslist_unset (struct peer *peer,afi_t afi, safi_t safi, int direct) { struct bgp_filter *filter; struct bgp_filter *gfilter; struct peer_group *group; struct listnode *node, *nnode; if (! peer->afc[afi][safi]) return BGP_ERR_PEER_INACTIVE; if (direct != FILTER_IN && direct != FILTER_OUT) return BGP_ERR_INVALID_VALUE; if (direct == FILTER_OUT && peer_is_group_member (peer, afi, safi)) return BGP_ERR_INVALID_FOR_PEER_GROUP_MEMBER; filter = &peer->filter[afi][safi]; /* apply peer-group filter */ if (peer->af_group[afi][safi]) { gfilter = &peer->group->conf->filter[afi][safi]; if (gfilter->aslist[direct].name) { if (filter->aslist[direct].name) free (filter->aslist[direct].name); filter->aslist[direct].name = strdup (gfilter->aslist[direct].name); filter->aslist[direct].aslist = gfilter->aslist[direct].aslist; return 0; } } if (filter->aslist[direct].name) free (filter->aslist[direct].name); filter->aslist[direct].name = NULL; filter->aslist[direct].aslist = NULL; if (! CHECK_FLAG (peer->sflags, PEER_STATUS_GROUP)) return 0; group = peer->group; for (ALL_LIST_ELEMENTS (group->peer, node, nnode, peer)) { filter = &peer->filter[afi][safi]; if (! peer->af_group[afi][safi]) continue; if (filter->aslist[direct].name) free (filter->aslist[direct].name); filter->aslist[direct].name = NULL; filter->aslist[direct].aslist = NULL; } return 0; } static void peer_aslist_update (void) { afi_t afi; safi_t safi; int direct; struct listnode *mnode, *mnnode; struct listnode *node, *nnode; struct bgp *bgp; struct peer *peer; struct peer_group *group; struct bgp_filter *filter; for (ALL_LIST_ELEMENTS (bm->bgp, mnode, mnnode, bgp)) { for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer)) { for (afi = AFI_IP; afi < AFI_MAX; afi++) for (safi = SAFI_UNICAST; safi < SAFI_MAX; safi++) { filter = &peer->filter[afi][safi]; for (direct = FILTER_IN; direct < FILTER_MAX; direct++) { if (filter->aslist[direct].name) filter->aslist[direct].aslist = as_list_lookup (filter->aslist[direct].name); else filter->aslist[direct].aslist = NULL; } } } for (ALL_LIST_ELEMENTS (bgp->group, node, nnode, group)) { for (afi = AFI_IP; afi < AFI_MAX; afi++) for (safi = SAFI_UNICAST; safi < SAFI_MAX; safi++) { filter = &group->conf->filter[afi][safi]; for (direct = FILTER_IN; direct < FILTER_MAX; direct++) { if (filter->aslist[direct].name) filter->aslist[direct].aslist = as_list_lookup (filter->aslist[direct].name); else filter->aslist[direct].aslist = NULL; } } } } } /* Set route-map to the peer. */ int peer_route_map_set (struct peer *peer, afi_t afi, safi_t safi, int direct, const char *name) { struct bgp_filter *filter; struct peer_group *group; struct listnode *node, *nnode; if (! peer->afc[afi][safi]) return BGP_ERR_PEER_INACTIVE; if (direct != RMAP_IN && direct != RMAP_OUT && direct != RMAP_IMPORT && direct != RMAP_EXPORT) return BGP_ERR_INVALID_VALUE; if ( (direct == RMAP_OUT || direct == RMAP_IMPORT) && peer_is_group_member (peer, afi, safi)) return BGP_ERR_INVALID_FOR_PEER_GROUP_MEMBER; filter = &peer->filter[afi][safi]; if (filter->map[direct].name) free (filter->map[direct].name); filter->map[direct].name = strdup (name); filter->map[direct].map = route_map_lookup_by_name (name); if (! CHECK_FLAG (peer->sflags, PEER_STATUS_GROUP)) return 0; group = peer->group; for (ALL_LIST_ELEMENTS (group->peer, node, nnode, peer)) { filter = &peer->filter[afi][safi]; if (! peer->af_group[afi][safi]) continue; if (filter->map[direct].name) free (filter->map[direct].name); filter->map[direct].name = strdup (name); filter->map[direct].map = route_map_lookup_by_name (name); } return 0; } /* Unset route-map from the peer. */ int peer_route_map_unset (struct peer *peer, afi_t afi, safi_t safi, int direct) { struct bgp_filter *filter; struct bgp_filter *gfilter; struct peer_group *group; struct listnode *node, *nnode; if (! peer->afc[afi][safi]) return BGP_ERR_PEER_INACTIVE; if (direct != RMAP_IN && direct != RMAP_OUT && direct != RMAP_IMPORT && direct != RMAP_EXPORT) return BGP_ERR_INVALID_VALUE; if ( (direct == RMAP_OUT || direct == RMAP_IMPORT) && peer_is_group_member (peer, afi, safi)) return BGP_ERR_INVALID_FOR_PEER_GROUP_MEMBER; filter = &peer->filter[afi][safi]; /* apply peer-group filter */ if (peer->af_group[afi][safi]) { gfilter = &peer->group->conf->filter[afi][safi]; if (gfilter->map[direct].name) { if (filter->map[direct].name) free (filter->map[direct].name); filter->map[direct].name = strdup (gfilter->map[direct].name); filter->map[direct].map = gfilter->map[direct].map; return 0; } } if (filter->map[direct].name) free (filter->map[direct].name); filter->map[direct].name = NULL; filter->map[direct].map = NULL; if (! CHECK_FLAG (peer->sflags, PEER_STATUS_GROUP)) return 0; group = peer->group; for (ALL_LIST_ELEMENTS (group->peer, node, nnode, peer)) { filter = &peer->filter[afi][safi]; if (! peer->af_group[afi][safi]) continue; if (filter->map[direct].name) free (filter->map[direct].name); filter->map[direct].name = NULL; filter->map[direct].map = NULL; } return 0; } /* Set unsuppress-map to the peer. */ int peer_unsuppress_map_set (struct peer *peer, afi_t afi, safi_t safi, const char *name) { struct bgp_filter *filter; struct peer_group *group; struct listnode *node, *nnode; if (! peer->afc[afi][safi]) return BGP_ERR_PEER_INACTIVE; if (peer_is_group_member (peer, afi, safi)) return BGP_ERR_INVALID_FOR_PEER_GROUP_MEMBER; filter = &peer->filter[afi][safi]; if (filter->usmap.name) free (filter->usmap.name); filter->usmap.name = strdup (name); filter->usmap.map = route_map_lookup_by_name (name); if (! CHECK_FLAG (peer->sflags, PEER_STATUS_GROUP)) return 0; group = peer->group; for (ALL_LIST_ELEMENTS (group->peer, node, nnode, peer)) { filter = &peer->filter[afi][safi]; if (! peer->af_group[afi][safi]) continue; if (filter->usmap.name) free (filter->usmap.name); filter->usmap.name = strdup (name); filter->usmap.map = route_map_lookup_by_name (name); } return 0; } /* Unset route-map from the peer. */ int peer_unsuppress_map_unset (struct peer *peer, afi_t afi, safi_t safi) { struct bgp_filter *filter; struct peer_group *group; struct listnode *node, *nnode; if (! peer->afc[afi][safi]) return BGP_ERR_PEER_INACTIVE; if (peer_is_group_member (peer, afi, safi)) return BGP_ERR_INVALID_FOR_PEER_GROUP_MEMBER; filter = &peer->filter[afi][safi]; if (filter->usmap.name) free (filter->usmap.name); filter->usmap.name = NULL; filter->usmap.map = NULL; if (! CHECK_FLAG (peer->sflags, PEER_STATUS_GROUP)) return 0; group = peer->group; for (ALL_LIST_ELEMENTS (group->peer, node, nnode, peer)) { filter = &peer->filter[afi][safi]; if (! peer->af_group[afi][safi]) continue; if (filter->usmap.name) free (filter->usmap.name); filter->usmap.name = NULL; filter->usmap.map = NULL; } return 0; } int peer_maximum_prefix_set (struct peer *peer, afi_t afi, safi_t safi, u_int32_t max, u_char threshold, int warning, u_int16_t restart) { struct peer_group *group; struct listnode *node, *nnode; if (! peer->afc[afi][safi]) return BGP_ERR_PEER_INACTIVE; SET_FLAG (peer->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX); peer->pmax[afi][safi] = max; peer->pmax_threshold[afi][safi] = threshold; peer->pmax_restart[afi][safi] = restart; if (warning) SET_FLAG (peer->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX_WARNING); else UNSET_FLAG (peer->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX_WARNING); if (! CHECK_FLAG (peer->sflags, PEER_STATUS_GROUP)) return 0; group = peer->group; for (ALL_LIST_ELEMENTS (group->peer, node, nnode, peer)) { if (! peer->af_group[afi][safi]) continue; SET_FLAG (peer->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX); peer->pmax[afi][safi] = max; peer->pmax_threshold[afi][safi] = threshold; peer->pmax_restart[afi][safi] = restart; if (warning) SET_FLAG (peer->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX_WARNING); else UNSET_FLAG (peer->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX_WARNING); } return 0; } int peer_maximum_prefix_unset (struct peer *peer, afi_t afi, safi_t safi) { struct peer_group *group; struct listnode *node, *nnode; if (! peer->afc[afi][safi]) return BGP_ERR_PEER_INACTIVE; /* apply peer-group config */ if (peer->af_group[afi][safi]) { if (CHECK_FLAG (peer->group->conf->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX)) SET_FLAG (peer->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX); else UNSET_FLAG (peer->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX); if (CHECK_FLAG (peer->group->conf->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX_WARNING)) SET_FLAG (peer->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX_WARNING); else UNSET_FLAG (peer->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX_WARNING); peer->pmax[afi][safi] = peer->group->conf->pmax[afi][safi]; peer->pmax_threshold[afi][safi] = peer->group->conf->pmax_threshold[afi][safi]; peer->pmax_restart[afi][safi] = peer->group->conf->pmax_restart[afi][safi]; return 0; } UNSET_FLAG (peer->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX); UNSET_FLAG (peer->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX_WARNING); peer->pmax[afi][safi] = 0; peer->pmax_threshold[afi][safi] = 0; peer->pmax_restart[afi][safi] = 0; if (! CHECK_FLAG (peer->sflags, PEER_STATUS_GROUP)) return 0; group = peer->group; for (ALL_LIST_ELEMENTS (group->peer, node, nnode, peer)) { if (! peer->af_group[afi][safi]) continue; UNSET_FLAG (peer->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX); UNSET_FLAG (peer->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX_WARNING); peer->pmax[afi][safi] = 0; peer->pmax_threshold[afi][safi] = 0; peer->pmax_restart[afi][safi] = 0; } return 0; } /* Set # of hops between us and BGP peer. */ int peer_ttl_security_hops_set (struct peer *peer, int gtsm_hops) { struct peer_group *group; struct listnode *node, *nnode; struct peer *peer1; int ret; zlog_debug ("peer_ttl_security_hops_set: set gtsm_hops to %d for %s", gtsm_hops, peer->host); if (peer_sort (peer) == BGP_PEER_IBGP) return BGP_ERR_NO_IBGP_WITH_TTLHACK; /* We cannot configure ttl-security hops when ebgp-multihop is already set. For non peer-groups, the check is simple. For peer-groups, it's slightly messy, because we need to check both the peer-group structure and all peer-group members for any trace of ebgp-multihop configuration before actually applying the ttl-security rules. Cisco really made a mess of this configuration parameter, and OpenBGPD got it right. */ if (peer->gtsm_hops == 0) { if (CHECK_FLAG (peer->sflags, PEER_STATUS_GROUP)) { group = peer->group; if (group->conf->ttl != 1) return BGP_ERR_NO_EBGP_MULTIHOP_WITH_TTLHACK; for (ALL_LIST_ELEMENTS (group->peer, node, nnode, peer1)) { if (peer_sort (peer1) == BGP_PEER_IBGP) continue; if (peer1->ttl != 1) return BGP_ERR_NO_EBGP_MULTIHOP_WITH_TTLHACK; } } else { if (peer->ttl != 1) return BGP_ERR_NO_EBGP_MULTIHOP_WITH_TTLHACK; } /* specify MAXTTL on outgoing packets */ ret = peer_ebgp_multihop_set (peer, MAXTTL); if (ret != 0) return ret; } peer->gtsm_hops = gtsm_hops; if (! CHECK_FLAG (peer->sflags, PEER_STATUS_GROUP)) { if (peer->fd >= 0 && peer_sort (peer) != BGP_PEER_IBGP) sockopt_minttl (peer->su.sa.sa_family, peer->fd, MAXTTL + 1 - gtsm_hops); } else { group = peer->group; for (ALL_LIST_ELEMENTS (group->peer, node, nnode, peer)) { if (peer_sort (peer) == BGP_PEER_IBGP) continue; peer->gtsm_hops = group->conf->gtsm_hops; /* Change setting of existing peer * established then change value (may break connectivity) * not established yet (teardown session and restart) * no session then do nothing (will get handled by next connection) */ if (peer->status == Established) { if (peer->fd >= 0 && peer->gtsm_hops != 0) sockopt_minttl (peer->su.sa.sa_family, peer->fd, MAXTTL + 1 - peer->gtsm_hops); } else if (peer->status < Established) { if (BGP_DEBUG (events, EVENTS)) zlog_debug ("%s Min-ttl changed", peer->host); BGP_EVENT_ADD (peer, BGP_Stop); } } } return 0; } int peer_ttl_security_hops_unset (struct peer *peer) { struct peer_group *group; struct listnode *node, *nnode; struct peer *opeer; zlog_debug ("peer_ttl_security_hops_unset: set gtsm_hops to zero for %s", peer->host); if (peer_sort (peer) == BGP_PEER_IBGP) return 0; /* if a peer-group member, then reset to peer-group default rather than 0 */ if (peer_group_active (peer)) peer->gtsm_hops = peer->group->conf->gtsm_hops; else peer->gtsm_hops = 0; opeer = peer; if (! CHECK_FLAG (peer->sflags, PEER_STATUS_GROUP)) { if (peer->fd >= 0 && peer_sort (peer) != BGP_PEER_IBGP) sockopt_minttl (peer->su.sa.sa_family, peer->fd, 0); } else { group = peer->group; for (ALL_LIST_ELEMENTS (group->peer, node, nnode, peer)) { if (peer_sort (peer) == BGP_PEER_IBGP) continue; peer->gtsm_hops = 0; if (peer->fd >= 0) sockopt_minttl (peer->su.sa.sa_family, peer->fd, 0); } } return peer_ebgp_multihop_unset (opeer); } int peer_clear (struct peer *peer) { if (! CHECK_FLAG (peer->flags, PEER_FLAG_SHUTDOWN)) { if (CHECK_FLAG (peer->sflags, PEER_STATUS_PREFIX_OVERFLOW)) { UNSET_FLAG (peer->sflags, PEER_STATUS_PREFIX_OVERFLOW); if (peer->t_pmax_restart) { BGP_TIMER_OFF (peer->t_pmax_restart); if (BGP_DEBUG (events, EVENTS)) zlog_debug ("%s Maximum-prefix restart timer canceled", peer->host); } BGP_EVENT_ADD (peer, BGP_Start); return 0; } peer->v_start = BGP_INIT_START_TIMER; if (peer->status == Established) bgp_notify_send (peer, BGP_NOTIFY_CEASE, BGP_NOTIFY_CEASE_ADMIN_RESET); else BGP_EVENT_ADD (peer, BGP_Stop); } return 0; } int peer_clear_soft (struct peer *peer, afi_t afi, safi_t safi, enum bgp_clear_type stype) { if (peer->status != Established) return 0; if (! peer->afc[afi][safi]) return BGP_ERR_AF_UNCONFIGURED; if (stype == BGP_CLEAR_SOFT_RSCLIENT) { if (! CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT)) return 0; bgp_check_local_routes_rsclient (peer, afi, safi); bgp_soft_reconfig_rsclient (peer, afi, safi); } if (stype == BGP_CLEAR_SOFT_OUT || stype == BGP_CLEAR_SOFT_BOTH) bgp_announce_route (peer, afi, safi); if (stype == BGP_CLEAR_SOFT_IN_ORF_PREFIX) { if (CHECK_FLAG (peer->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV) && (CHECK_FLAG (peer->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_RCV) || CHECK_FLAG (peer->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_OLD_RCV))) { struct bgp_filter *filter = &peer->filter[afi][safi]; u_char prefix_type; if (CHECK_FLAG (peer->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_RCV)) prefix_type = ORF_TYPE_PREFIX; else prefix_type = ORF_TYPE_PREFIX_OLD; if (filter->plist[FILTER_IN].plist) { if (CHECK_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_ORF_PREFIX_SEND)) bgp_route_refresh_send (peer, afi, safi, prefix_type, REFRESH_DEFER, 1); bgp_route_refresh_send (peer, afi, safi, prefix_type, REFRESH_IMMEDIATE, 0); } else { if (CHECK_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_ORF_PREFIX_SEND)) bgp_route_refresh_send (peer, afi, safi, prefix_type, REFRESH_IMMEDIATE, 1); else bgp_route_refresh_send (peer, afi, safi, 0, 0, 0); } return 0; } } if (stype == BGP_CLEAR_SOFT_IN || stype == BGP_CLEAR_SOFT_BOTH || stype == BGP_CLEAR_SOFT_IN_ORF_PREFIX) { /* If neighbor has soft reconfiguration inbound flag. Use Adj-RIB-In database. */ if (CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_SOFT_RECONFIG)) bgp_soft_reconfig_in (peer, afi, safi); else { /* If neighbor has route refresh capability, send route refresh message to the peer. */ if (CHECK_FLAG (peer->cap, PEER_CAP_REFRESH_OLD_RCV) || CHECK_FLAG (peer->cap, PEER_CAP_REFRESH_NEW_RCV)) bgp_route_refresh_send (peer, afi, safi, 0, 0, 0); else return BGP_ERR_SOFT_RECONFIG_UNCONFIGURED; } } return 0; } /* Display peer uptime.*/ /* XXX: why does this function return char * when it takes buffer? */ char * peer_uptime (time_t uptime2, char *buf, size_t len) { time_t uptime1; struct tm *tm; /* Check buffer length. */ if (len < BGP_UPTIME_LEN) { zlog_warn ("peer_uptime (): buffer shortage %lu", (u_long)len); /* XXX: should return status instead of buf... */ snprintf (buf, len, "<error> "); return buf; } /* If there is no connection has been done before print `never'. */ if (uptime2 == 0) { snprintf (buf, len, "never "); return buf; } /* Get current time. */ uptime1 = bgp_clock (); uptime1 -= uptime2; tm = gmtime (&uptime1); /* Making formatted timer strings. */ #define ONE_DAY_SECOND 60*60*24 #define ONE_WEEK_SECOND 60*60*24*7 if (uptime1 < ONE_DAY_SECOND) snprintf (buf, len, "%02d:%02d:%02d", tm->tm_hour, tm->tm_min, tm->tm_sec); else if (uptime1 < ONE_WEEK_SECOND) snprintf (buf, len, "%dd%02dh%02dm", tm->tm_yday, tm->tm_hour, tm->tm_min); else snprintf (buf, len, "%02dw%dd%02dh", tm->tm_yday/7, tm->tm_yday - ((tm->tm_yday/7) * 7), tm->tm_hour); return buf; } static void bgp_config_write_filter (struct vty *vty, struct peer *peer, afi_t afi, safi_t safi) { struct bgp_filter *filter; struct bgp_filter *gfilter = NULL; char *addr; int in = FILTER_IN; int out = FILTER_OUT; addr = peer->host; filter = &peer->filter[afi][safi]; if (peer->af_group[afi][safi]) gfilter = &peer->group->conf->filter[afi][safi]; /* distribute-list. */ if (filter->dlist[in].name) if (! gfilter || ! gfilter->dlist[in].name || strcmp (filter->dlist[in].name, gfilter->dlist[in].name) != 0) vty_out (vty, " neighbor %s distribute-list %s in%s", addr, filter->dlist[in].name, VTY_NEWLINE); if (filter->dlist[out].name && ! gfilter) vty_out (vty, " neighbor %s distribute-list %s out%s", addr, filter->dlist[out].name, VTY_NEWLINE); /* prefix-list. */ if (filter->plist[in].name) if (! gfilter || ! gfilter->plist[in].name || strcmp (filter->plist[in].name, gfilter->plist[in].name) != 0) vty_out (vty, " neighbor %s prefix-list %s in%s", addr, filter->plist[in].name, VTY_NEWLINE); if (filter->plist[out].name && ! gfilter) vty_out (vty, " neighbor %s prefix-list %s out%s", addr, filter->plist[out].name, VTY_NEWLINE); /* route-map. */ if (filter->map[RMAP_IN].name) if (! gfilter || ! gfilter->map[RMAP_IN].name || strcmp (filter->map[RMAP_IN].name, gfilter->map[RMAP_IN].name) != 0) vty_out (vty, " neighbor %s route-map %s in%s", addr, filter->map[RMAP_IN].name, VTY_NEWLINE); if (filter->map[RMAP_OUT].name && ! gfilter) vty_out (vty, " neighbor %s route-map %s out%s", addr, filter->map[RMAP_OUT].name, VTY_NEWLINE); if (filter->map[RMAP_IMPORT].name && ! gfilter) vty_out (vty, " neighbor %s route-map %s import%s", addr, filter->map[RMAP_IMPORT].name, VTY_NEWLINE); if (filter->map[RMAP_EXPORT].name) if (! gfilter || ! gfilter->map[RMAP_EXPORT].name || strcmp (filter->map[RMAP_EXPORT].name, gfilter->map[RMAP_EXPORT].name) != 0) vty_out (vty, " neighbor %s route-map %s export%s", addr, filter->map[RMAP_EXPORT].name, VTY_NEWLINE); /* unsuppress-map */ if (filter->usmap.name && ! gfilter) vty_out (vty, " neighbor %s unsuppress-map %s%s", addr, filter->usmap.name, VTY_NEWLINE); /* filter-list. */ if (filter->aslist[in].name) if (! gfilter || ! gfilter->aslist[in].name || strcmp (filter->aslist[in].name, gfilter->aslist[in].name) != 0) vty_out (vty, " neighbor %s filter-list %s in%s", addr, filter->aslist[in].name, VTY_NEWLINE); if (filter->aslist[out].name && ! gfilter) vty_out (vty, " neighbor %s filter-list %s out%s", addr, filter->aslist[out].name, VTY_NEWLINE); } /* BGP peer configuration display function. */ static void bgp_config_write_peer (struct vty *vty, struct bgp *bgp, struct peer *peer, afi_t afi, safi_t safi) { struct peer *g_peer = NULL; char buf[SU_ADDRSTRLEN]; char *addr; addr = peer->host; if (peer_group_active (peer)) g_peer = peer->group->conf; /************************************ ****** Global to the neighbor ****** ************************************/ if (afi == AFI_IP && safi == SAFI_UNICAST) { /* remote-as. */ if (! peer_group_active (peer)) { if (CHECK_FLAG (peer->sflags, PEER_STATUS_GROUP)) vty_out (vty, " neighbor %s peer-group%s", addr, VTY_NEWLINE); if (peer->as) vty_out (vty, " neighbor %s remote-as %u%s", addr, peer->as, VTY_NEWLINE); } else { if (! g_peer->as) vty_out (vty, " neighbor %s remote-as %u%s", addr, peer->as, VTY_NEWLINE); if (peer->af_group[AFI_IP][SAFI_UNICAST]) vty_out (vty, " neighbor %s peer-group %s%s", addr, peer->group->name, VTY_NEWLINE); } /* local-as. */ if (peer->change_local_as) if (! peer_group_active (peer)) vty_out (vty, " neighbor %s local-as %u%s%s", addr, peer->change_local_as, CHECK_FLAG (peer->flags, PEER_FLAG_LOCAL_AS_NO_PREPEND) ? " no-prepend" : "", VTY_NEWLINE); /* Description. */ if (peer->desc) vty_out (vty, " neighbor %s description %s%s", addr, peer->desc, VTY_NEWLINE); /* Shutdown. */ if (CHECK_FLAG (peer->flags, PEER_FLAG_SHUTDOWN)) if (! peer_group_active (peer) || ! CHECK_FLAG (g_peer->flags, PEER_FLAG_SHUTDOWN)) vty_out (vty, " neighbor %s shutdown%s", addr, VTY_NEWLINE); /* Password. */ if (peer->password) if (!peer_group_active (peer) || ! g_peer->password || strcmp (peer->password, g_peer->password) != 0) vty_out (vty, " neighbor %s password %s%s", addr, peer->password, VTY_NEWLINE); /* BGP port. */ if (peer->port != BGP_PORT_DEFAULT) vty_out (vty, " neighbor %s port %d%s", addr, peer->port, VTY_NEWLINE); /* Local interface name. */ if (peer->ifname) vty_out (vty, " neighbor %s interface %s%s", addr, peer->ifname, VTY_NEWLINE); /* Passive. */ if (CHECK_FLAG (peer->flags, PEER_FLAG_PASSIVE)) if (! peer_group_active (peer) || ! CHECK_FLAG (g_peer->flags, PEER_FLAG_PASSIVE)) vty_out (vty, " neighbor %s passive%s", addr, VTY_NEWLINE); /* EBGP multihop. */ if (peer_sort (peer) != BGP_PEER_IBGP && peer->ttl != 1 && !(peer->gtsm_hops != 0 && peer->ttl == MAXTTL)) if (! peer_group_active (peer) || g_peer->ttl != peer->ttl) vty_out (vty, " neighbor %s ebgp-multihop %d%s", addr, peer->ttl, VTY_NEWLINE); /* ttl-security hops */ if (peer_sort (peer) != BGP_PEER_IBGP && peer->gtsm_hops != 0) if (! peer_group_active (peer) || g_peer->gtsm_hops != peer->gtsm_hops) vty_out (vty, " neighbor %s ttl-security hops %d%s", addr, peer->gtsm_hops, VTY_NEWLINE); /* disable-connected-check. */ if (CHECK_FLAG (peer->flags, PEER_FLAG_DISABLE_CONNECTED_CHECK)) if (! peer_group_active (peer) || ! CHECK_FLAG (g_peer->flags, PEER_FLAG_DISABLE_CONNECTED_CHECK)) vty_out (vty, " neighbor %s disable-connected-check%s", addr, VTY_NEWLINE); /* Update-source. */ if (peer->update_if) if (! peer_group_active (peer) || ! g_peer->update_if || strcmp (g_peer->update_if, peer->update_if) != 0) vty_out (vty, " neighbor %s update-source %s%s", addr, peer->update_if, VTY_NEWLINE); if (peer->update_source) if (! peer_group_active (peer) || ! g_peer->update_source || sockunion_cmp (g_peer->update_source, peer->update_source) != 0) vty_out (vty, " neighbor %s update-source %s%s", addr, sockunion2str (peer->update_source, buf, SU_ADDRSTRLEN), VTY_NEWLINE); /* advertisement-interval */ if (CHECK_FLAG (peer->config, PEER_CONFIG_ROUTEADV)) vty_out (vty, " neighbor %s advertisement-interval %d%s", addr, peer->v_routeadv, VTY_NEWLINE); /* timers. */ if (CHECK_FLAG (peer->config, PEER_CONFIG_TIMER) && ! peer_group_active (peer)) vty_out (vty, " neighbor %s timers %d %d%s", addr, peer->keepalive, peer->holdtime, VTY_NEWLINE); if (CHECK_FLAG (peer->config, PEER_CONFIG_CONNECT)) vty_out (vty, " neighbor %s timers connect %d%s", addr, peer->connect, VTY_NEWLINE); /* Default weight. */ if (CHECK_FLAG (peer->config, PEER_CONFIG_WEIGHT)) if (! peer_group_active (peer) || g_peer->weight != peer->weight) vty_out (vty, " neighbor %s weight %d%s", addr, peer->weight, VTY_NEWLINE); /* Dynamic capability. */ if (CHECK_FLAG (peer->flags, PEER_FLAG_DYNAMIC_CAPABILITY)) if (! peer_group_active (peer) || ! CHECK_FLAG (g_peer->flags, PEER_FLAG_DYNAMIC_CAPABILITY)) vty_out (vty, " neighbor %s capability dynamic%s", addr, VTY_NEWLINE); /* dont capability negotiation. */ if (CHECK_FLAG (peer->flags, PEER_FLAG_DONT_CAPABILITY)) if (! peer_group_active (peer) || ! CHECK_FLAG (g_peer->flags, PEER_FLAG_DONT_CAPABILITY)) vty_out (vty, " neighbor %s dont-capability-negotiate%s", addr, VTY_NEWLINE); /* override capability negotiation. */ if (CHECK_FLAG (peer->flags, PEER_FLAG_OVERRIDE_CAPABILITY)) if (! peer_group_active (peer) || ! CHECK_FLAG (g_peer->flags, PEER_FLAG_OVERRIDE_CAPABILITY)) vty_out (vty, " neighbor %s override-capability%s", addr, VTY_NEWLINE); /* strict capability negotiation. */ if (CHECK_FLAG (peer->flags, PEER_FLAG_STRICT_CAP_MATCH)) if (! peer_group_active (peer) || ! CHECK_FLAG (g_peer->flags, PEER_FLAG_STRICT_CAP_MATCH)) vty_out (vty, " neighbor %s strict-capability-match%s", addr, VTY_NEWLINE); if (! peer_group_active (peer)) { if (bgp_flag_check (bgp, BGP_FLAG_NO_DEFAULT_IPV4)) { if (peer->afc[AFI_IP][SAFI_UNICAST]) vty_out (vty, " neighbor %s activate%s", addr, VTY_NEWLINE); } else { if (! peer->afc[AFI_IP][SAFI_UNICAST]) vty_out (vty, " no neighbor %s activate%s", addr, VTY_NEWLINE); } } } /************************************ ****** Per AF to the neighbor ****** ************************************/ if (! (afi == AFI_IP && safi == SAFI_UNICAST)) { if (peer->af_group[afi][safi]) vty_out (vty, " neighbor %s peer-group %s%s", addr, peer->group->name, VTY_NEWLINE); else vty_out (vty, " neighbor %s activate%s", addr, VTY_NEWLINE); } /* ORF capability. */ if (CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_ORF_PREFIX_SM) || CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_ORF_PREFIX_RM)) if (! peer->af_group[afi][safi]) { vty_out (vty, " neighbor %s capability orf prefix-list", addr); if (CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_ORF_PREFIX_SM) && CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_ORF_PREFIX_RM)) vty_out (vty, " both"); else if (CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_ORF_PREFIX_SM)) vty_out (vty, " send"); else vty_out (vty, " receive"); vty_out (vty, "%s", VTY_NEWLINE); } /* Route reflector client. */ if (peer_af_flag_check (peer, afi, safi, PEER_FLAG_REFLECTOR_CLIENT) && ! peer->af_group[afi][safi]) vty_out (vty, " neighbor %s route-reflector-client%s", addr, VTY_NEWLINE); /* Nexthop self. */ if (peer_af_flag_check (peer, afi, safi, PEER_FLAG_NEXTHOP_SELF) && ! peer->af_group[afi][safi]) vty_out (vty, " neighbor %s next-hop-self%s", addr, VTY_NEWLINE); /* Remove private AS. */ if (peer_af_flag_check (peer, afi, safi, PEER_FLAG_REMOVE_PRIVATE_AS) && ! peer->af_group[afi][safi]) vty_out (vty, " neighbor %s remove-private-AS%s", addr, VTY_NEWLINE); /* send-community print. */ if (! peer->af_group[afi][safi]) { if (bgp_option_check (BGP_OPT_CONFIG_CISCO)) { if (peer_af_flag_check (peer, afi, safi, PEER_FLAG_SEND_COMMUNITY) && peer_af_flag_check (peer, afi, safi, PEER_FLAG_SEND_EXT_COMMUNITY)) vty_out (vty, " neighbor %s send-community both%s", addr, VTY_NEWLINE); else if (peer_af_flag_check (peer, afi, safi, PEER_FLAG_SEND_EXT_COMMUNITY)) vty_out (vty, " neighbor %s send-community extended%s", addr, VTY_NEWLINE); else if (peer_af_flag_check (peer, afi, safi, PEER_FLAG_SEND_COMMUNITY)) vty_out (vty, " neighbor %s send-community%s", addr, VTY_NEWLINE); } else { if (! peer_af_flag_check (peer, afi, safi, PEER_FLAG_SEND_COMMUNITY) && ! peer_af_flag_check (peer, afi, safi, PEER_FLAG_SEND_EXT_COMMUNITY)) vty_out (vty, " no neighbor %s send-community both%s", addr, VTY_NEWLINE); else if (! peer_af_flag_check (peer, afi, safi, PEER_FLAG_SEND_EXT_COMMUNITY)) vty_out (vty, " no neighbor %s send-community extended%s", addr, VTY_NEWLINE); else if (! peer_af_flag_check (peer, afi, safi, PEER_FLAG_SEND_COMMUNITY)) vty_out (vty, " no neighbor %s send-community%s", addr, VTY_NEWLINE); } } /* Default information */ if (peer_af_flag_check (peer, afi, safi, PEER_FLAG_DEFAULT_ORIGINATE) && ! peer->af_group[afi][safi]) { vty_out (vty, " neighbor %s default-originate", addr); if (peer->default_rmap[afi][safi].name) vty_out (vty, " route-map %s", peer->default_rmap[afi][safi].name); vty_out (vty, "%s", VTY_NEWLINE); } /* Soft reconfiguration inbound. */ if (CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_SOFT_RECONFIG)) if (! peer->af_group[afi][safi] || ! CHECK_FLAG (g_peer->af_flags[afi][safi], PEER_FLAG_SOFT_RECONFIG)) vty_out (vty, " neighbor %s soft-reconfiguration inbound%s", addr, VTY_NEWLINE); /* maximum-prefix. */ if (CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX)) if (! peer->af_group[afi][safi] || g_peer->pmax[afi][safi] != peer->pmax[afi][safi] || g_peer->pmax_threshold[afi][safi] != peer->pmax_threshold[afi][safi] || CHECK_FLAG (g_peer->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX_WARNING) != CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX_WARNING)) { vty_out (vty, " neighbor %s maximum-prefix %ld", addr, peer->pmax[afi][safi]); if (peer->pmax_threshold[afi][safi] != MAXIMUM_PREFIX_THRESHOLD_DEFAULT) vty_out (vty, " %d", peer->pmax_threshold[afi][safi]); if (CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX_WARNING)) vty_out (vty, " warning-only"); if (peer->pmax_restart[afi][safi]) vty_out (vty, " restart %d", peer->pmax_restart[afi][safi]); vty_out (vty, "%s", VTY_NEWLINE); } /* Route server client. */ if (CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT) && ! peer->af_group[afi][safi]) vty_out (vty, " neighbor %s route-server-client%s", addr, VTY_NEWLINE); /* Nexthop-local unchanged. */ if (CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED) && ! peer->af_group[afi][safi]) vty_out (vty, " neighbor %s nexthop-local unchanged%s", addr, VTY_NEWLINE); /* Allow AS in. */ if (peer_af_flag_check (peer, afi, safi, PEER_FLAG_ALLOWAS_IN)) if (! peer_group_active (peer) || ! peer_af_flag_check (g_peer, afi, safi, PEER_FLAG_ALLOWAS_IN) || peer->allowas_in[afi][safi] != g_peer->allowas_in[afi][safi]) { if (peer->allowas_in[afi][safi] == 3) vty_out (vty, " neighbor %s allowas-in%s", addr, VTY_NEWLINE); else vty_out (vty, " neighbor %s allowas-in %d%s", addr, peer->allowas_in[afi][safi], VTY_NEWLINE); } /* Filter. */ bgp_config_write_filter (vty, peer, afi, safi); /* atribute-unchanged. */ if ((CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_AS_PATH_UNCHANGED) || CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_NEXTHOP_UNCHANGED) || CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_MED_UNCHANGED)) && ! peer->af_group[afi][safi]) { if (CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_AS_PATH_UNCHANGED) && CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_NEXTHOP_UNCHANGED) && CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_MED_UNCHANGED)) vty_out (vty, " neighbor %s attribute-unchanged%s", addr, VTY_NEWLINE); else vty_out (vty, " neighbor %s attribute-unchanged%s%s%s%s", addr, (CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_AS_PATH_UNCHANGED)) ? " as-path" : "", (CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_NEXTHOP_UNCHANGED)) ? " next-hop" : "", (CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_MED_UNCHANGED)) ? " med" : "", VTY_NEWLINE); } } /* Display "address-family" configuration header. */ void bgp_config_write_family_header (struct vty *vty, afi_t afi, safi_t safi, int *write) { if (*write) return; if (afi == AFI_IP && safi == SAFI_UNICAST) return; vty_out (vty, "!%s address-family ", VTY_NEWLINE); if (afi == AFI_IP) { if (safi == SAFI_MULTICAST) vty_out (vty, "ipv4 multicast"); else if (safi == SAFI_MPLS_VPN) vty_out (vty, "vpnv4 unicast"); } else if (afi == AFI_IP6) { vty_out (vty, "ipv6"); if (safi == SAFI_MULTICAST) vty_out (vty, " multicast"); } vty_out (vty, "%s", VTY_NEWLINE); *write = 1; } /* Address family based peer configuration display. */ static int bgp_config_write_family (struct vty *vty, struct bgp *bgp, afi_t afi, safi_t safi) { int write = 0; struct peer *peer; struct peer_group *group; struct listnode *node, *nnode; bgp_config_write_network (vty, bgp, afi, safi, &write); bgp_config_write_redistribute (vty, bgp, afi, safi, &write); for (ALL_LIST_ELEMENTS (bgp->group, node, nnode, group)) { if (group->conf->afc[afi][safi]) { bgp_config_write_family_header (vty, afi, safi, &write); bgp_config_write_peer (vty, bgp, group->conf, afi, safi); } } for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer)) { if (peer->afc[afi][safi]) { if (! CHECK_FLAG (peer->sflags, PEER_STATUS_ACCEPT_PEER)) { bgp_config_write_family_header (vty, afi, safi, &write); bgp_config_write_peer (vty, bgp, peer, afi, safi); } } } bgp_config_write_maxpaths (vty, bgp, afi, safi, &write); if (write) vty_out (vty, " exit-address-family%s", VTY_NEWLINE); return write; } int bgp_config_write (struct vty *vty) { int write = 0; struct bgp *bgp; struct peer_group *group; struct peer *peer; struct listnode *node, *nnode; struct listnode *mnode, *mnnode; /* BGP Multiple instance. */ if (bgp_option_check (BGP_OPT_MULTIPLE_INSTANCE)) { vty_out (vty, "bgp multiple-instance%s", VTY_NEWLINE); write++; } /* BGP Config type. */ if (bgp_option_check (BGP_OPT_CONFIG_CISCO)) { vty_out (vty, "bgp config-type cisco%s", VTY_NEWLINE); write++; } /* BGP configuration. */ for (ALL_LIST_ELEMENTS (bm->bgp, mnode, mnnode, bgp)) { if (write) vty_out (vty, "!%s", VTY_NEWLINE); /* Router bgp ASN */ vty_out (vty, "router bgp %u", bgp->as); if (bgp_option_check (BGP_OPT_MULTIPLE_INSTANCE)) { if (bgp->name) vty_out (vty, " view %s", bgp->name); } vty_out (vty, "%s", VTY_NEWLINE); /* No Synchronization */ if (bgp_option_check (BGP_OPT_CONFIG_CISCO)) vty_out (vty, " no synchronization%s", VTY_NEWLINE); /* BGP fast-external-failover. */ if (CHECK_FLAG (bgp->flags, BGP_FLAG_NO_FAST_EXT_FAILOVER)) vty_out (vty, " no bgp fast-external-failover%s", VTY_NEWLINE); /* BGP router ID. */ if (CHECK_FLAG (bgp->config, BGP_CONFIG_ROUTER_ID)) vty_out (vty, " bgp router-id %s%s", inet_ntoa (bgp->router_id), VTY_NEWLINE); /* BGP log-neighbor-changes. */ if (bgp_flag_check (bgp, BGP_FLAG_LOG_NEIGHBOR_CHANGES)) vty_out (vty, " bgp log-neighbor-changes%s", VTY_NEWLINE); /* BGP configuration. */ if (bgp_flag_check (bgp, BGP_FLAG_ALWAYS_COMPARE_MED)) vty_out (vty, " bgp always-compare-med%s", VTY_NEWLINE); /* BGP default ipv4-unicast. */ if (bgp_flag_check (bgp, BGP_FLAG_NO_DEFAULT_IPV4)) vty_out (vty, " no bgp default ipv4-unicast%s", VTY_NEWLINE); /* BGP default local-preference. */ if (bgp->default_local_pref != BGP_DEFAULT_LOCAL_PREF) vty_out (vty, " bgp default local-preference %d%s", bgp->default_local_pref, VTY_NEWLINE); /* BGP client-to-client reflection. */ if (bgp_flag_check (bgp, BGP_FLAG_NO_CLIENT_TO_CLIENT)) vty_out (vty, " no bgp client-to-client reflection%s", VTY_NEWLINE); /* BGP cluster ID. */ if (CHECK_FLAG (bgp->config, BGP_CONFIG_CLUSTER_ID)) vty_out (vty, " bgp cluster-id %s%s", inet_ntoa (bgp->cluster_id), VTY_NEWLINE); /* Confederation identifier*/ if (CHECK_FLAG (bgp->config, BGP_CONFIG_CONFEDERATION)) vty_out (vty, " bgp confederation identifier %i%s", bgp->confed_id, VTY_NEWLINE); /* Confederation peer */ if (bgp->confed_peers_cnt > 0) { int i; vty_out (vty, " bgp confederation peers"); for (i = 0; i < bgp->confed_peers_cnt; i++) vty_out(vty, " %u", bgp->confed_peers[i]); vty_out (vty, "%s", VTY_NEWLINE); } /* BGP enforce-first-as. */ if (bgp_flag_check (bgp, BGP_FLAG_ENFORCE_FIRST_AS)) vty_out (vty, " bgp enforce-first-as%s", VTY_NEWLINE); /* BGP deterministic-med. */ if (bgp_flag_check (bgp, BGP_FLAG_DETERMINISTIC_MED)) vty_out (vty, " bgp deterministic-med%s", VTY_NEWLINE); /* BGP graceful-restart. */ if (bgp->stalepath_time != BGP_DEFAULT_STALEPATH_TIME) vty_out (vty, " bgp graceful-restart stalepath-time %d%s", bgp->stalepath_time, VTY_NEWLINE); if (bgp_flag_check (bgp, BGP_FLAG_GRACEFUL_RESTART)) vty_out (vty, " bgp graceful-restart%s", VTY_NEWLINE); /* BGP bestpath method. */ if (bgp_flag_check (bgp, BGP_FLAG_ASPATH_IGNORE)) vty_out (vty, " bgp bestpath as-path ignore%s", VTY_NEWLINE); if (bgp_flag_check (bgp, BGP_FLAG_ASPATH_CONFED)) vty_out (vty, " bgp bestpath as-path confed%s", VTY_NEWLINE); if (bgp_flag_check (bgp, BGP_FLAG_COMPARE_ROUTER_ID)) vty_out (vty, " bgp bestpath compare-routerid%s", VTY_NEWLINE); if (bgp_flag_check (bgp, BGP_FLAG_MED_CONFED) || bgp_flag_check (bgp, BGP_FLAG_MED_MISSING_AS_WORST)) { vty_out (vty, " bgp bestpath med"); if (bgp_flag_check (bgp, BGP_FLAG_MED_CONFED)) vty_out (vty, " confed"); if (bgp_flag_check (bgp, BGP_FLAG_MED_MISSING_AS_WORST)) vty_out (vty, " missing-as-worst"); vty_out (vty, "%s", VTY_NEWLINE); } /* BGP network import check. */ if (bgp_flag_check (bgp, BGP_FLAG_IMPORT_CHECK)) vty_out (vty, " bgp network import-check%s", VTY_NEWLINE); /* BGP scan interval. */ bgp_config_write_scan_time (vty); /* BGP flag dampening. */ if (CHECK_FLAG (bgp->af_flags[AFI_IP][SAFI_UNICAST], BGP_CONFIG_DAMPENING)) bgp_config_write_damp (vty); /* BGP static route configuration. */ bgp_config_write_network (vty, bgp, AFI_IP, SAFI_UNICAST, &write); /* BGP redistribute configuration. */ bgp_config_write_redistribute (vty, bgp, AFI_IP, SAFI_UNICAST, &write); /* BGP timers configuration. */ if (bgp->default_keepalive != BGP_DEFAULT_KEEPALIVE && bgp->default_holdtime != BGP_DEFAULT_HOLDTIME) vty_out (vty, " timers bgp %d %d%s", bgp->default_keepalive, bgp->default_holdtime, VTY_NEWLINE); /* peer-group */ for (ALL_LIST_ELEMENTS (bgp->group, node, nnode, group)) { bgp_config_write_peer (vty, bgp, group->conf, AFI_IP, SAFI_UNICAST); } /* Normal neighbor configuration. */ for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer)) { if (! CHECK_FLAG (peer->sflags, PEER_STATUS_ACCEPT_PEER)) bgp_config_write_peer (vty, bgp, peer, AFI_IP, SAFI_UNICAST); } /* maximum-paths */ bgp_config_write_maxpaths (vty, bgp, AFI_IP, SAFI_UNICAST, &write); /* Distance configuration. */ bgp_config_write_distance (vty, bgp); /* No auto-summary */ if (bgp_option_check (BGP_OPT_CONFIG_CISCO)) vty_out (vty, " no auto-summary%s", VTY_NEWLINE); /* IPv4 multicast configuration. */ write += bgp_config_write_family (vty, bgp, AFI_IP, SAFI_MULTICAST); /* IPv4 VPN configuration. */ write += bgp_config_write_family (vty, bgp, AFI_IP, SAFI_MPLS_VPN); /* IPv6 unicast configuration. */ write += bgp_config_write_family (vty, bgp, AFI_IP6, SAFI_UNICAST); /* IPv6 multicast configuration. */ write += bgp_config_write_family (vty, bgp, AFI_IP6, SAFI_MULTICAST); write++; } return write; } void bgp_master_init (void) { memset (&bgp_master, 0, sizeof (struct bgp_master)); bm = &bgp_master; bm->bgp = list_new (); bm->listen_sockets = list_new (); bm->port = BGP_PORT_DEFAULT; bm->master = thread_master_create (); bm->start_time = bgp_clock (); } void bgp_init (void) { /* BGP VTY commands installation. */ bgp_vty_init (); /* Init kroute. */ bgp_kroute_init (); /* BGP inits. */ bgp_attr_init (); bgp_debug_init (); bgp_dump_init (); bgp_route_init (); bgp_route_map_init (); bgp_scan_init (); bgp_mplsvpn_init (); /* Access list initialize. */ access_list_init (); access_list_add_hook (peer_distribute_update); access_list_delete_hook (peer_distribute_update); /* Filter list initialize. */ bgp_filter_init (); as_list_add_hook (peer_aslist_update); as_list_delete_hook (peer_aslist_update); /* Prefix list initialize.*/ prefix_list_init (); prefix_list_add_hook (peer_prefix_list_update); prefix_list_delete_hook (peer_prefix_list_update); /* Community list initialize. */ bgp_clist = community_list_init (); #ifdef HAVE_SNMP bgp_snmp_init (); #endif /* HAVE_SNMP */ } void bgp_terminate (void) { struct bgp *bgp; struct peer *peer; struct listnode *node, *nnode; struct listnode *mnode, *mnnode; for (ALL_LIST_ELEMENTS (bm->bgp, mnode, mnnode, bgp)) for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer)) if (peer->status == Established) bgp_notify_send (peer, BGP_NOTIFY_CEASE, BGP_NOTIFY_CEASE_PEER_UNCONFIG); bgp_cleanup_routes (); if (bm->process_main_queue) { work_queue_free (bm->process_main_queue); bm->process_main_queue = NULL; } if (bm->process_rsclient_queue) { work_queue_free (bm->process_rsclient_queue); bm->process_rsclient_queue = NULL; } }
AirbornWdd/qpimd
bgpd/bgpd.c
C
gpl-2.0
144,930
/**************************************************************************** ** ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation ([email protected]) ** ** This file is part of the examples of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ ** Commercial Usage ** Licensees holding valid Qt Commercial licenses may use this file in ** accordance with the Qt Commercial License Agreement provided with the ** Software or, alternatively, in accordance with the terms contained in ** a written agreement between you and Nokia. ** ** GNU Lesser General Public License Usage ** Alternatively, this file may be used under the terms of the GNU Lesser ** General Public License version 2.1 as published by the Free Software ** Foundation and appearing in the file LICENSE.LGPL included in the ** packaging of this file. Please review the following information to ** ensure the GNU Lesser General Public License version 2.1 requirements ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. ** ** In addition, as a special exception, Nokia gives you certain additional ** rights. These rights are described in the Nokia Qt LGPL Exception ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. ** ** GNU General Public License Usage ** Alternatively, this file may be used under the terms of the GNU ** General Public License version 3.0 as published by the Free Software ** Foundation and appearing in the file LICENSE.GPL included in the ** packaging of this file. Please review the following information to ** ensure the GNU General Public License version 3.0 requirements will be ** met: http://www.gnu.org/copyleft/gpl.html. ** ** If you have questions regarding the use of this file, please contact ** Nokia at [email protected]. ** $QT_END_LICENSE$ ** ****************************************************************************/ #ifndef FLOWLAYOUT_H #define FLOWLAYOUT_H #include <QLayout> #include <QRect> #include <QWidgetItem> //! [0] class FlowLayout : public QLayout { public: FlowLayout(QWidget *parent, int margin = -1, int hSpacing = -1, int vSpacing = -1); FlowLayout(int margin = -1, int hSpacing = -1, int vSpacing = -1); ~FlowLayout(); void addItem(QLayoutItem *item); int horizontalSpacing() const; int verticalSpacing() const; Qt::Orientations expandingDirections() const; bool hasHeightForWidth() const; int heightForWidth(int) const; int count() const; QLayoutItem *itemAt(int index) const; QSize minimumSize() const; void setGeometry(const QRect &rect); QSize sizeHint() const; QLayoutItem *takeAt(int index); private: int doLayout(const QRect &rect, bool testOnly) const; int smartSpacing(QStyle::PixelMetric pm) const; QList<QLayoutItem *> itemList; int m_hSpace; int m_vSpace; }; //! [0] #endif
librelab/qtmoko-test
qtopiacore/qt/examples/layouts/flowlayout/flowlayout.h
C
gpl-2.0
2,910
@charset "utf-8"; /* CSS Document */ /* Dark Categories */ #categories_container{ background:url(images/categories_bg.png) !important; border:1px solid #4e4e4e !important; border-right:0 !important; border-left:0 !important; } #categories ul li a{ color:#fff !important; text-shadow:1px 1px #000 !important; border-right:1px solid #2d2d2d !important; } #categories .home_first_line{ border-left:1px solid #2d2d2d !important; } #categories .home_second_line{ border-left:1px solid #000000 !important; } #categories ul li{ border-right:1px solid #000000 !important; } #categories ul li a:hover{ background:url(images/categories_bg_hover.png) !important; color:#ccc !important; } #categories .current-cat a{ background:url(images/categories_bg_hover.png) !important; } .secondnav-menu ul{ background:#000 !important; border:1px solid #181818 !important; } .secondnav-menu li li a{ border-top:1px solid #181818 !important; } #categories ul li ul li a:hover{ background:none !important; }
tbinjiayou/CSerzs
wp-content/themes/broadcast/scripts/css/styles/dark/categories.css
CSS
gpl-2.0
1,067
<!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Strict//EN' 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd'> <html xmlns='http://www.w3.org/1999/xhtml' xml:lang='en' lang='en'> <head> <meta http-equiv='Content-Type' content='text/html; charset=utf-8'/> <title>Index of Types</title> <link href='reno.css' type='text/css' rel='stylesheet'/> </head> <body> <div class="body-0"> <div class="body-1"> <div class="body-2"> <div> <h1>QVM: Quaternions, Vectors, Matrices</h1> </div> <!-- Copyright (c) 2008-2016 Emil Dotchevski and Reverge Studios, Inc. --> <!-- Distributed under the Boost Software License, Version 1.0. (See accompanying --> <!-- file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) --> <div class="RenoIncludeDIV"><div class="RenoAutoDIV"><h3>Index of Types</h3> </div> <div class="RenoIndex"><h3>d</h3> <p><a href="deduce_mat.html">deduce_mat</a></p> <p><a href="deduce_mat2.html">deduce_mat2</a></p> <p><a href="deduce_quat.html">deduce_quat</a></p> <p><a href="deduce_quat2.html">deduce_quat2</a></p> <p><a href="deduce_scalar.html">deduce_scalar</a></p> <p><a href="deduce_vec.html">deduce_vec</a></p> <p><a href="deduce_vec2.html">deduce_vec2</a></p> <h3>i</h3> <p><a href="is_mat.html">is_mat</a></p> <p><a href="is_quat.html">is_quat</a></p> <p><a href="is_scalar.html">is_scalar</a></p> <p><a href="is_vec.html">is_vec</a></p> <h3>m</h3> <p><a href="mat.html">mat</a></p> <p><a href="mat_traits.html">mat_traits</a></p> <p><a href="mat_traits_M_scalar_type.html">mat_traits&lt;M&gt;::scalar_type</a></p> <h3>q</h3> <p><a href="quat.html">quat</a></p> <p><a href="quat_traits.html">quat_traits</a></p> <p><a href="quat_traits_Q_scalar_type.html">quat_traits&lt;Q&gt;::scalar_type</a></p> <h3>s</h3> <p><a href="scalar.html">scalar</a></p> <p><a href="scalar_traits.html">scalar_traits</a></p> <h3>v</h3> <p><a href="vec.html">vec</a></p> <p><a href="vec_traits.html">vec_traits</a></p> <p><a href="vec_traits_V_scalar_type.html">vec_traits&lt;V&gt;::scalar_type</a></p> </div> </div><div class="RenoAutoDIV"><div class="RenoHR"><hr/></div> See also: <span class="RenoPageList"><a href="index.html">Boost QVM</a></span> </div> <!-- Copyright (c) 2008-2016 Emil Dotchevski and Reverge Studios, Inc. --> <!-- Distributed under the Boost Software License, Version 1.0. (See accompanying --> <!-- file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) --> <div id="footer"> <p> <a class="logo" href="http://jigsaw.w3.org/css-validator/check/referer"><img class="logo_pic" src="valid-css.png" alt="Valid CSS" height="31" width="88"/></a> <a class="logo" href="http://validator.w3.org/check?uri=referer"><img class="logo_pic" src="valid-xhtml.png" alt="Valid XHTML 1.0" height="31" width="88"/></a> <small>Copyright (c) 2008-2016 by Emil Dotchevski and Reverge Studios, Inc.<br/> Distributed under the <a href="http://www.boost.org/LICENSE_1_0.txt">Boost Software License, Version 1.0</a>.</small> </p> </div> </div> </div> </div> </body> </html>
FFMG/myoddweb.piger
myodd/boost/libs/qvm/doc/Index_of_Types.html
HTML
gpl-2.0
2,996
using Mono.Data.Sqlite; namespace Noised.Core.DB.Sqlite { /// <summary> /// Factory for creating Sqlite connections /// </summary> public interface ISqliteConnectionFactory { /// <summary> /// Creates a new, still closed connection /// </summary> SqliteConnection Create(); }; }
bennygr/noised
src/NoisedCore/DB/Sqlite/ISqliteConnectionFactory.cs
C#
gpl-2.0
296
module.exports = function(grunt) { require("matchdep").filterDev("grunt-*").forEach(grunt.loadNpmTasks); grunt.initConfig({ pkg: grunt.file.readJSON("package.json"), copy: { main: { expand: true, cwd: "src/", src: ["**", "!css/**/*.scss", "!css/**/*.less"], dest: "dist/" } }, less: { options: { paths: ["src/css"] }, src: { expand: true, cwd: "src/css", src: "*.less", ext: ".css", dest: "src/css" } }, sass: { dist:{ options:{ style: 'expanded', // values: nested, expanded, compact, compressed noCache: true }, files:[{ expand: true, cwd: "src/css", src: ["*.scss"], dest: "src/css", ext: ".css" }] } }, watch: { options: { nospawn: true, livereload: true }, less: { files: ["src/css/**/*.less"], tasks: ["less"] }, sass: { files: ["src/css/**/*.scss"], tasks: ["sass"] }, copy: { files: ["src/**"], tasks: ["copy:main"] } } }); grunt.registerTask("default", ["watch"]); };
MDIAZ88/mad-css-less-sass
Gruntfile.js
JavaScript
gpl-2.0
1,266
<div class="toggle-region"></div>
atogle/assisi
src/web/jstemplates/request-layout-tpl.html
HTML
gpl-2.0
33
<!doctype html public "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd"> <html> <head> <title>PHPXRef 0.7.1 : Unnamed Project : Variable Reference: $force_regexp_dirname</title> <link rel="stylesheet" href="../sample.css" type="text/css"> <link rel="stylesheet" href="../sample-print.css" type="text/css" media="print"> <style id="hilight" type="text/css"></style> <meta http-equiv="content-type" content="text/html;charset=iso-8859-1"> </head> <body bgcolor="#ffffff" text="#000000" link="#801800" vlink="#300540" alink="#ffffff"> <table class="pagetitle" width="100%"> <tr> <td valign="top" class="pagetitle"> [ <a href="../index.html">Index</a> ] </td> <td align="right" class="pagetitle"> <h2 style="margin-bottom: 0px">PHP Cross Reference of Unnamed Project</h2> </td> </tr> </table> <!-- Generated by PHPXref 0.7.1 at Sat Nov 21 22:13:19 2015 --> <!-- PHPXref (c) 2000-2010 Gareth Watts - [email protected] --> <!-- http://phpxref.sourceforge.net/ --> <script src="../phpxref.js" type="text/javascript"></script> <script language="JavaScript" type="text/javascript"> <!-- ext='.html'; relbase='../'; subdir='_variables'; filename='index.html'; cookiekey='phpxref'; handleNavFrame(relbase, subdir, filename); logVariable('force_regexp_dirname'); // --> </script> <script language="JavaScript" type="text/javascript"> if (gwGetCookie('xrefnav')=='off') document.write('<p class="navlinks">[ <a href="javascript:navOn()">Show Explorer<\/a> ]<\/p>'); else document.write('<p class="navlinks">[ <a href="javascript:navOff()">Hide Explorer<\/a> ]<\/p>'); </script> <noscript> <p class="navlinks"> [ <a href="../nav.html" target="_top">Show Explorer</a> ] [ <a href="index.html" target="_top">Hide Navbar</a> ] </p> </noscript> [<a href="../index.html">Top level directory</a>]<br> <script language="JavaScript" type="text/javascript"> <!-- document.writeln('<table align="right" class="searchbox-link"><tr><td><a class="searchbox-link" href="javascript:void(0)" onMouseOver="showSearchBox()">Search</a><br>'); document.writeln('<table border="0" cellspacing="0" cellpadding="0" class="searchbox" id="searchbox">'); document.writeln('<tr><td class="searchbox-title">'); document.writeln('<a class="searchbox-title" href="javascript:showSearchPopup()">Search History +</a>'); document.writeln('<\/td><\/tr>'); document.writeln('<tr><td class="searchbox-body" id="searchbox-body">'); document.writeln('<form name="search" style="margin:0px; padding:0px" onSubmit=\'return jump()\'>'); document.writeln('<a class="searchbox-body" href="../_classes/index.html">Class<\/a>: '); document.writeln('<input type="text" size=10 value="" name="classname"><br>'); document.writeln('<a id="funcsearchlink" class="searchbox-body" href="../_functions/index.html">Function<\/a>: '); document.writeln('<input type="text" size=10 value="" name="funcname"><br>'); document.writeln('<a class="searchbox-body" href="../_variables/index.html">Variable<\/a>: '); document.writeln('<input type="text" size=10 value="" name="varname"><br>'); document.writeln('<a class="searchbox-body" href="../_constants/index.html">Constant<\/a>: '); document.writeln('<input type="text" size=10 value="" name="constname"><br>'); document.writeln('<a class="searchbox-body" href="../_tables/index.html">Table<\/a>: '); document.writeln('<input type="text" size=10 value="" name="tablename"><br>'); document.writeln('<input type="submit" class="searchbox-button" value="Search">'); document.writeln('<\/form>'); document.writeln('<\/td><\/tr><\/table>'); document.writeln('<\/td><\/tr><\/table>'); // --> </script> <div id="search-popup" class="searchpopup"><p id="searchpopup-title" class="searchpopup-title">title</p><div id="searchpopup-body" class="searchpopup-body">Body</div><p class="searchpopup-close"><a href="javascript:gwCloseActive()">[close]</a></p></div> <h3>Variable Cross Reference</h3> <h2><a href="index.html#force_regexp_dirname">$force_regexp_dirname</a></h2> <b>Defined at:</b><ul> <li><a href="../conf/_advanced.php.html">/conf/_advanced.php</A> -> <a href="../conf/_advanced.php.source.html#l661"> line 661</A></li> </ul> <br><b>Referenced 6 times:</b><ul> <li><a href="../inc/files/views/_file_settings.form.php.html">/inc/files/views/_file_settings.form.php</a> -> <a href="../inc/files/views/_file_settings.form.php.source.html#l179"> line 179</a></li> <li><a href="../inc/files/views/_file_settings.form.php.html">/inc/files/views/_file_settings.form.php</a> -> <a href="../inc/files/views/_file_settings.form.php.source.html#l193"> line 193</a></li> <li><a href="../inc/files/model/_file.funcs.php.html">/inc/files/model/_file.funcs.php</a> -> <a href="../inc/files/model/_file.funcs.php.source.html#l634"> line 634</a></li> <li><a href="../inc/files/model/_file.funcs.php.html">/inc/files/model/_file.funcs.php</a> -> <a href="../inc/files/model/_file.funcs.php.source.html#l643"> line 643</a></li> <li><a href="../inc/files/model/_file.funcs.php.html">/inc/files/model/_file.funcs.php</a> -> <a href="../inc/files/model/_file.funcs.php.source.html#l645"> line 645</a></li> <li><a href="../conf/_advanced.php.html">/conf/_advanced.php</a> -> <a href="../conf/_advanced.php.source.html#l661"> line 661</a></li> </ul> <!-- A link to the phpxref site in your customized footer file is appreciated ;-) --> <br><hr> <table width="100%"> <tr><td>Generated: Sat Nov 21 22:13:19 2015</td> <td align="right"><i>Cross-referenced by <a href="http://phpxref.sourceforge.net/">PHPXref 0.7.1</a></i></td> </tr> </table> </body></html>
mgsolipa/b2evolution_phpxref
_variables/force_regexp_dirname.html
HTML
gpl-2.0
5,639
/* vi: set sw=4 ts=4: */ /* * Utility routines. * * Copyright (C) 1999-2004 by Erik Andersen <[email protected]> * * Licensed under GPLv2 or later, see file LICENSE in this tarball for details. */ #include "libbb.h" void bb_herror_msg(const char *s, ...) { va_list p; va_start(p, s); bb_vherror_msg(s, p); va_end(p); }
xxha/busybox-1.6.0
libbb/herror_msg.c
C
gpl-2.0
336
#!/usr/bin/python "feed fetcher" from db import MySQLDatabase from fetcher import FeedFetcher def main(): db = MySQLDatabase() fetcher = FeedFetcher() feeds = db.get_feeds(offset=0, limit=10) read_count = 10 while len(feeds) > 0: for feed in feeds: fid = feed[0] url = feed[1] title = feed[2] print "fetching #{0}: {1}".format(fid, url) entries = fetcher.fetch(url) for entry in entries: entry.feed_id = fid try: print "insert {0}".format(entry.url) except UnicodeEncodeError: print "insert {0}".format(entry.url.encode('utf-8')) db.append_feed_content(entry) feeds = db.get_feeds(offset=read_count, limit=10) read_count += 10 if __name__ == '__main__': main()
hylom/grrreader
backend/feedfetcher.py
Python
gpl-2.0
889
/* * 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 sv.edu.uesocc.ingenieria.disenio2_2015.pymesell.presentacion.pymesellv1desktopclient; /** * * @author David */ public class Main { /** * @param args the command line arguments */ public static void main(String[] args) { System.out.println("Hola a todos!!!"); } }
girondave/Proyecto_Disenio2_2015-PymeSell_v1
PymeSellV1DesktopClient/src/java/sv/edu/uesocc/ingenieria/disenio2_2015/pymesell/presentacion/pymesellv1desktopclient/Main.java
Java
gpl-2.0
496
<?php global $post; $date_format = get_option('date_format'); $author_id=$post->post_author; $options = ST_Page_Builder::get_page_options($post->ID, array()); ?> <div <?php post_class(); ?>> <?php // show thumbnails if(st_get_setting('sc_show_featured_img','y')!='n'){ $thumb = st_theme_post_thumbnail($post->ID,array('force_video_size'=> false), false); ?> <?php if($thumb!=''){ ?> <div class="entry-thumbnail main-img"> <?php echo $thumb; if (isset($options['count_lessons']) && ($caption = $options['caption_featured_image']) != '') echo '<p class="lead">'. $caption .'</p>'; ?> </div> <?php } } ?> <div class="entry-content"> <?php // show the content if(function_exists('st_the_builder_content')){ if(!st_the_builder_content($post->ID)){ the_content(); } }else{ the_content(); } ?> </div> <?php // pagination for single $args = array( 'before' => '<p class="single-pagination">' . __('Pages:','smooththemes'), 'after' => '</p>', 'link_before' => '', 'link_after' => '', 'next_or_number' => 'number', 'nextpagelink' => __('Next page','smooththemes'), 'previouspagelink' => __('Previous page','smooththemes'), 'pagelink' => '%', 'echo' => 1 ); wp_link_pages( $args ); if(st_get_setting('sc_show_post_tag','y')!='n'){ echo get_the_term_list( $post->ID, 'course_category', '<div class="entry-tags"> '.__('Categories: '), ', ', '</div>' ); } if(st_get_setting("sc_show_author_desc",'y') != 'n'){ st_theme_author_template($author_id); }; if(st_get_setting("sc_show_comments",'y') != 'n'){ ?> <div id="comments"> <?php comments_template('', true ); ?> </div><!-- /#comments--> <?php } ?> </div><!-- /. end post_class -->
dangxuanha/wordpress_language
wp-content/themes/Edu/content-course.php
PHP
gpl-2.0
2,082
INTERFACE: #include "initcalls.h" #include "types.h" class Jdb_symbol_info; class Jdb_lines_info; class Jdb_dbinfo { }; //--------------------------------------------------------------------------- IMPLEMENTATION: #include "config.h" // We have to do this here because Jdb_symbol and Jdb_lines must not depend // on Kmem_alloc. PRIVATE static inline NOEXPORT void Jdb_dbinfo::init_symbols_lines () { Mword p; p = (sizeof(Jdb_symbol_info)*Jdb_symbol::Max_tasks) >> Config::PAGE_SHIFT; Jdb_symbol::init(Kmem_alloc::allocator() ->unaligned_alloc(p*Config::PAGE_SIZE), p); p = (sizeof(Jdb_lines_info) *Jdb_lines::Max_tasks) >> Config::PAGE_SHIFT; Jdb_lines::init(Kmem_alloc::allocator() ->unaligned_alloc(p*Config::PAGE_SIZE), p); } //--------------------------------------------------------------------------- IMPLEMENTATION[ia32,amd64]: #include "cpu_lock.h" #include "jdb_lines.h" #include "jdb_symbol.h" #include "kmem.h" #include "kmem_alloc.h" #include "mem_layout.h" #include "mem_unit.h" #include "paging.h" #include "space.h" #include "static_init.h" const Address area_start = Mem_layout::Jdb_debug_start; const Address area_end = Mem_layout::Jdb_debug_end; const unsigned area_size = area_end - area_start; const unsigned bitmap_size = (area_size / Config::PAGE_SIZE) / 8; // We don't use the amm library here anymore since it is nearly impossible // to debug it and I got some strange behavior. Instead of this we use a // simple bitfield here that takes 2k for a virtual memory size of 64MB // which is enough for the Jdb debug info. Speed for allocating/deallocating // pages is not an issue here. static unsigned char bitmap[bitmap_size]; STATIC_INITIALIZE(Jdb_dbinfo); //--------------------------------------------------------------------------- IMPLEMENTATION[ia32, amd64]: PUBLIC static FIASCO_INIT void Jdb_dbinfo::init() { Address addr; for (addr = area_start; addr < area_end; addr += Config::SUPERPAGE_SIZE) Kmem::kdir->walk(Virt_addr(addr), 100, pdir_alloc(Kmem_alloc::allocator())); init_symbols_lines(); } PRIVATE static Address Jdb_dbinfo::reserve_pages(unsigned pages) { auto guard = lock_guard(cpu_lock); Unsigned8 *ptr, bit; for (ptr=bitmap, bit=0; ptr<bitmap+bitmap_size;) { Unsigned8 *ptr1, bit1, c; unsigned pages1; for (ptr1=ptr, bit1=bit, pages1=pages;;) { if (ptr1>=bitmap+bitmap_size) return 0; c = *ptr1 & (1<<bit1); if (++bit1 >= 8) { bit1 = 0; ptr1++; } if (c) { ptr = ptr1; bit = bit1; break; } if (!--pages1) { // found area -- make it as reserved for (ptr1=ptr, bit1=bit, pages1=pages; pages1>0; pages1--) { *ptr1 |= (1<<bit1); if (++bit1 >= 8) { bit1 = 0; ptr1++; } } return area_start + Config::PAGE_SIZE * (8*(ptr-bitmap) + bit); } } } return 0; } PRIVATE static void Jdb_dbinfo::return_pages(Address addr, unsigned pages) { auto guard = lock_guard(cpu_lock); unsigned nr_page = (addr-area_start) / Config::PAGE_SIZE; Unsigned8 *ptr = bitmap + nr_page/8, bit = nr_page % 8; for (; pages && ptr < bitmap+bitmap_size; pages--) { assert (*ptr & (1<<bit)); *ptr &= ~(1<<bit); if (++bit >= 8) { bit = 0; ptr++; } } } //--------------------------------------------------------------------------- IMPLEMENTATION[ia32, amd64]: PUBLIC static bool Jdb_dbinfo::map(Address phys, size_t &size, Address &virt) { Address offs = phys & ~Config::PAGE_MASK; size = (offs + size + Config::PAGE_SIZE - 1) & Config::PAGE_MASK; virt = reserve_pages (size / Config::PAGE_SIZE); if (!virt) return false; phys &= Config::PAGE_MASK; Kmem::kdir->map(phys, Virt_addr(virt), Virt_size(size), Pt_entry::Valid | Pt_entry::Writable | Pt_entry::Referenced | Pt_entry::Dirty, 100, Ptab::Null_alloc()); virt += offs; return true; } PUBLIC static void Jdb_dbinfo::unmap(Address virt, size_t size) { if (virt && size) { virt &= Config::PAGE_MASK; Kmem::kdir->unmap(Virt_addr(virt), Virt_size(size), 100); Mem_unit::tlb_flush (); return_pages(virt, size/Config::PAGE_SIZE); } } PUBLIC static void Jdb_dbinfo::set(Jdb_symbol_info *sym, Address phys, size_t size) { Address virt; if (!sym) return; if (!phys) { sym->get (virt, size); if (! virt) return; unmap (virt, size); sym->reset (); return; } if (! map (phys, size, virt)) return; if (! sym->set (virt, size)) { unmap (virt, size); sym->reset (); } } PUBLIC static void Jdb_dbinfo::set(Jdb_lines_info *lin, Address phys, size_t size) { Address virt; if (!lin) return; if (!phys) { lin->get(virt, size); if (! virt) return; unmap(virt, size); lin->reset (); } if (!map(phys, size, virt)) return; if (!lin->set(virt, size)) { unmap(virt, size); lin->reset(); } } //--------------------------------------------------------------------------- IMPLEMENTATION[ux]: // No special mapping required for UX since all physical memory is mapped #include "jdb_lines.h" #include "jdb_symbol.h" #include "kmem_alloc.h" #include "mem_layout.h" #include "static_init.h" STATIC_INITIALIZE(Jdb_dbinfo); PUBLIC static void Jdb_dbinfo::init() { init_symbols_lines(); } PUBLIC static void Jdb_dbinfo::set(Jdb_symbol_info *sym, Address phys, size_t size) { if (!sym) return; if (!phys) sym->reset(); else sym->set(Mem_layout::phys_to_pmem(phys), size); } PUBLIC static void Jdb_dbinfo::set(Jdb_lines_info *lin, Address phys, size_t size) { if (!lin) return; if (!phys) lin->reset(); else lin->set(Mem_layout::phys_to_pmem(phys), size); }
MicroTrustRepos/microkernel
src/kernel/fiasco/src/jdb/jdb_dbinfo.cpp
C++
gpl-2.0
5,858
package org.booleanfloat.traveler.links; import org.booleanfloat.traveler.Location; import org.booleanfloat.traveler.interfaces.Traversable; import java.util.ArrayList; import java.util.concurrent.Callable; public class OneWayLink { public OneWayLink(Location start, Location end) { this(start, end, new ArrayList<Traversable>(), null); } public OneWayLink(Location start, Location end, ArrayList<Traversable> steps) { this(start, end, steps, null); } public OneWayLink(Location start, Location end, ArrayList<Traversable> steps, Callable<Boolean> requirement) { new Link(start, end, steps, requirement); } }
BooleanFloat/Traveler
src/org/booleanfloat/traveler/links/OneWayLink.java
Java
gpl-2.0
662
<?php /** * Template Name: Library * @package mjv-theme */ if (is_home()) : get_header(); else : get_header('insiders'); endif; ?> <div id="primary" class="content-area library"> <main id="main" class="site-main" role="main"> <?php //carrega os cases, clients e content get_template_part('template-parts/content', 'library'); ?> </main><!-- #main --> </div><!-- #primary --> <?php get_sidebar(); get_footer();
DiegoDCosta/mjv-wp
page-library.php
PHP
gpl-2.0
472
public class trace { public void mnonnullelements(int[] a) { int i = 0; //@ assert i == 0 && \nonnullelements(a); return ; } public void mnotmodified(int i) { //@ assert \not_modified(i); i = 4; //@ assert i == 4 && \not_modified(i); return ; } }
shunghsiyu/OpenJML_XOR
OpenJML/testfiles/escTraceBS/trace.java
Java
gpl-2.0
342