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
/* FatRat download manager http://fatrat.dolezel.info Copyright (C) 2006-2011 Lubos Dolezel <lubos a dolezel.info> 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. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ package info.dolezel.fatrat.plugins.util; import java.io.ByteArrayInputStream; import java.io.IOException; import java.nio.ByteBuffer; import java.nio.charset.Charset; import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.ParserConfigurationException; import javax.xml.xpath.XPath; import javax.xml.xpath.XPathConstants; import javax.xml.xpath.XPathExpression; import javax.xml.xpath.XPathExpressionException; import javax.xml.xpath.XPathFactory; import org.w3c.dom.Document; import org.w3c.dom.Node; import org.w3c.dom.NodeList; import org.xml.sax.SAXException; /** * * @author lubos */ public class XmlUtils { static final XPathFactory factory = XPathFactory.newInstance(); static final DocumentBuilderFactory dbf; static { dbf = DocumentBuilderFactory.newInstance(); dbf.setNamespaceAware(false); dbf.setValidating(false); } public static XPathExpression expr(String xpathStr) throws XPathExpressionException { XPath xpath = factory.newXPath(); return xpath.compile(xpathStr); } public static String xpathString(Node node, String xpath) throws XPathExpressionException { return (String) expr(xpath).evaluate(node, XPathConstants.STRING); } public static Node xpathNode(Node node, String xpath) throws XPathExpressionException { return (Node) expr(xpath).evaluate(node, XPathConstants.NODE); } public static NodeList xpathNodeList(Node node, String xpath) throws XPathExpressionException { return (NodeList) expr(xpath).evaluate(node, XPathConstants.NODESET); } public static Document loadDocument(ByteBuffer buf) throws ParserConfigurationException, SAXException, IOException { DocumentBuilder builder = dbf.newDocumentBuilder(); //byte[] b = Charset.forName("UTF-8").decode(buf).toString().getBytes("UTF-8"); //System.out.println("New byte[] len: "+b.length); //return builder.parse(new ByteArrayInputStream(b)); return builder.parse(new ByteBufferInputStream(buf)); } }
LubosD/fatrat-jplugins
core/src/main/java/info/dolezel/fatrat/plugins/util/XmlUtils.java
Java
gpl-2.0
2,849
/* * Copyright (C) 2005-2010 MaNGOS <http://getmangos.com/> * Copyright (C) 2009-2010 MaNGOSZero <http://github.com/mangoszero/mangoszero/> * * 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 */ #ifndef MANGOSSERVER_CREATURE_H #define MANGOSSERVER_CREATURE_H #include "Common.h" #include "Unit.h" #include "UpdateMask.h" #include "ItemPrototype.h" #include "LootMgr.h" #include "DBCEnums.h" #include "Database/DatabaseEnv.h" #include "Cell.h" #include <list> struct SpellEntry; class CreatureAI; class Group; class Quest; class Player; class WorldSession; struct GameEventCreatureData; enum CreatureFlagsExtra { CREATURE_FLAG_EXTRA_INSTANCE_BIND = 0x00000001, // creature kill bind instance with killer and killer's group CREATURE_FLAG_EXTRA_NO_AGGRO = 0x00000002, // not aggro (ignore faction/reputation hostility) CREATURE_FLAG_EXTRA_NO_PARRY = 0x00000004, // creature can't parry CREATURE_FLAG_EXTRA_NO_PARRY_HASTEN = 0x00000008, // creature can't counter-attack at parry CREATURE_FLAG_EXTRA_NO_BLOCK = 0x00000010, // creature can't block CREATURE_FLAG_EXTRA_NO_CRUSH = 0x00000020, // creature can't do crush attacks CREATURE_FLAG_EXTRA_NO_XP_AT_KILL = 0x00000040, // creature kill not provide XP CREATURE_FLAG_EXTRA_INVISIBLE = 0x00000080, // creature is always invisible for player (mostly trigger creatures) CREATURE_FLAG_EXTRA_NOT_TAUNTABLE = 0x00000100, // creature is immune to taunt auras and effect attack me }; // GCC have alternative #pragma pack(N) syntax and old gcc version not support pack(push,N), also any gcc version not support it at some platform #if defined( __GNUC__ ) #pragma pack(1) #else #pragma pack(push,1) #endif #define MAX_KILL_CREDIT 2 #define MAX_CREATURE_MODEL 2 // only single send to client in static data // from `creature_template` table struct CreatureInfo { uint32 Entry; uint32 KillCredit[MAX_KILL_CREDIT]; uint32 ModelId[MAX_CREATURE_MODEL]; char* Name; char* SubName; uint32 GossipMenuId; uint32 minlevel; uint32 maxlevel; uint32 minhealth; uint32 maxhealth; uint32 minmana; uint32 maxmana; uint32 armor; uint32 faction_A; uint32 faction_H; uint32 npcflag; float speed_walk; float speed_run; float scale; uint32 rank; float mindmg; float maxdmg; uint32 dmgschool; uint32 attackpower; float dmg_multiplier; uint32 baseattacktime; uint32 rangeattacktime; uint32 unit_class; // enum Classes. Note only 4 classes are known for creatures. uint32 unit_flags; // enum UnitFlags mask values uint32 dynamicflags; uint32 family; // enum CreatureFamily values (optional) uint32 trainer_type; uint32 trainer_spell; uint32 trainer_class; uint32 trainer_race; float minrangedmg; float maxrangedmg; uint32 rangedattackpower; uint32 type; // enum CreatureType values uint32 type_flags; // enum CreatureTypeFlags mask values uint32 lootid; uint32 pickpocketLootId; uint32 SkinLootId; int32 resistance1; int32 resistance2; int32 resistance3; int32 resistance4; int32 resistance5; int32 resistance6; uint32 spells[CREATURE_MAX_SPELLS]; uint32 PetSpellDataId; uint32 mingold; uint32 maxgold; char const* AIName; uint32 MovementType; uint32 InhabitType; uint32 civilian; bool RacialLeader; bool RegenHealth; uint32 equipmentId; uint32 trainerId; uint32 vendorId; uint32 MechanicImmuneMask; uint32 flags_extra; uint32 ScriptID; // helpers SkillType GetRequiredLootSkill() const { if(type_flags & CREATURE_TYPEFLAGS_HERBLOOT) return SKILL_HERBALISM; else if(type_flags & CREATURE_TYPEFLAGS_MININGLOOT) return SKILL_MINING; else return SKILL_SKINNING; // normal case } bool isTameable() const { return type == CREATURE_TYPE_BEAST && family != 0 && (type_flags & CREATURE_TYPEFLAGS_TAMEABLE); } }; struct EquipmentInfo { uint32 entry; uint32 equipmodel[3]; uint32 equipinfo[3]; uint32 equipslot[3]; }; // from `creature` table struct CreatureData { uint32 id; // entry in creature_template uint16 mapid; uint32 modelid_override; // overrides any model defined in creature_template int32 equipmentId; float posX; float posY; float posZ; float orientation; uint32 spawntimesecs; float spawndist; uint32 currentwaypoint; uint32 curhealth; uint32 curmana; bool is_dead; uint8 movementType; }; struct CreatureDataAddonAura { uint32 spell_id; SpellEffectIndex effect_idx; }; // from `creature_addon` table struct CreatureDataAddon { uint32 guidOrEntry; uint32 mount; uint32 bytes1; uint32 bytes2; uint32 emote; uint32 move_flags; CreatureDataAddonAura const* auras; // loaded as char* "spell1 eff1 spell2 eff2 ... " }; struct CreatureModelInfo { uint32 modelid; float bounding_radius; float combat_reach; uint8 gender; uint32 modelid_other_gender; // The oposite gender for this modelid (male/female) uint32 modelid_other_team; // The oposite team. Generally for alliance totem }; // GCC have alternative #pragma pack() syntax and old gcc version not support pack(pop), also any gcc version not support it at some platform #if defined( __GNUC__ ) #pragma pack() #else #pragma pack(pop) #endif struct CreatureLocale { std::vector<std::string> Name; std::vector<std::string> SubName; }; struct GossipMenuItemsLocale { std::vector<std::string> OptionText; std::vector<std::string> BoxText; }; struct PointOfInterestLocale { std::vector<std::string> IconName; }; enum InhabitTypeValues { INHABIT_GROUND = 1, INHABIT_WATER = 2, INHABIT_AIR = 4, INHABIT_ANYWHERE = INHABIT_GROUND | INHABIT_WATER | INHABIT_AIR }; // Enums used by StringTextData::Type (CreatureEventAI) enum ChatType { CHAT_TYPE_SAY = 0, CHAT_TYPE_YELL = 1, CHAT_TYPE_TEXT_EMOTE = 2, CHAT_TYPE_BOSS_EMOTE = 3, CHAT_TYPE_WHISPER = 4, CHAT_TYPE_BOSS_WHISPER = 5, CHAT_TYPE_ZONE_YELL = 6 }; // Selection method used by SelectAttackingTarget enum AttackingTarget { ATTACKING_TARGET_RANDOM = 0, //Just selects a random target ATTACKING_TARGET_TOPAGGRO, //Selects targes from top aggro to bottom ATTACKING_TARGET_BOTTOMAGGRO, //Selects targets from bottom aggro to top /* not implemented ATTACKING_TARGET_RANDOM_PLAYER, //Just selects a random target (player only) ATTACKING_TARGET_TOPAGGRO_PLAYER, //Selects targes from top aggro to bottom (player only) ATTACKING_TARGET_BOTTOMAGGRO_PLAYER, //Selects targets from bottom aggro to top (player only) */ }; // Vendors struct VendorItem { VendorItem(uint32 _item, uint32 _maxcount, uint32 _incrtime) : item(_item), maxcount(_maxcount), incrtime(_incrtime) {} uint32 item; uint32 maxcount; // 0 for infinity item amount uint32 incrtime; // time for restore items amount if maxcount != 0 }; typedef std::vector<VendorItem*> VendorItemList; struct VendorItemData { VendorItemList m_items; VendorItem* GetItem(uint32 slot) const { if(slot>=m_items.size()) return NULL; return m_items[slot]; } bool Empty() const { return m_items.empty(); } uint8 GetItemCount() const { return m_items.size(); } void AddItem( uint32 item, uint32 maxcount, uint32 ptime) { m_items.push_back(new VendorItem(item, maxcount, ptime)); } bool RemoveItem( uint32 item_id ); VendorItem const* FindItem(uint32 item_id) const; size_t FindItemSlot(uint32 item_id) const; void Clear() { for (VendorItemList::const_iterator itr = m_items.begin(); itr != m_items.end(); ++itr) delete (*itr); m_items.clear(); } }; struct VendorItemCount { explicit VendorItemCount(uint32 _item, uint32 _count) : itemId(_item), count(_count), lastIncrementTime(time(NULL)) {} uint32 itemId; uint32 count; time_t lastIncrementTime; }; typedef std::list<VendorItemCount> VendorItemCounts; struct TrainerSpell { TrainerSpell() : spell(0), spellCost(0), reqSkill(0), reqSkillValue(0), reqLevel(0) {} TrainerSpell(uint32 _spell, uint32 _spellCost, uint32 _reqSkill, uint32 _reqSkillValue, uint32 _reqLevel) : spell(_spell), spellCost(_spellCost), reqSkill(_reqSkill), reqSkillValue(_reqSkillValue), reqLevel(_reqLevel) {} uint32 spell; uint32 spellCost; uint32 reqSkill; uint32 reqSkillValue; uint32 reqLevel; }; typedef UNORDERED_MAP<uint32 /*spellid*/, TrainerSpell> TrainerSpellMap; struct TrainerSpellData { TrainerSpellData() : trainerType(0) {} TrainerSpellMap spellList; uint32 trainerType; // trainer type based at trainer spells, can be different from creature_template value. // req. for correct show non-prof. trainers like weaponmaster, allowed values 0 and 2. TrainerSpell const* Find(uint32 spell_id) const; void Clear() { spellList.clear(); } }; typedef std::map<uint32,time_t> CreatureSpellCooldowns; // max different by z coordinate for creature aggro reaction #define CREATURE_Z_ATTACK_RANGE 3 #define MAX_VENDOR_ITEMS 255 // Limitation in item count field size in SMSG_LIST_INVENTORY enum CreatureSubtype { CREATURE_SUBTYPE_GENERIC, // new Creature CREATURE_SUBTYPE_PET, // new Pet CREATURE_SUBTYPE_TOTEM, // new Totem CREATURE_SUBTYPE_TEMPORARY_SUMMON, // new TemporarySummon }; class MANGOS_DLL_SPEC Creature : public Unit { CreatureAI *i_AI; public: explicit Creature(CreatureSubtype subtype = CREATURE_SUBTYPE_GENERIC); virtual ~Creature(); void AddToWorld(); void RemoveFromWorld(); bool Create(uint32 guidlow, Map *map, uint32 Entry, uint32 team, const CreatureData *data = NULL, GameEventCreatureData const* eventData = NULL); bool LoadCreatureAddon(bool reload = false); void SelectLevel(const CreatureInfo *cinfo, float percentHealth = 100.0f, float percentMana = 100.0f); void LoadEquipment(uint32 equip_entry, bool force=false); uint32 GetDBTableGUIDLow() const { return m_DBTableGuid; } char const* GetSubName() const { return GetCreatureInfo()->SubName; } void Update(uint32 time); // overwrite Unit::Update void GetRespawnCoord(float &x, float &y, float &z, float* ori = NULL, float* dist =NULL) const; uint32 GetEquipmentId() const { return m_equipmentId; } CreatureSubtype GetSubtype() const { return m_subtype; } bool IsPet() const { return m_subtype == CREATURE_SUBTYPE_PET; } bool IsTotem() const { return m_subtype == CREATURE_SUBTYPE_TOTEM; } bool IsTemporarySummon() const { return m_subtype == CREATURE_SUBTYPE_TEMPORARY_SUMMON; } bool IsCorpse() const { return getDeathState() == CORPSE; } bool IsDespawned() const { return getDeathState() == DEAD; } void SetCorpseDelay(uint32 delay) { m_corpseDelay = delay; } bool IsRacialLeader() const { return GetCreatureInfo()->RacialLeader; } bool IsCivilian() const { return GetCreatureInfo()->civilian; } bool CanWalk() const { return GetCreatureInfo()->InhabitType & INHABIT_GROUND; } bool CanSwim() const { return GetCreatureInfo()->InhabitType & INHABIT_WATER; } bool CanFly() const { return GetCreatureInfo()->InhabitType & INHABIT_AIR; } bool IsTrainerOf(Player* player, bool msg) const; bool CanInteractWithBattleMaster(Player* player, bool msg) const; bool CanTrainAndResetTalentsOf(Player* pPlayer) const; bool IsOutOfThreatArea(Unit* pVictim) const; bool IsImmuneToSpell(SpellEntry const* spellInfo); // redefine Unit::IsImmuneToSpell bool IsImmuneToSpellEffect(SpellEntry const* spellInfo, SpellEffectIndex index) const; // redefine Unit::IsImmuneToSpellEffect bool IsElite() const { if(IsPet()) return false; uint32 rank = GetCreatureInfo()->rank; return rank != CREATURE_ELITE_NORMAL && rank != CREATURE_ELITE_RARE; } bool IsWorldBoss() const { if(IsPet()) return false; return GetCreatureInfo()->rank == CREATURE_ELITE_WORLDBOSS; } uint32 GetLevelForTarget(Unit const* target) const; // overwrite Unit::GetLevelForTarget for boss level support bool IsInEvadeMode() const; bool AIM_Initialize(); CreatureAI* AI() { return i_AI; } void AddSplineFlag(SplineFlags f) { bool need_walk_sync = (f & SPLINEFLAG_WALKMODE) != (m_splineFlags & SPLINEFLAG_WALKMODE); m_splineFlags = SplineFlags(m_splineFlags | f); if (need_walk_sync) UpdateWalkMode(this, false); } void RemoveSplineFlag(SplineFlags f) { bool need_walk_sync = (f & SPLINEFLAG_WALKMODE) != (m_splineFlags & SPLINEFLAG_WALKMODE); m_splineFlags = SplineFlags(m_splineFlags & ~f); if (need_walk_sync) UpdateWalkMode(this, false); } bool HasSplineFlag(SplineFlags f) const { return m_splineFlags & f; } SplineFlags GetSplineFlags() const { return m_splineFlags; } void SetSplineFlags(SplineFlags f) { bool need_walk_sync = (f & SPLINEFLAG_WALKMODE) != (m_splineFlags & SPLINEFLAG_WALKMODE); m_splineFlags = f; // need set before if (need_walk_sync) UpdateWalkMode(this, false); } void SendMonsterMoveWithSpeedToCurrentDestination(Player* player = NULL); uint32 GetShieldBlockValue() const // dunno mob block value { return (getLevel() / 2 + uint32(GetStat(STAT_STRENGTH) / 20)); } SpellSchoolMask GetMeleeDamageSchoolMask() const { return m_meleeDamageSchoolMask; } void SetMeleeDamageSchool(SpellSchools school) { m_meleeDamageSchoolMask = GetSchoolMask(school); } void _AddCreatureSpellCooldown(uint32 spell_id, time_t end_time); void _AddCreatureCategoryCooldown(uint32 category, time_t apply_time); void AddCreatureSpellCooldown(uint32 spellid); bool HasSpellCooldown(uint32 spell_id) const; bool HasCategoryCooldown(uint32 spell_id) const; bool HasSpell(uint32 spellID) const; bool UpdateEntry(uint32 entry, uint32 team = ALLIANCE, const CreatureData* data = NULL, GameEventCreatureData const* eventData = NULL, bool preserveHPAndPower = true); void ApplyGameEventSpells(GameEventCreatureData const* eventData, bool activated); bool UpdateStats(Stats stat); bool UpdateAllStats(); void UpdateResistances(uint32 school); void UpdateArmor(); void UpdateMaxHealth(); void UpdateMaxPower(Powers power); void UpdateAttackPowerAndDamage(bool ranged = false); void UpdateDamagePhysical(WeaponAttackType attType); uint32 GetCurrentEquipmentId() { return m_equipmentId; } float GetSpellDamageMod(int32 Rank); VendorItemData const* GetVendorItems() const; VendorItemData const* GetVendorTemplateItems() const; uint32 GetVendorItemCurrentCount(VendorItem const* vItem); uint32 UpdateVendorItemCurrentCount(VendorItem const* vItem, uint32 used_count); TrainerSpellData const* GetTrainerTemplateSpells() const; TrainerSpellData const* GetTrainerSpells() const; CreatureInfo const *GetCreatureInfo() const { return m_creatureInfo; } CreatureDataAddon const* GetCreatureAddon() const; static uint32 ChooseDisplayId(const CreatureInfo *cinfo, const CreatureData *data = NULL, GameEventCreatureData const* eventData = NULL); std::string GetAIName() const; std::string GetScriptName() const; uint32 GetScriptId() const; // overwrite WorldObject function for proper name localization const char* GetNameForLocaleIdx(int32 locale_idx) const; void SetDeathState(DeathState s); // overwrite virtual Unit::SetDeathState bool FallGround(); bool LoadFromDB(uint32 guid, Map *map); void SaveToDB(); // overwrited in Pet virtual void SaveToDB(uint32 mapid); virtual void DeleteFromDB(); // overwrited in Pet Loot loot; bool lootForPickPocketed; bool lootForBody; bool lootForSkin; void PrepareBodyLootState(); ObjectGuid GetLootRecipientGuid() const { return m_lootRecipientGuid; } uint32 GetLootGroupRecipientId() const { return m_lootGroupRecipientId; } Player* GetLootRecipient() const; // use group cases as prefered Group* GetGroupLootRecipient() const; bool HasLootRecipient() const { return m_lootGroupRecipientId || !m_lootRecipientGuid.IsEmpty(); } bool IsGroupLootRecipient() const { return m_lootGroupRecipientId; } void SetLootRecipient(Unit* unit); void AllLootRemovedFromCorpse(); Player* GetOriginalLootRecipient() const; // ignore group changes/etc, not for looting SpellEntry const *ReachWithSpellAttack(Unit *pVictim); SpellEntry const *ReachWithSpellCure(Unit *pVictim); uint32 m_spells[CREATURE_MAX_SPELLS]; CreatureSpellCooldowns m_CreatureSpellCooldowns; CreatureSpellCooldowns m_CreatureCategoryCooldowns; float GetAttackDistance(Unit const* pl) const; void SendAIReaction(AiReaction reactionType); void DoFleeToGetAssistance(); void CallForHelp(float fRadius); void CallAssistance(); void SetNoCallAssistance(bool val) { m_AlreadyCallAssistance = val; } void SetNoSearchAssistance(bool val) { m_AlreadySearchedAssistance = val; } bool HasSearchedAssistance() { return m_AlreadySearchedAssistance; } bool CanAssistTo(const Unit* u, const Unit* enemy, bool checkfaction = true) const; bool CanInitiateAttack(); MovementGeneratorType GetDefaultMovementType() const { return m_defaultMovementType; } void SetDefaultMovementType(MovementGeneratorType mgt) { m_defaultMovementType = mgt; } // for use only in LoadHelper, Map::Add Map::CreatureCellRelocation Cell const& GetCurrentCell() const { return m_currentCell; } void SetCurrentCell(Cell const& cell) { m_currentCell = cell; } bool IsVisibleInGridForPlayer(Player* pl) const; void RemoveCorpse(); bool IsDeadByDefault() const { return m_isDeadByDefault; }; void ForcedDespawn(uint32 timeMSToDespawn = 0); time_t const& GetRespawnTime() const { return m_respawnTime; } time_t GetRespawnTimeEx() const; void SetRespawnTime(uint32 respawn) { m_respawnTime = respawn ? time(NULL) + respawn : 0; } void Respawn(); void SaveRespawnTime(); uint32 GetRespawnDelay() const { return m_respawnDelay; } void SetRespawnDelay(uint32 delay) { m_respawnDelay = delay; } float GetRespawnRadius() const { return m_respawnradius; } void SetRespawnRadius(float dist) { m_respawnradius = dist; } void StartGroupLoot(Group* group, uint32 timer); void SendZoneUnderAttackMessage(Player* attacker); void SetInCombatWithZone(); Unit* SelectAttackingTarget(AttackingTarget target, uint32 position) const; bool HasQuest(uint32 quest_id) const; bool HasInvolvedQuest(uint32 quest_id) const; GridReference<Creature> &GetGridRef() { return m_gridRef; } bool IsRegeneratingHealth() { return m_regenHealth; } virtual uint8 GetPetAutoSpellSize() const { return CREATURE_MAX_SPELLS; } virtual uint32 GetPetAutoSpellOnPos(uint8 pos) const { if (pos >= CREATURE_MAX_SPELLS || m_charmInfo->GetCharmSpell(pos)->GetType() != ACT_ENABLED) return 0; else return m_charmInfo->GetCharmSpell(pos)->GetAction(); } void SetCombatStartPosition(float x, float y, float z) { CombatStartX = x; CombatStartY = y; CombatStartZ = z; } void GetCombatStartPosition(float &x, float &y, float &z) { x = CombatStartX; y = CombatStartY; z = CombatStartZ; } void SetSummonPoint(float fX, float fY, float fZ, float fOrient) { m_summonXpoint = fX; m_summonYpoint = fY; m_summonZpoint = fZ; m_summonOrientation = fOrient; } void GetSummonPoint(float &fX, float &fY, float &fZ, float &fOrient) const { fX = m_summonXpoint; fY = m_summonYpoint; fZ = m_summonZpoint; fOrient = m_summonOrientation; } void SetDeadByDefault (bool death_state) { m_isDeadByDefault = death_state; } void SetActiveObjectState(bool on); void SetNeedNotify() { m_needNotify = true; } void SendAreaSpiritHealerQueryOpcode(Player *pl); protected: bool CreateFromProto(uint32 guidlow,uint32 Entry,uint32 team, const CreatureData *data = NULL, GameEventCreatureData const* eventData =NULL); bool InitEntry(uint32 entry, uint32 team=ALLIANCE, const CreatureData* data = NULL, GameEventCreatureData const* eventData = NULL); void RelocationNotify(); uint32 m_groupLootTimer; // (msecs)timer used for group loot uint32 m_groupLootId; // used to find group which is looting corpse void StopGroupLoot(); // vendor items VendorItemCounts m_vendorItemCounts; void _RealtimeSetCreatureInfo(); static float _GetHealthMod(int32 Rank); static float _GetDamageMod(int32 Rank); uint32 m_lootMoney; ObjectGuid m_lootRecipientGuid; // player who will have rights for looting if m_lootGroupRecipient==0 or group disbanded uint32 m_lootGroupRecipientId; // group who will have rights for looting if set and exist /// Timers uint32 m_corpseDecayTimer; // (msecs)timer for death or corpse disappearance time_t m_respawnTime; // (secs) time of next respawn uint32 m_respawnDelay; // (secs) delay between corpse disappearance and respawning uint32 m_corpseDelay; // (secs) delay between death and corpse disappearance float m_respawnradius; CreatureSubtype m_subtype; // set in Creatures subclasses for fast it detect without dynamic_cast use void RegenerateMana(); void RegenerateHealth(); MovementGeneratorType m_defaultMovementType; Cell m_currentCell; // store current cell where creature listed uint32 m_DBTableGuid; ///< For new or temporary creatures is 0 for saved it is lowguid uint32 m_equipmentId; bool m_AlreadyCallAssistance; bool m_AlreadySearchedAssistance; bool m_regenHealth; bool m_AI_locked; bool m_isDeadByDefault; bool m_needNotify; SpellSchoolMask m_meleeDamageSchoolMask; uint32 m_originalEntry; float CombatStartX; float CombatStartY; float CombatStartZ; float m_summonXpoint; float m_summonYpoint; float m_summonZpoint; float m_summonOrientation; private: GridReference<Creature> m_gridRef; CreatureInfo const* m_creatureInfo; SplineFlags m_splineFlags; }; class AssistDelayEvent : public BasicEvent { public: AssistDelayEvent(ObjectGuid victim, Unit& owner, std::list<Creature*> const& assistants); bool Execute(uint64 e_time, uint32 p_time); private: AssistDelayEvent(); ObjectGuid m_victimGuid; std::vector<ObjectGuid> m_assistantGuids; Unit& m_owner; }; class ForcedDespawnDelayEvent : public BasicEvent { public: ForcedDespawnDelayEvent(Creature& owner) : BasicEvent(), m_owner(owner) { } bool Execute(uint64 e_time, uint32 p_time); private: Creature& m_owner; }; #endif
FoOtY/ClassyWoW
src/game/Creature.h
C
gpl-2.0
26,448
/*! * Grunt file * * @package CheckUser */ /* eslint-env node */ module.exports = function ( grunt ) { var conf = grunt.file.readJSON( 'extension.json' ); grunt.loadNpmTasks( 'grunt-eslint' ); grunt.loadNpmTasks( 'grunt-banana-checker' ); grunt.loadNpmTasks( 'grunt-stylelint' ); grunt.initConfig( { eslint: { options: { cache: true }, all: [ '*.{js,json}', 'modules/**/*.{js,json}' ] }, stylelint: { all: [ 'modules/**/*.{css,less}' ] }, banana: conf.MessagesDirs } ); grunt.registerTask( 'test', [ 'eslint', 'banana', 'stylelint' ] ); grunt.registerTask( 'default', 'test' ); };
skizzerz/thetestwiki-checkuser
Gruntfile.js
JavaScript
gpl-2.0
640
<?php /** * @file * Contains the SearchApiAutocompleteSearch class. */ /** * Class describing the settings for a certain search for which autocompletion * is available. */ class SearchApiAutocompleteSearch extends Entity { // Entity properties, loaded from the database: /** * @var integer */ public $id; /** * @var string */ public $machine_name; /** * @var string */ public $name; /** * @var integer */ public $index_id; /** * @var string */ public $type; /** * @var boolean */ public $enabled; /** * An array of options for this search, containing any of the following: * - results: Boolean indicating whether to also list the estimated number of * results for each suggestion (if possible). * - custom: An array of type-specific settings. * * @var array */ public $options = array(); // Inferred properties, for caching: /** * @var SearchApiIndex */ protected $index; /** * @var SearchApiServer */ protected $server; /** * Constructor. * * @param array $values * The entity properties. */ public function __construct(array $values = array()) { parent::__construct($values, 'search_api_autocomplete_search'); } /** * @return SearchApiIndex * The index this search belongs to. */ public function index() { if (!isset($this->index)) { $this->index = search_api_index_load($this->index_id); if (!$this->index) { $this->index = FALSE; } } return $this->index; } /** * @return SearchApiServer * The server this search would at the moment be executed on. */ public function server() { if (!isset($this->server)) { if (!$this->index() || !$this->index()->server) { $this->server = FALSE; } else { $this->server = $this->index()->server(); if (!$this->server) { $this->server = FALSE; } } } return $this->server; } /** * @return boolean * TRUE if the server this search is currently associated with supports the * autocompletion feature; FALSE otherwise. */ public function supportsAutocompletion() { return $this->server() && $this->server()->supportsFeature('search_api_autocomplete'); } /** * Helper method for altering a textfield form element to use autocompletion. */ public function alterElement(array &$element) { if (user_access('use search_api_autocomplete') && $this->supportsAutocompletion()) { $element['#attached']['css'][] = drupal_get_path('module', 'search_api_autocomplete') . '/search_api_autocomplete.css'; $element['#autocomplete_path'] = 'search_api_autocomplete/' . $this->machine_name; } } /** * Split a string with search keywords into two parts. * * The first part consists of all words the user has typed completely, the * second one contains the beginning of the last, possibly incomplete word. * * @return array * An array with $keys split into exactly two parts, both of which may be * empty. */ public function splitKeys($keys) { $keys = ltrim($keys); // If there is whitespace or a quote on the right, all words have been // completed. if (rtrim($keys, " \t\n\r\0\x0B\"") != $keys) { return array(rtrim($keys), ''); } if (preg_match('/^(.*?)\s*"?([\S]*)$/', $keys, $m)) { return array($m[1], $m[2]); } return array('', $keys); } /** * Create the query that would be issued for this search for the complete keys. * * @param $complete * A string containing the complete search keys. * @param $incomplete * A string containing the incomplete last search key. * * @return SearchApiQueryInterface * The query that would normally be executed when only $complete was entered * as the search keys for this search. */ public function getQuery($complete, $incomplete) { $info = search_api_autocomplete_get_types($this->type); if (empty($info['create query'])) { return NULL; } $query = $info['create query']($this, $complete, $incomplete); if ($complete && !$query->getKeys()) { $query->keys($complete); } return $query; } }
switch13/tonys-rest
sites/all/modules/search_api_autocomplete/search_api_autocomplete.entity.php
PHP
gpl-2.0
4,284
# -*- coding: utf-8 -*- __author__ = 'shreejoy' import unittest from article_text_mining.rep_html_table_struct import rep_html_table_struct class RepTableStructureTest(unittest.TestCase): @property def load_html_table_simple(self): # creates data table object 16055 with some dummy data with open('tests/test_html_data_tables/example_html_table_simple.html', mode='rb') as f: simple_table_text = f.read() return simple_table_text @property def load_html_table_complex(self): with open('tests/test_html_data_tables/example_html_table_complex.html', mode='rb') as f: complex_table_text = f.read() return complex_table_text def test_rep_html_table_struct_simple(self): expected_table_output = [['th-1', 'th-2', 'th-3', 'th-4', 'th-5', 'th-6'], ['td-1', 'td-1', 'td-1', 'td-1', 'td-1', 'td-1'], ['td-2', 'td-3', 'td-4', 'td-5', 'td-6', 'td-7'], ['td-8', 'td-9', 'td-10', 'td-11', 'td-12', 'td-13'], ['td-14', 'td-15', 'td-16', 'td-17', 'td-18', 'td-19'], ['td-20', 'td-21', 'td-22', 'td-23', 'td-24', 'td-25'], ['td-26', 'td-27', 'td-28', 'td-29', 'td-30', 'td-31'], ['td-32', 'td-33', 'td-34', 'td-35', 'td-36', 'td-37'], ['td-38', 'td-39', 'td-40', 'td-41', 'td-42', 'td-43'], ['td-44', 'td-45', 'td-46', 'td-47', 'td-48', 'td-49'], ['td-50', 'td-51', 'td-52', 'td-53', 'td-54', 'td-55'], ['td-56', 'td-57', 'td-58', 'td-59', 'td-60', 'td-61'], ['td-62', 'td-63', 'td-64', 'td-65', 'td-66', 'td-67'], ['td-68', 'td-69', 'td-70', 'td-71', 'td-72', 'td-73'], ['td-74', 'td-75', 'td-76', 'td-77', 'td-78', 'td-79'], ['td-80', 'td-81', 'td-82', 'td-83', 'td-84', 'td-85'], ['td-86', 'td-87', 'td-88', 'td-89', 'td-90', 'td-91'], ['td-92', 'td-93', 'td-94', 'td-95', 'td-96', 'td-97'], ['td-98', 'td-99', 'td-100', 'td-101', 'td-102', 'td-103'], ['td-104', 'td-105', 'td-106', 'td-107', 'td-108', 'td-109']] html_table_text = self.load_html_table_simple a, b, html_id_table = rep_html_table_struct(html_table_text) self.assertEqual(html_id_table, expected_table_output) def test_rep_html_table_struct_complex(self): expected_table_output = [['td-1', 0, 0, 0, 0, 0, 0, 0, 0, 0], ['td-2', 'td-2', 'td-2', 'td-2', 'td-2', 'td-2', 'td-2', 'td-2', 'td-2', 'td-2'], ['td-3', 'td-4', 'td-4', 'td-5', 'td-5', 'td-6', 'td-6', 0, 0, 0], ['td-3', 'td-7', 'td-8', 'td-9', 'td-10', 'td-11', 'td-12', 0, 0, 0], ['td-13', 'td-13', 'td-13', 'td-13', 'td-13', 'td-13', 'td-13', 'td-13', 'td-13', 'td-13'], ['td-14', 'td-15', 'td-16', 'td-17', 'td-18', 'td-19', 'td-20', 0, 0, 0], ['td-21', 'td-22', 'td-23', 'td-24', 'td-25', 'td-26', 'td-27', 0, 0, 0], ['td-28', 'td-29', 'td-30', 'td-31', 'td-32', 'td-33', 'td-34', 0, 0, 0], ['td-35', 'td-36', 'td-37', 'td-38', 'td-39', 'td-40', 'td-41', 0, 0, 0], ['td-42', 'td-43', 'td-44', 'td-45', 'td-46', 'td-47', 'td-48', 0, 0, 0], ['td-49', 'td-50', 'td-51', 'td-52', 'td-53', 'td-54', 'td-55', 0, 0, 0], ['td-56', 'td-57', 'td-58', 'td-59', 'td-60', 'td-61', 'td-62', 0, 0, 0], ['td-63', 'td-64', 'td-65', 'td-66', 'td-67', 'td-68', 'td-69', 0, 0, 0], ['td-70', 'td-71', 'td-72', 'td-73', 'td-74', 'td-75', 'td-76', 0, 0, 0], ['td-77', 'td-78', 'td-79', 'td-80', 'td-81', 'td-82', 'td-83', 0, 0, 0]] html_table_text = self.load_html_table_complex a, b, html_id_table = rep_html_table_struct(html_table_text) self.assertEqual(html_id_table, expected_table_output) if __name__ == '__main__': unittest.main()
neuroelectro/neuroelectro_org
tests/test_rep_html_table_struct.py
Python
gpl-2.0
4,596
/**************************************************************************** * MeshLab o o * * An extendible mesh processor o o * * _ O _ * * Copyright(C) 2005, 2009 \/)\/ * * Visual Computing Lab /\/| * * ISTI - Italian National Research Council | * * \ * * 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 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 (http://www.gnu.org/licenses/gpl.txt) * * for more details. * * * ****************************************************************************/ /* A class implementing Meshlab's Edit interface that is for picking points in 3D * * * @author Oscar Barney */ #include <QtGui> #include <GL/glew.h> #include "editpickpoints.h" #include <meshlab/mainwindow.h> #include <wrap/gl/picking.h> #include <wrap/gl/pick.h> #include <wrap/qt/gl_label.h> #include <math.h> using namespace vcg; #define PI 3.14159265 EditPickPointsPlugin::EditPickPointsPlugin() { //initialize to false so we dont end up collection some weird point in the beginning registerPoint = false; moveSelectPoint = false; pickPointsDialog = 0; currentModel = 0; overrideCursorShape = 0; } //Constants const QString EditPickPointsPlugin::Info() { return tr("Pick and save 3D points on the mesh"); } //called void EditPickPointsPlugin::Decorate(MeshModel &mm, GLArea *gla, QPainter *painter) { //qDebug() << "Decorate " << mm.fileName.c_str() << " ..." << mm.cm.fn; if(gla != glArea || mm.cm.fn < 1) { //qDebug() << "GLarea is different or no faces!!! "; return; } //make sure we picking points on the right meshes! if(&mm != currentModel){ //now that were are ending tell the dialog to save any points it has to metadata pickPointsDialog->savePointsToMetaData(); //set the new mesh model pickPointsDialog->setCurrentMeshModel(&mm, gla); currentModel = &mm; } //We have to calculate the position here because it doesnt work in the mouseEvent functions for some reason Point3f pickedPoint; if (moveSelectPoint && Pick<Point3f>(currentMousePosition.x(),gla->height()-currentMousePosition.y(),pickedPoint)){ /* qDebug("Found point for move %i %i -> %f %f %f", currentMousePosition.x(), currentMousePosition.y(), pickedPoint[0], pickedPoint[1], pickedPoint[2]); */ //let the dialog know that this was the pointed picked incase it wants the information pickPointsDialog->selectOrMoveThisPoint(pickedPoint); moveSelectPoint = false; } else if(registerPoint && Pick<Point3f>(currentMousePosition.x(),gla->height()-currentMousePosition.y(),pickedPoint)) { /* qDebug("Found point for add %i %i -> %f %f %f", currentMousePosition.x(), currentMousePosition.y(), pickedPoint[0], pickedPoint[1], pickedPoint[2]); */ //find the normal of the face we just clicked CFaceO *face; bool result = GLPickTri<CMeshO>::PickNearestFace(currentMousePosition.x(),gla->height()-currentMousePosition.y(), mm.cm, face); if(!result){ qDebug() << "find nearest face failed!"; } else { CFaceO::NormalType faceNormal = face->N(); //qDebug() << "found face normal: " << faceNormal[0] << faceNormal[1] << faceNormal[2]; //if we didnt find a face then dont add the point because the user was probably //clicking on another mesh opened inside the glarea pickPointsDialog->addMoveSelectPoint(pickedPoint, faceNormal); } registerPoint = false; } drawPickedPoints(pickPointsDialog->getPickedPointTreeWidgetItemVector(), mm.cm.bbox, painter); } bool EditPickPointsPlugin::StartEdit(MeshModel &mm, GLArea *gla ) { //qDebug() << "StartEdit Pick Points: " << mm.fileName.c_str() << " ..." << mm.cm.fn; //if there are no faces then we cant do anything with this plugin if(mm.cm.fn < 1) { if(NULL != pickPointsDialog) { pickPointsDialog->hide(); } //show message QMessageBox::warning(gla->window(), "Edit Pick Points", "Sorry, this mesh has no faces on which picked points can sit.", QMessageBox::Ok, QMessageBox::Ok); return false; } //get the cursor QCursor *cursor = QApplication::overrideCursor(); if(cursor) overrideCursorShape = cursor->shape(); else overrideCursorShape = Qt::ArrowCursor; //set this so redraw can use it glArea = gla; //Create GUI window if we dont already have one if(pickPointsDialog == 0) { pickPointsDialog = new PickPointsDialog(this, gla->window()); } currentModel = &mm; //set the current mesh pickPointsDialog->setCurrentMeshModel(&mm, gla); //show the dialog pickPointsDialog->show(); return true; } void EditPickPointsPlugin::EndEdit(MeshModel &mm, GLArea *gla) { //qDebug() << "EndEdit Pick Points: " << mm.fileName.c_str() << " ..." << mm.cm.fn; // some cleaning at the end. if(mm.cm.fn > 0) { assert(pickPointsDialog); //now that were are ending tell the dialog to save any points it has to metadata pickPointsDialog->savePointsToMetaData(); //remove the dialog from the screen pickPointsDialog->hide(); QApplication::setOverrideCursor( QCursor((Qt::CursorShape)overrideCursorShape) ); this->glArea = 0; } } void EditPickPointsPlugin::mousePressEvent(QMouseEvent *event, MeshModel &mm, GLArea *gla ) { //qDebug() << "mouse press Pick Points: " << mm.fileName.c_str() << " ..."; //if there are no faces then we cant do anything with this plugin if(mm.cm.fn < 1) return; if(Qt::LeftButton | event->buttons()) { gla->suspendedEditor = true; QCoreApplication::sendEvent(gla, event); gla->suspendedEditor = false; } if(Qt::RightButton == event->button() && pickPointsDialog->getMode() != PickPointsDialog::ADD_POINT){ currentMousePosition = event->pos(); pickPointsDialog->recordNextPointForUndo(); //set flag that we need to add a new point moveSelectPoint = true; } } void EditPickPointsPlugin::mouseMoveEvent(QMouseEvent *event, MeshModel &mm, GLArea *gla ) { //qDebug() << "mousemove pick Points: " << mm.fileName.c_str() << " ..."; //if there are no faces then we cant do anything with this plugin if(mm.cm.fn < 1) return; if(Qt::LeftButton | event->buttons()) { gla->suspendedEditor = true; QCoreApplication::sendEvent(gla, event); gla->suspendedEditor = false; } if(Qt::RightButton & event->buttons() && pickPointsDialog->getMode() != PickPointsDialog::ADD_POINT){ //qDebug() << "mouse move left button and move mode: "; currentMousePosition = event->pos(); //set flag that we need to add a new point registerPoint = true; } } void EditPickPointsPlugin::mouseReleaseEvent(QMouseEvent *event, MeshModel &mm, GLArea * gla) { //qDebug() << "mouseRelease Pick Points: " << mm.fileName.c_str() << " ..."; //if there are no faces then we cant do anything with this plugin if(mm.cm.fn < 1) return; if(Qt::LeftButton | event->buttons()) { gla->suspendedEditor = true; QCoreApplication::sendEvent(gla, event); gla->suspendedEditor = false; } //only add points for the left button if(Qt::RightButton == event->button()){ currentMousePosition = event->pos(); //set flag that we need to add a new point registerPoint = true; } } void EditPickPointsPlugin::drawPickedPoints( std::vector<PickedPointTreeWidgetItem*> &pointVector, vcg::Box3f &boundingBox, QPainter *painter) { assert(glArea); vcg::Point3f size = boundingBox.Dim(); //how we scale the object indicating the normal at each selected point float scaleFactor = (size[0]+size[1]+size[2])/90.0; //qDebug() << "scaleFactor: " << scaleFactor; glPushAttrib(GL_ALL_ATTRIB_BITS); // enable color tracking glEnable(GL_COLOR_MATERIAL); //draw the things that we always want to show, like the names glDepthFunc(GL_ALWAYS); glDisable(GL_DEPTH_TEST); glDepthMask(GL_FALSE); //set point attributes glPointSize(4.5); bool showNormal = pickPointsDialog->showNormal(); bool showPin = pickPointsDialog->drawNormalAsPin(); for(int i = 0; i < pointVector.size(); ++i) { PickedPointTreeWidgetItem * item = pointVector[i]; //if the point has been set (it may not be if a template has been loaded) if(item->isActive()){ Point3f point = item->getPoint(); glColor(Color4b::Blue); glLabel::render(painter,point, QString(item->getName())); //draw the dot if we arnt showing the normal or showing the normal as a line if(!showNormal || !showPin) { if(item->isSelected() ) glColor(Color4b::Green); glBegin(GL_POINTS); glVertex(point); glEnd(); } } } //now draw the things that we want drawn if they are not ocluded //we can see in bright red glDepthFunc(GL_LESS); glEnable(GL_DEPTH_TEST); glDepthMask(GL_TRUE); glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glMatrixMode(GL_MODELVIEW); Point3f yaxis; yaxis[0] = 0; yaxis[1] = 1; yaxis[2] = 0; for(int i = 0; i < pointVector.size(); ++i) { PickedPointTreeWidgetItem * item = pointVector[i]; //if the point has been set (it may not be if a template has been loaded) if(item->isActive()){ Point3f point = item->getPoint(); if(showNormal) { Point3f normal = item->getNormal(); if(showPin) { //dot product float angle = (Angle(normal,yaxis) * 180.0 / PI); //cross product Point3f axis = yaxis^normal; //qDebug() << "angle: " << angle << " x" << axis[0] << " y" << axis[1] << " z" << axis[2]; //bluegreen and a little clear glColor4f(0.0f, 1.0f, 0.0f, 0.7f); //glColor(Color4b::Green); glPushMatrix(); //move the pin to where it needs to be glTranslatef(point[0], point[1], point[2]); glRotatef(angle, axis[0], axis[1], axis[2]); glScalef(0.2*scaleFactor, 1.5*scaleFactor, 0.2*scaleFactor); glBegin(GL_TRIANGLES); //front glNormal3f(0, -1, 1); glVertex3f(0,0,0); glVertex3f(1,1,1); glVertex3f(-1,1,1); //right glNormal3f(1, -1, 0); glVertex3f(0,0,0); glVertex3f(1,1,-1); glVertex3f(1,1,1); //left glNormal3f(-1, -1, 0); glVertex3f(0,0,0); glVertex3f(-1,1,1); glVertex3f(-1,1,-1); //back glNormal3f(0, -1, -1); glVertex3f(0,0,0); glVertex3f(-1,1,-1); glVertex3f(1,1,-1); //top //if it is selected color it green if(item->isSelected() ) glColor4f(0.0f, 0.0f, 1.0f, 0.7f); glNormal3f(0, 1, 0); glVertex3f(1,1,1); glVertex3f(1,1,-1); glVertex3f(-1,1,-1); glNormal3f(0, 1, 0); glVertex3f(1,1,1); glVertex3f(-1,1,-1); glVertex3f(-1,1,1); //change back if(item->isSelected() ) glColor4f(0.0f, 1.0f, 0.0f, 0.7f); glEnd(); glPopMatrix(); } else { glColor(Color4b::Green); glBegin(GL_LINES); glVertex(point); glVertex(point+(normal*scaleFactor)); glEnd(); } } glColor(Color4b::Red); glArea->renderText(point[0], point[1], point[2], QString(item->getName()) ); } } glDisable(GL_BLEND); glDisable(GL_COLOR_MATERIAL); glDisable(GL_DEPTH_TEST); glPopAttrib(); }
guerrerocarlos/meshlab
src/plugins/edit_pickpoints/editpickpoints.cpp
C++
gpl-2.0
12,813
""" AUTHOR: Dr. Andrew David Burbanks, 2005. This software is Copyright (C) 2004-2008 Bristol University and is released under the GNU General Public License version 2. MODULE: SystemBath PURPOSE: Used to generate System Bath Hamiltonian, given number of bath modes. NOTES: The system defined by the Hamiltonian is (2n+2)-dimensional, and is ordered (s, p_s, x, p_x, y, p_y, ...). There is no need for Taylor expansion, as we have the Hamiltonian in explicit polynomial form. """ from math import * from random import * from Polynomial import * from LieAlgebra import LieAlgebra class SystemBath: """ The original (_not_ mass-weighted) system bath. The system-bath model represents a 'system' part: a symmetric quartic double-well potential, coupled to a number of 'bath modes': harmonic oscillators. The coupling is achieved via a bilinear coupling between the configuration space coordinate of the system and the conjugate momenta of each of the bath modes. The resulting Hamiltonian is a polynomial of degree 4 in the phase space coordinates. With this version, the client must specify all of the following:- @param n_bath_modes: (non-negative int). @param system_mass: (positive real). @param imag_harmonic_frequency_at_barrier: (real; imag part of pure imag). @param reciprocal_barrier_height_above_well_bottom: (positive real). @param bath_masses: (seq of n_bath_modes positive reals). @param bath_frequencies: (seq of n_bath_modes reals). @param bath_coupling_constants: (seq of n_bath_modes reals). """ def __init__(self, n_bath_modes, system_mass, imag_harmonic_frequency_at_barrier, reciprocal_barrier_height_above_well_bottom, bath_masses, bath_frequencies, bath_coupling_constants): assert n_bath_modes>=0 assert system_mass >= 0.0 assert abs(imag_harmonic_frequency_at_barrier) > 0.0 assert reciprocal_barrier_height_above_well_bottom >= 0.0 assert len(bath_masses) == n_bath_modes assert len(bath_frequencies) == n_bath_modes assert len(bath_coupling_constants) == n_bath_modes for f, g in zip(bath_frequencies[:-1], bath_frequencies[1:]): assert f < g self._m_s = system_mass #system mass self._omega_b = imag_harmonic_frequency_at_barrier self._v_0_sh = reciprocal_barrier_height_above_well_bottom self._n = n_bath_modes self._c = bath_coupling_constants #to the system s coordinate. self._w = bath_frequencies self._m = bath_masses self._lie = LieAlgebra(n_bath_modes+1) #$a = (-1/2)m_s\omega_b^2.$ self._a = -0.5*self._m_s*(self._omega_b**2) #$b = \frac{m_s^2\omega_b^4}{16V_0}.$ self._b = ((self._m_s**2) * (self._omega_b**4))/(16.0*self._v_0_sh) def lie_algebra(self): """ Return the Lie algebra on which the polynomials will be constructed. For N bath modes, this has (N+1)-dof. """ return self._lie def hamiltonian_real(self): """ Calculate the real Hamiltonian for the system-bath model. """ #Establish some convenient notation: n = self._n a = self._a b = self._b m_s = self._m_s c = self._c w = self._w m = self._m q_s = self._lie.q(0) p_s = self._lie.p(0) #Compute some constants: coeff_q_s = a for i in xrange(0, len(c)): coeff_q_s += (c[i]**2.0)/(2.0 * m[i] * (w[i]**2.0)) coeff_p_s = 1.0/(2.0 * m_s) coeff_q_bath = [] coeff_p_bath = [] for i in xrange(0, len(c)): coeff_q_bath.append(0.5 * m[i] * (w[i]**2.0)) coeff_p_bath.append(1.0/(2.0 * m[i])) #Sanity checks: assert n >= 0, 'Need zero or more bath modes.' assert len(c) == n, 'Need a coupling constant for each bath mode.' assert len(coeff_q_bath) == n, 'Need constant for each bath config.' assert len(coeff_p_bath) == n, 'Need constant for each bath momentum.' #System part: h_system = coeff_p_s * (p_s**2) h_system += coeff_q_s * (q_s**2) h_system += b * (q_s**4) #Bath part: h_bath = self._lie.zero() for i in xrange(len(c)): bath_dof = i+1 h_bath += coeff_q_bath[i] * (self._lie.q(bath_dof)**2) h_bath += coeff_p_bath[i] * (self._lie.p(bath_dof)**2) #Coupling part: h_coupling = self._lie.zero() for i, c_i in enumerate(c): bath_dof = i+1 h_coupling += -c_i * (self._lie.q(bath_dof) * q_s) #Complete Hamiltonian: h = h_system + h_bath + h_coupling #Sanity checks: assert h.degree() == 4 assert h.n_vars() == 2*n+2 assert len(h) == (3) + (2*n) + (n) #system+bath+coupling return h class MassWeightedSystemBath: """ The system-bath model represents a 'system' part (a symmetric quartic double-well potential) coupled to a number of 'bath modes' (harmonic oscillators). The coupling is achieved via a bilinear coupling between the configuration space coordinate of the system and the conjugate momenta of each of the bath modes. The resulting Hamiltonian is a polynomial of degree 4 in the phase space coordinates. """ def __init__(self, n_bath_modes, imag_harmonic_frequency_at_barrier, reciprocal_barrier_height_above_well_bottom, damping_strength, bath_cutoff_frequency, bath_masses, bath_frequencies, bath_compound_coupling_constants): """ Construct a mass-weighted system bath given the values of the parameters and the compound coupling constants. @param n_bath_modes: (non-negative int). @param imag_harmonic_frequency_at_barrier: (real; im part of pure im). @param reciprocal_barrier_height_above_well_bottom: (positive real). @param damping_strength: (real). @param bath_cutoff_frequency: (real, <<bath_frequencies[-1]). @param bath_masses: (seq of n_bath_modes positive reals). @param bath_frequencies: (increasing seq of n_bath_modes reals). @param bath_compound_coupling_constants: (seq of n_bath_modes reals). """ #check inputs assert n_bath_modes>=0 assert abs(imag_harmonic_frequency_at_barrier) > 0.0 assert reciprocal_barrier_height_above_well_bottom >= 0.0 assert len(bath_masses) == n_bath_modes assert len(bath_frequencies) == n_bath_modes assert len(bath_compound_coupling_constants) == n_bath_modes #ensure that the bath frequencies are increasing for f, g in zip(bath_frequencies[:-1], bath_frequencies[1:]): assert f < g #store member variables self._n = n_bath_modes self._omega_b = imag_harmonic_frequency_at_barrier self._v_0_sh = reciprocal_barrier_height_above_well_bottom self._eta = damping_strength self._omega_c = bath_cutoff_frequency self._c_star = bath_compound_coupling_constants #to system coord self._w = bath_omegas self._lie = LieAlgebra(n_bath_modes+1) def compute_compound_constants(n_bath_modes, damping_strength, bath_cutoff_frequency, bath_frequencies): """ Compute the compound coupling constants. @param n_bath_modes: (non-negative int). @param damping_strength: (real). @param bath_cutoff_frequency: (real, <<bath_frequencies[-1]). @param bath_frequencies: (seq of n_bath_modes reals increasing). @return: bath_compound_coupling_constants (seq of n_bath_modes reals). """ #check inputs assert n_bath_modes>=0 assert len(bath_frequencies) == n_bath_modes for f, g in zip(bath_frequencies[:-1], bath_frequencies[1:]): assert f < g assert bath_frequencies[-1] > bath_cutoff_frequency #accumulate compound frequencies c_star = [] omega_c = bath_cutoff_frequency eta = damping_strength for jm1, omega_j in enumerate(bath_frequencies): c = (-2.0/(pi*(jm1+1.0)))*eta*omega_c d = ((omega_j+omega_c)*exp(-omega_j/omega_c) - omega_c) c_star.append(c*d) return c_star compute_compound_constants = staticmethod(compute_compound_constants) def bath_spectral_density_function(self, omega): """ The bath is defined in terms of a continuous spectral density function, which has the Ohmic form with an exponential cutoff. For infinite bath cutoff frequency, $\omega_c$, the bath is strictly Ohmic, i.e., the friction kernel becomes a delta function in the time domain, and the classical dynamics of the system coordinate are described by the ordinary Langevin equation. In that case, $eta$ (the damping strength) is the classically measurable friction coefficient. However, for finite values of the bath cutoff frequency, the friction kernel is nonlocal, which introduces memory effects into the Generalized Langevin Equation (GLE). """ return self.eta * omega * exp(-omega/self._omega_c) def hamiltonian_real(self): """ Calculate the real Hamiltonian for the system-bath model. """ #establish some convenient notation: n = self._n w = self._w c_star = self._c_star #sanity checks: assert n >= 0, 'Need zero or more bath modes.' assert len(c_star) == n, 'Need a coupling constant for each bath mode.' #system coefficients: a = -0.5*(self._omega_b**2) b = (self._omega_b**4)/(16.0*self._v_0_sh) coeff_q_s = a for i in xrange(0, len(c_star)): coeff_q_s += c_star[i]/(2.0 * (w[i])) coeff_p_s = 1.0/2.0 #system part: q_s = self._lie.q(0) p_s = self._lie.p(0) h_system = coeff_p_s * (p_s**2) h_system += coeff_q_s * (q_s**2) h_system += b * (q_s**4) #bath coefficients: coeff_q_bath = [] coeff_p_bath = [] for i in xrange(0, len(c_star)): coeff_q_bath.append(0.5 * (w[i]**2.0)) coeff_p_bath.append(1.0/2.0) #sanity checks: assert len(coeff_q_bath) == n, 'Need constant for each bath config.' assert len(coeff_p_bath) == n, 'Need constant for each bath momentum.' #bath part: h_bath = self._lie.zero() for i in xrange(len(c_star)): bath_dof = i+1 h_bath += coeff_q_bath[i] * (self._lie.q(bath_dof)**2) h_bath += coeff_p_bath[i] * (self._lie.p(bath_dof)**2) #coupling part: h_coupling = self._lie.zero() for i, c_i in enumerate(c_star): bath_dof = i+1 h_coupling += -sqrt(c_i*w[i]) * (self._lie.q(bath_dof)*q_s) #complete Hamiltonian: h = h_system + h_bath + h_coupling #sanity checks: assert h.degree() == 4 assert h.n_vars() == 2*n+2 assert len(h) == (3) + (2*n) + (n) #system+bath+coupling return h def new_random_system_bath(n_bath_modes, system_mass, imag_harmonic_frequency_at_barrier, reciprocal_barrier_height_above_well_bottom, random_seed): #check inputs assert n_bath_modes >= 0 assert system_mass >= 0.0 #unitialize random number generator seed(random_seed) #generate parameters bath_masses = [] bath_omegas = [] bath_coupling_constants = [] for i in xrange(0, n_bath_modes): bath_coupling_constants.append(uniform(0.001, 0.5)) bath_masses.append(uniform(0.5, 3.6)) bath_omegas.append(gauss(0.0, 2.0)) #sort frequencies into increasing order bath_omegas.sort() #instantiate the system bath sb = SystemBath(n_bath_modes, system_mass, imag_harmonic_frequency_at_barrier, reciprocal_barrier_height_above_well_bottom, bath_masses, bath_omegas, bath_coupling_constants) return sb
Peter-Collins/NormalForm
src/py/SystemBath.py
Python
gpl-2.0
12,748
#ifndef UNDO_EFFECT_REORDER_H #define UNDO_EFFECT_REORDER_H #include "undo.h" #include "timeline.h" #include "engine/clip.h" class UndoEffectReorder : public QUndoCommand { public: UndoEffectReorder(Timeline *t, Clip *c, int track, int oldId, int newId, bool isVideo) { clip = c; timeline = t; video = isVideo; oldIndex = oldId; newIndex = newId; trackNumber = track; setText(QObject::tr("Reorder effect")); } void redo() { timeline->commandEffectReorder(clip, trackNumber, oldIndex, newIndex, video); } void undo() { timeline->commandEffectReorder(clip, trackNumber, newIndex, oldIndex, video); } private: Clip *clip; Timeline *timeline; bool video; int oldIndex, newIndex; int trackNumber; }; #endif // UNDO_EFFECT_REORDER_H
hftom/MachinTruc
app/timeline/undoeffectreorder.h
C
gpl-2.0
768
/* * Copyright 2004-2007 Freescale Semiconductor, Inc. All Rights Reserved. */ /* * The code contained herein is licensed under the GNU General Public * License. You may obtain a copy of the GNU General Public License * Version 2 or later at the following locations: * * http://www.opensource.org/licenses/gpl-license.html * http://www.gnu.org/copyleft/gpl.html */ #ifndef __ARCH_ARM_MACH_MX2_CRM_REGS_H__ #define __ARCH_ARM_MACH_MX2_CRM_REGS_H__ #include <asm/arch/hardware.h> /* Register offsets */ #define CCM_CSCR (IO_ADDRESS(CCM_BASE_ADDR) + 0x0) #define CCM_MPCTL0 (IO_ADDRESS(CCM_BASE_ADDR) + 0x4) #define CCM_MPCTL1 (IO_ADDRESS(CCM_BASE_ADDR) + 0x8) #define CCM_SPCTL0 (IO_ADDRESS(CCM_BASE_ADDR) + 0xC) #define CCM_SPCTL1 (IO_ADDRESS(CCM_BASE_ADDR) + 0x10) #define CCM_OSC26MCTL (IO_ADDRESS(CCM_BASE_ADDR) + 0x14) #define CCM_PCDR0 (IO_ADDRESS(CCM_BASE_ADDR) + 0x18) #define CCM_PCDR1 (IO_ADDRESS(CCM_BASE_ADDR) + 0x1c) #define CCM_PCCR0 (IO_ADDRESS(CCM_BASE_ADDR) + 0x20) #define CCM_PCCR1 (IO_ADDRESS(CCM_BASE_ADDR) + 0x24) #define CCM_CCSR (IO_ADDRESS(CCM_BASE_ADDR) + 0x28) #define CCM_PMCTL (IO_ADDRESS(CCM_BASE_ADDR) + 0x2c) #define CCM_PMCOUNT (IO_ADDRESS(CCM_BASE_ADDR) + 0x30) #define CCM_WKGDCTL (IO_ADDRESS(CCM_BASE_ADDR) + 0x34) #define CCM_CSCR_USB_OFFSET 28 #define CCM_CSCR_USB_MASK (0x7 << 28) #define CCM_CSCR_SD_OFFSET 24 #define CCM_CSCR_SD_MASK (0x3 << 24) #define CCM_CSCR_SSI2 (1 << 23) #define CCM_CSCR_SSI2_OFFSET 23 #define CCM_CSCR_SSI1 (1 << 22) #define CCM_CSCR_SSI1_OFFSET 22 #define CCM_CSCR_VPU (1 << 21) #define CCM_CSCR_VPU_OFFSET 21 #define CCM_CSCR_MSHC (1 << 20) #define CCM_CSCR_SPLLRES (1 << 19) #define CCM_CSCR_MPLLRES (1 << 18) #define CCM_CSCR_SP (1 << 17) #define CCM_CSCR_MCU (1 << 16) #define CCM_CSCR_ARM_SRC (1 << 15) #define CCM_CSCR_ARM_OFFSET 12 #define CCM_CSCR_ARM_MASK (0x3 << 12) #define CCM_CSCR_PRESC_OFFSET 13 #define CCM_CSCR_PRESC_MASK (0x7 << 13) #define CCM_CSCR_BCLK_OFFSET 9 #define CCM_CSCR_BCLK_MASK (0xf << 9) #define CCM_CSCR_IPDIV_OFFSET 8 #define CCM_CSCR_IPDIV (1 << 8) #define CCM_CSCR_AHB_OFFSET 8 #define CCM_CSCR_AHB_MASK (0x3 << 8) #define CCM_CSCR_OSC26MDIV (1 << 4) #define CCM_CSCR_OSC26M (1 << 3) #define CCM_CSCR_FPM (1 << 2) #define CCM_CSCR_SPEN (1 << 1) #define CCM_CSCR_MPEN 1 #define CCM_MPCTL0_CPLM (1 << 31) #define CCM_MPCTL0_PD_OFFSET 26 #define CCM_MPCTL0_PD_MASK (0xf << 26) #define CCM_MPCTL0_MFD_OFFSET 16 #define CCM_MPCTL0_MFD_MASK (0x3ff << 16) #define CCM_MPCTL0_MFI_OFFSET 10 #define CCM_MPCTL0_MFI_MASK (0xf << 10) #define CCM_MPCTL0_MFN_OFFSET 0 #define CCM_MPCTL0_MFN_MASK 0x3ff #define CCM_MPCTL1_LF (1 << 15) #define CCM_MPCTL1_BRMO (1 << 6) #define CCM_SPCTL0_CPLM (1 << 31) #define CCM_SPCTL0_PD_OFFSET 26 #define CCM_SPCTL0_PD_MASK (0xf << 26) #define CCM_SPCTL0_MFD_OFFSET 16 #define CCM_SPCTL0_MFD_MASK (0x3ff << 16) #define CCM_SPCTL0_MFI_OFFSET 10 #define CCM_SPCTL0_MFI_MASK (0xf << 10) #define CCM_SPCTL0_MFN_OFFSET 0 #define CCM_SPCTL0_MFN_MASK 0x3ff #define CCM_SPCTL1_LF (1 << 15) #define CCM_SPCTL1_BRMO (1 << 6) #define CCM_OSC26MCTL_PEAK_OFFSET 16 #define CCM_OSC26MCTL_PEAK_MASK (0x3 << 16) #define CCM_OSC26MCTL_AGC_OFFSET 8 #define CCM_OSC26MCTL_AGC_MASK (0x3f << 8) #define CCM_OSC26MCTL_ANATEST_OFFSET 0 #define CCM_OSC26MCTL_ANATEST_MASK 0x3f #define CCM_PCDR0_SSI2BAUDDIV_OFFSET 26 #define CCM_PCDR0_SSI2BAUDDIV_MASK (0x3f << 26) #define CCM_PCDR0_CLKO_EN 25 #define CCM_PCDR0_CLKODIV_OFFSET 22 #define CCM_PCDR0_CLKODIV_MASK (0x7 << 22) #define CCM_PCDR0_SSI1BAUDDIV_OFFSET 16 #define CCM_PCDR0_SSI1BAUDDIV_MASK (0x3f << 16) #define CCM_PCDR0_VPUDIV2_OFFSET 10 #define CCM_PCDR0_VPUDIV2_MASK (0x3f << 10) #define CCM_PCDR0_NFCDIV2_OFFSET 6 #define CCM_PCDR0_NFCDIV2_MASK (0xf << 6) #define CCM_PCDR0_MSHCDIV2_MASK 0x3f #define CCM_PCDR0_NFCDIV_OFFSET 12 #define CCM_PCDR0_NFCDIV_MASK (0xf << 12) #define CCM_PCDR0_VPUDIV_OFFSET 8 #define CCM_PCDR0_VPUDIV_MASK (0xf << 8) #define CCM_PCDR0_MSHCDIV_OFFSET 0 #define CCM_PCDR0_MSHCDIV_MASK 0x1f #define CCM_PCDR1_PERDIV4_OFFSET 24 #define CCM_PCDR1_PERDIV4_MASK (0x3f << 24) #define CCM_PCDR1_PERDIV3_OFFSET 16 #define CCM_PCDR1_PERDIV3_MASK (0x3f << 16) #define CCM_PCDR1_PERDIV2_OFFSET 8 #define CCM_PCDR1_PERDIV2_MASK (0x3f << 8) #define CCM_PCDR1_PERDIV1_OFFSET 0 #define CCM_PCDR1_PERDIV1_MASK 0x3f #define CCM_PCCR0_CSPI1_OFFSET 31 #define CCM_PCCR0_CSPI1_MASK (1 << 31) #define CCM_PCCR0_CSPI2_OFFSET 30 #define CCM_PCCR0_CSPI2_MASK (1 << 30) #define CCM_PCCR0_CSPI3_OFFSET 29 #define CCM_PCCR0_CSPI3_MASK (1 << 29) #define CCM_PCCR0_DMA_OFFSET 28 #define CCM_PCCR0_DMA_MASK (1 << 28) #define CCM_PCCR0_EMMA_OFFSET 27 #define CCM_PCCR0_EMMA_MASK (1 << 27) #define CCM_PCCR0_FEC_OFFSET 26 #define CCM_PCCR0_FEC_MASK (1 << 26) #define CCM_PCCR0_GPIO_OFFSET 25 #define CCM_PCCR0_GPIO_MASK (1 << 25) #define CCM_PCCR0_GPT1_OFFSET 24 #define CCM_PCCR0_GPT1_MASK (1 << 24) #define CCM_PCCR0_GPT2_OFFSET 23 #define CCM_PCCR0_GPT2_MASK (1 << 23) #define CCM_PCCR0_GPT3_OFFSET 22 #define CCM_PCCR0_GPT3_MASK (1 << 22) #define CCM_PCCR0_GPT4_OFFSET 21 #define CCM_PCCR0_GPT4_MASK (1 << 21) #define CCM_PCCR0_GPT5_OFFSET 20 #define CCM_PCCR0_GPT5_MASK (1 << 20) #define CCM_PCCR0_GPT6_OFFSET 19 #define CCM_PCCR0_GPT6_MASK (1 << 19) #define CCM_PCCR0_I2C1_OFFSET 18 #define CCM_PCCR0_I2C1_MASK (1 << 18) #define CCM_PCCR0_I2C2_OFFSET 17 #define CCM_PCCR0_I2C2_MASK (1 << 17) #define CCM_PCCR0_IIM_OFFSET 16 #define CCM_PCCR0_IIM_MASK (1 << 16) #define CCM_PCCR0_KPP_OFFSET 15 #define CCM_PCCR0_KPP_MASK (1 << 15) #define CCM_PCCR0_LCDC_OFFSET 14 #define CCM_PCCR0_LCDC_MASK (1 << 14) #define CCM_PCCR0_MSHC_OFFSET 13 #define CCM_PCCR0_MSHC_MASK (1 << 13) #define CCM_PCCR0_OWIRE_OFFSET 12 #define CCM_PCCR0_OWIRE_MASK (1 << 12) #define CCM_PCCR0_PWM_OFFSET 11 #define CCM_PCCR0_PWM_MASK (1 << 11) #define CCM_PCCR0_RTC_OFFSET 9 #define CCM_PCCR0_RTC_MASK (1 << 9) #define CCM_PCCR0_RTIC_OFFSET 8 #define CCM_PCCR0_RTIC_MASK (1 << 8) #define CCM_PCCR0_SAHARA_OFFSET 7 #define CCM_PCCR0_SAHARA_MASK (1 << 7) #define CCM_PCCR0_SCC_OFFSET 6 #define CCM_PCCR0_SCC_MASK (1 << 6) #define CCM_PCCR0_SDHC1_OFFSET 5 #define CCM_PCCR0_SDHC1_MASK (1 << 5) #define CCM_PCCR0_SDHC2_OFFSET 4 #define CCM_PCCR0_SDHC2_MASK (1 << 4) #define CCM_PCCR0_SDHC3_OFFSET 3 #define CCM_PCCR0_SDHC3_MASK (1 << 3) #define CCM_PCCR0_SLCDC_OFFSET 2 #define CCM_PCCR0_SLCDC_MASK (1 << 2) #define CCM_PCCR0_SSI1_IPG_OFFSET 1 #define CCM_PCCR0_SSI1_IPG_MASK (1 << 1) #define CCM_PCCR0_SSI2_IPG_OFFSET 0 #define CCM_PCCR0_SSI2_IPG_MASK (1 << 0) #define CCM_PCCR1_UART1_OFFSET 31 #define CCM_PCCR1_UART1_MASK (1 << 31) #define CCM_PCCR1_UART2_OFFSET 30 #define CCM_PCCR1_UART2_MASK (1 << 30) #define CCM_PCCR1_UART3_OFFSET 29 #define CCM_PCCR1_UART3_MASK (1 << 29) #define CCM_PCCR1_UART4_OFFSET 28 #define CCM_PCCR1_UART4_MASK (1 << 28) #define CCM_PCCR1_UART5_OFFSET 27 #define CCM_PCCR1_UART5_MASK (1 << 27) #define CCM_PCCR1_UART6_OFFSET 26 #define CCM_PCCR1_UART6_MASK (1 << 26) #define CCM_PCCR1_USBOTG_OFFSET 25 #define CCM_PCCR1_USBOTG_MASK (1 << 25) #define CCM_PCCR1_WDT_OFFSET 24 #define CCM_PCCR1_WDT_MASK (1 << 24) #define CCM_PCCR1_HCLK_ATA_OFFSET 23 #define CCM_PCCR1_HCLK_ATA_MASK (1 << 23) #define CCM_PCCR1_HCLK_BROM_OFFSET 22 #define CCM_PCCR1_HCLK_BROM_MASK (1 << 22) #define CCM_PCCR1_HCLK_CSI_OFFSET 21 #define CCM_PCCR1_HCLK_CSI_MASK (1 << 21) #define CCM_PCCR1_HCLK_DMA_OFFSET 20 #define CCM_PCCR1_HCLK_DMA_MASK (1 << 20) #define CCM_PCCR1_HCLK_EMI_OFFSET 19 #define CCM_PCCR1_HCLK_EMI_MASK (1 << 19) #define CCM_PCCR1_HCLK_EMMA_OFFSET 18 #define CCM_PCCR1_HCLK_EMMA_MASK (1 << 18) #define CCM_PCCR1_HCLK_FEC_OFFSET 17 #define CCM_PCCR1_HCLK_FEC_MASK (1 << 17) #define CCM_PCCR1_HCLK_VPU_OFFSET 16 #define CCM_PCCR1_HCLK_VPU_MASK (1 << 16) #define CCM_PCCR1_HCLK_LCDC_OFFSET 15 #define CCM_PCCR1_HCLK_LCDC_MASK (1 << 15) #define CCM_PCCR1_HCLK_RTIC_OFFSET 14 #define CCM_PCCR1_HCLK_RTIC_MASK (1 << 14) #define CCM_PCCR1_HCLK_SAHARA_OFFSET 13 #define CCM_PCCR1_HCLK_SAHARA_MASK (1 << 13) #define CCM_PCCR1_HCLK_SLCDC_OFFSET 12 #define CCM_PCCR1_HCLK_SLCDC_MASK (1 << 12) #define CCM_PCCR1_HCLK_USBOTG_OFFSET 11 #define CCM_PCCR1_HCLK_USBOTG_MASK (1 << 11) #define CCM_PCCR1_PERCLK1_OFFSET 10 #define CCM_PCCR1_PERCLK1_MASK (1 << 10) #define CCM_PCCR1_PERCLK2_OFFSET 9 #define CCM_PCCR1_PERCLK2_MASK (1 << 9) #define CCM_PCCR1_PERCLK3_OFFSET 8 #define CCM_PCCR1_PERCLK3_MASK (1 << 8) #define CCM_PCCR1_PERCLK4_OFFSET 7 #define CCM_PCCR1_PERCLK4_MASK (1 << 7) #define CCM_PCCR1_VPU_BAUD_OFFSET 6 #define CCM_PCCR1_VPU_BAUD_MASK (1 << 6) #define CCM_PCCR1_SSI1_BAUD_OFFSET 5 #define CCM_PCCR1_SSI1_BAUD_MASK (1 << 5) #define CCM_PCCR1_SSI2_BAUD_OFFSET 4 #define CCM_PCCR1_SSI2_BAUD_MASK (1 << 4) #define CCM_PCCR1_NFC_BAUD_OFFSET 3 #define CCM_PCCR1_NFC_BAUD_MASK (1 << 3) #define CCM_PCCR1_MSHC_BAUD_OFFSET 2 #define CCM_PCCR1_MSHC_BAUD_MASK (1 << 2) #define CCM_CCSR_32KSR (1 << 15) #define CCM_CCSR_CLKMODE1 (1 << 9) #define CCM_CCSR_CLKMODE0 (1 << 8) #define CCM_CCSR_CLKOSEL_OFFSET 0 #define CCM_CCSR_CLKOSEL_MASK 0x1f #endif
xoox/linux-2.6.18_pro500
arch/arm/mach-mx2/crm_regs.h
C
gpl-2.0
10,868
/****************************************************************************** °æÈ¨ËùÓÐ (C), 2001-2011, »ªÎª¼¼ÊõÓÐÏÞ¹«Ë¾ ****************************************************************************** ÎÄ ¼þ Ãû : PsMux.c °æ ±¾ ºÅ : ³õ¸å Éú³ÉÈÕÆÚ : 2012Äê8ÔÂ10ÈÕ ×î½üÐÞ¸Ä : ¹¦ÄÜÃèÊö : MUXͨµÀ¸´Óà º¯ÊýÁбí : ÐÞ¸ÄÀúÊ· : 1.ÈÕ ÆÚ : 2012Äê8ÔÂ10ÈÕ ÐÞ¸ÄÄÚÈÝ : ´´½¨Îļþ ******************************************************************************/ /***************************************************************************** 1 Í·Îļþ°üº¬ *****************************************************************************/ #include "PsTypeDef.h" #include "PsMux.h" #include "PsCommonDef.h" #include "SysNvId.h" #include "om.h" #include "OmApp.h" #include "NVIM_Interface.h" /*lint -e767*/ #define THIS_FILE_ID PS_FILE_ID_PSMUX_C /*lint +e767*/ /***************************************************************************** 2 È«¾Ö±äÁ¿¶¨Òå *****************************************************************************/ /* ´òÓ¡¿ª¹Ø */ VOS_UINT32 g_ulMuxPrintFlag = PS_FALSE; /* ÏûÏ¢¸ú×Ù¿ª¹Ø */ VOS_UINT32 g_ulMuxTraceFlag = PS_FALSE; /* MUXµÄͳ¼ÆÐÅÏ¢ */ MUX_DEV_STATIC_INFO_STRU g_stMuxStaticInfo; MUX_UNFRAME_STATE_ST g_stMuxUnframeState; /*Mux¶ÔÓ¦µÄ½ÓÊÕÊý¾Ý״̬*/ TTF_Q_ST g_stMuxUlQue; /*Mux¶ÔÓ¦µÄÉÏÐÐÊý¾Ý½ÓÊÕ¶ÓÁнṹ*/ MUX_DEV_INFO_STRU g_stMuxDevInfo; MUX_AT_UL_DLCI_INFO_STRU g_stMuxAtUlDlciInfo[AT_MUX_DLCI_TYPE_BUTT]; /*reversed, 8-bit, poly=0x07*/ const VOS_UINT8 gaucMuxcrctable[256] = { 0x00, 0x91, 0xE3, 0x72, 0x07, 0x96, 0xE4, 0x75, 0x0E, 0x9F, 0xED, 0x7C, 0x09,0x98, 0xEA, 0x7B, 0x1C, 0x8D, 0xFF, 0x6E, 0x1B, 0x8A, 0xF8, 0x69, 0x12, 0x83, 0xF1, 0x60, 0x15,0x84, 0xF6, 0x67, 0x38, 0xA9, 0xDB, 0x4A, 0x3F, 0xAE, 0xDC, 0x4D, 0x36, 0xA7, 0xD5, 0x44, 0x31,0xA0, 0xD2, 0x43, 0x24, 0xB5, 0xC7, 0x56, 0x23, 0xB2, 0xC0, 0x51, 0x2A, 0xBB, 0xC9, 0x58, 0x2D,0xBC, 0xCE, 0x5F, 0x70, 0xE1, 0x93, 0x02, 0x77, 0xE6, 0x94, 0x05, 0x7E, 0xEF, 0x9D, 0x0C, 0x79,0xE8, 0x9A, 0x0B, 0x6C, 0xFD, 0x8F, 0x1E, 0x6B, 0xFA, 0x88, 0x19, 0x62, 0xF3, 0x81, 0x10, 0x65,0xF4, 0x86, 0x17, 0x48, 0xD9, 0xAB, 0x3A, 0x4F, 0xDE, 0xAC, 0x3D, 0x46, 0xD7, 0xA5, 0x34, 0x41,0xD0, 0xA2, 0x33, 0x54, 0xC5, 0xB7, 0x26, 0x53, 0xC2, 0xB0, 0x21, 0x5A, 0xCB, 0xB9, 0x28, 0x5D,0xCC, 0xBE, 0x2F, 0xE0, 0x71, 0x03, 0x92, 0xE7, 0x76, 0x04, 0x95, 0xEE, 0x7F, 0x0D, 0x9C, 0xE9,0x78, 0x0A, 0x9B, 0xFC, 0x6D, 0x1F, 0x8E, 0xFB, 0x6A, 0x18, 0x89, 0xF2, 0x63, 0x11, 0x80, 0xF5,0x64, 0x16, 0x87, 0xD8, 0x49, 0x3B, 0xAA, 0xDF, 0x4E, 0x3C, 0xAD, 0xD6, 0x47, 0x35, 0xA4, 0xD1,0x40, 0x32, 0xA3, 0xC4, 0x55, 0x27, 0xB6, 0xC3, 0x52, 0x20, 0xB1, 0xCA, 0x5B, 0x29, 0xB8, 0xCD,0x5C, 0x2E, 0xBF, 0x90, 0x01, 0x73, 0xE2, 0x97, 0x06, 0x74, 0xE5, 0x9E, 0x0F, 0x7D, 0xEC, 0x99,0x08, 0x7A, 0xEB, 0x8C, 0x1D, 0x6F, 0xFE, 0x8B, 0x1A, 0x68, 0xF9, 0x82, 0x13, 0x61, 0xF0, 0x85,0x14, 0x66, 0xF7, 0xA8, 0x39, 0x4B, 0xDA, 0xAF, 0x3E, 0x4C, 0xDD, 0xA6, 0x37, 0x45, 0xD4, 0xA1,0x30, 0x42, 0xD3, 0xB4, 0x25, 0x57, 0xC6, 0xB3, 0x22, 0x50, 0xC1, 0xBA, 0x2B, 0x59, 0xC8, 0xBD,0x2C, 0x5E, 0xCF }; /***************************************************************************** 3 º¯ÊýʵÏÖ *****************************************************************************/ /***************************************************************************** º¯ Êý Ãû : MUX_PrintLog ¹¦ÄÜÃèÊö : ĿǰÁÙʱʹÓÃMUX´òÓ¡º¯Êý£¬ºóÐøµÈAºË´òÓ¡¿ÉÓúóÇл»ÎªPS_LOG£¬´òӡûÓвÎÊýµÄ´òÓ¡ ÊäÈë²ÎÊý : VOS_UINT32 ulModuleId ´òÓ¡Ä£¿éÃû VOS_UINT32 ulSubMod ´òÓ¡×ÓÄ£¿éÃû VOS_UINT32 ulLevel ´òÓ¡¼¶±ð VOS_CHAR *pcString ´òÓ¡ÄÚÈÝ VOS_INT32 lPara1 ´òÓ¡²ÎÊý Êä³ö²ÎÊý : ÎÞ ·µ »Ø Öµ : ÎÞ µ÷Óú¯Êý : ±»µ÷º¯Êý : ÐÞ¸ÄÀúÊ· : 1.ÈÕ ÆÚ : 2012Äê8ÔÂ10ÈÕ ÐÞ¸ÄÄÚÈÝ : ÐÂÉú³Éº¯Êý *****************************************************************************/ VOS_VOID MUX_PrintLog ( VOS_UINT32 ulModuleId, VOS_UINT32 ulSubMod, VOS_UINT32 ulLevel, VOS_CHAR *pcString ) { if (PS_TRUE == g_ulMuxPrintFlag) { vos_printf(pcString); } return; } /***************************************************************************** º¯ Êý Ãû : MUX_PrintLog1 ¹¦ÄÜÃèÊö : ĿǰÁÙʱʹÓÃMUX´òÓ¡º¯Êý£¬ºóÐøµÈAºË´òÓ¡¿ÉÓúóÇл»ÎªPS_LOG£¬´òÓ¡ÓÐ1¸ö²ÎÊýµÄ´òÓ¡ ÊäÈë²ÎÊý : VOS_UINT32 ulModuleId ´òÓ¡Ä£¿éÃû VOS_UINT32 ulSubMod ´òÓ¡×ÓÄ£¿éÃû VOS_UINT32 ulLevel ´òÓ¡¼¶±ð VOS_CHAR *pcString ´òÓ¡ÄÚÈÝ VOS_INT32 lPara1 ´òÓ¡²ÎÊý Êä³ö²ÎÊý : ÎÞ ·µ »Ø Öµ : ÎÞ µ÷Óú¯Êý : ±»µ÷º¯Êý : ÐÞ¸ÄÀúÊ· : 1.ÈÕ ÆÚ : 2012Äê8ÔÂ10ÈÕ ÐÞ¸ÄÄÚÈÝ : ÐÂÉú³Éº¯Êý *****************************************************************************/ VOS_VOID MUX_PrintLog1 ( VOS_UINT32 ulModuleId, VOS_UINT32 ulSubMod, VOS_UINT32 ulLevel, VOS_CHAR *pcString, VOS_INT32 lPara1 ) { if (PS_TRUE == g_ulMuxPrintFlag) { vos_printf(pcString, lPara1); } return; } /***************************************************************************** º¯ Êý Ãû : MUX_PrintLog2 ¹¦ÄÜÃèÊö : ĿǰÁÙʱʹÓÃMUX´òÓ¡º¯Êý£¬ºóÐøµÈAºË´òÓ¡¿ÉÓúóÇл»ÎªPS_LOG£¬´òÓ¡ÓÐ2¸ö²ÎÊýµÄ´òÓ¡ ÊäÈë²ÎÊý : VOS_UINT32 ulModuleId ´òÓ¡Ä£¿éÃû VOS_UINT32 ulSubMod ´òÓ¡×ÓÄ£¿éÃû VOS_UINT32 ulLevel ´òÓ¡¼¶±ð VOS_CHAR *pcString ´òÓ¡ÄÚÈÝ VOS_INT32 lPara1 ´òÓ¡²ÎÊý Êä³ö²ÎÊý : ÎÞ ·µ »Ø Öµ : ÎÞ µ÷Óú¯Êý : ±»µ÷º¯Êý : ÐÞ¸ÄÀúÊ· : 1.ÈÕ ÆÚ : 2012Äê8ÔÂ10ÈÕ ÐÞ¸ÄÄÚÈÝ : ÐÂÉú³Éº¯Êý *****************************************************************************/ VOS_VOID MUX_PrintLog2 ( VOS_UINT32 ulModuleId, VOS_UINT32 ulSubMod, VOS_UINT32 ulLevel, VOS_CHAR *pcString, VOS_INT32 lPara1, VOS_INT32 lPara2 ) { if (PS_TRUE == g_ulMuxPrintFlag) { vos_printf(pcString, lPara1, lPara2); } return; } /***************************************************************************** º¯ Êý Ãû : MUX_DlciCheckFcs ¹¦ÄÜÃèÊö : ¶ÔFcs½øÐÐУÑé ÊäÈë²ÎÊý : pData ½øÐÐУÑéµÄÊý¾ÝÖ¸Õë usLen ½øÐÐУÑéµÄÊý¾Ý³¤¶È ucFcs ²úÉúµÄУÑé×Ö½Ú Êä³ö²ÎÊý : ÎÞ ·µ »Ø Öµ : VOS_OK,VOS_ERR µ÷Óú¯Êý : ±»µ÷º¯Êý : ÐÞ¸ÄÀúÊ· : 1.ÈÕ ÆÚ : 2012Äê8ÔÂ10ÈÕ ÐÞ¸ÄÄÚÈÝ : ÐÂÉú³Éº¯Êý *****************************************************************************/ VOS_UINT32 MUX_DlciCheckFcs(VOS_UINT8* pData, VOS_UINT16 usLen, VOS_UINT8 ucFcs) { /*Init*/ VOS_UINT8 ucFCS = 0xFF; VOS_UINT16 usDatalen = usLen; VOS_UINT8 *pucBuf = pData; /*len is the number of bytes in the message, p points to message*/ while (usDatalen--) { ucFCS = gaucMuxcrctable[ucFCS^*pucBuf++]; } /*Ones complement*/ ucFCS = gaucMuxcrctable[ucFCS^ucFcs]; /*0xCF is the reversed order of 11110011.*/ if (0xCF == ucFCS) { /*FCS is OK*/ return VOS_OK; } else { /*FCS is not OK*/ return VOS_ERR; } } /***************************************************************************** º¯ Êý Ãû : MUX_DlciGetFcs ¹¦ÄÜÃèÊö : ÌáÈ¡³öÒ»¸öÖ¡ µÄFCS ÊäÈë²ÎÊý : pData ½øÐÐУÑéµÄÊý¾ÝÖ¸Õë usDataLen ½øÐÐУÑéµÄÊý¾Ý³¤¶È Êä³ö²ÎÊý : ÎÞ ·µ »Ø Öµ : FCS ²úÉúµÄFCS×Ö½Ú µ÷Óú¯Êý : ±»µ÷º¯Êý : ÐÞ¸ÄÀúÊ· : 1.ÈÕ ÆÚ : 2012Äê8ÔÂ10ÈÕ ÐÞ¸ÄÄÚÈÝ : ÐÂÉú³Éº¯Êý *****************************************************************************/ VOS_UINT8 MUX_DlciGetFcs(VOS_UINT8* pData, VOS_UINT16 usLen) { /*³õʼ»¯*/ VOS_UINT8 ucFCS = 0xFF; VOS_UINT16 usDatalen = usLen; VOS_UINT8 *pucBuf = pData; /*len ÊÇÕâ¸öframeµÄ×Ö½Ú³¤¶È, p Ö¸ÏòÕâ¸ömessage */ while (usDatalen--) { ucFCS = gaucMuxcrctable[ucFCS^*pucBuf++]; } /*Ò»¸öframeµÄFcs ´¦Àí½áÊø*/ ucFCS = 0xFF - ucFCS; return ucFCS; } /***************************************************************************** º¯ Êý Ãû : MUX_DlciIsValid ¹¦ÄÜÃèÊö : ¼ì²éDlciµÄÊÇ·ñΪÓÐЧֵ ÊäÈë²ÎÊý : AT_MUX_DLCI_TYPE_ENUM_UINT8 ucDlci Á´Â·ºÅ Êä³ö²ÎÊý : ÎÞ ·µ »Ø Öµ : VOS_UINT32 µ÷Óú¯Êý : ±»µ÷º¯Êý : ÐÞ¸ÄÀúÊ· : 1.ÈÕ ÆÚ : 2012Äê8ÔÂ10ÈÕ ÐÞ¸ÄÄÚÈÝ : ÐÂÉú³Éº¯Êý *****************************************************************************/ VOS_UINT32 MUX_DlciIsValid(AT_MUX_DLCI_TYPE_ENUM_UINT8 enDlci) { /* DlciµÄÓÐЧֵΪ{1,64} */ if ((enDlci < AT_MUX_DLCI1_ID) || ( enDlci >= AT_MUX_DLCI_TYPE_BUTT)) { MUX_PrintLog1(PS_PID_APP_MUX, 0, PS_PRINT_WARNING, "MUX, MUX_DlciIsValid, ucDlci<1> is error!\r\n", enDlci); return VOS_ERR; } else { return VOS_OK; } } /***************************************************************************** º¯ Êý Ãû : MUX_DlciUlDataToAt ¹¦ÄÜÃèÊö : ÉÏÐÐÊý¾Ý°´ÕÕbasicÖ¡Í·²¿´¦Àíºó½»¸øAT´¦Àí ÊäÈë²ÎÊý : VOS_UINT8 *pData ÉÏÐÐÊý¾Ý Êä³ö²ÎÊý : ÎÞ ·µ »Ø Öµ : VOS_OK Êý¾Ý´¦Àí³É¹¦ VOS_ERR Êý¾Ý´¦Àíʧ°Ü µ÷Óú¯Êý : ±»µ÷º¯Êý : ÐÞ¸ÄÀúÊ· : 1.ÈÕ ÆÚ : 2012Äê8ÔÂ10ÈÕ ÐÞ¸ÄÄÚÈÝ : ÐÂÉú³Éº¯Êý *****************************************************************************/ VOS_UINT32 MUX_DlciUlDataToAt(VOS_UINT8* pData) { MUX_FRAME_HEAD *pFrame = (MUX_FRAME_HEAD*)pData; VOS_UINT16 usFrameLen = 0; VOS_UINT8 bit1Len1EA = 0; VOS_UINT8 bit7Len1 = 0; VOS_UINT8 bit6AddrDlci = 0; VOS_UINT8 usFcsLen = 0; VOS_UINT8 ucFcs; VOS_UINT8 *pPayLoad = VOS_NULL_PTR; RCV_UL_DLCI_DATA_FUNC pRcvUlDlciDataFunc = VOS_NULL_PTR; /* ¼ì²éÊäÈë²ÎÊýµÄºÏÀíÐÔ*/ if (VOS_NULL_PTR == pData) { MUX_PrintLog(PS_PID_APP_MUX, 0, PS_PRINT_ERROR, "MUX, MUX_DlciUlDataToAt: pData is null.\r\n"); return VOS_ERR; } MUX_GET_17_BIT(pFrame->ucLen1, bit1Len1EA, bit7Len1); if (1 == bit1Len1EA) { /*±íʾ³¤¶ÈÖ»Õ¼ÓÐÒ»¸ö×Ö½Ú*/ usFrameLen = bit7Len1; pPayLoad = (pData + 4); usFcsLen = 3; ucFcs = *(pPayLoad + usFrameLen); } else /*±íʾ³¤¶ÈÓÐÁ½¸ö×Ö½Ú*/ { usFrameLen = (VOS_UINT16)(((VOS_UINT16)(pFrame->ucLen2)<<7)+bit7Len1); pPayLoad = (pData + 5); usFcsLen = 4; ucFcs = *(pPayLoad + usFrameLen); } /*УÑ鵨ַÓò£¬¿ØÖÆÓòºÍ³¤¶ÈÓò*/ if (VOS_OK != MUX_DlciCheckFcs(pData + 1, usFcsLen, ucFcs)) { MUX_PrintLog(PS_PID_APP_MUX, 0, PS_PRINT_ERROR, "MUX, MUX_DlciUlDataToAt::MUX_DlciCheckFcs return fail.\r\n"); return VOS_ERR; } /*ÌáÈ¡Á´Â·µÄDLCI*/ MUX_GET_116_BIT(pFrame->ucAddr, bit6AddrDlci); /* DLCIºÏ·¨ÐÔ¼ì²é */ if (VOS_OK != MUX_DlciIsValid(bit6AddrDlci)) { MUX_PrintLog1(PS_PID_APP_MUX, 0, PS_PRINT_WARNING, "MUX, MUX_AtRgstUlPortCallBack: enDlci <1> is", bit6AddrDlci); return VOS_ERR; } pRcvUlDlciDataFunc = MUX_AT_UL_DLCI_GET_DATA_CALLBACK_FUNC(bit6AddrDlci); /* ·¢ËÍÉÏÐÐÊý¾Ý */ if (VOS_NULL_PTR != pRcvUlDlciDataFunc) { (VOS_VOID)pRcvUlDlciDataFunc(bit6AddrDlci, pPayLoad, usFrameLen); MUX_TraceUlData(bit6AddrDlci, pPayLoad, usFrameLen); MUX_DBG_UL_SEND_SUCC_PKT_NUM(1); } else { MUX_PrintLog(PS_PID_APP_MUX, 0, PS_PRINT_ERROR, "MUX, MUX_AtRgstUlPortCallBack::pRcvUlDlciDataFunc is null.\r\n"); MUX_DBG_UL_SEND_FAIL_PKT_NUM(1); return VOS_ERR; } return VOS_OK; } /***************************************************************************** º¯ Êý Ãû : MUX_DlciUlQueProc ¹¦ÄÜÃèÊö : ½ÓÊÕ»º³å¶ÓÁд¦Àí ÊäÈë²ÎÊý : ÎÞ Êä³ö²ÎÊý : ÎÞ ·µ »Ø Öµ : VOS_OK Êý¾Ý´¦Àí³É¹¦ VOS_ERR Êý¾Ý´¦Àíʧ°Ü µ÷Óú¯Êý : ±»µ÷º¯Êý : ÐÞ¸ÄÀúÊ· : 1.ÈÕ ÆÚ : 2012Äê8ÔÂ10ÈÕ ÐÞ¸ÄÄÚÈÝ : ÐÂÉú³Éº¯Êý *****************************************************************************/ VOS_UINT32 MUX_DlciUlQueProc(VOS_VOID) { TTF_Q_ST *pRxDataQ; TTF_MBUF_ST *pMem; VOS_UINT32 ulQueCnt = 0; VOS_UINT32 ulQueLoop = 0; pRxDataQ = MUX_GET_RX_Q_ADDR(); ulQueCnt = TTF_Q_CNT(pRxDataQ); MUX_PrintLog1(PS_PID_APP_MUX, 0, PS_PRINT_INFO, "MUX, MUX_DlciUlQueProc Qcnt:%d.\r\n", (VOS_INT32)ulQueCnt); for (ulQueLoop = 0; ulQueLoop < ulQueCnt; ulQueLoop++) { pMem = (TTF_MBUF_ST *)TTF_QOut(PS_PID_APP_MUX, pRxDataQ); if (VOS_NULL_PTR == pMem) { MUX_PrintLog(PS_PID_APP_MUX, 0, PS_PRINT_ERROR, "MUX, MUX_DlciUlQueProc, pMem is null\r\n"); return VOS_ERR; } MUX_DlciUlDataToAt(pMem->pData); TTF_MbufFree(PS_PID_APP_MUX, pMem); } return VOS_OK; } /***************************************************************************** º¯ Êý Ãû : MUX_DlciUlDataEnque ¹¦ÄÜÃèÊö : ½«×éºÃµÄÖ¡ËÍÈë½ÓÊÕ»º³å¶ÓÁУ¬²¢Í³¼Æ¶ªÆúµÄÊý¾Ý ÊäÈë²ÎÊý : pMem ·¢Ë͵ÄÊý¾Ý½á¹¹ Êä³ö²ÎÊý : ÎÞ ·µ »Ø Öµ : VOS_OK Êý¾Ý´¦Àí³É¹¦ VOS_ERR Êý¾Ý´¦Àíʧ°Ü µ÷Óú¯Êý : ±»µ÷º¯Êý : ÐÞ¸ÄÀúÊ· : 1.ÈÕ ÆÚ : 2012Äê8ÔÂ10ÈÕ ÐÞ¸ÄÄÚÈÝ : ÐÂÉú³Éº¯Êý *****************************************************************************/ VOS_UINT32 MUX_DlciUlDataEnque(TTF_MBUF_ST *pMem) { TTF_Q_ST *pRxDataQ; VOS_UINT32 ulRtn = VOS_ERR; MUX_PrintLog(PS_PID_APP_MUX, 0, PS_PRINT_INFO, "MUX, MUX_DlciUlDataEnque Start.\r\n"); pRxDataQ = MUX_GET_RX_Q_ADDR(); ulRtn = TTF_QIn(PS_PID_APP_MUX, pRxDataQ, &pMem->stLink); if (VOS_OK != ulRtn) { MUX_PrintLog(PS_PID_APP_MUX, 0, PS_PRINT_WARNING, "MUX, MUX_DlciUlEnque, TTF_QIn return fail.\r\n"); TTF_MbufFree(PS_PID_APP_MUX, pMem); return VOS_ERR; } MUX_PrintLog(PS_PID_APP_MUX, 0, PS_PRINT_INFO, "MUX, MUX_DlciUlDataEnque End\r\n"); return VOS_OK; } /***************************************************************************** º¯ Êý Ãû : MUX_DlciUlDataProc ¹¦ÄÜÃèÊö : µ×ÈíÉϱ¨Êý¾ÝµÄÉÏÐÐÊý¾Ý´¦Àíº¯Êý ÊäÈë²ÎÊý : VOS_UINT8 *pData ÉÏÐÐÊý¾Ý VOS_UINT16 usDataLen ÏÂÐÐÊý¾Ý³¤¶È Êä³ö²ÎÊý : ÎÞ ·µ »Ø Öµ : VOS_OK Êý¾Ý´¦Àí³É¹¦ VOS_ERR Êý¾Ý´¦Àíʧ°Ü µ÷Óú¯Êý : ±»µ÷º¯Êý : ÐÞ¸ÄÀúÊ· : 1.ÈÕ ÆÚ : 2012Äê8ÔÂ10ÈÕ ÐÞ¸ÄÄÚÈÝ : ÐÂÉú³Éº¯Êý *****************************************************************************/ VOS_UINT32 MUX_DlciUlDataProc(VOS_UINT8* pData, VOS_UINT16 usDataLen) { TTF_MBUF_ST *pMbuf = VOS_NULL_PTR; VOS_UINT16 *pusLeftInfoLen; VOS_UINT8 *pucHeadBuff; VOS_UINT8 *pucUnframeState; /*ÊäÈë²ÎÊý¼ì²é*/ if ((VOS_NULL_PTR == pData) || (0 == usDataLen)) { MUX_PrintLog2(PS_PID_APP_MUX, 0, PS_PRINT_WARNING, "MUX, MUX_DlciUlDataProc, pData <1> is %d, usDataLen <2> is %d.\r\n", (VOS_INT32)pData, (VOS_INT32)usDataLen); return VOS_ERR; } pusLeftInfoLen = MUX_GET_UL_RX_LEN(); pucHeadBuff = MUX_GET_UL_RX_HEAD(); pucUnframeState = MUX_GET_UL_RX_STAT(); while (usDataLen > 0) /*´¦ÀíÊÕµ½µÄÊý¾Ý*/ { switch (*pucUnframeState) { case MUX_DLCI_UNFRAME_STATE_FNDING_F9: if (MUX_FRAME_FLAG != *pData) { MUX_PrintLog1(PS_PID_APP_MUX, 0, PS_PRINT_WARNING, "MUX, MUX_DlciUlDataProc::MUX_DLCI_UNFRAME_STATE_FNDING_F9, *pData <1> is.\r\n", *pData); pData++; usDataLen--; continue; } VOS_MemSet(pucHeadBuff, 0, MUX_FRAME_LEN_5); pucHeadBuff[MUX_FRAME_LEN_0] = *pData; pData++; usDataLen--; *pucUnframeState = MUX_DLCI_UNFRAME_STATE_FNDING_ADDR; break; case MUX_DLCI_UNFRAME_STATE_FNDING_ADDR: if (MUX_FRAME_FLAG == *pData) { MUX_PrintLog1(PS_PID_APP_MUX, 0, PS_PRINT_WARNING, "MUX, MUX_DlciUlDataProc::MUX_DLCI_UNFRAME_STATE_FNDING_ADDR, *pData <1> is.\r\n", *pData); pData++; usDataLen--; continue; } pucHeadBuff[MUX_FRAME_LEN_1] = *pData; pData++; usDataLen--; *pucUnframeState = MUX_DLCI_UNFRAME_STATE_FNDING_CTRL; break; case MUX_DLCI_UNFRAME_STATE_FNDING_CTRL: pucHeadBuff[MUX_FRAME_LEN_2] = *pData; pData++; usDataLen--; *pucUnframeState = MUX_DLCI_UNFRAME_STATE_FNDING_LEN1; break; case MUX_DLCI_UNFRAME_STATE_FNDING_LEN1: pucHeadBuff[MUX_FRAME_LEN_3] = *pData; pData++; usDataLen--; if (0x01 == (pucHeadBuff[MUX_FRAME_LEN_3] & 0x01)) /* Èç¹ûEA=1£¬³¤¶ÈÓòÖ»ÓÐÒ»¸ö×Ö½Ú */ { *pusLeftInfoLen = pucHeadBuff[MUX_FRAME_LEN_3] >> 1; /* ³¤¶ÈÎªÇ°Ãæ7¸ö±ÈÌØ */ pMbuf = MUX_GET_UL_RX_BUFF(); if (VOS_NULL_PTR != pMbuf) { MUX_PrintLog1(PS_PID_APP_MUX, 0, PS_PRINT_WARNING, "MUX, MUX_DlciUlDataProc::MUX_DLCI_UNFRAME_STATE_FNDING_LEN1, pMbuf <1> is.\r\n", (VOS_INT32)pMbuf); TTF_MbufFree(PS_PID_APP_MUX, pMbuf); } pMbuf = TTF_MbufNew(PS_PID_APP_MUX, *pusLeftInfoLen + MUX_FRAME_LEN_6); if (VOS_NULL_PTR == pMbuf) { MUX_PrintLog(PS_PID_APP_MUX, 0, PS_PRINT_WARNING, "MUX, MUX_DlciUlDataProc::MUX_DLCI_UNFRAME_STATE_FNDING_LEN1, pMbuf is null.\r\n"); *pucUnframeState = MUX_DLCI_UNFRAME_STATE_FNDING_F9; break; } g_stMuxUnframeState.pUnframeBuf = pMbuf; VOS_MemCpy(pMbuf->pData, pucHeadBuff, MUX_FRAME_LEN_4); pMbuf->usLen = ( *pusLeftInfoLen + MUX_FRAME_LEN_6 ); pMbuf->usUsed = MUX_FRAME_LEN_4; if (0 == *pusLeftInfoLen) { *pucUnframeState = MUX_DLCI_UNFRAME_STATE_FNDING_FCS; } else { *pucUnframeState = MUX_DLCI_UNFRAME_STATE_FNDING_INFO; } } else { *pucUnframeState = MUX_DLCI_UNFRAME_STATE_FNDING_LEN2; } break; case MUX_DLCI_UNFRAME_STATE_FNDING_LEN2: pucHeadBuff[MUX_FRAME_LEN_4] = *pData; pData++; usDataLen--; *pusLeftInfoLen = ((VOS_UINT16)pucHeadBuff[MUX_FRAME_LEN_4]) << 7; *pusLeftInfoLen |= (VOS_UINT16)( pucHeadBuff[MUX_FRAME_LEN_3] >> 1 ); if (MUX_DLCI_PAYLOAD_LEN_MAX < *pusLeftInfoLen) { MUX_PrintLog1(PS_PID_APP_MUX, 0, PS_PRINT_WARNING, "MUX, MUX_DlciUlDataProc::MUX_DLCI_UNFRAME_STATE_FNDING_LEN2, usLeftInfoLen is %d.\r\n", (VOS_INT32)*pusLeftInfoLen); VOS_MemSet(pucHeadBuff, 0, MUX_FRAME_LEN_5); *pucUnframeState = MUX_DLCI_UNFRAME_STATE_FNDING_F9; } else { pMbuf = MUX_GET_UL_RX_BUFF(); if (VOS_NULL_PTR != pMbuf) { MUX_PrintLog1(PS_PID_APP_MUX, 0, PS_PRINT_WARNING, "MUX, MUX_DlciUlDataProc::MUX_DLCI_UNFRAME_STATE_FNDING_LEN2, pMbuf <1> is.\r\n", (VOS_INT32)pMbuf); TTF_MbufFree(PS_PID_APP_MUX, pMbuf); } pMbuf = TTF_MbufNew(PS_PID_APP_MUX, *pusLeftInfoLen + MUX_FRAME_LEN_7); if (VOS_NULL_PTR == pMbuf) { MUX_PrintLog(PS_PID_APP_MUX, 0, PS_PRINT_WARNING, "MUX, MUX_DlciUlDataProc::MUX_DLCI_UNFRAME_STATE_FNDING_LEN2, pMbuf is null.\r\n"); *pucUnframeState = MUX_DLCI_UNFRAME_STATE_FNDING_F9; break; } g_stMuxUnframeState.pUnframeBuf = pMbuf; VOS_MemCpy(pMbuf->pData, pucHeadBuff, MUX_FRAME_LEN_5); pMbuf->usLen = ( *pusLeftInfoLen + MUX_FRAME_LEN_7 ); pMbuf->usUsed = MUX_FRAME_LEN_5; *pucUnframeState = MUX_DLCI_UNFRAME_STATE_FNDING_INFO; } break; case MUX_DLCI_UNFRAME_STATE_FNDING_INFO: pMbuf = MUX_GET_UL_RX_BUFF(); if (*pusLeftInfoLen <= usDataLen) { VOS_MemCpy(&pMbuf->pData[pMbuf->usUsed], pData, *pusLeftInfoLen); pMbuf->usUsed += *pusLeftInfoLen; pData += *pusLeftInfoLen; usDataLen -= *pusLeftInfoLen; *pusLeftInfoLen = 0; *pucUnframeState = MUX_DLCI_UNFRAME_STATE_FNDING_FCS; } else { VOS_MemCpy(&pMbuf->pData[pMbuf->usUsed], pData, usDataLen); pMbuf->usUsed += usDataLen; pData += usDataLen; *pusLeftInfoLen -= usDataLen; usDataLen = 0; } break; case MUX_DLCI_UNFRAME_STATE_FNDING_FCS: pMbuf = MUX_GET_UL_RX_BUFF(); pMbuf->pData[pMbuf->usUsed++] = *pData; pData++; usDataLen--; *pucUnframeState = MUX_DLCI_UNFRAME_STATE_FNDING_EOF; break; case MUX_DLCI_UNFRAME_STATE_FNDING_EOF: pMbuf = MUX_GET_UL_RX_BUFF(); if (MUX_FRAME_FLAG != *pData) { MUX_PrintLog1(PS_PID_APP_MUX, 0, PS_PRINT_WARNING, "MUX, MUX_DlciUlDataProc::MUX_DLCI_UNFRAME_STATE_FNDING_EOF, *pData <1> is.\r\n", *pData); TTF_MbufFree(PS_PID_APP_MUX, pMbuf); } else { pMbuf->pData[pMbuf->usUsed++] = *pData; MUX_DlciUlDataEnque(pMbuf); } *pucUnframeState = MUX_DLCI_UNFRAME_STATE_FNDING_F9; g_stMuxUnframeState.pUnframeBuf = VOS_NULL_PTR; pData++; usDataLen--; break; default: pMbuf = MUX_GET_UL_RX_BUFF(); if (VOS_NULL_PTR != pMbuf) { MUX_PrintLog1(PS_PID_APP_MUX, 0, PS_PRINT_WARNING, "MUX, MUX_DlciUlDataProc::default, pMbuf <1> is.\r\n", (VOS_INT32)pMbuf); TTF_MbufFree(PS_PID_APP_MUX, pMbuf); } *pucUnframeState = MUX_DLCI_UNFRAME_STATE_FNDING_F9; break; } } return VOS_OK; } /***************************************************************************** º¯ Êý Ãû : MUX_AcmGetUlDataBuf ¹¦ÄÜÃèÊö : ·â×°´ÓHSIC ACMÉ豸¶ÁÊý¾ÝµÄ½Ó¿Ú ÊäÈë²ÎÊý : UDI_HANDLE slUdiHsicAcmHdl ACMÉ豸µÄ¾ä±ú VOS_UINT8 **ppucBuf ÓÃÀ´Ö¸ÏòÊä³öµÄÉÏÐÐÊý¾ÝBufÖ¸Õë Êä³ö²ÎÊý : VOS_UINT8 **ppucBuf ÓÃÀ´Ö¸ÏòÊä³öµÄÉÏÐÐÊý¾ÝBufÖ¸ÕëÖÐÖ¸ÏòµÄÄÚÈÝ ·µ »Ø Öµ : VOS_OK:³É¹¦ VOS_ERR:ʧ°Ü µ÷Óú¯Êý : ±»µ÷º¯Êý : Mux_UsbAcmReadData ÐÞ¸ÄÀúÊ· : 1.ÈÕ ÆÚ : 2012Äê2ÔÂ15ÈÕ ÐÞ¸ÄÄÚÈÝ : ÐÂÉú³Éº¯Êý *****************************************************************************/ VOS_UINT32 MUX_DlciUlAcmGetDataBuf(UDI_HANDLE slUdiHsicAcmHdl, VOS_UINT8 **ppucBuf, VOS_UINT16 *usDataLen) { ACM_WR_ASYNC_INFO stCtlParam; VOS_INT32 lResult; stCtlParam.pBuffer = VOS_NULL_PTR; /* »ñÈ¡µ×ÈíÉÏÐÐÊý¾Ýbuffer */ lResult= DRV_UDI_IOCTL(slUdiHsicAcmHdl, ACM_IOCTL_GET_RD_BUFF, &stCtlParam); if ( VOS_OK != lResult ) { MUX_DBG_UL_CALLBACK_FAIL_NUM(1); MUX_PrintLog1(PS_PID_APP_MUX, 0, PS_PRINT_WARNING, "MUX, MUX_DlciUlAcmGetDataBuf, WARNING, Get modem buffer failed code is %d!\r\n", lResult); return VOS_ERR; } if (VOS_NULL_PTR == stCtlParam.pBuffer) { MUX_PrintLog(PS_PID_APP_MUX, 0, PS_PRINT_WARNING, "MUX, MUX_DlciUlAcmGetDataBuf, WARNING, Data buffer is NULL!\r\n"); return VOS_ERR; } *ppucBuf = (VOS_UINT8 *)stCtlParam.pBuffer; *usDataLen = (VOS_UINT16)stCtlParam.u32Size; return VOS_OK; } /***************************************************************************** º¯ Êý Ãû : MUX_UsbAcmReadUlData ¹¦ÄÜÃèÊö : µ×ÈíÉϱ¨Êý¾ÝµÄÉÏÐÐÊý¾Ý½ÓÊÕº¯Êý ÊäÈë²ÎÊý : MUX_DEV_ACM_ID_ENUM_UINT32 enDeviceId ֪ͨÓÐÉÏÐÐÊý¾ÝµÄÉ豸id,ʹÓõÄΪÄÚ²¿ID Êä³ö²ÎÊý : ÎÞ ·µ »Ø Öµ : VOS_OK Êý¾Ý³É¹¦½ÓÊÕºÍת·¢ VOS_ERR Êý¾Ý½ÓÊÕ»òÕßת·¢Ê§°Ü µ÷Óú¯Êý : ±»µ÷º¯Êý : ÐÞ¸ÄÀúÊ· : 1.ÈÕ ÆÚ : 2012Äê8ÔÂ10ÈÕ ÐÞ¸ÄÄÚÈÝ : ÐÂÉú³Éº¯Êý *****************************************************************************/ VOS_UINT32 MUX_DlciUlUsbAcmReadData(VOS_UINT32 ulDeviceId) { UDI_HANDLE slUdiHandle; VOS_UINT8 *pucBuf; VOS_UINT16 usDataLen; slUdiHandle = g_stMuxDevInfo.slUdiMuxAcmHdl; if (UDI_INVALID_HANDLE == slUdiHandle) { MUX_DBG_GET_INVALID_UDI_HANDLE_NUM(1); MUX_PrintLog1(PS_PID_APP_MUX, 0, PS_PRINT_WARNING, "MUX, MUX_DlciUlUsbAcmReadData, can not get the slUdiHandle,ulDeviceId <1>", (VOS_INT32)ulDeviceId); return VOS_ERR; } /* µ×ÈíÏÖÓнӿڣ¬Èç¹û²»È¡³öÊý¾Ý»áÓ°ÏìÏÂÒ»¸öÊý¾ÝµÄ½ÓÊÕ */ if (VOS_OK != MUX_DlciUlAcmGetDataBuf(slUdiHandle, &pucBuf, &usDataLen)) { MUX_PrintLog(PS_PID_APP_MUX, 0, PS_PRINT_WARNING, "MUX, MUX_DlciUlUsbAcmReadData, call Mux_AcmGetUlDataBuf return fail!\n"); return VOS_ERR; } MUX_TraceUlData(ulDeviceId, pucBuf, usDataLen); MUX_DBG_UL_GET_SUCC_PKT_NUM(1); MUX_DlciUlDataProc(pucBuf, usDataLen); MUX_DlciUlQueProc(); /* Êý¾ÝÍê±Ï£¬ÊÍ·ÅÉÏÐлº´æ */ if (VOS_OK != MUX_DlciUlHsicFreeDataBuf(slUdiHandle, pucBuf, usDataLen)) { MUX_PrintLog(PS_PID_APP_MUX, 0, PS_PRINT_WARNING, "MUX, MUX_DlciUlUsbAcmReadData, call MUX_DlciUlHsicFreeDataBuf return fail!\n"); return VOS_ERR; } MUX_DBG_UL_SEND_SUCC_PKT_NUM(1); return VOS_OK; } /***************************************************************************** º¯ Êý Ãû : MUX_DlciUlUsbAcmDataRecv ¹¦ÄÜÃèÊö : ACM14É豸ÉÏÉϱ¨µÄÉÏÐÐÊý¾Ý»Øµ÷º¯Êý ÊäÈë²ÎÊý : ÎÞ Êä³ö²ÎÊý : ÎÞ ·µ »Ø Öµ : VOS_OK Êý¾Ý³É¹¦½ÓÊÕºÍת·¢ VOS_ERR Êý¾Ý½ÓÊÕ»òÕßת·¢Ê§°Ü µ÷Óú¯Êý : Mux_UsbAcmReadData ±»µ÷º¯Êý : Mux_Init ÐÞ¸ÄÀúÊ· : 1.ÈÕ ÆÚ : 2012Äê2ÔÂ15ÈÕ ÐÞ¸ÄÄÚÈÝ : ÐÂÉú³Éº¯Êý *****************************************************************************/ VOS_UINT32 MUX_DlciUlUsbAcmDataRecv( VOS_VOID) { MUX_DlciUlUsbAcmReadData(UDI_ACM_HSIC_ACM14_ID); return VOS_OK; } /***************************************************************************** º¯ Êý Ãû : MUX_DlciUlHsicFreeDataBuf ¹¦ÄÜÃèÊö : ÊÍ·ÅÉÏÐÐÊý¾Ý»º´æ ÊäÈë²ÎÊý : ulUdiHdl ---- HSIC ATͨµÀµÄ¾ä±ú pucBuf ---- ÉÏÐÐÊý¾ÝÖ¸Õë usLen ---- Êý¾Ý³¤¶È Êä³ö²ÎÊý : ÎÞ ·µ »Ø Öµ : VOS_OK ---- ³É¹¦£» VOS_ERR ---- ʧ°Ü µ÷Óú¯Êý : ±»µ÷º¯Êý : ÐÞ¸ÄÀúÊ· : 1.ÈÕ ÆÚ : 2012Äê8ÔÂ10ÈÕ ÐÞ¸ÄÄÚÈÝ : ÐÂÉú³Éº¯Êý *****************************************************************************/ VOS_UINT32 MUX_DlciUlHsicFreeDataBuf( UDI_HANDLE ulUdiHdl, VOS_UINT8 *pucBuf, VOS_UINT16 usLen ) { ACM_WR_ASYNC_INFO stCtlParam; VOS_INT32 lResult; /* ÌîдÐèÒªÊͷŵÄÄÚ´æÖ¸Õë */ stCtlParam.pBuffer = (VOS_CHAR*)pucBuf; stCtlParam.u32Size = usLen; stCtlParam.pDrvPriv = VOS_NULL_PTR; lResult = DRV_UDI_IOCTL(ulUdiHdl, ACM_IOCTL_RETURN_BUFF, &stCtlParam); if ( VOS_OK != lResult ) { MUX_DBG_UL_CALLBACK_FAIL_NUM(1); MUX_PrintLog1(PS_PID_APP_MUX, 0, PS_PRINT_WARNING, "MUX, MUX_DlciUlHsicFreeDataBuf, call DRV_UDI_IOCTL return fail!\n", lResult); return VOS_ERR; } return VOS_OK; } /***************************************************************************** º¯ Êý Ãû : MUX_DlciDlUsbAcmFreeDataCB ¹¦ÄÜÃèÊö : Ïòµ×Èí×¢²áHSICÓû§ÃæÍ¨µÀÏÂÐÐÊý¾ÝÊͷŻص÷º¯Êý ÊäÈë²ÎÊý : ÎÞ Êä³ö²ÎÊý : ÎÞ ·µ »Ø Öµ : VOS_UINT32 µ÷Óú¯Êý : ÎÞ ±»µ÷º¯Êý : ÐÞ¸ÄÀúÊ· : 1.ÈÕ ÆÚ : 2012Äê8ÔÂ10ÈÕ ÐÞ¸ÄÄÚÈÝ : ÐÂÉú³Éº¯Êý *****************************************************************************/ VOS_UINT32 MUX_DlciDlUsbAcmFreeDataCB(VOS_UINT8 *pucBuf) { BSP_FREE(pucBuf); MUX_PrintLog(PS_PID_APP_MUX, 0, PS_PRINT_INFO, "MUX, MUX_DlciDlUsbAcmFreeDataCB success!\r\n"); MUX_DBG_DL_FREE_PKT_NUM(1); return VOS_OK; } /***************************************************************************** º¯ Êý Ãû : MUX_UsbAcmWriteData ¹¦ÄÜÃèÊö : ͨ¹ýHSIC¶ÔÓ¦µÄACM¿Ú½«Êý¾Ý·¢Ë͸øµ×Èí ÊäÈë²ÎÊý : UDI_HANDLE slUdiHandle ´ýдÊý¾ÝËùÔÚÉ豸µÄ¾ä±ú VOS_UINT8 *pucBuf ´ýдÊý¾ÝµÄÖ¸Õë Êä³ö²ÎÊý : ÎÞ ·µ »Ø Öµ : VOS_UINT32 µ÷Óú¯Êý : ±»µ÷º¯Êý : ÐÞ¸ÄÀúÊ· : 1.ÈÕ ÆÚ : 2012Äê8ÔÂ10ÈÕ ÐÞ¸ÄÄÚÈÝ : ÐÂÉú³Éº¯Êý *****************************************************************************/ VOS_UINT32 MUX_DlciDlUsbAcmWriteData(UDI_HANDLE slUdiHandle, VOS_UINT8 *pucBuf, VOS_UINT16 usDataLen) { ACM_WR_ASYNC_INFO stCtlParam; VOS_INT32 ulResult; /* ´ýдÈëÊý¾ÝÄÚ´æµØÖ· */ stCtlParam.pBuffer = (VOS_CHAR*)pucBuf; stCtlParam.u32Size = usDataLen; stCtlParam.pDrvPriv = VOS_NULL_PTR; /* Òì²½·½Ê½Ð´Êý£¬*/ ulResult = DRV_UDI_IOCTL(slUdiHandle, ACM_IOCTL_WRITE_ASYNC, &stCtlParam); if ( VOS_OK != ulResult ) { MUX_PrintLog1(PS_PID_APP_MUX, 0, PS_PRINT_WARNING, "MUX_DlciDlUsbAcmWriteData, Error, Write data failed with code <1>!\r\n", ulResult); return VOS_ERR; } return VOS_OK; } /***************************************************************************** º¯ Êý Ãû : MUX_DlciAllocPayloadMem ¹¦ÄÜÃèÊö : MUXÏÂÐз¢ËÍÊý¾Ýǰ·ÖÅ仺³å¿Õ¼ä ÊäÈë²ÎÊý : ulDataLen Òª·¢Ë͵ÄÊý¾Ý³¤¶È Êä³ö²ÎÊý : ·µ »Ø Öµ : µ÷Óú¯Êý :pMem ¶ÔÓ¦µÄ»º³å¿Õ¼ä ±»µ÷º¯Êý : ÐÞ¸ÄÀúÊ· : 1.ÈÕ ÆÚ : 2012Äê8ÔÂ10ÈÕ ÐÞ¸ÄÄÚÈÝ : ÐÂÉú³Éº¯Êý *****************************************************************************/ VOS_UINT8 *MUX_DlciAllocPayloadMem(VOS_UINT16 usDataLen) { VOS_UINT8 *pucMuxDlSendBuf; if (MUX_DLCI_PAYLOAD_LEN_MAX < usDataLen) { MUX_PrintLog1(PS_PID_APP_MUX, 0, PS_PRINT_WARNING, "MUX_DlciAllocPayloadMem, Error, ulDataLen <1> is error!\r\n", usDataLen); return VOS_NULL_PTR; } /*MUX UIHÖ¡Í·²¿Îª4»ò5¸ö×Ö½Ú£¬Î²²¿Îª2Á½¸ö×Ö½Ú£¬¹²7¸ö×Ö½Ú£¬Ô¤ÏÈÉêÇëÄÚ´æ¿Õ¼ä£¬¿ÉÒÔÈÃMUXÖ±½ÓʹÓøÃÄÚ´æ×éÖ¡ */ pucMuxDlSendBuf = (VOS_UINT8 *)BSP_MALLOC((VOS_UINT32)(usDataLen + MUX_FRAME_LEN_7), MEM_NORM_DDR_POOL); if (VOS_NULL_PTR == pucMuxDlSendBuf) { MUX_PrintLog(PS_PID_APP_MUX, 0, PS_PRINT_ERROR, "MUX, MUX_DlciAllocPayloadMem, Error, g_pucMuxDlSendBuf is null!\r\n"); return VOS_NULL_PTR; } return pucMuxDlSendBuf; } /***************************************************************************** º¯ Êý Ãû : MUX_DlciDlDataProc ¹¦ÄÜÃèÊö : MUXµÄÏÂÐÐÊý¾Ý´¦Àíº¯Êý ÊäÈë²ÎÊý : VOS_UINT8 *pData ÊäÈëÊý¾ÝÖ¸Õë VOS_UINT32 ulDataLen ÊäÈëÊý¾Ý³¤¶È Êä³ö²ÎÊý : ÎÞ ·µ »Ø Öµ : ÎÞ µ÷Óú¯Êý : ±»µ÷º¯Êý : ÐÞ¸ÄÀúÊ· : 1.ÈÕ ÆÚ : 2012Äê8ÔÂ10ÈÕ ÐÞ¸ÄÄÚÈÝ : ÐÂÉú³Éº¯Êý *****************************************************************************/ VOS_UINT32 MUX_DlciDlDataProc (AT_MUX_DLCI_TYPE_ENUM_UINT8 enDlci, VOS_UINT8* pucSendBuf, VOS_UINT16 *pusSendDataLen, VOS_UINT8* pucBuf, VOS_UINT16 usDataLen) { VOS_UINT16 usFcsLen; VOS_UINT8 ucDlci; VOS_UINT8 ucFcs; ucDlci = (VOS_UINT8)enDlci; /*Ìîд֡µÄ³¤¶ÈÓò*/ if (MUX_FRAME_LEN_128 > usDataLen)/*Èç¹ûΪ³¤¶ÈÓòΪ7λ,Í·²¿ÊÇ4¸ö×Ö½Ú*/ { pucSendBuf[MUX_FRAME_LEN_0] = MUX_FRAME_FLAG; pucSendBuf[MUX_FRAME_LEN_1] = MUX_SET_116_BIT(1, 1, ucDlci); /*µØÖ·Óò°üº¬DLCI*/ pucSendBuf[MUX_FRAME_LEN_2] = MUX_CONTROL_UIH; /*¿ØÖÆÓòÄÚÈÝΪ֡ÀàÐÍ,ÈçUIH,SABM,UAµÈ*/ pucSendBuf[MUX_FRAME_LEN_3] = (VOS_UINT8)(0x01 | (usDataLen << 1)); usFcsLen = MUX_FRAME_LEN_3; *pusSendDataLen = usDataLen + MUX_FRAME_LEN_6; /*¿½±´ATÄ£¿é¹ýÀ´µÄÏÂÐÐԭʼÊý¾Ý */ VOS_MemCpy(&pucSendBuf[MUX_FRAME_LEN_4], pucBuf, usDataLen); } else /*Èç¹ûΪ³¤¶ÈÓòΪ15λ£¬Í·²¿ÊÇ5¸ö×Ö½Ú*/ { pucSendBuf[MUX_FRAME_LEN_0] = MUX_FRAME_FLAG; pucSendBuf[MUX_FRAME_LEN_1] = MUX_SET_116_BIT(1, 1, ucDlci); /*µØÖ·Óò°üº¬DLCI*/ pucSendBuf[MUX_FRAME_LEN_2] = MUX_CONTROL_UIH; /*¿ØÖÆÓòÄÚÈÝΪ֡ÀàÐÍ,ÈçUIH,SABM,UAµÈ*/ pucSendBuf[MUX_FRAME_LEN_3] = (VOS_UINT8)(((0x7F & usDataLen) << 1) & 0xFE) ; pucSendBuf[MUX_FRAME_LEN_4] = (VOS_UINT8)(usDataLen >> 7); usFcsLen = MUX_FRAME_LEN_4; *pusSendDataLen = usDataLen + MUX_FRAME_LEN_7; /*¿½±´ATÄ£¿é¹ýÀ´µÄÏÂÐÐԭʼÊý¾Ý */ VOS_MemCpy(&pucSendBuf[MUX_FRAME_LEN_5], pucBuf, usDataLen); } ucFcs = MUX_DlciGetFcs(&pucSendBuf[MUX_FRAME_LEN_1], usFcsLen); /*²úÉúFCS×Ö½Ú*/ pucSendBuf[(*pusSendDataLen - MUX_FRAME_LEN_2)] = ucFcs; pucSendBuf[(*pusSendDataLen - MUX_FRAME_LEN_1)] = MUX_FRAME_FLAG; return VOS_OK; } /***************************************************************************** º¯ Êý Ãû : MUX_DlciDlDataSend ¹¦ÄÜÃèÊö : MUXµÄÏÂÐÐÊý¾Ý½ÓÊÕº¯ÊýAPI ÊäÈë²ÎÊý : AT_MUX_DLCI_TYPE_ENUM_UINT8 enDlci Á´Â·ºÅ VOS_UINT8 *pData ÊäÈëÊý¾ÝÖ¸Õë VOS_UINT32 ulDataLen ÊäÈëÊý¾Ý³¤¶È Êä³ö²ÎÊý : ÎÞ ·µ »Ø Öµ : ÎÞ µ÷Óú¯Êý : ±»µ÷º¯Êý : ÐÞ¸ÄÀúÊ· : 1.ÈÕ ÆÚ : 2012Äê8ÔÂ10ÈÕ ÐÞ¸ÄÄÚÈÝ : ÐÂÉú³Éº¯Êý *****************************************************************************/ VOS_UINT32 MUX_DlciDlDataSend (AT_MUX_DLCI_TYPE_ENUM_UINT8 enDlci, VOS_UINT8* pData, VOS_UINT16 usDataLen) { UDI_HANDLE slUdiHandle; VOS_UINT32 ulRslt; VOS_UINT16 usSendDataLen = 0; VOS_UINT8 *pucSendDataBuf; if (VOS_NULL_PTR == pData) { MUX_PrintLog(PS_PID_APP_MUX, 0, PS_PRINT_WARNING, "MUX, MUX_DlciDlDataSend, pData is null.\r\n"); MUX_DBG_DL_SEND_FAIL_PKT_NUM(1); return VOS_ERR; } MUX_TraceDlData(enDlci, pData, usDataLen); slUdiHandle = g_stMuxDevInfo.slUdiMuxAcmHdl; if (UDI_INVALID_HANDLE == slUdiHandle) { MUX_PrintLog(PS_PID_APP_MUX, 0, PS_PRINT_WARNING, "MUX, MUX_DlciDlDataSend, slUdiHandle is invalid.\r\n"); MUX_DBG_GET_INVALID_UDI_HANDLE_NUM(1); MUX_DBG_DL_SEND_FAIL_PKT_NUM(1); /*ԭʼÊý¾ÝÊÇATÄ£¿éµÄÈ«¾Ö±äÁ¿£¬¹Ê²»ÊÍ·ÅÏÂÐÐԭʼÊý¾ÝÄÚ´æ*/ return VOS_ERR; } pucSendDataBuf = MUX_DlciAllocPayloadMem(usDataLen); if (VOS_NULL_PTR == pucSendDataBuf) { MUX_PrintLog(PS_PID_APP_MUX, 0, PS_PRINT_WARNING, "MUX, MUX_DlciDlDataSend, pucSendDataBuf is null.\r\n"); MUX_DBG_DL_SEND_FAIL_PKT_NUM(1); /*ԭʼÊý¾ÝÊÇATÄ£¿éµÄÈ«¾Ö±äÁ¿£¬¹Ê²»ÊÍ·ÅÏÂÐÐԭʼÊý¾ÝÄÚ´æ*/ return VOS_ERR; } MUX_DlciDlDataProc(enDlci, pucSendDataBuf, &usSendDataLen, pData, usDataLen); MUX_TraceDlData(enDlci, pucSendDataBuf, usSendDataLen); /*Ïòµ×Èí·¢ËÍÏÂÐÐÊý¾Ý*/ ulRslt = MUX_DlciDlUsbAcmWriteData(slUdiHandle, pucSendDataBuf, usSendDataLen); if (VOS_OK != ulRslt) { MUX_DBG_DL_SEND_FAIL_PKT_NUM(1); /*ÊÍ·ÅÊý¾ÝÄÚ´æ*/ MUX_DlciDlUsbAcmFreeDataCB(pucSendDataBuf); return VOS_ERR; } MUX_DBG_DL_SEND_SUCC_PKT_NUM(1); return VOS_OK; } /***************************************************************************** º¯ Êý Ãû : MUX_AtRgstUlPortCallBack ¹¦ÄÜÃèÊö : ATÄ£¿éÏòMUXÄ£¿é×¢²áµÄÉÏÐлص÷º¯Êý ÊäÈë²ÎÊý : AT_MUX_DLCI_TYPE_ENUM_UINT8 enDlci Á´Â·ºÅ RCV_UL_DLCI_DATA_FUNC pFunc ÉÏÐÐÊý¾Ý´¦Àíº¯ÊýÖ¸Õë Êä³ö²ÎÊý : ÎÞ ·µ »Ø Öµ : ÎÞ µ÷Óú¯Êý : ±»µ÷º¯Êý : ÐÞ¸ÄÀúÊ· : 1.ÈÕ ÆÚ : 2012Äê8ÔÂ10ÈÕ ÐÞ¸ÄÄÚÈÝ : ÐÂÉú³Éº¯Êý *****************************************************************************/ VOS_UINT32 MUX_AtRgstUlPortCallBack (AT_MUX_DLCI_TYPE_ENUM_UINT8 enDlci, RCV_UL_DLCI_DATA_FUNC pFunc) { MUX_AT_UL_DLCI_INFO_STRU *pstMuxAtUlDlciInfo; /* DlciºÏ·¨ÐÔ¼ì²é */ if (VOS_OK != MUX_DlciIsValid(enDlci)) { MUX_PrintLog1(PS_PID_APP_MUX, 0, PS_PRINT_WARNING, "MUX, MUX_AtRgstUlPortCallBack: enDlci <1> is.\r\n", enDlci); return VOS_ERR; } pstMuxAtUlDlciInfo = MUX_AT_UL_GET_DLCI_INFO_PTR(enDlci); /* ÉèÖÃADSÏÂÐÐÊý¾Ý»Øµ÷ÄÚÈÝ */ pstMuxAtUlDlciInfo->enDlci = enDlci; pstMuxAtUlDlciInfo->pRcvUlDlciDataFunc = pFunc; return VOS_OK; } /***************************************************************************** º¯ Êý Ãû : MUX_AtMsgProc ¹¦ÄÜÃèÊö : MUX½ÓÊÕÀ´×ÔATÄ£¿éµÄÏûÏ¢´¦Àíº¯Êý ÊäÈë²ÎÊý : MsgBlock *pMsgBlock ´ÓAT·¢À´µÄÏûÏ¢ Êä³ö²ÎÊý : ÎÞ ·µ »Ø Öµ : VOS_UINT32 µ÷Óú¯Êý : Ä£¿é³õʼ»¯º¯Êý£¬ÔÚNDISÈÎÎñÖÐ ±»µ÷º¯Êý : ÐÞ¸ÄÀúÊ· : 1.ÈÕ ÆÚ : 2012Äê8ÔÂ10ÈÕ ÐÞ¸ÄÄÚÈÝ : ÐÂÉú³Éº¯Êý *****************************************************************************/ VOS_UINT32 MUX_AtMsgProc( const MsgBlock *pMsgBlock ) { return VOS_OK; } /***************************************************************************** º¯ Êý Ãû : MUX_OpenDevice ¹¦ÄÜÃèÊö : MUXʹÓõÄHSICÓû§ÃæÊý¾ÝÉ豸³õʼ»¯ ÊäÈë²ÎÊý : DEV_INFO_STRU *pstDevInfo É豸Ïà¹Ø½á¹¹ Êä³ö²ÎÊý : ÎÞ ·µ »Ø Öµ : VOS_OK:³É¹¦£» VOS_ERR:ʧ°Ü µ÷Óú¯Êý : ±»µ÷º¯Êý : Mux_Init ÐÞ¸ÄÀúÊ· : 1.ÈÕ ÆÚ : 2012Äê8ÔÂ10ÈÕ ÐÞ¸ÄÄÚÈÝ : ÐÂÉú³Éº¯Êý *****************************************************************************/ VOS_UINT32 MUX_OpenDevice(MUX_DEV_INFO_STRU *pstDevInfo) { UDI_OPEN_PARAM stParam; stParam.devid = pstDevInfo->enUdiDevId; pstDevInfo->slUdiMuxAcmHdl = DRV_UDI_OPEN(&stParam); if (UDI_INVALID_HANDLE == pstDevInfo->slUdiMuxAcmHdl) { MUX_DBG_GET_INVALID_UDI_HANDLE_NUM(1); MUX_PrintLog(PS_PID_APP_MUX, 0, PS_PRINT_ERROR, "MUX, MUX_OpenDevice, Call DRV_UDI_OPEN return UDI_INVALID_HANDLE.\n"); return VOS_ERR; } /* ×¢²áHSIC ACM Óû§ÃæÍ¨µÀÉÏÐÐÊý¾Ý½ÓÊջص÷ */ if (VOS_OK != DRV_UDI_IOCTL (pstDevInfo->slUdiMuxAcmHdl, ACM_IOCTL_SET_READ_CB, pstDevInfo->pMuxAcmUlRxFunc)) { MUX_DBG_UL_CALLBACK_FAIL_NUM(1); MUX_PrintLog(PS_PID_APP_MUX, 0, PS_PRINT_ERROR, "MUX, MUX_OpenDevice, ERROR, Set HSIC ACM data read callback failed!\n"); return VOS_ERR; } /* ×¢²áHSIC ACM Óû§ÃæÍ¨µÀÏÂÐÐÊý¾ÝÄÚ´æÊÍ·Å½Ó¿Ú */ if (VOS_OK != DRV_UDI_IOCTL (pstDevInfo->slUdiMuxAcmHdl, ACM_IOCTL_SET_FREE_CB, MUX_DlciDlUsbAcmFreeDataCB)) { MUX_DBG_UL_CALLBACK_FAIL_NUM(1); MUX_PrintLog(PS_PID_APP_MUX, 0, PS_PRINT_ERROR, "MUX, MUX_OpenDevice, ERROR, Set HSIC ACM memory free callback failed!\n"); return VOS_ERR; } return VOS_OK; } /***************************************************************************** º¯ Êý Ãû : MUX_PortInit ¹¦ÄÜÃèÊö : APPºË MUX¹¦Äܶ˿ڳõʼ»¯º¯Êý ÊäÈë²ÎÊý : VOS_VOID Êä³ö²ÎÊý : ÎÞ ·µ »Ø Öµ : VOS_OK ³õʼ»¯³É¹¦ VOS_ERR ³õʼ»¯Ê§°Ü µ÷Óú¯Êý : ±»µ÷º¯Êý : Mux_Pid_Init ÐÞ¸ÄÀúÊ· : 1.ÈÕ ÆÚ : 2012Äê8ÔÂ10ÈÕ ÐÞ¸ÄÄÚÈÝ : ÐÂÉú³Éº¯Êý *****************************************************************************/ VOS_UINT32 MUX_PortInit( VOS_VOID ) { BSP_MODULE_SUPPORT_E enSupport; enSupport = DRV_GET_HSIC_SUPPORT(); /* ²úÆ·²»Ö§³ÖHSICÌØÐÔ£¬Ö±½Ó³õʼ»¯³É¹¦ */ if (BSP_MODULE_SUPPORT != enSupport) { MUX_PrintLog1(PS_PID_APP_MUX, 0, PS_PRINT_WARNING, "MUX, MUX_PortInit, Hsic not support <1>.\r\n", enSupport); return VOS_OK; } /* ³õʼ»¯MUXͨµÀÐÅÏ¢ */ g_stMuxDevInfo.enUdiDevId = UDI_ACM_HSIC_ACM14_ID; g_stMuxDevInfo.pMuxAcmUlRxFunc = MUX_DlciUlUsbAcmDataRecv; g_stMuxDevInfo.slUdiMuxAcmHdl = UDI_INVALID_HANDLE; if (VOS_OK != MUX_OpenDevice(&g_stMuxDevInfo)) { MUX_PrintLog1(PS_PID_APP_MUX, 0, PS_PRINT_WARNING, "MUX, MUX_PortInit, Open Device <1> fail.\n", (VOS_INT32)g_stMuxDevInfo.enUdiDevId); return VOS_ERR; } return VOS_OK; } /***************************************************************************** º¯ Êý Ãû : MUX_Init ¹¦ÄÜÃèÊö : APPºË MUX¹¦Äܵijõʼ»¯º¯Êý ÊäÈë²ÎÊý : VOS_VOID Êä³ö²ÎÊý : ÎÞ ·µ »Ø Öµ : VOS_OK ³õʼ»¯³É¹¦ VOS_ERR ³õʼ»¯Ê§°Ü µ÷Óú¯Êý : ±»µ÷º¯Êý : Mux_Pid_InitFunc ÐÞ¸ÄÀúÊ· : 1.ÈÕ ÆÚ : 2012Äê8ÔÂ10ÈÕ ÐÞ¸ÄÄÚÈÝ : ÐÂÉú³Éº¯Êý *****************************************************************************/ VOS_UINT32 MUX_Init( VOS_VOID ) { VOS_UINT8 ucMuxSupportFlg; VOS_UINT32 ulDlciLoop; ucMuxSupportFlg = VOS_FALSE; /* ¶ÁNVʧ°Ü£¬Ö±½Ó·µ»Ø */ if (NV_OK != NV_Read(en_NV_Item_Mux_Support_Flg, &ucMuxSupportFlg, sizeof(VOS_UINT8))) { MUX_PrintLog(PS_PID_APP_MUX, 0, PS_PRINT_ERROR, "MUX, MUX_Init, read mux nv fail.\r\n"); return VOS_ERR; } /* MUXÌØÐÔ²»Ö§³Ö£¬Ö±½Ó·µ»Ø */ if (VOS_TRUE != ucMuxSupportFlg) { MUX_PrintLog(PS_PID_APP_MUX, 0, PS_PRINT_ERROR, "MUX, MUX_Init, mux not support.\r\n"); return VOS_ERR; } /* ³õʼ»¯ÉÏÐÐÁ´Â·ºÅÐÅÏ¢ */ for (ulDlciLoop = 0; ulDlciLoop < AT_MUX_DLCI_TYPE_BUTT; ulDlciLoop++) { g_stMuxAtUlDlciInfo[ulDlciLoop].enDlci = AT_MUX_DLCI_TYPE_BUTT; g_stMuxAtUlDlciInfo[ulDlciLoop].pRcvUlDlciDataFunc = VOS_NULL_PTR; } VOS_MemSet(&g_stMuxUnframeState, 0, sizeof(MUX_UNFRAME_STATE_ST)); /* ³õʼ»¯ÉÏÐжÓÁÐ */ TTF_QInit(PS_PID_APP_MUX, &g_stMuxUlQue); /* Èç¹ûHSICͨµÀÒѾ­Ã¶¾Ù³É¹¦£¬ÔòÓÉЭÒéÕ»Ö´Ðгõʼ»¯²Ù×÷£»·ñÔò½«³õʼ»¯º¯Êý×¢²áÖÁµ×Èí£¬ Óɵ×ÈíÔÚHSICö¾Ù³É¹¦ºóµ÷ÓÃÒÔ½øÐгõʼ»¯*/ if (VOS_TRUE == DRV_GET_HSIC_ENUM_STATUS()) { MUX_PrintLog(PS_PID_APP_MUX, 0, PS_PRINT_INFO, "MUX, MUX_Init, Hsic enum success.\r\n"); MUX_PortInit(); } else { DRV_HSIC_REGUDI_ENABLECB((HSIC_UDI_ENABLE_CB_T)MUX_PortInit); MUX_PrintLog(PS_PID_APP_MUX, 0, PS_PRINT_INFO, "MUX, MUX_Init, Hsic enum fail.\r\n"); } MUX_StaticInfoInit(); return VOS_OK; } /***************************************************************************** º¯ Êý Ãû : MUX_Pid_InitFunc ¹¦ÄÜÃèÊö : MUXÄ£¿é PID³õʼ»¯ ÊäÈë²ÎÊý : VOS_INIT_PHASE_DEFINE ip ³õʼ»¯ÀàÐÍ Êä³ö²ÎÊý : ÎÞ ·µ »Ø Öµ : VOS_UINT32 µ÷Óú¯Êý : ±»µ÷º¯Êý : Ä£¿é³õʼ»¯º¯Êý ÐÞ¸ÄÀúÊ· : 1.ÈÕ ÆÚ : 2012Äê8ÔÂ10ÈÕ ÐÞ¸ÄÄÚÈÝ : ÐÂÉú³Éº¯Êý *****************************************************************************/ VOS_UINT32 MUX_Pid_InitFunc( enum VOS_INIT_PHASE_DEFINE ip ) { switch( ip ) { case VOS_IP_LOAD_CONFIG: MUX_Init(); break; case VOS_IP_FARMALLOC: case VOS_IP_INITIAL: case VOS_IP_ENROLLMENT: case VOS_IP_LOAD_DATA: case VOS_IP_FETCH_DATA: case VOS_IP_STARTUP: case VOS_IP_RIVAL: case VOS_IP_KICKOFF: case VOS_IP_STANDBY: case VOS_IP_BROADCAST_STATE: case VOS_IP_RESTART: break; default: break; } return VOS_OK; } /***************************************************************************** º¯ Êý Ãû : MUX_TraceUlData ¹¦ÄÜÃèÊö : MUXÄ£¿é¶ÔÓÚµ×ÈíÉϱ¨µÄÊý¾Ý½øÐй´°ü£¬ÊÇ·ñÊä³öʹÓÃÈ«¾Ö±äÁ¿¿ØÖÆ ÊäÈë²ÎÊý : VOS_UINT32 ulDeviceId ֪ͨÓÐÉÏÐÐÊý¾ÝµÄÉ豸id,ʹÓõÄΪÄÚ²¿ID VOS_UINT8 *pucBuf ÉÏÐÐÊý¾ÝµØÖ· VOS_UINT16 usLen ÉÏÐÐÊý¾Ý³¤¶È Êä³ö²ÎÊý : ÎÞ ·µ »Ø Öµ : ÎÞ µ÷Óú¯Êý : ±»µ÷º¯Êý : ÐÞ¸ÄÀúÊ· : 1.ÈÕ ÆÚ : 2012Äê8ÔÂ10ÈÕ ÐÞ¸ÄÄÚÈÝ : ÐÂÉú³Éº¯Êý *****************************************************************************/ VOS_VOID MUX_TraceUlData(VOS_UINT32 ulDeviceId, VOS_UINT8 *pucBuf, VOS_UINT16 usLen) { VOS_UINT16 usLoop = 0; if (PS_TRUE != g_ulMuxTraceFlag) { return; } vos_printf("MUX_TraceUlData::ulDeviceId:%d, UL DataLen:%d, UL Data Start:\r\n", ulDeviceId, usLen); for (usLoop = 0; usLoop < usLen; usLoop++) { vos_printf("%x ", *(pucBuf + usLoop)); } vos_printf(" End.\r\n"); return; } /***************************************************************************** º¯ Êý Ãû : MUX_TraceDlData ¹¦ÄÜÃèÊö : MUXÄ£¿é¶ÔÓÚÏÂÐеÄÊý¾Ý½øÐй´°ü£¬ÊÇ·ñÊä³öʹÓÃÈ«¾Ö±äÁ¿¿ØÖÆ ÊäÈë²ÎÊý : AT_MUX_DLCI_TYPE_ENUM_UINT8 enDlci Á´Â·ºÅ VOS_UINT8 *pData ÏÂÐÐÊý¾ÝÖ¸Õë VOS_UINT32 ulDataLen ÏÂÐÐÊý¾Ý³¤¶È Êä³ö²ÎÊý : ÎÞ ·µ »Ø Öµ : ÎÞ µ÷Óú¯Êý : ±»µ÷º¯Êý : ÐÞ¸ÄÀúÊ· : 1.ÈÕ ÆÚ : 2012Äê8ÔÂ10ÈÕ ÐÞ¸ÄÄÚÈÝ : ÐÂÉú³Éº¯Êý *****************************************************************************/ VOS_VOID MUX_TraceDlData(AT_MUX_DLCI_TYPE_ENUM_UINT8 enDlci, VOS_UINT8 *pData, VOS_UINT16 usDataLen) { VOS_UINT16 usLoop = 0; if (PS_TRUE != g_ulMuxTraceFlag) { return; } vos_printf("MUX_TraceDlData::enDlci:%d,DL DataLen:%d, DL Data Start:\r\n", enDlci, usDataLen); for (usLoop = 0; usLoop < usDataLen; usLoop++) { vos_printf("%x ", pData[usLoop]); } vos_printf(" End.\r\n"); return; } /***************************************************************************** º¯ Êý Ãû : MUX_StaticInfoInit ¹¦ÄÜÃèÊö : AºË MUX¹¦ÄÜͳ¼ÆÐÅÏ¢³õʼ»¯ ÊäÈë²ÎÊý : VOS_VOID Êä³ö²ÎÊý : ÎÞ ·µ »Ø Öµ : ÎÞ µ÷Óú¯Êý : ÎÞ ±»µ÷º¯Êý : ÊÖ¶¯ÔÚ´®¿ÚÊäÈëµ÷Óà ÐÞ¸ÄÀúÊ· : 1.ÈÕ ÆÚ : 2012Äê8ÔÂ10ÈÕ ÐÞ¸ÄÄÚÈÝ : ÐÂÉú³Éº¯Êý *****************************************************************************/ VOS_VOID MUX_StaticInfoInit( VOS_VOID ) { PS_MEM_SET(&g_stMuxStaticInfo, 0, sizeof(MUX_DEV_STATIC_INFO_STRU)); return; } /***************************************************************************** º¯ Êý Ãû : MUX_ShowStat ¹¦ÄÜÃèÊö : AºË MUXͳ¼ÆÐÅÏ¢´òÓ¡ ÊäÈë²ÎÊý : VOS_VOID Êä³ö²ÎÊý : ÎÞ ·µ »Ø Öµ : ÎÞ µ÷Óú¯Êý : ±»µ÷º¯Êý : ÐÞ¸ÄÀúÊ· : 1.ÈÕ ÆÚ : 2012Äê8ÔÂ10ÈÕ ÐÞ¸ÄÄÚÈÝ : ÐÂÉú³Éº¯Êý *****************************************************************************/ VOS_VOID MUX_ShowStat( VOS_VOID ) { vos_printf("===========MUX_ShowStat============"); vos_printf("MUX Dev Static Info.\r\n"); vos_printf("MUX Invalid Udi Handle Num = %d.\r\n", g_stMuxStaticInfo.ulInvalidUdiHandleNums); vos_printf("MUX Ul Callback Fail Num = %d.\r\n", g_stMuxStaticInfo.ulGetDataFailNums); vos_printf("MUX Ul Discard PakcetNum = %u\r\n", g_stMuxStaticInfo.ulDiscardUlPacketNums); vos_printf("MUX Ul Succ Get PakcetNum = %u\r\n", g_stMuxStaticInfo.ulSuccGetUlPacketNums); vos_printf("MUX Ul FailSend PakcetNum = %u\r\n", g_stMuxStaticInfo.ulFailSendUlPacketNums); vos_printf("MUX Ul SuccSend PakcetNum = %u\r\n", g_stMuxStaticInfo.ulSuccSendUlPacketNums); vos_printf("MUX Dl FailSend PakcetNum = %u\r\n", g_stMuxStaticInfo.ulFailSendDlPacketNums); vos_printf("MUX Dl SuccSend PakcetNum = %u\r\n", g_stMuxStaticInfo.ulSuccSendDlPacketNums); vos_printf("MUX Dl Free PakcetNum = %u\r\n", g_stMuxStaticInfo.ulFreeDlPacketNums); vos_printf("\r\n"); return; } /***************************************************************************** º¯ Êý Ãû : MUX_SetTraceFlag ¹¦ÄÜÃèÊö : MUX Trace¿ª¹Ø´ò¿ª ÊäÈë²ÎÊý : VOS_UINT32 ulFlag ÊäÈë²ÎÊýÐ޸ıêʶ Êä³ö²ÎÊý : ÎÞ ·µ »Ø Öµ : ÎÞ µ÷Óú¯Êý : ±»µ÷º¯Êý : ÐÞ¸ÄÀúÊ· : 1.ÈÕ ÆÚ : 2012Äê2ÔÂ24ÈÕ ÐÞ¸ÄÄÚÈÝ : ÐÂÉú³Éº¯Êý *****************************************************************************/ VOS_VOID MUX_SetTraceFlag( VOS_UINT32 ulFlag ) { g_ulMuxTraceFlag = ulFlag; return; } /***************************************************************************** º¯ Êý Ãû : MUX_SetLogFlag ¹¦ÄÜÃèÊö : MUX Log¿ª¹Ø´ò¿ª ÊäÈë²ÎÊý : VOS_UINT32 ulFlag ÊäÈë²ÎÊýÐ޸ıêʶ Êä³ö²ÎÊý : ÎÞ ·µ »Ø Öµ : ÎÞ µ÷Óú¯Êý : ±»µ÷º¯Êý : ÐÞ¸ÄÀúÊ· : 1.ÈÕ ÆÚ : 2012Äê2ÔÂ24ÈÕ ÐÞ¸ÄÄÚÈÝ : ÐÂÉú³Éº¯Êý *****************************************************************************/ VOS_VOID MUX_SetLogFlag( VOS_UINT32 ulFlag ) { g_ulMuxPrintFlag = ulFlag; return; } #ifdef __cplusplus #if __cplusplus } #endif #endif
araca/Zen-Kernel-Huawei-P7
drivers/hisi/modem/ps/comm/comm/MUX/Src/PsMux.c
C
gpl-2.0
52,780
package by.falc0n.util; /** * Contains a set of extension methods and constants to operate with arrays * (primitive and object). * * @author falc0n * @version 1.0 * */ public final class ArrayExt { /** * An empty {@code byte} array. * * @since 1.0 */ public static final byte[] EMPTY_BYTE_ARRAY = new byte[0]; /** * An empty {@code short} array. * * @since 1.0 */ public static final short[] EMPTY_SHORT_ARRAY = new short[0]; /** * An empty {@code int} array. * * @since 1.0 */ public static final int[] EMPTY_INT_ARRAY = new int[0]; /** * An empty {@code long} array. * * @since 1.0 */ public static final long[] EMPTY_LONG_ARRAY = new long[0]; /** * An empty {@code float} array. * * @since 1.0 */ public static final float[] EMPTY_FLOAT_ARRAY = new float[0]; /** * An empty {@code double} array. * * @since 1.0 */ public static final double[] EMPTY_DOUBLE_ARRAY = new double[0]; /** * An empty {@code char} array. * * @since 1.0 */ public static final char[] EMPTY_CHAR_ARRAY = new char[0]; /** * An empty {@code boolean} array. * * @since 1.0 */ public static final boolean[] EMPTY_BOOLEAN_ARRAY = new boolean[0]; /** * An empty {@link Byte} array. * * @since 1.0 */ public static final Byte[] EMPTY_BYTE_OBJECT_ARRAY = new Byte[0]; /** * An empty {@link Short} array. * * @since 1.0 */ public static final Short[] EMPTY_SHORT_OBJECT_ARRAY = new Short[0]; /** * An empty {@link Integer} array. * * @since 1.0 */ public static final Integer[] EMPTY_INT_OBJECT_ARRAY = new Integer[0]; /** * An empty {@link Long} array. * * @since 1.0 */ public static final Long[] EMPTY_LONG_OBJECT_ARRAY = new Long[0]; /** * An empty {@link Float} array. * * @since 1.0 */ public static final Float[] EMPTY_FLOAT_OBJECT_ARRAY = new Float[0]; /** * An empty {@link Double} array. * * @since 1.0 */ public static final Double[] EMPTY_DOUBLE_OBJECT_ARRAY = new Double[0]; /** * An empty {@link Character} array. * * @since 1.0 */ public static final Character[] EMPTY_CHAR_OBJECT_ARRAY = new Character[0]; /** * An empty {@link Boolean} array. * * @since 1.0 */ public static final Boolean[] EMPTY_BOOLEAN_OBJECT_ARRAY = new Boolean[0]; /** * An empty object array. * * @since 1.0 */ public static final Object[] EMPTY_OBJECT_ARRAY = new Object[0]; /** * Checks whether the {@code byte} array contains the specified value. The * array shouldn't be {@code null}. * * @param array * - an array to check * @param value * - a value to search for * @return {@code true} - if the array contains the value; {@code false} - * otherwise * * @since 1.0 */ public static final boolean contains(byte[] array, byte value) { boolean result = false; for (int i = 0; i < array.length; i++) { if (value == array[i]) { result = true; break; } } return result; } /** * Checks whether the {@code short} array contains the specified value. The * array shouldn't be {@code null}. * * @param array * - an array to check * @param value * - a value to search for * @return {@code true} - if the array contains the value; {@code false} - * otherwise * * @since 1.0 */ public static final boolean contains(short[] array, short value) { boolean result = false; for (int i = 0; i < array.length; i++) { if (value == array[i]) { result = true; break; } } return result; } /** * Checks whether the {@code int} array contains the specified value. The * array shouldn't be {@code null}. * * @param array * - an array to check * @param value * - a value to search for * @return {@code true} - if the array contains the value; {@code false} - * otherwise * * @since 1.0 */ public static final boolean contains(int[] array, int value) { boolean result = false; for (int i = 0; i < array.length; i++) { if (value == array[i]) { result = true; break; } } return result; } /** * Checks whether the {@code long} array contains the specified value. The * array shouldn't be {@code null}. * * @param array * - an array to check * @param value * - a value to search for * @return {@code true} - if the array contains the value; {@code false} - * otherwise * * @since 1.0 */ public static final boolean contains(long[] array, long value) { boolean result = false; for (int i = 0; i < array.length; i++) { if (value == array[i]) { result = true; break; } } return result; } /** * Checks whether the {@code float} array contains the specified value. The * array shouldn't be {@code null}. * * @param array * - an array to check * @param value * - a value to search for * @return {@code true} - if the array contains the value; {@code false} - * otherwise * * @since 1.0 */ public static final boolean contains(float[] array, float value) { boolean result = false; for (int i = 0; i < array.length; i++) { if (value == array[i]) { result = true; break; } } return result; } /** * Checks whether the {@code double} array contains the specified value. The * array shouldn't be {@code null}. * * @param array * - an array to check * @param value * - a value to search for * @return {@code true} - if the array contains the value; {@code false} - * otherwise * * @since 1.0 */ public static final boolean contains(double[] array, double value) { boolean result = false; for (int i = 0; i < array.length; i++) { if (value == array[i]) { result = true; break; } } return result; } /** * Checks whether the {@code char} array contains the specified value. The * array shouldn't be {@code null}. * * @param array * - an array to check * @param value * - a value to search for * @return {@code true} - if the array contains the value; {@code false} - * otherwise * * @since 1.0 */ public static final boolean contains(char[] array, char value) { boolean result = false; for (int i = 0; i < array.length; i++) { if (value == array[i]) { result = true; break; } } return result; } /** * Checks whether the {@code boolean} array contains the specified value. * The array shouldn't be {@code null}. * * @param array * - an array to check * @param value * - a value to search for * @return {@code true} - if the array contains the value; {@code false} - * otherwise * * @since 1.0 */ public static final boolean contains(boolean[] array, boolean value) { boolean result = false; for (int i = 0; i < array.length; i++) { if (value == array[i]) { result = true; break; } } return result; } /** * Checks whether the object array contains the specified value. "Contains" * means that the array has an element which equals (see * {@link #equals(Object)} ) to the value or they're both {@code null}. The * array shouldn't be {@code null}. * * @param array * - an array to check * @param value * - a value to search for * @return {@code true} - if the array contains the value; {@code false} - * otherwise * * @since 1.0 */ public static final boolean contains(Object[] array, Object value) { boolean result = false; for (int i = 0; i < array.length; i++) { if (ObjectExt.equalOrNull(array[i], value)) { result = true; break; } } return result; } /** * Converts the {@code byte} array to an array of corresponding objects. If * the input array is {@code null}, then {@code null} will be returned. * * @param array * - an array to convert * @return an array of objects or {@code null} * * @since 1.0 */ public static final Byte[] toObjectArray(byte[] array) { Byte[] objArray = null; if (array != null) { if (array.length > 0) { objArray = new Byte[array.length]; for (int i = 0; i < array.length; i++) { objArray[i] = array[i]; } } else { objArray = EMPTY_BYTE_OBJECT_ARRAY; } } return objArray; } /** * Converts the {@code short} array to an array of corresponding objects. If * the input array is {@code null}, then {@code null} will be returned. * * @param array * - an array to convert * @return an array of objects or {@code null} * * @since 1.0 */ public static final Short[] toObjectArray(short[] array) { Short[] objArray = null; if (array != null) { if (array.length > 0) { objArray = new Short[array.length]; for (int i = 0; i < array.length; i++) { objArray[i] = array[i]; } } else { objArray = EMPTY_SHORT_OBJECT_ARRAY; } } return objArray; } /** * Converts the {@code int} array to an array of corresponding objects. If * the input array is {@code null}, then {@code null} will be returned. * * @param array * - an array to convert * @return an array of objects or {@code null} * * @since 1.0 */ public static final Integer[] toObjectArray(int[] array) { Integer[] objArray = null; if (array != null) { if (array.length > 0) { objArray = new Integer[array.length]; for (int i = 0; i < array.length; i++) { objArray[i] = array[i]; } } else { objArray = EMPTY_INT_OBJECT_ARRAY; } } return objArray; } /** * Converts the {@code long} array to an array of corresponding objects. If * the input array is {@code null}, then {@code null} will be returned. * * @param array * - an array to convert * @return an array of objects or {@code null} * * @since 1.0 */ public static final Long[] toObjectArray(long[] array) { Long[] objArray = null; if (array != null) { if (array.length > 0) { objArray = new Long[array.length]; for (int i = 0; i < array.length; i++) { objArray[i] = array[i]; } } else { objArray = EMPTY_LONG_OBJECT_ARRAY; } } return objArray; } /** * Converts the {@code float} array to an array of corresponding objects. If * the input array is {@code null}, then {@code null} will be returned. * * @param array * - an array to convert * @return an array of objects or {@code null} * * @since 1.0 */ public static final Float[] toObjectArray(float[] array) { Float[] objArray = null; if (array != null) { if (array.length > 0) { objArray = new Float[array.length]; for (int i = 0; i < array.length; i++) { objArray[i] = array[i]; } } else { objArray = EMPTY_FLOAT_OBJECT_ARRAY; } } return objArray; } /** * Converts the {@code double} array to an array of corresponding objects. * If the input array is {@code null}, then {@code null} will be returned. * * @param array * - an array to convert * @return an array of objects or {@code null} * * @since 1.0 */ public static final Double[] toObjectArray(double[] array) { Double[] objArray = null; if (array != null) { if (array.length > 0) { objArray = new Double[array.length]; for (int i = 0; i < array.length; i++) { objArray[i] = array[i]; } } else { objArray = EMPTY_DOUBLE_OBJECT_ARRAY; } } return objArray; } /** * Converts the {@code char} array to an array of corresponding objects. If * the input array is {@code null}, then {@code null} will be returned. * * @param array * - an array to convert * @return an array of objects or {@code null} * * @since 1.0 */ public static final Character[] toObjectArray(char[] array) { Character[] objArray = null; if (array != null) { if (array.length > 0) { objArray = new Character[array.length]; for (int i = 0; i < array.length; i++) { objArray[i] = array[i]; } } else { objArray = EMPTY_CHAR_OBJECT_ARRAY; } } return objArray; } /** * Converts the {@code boolean} array to an array of corresponding objects. * If the input array is {@code null}, then {@code null} will be returned. * * @param array * - an array to convert * @return an array of objects or {@code null} * * @since 1.0 */ public static final Boolean[] toObjectArray(boolean[] array) { Boolean[] objArray = null; if (array != null) { if (array.length > 0) { objArray = new Boolean[array.length]; for (int i = 0; i < array.length; i++) { objArray[i] = array[i]; } } else { objArray = EMPTY_BOOLEAN_OBJECT_ARRAY; } } return objArray; } public static final byte[] toPrimitiveArray(Byte[] array) { byte[] primArray = null; if (array != null) { if (array.length > 0) { primArray = new byte[array.length]; for (int i = 0; i < array.length; i++) { primArray[i] = array[i]; } } else { primArray = EMPTY_BYTE_ARRAY; } } return primArray; } public static final byte[] toPrimitiveArray(Byte[] array, byte nullValue) { byte[] primArray = null; if (array != null) { if (array.length > 0) { primArray = new byte[array.length]; for (int i = 0; i < array.length; i++) { primArray[i] = (array[i] != null) ? array[i] : nullValue; } } else { primArray = EMPTY_BYTE_ARRAY; } } return primArray; } private ArrayExt() { super(); } }
fa1con/falc0n-utils
src/main/java/by/falc0n/util/ArrayExt.java
Java
gpl-2.0
13,659
/* { dg-require-effective-target arm_arch_v8a_ok } */ /* { dg-do compile } */ /* { dg-options "-O2" } */ /* { dg-add-options arm_arch_v8a } */ #include "../aarch64/atomic-op-relaxed.x" /* { dg-final { scan-assembler-times "ldrex\tr\[0-9\]+, \\\[r\[0-9\]+\\\]" 6 } } */ /* { dg-final { scan-assembler-times "strex\t...?, r\[0-9\]+, \\\[r\[0-9\]+\\\]" 6 } } */ /* { dg-final { scan-assembler-not "dmb" } } */
Mustaavalkosta/toolchain_gcc-4.9
gcc/testsuite/gcc.target/arm/atomic-op-relaxed.c
C
gpl-2.0
409
<?php /** * @package CrowdfundingPartners * @subpackage Files * @author Todor Iliev * @copyright Copyright (C) 2015 Todor Iliev <todor@itprism.com>. All rights reserved. * @license http://www.gnu.org/copyleft/gpl.html GNU/GPL */ namespace CrowdfundingPartners; use Prism\Database\ArrayObject; use Joomla\Utilities\ArrayHelper; defined('JPATH_PLATFORM') or die; /** * This class provides functionality that manage partners. * * @package CrowdfundingPartners * @subpackage Parnters */ class Partners extends ArrayObject { /** * Load partners data by ID from database. * * <code> * $ids = array(1,2,3,4,5); * * $partners = new CrowdfundingPartners\Partners(JFactory::getDbo()); * $partners->load($ids); * * foreach($partners as $partner) { * echo $partners["name"]; * echo $partners["partner_id"]; * } * </code> * * @param int $projectId * @param array $ids */ public function load($projectId = 0, $ids = array()) { // Load project data $query = $this->db->getQuery(true); $query ->select("a.id, a.name, a.project_id, a.partner_id") ->from($this->db->quoteName("#__cfpartners_partners", "a")); if (!empty($ids)) { ArrayHelper::toInteger($ids); $query->where("a.id IN ( " . implode(",", $ids) . " )"); } if (!empty($projectId)) { $query->where("a.project_id = " . (int)$projectId); } $this->db->setQuery($query); $results = $this->db->loadAssocList(); if (!$results) { $results = array(); } $this->items = $results; } /** * Add a new value to the array. * * <code> * $partner = array( * "name" => "John Dow", * "project_id" => 1, * "partner_id" => 2 * ); * * $partners = new CrowdfundingPartners\Partners(); * $partners->add($partner); * </code> * * @param array $value * @param null|int $index * * @return $this */ public function add($value, $index = null) { if (!is_null($index)) { $this->items[$index] = $value; } else { $this->items[] = $value; } return $this; } }
Creativetech-Solutions/joomla-easysocial-network
libraries/CrowdfundingPartners/Partners.php
PHP
gpl-2.0
2,368
<?php get_header(); ?> <div id="content" class="clearfix row"> <div class="row centered"> <div class="brandhead"> <h1 class="">News and Articles</h1> <p class="lead">A partnership to deliver high quality, efficient patient care for South Yorkshire, Mid Yorkshire and North Derbyshire</p> </div> </div> <div id="main" class="col-sm-8 clearfix" role="main"> <?php if (have_posts()) : while (have_posts()) : the_post(); ?> <article id="post-<?php the_ID(); ?>" <?php post_class('clearfix'); ?> role="article"> <header> <a href="<?php the_permalink() ?>" title="<?php the_title_attribute(); ?>"><?php the_post_thumbnail( 'wpbs-featured' ); ?></a> <div class="article-header"><h1 class="h2"><a href="<?php the_permalink() ?>" rel="bookmark" title="<?php the_title_attribute(); ?>"><?php the_title(); ?></a></h1></div> <p class="meta"><?php _e("Posted", "wpbootstrap"); ?> <time datetime="<?php echo the_time('Y-m-j'); ?>" pubdate><?php the_time(); ?></time> <?php _e("by", "wpbootstrap"); ?> <?php the_author_posts_link(); ?> <span class="amp">&</span> <?php _e("filed under", "wpbootstrap"); ?> <?php the_category(', '); ?>.</p> </header> <!-- end article header --> <section class="post_content clearfix"> <?php the_content( __("Read more &raquo;","wpbootstrap") ); ?> </section> <!-- end article section --> <footer> <p class="tags"><?php the_tags('<span class="tags-title">' . __("Tags","wpbootstrap") . ':</span> ', ' ', ''); ?></p> </footer> <!-- end article footer --> </article> <!-- end article --> <?php endwhile; ?> <?php if (function_exists('page_navi')) { // if expirimental feature is active ?> <?php page_navi(); // use the page navi function ?> <?php } else { // if it is disabled, display regular wp prev & next links ?> <nav class="wp-prev-next"> <ul class="pager"> <li class="previous"><?php next_posts_link(_e('&laquo; Older Entries', "wpbootstrap")) ?></li> <li class="next"><?php previous_posts_link(_e('Newer Entries &raquo;', "wpbootstrap")) ?></li> </ul> </nav> <?php } ?> <?php else : ?> <article id="post-not-found"> <header> <h1><?php _e("Not Found", "wpbootstrap"); ?></h1> </header> <section class="post_content"> <p><?php _e("Sorry, but the requested resource was not found on this site.", "wpbootstrap"); ?></p> </section> <footer> </footer> </article> <?php endif; ?> </div> <!-- end #main --> <?php get_sidebar(); // sidebar 1 ?> </div> <!-- end #content --> <?php get_footer(); ?>
gitpress/together
wp-content/themes/wordpress-bootstrap-master/index.php
PHP
gpl-2.0
2,891
#ifdef __amd64__ #include <stdint.h> #include <stdio.h> #include <stdlib.h> #include "../86box.h" #include "cpu.h" #include "x86.h" #include "x86_flags.h" #include "x86_ops.h" #include "x87.h" #include "../mem.h" #include "386_common.h" #include "codegen.h" #include "codegen_ops.h" #include "codegen_ops_x86-64.h" #if defined(__linux__) || defined(__APPLE__) #include <sys/mman.h> #include <unistd.h> #endif #if WIN64 #include <windows.h> #endif int codegen_flat_ds, codegen_flat_ss; int codegen_flags_changed = 0; int codegen_fpu_entered = 0; int codegen_fpu_loaded_iq[8]; int codegen_reg_loaded[8]; x86seg *op_ea_seg; int op_ssegs; uint32_t op_old_pc; uint32_t recomp_page = -1; int host_reg_mapping[NR_HOST_REGS]; int host_reg_xmm_mapping[NR_HOST_XMM_REGS]; codeblock_t *codeblock; codeblock_t **codeblock_hash; int codegen_mmx_entered = 0; int block_current = 0; static int block_num; int block_pos; int cpu_recomp_flushes, cpu_recomp_flushes_latched; int cpu_recomp_evicted, cpu_recomp_evicted_latched; int cpu_recomp_reuse, cpu_recomp_reuse_latched; int cpu_recomp_removed, cpu_recomp_removed_latched; uint32_t codegen_endpc; int codegen_block_cycles; static int codegen_block_ins; static int codegen_block_full_ins; static uint32_t last_op32; static x86seg *last_ea_seg; static int last_ssegs; void codegen_init() { int c; #if defined(__linux__) || defined(__APPLE__) void *start; size_t len; long pagesize = sysconf(_SC_PAGESIZE); long pagemask = ~(pagesize - 1); #endif #if WIN64 codeblock = VirtualAlloc(NULL, BLOCK_SIZE * sizeof(codeblock_t), MEM_COMMIT, PAGE_EXECUTE_READWRITE); #else codeblock = malloc(BLOCK_SIZE * sizeof(codeblock_t)); #endif codeblock_hash = malloc(HASH_SIZE * sizeof(codeblock_t *)); memset(codeblock, 0, BLOCK_SIZE * sizeof(codeblock_t)); memset(codeblock_hash, 0, HASH_SIZE * sizeof(codeblock_t *)); for (c = 0; c < BLOCK_SIZE; c++) codeblock[c].valid = 0; #if defined(__linux__) || defined(__APPLE__) start = (void *)((long)codeblock & pagemask); len = ((BLOCK_SIZE * sizeof(codeblock_t)) + pagesize) & pagemask; if (mprotect(start, len, PROT_READ | PROT_WRITE | PROT_EXEC) != 0) { perror("mprotect"); exit(-1); } #endif // pclog("Codegen is %p\n", (void *)pages[0xfab12 >> 12].block); } void codegen_reset() { int c; memset(codeblock, 0, BLOCK_SIZE * sizeof(codeblock_t)); memset(codeblock_hash, 0, HASH_SIZE * sizeof(codeblock_t *)); mem_reset_page_blocks(); for (c = 0; c < BLOCK_SIZE; c++) codeblock[c].valid = 0; } void dump_block() { /* codeblock_t *block = pages[0x119000 >> 12].block; pclog("dump_block:\n"); while (block) { uint32_t start_pc = (block->pc & 0xffc) | (block->phys & ~0xfff); uint32_t end_pc = (block->endpc & 0xffc) | (block->phys & ~0xfff); pclog(" %p : %08x-%08x %08x-%08x %p %p\n", (void *)block, start_pc, end_pc, block->pc, block->endpc, (void *)block->prev, (void *)block->next); if (!block->pc) fatal("Dead PC=0\n"); block = block->next; } pclog("dump_block done\n");*/ } static void add_to_block_list(codeblock_t *block) { codeblock_t *block_prev = pages[block->phys >> 12].block[(block->phys >> 10) & 3]; if (!block->page_mask) fatal("add_to_block_list - mask = 0\n"); if (block_prev) { block->next = block_prev; block_prev->prev = block; pages[block->phys >> 12].block[(block->phys >> 10) & 3] = block; } else { block->next = NULL; pages[block->phys >> 12].block[(block->phys >> 10) & 3] = block; } if (block->next) { if (block->next->valid == 0) fatal("block->next->valid=0 %p %p %x %x\n", (void *)block->next, (void *)codeblock, block_current, block_pos); } if (block->page_mask2) { block_prev = pages[block->phys_2 >> 12].block_2[(block->phys_2 >> 10) & 3]; if (block_prev) { block->next_2 = block_prev; block_prev->prev_2 = block; pages[block->phys_2 >> 12].block_2[(block->phys_2 >> 10) & 3] = block; } else { block->next_2 = NULL; pages[block->phys_2 >> 12].block_2[(block->phys_2 >> 10) & 3] = block; } } } static void remove_from_block_list(codeblock_t *block, uint32_t pc) { if (!block->page_mask) return; if (block->prev) { block->prev->next = block->next; if (block->next) block->next->prev = block->prev; } else { pages[block->phys >> 12].block[(block->phys >> 10) & 3] = block->next; if (block->next) block->next->prev = NULL; else mem_flush_write_page(block->phys, 0); } if (!block->page_mask2) { if (block->prev_2 || block->next_2) fatal("Invalid block_2\n"); return; } if (block->prev_2) { block->prev_2->next_2 = block->next_2; if (block->next_2) block->next_2->prev_2 = block->prev_2; } else { // pclog(" pages.block_2=%p 3 %p %p\n", (void *)block->next_2, (void *)block, (void *)pages[block->phys_2 >> 12].block_2); pages[block->phys_2 >> 12].block_2[(block->phys_2 >> 10) & 3] = block->next_2; if (block->next_2) block->next_2->prev_2 = NULL; else mem_flush_write_page(block->phys_2, 0); } } static void delete_block(codeblock_t *block) { uint32_t old_pc = block->pc; if (block == codeblock_hash[HASH(block->phys)]) codeblock_hash[HASH(block->phys)] = NULL; if (block->valid == 0) fatal("Deleting deleted block\n"); block->valid = 0; codeblock_tree_delete(block); remove_from_block_list(block, old_pc); } void codegen_check_flush(page_t *page, uint64_t mask, uint32_t phys_addr) { struct codeblock_t *block = page->block[(phys_addr >> 10) & 3]; while (block) { if (mask & block->page_mask) { delete_block(block); cpu_recomp_evicted++; } if (block == block->next) fatal("Broken 1\n"); block = block->next; } block = page->block_2[(phys_addr >> 10) & 3]; while (block) { if (mask & block->page_mask2) { delete_block(block); cpu_recomp_evicted++; } if (block == block->next_2) fatal("Broken 2\n"); block = block->next_2; } } void codegen_block_init(uint32_t phys_addr) { codeblock_t *block; page_t *page = &pages[phys_addr >> 12]; if (!page->block[(phys_addr >> 10) & 3]) mem_flush_write_page(phys_addr, cs+cpu_state.pc); block_current = (block_current + 1) & BLOCK_MASK; block = &codeblock[block_current]; // if (block->pc == 0xb00b4ff5) // pclog("Init target block\n"); if (block->valid != 0) { // pclog("Reuse block : was %08x now %08x\n", block->pc, cs+pc); delete_block(block); cpu_recomp_reuse++; } block_num = HASH(phys_addr); codeblock_hash[block_num] = &codeblock[block_current]; block->valid = 1; block->ins = 0; block->pc = cs + cpu_state.pc; block->_cs = cs; block->pnt = block_current; block->phys = phys_addr; block->dirty_mask = &page->dirty_mask[(phys_addr >> PAGE_MASK_INDEX_SHIFT) & PAGE_MASK_INDEX_MASK]; block->dirty_mask2 = NULL; block->next = block->prev = NULL; block->next_2 = block->prev_2 = NULL; block->page_mask = 0; block->flags = 0; block->status = cpu_cur_status; block->was_recompiled = 0; recomp_page = block->phys & ~0xfff; codeblock_tree_add(block); } void codegen_block_start_recompile(codeblock_t *block) { page_t *page = &pages[block->phys >> 12]; if (!page->block[(block->phys >> 10) & 3]) mem_flush_write_page(block->phys, cs+cpu_state.pc); block_num = HASH(block->phys); block_current = block->pnt; if (block->pc != cs + cpu_state.pc || block->was_recompiled) fatal("Recompile to used block!\n"); block->status = cpu_cur_status; block_pos = BLOCK_GPF_OFFSET; #if WIN64 addbyte(0x48); /*XOR RCX, RCX*/ addbyte(0x31); addbyte(0xc9); addbyte(0x31); /*XOR EDX, EDX*/ addbyte(0xd2); #else addbyte(0x48); /*XOR RDI, RDI*/ addbyte(0x31); addbyte(0xff); addbyte(0x31); /*XOR ESI, ESI*/ addbyte(0xf6); #endif call(block, (uintptr_t)x86gpf); while (block_pos < BLOCK_EXIT_OFFSET) addbyte(0x90); /*NOP*/ block_pos = BLOCK_EXIT_OFFSET; /*Exit code*/ addbyte(0x48); /*ADDL $40,%rsp*/ addbyte(0x83); addbyte(0xC4); addbyte(0x28); addbyte(0x41); /*POP R15*/ addbyte(0x5f); addbyte(0x41); /*POP R14*/ addbyte(0x5e); addbyte(0x41); /*POP R13*/ addbyte(0x5d); addbyte(0x41); /*POP R12*/ addbyte(0x5c); addbyte(0x5f); /*POP RDI*/ addbyte(0x5e); /*POP RSI*/ addbyte(0x5d); /*POP RBP*/ addbyte(0x5b); /*POP RDX*/ addbyte(0xC3); /*RET*/ cpu_block_end = 0; block_pos = 0; /*Entry code*/ addbyte(0x53); /*PUSH RBX*/ addbyte(0x55); /*PUSH RBP*/ addbyte(0x56); /*PUSH RSI*/ addbyte(0x57); /*PUSH RDI*/ addbyte(0x41); /*PUSH R12*/ addbyte(0x54); addbyte(0x41); /*PUSH R13*/ addbyte(0x55); addbyte(0x41); /*PUSH R14*/ addbyte(0x56); addbyte(0x41); /*PUSH R15*/ addbyte(0x57); addbyte(0x48); /*SUBL $40,%rsp*/ addbyte(0x83); addbyte(0xEC); addbyte(0x28); addbyte(0x48); /*MOVL RBP, &cpu_state*/ addbyte(0xBD); addquad(((uintptr_t)&cpu_state) + 128); // pclog("New block %i for %08X %03x\n", block_current, cs+pc, block_num); last_op32 = -1; last_ea_seg = NULL; last_ssegs = -1; codegen_block_cycles = 0; codegen_timing_block_start(); codegen_block_ins = 0; codegen_block_full_ins = 0; recomp_page = block->phys & ~0xfff; codegen_flags_changed = 0; codegen_fpu_entered = 0; codegen_mmx_entered = 0; codegen_fpu_loaded_iq[0] = codegen_fpu_loaded_iq[1] = codegen_fpu_loaded_iq[2] = codegen_fpu_loaded_iq[3] = codegen_fpu_loaded_iq[4] = codegen_fpu_loaded_iq[5] = codegen_fpu_loaded_iq[6] = codegen_fpu_loaded_iq[7] = 0; _ds.checked = _es.checked = _fs.checked = _gs.checked = (cr0 & 1) ? 0 : 1; codegen_reg_loaded[0] = codegen_reg_loaded[1] = codegen_reg_loaded[2] = codegen_reg_loaded[3] = codegen_reg_loaded[4] = codegen_reg_loaded[5] = codegen_reg_loaded[6] = codegen_reg_loaded[7] = 0; block->was_recompiled = 1; codegen_flat_ds = !(cpu_cur_status & CPU_STATUS_NOTFLATDS); codegen_flat_ss = !(cpu_cur_status & CPU_STATUS_NOTFLATSS); } void codegen_block_remove() { codeblock_t *block = &codeblock[block_current]; delete_block(block); cpu_recomp_removed++; recomp_page = -1; } void codegen_block_generate_end_mask() { codeblock_t *block = &codeblock[block_current]; uint32_t start_pc; uint32_t end_pc; block->endpc = codegen_endpc; block->page_mask = 0; start_pc = (block->pc & 0x3ff) & ~15; if ((block->pc ^ block->endpc) & ~0x3ff) end_pc = 0x3ff & ~15; else end_pc = (block->endpc & 0x3ff) & ~15; if (end_pc < start_pc) end_pc = 0x3ff; start_pc >>= PAGE_MASK_SHIFT; end_pc >>= PAGE_MASK_SHIFT; // pclog("block_end: %08x %08x\n", start_pc, end_pc); for (; start_pc <= end_pc; start_pc++) { block->page_mask |= ((uint64_t)1 << start_pc); // pclog(" %08x %llx\n", start_pc, block->page_mask); } pages[block->phys >> 12].code_present_mask[(block->phys >> 10) & 3] |= block->page_mask; block->phys_2 = -1; block->page_mask2 = 0; block->next_2 = block->prev_2 = NULL; if ((block->pc ^ block->endpc) & ~0x3ff) { block->phys_2 = get_phys_noabrt(block->endpc); if (block->phys_2 != -1) { page_t *page_2 = &pages[block->phys_2 >> 12]; start_pc = 0; end_pc = (block->endpc & 0x3ff) >> PAGE_MASK_SHIFT; for (; start_pc <= end_pc; start_pc++) block->page_mask2 |= ((uint64_t)1 << start_pc); page_2->code_present_mask[(block->phys_2 >> 10) & 3] |= block->page_mask2; if (!pages[block->phys_2 >> 12].block_2[(block->phys_2 >> 10) & 3]) mem_flush_write_page(block->phys_2, block->endpc); if (!block->page_mask2) fatal("!page_mask2\n"); if (block->next_2) { // pclog(" next_2->pc=%08x\n", block->next_2->pc); if (block->next_2->valid == 0) fatal("block->next_2->valid=0 %p\n", (void *)block->next_2); } block->dirty_mask2 = &page_2->dirty_mask[(block->phys_2 >> PAGE_MASK_INDEX_SHIFT) & PAGE_MASK_INDEX_MASK]; } } // pclog("block_end: %08x %08x %016llx\n", block->pc, block->endpc, block->page_mask); recomp_page = -1; } void codegen_block_end() { codeblock_t *block = &codeblock[block_current]; codegen_block_generate_end_mask(); add_to_block_list(block); } void codegen_block_end_recompile(codeblock_t *block) { codegen_timing_block_end(); if (codegen_block_cycles) { addbyte(0x81); /*SUB $codegen_block_cycles, cyclcs*/ addbyte(0x6d); addbyte((uint8_t)cpu_state_offset(_cycles)); addlong((uint32_t)codegen_block_cycles); } if (codegen_block_ins) { addbyte(0x81); /*ADD $codegen_block_ins,ins*/ addbyte(0x45); addbyte((uint8_t)cpu_state_offset(cpu_recomp_ins)); addlong(codegen_block_ins); } #if 0 if (codegen_block_full_ins) { addbyte(0x81); /*ADD $codegen_block_ins,ins*/ addbyte(0x04); addbyte(0x25); addlong((uint32_t)&cpu_recomp_full_ins); addlong(codegen_block_full_ins); } #endif addbyte(0x48); /*ADDL $40,%rsp*/ addbyte(0x83); addbyte(0xC4); addbyte(0x28); addbyte(0x41); /*POP R15*/ addbyte(0x5f); addbyte(0x41); /*POP R14*/ addbyte(0x5e); addbyte(0x41); /*POP R13*/ addbyte(0x5d); addbyte(0x41); /*POP R12*/ addbyte(0x5c); addbyte(0x5f); /*POP RDI*/ addbyte(0x5e); /*POP RSI*/ addbyte(0x5d); /*POP RBP*/ addbyte(0x5b); /*POP RDX*/ addbyte(0xC3); /*RET*/ if (block_pos > BLOCK_GPF_OFFSET) fatal("Over limit!\n"); remove_from_block_list(block, block->pc); block->next = block->prev = NULL; block->next_2 = block->prev_2 = NULL; codegen_block_generate_end_mask(); add_to_block_list(block); // pclog("End block %i\n", block_num); } void codegen_flush() { return; } static int opcode_modrm[256] = { 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, /*00*/ 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, /*10*/ 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, /*20*/ 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, /*30*/ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /*40*/ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /*50*/ 0, 0, 1, 1, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, /*60*/ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /*70*/ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, /*80*/ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /*90*/ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /*a0*/ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /*b0*/ 1, 1, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, /*c0*/ 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, /*d0*/ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /*e0*/ 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, /*f0*/ }; int opcode_0f_modrm[256] = { 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /*00*/ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /*10*/ 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /*20*/ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /*30*/ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, /*40*/ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /*50*/ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1, /*60*/ 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, /*70*/ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /*80*/ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, /*90*/ 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, /*a0*/ 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1, 1, 1, /*b0*/ 1, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, /*c0*/ 0, 1, 1, 1, 0, 1, 0, 0, 1, 1, 0, 1, 1, 1, 0, 1, /*d0*/ 0, 1, 1, 0, 0, 1, 0, 0, 1, 1, 0, 1, 1, 1, 0, 1, /*e0*/ 0, 1, 1, 1, 0, 1, 0, 0, 1, 1, 1, 0, 1, 1, 1, 0 /*f0*/ }; void codegen_debug() { if (output) { pclog("At %04x(%08x):%04x %04x(%08x):%04x es=%08x EAX=%08x BX=%04x ECX=%08x BP=%04x EDX=%08x EDI=%08x\n", CS, cs, cpu_state.pc, SS, ss, ESP, es,EAX, BX,ECX,BP, EDX,EDI); } } static x86seg *codegen_generate_ea_16_long(x86seg *op_ea_seg, uint32_t fetchdat, int op_ssegs, uint32_t *op_pc) { if (!cpu_mod && cpu_rm == 6) { addbyte(0xC7); /*MOVL $0,(ssegs)*/ addbyte(0x45); addbyte((uint8_t)cpu_state_offset(eaaddr)); addlong((fetchdat >> 8) & 0xffff); (*op_pc) += 2; } else { int base_reg = 0, index_reg = 0; switch (cpu_rm) { case 0: case 1: case 7: base_reg = LOAD_REG_W(REG_BX); break; case 2: case 3: case 6: base_reg = LOAD_REG_W(REG_BP); break; case 4: base_reg = LOAD_REG_W(REG_SI); break; case 5: base_reg = LOAD_REG_W(REG_DI); break; } if (!(cpu_rm & 4)) { if (cpu_rm & 1) index_reg = LOAD_REG_W(REG_DI); else index_reg = LOAD_REG_W(REG_SI); } base_reg &= 7; index_reg &= 7; switch (cpu_mod) { case 0: if (cpu_rm & 4) { addbyte(0x41); /*MOVZX EAX, base_reg*/ addbyte(0x0f); addbyte(0xb7); addbyte(0xc0 | base_reg); } else { addbyte(0x67); /*LEA EAX, base_reg+index_reg*/ addbyte(0x43); addbyte(0x8d); if (base_reg == 5) { addbyte(0x44); addbyte(base_reg | (index_reg << 3)); addbyte(0); } else { addbyte(0x04); addbyte(base_reg | (index_reg << 3)); } } break; case 1: if (cpu_rm & 4) { addbyte(0x67); /*LEA EAX, base_reg+imm8*/ addbyte(0x41); addbyte(0x8d); addbyte(0x40 | base_reg); addbyte((fetchdat >> 8) & 0xff); } else { addbyte(0x67); /*LEA EAX, base_reg+index_reg+imm8*/ addbyte(0x43); addbyte(0x8d); addbyte(0x44); addbyte(base_reg | (index_reg << 3)); addbyte((fetchdat >> 8) & 0xff); } (*op_pc)++; break; case 2: if (cpu_rm & 4) { addbyte(0x67); /*LEA EAX, base_reg+imm8*/ addbyte(0x41); addbyte(0x8d); addbyte(0x80 | base_reg); addlong((fetchdat >> 8) & 0xffff); } else { addbyte(0x67); /*LEA EAX, base_reg+index_reg+imm16*/ addbyte(0x43); addbyte(0x8d); addbyte(0x84); addbyte(base_reg | (index_reg << 3)); addlong((fetchdat >> 8) & 0xffff); } (*op_pc) += 2; break; } if (cpu_mod || !(cpu_rm & 4)) { addbyte(0x25); /*ANDL $0xffff, %eax*/ addlong(0xffff); } addbyte(0x89); /*MOV eaaddr, EAX*/ addbyte(0x45); addbyte((uint8_t)cpu_state_offset(eaaddr)); if (mod1seg[cpu_rm] == &ss && !op_ssegs) op_ea_seg = &_ss; } return op_ea_seg; } //#if 0 static x86seg *codegen_generate_ea_32_long(x86seg *op_ea_seg, uint32_t fetchdat, int op_ssegs, uint32_t *op_pc, int stack_offset) { uint32_t new_eaaddr; if (cpu_rm == 4) { uint8_t sib = fetchdat >> 8; int base_reg = -1, index_reg = -1; (*op_pc)++; if (cpu_mod || (sib & 7) != 5) base_reg = LOAD_REG_L(sib & 7) & 7; if (((sib >> 3) & 7) != 4) index_reg = LOAD_REG_L((sib >> 3) & 7) & 7; if (index_reg == -1) { switch (cpu_mod) { case 0: if ((sib & 7) == 5) { new_eaaddr = fastreadl(cs + (*op_pc) + 1); addbyte(0xb8); /*MOV EAX, imm32*/ addlong(new_eaaddr); (*op_pc) += 4; } else { addbyte(0x44); /*MOV EAX, base_reg*/ addbyte(0x89); addbyte(0xc0 | (base_reg << 3)); } break; case 1: addbyte(0x67); /*LEA EAX, imm8+base_reg*/ addbyte(0x41); addbyte(0x8d); if (base_reg == 4) { addbyte(0x44); addbyte(0x24); } else { addbyte(0x40 | base_reg); } addbyte((fetchdat >> 16) & 0xff); (*op_pc)++; break; case 2: new_eaaddr = fastreadl(cs + (*op_pc) + 1); addbyte(0x67); /*LEA EAX, imm32+base_reg*/ addbyte(0x41); addbyte(0x8d); if (base_reg == 4) { addbyte(0x84); addbyte(0x24); } else { addbyte(0x80 | base_reg); } addlong(new_eaaddr); (*op_pc) += 4; break; } } else { switch (cpu_mod) { case 0: if ((sib & 7) == 5) { new_eaaddr = fastreadl(cs + (*op_pc) + 1); if (sib >> 6) { addbyte(0x67); /*LEA EAX, imm32+index_reg*scale*/ addbyte(0x42); addbyte(0x8d); addbyte(0x04); addbyte(0x05 | (sib & 0xc0) | (index_reg << 3)); addlong(new_eaaddr); } else { addbyte(0x67); /*LEA EAX, imm32+index_reg*/ addbyte(0x41); addbyte(0x8d); addbyte(0x80 | index_reg); addlong(new_eaaddr); } (*op_pc) += 4; } else { addbyte(0x67); /*LEA EAX, base_reg+index_reg*scale*/ addbyte(0x43); addbyte(0x8d); if (base_reg == 5) { addbyte(0x44); addbyte(base_reg | (index_reg << 3) | (sib & 0xc0)); addbyte(0); } else { addbyte(0x04); addbyte(base_reg | (index_reg << 3) | (sib & 0xc0)); } } break; case 1: addbyte(0x67); /*LEA EAX, imm8+base_reg+index_reg*scale*/ addbyte(0x43); addbyte(0x8d); addbyte(0x44); addbyte(base_reg | (index_reg << 3) | (sib & 0xc0)); addbyte((fetchdat >> 16) & 0xff); (*op_pc)++; break; case 2: new_eaaddr = fastreadl(cs + (*op_pc) + 1); addbyte(0x67); /*LEA EAX, imm32+base_reg+index_reg*scale*/ addbyte(0x43); addbyte(0x8d); addbyte(0x84); addbyte(base_reg | (index_reg << 3) | (sib & 0xc0)); addlong(new_eaaddr); (*op_pc) += 4; break; } } if (stack_offset && (sib & 7) == 4 && (cpu_mod || (sib & 7) != 5)) /*ESP*/ { addbyte(0x05); addlong(stack_offset); } if (((sib & 7) == 4 || (cpu_mod && (sib & 7) == 5)) && !op_ssegs) op_ea_seg = &_ss; addbyte(0x89); /*MOV eaaddr, EAX*/ addbyte(0x45); addbyte((uint8_t)cpu_state_offset(eaaddr)); } else { int base_reg; if (!cpu_mod && cpu_rm == 5) { new_eaaddr = fastreadl(cs + (*op_pc) + 1); addbyte(0xC7); /*MOVL $new_eaaddr,(eaaddr)*/ addbyte(0x45); addbyte((uint8_t)cpu_state_offset(eaaddr)); addlong(new_eaaddr); (*op_pc) += 4; return op_ea_seg; } base_reg = LOAD_REG_L(cpu_rm) & 7; if (cpu_mod) { if (cpu_rm == 5 && !op_ssegs) op_ea_seg = &_ss; if (cpu_mod == 1) { addbyte(0x67); /*LEA EAX, base_reg+imm8*/ addbyte(0x41); addbyte(0x8d); addbyte(0x40 | base_reg); addbyte((fetchdat >> 8) & 0xff); (*op_pc)++; } else { new_eaaddr = fastreadl(cs + (*op_pc) + 1); addbyte(0x67); /*LEA EAX, base_reg+imm32*/ addbyte(0x41); addbyte(0x8d); addbyte(0x80 | base_reg); addlong(new_eaaddr); (*op_pc) += 4; } addbyte(0x89); /*MOV eaaddr, EAX*/ addbyte(0x45); addbyte((uint8_t)cpu_state_offset(eaaddr)); } else { addbyte(0x44); /*MOV eaaddr, base_reg*/ addbyte(0x89); addbyte(0x45 | (base_reg << 3)); addbyte((uint8_t)cpu_state_offset(eaaddr)); } } return op_ea_seg; } //#endif void codegen_generate_call(uint8_t opcode, OpFn op, uint32_t fetchdat, uint32_t new_pc, uint32_t old_pc) { codeblock_t *block = &codeblock[block_current]; uint32_t op_32 = use32; uint32_t op_pc = new_pc; OpFn *op_table = x86_dynarec_opcodes; RecompOpFn *recomp_op_table = recomp_opcodes; int opcode_shift = 0; int opcode_mask = 0x3ff; int over = 0; int pc_off = 0; int test_modrm = 1; int c; op_ea_seg = &_ds; op_ssegs = 0; op_old_pc = old_pc; for (c = 0; c < NR_HOST_REGS; c++) host_reg_mapping[c] = -1; for (c = 0; c < NR_HOST_XMM_REGS; c++) host_reg_xmm_mapping[c] = -1; codegen_timing_start(); while (!over) { switch (opcode) { case 0x0f: op_table = x86_dynarec_opcodes_0f; recomp_op_table = recomp_opcodes_0f; over = 1; break; case 0x26: /*ES:*/ op_ea_seg = &_es; op_ssegs = 1; break; case 0x2e: /*CS:*/ op_ea_seg = &_cs; op_ssegs = 1; break; case 0x36: /*SS:*/ op_ea_seg = &_ss; op_ssegs = 1; break; case 0x3e: /*DS:*/ op_ea_seg = &_ds; op_ssegs = 1; break; case 0x64: /*FS:*/ op_ea_seg = &_fs; op_ssegs = 1; break; case 0x65: /*GS:*/ op_ea_seg = &_gs; op_ssegs = 1; break; case 0x66: /*Data size select*/ op_32 = ((use32 & 0x100) ^ 0x100) | (op_32 & 0x200); break; case 0x67: /*Address size select*/ op_32 = ((use32 & 0x200) ^ 0x200) | (op_32 & 0x100); break; case 0xd8: op_table = (op_32 & 0x200) ? x86_dynarec_opcodes_d8_a32 : x86_dynarec_opcodes_d8_a16; recomp_op_table = recomp_opcodes_d8; opcode_shift = 3; opcode_mask = 0x1f; over = 1; pc_off = -1; test_modrm = 0; block->flags |= CODEBLOCK_HAS_FPU; break; case 0xd9: op_table = (op_32 & 0x200) ? x86_dynarec_opcodes_d9_a32 : x86_dynarec_opcodes_d9_a16; recomp_op_table = recomp_opcodes_d9; opcode_mask = 0xff; over = 1; pc_off = -1; test_modrm = 0; block->flags |= CODEBLOCK_HAS_FPU; break; case 0xda: op_table = (op_32 & 0x200) ? x86_dynarec_opcodes_da_a32 : x86_dynarec_opcodes_da_a16; recomp_op_table = recomp_opcodes_da; opcode_mask = 0xff; over = 1; pc_off = -1; test_modrm = 0; block->flags |= CODEBLOCK_HAS_FPU; break; case 0xdb: op_table = (op_32 & 0x200) ? x86_dynarec_opcodes_db_a32 : x86_dynarec_opcodes_db_a16; recomp_op_table = recomp_opcodes_db; opcode_mask = 0xff; over = 1; pc_off = -1; test_modrm = 0; block->flags |= CODEBLOCK_HAS_FPU; break; case 0xdc: op_table = (op_32 & 0x200) ? x86_dynarec_opcodes_dc_a32 : x86_dynarec_opcodes_dc_a16; recomp_op_table = recomp_opcodes_dc; opcode_shift = 3; opcode_mask = 0x1f; over = 1; pc_off = -1; test_modrm = 0; block->flags |= CODEBLOCK_HAS_FPU; break; case 0xdd: op_table = (op_32 & 0x200) ? x86_dynarec_opcodes_dd_a32 : x86_dynarec_opcodes_dd_a16; recomp_op_table = recomp_opcodes_dd; opcode_mask = 0xff; over = 1; pc_off = -1; test_modrm = 0; block->flags |= CODEBLOCK_HAS_FPU; break; case 0xde: op_table = (op_32 & 0x200) ? x86_dynarec_opcodes_de_a32 : x86_dynarec_opcodes_de_a16; recomp_op_table = recomp_opcodes_de; opcode_mask = 0xff; over = 1; pc_off = -1; test_modrm = 0; block->flags |= CODEBLOCK_HAS_FPU; break; case 0xdf: op_table = (op_32 & 0x200) ? x86_dynarec_opcodes_df_a32 : x86_dynarec_opcodes_df_a16; recomp_op_table = recomp_opcodes_df; opcode_mask = 0xff; over = 1; pc_off = -1; test_modrm = 0; block->flags |= CODEBLOCK_HAS_FPU; break; case 0xf0: /*LOCK*/ break; case 0xf2: /*REPNE*/ op_table = x86_dynarec_opcodes_REPNE; recomp_op_table = recomp_opcodes_REPNE; break; case 0xf3: /*REPE*/ op_table = x86_dynarec_opcodes_REPE; recomp_op_table = recomp_opcodes_REPE; break; default: goto generate_call; } fetchdat = fastreadl(cs + op_pc); codegen_timing_prefix(opcode, fetchdat); if (cpu_state.abrt) return; opcode = fetchdat & 0xff; if (!pc_off) fetchdat >>= 8; op_pc++; } generate_call: codegen_timing_opcode(opcode, fetchdat, op_32); if ((op_table == x86_dynarec_opcodes && ((opcode & 0xf0) == 0x70 || (opcode & 0xfc) == 0xe0 || opcode == 0xc2 || (opcode & 0xfe) == 0xca || (opcode & 0xfc) == 0xcc || (opcode & 0xfc) == 0xe8 || (opcode == 0xff && ((fetchdat & 0x38) >= 0x10 && (fetchdat & 0x38) < 0x30)))) || (op_table == x86_dynarec_opcodes_0f && ((opcode & 0xf0) == 0x80))) { /*Opcode is likely to cause block to exit, update cycle count*/ if (codegen_block_cycles) { addbyte(0x81); /*SUB $codegen_block_cycles, cyclcs*/ addbyte(0x6d); addbyte((uint8_t)cpu_state_offset(_cycles)); addlong((uint32_t)codegen_block_cycles); codegen_block_cycles = 0; } if (codegen_block_ins) { addbyte(0x81); /*ADD $codegen_block_ins,ins*/ addbyte(0x45); addbyte((uint8_t)cpu_state_offset(cpu_recomp_ins)); addlong(codegen_block_ins); codegen_block_ins = 0; } #if 0 if (codegen_block_full_ins) { addbyte(0x81); /*ADD $codegen_block_ins,ins*/ addbyte(0x04); addbyte(0x25); addlong((uint32_t)&cpu_recomp_full_ins); addlong(codegen_block_full_ins); codegen_block_full_ins = 0; } #endif } if ((op_table == x86_dynarec_opcodes_REPNE || op_table == x86_dynarec_opcodes_REPE) && !op_table[opcode | op_32]) { op_table = x86_dynarec_opcodes; recomp_op_table = recomp_opcodes; } if (recomp_op_table && recomp_op_table[(opcode | op_32) & 0x1ff]) { uint32_t new_pc = recomp_op_table[(opcode | op_32) & 0x1ff](opcode, fetchdat, op_32, op_pc, block); if (new_pc) { if (new_pc != -1) STORE_IMM_ADDR_L((uintptr_t)&cpu_state.pc, new_pc); codegen_block_ins++; block->ins++; codegen_block_full_ins++; codegen_endpc = (cs + cpu_state.pc) + 8; return; } } op = op_table[((opcode >> opcode_shift) | op_32) & opcode_mask]; // if (output) // pclog("Generate call at %08X %02X %08X %02X %08X %08X %08X %08X %08X %02X %02X %02X %02X\n", &codeblock[block_current][block_pos], opcode, new_pc, ram[old_pc], EAX, EBX, ECX, EDX, ESI, ram[0x7bd2+6],ram[0x7bd2+7],ram[0x7bd2+8],ram[0x7bd2+9]); if (op_ssegs != last_ssegs) { last_ssegs = op_ssegs; addbyte(0xC6); /*MOVB $0,(ssegs)*/ addbyte(0x45); addbyte((uint8_t)cpu_state_offset(ssegs)); addbyte(op_ssegs); } //#if 0 if ((!test_modrm || (op_table == x86_dynarec_opcodes && opcode_modrm[opcode]) || (op_table == x86_dynarec_opcodes_0f && opcode_0f_modrm[opcode]))/* && !(op_32 & 0x200)*/) { int stack_offset = 0; if (op_table == x86_dynarec_opcodes && opcode == 0x8f) /*POP*/ stack_offset = (op_32 & 0x100) ? 4 : 2; cpu_mod = (fetchdat >> 6) & 3; cpu_reg = (fetchdat >> 3) & 7; cpu_rm = fetchdat & 7; addbyte(0xC7); /*MOVL $rm | mod | reg,(rm_mod_reg_data)*/ addbyte(0x45); addbyte((uint8_t)cpu_state_offset(rm_data.rm_mod_reg_data)); addlong(cpu_rm | (cpu_mod << 8) | (cpu_reg << 16)); op_pc += pc_off; if (cpu_mod != 3 && !(op_32 & 0x200)) op_ea_seg = codegen_generate_ea_16_long(op_ea_seg, fetchdat, op_ssegs, &op_pc); if (cpu_mod != 3 && (op_32 & 0x200)) op_ea_seg = codegen_generate_ea_32_long(op_ea_seg, fetchdat, op_ssegs, &op_pc, stack_offset); op_pc -= pc_off; } //#endif if (op_ea_seg != last_ea_seg) { // last_ea_seg = op_ea_seg; addbyte(0xC7); /*MOVL $&_ds,(ea_seg)*/ addbyte(0x45); addbyte((uint8_t)cpu_state_offset(ea_seg)); addlong((uint32_t)(uintptr_t)op_ea_seg); } addbyte(0xC7); /*MOVL [pc],new_pc*/ addbyte(0x45); addbyte((uint8_t)cpu_state_offset(pc)); addlong(op_pc + pc_off); addbyte(0xC7); /*MOVL $old_pc,(oldpc)*/ addbyte(0x45); addbyte((uint8_t)cpu_state_offset(oldpc)); addlong(old_pc); if (op_32 != last_op32) { last_op32 = op_32; addbyte(0xC7); /*MOVL $use32,(op32)*/ addbyte(0x45); addbyte((uint8_t)cpu_state_offset(op32)); addlong(op_32); } load_param_1_32(block, fetchdat); call(block, (uintptr_t)op); codegen_block_ins++; block->ins++; addbyte(0x85); /*OR %eax, %eax*/ addbyte(0xc0); addbyte(0x0F); addbyte(0x85); /*JNZ 0*/ addlong((uint32_t)(uintptr_t)&block->data[BLOCK_EXIT_OFFSET] - (uint32_t)(uintptr_t)(&block->data[block_pos + 4])); // call(block, codegen_debug); codegen_endpc = (cs + cpu_state.pc) + 8; } #endif
basic2004/86Box
src/cpu/codegen_x86-64.c
C
gpl-2.0
46,652
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns='http://www.w3.org/1999/xhtml' xml:lang='en' lang='en'> <head> <title>Transformer</title> <meta name='keywords' content='' /> <meta name='description' content='{&quot;xfmr&quot;, {primarypos, primaryneg, secondarypos, secondaryneg}, &quot; name&quot;, {TurnsP -> primaryturns, TurnsS -> secondaryturns}} is an ideal transformer with the turns ratio primaryturns:secondaryturns between the primary and secondary windings.' /> <link rel='stylesheet' type='text/css' href='../css/functions.css' /> <script src='../javascript/menu.js' type='text/javascript'></script> <script src='../javascript/common.js' type='text/javascript'></script> <script src='../javascript/prototype-1.4.0.js' type='text/javascript'></script> <script src='../javascript/search.js' type='text/javascript'></script> <script src='../javascript/jquery.js' type='text/javascript'></script> <script src='../javascript/jquery-query.js' type='text/javascript'></script> <script src='../javascript/jquery.dimensions.min.js' type='text/javascript'></script> <script src='../javascript/jquery.mousewheel.min.js' type='text/javascript'></script> <script src='../javascript/jScrollPane.js' type='text/javascript'></script> <script src='../javascript/FunctionBrowser.js' type='text/javascript'></script> <script src='../javascript/VirtualBook.js' type='text/javascript'></script> <script src='../javascript/Navigator.js' type='text/javascript'></script> <script language='JavaScript' type='text/javascript'>baselang='Transformer';</script> </head> <body style='margin:35px 0px 0px 0px; background:#ffffff'> <!-- saved from url=(0014)about:internet --> <div class="FlShdBar"> <a name="1"></a> <div class="Flt"> <a name="1"></a> <img src="../images/images/body_shdwspcr.gif" width="8" height="15" alt="" /> </div> <div id="CntTabTop" class="en"> <a name="1"></a> <div class="infoHeader"> <a name="1"></a> <table class="infoHeaderTable"> <tr><td align="left" style="width:90% important!;width:77%;"><span class="contextName"><i>S C A Pack</i> Symbol</span></td><td align="right" nowrap="true" style=""><span class=""><span name="parent_Tutorials" id="parent_Tutorials"><div class="TutorialsMenu" id="Layer_Tutorials" onmouseover="javascript:showMenu('Layer_Tutorials')" onmouseout="javascript:hideMenu('Layer_Tutorials')"> <div class="TutorialsRaw"> <a href="/mathematica/SCAPack/tutorial/Netlists.html">Netlists</a> </div> </div></span><a onmouseover="javascript:showMenu('Layer_Tutorials');return(true);" onmouseout="javascript:hideMenu('Layer_Tutorials');return(true);" id="head_Tutorials" href="#TutorialsSection" class="anchorLink"><span class="AnchorBarText">Tutorials &#187;</span></a><span class='vertBar'>|</span><span name="parent_SeeAlso" id="parent_SeeAlso"><div class="SeeAlsoMenu" id="Layer_SeeAlso" onmouseover="javascript:showMenu('Layer_SeeAlso')" onmouseout="javascript:hideMenu('Layer_SeeAlso')"> <div class="SeeAlsoRaw"> <a href="/mathematica/SCAPack/ref/Gyrator.html">Gyrator</a> </div> </div></span><a onmouseover="javascript:showMenu('Layer_SeeAlso');return(true);" onmouseout="javascript:hideMenu('Layer_SeeAlso');return(true);" id="head_SeeAlso" href="#SeeAlsoSection" class="anchorLink"><span class="AnchorBarText">See Also &#187;</span></a><span class='vertBar'>|</span><span name="parent_MoreAbout" id="parent_MoreAbout"><div class="MoreAboutMenu" id="Layer_MoreAbout" onmouseover="javascript:showMenu('Layer_MoreAbout')" onmouseout="javascript:hideMenu('Layer_MoreAbout')"> <div class="MoreAboutRaw"> <a href="/mathematica/SCAPack/guide/Elements.html">Elements</a> </div> </div></span><a onmouseover="javascript:showMenu('Layer_MoreAbout');return(true);" onmouseout="javascript:hideMenu('Layer_MoreAbout');return(true);" id="head_MoreAbout" href="#MoreAboutSection" class="anchorLink"><span class="AnchorBarText">More About &#187;</span></a></span></td></tr> </table> </div> </div> </div><div class="FlShdBar"> <a name="1224892054"></a> <div id="CntTabMid" class="en"> <a name="1224892054"></a> <h1 class="ObjectName"><a name="1224892054"></a>Transformer</h1> </div> </div><div class="FlShdBar"> <a name="982511436"></a> <div id="CntTabMid" class="en"> <a name="982511436"></a> <div id="UT"> <a name="982511436"></a> <table class="Table" width="100%" cellpadding="5" style="border-collapse: collapse;"> <col width="95%" /> <col width="5%" /> <tr class="" style=""><td class="UM"><span class="MBookTableText"><span class="IF">{&quot;xfmr&quot;, {<span class="TI">primarypos</span>, <span class="TI">primaryneg</span>, <span class="TI">secondarypos</span>, <span class="TI">secondaryneg</span>}, &quot;<span class="TI">name</span>&quot;, {TurnsP&#8594;<span class="TI">primaryturns</span>, TurnsS&#8594;<span class="TI">secondaryturns</span>}}</span> <br />is an ideal transformer with the turns ratio <span class="TI">primaryturns</span>:<span class="TI">secondaryturns</span> between the primary and secondary windings.</span></td></tr> </table> </div> </div> </div><div class="FlShdBar"> <div id="CntTabMid" class="en"> <div class="NS_Co" id="NS"> <a name="NotesSection"><div class="NSH" id="ModInfo_8" name="ModInfo_8"> <a name="732362698"></a> <a href="javascript:toggle('NS')" onmouseover="javascript:return(true);"><img src="../images/mathematicaImages/closedSectionGroup.gif" id="NS_" border="0" width="8" height="8" alt="" /> <span class="NSSpan">MORE INFORMATION</span></a> </div></a> <div class="NS" name="NSG" id="NSG"> <ul class="Notes"><li>If omitted, the turns ratio is left symbolic at TurnsP and TurnsS.</li></ul> <ul class="Notes"><li>The transformer ensures that the power in the primary is the same as in the secondary. Additionally, the voltage at the secondary is related to the primary by the ratio of the primary to secondary turns ratio, while the current in the primary and secondary are related to each other by the ratio of the secondary to primary turns ratio.</li></ul> </div> </div> </div> </div><div class="FlShdBar"> <div id="CntTabMid" class="en"> <div class="PES_Ex" name="PES" id="PES"> <a name="PES"><div class="PESH" name="PES"> <a name="PrimaryExamplesSection"></a> <a name="1591084329"></a> <table width="100%"> <tr><td><a href="javascript:toggle('PES')" onmouseover="javascript:return(true);"><img src="../images/mathematicaImages/openSectionGroup.gif" id="PES_" border="0" width="8" height="8" /> EXAMPLES</a></td><td style="text-align: right"><a class="oclink" name="oclink" id="oclink" href="javascript:close_ES()" onmouseover="javascript:return(true);">CLOSE ALL</a></td></tr> </table> </div></a> <div class="PES"> <div class="ES_Ex" id="ES_1"> <table class="ESHT"> <tr><td valign="top"><div class="ESH"><a name="887945059"></a><a name="ExampleSection" href="javascript:toggle('ES_1')" onmouseover="javascript:return(true);"><img src="../images/mathematicaImages/openGroup.gif" id="ES_1_" alt="" /> Basic Examples&#160;&#160;</a> <span class="excount">(1)</span></div></td><td class="CB" width="5px" onclick="toggle('ES_1')" /></tr> </table> <div class="ES"> <table class="EST"> <tr><td><a name="949083670" /><a name="1973312108" /><div class="IO"> <table class="InCell"> <tr><td class="lab"><a name="inoutlink" href="javascript:input('i_1')" onmouseover="javascript:return(true);">In[1]:=</a></td><td class="Input"><div> <a name="949083670"></a> <a href="javascript:input('i_1')" onmouseover="javascript:return(true);"><img src="Files/Transformer/I_2.gif" height="78" width="337" alt="Click for copyable input" /></a> </div><div name="i_1_out" id="i_1_out" class="IFL"><a name="949083670"></a></div></td></tr> </table> <table class="OCell"> <tr><td class="lab">Out[1]=</td><td class="Output"><img src="Files/Transformer/O_1.gif" height="32" width="68" alt="" /></td></tr> </table> </div></td><td class="CBG" width="5px" onclick="toggle('ES_1')" /></tr> </table> </div> </div> </div> </div> </div> </div><div class="FlShdBar"> <div id="CntTabMid" class="en"> <div class="SAS_Ex" id="SAS"> <a name="SeeAlsoSection"><div class="SASH"> <a name="1255426704"></a> <a href="javascript:toggle('SAS')" onmouseover="javascript:return(true);"><img src="../images/mathematicaImages/openSectionGroup.gif" id="SAS_" border="0" width="8" height="8" alt="" /> <span class="SASSpan">SEE ALSO</span></a> </div></a> <div class="SAS" name="SASG" id="SASG"> <ul class="SeeAlso"><li><a name="929782353"></a><a href="../ref/Gyrator.html">Gyrator</a></li></ul> <ul class="SeeAlso"><li><a name="1370301823"></a><a href="../ref/Nullor.html">Nullor</a></li></ul> </div> </div> </div> </div><div class="FlShdBar"> <div id="CntTabMid" class="en"> <div class="TS_Ex" id="TS"> <a name="TutorialsSection"><div class="TSH"> <a name="250839057"></a> <a href="javascript:toggle('TS')" onmouseover="javascript:return(true);"><img src="../images/mathematicaImages/openSectionGroup.gif" id="TS_" border="0" width="8" height="8" alt="" /> <span class="TSSpan">TUTORIALS</span></a> </div></a> <div class="TS" name="TSG" id="TSG"> <ul class="IndentedNote"><li><a name="341631938"></a><a href="../tutorial/Netlists.html">Netlists</a></li></ul> </div> </div> </div> </div><div class="FlShdBar"> <div id="CntTabMid" class="en"> <div class="MAS_Ex" id="MAS"> <a name="MoreAboutSection"><div class="MASH"> <a href="javascript:toggle('MAS')" onmouseover="javascript:return(true);"><img src="../images/mathematicaImages/openSectionGroup.gif" id="MAS_" border="0" width="8" height="8" alt="" /> <span class="MASSpan">MORE ABOUT</span></a> </div></a> <div class="MAS" name="MASG" id="MASG"> <ul class="IndentedNote"><li><a name="828743610"></a><a href="../guide/Elements.html">Elements</a></li></ul> </div> </div> </div> </div> <div class="FlShdBar"><div id="CntTabBtm"> </div></div> <img class="crnr" src="../images/images/body_shadow_corner.gif" width="25" height="9" alt=" "/> <div class="BmShdw"><img class="cornerbottomright" src="../images/images/body_shadow_bottomright.gif" width="23" height="9" alt=""/></div> <!--#include virtual="/includes/footer2010.cgi"--> <div class="dashboard" />
rub-a-dub-dub/SCAPack
dev/build/SCAPack-HTML/html/ref/Transformer.html
HTML
gpl-2.0
10,968
<?php /* * This file is part of PHPExifTool. * * (c) 2012 Romain Neutron <imprec@gmail.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace PHPExiftool\Driver\Tag\IFD0; use PHPExiftool\Driver\AbstractTag; class Copyright extends AbstractTag { protected $Id = 33432; protected $Name = 'Copyright'; protected $FullName = 'Exif::Main'; protected $GroupName = 'IFD0'; protected $g0 = 'EXIF'; protected $g1 = 'IFD0'; protected $g2 = 'Image'; protected $Type = 'string'; protected $Writable = true; protected $Description = 'Copyright'; protected $local_g2 = 'Author'; }
Droces/casabio
vendor/phpexiftool/phpexiftool/lib/PHPExiftool/Driver/Tag/IFD0/Copyright.php
PHP
gpl-2.0
724
/***************************************************************************** * * Filename: * --------- * sensor.h * * Project: * -------- * DUMA * * Description: * ------------ * CMOS sensor header file * ****************************************************************************/ #ifndef __SENSOR_H #define __SENSOR_H //------------------------Engineer mode--------------------------------- #define FACTORY_START_ADDR 0 #define ENGINEER_START_ADDR 10 typedef enum register_index { PRE_GAIN=0, CMMCLK_CURRENT, REGISTER_EDITOR, GROUP_TOTAL_NUMS } FACTORY_REGISTER_INDEX; typedef enum cct_register_index { INDEX_BASE_GAIN =0, INDEX_PRE_GAIN_R, INDEX_PRE_GAIN_Gr, INDEX_PRE_GAIN_Gb, INDEX_PRE_GAIN_B, FACTORY_END_ADDR } CCT_REGISTER_INDEX; typedef enum engineer_index { CMMCLK_CURRENT_INDEX=ENGINEER_START_ADDR, ENGINEER_END } FACTORY_ENGINEER_INDEX; //------------------------Engineer mode--------------------------------- typedef struct { SENSOR_REG_STRUCT Reg[ENGINEER_END]; SENSOR_REG_STRUCT CCT[FACTORY_END_ADDR]; } SENSOR_DATA_STRUCT,*PSENSOR_DATA_STRUCT; typedef enum _OV5650MIPI_OP_TYPE { OV5650MIPI_MODE_NONE, OV5650MIPI_MODE_PREVIEW, OV5650MIPI_MODE_CAPTURE, OV5650MIPI_MODE_QCIF_VIDEO, OV5650MIPI_MODE_CIF_VIDEO } OV5650MIPI_OP_TYPE; extern OV5650MIPI_OP_TYPE OV5650MIPI_g_iOV5650MIPI_Mode; /* MAXIMUM EXPLOSURE LINES USED BY AE */ extern kal_uint16 OV5650MIPI_MAX_EXPOSURE_LINES; extern kal_uint8 OV5650MIPI_MIN_EXPOSURE_LINES; /* DEFINITION USED BY CCT */ // extern SensorInfo OV5650MIPI_g_CCT_MainSensor; // extern kal_uint8 OV5650MIPI_g_CCT_FirstGrabColor; #define OV5650MIPI_VIDEO_NORMALMODE_FRAME_RATE (25) #define OV5650MIPI_VIDEO_NIGHTMODE_FRAME_RATE (13) // 0x3028, 0x3029 defines the PCLKs in one line of OV5650MIPI // If [0x3028:0x3029] = N, the total PCLKs in one line of QXGA(3M full mode) is (N+1), and // total PCLKs in one line of XGA subsampling mode is (N+1) / 2 // If need to add dummy pixels, just increase 0x3028 and 0x3029 directly #define OV5650MIPI_QXGA_MODE_WITHOUT_DUMMY_PIXELS (3252) //(3112) // QXGA mode's pixel # in one HSYNC w/o dummy pixels #define OV5650MIPI_XGA_MODE_WITHOUT_DUMMY_PIXELS (2176) //(OV5650MIPI_QXGA_MODE_WITHOUT_DUMMY_PIXELS / 2) // XGA mode's pixel # in one HSYNC w/o dummy pixels #define OV5650MIPI_PV_PERIOD_PIXEL_NUMS (OV5650MIPI_XGA_MODE_WITHOUT_DUMMY_PIXELS) // dummy pixels is down sampled by half in XGA mode // 0x302A, 0x302B defines total lines in one frame of OV5650MIPI // If [0x302A:0x302B] = N, the total lines in one is N in dependent of resolution setting // Even in XGA subsampling mode, total lines defined by 0x302A, 0x302B is not subsampled. // If need dummy lines, just increase 0x302A and 0x302B directly #define OV5650MIPI_QXGA_MODE_WITHOUT_DUMMY_LINES (1968)//(1568) // QXGA mode's HSYNC # in one HSYNC w/o dummy lines #define OV5650MIPI_XGA_MODE_WITHOUT_DUMMY_LINES (1019) //(984)//(784) // XGA mode's HSYNC # in one HSYNC w/o dummy lines #define OV5650MIPI_PV_PERIOD_LINE_NUMS (OV5650MIPI_XGA_MODE_WITHOUT_DUMMY_LINES) // XGA mode's HSYNC # in one VSYNC period // SENSOR EXPOSURE LINE LIMITATION #define OV5650MIPI_FULL_MAX_LINES_PER_FRAME (1944) // QXGA mode 1568 #define OV5650MIPI_FULL_EXPOSURE_LIMITATION (OV5650MIPI_FULL_MAX_LINES_PER_FRAME) #define OV5650MIPI_PV_MAX_LINES_PER_FRAME (OV5650MIPI_XGA_MODE_WITHOUT_DUMMY_LINES) // # of lines in one XGA frame #define OV5650MIPI_PV_EXPOSURE_LIMITATION (OV5650MIPI_PV_MAX_LINES_PER_FRAME) // sensor's full resolution #define OV5650MIPI_IMAGE_SENSOR_FULL_WIDTH (2600)//(2592) // (2584) #define OV5650MIPI_IMAGE_SENSOR_FULL_HEIGHT (1948)//(1944) //(1944) // sensor's full resolution #define OV5650MIPI_IMAGE_SENSOR_FULL_WIDTH_DRV (2560)//(2592 - 2 - (OV5650MIPI_ISP_INTERPOLATIO_FILTER_WIDTH - 1)) #define OV5650MIPI_IMAGE_SENSOR_FULL_HEIGHT_DRV (1920)//(1944 - 2 - (OV5650MIPI_ISP_INTERPOLATIO_FILTER_HEIGHT - 1)) // resolution for preview #define OV5650MIPI_IMAGE_SENSOR_PV_WIDTH (1280)//(1024)//640 #define OV5650MIPI_IMAGE_SENSOR_PV_HEIGHT (960)//(768)//480 // #define ISP_INTERPOLATIO_FILTER_WIDTH (7) // #define ISP_INTERPOLATIO_FILTER_HEIGHT (7) #define OV5650MIPI_ISP_INTERPOLATIO_FILTER_WIDTH (15)//5//11 #define OV5650MIPI_ISP_INTERPOLATIO_FILTER_HEIGHT (11)//7//14 /* SENSOR READ/WRITE ID */ #define OV5650MIPI_WRITE_ID (0x6C) #define OV5650MIPI_READ_ID (0x6D) /* SENSOR CHIP VERSION */ // #define OV5650MIPI_SENSOR_ID (0x3641) // rev.2A //#define OV5650MIPI_SENSOR_ID 0x364C // rev.2C //define OV5650MIPI_USE_OTP #if defined(OV5650MIPI_USE_OTP) struct OV5650MIPI_otp_struct { kal_uint16 customer_id; kal_uint16 module_integrator_id; kal_uint16 lens_id; kal_uint16 rg_ratio; kal_uint16 bg_ratio; kal_uint16 user_data[5]; kal_uint16 lenc_g[36]; kal_uint16 lenc_b[25]; kal_uint16 lenc_r[25]; }; #endif #define RG_TYPICAL 0x51 #define BG_TYPICAL 0x57 //s_porting add //s_porting add //s_porting add //#define PV_VGA_ACTUAL_WIDTH 648 //#define PV_VGA_ACTUAL_HEIGHT 490 //#define PV_VGA_TOTAL_PIXEL_PER_LINE (2068 + 648) //#define PV_VGA_TOTAL_LINE_PER_FRAME (662 + 490) //#define PV_1280X960_ACTUAL_WIDTH 1288 //(PV_ACTIVE_PIXEL_NUMS+1) //#define PV_1280X960_ACTUAL_HEIGHT 970 //(PV_ACTIVE_LINE_NUMS+1) //#define PV_1280X960_TOTAL_PIXEL_PER_LINE (1614 + 1288) //#define PV_1280X960_TOTAL_LINE_PER_FRAME (106 + 970) //#define FULL_ACTUAL_WIDTH 2592 //#define FULL_ACTUAL_HEIGHT 1944 //#define FULL_TOTAL_PIXEL_PER_LINE (2838 + 2592) //#define FULL_TOTAL_LINE_PER_FRAME (112 + 1944) //#define IMAGE_SENSOR_PV_WIDTH IMAGE_SENSOR_PV_WIDTH //#define IMAGE_SENSOR_PV_HEIGHT IMAGE_SENSOR_PV_HEIGHT //#define FULL_ACTUAL_WIDTH IMAGE_SENSOR_FULL_WIDTH //#define FULL_ACTUAL_HEIGHT IMAGE_SENSOR_FULL_HEIGHT //format index #define OV5650MIPI_PV_FORMAT_INDEX 1 //1280x960 mode #define OV5650MIPI_FULL_FORMAT_INDEX 2 //Full resolution mode //customize #define CAM_SIZE_QVGA_WIDTH 320 #define CAM_SIZE_QVGA_HEIGHT 240 #define CAM_SIZE_VGA_WIDTH 640 #define CAM_SIZE_VGA_HEIGHT 480 #define CAM_SIZE_05M_WIDTH 800 #define CAM_SIZE_05M_HEIGHT 600 #define CAM_SIZE_1M_WIDTH 1280 #define CAM_SIZE_1M_HEIGHT 960 #define CAM_SIZE_2M_WIDTH 1600 #define CAM_SIZE_2M_HEIGHT 1200 #define CAM_SIZE_3M_WIDTH 2048 #define CAM_SIZE_3M_HEIGHT 1536 #define CAM_SIZE_5M_WIDTH 2592 #define CAM_SIZE_5M_HEIGHT 1944 // //initial config function // int pfInitCfg_VGA(void); int pfInitCfg_1280X960(void); int pfInitCfg_FULL(void); //export functions UINT32 OV5650MIPIOpen(void); UINT32 OV5650MIPIControl(MSDK_SCENARIO_ID_ENUM ScenarioId, MSDK_SENSOR_EXPOSURE_WINDOW_STRUCT *pImageWindow, MSDK_SENSOR_CONFIG_STRUCT *pSensorConfigData); UINT32 OV5650MIPIFeatureControl(MSDK_SENSOR_FEATURE_ENUM FeatureId, UINT8 *pFeaturePara,UINT32 *pFeatureParaLen); UINT32 OV5650MIPIGetInfo(MSDK_SCENARIO_ID_ENUM ScenarioId, MSDK_SENSOR_INFO_STRUCT *pSensorInfo, MSDK_SENSOR_CONFIG_STRUCT *pSensorConfigData); UINT32 OV5650MIPIGetResolution(MSDK_SENSOR_RESOLUTION_INFO_STRUCT *pSensorResolution); UINT32 OV5650MIPIClose(void); #define Sleep(ms) mdelay(ms) #define RETAILMSG(x,...) #define TEXT //e_porting add //e_porting add //e_porting add #endif /* __SENSOR_H */
yevgeniy-logachev/CATB15Kernel
mediatek/custom/common/kernel/imgsensor/ov5650mipi_raw/ov5650mipi_Sensor.h
C
gpl-2.0
7,633
<?php /** * The template for displaying search results pages. * * @link https://developer.wordpress.org/themes/basics/template-hierarchy/#search-result * * @package Brushy Hill Cottage */ get_header(); ?> <section id="primary" class="content-area"> <main id="main" class="site-main" role="main"> <?php if ( have_posts() ) : ?> <header class="page-header"> <h1 class="page-title"><?php printf( esc_html__( 'Search Results for: %s', 'brushy-hill-cottage' ), '<span>' . get_search_query() . '</span>' ); ?></h1> </header><!-- .page-header --> <?php /* Start the Loop */ ?> <?php while ( have_posts() ) : the_post(); ?> <?php /** * Run the loop for the search to output the results. * If you want to overload this in a child theme then include a file * called content-search.php and that will be used instead. */ get_template_part( 'template-parts/content', 'search' ); ?> <?php endwhile; ?> <?php the_posts_navigation(); ?> <?php else : ?> <?php get_template_part( 'template-parts/content', 'none' ); ?> <?php endif; ?> </main><!-- #main --> </section><!-- #primary --> <?php get_sidebar(); ?> <?php get_footer(); ?>
bpriddy/brushyhillcottage
wp-content/themes/brushy-hill-cottage/search.php
PHP
gpl-2.0
1,206
/* * Systemstats MIB architecture support * * $Id: systemstats_common.c 11913 2005-02-08 21:58:36Z nba $ */ #include <net-snmp/net-snmp-config.h> #include <net-snmp/net-snmp-includes.h> #include "ip-mib/ipSystemStatsTable/ipSystemStatsTable_constants.h" #include <net-snmp/agent/net-snmp-agent-includes.h> #include <net-snmp/data_access/ipstats.h> #include <net-snmp/data_access/systemstats.h> /**---------------------------------------------------------------------*/ /* * local static vars */ static int need_wrap_check = -1; /* * local static prototypes */ static void _entry_release(netsnmp_systemstats_entry * entry, void *unused); /**---------------------------------------------------------------------*/ /* * external per-architecture functions prototypes * * These shouldn't be called by the general public, so they aren't in * the header file. */ extern int netsnmp_access_systemstats_container_arch_load(netsnmp_container* container, u_int load_flags); extern void netsnmp_access_systemstats_arch_init(void); /**---------------------------------------------------------------------*/ /* * initialization */ void netsnmp_access_systemstats_init(void) { netsnmp_container * ifcontainer; netsnmp_access_systemstats_arch_init(); /* * load once to set up ifIndexes */ ifcontainer = netsnmp_access_systemstats_container_load(NULL, 0); if(NULL != ifcontainer) netsnmp_access_systemstats_container_free(ifcontainer, 0); } /**---------------------------------------------------------------------*/ /* * container functions */ /** * initialize systemstats container */ netsnmp_container * netsnmp_access_systemstats_container_init(u_int flags) { netsnmp_container *container; DEBUGMSGTL(("access:systemstats:container", "init\n")); /* * create the containers. one indexed by ifIndex, the other * indexed by ifName. */ container = netsnmp_container_find("access_systemstats:table_container"); if (NULL == container) return NULL; return container; } /** * load systemstats information in specified container * * @param container empty container, or NULL to have one created for you * @param load_flags flags to modify behaviour. * * @retval NULL error * @retval !NULL pointer to container */ netsnmp_container* netsnmp_access_systemstats_container_load(netsnmp_container* container, u_int load_flags) { int rc; DEBUGMSGTL(("access:systemstats:container", "load\n")); if (NULL == container) container = netsnmp_access_systemstats_container_init(load_flags); if (NULL == container) { snmp_log(LOG_ERR, "no container specified/found for access_systemstats\n"); return NULL; } rc = netsnmp_access_systemstats_container_arch_load(container, load_flags); if (0 != rc) { netsnmp_access_systemstats_container_free(container, NETSNMP_ACCESS_SYSTEMSTATS_FREE_NOFLAGS); container = NULL; } return container; } void netsnmp_access_systemstats_container_free(netsnmp_container *container, u_int free_flags) { DEBUGMSGTL(("access:systemstats:container", "free\n")); if (NULL == container) { snmp_log(LOG_ERR, "invalid container for netsnmp_access_systemstats_free\n"); return; } if(! (free_flags & NETSNMP_ACCESS_SYSTEMSTATS_FREE_DONT_CLEAR)) { /* * free all items. */ CONTAINER_CLEAR(container, (netsnmp_container_obj_func*)_entry_release, NULL); } CONTAINER_FREE(container); } /**---------------------------------------------------------------------*/ /* * entry functions */ /** */ netsnmp_systemstats_entry * netsnmp_access_systemstats_entry_get_by_index(netsnmp_container *container, oid index) { netsnmp_index tmp; DEBUGMSGTL(("access:systemstats:entry", "by_index\n")); if (NULL == container) { snmp_log(LOG_ERR, "invalid container for netsnmp_access_systemstats_entry_get_by_index\n"); return NULL; } tmp.len = 1; tmp.oids = &index; return (netsnmp_systemstats_entry *) CONTAINER_FIND(container, &tmp); } /** */ netsnmp_systemstats_entry * netsnmp_access_systemstats_entry_create(int version) { netsnmp_systemstats_entry *entry = SNMP_MALLOC_TYPEDEF(netsnmp_systemstats_entry); DEBUGMSGTL(("access:systemstats:entry", "create\n")); if(NULL == entry) return NULL; entry->ns_ip_version = version; entry->oid_index.len = 1; entry->oid_index.oids = (oid *) & entry->ns_ip_version; return entry; } /** */ void netsnmp_access_systemstats_entry_free(netsnmp_systemstats_entry * entry) { DEBUGMSGTL(("access:systemstats:entry", "free\n")); if (NULL == entry) return; /* * SNMP_FREE not needed, for any of these, * since the whole entry is about to be freed */ if (NULL != entry->old_stats) free(entry->old_stats); free(entry); } /**---------------------------------------------------------------------*/ /* * Utility routines */ /** * \internal */ static void _entry_release(netsnmp_systemstats_entry * entry, void *context) { netsnmp_access_systemstats_entry_free(entry); } /** * update entry stats (checking for counter wrap) * * @retval 0 : success * @retval <0 : error */ int netsnmp_access_systemstats_entry_update_stats(netsnmp_systemstats_entry * prev_vals, netsnmp_systemstats_entry * new_vals) { DEBUGMSGTL(("access:systemstats", "check_wrap\n")); /* * sanity checks */ if ((NULL == prev_vals) || (NULL == new_vals) || (prev_vals->ns_ip_version != new_vals->ns_ip_version)) return -1; /* * if we've determined that we have 64 bit counters, just copy them. */ if (0 == need_wrap_check) { memcpy(&prev_vals->stats, &new_vals->stats, sizeof(new_vals->stats)); return 0; } if (NULL == prev_vals->old_stats) { /* * if we don't have old stats, they can't have wrapped, so just copy */ prev_vals->old_stats = SNMP_MALLOC_TYPEDEF(netsnmp_ipstats); if (NULL == prev_vals->old_stats) { return -2; } } else { /* * update straight 32 bit counters */ prev_vals->stats.InHdrErrors = new_vals->stats.InHdrErrors; prev_vals->stats.InNoRoutes = new_vals->stats.InNoRoutes; prev_vals->stats.InAddrErrors = new_vals->stats.InAddrErrors; prev_vals->stats.InUnknownProtos = new_vals->stats.InUnknownProtos; prev_vals->stats.InTruncatedPkts = new_vals->stats.InTruncatedPkts; prev_vals->stats.ReasmReqds = new_vals->stats.InTruncatedPkts; prev_vals->stats.ReasmOKs = new_vals->stats.ReasmOKs; prev_vals->stats.ReasmFails = new_vals->stats.ReasmFails; prev_vals->stats.InDiscards = new_vals->stats.InDiscards; prev_vals->stats.OutNoRoutes = new_vals->stats.OutNoRoutes; prev_vals->stats.OutDiscards = new_vals->stats.OutDiscards; prev_vals->stats.OutFragReqds = new_vals->stats.OutFragReqds; prev_vals->stats.OutFragOKs = new_vals->stats.OutFragOKs; prev_vals->stats.OutFragFails = new_vals->stats.OutFragFails; prev_vals->stats.OutFragCreates = new_vals->stats.OutFragCreates; /* * update 64bit counters */ netsnmp_c64_check32_and_update(&prev_vals->stats.HCInReceives, &new_vals->stats.HCInReceives, &prev_vals->old_stats->HCInReceives, &need_wrap_check); netsnmp_c64_check32_and_update(&prev_vals->stats.HCInOctets, &new_vals->stats.HCInOctets, &prev_vals->old_stats->HCInOctets, &need_wrap_check); netsnmp_c64_check32_and_update(&prev_vals->stats.HCInForwDatagrams, &new_vals->stats.HCInForwDatagrams, &prev_vals->old_stats->HCInForwDatagrams, &need_wrap_check); netsnmp_c64_check32_and_update(&prev_vals->stats.HCInDelivers, &new_vals->stats.HCInDelivers, &prev_vals->old_stats->HCInDelivers, &need_wrap_check); netsnmp_c64_check32_and_update(&prev_vals->stats.HCOutRequests, &new_vals->stats.HCOutRequests, &prev_vals->old_stats->HCOutRequests, &need_wrap_check); netsnmp_c64_check32_and_update(&prev_vals->stats.HCOutForwDatagrams, &new_vals->stats.HCOutForwDatagrams, &prev_vals->old_stats->HCOutForwDatagrams, &need_wrap_check); netsnmp_c64_check32_and_update(&prev_vals->stats.HCOutTransmits, &new_vals->stats.HCOutTransmits, &prev_vals->old_stats->HCOutTransmits, &need_wrap_check); netsnmp_c64_check32_and_update(&prev_vals->stats.HCOutOctets, &new_vals->stats.HCOutOctets, &prev_vals->old_stats->HCOutOctets, &need_wrap_check); netsnmp_c64_check32_and_update(&prev_vals->stats.HCInMcastPkts, &new_vals->stats.HCInMcastPkts, &prev_vals->old_stats->HCInMcastPkts, &need_wrap_check); netsnmp_c64_check32_and_update(&prev_vals->stats.HCInMcastOctets, &new_vals->stats.HCInMcastOctets, &prev_vals->old_stats->HCInMcastOctets, &need_wrap_check); netsnmp_c64_check32_and_update(&prev_vals->stats.HCOutMcastPkts, &new_vals->stats.HCOutMcastPkts, &prev_vals->old_stats->HCOutMcastPkts, &need_wrap_check); netsnmp_c64_check32_and_update(&prev_vals->stats.HCOutMcastOctets, &new_vals->stats.HCOutMcastOctets, &prev_vals->old_stats->HCOutMcastOctets, &need_wrap_check); netsnmp_c64_check32_and_update(&prev_vals->stats.HCInBcastPkts, &new_vals->stats.HCInBcastPkts, &prev_vals->old_stats->HCInBcastPkts, &need_wrap_check); netsnmp_c64_check32_and_update(&prev_vals->stats.HCOutBcastPkts, &new_vals->stats.HCOutBcastPkts, &prev_vals->old_stats->HCOutBcastPkts, &need_wrap_check); } /* * if we've decided we no longer need to check wraps, free old stats */ if (0 == need_wrap_check) { SNMP_FREE(prev_vals->old_stats); } /* * update old stats from new stats. * careful - old_stats is a pointer to stats... */ memcpy(prev_vals->old_stats, &new_vals->stats, sizeof(new_vals->stats)); return 0; } /** * update systemstats entry data (checking for counter wraps) * * Given an existing entry, update it with the new values from another * entry. * * @retval -2 : malloc failed * @retval -1 : systemstatss not the same * @retval 0 : no error */ int netsnmp_access_systemstats_entry_update(netsnmp_systemstats_entry * lhs, netsnmp_systemstats_entry * rhs) { DEBUGMSGTL(("access:systemstats", "copy\n")); if ((NULL == lhs) || (NULL == rhs) || (lhs->ns_ip_version != rhs->ns_ip_version)) return -1; /* * update stats */ netsnmp_access_systemstats_entry_update_stats(lhs, rhs); /* * update other data */ lhs->flags = rhs->flags; return 0; } /**---------------------------------------------------------------------*/ /* * */
ingran/balzac
package/teltonika-snmpd/src/agent/mibgroup/ip-mib/data_access/systemstats_common.c
C
gpl-2.0
12,739
package com.badday.ss.blocks; import java.util.Random; import net.minecraft.block.Block; import net.minecraft.block.BlockContainer; import net.minecraft.block.material.Material; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.IIcon; import net.minecraft.world.World; import com.badday.ss.SS; import com.badday.ss.SSConfig; import com.badday.ss.api.IGasNetwork; import com.badday.ss.api.IGasNetworkElement; import com.badday.ss.api.IGasNetworkVent; import com.badday.ss.core.atmos.GasUtils; import com.badday.ss.core.utils.BlockVec3; import com.badday.ss.events.RebuildNetworkPoint; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; /** * * @author KolesnikovAK * * Seal gases on bay * */ public class SSBlockAirVent extends BlockContainer implements IGasNetworkElement { private IIcon[] iconBuffer; //private int ICON_INACTIVE_SIDE = 0, ICON_BOTTOM = 1, ICON_SIDE_ACTIVATED = 2; private int ICON_SIDE = 0, ICON_SIDE_FRONT = 1, ICON_SIDE_BACK = 2, ICON_SIDE_FRONTON=3; public SSBlockAirVent(String assetName) { super(Material.rock); this.setResistance(1000.0F); this.setHardness(330.0F); this.setBlockTextureName(SS.ASSET_PREFIX + assetName); this.setBlockName(assetName); this.setBlockUnbreakable(); this.setStepSound(soundTypeMetal); this.setCreativeTab(SS.ssTab); disableStats(); } @Override @SideOnly(Side.CLIENT) public void registerBlockIcons(IIconRegister par1IconRegister) { iconBuffer = new IIcon[4]; //iconBuffer[ICON_INACTIVE_SIDE] = par1IconRegister.registerIcon("ss:airgenSideInactive"); //iconBuffer[ICON_BOTTOM] = par1IconRegister.registerIcon("ss:contBottom"); //iconBuffer[ICON_SIDE_ACTIVATED] = par1IconRegister.registerIcon("ss:airgenSideActive"); iconBuffer[ICON_SIDE] = par1IconRegister.registerIcon("ss:blockGasVentSide"); iconBuffer[ICON_SIDE_FRONT] = par1IconRegister.registerIcon("ss:blockGasVentFront"); iconBuffer[ICON_SIDE_BACK] = par1IconRegister.registerIcon("ss:blockGasVentBack"); iconBuffer[ICON_SIDE_FRONTON] = par1IconRegister.registerIcon("ss:blockGasVentFrontOn"); } @SideOnly(Side.CLIENT) @Override public IIcon getIcon(int side, int metadata) { if (side == 1) { if (metadata == 0) { return iconBuffer[ICON_SIDE_BACK]; } else if (metadata == 1) { return iconBuffer[ICON_SIDE_FRONT]; } else if (metadata == 2) { return iconBuffer[ICON_SIDE_BACK]; } else if (metadata == 3) { return iconBuffer[ICON_SIDE_FRONTON]; } } if (side == 0) { if (metadata == 0) { return iconBuffer[ICON_SIDE_FRONT]; } else if (metadata == 1) { return iconBuffer[ICON_SIDE_BACK]; } else if (metadata == 2) { return iconBuffer[ICON_SIDE_FRONTON]; } else if (metadata == 3) { return iconBuffer[ICON_SIDE_BACK]; } } return iconBuffer[ICON_SIDE]; } /** * Overridden by {@link #createTileEntity(World, int)} */ @Override public TileEntity createNewTileEntity(World w, int i) { return null; } @Override public TileEntity createTileEntity(World world, int meta) { return new SSTileEntityAirVent(); } /** * Returns the quantity of items to drop on block destruction. */ @Override public int quantityDropped(Random par1Random) { return 0; } @Override public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer entityplayer, int side, float a, float b, float c) { if (world.isRemote) return true; if (entityplayer.getCurrentEquippedItem() != null) { String itemName = entityplayer.getCurrentEquippedItem().getUnlocalizedName(); if (itemName.equals("item.ss.multitool")) { TileEntity tileEntity = world.getTileEntity(x, y, z); if (tileEntity instanceof SSTileEntityAirVent) { IGasNetwork net = ((SSTileEntityAirVent) tileEntity).getGasNetwork(); if (SS.Debug) { ((SSTileEntityAirVent) tileEntity).printDebugInfo(); } } } else if (itemName.equals("ic2.itemToolWrenchElectric") || itemName.equals("item.thermalexpansion.tool.wrench")) { // Rotate AirVent int oldMeta = world.getBlockMetadata(x, y, z); int oldSide = oldMeta & 1; if (side != oldSide && side >= 0 && side < 2) { if (side == 0 && side != oldSide) { world.setBlockMetadataWithNotify(x, y, z, oldMeta & 2, 3); // old meta 1 or 3 -> 0 or 2 entityplayer.getCurrentEquippedItem().damageItem(1, entityplayer); TileEntity tileEntity = world.getTileEntity(x, y, z); ((IGasNetworkVent) tileEntity).getGasNetwork().removeVent((IGasNetworkVent) tileEntity); // Rebuild new network on UP from Vent if (SS.Debug) System.out.println("Try to rebild on UP"); if (world.getBlock(x, y+1, z) == SSConfig.ssBlockGasPipe || world.getBlock(x, y+1, z) == SSConfig.ssBlockGasPipeCasing) { GasUtils.registeredEventRebuildGasNetwork(new RebuildNetworkPoint(world,new BlockVec3(x,y+1,z))); } } else if (side == 1 && side != oldSide) { world.setBlockMetadataWithNotify(x, y, z, oldMeta | 1, 3); // old meta 0 or 2 -> 1 or 3 entityplayer.getCurrentEquippedItem().damageItem(1, entityplayer); TileEntity tileEntity = world.getTileEntity(x, y, z); ((IGasNetworkVent) tileEntity).getGasNetwork().removeVent((IGasNetworkVent) tileEntity); // Rebuild new network on DOWN from Vent if (SS.Debug) System.out.println("Try to rebild on DOWN"); if (world.getBlock(x, y-1, z) == SSConfig.ssBlockGasPipe || world.getBlock(x, y-1, z) == SSConfig.ssBlockGasPipeCasing) { GasUtils.registeredEventRebuildGasNetwork(new RebuildNetworkPoint(world,new BlockVec3(x,y-1,z))); } } } } } return true; } @Override public void breakBlock(World par1World, int par2, int par3, int par4, Block par5, int par6) { TileEntity te = par1World.getTileEntity(par2, par3, par4); if (te != null) { te.invalidate(); } super.breakBlock(par1World, par2, par3, par4, par5, par6); } }
Tankistodor/SSAraminta
src/main/java/com/badday/ss/blocks/SSBlockAirVent.java
Java
gpl-2.0
6,252
<html> <head> <link rel="stylesheet" type="text/css" media="all" href="./css/base.css" /> </head> <body> <span data-l10n-id="Powred_by"></span><br> <a href="https://accessnow.org" target="_blank" ><img src ="./images/dark-logo.png" /></a> <ul> <li> <a href="https://fakedomains.accessnow.org/cgi-bin/report.pl" target="_blank" data-l10n-id="Report"></a> </li> <li> <a href="../data/setting.html" target="_blank" data-l10n-id="Setting"></a> </li> <li> <a href="../data/index.html" target="_blank" data-l10n-id="About"></a> </li> </ul> </body> </html>
bashz/FF-Fake-Domain
data/menu.html
HTML
gpl-2.0
725
Almadeladanza::Application.routes.draw do devise_for :users, ActiveAdmin::Devise.config ActiveAdmin.routes(self) mount ActiveAdmin::Tinymce::Engine => '/', as: 'admin_editor' root to: "news#index" resources :dance_styles, only: [:index, :show] resources :lessons, only: [:index, :show] resources :interior_images, only: [:index] resources :news, only: [:index, :show] resources :gallery_events, only: [:index] resources :about, only: [:index] resources :contacts, only: [:index] resources :feedback, only: [:index] resources :coaches, only: [:index, :show] resources :posts, only: [:index, :show] resources :clients, only: [:create] # The priority is based upon order of creation: # first created -> highest priority. # Sample of regular route: # match 'products/:id' => 'catalog#view' # Keep in mind you can assign values other than :controller and :action # Sample of named route: # match 'products/:id/purchase' => 'catalog#purchase', :as => :purchase # This route can be invoked with purchase_url(:id => product.id) # Sample resource route (maps HTTP verbs to controller actions automatically): # resources :products # Sample resource route with options: # resources :products do # member do # get 'short' # post 'toggle' # end # # collection do # get 'sold' # end # end # Sample resource route with sub-resources: # resources :products do # resources :comments, :sales # resource :seller # end # Sample resource route with more complex sub-resources # resources :products do # resources :comments # resources :sales do # get 'recent', :on => :collection # end # end # Sample resource route within a namespace: # namespace :admin do # # Directs /admin/products/* to Admin::ProductsController # # (app/controllers/admin/products_controller.rb) # resources :products # end # You can have the root of your site routed with "root" # just remember to delete public/index.html. # root :to => 'welcome#index' # See how all your routes lay out with "rake routes" # This is a legacy wild controller route that's not recommended for RESTful applications. # Note: This route will make all actions in every controller accessible via GET requests. # match ':controller(/:action(/:id))(.:format)' end
KernelCorp/almadeladanza
config/routes.rb
Ruby
gpl-2.0
2,432
<?php get_header( ); ?> <div class="page-content"> <div class="heading"> <h1><?php the_title( ); ?></h1> </div> <div class="news-events-blog"> <div class="container"> <div class="row"> <div class="col-md-8"> <div class="blog-post"> <div class="row"> <?php if ( has_post_thumbnail() ) { ?> <div class="col-md-12 col-sm-12"> <div class="blog-post-img"> <?php $image_id = get_post_thumbnail_id( get_the_ID() ); $large_image = wp_get_attachment_image_src( $image_id ,'huge'); ?> <img src="<?php echo esc_attr($large_image[0]); ?>" alt=""> </div> </div> <?php } ?> <div class="col-md-12 col-sm-12"> <h4><a href="<?php echo esc_url(the_permalink()); ?>"><?php the_title( ); ?></a></h4> <div class="about-author"> <ul class="list-inline"> <li class="place"><i class="fa fa-user"></i> <span class="bl-sort"><?php _e('by', 'takeaway'); ?></span><?php the_author_posts_link();?> </li> <li class="date"><i class="fa fa-clock-o"></i><?php the_time(get_option('date_format'));?> <?php _e('at', 'takeaway'); ?><?php the_time(get_option('time_format'));?></li> <li><i class="fa fa-folder-open"></i> <?php the_category(',&nbsp; '); ?></li> <li><i class="fa fa-comment"></i><a href="#"><?php comments_number( 'No Comment', 'One Comment', '% Comment' ); ?></a></li> </ul> </div> <div class="share-this"> <p><?php _e('Share this on:','takeaway'); ?></p> <ul class="list-inline"> <li> <a href="http://www.facebook.com/sharer.php?u=<?php the_permalink();?> "><i class="fa fa-facebook-square"></i></a> </li> <li> <a href="http://twitthis.com/twit?url=<?php the_permalink(); ?>"><i class="fa fa-twitter-square"></i></a> </li> <li> <a href="https://plus.google.com/share?url=<?php the_permalink();?>"><i class="fa fa-google-plus-square"></i></a> </li> <li> <a href="https://pinterest.com/pin/create/button/?url=<?php the_permalink();?>&amp;media=<?php echo urlencode(get_the_title()); ?>"><i class="fa fa-pinterest-square"></i></a> </li> </ul> <!-- end ul --> </div> <?php the_content( ); ?> <?php if (get_post_meta( $post->ID, '_ingrediant_meta_box_checkbox', true ) != -1) {?> <p> <strong><?php _e('Ingredient:','takeaway'); ?></strong> <?php $takeaway_ingredient = get_post_meta( $post->ID, '_ingrediant_meta_box_ingrediant', true ); ?> <?php echo esc_attr( $takeaway_ingredient ); ?></p> <?php } ?> <div class="tag"> <ul class="list-inline"> <li> <?php the_tags(' ',' ',' '); ?> </li> </ul> </div> <?php comments_template( '', true ); ?> </div> </div> </div> </div> <div class="col-md-4"> <div class="events-side-panel"> <?php get_sidebar(); ?> </div> </div> </div> </div> </div> </div> <?php get_footer( ); ?>
ankitparsanaa/foodapp
wp-content/themes/takeaway/single-news.php
PHP
gpl-2.0
7,288
using System; using System.Collections.Generic; using System.Linq; using Server.Engines.PartySystem; using Server.Items; using Server.Spells.Fourth; using Server.Spells.Necromancy; using Server.Targeting; namespace Server.Spells.Mysticism { public class CleansingWindsSpell : MysticSpell { public override SpellCircle Circle { get { return SpellCircle.Sixth; } } private static SpellInfo m_Info = new SpellInfo( "Cleansing Winds", "In Vas Mani Hur", 230, 9022, Reagent.Garlic, Reagent.Ginseng, Reagent.MandrakeRoot, Reagent.DragonBlood ); public CleansingWindsSpell(Mobile caster, Item scroll) : base(caster, scroll, m_Info) { } public override void OnCast() { Caster.Target = new MysticSpellTarget(this, TargetFlags.Beneficial); } public override void OnTarget(object o) { var targeted = o as Mobile; if (targeted == null) return; if (CheckBSequence(targeted)) { /* Soothing winds attempt to neutralize poisons, lift curses, and heal a valid * Target. The Caster's Mysticism and either Focus or Imbuing (whichever is * greater) skills determine the effectiveness of the Cleansing Winds. */ Caster.PlaySound(0x64C); var targets = new List<Mobile> {targeted}; targets.AddRange(FindAdditionalTargets(targeted).Take(3)); // This effect can hit up to 3 additional players beyond the primary target. double primarySkill = Caster.Skills[CastSkill].Value; double secondarySkill = Caster.Skills[DamageSkill].Value; var toHeal = (int)((primarySkill + secondarySkill) / 4.0) + Utility.RandomMinMax(-3, 3); toHeal /= targets.Count; // The effectiveness of the spell is reduced by the number of targets affected. foreach (var target in targets) { // WARNING: This spell will flag the caster as a criminal if a criminal or murderer party member is close enough // to the target to receive the benefits from the area of effect. Caster.DoBeneficial(target); PlayEffect(target); int toHealMod = toHeal; if (target.Poisoned) { int poisonLevel = target.Poison.RealLevel + 1; int chanceToCure = (10000 + (int)((primarySkill + secondarySkill) / 2 * 75) - (poisonLevel * 1750)) / 100; if (chanceToCure > Utility.Random(100) && target.CurePoison(Caster)) { // Poison reduces healing factor by 15% per level of poison. toHealMod -= (int)(toHeal * poisonLevel * 0.15); } else { // If the cure fails, the target will not be healed. toHealMod = 0; } } // Cleansing Winds will not heal the target after removing mortal wound. if (MortalStrike.IsWounded(target)) { MortalStrike.EndWound(target); toHealMod = 0; } var curseLevel = RemoveCurses(target); if (toHealMod > 0 && curseLevel > 0) { // Each Curse reduces healing by 3 points + 1% per curse level. int toHealMod1 = toHealMod - (curseLevel * 3); int toHealMod2 = toHealMod - (int)(toHealMod * (curseLevel / 100.0)); toHealMod -= toHealMod1 + toHealMod2; } if (toHealMod > 0) SpellHelper.Heal(toHealMod, target, Caster); } } FinishSequence(); } private static void PlayEffect(Mobile m) { m.FixedParticles(0x3709, 1, 30, 9963, 13, 3, EffectLayer.Head); var from = new Entity(Serial.Zero, new Point3D(m.X, m.Y, m.Z - 10), m.Map); var to = new Entity(Serial.Zero, new Point3D(m.X, m.Y, m.Z + 50), m.Map); Effects.SendMovingParticles(from, to, 0x2255, 1, 0, false, false, 13, 3, 9501, 1, 0, EffectLayer.Head, 0x100); } private IEnumerable<Mobile> FindAdditionalTargets(Mobile targeted) { var casterParty = Party.Get(Caster); if (casterParty == null) yield break; foreach (var m in Caster.Map.GetMobilesInRange(new Point3D(targeted), 2)) { if (m == null || m == targeted) continue; // Players in the area must be in the casters party in order to receive the beneficial effects of the spell. if (Caster.CanBeBeneficial(m, false) && casterParty.Contains(m)) yield return m; } } private static int RemoveCurses(Mobile m) { int curseLevel = 0; if (SleepSpell.IsUnderSleepEffects(m)) { SleepSpell.EndSleep(m); curseLevel += 2; } if (EvilOmenSpell.TryEndEffect(m)) { curseLevel += 1; } if (StrangleSpell.RemoveCurse(m)) { curseLevel += 2; } if (CorpseSkinSpell.RemoveCurse(m)) { curseLevel += 3; } if (CurseSpell.UnderEffect(m)) { CurseSpell.RemoveEffect(m); curseLevel += 4; } if (BloodOathSpell.RemoveCurse(m)) { curseLevel += 3; } if (MindRotSpell.HasMindRotScalar(m)) { MindRotSpell.ClearMindRotScalar(m); curseLevel += 2; } if (SpellPlagueSpell.HasSpellPlague(m)) { SpellPlagueSpell.RemoveFromList(m); curseLevel += 4; } if (m.GetStatMod("[Magic] Str Curse") != null) { m.RemoveStatMod("[Magic] Str Curse"); curseLevel += 1; } if (m.GetStatMod("[Magic] Dex Curse") != null) { m.RemoveStatMod("[Magic] Dex Curse"); curseLevel += 1; } if (m.GetStatMod("[Magic] Int Curse") != null) { m.RemoveStatMod("[Magic] Int Curse"); curseLevel += 1; } BuffInfo.RemoveBuff(m, BuffIcon.Clumsy); BuffInfo.RemoveBuff(m, BuffIcon.FeebleMind); BuffInfo.RemoveBuff(m, BuffIcon.Weaken); BuffInfo.RemoveBuff(m, BuffIcon.Curse); BuffInfo.RemoveBuff(m, BuffIcon.MassCurse); BuffInfo.RemoveBuff(m, BuffIcon.MortalStrike); BuffInfo.RemoveBuff(m, BuffIcon.Mindrot); BuffInfo.RemoveBuff(m, BuffIcon.CorpseSkin); BuffInfo.RemoveBuff(m, BuffIcon.Strangle); BuffInfo.RemoveBuff(m, BuffIcon.EvilOmen); return curseLevel; } } }
SirGrizzlyBear/ServUOGrizzly
Scripts/Spells/Mysticism/SpellDefinitions/CleansingWindsSpell.cs
C#
gpl-2.0
7,614
/* * Copyright (c) 2011, Intel Corporation. * * Licensed 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. */ #include <string.h> #include <sys/mman.h> #include <sys/types.h> #include <sys/stat.h> #include <fcntl.h> #include <errno.h> #include "kernelAPI.h" #include "globals.h" #define FILENAME_FLAGS (O_RDWR | O_TRUNC | O_CREAT) #define FILENAME_MODE (S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH) KernelAPI::KernelAPI() { } KernelAPI::~KernelAPI() { } uint8_t * KernelAPI::mmap(size_t bufLength, uint16_t bufID, MmapRegion region) { int prot = PROT_READ; if (region >= MMAPREGION_FENCE) throw FrmwkEx(HERE, "Detected illegal region = %d", region); if (region == MMR_META) prot |= PROT_WRITE; off_t encodeOffset = bufID; encodeOffset |= ((off_t)region << METADATA_UNIQUE_ID_BITS); encodeOffset *= sysconf(_SC_PAGESIZE); return (uint8_t *)::mmap(0, bufLength, prot, MAP_SHARED, gDutFd, encodeOffset); } void KernelAPI::munmap(uint8_t *memPtr, size_t bufLength) { ::munmap(memPtr, bufLength); } void KernelAPI::DumpKernelMetrics(DumpFilename filename) { int rc; struct nvme_file dumpMe = { (short unsigned int)filename.length(), filename.c_str() }; LOG_NRM("Dump dnvme metrics to filename: %s", filename.c_str()); if ((rc = ioctl(gDutFd, NVME_IOCTL_DUMP_METRICS, &dumpMe)) < 0) throw FrmwkEx(HERE, "Unable to dump dnvme metrics, err code = %d", rc); } void KernelAPI::DumpCtrlrSpaceRegs(DumpFilename filename, bool verbose) { int fd; string work; uint64_t value = 0; string outFile; const CtlSpcType *ctlMetrics = gRegisters->GetCtlMetrics(); LOG_NRM("Dump ctrlr regs to filename: %s", filename.c_str()); if ((fd = open(filename.c_str(), FILENAME_FLAGS, FILENAME_MODE)) == -1) throw FrmwkEx(HERE, "file=%s: %s", filename.c_str(), strerror(errno)); // Read all registers in ctrlr space for (int i = 0; i < CTLSPC_FENCE; i++) { if (!gRegisters->ValidSpecRev(ctlMetrics[i].specRev)) continue; if (ctlMetrics[i].size > MAX_SUPPORTED_REG_SIZE) { uint8_t *buffer; buffer = new uint8_t[ctlMetrics[i].size]; if (gRegisters->Read(NVMEIO_BAR01, ctlMetrics[i].size, ctlMetrics[i].offset, buffer, verbose) == false) { goto ERROR_OUT; } else { string work = " "; work += gRegisters->FormatRegister(NVMEIO_BAR01, ctlMetrics[i].size, ctlMetrics[i].offset, buffer); work += "\n"; write(fd, work.c_str(), work.size()); } delete [] buffer; } else if (gRegisters->Read((CtlSpc)i, value, verbose) == false) { break; } else { work = " "; // indent reg values within each capability work += gRegisters->FormatRegister(ctlMetrics[i].size, ctlMetrics[i].desc, value); work += "\n"; write(fd, work.c_str(), work.size()); } } close(fd); return; ERROR_OUT: close(fd); throw FrmwkEx(HERE); } void KernelAPI::DumpPciSpaceRegs(DumpFilename filename, bool verbose) { int fd; string work; uint64_t value; const PciSpcType *pciMetrics = gRegisters->GetPciMetrics(); const vector<PciCapabilities> *pciCap = gRegisters->GetPciCapabilities(); LOG_NRM("Dump PCI regs to filename: %s", filename.c_str()); if ((fd = open(filename.c_str(), FILENAME_FLAGS, FILENAME_MODE)) == -1) throw FrmwkEx(HERE, "file=%s: %s", filename.c_str(), strerror(errno)); // Traverse the PCI header registers work = "PCI header registers\n"; write(fd, work.c_str(), work.size()); for (int j = 0; j < PCISPC_FENCE; j++) { if (!gRegisters->ValidSpecRev(pciMetrics[j].specRev)) continue; // All PCI hdr regs don't have an associated capability if (pciMetrics[j].cap == PCICAP_FENCE) { if (gRegisters->Read((PciSpc)j, value, verbose) == false) goto ERROR_OUT; RegToFile(fd, pciMetrics[j], value); } } // Traverse all discovered capabilities for (size_t i = 0; i < pciCap->size(); i++) { switch (pciCap->at(i)) { case PCICAP_PMCAP: work = "Capabilities: PMCAP: PCI power management\n"; break; case PCICAP_MSICAP: work = "Capabilities: MSICAP: Message signaled interrupt\n"; break; case PCICAP_MSIXCAP: work = "Capabilities: MSIXCAP: Message signaled interrupt ext'd\n"; break; case PCICAP_PXCAP: work = "Capabilities: PXCAP: Message signaled interrupt\n"; break; case PCICAP_AERCAP: work = "Capabilities: AERCAP: Advanced Error Reporting\n"; break; default: LOG_ERR("PCI space reporting an unknown capability: %d\n", pciCap->at(i)); goto ERROR_OUT; } write(fd, work.c_str(), work.size()); // Read all registers assoc with the discovered capability for (int j = 0; j < PCISPC_FENCE; j++) { if (!gRegisters->ValidSpecRev(pciMetrics[j].specRev)) continue; if (pciCap->at(i) == pciMetrics[j].cap) { if (pciMetrics[j].size > MAX_SUPPORTED_REG_SIZE) { bool err = false; uint8_t *buffer; buffer = new uint8_t[pciMetrics[j].size]; if (gRegisters->Read(NVMEIO_PCI_HDR, pciMetrics[j].size, pciMetrics[j].offset, buffer, verbose) == false) { err = true; } else { string work = " "; work += gRegisters->FormatRegister(NVMEIO_PCI_HDR, pciMetrics[j].size, pciMetrics[j].offset, buffer); work += "\n"; write(fd, work.c_str(), work.size()); } delete [] buffer; if (err) goto ERROR_OUT; } else if (gRegisters->Read((PciSpc)j, value, verbose) == false) { goto ERROR_OUT; } else { RegToFile(fd, pciMetrics[j], value); } } } } close(fd); return; ERROR_OUT: close(fd); throw FrmwkEx(HERE); } void KernelAPI::RegToFile(int fd, const PciSpcType regMetrics, uint64_t value) { string work = " "; // indent reg values within each capability work += gRegisters->FormatRegister(regMetrics.size, regMetrics.desc, value); work += "\n"; write(fd, work.c_str(), work.size()); } void KernelAPI::LogCQMetrics(struct nvme_gen_cq &cqMetrics) { LOG_NRM("CQMetrics.q_id = 0x%04X", cqMetrics.q_id); LOG_NRM("CQMetrics.tail_ptr = 0x%04X", cqMetrics.tail_ptr); LOG_NRM("CQMetrics.head_ptr = 0x%04X", cqMetrics.head_ptr); LOG_NRM("CQMetrics.elements = 0x%04X", cqMetrics.elements); LOG_NRM("CQMetrics.irq_enabled = %s", cqMetrics.irq_enabled ? "T" : "F"); LOG_NRM("CQMetrics.irq_no = %d", cqMetrics.irq_no); LOG_NRM("CQMetrics.pbit_new_entry = %d", cqMetrics.pbit_new_entry); } void KernelAPI::LogSQMetrics(struct nvme_gen_sq &sqMetrics) { LOG_NRM("SQMetrics.sq_id = 0x%04X", sqMetrics.sq_id); LOG_NRM("SQMetrics.cq_id = 0x%04X", sqMetrics.cq_id); LOG_NRM("SQMetrics.tail_ptr = 0x%04X", sqMetrics.tail_ptr); LOG_NRM("SQMetrics.tail_ptr_virt = 0x%04X", sqMetrics.tail_ptr_virt); LOG_NRM("SQMetrics.head_ptr = 0x%04X", sqMetrics.head_ptr); LOG_NRM("SQMetrics.elements = 0x%04X", sqMetrics.elements); } void KernelAPI::WriteToDnvmeLog(string log) { int rc; struct nvme_logstr logMe = { (short unsigned int)log.length(), log.c_str() }; LOG_NRM("Write custom string to dnvme's log output: \"%s\"", log.c_str()); if ((rc = ioctl(gDutFd, NVME_IOCTL_MARK_SYSLOG, &logMe)) < 0) { throw FrmwkEx(HERE, "Unable to log custom string to dnvme, err = %d", rc); } }
junqiang521/Test
dnvme/tnvme-master/Utils/kernelAPI.cpp
C++
gpl-2.0
8,831
import csv import logging from fa.miner import yahoo from fa.piping import csv_string_to_records from fa.util import partition from fa.database.query import get_outdated_symbols, update_fundamentals import initialize from settings import * """ Download data from internet to database """ initialize.init() logger = logging.getLogger(__name__) logger.info("Will update historical prices of all symbols not up to date on {0}.".format(end_date)) all_symbols = [s.symbol for s in get_outdated_symbols("price", end_date)] # do the download in chunks of size 8 to prevent overloading servers for symbols in partition(all_symbols, 8): data = yahoo.get_historical_data(symbols, start_date, end_date) for symbol, csv_string in data.items(): if csv_string: try: records = csv_string_to_records(symbol, csv_string, strict=True) update_fundamentals("price", symbol, records, end_date, delete_old=True) except csv.Error as e: logger.exception(e) logger.error("csv of {0} is malformed.".format(symbol)) else: logger.warning("Could not find updated historical prices of {0}. Skip.".format(symbol)) logger.info("Finished updating historical prices.")
kakarukeys/algo-fa
examples/update_price_data.py
Python
gpl-2.0
1,268
/* packet-infiniband.c * Routines for Infiniband/ERF Dissection * Copyright 2008 Endace Technology Limited * * $Id: packet-infiniband.c 48400 2013-03-18 21:16:23Z etxrab $ * * Wireshark - Network traffic analyzer * By Gerald Combs <gerald@wireshark.org> * Copyright 1998 Gerald Combs * * Modified 2010 by Mellanox Technologies Ltd. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ #include "config.h" #include <string.h> #include <glib.h> #include <epan/packet.h> #include <epan/emem.h> #include <epan/conversation.h> #include <epan/prefs.h> #include <epan/etypes.h> #include <epan/show_exception.h> #include "packet-infiniband.h" #define PROTO_TAG_INFINIBAND "Infiniband" /* Wireshark ID */ static int proto_infiniband = -1; static int proto_infiniband_link = -1; /* Variables to hold expansion values between packets */ /* static gint ett_infiniband = -1; */ static gint ett_all_headers = -1; static gint ett_lrh = -1; static gint ett_grh = -1; static gint ett_bth = -1; static gint ett_rwh = -1; static gint ett_rdeth = -1; static gint ett_deth = -1; static gint ett_reth = -1; static gint ett_atomiceth = -1; static gint ett_aeth = -1; static gint ett_atomicacketh = -1; static gint ett_immdt = -1; static gint ett_ieth = -1; static gint ett_payload = -1; static gint ett_vendor = -1; static gint ett_subn_lid_routed = -1; static gint ett_subn_directed_route = -1; static gint ett_subnadmin = -1; static gint ett_mad = -1; static gint ett_cm = -1; static gint ett_rmpp = -1; static gint ett_subm_attribute = -1; static gint ett_suba_attribute = -1; static gint ett_datadetails = -1; static gint ett_noticestraps = -1; /* static gint ett_nodedesc = -1; */ /* static gint ett_nodeinfo = -1; */ /* static gint ett_switchinfo = -1; */ /* static gint ett_guidinfo = -1; */ /* static gint ett_portinfo = -1; */ static gint ett_portinfo_capmask = -1; static gint ett_pkeytable = -1; static gint ett_sltovlmapping = -1; static gint ett_vlarbitrationtable = -1; static gint ett_linearforwardingtable = -1; static gint ett_randomforwardingtable = -1; static gint ett_multicastforwardingtable = -1; static gint ett_sminfo = -1; static gint ett_vendordiag = -1; static gint ett_ledinfo = -1; static gint ett_linkspeedwidthpairs = -1; static gint ett_informinfo = -1; static gint ett_linkrecord = -1; static gint ett_servicerecord = -1; static gint ett_pathrecord = -1; static gint ett_mcmemberrecord = -1; static gint ett_tracerecord = -1; static gint ett_multipathrecord = -1; static gint ett_serviceassocrecord = -1; static gint ett_perfclass = -1; static gint ett_eoib = -1; static gint ett_link = -1; /* Global ref to highest level tree should we find other protocols encapsulated in IB */ static proto_tree *top_tree = NULL; /* Dissector Declarations */ static dissector_handle_t ipv6_handle; static dissector_handle_t data_handle; static dissector_handle_t eth_handle; static dissector_table_t ethertype_dissector_table; /* MAD_Data * Structure to hold information from the common MAD header. * This is necessary because the MAD header contains information which significantly changes the dissection algorithm. */ typedef struct { guint8 managementClass; guint8 classVersion; guint8 method; guint8 status; guint16 classSpecific; guint64 transactionID; guint16 attributeID; guint32 attributeModifier; char data[232]; } MAD_Data; /* Forward-declarations */ static void dissect_roce(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree); static void dissect_infiniband(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree); static void dissect_infiniband_common(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, gboolean starts_with_grh); static void dissect_infiniband_link(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree); static gint32 find_next_header_sequence(guint32 OpCode); static gboolean contains(guint32 value, guint32* arr, int length); static void dissect_general_info(tvbuff_t *tvb, gint offset, packet_info *pinfo, gboolean starts_with_grh); /* Parsing Methods for specific IB headers. */ static void parse_VENDOR(proto_tree *, tvbuff_t *, gint *); static void parse_PAYLOAD(proto_tree *, packet_info *, tvbuff_t *, gint *, gint length); static void parse_IETH(proto_tree *, tvbuff_t *, gint *); static void parse_IMMDT(proto_tree *, tvbuff_t *, gint *offset); static void parse_ATOMICACKETH(proto_tree *, tvbuff_t *, gint *offset); static void parse_AETH(proto_tree *, tvbuff_t *, gint *offset); static void parse_ATOMICETH(proto_tree *, tvbuff_t *, gint *offset); static void parse_RETH(proto_tree *, tvbuff_t *, gint *offset); static void parse_DETH(proto_tree *, packet_info *, tvbuff_t *, gint *offset); static void parse_RDETH(proto_tree *, tvbuff_t *, gint *offset); static void parse_IPvSix(proto_tree *, tvbuff_t *, gint *offset, packet_info *); static void parse_RWH(proto_tree *, tvbuff_t *, gint *offset, packet_info *); static gboolean parse_EoIB(proto_tree *, tvbuff_t *, gint offset, packet_info *); static void parse_SUBN_LID_ROUTED(proto_tree *, packet_info *, tvbuff_t *, gint *offset); static void parse_SUBN_DIRECTED_ROUTE(proto_tree *, packet_info *, tvbuff_t *, gint *offset); static void parse_SUBNADMN(proto_tree *, packet_info *, tvbuff_t *, gint *offset); static void parse_PERF(proto_tree *, tvbuff_t *, packet_info *, gint *offset); static void parse_BM(proto_tree *, tvbuff_t *, gint *offset); static void parse_DEV_MGT(proto_tree *, tvbuff_t *, gint *offset); static void parse_COM_MGT(proto_tree *parentTree, packet_info *pinfo, tvbuff_t *tvb, gint *offset); static void parse_SNMP(proto_tree *, tvbuff_t *, gint *offset); static void parse_VENDOR_MANAGEMENT(proto_tree *, tvbuff_t *, gint *offset); static void parse_APPLICATION_MANAGEMENT(proto_tree *, tvbuff_t *, gint *offset); static void parse_RESERVED_MANAGEMENT(proto_tree *, tvbuff_t *, gint *offset); static gboolean parse_MAD_Common(proto_tree*, tvbuff_t*, gint *offset, MAD_Data*); static gboolean parse_RMPP(proto_tree* , tvbuff_t* , gint *offset); static void label_SUBM_Method(proto_item*, MAD_Data*, packet_info*); static void label_SUBM_Attribute(proto_item*, MAD_Data*, packet_info*); static void label_SUBA_Method(proto_item*, MAD_Data*, packet_info*); static void label_SUBA_Attribute(proto_item*, MAD_Data*, packet_info*); /* Class Attribute Parsing Routines */ static gboolean parse_SUBM_Attribute(proto_tree*, tvbuff_t*, gint *offset, MAD_Data*); static gboolean parse_SUBA_Attribute(proto_tree*, tvbuff_t*, gint *offset, MAD_Data*); /* These methods parse individual attributes * Naming convention FunctionHandle = "parse_" + [Attribute Name]; * Where [Attribute Name] is the attribute identifier from chapter 14 of the IB Specification * Subnet Management */ static void parse_NoticesAndTraps(proto_tree*, tvbuff_t*, gint *offset); static void parse_NodeDescription(proto_tree*, tvbuff_t*, gint *offset); static int parse_NodeInfo(proto_tree*, tvbuff_t*, gint *offset); static int parse_SwitchInfo(proto_tree*, tvbuff_t*, gint *offset); static int parse_GUIDInfo(proto_tree*, tvbuff_t*, gint *offset); static int parse_PortInfo(proto_tree*, tvbuff_t*, gint *offset); static void parse_P_KeyTable(proto_tree*, tvbuff_t*, gint *offset); static void parse_SLtoVLMappingTable(proto_tree*, tvbuff_t*, gint *offset); static void parse_VLArbitrationTable(proto_tree*, tvbuff_t*, gint *offset); static void parse_LinearForwardingTable(proto_tree*, tvbuff_t*, gint *offset); static void parse_RandomForwardingTable(proto_tree*, tvbuff_t*, gint *offset); static void parse_MulticastForwardingTable(proto_tree*, tvbuff_t*, gint *offset); static int parse_SMInfo(proto_tree*, tvbuff_t*, gint *offset); static int parse_VendorDiag(proto_tree*, tvbuff_t*, gint *offset); static void parse_LedInfo(proto_tree*, tvbuff_t*, gint *offset); static int parse_LinkSpeedWidthPairsTable(proto_tree*, tvbuff_t*, gint *offset); /* These methods parse individual attributes for specific MAD management classes. * Naming convention FunctionHandle = "parse_" + [Management Class] + "_" + [Attribute Name]; * Where [Management Class] is the shorthand name for the management class as defined * in the MAD Management Classes section below in this file, and [Attribute Name] is the * attribute identifier from the corresponding chapter of the IB Specification */ static int parse_PERF_PortCounters(proto_tree* parentTree, tvbuff_t* tvb, packet_info *pinfo, gint *offset); static int parse_PERF_PortCountersExtended(proto_tree* parentTree, tvbuff_t* tvb, packet_info *pinfo, gint *offset); /* Subnet Administration */ static int parse_InformInfo(proto_tree*, tvbuff_t*, gint *offset); static int parse_LinkRecord(proto_tree*, tvbuff_t*, gint *offset); static int parse_ServiceRecord(proto_tree*, tvbuff_t*, gint *offset); static int parse_PathRecord(proto_tree*, tvbuff_t*, gint *offset); static int parse_MCMemberRecord(proto_tree*, tvbuff_t*, gint *offset); static int parse_TraceRecord(proto_tree*, tvbuff_t*, gint *offset); static int parse_MultiPathRecord(proto_tree*, tvbuff_t*, gint *offset); static int parse_ServiceAssociationRecord(proto_tree*, tvbuff_t*, gint *offset); /* Subnet Administration */ static void parse_RID(proto_tree*, tvbuff_t*, gint *offset, MAD_Data*); /* SM Methods */ static const value_string SUBM_Methods[] = { { 0x01, "SubnGet("}, { 0x02, "SubnSet("}, { 0x81, "SubnGetResp("}, { 0x05, "SubnTrap("}, { 0x07, "SubnTrapResp("}, { 0, NULL} }; /* SM Attributes */ static const value_string SUBM_Attributes[] = { { 0x0001, "Attribute (ClassPortInfo)"}, { 0x0002, "Attribute (Notice)"}, { 0x0003, "Attribute (InformInfo)"}, { 0x0010, "Attribute (NodeDescription)"}, { 0x0011, "Attribute (NodeInfo)"}, { 0x0012, "Attribute (SwitchInfo)"}, { 0x0014, "Attribute (GUIDInfo)"}, { 0x0015, "Attribute (PortInfo)"}, { 0x0016, "Attribute (P_KeyTable)"}, { 0x0017, "Attribute (SLtoVLMapptingTable)"}, { 0x0018, "Attribute (VLArbitrationTable)"}, { 0x0019, "Attribute (LinearForwardingTable)"}, { 0x001A, "Attribute (RandomForwardingTable)"}, { 0x001B, "Attribute (MulticastForwardingTable)"}, { 0x001C, "Attribute (LinkSpeedWidthPairsTable)"}, { 0x0020, "Attribute (SMInfo)"}, { 0x0030, "Attribute (VendorDiag)"}, { 0x0031, "Attribute (LedInfo)"}, { 0, NULL} }; /* SA Methods */ static const value_string SUBA_Methods[] = { { 0x01, "SubnAdmGet("}, { 0x81, "SubnAdmGetResp("}, { 0x02, "SubnAdmSet("}, { 0x06, "SubnAdmReport("}, { 0x86, "SubnAdmReportResp("}, { 0x12, "SubnAdmGetTable("}, { 0x92, "SubnAdmGetTableResp("}, { 0x13, "SubnAdmGetTraceTable("}, { 0x14, "SubnAdmGetMulti("}, { 0x94, "SubnAdmGetMultiResp("}, { 0x15, "SubnAdmDelete("}, { 0x95, "SubnAdmDeleteResp("}, { 0, NULL} }; /* SA Attributes */ static const value_string SUBA_Attributes[] = { { 0x0001, "Attribute (ClassPortInfo)"}, { 0x0002, "Attribute (Notice)"}, { 0x0003, "Attribute (InformInfo)"}, { 0x0011, "Attribute (NodeRecord)"}, { 0x0012, "Attribute (PortInfoRecord)"}, { 0x0013, "Attribute (SLtoVLMappingTableRecord)"}, { 0x0014, "Attribute (SwitchInfoRecord)"}, { 0x0015, "Attribute (LinearForwardingTableRecord)"}, { 0x0016, "Attribute (RandomForwardingTableRecord)"}, { 0x0017, "Attribute (MulticastForwardingTableRecord)"}, { 0x0018, "Attribute (SMInfoRecord)"}, { 0x0019, "Attribute (LinkSpeedWidthPairsTableRecord)"}, { 0x00F3, "Attribute (InformInfoRecord)"}, { 0x0020, "Attribute (LinkRecord)"}, { 0x0030, "Attribute (GuidInfoRecord)"}, { 0x0031, "Attribute (ServiceRecord)"}, { 0x0033, "Attribute (P_KeyTableRecord)"}, { 0x0035, "Attribute (PathRecord)"}, { 0x0036, "Attribute (VLArbitrationTableRecord)"}, { 0x0038, "Attribute (MCMembersRecord)"}, { 0x0039, "Attribute (TraceRecord)"}, { 0x003A, "Attribute (MultiPathRecord)"}, { 0x003B, "Attribute (ServiceAssociationRecord)"}, { 0, NULL} }; /* CM Attributes */ static const value_string CM_Attributes[] = { { 0x0001, "ClassPortInfo"}, { 0x0010, "ConnectRequest"}, { 0x0011, "MsgRcptAck"}, { 0x0012, "ConnectReject"}, { 0x0013, "ConnectReply"}, { 0x0014, "ReadyToUse"}, { 0x0015, "DisconnectRequest"}, { 0x0016, "DisconnectReply"}, { 0x0017, "ServiceIDResReq"}, { 0x0018, "ServiceIDResReqResp"}, { 0x0019, "LoadAlternatePath"}, { 0x001A, "AlternatePathResponse"}, { 0, NULL} }; /* RMPP Types */ #define RMPP_ILLEGAL 0 #define RMPP_DATA 1 #define RMPP_ACK 2 #define RMPP_STOP 3 #define RMPP_ABORT 4 static const value_string RMPP_Packet_Types[] = { { RMPP_ILLEGAL, " Illegal RMPP Type (0)! " }, { RMPP_DATA, "RMPP (DATA)" }, { RMPP_ACK, "RMPP (ACK)" }, { RMPP_STOP, "RMPP (STOP)" }, { RMPP_ABORT, "RMPP (ABORT)" }, { 0, NULL} }; static const value_string RMPP_Flags[] = { { 3, " (Transmission Sequence - First Packet)"}, { 5, " (Transmission Sequence - Last Packet)"}, { 1, " (Transmission Sequence) " }, { 0, NULL} }; static const value_string RMPP_Status[]= { { 0, " (Normal)"}, { 1, " (Resources Exhausted)"}, { 118, " (Total Time Too Long)"}, { 119, " (Inconsistent Last and PayloadLength)"}, { 120, " (Inconsistent First and Segment Number)"}, { 121, " (Bad RMPPType)"}, { 122, " (NewWindowLast Too Small)"}, { 123, " (SegmentNumber Too Big)"}, { 124, " (Illegal Status)"}, { 125, " (Unsupported Version)"}, { 126, " (Too Many Retries)"}, { 127, " (Unspecified - Unknown Error Code on ABORT)"}, { 0, NULL} }; static const value_string DiagCode[]= { {0x0000, "Function Ready"}, {0x0001, "Performing Self Test"}, {0x0002, "Initializing"}, {0x0003, "Soft Error - Function has non-fatal error"}, {0x0004, "Hard Error - Function has fatal error"}, { 0, NULL} }; static const value_string LinkWidthEnabled[]= { {0x0000, "No State Change"}, {0x0001, "1x"}, {0x0002, "4x"}, {0x0003, "1x or 4x"}, {0x0004, "8x"}, {0x0005, "1x or 8x"}, {0x0006, "4x or 8x"}, {0x0007, "1x or 4x or 8x"}, {0x0008, "12x"}, {0x0009, "1x or 12x"}, {0x000A, "4x or 12x"}, {0x000B, "1x or 4x or 12x"}, {0x000C, "8x or 12x"}, {0x000D, "1x or 8x or 12x"}, {0x000E, "4x or 8x or 12x"}, {0x000E, "1x or 4x or 8x or 12x"}, {0x00FF, "Set to LinkWidthSupported Value - Response contains actual LinkWidthSupported"}, { 0, NULL} }; static const value_string LinkWidthSupported[]= { {0x0001, "1x"}, {0x0003, "1x or 4x"}, {0x0007, "1x or 4x or 8x"}, {0x000B, "1x or 4x or 12x"}, {0x000F, "1x or 4x or 8x or 12x"}, { 0, NULL} }; static const value_string LinkWidthActive[]= { {0x0001, "1x"}, {0x0002, "4x"}, {0x0004, "8x"}, {0x0008, "12x"}, { 0, NULL} }; static const value_string LinkSpeedSupported[]= { {0x0001, "2.5 Gbps"}, {0x0003, "2.5 or 5.0 Gbps"}, {0x0005, "2.5 or 10.0 Gbps"}, {0x0007, "2.5 or 5.0 or 10.0 Gbps"}, { 0, NULL} }; static const value_string PortState[]= { {0x0000, "No State Change"}, {0x0001, "Down (includes failed links)"}, {0x0002, "Initialized"}, {0x0003, "Armed"}, {0x0004, "Active"}, { 0, NULL} }; static const value_string PortPhysicalState[]= { {0x0000, "No State Change"}, {0x0001, "Sleep"}, {0x0002, "Polling"}, {0x0003, "Disabled"}, {0x0004, "PortConfigurationTraining"}, {0x0005, "LinkUp"}, {0x0006, "LinkErrorRecovery"}, {0x0007, "Phy Test"}, { 0, NULL} }; static const value_string LinkDownDefaultState[]= { {0x0000, "No State Change"}, {0x0001, "Sleep"}, {0x0002, "Polling"}, { 0, NULL} }; static const value_string LinkSpeedActive[]= { {0x0001, "2.5 Gbps"}, {0x0002, "5.0 Gbps"}, {0x0004, "10.0 Gbps"}, { 0, NULL} }; static const value_string LinkSpeedEnabled[]= { {0x0000, "No State Change"}, {0x0001, "2.5 Gbps"}, {0x0003, "2.5 or 5.0 Gbps"}, {0x0005, "2.5 or 10.0 Gbps"}, {0x0007, "2.5 or 5.0 or 10.0 Gbps"}, {0x000F, "Set to LinkSpeedSupported value - response contains actual LinkSpeedSupported"}, { 0, NULL} }; static const value_string NeighborMTU[]= { {0x0001, "256"}, {0x0002, "512"}, {0x0003, "1024"}, {0x0004, "2048"}, {0x0005, "4096"}, { 0, NULL} }; static const value_string VLCap[]= { {0x0001, "VL0"}, {0x0002, "VL0, VL1"}, {0x0003, "VL0 - VL3"}, {0x0004, "VL0 - VL7"}, {0x0005, "VL0 - VL14"}, { 0, NULL} }; static const value_string MTUCap[]= { {0x0001, "256"}, {0x0002, "512"}, {0x0003, "1024"}, {0x0004, "2048"}, {0x0005, "4096"}, { 0, NULL} }; static const value_string OperationalVLs[]= { {0x0000, "No State Change"}, {0x0001, "VL0"}, {0x0002, "VL0, VL1"}, {0x0003, "VL0 - VL3"}, {0x0004, "VL0 - VL7"}, {0x0005, "VL0 - VL14"}, { 0, NULL} }; /* Local Route Header (LRH) */ static int hf_infiniband_LRH = -1; static int hf_infiniband_virtual_lane = -1; static int hf_infiniband_link_version = -1; static int hf_infiniband_service_level = -1; static int hf_infiniband_reserved2 = -1; static int hf_infiniband_link_next_header = -1; static int hf_infiniband_destination_local_id = -1; static int hf_infiniband_reserved5 = -1; static int hf_infiniband_packet_length = -1; static int hf_infiniband_source_local_id = -1; /* Global Route Header (GRH) */ static int hf_infiniband_GRH = -1; static int hf_infiniband_ip_version = -1; static int hf_infiniband_traffic_class = -1; static int hf_infiniband_flow_label = -1; static int hf_infiniband_payload_length = -1; static int hf_infiniband_next_header = -1; static int hf_infiniband_hop_limit = -1; static int hf_infiniband_source_gid = -1; static int hf_infiniband_destination_gid = -1; /* Base Transport Header (BTH) */ static int hf_infiniband_BTH = -1; static int hf_infiniband_opcode = -1; static int hf_infiniband_solicited_event = -1; static int hf_infiniband_migreq = -1; static int hf_infiniband_pad_count = -1; static int hf_infiniband_transport_header_version = -1; static int hf_infiniband_partition_key = -1; static int hf_infiniband_reserved8 = -1; static int hf_infiniband_destination_qp = -1; static int hf_infiniband_acknowledge_request = -1; static int hf_infiniband_reserved7 = -1; static int hf_infiniband_packet_sequence_number = -1; /* Raw Header (RWH) */ static int hf_infiniband_RWH = -1; static int hf_infiniband_reserved16_RWH = -1; static int hf_infiniband_etype = -1; /* Reliable Datagram Extended Transport Header (RDETH) */ static int hf_infiniband_RDETH = -1; static int hf_infiniband_reserved8_RDETH = -1; static int hf_infiniband_ee_context = -1; /* Datagram Extended Transport Header (DETH) */ static int hf_infiniband_DETH = -1; static int hf_infiniband_queue_key = -1; static int hf_infiniband_reserved8_DETH = -1; static int hf_infiniband_source_qp = -1; /* RDMA Extended Transport Header (RETH) */ static int hf_infiniband_RETH = -1; static int hf_infiniband_virtual_address = -1; static int hf_infiniband_remote_key = -1; static int hf_infiniband_dma_length = -1; /* Atomic Extended Transport Header (AtomicETH) */ static int hf_infiniband_AtomicETH = -1; /* static int hf_infiniband_virtual_address_AtomicETH = -1; */ /* static int hf_infiniband_remote_key_AtomicETH = -1; */ static int hf_infiniband_swap_or_add_data = -1; static int hf_infiniband_compare_data = -1; /* ACK Extended Transport Header (AETH) */ static int hf_infiniband_AETH = -1; static int hf_infiniband_syndrome = -1; static int hf_infiniband_message_sequence_number = -1; /* Atomic ACK Extended Transport Header (AtomicAckETH) */ static int hf_infiniband_AtomicAckETH = -1; static int hf_infiniband_original_remote_data = -1; /* Immediate Extended Transport Header (ImmDt) */ static int hf_infiniband_IMMDT = -1; /* Invalidate Extended Transport Header (IETH) */ static int hf_infiniband_IETH = -1; /* Payload */ static int hf_infiniband_payload = -1; static int hf_infiniband_invariant_crc = -1; static int hf_infiniband_variant_crc = -1; /* Unknown or Vendor Specific */ static int hf_infiniband_raw_data = -1; static int hf_infiniband_vendor = -1; /* CM REQ Header */ static int hf_cm_req_local_comm_id = -1; static int hf_cm_req_service_id = -1; static int hf_cm_req_local_ca_guid = -1; static int hf_cm_req_local_qkey = -1; static int hf_cm_req_local_qpn = -1; static int hf_cm_req_respo_res = -1; static int hf_cm_req_local_eecn = -1; static int hf_cm_req_init_depth = -1; static int hf_cm_req_remote_eecn = -1; static int hf_cm_req_remote_cm_resp_to = -1; static int hf_cm_req_transp_serv_type = -1; static int hf_cm_req_e2e_flow_ctrl = -1; static int hf_cm_req_start_psn = -1; static int hf_cm_req_local_cm_resp_to = -1; static int hf_cm_req_retry_count = -1; static int hf_cm_req_pkey = -1; static int hf_cm_req_path_pp_mtu = -1; static int hf_cm_req_rdc_exists = -1; static int hf_cm_req_rnr_retry_count = -1; static int hf_cm_req_max_cm_retries = -1; static int hf_cm_req_srq = -1; static int hf_cm_req_primary_local_lid = -1; static int hf_cm_req_primary_remote_lid = -1; static int hf_cm_req_primary_local_gid = -1; static int hf_cm_req_primary_remote_gid = -1; static int hf_cm_req_primary_flow_label = -1; static int hf_cm_req_primary_packet_rate = -1; static int hf_cm_req_primary_traffic_class = -1; static int hf_cm_req_primary_hop_limit = -1; static int hf_cm_req_primary_sl = -1; static int hf_cm_req_primary_subnet_local = -1; static int hf_cm_req_primary_local_ack_to = -1; static int hf_cm_req_alt_local_lid = -1; static int hf_cm_req_alt_remote_lid = -1; static int hf_cm_req_alt_local_gid = -1; static int hf_cm_req_alt_remote_gid = -1; static int hf_cm_req_flow_label = -1; static int hf_cm_req_packet_rate = -1; static int hf_cm_req_alt_traffic_class = -1; static int hf_cm_req_alt_hop_limit = -1; static int hf_cm_req_SL = -1; static int hf_cm_req_subnet_local = -1; static int hf_cm_req_local_ACK_timeout = -1; static int hf_cm_req_private_data = -1; /* CM REP Header */ static int hf_cm_rep_localcommid = -1; static int hf_cm_rep_remotecommid = -1; static int hf_cm_rep_localqkey = -1; static int hf_cm_rep_localqpn = -1; static int hf_cm_rep_localeecontnum = -1; static int hf_cm_rep_startingpsn = -1; static int hf_cm_rep_responderres = -1; static int hf_cm_rep_initiatordepth = -1; static int hf_cm_rep_tgtackdelay = -1; static int hf_cm_rep_failoveracc = -1; static int hf_cm_rep_e2eflowctl = -1; static int hf_cm_rep_rnrretrycount = -1; static int hf_cm_rep_srq = -1; static int hf_cm_rep_localcaguid = -1; static int hf_cm_rep_privatedata = -1; /* CM RTU Header */ static int hf_cm_rtu_localcommid = -1; static int hf_cm_rtu_remotecommid = -1; static int hf_cm_rtu_privatedata = -1; /* CM REJ Header */ static int hf_cm_rej_local_commid = -1; static int hf_cm_rej_remote_commid = -1; static int hf_cm_rej_msg_rej = -1; static int hf_cm_rej_rej_info_len = -1; static int hf_cm_rej_reason = -1; static int hf_cm_rej_add_rej_info = -1; static int hf_cm_rej_private_data = -1; /* MAD Base Header */ static int hf_infiniband_MAD = -1; static int hf_infiniband_base_version = -1; static int hf_infiniband_mgmt_class = -1; static int hf_infiniband_class_version = -1; /* static int hf_infiniband_reserved1 = -1; */ static int hf_infiniband_method = -1; static int hf_infiniband_status = -1; static int hf_infiniband_class_specific = -1; static int hf_infiniband_transaction_id = -1; static int hf_infiniband_attribute_id = -1; static int hf_infiniband_reserved16 = -1; static int hf_infiniband_attribute_modifier = -1; static int hf_infiniband_data = -1; /* RMPP Header */ static int hf_infiniband_RMPP = -1; static int hf_infiniband_rmpp_version = -1; static int hf_infiniband_rmpp_type = -1; static int hf_infiniband_r_resp_time = -1; static int hf_infiniband_rmpp_flags = -1; static int hf_infiniband_rmpp_status = -1; static int hf_infiniband_rmpp_data1 = -1; static int hf_infiniband_rmpp_data2 = -1; /* RMPP Data */ /* static int hf_infiniband_RMPP_DATA = -1; */ static int hf_infiniband_segment_number = -1; static int hf_infiniband_payload_length32 = -1; static int hf_infiniband_transferred_data = -1; /* RMPP ACK */ static int hf_infiniband_new_window_last = -1; static int hf_infiniband_reserved220 = -1; /* RMPP ABORT and STOP */ static int hf_infiniband_reserved32 = -1; static int hf_infiniband_optional_extended_error_data = -1; /* SMP Data LID Routed */ static int hf_infiniband_SMP_LID = -1; static int hf_infiniband_m_key = -1; static int hf_infiniband_smp_data = -1; static int hf_infiniband_reserved1024 = -1; static int hf_infiniband_reserved256 = -1; /* SMP Data Directed Route */ static int hf_infiniband_SMP_DIRECTED = -1; static int hf_infiniband_smp_status = -1; static int hf_infiniband_hop_pointer = -1; static int hf_infiniband_hop_count = -1; static int hf_infiniband_dr_slid = -1; static int hf_infiniband_dr_dlid = -1; static int hf_infiniband_reserved28 = -1; static int hf_infiniband_d = -1; static int hf_infiniband_initial_path = -1; static int hf_infiniband_return_path = -1; /* SA MAD Header */ static int hf_infiniband_SA = -1; static int hf_infiniband_sm_key = -1; static int hf_infiniband_attribute_offset = -1; static int hf_infiniband_component_mask = -1; static int hf_infiniband_subnet_admin_data = -1; /* Mellanox EoIB encapsulation header */ static int hf_infiniband_EOIB = -1; static int hf_infiniband_ver = -1; static int hf_infiniband_tcp_chk = -1; static int hf_infiniband_ip_chk = -1; static int hf_infiniband_fcs = -1; static int hf_infiniband_ms = -1; static int hf_infiniband_seg_off = -1; static int hf_infiniband_seg_id = -1; /* Attributes * Additional Structures for individuala attribute decoding. * Since they are not headers the naming convention is slightly modified * Convention: hf_infiniband_[attribute name]_[field] * This was not entirely necessary but I felt the previous convention * did not provide adequate readability for the granularity of attribute/attribute fields. */ /* NodeDescription */ static int hf_infiniband_NodeDescription_NodeString = -1; /* NodeInfo */ static int hf_infiniband_NodeInfo_BaseVersion = -1; static int hf_infiniband_NodeInfo_ClassVersion = -1; static int hf_infiniband_NodeInfo_NodeType = -1; static int hf_infiniband_NodeInfo_NumPorts = -1; static int hf_infiniband_NodeInfo_SystemImageGUID = -1; static int hf_infiniband_NodeInfo_NodeGUID = -1; static int hf_infiniband_NodeInfo_PortGUID = -1; static int hf_infiniband_NodeInfo_PartitionCap = -1; static int hf_infiniband_NodeInfo_DeviceID = -1; static int hf_infiniband_NodeInfo_Revision = -1; static int hf_infiniband_NodeInfo_LocalPortNum = -1; static int hf_infiniband_NodeInfo_VendorID = -1; /* SwitchInfo */ static int hf_infiniband_SwitchInfo_LinearFDBCap = -1; static int hf_infiniband_SwitchInfo_RandomFDBCap = -1; static int hf_infiniband_SwitchInfo_MulticastFDBCap = -1; static int hf_infiniband_SwitchInfo_LinearFDBTop = -1; static int hf_infiniband_SwitchInfo_DefaultPort = -1; static int hf_infiniband_SwitchInfo_DefaultMulticastPrimaryPort = -1; static int hf_infiniband_SwitchInfo_DefaultMulticastNotPrimaryPort = -1; static int hf_infiniband_SwitchInfo_LifeTimeValue = -1; static int hf_infiniband_SwitchInfo_PortStateChange = -1; static int hf_infiniband_SwitchInfo_OptimizedSLtoVLMappingProgramming = -1; static int hf_infiniband_SwitchInfo_LIDsPerPort = -1; static int hf_infiniband_SwitchInfo_PartitionEnforcementCap = -1; static int hf_infiniband_SwitchInfo_InboundEnforcementCap = -1; static int hf_infiniband_SwitchInfo_OutboundEnforcementCap = -1; static int hf_infiniband_SwitchInfo_FilterRawInboundCap = -1; static int hf_infiniband_SwitchInfo_FilterRawOutboundCap = -1; static int hf_infiniband_SwitchInfo_EnhancedPortZero = -1; /* GUIDInfo */ /* static int hf_infiniband_GUIDInfo_GUIDBlock = -1; */ static int hf_infiniband_GUIDInfo_GUID = -1; /* PortInfo */ static int hf_infiniband_PortInfo_GidPrefix = -1; static int hf_infiniband_PortInfo_LID = -1; static int hf_infiniband_PortInfo_MasterSMLID = -1; static int hf_infiniband_PortInfo_CapabilityMask = -1; /* Capability Mask Flags */ static int hf_infiniband_PortInfo_CapabilityMask_SM = -1; static int hf_infiniband_PortInfo_CapabilityMask_NoticeSupported = -1; static int hf_infiniband_PortInfo_CapabilityMask_TrapSupported = -1; static int hf_infiniband_PortInfo_CapabilityMask_OptionalPDSupported = -1; static int hf_infiniband_PortInfo_CapabilityMask_AutomaticMigrationSupported = -1; static int hf_infiniband_PortInfo_CapabilityMask_SLMappingSupported = -1; static int hf_infiniband_PortInfo_CapabilityMask_MKeyNVRAM = -1; static int hf_infiniband_PortInfo_CapabilityMask_PKeyNVRAM = -1; static int hf_infiniband_PortInfo_CapabilityMask_LEDInfoSupported = -1; static int hf_infiniband_PortInfo_CapabilityMask_SMdisabled = -1; static int hf_infiniband_PortInfo_CapabilityMask_SystemImageGUIDSupported = -1; static int hf_infiniband_PortInfo_CapabilityMask_PKeySwitchExternalPortTrapSupported = -1; static int hf_infiniband_PortInfo_CapabilityMask_CommunicationsManagementSupported = -1; static int hf_infiniband_PortInfo_CapabilityMask_SNMPTunnelingSupported = -1; static int hf_infiniband_PortInfo_CapabilityMask_ReinitSupported = -1; static int hf_infiniband_PortInfo_CapabilityMask_DeviceManagementSupported = -1; static int hf_infiniband_PortInfo_CapabilityMask_VendorClassSupported = -1; static int hf_infiniband_PortInfo_CapabilityMask_DRNoticeSupported = -1; static int hf_infiniband_PortInfo_CapabilityMask_CapabilityMaskNoticeSupported = -1; static int hf_infiniband_PortInfo_CapabilityMask_BootManagementSupported = -1; static int hf_infiniband_PortInfo_CapabilityMask_LinkRoundTripLatencySupported = -1; static int hf_infiniband_PortInfo_CapabilityMask_ClientRegistrationSupported = -1; static int hf_infiniband_PortInfo_CapabilityMask_OtherLocalChangesNoticeSupported = -1; static int hf_infiniband_PortInfo_CapabilityMask_LinkSpeedWIdthPairsTableSupported = -1; /* End Capability Mask Flags */ static int hf_infiniband_PortInfo_DiagCode = -1; static int hf_infiniband_PortInfo_M_KeyLeasePeriod = -1; static int hf_infiniband_PortInfo_LocalPortNum = -1; static int hf_infiniband_PortInfo_LinkWidthEnabled = -1; static int hf_infiniband_PortInfo_LinkWidthSupported = -1; static int hf_infiniband_PortInfo_LinkWidthActive = -1; static int hf_infiniband_PortInfo_LinkSpeedSupported = -1; static int hf_infiniband_PortInfo_PortState = -1; static int hf_infiniband_PortInfo_PortPhysicalState = -1; static int hf_infiniband_PortInfo_LinkDownDefaultState = -1; static int hf_infiniband_PortInfo_M_KeyProtectBits = -1; static int hf_infiniband_PortInfo_LMC = -1; static int hf_infiniband_PortInfo_LinkSpeedActive = -1; static int hf_infiniband_PortInfo_LinkSpeedEnabled = -1; static int hf_infiniband_PortInfo_NeighborMTU = -1; static int hf_infiniband_PortInfo_MasterSMSL = -1; static int hf_infiniband_PortInfo_VLCap = -1; static int hf_infiniband_PortInfo_M_Key = -1; static int hf_infiniband_PortInfo_InitType = -1; static int hf_infiniband_PortInfo_VLHighLimit = -1; static int hf_infiniband_PortInfo_VLArbitrationHighCap = -1; static int hf_infiniband_PortInfo_VLArbitrationLowCap = -1; static int hf_infiniband_PortInfo_InitTypeReply = -1; static int hf_infiniband_PortInfo_MTUCap = -1; static int hf_infiniband_PortInfo_VLStallCount = -1; static int hf_infiniband_PortInfo_HOQLife = -1; static int hf_infiniband_PortInfo_OperationalVLs = -1; static int hf_infiniband_PortInfo_PartitionEnforcementInbound = -1; static int hf_infiniband_PortInfo_PartitionEnforcementOutbound = -1; static int hf_infiniband_PortInfo_FilterRawInbound = -1; static int hf_infiniband_PortInfo_FilterRawOutbound = -1; static int hf_infiniband_PortInfo_M_KeyViolations = -1; static int hf_infiniband_PortInfo_P_KeyViolations = -1; static int hf_infiniband_PortInfo_Q_KeyViolations = -1; static int hf_infiniband_PortInfo_GUIDCap = -1; static int hf_infiniband_PortInfo_ClientReregister = -1; static int hf_infiniband_PortInfo_SubnetTimeOut = -1; static int hf_infiniband_PortInfo_RespTimeValue = -1; static int hf_infiniband_PortInfo_LocalPhyErrors = -1; static int hf_infiniband_PortInfo_OverrunErrors = -1; static int hf_infiniband_PortInfo_MaxCreditHint = -1; static int hf_infiniband_PortInfo_LinkRoundTripLatency = -1; /* P_KeyTable */ static int hf_infiniband_P_KeyTable_P_KeyTableBlock = -1; static int hf_infiniband_P_KeyTable_MembershipType = -1; static int hf_infiniband_P_KeyTable_P_KeyBase = -1; /* SLtoVLMappingTable */ static int hf_infiniband_SLtoVLMappingTable_SLtoVL_HighBits = -1; static int hf_infiniband_SLtoVLMappingTable_SLtoVL_LowBits = -1; /* VLArbitrationTable */ /* static int hf_infiniband_VLArbitrationTable_VLWeightPairs = -1; */ static int hf_infiniband_VLArbitrationTable_VL = -1; static int hf_infiniband_VLArbitrationTable_Weight = -1; /* LinearForwardingTable */ /* static int hf_infiniband_LinearForwardingTable_LinearForwardingTableBlock = -1; */ static int hf_infiniband_LinearForwardingTable_Port = -1; /* RandomForwardingTable */ /* static int hf_infiniband_RandomForwardingTable_RandomForwardingTableBlock = -1; */ static int hf_infiniband_RandomForwardingTable_LID = -1; static int hf_infiniband_RandomForwardingTable_Valid = -1; static int hf_infiniband_RandomForwardingTable_LMC = -1; static int hf_infiniband_RandomForwardingTable_Port = -1; /* MulticastForwardingTable */ /* static int hf_infiniband_MulticastForwardingTable_MulticastForwardingTableBlock = -1; */ static int hf_infiniband_MulticastForwardingTable_PortMask = -1; /* SMInfo */ static int hf_infiniband_SMInfo_GUID = -1; static int hf_infiniband_SMInfo_SM_Key = -1; static int hf_infiniband_SMInfo_ActCount = -1; static int hf_infiniband_SMInfo_Priority = -1; static int hf_infiniband_SMInfo_SMState = -1; /* VendorDiag */ static int hf_infiniband_VendorDiag_NextIndex = -1; static int hf_infiniband_VendorDiag_DiagData = -1; /* LedInfo */ static int hf_infiniband_LedInfo_LedMask = -1; /* LinkSpeedWidthPairsTable */ static int hf_infiniband_LinkSpeedWidthPairsTable_NumTables = -1; static int hf_infiniband_LinkSpeedWidthPairsTable_PortMask = -1; static int hf_infiniband_LinkSpeedWidthPairsTable_SpeedTwoFive = -1; static int hf_infiniband_LinkSpeedWidthPairsTable_SpeedFive = -1; static int hf_infiniband_LinkSpeedWidthPairsTable_SpeedTen = -1; /* Attributes for Subnet Administration. * Mostly we have "Records" here which are just structures of SM attributes. * There are some unique attributes though that we will want to have a structure for. */ /* NodeRecord */ /* PortInfoRecord */ /* SLtoVLMappingTableRecord */ /* SwitchInfoRecord */ /* LinearForwardingTableRecord */ /* RandomForwardingTableRecord */ /* MulticastForwardingTableRecord */ /* VLArbitrationTableRecord */ static int hf_infiniband_SA_LID = -1; static int hf_infiniband_SA_EndportLID = -1; static int hf_infiniband_SA_PortNum = -1; static int hf_infiniband_SA_InputPortNum = -1; static int hf_infiniband_SA_OutputPortNum = -1; static int hf_infiniband_SA_BlockNum_EightBit = -1; static int hf_infiniband_SA_BlockNum_NineBit = -1; static int hf_infiniband_SA_BlockNum_SixteenBit = -1; static int hf_infiniband_SA_Position = -1; /* static int hf_infiniband_SA_Index = -1; */ /* InformInfoRecord */ static int hf_infiniband_InformInfoRecord_SubscriberGID = -1; static int hf_infiniband_InformInfoRecord_Enum = -1; /* InformInfo */ static int hf_infiniband_InformInfo_GID = -1; static int hf_infiniband_InformInfo_LIDRangeBegin = -1; static int hf_infiniband_InformInfo_LIDRangeEnd = -1; static int hf_infiniband_InformInfo_IsGeneric = -1; static int hf_infiniband_InformInfo_Subscribe = -1; static int hf_infiniband_InformInfo_Type = -1; static int hf_infiniband_InformInfo_TrapNumberDeviceID = -1; static int hf_infiniband_InformInfo_QPN = -1; static int hf_infiniband_InformInfo_RespTimeValue = -1; static int hf_infiniband_InformInfo_ProducerTypeVendorID = -1; /* LinkRecord */ static int hf_infiniband_LinkRecord_FromLID = -1; static int hf_infiniband_LinkRecord_FromPort = -1; static int hf_infiniband_LinkRecord_ToPort = -1; static int hf_infiniband_LinkRecord_ToLID = -1; /* ServiceRecord */ static int hf_infiniband_ServiceRecord_ServiceID = -1; static int hf_infiniband_ServiceRecord_ServiceGID = -1; static int hf_infiniband_ServiceRecord_ServiceP_Key = -1; static int hf_infiniband_ServiceRecord_ServiceLease = -1; static int hf_infiniband_ServiceRecord_ServiceKey = -1; static int hf_infiniband_ServiceRecord_ServiceName = -1; static int hf_infiniband_ServiceRecord_ServiceData = -1; /* ServiceAssociationRecord */ static int hf_infiniband_ServiceAssociationRecord_ServiceKey = -1; static int hf_infiniband_ServiceAssociationRecord_ServiceName = -1; /* PathRecord */ static int hf_infiniband_PathRecord_DGID = -1; static int hf_infiniband_PathRecord_SGID = -1; static int hf_infiniband_PathRecord_DLID = -1; static int hf_infiniband_PathRecord_SLID = -1; static int hf_infiniband_PathRecord_RawTraffic = -1; static int hf_infiniband_PathRecord_FlowLabel = -1; static int hf_infiniband_PathRecord_HopLimit = -1; static int hf_infiniband_PathRecord_TClass = -1; static int hf_infiniband_PathRecord_Reversible = -1; static int hf_infiniband_PathRecord_NumbPath = -1; static int hf_infiniband_PathRecord_P_Key = -1; static int hf_infiniband_PathRecord_SL = -1; static int hf_infiniband_PathRecord_MTUSelector = -1; static int hf_infiniband_PathRecord_MTU = -1; static int hf_infiniband_PathRecord_RateSelector = -1; static int hf_infiniband_PathRecord_Rate = -1; static int hf_infiniband_PathRecord_PacketLifeTimeSelector = -1; static int hf_infiniband_PathRecord_PacketLifeTime = -1; static int hf_infiniband_PathRecord_Preference = -1; /* MCMemberRecord */ static int hf_infiniband_MCMemberRecord_MGID = -1; static int hf_infiniband_MCMemberRecord_PortGID = -1; static int hf_infiniband_MCMemberRecord_Q_Key = -1; static int hf_infiniband_MCMemberRecord_MLID = -1; static int hf_infiniband_MCMemberRecord_MTUSelector = -1; static int hf_infiniband_MCMemberRecord_MTU = -1; static int hf_infiniband_MCMemberRecord_TClass = -1; static int hf_infiniband_MCMemberRecord_P_Key = -1; static int hf_infiniband_MCMemberRecord_RateSelector = -1; static int hf_infiniband_MCMemberRecord_Rate = -1; static int hf_infiniband_MCMemberRecord_PacketLifeTimeSelector = -1; static int hf_infiniband_MCMemberRecord_PacketLifeTime = -1; static int hf_infiniband_MCMemberRecord_SL = -1; static int hf_infiniband_MCMemberRecord_FlowLabel = -1; static int hf_infiniband_MCMemberRecord_HopLimit = -1; static int hf_infiniband_MCMemberRecord_Scope = -1; static int hf_infiniband_MCMemberRecord_JoinState = -1; static int hf_infiniband_MCMemberRecord_ProxyJoin = -1; /* TraceRecord */ static int hf_infiniband_TraceRecord_GIDPrefix = -1; static int hf_infiniband_TraceRecord_IDGeneration = -1; static int hf_infiniband_TraceRecord_NodeType = -1; static int hf_infiniband_TraceRecord_NodeID = -1; static int hf_infiniband_TraceRecord_ChassisID = -1; static int hf_infiniband_TraceRecord_EntryPortID = -1; static int hf_infiniband_TraceRecord_ExitPortID = -1; static int hf_infiniband_TraceRecord_EntryPort = -1; static int hf_infiniband_TraceRecord_ExitPort = -1; /* MultiPathRecord */ static int hf_infiniband_MultiPathRecord_RawTraffic = -1; static int hf_infiniband_MultiPathRecord_FlowLabel = -1; static int hf_infiniband_MultiPathRecord_HopLimit = -1; static int hf_infiniband_MultiPathRecord_TClass = -1; static int hf_infiniband_MultiPathRecord_Reversible = -1; static int hf_infiniband_MultiPathRecord_NumbPath = -1; static int hf_infiniband_MultiPathRecord_P_Key = -1; static int hf_infiniband_MultiPathRecord_SL = -1; static int hf_infiniband_MultiPathRecord_MTUSelector = -1; static int hf_infiniband_MultiPathRecord_MTU = -1; static int hf_infiniband_MultiPathRecord_RateSelector = -1; static int hf_infiniband_MultiPathRecord_Rate = -1; static int hf_infiniband_MultiPathRecord_PacketLifeTimeSelector = -1; static int hf_infiniband_MultiPathRecord_PacketLifeTime = -1; static int hf_infiniband_MultiPathRecord_IndependenceSelector = -1; static int hf_infiniband_MultiPathRecord_GIDScope = -1; static int hf_infiniband_MultiPathRecord_SGIDCount = -1; static int hf_infiniband_MultiPathRecord_DGIDCount = -1; static int hf_infiniband_MultiPathRecord_SDGID = -1; /* Notice */ static int hf_infiniband_Notice_IsGeneric = -1; static int hf_infiniband_Notice_Type = -1; static int hf_infiniband_Notice_ProducerTypeVendorID = -1; static int hf_infiniband_Notice_TrapNumberDeviceID = -1; static int hf_infiniband_Notice_IssuerLID = -1; static int hf_infiniband_Notice_NoticeToggle = -1; static int hf_infiniband_Notice_NoticeCount = -1; static int hf_infiniband_Notice_DataDetails = -1; /* static int hf_infiniband_Notice_IssuerGID = -1; */ /* static int hf_infiniband_Notice_ClassTrapSpecificData = -1; */ /* PortCounters attribute in Performance class */ static int hf_infiniband_PortCounters = -1; static int hf_infiniband_PortCounters_PortSelect = -1; static int hf_infiniband_PortCounters_CounterSelect = -1; static int hf_infiniband_PortCounters_SymbolErrorCounter = -1; static int hf_infiniband_PortCounters_LinkErrorRecoveryCounter = -1; static int hf_infiniband_PortCounters_LinkDownedCounter = -1; static int hf_infiniband_PortCounters_PortRcvErrors = -1; static int hf_infiniband_PortCounters_PortRcvRemotePhysicalErrors = -1; static int hf_infiniband_PortCounters_PortRcvSwitchRelayErrors = -1; static int hf_infiniband_PortCounters_PortXmitDiscards = -1; static int hf_infiniband_PortCounters_PortXmitConstraintErrors = -1; static int hf_infiniband_PortCounters_PortRcvConstraintErrors = -1; static int hf_infiniband_PortCounters_LocalLinkIntegrityErrors = -1; static int hf_infiniband_PortCounters_ExcessiveBufferOverrunErrors = -1; static int hf_infiniband_PortCounters_VL15Dropped = -1; static int hf_infiniband_PortCounters_PortXmitData = -1; static int hf_infiniband_PortCounters_PortRcvData = -1; static int hf_infiniband_PortCounters_PortXmitPkts = -1; static int hf_infiniband_PortCounters_PortRcvPkts = -1; /* Extended PortCounters attribute in Performance class */ static int hf_infiniband_PortCountersExt = -1; static int hf_infiniband_PortCountersExt_PortSelect = -1; static int hf_infiniband_PortCountersExt_CounterSelect = -1; static int hf_infiniband_PortCountersExt_PortXmitData = -1; static int hf_infiniband_PortCountersExt_PortRcvData = -1; static int hf_infiniband_PortCountersExt_PortXmitPkts = -1; static int hf_infiniband_PortCountersExt_PortRcvPkts = -1; static int hf_infiniband_PortCountersExt_PortUnicastXmitPkts = -1; static int hf_infiniband_PortCountersExt_PortUnicastRcvPkts = -1; static int hf_infiniband_PortCountersExt_PortMulticastXmitPkts = -1; static int hf_infiniband_PortCountersExt_PortMulticastRcvPkts = -1; /* Notice DataDetails and ClassTrapSpecific Data for certain traps * Note that traps reuse many fields, so they are only declared once under the first trap that they appear. * There is no need to redeclare them for specific Traps (as with other SA Attributes) because they are uniform between Traps. */ /* Parse DataDetails for a given Trap */ static gint parse_NoticeDataDetails(proto_tree*, tvbuff_t*, gint *offset, guint16 trapNumber); /* Traps 64,65,66,67 */ static int hf_infiniband_Trap_GIDADDR = -1; /* Traps 68,69 */ /* DataDetails */ static int hf_infiniband_Trap_COMP_MASK = -1; static int hf_infiniband_Trap_WAIT_FOR_REPATH = -1; /* ClassTrapSpecificData */ /* static int hf_infiniband_Trap_PATH_REC = -1; */ /* Trap 128 */ static int hf_infiniband_Trap_LIDADDR = -1; /* Trap 129, 130, 131 */ static int hf_infiniband_Trap_PORTNO = -1; /* Trap 144 */ static int hf_infiniband_Trap_OtherLocalChanges = -1; static int hf_infiniband_Trap_CAPABILITYMASK = -1; static int hf_infiniband_Trap_LinkSpeecEnabledChange = -1; static int hf_infiniband_Trap_LinkWidthEnabledChange = -1; static int hf_infiniband_Trap_NodeDescriptionChange = -1; /* Trap 145 */ static int hf_infiniband_Trap_SYSTEMIMAGEGUID = -1; /* Trap 256 */ static int hf_infiniband_Trap_DRSLID = -1; static int hf_infiniband_Trap_METHOD = -1; static int hf_infiniband_Trap_ATTRIBUTEID = -1; static int hf_infiniband_Trap_ATTRIBUTEMODIFIER = -1; static int hf_infiniband_Trap_MKEY = -1; static int hf_infiniband_Trap_DRNotice = -1; static int hf_infiniband_Trap_DRPathTruncated = -1; static int hf_infiniband_Trap_DRHopCount = -1; static int hf_infiniband_Trap_DRNoticeReturnPath = -1; /* Trap 257, 258 */ static int hf_infiniband_Trap_LIDADDR1 = -1; static int hf_infiniband_Trap_LIDADDR2 = -1; static int hf_infiniband_Trap_KEY = -1; static int hf_infiniband_Trap_SL = -1; static int hf_infiniband_Trap_QP1 = -1; static int hf_infiniband_Trap_QP2 = -1; static int hf_infiniband_Trap_GIDADDR1 = -1; static int hf_infiniband_Trap_GIDADDR2 = -1; /* Trap 259 */ static int hf_infiniband_Trap_DataValid = -1; static int hf_infiniband_Trap_PKEY = -1; static int hf_infiniband_Trap_SWLIDADDR = -1; /* Infiniband Link */ static int hf_infiniband_link_op = -1; static int hf_infiniband_link_fctbs = -1; static int hf_infiniband_link_vl = -1; static int hf_infiniband_link_fccl = -1; static int hf_infiniband_link_lpcrc = -1; /* Trap Type/Descriptions for dissection */ static const value_string Operand_Description[]= { { 0, " Normal Flow Control"}, { 1, " Flow Control Init"}, { 0, NULL} }; /* Trap Type/Descriptions for dissection */ static const value_string Trap_Description[]= { { 64, " (Informational) <GIDADDR> is now in service"}, { 65, " (Informational) <GIDADDR> is out of service"}, { 66, " (Informational) New Multicast Group with multicast address <GIDADDR> is now created"}, { 67, " (Informational) Multicast Group with multicast address <GIDADDR> is now deleted"}, { 68, " (Informational) Paths indicated by <PATH_REC> and <COMP_MASK> are no longer valid"}, { 69, " (Informational) Paths indicated by <PATH_REC> and <COMP_MASK> have been recomputed"}, { 128, " (Urgent) Link State of at least one port of switch at <LIDADDR> has changed"}, { 129, " (Urgent) Local Link Integrity threshold reached at <LIDADDR><PORTNO>"}, { 130, " (Urgent) Excessive Buffer OVerrun threshold reached at <LIDADDR><PORTNO>"}, { 131, " (Urgent) Flow Control Update watchdog timer expired at <LIDADDR><PORTNO>"}, { 144, " (Informational) CapMask, NodeDesc, LinkWidthEnabled or LinkSpeedEnabled at <LIDADDR> has been modified"}, { 145, " (Informational) SystemImageGUID at <LIDADDR> has been modified. New value is <SYSTEMIMAGEGUID>"}, { 256, " (Security) Bad M_Key, <M_KEY> from <LIDADDR> attempted <METHOD> with <ATTRIBUTEID> and <ATTRIBUTEMODIFIER>"}, { 257, " (Security) Bad P_Key, <KEY> from <LIDADDR1><GIDADDR1><QP1> to <LIDADDR2><GIDADDR2><QP2> on <SL>"}, { 258, " (Security) Bad Q_Key, <KEY> from <LIDADDR1><GIDADDR1><QP1> to <LIDADDR2><GIDADDR2><QP2> on <SL>"}, { 259, " (Security) Bad P_Key, <KEY> from <LIDADDR1><GIDADDR1><QP1> to <LIDADDR2><GIDADDR2><QP2> on <SL> at switch <LIDADDR><PORTNO>"}, { 0, NULL} }; /* MAD Management Classes * Classes from the Common MAD Header * * Management Class Name Class Description * ------------------------------------------------------------------------------------------------------------ */ #define SUBN_LID_ROUTED 0x01 /* Subnet Management LID Route */ #define SUBN_DIRECTED_ROUTE 0x81 /* Subnet Management Directed Route */ #define SUBNADMN 0x03 /* Subnet Administration */ #define PERF 0x04 /* Performance Management */ #define BM 0x05 /* Baseboard Management (Tunneling of IB-ML commands through the IBA subnet) */ #define DEV_MGT 0x06 /* Device Management */ #define COM_MGT 0x07 /* Communications Management */ #define SNMP 0x08 /* SNMP Tunneling (tunneling of the SNMP protocol through the IBA fabric) */ #define VENDOR_1_START 0x09 /* Start of first Vendor Specific Range */ #define VENDOR_1_END 0x0F /* End of first Vendor Specific Range */ #define VENDOR_2_START 0x30 /* Start of second Vendor Specific Range */ #define VENDOR_2_END 0x4F /* End of the second Vendor Specific Range */ #define APPLICATION_START 0x10 /* Start of Application Specific Range */ #define APPLICATION_END 0x2F /* End of Application Specific Range */ /* Performance class Attributes */ #define ATTR_PORT_COUNTERS 0x0012 #define ATTR_PORT_COUNTERS_EXT 0x001D /* ComMgt class Attributes*/ #define ATTR_CM_REQ 0x0010 #define ATTR_CM_REP 0x0013 #define ATTR_CM_RTU 0x0014 #define ATTR_CM_REJ 0x0012 /* Link Next Header Values */ #define IBA_GLOBAL 3 #define IBA_LOCAL 2 #define IP_NON_IBA 1 #define RAW 0 /* OpCodeValues * Code Bits [7-5] Connection Type * [4-0] Message Type * Reliable Connection (RC) * [7-5] = 000 */ #define RC_SEND_FIRST 0 /*0x00000000 */ #define RC_SEND_MIDDLE 1 /*0x00000001 */ #define RC_SEND_LAST 2 /*0x00000010 */ #define RC_SEND_LAST_IMM 3 /*0x00000011 */ #define RC_SEND_ONLY 4 /*0x00000100 */ #define RC_SEND_ONLY_IMM 5 /*0x00000101 */ #define RC_RDMA_WRITE_FIRST 6 /*0x00000110 */ #define RC_RDMA_WRITE_MIDDLE 7 /*0x00000111 */ #define RC_RDMA_WRITE_LAST 8 /*0x00001000 */ #define RC_RDMA_WRITE_LAST_IMM 9 /*0x00001001 */ #define RC_RDMA_WRITE_ONLY 10 /*0x00001010 */ #define RC_RDMA_WRITE_ONLY_IMM 11 /*0x00001011 */ #define RC_RDMA_READ_REQUEST 12 /*0x00001100 */ #define RC_RDMA_READ_RESPONSE_FIRST 13 /*0x00001101 */ #define RC_RDMA_READ_RESPONSE_MIDDLE 14 /*0x00001110 */ #define RC_RDMA_READ_RESPONSE_LAST 15 /*0x00001111 */ #define RC_RDMA_READ_RESPONSE_ONLY 16 /*0x00010000 */ #define RC_ACKNOWLEDGE 17 /*0x00010001 */ #define RC_ATOMIC_ACKNOWLEDGE 18 /*0x00010010 */ #define RC_CMP_SWAP 19 /*0x00010011 */ #define RC_FETCH_ADD 20 /*0x00010100 */ #define RC_SEND_LAST_INVAL 22 /*0x00010110 */ #define RC_SEND_ONLY_INVAL 23 /*0x00010111 */ /* Reliable Datagram (RD) * [7-5] = 010 */ #define RD_SEND_FIRST 64 /*0x01000000 */ #define RD_SEND_MIDDLE 65 /*0x01000001 */ #define RD_SEND_LAST 66 /*0x01000010 */ #define RD_SEND_LAST_IMM 67 /*0x01000011 */ #define RD_SEND_ONLY 68 /*0x01000100 */ #define RD_SEND_ONLY_IMM 69 /*0x01000101 */ #define RD_RDMA_WRITE_FIRST 70 /*0x01000110 */ #define RD_RDMA_WRITE_MIDDLE 71 /*0x01000111 */ #define RD_RDMA_WRITE_LAST 72 /*0x01001000 */ #define RD_RDMA_WRITE_LAST_IMM 73 /*0x01001001 */ #define RD_RDMA_WRITE_ONLY 74 /*0x01001010 */ #define RD_RDMA_WRITE_ONLY_IMM 75 /*0x01001011 */ #define RD_RDMA_READ_REQUEST 76 /*0x01001100 */ #define RD_RDMA_READ_RESPONSE_FIRST 77 /*0x01001101 */ #define RD_RDMA_READ_RESPONSE_MIDDLE 78 /*0x01001110 */ #define RD_RDMA_READ_RESPONSE_LAST 79 /*0x01001111 */ #define RD_RDMA_READ_RESPONSE_ONLY 80 /*0x01010000 */ #define RD_ACKNOWLEDGE 81 /*0x01010001 */ #define RD_ATOMIC_ACKNOWLEDGE 82 /*0x01010010 */ #define RD_CMP_SWAP 83 /*0x01010011 */ #define RD_FETCH_ADD 84 /*0x01010100 */ #define RD_RESYNC 85 /*0x01010101 */ /* Unreliable Datagram (UD) * [7-5] = 011 */ #define UD_SEND_ONLY 100 /*0x01100100 */ #define UD_SEND_ONLY_IMM 101 /*0x01100101 */ /* Unreliable Connection (UC) * [7-5] = 001 */ #define UC_SEND_FIRST 32 /*0x00100000 */ #define UC_SEND_MIDDLE 33 /*0x00100001 */ #define UC_SEND_LAST 34 /*0x00100010 */ #define UC_SEND_LAST_IMM 35 /*0x00100011 */ #define UC_SEND_ONLY 36 /*0x00100100 */ #define UC_SEND_ONLY_IMM 37 /*0x00100101 */ #define UC_RDMA_WRITE_FIRST 38 /*0x00100110 */ #define UC_RDMA_WRITE_MIDDLE 39 /*0x00100111 */ #define UC_RDMA_WRITE_LAST 40 /*0x00101000 */ #define UC_RDMA_WRITE_LAST_IMM 41 /*0x00101001 */ #define UC_RDMA_WRITE_ONLY 42 /*0x00101010 */ #define UC_RDMA_WRITE_ONLY_IMM 43 /*0x00101011 */ static const value_string OpCodeMap[] = { { RC_SEND_FIRST, "RC Send First " }, { RC_SEND_MIDDLE, "RC Send Middle "}, { RC_SEND_LAST, "RC Send Last " }, { RC_SEND_LAST_IMM, "RC Send Last Immediate "}, { RC_SEND_ONLY, "RC Send Only "}, { RC_SEND_ONLY_IMM, "RC Send Only Immediate "}, { RC_RDMA_WRITE_FIRST, "RC RDMA Write First " }, { RC_RDMA_WRITE_MIDDLE, "RC RDMA Write Middle "}, { RC_RDMA_WRITE_LAST, "RC RDMA Write Last "}, { RC_RDMA_WRITE_LAST_IMM, "RC RDMA Write Last Immediate " }, { RC_RDMA_WRITE_ONLY, "RC RDMA Write Only " }, { RC_RDMA_WRITE_ONLY_IMM, "RC RDMA Write Only Immediate "}, { RC_RDMA_READ_REQUEST, "RC RDMA Read Request " }, { RC_RDMA_READ_RESPONSE_FIRST, "RC RDMA Read Response First " }, { RC_RDMA_READ_RESPONSE_MIDDLE, "RC RDMA Read Response Middle "}, { RC_RDMA_READ_RESPONSE_LAST, "RC RDMA Read Response Last " }, { RC_RDMA_READ_RESPONSE_ONLY, "RC RDMA Read Response Only "}, { RC_ACKNOWLEDGE, "RC Acknowledge " }, { RC_ATOMIC_ACKNOWLEDGE, "RC Atomic Acknowledge " }, { RC_CMP_SWAP, "RC Compare Swap " }, { RC_FETCH_ADD, "RC Fetch Add "}, { RC_SEND_LAST_INVAL, "RC Send Last Invalidate "}, { RC_SEND_ONLY_INVAL, "RC Send Only Invalidate " }, { RD_SEND_FIRST, "RD Send First "}, { RD_SEND_MIDDLE, "RD Send Middle " }, { RD_SEND_LAST, "RD Send Last "}, { RD_SEND_LAST_IMM, "RD Last Immediate " }, { RD_SEND_ONLY, "RD Send Only "}, { RD_SEND_ONLY_IMM, "RD Send Only Immediate "}, { RD_RDMA_WRITE_FIRST, "RD RDMA Write First "}, { RD_RDMA_WRITE_MIDDLE, "RD RDMA Write Middle "}, { RD_RDMA_WRITE_LAST, "RD RDMA Write Last "}, { RD_RDMA_WRITE_LAST_IMM, "RD RDMA Write Last Immediate "}, { RD_RDMA_WRITE_ONLY, "RD RDMA Write Only "}, { RD_RDMA_WRITE_ONLY_IMM, "RD RDMA Write Only Immediate "}, { RD_RDMA_READ_REQUEST, "RD RDMA Read Request "}, { RD_RDMA_READ_RESPONSE_FIRST, "RD RDMA Read Response First "}, { RD_RDMA_READ_RESPONSE_MIDDLE, "RD RDMA Read Response Middle "}, { RD_RDMA_READ_RESPONSE_LAST, "RD RDMA Read Response Last "}, { RD_RDMA_READ_RESPONSE_ONLY, "RD RDMA Read Response Only "}, { RD_ACKNOWLEDGE, "RD Acknowledge "}, { RD_ATOMIC_ACKNOWLEDGE, "RD Atomic Acknowledge "}, { RD_CMP_SWAP, "RD Compare Swap "}, { RD_FETCH_ADD, "RD Fetch Add "}, { RD_RESYNC, "RD RESYNC "}, { UD_SEND_ONLY, "UD Send Only "}, { UD_SEND_ONLY_IMM, "UD Send Only Immediate "}, { UC_SEND_FIRST, "UC Send First "}, { UC_SEND_MIDDLE, "UC Send Middle "}, { UC_SEND_LAST, "UC Send Last "}, { UC_SEND_LAST_IMM, "UC Send Last Immediate "}, { UC_SEND_ONLY, "UC Send Only "}, { UC_SEND_ONLY_IMM, "UC Send Only Immediate "}, { UC_RDMA_WRITE_FIRST, "UC RDMA Write First"}, { UC_RDMA_WRITE_MIDDLE, "Unreliable Connection RDMA Write Middle "}, { UC_RDMA_WRITE_LAST, "UC RDMA Write Last "}, { UC_RDMA_WRITE_LAST_IMM, "UC RDMA Write Last Immediate "}, { UC_RDMA_WRITE_ONLY, "UC RDMA Write Only "}, { UC_RDMA_WRITE_ONLY_IMM, "UC RDMA Write Only Immediate "}, { 0, NULL} }; /* Header Ordering Based on OPCODES * These are simply an enumeration of the possible header combinations defined by the IB Spec. * These enumerations * #DEFINE [HEADER_ORDER] [ENUM] * __________________________________ */ #define RDETH_DETH_PAYLD 0 /* __________________________________ */ #define RDETH_DETH_RETH_PAYLD 1 /* __________________________________ */ #define RDETH_DETH_IMMDT_PAYLD 2 /* __________________________________ */ #define RDETH_DETH_RETH_IMMDT_PAYLD 3 /* __________________________________ */ #define RDETH_DETH_RETH 4 /* __________________________________ */ #define RDETH_AETH_PAYLD 5 /* __________________________________ */ #define RDETH_PAYLD 6 /* __________________________________ */ #define RDETH_AETH 7 /* __________________________________ */ #define RDETH_AETH_ATOMICACKETH 8 /* __________________________________ */ #define RDETH_DETH_ATOMICETH 9 /* ___________________________________ */ #define RDETH_DETH 10 /* ___________________________________ */ #define DETH_PAYLD 11 /* ___________________________________ */ #define DETH_IMMDT_PAYLD 12 /* ___________________________________ */ #define PAYLD 13 /* ___________________________________ */ #define IMMDT_PAYLD 14 /* ___________________________________ */ #define RETH_PAYLD 15 /* ___________________________________ */ #define RETH_IMMDT_PAYLD 16 /* ___________________________________ */ #define RETH 17 /* ___________________________________ */ #define AETH_PAYLD 18 /* ___________________________________ */ #define AETH 19 /* ___________________________________ */ #define AETH_ATOMICACKETH 20 /* ___________________________________ */ #define ATOMICETH 21 /* ___________________________________ */ #define IETH_PAYLD 22 /* ___________________________________ */ /* Infiniband transport services These are an enumeration of the transport services over which an IB packet might be sent. The values match the corresponding 3 bits of the opCode field in the BTH */ #define TRANSPORT_RC 0 #define TRANSPORT_UC 1 #define TRANSPORT_RD 2 #define TRANSPORT_UD 3 /* Array of all availavle OpCodes to make matching a bit easier. * The OpCodes dictate the header sequence following in the packet. * These arrays tell the dissector which headers must be decoded for the given OpCode. */ static guint32 opCode_RDETH_DETH_ATOMICETH[] = { RD_CMP_SWAP, RD_FETCH_ADD }; static guint32 opCode_IETH_PAYLD[] = { RC_SEND_LAST_INVAL, RC_SEND_ONLY_INVAL }; static guint32 opCode_ATOMICETH[] = { RC_CMP_SWAP, RC_FETCH_ADD }; static guint32 opCode_RDETH_DETH_RETH_PAYLD[] = { RD_RDMA_WRITE_FIRST, RD_RDMA_WRITE_ONLY }; static guint32 opCode_RETH_IMMDT_PAYLD[] = { RC_RDMA_WRITE_ONLY_IMM, UC_RDMA_WRITE_ONLY_IMM }; static guint32 opCode_RDETH_DETH_IMMDT_PAYLD[] = { RD_SEND_LAST_IMM, RD_SEND_ONLY_IMM, RD_RDMA_WRITE_LAST_IMM }; static guint32 opCode_RDETH_AETH_PAYLD[] = { RD_RDMA_READ_RESPONSE_FIRST, RD_RDMA_READ_RESPONSE_LAST, RD_RDMA_READ_RESPONSE_ONLY }; static guint32 opCode_AETH_PAYLD[] = { RC_RDMA_READ_RESPONSE_FIRST, RC_RDMA_READ_RESPONSE_LAST, RC_RDMA_READ_RESPONSE_ONLY }; static guint32 opCode_RETH_PAYLD[] = { RC_RDMA_WRITE_FIRST, RC_RDMA_WRITE_ONLY, UC_RDMA_WRITE_FIRST, UC_RDMA_WRITE_ONLY }; static guint32 opCode_RDETH_DETH_PAYLD[] = { RD_SEND_FIRST, RD_SEND_MIDDLE, RD_SEND_LAST, RD_SEND_ONLY, RD_RDMA_WRITE_MIDDLE, RD_RDMA_WRITE_LAST }; static guint32 opCode_IMMDT_PAYLD[] = { RC_SEND_LAST_IMM, RC_SEND_ONLY_IMM, RC_RDMA_WRITE_LAST_IMM, UC_SEND_LAST_IMM, UC_SEND_ONLY_IMM, UC_RDMA_WRITE_LAST_IMM }; static guint32 opCode_PAYLD[] = { RC_SEND_FIRST, RC_SEND_MIDDLE, RC_SEND_LAST, RC_SEND_ONLY, RC_RDMA_WRITE_MIDDLE, RC_RDMA_WRITE_LAST, RC_RDMA_READ_RESPONSE_MIDDLE, UC_SEND_FIRST, UC_SEND_MIDDLE, UC_SEND_LAST, UC_SEND_ONLY, UC_RDMA_WRITE_MIDDLE, UC_RDMA_WRITE_LAST }; /* It is not necessary to create arrays for these OpCodes since they indicate only one further header. * We can just decode it directly * static guint32 opCode_DETH_IMMDT_PAYLD[] = { * UD_SEND_ONLY_IMM * }; * static guint32 opCode_DETH_PAYLD[] = { * UD_SEND_ONLY * }; * static guint32 opCode_RDETH_DETH[] = { * RD_RESYNC * }; * static guint32 opCode_RDETH_DETH_RETH[] = { * RD_RDMA_READ_REQUEST * }; * static guint32 opCode_RDETH_DETH_RETH_IMMDT_PAYLD[] = { * RD_RDMA_WRITE_ONLY_IMM * }; * static guint32 opCode_RDETH_AETH_ATOMICACKETH[] = { * RD_ATOMIC_ACKNOWLEDGE * }; * static guint32 opCode_RDETH_AETH[] = { * RD_ACKNOWLEDGE * }; * static guint32 opCode_RDETH_PAYLD[] = { * RD_RDMA_READ_RESPONSE_MIDDLE * }; * static guint32 opCode_AETH_ATOMICACKETH[] = { * RC_ATOMIC_ACKNOWLEDGE * }; * static guint32 opCode_RETH[] = { * RC_RDMA_READ_REQUEST * }; * static guint32 opCode_AETH[] = { * RC_ACKNOWLEDGE * }; */ static void *src_addr = NULL, /* the address to be displayed in the source/destination columns */ *dst_addr = NULL; /* (lid/gid number) will be stored here */ #define ADDR_MAX_LEN sizeof("IPv6 over IB Packet") /* maximum length of src_addr and dst_addr is for IPoIB where we print an explanation string */ static gint8 transport_type = -1; /* reflects the transport type of the packet being parsed. only use one of the TRANSPORT_* values for this field */ /* settings to be set by the user via the preferences dialog */ static gboolean pref_dissect_eoib = TRUE; static gboolean pref_identify_iba_payload = TRUE; /* saves information about connections that have been/are in the process of being negotiated via ConnectionManagement packets */ typedef struct { guint8 req_gid[GID_SIZE], resp_gid[GID_SIZE]; /* GID of requester/responder, respectively */ guint16 req_lid, resp_lid; /* LID of requester/responder, respectively */ guint32 req_qp, resp_qp; /* QP number of requester/responder, respectively */ guint64 service_id; /* service id for this connection */ } connection_context; /* holds a table of connection contexts being negotiated by CM. the key is a obtained using ADD_ADDRESS_TO_HASH(initiator address, TransactionID) [remember that the 1st argument to ADD_ADDRESS_TO_HASH must be an lvalue. */ static GHashTable *CM_context_table = NULL; /* heuristics sub-dissectors list for dissecting the data payload of IB packets */ static heur_dissector_list_t heur_dissectors_payload; /* heuristics sub-dissectors list for dissecting the PrivateData of CM packets */ static heur_dissector_list_t heur_dissectors_cm_private; /* ----- This sections contains various utility functions indirectly related to Infiniband dissection ---- */ /* g_int64_hash, g_int64_equal are defined starting glib 2.22 - otherwise, we'll have to provide them ourselves! */ #if !GLIB_CHECK_VERSION(2,22,0) guint g_int64_hash (gconstpointer v) { return (guint) *(const gint64*) v; } gboolean g_int64_equal (gconstpointer v1, gconstpointer v2) { return *((const gint64*) v1) == *((const gint64*) v2); } #endif void table_destroy_notify(gpointer data) { g_free(data); } /* --------------------------------------------------------------------------------------------------------*/ /* Helper dissector for correctly dissecting RoCE packets (encapsulated within an Ethernet */ /* frame). The only difference from regular IB packets is that RoCE packets do not contain */ /* a LRH, and always start with a GRH. */ static void dissect_roce(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) { /* this is a RoCE packet, so signal the IB dissector not to look for LRH */ dissect_infiniband_common(tvb, pinfo, tree, TRUE); } static void dissect_infiniband(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) { dissect_infiniband_common(tvb, pinfo, tree, FALSE); } /* Common Dissector for both InfiniBand and RoCE packets * IN: * tvb - The tvbbuff of packet data * pinfo - The packet info structure with column information * tree - The tree structure under which field nodes are to be added * starts_with_grh - If true this packets start with a GRH header (RoCE), otherwise with LRH as usual * Notes: * 1.) Floating "offset+=" statements should probably be "functionized" but they are inline * Offset is only passed by reference in specific places, so do not be confused when following code * In any code path, adding up "offset+=" statements will tell you what byte you are at */ static void dissect_infiniband_common(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, gboolean starts_with_grh) { /* Top Level Item */ proto_item *infiniband_packet; /* The Headers Subtree */ proto_tree *all_headers_tree; /* LRH - Local Route Header */ proto_item *local_route_header_item; proto_tree *local_route_header_tree; /* Raw Data */ proto_item *RAWDATA_header_item; guint8 lnh_val; /* Link Next Header Value */ gint offset = 0; /* Current Offset */ /* General Variables */ gboolean bthFollows = FALSE; /* Tracks if we are parsing a BTH. This is a significant decision point */ guint8 opCode = 0; /* OpCode from BTH header. */ gint32 nextHeaderSequence = -1; /* defined by this dissector. #define which indicates the upcoming header sequence from OpCode */ guint8 nxtHdr = 0; /* Keyed off for header dissection order */ guint16 packetLength = 0; /* Packet Length. We track this as tvb_length - offset. */ /* It provides the parsing methods a known size */ /* that must be available for that header. */ struct e_in6_addr SRCgid; /* Structures to hold GIDs should we need them */ struct e_in6_addr DSTgid; gint crc_length = 0; /* allocate space for source/destination addresses if not allocated already. we will fill them in later */ if (!src_addr) src_addr = se_alloc(ADDR_MAX_LEN); if (!dst_addr) dst_addr = se_alloc(ADDR_MAX_LEN); pinfo->srcport = pinfo->destport = 0xffffffff; /* set the src/dest QPN to something impossible instead of the default 0, so we don't mistake it for a MAD. (QP is only 24bit, so can't be 0xffffffff)*/ /* add any code that should only run the first time the packet is dissected here: */ if (!pinfo->fd->flags.visited) { pinfo->ptype = PT_IBQP; /* set the port-type for this packet to be Infiniband QP number */ } /* Mark the Packet type as Infiniband in the wireshark UI */ /* Clear other columns */ col_set_str(pinfo->cinfo, COL_PROTOCOL, "InfiniBand"); col_clear(pinfo->cinfo, COL_INFO); /* Get the parent tree from the ERF dissector. We don't want to nest under ERF */ if (tree && tree->parent) { /* Set the normal tree outside of ERF */ tree = tree->parent; /* Set a global reference for nested protocols */ top_tree = tree; } /* The "quick-dissection" code in dissect_general_info skips lots of the recently-added code for saving context etc. It is no longer viable to maintain two code branches, so we have (temporarily?) disabled the second one. All dissection now goes through the full branch, using a NULL tree pointer if this is not a full dissection call. Take care not to dereference the tree pointer or any subtree pointers you create using it and you'll be fine. */ if (0 && !tree) { /* If no packet details are being dissected, extract some high level info for the packet view */ /* Assigns column values rather than full tree population */ dissect_general_info(tvb, offset, pinfo, starts_with_grh); return; } /* Top Level Packet */ infiniband_packet = proto_tree_add_item(tree, proto_infiniband, tvb, offset, -1, ENC_NA); /* Headers Level Tree */ all_headers_tree = proto_item_add_subtree(infiniband_packet, ett_all_headers); if (starts_with_grh) { /* this is a RoCE packet, skip LRH parsing */ lnh_val = IBA_GLOBAL; packetLength = tvb_get_ntohs(tvb, 4); /* since we have no LRH to get PktLen from, use that of the GRH */ goto skip_lrh; } /* Local Route Header Subtree */ local_route_header_item = proto_tree_add_item(all_headers_tree, hf_infiniband_LRH, tvb, offset, 8, ENC_NA); proto_item_set_text(local_route_header_item, "%s", "Local Route Header"); local_route_header_tree = proto_item_add_subtree(local_route_header_item, ett_lrh); proto_tree_add_item(local_route_header_tree, hf_infiniband_virtual_lane, tvb, offset, 1, ENC_BIG_ENDIAN); proto_tree_add_item(local_route_header_tree, hf_infiniband_link_version, tvb, offset, 1, ENC_BIG_ENDIAN); offset += 1; proto_tree_add_item(local_route_header_tree, hf_infiniband_service_level, tvb, offset, 1, ENC_BIG_ENDIAN); proto_tree_add_item(local_route_header_tree, hf_infiniband_reserved2, tvb, offset, 1, ENC_BIG_ENDIAN); proto_tree_add_item(local_route_header_tree, hf_infiniband_link_next_header, tvb, offset, 1, ENC_BIG_ENDIAN); /* Save Link Next Header... This tells us what the next header is. */ lnh_val = tvb_get_guint8(tvb, offset); lnh_val = lnh_val & 0x03; offset += 1; proto_tree_add_item(local_route_header_tree, hf_infiniband_destination_local_id, tvb, offset, 2, ENC_BIG_ENDIAN); /* Set destination in packet view. */ *((guint16*) dst_addr) = tvb_get_ntohs(tvb, offset); SET_ADDRESS(&pinfo->dst, AT_IB, sizeof(guint16), dst_addr); offset += 2; proto_tree_add_item(local_route_header_tree, hf_infiniband_reserved5, tvb, offset, 2, ENC_BIG_ENDIAN); packetLength = tvb_get_ntohs(tvb, offset); /* Get the Packet Length. This will determine payload size later on. */ packetLength = packetLength & 0x07FF; /* Mask off top 5 bits, they are reserved */ packetLength = packetLength * 4; /* Multiply by 4 to get true byte length. This is by specification. */ /* PktLen is size in 4 byte words (byteSize /4). */ proto_tree_add_item(local_route_header_tree, hf_infiniband_packet_length, tvb, offset, 2, ENC_BIG_ENDIAN); offset += 2; proto_tree_add_item(local_route_header_tree, hf_infiniband_source_local_id, tvb, offset, 2, ENC_BIG_ENDIAN); /* Set Source in packet view. */ *((guint16*) src_addr) = tvb_get_ntohs(tvb, offset); SET_ADDRESS(&pinfo->src, AT_IB, sizeof(guint16), src_addr); offset += 2; packetLength -= 8; /* Shave 8 bytes for the LRH. */ skip_lrh: /* Key off Link Next Header. This tells us what High Level Data Format we have */ switch (lnh_val) { case IBA_GLOBAL: { proto_item *global_route_header_item; proto_tree *global_route_header_tree; global_route_header_item = proto_tree_add_item(all_headers_tree, hf_infiniband_GRH, tvb, offset, 40, ENC_NA); proto_item_set_text(global_route_header_item, "%s", "Global Route Header"); global_route_header_tree = proto_item_add_subtree(global_route_header_item, ett_grh); proto_tree_add_item(global_route_header_tree, hf_infiniband_ip_version, tvb, offset, 1, ENC_BIG_ENDIAN); proto_tree_add_item(global_route_header_tree, hf_infiniband_traffic_class, tvb, offset, 2, ENC_BIG_ENDIAN); proto_tree_add_item(global_route_header_tree, hf_infiniband_flow_label, tvb, offset, 4, ENC_BIG_ENDIAN); offset += 4; proto_tree_add_item(global_route_header_tree, hf_infiniband_payload_length, tvb, offset, 2, ENC_BIG_ENDIAN); offset += 2; nxtHdr = tvb_get_guint8(tvb, offset); proto_tree_add_item(global_route_header_tree, hf_infiniband_next_header, tvb, offset, 1, ENC_BIG_ENDIAN); offset += 1; proto_tree_add_item(global_route_header_tree, hf_infiniband_hop_limit, tvb, offset, 1, ENC_BIG_ENDIAN); offset += 1; proto_tree_add_item(global_route_header_tree, hf_infiniband_source_gid, tvb, offset, 16, ENC_NA); tvb_get_ipv6(tvb, offset, &SRCgid); /* set source GID in packet view*/ memcpy(src_addr, &SRCgid, GID_SIZE); SET_ADDRESS(&pinfo->src, AT_IB, GID_SIZE, src_addr); offset += 16; proto_tree_add_item(global_route_header_tree, hf_infiniband_destination_gid, tvb, offset, 16, ENC_NA); tvb_get_ipv6(tvb, offset, &DSTgid); /* set destination GID in packet view*/ memcpy(dst_addr, &DSTgid, GID_SIZE); SET_ADDRESS(&pinfo->dst, AT_IB, GID_SIZE, dst_addr); offset += 16; packetLength -= 40; /* Shave 40 bytes for GRH */ if (nxtHdr != 0x1B) { /* Some kind of packet being transported globally with IBA, but locally it is not IBA - no BTH following. */ break; } } /* otherwise fall through and start parsing BTH */ case IBA_LOCAL: { proto_item *base_transport_header_item; proto_tree *base_transport_header_tree; bthFollows = TRUE; base_transport_header_item = proto_tree_add_item(all_headers_tree, hf_infiniband_BTH, tvb, offset, 12, ENC_NA); proto_item_set_text(base_transport_header_item, "%s", "Base Transport Header"); base_transport_header_tree = proto_item_add_subtree(base_transport_header_item, ett_bth); proto_tree_add_item(base_transport_header_tree, hf_infiniband_opcode, tvb, offset, 1, ENC_BIG_ENDIAN); /* Get the OpCode - this tells us what headers are following */ opCode = tvb_get_guint8(tvb, offset); col_append_str(pinfo->cinfo, COL_INFO, val_to_str_const((guint32)opCode, OpCodeMap, "Unknown OpCode")); offset += 1; proto_tree_add_item(base_transport_header_tree, hf_infiniband_solicited_event, tvb, offset, 1, ENC_BIG_ENDIAN); proto_tree_add_item(base_transport_header_tree, hf_infiniband_migreq, tvb, offset, 1, ENC_BIG_ENDIAN); proto_tree_add_item(base_transport_header_tree, hf_infiniband_pad_count, tvb, offset, 1, ENC_BIG_ENDIAN); proto_tree_add_item(base_transport_header_tree, hf_infiniband_transport_header_version, tvb, offset, 1, ENC_BIG_ENDIAN); offset += 1; proto_tree_add_item(base_transport_header_tree, hf_infiniband_partition_key, tvb, offset, 2, ENC_BIG_ENDIAN); offset += 2; proto_tree_add_item(base_transport_header_tree, hf_infiniband_reserved8, tvb, offset, 1, ENC_BIG_ENDIAN); offset += 1; proto_tree_add_item(base_transport_header_tree, hf_infiniband_destination_qp, tvb, offset, 3, ENC_BIG_ENDIAN); pinfo->destport = tvb_get_ntoh24(tvb, offset); offset += 3; proto_tree_add_item(base_transport_header_tree, hf_infiniband_acknowledge_request, tvb, offset, 1, ENC_BIG_ENDIAN); proto_tree_add_item(base_transport_header_tree, hf_infiniband_reserved7, tvb, offset, 1, ENC_BIG_ENDIAN); offset += 1; proto_tree_add_item(base_transport_header_tree, hf_infiniband_packet_sequence_number, tvb, offset, 3, ENC_BIG_ENDIAN); offset += 3; packetLength -= 12; /* Shave 12 for Base Transport Header */ } break; case IP_NON_IBA: /* Raw IPv6 Packet */ g_snprintf((gchar *)dst_addr, ADDR_MAX_LEN, "IPv6 over IB Packet"); SET_ADDRESS(&pinfo->dst, AT_STRINGZ, (int)strlen((char *)dst_addr)+1, dst_addr); parse_IPvSix(all_headers_tree, tvb, &offset, pinfo); break; case RAW: parse_RWH(all_headers_tree, tvb, &offset, pinfo); break; default: /* Unknown Packet */ RAWDATA_header_item = proto_tree_add_item(all_headers_tree, hf_infiniband_raw_data, tvb, offset, -1, ENC_NA); proto_item_set_text(RAWDATA_header_item, "%s", "Unknown Raw Data - IB Encapsulated"); break; } /* Base Transport header is hit quite often, however it is alone since it is the exception not the rule */ /* Only IBA Local packets use it */ if (bthFollows) { /* Find our next header sequence based on the Opcode * Each case decrements the packetLength by the amount of bytes consumed by each header. * The find_next_header_sequence method could be used to automate this. * We need to keep track of this so we know much data to mark as payload/ICRC/VCRC values. */ transport_type = (opCode & 0xE0) >> 5; /* save transport type for identifying EoIB payloads later... */ nextHeaderSequence = find_next_header_sequence((guint32) opCode); /* find_next_header_sequence gives us the DEFINE value corresponding to the header order following */ /* Enumerations are named intuitively, e.g. RDETH DETH PAYLOAD means there is an RDETH Header, DETH Header, and a packet payload */ switch (nextHeaderSequence) { case RDETH_DETH_PAYLD: parse_RDETH(all_headers_tree, tvb, &offset); parse_DETH(all_headers_tree, pinfo, tvb, &offset); packetLength -= 4; /* RDETH */ packetLength -= 8; /* DETH */ parse_PAYLOAD(all_headers_tree, pinfo, tvb, &offset, packetLength); break; case RDETH_DETH_RETH_PAYLD: parse_RDETH(all_headers_tree, tvb, &offset); parse_DETH(all_headers_tree, pinfo, tvb, &offset); parse_RETH(all_headers_tree, tvb, &offset); packetLength -= 4; /* RDETH */ packetLength -= 8; /* DETH */ packetLength -= 16; /* RETH */ parse_PAYLOAD(all_headers_tree, pinfo, tvb, &offset, packetLength); break; case RDETH_DETH_IMMDT_PAYLD: parse_RDETH(all_headers_tree, tvb, &offset); parse_DETH(all_headers_tree, pinfo, tvb, &offset); parse_IMMDT(all_headers_tree, tvb, &offset); packetLength -= 4; /* RDETH */ packetLength -= 8; /* DETH */ packetLength -= 4; /* IMMDT */ parse_PAYLOAD(all_headers_tree, pinfo, tvb, &offset, packetLength); break; case RDETH_DETH_RETH_IMMDT_PAYLD: parse_RDETH(all_headers_tree, tvb, &offset); parse_DETH(all_headers_tree, pinfo, tvb, &offset); parse_RETH(all_headers_tree, tvb, &offset); parse_IMMDT(all_headers_tree, tvb, &offset); packetLength -= 4; /* RDETH */ packetLength -= 8; /* DETH */ packetLength -= 16; /* RETH */ packetLength -= 4; /* IMMDT */ parse_PAYLOAD(all_headers_tree, pinfo, tvb, &offset, packetLength); break; case RDETH_DETH_RETH: parse_RDETH(all_headers_tree, tvb, &offset); parse_DETH(all_headers_tree, pinfo, tvb, &offset); parse_RETH(all_headers_tree, tvb, &offset); /*packetLength -= 4;*/ /* RDETH */ /*packetLength -= 8;*/ /* DETH */ /*packetLength -= 16;*/ /* RETH */ break; case RDETH_AETH_PAYLD: parse_RDETH(all_headers_tree, tvb, &offset); parse_AETH(all_headers_tree, tvb, &offset); packetLength -= 4; /* RDETH */ packetLength -= 4; /* AETH */ parse_PAYLOAD(all_headers_tree, pinfo, tvb, &offset, packetLength); break; case RDETH_PAYLD: parse_RDETH(all_headers_tree, tvb, &offset); packetLength -= 4; /* RDETH */ parse_PAYLOAD(all_headers_tree, pinfo, tvb, &offset, packetLength); break; case RDETH_AETH: parse_AETH(all_headers_tree, tvb, &offset); /*packetLength -= 4;*/ /* RDETH */ /*packetLength -= 4;*/ /* AETH */ break; case RDETH_AETH_ATOMICACKETH: parse_RDETH(all_headers_tree, tvb, &offset); parse_AETH(all_headers_tree, tvb, &offset); parse_ATOMICACKETH(all_headers_tree, tvb, &offset); /*packetLength -= 4;*/ /* RDETH */ /*packetLength -= 4;*/ /* AETH */ /*packetLength -= 8;*/ /* AtomicAckETH */ break; case RDETH_DETH_ATOMICETH: parse_RDETH(all_headers_tree, tvb, &offset); parse_DETH(all_headers_tree, pinfo, tvb, &offset); parse_ATOMICETH(all_headers_tree, tvb, &offset); /*packetLength -= 4;*/ /* RDETH */ /*packetLength -= 8;*/ /* DETH */ /*packetLength -= 28;*/ /* AtomicETH */ break; case RDETH_DETH: parse_RDETH(all_headers_tree, tvb, &offset); parse_DETH(all_headers_tree, pinfo, tvb, &offset); /*packetLength -= 4;*/ /* RDETH */ /*packetLength -= 8;*/ /* DETH */ break; case DETH_PAYLD: parse_DETH(all_headers_tree, pinfo, tvb, &offset); packetLength -= 8; /* DETH */ parse_PAYLOAD(all_headers_tree, pinfo, tvb, &offset, packetLength); break; case PAYLD: parse_PAYLOAD(all_headers_tree, pinfo, tvb, &offset, packetLength); break; case IMMDT_PAYLD: parse_IMMDT(all_headers_tree, tvb, &offset); packetLength -= 4; /* IMMDT */ parse_PAYLOAD(all_headers_tree, pinfo, tvb, &offset, packetLength); break; case RETH_PAYLD: parse_RETH(all_headers_tree, tvb, &offset); packetLength -= 16; /* RETH */ parse_PAYLOAD(all_headers_tree, pinfo, tvb, &offset, packetLength); break; case RETH: parse_RETH(all_headers_tree, tvb, &offset); /*packetLength -= 16;*/ /* RETH */ break; case AETH_PAYLD: parse_AETH(all_headers_tree, tvb, &offset); packetLength -= 4; /* AETH */ parse_PAYLOAD(all_headers_tree, pinfo, tvb, &offset, packetLength); break; case AETH: parse_AETH(all_headers_tree, tvb, &offset); /*packetLength -= 4;*/ /* AETH */ break; case AETH_ATOMICACKETH: parse_AETH(all_headers_tree, tvb, &offset); parse_ATOMICACKETH(all_headers_tree, tvb, &offset); /*packetLength -= 4;*/ /* AETH */ /*packetLength -= 8;*/ /* AtomicAckETH */ break; case ATOMICETH: parse_ATOMICETH(all_headers_tree, tvb, &offset); /*packetLength -= 28;*/ /* AtomicETH */ break; case IETH_PAYLD: parse_IETH(all_headers_tree, tvb, &offset); packetLength -= 4; /* IETH */ parse_PAYLOAD(all_headers_tree, pinfo, tvb, &offset, packetLength); break; case DETH_IMMDT_PAYLD: parse_DETH(all_headers_tree, pinfo, tvb, &offset); parse_IMMDT(all_headers_tree, tvb, &offset); packetLength -= 8; /* DETH */ packetLength -= 4; /* IMMDT */ parse_PAYLOAD(all_headers_tree, pinfo, tvb, &offset, packetLength); break; default: parse_VENDOR(all_headers_tree, tvb, &offset); break; } } /* Display the ICRC/VCRC */ /* Doing it this way rather than in a variety of places according to the specific packet */ /* If we've already displayed it crc_length comes out 0 */ crc_length = tvb_reported_length_remaining(tvb, offset); if (crc_length == 6) { proto_tree_add_item(all_headers_tree, hf_infiniband_invariant_crc, tvb, offset, 4, ENC_BIG_ENDIAN); offset += 4; proto_tree_add_item(all_headers_tree, hf_infiniband_variant_crc, tvb, offset, 2, ENC_BIG_ENDIAN); offset += 2; } else if (crc_length == 4) { proto_tree_add_item(all_headers_tree, hf_infiniband_invariant_crc, tvb, offset, 4, ENC_BIG_ENDIAN); offset += 4; } else if (crc_length == 2) { proto_tree_add_item(all_headers_tree, hf_infiniband_variant_crc, tvb, offset, 2, ENC_BIG_ENDIAN); offset += 2; } } static void dissect_infiniband_link(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) { /* Top Level Item */ proto_item *infiniband_link_packet; /* The Link Subtree */ proto_tree *link_tree; proto_item *operand_item; gint offset = 0; /* Current Offset */ guint8 operand; /* Link packet Operand */ /* allocate space for source/destination addresses if not allocated already. we will fill them in later */ if (!src_addr) src_addr = se_alloc(ADDR_MAX_LEN); if (!dst_addr) dst_addr = se_alloc(ADDR_MAX_LEN); operand = tvb_get_guint8(tvb, offset); operand = (operand & 0xF0) >> 4; /* Mark the Packet type as Infiniband in the wireshark UI */ /* Clear other columns */ col_set_str(pinfo->cinfo, COL_PROTOCOL, "InfiniBand Link"); col_clear(pinfo->cinfo, COL_INFO); col_add_fstr(pinfo->cinfo, COL_INFO, "%s", val_to_str(operand, Operand_Description, "Unknown (0x%1x)")); /* Get the parent tree from the ERF dissector. We don't want to nest under ERF */ if (tree && tree->parent) { /* Set the normal tree outside of ERF */ tree = tree->parent; /* Set a global reference for nested protocols */ top_tree = tree; } if (!tree) { /* If no packet details are being dissected, extract some high level info for the packet view */ /* Assigns column values rather than full tree population */ dissect_general_info(tvb, offset, pinfo, FALSE); return; } /* Top Level Packet */ infiniband_link_packet = proto_tree_add_item(tree, proto_infiniband_link, tvb, offset, -1, ENC_NA); /* Headers Level Tree */ link_tree = proto_item_add_subtree(infiniband_link_packet, ett_link); operand_item = proto_tree_add_item(link_tree, hf_infiniband_link_op, tvb, offset, 2, ENC_BIG_ENDIAN); if (operand > 1) { proto_item_set_text(operand_item, "%s", "Reserved"); call_dissector(data_handle, tvb, pinfo, link_tree); } else { proto_tree_add_item(link_tree, hf_infiniband_link_fctbs, tvb, offset, 2, ENC_BIG_ENDIAN); offset += 2; proto_tree_add_item(link_tree, hf_infiniband_link_vl, tvb, offset, 2, ENC_BIG_ENDIAN); proto_tree_add_item(link_tree, hf_infiniband_link_fccl, tvb, offset, 2, ENC_BIG_ENDIAN); offset += 2; proto_tree_add_item(link_tree, hf_infiniband_link_lpcrc, tvb, offset, 2, ENC_BIG_ENDIAN); } } /* Description: Finds the header sequence that follows the Base Transport Header. * Somwhat inefficient (should be using a single key,value pair data structure) * But uses pure probablity to take a stab at better efficiency. * Searches largest header sequence groups first, and then finally resorts to single matches for unique header sequences * IN: OpCode: The OpCode from the Base Transport Header. * OUT: The Header Sequence enumeration. See Declarations for #defines from (0-22) */ static gint32 find_next_header_sequence(guint32 OpCode) { if (contains(OpCode, &opCode_PAYLD[0], (gint32)array_length(opCode_PAYLD))) return PAYLD; if (contains(OpCode, &opCode_IMMDT_PAYLD[0], (gint32)array_length(opCode_IMMDT_PAYLD))) return IMMDT_PAYLD; if (contains(OpCode, &opCode_RDETH_DETH_PAYLD[0], (gint32)array_length(opCode_RDETH_DETH_PAYLD))) return RDETH_DETH_PAYLD; if (contains(OpCode, &opCode_RETH_PAYLD[0], (gint32)array_length(opCode_RETH_PAYLD))) return RETH_PAYLD; if (contains(OpCode, &opCode_RDETH_AETH_PAYLD[0], (gint32)array_length(opCode_RDETH_AETH_PAYLD))) return RDETH_AETH_PAYLD; if (contains(OpCode, &opCode_AETH_PAYLD[0], (gint32)array_length(opCode_AETH_PAYLD))) return AETH_PAYLD; if (contains(OpCode, &opCode_RDETH_DETH_IMMDT_PAYLD[0], (gint32)array_length(opCode_RDETH_DETH_IMMDT_PAYLD))) return RDETH_DETH_IMMDT_PAYLD; if (contains(OpCode, &opCode_RETH_IMMDT_PAYLD[0], (gint32)array_length(opCode_RETH_IMMDT_PAYLD))) return RETH_IMMDT_PAYLD; if (contains(OpCode, &opCode_RDETH_DETH_RETH_PAYLD[0], (gint32)array_length(opCode_RDETH_DETH_RETH_PAYLD))) return RDETH_DETH_RETH_PAYLD; if (contains(OpCode, &opCode_ATOMICETH[0], (gint32)array_length(opCode_ATOMICETH))) return ATOMICETH; if (contains(OpCode, &opCode_IETH_PAYLD[0], (gint32)array_length(opCode_IETH_PAYLD))) return IETH_PAYLD; if (contains(OpCode, &opCode_RDETH_DETH_ATOMICETH[0], (gint32)array_length(opCode_RDETH_DETH_ATOMICETH))) return RDETH_DETH_ATOMICETH; if ((OpCode ^ RC_ACKNOWLEDGE) == 0) return AETH; if ((OpCode ^ RC_RDMA_READ_REQUEST) == 0) return RETH; if ((OpCode ^ RC_ATOMIC_ACKNOWLEDGE) == 0) return AETH_ATOMICACKETH; if ((OpCode ^ RD_RDMA_READ_RESPONSE_MIDDLE) == 0) return RDETH_PAYLD; if ((OpCode ^ RD_ACKNOWLEDGE) == 0) return RDETH_AETH; if ((OpCode ^ RD_ATOMIC_ACKNOWLEDGE) == 0) return RDETH_AETH_ATOMICACKETH; if ((OpCode ^ RD_RDMA_WRITE_ONLY_IMM) == 0) return RDETH_DETH_RETH_IMMDT_PAYLD; if ((OpCode ^ RD_RDMA_READ_REQUEST) == 0) return RDETH_DETH_RETH; if ((OpCode ^ RD_RESYNC) == 0) return RDETH_DETH; if ((OpCode ^ UD_SEND_ONLY) == 0) return DETH_PAYLD; if ((OpCode ^ UD_SEND_ONLY_IMM) == 0) return DETH_IMMDT_PAYLD; return -1; } /* Description: Finds if a given value is present in an array. This is probably in a standard library somewhere, * But I'd rather define my own. * IN: OpCode: The OpCode you are looking for * IN: Codes: The organized array of OpCodes to look through * IN: Array length, because we're in C++... * OUT: Boolean indicating if that OpCode was found in OpCodes */ static gboolean contains(guint32 OpCode, guint32* Codes, gint32 length) { gint32 i; for (i = 0; i < length; i++) { if ((OpCode ^ Codes[i]) == 0) return TRUE; } return FALSE; } /* Parse RDETH - Reliable Datagram Extended Transport Header * IN: parentTree to add the dissection to - in this code the all_headers_tree * IN: tvb - the data buffer from wireshark * IN/OUT: The current and updated offset */ static void parse_RDETH(proto_tree * parentTree, tvbuff_t *tvb, gint *offset) { gint local_offset = *offset; /* RDETH - Reliable Datagram Extended Transport Header */ proto_item *RDETH_header_item; proto_tree *RDETH_header_tree; RDETH_header_item = proto_tree_add_item(parentTree, hf_infiniband_RDETH, tvb, local_offset, 4, ENC_NA); proto_item_set_text(RDETH_header_item, "%s", "RDETH - Reliable Datagram Extended Transport Header"); RDETH_header_tree = proto_item_add_subtree(RDETH_header_item, ett_rdeth); proto_tree_add_item(RDETH_header_tree, hf_infiniband_reserved8_RDETH, tvb, local_offset, 1, ENC_BIG_ENDIAN); local_offset += 1; proto_tree_add_item(RDETH_header_tree, hf_infiniband_ee_context, tvb, local_offset, 3, ENC_BIG_ENDIAN); local_offset += 3; *offset = local_offset; } /* Parse DETH - Datagram Extended Transport Header * IN: parentTree to add the dissection to - in this code the all_headers_tree * IN: tvb - the data buffer from wireshark * IN/OUT: The current and updated offset */ static void parse_DETH(proto_tree *parentTree, packet_info *pinfo, tvbuff_t *tvb, gint *offset) { gint local_offset = *offset; /* DETH - Datagram Extended Transport Header */ proto_item *DETH_header_item; proto_tree *DETH_header_tree; DETH_header_item = proto_tree_add_item(parentTree, hf_infiniband_DETH, tvb, local_offset, 8, ENC_NA); proto_item_set_text(DETH_header_item, "%s", "DETH - Datagram Extended Transport Header"); DETH_header_tree = proto_item_add_subtree(DETH_header_item, ett_deth); proto_tree_add_item(DETH_header_tree, hf_infiniband_queue_key, tvb, local_offset, 4, ENC_BIG_ENDIAN); local_offset += 4; proto_tree_add_item(DETH_header_tree, hf_infiniband_reserved8_DETH, tvb, local_offset, 1, ENC_BIG_ENDIAN); local_offset += 1; proto_tree_add_item(DETH_header_tree, hf_infiniband_source_qp, tvb, local_offset, 3, ENC_BIG_ENDIAN); pinfo->srcport = tvb_get_ntoh24(tvb, local_offset); local_offset += 3; *offset = local_offset; } /* Parse RETH - RDMA Extended Transport Header * IN: parentTree to add the dissection to - in this code the all_headers_tree * IN: tvb - the data buffer from wireshark * IN/OUT: The current and updated offset */ static void parse_RETH(proto_tree * parentTree, tvbuff_t *tvb, gint *offset) { gint local_offset = *offset; /* RETH - RDMA Extended Transport Header */ proto_item *RETH_header_item; proto_tree *RETH_header_tree; RETH_header_item = proto_tree_add_item(parentTree, hf_infiniband_RETH, tvb, local_offset, 16, ENC_NA); proto_item_set_text(RETH_header_item, "%s", "RETH - RDMA Extended Transport Header"); RETH_header_tree = proto_item_add_subtree(RETH_header_item, ett_reth); proto_tree_add_item(RETH_header_tree, hf_infiniband_virtual_address, tvb, local_offset, 8, ENC_BIG_ENDIAN); local_offset += 8; proto_tree_add_item(RETH_header_tree, hf_infiniband_remote_key, tvb, local_offset, 4, ENC_BIG_ENDIAN); local_offset += 4; proto_tree_add_item(RETH_header_tree, hf_infiniband_dma_length, tvb, local_offset, 4, ENC_BIG_ENDIAN); local_offset += 4; *offset = local_offset; } /* Parse AtomicETH - Atomic Extended Transport Header * IN: parentTree to add the dissection to - in this code the all_headers_tree * IN: tvb - the data buffer from wireshark * IN/OUT: The current and updated offset */ static void parse_ATOMICETH(proto_tree * parentTree, tvbuff_t *tvb, gint *offset) { gint local_offset = *offset; /* AtomicETH - Atomic Extended Transport Header */ proto_item *ATOMICETH_header_item; proto_tree *ATOMICETH_header_tree; ATOMICETH_header_item = proto_tree_add_item(parentTree, hf_infiniband_AtomicETH, tvb, local_offset, 28, ENC_NA); proto_item_set_text(ATOMICETH_header_item, "%s", "AtomicETH - Atomic Extended Transport Header"); ATOMICETH_header_tree = proto_item_add_subtree(ATOMICETH_header_item, ett_atomiceth); proto_tree_add_item(ATOMICETH_header_tree, hf_infiniband_virtual_address, tvb, local_offset, 8, ENC_BIG_ENDIAN); local_offset += 8; proto_tree_add_item(ATOMICETH_header_tree, hf_infiniband_remote_key, tvb, local_offset, 4, ENC_BIG_ENDIAN); local_offset += 4; proto_tree_add_item(ATOMICETH_header_tree, hf_infiniband_swap_or_add_data, tvb, local_offset, 8, ENC_BIG_ENDIAN); local_offset += 8; proto_tree_add_item(ATOMICETH_header_tree, hf_infiniband_compare_data, tvb, local_offset, 8, ENC_BIG_ENDIAN); local_offset += 8; *offset = local_offset; } /* Parse AETH - ACK Extended Transport Header * IN: parentTree to add the dissection to - in this code the all_headers_tree * IN: tvb - the data buffer from wireshark * IN/OUT: The current and updated offset */ static void parse_AETH(proto_tree * parentTree, tvbuff_t *tvb, gint *offset) { gint local_offset = *offset; /* AETH - ACK Extended Transport Header */ proto_item *AETH_header_item; proto_tree *AETH_header_tree; AETH_header_item = proto_tree_add_item(parentTree, hf_infiniband_AETH, tvb, local_offset, 4, ENC_NA); proto_item_set_text(AETH_header_item, "%s", "AETH - ACK Extended Transport Header"); AETH_header_tree = proto_item_add_subtree(AETH_header_item, ett_aeth); proto_tree_add_item(AETH_header_tree, hf_infiniband_syndrome, tvb, local_offset, 1, ENC_BIG_ENDIAN); local_offset += 1; proto_tree_add_item(AETH_header_tree, hf_infiniband_message_sequence_number, tvb, local_offset, 3, ENC_BIG_ENDIAN); local_offset += 3; *offset = local_offset; } /* Parse AtomicAckEth - Atomic ACK Extended Transport Header * IN: parentTree to add the dissection to - in this code the all_headers_tree * IN: tvb - the data buffer from wireshark * IN/OUT: The current and updated offset */ static void parse_ATOMICACKETH(proto_tree * parentTree, tvbuff_t *tvb, gint *offset) { gint local_offset = *offset; /* AtomicAckEth - Atomic ACK Extended Transport Header */ proto_item *ATOMICACKETH_header_item; proto_tree *ATOMICACKETH_header_tree; ATOMICACKETH_header_item = proto_tree_add_item(parentTree, hf_infiniband_AtomicAckETH, tvb, local_offset, 8, ENC_NA); proto_item_set_text(ATOMICACKETH_header_item, "%s", "ATOMICACKETH - Atomic ACK Extended Transport Header"); ATOMICACKETH_header_tree = proto_item_add_subtree(ATOMICACKETH_header_item, ett_atomicacketh); proto_tree_add_item(ATOMICACKETH_header_tree, hf_infiniband_original_remote_data, tvb, local_offset, 8, ENC_BIG_ENDIAN); local_offset += 8; *offset = local_offset; } /* Parse IMMDT - Immediate Data Extended Transport Header * IN: parentTree to add the dissection to - in this code the all_headers_tree * IN: tvb - the data buffer from wireshark * IN/OUT: The current and updated offset */ static void parse_IMMDT(proto_tree * parentTree, tvbuff_t *tvb, gint *offset) { gint local_offset = *offset; /* IMMDT - Immediate Data Extended Transport Header */ proto_item *IMMDT_header_item; proto_tree *IMMDT_header_tree; IMMDT_header_item = proto_tree_add_item(parentTree, hf_infiniband_IMMDT, tvb, local_offset, 4, ENC_NA); proto_item_set_text(IMMDT_header_item, "%s", "IMMDT - Immediate Data Extended Transport Header"); IMMDT_header_tree = proto_item_add_subtree(IMMDT_header_item, ett_immdt); proto_tree_add_item(IMMDT_header_tree, hf_infiniband_IMMDT, tvb, local_offset, 4, ENC_NA); local_offset += 4; *offset = local_offset; } /* Parse IETH - Invalidate Extended Transport Header * IN: parentTree to add the dissection to - in this code the all_headers_tree * IN: tvb - the data buffer from wireshark * IN/OUT: The current and updated offset */ static void parse_IETH(proto_tree * parentTree, tvbuff_t *tvb, gint *offset) { gint local_offset = *offset; /* IETH - Invalidate Extended Transport Header */ proto_item *IETH_header_item; proto_tree *IETH_header_tree; IETH_header_item = proto_tree_add_item(parentTree, hf_infiniband_IETH, tvb, local_offset, 4, ENC_NA); proto_item_set_text(IETH_header_item, "%s", "IETH - Invalidate Extended Transport Header"); IETH_header_tree = proto_item_add_subtree(IETH_header_item, ett_ieth); proto_tree_add_item(IETH_header_tree, hf_infiniband_IETH, tvb, local_offset, 4, ENC_NA); local_offset += 4; *offset = local_offset; } /* Parse Payload - Packet Payload / Invariant CRC / Variant CRC * IN: parentTree to add the dissection to - in this code the all_headers_tree * IN: pinfo - packet info from wireshark * IN: tvb - the data buffer from wireshark * IN/OUT: offset - The current and updated offset * IN: length - Length of Payload */ static void parse_PAYLOAD(proto_tree *parentTree, packet_info *pinfo, tvbuff_t *tvb, gint *offset, gint length) { gint local_offset = *offset; /* Payload - Packet Payload */ guint8 management_class; tvbuff_t *volatile next_tvb; gint captured_length, reported_length; guint16 etype, reserved; const char *saved_proto; volatile gboolean dissector_found = FALSE; if (!tvb_bytes_exist(tvb, *offset, length)) /* previously consumed bytes + offset was all the data - none or corrupt payload */ { col_set_str(pinfo->cinfo, COL_INFO, "Invalid Packet Length from LRH! [Malformed Packet]"); col_set_fence(pinfo->cinfo, COL_INFO); return; } /* management datagrams are determined by the source/destination QPs */ if (pinfo->srcport == 0 || pinfo->srcport == 1 || pinfo->destport == 0 || pinfo->destport == 1) /* management datagram */ { management_class = tvb_get_guint8(tvb, (*offset) + 1); if (((management_class >= (guint8)VENDOR_1_START) && (management_class <= (guint8)VENDOR_1_END)) || ((management_class >= (guint8)VENDOR_2_START) && (management_class <= (guint8)VENDOR_2_END))) { /* parse vendor specific */ parse_VENDOR_MANAGEMENT(parentTree, tvb, offset); } else if ((management_class >= (guint8)APPLICATION_START) && (management_class <= (guint8)APPLICATION_END)) { /* parse application specific */ parse_APPLICATION_MANAGEMENT(parentTree, tvb, offset); } else if (((management_class == (guint8)0x00) || (management_class == (guint8)0x02)) || ((management_class >= (guint8)0x50) && (management_class <= (guint8)0x80)) || ((management_class >= (guint8)0x82))) { /* parse reserved classes */ parse_RESERVED_MANAGEMENT(parentTree, tvb, offset); } else /* we have a normal management_class */ { switch (management_class) { case SUBN_LID_ROUTED: /* parse subn man lid routed */ parse_SUBN_LID_ROUTED(parentTree, pinfo, tvb, &local_offset); break; case SUBN_DIRECTED_ROUTE: /* parse subn directed route */ parse_SUBN_DIRECTED_ROUTE(parentTree, pinfo, tvb, &local_offset); break; case SUBNADMN: /* parse sub admin */ parse_SUBNADMN(parentTree, pinfo, tvb, &local_offset); break; case PERF: /* parse performance */ parse_PERF(parentTree, tvb, pinfo, &local_offset); break; case BM: /* parse baseboard mgmt */ parse_BM(parentTree, tvb, &local_offset); break; case DEV_MGT: /* parse device management */ parse_DEV_MGT(parentTree, tvb, &local_offset); break; case COM_MGT: /* parse communication management */ parse_COM_MGT(parentTree, pinfo, tvb, &local_offset); break; case SNMP: /* parse snmp tunneling */ parse_SNMP(parentTree, tvb, &local_offset); break; default: break; } } } else /* Normal Data Packet - Parse as such */ { /* Calculation for Payload: * (tvb_length) Length of entire packet - (local_offset) Starting byte of Payload Data * offset addition is more complex for the payload. * We need the total length of the packet, - length of previous headers, + offset where payload started. * We also need to reserve 6 bytes for the CRCs which are not actually part of the payload. */ etype = tvb_get_ntohs(tvb, local_offset); reserved = tvb_get_ntohs(tvb, local_offset + 2); /* try to recognize whether or not this is a Mellanox EoIB packet by the transport type and the 4 first bits of the payload */ if (pref_dissect_eoib && (transport_type == TRANSPORT_UD) && (tvb_get_bits8(tvb, local_offset*8, 4) == 0xC)) { dissector_found = parse_EoIB(parentTree, tvb, local_offset, pinfo); } /* IBA packet data could be anything in principle, however it is common * practice to carry non-IBA data encapsulated with an EtherType header, * similar to the RWH header. There is no way to identify these frames * positively. * * If the appropriate option is set in protocol preferences, * We see if the first few bytes look like an EtherType header, and if so * call the appropriate dissector. If not we call the "data" dissector. */ if (!dissector_found && pref_identify_iba_payload && (reserved == 0)) { void *pd_save; /* Get the captured length and reported length of the data after the Ethernet type. */ captured_length = tvb_length_remaining(tvb, local_offset+4); reported_length = tvb_reported_length_remaining(tvb, local_offset+4); next_tvb = tvb_new_subset(tvb, local_offset+4, captured_length, reported_length); pinfo->ethertype = etype; /* Look for sub-dissector, and call it if found. Catch exceptions, so that if the reported length of "next_tvb" was reduced by some dissector before an exception was thrown, we can still put in an item for the trailer. */ saved_proto = pinfo->current_proto; pd_save = pinfo->private_data; TRY { dissector_found = dissector_try_uint(ethertype_dissector_table, etype, next_tvb, pinfo, top_tree); } CATCH_NONFATAL_ERRORS { /* Somebody threw an exception that means that there was a problem dissecting the payload; that means that a dissector was found, so we don't need to dissect the payload as data or update the protocol or info columns. Just show the exception and then drive on to show the trailer, after noting that a dissector was found and restoring the protocol value that was in effect before we called the subdissector. Restore the private_data structure in case one of the called dissectors modified it (and, due to the exception, was unable to restore it). */ pinfo->private_data = pd_save; show_exception(next_tvb, pinfo, top_tree, EXCEPT_CODE, GET_MESSAGE); dissector_found = TRUE; pinfo->current_proto = saved_proto; } ENDTRY; if (dissector_found) { proto_item *PAYLOAD_header_item; proto_tree *PAYLOAD_header_tree; /* now create payload entry to show Ethertype */ PAYLOAD_header_item = proto_tree_add_item(parentTree, hf_infiniband_payload, tvb, local_offset, tvb_reported_length_remaining(tvb, local_offset)-6, ENC_NA); proto_item_set_text(PAYLOAD_header_item, "%s", "IBA Payload - appears to be EtherType encapsulated"); PAYLOAD_header_tree = proto_item_add_subtree(PAYLOAD_header_item, ett_payload); proto_tree_add_uint(PAYLOAD_header_tree, hf_infiniband_etype, tvb, local_offset, 2, tvb_get_ntohs(tvb, local_offset)); local_offset += 2; proto_tree_add_uint(PAYLOAD_header_tree, hf_infiniband_reserved16_RWH, tvb, local_offset, 2, tvb_get_ntohs(tvb, local_offset)); } } captured_length = tvb_length_remaining(tvb, local_offset); reported_length = tvb_reported_length_remaining(tvb, local_offset); if (reported_length >= 6) reported_length -= 6; if (captured_length > reported_length) captured_length = reported_length; next_tvb = tvb_new_subset(tvb, local_offset, captured_length, reported_length); /* Try any heuristic dissectors that requested a chance to try and dissect IB payloads */ if (!dissector_found) { dissector_found = dissector_try_heuristic(heur_dissectors_payload, next_tvb, pinfo, parentTree, NULL); } if (!dissector_found) { /* No sub-dissector found. Label rest of packet as "Data" */ call_dissector(data_handle, next_tvb, pinfo, top_tree); } /*parse_RWH(parentTree, tvb, &local_offset, pinfo);*/ /* Will contain ICRC and VCRC = 4+2 */ local_offset = tvb_reported_length(tvb) - 6; } *offset = local_offset; } /* Parse VENDOR - Parse a vendor specific or unknown header sequence * IN: parentTree to add the dissection to - in this code the all_headers_tree * IN: tvb - the data buffer from wireshark * IN/OUT: The current and updated offset */ static void parse_VENDOR(proto_tree * parentTree, tvbuff_t *tvb, gint *offset) { gint local_offset = *offset; proto_item *VENDOR_header_item; proto_tree *VENDOR_header_tree; VENDOR_header_item = proto_tree_add_item(parentTree, hf_infiniband_vendor, tvb, local_offset, 4, ENC_NA); proto_item_set_text(VENDOR_header_item, "%s", "Vendor Specific or Unknown Header Sequence"); VENDOR_header_tree = proto_item_add_subtree(VENDOR_header_item, ett_vendor); proto_tree_add_item(VENDOR_header_tree, hf_infiniband_vendor, tvb, local_offset, -1, ENC_NA); *offset = local_offset; } /* Parse IPv6 - Parse an IPv6 Packet * IN: parentTree to add the dissection to - in this code the all_headers_tree * IN: tvb - the data buffer from wireshark * IN/OUT: The current and updated offset * IN: pinfo - packet info from wireshark */ static void parse_IPvSix(proto_tree *parentTree, tvbuff_t *tvb, gint *offset, packet_info *pinfo) { tvbuff_t *ipv6_tvb; /* (- 2) for VCRC which lives at the end of the packet */ ipv6_tvb = tvb_new_subset(tvb, *offset, tvb_length_remaining(tvb, *offset) - 2, tvb_reported_length_remaining(tvb, *offset) - 2); call_dissector(ipv6_handle, ipv6_tvb, pinfo, parentTree); *offset = tvb_reported_length(tvb) - 2; /* Display the VCRC */ proto_tree_add_item(parentTree, hf_infiniband_variant_crc, tvb, *offset, 2, ENC_BIG_ENDIAN); } /* Parse EtherType - Parse a generic IP packaet with an EtherType of IP or ARP * IN: parentTree to add the dissection to - in this code the all_headers_tree * IN: tvb - the data buffer from wireshark * IN/OUT: The current and updated offset * IN: pinfo - packet info from wireshark */ static void parse_RWH(proto_tree *ah_tree, tvbuff_t *tvb, gint *offset, packet_info *pinfo) { guint16 ether_type; tvbuff_t *next_tvb; /* RWH - Raw Header */ proto_item *RWH_header_item; proto_tree *RWH_header_tree; gint captured_length, reported_length; RWH_header_item = proto_tree_add_item(ah_tree, hf_infiniband_RWH, tvb, *offset, 4, ENC_NA); proto_item_set_text(RWH_header_item, "%s", "RWH - Raw Header"); RWH_header_tree = proto_item_add_subtree(RWH_header_item, ett_rwh); proto_tree_add_item(RWH_header_tree, hf_infiniband_reserved16_RWH, tvb, *offset, 2, ENC_BIG_ENDIAN); *offset += 2; ether_type = tvb_get_ntohs(tvb, *offset); proto_tree_add_uint(RWH_header_tree, hf_infiniband_etype, tvb, *offset, 2, ether_type); *offset += 2; /* Get the captured length and reported length of the data * after the Ethernet type. */ captured_length = tvb_length_remaining(tvb, *offset); reported_length = tvb_reported_length_remaining(tvb, *offset); /* Construct a tvbuff for the payload after the Ethernet type, * not including the FCS. */ if ((captured_length >= 0) && (reported_length >= 0)) { if (reported_length >= 2) reported_length -= 2; if (captured_length > reported_length) captured_length = reported_length; } next_tvb = tvb_new_subset(tvb, *offset, captured_length, reported_length); if (!dissector_try_uint(ethertype_dissector_table, ether_type, next_tvb, pinfo, top_tree)) call_dissector(data_handle, next_tvb, pinfo, top_tree); *offset = tvb_reported_length(tvb) - 2; /* Display the VCRC */ proto_tree_add_item(ah_tree, hf_infiniband_variant_crc, tvb, *offset, 2, ENC_BIG_ENDIAN); } /* Parse a Mellanox EoIB Encapsulation Header and the associated Ethernet frame * IN: parentTree to add the dissection to - in this code the all_headers_tree * IN: tvb - the data buffer from wireshark * IN: The current offset * IN: pinfo - packet info from wireshark */ static gboolean parse_EoIB(proto_tree *tree, tvbuff_t *tvb, gint offset, packet_info *pinfo) { proto_item *header_item; proto_tree *header_subtree; gboolean ms; gint8 seg_offset; tvbuff_t *encap_tvb; /* the encapsulated eoib size (including the header!) is remaining length-6 bytes of CRC */ int encap_size = tvb_reported_length_remaining(tvb, offset) - 6; if (encap_size < 4) { /* not even large enough to contain the eoib encap header. error! */ return FALSE; } encap_tvb = tvb_new_subset(tvb, offset + 4, tvb_length_remaining(tvb, offset + 4), encap_size - 4); header_item = proto_tree_add_item(tree, hf_infiniband_EOIB, tvb, offset, 4, ENC_NA); header_subtree = proto_item_add_subtree(header_item, ett_eoib); proto_tree_add_item(header_subtree, hf_infiniband_ver, tvb, offset, 2, ENC_BIG_ENDIAN); proto_tree_add_item(header_subtree, hf_infiniband_tcp_chk, tvb, offset, 2, ENC_BIG_ENDIAN); proto_tree_add_item(header_subtree, hf_infiniband_ip_chk, tvb, offset, 2, ENC_BIG_ENDIAN); proto_tree_add_item(header_subtree, hf_infiniband_fcs, tvb, offset, 2, ENC_BIG_ENDIAN); ms = tvb_get_bits8(tvb, (offset + 1)*8 + 2, 1); seg_offset = tvb_get_bits8(tvb, (offset + 1)*8 + 3, 5); proto_tree_add_item(header_subtree, hf_infiniband_ms, tvb, offset, 2, ENC_BIG_ENDIAN); proto_tree_add_item(header_subtree, hf_infiniband_seg_off, tvb, offset, 2, ENC_BIG_ENDIAN); offset += 2; proto_tree_add_item(header_subtree, hf_infiniband_seg_id, tvb, offset, 2, ENC_BIG_ENDIAN); if (seg_offset || ms) { /* this is a fragment of an encapsulated Ethernet jumbo frame, parse as data */ call_dissector(data_handle, encap_tvb, pinfo, top_tree); } else { /* non-fragmented frames can be fully parsed */ call_dissector(eth_handle, encap_tvb, pinfo, top_tree); } return TRUE; } /* Parse Subnet Management (LID Routed) * IN: parentTree to add the dissection to * IN: pinfo - packet info from wireshark * IN: tvb - the data buffer from wireshark * IN/OUT: The current and updated offset */ static void parse_SUBN_LID_ROUTED(proto_tree *parentTree, packet_info *pinfo, tvbuff_t *tvb, gint *offset) { /* Parse the Common MAD Header */ MAD_Data MadData; gint local_offset; proto_item *SUBN_LID_ROUTED_header_item; proto_tree *SUBN_LID_ROUTED_header_tree; if (!parse_MAD_Common(parentTree, tvb, offset, &MadData)) { /* TODO: Mark Corrupt Packet - Not enough bytes exist for at least the Common MAD header which is present in all MAD packets */ return; } local_offset = *offset; /* local_offset - 24 here because when we come out of parse_MAD_Common, the offset it sitting at the data section. */ SUBN_LID_ROUTED_header_item = proto_tree_add_item(parentTree, hf_infiniband_SMP_LID, tvb, local_offset - 24, 256, ENC_NA); proto_item_set_text(SUBN_LID_ROUTED_header_item, "%s", "SMP (LID Routed) "); SUBN_LID_ROUTED_header_tree = proto_item_add_subtree(SUBN_LID_ROUTED_header_item, ett_subn_lid_routed); proto_tree_add_item(SUBN_LID_ROUTED_header_tree, hf_infiniband_m_key, tvb, local_offset, 8, ENC_BIG_ENDIAN); local_offset += 8; proto_tree_add_item(SUBN_LID_ROUTED_header_tree, hf_infiniband_reserved256, tvb, local_offset, 32, ENC_NA); local_offset += 32; label_SUBM_Method(SUBN_LID_ROUTED_header_item, &MadData, pinfo); label_SUBM_Attribute(SUBN_LID_ROUTED_header_item, &MadData, pinfo); /* Try to do the detail parse of the attribute. If there is an error, or the attribute is unknown, we'll just highlight the generic data. */ if (!parse_SUBM_Attribute(SUBN_LID_ROUTED_header_tree, tvb, &local_offset, &MadData)) { proto_tree_add_item(SUBN_LID_ROUTED_header_tree, hf_infiniband_smp_data, tvb, local_offset, 64, ENC_NA); local_offset += 64; } proto_tree_add_item(SUBN_LID_ROUTED_header_tree, hf_infiniband_reserved1024, tvb, local_offset, 128, ENC_NA); local_offset += 128; *offset = local_offset; } /* Parse Subnet Management (Directed Route) * IN: parentTree to add the dissection to * IN: tvb - the data buffer from wireshark * IN/OUT: The current and updated offset */ static void parse_SUBN_DIRECTED_ROUTE(proto_tree *parentTree, packet_info *pinfo, tvbuff_t *tvb, gint *offset) { /* Parse the Common MAD Header */ MAD_Data MadData; gint local_offset; proto_item *SUBN_DIRECTED_ROUTE_header_item; proto_tree *SUBN_DIRECTED_ROUTE_header_tree; if (!parse_MAD_Common(parentTree, tvb, offset, &MadData)) { /* TODO: Mark Corrupt Packet - Not enough bytes exist for at least the Common MAD header which is present in all MAD packets */ return; } local_offset = *offset; /* local_offset - 24 here because when we come out of parse_MAD_Common, the offset it sitting at the data section. * We need to go backwards because this particular SMP uses the class specific portion of the Common MAD Header */ SUBN_DIRECTED_ROUTE_header_item = proto_tree_add_item(parentTree, hf_infiniband_SMP_DIRECTED, tvb, local_offset - 24, 256, ENC_NA); proto_item_set_text(SUBN_DIRECTED_ROUTE_header_item, "%s", "SMP (Directed Route) "); SUBN_DIRECTED_ROUTE_header_tree = proto_item_add_subtree(SUBN_DIRECTED_ROUTE_header_item, ett_subn_directed_route); label_SUBM_Method(SUBN_DIRECTED_ROUTE_header_item, &MadData, pinfo); label_SUBM_Attribute(SUBN_DIRECTED_ROUTE_header_item, &MadData, pinfo); /* Place us at offset 4, the "D" Bit (Direction bit for Directed Route SMPs) */ local_offset -= 20; proto_tree_add_item(SUBN_DIRECTED_ROUTE_header_tree, hf_infiniband_d, tvb, local_offset, 1, ENC_BIG_ENDIAN); proto_tree_add_item(SUBN_DIRECTED_ROUTE_header_tree, hf_infiniband_smp_status, tvb, local_offset, 2, ENC_BIG_ENDIAN); local_offset += 2; proto_tree_add_item(SUBN_DIRECTED_ROUTE_header_tree, hf_infiniband_hop_pointer, tvb, local_offset, 1, ENC_BIG_ENDIAN); local_offset += 1; proto_tree_add_item(SUBN_DIRECTED_ROUTE_header_tree, hf_infiniband_hop_count, tvb, local_offset, 1, ENC_BIG_ENDIAN); local_offset += 1; local_offset += 16; /* Skip over the rest of the Common MAD Header... It's already dissected by parse_MAD_Common */ proto_tree_add_item(SUBN_DIRECTED_ROUTE_header_tree, hf_infiniband_m_key, tvb, local_offset, 8, ENC_BIG_ENDIAN); local_offset += 8; proto_tree_add_item(SUBN_DIRECTED_ROUTE_header_tree, hf_infiniband_dr_slid, tvb, local_offset, 2, ENC_BIG_ENDIAN); local_offset += 2; proto_tree_add_item(SUBN_DIRECTED_ROUTE_header_tree, hf_infiniband_dr_dlid, tvb, local_offset, 2, ENC_BIG_ENDIAN); local_offset += 2; proto_tree_add_item(SUBN_DIRECTED_ROUTE_header_tree, hf_infiniband_reserved28, tvb, local_offset, 28, ENC_NA); local_offset += 28; /* Try to do the detail parse of the attribute. If there is an error, or the attribute is unknown, we'll just highlight the generic data. */ if (!parse_SUBM_Attribute(SUBN_DIRECTED_ROUTE_header_tree, tvb, &local_offset, &MadData)) { proto_tree_add_item(SUBN_DIRECTED_ROUTE_header_tree, hf_infiniband_smp_data, tvb, local_offset, 64, ENC_NA); local_offset += 64; } proto_tree_add_item(SUBN_DIRECTED_ROUTE_header_tree, hf_infiniband_initial_path, tvb, local_offset, 64, ENC_NA); local_offset += 64; proto_tree_add_item(SUBN_DIRECTED_ROUTE_header_tree, hf_infiniband_return_path, tvb, local_offset, 64, ENC_NA); local_offset += 64; *offset = local_offset; } /* Parse Subnet Administration * IN: parentTree to add the dissection to * IN: pinfo - packet info from wireshark * IN: tvb - the data buffer from wireshark * IN/OUT: The current and updated offset */ static void parse_SUBNADMN(proto_tree *parentTree, packet_info *pinfo, tvbuff_t *tvb, gint *offset) { /* Parse the Common MAD Header */ MAD_Data MadData; gint local_offset; proto_item *SUBNADMN_header_item; proto_tree *SUBNADMN_header_tree; if (!parse_MAD_Common(parentTree, tvb, offset, &MadData)) { /* TODO: Mark Corrupt Packet - Not enough bytes exist for at least the Common MAD header which is present in all MAD packets */ return; } if (!parse_RMPP(parentTree, tvb, offset)) { /* TODO: Mark Corrupt Packet */ return; } local_offset = *offset; SUBNADMN_header_item = proto_tree_add_item(parentTree, hf_infiniband_SA, tvb, local_offset - 36, 256, ENC_NA); proto_item_set_text(SUBNADMN_header_item, "%s", "SMA"); SUBNADMN_header_tree = proto_item_add_subtree(SUBNADMN_header_item, ett_subnadmin); proto_tree_add_item(SUBNADMN_header_tree, hf_infiniband_sm_key, tvb, local_offset, 8, ENC_BIG_ENDIAN); local_offset += 8; proto_tree_add_item(SUBNADMN_header_tree, hf_infiniband_attribute_offset, tvb, local_offset, 2, ENC_BIG_ENDIAN); local_offset += 4; proto_tree_add_item(SUBNADMN_header_tree, hf_infiniband_reserved16, tvb, local_offset, 2, ENC_BIG_ENDIAN); local_offset += 4; proto_tree_add_item(SUBNADMN_header_tree, hf_infiniband_component_mask, tvb, local_offset, 8, ENC_BIG_ENDIAN); local_offset += 8; label_SUBA_Method(SUBNADMN_header_item, &MadData, pinfo); label_SUBA_Attribute(SUBNADMN_header_item, &MadData, pinfo); if (!parse_SUBA_Attribute(SUBNADMN_header_tree, tvb, &local_offset, &MadData)) { proto_tree_add_item(SUBNADMN_header_tree, hf_infiniband_subnet_admin_data, tvb, local_offset, 200, ENC_NA); local_offset += 200; } *offset = local_offset; } /* Parse Performance Management * IN: parentTree to add the dissection to * IN: tvb - the data buffer from wireshark * IN: pinfo - the pinfo struct from wireshark * IN/OUT: The current and updated offset */ static void parse_PERF(proto_tree *parentTree, tvbuff_t *tvb, packet_info *pinfo, gint *offset) { /* Parse the Common MAD Header */ MAD_Data MadData; gint local_offset; proto_item *PERF_header_item; if (!parse_MAD_Common(parentTree, tvb, offset, &MadData)) { /* TODO: Mark Corrupt Packet - Not enough bytes exist for at least the Common MAD header which is present in all MAD packets */ return; } local_offset = *offset; /* offset now points to the start of the MAD data field */ switch (MadData.attributeID) { case ATTR_PORT_COUNTERS: parse_PERF_PortCounters(parentTree, tvb, pinfo, &local_offset); break; case ATTR_PORT_COUNTERS_EXT: parse_PERF_PortCountersExtended(parentTree, tvb, pinfo, &local_offset); break; default: PERF_header_item = proto_tree_add_item(parentTree, hf_infiniband_smp_data, tvb, local_offset, MAD_DATA_SIZE, ENC_NA); local_offset += MAD_DATA_SIZE; proto_item_set_text(PERF_header_item, "%s", "PERF - Performance Management MAD (Dissector Not Implemented)"); break; } *offset = local_offset; } /* Parse Baseboard Management * IN: parentTree to add the dissection to * IN: tvb - the data buffer from wireshark * IN/OUT: The current and updated offset */ static void parse_BM(proto_tree *parentTree, tvbuff_t *tvb, gint *offset) { /* Parse the Common MAD Header */ MAD_Data MadData; gint local_offset; proto_item *PERF_header_item; if (!parse_MAD_Common(parentTree, tvb, offset, &MadData)) { /* TODO: Mark Corrupt Packet - Not enough bytes exist for at least the Common MAD header which is present in all MAD packets */ return; } local_offset = *offset; PERF_header_item = proto_tree_add_item(parentTree, hf_infiniband_smp_data, tvb, local_offset, MAD_DATA_SIZE, ENC_NA); local_offset += MAD_DATA_SIZE; proto_item_set_text(PERF_header_item, "%s", "BM - Baseboard Management MAD (Dissector Not Implemented)"); *offset = local_offset; } /* Parse Device Management * IN: parentTree to add the dissection to * IN: tvb - the data buffer from wireshark * IN/OUT: The current and updated offset */ static void parse_DEV_MGT(proto_tree *parentTree, tvbuff_t *tvb, gint *offset) { /* Parse the Common MAD Header */ MAD_Data MadData; gint local_offset; proto_item *PERF_header_item; if (!parse_MAD_Common(parentTree, tvb, offset, &MadData)) { /* TODO: Mark Corrupt Packet - Not enough bytes exist for at least the Common MAD header which is present in all MAD packets */ return; } local_offset = *offset; PERF_header_item = proto_tree_add_item(parentTree, hf_infiniband_smp_data, tvb, local_offset, MAD_DATA_SIZE, ENC_NA); local_offset += MAD_DATA_SIZE; proto_item_set_text(PERF_header_item, "%s", "DEV_MGT - Device Management MAD (Dissector Not Implemented)"); *offset = local_offset; } /* Parse Communications Management * IN: parentTree to add the dissection to * IN: tvb - the data buffer from wireshark * IN/OUT: The current and updated offset */ static void parse_COM_MGT(proto_tree *parentTree, packet_info *pinfo, tvbuff_t *tvb, gint *offset) { MAD_Data MadData; gint local_offset; guint8 *local_gid, *remote_gid; const char *label; proto_item *CM_header_item; proto_tree *CM_header_tree; tvbuff_t *next_tvb; local_gid = (guint8 *)ep_alloc(GID_SIZE); remote_gid = (guint8 *)ep_alloc(GID_SIZE); if (!parse_MAD_Common(parentTree, tvb, offset, &MadData)) { /* TODO: Mark Corrupt Packet - Not enough bytes exist for at least the Common MAD header which is present in all MAD packets */ return; } local_offset = *offset; CM_header_item = proto_tree_add_item(parentTree, hf_infiniband_smp_data, tvb, local_offset, 140, ENC_NA); label = val_to_str_const(MadData.attributeID, CM_Attributes, "(Unknown CM Attribute)"); proto_item_set_text(CM_header_item, "CM %s", label); col_clear(pinfo->cinfo, COL_INFO); col_append_fstr(pinfo->cinfo, COL_INFO, "CM: %s", label); CM_header_tree = proto_item_add_subtree(CM_header_item, ett_cm); switch (MadData.attributeID) { case ATTR_CM_REQ: { guint32 local_qpn; guint32 local_lid; guint32 remote_lid; guint64 serviceid; proto_tree_add_item(CM_header_tree, hf_cm_req_local_comm_id, tvb, local_offset, 4, ENC_BIG_ENDIAN); local_offset += 4; local_offset += 4; /* skip reserved */ proto_tree_add_item(CM_header_tree, hf_cm_req_service_id, tvb, local_offset, 8, ENC_BIG_ENDIAN); serviceid = tvb_get_ntoh64(tvb, local_offset); local_offset += 8; proto_tree_add_item(CM_header_tree, hf_cm_req_local_ca_guid, tvb, local_offset, 8, ENC_BIG_ENDIAN); local_offset += 8; local_offset += 4; /* skip reserved */ proto_tree_add_item(CM_header_tree, hf_cm_req_local_qkey, tvb, local_offset, 4, ENC_BIG_ENDIAN); local_offset += 4; proto_tree_add_item(CM_header_tree, hf_cm_req_local_qpn, tvb, local_offset, 3, ENC_BIG_ENDIAN); local_qpn = tvb_get_ntoh24(tvb, local_offset); local_offset += 3; proto_tree_add_item(CM_header_tree, hf_cm_req_respo_res, tvb, local_offset, 1, ENC_BIG_ENDIAN); local_offset += 1; proto_tree_add_item(CM_header_tree, hf_cm_req_local_eecn, tvb, local_offset, 3, ENC_BIG_ENDIAN); local_offset += 3; proto_tree_add_item(CM_header_tree, hf_cm_req_init_depth, tvb, local_offset, 1, ENC_BIG_ENDIAN); local_offset += 1; proto_tree_add_item(CM_header_tree, hf_cm_req_remote_eecn, tvb, local_offset, 3, ENC_BIG_ENDIAN); local_offset += 3; proto_tree_add_item(CM_header_tree, hf_cm_req_remote_cm_resp_to, tvb, local_offset, 1, ENC_BIG_ENDIAN); proto_tree_add_item(CM_header_tree, hf_cm_req_transp_serv_type, tvb, local_offset, 1, ENC_BIG_ENDIAN); proto_tree_add_item(CM_header_tree, hf_cm_req_e2e_flow_ctrl, tvb, local_offset, 1, ENC_BIG_ENDIAN); local_offset += 1; proto_tree_add_item(CM_header_tree, hf_cm_req_start_psn, tvb, local_offset, 3, ENC_BIG_ENDIAN); local_offset += 3; proto_tree_add_item(CM_header_tree, hf_cm_req_local_cm_resp_to, tvb, local_offset, 1, ENC_BIG_ENDIAN); proto_tree_add_item(CM_header_tree, hf_cm_req_retry_count, tvb, local_offset, 1, ENC_BIG_ENDIAN); local_offset += 1; proto_tree_add_item(CM_header_tree, hf_cm_req_pkey, tvb, local_offset, 2, ENC_BIG_ENDIAN); local_offset += 2; proto_tree_add_item(CM_header_tree, hf_cm_req_path_pp_mtu, tvb, local_offset, 1, ENC_BIG_ENDIAN); proto_tree_add_item(CM_header_tree, hf_cm_req_rdc_exists, tvb, local_offset, 1, ENC_BIG_ENDIAN); proto_tree_add_item(CM_header_tree, hf_cm_req_rnr_retry_count, tvb, local_offset, 1, ENC_BIG_ENDIAN); local_offset += 1; proto_tree_add_item(CM_header_tree, hf_cm_req_max_cm_retries, tvb, local_offset, 1, ENC_BIG_ENDIAN); proto_tree_add_item(CM_header_tree, hf_cm_req_srq, tvb, local_offset, 1, ENC_BIG_ENDIAN); local_offset += 1; /* skip reserved */ proto_tree_add_item(CM_header_tree, hf_cm_req_primary_local_lid, tvb, local_offset, 2, ENC_BIG_ENDIAN); local_lid = tvb_get_ntohs(tvb, local_offset); local_offset += 2; proto_tree_add_item(CM_header_tree, hf_cm_req_primary_remote_lid, tvb, local_offset, 2, ENC_BIG_ENDIAN); remote_lid = tvb_get_ntohs(tvb, local_offset); local_offset += 2; proto_tree_add_item(CM_header_tree, hf_cm_req_primary_local_gid, tvb, local_offset, 16, ENC_NA); tvb_get_ipv6(tvb, local_offset, (struct e_in6_addr*)local_gid); local_offset += 16; proto_tree_add_item(CM_header_tree, hf_cm_req_primary_remote_gid, tvb, local_offset, 16, ENC_NA); tvb_get_ipv6(tvb, local_offset, (struct e_in6_addr*)remote_gid); local_offset += 16; proto_tree_add_item(CM_header_tree, hf_cm_req_primary_flow_label, tvb, local_offset, 2, ENC_BIG_ENDIAN); local_offset += 2; local_offset += 1; /* skip reserved */ proto_tree_add_item(CM_header_tree, hf_cm_req_primary_packet_rate, tvb, local_offset, 1, ENC_BIG_ENDIAN); local_offset += 1; proto_tree_add_item(CM_header_tree, hf_cm_req_primary_traffic_class, tvb, local_offset, 1, ENC_BIG_ENDIAN); local_offset += 1; proto_tree_add_item(CM_header_tree, hf_cm_req_primary_hop_limit, tvb, local_offset, 1, ENC_BIG_ENDIAN); local_offset += 1; proto_tree_add_item(CM_header_tree, hf_cm_req_primary_sl, tvb, local_offset, 1, ENC_BIG_ENDIAN); proto_tree_add_item(CM_header_tree, hf_cm_req_primary_subnet_local, tvb, local_offset, 1, ENC_BIG_ENDIAN); local_offset += 1; /* skip reserved */ proto_tree_add_item(CM_header_tree, hf_cm_req_primary_local_ack_to, tvb, local_offset, 1, ENC_BIG_ENDIAN); local_offset += 1; /* skip reserved */ proto_tree_add_item(CM_header_tree, hf_cm_req_alt_local_lid, tvb, local_offset, 2, ENC_BIG_ENDIAN); local_offset += 2; proto_tree_add_item(CM_header_tree, hf_cm_req_alt_remote_lid, tvb, local_offset, 2, ENC_BIG_ENDIAN); local_offset += 2; proto_tree_add_item(CM_header_tree, hf_cm_req_alt_local_gid, tvb, local_offset, 16, ENC_NA); local_offset += 16; proto_tree_add_item(CM_header_tree, hf_cm_req_alt_remote_gid, tvb, local_offset, 16, ENC_NA); local_offset += 16; proto_tree_add_item(CM_header_tree, hf_cm_req_flow_label, tvb, local_offset, 2, ENC_BIG_ENDIAN); local_offset += 2; local_offset += 1; /* skip reserved */ proto_tree_add_item(CM_header_tree, hf_cm_req_packet_rate, tvb, local_offset, 1, ENC_BIG_ENDIAN); local_offset += 1; proto_tree_add_item(CM_header_tree, hf_cm_req_alt_traffic_class, tvb, local_offset, 1, ENC_BIG_ENDIAN); local_offset += 1; proto_tree_add_item(CM_header_tree, hf_cm_req_alt_hop_limit, tvb, local_offset, 1, ENC_BIG_ENDIAN); local_offset += 1; proto_tree_add_item(CM_header_tree, hf_cm_req_SL, tvb, local_offset, 1, ENC_BIG_ENDIAN); proto_tree_add_item(CM_header_tree, hf_cm_req_subnet_local, tvb, local_offset, 1, ENC_BIG_ENDIAN); local_offset += 1; /* skip reserved */ proto_tree_add_item(CM_header_tree, hf_cm_req_local_ACK_timeout, tvb, local_offset, 1, ENC_BIG_ENDIAN); local_offset += 1; /* skip reserved */ /* the following saves information about the conversation this packet defines, so there's no point in doing it more than once per packet */ if (!pinfo->fd->flags.visited) { connection_context *connection; conversation_infiniband_data *proto_data; conversation_t *conv; guint64 *hash_key = (guint64 *)g_malloc(sizeof(guint64)); /* create a new connection context and store it in the hash table */ connection = (connection_context *)g_malloc(sizeof(connection_context)); memcpy(&(connection->req_gid), local_gid, GID_SIZE); memcpy(&(connection->resp_gid), remote_gid, GID_SIZE); connection->req_lid = local_lid; connection->resp_lid = remote_lid; connection->req_qp = local_qpn; connection->resp_qp = 0; /* not currently known. we'll fill this in later */ connection->service_id = serviceid; /* save the context to the context hash table, for retrieval when the corresponding CM REP message arrives*/ *hash_key = MadData.transactionID; ADD_ADDRESS_TO_HASH(*hash_key, &pinfo->src); g_hash_table_replace(CM_context_table, hash_key, connection); /* Now we create a conversation for the CM exchange. This uses both sides of the conversation since CM packets also include the source QPN */ proto_data = se_new(conversation_infiniband_data); proto_data->service_id = connection->service_id; conv = conversation_new(pinfo->fd->num, &pinfo->src, &pinfo->dst, PT_IBQP, pinfo->srcport, pinfo->destport, 0); conversation_add_proto_data(conv, proto_infiniband, proto_data); } /* give a chance for subdissectors to analyze the private data */ next_tvb = tvb_new_subset(tvb, local_offset, 92, -1); if (! dissector_try_heuristic(heur_dissectors_cm_private, next_tvb, pinfo, parentTree, NULL) ) /* if none reported success, add this as raw "data" */ proto_tree_add_item(CM_header_tree, hf_cm_req_private_data, tvb, local_offset, 92, ENC_NA); local_offset += 92; } break; case ATTR_CM_REP: { guint32 remote_qpn; proto_tree_add_item(CM_header_tree, hf_cm_rep_localcommid, tvb, local_offset, 4, ENC_BIG_ENDIAN); local_offset += 4; proto_tree_add_item(CM_header_tree, hf_cm_rep_remotecommid, tvb, local_offset, 4, ENC_BIG_ENDIAN); local_offset += 4; proto_tree_add_item(CM_header_tree, hf_cm_rep_localqkey, tvb, local_offset, 4, ENC_BIG_ENDIAN); local_offset += 4; proto_tree_add_item(CM_header_tree, hf_cm_rep_localqpn, tvb, local_offset, 3, ENC_BIG_ENDIAN); remote_qpn = tvb_get_ntoh24(tvb, local_offset); local_offset += 3; local_offset += 1; /* skip reserved */ proto_tree_add_item(CM_header_tree, hf_cm_rep_localeecontnum, tvb, local_offset, 3, ENC_BIG_ENDIAN); local_offset += 3; local_offset += 1; /* skip reserved */ proto_tree_add_item(CM_header_tree, hf_cm_rep_startingpsn, tvb, local_offset, 3, ENC_BIG_ENDIAN); local_offset += 3; local_offset += 1; /* skip reserved */ proto_tree_add_item(CM_header_tree, hf_cm_rep_responderres, tvb, local_offset, 1, ENC_BIG_ENDIAN); local_offset += 1; proto_tree_add_item(CM_header_tree, hf_cm_rep_initiatordepth, tvb, local_offset, 1, ENC_BIG_ENDIAN); local_offset += 1; proto_tree_add_item(CM_header_tree, hf_cm_rep_tgtackdelay, tvb, local_offset, 1, ENC_BIG_ENDIAN); proto_tree_add_item(CM_header_tree, hf_cm_rep_failoveracc, tvb, local_offset, 1, ENC_BIG_ENDIAN); proto_tree_add_item(CM_header_tree, hf_cm_rep_e2eflowctl, tvb, local_offset, 1, ENC_BIG_ENDIAN); local_offset += 1; proto_tree_add_item(CM_header_tree, hf_cm_rep_rnrretrycount, tvb, local_offset, 1, ENC_BIG_ENDIAN); proto_tree_add_item(CM_header_tree, hf_cm_rep_srq, tvb, local_offset, 1, ENC_BIG_ENDIAN); local_offset += 1; /* skip reserved */ proto_tree_add_item(CM_header_tree, hf_cm_rep_localcaguid, tvb, local_offset, 8, ENC_BIG_ENDIAN); local_offset += 8; /* the following saves information about the conversation this packet defines, so there's no point in doing it more than once per packet */ if (!pinfo->fd->flags.visited) { /* get the previously saved context for this connection */ connection_context *connection; guint64 hash_key; hash_key = MadData.transactionID; ADD_ADDRESS_TO_HASH(hash_key, &pinfo->dst); connection = (connection_context *)g_hash_table_lookup(CM_context_table, &hash_key); /* if an appropriate connection was not found there's something wrong, but nothing we can do about it here - so just skip saving the context */ if (connection) { address req_addr, resp_addr; /* we'll fill these in and pass them to conversation_new */ conversation_t *conv; conversation_infiniband_data *proto_data = NULL; connection->resp_qp = remote_qpn; proto_data = se_new(conversation_infiniband_data); proto_data->service_id = connection->service_id; /* RC traffic never(?) includes a field indicating the source QPN, so the destination host knows it only from previous context (a single QPN on the host that is part of an RC can only receive traffic from that RC). For this reason we do not register conversations with both sides, but rather we register the same conversation twice - once for each side of the Reliable Connection. */ /* first register the conversation using the GIDs */ SET_ADDRESS(&req_addr, AT_IB, GID_SIZE, connection->req_gid); SET_ADDRESS(&resp_addr, AT_IB, GID_SIZE, connection->resp_gid); conv = conversation_new(pinfo->fd->num, &req_addr, &req_addr, PT_IBQP, connection->req_qp, connection->req_qp, NO_ADDR2|NO_PORT2); conversation_add_proto_data(conv, proto_infiniband, proto_data); conv = conversation_new(pinfo->fd->num, &resp_addr, &resp_addr, PT_IBQP, connection->resp_qp, connection->resp_qp, NO_ADDR2|NO_PORT2); conversation_add_proto_data(conv, proto_infiniband, proto_data); /* next, register the conversation using the LIDs */ SET_ADDRESS(&req_addr, AT_IB, sizeof(guint16), &(connection->req_lid)); SET_ADDRESS(&resp_addr, AT_IB, sizeof(guint16), &(connection->resp_lid)); conv = conversation_new(pinfo->fd->num, &req_addr, &req_addr, PT_IBQP, connection->req_qp, connection->req_qp, NO_ADDR2|NO_PORT2); conversation_add_proto_data(conv, proto_infiniband, proto_data); conv = conversation_new(pinfo->fd->num, &resp_addr, &resp_addr, PT_IBQP, connection->resp_qp, connection->resp_qp, NO_ADDR2|NO_PORT2); conversation_add_proto_data(conv, proto_infiniband, proto_data); g_hash_table_remove(CM_context_table, &hash_key); } } /* give a chance for subdissectors to get the private data */ next_tvb = tvb_new_subset(tvb, local_offset, 196, -1); if (! dissector_try_heuristic(heur_dissectors_cm_private, next_tvb, pinfo, parentTree, NULL) ) /* if none reported success, add this as raw "data" */ proto_tree_add_item(CM_header_tree, hf_cm_rep_privatedata, tvb, local_offset, 196, ENC_NA); local_offset += 196; } break; case ATTR_CM_RTU: proto_tree_add_item(CM_header_tree, hf_cm_rtu_localcommid, tvb, local_offset, 4, ENC_BIG_ENDIAN); local_offset += 4; proto_tree_add_item(CM_header_tree, hf_cm_rtu_remotecommid, tvb, local_offset, 4, ENC_BIG_ENDIAN); local_offset += 4; /* currently only REQ/REP call subdissectors for the private data */ proto_tree_add_item(CM_header_tree, hf_cm_rtu_privatedata, tvb, local_offset, 224, ENC_NA); local_offset += 224; break; case ATTR_CM_REJ: proto_tree_add_item(CM_header_tree, hf_cm_rej_local_commid, tvb, local_offset, 4, ENC_BIG_ENDIAN); local_offset += 4; proto_tree_add_item(CM_header_tree, hf_cm_rej_remote_commid, tvb, local_offset, 4, ENC_BIG_ENDIAN); local_offset += 4; proto_tree_add_item(CM_header_tree, hf_cm_rej_msg_rej, tvb, local_offset, 1, ENC_BIG_ENDIAN); local_offset += 1; /* skip reserved */ proto_tree_add_item(CM_header_tree, hf_cm_rej_rej_info_len, tvb, local_offset, 1, ENC_BIG_ENDIAN); local_offset += 1; /* skip reserved */ proto_tree_add_item(CM_header_tree, hf_cm_rej_reason, tvb, local_offset, 2, ENC_BIG_ENDIAN); local_offset += 2; proto_tree_add_item(CM_header_tree, hf_cm_rej_add_rej_info, tvb, local_offset, 72, ENC_NA); local_offset += 72; /* currently only REQ/REP call subdissectors for the private data */ proto_tree_add_item(CM_header_tree, hf_cm_rej_private_data, tvb, local_offset, 148, ENC_NA); local_offset += 148; break; default: proto_item_append_text(CM_header_item, " (Dissector Not Implemented)"); local_offset += MAD_DATA_SIZE; break; } *offset = local_offset; } /* Parse SNMP Tunneling * IN: parentTree to add the dissection to * IN: tvb - the data buffer from wireshark * IN/OUT: The current and updated offset */ static void parse_SNMP(proto_tree *parentTree, tvbuff_t *tvb, gint *offset) { /* Parse the Common MAD Header */ MAD_Data MadData; gint local_offset; proto_item *PERF_header_item; if (!parse_MAD_Common(parentTree, tvb, offset, &MadData)) { /* TODO: Mark Corrupt Packet - Not enough bytes exist for at least the Common MAD header which is present in all MAD packets */ return; } local_offset = *offset; PERF_header_item = proto_tree_add_item(parentTree, hf_infiniband_smp_data, tvb, local_offset, MAD_DATA_SIZE, ENC_NA); local_offset += MAD_DATA_SIZE; proto_item_set_text(PERF_header_item, "%s", "SNMP - SNMP Tunneling MAD (Dissector Not Implemented)"); *offset = local_offset; } /* Parse Vendor Specific Management Packets * IN: parentTree to add the dissection to * IN: tvb - the data buffer from wireshark * IN/OUT: The current and updated offset */ static void parse_VENDOR_MANAGEMENT(proto_tree *parentTree, tvbuff_t *tvb, gint *offset) { /* Parse the Common MAD Header */ MAD_Data MadData; gint local_offset; proto_item *PERF_header_item; if (!parse_MAD_Common(parentTree, tvb, offset, &MadData)) { /* TODO: Mark Corrupt Packet - Not enough bytes exist for at least the Common MAD header which is present in all MAD packets */ return; } local_offset = *offset; PERF_header_item = proto_tree_add_item(parentTree, hf_infiniband_smp_data, tvb, local_offset, MAD_DATA_SIZE, ENC_NA); local_offset += MAD_DATA_SIZE; proto_item_set_text(PERF_header_item, "%s", "VENDOR - Vendor Specific Management MAD (Dissector Not Implemented)"); *offset = local_offset; } /* Parse Application Specific Management Packets * IN: parentTree to add the dissection to * IN: tvb - the data buffer from wireshark * IN/OUT: The current and updated offset */ static void parse_APPLICATION_MANAGEMENT(proto_tree *parentTree, tvbuff_t *tvb, gint *offset) { /* Parse the Common MAD Header */ MAD_Data MadData; gint local_offset; proto_item *PERF_header_item; if (!parse_MAD_Common(parentTree, tvb, offset, &MadData)) { /* TODO: Mark Corrupt Packet - Not enough bytes exist for at least the Common MAD header which is present in all MAD packets */ return; } local_offset = *offset; PERF_header_item = proto_tree_add_item(parentTree, hf_infiniband_smp_data, tvb, local_offset, MAD_DATA_SIZE, ENC_NA); local_offset += MAD_DATA_SIZE; proto_item_set_text(PERF_header_item, "%s", "APP - Application Specific MAD (Dissector Not Implemented)"); *offset = local_offset; } /* Parse Reserved Management Packets. * This is an !ERROR CONDITION! * It means that the Management Class value used was defined as a reserved value for furture use. * This method is here since we will want to report this information directly to the UI without blowing up Wireshark. * IN: parentTree to add the dissection to * IN: tvb - the data buffer from wireshark * IN/OUT: The current and updated offset */ static void parse_RESERVED_MANAGEMENT(proto_tree *parentTree, tvbuff_t *tvb, gint *offset) { /* Parse the Common MAD Header */ MAD_Data MadData; gint local_offset; proto_item *PERF_header_item; if (!parse_MAD_Common(parentTree, tvb, offset, &MadData)) { /* TODO: Mark Corrupt Packet - Not enough bytes exist for at least the Common MAD header which is present in all MAD packets */ return; } local_offset = *offset; PERF_header_item = proto_tree_add_item(parentTree, hf_infiniband_smp_data, tvb, local_offset, 256, ENC_NA); local_offset += 256; proto_item_set_text(PERF_header_item, "%s", "RESERVED - Reserved MAD Type (Possible Device Error)"); *offset = local_offset; } /* Parse the common MAD Header * IN: parentTree to add the dissection to * IN: tvb - the data buffer from wireshark * IN/OUT: The current and updated offset * IN/OUT: MadData - the data from the MAD header */ static gboolean parse_MAD_Common(proto_tree *parentTree, tvbuff_t *tvb, gint *offset, MAD_Data* MadData) { gint local_offset = *offset; proto_item *MAD_header_item; proto_tree *MAD_header_tree; if (MadData == NULL) return FALSE; if (!tvb_bytes_exist(tvb, *offset, 256)) return FALSE; /* Get the Management Class to decide between LID Routed and Direct Route */ MadData->managementClass = tvb_get_guint8(tvb, local_offset + 1); MadData->classVersion = tvb_get_guint8(tvb, local_offset + 2); MadData->method = tvb_get_guint8(tvb, local_offset + 3); MadData->status = tvb_get_guint8(tvb, local_offset + 4); MadData->classSpecific = tvb_get_ntohs(tvb, local_offset + 6); MadData->transactionID = tvb_get_ntoh64(tvb, local_offset + 8); MadData->attributeID = tvb_get_ntohs(tvb, local_offset + 16); MadData->attributeModifier = tvb_get_ntohl(tvb, local_offset + 20); tvb_memcpy(tvb, MadData->data, local_offset + 24, MAD_DATA_SIZE); /* Populate the Dissector Tree */ MAD_header_item = proto_tree_add_item(parentTree, hf_infiniband_MAD, tvb, local_offset, 256, ENC_NA); proto_item_set_text(MAD_header_item, "%s", "MAD Header - Common Management Datagram"); MAD_header_tree = proto_item_add_subtree(MAD_header_item, ett_mad); proto_tree_add_item(MAD_header_tree, hf_infiniband_base_version, tvb, local_offset, 1, ENC_BIG_ENDIAN); local_offset += 1; proto_tree_add_item(MAD_header_tree, hf_infiniband_mgmt_class, tvb, local_offset, 1, ENC_BIG_ENDIAN); local_offset += 1; proto_tree_add_item(MAD_header_tree, hf_infiniband_class_version, tvb, local_offset, 1, ENC_BIG_ENDIAN); local_offset += 1; proto_tree_add_item(MAD_header_tree, hf_infiniband_method, tvb, local_offset, 1, ENC_BIG_ENDIAN); local_offset += 1; proto_tree_add_item(MAD_header_tree, hf_infiniband_status, tvb, local_offset, 2, ENC_BIG_ENDIAN); local_offset += 2; proto_tree_add_item(MAD_header_tree, hf_infiniband_class_specific, tvb, local_offset, 2, ENC_BIG_ENDIAN); local_offset += 2; proto_tree_add_item(MAD_header_tree, hf_infiniband_transaction_id, tvb, local_offset, 8, ENC_BIG_ENDIAN); local_offset += 8; proto_tree_add_item(MAD_header_tree, hf_infiniband_attribute_id, tvb, local_offset, 2, ENC_BIG_ENDIAN); local_offset += 2; proto_tree_add_item(MAD_header_tree, hf_infiniband_reserved16, tvb, local_offset, 2, ENC_BIG_ENDIAN); local_offset += 2; proto_tree_add_item(MAD_header_tree, hf_infiniband_attribute_modifier, tvb, local_offset, 4, ENC_BIG_ENDIAN); local_offset += 4; proto_tree_add_item(MAD_header_tree, hf_infiniband_data, tvb, local_offset, MAD_DATA_SIZE, ENC_NA); *offset = local_offset; /* Move the offset to the start of the Data field - this will be where the other parsers start. */ return TRUE; } /* Parse the RMPP (Reliable Multi-Packet Transaction Protocol * IN: parentTree to add the dissection to * IN: tvb - the data buffer from wireshark * IN/OUT: The current and updated offset */ static gboolean parse_RMPP(proto_tree *parentTree, tvbuff_t *tvb, gint *offset) { gint local_offset = *offset; guint8 RMPP_Type = tvb_get_guint8(tvb, local_offset + 1); proto_item *RMPP_header_item; proto_tree *RMPP_header_tree; RMPP_header_item = proto_tree_add_item(parentTree, hf_infiniband_RMPP, tvb, local_offset, 12, ENC_NA); proto_item_set_text(RMPP_header_item, "%s", val_to_str(RMPP_Type, RMPP_Packet_Types, "Reserved RMPP Type! (0x%02x)")); RMPP_header_tree = proto_item_add_subtree(RMPP_header_item, ett_rmpp); proto_tree_add_item(RMPP_header_tree, hf_infiniband_rmpp_version, tvb, local_offset, 1, ENC_BIG_ENDIAN); local_offset += 1; proto_tree_add_item(RMPP_header_tree, hf_infiniband_rmpp_type, tvb, local_offset, 1, ENC_BIG_ENDIAN); local_offset += 1; proto_tree_add_item(RMPP_header_tree, hf_infiniband_r_resp_time, tvb, local_offset, 1, ENC_BIG_ENDIAN); proto_tree_add_item(RMPP_header_tree, hf_infiniband_rmpp_flags, tvb, local_offset, 1, ENC_BIG_ENDIAN); local_offset += 1; proto_tree_add_item(RMPP_header_tree, hf_infiniband_rmpp_status, tvb, local_offset, 1, ENC_BIG_ENDIAN); local_offset += 1; switch (RMPP_Type) { case RMPP_ILLEGAL: proto_tree_add_item(RMPP_header_tree, hf_infiniband_rmpp_data1, tvb, local_offset, 4, ENC_BIG_ENDIAN); local_offset += 4; proto_tree_add_item(RMPP_header_tree, hf_infiniband_rmpp_data2, tvb, local_offset, 4, ENC_BIG_ENDIAN); local_offset += 4; break; case RMPP_DATA: proto_tree_add_item(RMPP_header_tree, hf_infiniband_segment_number, tvb, local_offset, 4, ENC_BIG_ENDIAN); local_offset += 4; proto_tree_add_item(RMPP_header_tree, hf_infiniband_payload_length32, tvb, local_offset, 4, ENC_BIG_ENDIAN); local_offset += 4; proto_tree_add_item(RMPP_header_tree, hf_infiniband_transferred_data, tvb, local_offset, 220, ENC_NA); break; case RMPP_ACK: proto_tree_add_item(RMPP_header_tree, hf_infiniband_segment_number, tvb, local_offset, 4, ENC_BIG_ENDIAN); local_offset += 4; proto_tree_add_item(RMPP_header_tree, hf_infiniband_new_window_last, tvb, local_offset, 4, ENC_BIG_ENDIAN); local_offset += 4; proto_tree_add_item(RMPP_header_tree, hf_infiniband_reserved220, tvb, local_offset, 220, ENC_NA); break; case RMPP_STOP: case RMPP_ABORT: proto_tree_add_item(RMPP_header_tree, hf_infiniband_reserved32, tvb, local_offset, 4, ENC_NA); local_offset += 4; proto_tree_add_item(RMPP_header_tree, hf_infiniband_reserved32, tvb, local_offset, 4, ENC_NA); local_offset += 4; proto_tree_add_item(RMPP_header_tree, hf_infiniband_optional_extended_error_data, tvb, local_offset, 220, ENC_NA); break; default: break; } *offset = local_offset; return TRUE; } /* Parse the Method from the MAD Common Header. * Simply used to generate the identifier. * IN: SubMItem - the item to append the method label to. * IN: MadHeader - the MadData structure that contains the information from the Common MAD header. * IN: pinfo - packet info from wireshark. */ static void label_SUBM_Method(proto_item *SubMItem, MAD_Data *MadHeader, packet_info *pinfo) { const char *label = val_to_str_const(MadHeader->method, SUBM_Methods, "(Unknown SubManagement Method!)"); proto_item_append_text(SubMItem, "%s", label); col_append_str(pinfo->cinfo, COL_INFO, label); } /* Parse the SA Method from the MAD Common Header. * Simply used to generate the identifier. * IN: SubAItem - the item to append the method label to. * IN: MadHeader - the MadData structure that contains the information from the Common MAD header. * IN: pinfo - packet info from wireshark. */ static void label_SUBA_Method(proto_item *SubAItem, MAD_Data *MadHeader, packet_info *pinfo) { const char *label = val_to_str_const(MadHeader->method, SUBA_Methods, "(Unknown SubAdministration Method!)"); proto_item_append_text(SubAItem, "%s", label); col_append_str(pinfo->cinfo, COL_INFO, label); } /* Parse the Attribute from the MAD Common Header * Simply used to generate the identifier. * IN: SubMItem - the item to append the Attribute label to. * IN: MadHeader - the MadData structure that contains the information from the Common MAD header. * IN: pinfo - packet info from wireshark. */ static void label_SUBM_Attribute(proto_item *SubMItem, MAD_Data *MadHeader, packet_info *pinfo) { const char *label = val_to_str_const(MadHeader->attributeID, SUBM_Attributes, "(Unknown SubManagement Attribute!)"); proto_item_append_text(SubMItem, "%s", &label[11]); col_append_str(pinfo->cinfo, COL_INFO, &label[11]); } /* Parse the SA Attribute from the MAD Common Header * Simply used to generate the identifier. * IN: SubAItem - the item to append the Attribute label to. * IN: MadHeader - the MadData structure that contains the information from the Common MAD header. * IN: pinfo - packet info from wireshark. */ static void label_SUBA_Attribute(proto_item *SubAItem, MAD_Data *MadHeader, packet_info *pinfo) { const char *label = val_to_str_const(MadHeader->attributeID, SUBA_Attributes, "(Unknown SubAdministration Attribute!)"); proto_item_append_text(SubAItem, "%s", &label[11]); col_append_str(pinfo->cinfo, COL_INFO, &label[11]); } /* Parse the attribute from a Subnet Management Packet. * IN: Parent Tree to add the item to in the dissection tree * IN: tvbuff, offset - the data and where it is. * IN: MAD_Data the data from the Common MAD Header that provides the information we need */ static gboolean parse_SUBM_Attribute(proto_tree *parentTree, tvbuff_t *tvb, gint *offset, MAD_Data *MadHeader) { guint16 attributeID = MadHeader->attributeID; proto_item *SUBM_Attribute_header_item; proto_tree *SUBM_Attribute_header_tree; SUBM_Attribute_header_item = proto_tree_add_item(parentTree, hf_infiniband_smp_data, tvb, *offset, 64, ENC_NA); proto_item_set_text(SUBM_Attribute_header_item, "%s", val_to_str(attributeID, SUBM_Attributes, "Unknown Attribute Type! (0x%02x)")); SUBM_Attribute_header_tree = proto_item_add_subtree(SUBM_Attribute_header_item, ett_subm_attribute); switch (attributeID) { case 0x0002: parse_NoticesAndTraps(SUBM_Attribute_header_tree , tvb, offset); break; case 0x0010: parse_NodeDescription(SUBM_Attribute_header_tree , tvb, offset); break; case 0x0011: parse_NodeInfo(SUBM_Attribute_header_tree , tvb, offset); break; case 0x0012: parse_SwitchInfo(SUBM_Attribute_header_tree , tvb, offset); break; case 0x0014: parse_GUIDInfo(SUBM_Attribute_header_tree , tvb, offset); break; case 0x0015: parse_PortInfo(SUBM_Attribute_header_tree , tvb, offset); break; case 0x0016: parse_P_KeyTable(SUBM_Attribute_header_tree , tvb, offset); break; case 0x0017: parse_SLtoVLMappingTable(SUBM_Attribute_header_tree , tvb, offset); break; case 0x0018: parse_VLArbitrationTable(SUBM_Attribute_header_tree , tvb, offset); break; case 0x0019: parse_LinearForwardingTable(SUBM_Attribute_header_tree , tvb, offset); break; case 0x001A: parse_RandomForwardingTable(SUBM_Attribute_header_tree , tvb, offset); break; case 0x001B: parse_MulticastForwardingTable(SUBM_Attribute_header_tree , tvb, offset); break; case 0x001C: parse_SMInfo(SUBM_Attribute_header_tree , tvb, offset); break; case 0x0020: parse_VendorDiag(SUBM_Attribute_header_tree , tvb, offset); break; case 0x0030: parse_LedInfo(SUBM_Attribute_header_tree , tvb, offset); break; case 0x0031: parse_LinkSpeedWidthPairsTable(SUBM_Attribute_header_tree , tvb, offset); break; default: break; } *offset += 64; return TRUE; } /* Parse the attribute from a Subnet Administration Packet. * IN: Parent Tree to add the item to in the dissection tree * IN: tvbuff, offset - the data and where it is. * IN: MAD_Data the data from the Common MAD Header that provides the information we need */ static gboolean parse_SUBA_Attribute(proto_tree *parentTree, tvbuff_t *tvb, gint *offset, MAD_Data *MadHeader) { guint16 attributeID = MadHeader->attributeID; proto_item *SUBA_Attribute_header_item; proto_tree *SUBA_Attribute_header_tree; SUBA_Attribute_header_item = proto_tree_add_item(parentTree, hf_infiniband_SA, tvb, *offset, 200, ENC_NA); proto_item_set_text(SUBA_Attribute_header_item, "%s", val_to_str(attributeID, SUBA_Attributes, "Unknown Attribute Type! (0x%02x)")); SUBA_Attribute_header_tree = proto_item_add_subtree(SUBA_Attribute_header_item, ett_suba_attribute); /* Skim off the RID fields should they be present */ parse_RID(SUBA_Attribute_header_tree, tvb, offset, MadHeader); /* Parse the rest of the attributes */ switch (MadHeader->attributeID) { case 0x0001: /* (ClassPortInfo) */ parse_PortInfo(SUBA_Attribute_header_tree, tvb, offset); break; case 0x0002: /* (Notice) */ parse_NoticesAndTraps(SUBA_Attribute_header_tree, tvb, offset); break; case 0x0003: /* (InformInfo) */ parse_InformInfo(SUBA_Attribute_header_tree, tvb, offset); break; case 0x0011: /* (NodeRecord) */ parse_NodeInfo(SUBA_Attribute_header_tree, tvb, offset); *offset += 40; parse_NodeDescription(SUBA_Attribute_header_tree, tvb, offset); break; case 0x0012: /* (PortInfoRecord) */ parse_PortInfo(SUBA_Attribute_header_tree, tvb, offset); break; case 0x0013: /* (SLtoVLMappingTableRecord) */ parse_SLtoVLMappingTable(SUBA_Attribute_header_tree, tvb, offset); break; case 0x0014: /* (SwitchInfoRecord) */ parse_SwitchInfo(SUBA_Attribute_header_tree, tvb, offset); break; case 0x0015: /*(LinearForwardingTableRecord) */ parse_LinearForwardingTable(SUBA_Attribute_header_tree, tvb, offset); break; case 0x0016: /* (RandomForwardingTableRecord) */ parse_RandomForwardingTable(SUBA_Attribute_header_tree, tvb, offset); break; case 0x0017: /* (MulticastForwardingTableRecord) */ parse_MulticastForwardingTable(SUBA_Attribute_header_tree, tvb, offset); break; case 0x0018: /* (SMInfoRecord) */ parse_SMInfo(SUBA_Attribute_header_tree, tvb, offset); break; case 0x0019: /* (LinkSpeedWidthPairsTableRecord) */ parse_LinkSpeedWidthPairsTable(SUBA_Attribute_header_tree, tvb, offset); break; case 0x00F3: /*(InformInfoRecord) */ parse_InformInfo(SUBA_Attribute_header_tree, tvb, offset); break; case 0x0020: /* (LinkRecord) */ parse_LinkRecord(SUBA_Attribute_header_tree, tvb, offset); break; case 0x0030: /* (GuidInforecord) */ parse_GUIDInfo(SUBA_Attribute_header_tree, tvb, offset); break; case 0x0031: /*(ServiceRecord) */ parse_ServiceRecord(SUBA_Attribute_header_tree, tvb, offset); break; case 0x0033: /* (P_KeyTableRecord) */ parse_P_KeyTable(SUBA_Attribute_header_tree, tvb, offset); break; case 0x0035: /* (PathRecord) */ parse_PathRecord(SUBA_Attribute_header_tree, tvb, offset); break; case 0x0036: /* (VLArbitrationTableRecord) */ parse_VLArbitrationTable(SUBA_Attribute_header_tree, tvb, offset); break; case 0x0038: /* (MCMemberRecord) */ parse_MCMemberRecord(SUBA_Attribute_header_tree, tvb, offset); break; case 0x0039: /* (TraceRecord) */ parse_TraceRecord(SUBA_Attribute_header_tree, tvb, offset); break; case 0x003A: /* (MultiPathRecord) */ parse_MultiPathRecord(SUBA_Attribute_header_tree, tvb, offset); break; case 0x003B: /* (ServiceAssociationRecord) */ parse_ServiceAssociationRecord(SUBA_Attribute_header_tree, tvb, offset); break; default: /* (Unknown SubAdministration Attribute!) */ /* We've already labeled as unknown in item construction */ break; } *offset += 200; return TRUE; } /* Subnet Management Attribute Parsing Methods. * Also Parsing for Attributes common to both SM/SA. * The Subnet Admin Parsing methods will call some of these methods when an attribute is present within an SA MAD */ /* Parse NoticeDataDetails Attribute Field * IN: parentTree - The tree to add the dissection to * tvb - The tvbbuff of packet data * offset - The offset in TVB where the attribute begins * trapNumber - The Trap ID of the Trap Data being Dissected */ static gint parse_NoticeDataDetails(proto_tree* parentTree, tvbuff_t* tvb, gint *offset, guint16 trapNumber) { gint local_offset = *offset; proto_item *DataDetails_header_item; proto_tree *DataDetails_header_tree; if (!parentTree) return 0; DataDetails_header_item = proto_tree_add_item(parentTree, hf_infiniband_smp_data, tvb, local_offset, 54, ENC_NA); DataDetails_header_tree = proto_item_add_subtree(DataDetails_header_item, ett_datadetails); switch (trapNumber) { case 64: proto_item_set_text(DataDetails_header_item, "%s", "Trap 64 DataDetails"); local_offset += 6; proto_tree_add_item(DataDetails_header_tree, hf_infiniband_Trap_GIDADDR, tvb, local_offset, 16, ENC_NA); local_offset += 16; break; case 65: proto_item_set_text(DataDetails_header_item, "%s", "Trap 65 DataDetails"); local_offset += 6; proto_tree_add_item(DataDetails_header_tree, hf_infiniband_Trap_GIDADDR, tvb, local_offset, 16, ENC_NA); local_offset += 16; break; case 66: proto_item_set_text(DataDetails_header_item, "%s", "Trap 66 DataDetails"); local_offset += 6; proto_tree_add_item(DataDetails_header_tree, hf_infiniband_Trap_GIDADDR, tvb, local_offset, 16, ENC_NA); local_offset += 16; break; case 67: proto_item_set_text(DataDetails_header_item, "%s", "Trap 67 DataDetails"); local_offset += 6; proto_tree_add_item(DataDetails_header_tree, hf_infiniband_Trap_GIDADDR, tvb, local_offset, 16, ENC_NA); local_offset += 16; break; case 68: proto_item_set_text(DataDetails_header_item, "%s", "Trap 68 DataDetails"); proto_tree_add_item(DataDetails_header_tree, hf_infiniband_Trap_COMP_MASK, tvb, local_offset, 8, ENC_BIG_ENDIAN); local_offset += 8; proto_tree_add_item(DataDetails_header_tree, hf_infiniband_Trap_WAIT_FOR_REPATH, tvb, local_offset, 1, ENC_BIG_ENDIAN); break; case 69: proto_item_set_text(DataDetails_header_item, "%s", "Trap 69 DataDetails"); proto_tree_add_item(DataDetails_header_tree, hf_infiniband_Trap_COMP_MASK, tvb, local_offset, 8, ENC_BIG_ENDIAN); local_offset += 8; proto_tree_add_item(DataDetails_header_tree, hf_infiniband_Trap_WAIT_FOR_REPATH, tvb, local_offset, 1, ENC_BIG_ENDIAN); break; case 128: proto_item_set_text(DataDetails_header_item, "%s", "Trap 128 DataDetails"); proto_tree_add_item(DataDetails_header_tree, hf_infiniband_Trap_LIDADDR, tvb, local_offset, 2, ENC_BIG_ENDIAN); local_offset += 2; break; case 129: proto_item_set_text(DataDetails_header_item, "%s", "Trap 129 DataDetails"); local_offset += 2; proto_tree_add_item(DataDetails_header_tree, hf_infiniband_Trap_LIDADDR, tvb, local_offset, 2, ENC_BIG_ENDIAN); local_offset += 2; proto_tree_add_item(DataDetails_header_tree, hf_infiniband_Trap_PORTNO, tvb, local_offset, 1, ENC_BIG_ENDIAN); local_offset += 1; break; case 130: proto_item_set_text(DataDetails_header_item, "%s", "Trap 130 DataDetails"); local_offset += 2; proto_tree_add_item(DataDetails_header_tree, hf_infiniband_Trap_LIDADDR, tvb, local_offset, 2, ENC_BIG_ENDIAN); local_offset += 2; proto_tree_add_item(DataDetails_header_tree, hf_infiniband_Trap_PORTNO, tvb, local_offset, 1, ENC_BIG_ENDIAN); local_offset += 1; break; case 131: proto_item_set_text(DataDetails_header_item, "%s", "Trap 131 DataDetails"); local_offset += 2; proto_tree_add_item(DataDetails_header_tree, hf_infiniband_Trap_LIDADDR, tvb, local_offset, 2, ENC_BIG_ENDIAN); local_offset += 2; proto_tree_add_item(DataDetails_header_tree, hf_infiniband_Trap_PORTNO, tvb, local_offset, 1, ENC_BIG_ENDIAN); local_offset += 1; break; case 144: proto_item_set_text(DataDetails_header_item, "%s", "Trap 144 DataDetails"); local_offset += 2; proto_tree_add_item(DataDetails_header_tree, hf_infiniband_Trap_LIDADDR, tvb, local_offset, 2, ENC_BIG_ENDIAN); local_offset += 2; local_offset += 1; proto_tree_add_item(DataDetails_header_tree, hf_infiniband_Trap_OtherLocalChanges, tvb, local_offset, 1, ENC_BIG_ENDIAN); local_offset += 1; proto_tree_add_item(DataDetails_header_tree, hf_infiniband_Trap_CAPABILITYMASK, tvb, local_offset, 4, ENC_BIG_ENDIAN); local_offset += 4; local_offset += 1; proto_tree_add_item(DataDetails_header_tree, hf_infiniband_Trap_LinkSpeecEnabledChange, tvb, local_offset, 1, ENC_BIG_ENDIAN); proto_tree_add_item(DataDetails_header_tree, hf_infiniband_Trap_LinkWidthEnabledChange, tvb, local_offset, 1, ENC_BIG_ENDIAN); proto_tree_add_item(DataDetails_header_tree, hf_infiniband_Trap_NodeDescriptionChange, tvb, local_offset, 1, ENC_BIG_ENDIAN); break; case 145: proto_item_set_text(DataDetails_header_item, "%s", "Trap 145 DataDetails"); local_offset += 2; proto_tree_add_item(DataDetails_header_tree, hf_infiniband_Trap_LIDADDR, tvb, local_offset, 2, ENC_BIG_ENDIAN); local_offset += 2; local_offset += 2; proto_tree_add_item(DataDetails_header_tree, hf_infiniband_Trap_SYSTEMIMAGEGUID, tvb, local_offset, 8, ENC_BIG_ENDIAN); local_offset += 8; break; case 256: proto_item_set_text(DataDetails_header_item, "%s", "Trap 256 DataDetails"); local_offset += 2; proto_tree_add_item(DataDetails_header_tree, hf_infiniband_Trap_LIDADDR, tvb, local_offset, 2, ENC_BIG_ENDIAN); local_offset += 2; proto_tree_add_item(DataDetails_header_tree, hf_infiniband_Trap_DRSLID, tvb, local_offset, 2, ENC_BIG_ENDIAN); local_offset += 2; proto_tree_add_item(DataDetails_header_tree, hf_infiniband_Trap_METHOD, tvb, local_offset, 1, ENC_BIG_ENDIAN); local_offset += 1; local_offset += 1; proto_tree_add_item(DataDetails_header_tree, hf_infiniband_Trap_ATTRIBUTEID, tvb, local_offset, 2, ENC_BIG_ENDIAN); local_offset += 2; proto_tree_add_item(DataDetails_header_tree, hf_infiniband_Trap_ATTRIBUTEMODIFIER, tvb, local_offset, 4, ENC_BIG_ENDIAN); local_offset += 4; proto_tree_add_item(DataDetails_header_tree, hf_infiniband_Trap_MKEY, tvb, local_offset, 8, ENC_BIG_ENDIAN); local_offset += 8; local_offset += 1; proto_tree_add_item(DataDetails_header_tree, hf_infiniband_Trap_DRNotice, tvb, local_offset, 1, ENC_BIG_ENDIAN); proto_tree_add_item(DataDetails_header_tree, hf_infiniband_Trap_DRPathTruncated, tvb, local_offset, 1, ENC_BIG_ENDIAN); proto_tree_add_item(DataDetails_header_tree, hf_infiniband_Trap_DRHopCount, tvb, local_offset, 1, ENC_BIG_ENDIAN); local_offset += 1; proto_tree_add_item(DataDetails_header_tree, hf_infiniband_Trap_DRNoticeReturnPath, tvb, local_offset, 30, ENC_NA); local_offset += 30; break; case 257: proto_item_set_text(DataDetails_header_item, "%s", "Trap 257 DataDetails"); local_offset += 2; proto_tree_add_item(DataDetails_header_tree, hf_infiniband_Trap_LIDADDR1, tvb, local_offset, 2, ENC_BIG_ENDIAN); local_offset += 2; proto_tree_add_item(DataDetails_header_tree, hf_infiniband_Trap_LIDADDR2, tvb, local_offset, 2, ENC_BIG_ENDIAN); local_offset += 2; proto_tree_add_item(DataDetails_header_tree, hf_infiniband_Trap_KEY, tvb, local_offset, 4, ENC_BIG_ENDIAN); local_offset += 4; proto_tree_add_item(DataDetails_header_tree, hf_infiniband_Trap_SL, tvb, local_offset, 1, ENC_BIG_ENDIAN); local_offset += 1; proto_tree_add_item(DataDetails_header_tree, hf_infiniband_Trap_QP1, tvb, local_offset, 3, ENC_BIG_ENDIAN); local_offset += 3; local_offset += 1; proto_tree_add_item(DataDetails_header_tree, hf_infiniband_Trap_QP2, tvb, local_offset, 3, ENC_BIG_ENDIAN); local_offset += 3; proto_tree_add_item(DataDetails_header_tree, hf_infiniband_Trap_GIDADDR1, tvb, local_offset, 16, ENC_NA); local_offset += 16; proto_tree_add_item(DataDetails_header_tree, hf_infiniband_Trap_GIDADDR2, tvb, local_offset, 16, ENC_NA); local_offset += 16; break; case 258: proto_item_set_text(DataDetails_header_item, "%s", "Trap 258 DataDetails"); local_offset += 2; proto_tree_add_item(DataDetails_header_tree, hf_infiniband_Trap_LIDADDR1, tvb, local_offset, 2, ENC_BIG_ENDIAN); local_offset += 2; proto_tree_add_item(DataDetails_header_tree, hf_infiniband_Trap_LIDADDR2, tvb, local_offset, 2, ENC_BIG_ENDIAN); local_offset += 2; proto_tree_add_item(DataDetails_header_tree, hf_infiniband_Trap_KEY, tvb, local_offset, 4, ENC_BIG_ENDIAN); local_offset += 4; proto_tree_add_item(DataDetails_header_tree, hf_infiniband_Trap_SL, tvb, local_offset, 1, ENC_BIG_ENDIAN); local_offset += 1; proto_tree_add_item(DataDetails_header_tree, hf_infiniband_Trap_QP1, tvb, local_offset, 3, ENC_BIG_ENDIAN); local_offset += 3; local_offset += 1; proto_tree_add_item(DataDetails_header_tree, hf_infiniband_Trap_QP2, tvb, local_offset, 3, ENC_BIG_ENDIAN); local_offset += 3; proto_tree_add_item(DataDetails_header_tree, hf_infiniband_Trap_GIDADDR1, tvb, local_offset, 16, ENC_NA); local_offset += 16; proto_tree_add_item(DataDetails_header_tree, hf_infiniband_Trap_GIDADDR2, tvb, local_offset, 16, ENC_NA); local_offset += 16; break; case 259: proto_item_set_text(DataDetails_header_item, "%s", "Trap 259 DataDetails"); proto_tree_add_item(DataDetails_header_tree, hf_infiniband_Trap_DataValid, tvb, local_offset, 2, ENC_NA); local_offset += 2; proto_tree_add_item(DataDetails_header_tree, hf_infiniband_Trap_LIDADDR1, tvb, local_offset, 2, ENC_BIG_ENDIAN); local_offset += 2; proto_tree_add_item(DataDetails_header_tree, hf_infiniband_Trap_LIDADDR2, tvb, local_offset, 2, ENC_BIG_ENDIAN); local_offset += 2; proto_tree_add_item(DataDetails_header_tree, hf_infiniband_Trap_PKEY, tvb, local_offset, 2, ENC_BIG_ENDIAN); local_offset += 2; proto_tree_add_item(DataDetails_header_tree, hf_infiniband_Trap_SL, tvb, local_offset, 1, ENC_BIG_ENDIAN); local_offset += 1; proto_tree_add_item(DataDetails_header_tree, hf_infiniband_Trap_QP1, tvb, local_offset, 3, ENC_BIG_ENDIAN); local_offset += 3; local_offset += 1; proto_tree_add_item(DataDetails_header_tree, hf_infiniband_Trap_QP2, tvb, local_offset, 3, ENC_BIG_ENDIAN); local_offset += 3; proto_tree_add_item(DataDetails_header_tree, hf_infiniband_Trap_GIDADDR1, tvb, local_offset, 16, ENC_NA); local_offset += 16; proto_tree_add_item(DataDetails_header_tree, hf_infiniband_Trap_GIDADDR2, tvb, local_offset, 16, ENC_NA); local_offset += 16; proto_tree_add_item(DataDetails_header_tree, hf_infiniband_Trap_SWLIDADDR, tvb, local_offset, 2, ENC_NA); local_offset += 2; proto_tree_add_item(DataDetails_header_tree, hf_infiniband_Trap_PORTNO, tvb, local_offset, 1, ENC_BIG_ENDIAN); local_offset += 1; break; default: proto_item_set_text(DataDetails_header_item, "%s", "Vendor Specific Subnet Management Trap"); local_offset += 54; break; } return local_offset; } /* Parse NoticesAndTraps Attribute * IN: parentTree - The tree to add the dissection to * tvb - The tvbbuff of packet data * offset - The offset in TVB where the attribute begins * MadHeader - The common MAD header of the current SMP/SMA */ static void parse_NoticesAndTraps(proto_tree* parentTree, tvbuff_t* tvb, gint *offset) { gint local_offset = *offset; proto_item *NoticesAndTraps_header_item; proto_tree *NoticesAndTraps_header_tree; guint16 trapNumber = tvb_get_ntohs(tvb, local_offset + 4); if (!parentTree) return; NoticesAndTraps_header_item = proto_tree_add_item(parentTree, hf_infiniband_smp_data, tvb, local_offset, 64, ENC_NA); proto_item_set_text(NoticesAndTraps_header_item, "%s", val_to_str(trapNumber, Trap_Description, "Unknown or Vendor Specific Trap Number! (0x%02x)")); NoticesAndTraps_header_tree = proto_item_add_subtree(NoticesAndTraps_header_item, ett_noticestraps); proto_tree_add_item(NoticesAndTraps_header_tree, hf_infiniband_Notice_IsGeneric, tvb, local_offset, 1, ENC_BIG_ENDIAN); proto_tree_add_item(NoticesAndTraps_header_tree, hf_infiniband_Notice_Type, tvb, local_offset, 1, ENC_BIG_ENDIAN); local_offset += 1; proto_tree_add_item(NoticesAndTraps_header_tree, hf_infiniband_Notice_ProducerTypeVendorID, tvb, local_offset, 3, ENC_BIG_ENDIAN); local_offset += 3; proto_tree_add_item(NoticesAndTraps_header_tree, hf_infiniband_Notice_TrapNumberDeviceID, tvb, local_offset, 2, ENC_BIG_ENDIAN); local_offset += 2; proto_tree_add_item(NoticesAndTraps_header_tree, hf_infiniband_Notice_IssuerLID, tvb, local_offset, 2, ENC_BIG_ENDIAN); local_offset += 2; proto_tree_add_item(NoticesAndTraps_header_tree, hf_infiniband_Notice_NoticeToggle, tvb, local_offset, 1, ENC_BIG_ENDIAN); proto_tree_add_item(NoticesAndTraps_header_tree, hf_infiniband_Notice_NoticeCount, tvb, local_offset, 2, ENC_BIG_ENDIAN); local_offset += 2; parse_NoticeDataDetails(NoticesAndTraps_header_tree, tvb, &local_offset, trapNumber); proto_tree_add_item(NoticesAndTraps_header_tree, hf_infiniband_Notice_DataDetails, tvb, local_offset, 54, ENC_NA); local_offset += 54; #if 0 /* Only Defined For GMPs not SMPs which is not part of this dissector phase */ *proto_tree_add_item(NoticesAndTraps_header_tree, hf_infiniband_Notice_IssuerGID, tvb, local_offset, 16, ENC_NA); local_offset += 16; *proto_tree_add_item(NoticesAndTraps_header_tree, hf_infiniband_Notice_ClassTrapSpecificData, tvb, local_offset, 1, ENC_NA); local_offset += 1; #endif } /* Parse NodeDescription Attribute * IN: parentTree - The tree to add the dissection to * tvb - The tvbbuff of packet data * offset - The offset in TVB where the attribute begins * MadHeader - The common MAD header of the current SMP/SMA */ static void parse_NodeDescription(proto_tree* parentTree, tvbuff_t* tvb, gint *offset) { gint local_offset = *offset; proto_tree *NodeDescription_header_tree; if (!parentTree) return; NodeDescription_header_tree = parentTree; proto_tree_add_item(NodeDescription_header_tree, hf_infiniband_NodeDescription_NodeString, tvb, local_offset, 64, ENC_ASCII|ENC_NA); } /* Parse NodeInfo Attribute * IN: parentTree - The tree to add the dissection to * tvb - The tvbbuff of packet data * offset - The offset in TVB where the attribute begins * MadHeader - The common MAD header of the current SMP/SMA */ static int parse_NodeInfo(proto_tree* parentTree, tvbuff_t* tvb, gint *offset) { gint local_offset = *offset; proto_tree *NodeInfo_header_tree; if (!parentTree) return *offset; NodeInfo_header_tree = parentTree; proto_tree_add_item(NodeInfo_header_tree, hf_infiniband_NodeInfo_BaseVersion, tvb, local_offset, 1, ENC_BIG_ENDIAN); local_offset += 1; proto_tree_add_item(NodeInfo_header_tree, hf_infiniband_NodeInfo_ClassVersion, tvb, local_offset, 1, ENC_BIG_ENDIAN); local_offset += 1; proto_tree_add_item(NodeInfo_header_tree, hf_infiniband_NodeInfo_NodeType, tvb, local_offset, 1, ENC_BIG_ENDIAN); local_offset += 1; proto_tree_add_item(NodeInfo_header_tree, hf_infiniband_NodeInfo_NumPorts, tvb, local_offset, 1, ENC_BIG_ENDIAN); local_offset += 1; proto_tree_add_item(NodeInfo_header_tree, hf_infiniband_NodeInfo_SystemImageGUID, tvb, local_offset, 8, ENC_BIG_ENDIAN); local_offset += 8; proto_tree_add_item(NodeInfo_header_tree, hf_infiniband_NodeInfo_NodeGUID, tvb, local_offset, 8, ENC_BIG_ENDIAN); local_offset += 8; proto_tree_add_item(NodeInfo_header_tree, hf_infiniband_NodeInfo_PortGUID, tvb, local_offset, 8, ENC_BIG_ENDIAN); local_offset += 8; proto_tree_add_item(NodeInfo_header_tree, hf_infiniband_NodeInfo_PartitionCap, tvb, local_offset, 2, ENC_BIG_ENDIAN); local_offset += 2; proto_tree_add_item(NodeInfo_header_tree, hf_infiniband_NodeInfo_DeviceID, tvb, local_offset, 2, ENC_BIG_ENDIAN); local_offset += 2; proto_tree_add_item(NodeInfo_header_tree, hf_infiniband_NodeInfo_Revision, tvb, local_offset, 4, ENC_BIG_ENDIAN); local_offset += 4; proto_tree_add_item(NodeInfo_header_tree, hf_infiniband_NodeInfo_LocalPortNum, tvb, local_offset, 1, ENC_BIG_ENDIAN); local_offset += 1; proto_tree_add_item(NodeInfo_header_tree, hf_infiniband_NodeInfo_VendorID, tvb, local_offset, 3, ENC_BIG_ENDIAN); local_offset += 3; return local_offset; } /* Parse SwitchInfo Attribute * IN: parentTree - The tree to add the dissection to * tvb - The tvbbuff of packet data * offset - The offset in TVB where the attribute begins * MadHeader - The common MAD header of the current SMP/SMA */ static int parse_SwitchInfo(proto_tree* parentTree, tvbuff_t* tvb, gint *offset) { gint local_offset = *offset; proto_tree *SwitchInfo_header_tree; if (!parentTree) return *offset; SwitchInfo_header_tree = parentTree; proto_tree_add_item(SwitchInfo_header_tree, hf_infiniband_SwitchInfo_LinearFDBCap, tvb, local_offset, 2, ENC_BIG_ENDIAN); local_offset += 2; proto_tree_add_item(SwitchInfo_header_tree, hf_infiniband_SwitchInfo_RandomFDBCap, tvb, local_offset, 2, ENC_BIG_ENDIAN); local_offset += 2; proto_tree_add_item(SwitchInfo_header_tree, hf_infiniband_SwitchInfo_MulticastFDBCap, tvb, local_offset, 2, ENC_BIG_ENDIAN); local_offset += 2; proto_tree_add_item(SwitchInfo_header_tree, hf_infiniband_SwitchInfo_LinearFDBTop, tvb, local_offset, 2, ENC_BIG_ENDIAN); local_offset += 2; proto_tree_add_item(SwitchInfo_header_tree, hf_infiniband_SwitchInfo_DefaultPort, tvb, local_offset, 1, ENC_BIG_ENDIAN); local_offset += 1; proto_tree_add_item(SwitchInfo_header_tree, hf_infiniband_SwitchInfo_DefaultMulticastPrimaryPort, tvb, local_offset, 1, ENC_BIG_ENDIAN); local_offset += 1; proto_tree_add_item(SwitchInfo_header_tree, hf_infiniband_SwitchInfo_DefaultMulticastNotPrimaryPort, tvb, local_offset, 1, ENC_BIG_ENDIAN); local_offset += 1; proto_tree_add_item(SwitchInfo_header_tree, hf_infiniband_SwitchInfo_LifeTimeValue, tvb, local_offset, 1, ENC_BIG_ENDIAN); proto_tree_add_item(SwitchInfo_header_tree, hf_infiniband_SwitchInfo_PortStateChange, tvb, local_offset, 1, ENC_BIG_ENDIAN); proto_tree_add_item(SwitchInfo_header_tree, hf_infiniband_SwitchInfo_OptimizedSLtoVLMappingProgramming, tvb, local_offset, 1, ENC_BIG_ENDIAN); local_offset += 1; proto_tree_add_item(SwitchInfo_header_tree, hf_infiniband_SwitchInfo_LIDsPerPort, tvb, local_offset, 2, ENC_BIG_ENDIAN); local_offset += 2; proto_tree_add_item(SwitchInfo_header_tree, hf_infiniband_SwitchInfo_PartitionEnforcementCap, tvb, local_offset, 2, ENC_BIG_ENDIAN); local_offset += 2; proto_tree_add_item(SwitchInfo_header_tree, hf_infiniband_SwitchInfo_InboundEnforcementCap, tvb, local_offset, 1, ENC_BIG_ENDIAN); proto_tree_add_item(SwitchInfo_header_tree, hf_infiniband_SwitchInfo_OutboundEnforcementCap, tvb, local_offset, 1, ENC_BIG_ENDIAN); proto_tree_add_item(SwitchInfo_header_tree, hf_infiniband_SwitchInfo_FilterRawInboundCap, tvb, local_offset, 1, ENC_BIG_ENDIAN); proto_tree_add_item(SwitchInfo_header_tree, hf_infiniband_SwitchInfo_FilterRawOutboundCap, tvb, local_offset, 1, ENC_BIG_ENDIAN); proto_tree_add_item(SwitchInfo_header_tree, hf_infiniband_SwitchInfo_EnhancedPortZero, tvb, local_offset, 1, ENC_BIG_ENDIAN); local_offset += 1; return local_offset; } /* Parse GUIDInfo Attribute * IN: parentTree - The tree to add the dissection to * tvb - The tvbbuff of packet data * offset - The offset in TVB where the attribute begins * MadHeader - The common MAD header of the current SMP/SMA */ static int parse_GUIDInfo(proto_tree* parentTree, tvbuff_t* tvb, gint *offset) { gint local_offset = *offset; proto_tree *GUIDInfo_header_tree; proto_item *tempItemLow; gint i; if (!parentTree) return *offset; GUIDInfo_header_tree = parentTree; for (i = 0; i < 8; i++) { tempItemLow = proto_tree_add_item(GUIDInfo_header_tree, hf_infiniband_GUIDInfo_GUID, tvb, local_offset, 8, ENC_BIG_ENDIAN); local_offset += 8; proto_item_append_text(tempItemLow, "(%u)", i); } return local_offset; } /* Parse PortInfo Attribute * IN: parentTree - The tree to add the dissection to * tvb - The tvbbuff of packet data * offset - The offset in TVB where the attribute begins * MadHeader - The common MAD header of the current SMP/SMA */ static int parse_PortInfo(proto_tree* parentTree, tvbuff_t* tvb, gint *offset) { gint local_offset = *offset; proto_tree *PortInfo_header_tree; proto_item *PortInfo_CapabilityMask_item; proto_tree *PortInfo_CapabilityMask_tree; proto_item *temp_item; guint16 temp_val; if (!parentTree) return *offset; PortInfo_header_tree = parentTree; proto_tree_add_item(PortInfo_header_tree, hf_infiniband_PortInfo_M_Key, tvb, local_offset, 8, ENC_BIG_ENDIAN); local_offset += 8; proto_tree_add_item(PortInfo_header_tree, hf_infiniband_PortInfo_GidPrefix, tvb, local_offset, 8, ENC_BIG_ENDIAN); local_offset += 8; proto_tree_add_item(PortInfo_header_tree, hf_infiniband_PortInfo_LID, tvb, local_offset, 2, ENC_BIG_ENDIAN); local_offset += 2; proto_tree_add_item(PortInfo_header_tree, hf_infiniband_PortInfo_MasterSMLID, tvb, local_offset, 2, ENC_BIG_ENDIAN); local_offset += 2; /* Capability Mask Flags */ PortInfo_CapabilityMask_item = proto_tree_add_item(PortInfo_header_tree, hf_infiniband_PortInfo_CapabilityMask, tvb, local_offset, 4, ENC_BIG_ENDIAN); PortInfo_CapabilityMask_tree = proto_item_add_subtree(PortInfo_CapabilityMask_item, ett_portinfo_capmask); proto_tree_add_item(PortInfo_CapabilityMask_tree, hf_infiniband_PortInfo_CapabilityMask_SM, tvb, local_offset, 4, ENC_BIG_ENDIAN); proto_tree_add_item(PortInfo_CapabilityMask_tree, hf_infiniband_PortInfo_CapabilityMask_NoticeSupported, tvb, local_offset, 4, ENC_BIG_ENDIAN); proto_tree_add_item(PortInfo_CapabilityMask_tree, hf_infiniband_PortInfo_CapabilityMask_TrapSupported, tvb, local_offset, 4, ENC_BIG_ENDIAN); proto_tree_add_item(PortInfo_CapabilityMask_tree, hf_infiniband_PortInfo_CapabilityMask_OptionalPDSupported, tvb, local_offset, 4, ENC_BIG_ENDIAN); proto_tree_add_item(PortInfo_CapabilityMask_tree, hf_infiniband_PortInfo_CapabilityMask_AutomaticMigrationSupported, tvb, local_offset, 4, ENC_BIG_ENDIAN); proto_tree_add_item(PortInfo_CapabilityMask_tree, hf_infiniband_PortInfo_CapabilityMask_SLMappingSupported, tvb, local_offset, 4, ENC_BIG_ENDIAN); proto_tree_add_item(PortInfo_CapabilityMask_tree, hf_infiniband_PortInfo_CapabilityMask_MKeyNVRAM, tvb, local_offset, 4, ENC_BIG_ENDIAN); proto_tree_add_item(PortInfo_CapabilityMask_tree, hf_infiniband_PortInfo_CapabilityMask_PKeyNVRAM, tvb, local_offset, 4, ENC_BIG_ENDIAN); proto_tree_add_item(PortInfo_CapabilityMask_tree, hf_infiniband_PortInfo_CapabilityMask_LEDInfoSupported, tvb, local_offset, 4, ENC_BIG_ENDIAN); proto_tree_add_item(PortInfo_CapabilityMask_tree, hf_infiniband_PortInfo_CapabilityMask_SMdisabled, tvb, local_offset, 4, ENC_BIG_ENDIAN); proto_tree_add_item(PortInfo_CapabilityMask_tree, hf_infiniband_PortInfo_CapabilityMask_SystemImageGUIDSupported, tvb, local_offset, 4, ENC_BIG_ENDIAN); proto_tree_add_item(PortInfo_CapabilityMask_tree, hf_infiniband_PortInfo_CapabilityMask_PKeySwitchExternalPortTrapSupported, tvb, local_offset, 4, ENC_BIG_ENDIAN); proto_tree_add_item(PortInfo_CapabilityMask_tree, hf_infiniband_PortInfo_CapabilityMask_CommunicationsManagementSupported, tvb, local_offset, 4, ENC_BIG_ENDIAN); proto_tree_add_item(PortInfo_CapabilityMask_tree, hf_infiniband_PortInfo_CapabilityMask_SNMPTunnelingSupported, tvb, local_offset, 4, ENC_BIG_ENDIAN); proto_tree_add_item(PortInfo_CapabilityMask_tree, hf_infiniband_PortInfo_CapabilityMask_ReinitSupported, tvb, local_offset, 4, ENC_BIG_ENDIAN); proto_tree_add_item(PortInfo_CapabilityMask_tree, hf_infiniband_PortInfo_CapabilityMask_DeviceManagementSupported, tvb, local_offset, 4, ENC_BIG_ENDIAN); proto_tree_add_item(PortInfo_CapabilityMask_tree, hf_infiniband_PortInfo_CapabilityMask_VendorClassSupported, tvb, local_offset, 4, ENC_BIG_ENDIAN); proto_tree_add_item(PortInfo_CapabilityMask_tree, hf_infiniband_PortInfo_CapabilityMask_DRNoticeSupported, tvb, local_offset, 4, ENC_BIG_ENDIAN); proto_tree_add_item(PortInfo_CapabilityMask_tree, hf_infiniband_PortInfo_CapabilityMask_CapabilityMaskNoticeSupported, tvb, local_offset, 4, ENC_BIG_ENDIAN); proto_tree_add_item(PortInfo_CapabilityMask_tree, hf_infiniband_PortInfo_CapabilityMask_BootManagementSupported, tvb, local_offset, 4, ENC_BIG_ENDIAN); proto_tree_add_item(PortInfo_CapabilityMask_tree, hf_infiniband_PortInfo_CapabilityMask_LinkRoundTripLatencySupported, tvb, local_offset, 4, ENC_BIG_ENDIAN); proto_tree_add_item(PortInfo_CapabilityMask_tree, hf_infiniband_PortInfo_CapabilityMask_ClientRegistrationSupported, tvb, local_offset, 4, ENC_BIG_ENDIAN); proto_tree_add_item(PortInfo_CapabilityMask_tree, hf_infiniband_PortInfo_CapabilityMask_OtherLocalChangesNoticeSupported, tvb, local_offset, 4, ENC_BIG_ENDIAN); proto_tree_add_item(PortInfo_CapabilityMask_tree, hf_infiniband_PortInfo_CapabilityMask_LinkSpeedWIdthPairsTableSupported, tvb, local_offset, 4, ENC_BIG_ENDIAN); local_offset += 4; /* End Capability Mask Flags */ /* Diag Code */ temp_item = proto_tree_add_item(PortInfo_header_tree, hf_infiniband_PortInfo_DiagCode, tvb, local_offset, 2, ENC_BIG_ENDIAN); temp_val = tvb_get_ntohs(tvb, local_offset); proto_item_append_text(temp_item, ", %s", val_to_str_const(temp_val, DiagCode, "Reserved DiagCode! Possible Error")); local_offset += 2; /* End Diag Code */ proto_tree_add_item(PortInfo_header_tree, hf_infiniband_PortInfo_M_KeyLeasePeriod, tvb, local_offset, 2, ENC_BIG_ENDIAN); local_offset += 2; proto_tree_add_item(PortInfo_header_tree, hf_infiniband_PortInfo_LocalPortNum, tvb, local_offset, 1, ENC_BIG_ENDIAN); local_offset += 1; /* LinkWidthEnabled */ temp_item = proto_tree_add_item(PortInfo_header_tree, hf_infiniband_PortInfo_LinkWidthEnabled, tvb, local_offset, 1, ENC_BIG_ENDIAN); temp_val = (guint16)tvb_get_guint8(tvb, local_offset); proto_item_append_text(temp_item, ", %s", val_to_str_const(temp_val, LinkWidthEnabled, "Reserved LinkWidthEnabled Value! Possible Error")); local_offset += 1; /* End LinkWidthEnabled */ /* LinkWidthSupported */ temp_item = proto_tree_add_item(PortInfo_header_tree, hf_infiniband_PortInfo_LinkWidthSupported, tvb, local_offset, 1, ENC_BIG_ENDIAN); temp_val = (guint16)tvb_get_guint8(tvb, local_offset); proto_item_append_text(temp_item, ", %s", val_to_str_const(temp_val, LinkWidthSupported, "Reserved LinkWidthSupported Value! Possible Error")); local_offset += 1; /* End LinkWidthSupported */ /* LinkWidthActive */ temp_item = proto_tree_add_item(PortInfo_header_tree, hf_infiniband_PortInfo_LinkWidthActive, tvb, local_offset, 1, ENC_BIG_ENDIAN); temp_val = (guint16)tvb_get_guint8(tvb, local_offset); proto_item_append_text(temp_item, ", %s", val_to_str_const(temp_val, LinkWidthActive, "Reserved LinkWidthActive Value! Possible Error")); local_offset += 1; /* End LinkWidthActive */ /* LinkSpeedSupported */ temp_item = proto_tree_add_item(PortInfo_header_tree, hf_infiniband_PortInfo_LinkSpeedSupported, tvb, local_offset, 1, ENC_BIG_ENDIAN); temp_val = (guint16)tvb_get_guint8(tvb, local_offset); /* 4 bit values = mask and shift */ temp_val = temp_val & 0x00F0; temp_val = temp_val >> 4; proto_item_append_text(temp_item, ", %s", val_to_str_const(temp_val, LinkSpeedSupported, "Reserved LinkWidthSupported Value! Possible Error")); /* End LinkSpeedSupported */ /* PortState */ temp_item = proto_tree_add_item(PortInfo_header_tree, hf_infiniband_PortInfo_PortState, tvb, local_offset, 1, ENC_BIG_ENDIAN); temp_val = (guint16)tvb_get_guint8(tvb, local_offset); /* 4 bit values = mask and shift */ temp_val = temp_val & 0x000F; /*temp_val = temp_val >> 4 */ proto_item_append_text(temp_item, ", %s", val_to_str_const(temp_val, PortState, "Reserved PortState Value! Possible Error")); local_offset += 1; /* End PortState */ /* PortPhysicalState */ temp_item = proto_tree_add_item(PortInfo_header_tree, hf_infiniband_PortInfo_PortPhysicalState, tvb, local_offset, 1, ENC_BIG_ENDIAN); temp_val = (guint16)tvb_get_guint8(tvb, local_offset); /* 4 bit values = mask and shift */ temp_val = temp_val & 0x00F0; temp_val = temp_val >> 4; proto_item_append_text(temp_item, ", %s", val_to_str_const(temp_val, PortPhysicalState, "Reserved PortPhysicalState Value! Possible Error")); /* End PortPhysicalState */ /* LinkDownDefaultState */ temp_item = proto_tree_add_item(PortInfo_header_tree, hf_infiniband_PortInfo_LinkDownDefaultState, tvb, local_offset, 1, ENC_BIG_ENDIAN); temp_val = (guint16)tvb_get_guint8(tvb, local_offset); /* 4 bit values = mask and shift */ temp_val = temp_val & 0x000F; /*temp_val = temp_val >> 4 */ proto_item_append_text(temp_item, ", %s", val_to_str_const(temp_val, LinkDownDefaultState, "Reserved LinkDownDefaultState Value! Possible Error")); local_offset += 1; /* End LinkDownDefaultState */ proto_tree_add_item(PortInfo_header_tree, hf_infiniband_PortInfo_M_KeyProtectBits, tvb, local_offset, 1, ENC_BIG_ENDIAN); proto_tree_add_item(PortInfo_header_tree, hf_infiniband_PortInfo_LMC, tvb, local_offset, 1, ENC_BIG_ENDIAN); local_offset += 1; /* LinkSpeedActive */ temp_item = proto_tree_add_item(PortInfo_header_tree, hf_infiniband_PortInfo_LinkSpeedActive, tvb, local_offset, 1, ENC_BIG_ENDIAN); temp_val = (guint16)tvb_get_guint8(tvb, local_offset); /* 4 bit values = mask and shift */ temp_val = temp_val & 0x00F0; temp_val = temp_val >> 4; proto_item_append_text(temp_item, ", %s", val_to_str_const(temp_val, LinkSpeedActive, "Reserved LinkSpeedActive Value! Possible Error")); /* End LinkSpeedActive */ /* LinkSpeedEnabled */ temp_item = proto_tree_add_item(PortInfo_header_tree, hf_infiniband_PortInfo_LinkSpeedEnabled, tvb, local_offset, 1, ENC_BIG_ENDIAN); temp_val = (guint16)tvb_get_guint8(tvb, local_offset); /* 4 bit values = mask and shift */ temp_val = temp_val & 0x000F; /*temp_val = temp_val >> 4 */ proto_item_append_text(temp_item, ", %s", val_to_str_const(temp_val, LinkSpeedEnabled, "Reserved LinkSpeedEnabled Value! Possible Error")); local_offset += 1; /* End LinkSpeedEnabled */ /* NeighborMTU */ temp_item = proto_tree_add_item(PortInfo_header_tree, hf_infiniband_PortInfo_NeighborMTU, tvb, local_offset, 1, ENC_BIG_ENDIAN); temp_val = (guint16)tvb_get_guint8(tvb, local_offset); /* 4 bit values = mask and shift */ temp_val = temp_val & 0x00F0; temp_val = temp_val >> 4; proto_item_append_text(temp_item, ", %s", val_to_str_const(temp_val, NeighborMTU, "Reserved NeighborMTU Value! Possible Error")); /* End NeighborMTU */ proto_tree_add_item(PortInfo_header_tree, hf_infiniband_PortInfo_MasterSMSL, tvb, local_offset, 1, ENC_BIG_ENDIAN); local_offset += 1; /* VLCap */ temp_item = proto_tree_add_item(PortInfo_header_tree, hf_infiniband_PortInfo_VLCap, tvb, local_offset, 1, ENC_BIG_ENDIAN); temp_val = (guint16)tvb_get_guint8(tvb, local_offset); /* 4 bit values = mask and shift */ temp_val = temp_val & 0x00F0; temp_val = temp_val >> 4; proto_item_append_text(temp_item, ", %s", val_to_str_const(temp_val, VLCap, "Reserved VLCap Value! Possible Error")); /* End VLCap */ proto_tree_add_item(PortInfo_header_tree, hf_infiniband_PortInfo_InitType, tvb, local_offset, 1, ENC_BIG_ENDIAN); local_offset += 1; proto_tree_add_item(PortInfo_header_tree, hf_infiniband_PortInfo_VLHighLimit, tvb, local_offset, 1, ENC_BIG_ENDIAN); local_offset += 1; proto_tree_add_item(PortInfo_header_tree, hf_infiniband_PortInfo_VLArbitrationHighCap, tvb, local_offset, 1, ENC_BIG_ENDIAN); local_offset += 1; proto_tree_add_item(PortInfo_header_tree, hf_infiniband_PortInfo_VLArbitrationLowCap, tvb, local_offset, 1, ENC_BIG_ENDIAN); local_offset += 1; proto_tree_add_item(PortInfo_header_tree, hf_infiniband_PortInfo_InitTypeReply, tvb, local_offset, 1, ENC_BIG_ENDIAN); /* MTUCap */ temp_item = proto_tree_add_item(PortInfo_header_tree, hf_infiniband_PortInfo_MTUCap, tvb, local_offset, 1, ENC_BIG_ENDIAN); temp_val = (guint16)tvb_get_guint8(tvb, local_offset); /* 4 bit values = mask and shift */ temp_val = temp_val & 0x000F; /*temp_val = temp_val >> 4 */ proto_item_append_text(temp_item, ", %s", val_to_str_const(temp_val, MTUCap, "Reserved MTUCap Value! Possible Error")); local_offset += 1; /* End MTUCap */ proto_tree_add_item(PortInfo_header_tree, hf_infiniband_PortInfo_VLStallCount, tvb, local_offset, 1, ENC_BIG_ENDIAN); proto_tree_add_item(PortInfo_header_tree, hf_infiniband_PortInfo_HOQLife, tvb, local_offset, 1, ENC_BIG_ENDIAN); local_offset += 1; /* OperationalVLs */ temp_item = proto_tree_add_item(PortInfo_header_tree, hf_infiniband_PortInfo_OperationalVLs, tvb, local_offset, 1, ENC_BIG_ENDIAN); temp_val = (guint16)tvb_get_guint8(tvb, local_offset); /* 4 bit values = mask and shift */ temp_val = temp_val & 0x00F0; temp_val = temp_val >> 4; proto_item_append_text(temp_item, ", %s", val_to_str_const(temp_val, OperationalVLs, "Reserved OperationalVLs Value! Possible Error")); /* End OperationalVLs */ proto_tree_add_item(PortInfo_header_tree, hf_infiniband_PortInfo_PartitionEnforcementInbound, tvb, local_offset, 1, ENC_BIG_ENDIAN); proto_tree_add_item(PortInfo_header_tree, hf_infiniband_PortInfo_PartitionEnforcementOutbound, tvb, local_offset, 1, ENC_BIG_ENDIAN); proto_tree_add_item(PortInfo_header_tree, hf_infiniband_PortInfo_FilterRawInbound, tvb, local_offset, 1, ENC_BIG_ENDIAN); proto_tree_add_item(PortInfo_header_tree, hf_infiniband_PortInfo_FilterRawOutbound, tvb, local_offset, 1, ENC_BIG_ENDIAN); local_offset += 1; proto_tree_add_item(PortInfo_header_tree, hf_infiniband_PortInfo_M_KeyViolations, tvb, local_offset, 2, ENC_BIG_ENDIAN); local_offset += 2; proto_tree_add_item(PortInfo_header_tree, hf_infiniband_PortInfo_P_KeyViolations, tvb, local_offset, 2, ENC_BIG_ENDIAN); local_offset += 2; proto_tree_add_item(PortInfo_header_tree, hf_infiniband_PortInfo_Q_KeyViolations, tvb, local_offset, 2, ENC_BIG_ENDIAN); local_offset += 2; proto_tree_add_item(PortInfo_header_tree, hf_infiniband_PortInfo_GUIDCap, tvb, local_offset, 1, ENC_BIG_ENDIAN); local_offset += 1; proto_tree_add_item(PortInfo_header_tree, hf_infiniband_PortInfo_ClientReregister, tvb, local_offset, 1, ENC_BIG_ENDIAN); proto_tree_add_item(PortInfo_header_tree, hf_infiniband_PortInfo_SubnetTimeOut, tvb, local_offset, 1, ENC_BIG_ENDIAN); local_offset += 1; proto_tree_add_item(PortInfo_header_tree, hf_infiniband_PortInfo_RespTimeValue, tvb, local_offset, 1, ENC_BIG_ENDIAN); local_offset += 1; proto_tree_add_item(PortInfo_header_tree, hf_infiniband_PortInfo_LocalPhyErrors, tvb, local_offset, 1, ENC_BIG_ENDIAN); proto_tree_add_item(PortInfo_header_tree, hf_infiniband_PortInfo_OverrunErrors, tvb, local_offset, 1, ENC_BIG_ENDIAN); local_offset += 1; proto_tree_add_item(PortInfo_header_tree, hf_infiniband_PortInfo_MaxCreditHint, tvb, local_offset, 2, ENC_BIG_ENDIAN); local_offset += 3; /* 2 + 1 Reserved */ proto_tree_add_item(PortInfo_header_tree, hf_infiniband_PortInfo_LinkRoundTripLatency, tvb, local_offset, 3, ENC_BIG_ENDIAN); local_offset += 3; return local_offset; } /* Parse P_KeyTable Attribute * IN: parentTree - The tree to add the dissection to * tvb - The tvbbuff of packet data * offset - The offset in TVB where the attribute begins * MadHeader - The common MAD header of the current SMP/SMA */ static void parse_P_KeyTable(proto_tree* parentTree, tvbuff_t* tvb, gint *offset) { gint local_offset = *offset; gint i; proto_item *P_KeyTable_header_item; proto_tree *P_KeyTable_header_tree; proto_item *tempItemLow; proto_item *tempItemHigh; if (!parentTree) return; P_KeyTable_header_item = proto_tree_add_item(parentTree, hf_infiniband_P_KeyTable_P_KeyTableBlock, tvb, local_offset, 64, ENC_NA); proto_item_set_text(P_KeyTable_header_item, "%s", "P_KeyTable"); P_KeyTable_header_tree = proto_item_add_subtree(P_KeyTable_header_item, ett_pkeytable); for (i = 0; i < 32; i++) { tempItemLow = proto_tree_add_item(P_KeyTable_header_tree, hf_infiniband_P_KeyTable_MembershipType, tvb, local_offset, 1, ENC_BIG_ENDIAN); tempItemHigh = proto_tree_add_item(P_KeyTable_header_tree, hf_infiniband_P_KeyTable_P_KeyBase, tvb, local_offset, 2, ENC_BIG_ENDIAN); local_offset += 2; proto_item_append_text(tempItemLow, "(%u)", i); proto_item_append_text(tempItemHigh, "(%u)", i+1); } } /* Parse SLtoVLMappingTable Attribute * IN: parentTree - The tree to add the dissection to * tvb - The tvbbuff of packet data * offset - The offset in TVB where the attribute begins * MadHeader - The common MAD header of the current SMP/SMA */ static void parse_SLtoVLMappingTable(proto_tree* parentTree, tvbuff_t* tvb, gint *offset) { gint local_offset = *offset; proto_item *SLtoVLMappingTable_header_item; proto_tree *SLtoVLMappingTable_header_tree; proto_item *tempItemLow; proto_item *tempItemHigh; gint i; if (!parentTree) return; SLtoVLMappingTable_header_item = proto_tree_add_item(parentTree, hf_infiniband_smp_data, tvb, local_offset, 64, ENC_NA); proto_item_set_text(SLtoVLMappingTable_header_item, "%s", "SLtoVLMappingTable"); SLtoVLMappingTable_header_tree = proto_item_add_subtree(SLtoVLMappingTable_header_item, ett_sltovlmapping); for (i = 0; i < 8; i++) { tempItemLow = proto_tree_add_item(SLtoVLMappingTable_header_tree, hf_infiniband_SLtoVLMappingTable_SLtoVL_HighBits, tvb, local_offset, 1, ENC_BIG_ENDIAN); tempItemHigh = proto_tree_add_item(SLtoVLMappingTable_header_tree, hf_infiniband_SLtoVLMappingTable_SLtoVL_LowBits, tvb, local_offset, 1, ENC_BIG_ENDIAN); local_offset += 1; proto_item_append_text(tempItemLow, "(%u)", i); proto_item_append_text(tempItemHigh, "(%u)", i+1); } } /* Parse VLArbitrationTable Attribute * IN: parentTree - The tree to add the dissection to * tvb - The tvbbuff of packet data * offset - The offset in TVB where the attribute begins * MadHeader - The common MAD header of the current SMP/SMA */ static void parse_VLArbitrationTable(proto_tree* parentTree, tvbuff_t* tvb, gint *offset) { gint local_offset = *offset; gint i; proto_item *VLArbitrationTable_header_item; proto_tree *VLArbitrationTable_header_tree; proto_item *tempItemLow; proto_item *tempItemHigh; if (!parentTree) return; VLArbitrationTable_header_item = proto_tree_add_item(parentTree, hf_infiniband_smp_data, tvb, local_offset, 64, ENC_NA); proto_item_set_text(VLArbitrationTable_header_item, "%s", "VLArbitrationTable"); VLArbitrationTable_header_tree = proto_item_add_subtree(VLArbitrationTable_header_item, ett_vlarbitrationtable); for (i = 0; i < 32; i++) { tempItemLow = proto_tree_add_item(VLArbitrationTable_header_tree, hf_infiniband_VLArbitrationTable_VL, tvb, local_offset, 1, ENC_BIG_ENDIAN); local_offset += 1; tempItemHigh = proto_tree_add_item(VLArbitrationTable_header_tree, hf_infiniband_VLArbitrationTable_Weight, tvb, local_offset, 1, ENC_BIG_ENDIAN); local_offset += 1; proto_item_append_text(tempItemLow, "(%u)", i); proto_item_append_text(tempItemHigh, "(%u)", i); } } /* Parse LinearForwardingTable Attribute * IN: parentTree - The tree to add the dissection to * tvb - The tvbbuff of packet data * offset - The offset in TVB where the attribute begins * MadHeader - The common MAD header of the current SMP/SMA */ static void parse_LinearForwardingTable(proto_tree* parentTree, tvbuff_t* tvb, gint *offset) { gint i; gint local_offset = *offset; proto_item *LinearForwardingTable_header_item; proto_tree *LinearForwardingTable_header_tree; proto_item *tempItemLow; if (!parentTree) return; LinearForwardingTable_header_item = proto_tree_add_item(parentTree, hf_infiniband_smp_data, tvb, local_offset, 64, ENC_NA); proto_item_set_text(LinearForwardingTable_header_item, "%s", "LinearForwardingTable"); LinearForwardingTable_header_tree = proto_item_add_subtree(LinearForwardingTable_header_item, ett_linearforwardingtable); for (i = 0; i < 64; i++) { tempItemLow = proto_tree_add_item(LinearForwardingTable_header_tree, hf_infiniband_LinearForwardingTable_Port, tvb, local_offset, 1, ENC_BIG_ENDIAN); local_offset += 1; proto_item_append_text(tempItemLow, "(%u)", i); } } /* Parse RandomForwardingTable Attribute * IN: parentTree - The tree to add the dissection to * tvb - The tvbbuff of packet data * offset - The offset in TVB where the attribute begins * MadHeader - The common MAD header of the current SMP/SMA */ static void parse_RandomForwardingTable(proto_tree* parentTree, tvbuff_t* tvb, gint *offset) { gint i; gint local_offset = *offset; proto_item *RandomForwardingTable_header_item; proto_tree *RandomForwardingTable_header_tree; proto_item *tempItemLow; if (!parentTree) return; RandomForwardingTable_header_item = proto_tree_add_item(parentTree, hf_infiniband_smp_data, tvb, local_offset, 64, ENC_NA); proto_item_set_text(RandomForwardingTable_header_item, "%s", "RandomForwardingTable"); RandomForwardingTable_header_tree = proto_item_add_subtree(RandomForwardingTable_header_item, ett_randomforwardingtable); for (i = 0; i < 16; i++) { tempItemLow = proto_tree_add_item(RandomForwardingTable_header_tree, hf_infiniband_RandomForwardingTable_LID, tvb, local_offset, 2, ENC_BIG_ENDIAN); local_offset += 2; proto_item_append_text(tempItemLow, "(%u)", i); tempItemLow = proto_tree_add_item(RandomForwardingTable_header_tree, hf_infiniband_RandomForwardingTable_Valid, tvb, local_offset, 1, ENC_BIG_ENDIAN); proto_item_append_text(tempItemLow, "(%u)", i); tempItemLow = proto_tree_add_item(RandomForwardingTable_header_tree, hf_infiniband_RandomForwardingTable_LMC, tvb, local_offset, 1, ENC_BIG_ENDIAN); local_offset += 1; proto_item_append_text(tempItemLow, "(%u)", i); tempItemLow = proto_tree_add_item(RandomForwardingTable_header_tree, hf_infiniband_RandomForwardingTable_Port, tvb, local_offset, 1, ENC_BIG_ENDIAN); local_offset += 1; proto_item_append_text(tempItemLow, "(%u)", i); } } /* Parse NoticesAndTraps Attribute * IN: parentTree - The tree to add the dissection to * tvb - The tvbbuff of packet data * offset - The offset in TVB where the attribute begins * MadHeader - The common MAD header of the current SMP/SMA */ static void parse_MulticastForwardingTable(proto_tree* parentTree, tvbuff_t* tvb, gint *offset) { gint i; gint local_offset = *offset; proto_item *MulticastForwardingTable_header_item; proto_tree *MulticastForwardingTable_header_tree; proto_item *tempItemLow; if (!parentTree) return; MulticastForwardingTable_header_item = proto_tree_add_item(parentTree, hf_infiniband_smp_data, tvb, local_offset, 64, ENC_NA); proto_item_set_text(MulticastForwardingTable_header_item, "%s", "MulticastForwardingTable"); MulticastForwardingTable_header_tree = proto_item_add_subtree(MulticastForwardingTable_header_item, ett_multicastforwardingtable); for (i = 0; i < 16; i++) { tempItemLow = proto_tree_add_item(MulticastForwardingTable_header_tree, hf_infiniband_MulticastForwardingTable_PortMask, tvb, local_offset, 2, ENC_BIG_ENDIAN); local_offset += 2; proto_item_append_text(tempItemLow, "(%u)", i); } } /* Parse SMInfo Attribute * IN: parentTree - The tree to add the dissection to * tvb - The tvbbuff of packet data * offset - The offset in TVB where the attribute begins * MadHeader - The common MAD header of the current SMP/SMA */ static int parse_SMInfo(proto_tree* parentTree, tvbuff_t* tvb, gint *offset) { gint local_offset = *offset; proto_item *SMInfo_header_item; proto_tree *SMInfo_header_tree; if (!parentTree) return *offset; SMInfo_header_item = proto_tree_add_item(parentTree, hf_infiniband_smp_data, tvb, local_offset, 64, ENC_NA); proto_item_set_text(SMInfo_header_item, "%s", "SMInfo"); SMInfo_header_tree = proto_item_add_subtree(SMInfo_header_item, ett_sminfo); proto_tree_add_item(SMInfo_header_tree, hf_infiniband_SMInfo_GUID, tvb, local_offset, 8, ENC_BIG_ENDIAN); local_offset += 8; proto_tree_add_item(SMInfo_header_tree, hf_infiniband_SMInfo_SM_Key, tvb, local_offset, 8, ENC_BIG_ENDIAN); local_offset += 8; proto_tree_add_item(SMInfo_header_tree, hf_infiniband_SMInfo_ActCount, tvb, local_offset, 4, ENC_BIG_ENDIAN); local_offset += 4; proto_tree_add_item(SMInfo_header_tree, hf_infiniband_SMInfo_Priority, tvb, local_offset, 1, ENC_BIG_ENDIAN); proto_tree_add_item(SMInfo_header_tree, hf_infiniband_SMInfo_SMState, tvb, local_offset, 1, ENC_BIG_ENDIAN); local_offset += 1; return local_offset; } /* Parse VendorDiag Attribute * IN: parentTree - The tree to add the dissection to * tvb - The tvbbuff of packet data * offset - The offset in TVB where the attribute begins * MadHeader - The common MAD header of the current SMP/SMA */ static int parse_VendorDiag(proto_tree* parentTree, tvbuff_t* tvb, gint *offset) { gint local_offset = *offset; proto_item *VendorDiag_header_item; proto_tree *VendorDiag_header_tree; if (!parentTree) return *offset; VendorDiag_header_item = proto_tree_add_item(parentTree, hf_infiniband_smp_data, tvb, local_offset, 64, ENC_NA); proto_item_set_text(VendorDiag_header_item, "%s", "VendorDiag"); VendorDiag_header_tree = proto_item_add_subtree(VendorDiag_header_item, ett_vendordiag); proto_tree_add_item(VendorDiag_header_tree, hf_infiniband_VendorDiag_NextIndex, tvb, local_offset, 2, ENC_BIG_ENDIAN); local_offset += 2; proto_tree_add_item(VendorDiag_header_tree, hf_infiniband_VendorDiag_DiagData, tvb, local_offset, 62, ENC_NA); local_offset += 62; return local_offset; } /* Parse LedInfo Attribute * IN: parentTree - The tree to add the dissection to * tvb - The tvbbuff of packet data * offset - The offset in TVB where the attribute begins * MadHeader - The common MAD header of the current SMP/SMA */ static void parse_LedInfo(proto_tree* parentTree, tvbuff_t* tvb, gint *offset) { gint local_offset = *offset; proto_item *LedInfo_header_item; proto_tree *LedInfo_header_tree; if (!parentTree) return; LedInfo_header_item = proto_tree_add_item(parentTree, hf_infiniband_smp_data, tvb, local_offset, 64, ENC_NA); proto_item_set_text(LedInfo_header_item, "%s", "LedInfo"); LedInfo_header_tree = proto_item_add_subtree(LedInfo_header_item, ett_ledinfo); proto_tree_add_item(LedInfo_header_tree, hf_infiniband_LedInfo_LedMask, tvb, local_offset, 1, ENC_BIG_ENDIAN); } /* Parse LinkSpeedWidthPairsTable Attribute * IN: parentTree - The tree to add the dissection to * tvb - The tvbbuff of packet data * offset - The offset in TVB where the attribute begins * MadHeader - The common MAD header of the current SMP/SMA */ static int parse_LinkSpeedWidthPairsTable(proto_tree* parentTree, tvbuff_t* tvb, gint *offset) { gint local_offset = *offset; proto_item *LinkSpeedWidthPairsTable_header_item; proto_tree *LinkSpeedWidthPairsTable_header_tree; if (!parentTree) return *offset; LinkSpeedWidthPairsTable_header_item = proto_tree_add_item(parentTree, hf_infiniband_smp_data, tvb, local_offset, 64, ENC_NA); proto_item_set_text(LinkSpeedWidthPairsTable_header_item, "%s", "LinkSpeedWidthPairsTable"); LinkSpeedWidthPairsTable_header_tree = proto_item_add_subtree(LinkSpeedWidthPairsTable_header_item, ett_linkspeedwidthpairs); proto_tree_add_item(LinkSpeedWidthPairsTable_header_tree, hf_infiniband_LinkSpeedWidthPairsTable_NumTables, tvb, local_offset, 1, ENC_BIG_ENDIAN); local_offset += 1; proto_tree_add_item(LinkSpeedWidthPairsTable_header_tree, hf_infiniband_LinkSpeedWidthPairsTable_PortMask, tvb, local_offset, 32, ENC_NA); local_offset += 32; proto_tree_add_item(LinkSpeedWidthPairsTable_header_tree, hf_infiniband_LinkSpeedWidthPairsTable_SpeedTwoFive, tvb, local_offset, 1, ENC_BIG_ENDIAN); local_offset += 1; proto_tree_add_item(LinkSpeedWidthPairsTable_header_tree, hf_infiniband_LinkSpeedWidthPairsTable_SpeedFive, tvb, local_offset, 1, ENC_BIG_ENDIAN); local_offset += 1; proto_tree_add_item(LinkSpeedWidthPairsTable_header_tree, hf_infiniband_LinkSpeedWidthPairsTable_SpeedTen, tvb, local_offset, 1, ENC_BIG_ENDIAN); local_offset += 1; return local_offset; } /* Parse RID Field from Subnet Administraiton Packets. * IN: SA_header_tree - the dissection tree of the subnet admin attribute. * tvb - the packet buffer * MadHeader - the Common MAD header from this packet. * IN/OUT: offset - the current and updated offset in the packet buffer */ static void parse_RID(proto_tree* SA_header_tree, tvbuff_t* tvb, gint *offset, MAD_Data* MadHeader) { gint local_offset = *offset; if (!SA_header_tree) { return; } switch (MadHeader->attributeID) { case 0x0011: /* NodeRecord */ proto_tree_add_item(SA_header_tree, hf_infiniband_SA_LID, tvb, local_offset, 2, ENC_BIG_ENDIAN); local_offset += 2; local_offset += 2; /* Reserved bits */ break; case 0x0012: /* PortInfoRecord */ proto_tree_add_item(SA_header_tree, hf_infiniband_SA_EndportLID, tvb, local_offset, 2, ENC_BIG_ENDIAN); local_offset += 2; proto_tree_add_item(SA_header_tree, hf_infiniband_SA_PortNum, tvb, local_offset, 1, ENC_BIG_ENDIAN); local_offset += 1; local_offset += 1; /* Reserved bits */ break; case 0x0013: /* SLtoVLMappingTableRecord */ proto_tree_add_item(SA_header_tree, hf_infiniband_SA_LID, tvb, local_offset, 2, ENC_BIG_ENDIAN); local_offset += 2; proto_tree_add_item(SA_header_tree, hf_infiniband_SA_InputPortNum, tvb, local_offset, 1, ENC_BIG_ENDIAN); local_offset += 1; proto_tree_add_item(SA_header_tree, hf_infiniband_SA_OutputPortNum, tvb, local_offset, 1, ENC_BIG_ENDIAN); local_offset += 1; local_offset += 4; /* Reserved bits */ break; case 0x0014: /* SwitchInfoRecord */ proto_tree_add_item(SA_header_tree, hf_infiniband_SA_LID, tvb, local_offset, 2, ENC_BIG_ENDIAN); local_offset += 2; local_offset += 2; /* Reserved bits */ break; case 0x0015: /* LinearForwardingTableRecord */ proto_tree_add_item(SA_header_tree, hf_infiniband_SA_LID, tvb, local_offset, 2, ENC_BIG_ENDIAN); local_offset += 2; proto_tree_add_item(SA_header_tree, hf_infiniband_SA_BlockNum_SixteenBit, tvb, local_offset, 2, ENC_BIG_ENDIAN); local_offset += 2; local_offset += 4; /* Reserved bits */ break; case 0x0016: /* RandomForwardingTableRecord */ proto_tree_add_item(SA_header_tree, hf_infiniband_SA_LID, tvb, local_offset, 2, ENC_BIG_ENDIAN); local_offset += 2; proto_tree_add_item(SA_header_tree, hf_infiniband_SA_BlockNum_SixteenBit, tvb, local_offset, 2, ENC_BIG_ENDIAN); local_offset += 2; local_offset += 4; /* Reserved bits */ break; case 0x0017: /* MulticastForwardingTableRecord */ proto_tree_add_item(SA_header_tree, hf_infiniband_SA_LID, tvb, local_offset, 2, ENC_BIG_ENDIAN); local_offset += 2; proto_tree_add_item(SA_header_tree, hf_infiniband_SA_Position, tvb, local_offset, 1, ENC_BIG_ENDIAN); proto_tree_add_item(SA_header_tree, hf_infiniband_SA_BlockNum_NineBit, tvb, local_offset, 2, ENC_BIG_ENDIAN); local_offset += 2; local_offset += 4; /* Reserved bits */ break; case 0x0036: /*VLArbitrationTableRecord */ proto_tree_add_item(SA_header_tree, hf_infiniband_SA_LID, tvb, local_offset, 2, ENC_BIG_ENDIAN); local_offset += 2; proto_tree_add_item(SA_header_tree, hf_infiniband_SA_OutputPortNum, tvb, local_offset, 1, ENC_BIG_ENDIAN); local_offset += 1; proto_tree_add_item(SA_header_tree, hf_infiniband_SA_BlockNum_EightBit, tvb, local_offset, 1, ENC_BIG_ENDIAN); local_offset += 1; local_offset += 4; /* Reserved bits */ break; case 0x0018: /* SMInfoRecord */ proto_tree_add_item(SA_header_tree, hf_infiniband_SA_LID, tvb, local_offset, 2, ENC_BIG_ENDIAN); local_offset += 2; local_offset += 2; /* Reserved bits */ break; case 0x0033: /* P_KeyTableRecord */ proto_tree_add_item(SA_header_tree, hf_infiniband_SA_LID, tvb, local_offset, 2, ENC_BIG_ENDIAN); local_offset += 2; proto_tree_add_item(SA_header_tree, hf_infiniband_SA_BlockNum_SixteenBit, tvb, local_offset, 2, ENC_BIG_ENDIAN); local_offset += 2; proto_tree_add_item(SA_header_tree, hf_infiniband_SA_PortNum, tvb, local_offset, 1, ENC_BIG_ENDIAN); local_offset += 1; local_offset += 3; /* Reserved bits */ break; case 0x00F3: /* InformInfoRecord */ proto_tree_add_item(SA_header_tree, hf_infiniband_InformInfoRecord_SubscriberGID, tvb, local_offset, 16, ENC_NA); local_offset += 16; proto_tree_add_item(SA_header_tree, hf_infiniband_InformInfoRecord_Enum, tvb, local_offset, 2, ENC_BIG_ENDIAN); local_offset += 2; local_offset += 6; /* Reserved bits */ break; case 0x0020: /* LinkRecord */ proto_tree_add_item(SA_header_tree, hf_infiniband_LinkRecord_FromLID, tvb, local_offset, 2, ENC_BIG_ENDIAN); local_offset += 2; proto_tree_add_item(SA_header_tree, hf_infiniband_LinkRecord_FromPort, tvb, local_offset, 1, ENC_BIG_ENDIAN); local_offset += 1; break; case 0x0031: /* ServiceRecord */ proto_tree_add_item(SA_header_tree, hf_infiniband_ServiceRecord_ServiceID, tvb, local_offset, 8, ENC_BIG_ENDIAN); local_offset += 8; proto_tree_add_item(SA_header_tree, hf_infiniband_ServiceRecord_ServiceGID, tvb, local_offset, 16, ENC_NA); local_offset += 16; proto_tree_add_item(SA_header_tree, hf_infiniband_ServiceRecord_ServiceP_Key, tvb, local_offset, 2, ENC_BIG_ENDIAN); local_offset += 2; local_offset += 2; break; case 0x0038: /* MCMemberRecord */ proto_tree_add_item(SA_header_tree, hf_infiniband_MCMemberRecord_MGID, tvb, local_offset, 16, ENC_NA); local_offset += 16; proto_tree_add_item(SA_header_tree, hf_infiniband_MCMemberRecord_PortGID, tvb, local_offset, 16, ENC_NA); local_offset += 16; break; case 0x0030: /* GuidInfoRecord */ proto_tree_add_item(SA_header_tree, hf_infiniband_SA_LID, tvb, local_offset, 2, ENC_BIG_ENDIAN); local_offset += 2; proto_tree_add_item(SA_header_tree, hf_infiniband_SA_BlockNum_EightBit, tvb, local_offset, 1, ENC_BIG_ENDIAN); local_offset += 2; local_offset += 4; break; default: break; } *offset = local_offset; } /* Parse InformInfo Attribute * IN: parentTree - The tree to add the dissection to * tvb - The tvbbuff of packet data * offset - The offset in TVB where the attribute begins * MadHeader - The common MAD header of the current SMP/SMA */ static int parse_InformInfo(proto_tree* parentTree, tvbuff_t* tvb, gint *offset) { gint local_offset = *offset; proto_item *InformInfo_header_item; proto_tree *InformInfo_header_tree; if (!parentTree) { return *offset; } InformInfo_header_item = proto_tree_add_item(parentTree, hf_infiniband_SA, tvb, local_offset, 36, ENC_NA); proto_item_set_text(InformInfo_header_item, "%s", "InformInfo"); InformInfo_header_tree = proto_item_add_subtree(InformInfo_header_item, ett_informinfo); proto_tree_add_item(InformInfo_header_tree, hf_infiniband_InformInfo_GID, tvb, local_offset, 16, ENC_NA); local_offset += 16; proto_tree_add_item(InformInfo_header_tree, hf_infiniband_InformInfo_LIDRangeBegin, tvb, local_offset, 2, ENC_BIG_ENDIAN); local_offset += 2; proto_tree_add_item(InformInfo_header_tree, hf_infiniband_InformInfo_LIDRangeEnd, tvb, local_offset, 2, ENC_BIG_ENDIAN); local_offset += 2; local_offset += 2; /* Reserved Bits */ proto_tree_add_item(InformInfo_header_tree, hf_infiniband_InformInfo_IsGeneric, tvb, local_offset, 1, ENC_BIG_ENDIAN); local_offset += 1; proto_tree_add_item(InformInfo_header_tree, hf_infiniband_InformInfo_Subscribe, tvb, local_offset, 1, ENC_BIG_ENDIAN); local_offset += 1; proto_tree_add_item(InformInfo_header_tree, hf_infiniband_InformInfo_Type, tvb, local_offset, 2, ENC_BIG_ENDIAN); local_offset += 2; proto_tree_add_item(InformInfo_header_tree, hf_infiniband_InformInfo_TrapNumberDeviceID, tvb, local_offset, 2, ENC_BIG_ENDIAN); local_offset += 2; proto_tree_add_item(InformInfo_header_tree, hf_infiniband_InformInfo_QPN, tvb, local_offset, 3, ENC_BIG_ENDIAN); local_offset += 3; proto_tree_add_item(InformInfo_header_tree, hf_infiniband_InformInfo_RespTimeValue, tvb, local_offset, 1, ENC_BIG_ENDIAN); local_offset += 1; local_offset += 1; proto_tree_add_item(InformInfo_header_tree, hf_infiniband_InformInfo_ProducerTypeVendorID, tvb, local_offset, 3, ENC_BIG_ENDIAN); local_offset += 3; return local_offset; } /* Parse LinkRecord Attribute * IN: parentTree - The tree to add the dissection to * tvb - The tvbbuff of packet data * offset - The offset in TVB where the attribute begins * MadHeader - The common MAD header of the current SMP/SMA */ static int parse_LinkRecord(proto_tree* parentTree, tvbuff_t* tvb, gint *offset) { gint local_offset = *offset; proto_item *LinkRecord_header_item; proto_tree *LinkRecord_header_tree; if (!parentTree) { return *offset; } LinkRecord_header_item = proto_tree_add_item(parentTree, hf_infiniband_SA, tvb, local_offset, 3, ENC_NA); proto_item_set_text(LinkRecord_header_item, "%s", "LinkRecord"); LinkRecord_header_tree = proto_item_add_subtree(LinkRecord_header_item, ett_linkrecord); proto_tree_add_item(LinkRecord_header_tree, hf_infiniband_LinkRecord_ToPort, tvb, local_offset, 1, ENC_BIG_ENDIAN); local_offset += 1; proto_tree_add_item(LinkRecord_header_tree, hf_infiniband_LinkRecord_ToLID, tvb, local_offset, 2, ENC_BIG_ENDIAN); local_offset += 2; return local_offset; } /* Parse ServiceRecord Attribute * IN: parentTree - The tree to add the dissection to * tvb - The tvbbuff of packet data * offset - The offset in TVB where the attribute begins * MadHeader - The common MAD header of the current SMP/SMA */ static int parse_ServiceRecord(proto_tree* parentTree, tvbuff_t* tvb, gint *offset) { gint local_offset = *offset; proto_item *ServiceRecord_header_item; proto_tree *ServiceRecord_header_tree; proto_item *tempData; if (!parentTree) { return *offset; } ServiceRecord_header_item = proto_tree_add_item(parentTree, hf_infiniband_SA, tvb, local_offset, 176, ENC_NA); proto_item_set_text(ServiceRecord_header_item, "%s", "ServiceRecord"); ServiceRecord_header_tree = proto_item_add_subtree(ServiceRecord_header_item, ett_servicerecord); proto_tree_add_item(ServiceRecord_header_tree, hf_infiniband_ServiceRecord_ServiceLease, tvb, local_offset, 4, ENC_BIG_ENDIAN); local_offset += 4; proto_tree_add_item(ServiceRecord_header_tree, hf_infiniband_ServiceRecord_ServiceKey, tvb, local_offset, 16, ENC_NA); local_offset += 16; proto_tree_add_item(ServiceRecord_header_tree, hf_infiniband_ServiceRecord_ServiceName, tvb, local_offset, 64, ENC_NA); local_offset += 64; tempData = proto_tree_add_item(ServiceRecord_header_tree, hf_infiniband_ServiceRecord_ServiceData, tvb, local_offset, 16, ENC_NA); local_offset += 16; proto_item_append_text(tempData, "%s", "(ServiceData 8.1, 8.16)"); tempData = proto_tree_add_item(ServiceRecord_header_tree, hf_infiniband_ServiceRecord_ServiceData, tvb, local_offset, 16, ENC_NA); local_offset += 16; proto_item_append_text(tempData, "%s", "(ServiceData 16.1, 16.8)"); tempData = proto_tree_add_item(ServiceRecord_header_tree, hf_infiniband_ServiceRecord_ServiceData, tvb, local_offset, 16, ENC_NA); local_offset += 16; proto_item_append_text(tempData, "%s", "(ServiceData 32.1, 32.4)"); tempData = proto_tree_add_item(ServiceRecord_header_tree, hf_infiniband_ServiceRecord_ServiceData, tvb, local_offset, 16, ENC_NA); local_offset += 16; proto_item_append_text(tempData, "%s", "(ServiceData 64.1, 64.2)"); return local_offset; } /* Parse PathRecord Attribute * IN: parentTree - The tree to add the dissection to * tvb - The tvbbuff of packet data * offset - The offset in TVB where the attribute begins * MadHeader - The common MAD header of the current SMP/SMA */ static int parse_PathRecord(proto_tree* parentTree, tvbuff_t* tvb, gint *offset) { gint local_offset = *offset; proto_item *PathRecord_header_item; proto_tree *PathRecord_header_tree; if (!parentTree) { return *offset; } PathRecord_header_item = proto_tree_add_item(parentTree, hf_infiniband_SA, tvb, local_offset, 64, ENC_NA); proto_item_set_text(PathRecord_header_item, "%s", "PathRecord"); PathRecord_header_tree = proto_item_add_subtree(PathRecord_header_item, ett_pathrecord); local_offset += 8; /* Reserved Bits */ proto_tree_add_item(PathRecord_header_tree, hf_infiniband_PathRecord_DGID, tvb, local_offset, 16, ENC_NA); local_offset += 16; proto_tree_add_item(PathRecord_header_tree, hf_infiniband_PathRecord_SGID, tvb, local_offset, 16, ENC_NA); local_offset += 16; proto_tree_add_item(PathRecord_header_tree, hf_infiniband_PathRecord_DLID, tvb, local_offset, 2, ENC_BIG_ENDIAN); local_offset += 2; proto_tree_add_item(PathRecord_header_tree, hf_infiniband_PathRecord_SLID, tvb, local_offset, 2, ENC_BIG_ENDIAN); local_offset += 2; proto_tree_add_item(PathRecord_header_tree, hf_infiniband_PathRecord_RawTraffic, tvb, local_offset, 1, ENC_BIG_ENDIAN); proto_tree_add_item(PathRecord_header_tree, hf_infiniband_PathRecord_FlowLabel, tvb, local_offset, 3, ENC_BIG_ENDIAN); local_offset += 3; proto_tree_add_item(PathRecord_header_tree, hf_infiniband_PathRecord_HopLimit, tvb, local_offset, 1, ENC_BIG_ENDIAN); local_offset += 1; proto_tree_add_item(PathRecord_header_tree, hf_infiniband_PathRecord_TClass, tvb, local_offset, 1, ENC_BIG_ENDIAN); local_offset += 1; proto_tree_add_item(PathRecord_header_tree, hf_infiniband_PathRecord_Reversible, tvb, local_offset, 1, ENC_BIG_ENDIAN); proto_tree_add_item(PathRecord_header_tree, hf_infiniband_PathRecord_NumbPath, tvb, local_offset, 1, ENC_BIG_ENDIAN); local_offset += 1; proto_tree_add_item(PathRecord_header_tree, hf_infiniband_PathRecord_P_Key, tvb, local_offset, 2, ENC_BIG_ENDIAN); local_offset += 2; proto_tree_add_item(PathRecord_header_tree, hf_infiniband_PathRecord_SL, tvb, local_offset, 2, ENC_BIG_ENDIAN); local_offset += 2; proto_tree_add_item(PathRecord_header_tree, hf_infiniband_PathRecord_MTUSelector, tvb, local_offset, 1, ENC_BIG_ENDIAN); proto_tree_add_item(PathRecord_header_tree, hf_infiniband_PathRecord_MTU, tvb, local_offset, 1, ENC_BIG_ENDIAN); local_offset += 1; proto_tree_add_item(PathRecord_header_tree, hf_infiniband_PathRecord_RateSelector, tvb, local_offset, 1, ENC_BIG_ENDIAN); proto_tree_add_item(PathRecord_header_tree, hf_infiniband_PathRecord_Rate, tvb, local_offset, 1, ENC_BIG_ENDIAN); local_offset += 1; proto_tree_add_item(PathRecord_header_tree, hf_infiniband_PathRecord_PacketLifeTimeSelector, tvb, local_offset, 1, ENC_BIG_ENDIAN); proto_tree_add_item(PathRecord_header_tree, hf_infiniband_PathRecord_PacketLifeTime, tvb, local_offset, 1, ENC_BIG_ENDIAN); local_offset += 1; proto_tree_add_item(PathRecord_header_tree, hf_infiniband_PathRecord_Preference, tvb, local_offset, 1, ENC_BIG_ENDIAN); local_offset += 1; return local_offset; } /* Parse MCMemberRecord Attribute * IN: parentTree - The tree to add the dissection to * tvb - The tvbbuff of packet data * offset - The offset in TVB where the attribute begins * MadHeader - The common MAD header of the current SMP/SMA */ static int parse_MCMemberRecord(proto_tree* parentTree, tvbuff_t* tvb, gint *offset) { gint local_offset = *offset; proto_item *MCMemberRecord_header_item; proto_tree *MCMemberRecord_header_tree; if (!parentTree) { return *offset; } MCMemberRecord_header_item = proto_tree_add_item(parentTree, hf_infiniband_SA, tvb, local_offset, 64, ENC_NA); proto_item_set_text(MCMemberRecord_header_item, "%s", "MCMemberRecord"); MCMemberRecord_header_tree = proto_item_add_subtree(MCMemberRecord_header_item, ett_mcmemberrecord); proto_tree_add_item(MCMemberRecord_header_tree, hf_infiniband_MCMemberRecord_Q_Key, tvb, local_offset, 4, ENC_BIG_ENDIAN); local_offset += 4; proto_tree_add_item(MCMemberRecord_header_tree, hf_infiniband_MCMemberRecord_MLID, tvb, local_offset, 2, ENC_BIG_ENDIAN); local_offset += 2; proto_tree_add_item(MCMemberRecord_header_tree, hf_infiniband_MCMemberRecord_MTUSelector, tvb, local_offset, 1, ENC_BIG_ENDIAN); proto_tree_add_item(MCMemberRecord_header_tree, hf_infiniband_MCMemberRecord_MTU, tvb, local_offset, 1, ENC_BIG_ENDIAN); local_offset += 1; proto_tree_add_item(MCMemberRecord_header_tree, hf_infiniband_MCMemberRecord_TClass, tvb, local_offset, 1, ENC_BIG_ENDIAN); local_offset += 1; proto_tree_add_item(MCMemberRecord_header_tree, hf_infiniband_MCMemberRecord_P_Key, tvb, local_offset, 2, ENC_BIG_ENDIAN); local_offset += 2; proto_tree_add_item(MCMemberRecord_header_tree, hf_infiniband_MCMemberRecord_RateSelector, tvb, local_offset, 1, ENC_BIG_ENDIAN); proto_tree_add_item(MCMemberRecord_header_tree, hf_infiniband_MCMemberRecord_Rate, tvb, local_offset, 1, ENC_BIG_ENDIAN); local_offset += 1; proto_tree_add_item(MCMemberRecord_header_tree, hf_infiniband_MCMemberRecord_PacketLifeTimeSelector, tvb, local_offset, 1, ENC_BIG_ENDIAN); proto_tree_add_item(MCMemberRecord_header_tree, hf_infiniband_MCMemberRecord_PacketLifeTime, tvb, local_offset, 1, ENC_BIG_ENDIAN); local_offset += 1; proto_tree_add_item(MCMemberRecord_header_tree, hf_infiniband_MCMemberRecord_SL, tvb, local_offset, 1, ENC_BIG_ENDIAN); proto_tree_add_item(MCMemberRecord_header_tree, hf_infiniband_MCMemberRecord_FlowLabel, tvb, local_offset, 3, ENC_BIG_ENDIAN); local_offset += 3; proto_tree_add_item(MCMemberRecord_header_tree, hf_infiniband_MCMemberRecord_HopLimit, tvb, local_offset, 1, ENC_BIG_ENDIAN); local_offset += 1; proto_tree_add_item(MCMemberRecord_header_tree, hf_infiniband_MCMemberRecord_Scope, tvb, local_offset, 1, ENC_BIG_ENDIAN); proto_tree_add_item(MCMemberRecord_header_tree, hf_infiniband_MCMemberRecord_JoinState, tvb, local_offset, 1, ENC_BIG_ENDIAN); local_offset += 1; proto_tree_add_item(MCMemberRecord_header_tree, hf_infiniband_MCMemberRecord_ProxyJoin, tvb, local_offset, 1, ENC_BIG_ENDIAN); local_offset += 3; return local_offset; } /* Parse TraceRecord Attribute * IN: parentTree - The tree to add the dissection to * tvb - The tvbbuff of packet data * offset - The offset in TVB where the attribute begins * MadHeader - The common MAD header of the current SMP/SMA */ static int parse_TraceRecord(proto_tree* parentTree, tvbuff_t* tvb, gint *offset) { gint local_offset = *offset; proto_item *TraceRecord_header_item; proto_tree *TraceRecord_header_tree; if (!parentTree) { return *offset; } TraceRecord_header_item = proto_tree_add_item(parentTree, hf_infiniband_SA, tvb, local_offset, 46, ENC_NA); proto_item_set_text(TraceRecord_header_item, "%s", "TraceRecord"); TraceRecord_header_tree = proto_item_add_subtree(TraceRecord_header_item, ett_tracerecord); proto_tree_add_item(TraceRecord_header_tree, hf_infiniband_TraceRecord_GIDPrefix, tvb, local_offset, 8, ENC_BIG_ENDIAN); local_offset += 8; proto_tree_add_item(TraceRecord_header_tree, hf_infiniband_TraceRecord_IDGeneration, tvb, local_offset, 2, ENC_BIG_ENDIAN); local_offset += 2; local_offset += 1; /* Reserved Bits */ proto_tree_add_item(TraceRecord_header_tree, hf_infiniband_TraceRecord_NodeType, tvb, local_offset, 1, ENC_BIG_ENDIAN); local_offset += 1; proto_tree_add_item(TraceRecord_header_tree, hf_infiniband_TraceRecord_NodeID, tvb, local_offset, 8, ENC_BIG_ENDIAN); local_offset += 8; proto_tree_add_item(TraceRecord_header_tree, hf_infiniband_TraceRecord_ChassisID, tvb, local_offset, 8, ENC_BIG_ENDIAN); local_offset += 8; proto_tree_add_item(TraceRecord_header_tree, hf_infiniband_TraceRecord_EntryPortID, tvb, local_offset, 8, ENC_BIG_ENDIAN); local_offset += 8; proto_tree_add_item(TraceRecord_header_tree, hf_infiniband_TraceRecord_ExitPortID, tvb, local_offset, 8, ENC_BIG_ENDIAN); local_offset += 8; proto_tree_add_item(TraceRecord_header_tree, hf_infiniband_TraceRecord_EntryPort, tvb, local_offset, 1, ENC_BIG_ENDIAN); local_offset += 1; proto_tree_add_item(TraceRecord_header_tree, hf_infiniband_TraceRecord_ExitPort, tvb, local_offset, 1, ENC_BIG_ENDIAN); local_offset += 1; return local_offset; } /* Parse MultiPathRecord Attribute * IN: parentTree - The tree to add the dissection to * tvb - The tvbbuff of packet data * offset - The offset in TVB where the attribute begins * MadHeader - The common MAD header of the current SMP/SMA */ static int parse_MultiPathRecord(proto_tree* parentTree, tvbuff_t* tvb, gint *offset) { gint local_offset = *offset; proto_item *MultiPathRecord_header_item; proto_tree *MultiPathRecord_header_tree; proto_item *SDGID; guint8 SDGIDCount; guint8 DGIDCount; guint32 i; if (!parentTree) { return *offset; } MultiPathRecord_header_item = proto_tree_add_item(parentTree, hf_infiniband_SA, tvb, local_offset, 200, ENC_NA); proto_item_set_text(MultiPathRecord_header_item, "%s", "MultiPathRecord"); MultiPathRecord_header_tree = proto_item_add_subtree(MultiPathRecord_header_item, ett_multipathrecord); proto_tree_add_item(MultiPathRecord_header_tree, hf_infiniband_MultiPathRecord_RawTraffic, tvb, local_offset, 1, ENC_BIG_ENDIAN); proto_tree_add_item(MultiPathRecord_header_tree, hf_infiniband_MultiPathRecord_FlowLabel, tvb, local_offset, 3, ENC_BIG_ENDIAN); local_offset += 3; proto_tree_add_item(MultiPathRecord_header_tree, hf_infiniband_MultiPathRecord_HopLimit, tvb, local_offset, 1, ENC_BIG_ENDIAN); local_offset += 1; proto_tree_add_item(MultiPathRecord_header_tree, hf_infiniband_MultiPathRecord_TClass, tvb, local_offset, 1, ENC_BIG_ENDIAN); local_offset += 1; proto_tree_add_item(MultiPathRecord_header_tree, hf_infiniband_MultiPathRecord_Reversible, tvb, local_offset, 1, ENC_BIG_ENDIAN); proto_tree_add_item(MultiPathRecord_header_tree, hf_infiniband_MultiPathRecord_NumbPath, tvb, local_offset, 1, ENC_BIG_ENDIAN); local_offset += 1; proto_tree_add_item(MultiPathRecord_header_tree, hf_infiniband_MultiPathRecord_P_Key, tvb, local_offset, 2, ENC_BIG_ENDIAN); local_offset += 2; proto_tree_add_item(MultiPathRecord_header_tree, hf_infiniband_MultiPathRecord_SL, tvb, local_offset, 2, ENC_BIG_ENDIAN); local_offset += 2; proto_tree_add_item(MultiPathRecord_header_tree, hf_infiniband_MultiPathRecord_MTUSelector, tvb, local_offset, 1, ENC_BIG_ENDIAN); proto_tree_add_item(MultiPathRecord_header_tree, hf_infiniband_MultiPathRecord_MTU, tvb, local_offset, 1, ENC_BIG_ENDIAN); local_offset += 1; proto_tree_add_item(MultiPathRecord_header_tree, hf_infiniband_MultiPathRecord_RateSelector, tvb, local_offset, 1, ENC_BIG_ENDIAN); proto_tree_add_item(MultiPathRecord_header_tree, hf_infiniband_MultiPathRecord_Rate, tvb, local_offset, 1, ENC_BIG_ENDIAN); local_offset += 1; proto_tree_add_item(MultiPathRecord_header_tree, hf_infiniband_MultiPathRecord_PacketLifeTimeSelector, tvb, local_offset, 1, ENC_BIG_ENDIAN); proto_tree_add_item(MultiPathRecord_header_tree, hf_infiniband_MultiPathRecord_PacketLifeTime, tvb, local_offset, 1, ENC_BIG_ENDIAN); local_offset += 1; local_offset += 1; /* Reserved Bits */ proto_tree_add_item(MultiPathRecord_header_tree, hf_infiniband_MultiPathRecord_IndependenceSelector, tvb, local_offset, 1, ENC_BIG_ENDIAN); proto_tree_add_item(MultiPathRecord_header_tree, hf_infiniband_MultiPathRecord_GIDScope, tvb, local_offset, 1, ENC_BIG_ENDIAN); local_offset += 1; SDGIDCount = tvb_get_guint8(tvb, local_offset); proto_tree_add_item(MultiPathRecord_header_tree, hf_infiniband_MultiPathRecord_SGIDCount, tvb, local_offset, 1, ENC_BIG_ENDIAN); local_offset += 1; DGIDCount = tvb_get_guint8(tvb, local_offset); proto_tree_add_item(MultiPathRecord_header_tree, hf_infiniband_MultiPathRecord_DGIDCount, tvb, local_offset, 1, ENC_BIG_ENDIAN); local_offset += 1; local_offset += 7; /*Reserved Bits */ for (i = 0; i < SDGIDCount; i++) { SDGID = proto_tree_add_item(MultiPathRecord_header_tree, hf_infiniband_MultiPathRecord_SDGID, tvb, local_offset, 16, ENC_NA); local_offset += 16; proto_item_set_text(SDGID, "(%s%u)", "SGID", i); } for (i = 0; i < DGIDCount; i++) { SDGID = proto_tree_add_item(MultiPathRecord_header_tree, hf_infiniband_MultiPathRecord_SDGID, tvb, local_offset, 16, ENC_NA); local_offset += 16; proto_item_set_text(SDGID, "(%s%u)", "DGID", i); } return local_offset; } /* Parse ServiceAssociationRecord Attribute * IN: parentTree - The tree to add the dissection to * tvb - The tvbbuff of packet data * offset - The offset in TVB where the attribute begins * MadHeader - The common MAD header of the current SMP/SMA */ static int parse_ServiceAssociationRecord(proto_tree* parentTree, tvbuff_t* tvb, gint *offset) { gint local_offset = *offset; proto_item *ServiceAssociationRecord_header_item; proto_tree *ServiceAssociationRecord_header_tree; if (!parentTree) { return *offset; } ServiceAssociationRecord_header_item = proto_tree_add_item(parentTree, hf_infiniband_SA, tvb, local_offset, 80, ENC_NA); proto_item_set_text(ServiceAssociationRecord_header_item, "%s", "ServiceAssociationRecord"); ServiceAssociationRecord_header_tree = proto_item_add_subtree(ServiceAssociationRecord_header_item, ett_serviceassocrecord); proto_tree_add_item(ServiceAssociationRecord_header_tree, hf_infiniband_ServiceAssociationRecord_ServiceKey, tvb, local_offset, 16, ENC_NA); local_offset += 16; proto_tree_add_item(ServiceAssociationRecord_header_tree, hf_infiniband_ServiceAssociationRecord_ServiceName, tvb, local_offset, 64, ENC_ASCII|ENC_NA); local_offset += 64; return local_offset; } /* Parse PortCounters MAD from the Performance management class. * IN: parentTree - The tree to add the dissection to * tvb - The tvbbuff of packet data * offset - The offset in TVB where the attribute begins * pinfo - The packet info structure with column information */ static int parse_PERF_PortCounters(proto_tree* parentTree, tvbuff_t* tvb, packet_info *pinfo, gint *offset) { proto_item *perf_item; proto_tree *perf_tree; gint local_offset = *offset; col_set_str(pinfo->cinfo, COL_INFO, "PERF (PortCounters)"); perf_item = proto_tree_add_item(parentTree, hf_infiniband_PortCounters, tvb, local_offset, 40, ENC_NA); perf_tree = proto_item_add_subtree(perf_item, ett_perfclass); local_offset += 40; /* skip reserved field */ local_offset += 1; /* skip reserved field */ proto_tree_add_item(perf_tree, hf_infiniband_PortCounters_PortSelect, tvb, local_offset, 1, ENC_BIG_ENDIAN); local_offset += 1; proto_tree_add_item(perf_tree, hf_infiniband_PortCounters_CounterSelect, tvb, local_offset, 2, ENC_BIG_ENDIAN); local_offset += 2; proto_tree_add_item(perf_tree, hf_infiniband_PortCounters_SymbolErrorCounter, tvb, local_offset, 2, ENC_BIG_ENDIAN); local_offset += 2; proto_tree_add_item(perf_tree, hf_infiniband_PortCounters_LinkErrorRecoveryCounter, tvb, local_offset, 1, ENC_BIG_ENDIAN); local_offset += 1; proto_tree_add_item(perf_tree, hf_infiniband_PortCounters_LinkDownedCounter, tvb, local_offset, 1, ENC_BIG_ENDIAN); local_offset += 1; proto_tree_add_item(perf_tree, hf_infiniband_PortCounters_PortRcvErrors, tvb, local_offset, 2, ENC_BIG_ENDIAN); local_offset += 2; proto_tree_add_item(perf_tree, hf_infiniband_PortCounters_PortRcvRemotePhysicalErrors, tvb, local_offset, 2, ENC_BIG_ENDIAN); local_offset += 2; proto_tree_add_item(perf_tree, hf_infiniband_PortCounters_PortRcvSwitchRelayErrors, tvb, local_offset, 2, ENC_BIG_ENDIAN); local_offset += 2; proto_tree_add_item(perf_tree, hf_infiniband_PortCounters_PortXmitDiscards, tvb, local_offset, 2, ENC_BIG_ENDIAN); local_offset += 2; proto_tree_add_item(perf_tree, hf_infiniband_PortCounters_PortXmitConstraintErrors, tvb, local_offset, 1, ENC_BIG_ENDIAN); local_offset += 1; proto_tree_add_item(perf_tree, hf_infiniband_PortCounters_PortRcvConstraintErrors, tvb, local_offset, 1, ENC_BIG_ENDIAN); local_offset += 1; local_offset += 1; /* skip reserved field */ proto_tree_add_bits_item(perf_tree, hf_infiniband_PortCounters_LocalLinkIntegrityErrors, tvb, local_offset*8, 4, ENC_BIG_ENDIAN); proto_tree_add_bits_item(perf_tree, hf_infiniband_PortCounters_ExcessiveBufferOverrunErrors, tvb, local_offset*8 + 4, 4, ENC_BIG_ENDIAN); local_offset += 1; local_offset += 2; /* skip reserved field */ proto_tree_add_item(perf_tree, hf_infiniband_PortCounters_VL15Dropped, tvb, local_offset, 2, ENC_BIG_ENDIAN); local_offset += 2; proto_tree_add_item(perf_tree, hf_infiniband_PortCounters_PortXmitData, tvb, local_offset, 4, ENC_BIG_ENDIAN); local_offset += 4; proto_tree_add_item(perf_tree, hf_infiniband_PortCounters_PortRcvData, tvb, local_offset, 4, ENC_BIG_ENDIAN); local_offset += 4; proto_tree_add_item(perf_tree, hf_infiniband_PortCounters_PortXmitPkts, tvb, local_offset, 4, ENC_BIG_ENDIAN); local_offset += 4; proto_tree_add_item(perf_tree, hf_infiniband_PortCounters_PortRcvPkts, tvb, local_offset, 4, ENC_BIG_ENDIAN); local_offset += 4; *offset = local_offset; /* update caller's offset to point to end of the PortCounters payload */ return local_offset; } /* Parse PortCountersExtended MAD from the Performance management class. * IN: parentTree - The tree to add the dissection to * tvb - The tvbbuff of packet data * offset - The offset in TVB where the attribute begins * pinfo - The packet info structure with column information */ static int parse_PERF_PortCountersExtended(proto_tree* parentTree, tvbuff_t* tvb, packet_info *pinfo, gint *offset) { proto_item *perf_item; proto_tree *perf_tree; gint local_offset = *offset; col_set_str(pinfo->cinfo, COL_INFO, "PERF (PortCountersExtended)"); perf_item = proto_tree_add_item(parentTree, hf_infiniband_PortCountersExt, tvb, local_offset, 72, ENC_NA); perf_tree = proto_item_add_subtree(perf_item, ett_perfclass); local_offset += 40; /* skip reserved field */ local_offset += 1; /* skip reserved field */ proto_tree_add_item(perf_tree, hf_infiniband_PortCountersExt_PortSelect, tvb, local_offset, 1, ENC_BIG_ENDIAN); local_offset += 1; proto_tree_add_item(perf_tree, hf_infiniband_PortCountersExt_CounterSelect, tvb, local_offset, 2, ENC_BIG_ENDIAN); local_offset += 2; local_offset += 4; /* skip reserved field */ proto_tree_add_item(perf_tree, hf_infiniband_PortCountersExt_PortXmitData, tvb, local_offset, 8, ENC_BIG_ENDIAN); local_offset += 8; proto_tree_add_item(perf_tree, hf_infiniband_PortCountersExt_PortRcvData, tvb, local_offset, 8, ENC_BIG_ENDIAN); local_offset += 8; proto_tree_add_item(perf_tree, hf_infiniband_PortCountersExt_PortXmitPkts, tvb, local_offset, 8, ENC_BIG_ENDIAN); local_offset += 8; proto_tree_add_item(perf_tree, hf_infiniband_PortCountersExt_PortRcvPkts, tvb, local_offset, 8, ENC_BIG_ENDIAN); local_offset += 8; proto_tree_add_item(perf_tree, hf_infiniband_PortCountersExt_PortUnicastXmitPkts, tvb, local_offset, 8, ENC_BIG_ENDIAN); local_offset += 8; proto_tree_add_item(perf_tree, hf_infiniband_PortCountersExt_PortUnicastRcvPkts, tvb, local_offset, 8, ENC_BIG_ENDIAN); local_offset += 8; proto_tree_add_item(perf_tree, hf_infiniband_PortCountersExt_PortMulticastXmitPkts, tvb, local_offset, 8, ENC_BIG_ENDIAN); local_offset += 8; proto_tree_add_item(perf_tree, hf_infiniband_PortCountersExt_PortMulticastRcvPkts, tvb, local_offset, 8, ENC_BIG_ENDIAN); local_offset += 8; *offset = local_offset; /* update caller's offset to point to end of the PortCountersExt payload */ return local_offset; } /* dissect_general_info * Used to extract very few values from the packet in the case that full dissection is disabled by the user. * IN: * tvb - The tvbbuff of packet data * offset - The offset in TVB where the attribute begins * pinfo - The packet info structure with column information * starts_with_grh - If true this packets start with a GRH header, otherwise with LRH */ static void dissect_general_info(tvbuff_t *tvb, gint offset, packet_info *pinfo, gboolean starts_with_grh) { guint8 lnh_val = 0; /* The Link Next Header Value. Tells us which headers are coming */ gboolean bthFollows = FALSE; /* Tracks if we are parsing a BTH. This is a significant decision point */ guint8 virtualLane = 0; /* The Virtual Lane of the current Packet */ guint8 opCode = 0; /* OpCode from BTH header. */ gint32 nextHeaderSequence = -1; /* defined by this dissector. #define which indicates the upcoming header sequence from OpCode */ guint8 nxtHdr = 0; /* that must be available for that header. */ struct e_in6_addr SRCgid; /* Struct to display ipv6 Address */ struct e_in6_addr DSTgid; /* Struct to display ipv6 Address */ guint8 management_class = 0; MAD_Data MadData; if (starts_with_grh) { /* this is a RoCE packet, skip LRH parsing */ lnh_val = IBA_GLOBAL; goto skip_lrh; } virtualLane = tvb_get_guint8(tvb, offset); virtualLane = virtualLane & 0xF0; offset += 1; /* Save Link Next Header... This tells us what the next header is. */ lnh_val = tvb_get_guint8(tvb, offset); lnh_val = lnh_val & 0x03; offset += 1; /* Set destination in packet view. */ *((guint16*) dst_addr) = tvb_get_ntohs(tvb, offset); SET_ADDRESS(&pinfo->dst, AT_IB, sizeof(guint16), dst_addr); offset += 4; /* Set Source in packet view. */ *((guint16*) src_addr) = tvb_get_ntohs(tvb, offset); SET_ADDRESS(&pinfo->src, AT_IB, sizeof(guint16), src_addr); offset += 2; skip_lrh: switch (lnh_val) { case IBA_GLOBAL: offset += 6; nxtHdr = tvb_get_guint8(tvb, offset); offset += 2; tvb_get_ipv6(tvb, offset, &SRCgid); /* Set source GID in packet view. */ memcpy(src_addr, &SRCgid, GID_SIZE); SET_ADDRESS(&pinfo->src, AT_IB, GID_SIZE, src_addr); offset += 16; tvb_get_ipv6(tvb, offset, &DSTgid); /* Set destination GID in packet view. */ memcpy(dst_addr, &DSTgid, GID_SIZE); SET_ADDRESS(&pinfo->dst, AT_IB, GID_SIZE, dst_addr); offset += 16; if (nxtHdr != 0x1B) { /* Some kind of packet being transported globally with IBA, but locally it is not IBA - no BTH following. */ break; } /* else * { * Fall through switch and start parsing Local Headers and BTH * } */ case IBA_LOCAL: bthFollows = TRUE; /* Get the OpCode - this tells us what headers are following */ opCode = tvb_get_guint8(tvb, offset); col_append_str(pinfo->cinfo, COL_INFO, val_to_str_const((guint32)opCode, OpCodeMap, "Unknown OpCode")); offset += 12; break; case IP_NON_IBA: /* Raw IPv6 Packet */ g_snprintf((gchar *)dst_addr, ADDR_MAX_LEN, "IPv6 over IB Packet"); SET_ADDRESS(&pinfo->dst, AT_STRINGZ, (int)strlen((char *)dst_addr)+1, dst_addr); break; case RAW: break; default: break; } if (bthFollows) { /* Find our next header sequence based on the Opcode * Since we're not doing dissection here, we just need the proper offsets to get our labels in packet view */ nextHeaderSequence = find_next_header_sequence((guint32) opCode); switch (nextHeaderSequence) { case RDETH_DETH_PAYLD: offset += 4; /* RDETH */ offset += 8; /* DETH */ break; case RDETH_DETH_RETH_PAYLD: offset += 4; /* RDETH */ offset += 8; /* DETH */ offset += 16; /* RETH */ break; case RDETH_DETH_IMMDT_PAYLD: offset += 4; /* RDETH */ offset += 8; /* DETH */ offset += 4; /* IMMDT */ break; case RDETH_DETH_RETH_IMMDT_PAYLD: offset += 4; /* RDETH */ offset += 8; /* DETH */ offset += 16; /* RETH */ offset += 4; /* IMMDT */ break; case RDETH_DETH_RETH: offset += 4; /* RDETH */ offset += 8; /* DETH */ offset += 16; /* RETH */ break; case RDETH_AETH_PAYLD: offset += 4; /* RDETH */ offset += 4; /* AETH */ break; case RDETH_PAYLD: offset += 4; /* RDETH */ break; case RDETH_AETH: offset += 4; /* RDETH */ offset += 4; /* AETH */ break; case RDETH_AETH_ATOMICACKETH: offset += 4; /* RDETH */ offset += 4; /* AETH */ offset += 8; /* AtomicAckETH */ break; case RDETH_DETH_ATOMICETH: offset += 4; /* RDETH */ offset += 8; /* DETH */ offset += 28; /* AtomicETH */ break; case RDETH_DETH: offset += 4; /* RDETH */ offset += 8; /* DETH */ break; case DETH_PAYLD: offset += 8; /* DETH */ break; case PAYLD: break; case IMMDT_PAYLD: offset += 4; /* IMMDT */ break; case RETH_PAYLD: offset += 16; /* RETH */ break; case RETH: offset += 16; /* RETH */ break; case AETH_PAYLD: offset += 4; /* AETH */ break; case AETH: offset += 4; /* AETH */ break; case AETH_ATOMICACKETH: offset += 4; /* AETH */ offset += 8; /* AtomicAckETH */ break; case ATOMICETH: offset += 28; /* AtomicETH */ break; case IETH_PAYLD: offset += 4; /* IETH */ break; case DETH_IMMDT_PAYLD: offset += 8; /* DETH */ offset += 4; /* IMMDT */ break; default: break; } } if (virtualLane == 0xF0) { management_class = tvb_get_guint8(tvb, offset + 1); if (((management_class >= (guint8)VENDOR_1_START) && (management_class <= (guint8)VENDOR_1_END)) || ((management_class >= (guint8)VENDOR_2_START) && (management_class <= (guint8)VENDOR_2_END))) { return; } else if ((management_class >= (guint8)APPLICATION_START) && (management_class <= (guint8)APPLICATION_END)) { return; } else if (((management_class == (guint8)0x00) || (management_class == (guint8)0x02)) || ((management_class >= (guint8)0x50) && (management_class <= (guint8)0x80)) || ((management_class >= (guint8)0x82))) { return; } else /* we have a normal management_class */ { if (parse_MAD_Common(NULL, tvb, &offset, &MadData)) { label_SUBM_Method(NULL, &MadData, pinfo); label_SUBM_Attribute(NULL, &MadData, pinfo); } } } return; } static void proto_init_infiniband(void) { src_addr = dst_addr = NULL; } /* Protocol Registration */ void proto_register_infiniband(void) { module_t *infiniband_module; /* Field dissector structures. * For reserved fields, reservedX denotes the reserved field is X bits in length. * e.g. reserved2 is a reserved field 2 bits in length. * The third parameter is a filter string associated for this field. * So for instance, to filter packets for a given virtual lane, * The filter (infiniband.LRH.vl == 3) or something similar would be used. */ /* XXX: ToDo: Verify against Infiniband 1.2.1 Specification */ /* Fields verified/corrected: Those after comment "XX: All following ..." */ /* meanings for MAD method field */ static const value_string mad_method_str[] = { { 0x01, "Get()" }, { 0x02, "Set()" }, { 0x81, "GetResp()" }, { 0x03, "Send()" }, { 0x05, "Trap()" }, { 0x06, "Report()" }, { 0x86, "ReportResp()" }, { 0x07, "TrapRepress()" }, { 0, NULL } }; static hf_register_info hf[] = { /* Local Route Header (LRH) */ { &hf_infiniband_LRH, { "Local Route Header", "infiniband.lrh", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL} }, { &hf_infiniband_virtual_lane, { "Virtual Lane", "infiniband.lrh.vl", FT_UINT8, BASE_HEX, NULL, 0xF0, NULL, HFILL} }, { &hf_infiniband_link_version, { "Link Version", "infiniband.lrh.lver", FT_UINT8, BASE_DEC, NULL, 0x0F, NULL, HFILL} }, { &hf_infiniband_service_level, { "Service Level", "infiniband.lrh.sl", FT_UINT8, BASE_DEC, NULL, 0xF0, NULL, HFILL} }, { &hf_infiniband_reserved2, { "Reserved (2 bits)", "infiniband.lrh.reserved2", FT_UINT8, BASE_DEC, NULL, 0x0C, NULL, HFILL} }, { &hf_infiniband_link_next_header, { "Link Next Header", "infiniband.lrh.lnh", FT_UINT8, BASE_HEX, NULL, 0x03, NULL, HFILL} }, { &hf_infiniband_destination_local_id, { "Destination Local ID", "infiniband.lrh.dlid", FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL} }, { &hf_infiniband_reserved5, { "Reserved (5 bits)", "infiniband.lrh.reserved5", FT_UINT16, BASE_DEC, NULL, 0xF800, NULL, HFILL} }, { &hf_infiniband_packet_length, { "Packet Length", "infiniband.lrh.pktlen", FT_UINT16, BASE_DEC, NULL, 0x07FF, NULL, HFILL} }, { &hf_infiniband_source_local_id, { "Source Local ID", "infiniband.lrh.slid", FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL} }, /* Global Route Header (GRH) */ { &hf_infiniband_GRH, { "Global Route Header", "infiniband.grh", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL} }, { &hf_infiniband_ip_version, { "IP Version", "infiniband.grh.ipver", FT_UINT8, BASE_DEC, NULL, 0xF0, NULL, HFILL} }, { &hf_infiniband_traffic_class, { "Traffic Class", "infiniband.grh.tclass", FT_UINT16, BASE_DEC, NULL, 0x0FF0, NULL, HFILL} }, { &hf_infiniband_flow_label, { "Flow Label", "infiniband.grh.flowlabel", FT_UINT32, BASE_DEC, NULL, 0x000FFFFF, NULL, HFILL} }, { &hf_infiniband_payload_length, { "Payload Length", "infiniband.grh.paylen", FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL} }, { &hf_infiniband_next_header, { "Next Header", "infiniband.grh.nxthdr", FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL} }, { &hf_infiniband_hop_limit, { "Hop Limit", "infiniband.grh.hoplmt", FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL} }, { &hf_infiniband_source_gid, { "Source GID", "infiniband.grh.sgid", FT_IPv6, BASE_NONE, NULL, 0x0, NULL, HFILL} }, { &hf_infiniband_destination_gid, { "Destination GID", "infiniband.grh.dgid", FT_IPv6, BASE_NONE, NULL, 0x0, NULL, HFILL} }, /* Base Transport Header (BTH) */ { &hf_infiniband_BTH, { "Base Transport Header", "infiniband.bth", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL} }, { &hf_infiniband_opcode, { "Opcode", "infiniband.bth.opcode", FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL} }, { &hf_infiniband_solicited_event, { "Solicited Event", "infiniband.bth.se", FT_BOOLEAN, 8, NULL, 0x80, NULL, HFILL} }, { &hf_infiniband_migreq, { "MigReq", "infiniband.bth.m", FT_BOOLEAN, 8, NULL, 0x40, NULL, HFILL} }, { &hf_infiniband_pad_count, { "Pad Count", "infiniband.bth.padcnt", FT_UINT8, BASE_DEC, NULL, 0x30, NULL, HFILL} }, { &hf_infiniband_transport_header_version, { "Header Version", "infiniband.bth.tver", FT_UINT8, BASE_DEC, NULL, 0x0F, NULL, HFILL} }, { &hf_infiniband_partition_key, { "Partition Key", "infiniband.bth.p_key", FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL} }, { &hf_infiniband_reserved8, { "Reserved (8 bits)", "infiniband.bth.reserved8", FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL} }, { &hf_infiniband_destination_qp, { "Destination Queue Pair", "infiniband.bth.destqp", FT_UINT24, BASE_HEX, NULL, 0x0, NULL, HFILL} }, { &hf_infiniband_acknowledge_request, { "Acknowledge Request", "infiniband.bth.a", FT_BOOLEAN, 8, NULL, 0x80, NULL, HFILL} }, { &hf_infiniband_reserved7, { "Reserved (7 bits)", "infiniband.bth.reserved7", FT_UINT8, BASE_DEC, NULL, 0x7F, NULL, HFILL} }, { &hf_infiniband_packet_sequence_number, { "Packet Sequence Number", "infiniband.bth.psn", FT_UINT24, BASE_DEC, NULL, 0x0, NULL, HFILL} }, /* Raw Header (RWH) */ { &hf_infiniband_RWH, { "Raw Header", "infiniband.rwh", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL} }, { &hf_infiniband_reserved16_RWH, { "Reserved (16 bits)", "infiniband.rwh.reserved", FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL} }, { &hf_infiniband_etype, { "Ethertype", "infiniband.rwh.etype", FT_UINT16, BASE_HEX, NULL /*VALS(etype_vals)*/, 0x0, "Type", HFILL } }, /* Reliable Datagram Extended Transport Header (RDETH) */ { &hf_infiniband_RDETH, { "Reliable Datagram Extended Transport Header", "infiniband.rdeth", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL} }, { &hf_infiniband_reserved8_RDETH, { "Reserved (8 bits)", "infiniband.rdeth.reserved8", FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL} }, { &hf_infiniband_ee_context, { "E2E Context", "infiniband.rdeth.eecnxt", FT_UINT24, BASE_DEC, NULL, 0x0, NULL, HFILL} }, /* Datagram Extended Transport Header (DETH) */ { &hf_infiniband_DETH, { "Datagram Extended Transport Header", "infiniband.deth", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL} }, { &hf_infiniband_queue_key, { "Queue Key", "infiniband.deth.q_key", FT_UINT64, BASE_DEC, NULL, 0x0, NULL, HFILL} }, { &hf_infiniband_reserved8_DETH, { "Reserved (8 bits)", "infiniband.deth.reserved8", FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL} }, { &hf_infiniband_source_qp, { "Source Queue Pair", "infiniband.deth.srcqp", FT_UINT32, BASE_HEX, NULL, 0x0, NULL, HFILL} }, /* RDMA Extended Transport Header (RETH) */ { &hf_infiniband_RETH, { "RDMA Extended Transport Header", "infiniband.reth", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL} }, { &hf_infiniband_virtual_address, { "Virtual Address", "infiniband.reth.va", FT_UINT64, BASE_DEC, NULL, 0x0, NULL, HFILL} }, { &hf_infiniband_remote_key, { "Remote Key", "infiniband.reth.r_key", FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL} }, { &hf_infiniband_dma_length, { "DMA Length", "infiniband.reth.dmalen", FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL} }, /* Atomic Extended Transport Header (AtomicETH) */ { &hf_infiniband_AtomicETH, { "Atomic Extended Transport Header", "infiniband.atomiceth", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL} }, #if 0 { &hf_infiniband_virtual_address_AtomicETH, { "Virtual Address", "infiniband.atomiceth.va", FT_UINT64, BASE_DEC, NULL, 0x0, NULL, HFILL} }, { &hf_infiniband_remote_key_AtomicETH, { "Remote Key", "infiniband.atomiceth.r_key", FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL} }, #endif { &hf_infiniband_swap_or_add_data, { "Swap (Or Add) Data", "infiniband.atomiceth.swapdt", FT_UINT64, BASE_DEC, NULL, 0x0, NULL, HFILL} }, { &hf_infiniband_compare_data, { "Compare Data", "infiniband.atomiceth.cmpdt", FT_UINT64, BASE_DEC, NULL, 0x0, NULL, HFILL} }, /* ACK Extended Transport Header (AETH) */ { &hf_infiniband_AETH, { "ACK Extended Transport Header", "infiniband.aeth", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL} }, { &hf_infiniband_syndrome, { "Syndrome", "infiniband.aeth.syndrome", FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL} }, { &hf_infiniband_message_sequence_number, { "Message Sequence Number", "infiniband.aeth.msn", FT_UINT24, BASE_DEC, NULL, 0x0, NULL, HFILL} }, /* Atomic ACK Extended Transport Header (AtomicAckETH) */ { &hf_infiniband_AtomicAckETH, { "Atomic ACK Extended Transport Header", "infiniband.atomicacketh", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL} }, { &hf_infiniband_original_remote_data, { "Original Remote Data", "infiniband.atomicacketh.origremdt", FT_UINT64, BASE_DEC, NULL, 0x0, NULL, HFILL} }, /* Immediate Extended Transport Header (ImmDT) */ { &hf_infiniband_IMMDT, { "Immediate Data", "infiniband.immdt", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL} }, /* Invalidate Extended Transport Header (IETH) */ { &hf_infiniband_IETH, { "RKey", "infiniband.ieth", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL} }, /* Payload */ { &hf_infiniband_payload, { "Payload", "infiniband.payload", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL} }, { &hf_infiniband_invariant_crc, { "Invariant CRC", "infiniband.invariant.crc", FT_UINT32, BASE_HEX, NULL, 0x0, NULL, HFILL} }, { &hf_infiniband_variant_crc, { "Variant CRC", "infiniband.variant.crc", FT_UINT16, BASE_HEX, NULL, 0x0, NULL, HFILL} }, { &hf_infiniband_raw_data, { "Raw Data", "infiniband.rawdata", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL} }, /* Unknown or Vendor Specific */ { &hf_infiniband_vendor, { "Unknown/Vendor Specific Data", "infiniband.vendor", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL} }, /* CM REQ Header */ {&hf_cm_req_local_comm_id, { "Local Communication ID", "infiniband.cm.req", FT_UINT32, BASE_HEX, NULL, 0x0, NULL, HFILL} }, {&hf_cm_req_service_id, { "ServiceID", "infiniband.cm.req.serviceid", FT_UINT64, BASE_HEX, NULL, 0x0, NULL, HFILL} }, {&hf_cm_req_local_ca_guid, { "Local CA GUID", "infiniband.cm.req.localcaguid", FT_UINT64, BASE_HEX, NULL, 0x0, NULL, HFILL} }, {&hf_cm_req_local_qkey, { "Local Q_Key", "infiniband.cm.req.localqkey", FT_UINT32, BASE_HEX, NULL, 0x0, NULL, HFILL} }, {&hf_cm_req_local_qpn, { "Local QPN", "infiniband.cm.req.localqpn", FT_UINT24, BASE_HEX, NULL, 0x0, NULL, HFILL} }, {&hf_cm_req_respo_res, { "Responder Resources", "infiniband.cm.req.responderres", FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL} }, {&hf_cm_req_local_eecn, { "Local EECN", "infiniband.cm.req.localeecn", FT_UINT24, BASE_HEX, NULL, 0x0, NULL, HFILL} }, {&hf_cm_req_init_depth, { "Initiator Depth", "infiniband.cm.req.initdepth", FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL} }, {&hf_cm_req_remote_eecn, { "Remote EECN", "infiniband.cm.req.remoteeecn", FT_UINT24, BASE_HEX, NULL, 0x0, NULL, HFILL} }, {&hf_cm_req_remote_cm_resp_to, { "Remote CM Response Timeout", "infiniband.cm.req.remoteresptout", FT_UINT8, BASE_HEX, NULL, 0x1f, NULL, HFILL} }, {&hf_cm_req_transp_serv_type, { "Transport Service Type", "infiniband.cm.req.transpsvctype", FT_UINT8, BASE_HEX, NULL, 0x60, NULL, HFILL} }, {&hf_cm_req_e2e_flow_ctrl, { "End-to-End Flow Control", "infiniband.cm.req.e2eflowctrl", FT_UINT8, BASE_HEX, NULL, 0x80, NULL, HFILL} }, {&hf_cm_req_start_psn, { "Starting PSN", "infiniband.cm.req.startpsn", FT_UINT24, BASE_HEX, NULL, 0x0, NULL, HFILL} }, {&hf_cm_req_local_cm_resp_to, { "Local CM Response Timeout", "infiniband.cm.req.localresptout", FT_UINT8, BASE_HEX, NULL, 0x1f, NULL, HFILL} }, {&hf_cm_req_retry_count, { "Retry Count", "infiniband.cm.req.retrcount", FT_UINT8, BASE_HEX, NULL, 0xe0, NULL, HFILL} }, {&hf_cm_req_pkey, { "Partition Key", "infiniband.cm.req.pkey", FT_UINT16, BASE_HEX, NULL, 0x0, NULL, HFILL} }, {&hf_cm_req_path_pp_mtu, { "Path Packet Payload MTU", "infiniband.cm.req.pppmtu", FT_UINT8, BASE_HEX, NULL, 0xf, NULL, HFILL} }, {&hf_cm_req_rdc_exists, { "RDC Exists", "infiniband.cm.req.rdcexist", FT_UINT8, BASE_HEX, NULL, 0x10, NULL, HFILL} }, {&hf_cm_req_rnr_retry_count, { "RNR Retry Count", "infiniband.cm.req.rnrretrcount", FT_UINT8, BASE_HEX, NULL, 0xe0, NULL, HFILL} }, {&hf_cm_req_max_cm_retries, { "Max CM Retries", "infiniband.cm.req.maxcmretr", FT_UINT8, BASE_HEX, NULL, 0xf, NULL, HFILL} }, {&hf_cm_req_srq, { "SRQ", "infiniband.cm.req.srq", FT_UINT8, BASE_HEX, NULL, 0x10, NULL, HFILL} }, {&hf_cm_req_primary_local_lid, { "Primary Local Port LID", "infiniband.cm.req.prim_locallid", FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL} }, {&hf_cm_req_primary_remote_lid, { "Primary Remote Port LID", "infiniband.cm.req.prim_remotelid", FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL} }, {&hf_cm_req_primary_local_gid, { "Primary Local Port GID", "infiniband.cm.req.prim_localgid", FT_IPv6, BASE_NONE, NULL, 0x0, NULL, HFILL} }, {&hf_cm_req_primary_remote_gid, { "Primary Remote Port GID", "infiniband.cm.req.prim_remotegid", FT_IPv6, BASE_NONE, NULL, 0x0, NULL, HFILL} }, {&hf_cm_req_primary_flow_label, { "Primary Flow Label", "infiniband.cm.req.prim_flowlabel", FT_UINT24, BASE_HEX, NULL, 0xfffff, NULL, HFILL} }, {&hf_cm_req_primary_packet_rate, { "Primary Packet Rate", "infiniband.cm.req.prim_pktrate", FT_UINT8, BASE_HEX, NULL, 0xfc, NULL, HFILL} }, {&hf_cm_req_primary_traffic_class, { "Primary Traffic Class", "infiniband.cm.req.prim_tfcclass", FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL} }, {&hf_cm_req_primary_hop_limit, { "Primary Hop Limit", "infiniband.cm.req.prim_hoplim", FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL} }, {&hf_cm_req_primary_sl, { "Primary SL", "infiniband.cm.req.prim_sl", FT_UINT8, BASE_HEX, NULL, 0xf, NULL, HFILL} }, {&hf_cm_req_primary_subnet_local, { "Primary Subnet Local", "infiniband.cm.req.prim_subnetlocal", FT_UINT8, BASE_HEX, NULL, 0x10, NULL, HFILL} }, {&hf_cm_req_primary_local_ack_to, { "Primary Local ACK Timeout", "infiniband.cm.req.prim_localacktout", FT_UINT8, BASE_HEX, NULL, 0x1f, NULL, HFILL} }, {&hf_cm_req_alt_local_lid, { "Alternate Local Port LID", "infiniband.cm.req.alt_locallid", FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL} }, {&hf_cm_req_alt_remote_lid, { "Alternate Remote Port LID", "infiniband.cm.req.alt_remotelid", FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL} }, {&hf_cm_req_alt_local_gid, { "Alternate Local Port GID", "infiniband.cm.req.alt_localgid", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL} }, {&hf_cm_req_alt_remote_gid, { "Alternate Remote Port GID", "infiniband.cm.req.alt_remotegid", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL} }, {&hf_cm_req_flow_label, { "Alternate Flow Label", "infiniband.cm.req.alt_flowlabel", FT_UINT24, BASE_HEX, NULL, 0xfffff, NULL, HFILL} }, {&hf_cm_req_packet_rate, { "Alternate Packet Rate", "infiniband.cm.req.alt_pktrate", FT_UINT8, BASE_HEX, NULL, 0xfc, NULL, HFILL} }, {&hf_cm_req_alt_traffic_class, { "Alternate Traffic Class", "infiniband.cm.req.alt_tfcclass", FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL} }, {&hf_cm_req_alt_hop_limit, { "Alternate Hop Limit", "infiniband.cm.req.alt_hoplim", FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL} }, {&hf_cm_req_SL, { "Alternate SL", "infiniband.cm.req.alt_sl", FT_UINT8, BASE_HEX, NULL, 0xf, NULL, HFILL} }, {&hf_cm_req_subnet_local, { "Alternate Subnet Local", "infiniband.cm.req.alt_subnetlocal", FT_UINT8, BASE_HEX, NULL, 0x10, NULL, HFILL} }, {&hf_cm_req_local_ACK_timeout, { "Alternate Local ACK Timeout", "infiniband.cm.req.alt_localacktout", FT_UINT8, BASE_HEX, NULL, 0x1f, NULL, HFILL} }, {&hf_cm_req_private_data, { "PrivateData", "infiniband.cm.req.private", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL} }, /* CM REP Header */ {&hf_cm_rep_localcommid, { "Local Communication ID", "infiniband.cm.rep", FT_UINT32, BASE_HEX, NULL, 0x0, NULL, HFILL} }, {&hf_cm_rep_remotecommid, { "Remote Communication ID", "infiniband.cm.rep.remotecommid", FT_UINT32, BASE_HEX, NULL, 0x0, NULL, HFILL} }, {&hf_cm_rep_localqkey, { "Local Q_Key", "infiniband.cm.rep.localqkey", FT_UINT32, BASE_HEX, NULL, 0x0, NULL, HFILL} }, {&hf_cm_rep_localqpn, { "Local QPN", "infiniband.cm.rep.localqpn", FT_UINT24, BASE_HEX, NULL, 0x0, NULL, HFILL} }, {&hf_cm_rep_localeecontnum, { "Local EE Context Number", "infiniband.cm.rep.localeecn", FT_UINT24, BASE_HEX, NULL, 0x0, NULL, HFILL} }, {&hf_cm_rep_startingpsn, { "Starting PSN", "infiniband.cm.rep.startpsn", FT_UINT24, BASE_HEX, NULL, 0x0, NULL, HFILL} }, {&hf_cm_rep_responderres, { "Responder Resources", "infiniband.cm.rep.respres", FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL} }, {&hf_cm_rep_initiatordepth, { "Initiator Depth", "infiniband.cm.rep.initdepth", FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL} }, {&hf_cm_rep_tgtackdelay, { "Target ACK Delay", "infiniband.cm.rep.tgtackdelay", FT_UINT8, BASE_HEX, NULL, 0x1f, NULL, HFILL} }, {&hf_cm_rep_failoveracc, { "Failover Accepted", "infiniband.cm.rep.failoveracc", FT_UINT8, BASE_HEX, NULL, 0x60, NULL, HFILL} }, {&hf_cm_rep_e2eflowctl, { "End-To-End Flow Control", "infiniband.cm.rep.e2eflowctrl", FT_UINT8, BASE_HEX, NULL, 0x80, NULL, HFILL} }, {&hf_cm_rep_rnrretrycount, { "RNR Retry Count", "infiniband.cm.rep.rnrretrcount", FT_UINT8, BASE_HEX, NULL, 0x7, NULL, HFILL} }, {&hf_cm_rep_srq, { "SRQ", "infiniband.cm.rep.srq", FT_UINT8, BASE_HEX, NULL, 0x8, NULL, HFILL} }, {&hf_cm_rep_localcaguid, { "Local CA GUID", "infiniband.cm.rep.localcaguid", FT_UINT64, BASE_HEX, NULL, 0x0, NULL, HFILL} }, {&hf_cm_rep_privatedata, { "PrivateData", "infiniband.cm.rep.private", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL} }, /* IB CM RTU Header */ {&hf_cm_rtu_localcommid, { "Local Communication ID", "infiniband.cm.rtu.localcommid", FT_UINT32, BASE_HEX, NULL, 0x0, NULL, HFILL} }, {&hf_cm_rtu_remotecommid, { "Remote Communication ID", "infiniband.cm.rtu.remotecommid", FT_UINT32, BASE_HEX, NULL, 0x0, NULL, HFILL} }, {&hf_cm_rtu_privatedata, { "PrivateData", "infiniband.cm.rtu.private", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL} }, /* CM REJ Header */ {&hf_cm_rej_local_commid, { "Local Communication ID", "infiniband.cm.rej.localcommid", FT_UINT32, BASE_HEX, NULL, 0x0, NULL, HFILL} }, {&hf_cm_rej_remote_commid, { "Remote Communication ID", "infiniband.cm.rej.remotecommid", FT_UINT32, BASE_HEX, NULL, 0x0, NULL, HFILL} }, {&hf_cm_rej_msg_rej, { "Message REJected", "infiniband.cm.rej.msgrej", FT_UINT8, BASE_HEX, NULL, 0x3, NULL, HFILL} }, {&hf_cm_rej_rej_info_len, { "Reject Info Length", "infiniband.cm.rej.rejinfolen", FT_UINT8, BASE_HEX, NULL, 0x7f, NULL, HFILL} }, {&hf_cm_rej_reason, { "Reason", "infiniband.cm.rej.reason", FT_UINT16, BASE_HEX, NULL, 0x0, NULL, HFILL} }, {&hf_cm_rej_add_rej_info, { "Additional Reject Information (ARI)", "infiniband.cm.rej.ari", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL} }, {&hf_cm_rej_private_data, { "PrivateData", "infiniband.cm.rej.private", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL} }, /* MAD Base Header */ { &hf_infiniband_MAD, { "MAD (Management Datagram) Common Header", "infiniband.mad", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL} }, { &hf_infiniband_base_version, { "Base Version", "infiniband.mad.baseversion", FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL} }, { &hf_infiniband_mgmt_class, { "Management Class", "infiniband.mad.mgmtclass", FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL} }, { &hf_infiniband_class_version, { "Class Version", "infiniband.mad.classversion", FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL} }, #if 0 { &hf_infiniband_reserved1, { "Reserved", "infiniband.mad.reserved1", FT_UINT8, BASE_HEX, NULL, 0x80, NULL, HFILL} }, #endif { &hf_infiniband_method, { "Method", "infiniband.mad.method", FT_UINT8, BASE_HEX, VALS(mad_method_str), 0x0, NULL, HFILL} }, { &hf_infiniband_status, { "Status", "infiniband.mad.status", FT_UINT16, BASE_HEX, NULL, 0x0, NULL, HFILL} }, { &hf_infiniband_class_specific, { "Class Specific", "infiniband.mad.classspecific", FT_UINT16, BASE_HEX, NULL, 0x0, NULL, HFILL} }, { &hf_infiniband_transaction_id, { "Transaction ID", "infiniband.mad.transactionid", FT_UINT64, BASE_HEX, NULL, 0x0, NULL, HFILL} }, { &hf_infiniband_attribute_id, { "Attribute ID", "infiniband.mad.attributeid", FT_UINT16, BASE_HEX, NULL, 0x0, NULL, HFILL} }, { &hf_infiniband_reserved16, { "Reserved", "infiniband.mad.reserved16", FT_UINT16, BASE_HEX, NULL, 0x0, NULL, HFILL} }, { &hf_infiniband_attribute_modifier, { "Attribute Modifier", "infiniband.mad.attributemodifier", FT_UINT32, BASE_HEX, NULL, 0x0, NULL, HFILL} }, { &hf_infiniband_data, { "MAD Data Payload", "infiniband.mad.data", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL} }, /* RMPP Header */ { &hf_infiniband_RMPP, { "RMPP (Reliable Multi-Packet Transaction Protocol)", "infiniband.rmpp", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL} }, { &hf_infiniband_rmpp_version, { "RMPP Type", "infiniband.rmpp.rmppversion", FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL} }, { &hf_infiniband_rmpp_type, { "RMPP Type", "infiniband.rmpp.rmpptype", FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL} }, { &hf_infiniband_r_resp_time, { "R Resp Time", "infiniband.rmpp.rresptime", FT_UINT8, BASE_HEX, NULL, 0xF0, NULL, HFILL} }, { &hf_infiniband_rmpp_flags, { "RMPP Flags", "infiniband.rmpp.rmppflags", FT_UINT8, BASE_HEX, VALS(RMPP_Flags), 0x0F, NULL, HFILL} }, { &hf_infiniband_rmpp_status, { "RMPP Status", "infiniband.rmpp.rmppstatus", FT_UINT8, BASE_HEX, VALS(RMPP_Status), 0x0, NULL, HFILL} }, { &hf_infiniband_rmpp_data1, { "RMPP Data 1", "infiniband.rmpp.data1", FT_UINT32, BASE_HEX, NULL, 0x0, NULL, HFILL} }, { &hf_infiniband_rmpp_data2, { "RMPP Data 2", "infiniband.rmpp.data2", FT_UINT32, BASE_HEX, NULL, 0x0, NULL, HFILL} }, /* RMPP Data */ #if 0 { &hf_infiniband_RMPP_DATA, { "RMPP Data (Reliable Multi-Packet Transaction Protocol)", "infiniband.rmpp.data", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL} }, #endif { &hf_infiniband_segment_number, { "Segment Number", "infiniband.rmpp.segmentnumber", FT_UINT32, BASE_HEX, NULL, 0x0, NULL, HFILL} }, { &hf_infiniband_payload_length32, { "Payload Length", "infiniband.rmpp.payloadlength", FT_UINT32, BASE_HEX, NULL, 0x0, NULL, HFILL} }, { &hf_infiniband_transferred_data, { "Transferred Data", "infiniband.rmpp.transferreddata", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL} }, /* RMPP ACK */ { &hf_infiniband_new_window_last, { "New Window Last", "infiniband.rmpp.newwindowlast", FT_UINT32, BASE_HEX, NULL, 0x0, NULL, HFILL} }, { &hf_infiniband_reserved220, { "Segment Number", "infiniband.rmpp.reserved220", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL} }, /* RMPP ABORT/STOP */ { &hf_infiniband_reserved32, { "Reserved (32 bits)", "infiniband.rmpp.reserved32", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL} }, { &hf_infiniband_optional_extended_error_data, { "Optional Extended Error Data", "infiniband.rmpp.extendederrordata", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL} }, /* SMP Data (LID Routed) */ { &hf_infiniband_SMP_LID, { "Subnet Management Packet (LID Routed)", "infiniband.smplid", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL} }, { &hf_infiniband_m_key, { "M_Key", "infiniband.smplid.mkey", FT_UINT64, BASE_HEX, NULL, 0x0, NULL, HFILL} }, { &hf_infiniband_smp_data, { "SMP Data", "infiniband.smplid.smpdata", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL} }, { &hf_infiniband_reserved1024, { "Reserved (1024 bits)", "infiniband.smplid.reserved1024", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL} }, { &hf_infiniband_reserved256, { "Reserved (256 bits)", "infiniband.smplid.reserved256", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL} }, /* XX: All following verified/corrected against Infiniband 1.2.1 Specification */ /* SMP Data Directed Route */ { &hf_infiniband_SMP_DIRECTED, { "Subnet Management Packet (Directed Route)", "infiniband.smpdirected", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL} }, { &hf_infiniband_smp_status, { "Status", "infiniband.smpdirected.smpstatus", FT_UINT16, BASE_HEX, NULL, 0x0, NULL, HFILL} }, { &hf_infiniband_hop_pointer, { "Hop Pointer", "infiniband.smpdirected.hoppointer", FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL} }, { &hf_infiniband_hop_count, { "Hop Count", "infiniband.smpdirected.hopcount", FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL} }, { &hf_infiniband_dr_slid, { "DrSLID", "infiniband.smpdirected.drslid", FT_UINT16, BASE_HEX, NULL, 0x0, NULL, HFILL} }, { &hf_infiniband_dr_dlid, { "DrDLID", "infiniband.smpdirected.drdlid", FT_UINT16, BASE_HEX, NULL, 0x0, NULL, HFILL} }, { &hf_infiniband_reserved28, { "Reserved (224 bits)", "infiniband.smpdirected.reserved28", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL} }, { &hf_infiniband_d, { "D (Direction Bit)", "infiniband.smpdirected.d", FT_UINT64, BASE_HEX, NULL, 0x8000, NULL, HFILL} }, { &hf_infiniband_initial_path, { "Initial Path", "infiniband.smpdirected.initialpath", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL} }, { &hf_infiniband_return_path, { "Return Path", "infiniband.smpdirected.returnpath", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL} }, /* SA MAD Header */ { &hf_infiniband_SA, { "SA Packet (Subnet Administration)", "infiniband.sa.drdlid", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL} }, { &hf_infiniband_sm_key, { "SM_Key (Verification Key)", "infiniband.sa.smkey", FT_UINT64, BASE_HEX, NULL, 0x0, NULL, HFILL} }, { &hf_infiniband_attribute_offset, { "Attribute Offset", "infiniband.sa.attributeoffset", FT_UINT16, BASE_HEX, NULL, 0x0, NULL, HFILL} }, { &hf_infiniband_component_mask, { "Component Mask", "infiniband.sa.componentmask", FT_UINT64, BASE_HEX, NULL, 0x0, NULL, HFILL} }, { &hf_infiniband_subnet_admin_data, { "Subnet Admin Data", "infiniband.sa.subnetadmindata", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL} }, /* Mellanox EoIB encapsulation header */ { &hf_infiniband_EOIB, { "Mellanox EoIB Encapsulation Header", "infiniband.eoib", FT_NONE, BASE_NONE, NULL, 0x0, NULL, HFILL} }, { &hf_infiniband_ver, { "Version", "infiniband.eoib.version", FT_UINT16, BASE_HEX, NULL, 0x3000, NULL, HFILL} }, { &hf_infiniband_tcp_chk, { "TCP Checksum", "infiniband.eoib.tcp_chk", FT_UINT16, BASE_HEX, NULL, 0x0c00, NULL, HFILL} }, { &hf_infiniband_ip_chk, { "IP Checksum", "infiniband.eoib.ip_chk", FT_UINT16, BASE_HEX, NULL, 0x0300, NULL, HFILL} }, { &hf_infiniband_fcs, { "FCS Field Present", "infiniband.eoib.fcs", FT_BOOLEAN, 16, NULL, 0x0040, NULL, HFILL} }, { &hf_infiniband_ms, { "More Segments to Follow", "infiniband.eoib.ms", FT_BOOLEAN, 16, NULL, 0x0020, NULL, HFILL} }, { &hf_infiniband_seg_off, { "Segment Offset", "infiniband.eoib.ip_seg_offset", FT_UINT16, BASE_DEC, NULL, 0x001f, NULL, HFILL} }, { &hf_infiniband_seg_id, { "Segment ID", "infiniband.eoib.ip_seg_id", FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL} }, /* NodeDescription */ { &hf_infiniband_NodeDescription_NodeString, { "NodeString", "infiniband.nodedescription.nodestring", FT_STRING, BASE_NONE, NULL, 0x0, NULL, HFILL} }, /* NodeInfo */ { &hf_infiniband_NodeInfo_BaseVersion, { "BaseVersion", "infiniband.nodeinfo.baseversion", FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL} }, { &hf_infiniband_NodeInfo_ClassVersion, { "ClassVersion", "infiniband.nodeinfo.classversion", FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL} }, { &hf_infiniband_NodeInfo_NodeType, { "NodeType", "infiniband.nodeinfo.nodetype", FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL} }, { &hf_infiniband_NodeInfo_NumPorts, { "NumPorts", "infiniband.nodeinfo.numports", FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL} }, { &hf_infiniband_NodeInfo_SystemImageGUID, { "SystemImageGUID", "infiniband.nodeinfo.systemimageguid", FT_UINT64, BASE_HEX, NULL, 0x0, NULL, HFILL} }, { &hf_infiniband_NodeInfo_NodeGUID, { "NodeGUID", "infiniband.nodeinfo.nodeguid", FT_UINT64, BASE_HEX, NULL, 0x0, NULL, HFILL} }, { &hf_infiniband_NodeInfo_PortGUID, { "PortGUID", "infiniband.nodeinfo.portguid", FT_UINT64, BASE_HEX, NULL, 0x0, NULL, HFILL} }, { &hf_infiniband_NodeInfo_PartitionCap, { "PartitionCap", "infiniband.nodeinfo.partitioncap", FT_UINT16, BASE_HEX, NULL, 0x0, NULL, HFILL} }, { &hf_infiniband_NodeInfo_DeviceID, { "DeviceID", "infiniband.nodeinfo.deviceid", FT_UINT16, BASE_HEX, NULL, 0x0, NULL, HFILL} }, { &hf_infiniband_NodeInfo_Revision, { "Revision", "infiniband.nodeinfo.revision", FT_UINT32, BASE_HEX, NULL, 0x0, NULL, HFILL} }, { &hf_infiniband_NodeInfo_LocalPortNum, { "LocalPortNum", "infiniband.nodeinfo.localportnum", FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL} }, { &hf_infiniband_NodeInfo_VendorID, { "VendorID", "infiniband.nodeinfo.vendorid", FT_UINT24, BASE_HEX, NULL, 0x0, NULL, HFILL} }, /* SwitchInfo */ { &hf_infiniband_SwitchInfo_LinearFDBCap, { "LinearFDBCap", "infiniband.switchinfo.linearfdbcap", FT_UINT16, BASE_HEX, NULL, 0x0, NULL, HFILL} }, { &hf_infiniband_SwitchInfo_RandomFDBCap, { "RandomFDBCap", "infiniband.switchinfo.randomfdbcap", FT_UINT16, BASE_HEX, NULL, 0x0, NULL, HFILL} }, { &hf_infiniband_SwitchInfo_MulticastFDBCap, { "MulticastFDBCap", "infiniband.switchinfo.multicastfdbcap", FT_UINT16, BASE_HEX, NULL, 0x0, NULL, HFILL} }, { &hf_infiniband_SwitchInfo_LinearFDBTop, { "LinearFDBTop", "infiniband.switchinfo.linearfdbtop", FT_UINT16, BASE_HEX, NULL, 0x0, NULL, HFILL} }, { &hf_infiniband_SwitchInfo_DefaultPort, { "DefaultPort", "infiniband.switchinfo.defaultport", FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL} }, { &hf_infiniband_SwitchInfo_DefaultMulticastPrimaryPort, { "DefaultMulticastPrimaryPort", "infiniband.switchinfo.defaultmulticastprimaryport", FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL} }, { &hf_infiniband_SwitchInfo_DefaultMulticastNotPrimaryPort, { "DefaultMulticastNotPrimaryPort", "infiniband.switchinfo.defaultmulticastnotprimaryport", FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL} }, { &hf_infiniband_SwitchInfo_LifeTimeValue, { "LifeTimeValue", "infiniband.switchinfo.lifetimevalue", FT_UINT8, BASE_HEX, NULL, 0xF8, NULL, HFILL} }, { &hf_infiniband_SwitchInfo_PortStateChange, { "PortStateChange", "infiniband.switchinfo.portstatechange", FT_UINT8, BASE_HEX, NULL, 0x04, NULL, HFILL} }, { &hf_infiniband_SwitchInfo_OptimizedSLtoVLMappingProgramming, { "OptimizedSLtoVLMappingProgramming", "infiniband.switchinfo.optimizedsltovlmappingprogramming", FT_UINT8, BASE_HEX, NULL, 0x03, NULL, HFILL} }, { &hf_infiniband_SwitchInfo_LIDsPerPort, { "LIDsPerPort", "infiniband.switchinfo.lidsperport", FT_UINT16, BASE_HEX, NULL, 0x0, NULL, HFILL} }, { &hf_infiniband_SwitchInfo_PartitionEnforcementCap, { "PartitionEnforcementCap", "infiniband.switchinfo.partitionenforcementcap", FT_UINT16, BASE_HEX, NULL, 0x0, NULL, HFILL} }, { &hf_infiniband_SwitchInfo_InboundEnforcementCap, { "InboundEnforcementCap", "infiniband.switchinfo.inboundenforcementcap", FT_UINT8, BASE_HEX, NULL, 0x80, NULL, HFILL} }, { &hf_infiniband_SwitchInfo_OutboundEnforcementCap, { "OutboundEnforcementCap", "infiniband.switchinfo.outboundenforcementcap", FT_UINT8, BASE_HEX, NULL, 0x40, NULL, HFILL} }, { &hf_infiniband_SwitchInfo_FilterRawInboundCap, { "FilterRawInboundCap", "infiniband.switchinfo.filterrawinboundcap", FT_UINT8, BASE_HEX, NULL, 0x20, NULL, HFILL} }, { &hf_infiniband_SwitchInfo_FilterRawOutboundCap, { "FilterRawOutboundCap", "infiniband.switchinfo.filterrawoutboundcap", FT_UINT8, BASE_HEX, NULL, 0x10, NULL, HFILL} }, { &hf_infiniband_SwitchInfo_EnhancedPortZero, { "EnhancedPortZero", "infiniband.switchinfo.enhancedportzero", FT_UINT8, BASE_HEX, NULL, 0x08, NULL, HFILL} }, /* GUIDInfo */ #if 0 { &hf_infiniband_GUIDInfo_GUIDBlock, { "GUIDBlock", "infiniband.switchinfo.guidblock", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL} }, #endif { &hf_infiniband_GUIDInfo_GUID, { "GUID", "infiniband.switchinfo.guid", FT_UINT64, BASE_HEX, NULL, 0x0, NULL, HFILL} }, /* PortInfo */ { &hf_infiniband_PortInfo_M_Key, { "M_Key", "infiniband.portinfo.m_key", FT_UINT64, BASE_HEX, NULL, 0x0, NULL, HFILL} }, { &hf_infiniband_PortInfo_GidPrefix, { "GidPrefix", "infiniband.portinfo.guid", FT_UINT64, BASE_HEX, NULL, 0x0, NULL, HFILL} }, { &hf_infiniband_PortInfo_LID, { "LID", "infiniband.portinfo.lid", FT_UINT16, BASE_HEX, NULL, 0x0, NULL, HFILL} }, { &hf_infiniband_PortInfo_MasterSMLID, { "MasterSMLID", "infiniband.portinfo.mastersmlid", FT_UINT16, BASE_HEX, NULL, 0x0, NULL, HFILL} }, { &hf_infiniband_PortInfo_CapabilityMask, { "CapabilityMask", "infiniband.portinfo.capabilitymask", FT_UINT32, BASE_HEX, NULL, 0x0, NULL, HFILL} }, /* Capability Mask Flags */ { &hf_infiniband_PortInfo_CapabilityMask_SM, { "SM", "infiniband.portinfo.capabilitymask.issm", FT_UINT32, BASE_HEX, NULL, 0x00000002, NULL, HFILL} }, { &hf_infiniband_PortInfo_CapabilityMask_NoticeSupported, { "NoticeSupported", "infiniband.portinfo.capabilitymask.noticesupported", FT_UINT32, BASE_HEX, NULL, 0x00000004, NULL, HFILL} }, { &hf_infiniband_PortInfo_CapabilityMask_TrapSupported, { "TrapSupported", "infiniband.portinfo.capabilitymask.trapsupported", FT_UINT32, BASE_HEX, NULL, 0x00000008, NULL, HFILL} }, { &hf_infiniband_PortInfo_CapabilityMask_OptionalPDSupported, { "OptionalPDSupported", "infiniband.portinfo.capabilitymask.optionalpdsupported", FT_UINT32, BASE_HEX, NULL, 0x00000010, NULL, HFILL} }, { &hf_infiniband_PortInfo_CapabilityMask_AutomaticMigrationSupported, { "AutomaticMigrationSupported", "infiniband.portinfo.capabilitymask.automaticmigrationsupported", FT_UINT32, BASE_HEX, NULL, 0x00000020, NULL, HFILL} }, { &hf_infiniband_PortInfo_CapabilityMask_SLMappingSupported, { "SLMappingSupported", "infiniband.portinfo.capabilitymask.slmappingsupported", FT_UINT32, BASE_HEX, NULL, 0x00000040, NULL, HFILL} }, { &hf_infiniband_PortInfo_CapabilityMask_MKeyNVRAM, { "MKeyNVRAM", "infiniband.portinfo.capabilitymask.mkeynvram", FT_UINT32, BASE_HEX, NULL, 0x00000080, NULL, HFILL} }, { &hf_infiniband_PortInfo_CapabilityMask_PKeyNVRAM, { "PKeyNVRAM", "infiniband.portinfo.capabilitymask.pkeynvram", FT_UINT32, BASE_HEX, NULL, 0x00000100, NULL, HFILL} }, { &hf_infiniband_PortInfo_CapabilityMask_LEDInfoSupported, { "LEDInfoSupported", "infiniband.portinfo.capabilitymask.ledinfosupported", FT_UINT32, BASE_HEX, NULL, 0x00000200, NULL, HFILL} }, { &hf_infiniband_PortInfo_CapabilityMask_SMdisabled, { "SMdisabled", "infiniband.portinfo.capabilitymask.smdisabled", FT_UINT32, BASE_HEX, NULL, 0x00000400, NULL, HFILL} }, { &hf_infiniband_PortInfo_CapabilityMask_SystemImageGUIDSupported, { "SystemImageGUIDSupported", "infiniband.portinfo.capabilitymask.systemimageguidsupported", FT_UINT32, BASE_HEX, NULL, 0x00000800, NULL, HFILL} }, { &hf_infiniband_PortInfo_CapabilityMask_PKeySwitchExternalPortTrapSupported, { "PKeySwitchExternalPortTrapSupported", "infiniband.portinfo.capabilitymask.pkeyswitchexternalporttrapsupported", FT_UINT32, BASE_HEX, NULL, 0x00001000, NULL, HFILL} }, { &hf_infiniband_PortInfo_CapabilityMask_CommunicationsManagementSupported, { "CommunicationsManagementSupported", "infiniband.portinfo.capabilitymask.communicationsmanagementsupported", FT_UINT32, BASE_HEX, NULL, 0x00010000, NULL, HFILL} }, { &hf_infiniband_PortInfo_CapabilityMask_SNMPTunnelingSupported, { "SNMPTunnelingSupported", "infiniband.portinfo.capabilitymask.snmptunnelingsupported", FT_UINT32, BASE_HEX, NULL, 0x00020000, NULL, HFILL} }, { &hf_infiniband_PortInfo_CapabilityMask_ReinitSupported, { "ReinitSupported", "infiniband.portinfo.capabilitymask.reinitsupported", FT_UINT32, BASE_HEX, NULL, 0x00040000, NULL, HFILL} }, { &hf_infiniband_PortInfo_CapabilityMask_DeviceManagementSupported, { "DeviceManagementSupported", "infiniband.portinfo.capabilitymask.devicemanagementsupported", FT_UINT32, BASE_HEX, NULL, 0x00080000, NULL, HFILL} }, { &hf_infiniband_PortInfo_CapabilityMask_VendorClassSupported, { "VendorClassSupported", "infiniband.portinfo.capabilitymask.vendorclasssupported", FT_UINT32, BASE_HEX, NULL, 0x00100000, NULL, HFILL} }, { &hf_infiniband_PortInfo_CapabilityMask_DRNoticeSupported, { "DRNoticeSupported", "infiniband.portinfo.capabilitymask.drnoticesupported", FT_UINT32, BASE_HEX, NULL, 0x00200000, NULL, HFILL} }, { &hf_infiniband_PortInfo_CapabilityMask_CapabilityMaskNoticeSupported, { "CapabilityMaskNoticeSupported", "infiniband.portinfo.capabilitymask.capabilitymasknoticesupported", FT_UINT32, BASE_HEX, NULL, 0x00400000, NULL, HFILL} }, { &hf_infiniband_PortInfo_CapabilityMask_BootManagementSupported, { "BootManagementSupported", "infiniband.portinfo.capabilitymask.bootmanagementsupported", FT_UINT32, BASE_HEX, NULL, 0x00800000, NULL, HFILL} }, { &hf_infiniband_PortInfo_CapabilityMask_LinkRoundTripLatencySupported, { "LinkRoundTripLatencySupported", "infiniband.portinfo.capabilitymask.linkroundtriplatencysupported", FT_UINT32, BASE_HEX, NULL, 0x01000000, NULL, HFILL} }, { &hf_infiniband_PortInfo_CapabilityMask_ClientRegistrationSupported, { "ClientRegistrationSupported", "infiniband.portinfo.capabilitymask.clientregistrationsupported", FT_UINT32, BASE_HEX, NULL, 0x02000000, NULL, HFILL} }, { &hf_infiniband_PortInfo_CapabilityMask_OtherLocalChangesNoticeSupported, { "OtherLocalChangesNoticeSupported", "infiniband.portinfo.capabilitymask.otherlocalchangesnoticesupported", FT_UINT32, BASE_HEX, NULL, 0x04000000, NULL, HFILL} }, { &hf_infiniband_PortInfo_CapabilityMask_LinkSpeedWIdthPairsTableSupported, { "LinkSpeedWIdthPairsTableSupported", "infiniband.portinfo.capabilitymask.linkspeedwidthpairstablesupported", FT_UINT32, BASE_HEX, NULL, 0x08000000, NULL, HFILL} }, /* End Capability Mask Flags */ /* PortInfo */ { &hf_infiniband_PortInfo_DiagCode, { "DiagCode", "infiniband.portinfo.diagcode", FT_UINT16, BASE_HEX, NULL, 0x0, NULL, HFILL} }, { &hf_infiniband_PortInfo_M_KeyLeasePeriod, { "M_KeyLeasePeriod", "infiniband.portinfo.m_keyleaseperiod", FT_UINT16, BASE_HEX, NULL, 0x0, NULL, HFILL} }, { &hf_infiniband_PortInfo_LocalPortNum, { "LocalPortNum", "infiniband.portinfo.localportnum", FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL} }, { &hf_infiniband_PortInfo_LinkWidthEnabled, { "LinkWidthEnabled", "infiniband.portinfo.linkwidthenabled", FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL} }, { &hf_infiniband_PortInfo_LinkWidthSupported, { "LinkWidthSupported", "infiniband.portinfo.linkwidthsupported", FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL} }, { &hf_infiniband_PortInfo_LinkWidthActive, { "LinkWidthActive", "infiniband.portinfo.linkwidthactive", FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL} }, { &hf_infiniband_PortInfo_LinkSpeedSupported, { "LinkSpeedSupported", "infiniband.portinfo.linkspeedsupported", FT_UINT8, BASE_HEX, NULL, 0xF0, NULL, HFILL} }, { &hf_infiniband_PortInfo_PortState, { "PortState", "infiniband.portinfo.portstate", FT_UINT8, BASE_HEX, NULL, 0x0F, NULL, HFILL} }, { &hf_infiniband_PortInfo_PortPhysicalState, { "PortPhysicalState", "infiniband.portinfo.portphysicalstate", FT_UINT8, BASE_HEX, NULL, 0xF0, NULL, HFILL} }, { &hf_infiniband_PortInfo_LinkDownDefaultState, { "LinkDownDefaultState", "infiniband.portinfo.linkdowndefaultstate", FT_UINT8, BASE_HEX, NULL, 0x0F, NULL, HFILL} }, { &hf_infiniband_PortInfo_M_KeyProtectBits, { "M_KeyProtectBits", "infiniband.portinfo.m_keyprotectbits", FT_UINT8, BASE_HEX, NULL, 0xC0, NULL, HFILL} }, { &hf_infiniband_PortInfo_LMC, { "LMC", "infiniband.portinfo.lmc", FT_UINT8, BASE_HEX, NULL, 0x07, NULL, HFILL} }, { &hf_infiniband_PortInfo_LinkSpeedActive, { "LinkSpeedActive", "infiniband.portinfo.linkspeedactive", FT_UINT8, BASE_HEX, NULL, 0xF0, NULL, HFILL} }, { &hf_infiniband_PortInfo_LinkSpeedEnabled, { "LinkSpeedEnabled", "infiniband.portinfo.linkspeedenabled", FT_UINT8, BASE_HEX, NULL, 0x0F, NULL, HFILL} }, { &hf_infiniband_PortInfo_NeighborMTU, { "NeighborMTU", "infiniband.portinfo.neighbormtu", FT_UINT8, BASE_HEX, NULL, 0xF0, NULL, HFILL} }, { &hf_infiniband_PortInfo_MasterSMSL, { "MasterSMSL", "infiniband.portinfo.mastersmsl", FT_UINT8, BASE_HEX, NULL, 0x0F, NULL, HFILL} }, { &hf_infiniband_PortInfo_VLCap, { "VLCap", "infiniband.portinfo.vlcap", FT_UINT8, BASE_HEX, NULL, 0xF0, NULL, HFILL} }, { &hf_infiniband_PortInfo_InitType, { "InitType", "infiniband.portinfo.inittype", FT_UINT8, BASE_HEX, NULL, 0x0F, NULL, HFILL} }, { &hf_infiniband_PortInfo_VLHighLimit, { "VLHighLimit", "infiniband.portinfo.vlhighlimit", FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL} }, { &hf_infiniband_PortInfo_VLArbitrationHighCap, { "VLArbitrationHighCap", "infiniband.portinfo.vlarbitrationhighcap", FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL} }, { &hf_infiniband_PortInfo_VLArbitrationLowCap, { "VLArbitrationLowCap", "infiniband.portinfo.vlarbitrationlowcap", FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL} }, { &hf_infiniband_PortInfo_InitTypeReply, { "InitTypeReply", "infiniband.portinfo.inittypereply", FT_UINT8, BASE_HEX, NULL, 0xF0, NULL, HFILL} }, { &hf_infiniband_PortInfo_MTUCap, { "MTUCap", "infiniband.portinfo.mtucap", FT_UINT8, BASE_HEX, NULL, 0x0F, NULL, HFILL} }, { &hf_infiniband_PortInfo_VLStallCount, { "VLStallCount", "infiniband.portinfo.vlstallcount", FT_UINT8, BASE_HEX, NULL, 0xE0, NULL, HFILL} }, { &hf_infiniband_PortInfo_HOQLife, { "HOQLife", "infiniband.portinfo.hoqlife", FT_UINT8, BASE_HEX, NULL, 0x1F, NULL, HFILL} }, { &hf_infiniband_PortInfo_OperationalVLs, { "OperationalVLs", "infiniband.portinfo.operationalvls", FT_UINT8, BASE_HEX, NULL, 0xF0, NULL, HFILL} }, { &hf_infiniband_PortInfo_PartitionEnforcementInbound, { "PartitionEnforcementInbound", "infiniband.portinfo.partitionenforcementinbound", FT_UINT8, BASE_HEX, NULL, 0x08, NULL, HFILL} }, { &hf_infiniband_PortInfo_PartitionEnforcementOutbound, { "PartitionEnforcementOutbound", "infiniband.portinfo.partitionenforcementoutbound", FT_UINT8, BASE_HEX, NULL, 0x04, NULL, HFILL} }, { &hf_infiniband_PortInfo_FilterRawInbound, { "FilterRawInbound", "infiniband.portinfo.filterrawinbound", FT_UINT8, BASE_HEX, NULL, 0x02, NULL, HFILL} }, { &hf_infiniband_PortInfo_FilterRawOutbound, { "FilterRawOutbound", "infiniband.portinfo.filterrawoutbound", FT_UINT8, BASE_HEX, NULL, 0x01, NULL, HFILL} }, { &hf_infiniband_PortInfo_M_KeyViolations, { "M_KeyViolations", "infiniband.portinfo.m_keyviolations", FT_UINT16, BASE_HEX, NULL, 0x0, NULL, HFILL} }, { &hf_infiniband_PortInfo_P_KeyViolations, { "P_KeyViolations", "infiniband.portinfo.p_keyviolations", FT_UINT16, BASE_HEX, NULL, 0x0, NULL, HFILL} }, { &hf_infiniband_PortInfo_Q_KeyViolations, { "Q_KeyViolations", "infiniband.portinfo.q_keyviolations", FT_UINT16, BASE_HEX, NULL, 0x0, NULL, HFILL} }, { &hf_infiniband_PortInfo_GUIDCap, { "GUIDCap", "infiniband.portinfo.guidcap", FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL} }, { &hf_infiniband_PortInfo_ClientReregister, { "ClientReregister", "infiniband.portinfo.clientreregister", FT_UINT8, BASE_HEX, NULL, 0x80, NULL, HFILL} }, { &hf_infiniband_PortInfo_SubnetTimeOut, { "SubnetTimeOut", "infiniband.portinfo.subnettimeout", FT_UINT8, BASE_HEX, NULL, 0x1F, NULL, HFILL} }, { &hf_infiniband_PortInfo_RespTimeValue, { "RespTimeValue", "infiniband.portinfo.resptimevalue", FT_UINT8, BASE_HEX, NULL, 0x1F, NULL, HFILL} }, { &hf_infiniband_PortInfo_LocalPhyErrors, { "LocalPhyErrors", "infiniband.portinfo.localphyerrors", FT_UINT8, BASE_HEX, NULL, 0xF0, NULL, HFILL} }, { &hf_infiniband_PortInfo_OverrunErrors, { "OverrunErrors", "infiniband.portinfo.overrunerrors", FT_UINT8, BASE_HEX, NULL, 0x0F, NULL, HFILL} }, { &hf_infiniband_PortInfo_MaxCreditHint, { "MaxCreditHint", "infiniband.portinfo.maxcredithint", FT_UINT16, BASE_HEX, NULL, 0x0, NULL, HFILL} }, { &hf_infiniband_PortInfo_LinkRoundTripLatency, { "LinkRoundTripLatency", "infiniband.portinfo.linkroundtriplatency", FT_UINT24, BASE_HEX, NULL, 0x0, NULL, HFILL} }, /* P_KeyTable */ { &hf_infiniband_P_KeyTable_P_KeyTableBlock, { "P_KeyTableBlock", "infiniband.p_keytable.p_keytableblock", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL} }, { &hf_infiniband_P_KeyTable_MembershipType, { "MembershipType", "infiniband.p_keytable.membershiptype", FT_UINT8, BASE_HEX, NULL, 0x80, NULL, HFILL} }, { &hf_infiniband_P_KeyTable_P_KeyBase, { "P_KeyBase", "infiniband.p_keytable.p_keybase", FT_UINT16, BASE_HEX, NULL, 0x7FFF, NULL, HFILL} }, /* SLtoVLMappingTable */ { &hf_infiniband_SLtoVLMappingTable_SLtoVL_HighBits, { "SL(x)toVL", "infiniband.sltovlmappingtable.sltovlhighbits", FT_UINT8, BASE_HEX, NULL, 0xF0, NULL, HFILL} }, { &hf_infiniband_SLtoVLMappingTable_SLtoVL_LowBits, { "SL(x)toVL", "infiniband.sltovlmappingtable.sltovllowbits", FT_UINT8, BASE_HEX, NULL, 0x0F, NULL, HFILL} }, /* VLArbitrationTable */ #if 0 { &hf_infiniband_VLArbitrationTable_VLWeightPairs, { "VLWeightPairs", "infiniband.vlarbitrationtable.vlweightpairs", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL} }, #endif { &hf_infiniband_VLArbitrationTable_VL, { "VL", "infiniband.vlarbitrationtable.vl", FT_UINT8, BASE_HEX, NULL, 0x0F, NULL, HFILL} }, { &hf_infiniband_VLArbitrationTable_Weight, { "Weight", "infiniband.vlarbitrationtable.weight", FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL} }, /* LinearForwardingTable */ #if 0 { &hf_infiniband_LinearForwardingTable_LinearForwardingTableBlock, { "LinearForwardingTableBlock", "infiniband.linearforwardingtable.linearforwardingtableblock", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL} }, #endif { &hf_infiniband_LinearForwardingTable_Port, { "Port", "infiniband.linearforwardingtable.port", FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL} }, /* RandomForwardingTable */ #if 0 { &hf_infiniband_RandomForwardingTable_RandomForwardingTableBlock, { "RandomForwardingTableBlock", "infiniband.randomforwardingtable.randomforwardingtableblock", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL} }, #endif { &hf_infiniband_RandomForwardingTable_LID, { "LID", "infiniband.randomforwardingtable.lid", FT_UINT16, BASE_HEX, NULL, 0x0, NULL, HFILL} }, { &hf_infiniband_RandomForwardingTable_Valid, { "Valid", "infiniband.randomforwardingtable.valid", FT_UINT8, BASE_HEX, NULL, 0x80, NULL, HFILL} }, { &hf_infiniband_RandomForwardingTable_LMC, { "LMC", "infiniband.randomforwardingtable.lmc", FT_UINT8, BASE_HEX, NULL, 0x70, NULL, HFILL} }, { &hf_infiniband_RandomForwardingTable_Port, { "Port", "infiniband.randomforwardingtable.port", FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL} }, /* MulticastForwardingTable */ #if 0 { &hf_infiniband_MulticastForwardingTable_MulticastForwardingTableBlock , { "MulticastForwardingTableBlock", "infiniband.multicastforwardingtable.multicastforwardingtableblock", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL} }, #endif { &hf_infiniband_MulticastForwardingTable_PortMask, { "PortMask", "infiniband.multicastforwardingtable.portmask", FT_UINT16, BASE_HEX, NULL, 0x0, NULL, HFILL} }, /* SMInfo */ { &hf_infiniband_SMInfo_GUID, { "GUID", "infiniband.sminfo.guid", FT_UINT64, BASE_HEX, NULL, 0x0, NULL, HFILL} }, { &hf_infiniband_SMInfo_SM_Key, { "SM_Key", "infiniband.sminfo.sm_key", FT_UINT64, BASE_HEX, NULL, 0x0, NULL, HFILL} }, { &hf_infiniband_SMInfo_ActCount, { "ActCount", "infiniband.sminfo.actcount", FT_UINT32, BASE_HEX, NULL, 0x0, NULL, HFILL} }, { &hf_infiniband_SMInfo_Priority, { "Priority", "infiniband.sminfo.priority", FT_UINT8, BASE_HEX, NULL, 0xF0, NULL, HFILL} }, { &hf_infiniband_SMInfo_SMState, { "SMState", "infiniband.sminfo.smstate", FT_UINT8, BASE_HEX, NULL, 0x0F, NULL, HFILL} }, /* VendorDiag */ { &hf_infiniband_VendorDiag_NextIndex, { "NextIndex", "infiniband.vendordiag.nextindex", FT_UINT16, BASE_HEX, NULL, 0x0, NULL, HFILL} }, { &hf_infiniband_VendorDiag_DiagData, { "DiagData", "infiniband.vendordiag.diagdata", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL} }, /* LedInfo */ { &hf_infiniband_LedInfo_LedMask, { "LedMask", "infiniband.ledinfo.ledmask", FT_UINT8, BASE_HEX, NULL, 0x80, NULL, HFILL} }, /* LinkSpeedWidthPairsTable */ { &hf_infiniband_LinkSpeedWidthPairsTable_NumTables, { "NumTables", "infiniband.linkspeedwidthpairstable.numtables", FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL} }, { &hf_infiniband_LinkSpeedWidthPairsTable_PortMask, { "PortMask", "infiniband.linkspeedwidthpairstable.portmask", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL} }, { &hf_infiniband_LinkSpeedWidthPairsTable_SpeedTwoFive, { "Speed 2.5 Gbps", "infiniband.linkspeedwidthpairstable.speedtwofive", FT_UINT8, BASE_HEX, NULL, 0x80, NULL, HFILL} }, { &hf_infiniband_LinkSpeedWidthPairsTable_SpeedFive, { "Speed 5 Gbps", "infiniband.linkspeedwidthpairstable.speedfive", FT_UINT8, BASE_HEX, NULL, 0x80, NULL, HFILL} }, { &hf_infiniband_LinkSpeedWidthPairsTable_SpeedTen, { "Speed 10 Gbps", "infiniband.linkspeedwidthpairstable.speedten", FT_UINT8, BASE_HEX, NULL, 0x80, NULL, HFILL} }, /* NodeRecord */ /* PortInfoRecord */ /* SLtoVLMappingTableRecord */ /* SwitchInfoRecord */ /* LinearForwardingTableRecord */ /* RandomForwardingTableRecord */ /* MulticastForwardingTableRecord */ /* VLArbitrationTableRecord */ { &hf_infiniband_SA_LID, { "LID", "infiniband.sa.lid", FT_UINT16, BASE_HEX, NULL, 0x0, NULL, HFILL} }, { &hf_infiniband_SA_EndportLID, { "EndportLID", "infiniband.sa.endportlid", FT_UINT16, BASE_HEX, NULL, 0x0, NULL, HFILL} }, { &hf_infiniband_SA_PortNum, { "PortNum", "infiniband.sa.portnum", FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL} }, { &hf_infiniband_SA_InputPortNum , { "InputPortNum", "infiniband.sa.inputportnum", FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL} }, { &hf_infiniband_SA_OutputPortNum, { "OutputPortNum", "infiniband.sa.outputportnum", FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL} }, { &hf_infiniband_SA_BlockNum_EightBit, { "BlockNum_EightBit", "infiniband.sa.blocknum_eightbit", FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL} }, { &hf_infiniband_SA_BlockNum_NineBit, { "BlockNum_NineBit", "infiniband.sa.blocknum_ninebit", FT_UINT16, BASE_HEX, NULL, 0x01FF, NULL, HFILL} }, { &hf_infiniband_SA_BlockNum_SixteenBit, { "BlockNum_SixteenBit", "infiniband.sa.blocknum_sixteenbit", FT_UINT16, BASE_HEX, NULL, 0x0, NULL, HFILL} }, { &hf_infiniband_SA_Position, { "Position", "infiniband.sa.position", FT_UINT8, BASE_HEX, NULL, 0xF0, NULL, HFILL} }, #if 0 { &hf_infiniband_SA_Index, { "Index", "infiniband.sa.index", FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL} }, #endif /* InformInfoRecord */ { &hf_infiniband_InformInfoRecord_SubscriberGID, { "SubscriberGID", "infiniband.informinforecord.subscribergid", FT_IPv6, BASE_NONE, NULL, 0x0, NULL, HFILL} }, { &hf_infiniband_InformInfoRecord_Enum, { "Enum", "infiniband.informinforecord.enum", FT_UINT16, BASE_HEX, NULL, 0x0, NULL, HFILL} }, /* InformInfo */ { &hf_infiniband_InformInfo_GID, { "GID", "infiniband.informinfo.gid", FT_IPv6, BASE_NONE, NULL, 0x0, NULL, HFILL} }, { &hf_infiniband_InformInfo_LIDRangeBegin, { "LIDRangeBegin", "infiniband.informinfo.lidrangebegin", FT_UINT16, BASE_HEX, NULL, 0x0, NULL, HFILL} }, { &hf_infiniband_InformInfo_LIDRangeEnd, { "LIDRangeEnd", "infiniband.informinfo.lidrangeend", FT_UINT16, BASE_HEX, NULL, 0x0, NULL, HFILL} }, { &hf_infiniband_InformInfo_IsGeneric, { "IsGeneric", "infiniband.informinfo.isgeneric", FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL} }, { &hf_infiniband_InformInfo_Subscribe, { "Subscribe", "infiniband.informinfo.subscribe", FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL} }, { &hf_infiniband_InformInfo_Type, { "Type", "infiniband.informinfo.type", FT_UINT16, BASE_HEX, NULL, 0x0, NULL, HFILL} }, { &hf_infiniband_InformInfo_TrapNumberDeviceID, { "TrapNumberDeviceID", "infiniband.informinfo.trapnumberdeviceid", FT_UINT16, BASE_HEX, NULL, 0x0, NULL, HFILL} }, { &hf_infiniband_InformInfo_QPN, { "QPN", "infiniband.informinfo.qpn", FT_UINT24, BASE_HEX, NULL, 0x0, NULL, HFILL} }, { &hf_infiniband_InformInfo_RespTimeValue, { "RespTimeValue", "infiniband.informinfo.resptimevalue", FT_UINT8, BASE_HEX, NULL, 0x1F, NULL, HFILL} }, { &hf_infiniband_InformInfo_ProducerTypeVendorID, { "ProducerTypeVendorID", "infiniband.informinfo.producertypevendorid", FT_UINT24, BASE_HEX, NULL, 0x0, NULL, HFILL} }, /* LinkRecord */ { &hf_infiniband_LinkRecord_FromLID, { "FromLID", "infiniband.linkrecord.fromlid", FT_UINT16, BASE_HEX, NULL, 0x0, NULL, HFILL} }, { &hf_infiniband_LinkRecord_FromPort, { "FromPort", "infiniband.linkrecord.fromport", FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL} }, { &hf_infiniband_LinkRecord_ToPort, { "ToPort", "infiniband.linkrecord.toport", FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL} }, { &hf_infiniband_LinkRecord_ToLID, { "ToLID", "infiniband.linkrecord.tolid", FT_UINT16, BASE_HEX, NULL, 0x0, NULL, HFILL} }, /* ServiceRecord */ { &hf_infiniband_ServiceRecord_ServiceID, { "ServiceID", "infiniband.linkrecord.serviceid", FT_UINT64, BASE_HEX, NULL, 0x0, NULL, HFILL} }, { &hf_infiniband_ServiceRecord_ServiceGID, { "ServiceGID", "infiniband.linkrecord.servicegid", FT_IPv6, BASE_NONE, NULL, 0x0, NULL, HFILL} }, { &hf_infiniband_ServiceRecord_ServiceP_Key, { "ServiceP_Key", "infiniband.linkrecord.servicep_key", FT_UINT16, BASE_HEX, NULL, 0x0, NULL, HFILL} }, { &hf_infiniband_ServiceRecord_ServiceLease, { "ServiceLease", "infiniband.linkrecord.servicelease", FT_UINT32, BASE_HEX, NULL, 0x0, NULL, HFILL} }, { &hf_infiniband_ServiceRecord_ServiceKey, { "ServiceKey", "infiniband.linkrecord.servicekey", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL} }, { &hf_infiniband_ServiceRecord_ServiceName, { "ServiceName", "infiniband.linkrecord.servicename", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL} }, { &hf_infiniband_ServiceRecord_ServiceData, { "ServiceData", "infiniband.linkrecord.servicedata", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL} }, /* ServiceAssociationRecord */ { &hf_infiniband_ServiceAssociationRecord_ServiceKey, { "ServiceKey", "infiniband.serviceassociationrecord.servicekey", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL} }, { &hf_infiniband_ServiceAssociationRecord_ServiceName, { "ServiceName", "infiniband.serviceassociationrecord.servicename", FT_STRING, BASE_NONE, NULL, 0x0, NULL, HFILL} }, /* PathRecord */ { &hf_infiniband_PathRecord_DGID, { "DGID", "infiniband.pathrecord.dgid", FT_IPv6, BASE_NONE, NULL, 0x0, NULL, HFILL} }, { &hf_infiniband_PathRecord_SGID, { "SGID", "infiniband.pathrecord.sgid", FT_IPv6, BASE_NONE, NULL, 0x0, NULL, HFILL} }, { &hf_infiniband_PathRecord_DLID, { "DLID", "infiniband.pathrecord.dlid", FT_UINT16, BASE_HEX, NULL, 0x0, NULL, HFILL} }, { &hf_infiniband_PathRecord_SLID, { "SLID", "infiniband.pathrecord.slid", FT_UINT16, BASE_HEX, NULL, 0x0, NULL, HFILL} }, { &hf_infiniband_PathRecord_RawTraffic, { "RawTraffic", "infiniband.pathrecord.rawtraffic", FT_UINT8, BASE_HEX, NULL, 0x80, NULL, HFILL} }, { &hf_infiniband_PathRecord_FlowLabel, { "FlowLabel", "infiniband.pathrecord.flowlabel", FT_UINT24, BASE_HEX, NULL, 0x0FFFFF, NULL, HFILL} }, { &hf_infiniband_PathRecord_HopLimit, { "HopLimit", "infiniband.pathrecord.hoplimit", FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL} }, { &hf_infiniband_PathRecord_TClass, { "TClass", "infiniband.pathrecord.tclass", FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL} }, { &hf_infiniband_PathRecord_Reversible, { "Reversible", "infiniband.pathrecord.reversible", FT_UINT8, BASE_HEX, NULL, 0x80, NULL, HFILL} }, { &hf_infiniband_PathRecord_NumbPath, { "NumbPath", "infiniband.pathrecord.numbpath", FT_UINT8, BASE_HEX, NULL, 0x7F, NULL, HFILL} }, { &hf_infiniband_PathRecord_P_Key, { "P_Key", "infiniband.pathrecord.p_key", FT_UINT16, BASE_HEX, NULL, 0x0, NULL, HFILL} }, { &hf_infiniband_PathRecord_SL, { "SL", "infiniband.pathrecord.sl", FT_UINT16, BASE_HEX, NULL, 0x000F, NULL, HFILL} }, { &hf_infiniband_PathRecord_MTUSelector, { "MTUSelector", "infiniband.pathrecord.mtuselector", FT_UINT8, BASE_HEX, NULL, 0xC0, NULL, HFILL} }, { &hf_infiniband_PathRecord_MTU, { "MTU", "infiniband.pathrecord.mtu", FT_UINT8, BASE_HEX, NULL, 0x3F, NULL, HFILL} }, { &hf_infiniband_PathRecord_RateSelector, { "RateSelector", "infiniband.pathrecord.rateselector", FT_UINT8, BASE_HEX, NULL, 0xC0, NULL, HFILL} }, { &hf_infiniband_PathRecord_Rate, { "Rate", "infiniband.pathrecord.rate", FT_UINT8, BASE_HEX, NULL, 0x3F, NULL, HFILL} }, { &hf_infiniband_PathRecord_PacketLifeTimeSelector, { "PacketLifeTimeSelector", "infiniband.pathrecord.packetlifetimeselector", FT_UINT8, BASE_HEX, NULL, 0xC0, NULL, HFILL} }, { &hf_infiniband_PathRecord_PacketLifeTime, { "PacketLifeTime", "infiniband.pathrecord.packetlifetime", FT_UINT8, BASE_HEX, NULL, 0x3F, NULL, HFILL} }, { &hf_infiniband_PathRecord_Preference, { "Preference", "infiniband.pathrecord.preference", FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL} }, /* MCMemberRecord */ { &hf_infiniband_MCMemberRecord_MGID, { "MGID", "infiniband.mcmemberrecord.mgid", FT_IPv6, BASE_NONE, NULL, 0x0, NULL, HFILL} }, { &hf_infiniband_MCMemberRecord_PortGID, { "PortGID", "infiniband.mcmemberrecord.portgid", FT_IPv6, BASE_NONE, NULL, 0x0, NULL, HFILL} }, { &hf_infiniband_MCMemberRecord_Q_Key, { "Q_Key", "infiniband.mcmemberrecord.q_key", FT_UINT32, BASE_HEX, NULL, 0x0, NULL, HFILL} }, { &hf_infiniband_MCMemberRecord_MLID, { "MLID", "infiniband.mcmemberrecord.mlid", FT_UINT16, BASE_HEX, NULL, 0x0, NULL, HFILL} }, { &hf_infiniband_MCMemberRecord_MTUSelector, { "MTUSelector", "infiniband.mcmemberrecord.mtuselector", FT_UINT8, BASE_HEX, NULL, 0xC0, NULL, HFILL} }, { &hf_infiniband_MCMemberRecord_MTU, { "MTU", "infiniband.mcmemberrecord.mtu", FT_UINT8, BASE_HEX, NULL, 0x3F, NULL, HFILL} }, { &hf_infiniband_MCMemberRecord_TClass, { "TClass", "infiniband.mcmemberrecord.tclass", FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL} }, { &hf_infiniband_MCMemberRecord_P_Key, { "P_Key", "infiniband.mcmemberrecord.p_key", FT_UINT16, BASE_HEX, NULL, 0x0, NULL, HFILL} }, { &hf_infiniband_MCMemberRecord_RateSelector, { "RateSelector", "infiniband.mcmemberrecord.rateselector", FT_UINT8, BASE_HEX, NULL, 0xC0, NULL, HFILL} }, { &hf_infiniband_MCMemberRecord_Rate, { "Rate", "infiniband.mcmemberrecord.rate", FT_UINT8, BASE_HEX, NULL, 0x3F, NULL, HFILL} }, { &hf_infiniband_MCMemberRecord_PacketLifeTimeSelector, { "PacketLifeTimeSelector", "infiniband.mcmemberrecord.packetlifetimeselector", FT_UINT8, BASE_HEX, NULL, 0xC0, NULL, HFILL} }, { &hf_infiniband_MCMemberRecord_PacketLifeTime, { "PacketLifeTime", "infiniband.mcmemberrecord.packetlifetime", FT_UINT8, BASE_HEX, NULL, 0x3F, NULL, HFILL} }, { &hf_infiniband_MCMemberRecord_SL, { "SL", "infiniband.mcmemberrecord.sl", FT_UINT8, BASE_HEX, NULL, 0xF0, NULL, HFILL} }, { &hf_infiniband_MCMemberRecord_FlowLabel, { "FlowLabel", "infiniband.mcmemberrecord.flowlabel", FT_UINT24, BASE_HEX, NULL, 0x0FFFFF, NULL, HFILL} }, { &hf_infiniband_MCMemberRecord_HopLimit, { "HopLimit", "infiniband.mcmemberrecord.hoplimit", FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL} }, { &hf_infiniband_MCMemberRecord_Scope, { "Scope", "infiniband.mcmemberrecord.scope", FT_UINT8, BASE_HEX, NULL, 0xF0, NULL, HFILL} }, { &hf_infiniband_MCMemberRecord_JoinState, { "JoinState", "infiniband.mcmemberrecord.joinstate", FT_UINT8, BASE_HEX, NULL, 0xF0, NULL, HFILL} }, { &hf_infiniband_MCMemberRecord_ProxyJoin, { "ProxyJoin", "infiniband.mcmemberrecord.proxyjoin", FT_UINT8, BASE_HEX, NULL, 0x80, NULL, HFILL} }, /* TraceRecord */ { &hf_infiniband_TraceRecord_GIDPrefix, { "GidPrefix", "infiniband.tracerecord.gidprefix", FT_UINT64, BASE_HEX, NULL, 0x0, NULL, HFILL} }, { &hf_infiniband_TraceRecord_IDGeneration, { "IDGeneration", "infiniband.tracerecord.idgeneration", FT_UINT16, BASE_HEX, NULL, 0x0, NULL, HFILL} }, { &hf_infiniband_TraceRecord_NodeType, { "NodeType", "infiniband.tracerecord.nodetype", FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL} }, { &hf_infiniband_TraceRecord_NodeID, { "NodeID", "infiniband.tracerecord.nodeid", FT_UINT64, BASE_HEX, NULL, 0x0, NULL, HFILL} }, { &hf_infiniband_TraceRecord_ChassisID, { "ChassisID", "infiniband.tracerecord.chassisid", FT_UINT64, BASE_HEX, NULL, 0x0, NULL, HFILL} }, { &hf_infiniband_TraceRecord_EntryPortID, { "EntryPortID", "infiniband.tracerecord.entryportid", FT_UINT64, BASE_HEX, NULL, 0x0, NULL, HFILL} }, { &hf_infiniband_TraceRecord_ExitPortID, { "ExitPortID", "infiniband.tracerecord.exitportid", FT_UINT64, BASE_HEX, NULL, 0x0, NULL, HFILL} }, { &hf_infiniband_TraceRecord_EntryPort, { "EntryPort", "infiniband.tracerecord.entryport", FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL} }, { &hf_infiniband_TraceRecord_ExitPort, { "ExitPort", "infiniband.tracerecord.exitport", FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL} }, /* MultiPathRecord */ { &hf_infiniband_MultiPathRecord_RawTraffic, { "RawTraffic", "infiniband.multipathrecord.rawtraffic", FT_UINT8, BASE_HEX, NULL, 0x80, NULL, HFILL} }, { &hf_infiniband_MultiPathRecord_FlowLabel, { "FlowLabel", "infiniband.multipathrecord.flowlabel", FT_UINT24, BASE_HEX, NULL, 0x0FFFFF, NULL, HFILL} }, { &hf_infiniband_MultiPathRecord_HopLimit, { "HopLimit", "infiniband.multipathrecord.hoplimit", FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL} }, { &hf_infiniband_MultiPathRecord_TClass, { "TClass", "infiniband.multipathrecord.tclass", FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL} }, { &hf_infiniband_MultiPathRecord_Reversible, { "Reversible", "infiniband.multipathrecord.reversible", FT_UINT8, BASE_HEX, NULL, 0x80, NULL, HFILL} }, { &hf_infiniband_MultiPathRecord_NumbPath, { "NumbPath", "infiniband.multipathrecord.numbpath", FT_UINT8, BASE_HEX, NULL, 0x7F, NULL, HFILL} }, { &hf_infiniband_MultiPathRecord_P_Key, { "P_Key", "infiniband.multipathrecord.p_key", FT_UINT16, BASE_HEX, NULL, 0x0, NULL, HFILL} }, { &hf_infiniband_MultiPathRecord_SL, { "SL", "infiniband.multipathrecord.sl", FT_UINT8, BASE_HEX, NULL, 0x0F, NULL, HFILL} }, { &hf_infiniband_MultiPathRecord_MTUSelector, { "MTUSelector", "infiniband.multipathrecord.mtuselector", FT_UINT8, BASE_HEX, NULL, 0xC0, NULL, HFILL} }, { &hf_infiniband_MultiPathRecord_MTU, { "MTU", "infiniband.multipathrecord.mtu", FT_UINT8, BASE_HEX, NULL, 0x3F, NULL, HFILL} }, { &hf_infiniband_MultiPathRecord_RateSelector, { "RateSelector", "infiniband.multipathrecord.rateselector", FT_UINT8, BASE_HEX, NULL, 0xC0, NULL, HFILL} }, { &hf_infiniband_MultiPathRecord_Rate, { "Rate", "infiniband.multipathrecord.rate", FT_UINT8, BASE_HEX, NULL, 0x3F, NULL, HFILL} }, { &hf_infiniband_MultiPathRecord_PacketLifeTimeSelector, { "PacketLifeTimeSelector", "infiniband.multipathrecord.packetlifetimeselector", FT_UINT8, BASE_HEX, NULL, 0xC0, NULL, HFILL} }, { &hf_infiniband_MultiPathRecord_PacketLifeTime, { "PacketLifeTime", "infiniband.multipathrecord.packetlifetime", FT_UINT8, BASE_HEX, NULL, 0x3F, NULL, HFILL} }, { &hf_infiniband_MultiPathRecord_IndependenceSelector, { "IndependenceSelector", "infiniband.multipathrecord.independenceselector", FT_UINT8, BASE_HEX, NULL, 0xC0, NULL, HFILL} }, { &hf_infiniband_MultiPathRecord_GIDScope, { "GIDScope", "infiniband.multipathrecord.gidscope", FT_UINT8, BASE_HEX, NULL, 0x3F, NULL, HFILL} }, { &hf_infiniband_MultiPathRecord_SGIDCount, { "SGIDCount", "infiniband.multipathrecord.sgidcount", FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL} }, { &hf_infiniband_MultiPathRecord_DGIDCount, { "DGIDCount", "infiniband.multipathrecord.dgidcount", FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL} }, { &hf_infiniband_MultiPathRecord_SDGID, { "SDGID", "infiniband.multipathrecord.sdgid", FT_IPv6, BASE_NONE, NULL, 0x0, NULL, HFILL} }, /* Notice */ { &hf_infiniband_Notice_IsGeneric, { "IsGeneric", "infiniband.notice.isgeneric", FT_UINT8, BASE_HEX, NULL, 0x80, NULL, HFILL} }, { &hf_infiniband_Notice_Type, { "Type", "infiniband.notice.type", FT_UINT8, BASE_HEX, NULL, 0x7F, NULL, HFILL} }, { &hf_infiniband_Notice_ProducerTypeVendorID, { "ProducerTypeVendorID", "infiniband.notice.producertypevendorid", FT_UINT24, BASE_HEX, NULL, 0x0, NULL, HFILL} }, { &hf_infiniband_Notice_TrapNumberDeviceID, { "TrapNumberDeviceID", "infiniband.notice.trapnumberdeviceid", FT_UINT16, BASE_HEX, NULL, 0x0, NULL, HFILL} }, { &hf_infiniband_Notice_IssuerLID, { "IssuerLID", "infiniband.notice.issuerlid", FT_UINT16, BASE_HEX, NULL, 0x0, NULL, HFILL} }, { &hf_infiniband_Notice_NoticeToggle, { "NoticeToggle", "infiniband.notice.noticetoggle", FT_UINT8, BASE_HEX, NULL, 0x80, NULL, HFILL} }, { &hf_infiniband_Notice_NoticeCount, { "NoticeCount", "infiniband.notice.noticecount", FT_UINT16, BASE_HEX, NULL, 0x7FFF, NULL, HFILL} }, { &hf_infiniband_Notice_DataDetails, { "DataDetails", "infiniband.notice.datadetails", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL} }, #if 0 { &hf_infiniband_Notice_IssuerGID, { "IssuerGID", "infiniband.notice.issuergid", FT_IPv6, BASE_NONE, NULL, 0x0, NULL, HFILL} }, { &hf_infiniband_Notice_ClassTrapSpecificData, { "ClassTrapSpecificData", "infiniband.notice.classtrapspecificdata", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL} }, #endif /* Traps 64,65,66,67 */ { &hf_infiniband_Trap_GIDADDR, { "GIDADDR", "infiniband.trap.gidaddr", FT_IPv6, BASE_NONE, NULL, 0x0, NULL, HFILL} }, /* Traps 68,69 */ { &hf_infiniband_Trap_COMP_MASK, { "COMP_MASK", "infiniband.trap.comp_mask", FT_UINT64, BASE_HEX, NULL, 0x0, NULL, HFILL} }, { &hf_infiniband_Trap_WAIT_FOR_REPATH, { "WAIT_FOR_REPATH", "infiniband.trap.wait_for_repath", FT_UINT8, BASE_HEX, NULL, 0x80, NULL, HFILL} }, #if 0 { &hf_infiniband_Trap_PATH_REC, { "PATH_REC", "infiniband.trap.path_rec", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL} }, #endif /* Trap 128 */ { &hf_infiniband_Trap_LIDADDR, { "LIDADDR", "infiniband.trap.lidaddr", FT_UINT16, BASE_HEX, NULL, 0x0, NULL, HFILL} }, /* Trap 129, 130, 131 */ { &hf_infiniband_Trap_PORTNO, { "PORTNO", "infiniband.trap.portno", FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL} }, /* Trap 144 */ { &hf_infiniband_Trap_OtherLocalChanges, { "OtherLocalChanges", "infiniband.trap.otherlocalchanges", FT_UINT8, BASE_HEX, NULL, 0x01, NULL, HFILL} }, { &hf_infiniband_Trap_CAPABILITYMASK, { "CAPABILITYMASK", "infiniband.trap.capabilitymask", FT_UINT32, BASE_HEX, NULL, 0x0, NULL, HFILL} }, { &hf_infiniband_Trap_LinkSpeecEnabledChange, { "LinkSpeecEnabledChange", "infiniband.trap.linkspeecenabledchange", FT_UINT8, BASE_HEX, NULL, 0x04, NULL, HFILL} }, { &hf_infiniband_Trap_LinkWidthEnabledChange, { "LinkWidthEnabledChange", "infiniband.trap.linkwidthenabledchange", FT_UINT8, BASE_HEX, NULL, 0x02, NULL, HFILL} }, { &hf_infiniband_Trap_NodeDescriptionChange, { "NodeDescriptionChange", "infiniband.trap.nodedescriptionchange", FT_UINT8, BASE_HEX, NULL, 0x01, NULL, HFILL} }, /* Trap 145 */ { &hf_infiniband_Trap_SYSTEMIMAGEGUID, { "SYSTEMIMAGEGUID", "infiniband.trap.systemimageguid", FT_UINT64, BASE_HEX, NULL, 0x0, NULL, HFILL} }, /* Trap 256 */ { &hf_infiniband_Trap_DRSLID, { "DRSLID", "infiniband.trap.drslid", FT_UINT16, BASE_HEX, NULL, 0x0, NULL, HFILL} }, { &hf_infiniband_Trap_METHOD, { "METHOD", "infiniband.trap.method", FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL} }, { &hf_infiniband_Trap_ATTRIBUTEID, { "ATTRIBUTEID", "infiniband.trap.attributeid", FT_UINT16, BASE_HEX, NULL, 0x0, NULL, HFILL} }, { &hf_infiniband_Trap_ATTRIBUTEMODIFIER, { "ATTRIBUTEMODIFIER", "infiniband.trap.attributemodifier", FT_UINT32, BASE_HEX, NULL, 0x0, NULL, HFILL} }, { &hf_infiniband_Trap_MKEY, { "MKEY", "infiniband.trap.mkey", FT_UINT64, BASE_HEX, NULL, 0x0, NULL, HFILL} }, { &hf_infiniband_Trap_DRNotice, { "DRNotice", "infiniband.trap.drnotice", FT_UINT8, BASE_HEX, NULL, 0x80, NULL, HFILL} }, { &hf_infiniband_Trap_DRPathTruncated, { "DRPathTruncated", "infiniband.trap.drpathtruncated", FT_UINT8, BASE_HEX, NULL, 0x40, NULL, HFILL} }, { &hf_infiniband_Trap_DRHopCount, { "DRHopCount", "infiniband.trap.drhopcount", FT_UINT8, BASE_HEX, NULL, 0x3F, NULL, HFILL} }, { &hf_infiniband_Trap_DRNoticeReturnPath, { "DRNoticeReturnPath", "infiniband.trap.drnoticereturnpath", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL} }, /* Trap 257, 258 */ { &hf_infiniband_Trap_LIDADDR1, { "LIDADDR1", "infiniband.trap.lidaddr1", FT_UINT16, BASE_HEX, NULL, 0x0, NULL, HFILL} }, { &hf_infiniband_Trap_LIDADDR2, { "LIDADDR2", "infiniband.trap.lidaddr2", FT_UINT16, BASE_HEX, NULL, 0x0, NULL, HFILL} }, { &hf_infiniband_Trap_KEY, { "KEY", "infiniband.trap.key", FT_UINT32, BASE_HEX, NULL, 0x0, NULL, HFILL} }, { &hf_infiniband_Trap_SL, { "SL", "infiniband.trap.sl", FT_UINT8, BASE_HEX, NULL, 0xF0, NULL, HFILL} }, { &hf_infiniband_Trap_QP1, { "QP1", "infiniband.trap.qp1", FT_UINT24, BASE_HEX, NULL, 0x0, NULL, HFILL} }, { &hf_infiniband_Trap_QP2, { "QP2", "infiniband.trap.qp2", FT_UINT24, BASE_HEX, NULL, 0x0, NULL, HFILL} }, { &hf_infiniband_Trap_GIDADDR1, { "GIDADDR1", "infiniband.trap.gidaddr1", FT_IPv6, BASE_NONE, NULL, 0x0, NULL, HFILL} }, { &hf_infiniband_Trap_GIDADDR2, { "GIDADDR2", "infiniband.trap.gidaddr2", FT_IPv6, BASE_NONE, NULL, 0x0, NULL, HFILL} }, /* Trap 259 */ { &hf_infiniband_Trap_DataValid, { "DataValid", "infiniband.trap.datavalid", FT_IPv6, BASE_NONE, NULL, 0x0, NULL, HFILL} }, { &hf_infiniband_Trap_PKEY, { "PKEY", "infiniband.trap.pkey", FT_UINT16, BASE_HEX, NULL, 0x0, NULL, HFILL} }, { &hf_infiniband_Trap_SWLIDADDR, { "SWLIDADDR", "infiniband.trap.swlidaddr", FT_IPv6, BASE_NONE, NULL, 0x0, NULL, HFILL} }, /* PortCounters in Performance class */ { &hf_infiniband_PortCounters, { "Port Counters (Performance Management MAD)", "infiniband.portcounters", FT_NONE, BASE_NONE, NULL, 0x0, "Performance class PortCounters packet", HFILL} }, { &hf_infiniband_PortCounters_PortSelect, { "PortSelect", "infiniband.portcounters.portselect", FT_UINT8, BASE_HEX, NULL, 0x0, "Selects the port that will be accessed", HFILL} }, { &hf_infiniband_PortCounters_CounterSelect, { "CounterSelect", "infiniband.portcounters.counterselect", FT_UINT16, BASE_HEX, NULL, 0x0, "When writing, selects which counters are affected by the operation", HFILL} }, { &hf_infiniband_PortCounters_SymbolErrorCounter, { "SymbolErrorCounter", "infiniband.portcounters.symbolerrorcounter", FT_UINT16, BASE_DEC, NULL, 0x0, "Total number of minor link errors", HFILL} }, { &hf_infiniband_PortCounters_LinkErrorRecoveryCounter, { "LinkErrorRecoveryCounter", "infiniband.portcounters.linkerrorrecoverycounter", FT_UINT8, BASE_DEC, NULL, 0x0, "Total number of times successfully completed link error recovery process", HFILL} }, { &hf_infiniband_PortCounters_LinkDownedCounter, { "LinkDownedCounter", "infiniband.portcounters.linkdownedcounter", FT_UINT8, BASE_DEC, NULL, 0x0, "Total number of times failed link error recovery process", HFILL} }, { &hf_infiniband_PortCounters_PortRcvErrors, { "PortRcvErrors", "infiniband.portcounters.portrcverrors", FT_UINT16, BASE_DEC, NULL, 0x0, "Total number of packets containing an error received", HFILL} }, { &hf_infiniband_PortCounters_PortRcvRemotePhysicalErrors, { "PortRcvRemotePhysicalErrors", "infiniband.portcounters.portrcvremotephysicalerrors", FT_UINT16, BASE_DEC, NULL, 0x0, "Total number of packets marked with EBP delimiter received", HFILL} }, { &hf_infiniband_PortCounters_PortRcvSwitchRelayErrors, { "PortRcvSwitchRelayErrors", "infiniband.portcounters.portrcvswitchrelayerrors", FT_UINT16, BASE_DEC, NULL, 0x0, "Total number of packets discarded because they could not be forwarded by switch relay", HFILL} }, { &hf_infiniband_PortCounters_PortXmitDiscards, { "PortXmitDiscards", "infiniband.portcounters.portxmitdiscards", FT_UINT16, BASE_DEC, NULL, 0x0, "Total number of outbound packets discarded", HFILL} }, { &hf_infiniband_PortCounters_PortXmitConstraintErrors, { "PortXmitConstraintErrors", "infiniband.portcounters.portxmitconstrainterrors", FT_UINT8, BASE_DEC, NULL, 0x0, "Total number of packets not transmitted from the switch physical port", HFILL} }, { &hf_infiniband_PortCounters_PortRcvConstraintErrors, { "PortRcvConstraintErrors", "infiniband.portcounters.portrcvconstrainterrors", FT_UINT8, BASE_DEC, NULL, 0x0, "Total number of packets received on the switch physical port that are discarded", HFILL} }, { &hf_infiniband_PortCounters_LocalLinkIntegrityErrors, { "LocalLinkIntegrityErrors", "infiniband.portcounters.locallinkintegrityerrors", FT_UINT8, BASE_DEC, NULL, 0x0, "The number of times the count of local physical errors exceeded the threshold specified by LocalPhyErrors", HFILL} }, { &hf_infiniband_PortCounters_ExcessiveBufferOverrunErrors, { "ExcessiveBufferOverrunErrors", "infiniband.portcounters.excessivebufferoverrunerrors", FT_UINT8, BASE_DEC, NULL, 0x0, "The number of times that OverrunErrors consecutive flow control update periods occurred", HFILL} }, { &hf_infiniband_PortCounters_VL15Dropped, { "VL15Dropped", "infiniband.portcounters.vl15dropped", FT_UINT16, BASE_DEC, NULL, 0x0, "Number of incoming VL15 packets dropped", HFILL} }, { &hf_infiniband_PortCounters_PortXmitData, { "PortXmitData", "infiniband.portcounters.portxmitdata", FT_UINT32, BASE_DEC, NULL, 0x0, "Total number of data octets, divided by 4, transmitted on all VLs from the port", HFILL} }, { &hf_infiniband_PortCounters_PortRcvData, { "PortRcvData", "infiniband.portcounters.portrcvdata", FT_UINT32, BASE_DEC, NULL, 0x0, "Total number of data octets, divided by 4, received on all VLs at the port", HFILL} }, { &hf_infiniband_PortCounters_PortXmitPkts, { "PortXmitPkts", "infiniband.portcounters.portxmitpkts", FT_UINT32, BASE_DEC, NULL, 0x0, "Total number of packets transmitted on all VLs from the port", HFILL} }, { &hf_infiniband_PortCounters_PortRcvPkts, { "PortRcvPkts", "infiniband.portcounters.portrcvpkts", FT_UINT32, BASE_DEC, NULL, 0x0, "Total number of packets received from all VLs on the port", HFILL} }, /* PortCountersExtended in Performance class */ { &hf_infiniband_PortCountersExt, { "Port Counters Extended (Performance Management MAD)", "infiniband.portcounters_ext", FT_NONE, BASE_NONE, NULL, 0x0, "Performance class PortCountersExtended packet", HFILL} }, { &hf_infiniband_PortCountersExt_PortSelect, { "PortSelect", "infiniband.portcounters_ext.portselect", FT_UINT8, BASE_HEX, NULL, 0x0, "Selects the port that will be accessed", HFILL} }, { &hf_infiniband_PortCountersExt_CounterSelect, { "CounterSelect", "infiniband.portcounters_ext.counterselect", FT_UINT16, BASE_HEX, NULL, 0x0, "When writing, selects which counters are affected by the operation", HFILL} }, { &hf_infiniband_PortCountersExt_PortXmitData, { "PortXmitData", "infiniband.portcounters_ext.portxmitdata", FT_UINT64, BASE_DEC, NULL, 0x0, "Total number of data octets, divided by 4, transmitted on all VLs from the port", HFILL} }, { &hf_infiniband_PortCountersExt_PortRcvData, { "PortRcvData", "infiniband.portcounters_ext.portrcvdata", FT_UINT64, BASE_DEC, NULL, 0x0, "Total number of data octets, divided by 4, received on all VLs at the port", HFILL} }, { &hf_infiniband_PortCountersExt_PortXmitPkts, { "PortXmitPkts", "infiniband.portcounters_ext.portxmitpkts", FT_UINT64, BASE_DEC, NULL, 0x0, "Total number of packets transmitted on all VLs from the port", HFILL} }, { &hf_infiniband_PortCountersExt_PortRcvPkts, { "PortRcvPkts", "infiniband.portcounters_ext.portrcvpkts", FT_UINT64, BASE_DEC, NULL, 0x0, "Total number of packets received from all VLs on the port", HFILL} }, { &hf_infiniband_PortCountersExt_PortUnicastXmitPkts, { "PortUnicastXmitPkts", "infiniband.portcounters_ext.portunicastxmitpkts", FT_UINT64, BASE_DEC, NULL, 0x0, "Total number of unicast packets transmitted on all VLs from the port", HFILL} }, { &hf_infiniband_PortCountersExt_PortUnicastRcvPkts, { "PortUnicastRcvPkts", "infiniband.portcounters_ext.portunicastrcvpkts", FT_UINT64, BASE_DEC, NULL, 0x0, "Total number of unicast packets received from all VLs on the port", HFILL} }, { &hf_infiniband_PortCountersExt_PortMulticastXmitPkts, { "PortMulticastXmitPkts", "infiniband.portcounters_ext.portmulticastxmitpkts", FT_UINT64, BASE_DEC, NULL, 0x0, "Total number of multicast packets transmitted on all VLs from the port", HFILL} }, { &hf_infiniband_PortCountersExt_PortMulticastRcvPkts, { "PortMulticastRcvPkts", "infiniband.portcounters_ext.portmulticastrcvpkts", FT_UINT64, BASE_DEC, NULL, 0x0, "Total number of multicast packets received from all VLs on the port", HFILL} } }; /* Array to hold expansion options between dissections */ static gint *ett[] = { /* &ett_infiniband, */ &ett_all_headers, &ett_lrh, &ett_grh, &ett_bth, &ett_rwh, &ett_rdeth, &ett_deth, &ett_reth, &ett_atomiceth, &ett_aeth, &ett_atomicacketh, &ett_immdt, &ett_ieth, &ett_payload, &ett_vendor, &ett_subn_lid_routed, &ett_subn_directed_route, &ett_subnadmin, &ett_cm, &ett_mad, &ett_rmpp, &ett_subm_attribute, &ett_suba_attribute, &ett_datadetails, &ett_noticestraps, /* &ett_nodedesc, */ /* &ett_nodeinfo, */ /* &ett_switchinfo, */ /* &ett_guidinfo, */ /* &ett_portinfo, */ &ett_portinfo_capmask, &ett_pkeytable, &ett_sltovlmapping, &ett_vlarbitrationtable, &ett_linearforwardingtable, &ett_randomforwardingtable, &ett_multicastforwardingtable, &ett_sminfo, &ett_vendordiag, &ett_ledinfo, &ett_linkspeedwidthpairs, &ett_informinfo, &ett_linkrecord, &ett_servicerecord, &ett_pathrecord, &ett_mcmemberrecord, &ett_tracerecord, &ett_multipathrecord, &ett_serviceassocrecord, &ett_perfclass, &ett_eoib }; static hf_register_info hf_link[] = { { &hf_infiniband_link_op, { "Operand", "infiniband_link.op", FT_UINT16, BASE_DEC, VALS(Operand_Description), 0xF000, NULL, HFILL} }, { &hf_infiniband_link_fctbs, { "Flow Control Total Blocks Sent", "infiniband_link.fctbs", FT_UINT16, BASE_DEC, NULL, 0x0FFF, NULL, HFILL} }, { &hf_infiniband_link_vl, { "Virtual Lane", "infiniband_link.vl", FT_UINT16, BASE_DEC, NULL, 0xF000, NULL, HFILL} }, { &hf_infiniband_link_fccl, { "Flow Control Credit Limit", "infiniband_link.fccl", FT_UINT16, BASE_DEC, NULL, 0x0FFF, NULL, HFILL} }, { &hf_infiniband_link_lpcrc, { "Link Packet CRC", "infiniband_link.lpcrc", FT_UINT16, BASE_HEX, NULL, 0, NULL, HFILL} } }; static gint *ett_link_array[] = { &ett_link }; proto_infiniband = proto_register_protocol("InfiniBand", "InfiniBand", "infiniband"); register_dissector("infiniband", dissect_infiniband, proto_infiniband); proto_register_field_array(proto_infiniband, hf, array_length(hf)); proto_register_subtree_array(ett, array_length(ett)); /* register the subdissector tables */ register_heur_dissector_list("infiniband.payload", &heur_dissectors_payload); register_heur_dissector_list("infiniband.mad.cm.private", &heur_dissectors_cm_private); /* register dissection preferences */ infiniband_module = prefs_register_protocol(proto_infiniband, NULL); prefs_register_bool_preference(infiniband_module, "identify_payload", "Attempt to identify and parse encapsulated IBA payloads", "When set, dissector will attempt to identify unknown IBA payloads " "as containing an encapsulated ethertype, and parse them accordingly", &pref_identify_iba_payload); prefs_register_bool_preference(infiniband_module, "dissect_eoib", "Attempt to identify and parse Mellanox EoIB packets", "When set, dissector will attempt to identify and parse " "Mellanox Ethernet-over-InfiniBand packets", &pref_dissect_eoib); proto_infiniband_link = proto_register_protocol("InfiniBand Link", "InfiniBand Link", "infiniband_link"); register_dissector("infiniband_link", dissect_infiniband_link, proto_infiniband_link); proto_register_field_array(proto_infiniband_link, hf_link, array_length(hf_link)); proto_register_subtree_array(ett_link_array, array_length(ett_link_array)); register_init_routine(proto_init_infiniband); /* initialize the hash table */ CM_context_table = g_hash_table_new_full(g_int64_hash, g_int64_equal, table_destroy_notify, table_destroy_notify); } /* Reg Handoff. Register dissectors we'll need for IPoIB and RoCE */ void proto_reg_handoff_infiniband(void) { dissector_handle_t roce_handle; dissector_handle_t ib_handle; ipv6_handle = find_dissector("ipv6"); data_handle = find_dissector("data"); eth_handle = find_dissector("eth"); ethertype_dissector_table = find_dissector_table("ethertype"); /* create and announce an anonymous RoCE dissector */ roce_handle = create_dissector_handle(dissect_roce, proto_infiniband); dissector_add_uint("ethertype", ETHERTYPE_ROCE, roce_handle); ib_handle = create_dissector_handle(dissect_infiniband, proto_infiniband); dissector_add_uint("wtap_encap", WTAP_ENCAP_INFINIBAND, ib_handle); }
P1sec/LTE_monitor_c2xx
wireshark/epan/dissectors/packet-infiniband.c
C
gpl-2.0
366,022
<?php /** * @version $Id: frontpage.class.php,v 1.1 2005/07/22 01:54:45 eddieajau Exp $ * @package Mambo * @subpackage Content * @copyright (C) 2000 - 2005 Miro International Pty Ltd * @license http://www.gnu.org/copyleft/gpl.html GNU/GPL * Mambo is Free Software */ /** ensure this file is being included by a parent file */ defined( '_VALID_MOS' ) or die( 'Direct Access to this location is not allowed.' ); /** * @package Mambo * @subpackage Content */ class mosFrontPage extends mosDBTable { /** @var int Primary key */ var $content_id=null; /** @var int */ var $ordering=null; /** * @param database A database connector object */ function mosFrontPage( &$db ) { $this->mosDBTable( '#__content_frontpage', 'content_id', $db ); } } ?>
wuts/earthquake
components/com_frontpage/frontpage.class.php
PHP
gpl-2.0
752
/* * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ /** * JDK-8050964: OptimisticTypesPersistence.java should use java.util.Date instead of java.sql.Date * * Make sure that nashorn.jar has only 'compact1' dependency. * * @test * @option -scripting * @run */ // assume that this script is run with "nashorn.jar" System // property set to relative path of nashorn.jar from the current // directory of test execution. if (typeof fail != 'function') { fail = print; } var System = java.lang.System; var File = java.io.File; var nashornJar = new File(System.getProperty("nashorn.jar")); if (! nashornJar.isAbsolute()) { nashornJar = new File(".", nashornJar); } var javahome = System.getProperty("java.home"); var jdepsPath = javahome + "/../bin/jdeps".replaceAll(/\//g, File.separater); // run jdep on nashorn.jar - only summary but print profile info `${jdepsPath} -s -P ${nashornJar.absolutePath}` // check for "(compact1)" in output from jdep tool if (! /(compact1)/.test($OUT)) { fail("non-compact1 dependency: " + $OUT); }
koutheir/incinerator-hotspot
nashorn/test/script/nosecurity/JDK-8050964.js
JavaScript
gpl-2.0
2,050
from infoshopkeeper_config import configuration cfg = configuration() dbtype = cfg.get("dbtype") dbname = cfg.get("dbname") dbhost = cfg.get("dbhost") dbuser = cfg.get("dbuser") dbpass = cfg.get("dbpass") from sqlobject import * if dbtype in ('mysql', 'postgres'): if dbtype is 'mysql': import MySQLdb as dbmodule elif dbtype is 'postgres': import psycopg as dbmodule #deprecate def connect(): return dbmodule.connect (host=dbhost,db=dbname,user=dbuser,passwd=dbpass) def conn(): return '%s://%s:%s@%s/%s?charset=utf8&sqlobject_encoding=utf8' % (dbtype,dbuser,dbpass,dbhost,dbname) elif dbtype is 'sqlite': import os, time, re from pysqlite2 import dbapi2 as sqlite db_file_ext = '.' + dbtype if not dbname.endswith(db_file_ext): dbname+=db_file_ext dbpath = os.path.join(dbhost, dbname) def now(): return time.strftime('%Y-%m-%d %H:%M:%S') def regexp(regex, val): print regex, val, bool(re.search(regex, val, re.I)) return bool(re.search(regex, val, re.I)) class SQLiteCustomConnection(sqlite.Connection): def __init__(self, *args, **kwargs): print '@@@ SQLiteCustomConnection: registering functions' sqlite.Connection.__init__(self, *args, **kwargs) SQLiteCustomConnection.registerFunctions(self) def registerFunctions(self): self.create_function("NOW", 0, now) self.create_function("REGEXP", 2, regexp) self.create_function("regexp", 2, regexp) #~ self.execute("SELECT * FROM title WHERE title.booktitle REGEXP 'mar'") registerFunctions=staticmethod(registerFunctions) #deprecate _conn=None def connect(): import sqlobject #~ return sqlite.connect (database=dbpath) global _conn if not _conn: #~ _conn = sqlite.connect (database=dbpath) from objects.title import Title # can't use factory in URI because sqliteconnection doesn't share globals with us Title._connection._connOptions['factory'] = SQLiteCustomConnection # get the connection instance that sqlobject is going to use, so we only have one _conn = Title._connection.getConnection() # since a connection is made before we can set the factory, we have to register # the functions here also SQLiteCustomConnection.registerFunctions(_conn) return _conn def conn(): return '%s://%s?debug=t' % (dbtype,dbpath) #~ return '%s://%s?debug=t&factory=SQLiteCustomConnection' % (dbtype,dbpath)
johm/infoshopkeeper
components/db.py
Python
gpl-2.0
2,693
/* librfid-tool - a small command-line tool for librfid testing * * (C) 2005-2008 by Harald Welte <laforge@gnumonks.org> * * 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 * * 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 <stdio.h> #include <unistd.h> #include <stdlib.h> #include <string.h> #include <errno.h> #ifndef __MINGW32__ #include <libgen.h> #endif #define _GNU_SOURCE #include <getopt.h> #include <librfid/rfid.h> #include <librfid/rfid_scan.h> #include <librfid/rfid_reader.h> #include <librfid/rfid_layer2.h> #include <librfid/rfid_protocol.h> #include <librfid/rfid_layer2_iso14443a.h> #include <librfid/rfid_layer2_iso15693.h> #include <librfid/rfid_protocol_mifare_classic.h> #include <librfid/rfid_protocol_mifare_ul.h> #include <librfid/rfid_protocol_tagit.h> #include <librfid/rfid_protocol_icode.h> #include <librfid/rfid_protocol_tcl.h> #include "librfid-tool.h" static int select_mf(void) { unsigned char cmd[] = { 0x00, 0xa4, 0x00, 0x00, 0x02, 0x3f, 0x00, 0x00 }; unsigned char ret[256]; unsigned int rlen = sizeof(ret); int rv; rv = rfid_protocol_transceive(ph, cmd, sizeof(cmd), ret, &rlen, 0, 0); if (rv < 0) return rv; printf("%d: [%s]\n", rlen, hexdump(ret, rlen)); return 0; } static int iso7816_get_challenge(unsigned char len) { unsigned char cmd[] = { 0x00, 0x84, 0x00, 0x00, 0x08 }; unsigned char ret[256]; unsigned int rlen = sizeof(ret); cmd[4] = len; int rv; rv = rfid_protocol_transceive(ph, cmd, sizeof(cmd), ret, &rlen, 0, 0); if (rv < 0) return rv; printf("%d: [%s]\n", rlen, hexdump(ret, rlen)); return 0; } int iso7816_select_application(void) { unsigned char cmd[] = { 0x00, 0xa4, 0x04, 0x0c, 0x07, 0xa0, 0x00, 0x00, 0x02, 0x47, 0x10, 0x01 }; unsigned char resp[7]; unsigned int rlen = sizeof(resp); int rv; rv = rfid_protocol_transceive(ph, cmd, sizeof(cmd), resp, &rlen, 0, 0); if (rv < 0) return rv; /* FIXME: parse response */ printf("%s\n", hexdump(resp, rlen)); return 0; } int iso7816_select_ef(u_int16_t fid) { unsigned char cmd[7] = { 0x00, 0xa4, 0x02, 0x0c, 0x02, 0x00, 0x00 }; unsigned char resp[7]; unsigned int rlen = sizeof(resp); int rv; cmd[5] = (fid >> 8) & 0xff; cmd[6] = fid & 0xff; rv = rfid_protocol_transceive(ph, cmd, sizeof(cmd), resp, &rlen, 0, 0); if (rv < 0) return rv; /* FIXME: parse response */ printf("%s\n", hexdump(resp, rlen)); return 0; } int iso7816_read_binary(unsigned char *buf, unsigned int *len) { unsigned char cmd[] = { 0x00, 0xb0, 0x00, 0x00, 0x00 }; unsigned char resp[256]; unsigned int rlen = sizeof(resp); int rv; rv = rfid_protocol_transceive(ph, cmd, sizeof(cmd), resp, &rlen, 0, 0); if (rv < 0) return rv; printf("%s\n", hexdump(resp, rlen)); /* FIXME: parse response, determine whether we need additional reads */ /* FIXME: copy 'len' number of response bytes to 'buf' */ return 0; } /* wrapper function around SELECT EF and READ BINARY */ int iso7816_read_ef(u_int16_t fid, unsigned char *buf, unsigned int *len) { int rv; rv = iso7816_select_ef(fid); if (rv < 0) return rv; return iso7816_read_binary(buf, len); } /* mifare ultralight helpers */ int mifare_ulight_write(struct rfid_protocol_handle *ph) { unsigned char buf[4] = { 0xa1, 0xa2, 0xa3, 0xa4 }; return rfid_protocol_write(ph, 10, buf, 4); } int mifare_ulight_blank(struct rfid_protocol_handle *ph) { unsigned char buf[4] = { 0x00, 0x00, 0x00, 0x00 }; int i, ret; for (i = 4; i <= MIFARE_UL_PAGE_MAX; i++) { ret = rfid_protocol_write(ph, i, buf, 4); if (ret < 0) return ret; } return 0; } static int mifare_ulight_read(struct rfid_protocol_handle *ph) { unsigned char buf[20]; unsigned int len = sizeof(buf); int ret; int i; for (i = 0; i <= MIFARE_UL_PAGE_MAX; i++) { ret = rfid_protocol_read(ph, i, buf, &len); if (ret < 0) return ret; printf("Page 0x%x: %s\n", i, hexdump(buf, 4)); } return 0; } /* mifare classic helpers */ static int mifare_classic_read_sector(struct rfid_protocol_handle *ph, int sector) { unsigned char buf[20]; unsigned int len = sizeof(buf); int ret; int block, blocks_per_sector, first_block; printf("Reading sector %u\n", sector); first_block = mfcl_sector2block(sector); blocks_per_sector = mfcl_sector_blocks(sector); if (first_block < 0 || blocks_per_sector < 0) return -EINVAL; for (block = first_block; block < first_block + blocks_per_sector; block++) { printf("Reading block %u: ", block); ret = rfid_protocol_read(ph, block, buf, &len); if (ret == -ETIMEDOUT) fprintf(stderr, "TIMEOUT\n"); if (ret < 0) { printf("Error %d reading\n", ret); return ret; } printf("Page 0x%x: %s\n", block, hexdump(buf, len)); } return 0; } static int mifare_classic_dump(struct rfid_protocol_handle *ph) { unsigned int size; unsigned int size_len = sizeof(size); int sector, num_sectors; if (rfid_protocol_getopt(ph, RFID_OPT_PROTO_SIZE, &size, &size_len) == 0) { printf("Size: %u bytes\n", size); } else { printf("Size: unknown ?!?\n"); return -EINVAL; } switch (size) { case 320: num_sectors = 5; break; case 1024: num_sectors = 16; break; case 4096: num_sectors = 40; break; default: return -EINVAL; } for (sector = 0; sector < num_sectors; sector++) { int rc; printf("Authenticating sector %u: ", sector); fflush(stdout); rc = mfcl_set_key(ph, MIFARE_CL_KEYA_DEFAULT_INFINEON); if (rc < 0) { printf("key format error\n"); exit(1); } rc = mfcl_auth(ph, RFID_CMD_MIFARE_AUTH1A, mfcl_sector2block(sector)); if (rc < 0) { printf("mifare auth error\n"); exit(1); } else printf("mifare auth succeeded!\n"); mifare_classic_read_sector(ph, sector); } } void iso15693_write(struct rfid_reader_handle *rh,int layer2,int sector, unsigned char *data, unsigned int len) { int rc; unsigned char uid_buf[16]; unsigned int uid_len = sizeof(uid_buf); if (rh->reader->l2_supported & (1 << layer2)) { l2h = rfid_layer2_init(rh, layer2); if (!l2h) { printf("error during layer2(%d)_init (0=14a,1=14b,3=15)\n",layer2); return; } printf("Layer2 init ok\n"); rc = rfid_layer2_open(l2h); if (rc>0){ rfid_layer2_getopt(l2h, RFID_OPT_LAYER2_UID, &uid_buf, &uid_len); printf("Layer 2 success (%s)[%d]: '%s'\n", rfid_layer2_name(l2h), uid_len, hexdump(uid_buf, uid_len)); rc = iso15693_write_block(l2h,sector,data,len); printf("write>>rc: %d\n",rc); }else { printf("error during layer2_open\n"); return ; } rfid_layer2_close(l2h); rfid_layer2_fini(l2h); } } void iso15693_dump(struct rfid_reader_handle *rh,int layer2,int sector){ unsigned int size; unsigned int size_len = sizeof(size); unsigned char buf[1024]; int rc,i; unsigned char uid_buf[16], block_sec; unsigned int uid_len = sizeof(uid_buf); if (rh->reader->l2_supported & (1 << layer2)) { l2h = rfid_layer2_init(rh, layer2); if (!l2h) { printf("error during layer2(%d)_init (0=14a,1=14b,3=15)\n",layer2); return; } printf("Layer2 init ok\n"); rc = rfid_layer2_open(l2h); if (rc>0){ rfid_layer2_getopt(l2h, RFID_OPT_LAYER2_UID, &uid_buf, &uid_len); printf("Layer 2 success (%s)[%d]: '%s'\n", rfid_layer2_name(l2h), uid_len, hexdump(uid_buf, uid_len)); if (sector < 0){ if (sector<=-3) iso15693_select(l2h); for(i=0;i<=255;i++){ rc = iso15693_read_block(l2h,i,buf,sizeof(buf),&block_sec); if (rc>=0) printf("block[%3d:%02x]sec:0x%0x data(%d): %s\n",i,i,block_sec,rc,hexdump(buf,rc)); else{ printf("no data(read_block(%d)>> %d)\n",i,rc); if ((sector == -1)||(sector == -3)) break; } } }else{ if (sector>255) sector=255; rc = iso15693_read_block(l2h,sector,buf,sizeof(buf)); if (rc>=0) printf("block[%d]data(%d): %s\n",i,rc,hexdump(buf,rc)); else printf("no data(read_block(%d)>> %d)\n",i,rc); } } else { printf("error during layer2_open\n"); return ; } rfid_layer2_close(l2h); rfid_layer2_fini(l2h); } } static char *proto_names[] = { [RFID_PROTOCOL_TCL] = "tcl", [RFID_PROTOCOL_MIFARE_UL] = "mifare-ultralight", [RFID_PROTOCOL_MIFARE_CLASSIC] = "mifare-classic", [RFID_PROTOCOL_ICODE_SLI] = "icode", [RFID_PROTOCOL_TAGIT] = "tagit", }; static int proto_by_name(const char *name) { int i; for (i = 0; i < ARRAY_SIZE(proto_names); i++) { if (proto_names[i] == NULL) continue; if (!strcasecmp(name, proto_names[i])) return i; } return -1; } static char *l2_names[] = { [RFID_LAYER2_ISO14443A] = "iso14443a", [RFID_LAYER2_ISO14443B] = "iso14443b", [RFID_LAYER2_ISO15693] = "iso15693", [RFID_LAYER2_ICODE1] = "icode1", }; static int l2_by_name(const char *name) { int i; for (i = 0; i < ARRAY_SIZE(l2_names); i++) { if (l2_names[i] == NULL) continue; if (!strcasecmp(name, l2_names[i])) return i; } return -1; } static int do_scan(int first) { int rc; unsigned int size; unsigned int size_len = sizeof(size); char *data; unsigned int data_len; if (first) { unsigned int opt; unsigned int optlen = sizeof(opt); /* turn off RF */ opt = 1; rfid_reader_setopt(rh, RFID_OPT_RDR_RF_KILL, &opt, optlen); usleep(10*1000); /* turn on RF */ opt = 0; rfid_reader_setopt(rh, RFID_OPT_RDR_RF_KILL, &opt, optlen); } printf("scanning for RFID token...\n"); rc = rfid_scan(rh, &l2h, &ph); if (rc >= 2) { unsigned char uid_buf[16]; unsigned int uid_len = sizeof(uid_buf); rfid_layer2_getopt(l2h, RFID_OPT_LAYER2_UID, &uid_buf, &uid_len); printf("Layer 2 success (%s): %s\n", rfid_layer2_name(l2h), hexdump(uid_buf, uid_len)); } if (rc >= 3) { printf("Protocol success (%s)\n", rfid_protocol_name(ph)); if (rfid_protocol_getopt(ph, RFID_OPT_PROTO_SIZE, &size, &size_len) == 0) printf("Size: %u bytes\n", size); size_len = sizeof(size); size = 0; if (rfid_protocol_getopt(ph, RFID_OPT_P_TCL_ATS_LEN, &size, &size_len) == 0) { data_len = size + 1; data = malloc(data_len); if (data) { if (rfid_protocol_getopt(ph, RFID_OPT_P_TCL_ATS, data, &data_len) == 0) { printf("Got ATS of %u bytes: %s\n", size, hexdump(data, data_len)); } } } } return rc; } static void do_endless_scan() { int rc; int first = 1; while (1) { if (first) putc('\n', stdout); printf("==> doing %s scan\n", first ? "first" : "successive"); rc = do_scan(first); if (rc >= 3) { printf("closing proto\n"); rfid_protocol_close(ph); } if (rc >= 2) { printf("closing layer2\n"); rfid_layer2_close(l2h); first = 0; } else first = 1; } } static void do_regdump(void) { u_int8_t buffer[0xff]; int i; printf("dumping rc632 regs...\n"); rc632_register_dump(rh->ah, buffer); printf("\n "); for (i=0; i<=0x0f; i++) printf(" 0x_%01X",i); printf("\n-----------------------------------------------------------------------------------\n"); for (i=0; i <= 0x3f; i++) { if ((i % 0x10) == 0) printf("0x%01X_:",i/0x10); printf(" 0x%02X", buffer[i]); if ((i% 0x10) == 0x0f) printf("\n"); } /* print regdump as c-style array*/ printf("u_int8_t rc632_regs[] = {"); for (i = 0; i <= 0x3f; i++) { if (((i+1) % 0x08) == 1) { if (i > 7) printf("//%2d..%2d",i-8,i-1); printf("\n\t"); } printf(" 0x%02X, ",buffer[i]); } printf("//%2d..%2d\n\t 0 };\n",i-8,i-1); } static void do_enum(int layer2) { int rc; //unsigned int size; //unsigned int size_len = sizeof(size); unsigned char uid_buf[16]; unsigned int uid_len; printf("scanning for RFID token on layer %s...\n", l2_names[layer2]); if (rh->reader->l2_supported & (1 << layer2)) { l2h = rfid_layer2_init(rh, layer2); if (!l2h) { printf("error during layer2(%s)_init\n", l2_names[layer2]); return; } printf("Layer2 init ok\n"); rc = rfid_layer2_open(l2h); } else { printf("error during layer2_open\n"); return ; } while (rc>=0) { if (l2h) { uid_len = sizeof(uid_buf); rfid_layer2_getopt(l2h, RFID_OPT_LAYER2_UID, &uid_buf, &uid_len); printf("Layer 2 success (%s)[%d]: '%s'\n", rfid_layer2_name(l2h), uid_len, hexdump(uid_buf, uid_len)); } /* ph = rfid_protocol_scan(l2h); if (ph) { printf("Protocol success (%s)\n", rfid_protocol_name(ph)); if (rfid_protocol_getopt(ph, RFID_OPT_PROTO_SIZE, &size, &size_len) == 0) printf("Size: %u bytes\n", size); } else printf("##############\n"); */ if (rc >= 0) { rfid_layer2_close(l2h); } rc = rfid_layer2_open(l2h); } } static void do_enum_loop(int layer2, unsigned int delay) { while (1) { do_enum(layer2); { unsigned int opt; unsigned int optlen = sizeof(opt); /* turn off RF */ opt = 1; rfid_reader_setopt(rh, RFID_OPT_RDR_RF_KILL, &opt, optlen); usleep(10 * 1000); /* turn on RF */ opt = 0; rfid_reader_setopt(rh, RFID_OPT_RDR_RF_KILL, &opt, optlen); } usleep(delay * 1000); printf("--- next run ---\n"); } } #define OPTION_OFFSET 256 static struct option original_opts[] = { { "help", 0, 0, 'h' }, { "layer2", 1, 0, 'l' }, { "protocol", 1, 0, 'p' }, { "scan", 0, 0, 's' }, { "scan-loop", 0, 0, 'S' }, { "dump", 0, 0, 'd' }, { "enum", 0, 0, 'e' }, { "read", 1, 0, 'r' }, { "write", 1, 0, 'w'}, { "enum-loop", 1, 0, 'E' }, {0, 0, 0, 0} }; /* module / option merging code */ static struct option *opts = original_opts; static unsigned int global_option_offset = 0; static char *program_name; static char *program_version = LIBRFID_TOOL_VERSION; static void free_opts(int reset_offset) { if (opts != original_opts) { free(opts); opts = original_opts; if (reset_offset) global_option_offset = 0; } } static struct option * merge_options(struct option *oldopts, const struct option *newopts, unsigned int *option_offset) { unsigned int num_old, num_new, i; struct option *merge; for (num_old = 0; oldopts[num_old].name; num_old++); for (num_new = 0; oldopts[num_new].name; num_new++); global_option_offset += OPTION_OFFSET; *option_offset = global_option_offset; merge = malloc(sizeof(struct option) * (num_new + num_old + 1)); memcpy(merge, oldopts, num_old * sizeof(struct option)); free_opts(0); /* Release previous options merged if any */ for (i = 0; i < num_new; i++) { merge[num_old + i] = newopts[i]; merge[num_old + i].val += *option_offset; } memset(merge + num_old + num_new, 0, sizeof(struct option)); return merge; } struct rfidtool_module *find_module(const char *name) { return NULL; } void register_module(struct rfidtool_module *me) { struct rfidtool_module *old; if (strcmp(me->version, program_version) != 0) { fprintf(stderr, "%s: target `%s' v%s (I'm v%s).\n", program_name, me->name, me->version, program_version); exit(1); } old = find_module(me->name); if (old) { fprintf(stderr, "%s: target `%s' already registered.\n", program_name, me->name); exit(1); } } static void help(void) { printf( " -s --scan scan until first RFID tag is found\n" " -S --scan-loop endless scanning loop\n" " -p --protocol {tcl,mifare-ultralight,mifare-classic,tagit,icode}\n" " -l --layer2 {iso14443a,iso14443b,iso15693,icode1}\n" " -d --dump dump rc632 registers\n" " -e --enum enumerate all tag's in field \n" " -E --enum-loop <delay> (ms) enumerate endless\n" " -r --read <secror> read iso15693 sector \n\t\t\t(-1:0-255 stop on error, -2: 0-255 no stop)\n" " -w --write <sector> write to iso15693 sector data: 01:02:03:04\n" " -h --help\n"); } int main(int argc, char **argv) { int rc; char buf[0x100]; int i, len, protocol = -1, layer2 = -1; #ifdef __MINGW32__ program_name = argv[0]; #else /*__MINGW32__*/ program_name = basename(argv[0]); #endif/*__MINGW32__*/ printf("%s - (C) 2005-2008 by Harald Welte\n" "This program is Free Software and has " "ABSOLUTELY NO WARRANTY\n\n", program_name); printf("initializing librfid\n"); rfid_init(); while (1) { int c, option_index = 0; c = getopt_long(argc, argv, "hp:l:sSdeE:r:w:", opts, &option_index); if (c == -1) break; switch (c) { case 'w': //hexread(key, optarg, strlen(optarg)); i = strtol(optarg, NULL, 10); if (reader_init() < 0) exit(1); layer2 = RFID_LAYER2_ISO15693; iso15693_write(rh,layer2,i,"\x1\x2\x3\x4",4); rfid_reader_close(rh); exit(0); break; case 'r': i = strtol(optarg, NULL, 10); if (reader_init() < 0) exit(1); //if (layer2 < 0) layer2 = RFID_LAYER2_ISO15693; iso15693_dump(rh,layer2,i); rfid_reader_close(rh); exit(0); break; case 'E': i = strtol(optarg, NULL, 10); if (reader_init() < 0) exit(1); if (layer2<0) layer2 = RFID_LAYER2_ISO14443A; do_enum_loop(layer2, i>1? i : 500); rfid_reader_close(rh); exit(0); break; case 'e': if (reader_init() < 0) exit(1); if (layer2 < 0) layer2 = RFID_LAYER2_ISO14443A; do_enum(layer2); rfid_reader_close(rh); exit(0); break; case 'd': if (reader_init() < 0) exit(1); do_regdump(); rfid_reader_close(rh); break; case 's': if (reader_init() < 0) exit(1); do_scan(0); rfid_reader_close(rh); exit(0); break; case 'S': if (reader_init() < 0) exit(1); do_endless_scan(); exit(0); break; case 'p': protocol = proto_by_name(optarg); if (protocol < 0) { fprintf(stderr, "unknown protocol `%s'\n", optarg); exit(2); } break; case 'l': layer2 = l2_by_name(optarg); if (layer2 < 0) { fprintf(stderr, "unknown layer2 `%s'\n", optarg); exit(2); } break; default: printf("unknown cmd: %c\n",c); case 'h': help(); exit(0); break; case '?': exit(0); } } switch (protocol) { case RFID_PROTOCOL_MIFARE_UL: case RFID_PROTOCOL_MIFARE_CLASSIC: layer2 = RFID_LAYER2_ISO14443A; break; case -1: fprintf(stderr, "you have to specify --protocol\n"); exit(2); } if (layer2 < 0) { fprintf(stderr, "you have to specify --layer2\n"); exit(2); } if (reader_init() < 0) exit(1); if (l2_init(layer2) < 0) { rfid_reader_close(rh); exit(1); } if (l3_init(protocol) < 0) { rfid_reader_close(rh); exit(1); } switch (protocol) { case RFID_PROTOCOL_TCL: printf("Protocol T=CL\n"); /* we've established T=CL at this point */ printf("selecting Master File\n"); rc = select_mf(); if (rc < 0) { printf("error selecting MF\n"); break; } printf("Getting random challenge, length 255\n"); rc = iso7816_get_challenge(0xff); if (rc < 0) { printf("error getting random challenge\n"); break; } printf("selecting Passport application\n"); rc = iso7816_select_application(); if (rc < 0) { printf("error selecting passport application\n"); break; } printf("selecting EF 0x1e\n"); rc = iso7816_select_ef(0x011e); if (rc < 0) { printf("error selecting EF 0x1e\n"); break; } printf("selecting EF 0x01\n"); rc = iso7816_select_ef(0x0101); if (rc < 0) { printf("error selecting EF 0x01\n"); break; } while (1) { printf("reading EF1\n"); len = sizeof(buf); printf("reading ef\n"); rc = iso7816_read_binary(buf, &len); if (rc < 0) { printf("error reading EF\n"); break; } } #if 0 for (i = 0; i < 4; i++) iso7816_get_challenge(0xff); #endif break; case RFID_PROTOCOL_MIFARE_UL: printf("Protocol Mifare Ultralight\n"); mifare_ulight_read(ph); #if 0 mifare_ulight_blank(ph); mifare_ulight_write(ph); mifare_ulight_read(ph); #endif break; case RFID_PROTOCOL_MIFARE_CLASSIC: printf("Protocol Mifare Classic\n"); mifare_classic_dump(ph); break; default: printf("unknown protocol %u\n", protocol); exit(1); break; } rfid_reader_close(rh); exit(0); }
dpavlin/librfid
utils/librfid-tool.c
C
gpl-2.0
20,449
article,aside,details,figcaption,figure,footer,header,hgroup,nav,section{display:block} audio,canvas,video{display:inline-block;*display:inline;*zoom:1} audio:not([controls]){display:none} html{font-size:100%;-webkit-text-size-adjust:100%;-ms-text-size-adjust:100%} a:focus{outline:thin dotted #333;outline:5px auto -webkit-focus-ring-color;outline-offset:-2px} a:hover,a:active{outline:0} sub,sup{position:relative;font-size:75%;line-height:0;vertical-align:baseline} sup{top:-0.5em} sub{bottom:-0.25em} img{max-width:100%;width:auto\9;height:auto;vertical-align:middle;border:0;-ms-interpolation-mode:bicubic} button,input,select,textarea{margin:0;font-size:100%;vertical-align:middle} button,input{*overflow:visible;line-height:normal} button::-moz-focus-inner,input::-moz-focus-inner{padding:0;border:0} button,html input[type="button"],input[type="reset"],input[type="submit"]{-webkit-appearance:button;cursor:pointer} label,select,button,input[type="button"],input[type="reset"],input[type="submit"],input[type="radio"],input[type="checkbox"]{cursor:pointer} input[type="search"]{-webkit-box-sizing:content-box;-moz-box-sizing:content-box;box-sizing:content-box;-webkit-appearance:textfield} input[type="search"]::-webkit-search-decoration,input[type="search"]::-webkit-search-cancel-button{-webkit-appearance:none} textarea{overflow:auto;vertical-align:top} p{margin:0 0 10px} .lead{margin-bottom:20px;font-size:18px;font-weight:200;line-height:30px} small{font-size:85%} strong{font-weight:bold} em{font-style:italic} cite{font-style:normal} .muted, .muted a{color:#999999} a.muted:hover,a.muted:focus{color:#808080} .text-warning{color:#c09853} a.text-warning:hover,a.text-warning:focus{color:#a47e3c} .text-error{color:#d9534f} a.text-error:hover,a.text-error:focus{color:#c9302c} .text-info{color:#3a87ad} a.text-info:hover,a.text-info:focus{color:#2d6987} .text-success{color:#56af45} a.text-success:hover,a.text-success:focus{color:#448a37} .text-left{text-align:left} .text-right{text-align:right} .text-center{text-align:center} .text-overflow {overflow: hidden; -ms-text-overflow: ellipsis; -o-text-overflow: ellipsis; text-overflow: ellipsis; white-space: nowrap;display:inline-block; vertical-align:middle;} h1,h2,h3,h4,h5,h6{margin:5px 0;font-family:inherit;font-weight:bold;line-height:20px;color:inherit;text-rendering:optimizelegibility} h1 small,h2 small,h3 small,h4 small,h5 small,h6 small{font-weight:normal;line-height:1;color:#999999} h1,h2,h3{line-height:35px} h1{font-size:20px;font-weight: normal;} h2{font-size:17px;font-weight: normal;} h3{font-size:14px;font-weight: normal;} h4{font-size:12px} h5{font-size:12px} h6{font-size:10.2px} h1 small{font-size:15px} h2 small{font-size:12px} h3 small{font-size:12px} h4 small{font-size:12px} .page-header{padding-bottom:9px;margin:20px 0 20px;border-bottom:1px solid #eeeeee} ul,ol{padding:0;margin:0;list-style:none} li{line-height:20px} ul.inline,ol.inline{margin-left:0;list-style:none} ul.inline > li,ol.inline > li{display:inline-block;*display:inline;*zoom:1;padding-left:5px;padding-right:5px} dl{margin-bottom:20px} dt,dd{line-height:20px} dt{font-weight:bold} dd{margin-left:10px} .dl-horizontal{*zoom:1} .dl-horizontal:before,.dl-horizontal:after{display:table;content:"";line-height:0} .dl-horizontal:after{clear:both} .dl-horizontal dt{float:left;width:160px;clear:left;text-align:right;overflow:hidden;text-overflow:ellipsis;white-space:nowrap} .dl-horizontal dd{margin-left:180px} hr{margin:20px 0;border:0;border-top:1px solid #eeeeee;border-bottom:1px solid #ffffff} blockquote{padding:0 0 0 15px;margin:0 0 20px;border-left:5px solid #eeeeee} blockquote p{margin-bottom:0;font-size:15px;font-weight:300;line-height:1.25} blockquote small{display:block;line-height:20px;color:#999999} blockquote small:before{content:'\2014 \00A0'} blockquote.pull-right{float:right;padding-right:15px;padding-left:0;border-right:5px solid #eeeeee;border-left:0} blockquote.pull-right p,blockquote.pull-right small{text-align:right} blockquote.pull-right small:before{content:''} blockquote.pull-right small:after{content:'\00A0 \2014'} q:before,q:after,blockquote:before,blockquote:after{content:""} code,pre{padding:0 3px 2px;font-family:Monaco,Menlo,Consolas,"Courier New",monospace;font-size:10px;color:#444444;border-radius:3px} code{padding:2px 4px;color:#d14;background-color:#fbfbfb;border:1px solid #e1e1e8;white-space:nowrap} pre{display:block;padding:9.5px;margin:0 0 10px;font-size:11px;line-height:20px;word-break:break-all;word-wrap:break-word;white-space:pre;white-space:pre-wrap;background-color:#f5f5f5;border:1px solid #ccc;border:1px solid rgba(0,0,0,0.15);border-radius:2px} pre.prettyprint{margin-bottom:20px} pre code{padding:0;color:inherit;white-space:pre;white-space:pre-wrap;background-color:transparent;border:0} .pre-scrollable{max-height:340px;overflow-y:scroll} .close{float:right;font-size:20px;font-weight:bold;line-height:20px;color:#000000;text-shadow:0 1px 0 #ffffff;opacity:0.2;filter:alpha(opacity=20)} .close:hover,.close:focus{color:#000000;text-decoration:none;cursor:pointer;opacity:0.4;filter:alpha(opacity=40)} button.close{padding:0;cursor:pointer;background:transparent;border:0;-webkit-appearance:none} .clearfix{*zoom:1} .clearfix:before,.clearfix:after{display:table;content:"";line-height:0} .clearfix:after{clear:both} .hide-text{font:0/0 a;color:transparent;text-shadow:none;background-color:transparent;border:0} .input-block-level{display:block;width:100%;min-height:30px;-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box} .row-fluid{width:100%;*zoom:1} .row-fluid:before,.row-fluid:after{display:table;content:"";line-height:0} .row-fluid:after{clear:both} .row-fluid [class*="span"]{display:block;width:100%;min-height:30px;-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box;float:left;margin-left:2%;*margin-left:1.95%} .row-fluid [class*="span"]:first-child{margin-left:0} .row-fluid .controls-row [class*="span"] + [class*="span"]{margin-left:2%} .row-fluid .span12{width:100%;*width:99.95%} .row-fluid .span11{width:91.5%;*width:91.45%} .row-fluid .span10{width:83%;*width:82.95%} .row-fluid .span9{width:74.5%;*width:74.45%} .row-fluid .span8{width:66%;*width:65.95%} .row-fluid .span7{width:57.5%;*width:57.45%} .row-fluid .span6{width:49%;*width:48.95%} .row-fluid .span5{width:40.5%;*width:40.45%} .row-fluid .span4{width:32%;*width:31.95%} .row-fluid .span3{width:23.5%;*width:23.45%} .row-fluid .span2{width:15%;*width:14.95%} .row-fluid .span1{width:6.5%;*width:6.45%} .row-fluid .offset12{margin-left:104%;*margin-left:103.9%} .row-fluid .offset12:first-child{margin-left:102%;*margin-left:101.9%} .row-fluid .offset11{margin-left:95.5%;*margin-left:95.4%} .row-fluid .offset11:first-child{margin-left:93.5%;*margin-left:93.4%} .row-fluid .offset10{margin-left:87%;*margin-left:86.9%} .row-fluid .offset10:first-child{margin-left:85%;*margin-left:84.9%} .row-fluid .offset9{margin-left:78.5%;*margin-left:78.4%} .row-fluid .offset9:first-child{margin-left:76.5%;*margin-left:76.4%} .row-fluid .offset8{margin-left:70%;*margin-left:69.9%} .row-fluid .offset8:first-child{margin-left:68%;*margin-left:67.9%} .row-fluid .offset7{margin-left:61.5%;*margin-left:61.400000000000006%} .row-fluid .offset7:first-child{margin-left:59.5%;*margin-left:59.400000000000006%} .row-fluid .offset6{margin-left:53%;*margin-left:52.900000000000006%} .row-fluid .offset6:first-child{margin-left:51%;*margin-left:50.900000000000006%} .row-fluid .offset5{margin-left:44.5%;*margin-left:44.400000000000006%} .row-fluid .offset5:first-child{margin-left:42.5%;*margin-left:42.400000000000006%} .row-fluid .offset4{margin-left:36%;*margin-left:35.900000000000006%} .row-fluid .offset4:first-child{margin-left:34%;*margin-left:33.900000000000006%} .row-fluid .offset3{margin-left:27.5%;*margin-left:27.4%} .row-fluid .offset3:first-child{margin-left:25.5%;*margin-left:25.4%} .row-fluid .offset2{margin-left:19%;*margin-left:18.9%} .row-fluid .offset2:first-child{margin-left:17%;*margin-left:16.9%} .row-fluid .offset1{margin-left:10.5%;*margin-left:10.399999999999999%} .row-fluid .offset1:first-child{margin-left:8.5%;*margin-left:8.399999999999999%} [class*="span"].hide,.row-fluid [class*="span"].hide{display:none} [class*="span"].pull-right,.row-fluid [class*="span"].pull-right{float:right} body{margin:0;font-family:"Microsoft Yahei","Helvetica Neue",Helvetica,Arial,sans-serif;font-size:12px;line-height:20px;color:#666;background-color:#eeeeee;overflow-x: hidden;} a{color:#666;text-decoration:none} a:hover,a:focus{color: #8e60bb;text-decoration:none} ::selection{background:#72d0eb;color:#fff;text-shadow:none} ::-moz-selection{background:#72d0eb;color:#fff;text-shadow:none} .header, .container{max-width:1110px; min-width:320px;margin:0 auto;text-align:left;position:relative;*zoom:1} /*.footer{max-width:1110px; min-width:320px;margin:0 auto;text-align:left;position:relative;*zoom:1}*/ .container{width:1110px;} .header:before, .container:before, .footer:before, .header:after, .container:after, .footer:after{display:table;content:"";line-height:0} .header:after,.container:after,.footer:after{clear:both} .header{top:0;width:100%;z-index:999; margin-bottom:10px;height:140px;background-color: #fff;} .header-logo{background:url("img/header-logo.jpg") 0 0 no-repeat; width: 80px; height: 140px;margin-left:10px; filter:alpha(opacity=85);-moz-opacity:0.85; opacity: 0.85;background-size:contain;} .header-logo:hover{filter:alpha(opacity=100);-moz-opacity:1; opacity:1;} .header-name{padding:20px 0 0 30px; white-space: nowrap;} .header-name h1 a{color:#7B37AD;font-size:32px;padding-bottom:10px; text-shadow: 1px 1px 2px rgba(123, 55, 173, 0.53);} .header-name p{color:#999;} .header-name p a{color:#8e60bb;} .header-name p a:hover{ text-decoration: underline;} .header .menu{padding:25px 25px 0 0;} .header .btn-group{ display: none;} .container{margin-bottom:10px} .content-wrap{width:100%;float:left} .content{margin-right:370px} .content-page{position: relative;background-color: #fff;} .page-sidebar{width: 225px;position: absolute;top: 0;left: 0;bottom: 0;height:100%;border-right: 1px solid #eee;} .content-title{font-size: 20px;font-weight: normal;padding: 15px 20px 14px;line-height: 20px;background-color: #F7F7F7;margin: 0 0 1px;border-bottom: 1px solid #eee;} .sidebar{float:left;margin-left:-360px;width:360px;position:relative} .footer{clear:both;color:#ddd;text-shadow:0 -1px 0 #333333;position:relative;z-index:1;background-color:#414141;} .trackcode{float:right} .footer-inner{padding:16px 20px 14px;margin-bottom:0; color:#aaa;text-shadow:0 -1px 0 #333333;*zoom:1} .footer-inner:before, .footer-inner:after{display:table;content:"";line-height:0} .footer-inner:after{clear:both} .footer a{color:#aaa} .footer a:hover{color:#ddd;text-decoration:underline} .pagewrapper{background-color: #fff;position: relative;} .pageheader{padding: 10px 20px 8px;line-height: 24px;position: relative;border-bottom: 1px solid #eee;margin-bottom: 0;background-color: #f7f7f7;} .pageheader h1{font-size: 20px;font-weight: normal;padding: 0;margin: 0;line-height: 24px;} .pageheader h1 a{color: #444;} .pageheader h1 .avatar{float: left;margin-right: 5px;} .pageheader h1 em{font-size: 12px;font-style: normal;font-weight: normal;} .pagecontent .pageheader{background: none;padding: 0 0 8px;margin-bottom: 20px;} .pagecontent .pageheader h1{font-size: 20px;font-weight: normal;} .pagecontent .article-content{padding: 0} .pagecontent #respond, .pagecontent #postcomments{margin: 0 -20px;} .pagesidebar{position: absolute;top:0;left:0;width: 200px;background-color: #fbfbfb;bottom: 0} .pagesider-menu{font-size: 14px;} .pagesider-menu .sub-menu{display: none;} .pagesider-menu a{margin-bottom: 1px;padding:10px 15px;color:#888;border-left: solid 4px transparent;cursor: pointer;overflow: hidden;border-bottom: 1px solid #EEEEEE;display: block;} .pagesider-menu a:hover{background-color:#f7f7f7;color:#666} .pagesider-menu li.active a, .pagesider-menu li.current_page_item a, .pagesider-menu li.current-menu-item a {color:#444;background-color:#fff;border-left-color:#428BCA;margin-right: -1px;position: relative;z-index:2;} .pagesider-menu [class^="icon-"],.pagesider-menu [class*=" icon-"]{opacity: 0.70;filter:alpha(opacity=70);} .pagesider-menu li.active [class^="icon-"],.pagesider-menu li.active [class*=" icon-"]{opacity: 0.88;filter:alpha(opacity=88);} .pagecontent{margin-left: 200px;min-height: 600px;border-left: 1px solid #eee;padding: 20px;} .page-navbar{margin-top: 50px;} .page-navbar li a{padding:10px 16px;color:#888;display: block;font-size: 14px;border-left: 4px solid transparent;} .page-navbar .dropdown-toggle .caret{margin-top:8px} .page-navbar .active a,.page-navbar .active a:hover,.page-navbar .active a:focus{color:#666;background-color:#F7F7F7} .page-navbar > li > ul{font-size:14px} .page-navbar > li > ul a{padding-left: 36px;} .page-navbar li:hover a{background-color: #F7F7F7;color: #666;} .page-navbar li.current-menu-item a,.page-navbar li.current-menu-parent a,.page-navbar li.current_page_item a,.page-navbar li.current-post-ancestor a,.page-navbar li ul{background-color:#F7F7F7;border-left-color: #428BCA;color: #666;}
flh0909/wordpress
wp-content/themes/D8_4.0/styles/base.css
CSS
gpl-2.0
13,256
package co.deepthought; import co.deepthought.imagine.image.Fingerprinter; import co.deepthought.imagine.store.Size; import javax.imageio.ImageIO; import java.awt.image.BufferedImage; import java.io.File; import java.io.IOException; import java.util.HashSet; public class Tester { public static void main(String[] args) throws IOException { final String[] imageFiles = { "fireboat-300x200-100.jpg", "fireboat-1200x800-60.jpg", "liberty+autocolor-900x600-60.jpg", "liberty-600x400-40.jpg", "liberty-1200x800-80.jpg", "pathological-cropped-1.jpeg", "pathological-cropped-2.jpeg", "pathological-skyline-1.jpeg", "pathological-skyline-2.jpeg", "hat-small.jpeg", "hat-large.jpeg" }; final String[] fingerprints = new String[imageFiles.length]; for(int i = 0; i < imageFiles.length; i++) { final BufferedImage image = ImageIO.read( new File("/Users/kevindolan/rentenna/imagine/resources/test/"+imageFiles[i])); final Fingerprinter fingerprinter = new Fingerprinter(image); fingerprints[i] = fingerprinter.getFingerprint(new Size(36, 24)); } final HashSet<String> seen = new HashSet<>(); for(int i = 0; i < imageFiles.length; i++) { if(!seen.contains(imageFiles[i])) { seen.add(imageFiles[i]); System.out.println(imageFiles[i]); for(int j = 0; j < imageFiles.length; j++) { if(!seen.contains(imageFiles[j])) { final int difference = Fingerprinter.difference(fingerprints[i], fingerprints[j]); System.out.println(difference); if(difference < 256) { System.out.println("\t" + imageFiles[j]); seen.add(imageFiles[j]); } } } } } } }
metric-collective/imagine
src/main/java/co/deepthought/Tester.java
Java
gpl-2.0
2,065
// Copyright 2013 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef CHROME_BROWSER_UI_WEBUI_OPTIONS_RESET_PROFILE_SETTINGS_HANDLER_H_ #define CHROME_BROWSER_UI_WEBUI_OPTIONS_RESET_PROFILE_SETTINGS_HANDLER_H_ #include "base/compiler_specific.h" #include "base/memory/weak_ptr.h" #include "chrome/browser/ui/webui/options/options_ui.h" namespace base { class DictionaryValue; class ListValue; } class AutomaticProfileResetter; class BrandcodeConfigFetcher; class ProfileResetter; class ResettableSettingsSnapshot; namespace options { class ResetProfileSettingsHandler : public OptionsPageUIHandler, public base::SupportsWeakPtr<ResetProfileSettingsHandler> { public: ResetProfileSettingsHandler(); virtual ~ResetProfileSettingsHandler(); virtual void GetLocalizedValues( base::DictionaryValue* localized_strings) OVERRIDE; virtual void InitializeHandler() OVERRIDE; virtual void InitializePage() OVERRIDE; virtual void Uninitialize() OVERRIDE; virtual void RegisterMessages() OVERRIDE; private: void HandleResetProfileSettings(const base::ListValue* value); void OnResetProfileSettingsDone(); void OnShowResetProfileDialog(const base::ListValue* value); void OnDismissedResetProfileSettingsBanner(const base::ListValue* args); void OnSettingsFetched(); void ResetProfile(bool send_settings); AutomaticProfileResetter* automatic_profile_resetter_; bool has_shown_confirmation_dialog_; scoped_ptr<ProfileResetter> resetter_; scoped_ptr<BrandcodeConfigFetcher> config_fetcher_; scoped_ptr<ResettableSettingsSnapshot> setting_snapshot_; std::string brandcode_; DISALLOW_COPY_AND_ASSIGN(ResetProfileSettingsHandler); }; } #endif
qtekfun/htcDesire820Kernel
external/chromium_org/chrome/browser/ui/webui/options/reset_profile_settings_handler.h
C
gpl-2.0
1,859
<!-- ~ Copyright (C) 2009-2015 Pivotal Software, Inc ~ ~ This program is is free software; you can redistribute it and/or modify ~ it under the terms 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. --> <table class="dijitReset dijitSlider dijitSliderV dojoxRangeSlider" cellspacing="0" cellpadding="0" border="0" rules="none" ><tr class="dijitReset" ><td class="dijitReset"></td ><td class="dijitReset dijitSliderButtonContainer dijitSliderButtonContainerV" ><div class="dijitSliderIncrementIconV" tabIndex="-1" style="display:none" dojoAttachPoint="decrementButton" dojoAttachEvent="onclick: increment"><span class="dijitSliderButtonInner">+</span></div ></td ><td class="dijitReset"></td ></tr ><tr class="dijitReset" ><td class="dijitReset"></td ><td class="dijitReset" ><center><div class="dijitSliderBar dijitSliderBumper dijitSliderBumperV dijitSliderTopBumper" dojoAttachEvent="onclick:_onClkIncBumper"></div></center ></td ><td class="dijitReset"></td ></tr ><tr class="dijitReset" ><td dojoAttachPoint="leftDecoration" class="dijitReset dijitSliderDecoration dijitSliderDecorationL dijitSliderDecorationV" style="text-align:center;height:100%;"></td ><td class="dijitReset" style="height:100%;" ><input dojoAttachPoint="valueNode" type="hidden" ${!nameAttrSetting} /><center waiRole="presentation" style="position:relative;height:100%;" dojoAttachPoint="sliderBarContainer" ><div waiRole="presentation" dojoAttachPoint="remainingBar" class="dijitSliderBar dijitSliderBarV dijitSliderRemainingBar dijitSliderRemainingBarV" dojoAttachEvent="onmousedown:_onRemainingBarClick" ><div dojoAttachPoint="sliderHandle" tabIndex="${tabIndex}" class="dijitSliderMoveable dijitSliderMoveableV" dojoAttachEvent="onkeypress:_onKeyPress,onmousedown:_onHandleClick" style="vertical-align:top;" waiRole="slider" valuemin="${minimum}" valuemax="${maximum}" ><div class="dijitSliderImageHandle dijitSliderImageHandleV"></div ></div ><div waiRole="presentation" dojoAttachPoint="progressBar,focusNode" tabIndex="${tabIndex}" class="dijitSliderBar dijitSliderBarV dijitSliderProgressBar dijitSliderProgressBarV" dojoAttachEvent="onkeypress:_onKeyPress,onmousedown:_onBarClick" ></div ><div dojoAttachPoint="sliderHandleMax,focusNodeMax" tabIndex="${tabIndex}" class="dijitSliderMoveable dijitSliderMoveableV" dojoAttachEvent="onkeypress:_onKeyPress,onmousedown:_onHandleClickMax" style="vertical-align:top;" waiRole="slider" valuemin="${minimum}" valuemax="${maximum}" ><div class="dijitSliderImageHandle dijitSliderImageHandleV"></div ></div ></div ></center ></td ><td dojoAttachPoint="containerNode,rightDecoration" class="dijitReset dijitSliderDecoration dijitSliderDecorationR dijitSliderDecorationV" style="text-align:center;height:100%;"></td ></tr ><tr class="dijitReset" ><td class="dijitReset"></td ><td class="dijitReset" ><center><div class="dijitSliderBar dijitSliderBumper dijitSliderBumperV dijitSliderBottomBumper" dojoAttachEvent="onclick:_onClkDecBumper"></div></center ></td ><td class="dijitReset"></td ></tr ><tr class="dijitReset" ><td class="dijitReset"></td ><td class="dijitReset dijitSliderButtonContainer dijitSliderButtonContainerV" ><div class="dijitSliderDecrementIconV" tabIndex="-1" style="display:none" dojoAttachPoint="incrementButton" dojoAttachEvent="onclick: decrement"><span class="dijitSliderButtonInner">-</span></div ></td ><td class="dijitReset"></td ></tr ></table>
pivotal/tcs-hq-management-plugin
com.springsource.hq.plugin.tcserver.serverconfig.web/src/main/webapp/dojox/form/resources/VerticalRangeSlider.html
HTML
gpl-2.0
4,052
package net.demilich.metastone.game.spells; import net.demilich.metastone.game.Attribute; import net.demilich.metastone.game.GameContext; import net.demilich.metastone.game.Player; import net.demilich.metastone.game.cards.Card; import net.demilich.metastone.game.cards.CardCatalogue; import net.demilich.metastone.game.cards.CardList; import net.demilich.metastone.game.entities.Entity; import net.demilich.metastone.game.spells.desc.SpellArg; import net.demilich.metastone.game.spells.desc.SpellDesc; import net.demilich.metastone.game.spells.desc.filter.EntityFilter; import net.demilich.metastone.game.targeting.CardLocation; public class ReceiveCardAndDoSomethingSpell extends Spell { private void castSomethingSpell(GameContext context, Player player, SpellDesc spell, Entity source, Card card) { context.getLogic().receiveCard(player.getId(), card); // card may be null (i.e. try to draw from deck, but already in // fatigue) if (card == null || card.getLocation() == CardLocation.GRAVEYARD) { return; } context.setEventCard(card); SpellUtils.castChildSpell(context, player, spell, source, card); context.setEventCard(null); } @Override protected void onCast(GameContext context, Player player, SpellDesc desc, Entity source, Entity target) { EntityFilter cardFilter = (EntityFilter) desc.get(SpellArg.CARD_FILTER); SpellDesc cardEffectSpell = (SpellDesc) desc.get(SpellArg.SPELL); int count = desc.getValue(SpellArg.VALUE, context, player, target, source, 1); if (cardFilter != null) { CardList cards = CardCatalogue.query(context.getDeckFormat()); CardList result = new CardList(); String replacementCard = (String) desc.get(SpellArg.CARD); for (Card card : cards) { if (cardFilter.matches(context, player, card)) { result.add(card); } } for (int i = 0; i < count; i++) { Card card = null; if (!result.isEmpty()) { card = result.getRandom(); } else if (replacementCard != null) { card = CardCatalogue.getCardById(replacementCard); } if (card != null) { Card clone = card.clone(); castSomethingSpell(context, player, cardEffectSpell, source, clone); } } } else { for (Card card : SpellUtils.getCards(context, desc, player)) { for (int i = 0; i < count; i++) { castSomethingSpell(context, player, cardEffectSpell, source, card); } } } } }
doombubbles/metastonething
game/src/main/java/net/demilich/metastone/game/spells/ReceiveCardAndDoSomethingSpell.java
Java
gpl-2.0
2,386
<?php /** * --------------------------------------------------------------------- * GLPI - Gestionnaire Libre de Parc Informatique * Copyright (C) 2015-2017 Teclib' and contributors. * * http://glpi-project.org * * based on GLPI - Gestionnaire Libre de Parc Informatique * Copyright (C) 2003-2014 by the INDEPNET Development Team. * * --------------------------------------------------------------------- * * LICENSE * * This file is part of GLPI. * * GLPI 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. * * GLPI 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 GLPI. If not, see <http://www.gnu.org/licenses/>. * --------------------------------------------------------------------- */ /** @file * @brief */ if (!defined('GLPI_ROOT')) { die("Sorry. You can't access this file directly"); } /** * Relation between item and devices **/ class Item_DevicePowerSupply extends Item_Devices { static public $itemtype_2 = 'DevicePowerSupply'; static public $items_id_2 = 'devicepowersupplies_id'; static protected $notable = false; /** * @since version 0.85 **/ static function getSpecificities($specif='') { return array('serial' => parent::getSpecificities('serial'), 'otherserial' => parent::getSpecificities('otherserial'), 'locations_id' => parent::getSpecificities('locations_id'), 'states_id' => parent::getSpecificities('states_id') ); } }
eltharin/glpi
inc/item_devicepowersupply.class.php
PHP
gpl-2.0
1,935
/* * Copyright (c) 1998-2010 Caucho Technology -- all rights reserved * * This file is part of Resin(R) Open Source * * Each copy or derived work must preserve the copyright notice and this * notice unmodified. * * Resin Open Source 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. * * Resin Open Source 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, or any warranty * of NON-INFRINGEMENT. See the GNU General Public License for more * details. * * You should have received a copy of the GNU General Public License * along with Resin Open Source; if not, write to the * Free SoftwareFoundation, Inc. * 59 Temple Place, Suite 330 * Boston, MA 02111-1307 USA * * @author Scott Ferguson * * $Id: DocumentEcmaWrap.java,v 1.2 2004/09/29 00:13:10 cvs Exp $ */ package com.caucho.eswrap.org.w3c.dom; import org.w3c.dom.Attr; import org.w3c.dom.DOMException; import org.w3c.dom.Document; public class DocumentEcmaWrap { public static Attr createAttribute(Document doc, String name, String value) throws DOMException { Attr attr = doc.createAttribute(name); attr.setValue(value); return attr; } }
christianchristensen/resin
modules/ecmascript/src/com/caucho/eswrap/org/w3c/dom/DocumentEcmaWrap.java
Java
gpl-2.0
1,457
<html><head> <title> SPRNG: Scalable Parallel Pseudo-Random Number Generator Library </title> </head> <body bgcolor="#ffffff" alink="#CC3300" vlink="#666666" link="#006666"> <H1 ALIGN=CENTER> SPRNG Documentation </H1> <P ALIGN=CENTER><STRONG>Version 1.0</STRONG> <BLOCKQUOTE> <P> <B>For technical assistance</B> in installing or using SPRNG, please call Ashok Srinivasan at <B>(217) 244-2937</B> or email <a href="mailto:sprng@ncsa.uiuc.edu">sprng@ncsa.uiuc.edu</a>. <P> <a href="changes.html"><STRONG>Changes to Version 0.5</STRONG></a> <BR> <STRONG>Please read this if you have been using SPRNG 0.5</STRONG>. <P> The following documents are available for the SPRNG parallel pseudorandom number generator libraries: <P> <DL> <DT><H2><A HREF="quick-start.html">Quick Start</A></H2> <P> <DD>This is a brief tutorial on <FONT COLOR=RED>installing</FONT> and <FONT COLOR=RED>using</FONT> some simple SPRNG features. It assumes some experience in installing software. However, links are provided in case more details are required. <P> <DT><H2><A HREF="quick-reference.html">Quick Reference </A></H2> <P> <DD>Quick reference sheets for the SPRNG interfaces. <P> <DT><H2><A HREF="users-guide.html">User's Guide</A></H2> <P> <DD>The User's Guide contains detailed information on installing and using the libraries. It also discusses testing the generators for their quality. <P> <DT><H2><A HREF="reference.html">Reference Manual</A></H2> <P> <DD>Detailed discussions of the various SPRNG functions are presented in this document. <P> <DT><H2><A HREF="./paper/index.html">Introduction to Parallel RNGs</A></H2> <P> <DD>A discussion of random number generators for use in parallel applications. </DL> </BLOCKQUOTE> <HR> <p> </body></html>
eliask/sprng
DOCS/www/toc.html
HTML
gpl-2.0
1,801
<!DOCTYPE html> <!--[if lt IE 7 ]><html class="ie ie6" lang="en"> <![endif]--> <!--[if IE 7 ]><html class="ie ie7" lang="en"> <![endif]--> <!--[if IE 8 ]><html class="ie ie8" lang="en"> <![endif]--> <!--[if (gte IE 9)|!(IE)]><!--> <html lang="en-US" > <!--<![endif]--> <!-- =========================================================================== Jarvis Onepage Parallax WordPress Theme by rocknrolladesigns.com (http://www.rocknrolladesigns.com) =========================================================================== --> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"> <meta http-equiv="x-ua-compatible" content="IE=edge" /> <!-- PAGE TITLE --> <title>rajat bhageria book &raquo; Rajat Bhageria &raquo; 17-Year-Old Entrepreneur, Doer, and Author</title> <meta name="description" content="17-Year-Old Entrepreneur, Doer, and Author"> </title> <!--[if lt IE 9]> <script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script> <![endif]--> <!-- Mobile Specific Metas & Favicons ========================================================= --> <!-- WordPress Stuff ========================================================= --> <link rel="pingback" href="http://rajatbhageria.com/xmlrpc.php" /> <!-- Google Web Fonts --> <link href='http://fonts.googleapis.com/css?family=Open+Sans:300italic,400italic,600italic,700italic,800italic,400,300,600,700,800|&subset=latin,latin-ext,cyrillic,cyrillic-ext,greek-ext,greek,vietnamese' rel='stylesheet' type='text/css'><link href='http://fonts.googleapis.com/css?family=Oswald:300italic,400italic,600italic,700italic,800italic,400,300,600,700,800|&subset=latin,latin-ext,cyrillic,cyrillic-ext,greek-ext,greek,vietnamese' rel='stylesheet' type='text/css'> <link rel="alternate" type="application/rss+xml" title="Rajat Bhageria &raquo; Feed" href="http://rajatbhageria.com/feed/" /> <link rel="alternate" type="application/rss+xml" title="Rajat Bhageria &raquo; Comments Feed" href="http://rajatbhageria.com/comments/feed/" /> <link rel="alternate" type="application/rss+xml" title="Rajat Bhageria &raquo; rajat bhageria book Tag Feed" href="http://rajatbhageria.com/tag/rajat-bhageria-book/feed/" /> <link rel='stylesheet' id='jetpack_css-css' href='http://rajatbhageria.com/wp-content/plugins/jetpack/css/jetpack.css?ver=3.2' type='text/css' media='all' /> <link rel='stylesheet' id='rnrWide-css' href='http://rajatbhageria.com/wp-content/themes/jarvis_wp/css/1200.css?ver=1' type='text/css' media='all' /> <link rel='stylesheet' id='rnrSocial-css' href='http://rajatbhageria.com/wp-content/themes/jarvis_wp/css/social.css?ver=1' type='text/css' media='all' /> <link rel='stylesheet' id='rnrFlexslider-css' href='http://rajatbhageria.com/wp-content/themes/jarvis_wp/css/flexslider.css?ver=1' type='text/css' media='all' /> <link rel='stylesheet' id='rnrFontawesome-css' href='http://rajatbhageria.com/wp-content/themes/jarvis_wp/css/font-awesome.css?ver=1' type='text/css' media='all' /> <link rel='stylesheet' id='rnrPrettyPhoto-css' href='http://rajatbhageria.com/wp-content/themes/jarvis_wp/css/prettyPhoto.css?ver=1' type='text/css' media='all' /> <link rel='stylesheet' id='rnrShortcodes-css' href='http://rajatbhageria.com/wp-content/themes/jarvis_wp/css/shortcodes.css?ver=1' type='text/css' media='all' /> <link rel='stylesheet' id='rnrTheme-css' href='http://rajatbhageria.com/wp-content/themes/jarvis_wp/css/theme.css?ver=1' type='text/css' media='all' /> <link rel='stylesheet' id='rnrAnimate-css' href='http://rajatbhageria.com/wp-content/themes/jarvis_wp/css/rnr-animate.css?ver=1' type='text/css' media='all' /> <link rel='stylesheet' id='rnrMedia-css' href='http://rajatbhageria.com/wp-content/themes/jarvis_wp/css/media.css?ver=1' type='text/css' media='all' /> <link rel='stylesheet' id='style-css' href='http://rajatbhageria.com/wp-content/themes/jarvis_wp/style.css?ver=1' type='text/css' media='all' /> <script type='text/javascript' src='http://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js?ver=4.0'></script> <link rel="EditURI" type="application/rsd+xml" title="RSD" href="http://rajatbhageria.com/xmlrpc.php?rsd" /> <link rel="wlwmanifest" type="application/wlwmanifest+xml" href="http://rajatbhageria.com/wp-includes/wlwmanifest.xml" /> <meta name="generator" content="WordPress 4.0" /> <style type="text/css">.recentcomments a{display:inline !important;padding:0 !important;margin:0 !important;}</style> <!-- CUSTOM TYPOGRAPHY STYLES --> <style type="text/css"> .home-parallax { background: url('http://rajatbhageria.com/wp-content/uploads/2013/08/Edited-for-Website-v3.jpg') center top; } .rnr-video { background: url('http://rajatbhageria.com/wp-content/uploads/2013/08/Edited-for-Website-v3.jpg') center top; } #parallax-quote.parallax { background-image: url('http://rajatbhageria.com/wp-content/uploads/2014/10/parallax1-1155x400.jpg') !important; } #parallax-twitter.parallax { background-image: url('http://rajatbhageria.com/wp-content/uploads/2013/08/sunset-hair-770x330.jpg') !important; } #parallax-address.parallax { background-image: url('http://rajatbhageria.com/wp-content/uploads/2013/08/parallax4-770x330.jpg') !important; } #second-quote.parallax { background-image: url('http://rajatbhageria.com/wp-content/uploads/2014/06/office2-1000x400.jpg') !important; } #resume.parallax { background-image: url('http://rajatbhageria.com/wp-content/uploads/2014/06/6958645786_fe7ca5a719_o-770x330.jpg') !important; } body{ font-family: Open Sans, Arial, Helvetica, sans-serif !important; font-size: 13px; font-style: normal; color: #000000; font-weight: normal; } h1{ font-size: 80px; font-style: normal; color: #000000; font-weight: normal; text-transform: none; } .contact-details h1 { font-size: 80px !important; } h2{ font-size: 36px; font-style: normal; color: #000000; font-weight: normal; text-transform: none; } h3{ font-size: 20px; font-style: normal; color: #000000; font-weight: normal; text-transform: none; } h4{ font-size: 18px; font-style: normal; font-weight: normal; text-transform: none; color: #000000; } h5{ font-size: 16px; font-style: normal; color: #000000; font-weight: normal; text-transform: none; } h6{ font-size: 14px; font-style: normal; font-weight: normal; text-transform: none; color: #000000; } .subtitle { font-size: 25px; font-style: normal; font-weight: lighter; text-transform: uppercase; color: #000000; } .home-parallax h1, .home-parallax h2, .home-parallax h3, .home-parallax h4, .home-parallax h5, .home-parallax h6, .home-fullscreenslider h1, .home-fullscreenslider h2, .home-fullscreenslider h3, .home-fullscreenslider h4, .home-fullscreenslider h5, .home-fullscreenslider h6, .home-video h1, .home-video h2, .home-video h3, .home-video h4, .home-video h5, .home-video h6, .parallax h1, .parallax h2, .parallax h3, .parallax h4, .parallax h5, .parallax h6, .parallax p.quote, .home-slide .home-slide-content, #slidecaption, .parallax .twitter-author a, .contact-details h2, .home3 h1 { font-size: 45px; font-style: normal; font-weight: normal; text-transform: none; color: #ffffff; } .home3 h1{ width:420px; margin:0 40px; } @media only screen and (max-width: 767px) { .home3 h1 { width: 380px; margin:0 30px; } } @media only screen and (max-width: 479px) { .home3 h1 { width: 220px; margin:0 30px; } } .home-logo-text a { } .home-parallax, .home-video, .parallax, .parallax #twitter-feed ul.slides > li, .parallax .testimonial-slide .client-testimonial, .slidedescription { font-size: 16px; font-style: normal; color: #ffffff; } .navigation.colored li a, nav.light .main-menu a, nav.dark .main-menu a, nav.transparent.scroll a, .page-template-default nav.transparent .main-menu a, .blog nav.transparent .main-menu a, nav.transparent.scroll .main-menu a { font-family: Oswald, Arial, Helvetica, sans-serif; font-size: 14px; font-style: normal; color: #0a0a0a; font-weight: bold; text-transform: uppercase; } nav.transparent a { font-family: Oswald, Arial, Helvetica, sans-serif; font-size: 14px; font-style: normal; font-weight: bold; text-transform: uppercase; } .navigation li a:hover, .navigation li.active a , .navigation.colored li a:hover, .navigation.colored li.active a, .navigation li.current-menu-item a, .navigation li.current_page_parent > a{ color: #20c2db !important; } .navigation.transparent li.current-menu-item a, .navigation.transparent li.active a { color: #00b3c4 !important; } .copyright { background: #00dbd0 !important; font-family: Open Sans, Arial, Helvetica, sans-serif; font-size: 14px; font-style: normal; color: #ffffff; } .copyright a, .copyright .social-icons .social-icon { color: #ffffff; } .copyright a:hover { color: #000000; } .home-text-wrapper, .parallax-overlay { } a.rnr-video-control { display:none !important; } /*========== B A C K G R O U N D S K I N S =============*/ ::-moz-selection { background: #00b3c4; } ::selection { background:#00b3c4; } nav.colored, nav.light.colored, .twitter-feed-icon i, .testimonial-icon i, .home-gradient, .home-parallax, #project-navigation ul li#prevProject a:hover, #project-navigation ul li#nextProject a:hover, #project-navigation ul li a:hover, #closeProject a:hover, .mc4wp-form input[type="submit"], #respond input[type="submit"], input[type="submit"], .pagination a.previous:hover, .pagination a.next:hover, .service-box:hover, .button, .skillbar .skill-percentage, .flex-control-nav li a:hover, .flex-control-nav li a.flex-active, .testimonial-slider .flex-direction-nav li a i, .twitter-slider .flex-direction-nav li a i, .project-media .flex-direction-nav li a i, .color-block, .home1 .slabtextdone .slabtext.second-child, .home4 .slabtextdone .slabtext.second-child, .caption, .copyright, .title h1, .service-features .img-container, .service-features .img-container, .view-profile, .team-member:hover .team-desc, .service-box .service-icon, .modal .close, #nav .sub-menu li.current-menu-item a, #nav .sub-menu li.current-menu-item a:hover, #nav .sub-menu li.current_page_item a, #nav .sub-menu li.current_page_item a:hover, #nav .sub-menu li .sub-menu li.current-menu-item a, #nav .sub-menu li .sub-menu li.current-menu-item a:hover, #nav .sub-menu li .sub-menu li.current_page_item a, #nav .sub-menu li .sub-menu li.current_page_item a:hover, #nav .sub-menu li a.active, #nav .sub-menu li a.active:hover, #port-pagination a:hover, #respond input[type="submit"], .woocommerce #respond input#submit, .woocommerce ul.products li.product a.button, .woocommerce-page ul.products li.product a.button, .woocommerce div.product form.cart .button, .woocommerce-page .woocommerce-message .button, .woocommerce .cart-collaterals .shipping_calculator .button, .woocommerce-page .cart-collaterals .shipping_calculator .button, .woocommerce .login input.button, .woocommerce .checkout_coupon input.button, .woocommerce .cart input.button.alt, .woocommerce .login input.button, .woocommerce .checkout_coupon input.button, .woocommerce #respond input#submit:hover, .woocommerce-page .woocommerce-message .button:hover, .woocommerce button.button.alt, .woocommerce a.wc-backward, .woocommerce a.wc-backward:hover, .woocommerce #payment #place_order, .woocommerce-page #payment #place_order, .woocommerce #payment #place_order:hover, .woocommerce-page #payment #place_order:hover, .woocommerce .widget_price_filter .ui-slider .ui-slider-range, .woocommerce-page .widget_price_filter .ui-slider .ui-slider-range, .latest-blog .blog-item .inner:hover .blog-item-description .desc.post-icon, .blog .blog-overlay, .latest-blog .blog-item .blog-item-description span.date, div.wpcf7 div.stretch-submit input[type="submit"], .plan.featured .plan-head { background-color: #00b3c4; } /*========== B O X S H A D O W S K I N S =============*/ .title h1, .service-box .service-icon { box-shadow:0px 0px 0px 3px #00b3c4; } .tab a.selected { box-shadow: 0px -3px 0px 0px #00b3c4; } /*========== C O L O R S K I N S =============*/ a, .highlight, nav.light .main-menu a:hover, nav.dark .main-menu a:hover, nav.light .main-menu li.active a, nav.transparent .main-menu li.active a, nav.dark .main-menu li.active a, .parallax .quote i, #filters ul li a:hover h3, #filters ul li a.active h3, .post-title a:hover, .post-tags li a:hover, .tags-list li a:hover, .pages li a:hover, .home3 .slabtextdone .slabtext.second-child, .service-box:hover .service-icon, span.amount, #nav .sub-menu li a:hover, #nav .sub-menu li .sub-menu li a:hover, #nav .sub-menu li .sub-menu li .sub-menu li a:hover { color:#00b3c4; } /*========== B O R D E R S K I N S =============*/ .pages li a.current, .pages li a.current, .service-features .img-container:after, .service-box:hover .service-icon, .callout, blockquote p, .pullquote.align-right, .pullquote.align-left { border-color: #00b3c4; } </style> </head> <body class="archive tag tag-rajat-bhageria-book tag-43 onepage" data-spy="scroll" data-target=".navigation" data-offset="82"> <div id="load"></div> <!-- START PAGE WRAP --> <div class="page-wrap "> <!-- HEADER SECTION --> <!-- START NAVIGATION --> <nav class=" navigation light sticky-nav"> <!-- START CONTAINER --> <div class="container clearfix"> <div class="four columns"> <!-- START LOGO --> <div class="logo large"> <h1><a href="http://rajatbhageria.com/#" class="">Rajat Bhageria</a></h1> </div> <!-- END LOGO --> <div class="wpml-mobile"> </div> </div><!-- END FOUR COLUMNS --> <!-- BEGIN NAVIGATION SECTION --> <div class="twelve columns"> <!-- START NAVIGATION MENU ITEMS --> <ul id="nav" class="main-menu large nav sf-menu sf-js-enabled"><li id="menu-item-734" class="menu-item menu-item-type-post_type menu-item-object-page"><a rel="author" href="http://rajatbhageria.com/#home"><span>Home</span></a></li> <li id="menu-item-733" class="menu-item menu-item-type-post_type menu-item-object-page"><a rel="author" href="http://rajatbhageria.com/#cafemocha"><span>CafeMocha</span></a></li> </li> <li id="menu-item-799" class="menu-item menu-item-type-post_type menu-item-object-page"><a href="http://rajatbhageria.com/#thirdeye"><span>ThirdEye</span></a></li> </li> <li id="menu-item-743" class="menu-item menu-item-type-post_type menu-item-object-page"><a rel="author" href="http://rajatbhageria.com/#portfolio"><span>Portfolio</span></a></li> </li> </li> <li id="menu-item-751" class="menu-item menu-item-type-post_type menu-item-object-page"><a href="http://rajatbhageria.com/#resume"><span>Resume</span></a></li> <li id="menu-item-748" class="menu-item menu-item-type-post_type menu-item-object-page"><a rel="author" href="http://rajatbhageria.com/#blog-2"><span>Blog</span></a></li> </li> <li id="menu-item-747" class="menu-item menu-item-type-post_type menu-item-object-page"><a href="http://rajatbhageria.com/#skillset"><span>Skills</span></a></li> </li> <li id="menu-item-745" class="menu-item menu-item-type-post_type menu-item-object-page"><a href="http://rajatbhageria.com/#contact"><span>Contact</span></a></li> </li> </ul> <!-- END NAVIGATION MENU ITEMS --> <div class="wpml-desktop"> </div> </div><!-- END TWELVE COLUMNS --> </div><!-- END CONTAINER --> </nav> <!-- END NAVIGATION --> <div class="section post-single"><!-- SECTION --> <div class="container"> <div class="row"> <div class="sixteen columns"> <!-- START TITLE --> <div class="title"> <h1 class="header-text"> Posts Tagged:rajat bhageria book </h1> </div><!-- END TITLE --> </div><!-- END SIXTEEN COLUMNS --> </div><!-- END ROW --> </div><!-- END CONTAINER --> </div> <div class="container"> <div class="row"> <div class="twelve columns"> <h2>No Posts Found</h2> </div><!-- END SPAN8 --> <div id="sidebar" class="four columns"> <div class="sidebar-content"> <div id="search-2" class="widget widget_search"><form action="http://rajatbhageria.com/" id="searchform" method="get"> <input type="text" id="s" name="s" value="To search type and hit enter" onfocus="if(this.value=='To search type and hit enter')this.value='';" onblur="if(this.value=='')this.value='To search type and hit enter';" autocomplete="off" /> <input type="submit" value="Search" id="searchsubmit" class="hidden" /> </form> </div> <div id="recent-posts-2" class="widget widget_recent_entries"> <h3>Recent Posts</h3> <ul> <li> <a href="http://rajatbhageria.com/start-school-later/">Why Don&#039;t We Start School Later?</a> </li> <li> <a href="http://rajatbhageria.com/161718-year-old-entrepreneur/">How to be a 16/17/18 Year old Entrepreneur</a> </li> <li> <a href="http://rajatbhageria.com/high-school-didnt-teach-excerpt/">What High School Didn&#039;t Teach Me Excerpt</a> </li> <li> <a href="http://rajatbhageria.com/fifa-world-cup-watched-sporting-event-time/">Why the FIFA World Cup is the Most Watched Sporting Event of all time</a> </li> <li> <a href="http://rajatbhageria.com/optimism-always-wins/">Why Optimism Always Wins</a> </li> </ul> </div><div id="recent-comments-2" class="widget widget_recent_comments"><h3>Recent Comments</h3><ul id="recentcomments"><li class="recentcomments"><span class="comment-author-link"><a href='http://rajatbhageria.com/start-school-later/' rel='external nofollow' class='url'>Rajat Bhageria | Why Don&#039;t We Start School Later?</a></span> on <a href="http://rajatbhageria.com/high-school-didnt-teach-excerpt/#comment-2">What High School Didn&#039;t Teach Me Excerpt</a></li></ul></div><div id="archives-2" class="widget widget_archive"><h3>Archives</h3> <ul> <li><a href='http://rajatbhageria.com/2014/08/'>August 2014</a></li> <li><a href='http://rajatbhageria.com/2014/07/'>July 2014</a></li> </ul> </div><div id="categories-2" class="widget widget_categories"><h3>Categories</h3> <ul> <li class="cat-item cat-item-2"><a href="http://rajatbhageria.com/category/cafemocha/" >CafeMocha</a> </li> <li class="cat-item cat-item-3"><a href="http://rajatbhageria.com/category/education-reform/" >Education Reform</a> </li> <li class="cat-item cat-item-4"><a href="http://rajatbhageria.com/category/entertainement/" >Entertainement</a> </li> <li class="cat-item cat-item-5"><a href="http://rajatbhageria.com/category/entrepreneurship/" >Entrepreneurship</a> </li> <li class="cat-item cat-item-6"><a href="http://rajatbhageria.com/category/fun/" >Fun</a> </li> <li class="cat-item cat-item-7"><a href="http://rajatbhageria.com/category/journal/" >Journal</a> </li> <li class="cat-item cat-item-1"><a href="http://rajatbhageria.com/category/uncategorized/" >Uncategorized</a> </li> </ul> </div><div id="meta-2" class="widget widget_meta"><h3>Meta</h3> <ul> <li><a href="http://rajatbhageria.com/wp-login.php">Log in</a></li> <li><a href="http://rajatbhageria.com/feed/">Entries <abbr title="Really Simple Syndication">RSS</abbr></a></li> <li><a href="http://rajatbhageria.com/comments/feed/">Comments <abbr title="Really Simple Syndication">RSS</abbr></a></li> <li><a href="https://wordpress.org/" title="Powered by WordPress, state-of-the-art semantic personal publishing platform.">WordPress.org</a></li> </ul> </div> </div> </div> </div> </div> </div><!--END SECTION --> <!-- START COPYRIGHT SECTION --> <div class="copyright aligncenter"> <div class="container clearfix"> <div class="sixteen columns"> <div class="copyright-logo"> <h1><a href="http://rajatbhageria.com/">Rajat Bhageria</a></h1> </div> <div class="social-icons"> <div class="social-icon social-email"><a href="mailto:rajat@cafemocha.org" title="Email">Email</a></div> <div class="social-icon social-behance"><a href="https://www.behance.net/rajatbhageria" target="_blank" title="Behance">Behance</a></div> <div class="social-icon social-facebook"><a href="https://www.facebook.com/rajat.bhageria" target="_blank" title="Facebook">Facebook</a></div> <div class="social-icon social-flickr"><a href="https://www.flickr.com/photos/rajatbhageria" target="_blank" title="Flickr">Flickr</a></div> <div class="social-icon social-googleplus"><a href="google.com/+RajatBhageria96" target="_blank" title="Googleplus">Googleplus</a></div> <div class="social-icon social-linkedin"><a href="https://www.linkedin.com/in/Rajatbhageria" target="_blank" title="Linkedin">Linkedin</a></div> <div class="social-icon social-pinterest"><a href="http://www.pinterest.com/RajatBhageria/" target="_blank" title="Pinterest">Pinterest</a></div> <div class="social-icon social-twitter"><a href="https://twitter.com/RajatBhageria" target="_blank" title="Twitter">Twitter</a></div> <div class="social-icon social-wordpress"><a href="http://RajatBhageria.com" target="_blank" title="Wordpress">Wordpress</a></div> <div class="social-icon social-youtube"><a href="https://www.youtube.com/channel/UCQEm7E_pa0BijXoj4cZ--0A" target="_blank" title="Youtube">Youtube</a></div> <div class="social-icon social-angellist"><a href="https://angel.co/rajat-bhageria" target="_blank" title="Angel List">Angel List</a></div> </div> <p>Created by Rajat Bhageria. All Rights Reserved. </p> </div> <!-- END SIXTEEN COLUMNS --> </div><!-- END CONTAINER --> </div> <!-- END COPYRIGHT SECTION --> </div> <div id="back-to-top"><a href="#">Back to Top</a></div> <script type='text/javascript' src='http://rajatbhageria.com/wp-content/themes/jarvis_wp/js/jquery.queryloader2.js?ver=1'></script> <script type='text/javascript' src='http://rajatbhageria.com/wp-content/themes/jarvis_wp/js/init.js?ver=1'></script> <script type='text/javascript' src='http://rajatbhageria.com/wp-content/themes/jarvis_wp/js/SmoothScroll.js?ver=4.0'></script> <script type='text/javascript' src='http://rajatbhageria.com/wp-content/themes/jarvis_wp/js/scripts.js?ver=1'></script> <script type='text/javascript' src='http://rajatbhageria.com/wp-content/themes/jarvis_wp/js/ajax-portfolio.js?ver=1'></script> <script type='text/javascript' src='http://rajatbhageria.com/wp-content/themes/jarvis_wp/js/shortcodes.js?ver=1'></script> <script type='text/javascript' src='https://maps.googleapis.com/maps/api/js?sensor=false&#038;libraries=places&#038;ver=2.1'></script> <script type='text/javascript' src='http://google-maps-utility-library-v3.googlecode.com/svn/trunk/infobox/src/infobox.js?ver=2.1'></script> </body> </html> <!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/ Page Caching using disk: enhanced Served from: rajatbhageria.com @ 2014-11-02 02:12:35 by W3 Total Cache -->
RajatBhageria/RajatBhageria.com
wp-content/cache/page_enhanced/RAJATBHAGERIA.COM/tag/rajat-bhageria-book/_index.html
HTML
gpl-2.0
25,660
/***************************************************************************** * Free42 -- an HP-42S calculator simulator * Copyright (C) 2004-2014 Thomas Okken * * 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. * * 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 AUDIO_ALSA_H #define AUDIO_ALSA_H 1 bool alsa_beeper(int frequency, int duration); #endif
jackokring/free42
gtk/audio_alsa.h
C
gpl-2.0
928
#include <QImage> #include <QFile> #include "SpriteBundle.h" SpriteBundle::SpriteBundle() { m_index = 0; } void SpriteBundle::update(const int delta) { Sprite &image = m_sprites[m_index]; image.update(delta); } void SpriteBundle::setImageIndex(const int index) { m_index = index; } QSGTexture *SpriteBundle::currentImage(Scene *scene, bool flipped) { Sprite &image = m_sprites[m_index]; QSGTexture *frame = image.currentFrame(scene, flipped); return frame; } int SpriteBundle::spriteCount() const { return m_sprites.count(); } int SpriteBundle::imageIndex() const { return m_index; } QDataStream &operator >>(QDataStream &stream, SpriteBundle &bundle) { stream >> bundle.m_sprites; return stream; }
MemoryLeek/ld27
SpriteBundle.cpp
C++
gpl-2.0
720
/************************************************************************* * Clus - Software for Predictive Clustering * * Copyright (C) 2007 * * Katholieke Universiteit Leuven, Leuven, Belgium * * Jozef Stefan Institute, Ljubljana, Slovenia * * * * 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/>. * * * * Contact information: <http://www.cs.kuleuven.be/~dtai/clus/>. * *************************************************************************/ /* * Created on Jul 28, 2005 * */ package clus.ext.beamsearch; import clus.algo.tdidt.ClusNode; import clus.main.Settings; import clus.statistic.ClusStatistic; import clus.statistic.RegressionStat; public class ClusBeamHeuristicMorishita extends ClusBeamHeuristic { public ClusBeamHeuristicMorishita(ClusStatistic stat) { super(stat); } public double computeMorishitaStat(ClusStatistic stat, ClusStatistic tstat) { RegressionStat stat_set = (RegressionStat)stat; RegressionStat stat_all = (RegressionStat)tstat; // Compute half of formula from Definition 2 of Morishita paper double result = 0.0; for (int i = 0; i < stat_set.getNbAttributes(); i++) { double term_i = stat_set.getMean(i) - stat_all.getMean(i); result += term_i * term_i; } return result * stat_set.getTotalWeight(); } public double calcHeuristic(ClusStatistic c_tstat, ClusStatistic c_pstat, ClusStatistic missing) { double n_tot = c_tstat.m_SumWeight; double n_pos = c_pstat.m_SumWeight; double n_neg = n_tot - n_pos; // Acceptable? if (n_pos < Settings.MINIMAL_WEIGHT || n_neg < Settings.MINIMAL_WEIGHT) { return Double.NEGATIVE_INFINITY; } m_Neg.copy(c_tstat); m_Neg.subtractFromThis(c_pstat); // Does not take into account missing values! return computeMorishitaStat(c_pstat, c_tstat) + computeMorishitaStat(m_Neg, c_tstat); } public double estimateBeamMeasure(ClusNode tree, ClusNode parent) { if (tree.atBottomLevel()) { return computeMorishitaStat(tree.getClusteringStat(), parent.getClusteringStat()); } else { double result = 0.0; for (int i = 0; i < tree.getNbChildren(); i++) { ClusNode child = (ClusNode)tree.getChild(i); result += estimateBeamMeasure(child); } return result; } } public double estimateBeamMeasure(ClusNode tree) { if (tree.atBottomLevel()) { return 0; } else { double result = 0.0; for (int i = 0; i < tree.getNbChildren(); i++) { ClusNode child = (ClusNode)tree.getChild(i); result += estimateBeamMeasure(child, tree); } return result; } } public double computeLeafAdd(ClusNode leaf) { return 0.0; } public String getName() { return "Beam Heuristic (Morishita)"; } public void setRootStatistic(ClusStatistic stat) { super.setRootStatistic(stat); } }
active-learning/active-learning-scala
src/main/java/clus/ext/beamsearch/ClusBeamHeuristicMorishita.java
Java
gpl-2.0
3,865
// Implementing the functionality for system calls (keystrokes etc.) and // exercising different functions available from other classes/files // // Author: Archit Gupta, Nehal Bhandari // Date: December 24, 2015 #include "process.h" char valid_keystroke(DisplayHandler* display, char input) { if ((input <= 'z' && input >= 'a') || (input <= 'Z' && input >= 'A')) { return 0; } return input; } // Function definitions for PreviewManager class PreviewManager::PreviewManager() { win = NULL; m_mode = VISUAL; m_exit_signal = false; m_cursor_y = Y_OFFSET; m_cursor_x = X_OFFSET; } // Function definitions specific to ListPreviewManager ListPreviewManager::ListPreviewManager() { ListPreviewManager(NULL, NULL); } ListPreviewManager::ListPreviewManager(WINDOW *_win, ToDoList *td) { win = _win; td_list = td; if (td_list != NULL) { entry_under_cursor = td->get_list_top(); } m_mode = VISUAL; m_exit_signal = false; m_cursor_y = Y_OFFSET; m_cursor_x = X_OFFSET; } void ListPreviewManager::printToDoList(ToDoListEntry* first_entry_to_print) { int y_cursor = m_cursor_y; // TODO: Add functionality to print the todo-list title here (and have a // title for the todo list in the first place ToDoListEntry* entry_to_print = first_entry_to_print; while(entry_to_print != NULL) { printToDoEntry(entry_to_print, y_cursor); y_cursor += entry_to_print->get_message_block_length(); entry_to_print = entry_to_print->get_next_todo_entry(); } box(win, 0, 0); wrefresh(win); } void ListPreviewManager::printToDoEntry(ToDoListEntry* entry_to_print, int y_cursor) { entry_to_print->print(win, y_cursor, entry_to_print == entry_under_cursor); #ifdef __DEBUG__ //getch(); //box(win, 0, 0); wrefresh(win); #endif } void ListPreviewManager::insert_text(char input) { entry_under_cursor->insert_text(win, m_cursor_y, m_cursor_x, input); if ((input >= (char) FIRST_WRITABLE_ASCII_CHAR) && (input <= (char) LAST_WRITEABLE_ASCII_CHAR)) { move_cursor_right(); } else if (input == (char) M_KEY_BACKSPACE) { move_cursor_left(); } wrefresh(win); } void ListPreviewManager::process(char input) { switch (input) { #define F_DEF(INPUT, FUNCTION, NON_FUNC_MODE)\ case INPUT:\ if (m_mode == NON_FUNC_MODE)\ {\ insert_text(INPUT);\ } else {\ FUNCTION(); \ } break; #include "keystrokes.def" #undef F_DEF default: if (m_mode == INSERT) { insert_text(input); } else { return; } break; } } // Key stroke related functions have been described here void ListPreviewManager::move_cursor_left(){ if (m_mode == EDIT || m_mode == INSERT) { if (m_cursor_x > X_OFFSET) { wmove(win, m_cursor_y, --m_cursor_x); wrefresh(win); } else{ int old_cursor_y = m_cursor_y; move_cursor_up(); if (old_cursor_y != m_cursor_y) { // Change the x cursor value only if the y cursor has changed // (i.e. the line under cursor has been switched) m_cursor_x = WRITABLE_X; wmove(win, m_cursor_y, m_cursor_x); wrefresh(win); } } } } void ListPreviewManager::move_cursor_right(){ if (m_mode == EDIT || m_mode == INSERT) { if (m_cursor_x < entry_under_cursor->x_limit()) { wmove(win, m_cursor_y, ++m_cursor_x); wrefresh(win); } else{ int old_cursor_y = m_cursor_y; move_cursor_down(); if (old_cursor_y != m_cursor_y) { // Change the x cursor value only if the y cursor has changed // (i.e. the line under cursor has been switched) m_cursor_x = X_OFFSET; wmove(win, m_cursor_y, m_cursor_x); wrefresh(win); } } } } void ListPreviewManager::move_cursor_up(){ if (m_mode == VISUAL) { if(entry_under_cursor->get_prev_todo_entry() != NULL) { entry_under_cursor->refresh(win, m_cursor_y, false); entry_under_cursor = entry_under_cursor->get_prev_todo_entry(); m_cursor_y -= entry_under_cursor->get_message_block_length(); entry_under_cursor->refresh(win, m_cursor_y, true); wrefresh(win); box(win, 0, 0); } } else { bool jump_todo_entry = entry_under_cursor->check_end_point(true); if (jump_todo_entry) { if(entry_under_cursor->get_prev_todo_entry() != NULL) { entry_under_cursor = entry_under_cursor->get_prev_todo_entry(); entry_under_cursor->set_cursor_bottom(); m_cursor_x = entry_under_cursor->x_limit(); wmove(win, --m_cursor_y, m_cursor_x); } } else { entry_under_cursor->update_cursor_position(win, m_cursor_y, m_cursor_x, true); } wrefresh(win); } } void ListPreviewManager::move_cursor_down(){ if (m_mode == VISUAL) { if(entry_under_cursor->get_next_todo_entry() != NULL) { entry_under_cursor->refresh(win, m_cursor_y, false); m_cursor_y += entry_under_cursor->get_message_block_length(); entry_under_cursor = entry_under_cursor->get_next_todo_entry(); entry_under_cursor->refresh(win, m_cursor_y, true); wrefresh(win); box(win, 0, 0); } } else { bool jump_todo_entry = entry_under_cursor->check_end_point(false); if (jump_todo_entry) { if(entry_under_cursor->get_prev_todo_entry() != NULL) { entry_under_cursor = entry_under_cursor->get_next_todo_entry(); entry_under_cursor->set_cursor_top(); m_cursor_x = X_OFFSET; wmove(win, ++m_cursor_y, m_cursor_x); } } else { entry_under_cursor->update_cursor_position(win, m_cursor_y, m_cursor_x, false); } wrefresh(win); } } // Switching between various modes void ListPreviewManager::switch_to_edit_mode(){ PreviewMode last_mode = m_mode; m_mode = EDIT; curs_set(m_mode); if (last_mode == VISUAL) { entry_under_cursor->refresh(win, m_cursor_y, false); wmove(win, m_cursor_y, X_OFFSET); wrefresh(win); } } void ListPreviewManager::switch_to_visual_mode(){ if (m_mode == EDIT) { m_mode = VISUAL; curs_set(m_mode); entry_under_cursor->refresh(win, m_cursor_y, true); wrefresh(win); } } void ListPreviewManager::switch_to_insert_mode(){ m_mode = INSERT; curs_set(EDIT); // Using curs_set(INSERT) makes the cursor invisible -___- entry_under_cursor->refresh(win, m_cursor_y, false); wmove(win, m_cursor_y, m_cursor_x); wrefresh(win); } void ListPreviewManager::step_modes_back(){ switch (m_mode) { case EDIT: switch_to_visual_mode(); break; case INSERT: switch_to_edit_mode(); break; default: switch_to_visual_mode(); break; } } // Adding and deleting ToDo Entries void ListPreviewManager::add_todo_entry(){ entry_under_cursor = td_list->new_todo_entry(entry_under_cursor); printToDoList(entry_under_cursor); } void ListPreviewManager::two_tap_delete(){ char repeat = getch(); if (repeat == 'd') { ToDoListEntry* next_todo_entry = entry_under_cursor->get_next_todo_entry(); td_list->remove_todo_entry(entry_under_cursor); entry_under_cursor = next_todo_entry; printToDoList(entry_under_cursor); } } void ListPreviewManager::two_tap_quit(){ char repeat = getch(); if (repeat == 'q') { m_exit_signal = true; } } void ListPreviewManager::toggle_mark_unmark(){ entry_under_cursor->toggle_mark_unmark(); entry_under_cursor->refresh(win, m_cursor_y, true); wrefresh(win); }
architgupta93/todo-app
2_Code/process.cpp
C++
gpl-2.0
8,567
function Drag(id,init) { var _this=this; this.disX=0; this.disY=0; this.oDiv=document.getElementById(id); if(init) { _this.fnDown(); } this.oDiv.onmousedown=function (ev) { _this.fnDown(ev); return false; }; } Drag.prototype.fnDown=function (ev) { var _this=this; var oEvent=ev||event; this.disX=oEvent.clientX-this.oDiv.offsetLeft; this.disY=oEvent.clientY-this.oDiv.offsetTop; document.onmousemove=function (ev) { _this.fnMove(ev); }; document.onmouseup=function () { _this.fnUp(); }; }; Drag.prototype.fnMove=function (ev) { var oEvent=ev||event; this.oDiv.style.left=oEvent.clientX-this.disX+'px'; this.oDiv.style.top=oEvent.clientY-this.disY+'px'; }; Drag.prototype.fnUp=function () { document.onmousemove=null; document.onmouseup=null; }; function LimitDrag(id) { Drag.call(this, id); } //LimitDrag.prototype=Drag.prototype; for(var i in Drag.prototype) { LimitDrag.prototype[i]=Drag.prototype[i]; } LimitDrag.prototype.fnMove=function (ev) { var oEvent=ev||event; var l=oEvent.clientX-this.disX; var t=oEvent.clientY-this.disY; if(l<0) { l=0; } else if(l>document.documentElement.clientWidth-this.oDiv.offsetWidth) { l=document.documentElement.clientWidth-this.oDiv.offsetWidth; } if(t<0) { t=0; } else if(t>document.documentElement.clientHeight-this.oDiv.offsetHeight) { t=document.documentElement.clientHeight-this.oDiv.offsetHeight; } this.oDiv.style.left=l+'px'; this.oDiv.style.top=t+'px'; };
Jackmeng1985/drupal7
sites/all/modules/beauty_crm/js/drag.js
JavaScript
gpl-2.0
1,492
#!/usr/bin/env python background_image_filename = 'sushiplate.jpg' import pygame from pygame.locals import * from sys import exit SCREEN_SIZE = (640, 480) pygame.init() screen = pygame.display.set_mode(SCREEN_SIZE, NOFRAME, 32) background = pygame.image.load(background_image_filename).convert() while True: event = pygame.event.wait() if event.type == QUIT: exit() if event.type == VIDEORESIZE: SCREEN_SIZE = event.size screen = pygame.display.set_mode(SCREEN_SIZE, RESIZABLE, 32) pygame.display.set_caption('Window resized to ' + str(event.size)) # screen.fill((0, 0, 0)) screen.blit(background, (0, 0)) # screen_width, screen_height = SCREEN_SIZE # for y in range(0, screen_height, background.get_height()): # for x in range(0, screen_width, background.get_width()): # screen.blit(background, (x, y)) pygame.display.update()
opensvn/python
pygame/resize.py
Python
gpl-2.0
919
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <html><head> <meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1"/> <meta name="keywords" content="TEMU, dynamic analysis, binary analysis, dynamic taint analysis"/> <meta name="description" content="C/C++/OCaml Source Code Documentation for the TEMU Project."/> <title>TEMU: term_cmd_t Struct Reference</title> <link href="doxygen.css" rel="stylesheet" type="text/css"/> </head><body> <p class="title">TEMU: Dynamic Binary Analysis Platform</p> <!-- Generated by Doxygen 1.5.8 --> <div class="navigation" id="top"> <div class="tabs"> <ul> <li><a href="index.html"><span>Main&nbsp;Page</span></a></li> <li><a href="modules.html"><span>Modules</span></a></li> <li class="current"><a href="annotated.html"><span>Data&nbsp;Structures</span></a></li> <li><a href="files.html"><span>Files</span></a></li> <li><a href="dirs.html"><span>Directories</span></a></li> <li> <form action="search.php" method="get"> <table cellspacing="0" cellpadding="0" border="0"> <tr> <td><label>&nbsp;<u>S</u>earch&nbsp;for&nbsp;</label></td> <td><input type="text" name="query" value="" size="20" accesskey="s"/></td> </tr> </table> </form> </li> </ul> </div> <div class="tabs"> <ul> <li><a href="annotated.html"><span>Data&nbsp;Structures</span></a></li> <li><a href="classes.html"><span>Data&nbsp;Structure&nbsp;Index</span></a></li> <li><a href="functions.html"><span>Data&nbsp;Fields</span></a></li> </ul> </div> </div> <div class="contents"> <h1>term_cmd_t Struct Reference<br> <small> [<a class="el" href="group__main.html">temu: Main TEMU Module</a>]</small> </h1><!-- doxytag: class="term_cmd_t" -->structure for defining a terminal command <a href="#_details">More...</a> <p> <code>#include &lt;<a class="el" href="TEMU__main_8h-source.html">TEMU_main.h</a>&gt;</code> <p> <div class="dynheader"> Collaboration diagram for term_cmd_t:</div> <div class="dynsection"> <center><font size="2">[<a href="graph_legend.html">legend</a>]</font></center></div> <table border="0" cellpadding="0" cellspacing="0"> <tr><td></td></tr> <tr><td colspan="2"><br><h2>Data Fields</h2></td></tr> <tr><td class="memItemLeft" nowrap align="right" valign="top">const char *&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="structterm__cmd__t.html#25fe00d19374b3d6acfb11dcc55d82cf">args_type</a></td></tr> <tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">command name <a href="#25fe00d19374b3d6acfb11dcc55d82cf"></a><br></td></tr> <tr><td class="memItemLeft" nowrap align="right" valign="top">void(*&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="structterm__cmd__t.html#f1e8463e79b45f08987f78a1ac9623a1">handler</a> )()</td></tr> <tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">command argument list <a href="#f1e8463e79b45f08987f78a1ac9623a1"></a><br></td></tr> <tr><td class="memItemLeft" nowrap align="right" valign="top">const char *&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="structterm__cmd__t.html#3dd16518d3ef1f028a96b1e556d21059">help</a></td></tr> <tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">parameters of command handler <a href="#3dd16518d3ef1f028a96b1e556d21059"></a><br></td></tr> <tr><td class="memItemLeft" nowrap align="right" valign="top">const char *&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="structterm__cmd__t.html#ead95d26b2657ee3cab27a58b6d37004">name</a></td></tr> <tr><td class="memItemLeft" nowrap align="right" valign="top">const char *&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="structterm__cmd__t.html#e059485abd02e34fe57b8620719d1a96">params</a></td></tr> <tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">command handler <a href="#e059485abd02e34fe57b8620719d1a96"></a><br></td></tr> </table> <hr><a name="_details"></a><h2>Detailed Description</h2> structure for defining a terminal command <p>Definition at line <a class="el" href="TEMU__main_8h-source.html#l00227">227</a> of file <a class="el" href="TEMU__main_8h-source.html">TEMU_main.h</a>.</p> <hr><h2>Field Documentation</h2> <a class="anchor" name="25fe00d19374b3d6acfb11dcc55d82cf"></a><!-- doxytag: member="term_cmd_t::args_type" ref="25fe00d19374b3d6acfb11dcc55d82cf" args="" --> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">const char* <a class="el" href="structterm__cmd__t.html#25fe00d19374b3d6acfb11dcc55d82cf">term_cmd_t::args_type</a> </td> </tr> </table> </div> <div class="memdoc"> <p> command name <p> <p>Definition at line <a class="el" href="TEMU__main_8h-source.html#l00229">229</a> of file <a class="el" href="TEMU__main_8h-source.html">TEMU_main.h</a>.</p> </div> </div><p> <a class="anchor" name="f1e8463e79b45f08987f78a1ac9623a1"></a><!-- doxytag: member="term_cmd_t::handler" ref="f1e8463e79b45f08987f78a1ac9623a1" args=")()" --> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">void(* <a class="el" href="structterm__cmd__t.html#f1e8463e79b45f08987f78a1ac9623a1">term_cmd_t::handler</a>)() </td> </tr> </table> </div> <div class="memdoc"> <p> command argument list <p> </div> </div><p> <a class="anchor" name="3dd16518d3ef1f028a96b1e556d21059"></a><!-- doxytag: member="term_cmd_t::help" ref="3dd16518d3ef1f028a96b1e556d21059" args="" --> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">const char* <a class="el" href="structterm__cmd__t.html#3dd16518d3ef1f028a96b1e556d21059">term_cmd_t::help</a> </td> </tr> </table> </div> <div class="memdoc"> <p> parameters of command handler <p> <p>Definition at line <a class="el" href="TEMU__main_8h-source.html#l00232">232</a> of file <a class="el" href="TEMU__main_8h-source.html">TEMU_main.h</a>.</p> </div> </div><p> <a class="anchor" name="ead95d26b2657ee3cab27a58b6d37004"></a><!-- doxytag: member="term_cmd_t::name" ref="ead95d26b2657ee3cab27a58b6d37004" args="" --> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">const char* <a class="el" href="structterm__cmd__t.html#ead95d26b2657ee3cab27a58b6d37004">term_cmd_t::name</a> </td> </tr> </table> </div> <div class="memdoc"> <p> <p>Definition at line <a class="el" href="TEMU__main_8h-source.html#l00228">228</a> of file <a class="el" href="TEMU__main_8h-source.html">TEMU_main.h</a>.</p> </div> </div><p> <a class="anchor" name="e059485abd02e34fe57b8620719d1a96"></a><!-- doxytag: member="term_cmd_t::params" ref="e059485abd02e34fe57b8620719d1a96" args="" --> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">const char* <a class="el" href="structterm__cmd__t.html#e059485abd02e34fe57b8620719d1a96">term_cmd_t::params</a> </td> </tr> </table> </div> <div class="memdoc"> <p> command handler <p> <p>Definition at line <a class="el" href="TEMU__main_8h-source.html#l00231">231</a> of file <a class="el" href="TEMU__main_8h-source.html">TEMU_main.h</a>.</p> </div> </div><p> <hr>The documentation for this struct was generated from the following file:<ul> <li><a class="el" href="TEMU__main_8h-source.html">TEMU_main.h</a></ul> </div> <hr> <p class="footer"> Generated on Fri Mar 30 16:18:26 2012 for <a href="http://bitblaze.cs.berkeley.edu/temu.html">TEMU</a> by <a href="http://www.doxygen.org"><img src="doxygen.png" alt="Doxygen" align="middle" border="0"/>1.5.8</a><br/> Copyright &copy; 2008-2009, BitBlaze Project. All Rights Reserved.</p> <hr> <!--#include virtual="/attrib.incl" --> </body> </html>
huydhn/Detector
docs/doxygen/html/structterm__cmd__t.html
HTML
gpl-2.0
7,991
/* * MTD partitioning layer definitions * * (C) 2000 Nicolas Pitre <nico@cam.org> * * This code is GPL * * $Id: partitions.h,v 1.14 2003/05/20 21:56:29 dwmw2 Exp $ */ #ifndef MTD_PARTITIONS_H #define MTD_PARTITIONS_H #include <linux/types.h> /* * Partition definition structure: * * An array of struct partition is passed along with a MTD object to * add_mtd_partitions() to create them. * * For each partition, these fields are available: * name: string that will be used to label the partition's MTD device. * size: the partition size; if defined as MTDPART_SIZ_FULL, the partition * will extend to the end of the master MTD device. * offset: absolute starting position within the master MTD device; if * defined as MTDPART_OFS_APPEND, the partition will start where the * previous one ended; if MTDPART_OFS_NXTBLK, at the next erase block. * mask_flags: contains flags that have to be masked (removed) from the * master MTD flag set for the corresponding MTD partition. * For example, to force a read-only partition, simply adding * MTD_WRITEABLE to the mask_flags will do the trick. * * Note: writeable partitions require their size and offset be * erasesize aligned (e.g. use MTDPART_OFS_NEXTBLK). */ struct mtd_partition { char *name; /* identifier string */ u_int32_t size; /* partition size */ u_int32_t offset; /* offset within the master MTD space */ u_int32_t mask_flags; /* master MTD flags to mask out for this partition */ struct nand_oobinfo *oobsel; /* out of band layout for this partition (NAND only)*/ struct mtd_info **mtdp; /* pointer to store the MTD object */ }; #define MTDPART_OFS_NXTBLK (-2) #define MTDPART_OFS_APPEND (-1) #define MTDPART_SIZ_FULL (0) int add_mtd_partitions(struct mtd_info *, const struct mtd_partition *, int); int del_mtd_partitions(struct mtd_info *); /* * Functions dealing with the various ways of partitioning the space */ struct mtd_part_parser { struct list_head list; struct module *owner; const char *name; int (*parse_fn)(struct mtd_info *, struct mtd_partition **, unsigned long); }; extern struct mtd_part_parser *get_partition_parser(const char *name); extern int register_mtd_parser(struct mtd_part_parser *parser); extern int deregister_mtd_parser(struct mtd_part_parser *parser); extern int parse_mtd_partitions(struct mtd_info *master, const char **types, struct mtd_partition **pparts, unsigned long origin); #define put_partition_parser(p) do { module_put((p)->owner); } while(0) #endif
robacklin/celinux
include/linux/mtd/partitions.h
C
gpl-2.0
2,532
/* WMix 3.0 -- a mixer using the OSS mixer API. * Copyright (C) 2000, 2001 timecop@japan.co.jp * Mixer code in version 3.0 based on mixer api library by * Daniel Richard G. <skunk@mit.edu>, which in turn was based on * the mixer code in WMix 2.x releases. * * 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 <stdio.h> #include <stdlib.h> #include <string.h> #include <signal.h> #include <string.h> #include <getopt.h> #include <unistd.h> #include <X11/X.h> #include <X11/Xlib.h> #include <X11/Xutil.h> #include <sys/soundcard.h> #include "include/common.h" #include "include/mixer.h" #include "include/misc.h" #include "include/ui_x.h" #include "include/mmkeys.h" #include "include/config.h" static Display *display; static bool button_pressed = false; static bool slider_pressed = false; static double prev_button_press_time = 0.0; static float display_height; static float display_width; static int mouse_drag_home_x; static int mouse_drag_home_y; static int idle_loop; /* local stuff */ static void signal_catch(int sig); static void button_press_event(XButtonEvent *event); static void button_release_event(XButtonEvent *event); static int key_press_event(XKeyEvent *event); static void motion_event(XMotionEvent *event); int main(int argc, char **argv) { XEvent event; config_init(); parse_cli_options(argc, argv); config_read(); mixer_init(config.mixer_device, config.verbose, (const char **)config.exclude_channel); mixer_set_channel(0); display = XOpenDisplay(config.display_name); if (display == NULL) { const char *name; if (config.display_name) { name = config.display_name; } else { name = getenv("DISPLAY"); if (name == NULL) { fprintf(stderr, "wmix:error: Unable to open display, variable $DISPLAY not set\n"); return EXIT_FAILURE; } } fprintf(stderr, "wmix:error: Unable to open display \"%s\"\n", name); return EXIT_FAILURE; } display_width = (float)DisplayWidth(display, DefaultScreen(display)) / 4.0; display_height = (float)DisplayHeight(display, DefaultScreen(display)) / 2.0; dockapp_init(display); new_window("wmix", 64, 64); new_osd(DisplayWidth(display, DefaultScreen(display)) - 200, 60); if (config.mmkeys) mmkey_install(display); config_release(); blit_string("wmix " VERSION); scroll_text(3, 4, 57, true); ui_update(); /* add click regions */ add_region(1, 37, 36, 25, 25); /* knob */ add_region(2, 4, 42, 27, 15); /* balancer */ add_region(3, 2, 26, 7, 10); /* previous channel */ add_region(4, 10, 26, 7, 10); /* next channel */ add_region(5, 39, 14, 20, 7); /* mute toggle */ add_region(6, 4, 14, 13, 7); /* rec toggle */ add_region(10, 3, 4, 56, 7); /* re-scroll current channel name */ /* setup up/down signal handler */ create_pid_file(); signal(SIGUSR1, (void *) signal_catch); signal(SIGUSR2, (void *) signal_catch); while (true) { if (button_pressed || slider_pressed || (XPending(display) > 0)) { XNextEvent(display, &event); switch (event.type) { case KeyPress: if (key_press_event(&event.xkey)) idle_loop = 0; break; case Expose: redraw_window(); break; case ButtonPress: button_press_event(&event.xbutton); idle_loop = 0; break; case ButtonRelease: button_release_event(&event.xbutton); idle_loop = 0; break; case MotionNotify: /* process cursor change, or drag events */ motion_event(&event.xmotion); idle_loop = 0; break; case LeaveNotify: /* go back to standard cursor */ if ((!button_pressed) && (!slider_pressed)) set_cursor(NORMAL_CURSOR); break; case DestroyNotify: XCloseDisplay(display); return EXIT_SUCCESS; default: break; } } else { usleep(100000); scroll_text(3, 4, 57, false); /* rescroll message after some delay */ if (idle_loop++ > 256) { scroll_text(3, 4, 57, true); idle_loop = 0; } /* get rid of OSD after a few seconds of idle */ if ((idle_loop > 15) && osd_mapped() && !button_pressed) { unmap_osd(); idle_loop = 0; } if (mixer_is_changed()) ui_update(); } } return EXIT_SUCCESS; } static void signal_catch(int sig) { switch (sig) { case SIGUSR1: mixer_set_volume_rel(config.scrollstep); if (!osd_mapped()) map_osd(); if (osd_mapped()) update_osd(mixer_get_volume(), false); ui_update(); idle_loop = 0; break; case SIGUSR2: mixer_set_volume_rel(-config.scrollstep); if (!osd_mapped()) map_osd(); if (osd_mapped()) update_osd(mixer_get_volume(), false); ui_update(); idle_loop = 0; break; } } static void button_press_event(XButtonEvent *event) { double button_press_time = get_current_time(); int x = event->x; int y = event->y; bool double_click = false; /* handle wheel scrolling to adjust volume */ if (config.mousewheel) { if (event->button == config.wheel_button_up) { mixer_set_volume_rel(config.scrollstep); if (!osd_mapped()) map_osd(); if (osd_mapped()) update_osd(mixer_get_volume(), false); ui_update(); return; } if (event->button == config.wheel_button_down) { mixer_set_volume_rel(-config.scrollstep); if (!osd_mapped()) map_osd(); if (osd_mapped()) update_osd(mixer_get_volume(), false); ui_update(); return; } } if ((button_press_time - prev_button_press_time) <= 0.5) { double_click = true; prev_button_press_time = 0.0; } else prev_button_press_time = button_press_time; switch (check_region(x, y)) { case 1: /* on knob */ button_pressed = true; slider_pressed = false; mouse_drag_home_x = x; mouse_drag_home_y = y; if (double_click) { mixer_toggle_mute(); ui_update(); } break; case 2: /* on slider */ button_pressed = false; slider_pressed = true; mouse_drag_home_x = x; mouse_drag_home_y = y; if (double_click) { mixer_set_balance(0.0); ui_update(); } break; case 3: /* previous channel */ mixer_set_channel_rel(-1); blit_string(config.scrolltext ? mixer_get_channel_name() : mixer_get_short_name()); scroll_text(3, 4, 57, true); unmap_osd(); map_osd(); ui_update(); break; case 4: /* next channel */ mixer_set_channel_rel(1); blit_string(config.scrolltext ? mixer_get_channel_name() : mixer_get_short_name()); scroll_text(3, 4, 57, true); unmap_osd(); map_osd(); ui_update(); break; case 5: /* toggle mute */ mixer_toggle_mute(); ui_update(); break; case 6: /* toggle rec */ mixer_toggle_rec(); ui_update(); break; case 10: scroll_text(3, 4, 57, true); break; default: printf("unknown region pressed\n"); break; } } static int key_press_event(XKeyEvent *event) { if (event->keycode == mmkeys.raise_volume) { mixer_set_volume_rel(config.scrollstep); if (!osd_mapped()) map_osd(); if (osd_mapped()) update_osd(mixer_get_volume(), false); ui_update(); return 1; } if (event->keycode == mmkeys.lower_volume) { mixer_set_volume_rel(-config.scrollstep); if (!osd_mapped()) map_osd(); if (osd_mapped()) update_osd(mixer_get_volume(), false); ui_update(); return 1; } if (event->keycode == mmkeys.mute) { mixer_toggle_mute(); ui_update(); return 1; } /* Ignore other keys */ return 0; } static void button_release_event(XButtonEvent *event) { int x = event->x; int y = event->y; int region; region = check_region(x, y); if (region == 1) set_cursor(HAND_CURSOR); button_pressed = false; slider_pressed = false; } static void motion_event(XMotionEvent *event) { int x = event->x; int y = event->y; int region; if ((x == mouse_drag_home_x) && (y == mouse_drag_home_y)) return; region = check_region(x, y); if (button_pressed) { if (y != mouse_drag_home_y) { float delta; set_cursor(NULL_CURSOR); delta = (float)(mouse_drag_home_y - y) / display_height; knob_turn(delta); if (!osd_mapped()) map_osd(); if (osd_mapped()) update_osd(mixer_get_volume(), false); } XWarpPointer(display, None, event->window, x, y, 0, 0, mouse_drag_home_x, mouse_drag_home_y); return; } if (slider_pressed) { if (x != mouse_drag_home_x) { float delta; set_cursor(NULL_CURSOR); delta = (float)(x - mouse_drag_home_x) / display_width; slider_move(delta); } XWarpPointer(display, None, event->window, x, y, 0, 0, mouse_drag_home_x, mouse_drag_home_y); return; } if (region == 1) set_cursor(HAND_CURSOR); else if (region == 2) set_cursor(BAR_CURSOR); else set_cursor(NORMAL_CURSOR); }
burzumishi/XCompWMaker
WMaker/dockapps/wmix/wmix.c
C
gpl-2.0
9,546
#! /bin/sh -e # tup - A file-based build system # # Copyright (C) 2011-2018 Mike Shal <marfey@gmail.com> # # 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. # # 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. # File creation events (such as the first time we run a command), should not # result in the monitor re-running an autoupdate. . ./tup.sh check_monitor_supported monitor --autoupdate > .tup/.monitor.output 2>&1 tup flush cat > main.c << HERE #include <stdio.h> int main(void) { return 0; } HERE cat > Tupfile << HERE : foreach *.c |> gcc -c %f -o %o |> %B.o : *.o |> gcc %f -o %o |> prog HERE tup flush check_exist prog if ! cat .tup/.monitor.output | grep Updated | wc -l | grep 1 > /dev/null; then sleep 0.5 if ! cat .tup/.monitor.output | grep Updated | wc -l | grep 1 > /dev/null; then echo "Monitor output:" 1>&2 cat .tup/.monitor.output 1>&2 echo "Error: tup should only update once" 1>&2 exit 1 fi fi eotup
jonatanolofsson/tup
test/t7052-autoupdate8.sh
Shell
gpl-2.0
1,479
/* * _ __ _ * | |/ /__ __ __ _ _ __ | |_ _ _ _ __ ___ * | ' / \ \ / // _` || '_ \ | __|| | | || '_ ` _ \ * | . \ \ V /| (_| || | | || |_ | |_| || | | | | | * |_|\_\ \_/ \__,_||_| |_| \__| \__,_||_| |_| |_| * * Copyright (C) 2019 Alexander Söderberg * * Licensed 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 xyz.kvantum.server.api.util; public interface ApplicationStructureFactory<A extends ApplicationStructure> { A create(ApplicationContext applicationContext); }
IntellectualSites/IntellectualServer
ServerAPI/src/main/java/xyz/kvantum/server/api/util/ApplicationStructureFactory.java
Java
gpl-2.0
1,042
/* This file is part of the KDE project Copyright (C) 2006 Jarosław Staniek <staniek@kde.org> This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library 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 Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301, USA. */ #ifndef SQLITE_VACUUM_H #define SQLITE_VACUUM_H #include <qobject.h> #include <qstring.h> #include <kexiutils/tristate.h> class Q3Process; class KProgressDialog; //! @short Helper class performing interactive compacting (VACUUM) of the SQLite database /*! Proved SQLite database filename in the constructor. Then execute run() should be executed. KProgressDialog will be displayed. Its progress bar will be updated whenever another table's data compacting is performed. User can click "Cancel" button in any time (except the final committing) to cancel the operation. In this case, it's guaranteed that the original file remains unchanged. This is possible because we rely on SQLite's VACUUM SQL command, which itself temporarily creates a copy of the original database file, and replaces the orginal with the new only on success. */ class SQLiteVacuum : public QObject { Q_OBJECT public: SQLiteVacuum(const QString& filePath); ~SQLiteVacuum(); /*! Performs compacting procedure. \return true on success, false on failure and cancelled if user clicked "Cancel" button in the progress dialog. */ tristate run(); public slots: void readFromStdout(); void processExited(); void cancelClicked(); protected: QString m_filePath; Q3Process *m_process; KProgressDialog* m_dlg; int m_percent; tristate m_result; }; #endif
JeremiasE/KFormula
kexi/kexidb/drivers/sqlite/sqlitevacuum.h
C
gpl-2.0
2,264
<? echo "<div class='information'>\n"; require("../updatePubliDocs.php"); $chemin="$_SERVER[DOCUMENT_ROOT]$public_path/$publi[year]/$publi[bibTex]/" ; intranetSqlConnect(); if (!empty($_POST["group"])) $group=$_POST["group"]; $res_upd = sqlQuery("SELECT * from docs WHERE id=$id_doc"); $docs = mysql_fetch_array($res_upd); switch ($group) { case "public": rename($chemin."$protected/$docs[source]", $chemin.$docs['source']); break; case "private": if (!is_dir($chemin."$protected/")) { mkdir($chemin."$protected/", 0755); } if (!is_file($chemin."$protected/.htaccess")) { // Creation of .htaccess file $file = $chemin."$protected/.htaccess"; echo "Creating .htaccess file in $chemin$protected/<br />\n"; copy("$_SERVER[DOCUMENT_ROOT]$intra_path/htaccess_private", $file); if (!is_file("$file")) error("File .htaccess could not be created"); } rename($chemin.$docs['source'], $chemin."$protected/$docs[source]"); break; } updatePubliDocs($id); echo "</div>\n"; ?>
truijllo/basilic
Sources/Intranet/Publications/mod_upd.php
PHP
gpl-2.0
1,036
/* * * btusb_lite_av.c * * * * Copyright (C) 2011-2014 Broadcom Corporation. * * * * This software is licensed under the terms of the GNU General Public License, * version 2, as published by the Free Software Foundation (the "GPL"), 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 GPL for more details. * * * A copy of the GPL is available at http://www.broadcom.com/licenses/GPLv2.php * or by writing to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA * * */ #include <linux/moduleparam.h> #include "btusb.h" #include "bd.h" #include "btpcm_api.h" #include "btsbc_api.h" #ifdef BTUSB_LITE_SEC #include "btsec_api.h" #endif struct btusb_lite_av_sbc_param { int frequency; unsigned char nb_blocks; unsigned char nb_subbands; unsigned char mode; unsigned char allocation; unsigned char bitpool_min; unsigned char bitpool_max; }; /* Codec (From BT Spec) */ #define A2D_MEDIA_TYPE_AUDIO 0x00 #define A2D_MEDIA_CT_SBC 0x00 /* SBC Codec */ #define A2D_MEDIA_CT_VEND 0xFF /* Vendor specific */ /* SBC Codec (From BT Spec) */ #define CODEC_SBC_LOSC 6 #define CODEC_SBC_FREQ_MASK 0xF0 #define CODEC_SBC_FREQ_48 0x10 #define CODEC_SBC_FREQ_44 0x20 #define CODEC_SBC_FREQ_32 0x40 #define CODEC_SBC_FREQ_16 0x80 #define CODEC_MODE_MASK 0x0F #define CODEC_MODE_JOIN_STEREO 0x01 #define CODEC_MODE_STEREO 0x02 #define CODEC_MODE_DUAL 0x04 #define CODEC_MODE_MONO 0x08 #define CODEC_SBC_BLOCK_MASK 0xF0 #define CODEC_SBC_BLOCK_16 0x10 #define CODEC_SBC_BLOCK_12 0x20 #define CODEC_SBC_BLOCK_8 0x40 #define CODEC_SBC_BLOCK_4 0x80 #define CODEC_SBC_NBBAND_MASK 0x0C #define CODEC_SBC_NBBAND_8 0x04 #define CODEC_SBC_NBBAND_4 0x08 #define CODEC_SBC_ALLOC_MASK 0x03 #define CODEC_SBC_ALLOC_LOUDNESS 0x01 #define CODEC_SBC_ALLOC_SNR 0x02 /* SEC codec */ #ifdef BTUSB_LITE_SEC #define A2D_MEDIA_CT_SEC 0x07 /* Internal SEC Codec type */ struct btusb_lite_av_sec_param { int frequency; unsigned char mode; }; #endif /* BAV Packet Header Info*/ #define BSA_SV_AV_BAV_HEADER_SIZE (1 /*BSA_SV_AV_BAV_PACKET_HEADER_SIZE*/ + \ 1 /*BTA_AV_SBC_HDR_SIZE*/ + \ 12 /*AVDT_MEDIA_HDR_SIZE*/) #define BSA_SV_AV_BAV_PACKET_HEADER_SBC_MASK 0x80 /* SBC Data */ #define AVDT_MEDIA_OCTET1 0x80 /* first byte of media packet header */ #define BSA_SV_AV_BAV_RTP_PAYLOAD_TYPE 0x60 /* First Dynamic Payload type */ /* AFBT stack vendor lib requires an l2cap header and length in assemble the BAV frames */ #define BSA_BAV_L2C_HDR_SZ 4 #define BSA_BAV_L2C_FAKE_CID 0x1234 /* l2cap CID for BAV frames */ /* * Globals */ int pcm0_mute = 0; module_param(pcm0_mute, int, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP); MODULE_PARM_DESC(pcm0_mute, "Mute PCM channel 0"); #define SILENSE_PCM_BUF_SIZE (2 * 128) /* 128 samples, Stereo */ static const unsigned short btusb_lite_silence_pcm[SILENSE_PCM_BUF_SIZE] = {0}; /* * Local functions */ static int btusb_lite_av_parse_sbc_codec(struct btusb_lite_av_sbc_param *p_sbc, UINT8 *p_codec); static int btusb_lite_sbc_get_bitpool(struct btusb_lite_av_sbc_param *p_sbc_param, int target_bitrate); static void btusb_lite_av_pcm_cback(void *p_opaque, void *p_data, int nb_pcm_frames); static void btusb_lite_av_send_packet(struct btusb *p_dev, BT_HDR *p_msg); static int btusb_lite_av_sbc_start(struct btusb *p_dev, UINT8 scb_idx, tBTA_AV_AUDIO_CODEC_INFO*p_codec_cfg); static int btusb_lite_av_parse_vendor_codec(UINT8 *p_codec_info, UINT32 *p_vendor_id, UINT16 *p_vendor_codec_id); #ifdef BTUSB_LITE_SEC static int btusb_lite_av_parse_sec_codec(struct btusb_lite_av_sec_param *p_sec_param, UINT8 *p_codec_info); static int btusb_lite_av_sec_start(struct btusb *p_dev, UINT8 scb_idx, tBTA_AV_AUDIO_CODEC_INFO*p_codec_cfg); #endif static void btusb_lite_clb_send(struct btusb *p_dev, BT_HDR *p_msg, UINT8 avdt_handle, UINT8 m_pt, UINT8 option, UINT32 timestamp); /******************************************************************************* ** ** Function btusb_lite_av_add ** ** Description Add (Sync) an AV channel. ** ** Returns None. ** *******************************************************************************/ void btusb_lite_av_add(struct btusb *p_dev, tBTA_AV_SYNC_INFO *p_sync_info, UINT8 multi_av_supported, UINT16 curr_mtu) { struct btusb_lite_av_cb *p_av_cb = &p_dev->lite_cb.s.av; struct btusb_lite_av_scb *p_av_scb; int rv; p_av_cb->stack_mtu = curr_mtu; /* Update MTU */ p_av_cb->curr_mtu = curr_mtu; /* Update MTU */ if (p_sync_info->hdi >= BTA_AV_NUM_STRS) { BTUSB_ERR("Bad AV Index=%d\n", p_sync_info->hdi); return; } #if (BTU_MULTI_AV_INCLUDED == TRUE) p_av_cb->multi_av &= ~(BTA_AV_MULTI_AV_SUPPORTED); p_av_cb->multi_av |= multi_av_supported; #endif p_av_scb = &p_av_cb->scb[p_sync_info->hdi]; p_av_scb->avdt_handle = p_sync_info->avdt_handle; p_av_scb->chnl = p_sync_info->chnl; p_av_scb->codec_type = p_sync_info->codec_type; p_av_scb->cong = p_sync_info->cong; p_av_scb->hdi = p_sync_info->hdi; p_av_scb->hndl = p_sync_info->hndl; p_av_scb->l2c_bufs = p_sync_info->l2c_bufs; p_av_scb->l2c_cid = p_sync_info->l2c_cid; memcpy(p_av_scb->peer_addr, p_sync_info->peer_addr, BD_ADDR_LEN); if (p_av_cb->pcm.state == PCM_CLOSED) { /* Open the PCM Channel */ rv = btpcm_open(p_dev->lite_cb.p_btpcm); if (rv < 0) { BTUSB_ERR("btpcm_open failed\n"); return; } p_av_cb->pcm.state = PCM_OPENED; p_av_cb->pcm.frequency = -1; } } /******************************************************************************* ** ** Function btusb_lite_av_remove ** ** Description Remove (Cleanup) an AV channel. ** ** Returns None. ** *******************************************************************************/ void btusb_lite_av_remove(struct btusb *p_dev, UINT8 scb_idx, UINT8 audio_open_cnt, UINT16 curr_mtu) { struct btusb_lite_av_cb *p_av_cb = &p_dev->lite_cb.s.av; struct btusb_lite_av_scb *p_av_scb; int av_scb; int cleanup_needed = 1; int rv; p_av_cb->curr_mtu = curr_mtu; /* Update MTU */ p_av_cb->audio_open_cnt = audio_open_cnt; /* Update audio_open_cnt */ if (scb_idx >= BTA_AV_NUM_STRS) { BTUSB_ERR("Bad Index=%d\n", scb_idx); return; } p_av_scb = &p_av_cb->scb[scb_idx]; /* Remove AVDT CCB and SCB */ btusb_lite_avdt_remove_scb(p_dev, p_av_scb->avdt_handle, NULL); /* Clear the AV Stream Control Clock */ memset(p_av_scb, 0, sizeof(*p_av_scb)); /* Check this is the last AV channel removed */ p_av_scb = &p_av_cb->scb[0]; for (av_scb = 0 ; av_scb < BTA_AV_NUM_STRS ; av_scb++, p_av_scb++) { if (p_av_scb->hndl) { cleanup_needed = 0; break; } } if (cleanup_needed) { if (p_av_cb->pcm.state == PCM_STARTED) { /* Stop the PCM Channel */ rv = btpcm_stop(p_dev->lite_cb.p_btpcm); if (rv < 0) { BTUSB_ERR("btpcm_close failed\n"); } p_av_cb->pcm.state = PCM_CONFIGURED; } if (p_av_cb->pcm.state != PCM_CLOSED) { /* Close the PCM Channel */ rv = btpcm_close(p_dev->lite_cb.p_btpcm); if (rv < 0) { BTUSB_ERR("btpcm_close failed\n"); } p_av_cb->pcm.state = PCM_CLOSED; } if (p_av_cb->encoder.opened) { switch(p_av_cb->encoder.type) { case A2D_MEDIA_CT_SBC: btsbc_free(p_av_cb->encoder.channel); break; #ifdef BTUSB_LITE_SEC case A2D_MEDIA_CT_SEC: btsec_free(p_av_cb->encoder.channel); break; #endif default: BTUSB_ERR("Unknown Encoder type=%d\n", p_av_cb->encoder.encoder.codec_type); break; } p_av_cb->encoder.opened = 0; } } } /******************************************************************************* ** ** Function btusb_lite_av_start ** ** Description Start AV ** ** Returns None. ** *******************************************************************************/ void btusb_lite_av_start(struct btusb *p_dev, UINT8 scb_idx, UINT8 start_stop_flag, UINT8 audio_open_cnt, tBTA_AV_AUDIO_CODEC_INFO *p_codec_cfg, UINT8 streaming_type) { struct btusb_lite_av_cb *p_av_cb = &p_dev->lite_cb.s.av; UINT32 vendor_id; UINT16 vendor_codec_id; struct btusb_lite_av_scb *p_av_scb; if (scb_idx >= BTA_AV_NUM_STRS) { BTUSB_ERR("Bad scb_idx=%d", scb_idx); return; } /* streaming_type - regular A2DP or CLB */ p_av_cb->streaming_type = streaming_type; if (p_av_cb->streaming_type == AV_LITE_STREAMING_AVDT) p_av_cb->p_stream_func = btusb_lite_avdt_send; else if (p_av_cb->streaming_type == AV_LITE_STREAMING_CLB) p_av_cb->p_stream_func = btusb_lite_clb_send; p_av_scb = &p_av_cb->scb[scb_idx]; if (start_stop_flag) { p_av_cb->scb[scb_idx].started = FALSE; BTUSB_ERR("start_stop_flag TODO!!!"); } else { /* If the Codec Type is SBC */ if (p_codec_cfg->codec_type == A2D_MEDIA_CT_SBC) { if (btusb_lite_av_sbc_start(p_dev, scb_idx, p_codec_cfg) < 0) { BTUSB_ERR("SBC Stream not started\n"); return; } } /* Else if the Codec Type is a Vendor Specific Codec */ else if (p_codec_cfg->codec_type == A2D_MEDIA_CT_VEND) { if (btusb_lite_av_parse_vendor_codec(p_codec_cfg->codec_info, &vendor_id, &vendor_codec_id) < 0) { BTUSB_ERR("Unable to parse Vendor Codec\n"); return; } #ifdef BTUSB_LITE_SEC /* If This is the SEC Encoder */ if ((vendor_id == BTSEC_VENDOR_ID) && (vendor_codec_id == BTSEC_VENDOR_CODEC_ID)) { btusb_lite_av_sec_start(p_dev, scb_idx, p_codec_cfg); } else #endif /* Add other Vendor Specific Vendor coder Here... */ { BTUSB_ERR("Unsupported Codec VendorId=0x%08x VendorCodecId=0x%04x\n", vendor_id, vendor_codec_id); } } else { BTUSB_ERR("Unsupported Encoder type=%d\n", p_codec_cfg->codec_type); } } } /******************************************************************************* ** ** Function btusb_lite_av_parse_vendor_codec ** ** Description Parse Vendor Id and Vendor Codec Id from Codec information ** ** Returns Status, VendorId and VendorCodecId ** *******************************************************************************/ static int btusb_lite_av_parse_vendor_codec(UINT8 *p_codec_info, UINT32 *p_vendor_id, UINT16 *p_vendor_codec_id) { UINT8 byte; UINT32 vendor_id; UINT16 vendor_codec_id; if (!p_codec_info || !p_vendor_id || !p_vendor_codec_id) { BTUSB_ERR("Bad parameter\n"); return -1; } STREAM_TO_UINT8(byte, p_codec_info); /* Extract LOSC */ if (byte < (1 + 1 + 4 + 2)) /* Media Type, Media Codec Type, Vid, VCId */ { BTUSB_ERR("Codec LOSC=%d too small\n", byte); return -1; } STREAM_TO_UINT8(byte, p_codec_info); /* Extract Media Type */ if (byte != A2D_MEDIA_TYPE_AUDIO) { BTUSB_ERR("Unsupported Media Type=0x%x\n", byte); return -1; } STREAM_TO_UINT8(byte, p_codec_info); /* Extract Media Codec Type */ if (byte != A2D_MEDIA_CT_VEND) { BTUSB_ERR("Media codec Type=0x%x is not Vendor(0xFF)\n", byte); return -1; } STREAM_TO_UINT32(vendor_id, p_codec_info); /* Extract Vendor Id */ STREAM_TO_UINT16(vendor_codec_id, p_codec_info); /* Extract Vendor Codec Id */ *p_vendor_id = vendor_id; *p_vendor_codec_id = vendor_codec_id; BTUSB_INFO("Extracted Codec VendorId=0x%08x VendorCodecId=0x%04x\n", vendor_id, vendor_codec_id); return 0; } /******************************************************************************* ** ** Function btusb_lite_av_sbc_start ** ** Description Start AV SBC Stream ** ** Returns Status ** *******************************************************************************/ static int btusb_lite_av_sbc_start(struct btusb *p_dev, UINT8 scb_idx, tBTA_AV_AUDIO_CODEC_INFO*p_codec_cfg) { struct btusb_lite_av_cb *p_av_cb = &p_dev->lite_cb.s.av; struct btusb_lite_encoder_ccb *p_encoder; struct btusb_lite_av_scb *p_av_scb; int nb_sbc_frames; int rv; int bitpool; struct btusb_lite_av_sbc_param sbc_param; int av_header_len; /* Parse SBC Codec Info */ if (btusb_lite_av_parse_sbc_codec(&sbc_param, p_codec_cfg->codec_info) < 0) { BTUSB_ERR("Bad SBC Codec. Stream not started\n"); return -1; } if (scb_idx >= BTA_AV_NUM_STRS) { BTUSB_ERR("Bad scb_idx=%d", scb_idx); return -1; } p_av_scb = &p_av_cb->scb[scb_idx]; /* Calculate the BitPool for this BitRate */ bitpool = btusb_lite_sbc_get_bitpool(&sbc_param, p_codec_cfg->bit_rate); if (bitpool <= 0) { BTUSB_ERR("btusb_lite_sbc_get_bitpool return wrong bitpool=%d\n", bitpool); return -1; } BTUSB_INFO("SBC BitPool=%d\n", bitpool); p_av_cb->timestamp = 0; /* Reset TimeStamp */ p_av_cb->option = 0; /* No specific Option (RTP and Media Payload Header presents) */ p_av_cb->m_pt = AVDT_RTP_PAYLOAD_TYPE | A2D_MEDIA_CT_SBC; p_av_cb->m_pt &= ~AVDT_MARKER_SET; /* Calculate Packet Header Size (HCI, L2CAP, RTP and MediaPayloadHeader) */ p_av_cb->header_len = BTUSB_LITE_HCI_ACL_HDR_SIZE + BTUSB_LITE_L2CAP_HDR_SIZE + BTUSB_LITE_RTP_SIZE + BTUSB_LITE_SCMS_SIZE + BTUSB_LITE_MEDIA_SIZE; /* Calculate AV Header Size */ av_header_len = BTUSB_LITE_L2CAP_HDR_SIZE + BTUSB_LITE_RTP_SIZE + BTUSB_LITE_SCMS_SIZE + BTUSB_LITE_MEDIA_SIZE; /* clear the congestion flag: full stack made it congested when opening */ p_av_scb->cong = FALSE; p_av_scb->started = TRUE; /* Get reference to AV's encoder */ p_encoder = &p_av_cb->encoder; if (p_encoder->opened == 0) { /* Allocate an SBC Channel */ rv = btsbc_alloc(); if (rv < 0) { BTUSB_ERR("btsbc_alloc failed\n"); return -1; } p_encoder->opened = 1; p_encoder->channel = rv; p_encoder->type = A2D_MEDIA_CT_SBC; } BTUSB_DBG("frequency=%d, nb_blocks=%d, nb_subbands=%d, mode=%d, allocation=%d, bitpool=%d \n", sbc_param.frequency, sbc_param.nb_blocks, sbc_param.nb_subbands, sbc_param.mode, sbc_param.allocation, bitpool); /* Configure the SBC Channel */ rv = btsbc_config(p_encoder->channel, sbc_param.frequency, sbc_param.nb_blocks, sbc_param.nb_subbands, sbc_param.mode, sbc_param.allocation, (unsigned char)bitpool); BTUSB_DBG("sbc_frame_size=%d calculated by btsbc_config()\n", rv); if (rv <= 0) { BTUSB_ERR("btsbc_config failed\n"); btsbc_free(p_encoder->channel); p_encoder->opened = 0; return -1; } /* Save the calculated SBC Frame size */ p_encoder->encoded_frame_size = rv; BTUSB_INFO("encoded_frame_size=%d\n", rv); /* Configure the PCM Channel */ rv = btpcm_config(p_dev->lite_cb.p_btpcm, p_dev, sbc_param.frequency, sbc_param.mode==CODEC_MODE_MONO?1:2, 16, /* SBC Encoder requires 16 bits per sample */ btusb_lite_av_pcm_cback); if (rv < 0) { BTUSB_ERR("btpcm_config failed\n"); return -1; } /* Calculate and save the PCM frame size */ p_encoder->pcm_frame_size = sbc_param.nb_blocks * sbc_param.nb_subbands; BTUSB_INFO("pcm_frame_size=%d\n", p_encoder->pcm_frame_size); #if 0 /* Calculate nb_sbc_frames depending on MTU */ nb_sbc_frames = (p_av_cb->curr_mtu - av_header_len) / p_encoder->encoded_frame_size; #else nb_sbc_frames = 10; if(p_av_cb->stack_mtu < (p_encoder->encoded_frame_size * nb_sbc_frames + av_header_len)) { /* if 10 SBC frame is bigger than mtu size, should change nb_sbc_frames value to fit in mtu */ nb_sbc_frames = (p_av_cb->stack_mtu - av_header_len) / p_encoder->encoded_frame_size; p_av_cb->curr_mtu = p_av_cb->stack_mtu; } else { p_av_cb->curr_mtu = p_encoder->encoded_frame_size * nb_sbc_frames + av_header_len; } #endif BTUSB_INFO("mtu:%d, nb_sbc_frames:%d, pcm_frame_size:%d\n", p_av_cb->curr_mtu, nb_sbc_frames, p_encoder->pcm_frame_size); /* Calculate the size of the Payload */ p_av_cb->payload_len = nb_sbc_frames * p_encoder->encoded_frame_size; BTUSB_INFO("nb_sbc_frames=%d payload_len=%d\n", nb_sbc_frames, p_av_cb->payload_len); /* Start the PCM stream */ rv = btpcm_start(p_dev->lite_cb.p_btpcm, p_encoder->pcm_frame_size, nb_sbc_frames, 0); if (rv < 0) { BTUSB_ERR("btpcm_start failed\n"); return -1; } p_av_cb->pcm.state = PCM_STARTED; return 0; } #ifdef BTUSB_LITE_SEC /******************************************************************************* ** ** Function btusb_lite_av_parse_vendor_codec ** ** Description Parse Vendor Id and Vendor Codec Id from Codec information ** ** Returns Status, VendorId and VendorCodecId ** *******************************************************************************/ static int btusb_lite_av_parse_sec_codec(struct btusb_lite_av_sec_param *p_sec_param, UINT8 *p_codec_info) { UINT8 byte; UINT32 vendor_id; UINT16 vendor_codec_id; if (!p_codec_info || !p_sec_param) { BTUSB_ERR("Bad parameter\n"); return -1; } /* Extract/Ignore parameters already checked */ STREAM_TO_UINT8(byte, p_codec_info); /* Extract LOSC */ STREAM_TO_UINT8(byte, p_codec_info); /* Extract Media Type */ STREAM_TO_UINT8(byte, p_codec_info); /* Extract Media Codec Type */ STREAM_TO_UINT32(vendor_id, p_codec_info); /* Extract Vendor Id */ STREAM_TO_UINT16(vendor_codec_id, p_codec_info); /* Extract Vendor Codec Id */ STREAM_TO_UINT8(byte, p_codec_info); /* SEC codec configuration */ /* Check Frequency */ switch(byte & BTSEC_FREQ_MASK) { case BTSEC_FREQ_48K: p_sec_param->frequency = 48000; break; case BTSEC_FREQ_44K: p_sec_param->frequency = 44100; break; case BTSEC_FREQ_32K: p_sec_param->frequency = 32000; break; default: BTUSB_ERR("SEC Frequency=0x%x unsupported\n", byte & BTSEC_FREQ_MASK); return -1; } /* Check Mode */ switch(byte & BTSEC_MODE_MASK) { case BTSEC_MODE_MONO: p_sec_param->mode = BTSEC_MODE_MONO; break; case BTSEC_MODE_STEREO: p_sec_param->mode = BTSEC_MODE_STEREO; break; default: BTUSB_ERR("SEC Mode=0x%x unsupported\n", byte & BTSEC_FREQ_MASK); return -1; } BTUSB_INFO("SEC Frequency=%d Mode=%s\n", p_sec_param->frequency, p_sec_param->mode == BTSEC_MODE_MONO?"Mono":"Stereo"); return 0; } /******************************************************************************* ** ** Function btusb_lite_av_sec_start ** ** Description Start AV SBC Stream ** ** Returns Status ** *******************************************************************************/ static int btusb_lite_av_sec_start(struct btusb *p_dev, UINT8 scb_idx, tBTA_AV_AUDIO_CODEC_INFO*p_codec_cfg) { struct btusb_lite_av_cb *p_av_cb = &p_dev->lite_cb.s.av; struct btusb_lite_encoder_ccb *p_encoder; struct btusb_lite_av_scb *p_av_scb; int nb_sec_frames; int rv; struct btusb_lite_av_sec_param sec_param; int av_header_len; /* Parse SBC Codec Info */ if (btusb_lite_av_parse_sec_codec(&sec_param, p_codec_cfg->codec_info) < 0) { BTUSB_ERR("Bad SEC Codec parameters. Stream not started\n"); return -1; } if (scb_idx >= BTA_AV_NUM_STRS) { BTUSB_ERR("Bad scb_idx=%d", scb_idx); return -1; } p_av_scb = &p_av_cb->scb[scb_idx]; BTUSB_INFO("SEC Bitrate =%d\n", p_codec_cfg->bit_rate); p_av_cb->timestamp = 0; /* Reset TimeStamp */ p_av_cb->option = BTUSB_LITE_AVDT_OPT_NO_MPH; /* No Media Payload Header */ p_av_cb->m_pt = AVDT_RTP_PAYLOAD_TYPE | A2D_MEDIA_CT_VEND; p_av_cb->m_pt &= ~AVDT_MARKER_SET; /* Calculate Packet Header Size (HCI, L2CAP, RTP) */ p_av_cb->header_len = BTUSB_LITE_HCI_ACL_HDR_SIZE + BTUSB_LITE_L2CAP_HDR_SIZE + BTUSB_LITE_RTP_SIZE; /* Calculate AV Header Size */ av_header_len = BTUSB_LITE_L2CAP_HDR_SIZE + BTUSB_LITE_RTP_SIZE; /* Clear the congestion flag: full stack made it congested when opening */ p_av_scb->cong = FALSE; p_av_scb->started = TRUE; /* Get reference to AV's encoder */ p_encoder = &p_av_cb->encoder; if (p_encoder->opened == 0) { /* Allocate a SEC Channel */ rv = btsec_alloc(); if (rv < 0) { BTUSB_ERR("btsec_alloc failed\n"); return -1; } p_encoder->opened = 1; p_encoder->channel = rv; p_encoder->type = A2D_MEDIA_CT_SEC; } /* Configure the SEC Channel */ rv = btsec_config(p_encoder->channel, sec_param.frequency, sec_param.mode, p_codec_cfg->bit_rate * 1000); if (rv <= 0) { BTUSB_ERR("btsec_config failed\n"); btsec_free(p_encoder->channel); p_encoder->opened = 0; return -1; } /* Save the calculated SEC Frame size */ p_encoder->encoded_frame_size = rv; BTUSB_INFO("encoded_frame_size=%d\n", rv); /* Configure the PCM Channel */ rv = btpcm_config(p_dev->lite_cb.p_btpcm, p_dev, sec_param.frequency, sec_param.mode==BTSEC_MODE_MONO?1:2, 16, /* SBC Encoder requires 16 bits per sample */ btusb_lite_av_pcm_cback); if (rv < 0) { BTUSB_ERR("btpcm_config failed\n"); btsec_free(p_encoder->channel); p_encoder->opened = 0; return -1; } /* SEC requires a fixed number of PCM Samples */ p_encoder->pcm_frame_size = BTSEC_FRAME_SIZE; BTUSB_INFO("pcm_frame_size=%d\n", p_encoder->pcm_frame_size); #if 0 /* Calculate nb_sec_frames depending on MTU */ nb_sec_frames = (p_av_cb->curr_mtu - av_header_len) / p_encoder->encoded_frame_size; #else nb_sec_frames = 10; if(p_av_cb->stack_mtu < (p_encoder->encoded_frame_size * nb_sec_frames + av_header_len)) { /* if 10 SEC frames is bigger than mtu value, should use mtu */ nb_sec_frames = (p_av_cb->stack_mtu - av_header_len) / p_encoder->encoded_frame_size; p_av_cb->curr_mtu = p_av_cb->stack_mtu; } else { p_av_cb->curr_mtu = p_encoder->encoded_frame_size * nb_sec_frames + av_header_len; } #endif /* Calculate the size of the Payload */ p_av_cb->payload_len = nb_sec_frames * p_encoder->encoded_frame_size; BTUSB_INFO("nb_sec_frames=%d payload_len=%d\n", nb_sec_frames, p_av_cb->payload_len); /* Start the PCM stream */ rv = btpcm_start(p_dev->lite_cb.p_btpcm, p_encoder->pcm_frame_size, nb_sec_frames, 0); if (rv < 0) { BTUSB_ERR("btpcm_start failed\n"); btsec_free(p_encoder->channel); p_encoder->opened = 0; return -1; } p_av_cb->pcm.state = PCM_STARTED; return 0; } #endif /******************************************************************************* ** ** Function btusb_lite_av_stop ** ** Description Start AV ** ** Returns None. ** *******************************************************************************/ void btusb_lite_av_stop(struct btusb *p_dev, UINT8 scb_idx, UINT8 audio_open_cnt) { struct btusb_lite_av_cb *p_av_cb = &p_dev->lite_cb.s.av; struct btusb_lite_av_scb *p_av_scb; int rv; BTUSB_INFO("scb_idx=%d audio_open_cnt=%d\n", scb_idx, audio_open_cnt); if (scb_idx >= BTA_AV_NUM_STRS) { BTUSB_ERR("Bad scb_idx=%d", scb_idx); return; } p_av_cb->audio_open_cnt = audio_open_cnt; p_av_scb = &p_av_cb->scb[scb_idx]; p_av_cb->scb[scb_idx].started = FALSE; if (p_av_cb->pcm.state != PCM_STARTED) { BTUSB_ERR("BTPCM was not started\n"); return; } /* Stop the PCM stream */ rv = btpcm_stop(p_dev->lite_cb.p_btpcm); if (rv < 0) { BTUSB_ERR("btpcm_stop failed\n"); return; } p_av_cb->pcm.state = PCM_CONFIGURED; } /******************************************************************************* ** ** Function btusb_lite_av_suspend ** ** Description Suspend AV ** ** Returns none. ** *******************************************************************************/ void btusb_lite_av_suspend(struct btusb *p_dev, UINT8 scb_idx, UINT8 audio_open_cnt) { struct btusb_lite_av_cb *p_av_cb = &p_dev->lite_cb.s.av; struct btusb_lite_av_scb *p_av_scb; int rv; BTUSB_INFO("scb_idx=%d audio_open_cnt=%d\n", scb_idx, audio_open_cnt); if (scb_idx >= BTA_AV_NUM_STRS) { BTUSB_ERR("Bad scb_idx=%d", scb_idx); return; } p_av_cb->audio_open_cnt = audio_open_cnt; p_av_scb = &p_av_cb->scb[scb_idx]; p_av_cb->scb[scb_idx].started = FALSE; if (p_av_cb->pcm.state != PCM_STARTED) { BTUSB_ERR("BTPCM was not started\n"); return; } /* Stop the PCM stream */ rv = btpcm_stop(p_dev->lite_cb.p_btpcm); if (rv < 0) { BTUSB_ERR("btpcm_stop failed\n"); return; } p_av_cb->pcm.state = PCM_CONFIGURED; } /******************************************************************************* ** ** Function btusb_lite_av_parse_sbc_codec ** ** Description Parse an SBC A2DP Codec ** ** Returns Status ** *******************************************************************************/ static int btusb_lite_av_parse_sbc_codec(struct btusb_lite_av_sbc_param *p_sbc, UINT8 *p_codec) { UINT8 byte; unsigned char codec_freq; unsigned char codec_blocks; unsigned char codec_subbands; unsigned char codec_mode; unsigned char codec_alloc; unsigned char bitpool_min; unsigned char bitpool_max; if (p_sbc == NULL) { BTUSB_ERR("p_sbc is NULL\n"); return -1; } /* Extract LOSC */ byte = *p_codec++; if (byte != CODEC_SBC_LOSC) { BTUSB_ERR("Bad SBC LOSC=%d", byte); return -1; } p_codec++; /* Ignore MT */ /* Extract Codec Type */ byte = *p_codec++; if (byte != A2D_MEDIA_CT_SBC) { BTUSB_ERR("Bad SBC codec type=%d", byte); return -1; } /* Extract Freq & Mode */ byte = *p_codec++; codec_freq = byte & CODEC_SBC_FREQ_MASK; codec_mode = byte & CODEC_MODE_MASK; /* Extract NbBlock NbSubBand and Alloc Method */ byte = *p_codec++; codec_blocks = byte & CODEC_SBC_BLOCK_MASK; codec_subbands = byte & CODEC_SBC_NBBAND_MASK; codec_alloc = byte & CODEC_SBC_ALLOC_MASK; bitpool_min = *p_codec++; bitpool_max = *p_codec++; switch(codec_freq) { case CODEC_SBC_FREQ_48: BTUSB_INFO("SBC Freq=48K\n"); p_sbc->frequency = 48000; break; case CODEC_SBC_FREQ_44: BTUSB_INFO("SBC Freq=44.1K\n"); p_sbc->frequency = 44100; break; case CODEC_SBC_FREQ_32: BTUSB_INFO("SBC Freq=32K\n"); p_sbc->frequency = 32000; break; case CODEC_SBC_FREQ_16: BTUSB_INFO("SBC Freq=16K\n"); p_sbc->frequency = 16000; break; default: BTUSB_INFO("Bad SBC Freq=%d\n", codec_freq); return -1; } switch(codec_mode) { case CODEC_MODE_JOIN_STEREO: BTUSB_INFO("SBC Join Stereo\n"); p_sbc->mode = CODEC_MODE_JOIN_STEREO; break; case CODEC_MODE_STEREO: BTUSB_INFO("SBC Stereo\n"); p_sbc->mode = CODEC_MODE_STEREO; break; case CODEC_MODE_DUAL: BTUSB_INFO("SBC Dual\n"); p_sbc->mode = CODEC_MODE_DUAL; break; case CODEC_MODE_MONO: BTUSB_INFO("SBC Mono\n"); p_sbc->mode = CODEC_MODE_MONO; break; default: BTUSB_INFO("Bad SBC mode=%d\n", codec_mode); return -1; } switch(codec_blocks) { case CODEC_SBC_BLOCK_16: BTUSB_INFO("SBC Block=16\n"); p_sbc->nb_blocks = 16; break; case CODEC_SBC_BLOCK_12: BTUSB_INFO("SBC Block=12\n"); p_sbc->nb_blocks = 12; break; case CODEC_SBC_BLOCK_8: BTUSB_INFO("SBC Block=8\n"); p_sbc->nb_blocks = 8; break; case CODEC_SBC_BLOCK_4: BTUSB_INFO("SBC Block=4\n"); p_sbc->nb_blocks = 4; break; default: BTUSB_INFO("Bad SBC Block=%d\n", codec_blocks); return -1; } switch(codec_subbands) { case CODEC_SBC_NBBAND_8: BTUSB_INFO("SBC NbSubBand=8\n"); p_sbc->nb_subbands = 8; break; case CODEC_SBC_NBBAND_4: BTUSB_INFO("SBC NbSubBand=4\n"); p_sbc->nb_subbands = 4; break; default: BTUSB_INFO("Bad SBC NbSubBand=%d\n", codec_blocks); return -1; } switch(codec_alloc) { case CODEC_SBC_ALLOC_LOUDNESS: BTUSB_INFO("SBC Loudness\n"); p_sbc->allocation = CODEC_SBC_ALLOC_LOUDNESS; break; case CODEC_SBC_ALLOC_SNR: BTUSB_INFO("SBC SNR\n"); p_sbc->allocation = CODEC_SBC_ALLOC_SNR; break; default: BTUSB_INFO("Bad SBC AllocMethod=%d\n", codec_blocks); return -1; } BTUSB_INFO("BitpoolMin=%d BitpoolMax=%d\n", bitpool_min, bitpool_max); p_sbc->bitpool_min = bitpool_min; p_sbc->bitpool_max = bitpool_max; return 0; } /******************************************************************************* ** ** Function btusb_lite_sbc_get_bitpool ** ** Description Calculate the BitPool for a specified BitRate (and other parameters) ** ** Returns Void ** *******************************************************************************/ static int btusb_lite_sbc_get_bitpool(struct btusb_lite_av_sbc_param *p_sbc_param, int target_bitrate) { int nb_channels; int frame_length; int bitpool = p_sbc_param->bitpool_max + 1; int bitrate; /* Required number of channels */ if (p_sbc_param->mode == CODEC_MODE_MONO) nb_channels = 1; else nb_channels = 2; target_bitrate *= 1000; /* Bitrate from app is in Kbps */ do { bitpool--; /* Reduce Bit Pool by one */ /* Calculate common SBC Frame length */ frame_length = 4 + (4 * p_sbc_param->nb_subbands * nb_channels) / 8; /* Add specific SBC Frame length (depending on mode) */ switch(p_sbc_param->mode) { case CODEC_MODE_MONO: case CODEC_MODE_DUAL: frame_length += (p_sbc_param->nb_blocks * nb_channels * bitpool) / 8; break; case CODEC_MODE_JOIN_STEREO: frame_length += (p_sbc_param->nb_subbands + p_sbc_param->nb_blocks * bitpool) / 8; break; case CODEC_MODE_STEREO: frame_length += (p_sbc_param->nb_blocks * bitpool) / 8; break; } /* Calculate bit rate */ bitrate = 8 * frame_length * p_sbc_param->frequency / p_sbc_param->nb_subbands / p_sbc_param->nb_blocks; } while (bitrate > target_bitrate); /* While bitrate is too big */ BTUSB_INFO("final bitpool=%d frame_length=%d bitrate=%d\n", bitpool, frame_length, bitrate); return (int)bitpool; } /******************************************************************************* ** ** Function btusb_lite_av_pcm_cback ** ** Description BTUSB Lte AV PCM Callback function. ** ** Returns Void ** *******************************************************************************/ static void btusb_lite_av_pcm_cback(void *p_opaque, void *p_data, int nb_pcm_frames) { struct btusb *p_dev = p_opaque; struct btusb_lite_av_cb *p_av_cb; int pcm_frame_size_byte; void *p_dest; int written_enc_size; struct btusb_lite_encoder_ccb *p_encoder; if (!p_dev) { BTUSB_ERR("Null p_dev\n"); return; } if (!p_data) { BTUSB_ERR("Null p_data\n"); return; } /* Get Reference on the SBC Stream (which is the same than the Encoder channel) */ p_av_cb = &p_dev->lite_cb.s.av; if (p_av_cb->pcm.state != PCM_STARTED) { BTUSB_ERR("BTPCM is not started\n"); btpcm_stop(p_dev->lite_cb.p_btpcm); return; } /* Get reference to AV's encoder */ p_encoder = &p_av_cb->encoder; BTUSB_DBG("nb_pcm_frames=%d, pcm_frame_size=%d, encoded_frame_size=%d \n", nb_pcm_frames, p_av_cb->encoder.pcm_frame_size, p_av_cb->encoder.encoded_frame_size); /* Calculate the size (in byte) of an Input PCM buffer (holding one encoded frame) */ pcm_frame_size_byte = p_av_cb->encoder.pcm_frame_size; pcm_frame_size_byte *= 2; /* Stereo */ pcm_frame_size_byte *= 2; /* 16 bits per sample */ /* Sanity Check */ if (pcm_frame_size_byte == 0) { BTUSB_ERR("Bad PCM Frame size=%d\n", pcm_frame_size_byte); return; } /* * No PCM data in a timer period. * Need to send AV data in a working buffer if it exists */ if (nb_pcm_frames == 0) { BTUSB_DBG("No PCM data, send AV data in a working buffer. \n"); if (p_av_cb->p_buf_working) { if (p_av_cb->p_buf_working->len) { /* For AV channel, send the packet */ btusb_lite_av_send_packet((struct btusb *)p_dev, p_av_cb->p_buf_working); /* A new working buffer must be allocated */ p_av_cb->p_buf_working = NULL; } } return; } /* While received buffer is not empty */ while (nb_pcm_frames) { /* Check if there are enough remaining frames in the buffer */ if ((nb_pcm_frames * 2 * 2) < pcm_frame_size_byte) { BTUSB_ERR("Bad nb_pcm_frames=%d\n", nb_pcm_frames); return; } /* If no working buffer allocated */ if (!p_av_cb->p_buf_working) { /* Get a buffer from the pool */ p_av_cb->p_buf_working = (BT_HDR *)GKI_getbuf(sizeof(BT_HDR) + p_av_cb->header_len + p_av_cb->payload_len); if(unlikely(p_av_cb->p_buf_working == NULL)) { BTUSB_ERR("Unable to get GKI buffer - sent fail\n"); return; } if (unlikely(dbgflags & BTUSB_GKI_CHK_MSG) && unlikely(GKI_buffer_status(p_av_cb->p_buf_working) != BUF_STATUS_UNLINKED)) { BTUSB_ERR("buffer != BUF_STATUS_UNLINKED 0x%p\n", p_av_cb->p_buf_working); return; } /* Skip headers */ p_av_cb->p_buf_working->offset = p_av_cb->header_len; p_av_cb->p_buf_working->len = 0; p_av_cb->p_buf_working->layer_specific = 0; /* Used to store the number of Encoded Frames */ } /* Fill the ACL Packet with SBC Frames */ do { /* Get Write address */ p_dest = (UINT8 *)(p_av_cb->p_buf_working + 1) + p_av_cb->p_buf_working->offset + p_av_cb->p_buf_working->len; if (p_encoder->type == A2D_MEDIA_CT_SBC) { /* Encode one PCM frame with SBC Encoder*/ btsbc_encode(p_encoder->channel, /* If Mute => Zero filled PCM sample*/ /* Otherwise => regular PCM data */ pcm0_mute?btusb_lite_silence_pcm:p_data, pcm_frame_size_byte, p_dest, /* SBC Output buffer */ p_av_cb->encoder.encoded_frame_size, /* Expected Output SBC frame size */ &written_enc_size); } #ifdef BTUSB_LITE_SEC else if (p_encoder->type == A2D_MEDIA_CT_SEC) { /* Encode one PCM frame with SEC Encoder*/ written_enc_size = btsec_encode(p_av_cb->encoder.channel, /* If Mute => Zero filled PCM sample*/ /* Otherwise => regular PCM data */ pcm0_mute?btusb_lite_silence_pcm:p_data, pcm_frame_size_byte, p_dest, /* SEC Output buffer */ p_encoder->encoded_frame_size);/* Expected Output SEC frame size */ } #endif else { BTUSB_ERR("Bad Encoding TYPE:%d\n", p_encoder->type); } if (written_enc_size != p_av_cb->encoder.encoded_frame_size) { BTUSB_ERR("Bad Encoded Frame length=%d (expected=%d)\n", written_enc_size, p_av_cb->encoder.encoded_frame_size); } /* Update Encoded packet length */ p_av_cb->p_buf_working->len += (UINT16)p_av_cb->encoder.encoded_frame_size; /* One more Encoded Frame */ p_av_cb->p_buf_working->layer_specific++; p_data += pcm_frame_size_byte; /* Jump to the next PCM sample */ nb_pcm_frames -= pcm_frame_size_byte / 4; /* Update number of remaining samples */ } while (nb_pcm_frames && (p_av_cb->p_buf_working->layer_specific < A2D_SBC_HDR_NUM_MSK) && ((p_av_cb->p_buf_working->len + p_av_cb->encoder.encoded_frame_size + BTUSB_LITE_AVDT_HDR_SIZE) < p_av_cb->curr_mtu)); /* A2DP streaming */ if (p_av_cb->streaming_type == AV_LITE_STREAMING_AVDT) { /* If no more room to store an encoded frame */ if (p_av_cb->encoder.encoded_frame_size > (p_av_cb->curr_mtu - p_av_cb->p_buf_working->len - BTUSB_LITE_AVDT_HDR_SIZE)) { BTUSB_DBG("nb_pcm_fr=%d nb_sbc_fr=%d len=%d sbc_fr_size=%d mtu=%d nb_seq=%d\n", nb_pcm_frames, p_av_cb->p_buf_working->layer_specific, p_av_cb->p_buf_working->len, p_av_cb->encoder.encoded_frame_size, p_av_cb->curr_mtu, p_av_cb->seq_number); /* For AV channel, send the packet */ btusb_lite_av_send_packet((struct btusb *)p_dev, p_av_cb->p_buf_working); /* A new working buffer must be allocated */ p_av_cb->p_buf_working = NULL; } } /* CLB streaming */ else if (p_av_cb->streaming_type == AV_LITE_STREAMING_CLB) { BTUSB_DBG("nb_pcm_fr=%d nb_sbc_fr=%d len=%d sbc_fr_size=%d mtu=%d nb_seq=%d\n", nb_pcm_frames, p_av_cb->p_buf_working->layer_specific, p_av_cb->p_buf_working->len, p_av_cb->encoder.encoded_frame_size, p_av_cb->curr_mtu, p_av_cb->seq_number); /* If at least one SBC frame encoded */ if (p_av_cb->p_buf_working->layer_specific) { /* For AV channel, send the packet */ btusb_lite_av_send_packet((struct btusb *)p_dev, p_av_cb->p_buf_working); /* A new working buffer must be allocated */ p_av_cb->p_buf_working = NULL; } /* Increase sequence number (even if no packet sent) */ p_av_cb->seq_number++; } else { BTUSB_ERR("Bad Streaming Type:%d \n", p_av_cb->streaming_type); } } } /******************************************************************************* ** ** Function btusb_lite_clb_send ** ** Description Send a new Connectionless BAV packet to the controller ** ** Returns Void ** *******************************************************************************/ static void btusb_lite_clb_send(struct btusb *p_dev, BT_HDR *p_msg, UINT8 avdt_handle, UINT8 m_pt, UINT8 option, UINT32 timestamp) { struct btusb_lite_av_cb *p_av_cb = &p_dev->lite_cb.s.av; UINT8 *p_data; if (p_dev == NULL) { BTUSB_ERR("p_dev is NULL\n"); if (p_msg) GKI_freebuf(p_msg); return; } if (p_msg == NULL) { BTUSB_ERR("p_msg is NULL\n"); return; } if (p_msg->offset < (BSA_SV_AV_BAV_HEADER_SIZE + BSA_BAV_L2C_HDR_SZ)) /*14+4*/ { BTUSB_ERR("bad offset, p_msg->offset=%d handle=%d", p_msg->offset, avdt_handle); GKI_freebuf(p_msg); return; } /* Packet Header - BSA_SV_AV_BAV_HEADER_SIZE - 14 bytes */ p_msg->offset -= BSA_SV_AV_BAV_HEADER_SIZE; p_msg->len += BSA_SV_AV_BAV_HEADER_SIZE; p_data = (UINT8 *)(p_msg + 1) + p_msg->offset; UINT8_TO_STREAM(p_data, BSA_SV_AV_BAV_PACKET_HEADER_SBC_MASK); UINT8_TO_BE_STREAM(p_data, AVDT_MEDIA_OCTET1); /* Version, Padding, Ext, CSRC */ UINT8_TO_BE_STREAM(p_data, BSA_SV_AV_BAV_RTP_PAYLOAD_TYPE); UINT16_TO_BE_STREAM(p_data, p_av_cb->seq_number); UINT32_TO_BE_STREAM(p_data, 0); /* todo: TimeStamp */ UINT32_TO_BE_STREAM(p_data, 0); /* todo: SSRC */ /* Number of SBC Frames */ UINT8_TO_BE_STREAM(p_data, p_msg->layer_specific & A2D_SBC_HDR_NUM_MSK); /* Packet Header, BSA_BAV_L2C_HDR_SZ = 4 */ p_msg->offset -= BSA_BAV_L2C_HDR_SZ; p_msg->len += BSA_BAV_L2C_HDR_SZ; p_data = (UINT8 *)(p_msg + 1) + p_msg->offset; UINT16_TO_STREAM(p_data, p_msg->len - BSA_BAV_L2C_HDR_SZ); UINT16_TO_STREAM(p_data, BSA_BAV_L2C_FAKE_CID); BTUSB_DBG("len=%d, offset=%d, nb_frame=%d, seq_number=%d \n", p_msg->len, p_msg->offset, p_msg->layer_specific, p_av_cb->seq_number); BTUSB_DBG("p_msg->len should be 678 - AFBT compatible"); if (btusb_lite_hci_acl_send(p_dev, p_msg, 1 /*LTAddr*/) < 0) { BTUSB_ERR("Fail-btusb_lite_hci_acl_send() "); return; } } /******************************************************************************* ** ** Function btusb_lite_av_send_packet ** ** Description Send a new BAV packet to the controller ** ** Returns Void ** *******************************************************************************/ static void btusb_lite_av_send_packet(struct btusb *p_dev, BT_HDR *p_msg) { struct btusb_lite_av_cb *p_av_cb; struct btusb_lite_av_scb *p_av_scb; int stream; int nb_started_streams; BT_HDR *p_msg_dup; if (!p_dev || !p_msg) { BTUSB_ERR("Bad reference p_dev=%p p_msg=%p\n", p_dev, p_msg); return; } /* Sanity */ if (p_msg->len == 0) { BTUSB_ERR("Length is 0=%d\n", p_msg->len); GKI_freebuf(p_msg); /* Free this ACL buffer */ return; } /* Get Reference on the AV Streams */ p_av_cb = &p_dev->lite_cb.s.av; /* Update TimeStamp */ p_av_cb->timestamp += p_msg->layer_specific * p_av_cb->encoder.pcm_frame_size; nb_started_streams = 0; /* Count how many AV stream are started */ for (stream = 0, p_av_scb = p_av_cb->scb ; stream < BTA_AV_NUM_STRS ; stream++, p_av_scb++) { if (p_av_scb->started) { nb_started_streams++; /* One more started stream */ } } if (nb_started_streams == 0) { BTUSB_ERR("No Started AV stream found\n"); GKI_freebuf(p_msg); /* Free this ACL buffer */ return; } else if (nb_started_streams == 1) { p_msg_dup = NULL; } else { /* * Duplicate the AV packet */ /* Get a buffer from the pool */ p_msg_dup = (BT_HDR *)GKI_getbuf(sizeof(BT_HDR) + p_msg->offset + p_msg->offset); if(p_msg_dup) { if (unlikely(dbgflags & BTUSB_GKI_CHK_MSG) && unlikely(GKI_buffer_status(p_msg_dup) != BUF_STATUS_UNLINKED)) { BTUSB_ERR("buffer != BUF_STATUS_UNLINKED 0x%p\n", p_msg_dup); p_msg_dup = NULL; /* Do not use this buffer */ } if(p_msg_dup) { /* Duplicate all the data (Header, and payload */ memcpy(p_msg_dup, p_msg, sizeof(BT_HDR) + p_msg->offset + p_msg->offset); } } if (nb_started_streams > 2) { BTUSB_ERR("nb_started_streams=%d force it to 2\n", nb_started_streams); nb_started_streams = 2; } } /* For every AV stream Started */ for (stream = 0, p_av_scb = p_av_cb->scb ; stream < BTA_AV_NUM_STRS ; stream++, p_av_scb++) { if (p_av_scb->started) { if (p_msg) { /* Send the original packet to AVDT/CLB */ p_av_cb->p_stream_func(p_dev, p_msg, p_av_scb->avdt_handle, p_av_cb->m_pt, p_av_cb->option, p_av_cb->timestamp); p_msg = NULL; } else if (p_msg_dup) { /* Send the duplicated packet to AVDT/CLB */ p_av_cb->p_stream_func(p_dev, p_msg_dup, p_av_scb->avdt_handle, p_av_cb->m_pt, p_av_cb->option, p_av_cb->timestamp); p_msg_dup = NULL; } else { BTUSB_ERR("No AV data to send for AV stream=%d \n", stream); } } } }
pd2-linux/tina
package/softwinner/bluetooth/3rdparty/embedded/brcm/linux/btusb/src/btusb_lite_av.c
C
gpl-2.0
47,156
<?php /** *------------------------------------------------------------------------------ * iCagenda v3 by Jooml!C - Events Management Extension for Joomla! 2.5 / 3.x *------------------------------------------------------------------------------ * @package com_icagenda * @copyright Copyright (c)2012-2014 Cyril RezŽ, Jooml!C - All rights reserved * * @license GNU General Public License version 3 or later; see LICENSE.txt * @author Cyril RezŽ (Lyr!C) * @link http://www.joomlic.com * * @version 3.3.3 2014-04-02 * @since 3.3.3 *------------------------------------------------------------------------------ */ // No direct access to this file defined('_JEXEC') or die(); /** * category Table class */ class iCagendaTableregistration extends JTable { /** * Constructor * * @param JDatabase A database connector object */ public function __construct(&$_db) { parent::__construct('#__icagenda_registration', 'id', $_db); } /** * Overloaded bind function to pre-process the params. * * @param array Named array * @return null|string null is operation was satisfactory, otherwise returns an error * @see JTable:bind * @since 1.5 */ public function bind($array, $ignore = '') { if (isset($array['params']) && is_array($array['params'])) { $registry = new JRegistry(); $registry->loadArray($array['params']); $array['params'] = (string)$registry; } if (isset($array['metadata']) && is_array($array['metadata'])) { $registry = new JRegistry(); $registry->loadArray($array['metadata']); $array['metadata'] = (string)$registry; } return parent::bind($array, $ignore); } /** * Overloaded check function */ public function check() { //If there is an ordering column and this is a new row then get the next ordering value if (property_exists($this, 'ordering') && $this->id == 0) { $this->ordering = self::getNextOrder(); } // URL jimport( 'joomla.filter.output' ); // if(empty($this->alias)) { // $this->alias = $this->title; // } // $this->alias = JFilterOutput::stringURLSafe($this->alias); return parent::check(); } /** * Method to set the publishing state for a row or list of rows in the database * table. The method respects checked out rows by other users and will attempt * to checkin rows that it can after adjustments are made. * * @param mixed An optional array of primary key values to update. If not * set the instance property value is used. * @param integer The publishing state. eg. [0 = unpublished, 1 = published] * @param integer The user id of the user performing the operation. * @return boolean True on success. * @since 1.0.4 */ public function publish($pks = null, $state = 1, $userId = 0) { // Initialise variables. $k = $this->_tbl_key; // Sanitize input. JArrayHelper::toInteger($pks); $userId = (int) $userId; $state = (int) $state; // If there are no primary keys set check to see if the instance key is set. if (empty($pks)) { if ($this->$k) { $pks = array($this->$k); } // Nothing to set publishing state on, return false. else { $this->setError(JText::_('JLIB_DATABASE_ERROR_NO_ROWS_SELECTED')); return false; } } // Build the WHERE clause for the primary keys. $where = $k.'='.implode(' OR '.$k.'=', $pks); // Determine if there is checkin support for the table. if (!property_exists($this, 'checked_out') || !property_exists($this, 'checked_out_time')) { $checkin = ''; } else { $checkin = ' AND (checked_out = 0 OR checked_out = '.(int) $userId.')'; } // Update the publishing state for rows with the given primary keys. $this->_db->setQuery( 'UPDATE `'.$this->_tbl.'`' . ' SET `state` = '.(int) $state . ' WHERE ('.$where.')' . $checkin ); $this->_db->query(); // Check for a database error. if ($this->_db->getErrorNum()) { $this->setError($this->_db->getErrorMsg()); return false; } // If checkin is supported and all rows were adjusted, check them in. if ($checkin && (count($pks) == $this->_db->getAffectedRows())) { // Checkin the rows. foreach($pks as $pk) { $this->checkin($pk); } } // If the JTable instance value is in the list of primary keys that were set, set the instance. if (in_array($this->$k, $pks)) { $this->state = $state; } $this->setError(''); return true; } }
C3Style/appuihec
administrator/components/com_icagenda/tables/registration.php
PHP
gpl-2.0
4,975
/** * stencil_maskType.java * * This file was generated by XMLSpy 2007sp2 Enterprise Edition. * * YOU SHOULD NOT MODIFY THIS FILE, BECAUSE IT WILL BE * OVERWRITTEN WHEN YOU RE-RUN CODE GENERATION. * * Refer to the XMLSpy Documentation for further details. * http://www.altova.com/xmlspy */ package com.jmex.model.collada.schema; import com.jmex.xml.types.SchemaNCName; public class stencil_maskType extends com.jmex.xml.xml.Node { public stencil_maskType(stencil_maskType node) { super(node); } public stencil_maskType(org.w3c.dom.Node node) { super(node); } public stencil_maskType(org.w3c.dom.Document doc) { super(doc); } public stencil_maskType(com.jmex.xml.xml.Document doc, String namespaceURI, String prefix, String name) { super(doc, namespaceURI, prefix, name); } public void adjustPrefix() { for ( org.w3c.dom.Node tmpNode = getDomFirstChild( Attribute, null, "value" ); tmpNode != null; tmpNode = getDomNextChild( Attribute, null, "value", tmpNode ) ) { internalAdjustPrefix(tmpNode, false); } for ( org.w3c.dom.Node tmpNode = getDomFirstChild( Attribute, null, "param" ); tmpNode != null; tmpNode = getDomNextChild( Attribute, null, "param", tmpNode ) ) { internalAdjustPrefix(tmpNode, false); } } public void setXsiType() { org.w3c.dom.Element el = (org.w3c.dom.Element) domNode; el.setAttributeNS("http://www.w3.org/2001/XMLSchema-instance", "xsi:type", "stencil_mask"); } public static int getvalue2MinCount() { return 0; } public static int getvalue2MaxCount() { return 1; } public int getvalue2Count() { return getDomChildCount(Attribute, null, "value"); } public boolean hasvalue2() { return hasDomChild(Attribute, null, "value"); } public int2 newvalue2() { return new int2(); } public int2 getvalue2At(int index) throws Exception { return new int2(getDomNodeValue(getDomChildAt(Attribute, null, "value", index))); } public org.w3c.dom.Node getStartingvalue2Cursor() throws Exception { return getDomFirstChild(Attribute, null, "value" ); } public org.w3c.dom.Node getAdvancedvalue2Cursor( org.w3c.dom.Node curNode ) throws Exception { return getDomNextChild( Attribute, null, "value", curNode ); } public int2 getvalue2ValueAtCursor( org.w3c.dom.Node curNode ) throws Exception { if( curNode == null ) throw new com.jmex.xml.xml.XmlException("Out of range"); else return new int2(getDomNodeValue(curNode)); } public int2 getvalue2() throws Exception { return getvalue2At(0); } public void removevalue2At(int index) { removeDomChildAt(Attribute, null, "value", index); } public void removevalue2() { removevalue2At(0); } public org.w3c.dom.Node addvalue2(int2 value) { if( value.isNull() ) return null; return appendDomChild(Attribute, null, "value", value.toString()); } public org.w3c.dom.Node addvalue2(String value) throws Exception { return addvalue2(new int2(value)); } public void insertvalue2At(int2 value, int index) { insertDomChildAt(Attribute, null, "value", index, value.toString()); } public void insertvalue2At(String value, int index) throws Exception { insertvalue2At(new int2(value), index); } public void replacevalue2At(int2 value, int index) { replaceDomChildAt(Attribute, null, "value", index, value.toString()); } public void replacevalue2At(String value, int index) throws Exception { replacevalue2At(new int2(value), index); } public static int getparamMinCount() { return 0; } public static int getparamMaxCount() { return 1; } public int getparamCount() { return getDomChildCount(Attribute, null, "param"); } public boolean hasparam() { return hasDomChild(Attribute, null, "param"); } public SchemaNCName newparam() { return new SchemaNCName(); } public SchemaNCName getparamAt(int index) throws Exception { return new SchemaNCName(getDomNodeValue(getDomChildAt(Attribute, null, "param", index))); } public org.w3c.dom.Node getStartingparamCursor() throws Exception { return getDomFirstChild(Attribute, null, "param" ); } public org.w3c.dom.Node getAdvancedparamCursor( org.w3c.dom.Node curNode ) throws Exception { return getDomNextChild( Attribute, null, "param", curNode ); } public SchemaNCName getparamValueAtCursor( org.w3c.dom.Node curNode ) throws Exception { if( curNode == null ) throw new com.jmex.xml.xml.XmlException("Out of range"); else return new SchemaNCName(getDomNodeValue(curNode)); } public SchemaNCName getparam() throws Exception { return getparamAt(0); } public void removeparamAt(int index) { removeDomChildAt(Attribute, null, "param", index); } public void removeparam() { removeparamAt(0); } public org.w3c.dom.Node addparam(SchemaNCName value) { if( value.isNull() ) return null; return appendDomChild(Attribute, null, "param", value.toString()); } public org.w3c.dom.Node addparam(String value) throws Exception { return addparam(new SchemaNCName(value)); } public void insertparamAt(SchemaNCName value, int index) { insertDomChildAt(Attribute, null, "param", index, value.toString()); } public void insertparamAt(String value, int index) throws Exception { insertparamAt(new SchemaNCName(value), index); } public void replaceparamAt(SchemaNCName value, int index) { replaceDomChildAt(Attribute, null, "param", index, value.toString()); } public void replaceparamAt(String value, int index) throws Exception { replaceparamAt(new SchemaNCName(value), index); } }
tectronics/xenogeddon
src/com/jmex/model/collada/schema/stencil_maskType.java
Java
gpl-2.0
5,745
#include "document.h" #include "effect.h" #include "newdialog.h" #include <QtCore/QFile> #include <QtCore/QTimer> #include <QtCore/QUrl> #include <QtGui/QMessageBox> #include <QtGui/QFileDialog> namespace { static QString strippedName(const QString & fileName) { return QFileInfo(fileName).fileName(); } static QString strippedName(const QFile & file) { return QFileInfo(file).fileName(); } } // static QString Document::lastEffect() { return s_lastEffect; } // static void Document::setLastEffect(const QString & effectPath) { s_lastEffect = effectPath; } // static QString Document::s_lastEffect; Document::Document(QGLWidget * glWidget, QWidget * parent/*= 0*/) : QObject(parent) { Q_ASSERT(glWidget != NULL); m_glWidget = glWidget; m_owner = parent; m_effectFactory = NULL; m_file = NULL; m_effect = NULL; m_modified = false; } Document::~Document() { closeEffect(); } bool Document::isModified() const { return m_modified; } void Document::setModified(bool m) { // If file not saved, modified is always true. //if (m_modified != m) // Sometimes want to force an update by invoking the signal. { m_modified = m; emit modifiedChanged(m_modified); } } /// Return the current document file name. QString Document::fileName() const { QString fileName; if (m_file != NULL) { fileName = strippedName(*m_file); } else { QString fileExtension = m_effectFactory->extension(); fileName = tr("untitled") + "." + fileExtension; } return fileName; } /// Return document's title. QString Document::title() const { QString title; if (m_file == NULL) { title = tr("Untitled"); } else { title = strippedName(*m_file); } if (m_modified) { title.append(" "); title.append(tr("[modified]")); } return title; } bool Document::canLoadFile(const QString & fileName) const { int idx = fileName.lastIndexOf('.'); QString fileExtension = fileName.mid(idx+1); const EffectFactory * effectFactory = EffectFactory::factoryForExtension(fileExtension); return (effectFactory != NULL) && m_effectFactory->isSupported(); } /*************************Peter Komar code, august 2009 ************************************/ void Document::slot_load_from_library_shader(const QString& name_lib) { if (!close()) { // User cancelled the operation. return; } QApplication::setOverrideCursor(QCursor(Qt::WaitCursor)); QFile *filelib = new QFile(name_lib); if (!filelib->open(QIODevice::ReadOnly)) { QMessageBox::critical(m_owner, tr("Error"), tr("Can't open library.")); return; } int idx = name_lib.lastIndexOf('.'); QString Ext = name_lib.mid(idx+1); m_effectFactory = EffectFactory::factoryForExtension(Ext); if (m_effectFactory != NULL) { Q_ASSERT(m_effectFactory->isSupported()); m_effect = m_effectFactory->createEffect(m_glWidget); Q_ASSERT(m_effect != NULL); connect(m_effect, SIGNAL(built(bool)), this, SIGNAL(effectBuilt(bool))); m_effect->load(filelib); emit effectCreated(); build(false); } emit titleChanged(name_lib.mid(name_lib.lastIndexOf("/")+1,idx)); filelib->close(); delete filelib; QApplication::restoreOverrideCursor(); } /**************************************************************************/ bool Document::loadFile(const QString & fileName) { if (!close()) { // User cancelled the operation. return false; } delete m_file; m_file = new QFile(fileName); if (!m_file->open(QIODevice::ReadOnly)) { delete m_file; m_file = NULL; return false; } QApplication::setOverrideCursor(QCursor(Qt::WaitCursor)); m_modified = false; int idx = fileName.lastIndexOf('.'); QString fileExtension = fileName.mid(idx+1); m_effectFactory = EffectFactory::factoryForExtension(fileExtension); if (m_effectFactory != NULL) { Q_ASSERT(m_effectFactory->isSupported()); m_effect = m_effectFactory->createEffect(m_glWidget); Q_ASSERT(m_effect != NULL); connect(m_effect, SIGNAL(built(bool)), this, SIGNAL(effectBuilt(bool))); m_effect->load(m_file); emit effectCreated(); build(false); } else { // @@ Can this happen? } m_file->close(); emit titleChanged(title()); s_lastEffect = fileName; // @@ Move this somewhere else! emit fileNameChanged(fileName); QApplication::restoreOverrideCursor(); return true; } void Document::reset(bool startup) { // Count effect file types. const QList<const EffectFactory *> & effectFactoryList = EffectFactory::factoryList(); int count = 0; foreach(const EffectFactory * ef, effectFactoryList) { if(ef->isSupported()) { ++count; } } const EffectFactory * effectFactory = NULL; if (count == 0) { // Display error. QMessageBox::critical(m_owner, tr("Error"), tr("No effect files supported"), QMessageBox::Ok, QMessageBox::NoButton, QMessageBox::NoButton); } else if(count == 1) { // Use the first supported effect type. foreach(const EffectFactory * ef, effectFactoryList) { if(ef->isSupported()) { effectFactory = ef; break; } } } else { // Let the user choose the effect type. NewDialog newDialog(m_owner, startup); int result = newDialog.exec(); if (result == QDialog::Accepted) { QString selection = newDialog.shaderType(); foreach(const EffectFactory * ef, effectFactoryList) { if(ef->isSupported() && ef->name() == selection) { effectFactory = ef; break; } } } else if (result == NewDialog::OpenEffect) { open(); return; } } if (effectFactory != NULL) { newEffect(effectFactory); } } void Document::open() { // Find supported effect types. QStringList effectTypes; QStringList effectExtensions; foreach (const EffectFactory * factory, EffectFactory::factoryList()) { if (factory->isSupported()) { QString effectType = QString("%1 (*.%2)").arg(factory->namePlural()).arg(factory->extension()); effectTypes.append(effectType); QString effectExtension = factory->extension(); effectExtensions.append("*." + effectExtension); } } if (effectTypes.isEmpty()) { QMessageBox::critical(m_owner, tr("Error"), tr("No effect files supported"), QMessageBox::Ok, QMessageBox::NoButton, QMessageBox::NoButton); return; } //QString fileName = QFileDialog::getOpenFileName(this, tr("Open File"), tr("."), effectTypes.join(";")); QString fileName = QFileDialog::getOpenFileName(m_owner, tr("Open File"), s_lastEffect, QString(tr("Effect Files (%1)")).arg(effectExtensions.join(" "))); if (!fileName.isEmpty()) { loadFile(fileName); } } bool Document::save() { if (m_file == NULL) { // Choose file dialog. QString fileExtension = m_effectFactory->extension(); QString effectType = QString("%1 (*.%2)").arg(m_effectFactory->namePlural()).arg(fileExtension); QString fileName = QFileDialog::getSaveFileName(m_owner, tr("Save File"), tr("untitled") + "." + fileExtension, effectType); if( fileName.isEmpty() ) { return false; } m_file = new QFile(fileName); } // @@ Check for errors. return saveEffect(); } void Document::saveAs() { Q_ASSERT(m_effectFactory != NULL); QString fileExtension = m_effectFactory->extension(); QString effectType = QString("%1 (*.%2)").arg(m_effectFactory->namePlural()).arg(fileExtension); // Choose file dialog. QString fileName = QFileDialog::getSaveFileName(m_owner, tr("Save File"), this->fileName(), effectType); if( fileName.isEmpty() ) { return; } delete m_file; m_file = new QFile(fileName); // @@ Check for errors. saveEffect(); // @@ Emit only when file name actually changed. emit fileNameChanged(fileName); } bool Document::close() { if (m_effect == NULL) { Q_ASSERT(m_file == NULL); // No effect open. return true; } if (m_effectFactory != NULL && isModified()) { QString fileName; if (m_file != NULL) { fileName = strippedName(*m_file); } else { QString extension = m_effectFactory->extension(); fileName = tr("untitled") + "." + extension; } while (true) { int answer = QMessageBox::question(m_owner, tr("Save modified files"), tr("Do you want to save '%1' before closing?").arg(fileName), QMessageBox::Yes, QMessageBox::No, QMessageBox::Cancel); if (answer == QMessageBox::Yes) { if( save() ) { break; } } else if (answer == QMessageBox::Cancel) { return false; } else { break; } } } emit effectDeleted(); closeEffect(); return true; } void Document::build(bool threaded /*= true*/) { Q_ASSERT(m_effect != NULL); emit synchronizeEditors(); emit effectBuilding(); m_effect->build(threaded); } void Document::onParameterChanged() { Q_ASSERT(m_effectFactory != NULL); if (m_effectFactory->savesParameters() && !isModified()) { setModified(true); } } void Document::newEffect(const EffectFactory * effectFactory) { Q_ASSERT(effectFactory != NULL); if (!close()) { // User cancelled the operation. return; } QApplication::setOverrideCursor(QCursor(Qt::WaitCursor)); m_effectFactory = effectFactory; m_effect = m_effectFactory->createEffect(m_glWidget); Q_ASSERT(m_effect != NULL); connect(m_effect, SIGNAL(built(bool)), this, SIGNAL(effectBuilt(bool))); m_modified = false; emit effectCreated(); emit titleChanged(title()); build(false); QApplication::restoreOverrideCursor(); } bool Document::saveEffect() { m_file->open(QIODevice::WriteOnly); // Synchronize before save. emit synchronizeEditors(); m_effect->save(m_file); m_file->close(); setModified(false); emit titleChanged(title()); //updateActions(); // qshaderedit listens to modifiedChanged return true; } void Document::closeEffect() { // Delete effect. delete m_effect; m_effect = NULL; delete m_file; m_file = NULL; }
peterkomar/qshaderedit
src/document.cpp
C++
gpl-2.0
10,048
<?php /* Plugin Name: Email Subscribers Plugin URI: http://www.gopiplus.com/work/2014/05/02/email-subscribers-wordpress-plugin/ Description: Email subscribers plugin has options to send newsletters to subscribers. It has a separate page with HTML editor to create a HTML newsletter. Also have options to send notification email to subscribers when new posts are published to your blog. Separate page available to include and exclude categories to send notifications. Version: 2.7 Author: Gopi Ramasamy Donate link: http://www.gopiplus.com/work/2014/05/02/email-subscribers-wordpress-plugin/ Author URI: http://www.gopiplus.com/work/2014/05/02/email-subscribers-wordpress-plugin/ License: GPLv2 or later License URI: http://www.gnu.org/licenses/gpl-2.0.html */ /* Copyright 2014 Email subscribers (http://www.gopiplus.com) 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. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ if(preg_match('#' . basename(__FILE__) . '#', $_SERVER['PHP_SELF'])) { die('You are not allowed to call this page directly.'); } require_once(dirname(__FILE__).DIRECTORY_SEPARATOR.'base'.DIRECTORY_SEPARATOR.'es-defined.php'); require_once(dirname(__FILE__).DIRECTORY_SEPARATOR.'classes'.DIRECTORY_SEPARATOR.'es-stater.php'); add_action('admin_menu', array( 'es_cls_registerhook', 'es_adminmenu' )); register_activation_hook(ES_FILE, array( 'es_cls_registerhook', 'es_activation' )); register_deactivation_hook(ES_FILE, array( 'es_cls_registerhook', 'es_deactivation' )); add_action( 'widgets_init', array( 'es_cls_registerhook', 'es_widget_loading' )); add_shortcode( 'email-subscribers', 'es_shortcode' ); require_once(dirname(__FILE__).DIRECTORY_SEPARATOR.'classes'.DIRECTORY_SEPARATOR.'es-directly.php'); function es_textdomain() { load_plugin_textdomain( 'email-subscribers' , false, dirname( plugin_basename( __FILE__ ) ) . '/languages/' ); } add_action('plugins_loaded', 'es_textdomain'); add_action( 'transition_post_status', array( 'es_cls_sendmail', 'es_prepare_notification' ), 10, 3 ); ?>
CosmicPi/cosmicpi.org
wp-content/plugins/email-subscribers/email-subscribers.php
PHP
gpl-2.0
2,553
<?php use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Migrations\Migration; class CreateProjectPackageTable extends Migration { /** * Run the migrations. * * @return void */ public function up() { Schema::create('project_package', function (Blueprint $table) { $table->increments('id'); $table->string('name'); $table->string('repository'); $table->string('deploy_branch'); $table->string('deploy_location'); $table->integer('order'); $table->integer('project_id')->unsigned(); }); Schema::table('project_package', function($table) { $table->foreign('project_id') ->references('id')->on('project') ->onDelete('cascade'); }); } /** * Reverse the migrations. * * @return void */ public function down() { Schema::drop('project_package'); } }
ImbalanceGaming/imbalance-gaming-laravel
database/migrations/2016_04_14_100207_create_project_package_table.php
PHP
gpl-2.0
1,001
package com.example.seventeen.blissappid; import android.app.Activity; import android.content.Intent; import android.net.Uri; import android.os.Bundle; import android.os.CountDownTimer; import android.view.Menu; import android.view.MenuItem; import android.view.View; import android.widget.ImageButton; /** * Hofundur: Egill Orn Sigthorsson * Dagsetning: 1.10.2014 * Lysing: Vidmot fyrir nothafa, tar sem hann getur tjad ja og nei * a audskiljanlegan hatt og opnad fulla blisstaknatoflu */ public class nothafi1 extends Activity { /** * Gerum sitthvoran onclicklistner fyrir ja og nei * @param savedInstanceState save instance */ @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_nothafi1); makeOnclickListeners(); } /** * bua til on click listnera fyrir takka i netenda vidmoti */ public void makeOnclickListeners(){ ImageButton jabutt; jabutt = (ImageButton) findViewById(R.id.ja); jabutt.setOnClickListener(gotoClickListener); ImageButton neibutt; neibutt = (ImageButton) findViewById(R.id.nei); neibutt.setOnClickListener(gotoneiClickListener); ImageButton bio; bio = (ImageButton) findViewById(R.id.bio); bio.setOnClickListener(gotoBioClickListener); ImageButton ftafla; ftafla = (ImageButton) findViewById(R.id.ftafla); ftafla.setOnClickListener(gotoftaflaClickListener); } /** * Ef smellt er a ja takkan */ View.OnClickListener gotoClickListener = new View.OnClickListener() { /** * tegar smellt er a ja takkan gloir hann i 3 sekundur * * @param v er view */ @Override public void onClick(View v) { final ImageButton jabutt; jabutt = (ImageButton) findViewById(R.id.ja); new CountDownTimer(3000,1000){ /** * breytum bakgrunni a takkanum a medan vid teljum nidur * @param millisUntilFinished timi eftir */ @Override public void onTick(long millisUntilFinished){ jabutt.setBackgroundResource(R.drawable.jafoc); } /** * breytum bakgrunni a takkanum i upprunalegt astandi tegar 3 sekundur eru lidnar */ @Override public void onFinish(){ //set the new Content of your activity jabutt.setBackgroundResource(R.drawable.ja); } }.start(); } }; /** * Ef smellt er a nei takkan */ View.OnClickListener gotoneiClickListener = new View.OnClickListener() { /** * Þegar smellt er á nei takkan glóir hann i 3 sekundur * @param v er view */ @Override public void onClick(View v) { final ImageButton neibutt; neibutt = (ImageButton) findViewById(R.id.nei); new CountDownTimer(3000,1000){ /** * breytum bakgrunni á takkanum a medan við teljum nidur * @param millisUntilFinished timi eftir */ @Override public void onTick(long millisUntilFinished){ neibutt.setBackgroundResource(R.drawable.neifoc); } /** * breytum bakgrunni á takkanum í upprunalegt astandi tegar 3 sekundur eru lidnar */ @Override public void onFinish(){ //set the new Content of your activity neibutt.setBackgroundResource(R.drawable.nei); } }.start(); } }; /** * Ef smellt er a bio takkan */ View.OnClickListener gotoBioClickListener = new View.OnClickListener() { /** * ef smellt er a bio takkan er kallad a fallid bio() * @param v view */ @Override public void onClick(View v) { bio(); } }; /** * opnar nyja gluggan bio */ private void bio(){ startActivity(new Intent(this, bio.class)); } /** * Ef smellt er a bio takkan */ View.OnClickListener gotoftaflaClickListener = new View.OnClickListener() { /** * ef smellt er a bio takkan er kallad a fallid bio() * @param v view */ @Override public void onClick(View v) { ftafla(); } }; /** * opnar nyja gluggan ftafla */ private void ftafla(){ startActivity(new Intent(this, full_blisstafla.class)); } /** * Inflate the menu; this adds items to the action bar if it is present. * @param menu Menu * @return true */ @Override public boolean onCreateOptionsMenu(Menu menu) { getMenuInflater().inflate(R.menu.nothafi1, menu); return true; } /** * Handle action bar item clicks here. The action bar will * automatically handle clicks on the Home/Up button, so long * as you specify a parent activity in AndroidManifest.xml. * @param item MenuItem * @return super.onOptionsItemSelected(item); */ @Override public boolean onOptionsItemSelected(MenuItem item) { int id = item.getItemId(); if (id == R.id.action_settings) { return true; } return super.onOptionsItemSelected(item); } }
sbleika/Blissid
BlissAppid_git/BlissAppid/app/src/main/java/com/example/seventeen/blissappid/nothafi1.java
Java
gpl-2.0
5,549
/** * */ package com.ankamagames.dofus.harvey.engine.numeric.bytes.sets.classes; import java.util.List; import com.ankamagames.dofus.harvey.engine.common.sets.classes.AbstractIntervalBridge; import com.ankamagames.dofus.harvey.engine.common.sets.classes.SplitOnRangeBridge; import com.ankamagames.dofus.harvey.engine.numeric.bytes.sets.classes.toolboxes.ByteBoundComparisonToolbox; import com.ankamagames.dofus.harvey.engine.numeric.bytes.sets.classes.toolboxes.ByteEqualityToolbox; import com.ankamagames.dofus.harvey.engine.numeric.bytes.sets.classes.toolboxes.ByteIntervalCreationToolbox; import com.ankamagames.dofus.harvey.numeric.bytes.sets.classes.ByteInterval; import com.ankamagames.dofus.harvey.numeric.bytes.sets.interfaces.IByteBound; import com.ankamagames.dofus.harvey.numeric.bytes.sets.interfaces.IByteInterval; import com.ankamagames.dofus.harvey.numeric.bytes.sets.interfaces.IByteSet; import com.ankamagames.dofus.harvey.numeric.bytes.sets.interfaces.IElementaryByteSet; import com.ankamagames.dofus.harvey.numeric.bytes.sets.interfaces.IEmptyByteSet; import com.ankamagames.dofus.harvey.numeric.bytes.sets.interfaces.ISimpleByteSet; import org.eclipse.jdt.annotation.NonNullByDefault; /** * @author sgros * */ @NonNullByDefault public class ByteIntervalBridge<Bridged extends ByteInterval> extends AbstractIntervalBridge<IByteBound, IByteSet, ISimpleByteSet, IElementaryByteSet, IByteInterval, IEmptyByteSet, Bridged> { protected ByteBoundComparisonToolbox<IByteBound, IByteSet, ISimpleByteSet, IElementaryByteSet, Bridged> _boundToolbox; protected ByteIntervalCreationToolbox<Bridged> _creationToolbox; protected ByteEqualityToolbox<IByteSet, ISimpleByteSet, IElementaryByteSet, Bridged> _equalityToolbox; protected SplitOnRangeBridge<IByteBound, IByteSet, ISimpleByteSet, IElementaryByteSet, IByteInterval, IEmptyByteSet, Bridged> _splitBridge; public ByteIntervalBridge(final Bridged bridged) { super(bridged); _boundToolbox = new ByteBoundComparisonToolbox<IByteBound, IByteSet, ISimpleByteSet, IElementaryByteSet, Bridged>(_bridged); _creationToolbox = new ByteIntervalCreationToolbox<Bridged>(_bridged); _equalityToolbox = new ByteEqualityToolbox<IByteSet, ISimpleByteSet, IElementaryByteSet, Bridged>(_bridged); _splitBridge = new SplitOnRangeBridge<IByteBound, IByteSet, ISimpleByteSet, IElementaryByteSet, IByteInterval, IEmptyByteSet, Bridged>(_bridged, _creationToolbox); } @Override protected SplitOnRangeBridge<IByteBound, IByteSet, ISimpleByteSet, IElementaryByteSet, IByteInterval, IEmptyByteSet, Bridged> getSplitBridge() { return _splitBridge; } @Override protected ByteBoundComparisonToolbox<IByteBound, IByteSet, ISimpleByteSet, IElementaryByteSet, Bridged> getBoundComparisonToolbox() { return _boundToolbox; } @Override protected ByteIntervalCreationToolbox<Bridged> getSetCreationToolbox() { return _creationToolbox; } @Override protected ByteEqualityToolbox<IByteSet, ISimpleByteSet, IElementaryByteSet, Bridged> getEqualityToolbox() { return _equalityToolbox; } public List<? extends IByteSet> split(final byte[] values, final boolean[] isIntervalStart) { return getSetCreationToolbox().split(values, isIntervalStart); } @Override public boolean isEmpty() { final IByteBound lowerBound = _bridged.getLowerBound(); final IByteBound upperBound = _bridged.getUpperBound(); if(lowerBound == null || upperBound == null) return true; return (lowerBound.getValue() - upperBound.getValue())>0; } @Override public IByteSet unite(final IByteSet set) { return super.unite(set).getAsSet(); } @Override public IByteSet intersect(final IByteSet set) { return super.intersect(set).getAsSet(); } }
Ankama/harvey
src/com/ankamagames/dofus/harvey/engine/numeric/bytes/sets/classes/ByteIntervalBridge.java
Java
gpl-2.0
3,714
<!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 : Function Reference: beforecommentforminsert()</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 - gareth@omnipotent.net --> <!-- http://phpxref.sourceforge.net/ --> <script src="../phpxref.js" type="text/javascript"></script> <script language="JavaScript" type="text/javascript"> <!-- ext='.html'; relbase='../'; subdir='_functions'; filename='index.html'; cookiekey='phpxref'; handleNavFrame(relbase, subdir, filename); logFunction('beforecommentforminsert'); // --> </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>Function and Method Cross Reference</h3> <h2><a href="index.html#beforecommentforminsert">beforecommentforminsert()</a></h2> <b>Defined at:</b><ul> <li><a href="../inc/plugins/_plugin.class.php.html#beforecommentforminsert">/inc/plugins/_plugin.class.php</a> -> <a onClick="logFunction('beforecommentforminsert', '/inc/plugins/_plugin.class.php.source.html#l1696')" href="../inc/plugins/_plugin.class.php.source.html#l1696"> line 1696</a></li> <li><a href="../plugins/_captcha_qstn.plugin.php.html#beforecommentforminsert">/plugins/_captcha_qstn.plugin.php</a> -> <a onClick="logFunction('beforecommentforminsert', '/plugins/_captcha_qstn.plugin.php.source.html#l477')" href="../plugins/_captcha_qstn.plugin.php.source.html#l477"> line 477</a></li> <li><a href="../plugins/code_highlight_plugin/_code_highlight.plugin.php.html#beforecommentforminsert">/plugins/code_highlight_plugin/_code_highlight.plugin.php</a> -> <a onClick="logFunction('beforecommentforminsert', '/plugins/code_highlight_plugin/_code_highlight.plugin.php.source.html#l433')" href="../plugins/code_highlight_plugin/_code_highlight.plugin.php.source.html#l433"> line 433</a></li> <li><a href="../plugins/basic_antispam_plugin/_basic_antispam.plugin.php.html#beforecommentforminsert">/plugins/basic_antispam_plugin/_basic_antispam.plugin.php</a> -> <a onClick="logFunction('beforecommentforminsert', '/plugins/basic_antispam_plugin/_basic_antispam.plugin.php.source.html#l192')" href="../plugins/basic_antispam_plugin/_basic_antispam.plugin.php.source.html#l192"> line 192</a></li> </ul> <b>Referenced 2 times:</b><ul> <li><a href="../plugins/_captcha_qstn.plugin.php.html">/plugins/_captcha_qstn.plugin.php</a> -> <a href="../plugins/_captcha_qstn.plugin.php.source.html#l518"> line 518</a></li> <li><a href="../plugins/_captcha_qstn.plugin.php.html">/plugins/_captcha_qstn.plugin.php</a> -> <a href="../plugins/_captcha_qstn.plugin.php.source.html#l539"> line 539</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
_functions/beforecommentforminsert.html
HTML
gpl-2.0
6,223
<html lang="en"> <head> <meta charset="UTF-8" /> <meta name="viewport" content="width=device-width, initial-scale=1.0" /> <meta http-equiv="X-UA-Compatible" content="ie=edge" /> <!-- COMMON TAGS --> <title>toqito - Theory of Quantum Information Toolkit</title> <!-- Search Engine --> <meta name="description" content="An open source Python library for studying various objects in quantum information." /> <!-- Schema.org for Google --> <meta itemprop="name" content="toqito - Theory of Quantum Information Toolkit" /> <meta itemprop="description" content="An open source Python library for studying various objects in quantum information." /> <!-- Twitter --> <meta name="twitter:card" content="summary" /> <meta name="twitter:title" content="toqito - Theory of Quantum Information Toolkit" /> <meta name="twitter:description" content="An open source Python library for studying various objects in quantum information." /> <meta name="twitter:creator" content="@captainhamptons" /> <!-- Open Graph general (Facebook, Pinterest & Google+) --> <meta name="og:title" content="toqito - Theory of Quantum Information Toolkit" /> <meta name="og:description" content="An open source Python library for studying various objects in quantum information." /> <meta name="og:url" content="https://toqito.github.io" /> <meta name="og:site_name" content="toqito" /> <meta name="og:locale" content="en_US" /> <meta name="og:type" content="website" /> <link rel="apple-touch-icon" sizes="180x180" href="/icons/apple-touch-icon.png"> <link rel="icon" type="image/png" sizes="32x32" href="/icons/favicon-32x32.png"> <link rel="icon" type="image/png" sizes="16x16" href="/icons/favicon-16x16.png"> <link rel="manifest" href="/icons/site.webmanifest"> <meta name="msapplication-TileColor" content="#da532c"> <meta name="theme-color" content="#ffffff"> <!-- Compressed CSS --> <link rel="stylesheet" href="/css/foundation.min.css" /> <link rel="stylesheet" href="/css/code-styles/atom-one-light.css" /> <link rel="stylesheet" href="/css/app.css" /> <link href="https://fonts.googleapis.com/css?family=Fira+Sans:300,500" rel="stylesheet" /> </head> <body> <div class="grid-container"> <div class="grid-x grid-padding-x"> <div class="small-1"> <!-- GUTTER --> </div> <div class="small-10"> <div class="grid-x grid-margin-x"> <div class="small-12 large-2"> <img class="logo" src="/images/Logo.svg" alt="toqito Logo" /> </div> <div class="small-12 large-10 nav"> <a href="https://toqito.readthedocs.io/en/latest/">Documentation</a> <a href="https://toqito.readthedocs.io/en/latest/tutorials.html">Tutorial</a> <a href="https://toqito.readthedocs.io/en/latest/getting_started.html">Install</a> <a href="https://vprusso.github.io/toqito_slides/">Slides</a> </div> </div> <div class="grid-x grid-margin-x section-2"> <div class="medium-7 small-12"> <p class="pitch"><b>toqito</b> is an open source Python library for studying various objects in quantum information. </div> <div class="medium-1"></div> <div class="medium-4 small-12"> <a href="https://github.com/vprusso/toqito" class="button medium expanded"> <i class="fab fa-github"></i> GitHub Repository </a> <a href="https://toqito.readthedocs.io/en/latest/" class="button medium expanded"> Read The User Guide </a> </div> </div> <div class="grid-x grid-padding-x"> <div class="features medium-3 small-12"> <ul> <div class="grid-x grid-padding-x"> <div class="medium-11 small-6"> <li>Estimate quantum and classical values of nonlocal games.</li> <li>Optimizations for quantum state distinguishability scenarios.</li> <li>Functions for exploring measures of entanglement and entangled states.</li> <li>Perform operations on and determine properties of quantum states, channels, and measurements.</li> </div> <div class="medium-2"></div> <div class="medium-11 small-6"> <li>Support for generating random quantum states and measurement operators.</li> <li>Pure Python module that easily integrates into existing projects.</li> </div> </div> </ul> </div> <div class="medium-1"></div> <div class="medium-8 small-12"> <pre><code class="python">>>> # Calculate the classical and quantum value of the CHSH game. >>> import numpy as np >>> from toqito.nonlocal_games.xor_game import XORGame >>> >>> # The probability matrix. >>> prob_mat = np.array([[1/4, 1/4], [1/4, 1/4]]) >>> >>> # The predicate matrix. >>> pred_mat = np.array([[0, 0], [0, 1]]) >>> >>> # Define CHSH game from matrices. >>> chsh = XORGame(prob_mat, pred_mat) >>> >>> chsh.classical_value() 0.75 >>> chsh.quantum_value() 0.8535533 </code></pre> </div> </div> </div> <div class="small-1"> <!-- GUTTER --> </div> </div> </div> <script defer src="https://use.fontawesome.com/releases/v5.0.9/js/all.js" integrity="sha384-8iPTk2s/jMVj81dnzb/iFR2sdA7u06vHJyyLlAd4snFpCl/SnyUjRrbdJsw1pGIl" crossorigin="anonymous"></script> <link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/highlight.js/10.0.2/styles/default.min.css"> <script src="//cdnjs.cloudflare.com/ajax/libs/highlight.js/10.0.2/highlight.min.js"></script> <script> hljs.initHighlightingOnLoad(); </script> </body> </html>
vprusso/vprusso.github.io
toqito/index.html
HTML
gpl-2.0
6,024
Introduction ============ This project provides three related components: 1. Artist credit recording mapping which chooses the earliest digital releases from MusicBrainz and then creates a table with the first instance of any (artist_credit, recording_name) and maps it to the MBIDs from which it originated. This index is useful for resolving ListenBrainz listens where we may only have an artist name and a recording name onto sane MusicBrainz release that would be a reasonable choice for what users might expect. 2. The same mapping as above, but focused on having the very first release of any given (artist_credit, recording_name) so that it can be used to find the first release year of that pair. 3. A typesense index that takes the data from #1 and generates an index that can be used to quickly and fuzzily look up data from the table in #1. This index will serve as the official "MusicBrainz mapping". Creating mappings and running tests ----------------------------------- You will need to have a copy of [musicbrainz-docker](https://github.com/metabrainz/musicbrainz-docker) installed and running in order to run these commands. To build the docker image for the mapping tools: ``` cp config.py.sample config.py ./build.sh ``` config.py may need tweaking, depending on your setup. Then to access the manage.py command that is used to invoke the various functions, do: ```docker run --rm -it --network musicbrainzdocker_default metabrainz/mbid-mapping python3 manage.py``` To create the MusicBrainz MBID mapping run: ```manage.py mbid-mapping``` To create the MusicBrainz year mapping run: ```manage.py year-mapping``` Creating a typesense index for searching the mapping ---------------------------------------------------- If you plan to create a typesense index, you'll need typesense installed. First set an API KEY in config.py, then run: ``` docker run -p 8108:8108 -d -v <some_data_dir_for_typesense>/data --name=typesense --network=musicbrainzdocker_default typesense/typesense:0.17.0 --data-dir /data --api-key=<the api key> ``` To create the typesense index: ```manage.py build-index``` To test searching the index: ```manage.py search sun shines tv``` To run the mapping tests: ```manage.py test-mapping```
Freso/listenbrainz-server
listenbrainz/mbid_mapping/README.md
Markdown
gpl-2.0
2,262
using System; using System.Collections; using Server; using Server.Mobiles; using Server.Items; using Server.Gumps; using MC = Server.MegaSpawnerSystem.MasterControl; namespace Server.MegaSpawnerSystem { public class RemoveEmptySpawnersGump : Gump { private ArrayList ArgsList = new ArrayList(); private string FileName; private ArrayList MSGCheckBoxesList = new ArrayList(); private ArrayList PersonalConfigList = new ArrayList(); private StyleType StyleTypeConfig; private BackgroundType BackgroundTypeConfig; private TextColor DefaultTextColor, TitleTextColor; private string MessagesTitle, Messages; private string defaultTextColor, titleTextColor; private Mobile gumpMobile; public static void Initialize() { string helpDesc = "That plug-in will remove all spawners that do not have any entries."; MC.RegisterPlugIn( new MC.OnCommand( RemoveEmptySpawners ), "RemoveEmptySpawners", "Remove All Empty Spawners", helpDesc ); } public static void RemoveEmptySpawners( Mobile mobile, ArrayList argsList ) { mobile.SendGump( new RemoveEmptySpawnersGump( mobile, argsList ) ); } public RemoveEmptySpawnersGump( Mobile mobile, ArrayList argsList ) : base( 0,0 ) { gumpMobile = mobile; ArgsList = argsList; GetArgsList(); GetTextColors(); AddPage(0); // Page 0 MC.DisplayStyle( this, StyleTypeConfig, 180, 180, 380, 110 ); MC.DisplayBackground( this, BackgroundTypeConfig, 200, 200, 340, 40 ); MC.DisplayBackground( this, BackgroundTypeConfig, 200, 250, 340, 20 ); AddHtml( 221, 181, 320, 20, MC.ColorText( titleTextColor, "Confirmation Of Deleting Empty Spawners" ), false, false ); AddHtml( 201, 201, 340, 40, MC.ColorText( defaultTextColor, "Are you sure you want to delete all empty spawners on the entire server?" ), false, false ); AddHtml( 491, 251, 60, 20, MC.ColorText( defaultTextColor, "Cancel" ), false, false ); AddButton( 450, 250, 4017, 4019, 0, GumpButtonType.Reply, 0 ); AddHtml( 241, 251, 60, 20, MC.ColorText( defaultTextColor, "Ok" ), false, false ); AddButton( 200, 250, 4023, 4025, 1, GumpButtonType.Reply, 0 ); } public override void OnResponse( Server.Network.NetState sender, RelayInfo info ) { switch ( info.ButtonID ) { case 0: // Close Gump { MessagesTitle = "Delete Empty Spawners"; Messages = "You have chosen not to delete all empty spawners on the entire server."; SetArgsList(); gumpMobile.SendGump( new PlugInsGump( gumpMobile, ArgsList ) ); break; } case 1: // Delete Empty Spawners { int count = 0; for ( int i = 0; i < MC.SpawnerList.Count; i++ ) { MegaSpawner megaSpawner = (MegaSpawner) MC.SpawnerList[i]; if ( megaSpawner.EntryList.Count == 0 ) { count++; megaSpawner.Delete(); } } MessagesTitle = "Delete Empty Spawners"; if ( count > 0 ) Messages = String.Format( "{0} empty Mega Spawner{1} been deleted.", count, count == 1 ? " has" : "s have" ); else Messages = "There are no empty Mega Spawners on the entire server."; SetArgsList(); ArgsList[34] = (bool) true; // RefreshSpawnerLists gumpMobile.SendGump( new PlugInsGump( gumpMobile, ArgsList ) ); break; } } } private void SetArgsList() { ArgsList[2] = MessagesTitle; ArgsList[4] = Messages; ArgsList[13] = MSGCheckBoxesList; } private void GetArgsList() { MessagesTitle = (string) ArgsList[2]; Messages = (string) ArgsList[4]; MSGCheckBoxesList = (ArrayList) ArgsList[13]; PersonalConfigList = (ArrayList) ArgsList[28]; StyleTypeConfig = (StyleType) PersonalConfigList[0]; BackgroundTypeConfig = (BackgroundType) PersonalConfigList[1]; DefaultTextColor = (TextColor) PersonalConfigList[4]; TitleTextColor = (TextColor) PersonalConfigList[5]; } private void GetTextColors() { defaultTextColor = MC.GetTextColor( DefaultTextColor ); titleTextColor = MC.GetTextColor( TitleTextColor ); } } }
alucardxlx/kaltar
Mega Spawner/Plug-Ins/RemoveEmptySpawnersGump.cs
C#
gpl-2.0
4,208
This program creates a 5 bit simple decoder that prints out hexadecimal for the first 16 binary values and then parts of the alphabet for the next 16 binary values. It is a simple truth table that can be burned into a PLD.
scyphi/abel
Simple Decoder/README.md
Markdown
gpl-2.0
224
<!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"> <head> <title>CRAN - Package highfrequency</title> <link rel="stylesheet" type="text/css" href="../../CRAN_web.css" /> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <style type="text/css"> table td { vertical-align: top; } </style> </head> <body> <h2>highfrequency: Tools for Highfrequency Data Analysis</h2> <p>Provide functionality to manage, clean and match highfrequency trades and quotes data, calculate various liquidity measures, estimate and forecast volatility, and investigate microstructure noise and intraday periodicity.</p> <table summary="Package highfrequency summary"> <tr> <td>Version:</td> <td>0.5</td> </tr> <tr> <td>Depends:</td> <td>R (&ge; 2.12.0), <a href="../xts/index.html">xts</a>, <a href="../zoo/index.html">zoo</a></td> </tr> <tr> <td>Imports:</td> <td>graphics, methods, stats, utils, grDevices, <a href="../numDeriv/index.html">numDeriv</a>, <a href="../sandwich/index.html">sandwich</a>, <a href="../robustbase/index.html">robustbase</a>, <a href="../cubature/index.html">cubature</a>, <a href="../mvtnorm/index.html">mvtnorm</a>, <a href="../chron/index.html">chron</a>, <a href="../timeDate/index.html">timeDate</a>, <a href="../quantmod/index.html">quantmod</a>, <a href="../MASS/index.html">MASS</a>, <a href="../FKF/index.html">FKF</a>, <a href="../BMS/index.html">BMS</a>, <a href="../rugarch/index.html">rugarch</a></td> </tr> <tr> <td>Published:</td> <td>2017-02-15</td> </tr> <tr> <td>Author:</td> <td>Kris Boudt [aut, cre], Jonathan Cornelissen [aut], Scott Payseur [aut], Giang Nguyen [ctb], Maarten Schermer [ctb]</td> </tr> <tr> <td>Maintainer:</td> <td>Kris Boudt &#x3c;&#x4b;&#x72;&#x69;&#x73;&#x2e;&#x42;&#x6f;&#x75;&#x64;&#x74;&#x20;&#x61;&#x74;&#x20;&#x65;&#x63;&#x6f;&#x6e;&#x2e;&#x6b;&#x75;&#x6c;&#x65;&#x75;&#x76;&#x65;&#x6e;&#x2e;&#x62;&#x65;&#x3e;</td> </tr> <tr> <td>License:</td> <td><a href="../../licenses/GPL-2">GPL-2</a> | <a href="../../licenses/GPL-3">GPL-3</a> [expanded from: GPL (&ge; 2)]</td> </tr> <tr> <td>NeedsCompilation:</td> <td>yes</td> </tr> <tr> <td>In&nbsp;views:</td> <td><a href="../../views/Finance.html">Finance</a></td> </tr> <tr> <td>CRAN&nbsp;checks:</td> <td><a href="../../checks/check_results_highfrequency.html">highfrequency results</a></td> </tr> </table> <h4>Downloads:</h4> <table summary="Package highfrequency downloads"> <tr> <td> Reference&nbsp;manual: </td> <td> <a href="highfrequency.pdf"> highfrequency.pdf </a> </td> </tr> <tr> <td> Package&nbsp;source: </td> <td> <a href="../../../src/contrib/highfrequency_0.5.tar.gz"> highfrequency_0.5.tar.gz </a> </td> </tr> <tr> <td> Windows&nbsp;binaries: </td> <td> r-devel: <a href="../../../bin/windows/contrib/3.5/highfrequency_0.5.zip">highfrequency_0.5.zip</a>, r-release: <a href="../../../bin/windows/contrib/3.4/highfrequency_0.5.zip">highfrequency_0.5.zip</a>, r-oldrel: <a href="../../../bin/windows/contrib/3.3/highfrequency_0.5.zip">highfrequency_0.5.zip</a> </td> </tr> <tr> <td> OS&nbsp;X&nbsp;El&nbsp;Capitan&nbsp;binaries: </td> <td> r-release: <a href="../../../bin/macosx/el-capitan/contrib/3.4/highfrequency_0.5.tgz">highfrequency_0.5.tgz</a> </td> </tr> <tr> <td> OS&nbsp;X&nbsp;Mavericks&nbsp;binaries: </td> <td> r-oldrel: <a href="../../../bin/macosx/mavericks/contrib/3.3/highfrequency_0.5.tgz">highfrequency_0.5.tgz</a> </td> </tr> <tr> <td> Old&nbsp;sources: </td> <td> <a href="../../../src/contrib/Archive/highfrequency"> highfrequency archive </a> </td> </tr> </table> <h4>Linking:</h4> <p>Please use the canonical form <a href="https://CRAN.R-project.org/package=highfrequency"><samp>https://CRAN.R-project.org/package=highfrequency</samp></a> to link to this page.</p> </body> </html>
esander91/NamespacePollution
Code/GetMetaDataFromCRAN/raw_html/highfrequency.html
HTML
gpl-2.0
3,857
package com.frm.bdTask.controls; /** * @author: Larry Pham. * @since: 3/24/2014. * @version: 2014.03.24. */ public class ListTodosActivityControl { }
PhamPhi/birdy_task
src/com/frm/bdTask/controls/ListTodosActivityControl.java
Java
gpl-2.0
155
.version.navigate_3_fields /* version checker */ { color: #00000D; background-color: #63D21E; } #page { z-index: 1; width: 962px; margin-left: auto; margin-right: auto; } ._page.f3s_top { background-image: url("/images/page-sprite4.png"); width: 962px; overflow: hidden; height: 7px; background-position: left top; } ._page.f3s_mid { background-image: url("/images/page-sprite4.png"); overflow: visible; background-position: -962px top; width: 962px; min-height: 537px; padding-bottom: 0px; } ._page.f3s_bot { background-image: url("/images/page-sprite4.png"); width: 962px; overflow: visible; height: 7px; background-position: -1924px top; } #page_position_content { margin-top: -87px; padding-bottom: 41px; } #pu14002-4 { width: 0.01px; margin-left: 24px; } #u14002-4 { z-index: 296; width: 148px; min-height: 15px; margin-right: -10000px; margin-top: 41px; left: 266px; } #u14002-4:hover { padding-top: 0px; padding-bottom: 0px; min-height: 15px; margin: 41px -10000px 0px 0px; } #menuu14003 { z-index: 300; width: 133px; margin-right: -10000px; margin-top: 36px; left: 410px; } #u14021 { width: 133px; min-height: 35px; margin-right: -10000px; } #u14052 { width: 133px; padding-bottom: 11px; } #u14052:hover { margin: 0px; } #u14052:active { margin: 0px; } #u14054-4 { width: 119px; min-height: 24px; margin-right: -10000px; top: 5px; } #u14052:hover #u14054-4 { padding-top: 0px; padding-bottom: 0px; min-height: 24px; margin: 0px -10000px 0px 0px; } #u14052:active #u14054-4 { padding-top: 0px; padding-bottom: 0px; min-height: 24px; margin: 0px -10000px 0px 0px; } #u14052.MuseMenuActive #u14054-4 { padding-top: 0px; padding-bottom: 0px; min-height: 24px; margin: 0px -10000px 0px 0px; } #u14055 { z-index: 307; width: 14px; height: 14px; margin-right: -10000px; top: 10px; left: 119px; } .ie #u14055 { background-color: #FFFFFF; opacity: 0.01; -ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=1)"; filter: alpha(opacity=1); } #u14052:hover #u14055 { margin: 0px -10000px 0px 0px; } .ie #u14052:hover #u14055 { background-color: #FFFFFF; opacity: 0.01; -ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=1)"; filter: alpha(opacity=1); } #u14052:active #u14055 { margin: 0px -10000px 0px 0px; } .ie #u14052:active #u14055 { background-color: #FFFFFF; opacity: 0.01; -ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=1)"; filter: alpha(opacity=1); } #u14052.MuseMenuActive #u14055 { margin: 0px -10000px 0px 0px; } .ie #u14052.MuseMenuActive #u14055 { background-color: #FFFFFF; opacity: 0.01; -ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=1)"; filter: alpha(opacity=1); } #u14022 { width: 122px; top: 35px; } #u14023 { width: 122px; padding-top: 1px; } #u14052.MuseMenuActive,#u14023:hover { margin: 0px; } #u14031 { width: 122px; } #u14032 { width: 122px; padding-bottom: 16px; margin-right: -10000px; } #u14032:hover { margin: 0px -10000px 0px 0px; } #u14033-4 { width: 114px; min-height: 19px; padding-left: 2px; padding-top: 4px; padding-right: 2px; margin-right: -10000px; top: 8px; left: 2px; } #u14032:hover #u14033-4 { padding-top: 4px; padding-bottom: 0px; min-height: 19px; margin: 0px -10000px 0px 0px; } #u14032:active #u14033-4 { padding-top: 4px; padding-bottom: 0px; min-height: 19px; margin: 0px -10000px 0px 0px; } #u14039 { width: 122px; padding-bottom: 10px; margin-right: -10000px; } #u14032.MuseMenuActive,#u14039:hover { margin: 0px -10000px 0px 0px; } #u14042-4 { width: 114px; min-height: 19px; padding-left: 2px; padding-top: 4px; padding-right: 2px; margin-right: -10000px; top: 5px; left: 2px; } #u14032.MuseMenuActive #u14033-4,#u14039:hover #u14042-4 { padding-top: 4px; padding-bottom: 0px; min-height: 19px; margin: 0px -10000px 0px 0px; } #u14039:active #u14042-4 { padding-top: 4px; padding-bottom: 0px; min-height: 19px; margin: 0px -10000px 0px 0px; } #u14027 { width: 122px; padding-bottom: 8px; margin-right: -10000px; } #u14039.MuseMenuActive,#u14027:hover { margin: 0px -10000px 0px 0px; } #u14029-4 { width: 114px; min-height: 19px; padding-left: 2px; padding-top: 4px; padding-right: 2px; margin-right: -10000px; top: 4px; left: 2px; } #u14039.MuseMenuActive #u14042-4,#u14027:hover #u14029-4 { padding-top: 4px; padding-bottom: 0px; min-height: 19px; margin: 0px -10000px 0px 0px; } #u14027:active #u14029-4 { padding-top: 4px; padding-bottom: 0px; min-height: 19px; margin: 0px -10000px 0px 0px; } #u14038,#u14024,#u14045 { width: 122px; margin-top: 3px; } #u14048 { width: 122px; padding-bottom: 10px; margin-right: -10000px; } #u14027.MuseMenuActive,#u14048:hover { margin: 0px -10000px 0px 0px; } #u14050-4 { width: 114px; min-height: 19px; padding-left: 2px; padding-top: 4px; padding-right: 2px; margin-right: -10000px; top: 5px; left: 2px; } #u14027.MuseMenuActive #u14029-4,#u14048:hover #u14050-4 { padding-top: 4px; padding-bottom: 0px; min-height: 19px; margin: 0px -10000px 0px 0px; } #u14048:active #u14050-4 { padding-top: 4px; padding-bottom: 0px; min-height: 19px; margin: 0px -10000px 0px 0px; } #u14048.MuseMenuActive #u14050-4 { padding-top: 4px; padding-bottom: 0px; min-height: 19px; margin: 0px -10000px 0px 0px; } #u19910 { z-index: 359; width: 212px; margin-right: -10000px; } #pu10003 { width: 0.01px; margin-left: -99px; margin-top: -1px; } #u10003 { z-index: 2; height: 41px; } #u10003-bw { z-index: 2; height: 43px; } #u10004 { z-index: 3; height: 12px; } #u10004-bw { z-index: 3; margin-top: 42px; height: 12px; } #u14057-4 { z-index: 334; width: 148px; min-height: 15px; margin-right: -10000px; margin-top: 21px; left: 319px; } #u14057-4:hover { padding-top: 0px; padding-bottom: 0px; min-height: 15px; margin: 21px -10000px 0px 0px; } #u14058-4 { z-index: 338; width: 180px; min-height: 15px; margin-right: -10000px; margin-top: 21px; left: 509px; } #u14057-4.MuseLinkActive,#u14058-4:hover { padding-top: 0px; padding-bottom: 0px; min-height: 15px; margin: 21px -10000px 0px 0px; } #u14059-4 { z-index: 342; width: 80px; min-height: 15px; margin-right: -10000px; margin-top: 21px; left: 730px; } #u14058-4.MuseLinkActive,#u14059-4:hover { padding-top: 0px; padding-bottom: 0px; min-height: 15px; margin: 21px -10000px 0px 0px; } #u14060-4 { z-index: 346; width: 111px; min-height: 15px; margin-right: -10000px; margin-top: 21px; left: 852px; } #u14059-4.MuseLinkActive,#u14060-4:hover { padding-top: 0px; padding-bottom: 0px; min-height: 15px; margin: 21px -10000px 0px 0px; } #u14061-4 { z-index: 350; width: 56px; min-height: 15px; margin-right: -10000px; margin-top: 21px; left: 1004px; } #u14060-4.MuseLinkActive,#u14061-4:hover { padding-top: 0px; padding-bottom: 0px; min-height: 15px; margin: 21px -10000px 0px 0px; } #u14061-4.MuseLinkActive { padding-top: 0px; padding-bottom: 0px; min-height: 15px; margin: 21px -10000px 0px 0px; } #u15533 { z-index: 354; margin-bottom: -32px; width: 132px; margin-right: -10000px; margin-top: -27px; left: 199px; } #pu10006-3 { width: 0.01px; margin-left: -30px; margin-top: 11px; } #u10006-3 { z-index: 4; width: 4px; min-height: 5px; margin-right: -10000px; margin-top: 43px; } #menuu10124 { z-index: 7; width: 131px; margin-right: -10000px; margin-top: 46px; left: 54px; } #u10289 { width: 131px; } #u10362 { width: 131px; min-height: 17px; padding-bottom: 11px; margin-right: -10000px; } #u14048.MuseMenuActive,#u10362:hover { margin: 0px -10000px 0px 0px; } #u10362:active { margin: 0px -10000px 0px 0px; } #u10365-4 { width: 131px; min-height: 17px; margin-right: -10000px; top: 5px; } #u10362:hover #u10365-4 { padding-top: 0px; padding-bottom: 0px; min-height: 17px; margin: 0px -10000px 0px 0px; } #u10362:active #u10365-4 { padding-top: 0px; padding-bottom: 0px; min-height: 17px; margin: 0px -10000px 0px 0px; } #u10335 { width: 115px; padding-bottom: 5px; margin-right: -10000px; } #u10335:hover { width: 114px; min-height: 0px; margin: 0px -10001px -1px 0px; } #u10338-4 { width: 107px; min-height: 13px; padding-left: 2px; padding-top: 4px; padding-right: 2px; margin-right: -10000px; top: 2px; left: 2px; } #u10335:hover #u10338-4 { padding-top: 4px; padding-bottom: 0px; min-height: 13px; margin: 0px -10000px 0px 0px; } #u10309 { width: 115px; padding-bottom: 5px; margin-right: -10000px; } #u10309:hover { width: 114px; min-height: 0px; margin: 0px -10001px -1px 0px; } #u10312-4 { width: 107px; min-height: 14px; padding-left: 2px; padding-top: 4px; padding-right: 2px; margin-right: -10000px; top: 2px; left: 2px; } #u10309:hover #u10312-4 { padding-top: 4px; padding-bottom: 0px; min-height: 14px; margin: 0px -10000px 0px 0px; } #u10321 { width: 115px; padding-bottom: 5px; margin-right: -10000px; } #u10321:hover { width: 114px; min-height: 0px; margin: 0px -10001px -1px 0px; } #u10323-4 { width: 107px; min-height: 14px; padding-left: 2px; padding-top: 4px; padding-right: 2px; margin-right: -10000px; top: 2px; left: 2px; } #u10309.MuseMenuActive #u10312-4,#u10321:hover #u10323-4 { padding-top: 4px; padding-bottom: 0px; min-height: 14px; margin: 0px -10000px 0px 0px; } #u10314 { width: 115px; padding-bottom: 5px; margin-right: -10000px; } #u10314:hover { width: 114px; min-height: 0px; margin: 0px -10001px -1px 0px; } #u10317-4 { width: 107px; min-height: 14px; padding-left: 2px; padding-top: 4px; padding-right: 2px; margin-right: -10000px; top: 2px; left: 2px; } #u10321.MuseMenuActive #u10323-4,#u10314:hover #u10317-4 { padding-top: 4px; padding-bottom: 0px; min-height: 14px; margin: 0px -10000px 0px 0px; } #u10342 { width: 115px; padding-bottom: 5px; margin-right: -10000px; } #u10342:hover { width: 114px; min-height: 0px; margin: 0px -10001px -1px 0px; } #u10344-4 { width: 107px; min-height: 14px; padding-left: 2px; padding-top: 4px; padding-right: 2px; margin-right: -10000px; top: 2px; left: 2px; } #u10314.MuseMenuActive #u10317-4,#u10342:hover #u10344-4 { padding-top: 4px; padding-bottom: 0px; min-height: 14px; margin: 0px -10000px 0px 0px; } #u10295 { width: 115px; padding-bottom: 5px; margin-right: -10000px; } #u10295:hover { width: 114px; min-height: 0px; margin: 0px -10001px -1px 0px; } #u10297-4 { width: 107px; min-height: 14px; padding-left: 2px; padding-top: 4px; padding-right: 2px; margin-right: -10000px; top: 2px; left: 2px; } #u10342.MuseMenuActive #u10344-4,#u10295:hover #u10297-4 { padding-top: 4px; padding-bottom: 0px; min-height: 14px; margin: 0px -10000px 0px 0px; } #u10300 { width: 115px; padding-bottom: 5px; margin-right: -10000px; } #u10300:hover { width: 114px; min-height: 0px; margin: 0px -10001px -1px 0px; } #u10301-4 { width: 107px; min-height: 14px; padding-left: 2px; padding-top: 4px; padding-right: 2px; margin-right: -10000px; top: 2px; left: 2px; } #u10295.MuseMenuActive #u10297-4,#u10300:hover #u10301-4 { padding-top: 4px; padding-bottom: 0px; min-height: 14px; margin: 0px -10000px 0px 0px; } #u10328 { width: 115px; padding-bottom: 5px; margin-right: -10000px; } #u10328:hover { width: 114px; min-height: 0px; margin: 0px -10001px -1px 0px; } #u10331-4 { width: 107px; min-height: 14px; padding-left: 2px; padding-top: 4px; padding-right: 2px; margin-right: -10000px; top: 2px; left: 2px; } #u10300.MuseMenuActive #u10301-4,#u10328:hover #u10331-4 { padding-top: 4px; padding-bottom: 0px; min-height: 14px; margin: 0px -10000px 0px 0px; } #u10351 { width: 115px; padding-bottom: 5px; margin-right: -10000px; } #u10351:hover { width: 114px; min-height: 0px; margin: 0px -10001px -1px 0px; } #u10354-4 { width: 107px; min-height: 14px; padding-left: 2px; padding-top: 4px; padding-right: 2px; margin-right: -10000px; top: 2px; left: 2px; } #u10328.MuseMenuActive #u10331-4,#u10351:hover #u10354-4 { padding-top: 4px; padding-bottom: 0px; min-height: 14px; margin: 0px -10000px 0px 0px; } #u10358 { width: 115px; padding-bottom: 5px; margin-right: -10000px; } #u10358:hover { width: 114px; min-height: 0px; margin: 0px -10001px -1px 0px; } #u10360-4 { width: 107px; min-height: 14px; padding-left: 2px; padding-top: 4px; padding-right: 2px; margin-right: -10000px; top: 2px; left: 2px; } #u10351.MuseMenuActive #u10354-4,#u10358:hover #u10360-4 { padding-top: 4px; padding-bottom: 0px; min-height: 14px; margin: 0px -10000px 0px 0px; } #u10203 { width: 131px; min-height: 17px; padding-bottom: 12px; margin-right: -10000px; } #u10362.MuseMenuActive,#u10335.MuseMenuActive,#u10309.MuseMenuActive,#u10321.MuseMenuActive,#u10314.MuseMenuActive,#u10342.MuseMenuActive,#u10295.MuseMenuActive,#u10300.MuseMenuActive,#u10328.MuseMenuActive,#u10351.MuseMenuActive,#u10358.MuseMenuActive,#u10203:hover { margin: 0px -10000px 0px 0px; } #u10203:active { margin: 0px -10000px 0px 0px; } #u10206-4 { width: 131px; min-height: 17px; margin-right: -10000px; top: 6px; } #u10362.MuseMenuActive #u10365-4,#u10203:hover #u10206-4 { padding-top: 0px; padding-bottom: 0px; min-height: 17px; margin: 0px -10000px 0px 0px; } #u10203:active #u10206-4 { padding-top: 0px; padding-bottom: 0px; min-height: 17px; margin: 0px -10000px 0px 0px; } #u10212 { width: 115px; padding-bottom: 5px; margin-right: -10000px; } #u10212:hover { width: 114px; min-height: 0px; margin: 0px -10001px -1px 0px; } #u10215-4 { width: 107px; min-height: 14px; padding-left: 2px; padding-top: 4px; padding-right: 2px; margin-right: -10000px; top: 2px; left: 2px; } #u10358.MuseMenuActive #u10360-4,#u10212:hover #u10215-4 { padding-top: 4px; padding-bottom: 0px; min-height: 14px; margin: 0px -10000px 0px 0px; } #u10217 { width: 115px; padding-bottom: 5px; margin-right: -10000px; } #u10217:hover { width: 114px; min-height: 0px; margin: 0px -10001px -1px 0px; } #u10219-4 { width: 107px; min-height: 14px; padding-left: 2px; padding-top: 4px; padding-right: 2px; margin-right: -10000px; top: 2px; left: 2px; } #u10212.MuseMenuActive #u10215-4,#u10217:hover #u10219-4 { padding-top: 4px; padding-bottom: 0px; min-height: 14px; margin: 0px -10000px 0px 0px; } #u10163 { width: 131px; min-height: 17px; padding-bottom: 12px; margin-right: -10000px; } #u10203.MuseMenuActive,#u10212.MuseMenuActive,#u10217.MuseMenuActive,#u10163:hover { margin: 0px -10000px 0px 0px; } #u10163:active { margin: 0px -10000px 0px 0px; } #u10166-4 { width: 131px; min-height: 17px; margin-right: -10000px; top: 6px; } #u10203.MuseMenuActive #u10206-4,#u10163:hover #u10166-4 { padding-top: 0px; padding-bottom: 0px; min-height: 17px; margin: 0px -10000px 0px 0px; } #u10163:active #u10166-4 { padding-top: 0px; padding-bottom: 0px; min-height: 17px; margin: 0px -10000px 0px 0px; } #u10150 { width: 115px; padding-bottom: 5px; margin-right: -10000px; } #u10150:hover { width: 114px; min-height: 0px; margin: 0px -10001px -1px 0px; } #u10152-4 { width: 107px; min-height: 14px; padding-left: 2px; padding-top: 4px; padding-right: 2px; margin-right: -10000px; top: 2px; left: 2px; } #u10217.MuseMenuActive #u10219-4,#u10150:hover #u10152-4 { padding-top: 4px; padding-bottom: 0px; min-height: 14px; margin: 0px -10000px 0px 0px; } #u10157 { width: 116px; padding-bottom: 4px; margin-right: -10000px; } #u10157:hover { width: 116px; min-height: 0px; margin: 0px -10000px 0px 0px; } #u10160-4 { width: 108px; min-height: 13px; padding-left: 2px; padding-top: 4px; padding-right: 2px; margin-right: -10000px; top: 2px; left: 2px; } #u10335.MuseMenuActive #u10338-4,#u10157:hover #u10160-4 { padding-top: 4px; padding-bottom: 0px; min-height: 13px; margin: 0px -10000px 0px 0px; } #u16451 { width: 116px; padding-bottom: 4px; margin-right: -10000px; } #u10157.MuseMenuActive,#u16451:hover { width: 116px; min-height: 0px; margin: 0px -10000px 0px 0px; } #u16452-4 { width: 108px; min-height: 13px; padding-left: 2px; padding-top: 4px; padding-right: 2px; margin-right: -10000px; top: 2px; left: 2px; } #u10157.MuseMenuActive #u10160-4,#u16451:hover #u16452-4 { padding-top: 4px; padding-bottom: 0px; min-height: 13px; margin: 0px -10000px 0px 0px; } #u16456 { width: 116px; padding-bottom: 4px; margin-right: -10000px; } #u16451.MuseMenuActive,#u16456:hover { width: 116px; min-height: 0px; margin: 0px -10000px 0px 0px; } #u16459-4 { width: 108px; min-height: 13px; padding-left: 2px; padding-top: 4px; padding-right: 2px; margin-right: -10000px; top: 2px; left: 2px; } #u16451.MuseMenuActive #u16452-4,#u16456:hover #u16459-4 { padding-top: 4px; padding-bottom: 0px; min-height: 13px; margin: 0px -10000px 0px 0px; } #u10129 { width: 115px; padding-bottom: 5px; margin-right: -10000px; } #u10129:hover { width: 114px; min-height: 0px; margin: 0px -10001px -1px 0px; } #u10130-4 { width: 107px; min-height: 14px; padding-left: 2px; padding-top: 4px; padding-right: 2px; margin-right: -10000px; top: 2px; left: 2px; } #u10150.MuseMenuActive #u10152-4,#u10129:hover #u10130-4 { padding-top: 4px; padding-bottom: 0px; min-height: 14px; margin: 0px -10000px 0px 0px; } #u10129.MuseMenuActive #u10130-4 { padding-top: 4px; padding-bottom: 0px; min-height: 14px; margin: 0px -10000px 0px 0px; } #u10155,#u10134 { width: 118px; padding-left: 2px; } #u10156,#u16448,#u16455,#u10142 { width: 118px; } #u10145 { width: 116px; padding-bottom: 4px; margin-right: -10000px; } #u16456.MuseMenuActive,#u10145:hover { width: 116px; min-height: 0px; margin: 0px -10000px 0px 0px; } #u10148-4 { width: 108px; min-height: 13px; padding-left: 2px; padding-top: 4px; padding-right: 2px; margin-right: -10000px; top: 2px; left: 2px; } #u16456.MuseMenuActive #u16459-4,#u10145:hover #u10148-4 { padding-top: 4px; padding-bottom: 0px; min-height: 13px; margin: 0px -10000px 0px 0px; } #u10135 { width: 118px; margin-top: 2px; } #u10136 { width: 116px; padding-bottom: 4px; margin-right: -10000px; } #u10145.MuseMenuActive,#u10136:hover { width: 116px; min-height: 0px; margin: 0px -10000px 0px 0px; } #u10136.MuseMenuActive { width: 116px; min-height: 0px; margin: 0px -10000px 0px 0px; } #u10137-4 { width: 108px; min-height: 13px; padding-left: 2px; padding-top: 4px; padding-right: 2px; margin-right: -10000px; top: 2px; left: 2px; } #u10145.MuseMenuActive #u10148-4,#u10136:hover #u10137-4 { padding-top: 4px; padding-bottom: 0px; min-height: 13px; margin: 0px -10000px 0px 0px; } #u10168 { width: 131px; min-height: 17px; padding-bottom: 12px; margin-right: -10000px; } #u10163.MuseMenuActive,#u10150.MuseMenuActive,#u10129.MuseMenuActive,#u10168:hover { margin: 0px -10000px 0px 0px; } #u10168:active { margin: 0px -10000px 0px 0px; } #u10171-4 { width: 131px; min-height: 17px; margin-right: -10000px; top: 6px; } #u10163.MuseMenuActive #u10166-4,#u10168:hover #u10171-4 { padding-top: 0px; padding-bottom: 0px; min-height: 17px; margin: 0px -10000px 0px 0px; } #u10168:active #u10171-4 { padding-top: 0px; padding-bottom: 0px; min-height: 17px; margin: 0px -10000px 0px 0px; } #u10175 { width: 115px; padding-bottom: 7px; margin-right: -10000px; } #u10175:hover { width: 114px; min-height: 0px; margin: 0px -10001px -1px 0px; } #u10178-4 { width: 107px; min-height: 14px; padding: 2px; margin-right: -10000px; top: 3px; left: 2px; } #u10175:hover #u10178-4 { padding-top: 2px; padding-bottom: 2px; min-height: 14px; margin: 0px -10000px 0px 0px; } #u10180 { width: 116px; padding: 2px; } #u10180:hover { width: 115px; min-height: 0px; margin: 0px -1px -1px 0px; } #u16490 { width: 116px; } #u16491 { width: 114px; padding-bottom: 4px; margin-right: -10000px; } #u16491:hover { width: 114px; min-height: 0px; margin: 0px -10000px 0px 0px; } #u16493-4 { width: 106px; min-height: 13px; padding-left: 2px; padding-top: 4px; padding-right: 2px; margin-right: -10000px; top: 2px; left: 2px; } #u10136.MuseMenuActive #u10137-4,#u16491:hover #u16493-4 { padding-top: 4px; padding-bottom: 0px; min-height: 13px; margin: 0px -10000px 0px 0px; } #u16503 { width: 114px; padding-bottom: 4px; margin-right: -10000px; } #u16491.MuseMenuActive,#u16503:hover { width: 114px; min-height: 0px; margin: 0px -10000px 0px 0px; } #u16504-4 { width: 106px; min-height: 13px; padding-left: 2px; padding-top: 4px; padding-right: 2px; margin-right: -10000px; top: 2px; left: 2px; } #u16491.MuseMenuActive #u16493-4,#u16503:hover #u16504-4 { padding-top: 4px; padding-bottom: 0px; min-height: 13px; margin: 0px -10000px 0px 0px; } #u16500,#u16507 { width: 116px; margin-top: 1px; } #u16508 { width: 114px; padding-bottom: 4px; margin-right: -10000px; } #u16503.MuseMenuActive,#u16508:hover { width: 114px; min-height: 0px; margin: 0px -10000px 0px 0px; } #u16508.MuseMenuActive { width: 114px; min-height: 0px; margin: 0px -10000px 0px 0px; } #u16511-4 { width: 106px; min-height: 13px; padding-left: 2px; padding-top: 4px; padding-right: 2px; margin-right: -10000px; top: 2px; left: 2px; } #u16503.MuseMenuActive #u16504-4,#u16508:hover #u16511-4 { padding-top: 4px; padding-bottom: 0px; min-height: 13px; margin: 0px -10000px 0px 0px; } #u10191 { width: 115px; padding-bottom: 6px; margin-right: -10000px; } #u10191:hover { width: 114px; min-height: 0px; margin: 0px -10001px -1px 0px; } #u10194-4 { width: 107px; min-height: 14px; padding: 2px; margin-right: -10000px; top: 3px; left: 2px; } #u10175.MuseMenuActive #u10178-4,#u10191:hover #u10194-4 { padding-top: 2px; padding-bottom: 2px; min-height: 14px; margin: 0px -10000px 0px 0px; } #u16517 { width: 115px; padding-bottom: 4px; margin-right: -10000px; } #u16517:hover { width: 115px; min-height: 0px; margin: 0px -10000px 0px 0px; } #u16519-4 { width: 107px; min-height: 13px; padding-left: 2px; padding-top: 4px; padding-right: 2px; margin-right: -10000px; top: 2px; left: 2px; } #u16508.MuseMenuActive #u16511-4,#u16517:hover #u16519-4 { padding-top: 4px; padding-bottom: 0px; min-height: 13px; margin: 0px -10000px 0px 0px; } #u16524 { width: 115px; padding-bottom: 4px; margin-right: -10000px; } #u16517.MuseMenuActive,#u16524:hover { width: 115px; min-height: 0px; margin: 0px -10000px 0px 0px; } #u16527-4 { width: 107px; min-height: 13px; padding-left: 2px; padding-top: 4px; padding-right: 2px; margin-right: -10000px; top: 2px; left: 2px; } #u16517.MuseMenuActive #u16519-4,#u16524:hover #u16527-4 { padding-top: 4px; padding-bottom: 0px; min-height: 13px; margin: 0px -10000px 0px 0px; } #u16545 { width: 115px; padding-bottom: 4px; margin-right: -10000px; } #u16524.MuseMenuActive,#u16545:hover { width: 115px; min-height: 0px; margin: 0px -10000px 0px 0px; } #u16548-4 { width: 107px; min-height: 13px; padding-left: 2px; padding-top: 4px; padding-right: 2px; margin-right: -10000px; top: 2px; left: 2px; } #u16524.MuseMenuActive #u16527-4,#u16545:hover #u16548-4 { padding-top: 4px; padding-bottom: 0px; min-height: 13px; margin: 0px -10000px 0px 0px; } #u16538 { width: 115px; padding-bottom: 4px; margin-right: -10000px; } #u16545.MuseMenuActive,#u16538:hover { width: 115px; min-height: 0px; margin: 0px -10000px 0px 0px; } #u16541-4 { width: 107px; min-height: 13px; padding-left: 2px; padding-top: 4px; padding-right: 2px; margin-right: -10000px; top: 2px; left: 2px; } #u16545.MuseMenuActive #u16548-4,#u16538:hover #u16541-4 { padding-top: 4px; padding-bottom: 0px; min-height: 13px; margin: 0px -10000px 0px 0px; } #u10184 { width: 115px; padding-bottom: 7px; margin-right: -10000px; } #u10184:hover { width: 114px; min-height: 0px; margin: 0px -10001px -1px 0px; } #u10186-4 { width: 107px; min-height: 14px; padding: 2px; margin-right: -10000px; top: 3px; left: 2px; } #u10191.MuseMenuActive #u10194-4,#u10184:hover #u10186-4 { padding-top: 2px; padding-bottom: 2px; min-height: 14px; margin: 0px -10000px 0px 0px; } #u16463 { width: 131px; min-height: 17px; padding-bottom: 12px; margin-right: -10000px; } #u10168.MuseMenuActive,#u10175.MuseMenuActive,#u10191.MuseMenuActive,#u10184.MuseMenuActive,#u16463:hover { margin: 0px -10000px 0px 0px; } #u16463:active { margin: 0px -10000px 0px 0px; } #u16465-4 { width: 131px; min-height: 17px; margin-right: -10000px; top: 6px; } #u10168.MuseMenuActive #u10171-4,#u16463:hover #u16465-4 { padding-top: 0px; padding-bottom: 0px; min-height: 17px; margin: 0px -10000px 0px 0px; } #u16463:active #u16465-4 { padding-top: 0px; padding-bottom: 0px; min-height: 17px; margin: 0px -10000px 0px 0px; } #u16479 { width: 115px; padding-bottom: 7px; margin-right: -10000px; } #u16479:hover { width: 114px; min-height: 0px; margin: 0px -10001px -1px 0px; } #u16482-4 { width: 107px; min-height: 14px; padding: 2px; margin-right: -10000px; top: 3px; left: 2px; } #u10184.MuseMenuActive #u10186-4,#u16479:hover #u16482-4 { padding-top: 2px; padding-bottom: 2px; min-height: 14px; margin: 0px -10000px 0px 0px; } #u16470 { width: 115px; padding-bottom: 6px; margin-right: -10000px; } #u16470:hover { width: 114px; min-height: 0px; margin: 0px -10001px -1px 0px; } #u16473-4 { width: 107px; min-height: 14px; padding: 2px; margin-right: -10000px; top: 3px; left: 2px; } #u16479.MuseMenuActive #u16482-4,#u16470:hover #u16473-4 { padding-top: 2px; padding-bottom: 2px; min-height: 14px; margin: 0px -10000px 0px 0px; } #u16470.MuseMenuActive #u16473-4 { padding-top: 2px; padding-bottom: 2px; min-height: 14px; margin: 0px -10000px 0px 0px; } #u10250 { width: 131px; min-height: 17px; padding-bottom: 12px; margin-right: -10000px; } #u16463.MuseMenuActive,#u16479.MuseMenuActive,#u16470.MuseMenuActive,#u10250:hover { margin: 0px -10000px 0px 0px; } #u10250:active { margin: 0px -10000px 0px 0px; } #u10252-4 { width: 131px; min-height: 17px; margin-right: -10000px; top: 6px; } #u16463.MuseMenuActive #u16465-4,#u10250:hover #u10252-4 { padding-top: 0px; padding-bottom: 0px; min-height: 17px; margin: 0px -10000px 0px 0px; } #u10250:active #u10252-4 { padding-top: 0px; padding-bottom: 0px; min-height: 17px; margin: 0px -10000px 0px 0px; } #u10242 { width: 113px; padding: 2px 2px 2px 5px; } #u14023:active,#u10242:hover { margin: 0px; } #u10242:active { margin: 0px; } #u10243 { width: 113px; } #u10244 { width: 113px; padding-bottom: 7px; margin-right: -10000px; } #u10250.MuseMenuActive,#u10244:hover { margin: 0px -10000px 0px 0px; } #u10246-4 { width: 105px; min-height: 13px; padding: 2px; margin-right: -10000px; top: 3px; left: 2px; } #u10244:hover #u10246-4 { padding-top: 2px; padding-bottom: 2px; min-height: 12px; width: 104px; margin: 0px -10001px -1px 0px; } #u10370 { width: 113px; margin-top: 2px; } #u10371 { width: 113px; padding-bottom: 7px; margin-right: -10000px; } #u10244.MuseMenuActive,#u10371:hover { margin: 0px -10000px 0px 0px; } #u10372-4 { width: 105px; min-height: 13px; padding: 2px; margin-right: -10000px; top: 3px; left: 2px; } #u10371:hover #u10372-4 { padding-top: 2px; padding-bottom: 2px; min-height: 12px; width: 104px; margin: 0px -10001px -1px 0px; } #u10244.MuseMenuActive #u10246-4,#u10371.MuseMenuActive #u10372-4 { padding-top: 2px; padding-bottom: 2px; min-height: 13px; margin: 0px -10000px 0px 0px; } #u10202,#u10125,#u10167,#u16462,#u10240,#u10254 { width: 131px; margin-top: 2px; } #u10285 { width: 131px; min-height: 17px; padding-bottom: 12px; margin-right: -10000px; } #u10371.MuseMenuActive,#u10285:hover { margin: 0px -10000px 0px 0px; } #u10285:active { margin: 0px -10000px 0px 0px; } #u10287-4 { width: 131px; min-height: 17px; margin-right: -10000px; top: 6px; } #u10250.MuseMenuActive #u10252-4,#u10285:hover #u10287-4 { padding-top: 0px; padding-bottom: 0px; min-height: 17px; margin: 0px -10000px 0px 0px; } #u10285:active #u10287-4 { padding-top: 0px; padding-bottom: 0px; min-height: 17px; margin: 0px -10000px 0px 0px; } #u10285.MuseMenuActive #u10287-4 { padding-top: 0px; padding-bottom: 0px; min-height: 17px; margin: 0px -10000px 0px 0px; } #u10290,#u10207,#u10126,#u10172,#u16467,#u10241,#u10255 { width: 120px; left: 131px; } #u10291,#u10208,#u10127,#u10173,#u16468,#u10256 { width: 115px; padding-left: 5px; } #u10334,#u10209,#u10149,#u10174,#u16476,#u10264 { width: 115px; } #u10265 { width: 115px; padding-bottom: 5px; margin-right: -10000px; } #u10265:hover { width: 114px; min-height: 0px; margin: 0px -10001px -1px 0px; } #u10267-4 { width: 107px; min-height: 13px; padding-left: 2px; padding-top: 4px; padding-right: 2px; margin-right: -10000px; top: 2px; left: 2px; } #u16538.MuseMenuActive #u16541-4,#u10265:hover #u10267-4 { padding-top: 4px; padding-bottom: 0px; min-height: 13px; margin: 0px -10000px 0px 0px; } #u10154,#u10133,#u10179,#u10189,#u10269 { width: 120px; left: 115px; } #u10190,#u10270 { width: 117px; padding-left: 3px; } #u16516,#u16523,#u16544,#u16537,#u10271 { width: 117px; } #u10272 { width: 115px; padding-bottom: 4px; margin-right: -10000px; } #u16538.MuseMenuActive,#u10272:hover { width: 115px; min-height: 0px; margin: 0px -10000px 0px 0px; } #u10273-4 { width: 107px; min-height: 13px; padding-left: 2px; padding-top: 4px; padding-right: 2px; margin-right: -10000px; top: 2px; left: 2px; } #u10265.MuseMenuActive #u10267-4,#u10272:hover #u10273-4 { padding-top: 4px; padding-bottom: 0px; min-height: 13px; margin: 0px -10000px 0px 0px; } #u10278 { width: 117px; margin-top: 2px; } #u10281 { width: 115px; padding-bottom: 4px; margin-right: -10000px; } #u10272.MuseMenuActive,#u10281:hover { width: 115px; min-height: 0px; margin: 0px -10000px 0px 0px; } #u10281.MuseMenuActive { width: 115px; min-height: 0px; margin: 0px -10000px 0px 0px; } #u10282-4 { width: 107px; min-height: 26px; padding-left: 2px; padding-top: 4px; padding-right: 2px; margin-right: -10000px; top: 2px; left: 2px; } #u10281:hover #u10282-4 { padding-top: 4px; padding-bottom: 0px; min-height: 26px; margin: 0px -10000px 0px 0px; } #u10281.MuseMenuActive #u10282-4 { padding-top: 4px; padding-bottom: 0px; min-height: 26px; margin: 0px -10000px 0px 0px; } #u10306,#u10320,#u10313,#u10341,#u10292,#u10299,#u10327,#u10348,#u10355,#u10216,#u10128,#u10188,#u10181,#u16469,#u10257 { width: 115px; margin-top: 2px; } #u10258 { width: 115px; padding-bottom: 6px; margin-right: -10000px; } #u10258:hover { width: 114px; min-height: 0px; margin: 0px -10001px -1px 0px; } #u10285.MuseMenuActive,#u10265.MuseMenuActive,#u10258.MuseMenuActive { margin: 0px -10000px 0px 0px; } #u10261-4 { width: 107px; min-height: 13px; padding-left: 2px; padding-top: 4px; padding-right: 2px; margin-right: -10000px; top: 3px; left: 2px; } #u10272.MuseMenuActive #u10273-4,#u10258:hover #u10261-4 { padding-top: 4px; padding-bottom: 0px; min-height: 13px; margin: 0px -10000px 0px 0px; } #u10258.MuseMenuActive #u10261-4 { padding-top: 4px; padding-bottom: 0px; min-height: 13px; margin: 0px -10000px 0px 0px; } #u16515-3 { z-index: 356; width: 5px; margin-right: -10000px; margin-top: 205px; left: 381px; } #u1122-19 { z-index: 361; width: 551px; min-height: 72px; background-color: transparent; position: relative; margin-right: -10000px; left: 240px; } #u1122-2 { line-height: 0px;/* 0 for mixed font sized paras; applied on spans instead */ } #u1122-2 span /* line-height set on spans of mixed font sized paras */ { line-height: 1.2; } #u1141 { float: left; margin: 9px 12px -9px -30px; } #u1135 { z-index: 368; width: 312px; background-color: transparent; } #u1122-6 { font-weight: normal; } #u1122-5,#u1122-7 { font-weight: bold; } #u1123 { z-index: 383; width: 152px; background-color: transparent; position: relative; margin-right: -10000px; margin-top: 16px; left: 804px; } body { position: relative; min-width: 962px; padding-top: 83px; padding-bottom: 36px; }
idies/voyages_sdss_wp
wp-content/legacy/help/css/navigate_3_fields.css
CSS
gpl-2.0
32,445
<?php prado::using ('Application.pages.s.report.MainPageReports'); class ReportDT1 extends MainPageReports { public function onLoad ($param) { parent::onLoad ($param); $this->showLokasi=true; $this->showDT1=true; $this->createObjFinance(); $this->createObjKegiatan(); if (!$this->IsPostBack&&!$this->IsCallBack) { $this->toolbarOptionsBulanRealisasi->Enabled=false; $this->toolbarOptionsTahunAnggaran->DataSource=$this->TGL->getYear(); $this->toolbarOptionsTahunAnggaran->Text=$this->session['ta']; $this->toolbarOptionsTahunAnggaran->dataBind(); if (isset($_SESSION['currentPageReportDT1']['datakegiatan']['iddt1'])) { $this->detailProcess(); }else { if (!isset($_SESSION['currentPageReportDT1'])||$_SESSION['currentPageReportDT1']['page_name']!='s.report.ReportDT1') { $_SESSION['currentPageReportDT1']=array('page_name'=>'s.report.ReportDT1','page_num'=>0,'datakegiatan'=>array()); } $this->literalHeader->Text='Laporan Kegiatan Berdasarkan Daerah Tingkat I '; $this->populateData (); } } } public function changeTahunAnggaran ($sender,$param) { if (isset($_SESSION['currentPageReportDT1']['datakegiatan']['iddt1'])) { $this->idProcess='view'; $_SESSION['ta']=$this->toolbarOptionsTahunAnggaran->Text; $this->contentReport->Text=$this->printContent(); }else { $_SESSION['ta']=$this->toolbarOptionsTahunAnggaran->Text; $this->populateData(); } } protected function populateData () { $ta=$this->session['ta']; $str = 'SELECT iddt1,nama_dt1 FROM dt1 ORDER BY dt1.iddt1 ASC'; $this->DB->setFieldTable(array('iddt1','nama_dt1')); $r=$this->DB->getRecord($str); $result=array(); $str = "SELECT idlok,COUNT(idproyek) AS jumlah_proyek,SUM(nilai_pagu) AS nilai_pagu FROM proyek WHERE ket_lok='dt1' AND tahun_anggaran=$ta GROUP BY idlok ORDER BY idlok ASC"; $this->DB->setFieldTable(array('idlok','jumlah_proyek','nilai_pagu')); $kegiatan=$this->DB->getRecord($str); while (list($k,$v)=each($r)) { $jumlah_kegiatan=0; $nilai_pagu=0; foreach ($kegiatan as $lokasi) { if ($lokasi['idlok']==$v['iddt1']) { $jumlah_kegiatan=$lokasi['jumlah_proyek']; $nilai_pagu=$this->finance->toRupiah($lokasi['nilai_pagu']); break; } } $v['jumlah_kegiatan']=$jumlah_kegiatan; $v['nilai_pagu']=$nilai_pagu; $result[$k]=$v; } $this->RepeaterS->DataSource=$result; $this->RepeaterS->dataBind(); } public function viewRecord($sender,$param) { $iddt1=$this->getDataKeyField($sender, $this->RepeaterS); $str = "SELECT iddt1,nama_dt1 FROM dt1 WHERE iddt1=$iddt1"; $this->DB->setFieldTable(array('iddt1','nama_dt1')); $r=$this->DB->getRecord($str); $_SESSION['currentPageReportDT1']['datakegiatan']=$r[1]; $this->redirect('s.report.ReportDT1'); } public function detailProcess () { $this->idProcess='view'; $datalokasi=$_SESSION['currentPageReportDT1']['datakegiatan']; $this->literalHeader->Text="Daftar Kegiatan di {$datalokasi['nama_dt1']} "; $this->contentReport->Text=$this->printContent(); } /** * digunakan untuk mendapatkan nilai total pagu untuk satu unit * */ private function getTotalNilaiPaguUnit ($idunit,$ta) { $iddt1=$_SESSION['currentPageReportDT1']['datakegiatan']['iddt1']; $str = "SELECT SUM(p.nilai_pagu) AS total FROM proyek p,program pr WHERE p.idprogram=pr.idprogram AND pr.idunit='$idunit' AND pr.tahun='$ta' AND ket_lok='dt1' AND idlok=$iddt1"; $this->DB->setFieldTable (array('total')); $r=$this->DB->getRecord($str); if (isset($r[1])) return $r[1]['total']; else return 0; } /** * * total fisik satu proyek, tahun, bulan penggunaan */ private function getTotalFisik ($idproyek,$tahun) { $str = "SELECT SUM(fisik) AS total FROM v_laporan_a WHERE tahun_penggunaan='$tahun' AND idproyek='$idproyek'"; $this->DB->setFieldTable (array('total')); $r=$this->DB->getRecord($str); if (isset($r[1])) return $r[1]['total']; else return 0; } /** * * jumlah realisasi satu proyek, tahun, bulan penggunaan */ private function getJumlahFisik ($idproyek,$tahun) { $str = "SELECT COUNT(realisasi) AS total FROM v_laporan_a WHERE tahun_penggunaan='$tahun' AND idproyek='$idproyek'"; $this->DB->setFieldTable (array('total')); $r=$this->DB->getRecord($str); if (isset($r[1])) return $r[1]['total']; else return 0; } public function printContent () { $datalokasi=$_SESSION['currentPageReportDT1']['datakegiatan']; $idunit=$this->idunit; $ta=$this->session['ta']; $this->DB->setFieldTable (array('idprogram','kode_program','nama_program')); $str = "SELECT idprogram,kode_program,nama_program FROM program WHERE idunit='$idunit' AND tahun='$ta'"; //daftar program pada unit $daftar_program=$this->DB->getRecord($str); $content="<p class=\"msg info\"> Belum ada program pada tahun anggaran $ta.</p>"; if (isset($daftar_program[1])) { //total pagu satu unit $totalPaguUnit = $this->getTotalNilaiPaguUnit ($idunit,$ta); if ($totalPaguUnit > 0) { $content= '<table class="list" style="font-size:9px"> <thead> <tr> <th rowspan="4" class="center">NO</th> <th rowspan="4" width="350" class="center">PROGRAM/KEGIATAN</th> <th rowspan="4" class="center">SUMBER<br />DANA</th> <th rowspan="4" class="center">PAGU DANA</th> <th rowspan="4" class="center">BOBOT</th> <th colspan="5" class="center">REALISASI</th> <th rowspan="2" colspan="2" class="center">SISA ANGGARAN</th> </tr> <tr> <th colspan="2" class="center">FISIK</th> <th colspan="3" class="center">KEUANGAN</th> </tr> <tr> <th class="center">% per</th> <th class="center">% per</th> <th rowspan="2" class="center">(Rp)</th> <th class="center">% per</th> <th class="center">% per</th> <th rowspan="2" class="center">(Rp)</th> <th rowspan="2" class="center">(%)</th> </tr> <tr> <th class="center">kegiatan</th> <th class="center">SPPD</th> <th class="center">kegiatan</th> <th class="center">SPPD</th> </tr> <tr> <th class="center">1</th> <th class="center">2</th> <th class="center">3</th> <th class="center">4</th> <th class="center">5</th> <th class="center">6</th> <th class="center">7</th> <th class="center">8</th> <th class="center">9</th> <th class="center">10</th> <th class="center">11</th> <th class="center">12</th> </tr> </thead><tbody>'; $no_huruf=ord('a'); $totalRealisasiKeseluruhan=0; $totalPersenRealisasiPerSPPD='0.00'; $totalSisaAnggaran=0; $jumlah_kegiatan=0; while (list($k,$v)=each($daftar_program)) { $idprogram=$v['idprogram']; $this->DB->setFieldTable(array('idproyek','nama_proyek','nilai_pagu','sumber_anggaran','idlok','ket_lok')); $str = "SELECT p.idproyek,p.nama_proyek,p.nilai_pagu,p.sumber_anggaran,idlok,ket_lok FROM proyek p WHERE idprogram='$idprogram' AND ket_lok='dt1' AND idlok='{$datalokasi['iddt1']}'"; $daftar_kegiatan = $this->DB->getRecord($str); if (isset($daftar_kegiatan[1])) { $totalpagueachprogram=0; foreach ($daftar_kegiatan as $eachprogram) { $totalpagueachprogram+=$eachprogram['nilai_pagu']; } $totalpagueachprogram=$this->finance->toRupiah($totalpagueachprogram,'tanpa_rp'); $content.= '<tr> <td class="center"><strong>'.chr($no_huruf).'</strong></td> <td class="left"><strong>'.$v['nama_program'].'</strong></td> <td class="left">&nbsp;</td> <td class="right"><strong>'.$totalpagueachprogram.'</strong></td> <td class="left">&nbsp;</td> <td class="left">&nbsp;</td> <td class="left">&nbsp;</td> <td class="left">&nbsp;</td> <td class="left">&nbsp;</td> <td class="left">&nbsp;</td> <td class="left">&nbsp;</td> <td class="left">&nbsp;</td> </tr>'; $no=1; while (list($m,$n)=each($daftar_kegiatan)) { $idproyek=$n['idproyek']; $content.= '<tr>'; $content.= '<td class="center">'.$n['no'].'</td>'; $content.= '<td class="left">'.$n['nama_proyek'].'</td>'; $content.= '<td class="center">'.$n['sumber_anggaran'].'</td>'; $nilai_pagu_proyek=$n['nilai_pagu']; $rp_nilai_pagu_proyek=$this->finance->toRupiah($nilai_pagu_proyek,'tanpa_rp'); $content.= "<td class=\"right\">$rp_nilai_pagu_proyek</td>"; $persen_bobot=number_format(($nilai_pagu_proyek/$totalPaguUnit)*100,2); $totalPersenBobot+=$persen_bobot; $content.= "<td class=\"center\">$persen_bobot</td>"; $str = "SELECT SUM(realisasi) AS total FROM v_laporan_a WHERE idproyek=$idproyek AND tahun_penggunaan='$ta'"; $this->DB->setFieldTable(array('total')); $realisasi=$this->DB->getRecord($str); $persen_fisik='0.00'; $persenFisikPerSPPD='0.00'; $totalrealisasi=0; $persen_realisasi='0.00'; $persenRealisasiPerSPPD='0.00'; $sisa_anggaran=0; $persen_sisa_anggaran='0.00'; if ($realisasi[1]['total'] > 0 ){ //fisik $totalFisikSatuProyek=$this->getTotalFisik($idproyek,$ta); $jumlahRealisasiFisikSatuProyek=$this->getJumlahFisik ($idproyek,$ta); $persen_fisik=number_format(($totalFisikSatuProyek/$jumlahRealisasiFisikSatuProyek),2); $totalPersenFisik+=$persen_fisik; $persenFisikPerSPPD=number_format(($persen_fisik/100)*$persen_bobot,2); $totalPersenFisikPerSPPD+=$persenFisikPerSPPD; $totalrealisasi=$realisasi[1]['total']; $totalRealisasiKeseluruhan+=$totalrealisasi; $persen_realisasi=number_format(($totalrealisasi/$nilai_pagu_proyek)*100,2); $totalPersenRealisasi+=$persen_realisasi; $persenRealisasiPerSPPD=number_format(($persen_realisasi/100)*$persen_bobot,2); $totalPersenRealisasiPerSPPD+=$persenRealisasiPerSPPD; $sisa_anggaran=$nilai_pagu_proyek- $totalrealisasi; $persen_sisa_anggaran=number_format(($sisa_anggaran/$totalPaguUnit)*100,2); $totalPersenSisaAnggaran+=$persen_sisa_anggaran; $totalSisaAnggaran+=$sisa_anggaran; } $content.= '<td class="center">'.$persen_fisik.'</td>'; $content.= '<td class="center">'.$persenFisikPerSPPD.'</td>'; $content.= '<td class="right">'.$this->finance->toRupiah($totalrealisasi,'tanpa_rp').'</td>'; $content.= '<td class="center">'.$persen_realisasi.'</td>'; $content.= '<td class="center">'.$persenRealisasiPerSPPD.'</td>'; $content.= '<td class="right">'.$this->finance->toRupiah($sisa_anggaran,'tanpa_rp').'</td>'; $content.= '<td class="center">'.$persen_sisa_anggaran.'</td>'; $content.='</tr>'; $no++; $jumlah_kegiatan++; } $no_huruf++; } } $rp_total_pagu_unit=$this->finance->toRupiah($totalPaguUnit,'tanpa_rp'); $totalPersenBobot=number_format($totalPersenBobot); $rp_total_realisasi_keseluruhan=$this->finance->toRupiah($totalRealisasiKeseluruhan,'tanpa_rp'); if ($totalPersenRealisasi > 0) $totalPersenRealisasi=number_format(($totalPersenRealisasi/$jumlah_kegiatan),2); if ($totalPersenSisaAnggaran > 0) $totalPersenSisaAnggaran=number_format(($totalPersenSisaAnggaran/$jumlah_kegiatan),2); $totalPersenFisik=number_format($totalPersenFisik/$jumlah_kegiatan,2); $totalPersenRealisasiPerSPPD=number_format($totalPersenRealisasiPerSPPD,2); $totalPersenFisikPerSPPD=number_format($totalPersenFisikPerSPPD,2); $rp_total_sisa_anggaran=$this->finance->toRupiah($totalSisaAnggaran,'tanpa_rp'); $content.= '<tr> <td colspan="2" class="right"><strong>Jumlah</strong></td> <td class="left"></td> <td class="right">'.$rp_total_pagu_unit.'</td> <td class="center">'.$totalPersenBobot.'</td> <td class="center">'.$totalPersenFisik.'</td> <td class="center">'.$totalPersenFisikPerSPPD.'</td> <td class="right">'.$rp_total_realisasi_keseluruhan.'</td> <td class="center">'.$totalPersenRealisasi.'</td> <td class="center">'.$totalPersenRealisasiPerSPPD.'</td> <td class="right">'.$rp_total_sisa_anggaran.'</td> <td class="center">'.$totalPersenSisaAnggaran.'</td> </tr>'; $content.='</tbody></table>'; } } return $content; } public function printOut ($sender,$param) { $this->idProcess='view'; $this->createObjReport(); $this->report->dataKegiatan=$_SESSION['currentPageReportDT1']['datakegiatan']; $this->report->dataKegiatan['idunit']=$this->idunit; $this->report->dataKegiatan['tahun']=$_SESSION['ta']; $this->report->dataKegiatan['userid']=$this->userid; $this->report->dataKegiatan['tipe_lokasi']='dt1'; $filetype=$this->cmbTipePrintOut->Text; switch($filetype) { case 'excel2003' : $this->report->setMode('excel2003'); $this->report->printLokasi($this->linkOutput); break; case 'excel2007' : $this->report->setMode('excel2007'); $this->report->printLokasi($this->linkOutput); break; } } public function close($sender,$param) { unset($_SESSION['currentPageReportDT1']); $this->redirect('s.report.ReportDT1'); } } ?>
ibnoe/simonev
protected/pages/s/report/ReportDT1.php
PHP
gpl-2.0
18,291
######################################################################### # OpenKore - Network subsystem # This module contains functions for sending messages to the server. # # This software is open source, licensed under the GNU General Public # License, version 2. # Basically, this means that you're allowed to modify and distribute # this software. However, if you distribute modified versions, you MUST # also distribute the source code. # See http://www.gnu.org/licenses/gpl.html for the full license. ######################################################################### # tRO (Thai) for 2008-09-16Ragexe12_Th # Servertype overview: http://wiki.openkore.com/index.php/ServerType package Network::Send::iRO; use strict; use Globals; use Network::Send::ServerType0; use base qw(Network::Send::ServerType0); use Log qw(error debug); use I18N qw(stringToBytes); use Utils qw(getTickCount getHex getCoordString); sub new { my ($class) = @_; my $self = $class->SUPER::new(@_); my %packets = ( '098f' => ['char_delete2_accept', 'v a4 a*', [qw(length charID code)]], ); $self->{packet_list}{$_} = $packets{$_} for keys %packets; my %handlers = qw( sync 0360 character_move 035F actor_info_request 0368 actor_look_at 0361 item_take 0362 item_drop 0363 storage_item_add 0364 storage_item_remove 0365 skill_use_location 0366 party_setting 07D7 buy_bulk_vender 0801 char_delete2_accept 098f send_equip 0998 ); $self->{packet_lut}{$_} = $handlers{$_} for keys %handlers; $self->{char_create_version} = 0x0A39; $self->{sell_mode} = 0; return $self; } sub sendMove { my $self = shift; # The server won't let us move until we send the sell complete packet. $self->sendSellComplete if $self->{sell_mode}; $self->SUPER::sendMove(@_); } sub sendSellComplete { my ($self) = @_; $messageSender->sendToServer(pack 'C*', 0xD4, 0x09); $self->{sell_mode} = 0; } sub reconstruct_char_delete2_accept { my ($self, $args) = @_; # length = [packet:2] + [length:2] + [charid:4] + [code_length] $args->{length} = 8 + length($args->{code}); debug "Sent sendCharDelete2Accept. CharID: $args->{CharID}, Code: $args->{code}, Length: $args->{length}\n", "sendPacket", 2; } sub sendCharCreate { my ( $self, $slot, $name, $hair_style, $hair_color, $job_id, $sex ) = @_; $hair_color ||= 1; $hair_style ||= 0; $job_id ||= 0; # novice $sex ||= 0; # female my $msg = pack 'v a24 CvvvvC', 0x0A39, stringToBytes( $name ), $slot, $hair_color, $hair_style, $job_id, 0, $sex; $self->sendToServer( $msg ); } #sub sendCharDelete { # my ($self, $charID, $email) = @_; # my $msg = pack("C*", 0xFB, 0x01) . # $charID . pack("a50", stringToBytes($email)); # $self->sendToServer($msg); #} sub sendTop10Alchemist { shift->sendToServer( pack 'vv', 0x097C, 1 ); } sub sendTop10Blacksmith { shift->sendToServer( pack 'vv', 0x097C, 0 ); } sub sendTop10PK { shift->sendToServer( pack 'vv', 0x097C, 3 ); } sub sendTop10Taekwon { shift->sendToServer( pack 'vv', 0x097C, 2 ); } 1;
AndreasWilliams/BotGravindo
src/Network/Send/iRO.pm
Perl
gpl-2.0
3,040
# Staff A repository of some AvaCon's code.
AvaCon/Staff
README.md
Markdown
gpl-2.0
44
/* * 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 datagen.engine; import java.util.ArrayList; /** * * @author juan.garson */ public class Table { private final ArrayList<Column> columns; private final String name; private int count; private final ArrayList<String> reference; public Table(String name){ this.name = name; columns = new ArrayList<>(); reference = new ArrayList<>(); } public Column getColumn(String name){ Column response; try{ response = null; for(Column column: columns){ if(column.field.equals(name)){ response = column; break; } } }catch(Exception e){ response = null; } return response; } public String[] getRow(int position){ String[] response; try{ response = new String[columns.size()]; for(int i=0;i<columns.size();i++){ response[i] = columns.get(i).gen[position]; } }catch(Exception e){ System.err.println(e.getMessage()); response = null; } return response; } public boolean hasReferences(){ return reference.size() > 0; } public ArrayList<String> getReferences(){ return reference; } public void addColumn(Column column){ columns.add(column); } public String getName(){ return name; } public void setCount(int count){ this.count = count; } public int getCount(){ return count; } public ArrayList<Column> getColumns(){ return columns; } /*@Override public String toString() { StringBuilder builder; builder = new StringBuilder(); builder.append("Table : "); builder.append(name); builder.append("\n"); for(Column col : columns){ builder.append(col.toString()); builder.append("\n"); } return builder.toString(); }*/ @Override public String toString() { return name; } }
lanstat/DataGen
src/datagen/engine/Table.java
Java
gpl-2.0
2,373
/* * Copyright (C) 2004-2005 Volker Stroebel <volker@planetpenguin.de> * * 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. */ #ifndef _VIDEO_CONFIG_H #define _VIDEO_CONFIG_H #include "configmode.h" #include "ppgltk/listbox.h" #include "ppgltk/checkbox.h" typedef struct{ std::string name; int x; int y; }resolution_t; typedef struct{ std::string name; int data; }bpp_t, multisample_t; class VideoConfig : public ConfigMode { pp::Listbox<resolution_t>* mp_resolutionListbox; pp::Listbox<bpp_t>* mp_bppListbox; pp::Listbox<multisample_t>* mp_multisampleListbox; std::list<resolution_t> m_resolutionList; std::list<bpp_t> m_bppList; std::list<multisample_t> m_multisampleList; pp::CheckBox* mp_fullscreenBox; pp::CheckBox* mp_stencilBox; pp::CheckBox* mp_fsaaBox; void initVideoModes(); public: VideoConfig(); ~VideoConfig(); void setWidgetPositions(); void apply(); }; #endif // _VIDEO_CONFIG_H
gonium/fc-extremetuxracer
src/videoconfig.h
C
gpl-2.0
1,603
/* * Block driver for media (i.e., flash cards) * * Copyright 2002 Hewlett-Packard Company * Copyright 2005-2008 Pierre Ossman * * Use consistent with the GNU GPL is permitted, * provided that this copyright notice is * preserved in its entirety in all copies and derived works. * * HEWLETT-PACKARD COMPANY MAKES NO WARRANTIES, EXPRESSED OR IMPLIED, * AS TO THE USEFULNESS OR CORRECTNESS OF THIS CODE OR ITS * FITNESS FOR ANY PARTICULAR PURPOSE. * * Many thanks to Alessandro Rubini and Jonathan Corbet! * * Author: Andrew Christian * 28 May 2002 */ #include <linux/moduleparam.h> #include <linux/module.h> #include <linux/init.h> #include <linux/kernel.h> #include <linux/fs.h> #include <linux/errno.h> #include <linux/hdreg.h> #include <linux/kdev_t.h> #include <linux/blkdev.h> #include <linux/mutex.h> #include <linux/scatterlist.h> #include <linux/string_helpers.h> #include <linux/mmc/card.h> #include <linux/mmc/host.h> #include <linux/mmc/mmc.h> #include <linux/mmc/sd.h> #include <asm/system.h> #include <asm/uaccess.h> #include "queue.h" MODULE_ALIAS("mmc:block"); /* * max 8 partitions per card */ #define MMC_SHIFT 3 #define MMC_NUM_MINORS (256 >> MMC_SHIFT) static DECLARE_BITMAP(dev_use, MMC_NUM_MINORS); /* * There is one mmc_blk_data per slot. */ struct mmc_blk_data { spinlock_t lock; struct gendisk *disk; struct mmc_queue queue; unsigned int usage; unsigned int read_only; }; static DEFINE_MUTEX(open_lock); static struct mmc_blk_data *mmc_blk_get(struct gendisk *disk) { struct mmc_blk_data *md; mutex_lock(&open_lock); md = disk->private_data; if (md && md->usage == 0) md = NULL; if (md) md->usage++; mutex_unlock(&open_lock); return md; } static void mmc_blk_put(struct mmc_blk_data *md) { mutex_lock(&open_lock); md->usage--; if (md->usage == 0) { int devidx = MINOR(disk_devt(md->disk)) >> MMC_SHIFT; __clear_bit(devidx, dev_use); put_disk(md->disk); kfree(md); } mutex_unlock(&open_lock); } static int mmc_blk_open(struct block_device *bdev, fmode_t mode) { struct mmc_blk_data *md = mmc_blk_get(bdev->bd_disk); int ret = -ENXIO; if (md) { if (md->usage == 2) check_disk_change(bdev); ret = 0; if ((mode & FMODE_WRITE) && md->read_only) { mmc_blk_put(md); ret = -EROFS; } } return ret; } static int mmc_blk_release(struct gendisk *disk, fmode_t mode) { struct mmc_blk_data *md = disk->private_data; mmc_blk_put(md); return 0; } static int mmc_blk_getgeo(struct block_device *bdev, struct hd_geometry *geo) { geo->cylinders = get_capacity(bdev->bd_disk) / (4 * 16); geo->heads = 4; geo->sectors = 16; return 0; } static struct block_device_operations mmc_bdops = { .open = mmc_blk_open, .release = mmc_blk_release, .getgeo = mmc_blk_getgeo, .owner = THIS_MODULE, }; struct mmc_blk_request { struct mmc_request mrq; struct mmc_command cmd; struct mmc_command stop; struct mmc_data data; }; static u32 mmc_sd_num_wr_blocks(struct mmc_card *card) { int err; __be32 blocks; struct mmc_request mrq; struct mmc_command cmd; struct mmc_data data; unsigned int timeout_us; struct scatterlist sg; memset(&cmd, 0, sizeof(struct mmc_command)); cmd.opcode = MMC_APP_CMD; cmd.arg = card->rca << 16; cmd.flags = MMC_RSP_SPI_R1 | MMC_RSP_R1 | MMC_CMD_AC; err = mmc_wait_for_cmd(card->host, &cmd, 0); if (err) return (u32)-1; if (!mmc_host_is_spi(card->host) && !(cmd.resp[0] & R1_APP_CMD)) return (u32)-1; memset(&cmd, 0, sizeof(struct mmc_command)); cmd.opcode = SD_APP_SEND_NUM_WR_BLKS; cmd.arg = 0; cmd.flags = MMC_RSP_SPI_R1 | MMC_RSP_R1 | MMC_CMD_ADTC; memset(&data, 0, sizeof(struct mmc_data)); data.timeout_ns = card->csd.tacc_ns * 100; data.timeout_clks = card->csd.tacc_clks * 100; timeout_us = data.timeout_ns / 1000; timeout_us += data.timeout_clks * 1000 / (card->host->ios.clock / 1000); if (timeout_us > 100000) { data.timeout_ns = 100000000; data.timeout_clks = 0; } data.blksz = 4; data.blocks = 1; data.flags = MMC_DATA_READ; data.sg = &sg; data.sg_len = 1; memset(&mrq, 0, sizeof(struct mmc_request)); mrq.cmd = &cmd; mrq.data = &data; sg_init_one(&sg, &blocks, 4); mmc_wait_for_req(card->host, &mrq); if (cmd.error || data.error) return (u32)-1; return ntohl(blocks); } static u32 get_card_status(struct mmc_card *card, struct request *req) { struct mmc_command cmd; int err; 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_SPI_R2 | MMC_RSP_R1 | MMC_CMD_AC; err = mmc_wait_for_cmd(card->host, &cmd, 0); if (err) printk(KERN_ERR "%s: error %d sending status comand", req->rq_disk->disk_name, err); return cmd.resp[0]; } static int mmc_blk_issue_rq(struct mmc_queue *mq, struct request *req) { struct mmc_blk_data *md = mq->data; struct mmc_card *card = md->queue.card; struct mmc_blk_request brq; int ret = 1, disable_multi = 0; mmc_claim_host(card->host); do { struct mmc_command cmd; u32 readcmd, writecmd, status = 0; memset(&brq, 0, sizeof(struct mmc_blk_request)); brq.mrq.cmd = &brq.cmd; brq.mrq.data = &brq.data; brq.cmd.arg = req->sector; if (!mmc_card_blockaddr(card)) brq.cmd.arg <<= 9; brq.cmd.flags = MMC_RSP_SPI_R1 | MMC_RSP_R1 | MMC_CMD_ADTC; brq.data.blksz = 512; brq.stop.opcode = MMC_STOP_TRANSMISSION; brq.stop.arg = 0; brq.stop.flags = MMC_RSP_SPI_R1B | MMC_RSP_R1B | MMC_CMD_AC; brq.data.blocks = req->nr_sectors; /* * After a read error, we redo the request one sector at a time * in order to accurately determine which sectors can be read * successfully. */ if (disable_multi && brq.data.blocks > 1) brq.data.blocks = 1; if (brq.data.blocks > 1) { /* SPI multiblock writes terminate using a special * token, not a STOP_TRANSMISSION request. */ if (!mmc_host_is_spi(card->host) || rq_data_dir(req) == READ) brq.mrq.stop = &brq.stop; readcmd = MMC_READ_MULTIPLE_BLOCK; writecmd = MMC_WRITE_MULTIPLE_BLOCK; } else { brq.mrq.stop = NULL; readcmd = MMC_READ_SINGLE_BLOCK; writecmd = MMC_WRITE_BLOCK; } if (rq_data_dir(req) == READ) { brq.cmd.opcode = readcmd; brq.data.flags |= MMC_DATA_READ; } else { brq.cmd.opcode = writecmd; brq.data.flags |= MMC_DATA_WRITE; } mmc_set_data_timeout(&brq.data, card); brq.data.sg = mq->sg; brq.data.sg_len = mmc_queue_map_sg(mq); /* * Adjust the sg list so it is the same size as the * request. */ if (brq.data.blocks != req->nr_sectors) { int i, data_size = brq.data.blocks << 9; struct scatterlist *sg; for_each_sg(brq.data.sg, sg, brq.data.sg_len, i) { data_size -= sg->length; if (data_size <= 0) { sg->length += data_size; i++; break; } } brq.data.sg_len = i; } mmc_queue_bounce_pre(mq); mmc_wait_for_req(card->host, &brq.mrq); mmc_queue_bounce_post(mq); /* * Check for errors here, but don't jump to cmd_err * until later as we need to wait for the card to leave * programming mode even when things go wrong. */ if (brq.cmd.error || brq.data.error || brq.stop.error) { if (brq.data.blocks > 1 && rq_data_dir(req) == READ) { /* Redo read one sector at a time */ printk(KERN_WARNING "%s: retrying using single " "block read\n", req->rq_disk->disk_name); disable_multi = 1; continue; } status = get_card_status(card, req); } if (brq.cmd.error) { printk(KERN_ERR "%s: error %d sending read/write " "command, response %#x, card status %#x\n", req->rq_disk->disk_name, brq.cmd.error, brq.cmd.resp[0], status); } if (brq.data.error) { if (brq.data.error == -ETIMEDOUT && brq.mrq.stop) /* 'Stop' response contains card status */ status = brq.mrq.stop->resp[0]; printk(KERN_ERR "%s: error %d transferring data," " sector %u, nr %u, card status %#x\n", req->rq_disk->disk_name, brq.data.error, (unsigned)req->sector, (unsigned)req->nr_sectors, status); } if (brq.stop.error) { printk(KERN_ERR "%s: error %d sending stop command, " "response %#x, card status %#x\n", req->rq_disk->disk_name, brq.stop.error, brq.stop.resp[0], status); } if (!mmc_host_is_spi(card->host) && rq_data_dir(req) != READ) { do { int err; cmd.opcode = MMC_SEND_STATUS; cmd.arg = card->rca << 16; cmd.flags = MMC_RSP_R1 | MMC_CMD_AC; err = mmc_wait_for_cmd(card->host, &cmd, 5); if (err) { printk(KERN_ERR "%s: error %d requesting status\n", req->rq_disk->disk_name, err); goto cmd_err; } /* * Some cards mishandle the status bits, * so make sure to check both the busy * indication and the card state. */ } while (!(cmd.resp[0] & R1_READY_FOR_DATA) || (R1_CURRENT_STATE(cmd.resp[0]) == 7)); #if 0 if (cmd.resp[0] & ~0x00000900) printk(KERN_ERR "%s: status = %08x\n", req->rq_disk->disk_name, cmd.resp[0]); if (mmc_decode_status(cmd.resp)) goto cmd_err; #endif } if (brq.cmd.error || brq.stop.error || brq.data.error) { if (rq_data_dir(req) == READ) { /* * After an error, we redo I/O one sector at a * time, so we only reach here after trying to * read a single sector. */ spin_lock_irq(&md->lock); ret = __blk_end_request(req, -EIO, brq.data.blksz); spin_unlock_irq(&md->lock); continue; } goto cmd_err; } /* * A block was successfully transferred. */ spin_lock_irq(&md->lock); ret = __blk_end_request(req, 0, brq.data.bytes_xfered); spin_unlock_irq(&md->lock); } while (ret); mmc_release_host(card->host); return 1; cmd_err: /* * If this is an SD card and we're writing, we can first * mark the known good sectors as ok. * * If the card is not SD, we can still ok written sectors * as reported by the controller (which might be less than * the real number of written sectors, but never more). */ if (mmc_card_sd(card)) { u32 blocks; blocks = mmc_sd_num_wr_blocks(card); if (blocks != (u32)-1) { spin_lock_irq(&md->lock); ret = __blk_end_request(req, 0, blocks << 9); spin_unlock_irq(&md->lock); } } else { spin_lock_irq(&md->lock); ret = __blk_end_request(req, 0, brq.data.bytes_xfered); spin_unlock_irq(&md->lock); } mmc_release_host(card->host); spin_lock_irq(&md->lock); while (ret) ret = __blk_end_request(req, -EIO, blk_rq_cur_bytes(req)); spin_unlock_irq(&md->lock); return 0; } static inline int mmc_blk_readonly(struct mmc_card *card) { return mmc_card_readonly(card) || !(card->csd.cmdclass & CCC_BLOCK_WRITE); } static struct mmc_blk_data *mmc_blk_alloc(struct mmc_card *card) { struct mmc_blk_data *md; int devidx, ret; devidx = find_first_zero_bit(dev_use, MMC_NUM_MINORS); if (devidx >= MMC_NUM_MINORS) return ERR_PTR(-ENOSPC); __set_bit(devidx, dev_use); md = kzalloc(sizeof(struct mmc_blk_data), GFP_KERNEL); if (!md) { ret = -ENOMEM; goto out; } /* * Set the read-only status based on the supported commands * and the write protect switch. */ md->read_only = mmc_blk_readonly(card); md->disk = alloc_disk(1 << MMC_SHIFT); if (md->disk == NULL) { ret = -ENOMEM; goto err_kfree; } spin_lock_init(&md->lock); md->usage = 1; ret = mmc_init_queue(&md->queue, card, &md->lock); if (ret) goto err_putdisk; md->queue.issue_fn = mmc_blk_issue_rq; md->queue.data = md; md->disk->major = MMC_BLOCK_MAJOR; md->disk->first_minor = devidx << MMC_SHIFT; md->disk->fops = &mmc_bdops; md->disk->private_data = md; md->disk->queue = md->queue.queue; md->disk->driverfs_dev = &card->dev; /* * As discussed on lkml, GENHD_FL_REMOVABLE should: * * - be set for removable media with permanent block devices * - be unset for removable block devices with permanent media * * Since MMC block devices clearly fall under the second * case, we do not set GENHD_FL_REMOVABLE. Userspace * should use the block device creation/destruction hotplug * messages to tell when the card is present. */ sprintf(md->disk->disk_name, "mmcblk%d", devidx); blk_queue_hardsect_size(md->queue.queue, 512); if (!mmc_card_sd(card) && mmc_card_blockaddr(card)) { /* * The EXT_CSD sector count is in number or 512 byte * sectors. */ set_capacity(md->disk, card->ext_csd.sectors); } else { /* * The CSD capacity field is in units of read_blkbits. * set_capacity takes units of 512 bytes. */ set_capacity(md->disk, card->csd.capacity << (card->csd.read_blkbits - 9)); } return md; err_putdisk: put_disk(md->disk); err_kfree: kfree(md); out: return ERR_PTR(ret); } static int mmc_blk_set_blksize(struct mmc_blk_data *md, struct mmc_card *card) { struct mmc_command cmd; int err; /* Block-addressed cards ignore MMC_SET_BLOCKLEN. */ if (mmc_card_blockaddr(card)) return 0; mmc_claim_host(card->host); cmd.opcode = MMC_SET_BLOCKLEN; cmd.arg = 512; cmd.flags = MMC_RSP_SPI_R1 | MMC_RSP_R1 | MMC_CMD_AC; err = mmc_wait_for_cmd(card->host, &cmd, 5); mmc_release_host(card->host); if (err) { printk(KERN_ERR "%s: unable to set block size to %d: %d\n", md->disk->disk_name, cmd.arg, err); return -EINVAL; } return 0; } static int mmc_blk_probe(struct mmc_card *card) { struct mmc_blk_data *md; int err; char cap_str[10]; /* * Check that the card supports the command class(es) we need. */ if (!(card->csd.cmdclass & CCC_BLOCK_READ)) return -ENODEV; md = mmc_blk_alloc(card); if (IS_ERR(md)) return PTR_ERR(md); err = mmc_blk_set_blksize(md, card); if (err) goto out; string_get_size((u64)get_capacity(md->disk) << 9, STRING_UNITS_2, cap_str, sizeof(cap_str)); printk(KERN_INFO "%s: %s %s %s %s\n", md->disk->disk_name, mmc_card_id(card), mmc_card_name(card), cap_str, md->read_only ? "(ro)" : ""); mmc_set_drvdata(card, md); add_disk(md->disk); return 0; out: mmc_blk_put(md); return err; } static void mmc_blk_remove(struct mmc_card *card) { struct mmc_blk_data *md = mmc_get_drvdata(card); if (md) { /* Stop new requests from getting into the queue */ del_gendisk(md->disk); /* Then flush out any already in there */ mmc_cleanup_queue(&md->queue); mmc_blk_put(md); } mmc_set_drvdata(card, NULL); } #ifdef CONFIG_PM static int mmc_blk_suspend(struct mmc_card *card, pm_message_t state) { struct mmc_blk_data *md = mmc_get_drvdata(card); if (md) { mmc_queue_suspend(&md->queue); } return 0; } static int mmc_blk_resume(struct mmc_card *card) { struct mmc_blk_data *md = mmc_get_drvdata(card); if (md) { mmc_blk_set_blksize(md, card); mmc_queue_resume(&md->queue); } return 0; } #else #define mmc_blk_suspend NULL #define mmc_blk_resume NULL #endif static struct mmc_driver mmc_driver = { .drv = { .name = "mmcblk", }, .probe = mmc_blk_probe, .remove = mmc_blk_remove, .suspend = mmc_blk_suspend, .resume = mmc_blk_resume, }; static int __init mmc_blk_init(void) { int res; res = register_blkdev(MMC_BLOCK_MAJOR, "mmc"); if (res) goto out; res = mmc_register_driver(&mmc_driver); if (res) goto out2; return 0; out2: unregister_blkdev(MMC_BLOCK_MAJOR, "mmc"); out: return res; } static void __exit mmc_blk_exit(void) { mmc_unregister_driver(&mmc_driver); unregister_blkdev(MMC_BLOCK_MAJOR, "mmc"); } module_init(mmc_blk_init); module_exit(mmc_blk_exit); MODULE_LICENSE("GPL"); MODULE_DESCRIPTION("Multimedia Card (MMC) block device driver");
pierre/tuxonice-fastboot
drivers/mmc/card/block.c
C
gpl-2.0
15,594
############################################################# # Signal.rb # # Copyright (c) 2002 Phil Tomson # released under the GNU General Public License (GPL) # ################################################## ####################################################### # add a bin method to the built-in String class # converts a String composed of '1's and '0's to binary # (note: won't be needed in Ruby 1.7/1.8 # ##################################################### class String def bin val = self.strip pattern = /^([+-]?)(0b)?([01]+)(.*)$/ parts = pattern.match(val) return 0 if not parts sign = parts[1] num = parts[3] eval(sign+"0b"+num) end end ##################################################### # add a 'inv' method to the built-in Fixnum class # ##################################################### class Fixnum def inv binary = sprintf("%b",self) #get a binary representation of 'self' ones = '1'*binary.length #create a string of '1's the length of binary self ^ ones.bin #invert by XOR'ing with ones end end module RHDL ############################################################### # Signal - ############################################################### class Signal @@signalList = []#everytime we create a new signal we add it to this list @@deltaEvents = true attr_reader :valObj, :next_value, :event attr_writer :event def Signal.update_all @@signalList.each {|signal| signal.update } end def Signal.deltaEvents? @@deltaEvents end def Signal.clear_deltaEvents @@deltaEvents = false end def Signal.set_deltaEvents @@deltaEvents = true end def inspect @valObj.inspect end def value #was: #self.inspect #TODO: should it just be: @valObj @valObj end def value=(n) @valObj.assign(n) end #TODO: do we need Signal.clear_events ? def Signal.clear_events @@signalList.each { |signal| signal.event = false } end def type @valObj.class end def rising_edge event && value == '1' end def falling_edge event && value == '0' end #signals have history def initialize(valObj,width = 1) @valObj = valObj @@signalList << self @eventQueue = [] @event = false @next_value = nil end ####The old assign_at and assign methods:############## # define a driver function for this signal: #def assign_at (relTime=0,function=nil) # #schedule an event # nextValue = case function # when nil # Proc.new.call # when Proc # function.call # when Signal # proc{function.to_s}.call # else # function # end # @eventQueue[relTime] = nextValue # nextValInQueue = @eventQueue.shift # @next_value = nextValInQueue if nextValInQueue #end # #def assign(function=nil) # if function # assign_at(0,function) # else # assign_at(0,Proc.new) # end #end ####################################################### def call proc{self.to_s}.call end #.... def assign_at (relTime=0,nextValue=Proc.new) nextValue = nextValue.call if nextValue.respond_to? :call ###Experimental#### if(relTime < @eventQueue.length) @eventQueue.clear @eventQueue[0] = nextValue else @eventQueue[relTime] = nextValue end #@eventQueue[relTime] = nextValue if @@deltaEvents nextValInQueue = @eventQueue[0] #nextValInQueue = @eventQueue.shift else nextValInQueue = @eventQueue.shift end ###\Experimental#### puts "nextValInQueue: #{nextValInQueue}" if $DEBUG puts "@eventQueue:" if $DEBUG puts @eventQueue if $DEBUG @next_value = nextValInQueue if nextValInQueue != nil end def assign(nextValue=Proc.new) puts "assign #{nextValue}" if $DEBUG assign_at(0,nextValue) end #deprecated: #def <<(nextValue=Proc.new) # self.assign(nextValue) #end ########################################### # <= means assignment, not les-than-or-equal ########################################### def <=(nextValue=Proc.new) self.assign(nextValue) end ########################################### # less-than-or-equal (since we can't use <= anymore ) # ######################################### def lte(other) if other.class == Signal @valObj <= other.value else @valObj <= other end end ########################################## # greater-than-or-equal # ######################################## def gte(other) if other.class == Signal @valObj >= other.value else @valObj >= other end end #was commented: def method_missing(methID,*args) puts "methID is: #{methID}, args are: #{args}" if $DEBUG case methID when :+,:-,:*,:==,:===,:<=>,:>,:<,:or,:and,:^,:&,:|,:xor other = args[0] if other.class == Signal @valObj.send(methID,other.value) else @valObj.send(methID,other) end else @valObj.send(methID,*args) end end def to_s @valObj.to_s end def update puts "update: next_value = #@next_value current value = #{@valObj.inspect}" if $DEBUG puts "update: next_value = #@next_value current value = #{@valObj}" if $DEBUG puts "update: next_value.class = #{@next_value.class} current value.class = #{@valObj.class}" if $DEBUG #TODO: what about using 'inspect' to determine values for events? #was:if @next_value && @next_value.to_s != @valObj.inspect.to_s #if changed if @next_value && @valObj != @next_value #if changed puts "update: #{@next_value.to_s} #{valObj.inspect.to_s}" if $DEBUG puts "update: #{@next_value} #{valObj}" if $DEBUG puts "update: class:#{@next_value.class}!= #{@valObj.class}" if @next_value.class != @valObj.class if $DEBUG @event = true @@deltaEvents = true else @event = false end if @next_value if @valObj.respond_to?(:assign) @valObj.assign(@next_value) else @valObj = @next_value end end puts "update value is now: #@valObj" if $DEBUG end def coerce(other) puts "coersion called! other is: #{other}, other.class is: #{other.class}" case other when Fixnum #return [ Signal.new(other), self.value.to_i] return [ other, self.value.to_i] when String puts "Coerce String!!!!!!" return [ Signal(BitVector(other)), self] end end #the '==' that comes with all objects must be overridden def ==(other) if other.class == Signal @valObj == other.value else @valObj == other end end #NOTE: commented to try coerce #def ===(other) # puts "Signal::===" if $DEBUG # @valObj === other #end end def Signal(val,width=1) Signal.new(val,width) end end #RHDL if $0 == __FILE__ require 'Bit' include RHDL require "test/unit" puts "Test Signal" class Testing_Signal < Test::Unit::TestCase def setup @a_bit = Signal(Bit('1')) @b_bit = Signal(Bit('1')) @c_bit = Signal(Bit()) @counter = Signal(0) @a_bv = Signal(BitVector('1010')) @b_bv = Signal(BitVector('0101')) @c_bv = Signal(BitVector('XXXX')) end def test_add_bit @c_bit <= @a_bit + @b_bit @c_bit.update assert_equal(1, @c_bit) end def test_inv_bit @a_bit <= @a_bit.inv @a_bit.update assert_equal(0, @a_bit) end def test_compare_bv assert_not_equal(@a_bv, @b_bv) assert( @a_bv > @b_bv ) #compare with a string literal: assert( @a_bv > '0000') #compare with an integer: assert( @a_bv < 22 ) assert( @a_bv == 0b1010 ) assert( @a_bv.lte(0b1010) ) assert( @a_bv.gte(@b_bv )) end def test_add_bv @c_bv <= (@a_bv + @b_bv) @c_bv.update puts "@c_bv.value.class is: #{@c_bv.value.class}" #assert_equal( @c_bv, '1111') assert_equal( '1111', @c_bv.value.to_s) #try adding a literal to a Signal: @c_bv <= ( @c_bv + '0001' ) @c_bv.update assert_equal( '0000', @c_bv.value.to_s ) #try adding a BitVector to a BitVector Signal: @c_bv <= ( @c_bv + BitVector.new('1000')) @c_bv.update assert_equal( '1000', @c_bv.value.to_s ) #try adding an integer to a BitVector Signal: @c_bv <= ( @c_bv + 1 ) @c_bv.update assert_equal( '1001', @c_bv.value.to_s ) #try adding a Signal(BitVector) to an integer: @c_bv <= ( 1 + @c_bv ) @c_bv.update assert_equal( '1010', @c_bv.value.to_s ) #try adding a Bitvector to a Signal: @c_bv <= (@c_bv + BitVector('0011') ) @c_bv.update assert_equal( '1101', @c_bv.value.to_s ) #NOTE: the following doesn't work and probably won't ever #try adding Signal to string literal (which represents BitVector): #@c_bv <= ('0010' + @c_bv) #@c_bv.update #assert_equal( '1111', @c_bv.value.to_s ) end def test_reassignment_options @a_bit <= 0 @a_bit.update assert_equal(0, @a_bit) @a_bit <= '1' @a_bit.update assert_equal(1, @a_bit) @c_bv <= '0000' @c_bv.update assert_equal(RHDL::Signal, @c_bv.class) assert_equal(BitVector, @c_bv.value.class ) assert_equal('0000', @c_bv.value.to_s) end def test_integer_signal @counter <= @counter + 1 @counter.update assert_equal(1, @counter) #try adding two signals: val = Signal( 1 ) @counter <= @counter + val @counter.update assert_equal(2, @counter) end end if false c0 = 0 #Integer a = Signal(Bit('1')) b = Signal(Bit('1')) c = Signal(Bit()) c <= (a + b) c.update if c == '1' puts "yes" end counter = Signal(c0) counter.<<(counter + 1) counter.update puts counter.inspect puts c counter.assign(counter + 8) counter.update puts counter.inspect counter.assign(counter & 5) counter.update puts counter.inspect counter.assign(counter * 0b0101) counter.update puts counter.inspect counter.assign(counter ^ 0xF) counter.update puts counter.inspect if c == '1' puts "yes" end end end
philtomson/RHDL
lib/hardware/RHDL/Signal.rb
Ruby
gpl-2.0
10,266
// C program to store temperature of two cities for a week and display it. #include <stdio.h> //const int CITY = 2; //const int WEEK = 7; int main() { int CITY = 2; int WEEK = 7; int i = 0; int j = 0; int temperature[CITY][WEEK]; for ( i = 0; i < CITY; ++i ) { for( j = 0; j < WEEK; ++j ) { printf ( "i = %d; j = %d;\n", i, j ); printf("City %d, Day %d: ", i+1, j+1); scanf("%d", &temperature[i][j]); } } printf("\nDisplaying values: \n\n"); for ( i = 0; i < CITY; ++i ) { for( j = 0; j < WEEK; ++j ) { printf("City %d, Day %d = %d\n", i+1, j+1, temperature[i][j]); } } return 0; }
andrew0snake/5
tests/pointer/descr/weather.c
C
gpl-2.0
719
#!/bin/sh #Install Docker #sudo which wget #sudo apt-get update $ sudo apt-get install wget #wget -qO- https://get.docker.com/ | sh #echo "Docker Setup complete" #install NodeJs #sudo apt-get update #sudo apt-get install nodejs #sudo apt-get install npm #echo "NodeJS setup Complete" ########################### # Start Docker ########################### sudo chmod 777 ../API/DockerTimeout.sh sudo chmod 777 ../API/Payload/script.sh sudo chmod 777 ../API/Payload/javaRunner.sh sudo chmod 777 UpdateDocker.sh sudo service docker restart sudo ./UpdateDocker.sh
ManoloBrn/Open-CloudCompiler
Setup/Install.sh
Shell
gpl-2.0
567
#!/usr/bin/python # -*- encoding: utf-8; py-indent-offset: 4 -*- # +------------------------------------------------------------------+ # | ____ _ _ __ __ _ __ | # | / ___| |__ ___ ___| | __ | \/ | |/ / | # | | | | '_ \ / _ \/ __| |/ / | |\/| | ' / | # | | |___| | | | __/ (__| < | | | | . \ | # | \____|_| |_|\___|\___|_|\_\___|_| |_|_|\_\ | # | | # | Copyright Mathias Kettner 2014 mk@mathias-kettner.de | # +------------------------------------------------------------------+ # # This file is part of Check_MK. # The official homepage is at http://mathias-kettner.de/check_mk. # # check_mk 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 in version 2. check_mk is distributed # in the hope that it will be useful, but WITHOUT ANY WARRANTY; with- # out even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. See the GNU General Public License for more de- # tails. You should have received a copy of the GNU General Public # License along with GNU Make; see the file COPYING. If not, write # to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, # Boston, MA 02110-1301 USA. import utils import config, time, os, re, pprint import hashlib import weblib, traceback, forms, valuespec, inventory, visuals, metrics import sites import bi import inspect import livestatus from log import logger from gui_exceptions import MKGeneralException, MKUserError, MKInternalError import cmk.paths # Datastructures and functions needed before plugins can be loaded loaded_with_language = False display_options = None # Load all view plugins def load_plugins(force): global loaded_with_language if loaded_with_language == current_language and not force: # always reload the hosttag painters, because new hosttags might have been # added during runtime load_host_tag_painters() clear_alarm_sound_states() return global multisite_datasources ; multisite_datasources = {} global multisite_layouts ; multisite_layouts = {} global multisite_painters ; multisite_painters = {} global multisite_sorters ; multisite_sorters = {} global multisite_builtin_views ; multisite_builtin_views = {} global multisite_painter_options ; multisite_painter_options = {} global multisite_commands ; multisite_commands = [] global multisite_command_groups ; multisite_command_groups = {} global view_hooks ; view_hooks = {} global inventory_displayhints ; inventory_displayhints = {} config.declare_permission_section("action", _("Commands on host and services"), do_sort = True) utils.load_web_plugins("views", globals()) load_host_tag_painters() clear_alarm_sound_states() # This must be set after plugin loading to make broken plugins raise # exceptions all the time and not only the first time (when the plugins # are loaded). loaded_with_language = current_language # Declare permissions for builtin views config.declare_permission_section("view", _("Multisite Views"), do_sort = True) for name, view in multisite_builtin_views.items(): config.declare_permission("view.%s" % name, format_view_title(view), "%s - %s" % (name, _u(view["description"])), config.builtin_role_ids) # Make sure that custom views also have permissions config.declare_dynamic_permissions(lambda: visuals.declare_custom_permissions('views')) declare_inventory_columns() # Load all views - users or builtins def load_views(): global multisite_views, available_views # Skip views which do not belong to known datasources multisite_views = visuals.load('views', multisite_builtin_views, skip_func = lambda v: v['datasource'] not in multisite_datasources) available_views = visuals.available('views', multisite_views) transform_old_views() def permitted_views(): try: return available_views except: # In some cases, for example when handling AJAX calls the views might # have not been loaded yet load_views() return available_views def all_views(): return multisite_views # Convert views that are saved in the pre 1.2.6-style # FIXME: Can be removed one day. Mark as incompatible change or similar. def transform_old_views(): for view in multisite_views.values(): ds_name = view['datasource'] datasource = multisite_datasources[ds_name] if "context" not in view: # legacy views did not have this explicitly view.setdefault("user_sortable", True) if 'context_type' in view: # This code transforms views from user_views.mk which have been migrated with # daily snapshots from 2014-08 till beginning 2014-10. visuals.transform_old_visual(view) elif 'single_infos' not in view: # This tries to map the datasource and additional settings of the # views to get the correct view context # # This code transforms views from views.mk (legacy format) to the current format try: hide_filters = view.get('hide_filters') if 'service' in hide_filters and 'host' in hide_filters: view['single_infos'] = ['service', 'host'] elif 'service' in hide_filters and 'host' not in hide_filters: view['single_infos'] = ['service'] elif 'host' in hide_filters: view['single_infos'] = ['host'] elif 'hostgroup' in hide_filters: view['single_infos'] = ['hostgroup'] elif 'servicegroup' in hide_filters: view['single_infos'] = ['servicegroup'] elif 'aggr_service' in hide_filters: view['single_infos'] = ['service'] elif 'aggr_name' in hide_filters: view['single_infos'] = ['aggr'] elif 'aggr_group' in hide_filters: view['single_infos'] = ['aggr_group'] elif 'log_contact_name' in hide_filters: view['single_infos'] = ['contact'] elif 'event_host' in hide_filters: view['single_infos'] = ['host'] elif hide_filters == ['event_id', 'history_line']: view['single_infos'] = ['history'] elif 'event_id' in hide_filters: view['single_infos'] = ['event'] elif 'aggr_hosts' in hide_filters: view['single_infos'] = ['host'] else: # For all other context types assume the view is showing multiple objects # and the datasource can simply be gathered from the datasource view['single_infos'] = [] except: # Exceptions can happen for views saved with certain GIT versions if config.debug: raise # Convert from show_filters, hide_filters, hard_filters and hard_filtervars # to context construct if 'context' not in view: view['show_filters'] = view['hide_filters'] + view['hard_filters'] + view['show_filters'] single_keys = visuals.get_single_info_keys(view) # First get vars for the classic filters context = {} filtervars = dict(view['hard_filtervars']) all_vars = {} for filter_name in view['show_filters']: if filter_name in single_keys: continue # skip conflictings vars / filters context.setdefault(filter_name, {}) try: f = visuals.get_filter(filter_name) except: # The exact match filters have been removed. They where used only as # link filters anyway - at least by the builtin views. continue for var in f.htmlvars: # Check whether or not the filter is supported by the datasource, # then either skip or use the filter vars if var in filtervars and f.info in datasource['infos']: value = filtervars[var] all_vars[var] = value context[filter_name][var] = value # We changed different filters since the visuals-rewrite. This must be treated here, since # we need to transform views which have been created with the old filter var names. # Changes which have been made so far: changed_filter_vars = { 'serviceregex': { # Name of the filter # old var name: new var name 'service': 'service_regex', }, 'hostregex': { 'host': 'host_regex', }, 'hostgroupnameregex': { 'hostgroup_name': 'hostgroup_regex', }, 'servicegroupnameregex': { 'servicegroup_name': 'servicegroup_regex', }, 'opthostgroup': { 'opthostgroup': 'opthost_group', 'neg_opthostgroup': 'neg_opthost_group', }, 'optservicegroup': { 'optservicegroup': 'optservice_group', 'neg_optservicegroup': 'neg_optservice_group', }, 'hostgroup': { 'hostgroup': 'host_group', 'neg_hostgroup': 'neg_host_group', }, 'servicegroup': { 'servicegroup': 'service_group', 'neg_servicegroup': 'neg_service_group', }, 'host_contactgroup': { 'host_contactgroup': 'host_contact_group', 'neg_host_contactgroup': 'neg_host_contact_group', }, 'service_contactgroup': { 'service_contactgroup': 'service_contact_group', 'neg_service_contactgroup': 'neg_service_contact_group', }, } if filter_name in changed_filter_vars and f.info in datasource['infos']: for old_var, new_var in changed_filter_vars[filter_name].items(): if old_var in filtervars: value = filtervars[old_var] all_vars[new_var] = value context[filter_name][new_var] = value # Now, when there are single object infos specified, add these keys to the # context for single_key in single_keys: if single_key in all_vars: context[single_key] = all_vars[single_key] view['context'] = context # Cleanup unused attributes for k in [ 'hide_filters', 'hard_filters', 'show_filters', 'hard_filtervars' ]: try: del view[k] except KeyError: pass def save_views(us): visuals.save('views', multisite_views) # For each view a function can be registered that has to return either True # or False to show a view as context link view_is_enabled = {} def is_enabled_for(linking_view, view, context_vars): if view["name"] not in view_is_enabled: return True # Not registered are always visible! return view_is_enabled[view["name"]](linking_view, view, context_vars) #. # .--PainterOptions------------------------------------------------------. # | ____ _ _ ___ _ _ | # | | _ \ __ _(_)_ __ | |_ ___ _ __ / _ \ _ __ | |_(_) ___ _ __ ___ | # | | |_) / _` | | '_ \| __/ _ \ '__| | | | '_ \| __| |/ _ \| '_ \/ __| | # | | __/ (_| | | | | | || __/ | | |_| | |_) | |_| | (_) | | | \__ \ | # | |_| \__,_|_|_| |_|\__\___|_| \___/| .__/ \__|_|\___/|_| |_|___/ | # | |_| | # +----------------------------------------------------------------------+ # | Painter options are settings that can be changed per user per view. | # | These options are controlled throught the painter options form which | # | is accessible through the small monitor icon on the top left of the | # | views. | # '----------------------------------------------------------------------' # TODO: Better name it PainterOptions or DisplayOptions? There are options which only affect # painters, but some which affect generic behaviour of the views, so DisplayOptions might # be better. class PainterOptions(object): def __init__(self, view_name=None): self._view_name = view_name # The names of the painter options used by the current view self._used_option_names = None # The effective options for this view self._options = {} def load(self): self._load_from_config() # Load the options to be used for this view def _load_used_options(self, view): if self._used_option_names != None: return # only load once per request options = set([]) for cell in get_group_cells(view) + get_cells(view): options.update(cell.painter_options()) # Also layouts can register painter options layout_name = view.get("layout") if layout_name != None: options.update(multisite_layouts[layout_name].get("options", [])) # TODO: Improve sorting. Add a sort index? self._used_option_names = sorted(options) def _load_from_config(self): if self._is_anonymous_view(): return # never has options if not self.painter_options_permitted(): return # Options are stored per view. Get all options for all views vo = config.user.load_file("viewoptions", {}) self._options = vo.get(self._view_name, {}) def save_to_config(self): vo = config.user.load_file("viewoptions", {}, lock=True) vo[self._view_name] = self._options config.user.save_file("viewoptions", vo) def update_from_url(self, view): self._load_used_options(view) if not self.painter_option_form_enabled(): return if html.has_var("_reset_painter_options"): self._clear_painter_options() return elif html.has_var("_update_painter_options"): self._set_from_submitted_form() def _set_from_submitted_form(self): # TODO: Remove all keys that are in multisite_painter_options # but not in self._used_option_names modified = False for option_name in self._used_option_names: # Get new value for the option from the value spec vs = self.get_valuespec_of(option_name) value = vs.from_html_vars("po_%s" % option_name) if not self._is_set(option_name) or self.get(option_name) != value: modified = True self.set(option_name, value) if modified: self.save_to_config() def _clear_painter_options(self): # TODO: This never removes options that are not existant anymore modified = False for name in multisite_painter_options.keys(): try: del self._options[name] modified = True except KeyError: pass if modified: self.save_to_config() # Also remove the options from current html vars. Otherwise the # painter option form will display the just removed options as # defaults of the painter option form. for varname in html.all_varnames_with_prefix("po_"): html.del_var(varname) def get_valuespec_of(self, name): opt = multisite_painter_options[name] if type(lambda: None) == type(opt["valuespec"]): return opt["valuespec"]() else: return opt["valuespec"] def _is_set(self, name): return name in self._options # Sets a painter option value (only for this request). Is not persisted! def set(self, name, value): self._options[name] = value # Returns either the set value, the provided default value or if none # provided, it returns the default value of the valuespec. def get(self, name, dflt=None): if dflt == None: try: dflt = self.get_valuespec_of(name).default_value() except KeyError: # Some view options (that are not declared as display options) # like "refresh" don't have a valuespec. So they need to default # to None. # TODO: Find all occurences and simply declare them as "invisible" # painter options. pass return self._options.get(name, dflt) # Not falling back to a default value, simply returning None in case # the option is not set. def get_without_default(self, name): return self._options.get(name) def get_all(self): return self._options def _is_anonymous_view(self): return self._view_name == None def painter_options_permitted(self): return config.user.may("general.painter_options") def painter_option_form_enabled(self): return self._used_option_names and self.painter_options_permitted() def show_form(self, view): self._load_used_options(view) if not display_options.enabled(display_options.D) or not self.painter_option_form_enabled(): return html.open_div(id_="painteroptions", class_=["view_form"], style="display: none;") html.begin_form("painteroptions") forms.header(_("Display Options")) for name in self._used_option_names: vs = self.get_valuespec_of(name) forms.section(vs.title()) # TODO: Possible improvement for vars which default is specified # by the view: Don't just default to the valuespecs default. Better # use the view default value here to get the user the current view # settings reflected. vs.render_input("po_%s" % name, self.get(name)) forms.end() html.button("_update_painter_options", _("Submit"), "submit") html.button("_reset_painter_options", _("Reset"), "submit") html.hidden_fields() html.end_form() html.close_div() def prepare_painter_options(view_name=None): global painter_options painter_options = PainterOptions(view_name) painter_options.load() #. # .--Cells---------------------------------------------------------------. # | ____ _ _ | # | / ___|___| | |___ | # | | | / _ \ | / __| | # | | |__| __/ | \__ \ | # | \____\___|_|_|___/ | # | | # +----------------------------------------------------------------------+ # | View cell handling classes. Each cell instanciates a multisite | # | painter to render a table cell. | # '----------------------------------------------------------------------' # A cell is an instance of a painter in a view (-> a cell or a grouping cell) class Cell(object): # Wanted to have the "parse painter spec logic" in one place (The Cell() class) # but this should be cleaned up more. TODO: Move this to another place @staticmethod def painter_exists(painter_spec): if type(painter_spec[0]) == tuple: painter_name = painter_spec[0][0] else: painter_name = painter_spec[0] return painter_name in multisite_painters # Wanted to have the "parse painter spec logic" in one place (The Cell() class) # but this should be cleaned up more. TODO: Move this to another place @staticmethod def is_join_cell(painter_spec): return len(painter_spec) >= 4 def __init__(self, view, painter_spec=None): self._view = view self._painter_name = None self._painter_params = None self._link_view_name = None self._tooltip_painter_name = None if painter_spec: self._from_view(painter_spec) # In views the painters are saved as tuples of the following formats: # # Painter name, Link view name # ('service_discovery_service', None), # # Painter name, Link view name, Hover painter name # ('host_plugin_output', None, None), # # Join column: Painter name, Link view name, hover painter name, Join service description # ('service_description', None, None, u'CPU load') # # Join column: Painter name, Link view name, hover painter name, Join service description, custom title # ('service_description', None, None, u'CPU load') # # Parameterized painters: # Same as above but instead of the "Painter name" a two element tuple with the painter name as # first element and a dictionary of parameters as second element is set. def _from_view(self, painter_spec): if type(painter_spec[0]) == tuple: self._painter_name, self._painter_params = painter_spec[0] else: self._painter_name = painter_spec[0] if painter_spec[1] != None: self._link_view_name = painter_spec[1] # Clean this call to Cell.painter_exists() up! if len(painter_spec) >= 3 and Cell.painter_exists((painter_spec[2], None)): self._tooltip_painter_name = painter_spec[2] # Get a list of columns we need to fetch in order to render this cell def needed_columns(self): columns = set(get_painter_columns(self.painter())) if self._link_view_name: # Make sure that the information about the available views is present. If # called via the reporting, then this might not be the case # TODO: Move this to some better place. views = permitted_views() if self._has_link(): link_view = self._link_view() if link_view: # TODO: Clean this up here for filt in [ visuals.get_filter(fn) for fn in visuals.get_single_info_keys(link_view) ]: columns.update(filt.link_columns) if self.has_tooltip(): columns.update(get_painter_columns(self.tooltip_painter())) return columns def is_joined(self): return False def join_service(self): return None def _has_link(self): return self._link_view_name != None def _link_view(self): try: return get_view_by_name(self._link_view_name) except KeyError: return None def painter(self): return multisite_painters[self._painter_name] def painter_name(self): return self._painter_name def export_title(self): return self._painter_name def painter_options(self): return self.painter().get("options", []) # The parameters configured in the view for this painter. In case the # painter has params, it defaults to the valuespec default value and # in case the painter has no params, it returns None. def painter_parameters(self): vs_painter_params = get_painter_params_valuespec(self.painter()) if not vs_painter_params: return if vs_painter_params and self._painter_params == None: return vs_painter_params.default_value() else: return self._painter_params def title(self, use_short=True): painter = self.painter() if use_short: return painter.get("short", painter["title"]) else: return painter["title"] # Can either be: # True : Is printable in PDF # False : Is not printable at all # "<string>" : ID of a painter_printer (Reporting module) def printable(self): return self.painter().get("printable", True) def has_tooltip(self): return self._tooltip_painter_name != None def tooltip_painter_name(self): return self._tooltip_painter_name def tooltip_painter(self): return multisite_painters[self._tooltip_painter_name] def paint_as_header(self, is_last_column_header=False): # Optional: Sort link in title cell # Use explicit defined sorter or implicit the sorter with the painter name # Important for links: # - Add the display options (Keeping the same display options as current) # - Link to _self (Always link to the current frame) classes = [] onclick = '' title = '' if display_options.enabled(display_options.L) \ and self._view.get('user_sortable', False) \ and get_sorter_name_of_painter(self.painter_name()) is not None: params = [ ('sort', self._sort_url()), ] if display_options.title_options: params.append(('display_options', display_options.title_options)) classes += [ "sort", get_primary_sorter_order(self._view, self.painter_name()) ] onclick = "location.href=\'%s\'" % html.makeuri(params, 'sort') title = _('Sort by %s') % self.title() if is_last_column_header: classes.append("last_col") html.open_th(class_=classes, onclick=onclick, title=title) html.write(self.title()) html.close_th() #html.guitest_record_output("view", ("header", title)) def _sort_url(self): """ The following sorters need to be handled in this order: 1. group by sorter (needed in grouped views) 2. user defined sorters (url sorter) 3. configured view sorters """ sorter = [] group_sort, user_sort, view_sort = get_separated_sorters(self._view) sorter = group_sort + user_sort + view_sort # Now apply the sorter of the current column: # - Negate/Disable when at first position # - Move to the first position when already in sorters # - Add in the front of the user sorters when not set sorter_name = get_sorter_name_of_painter(self.painter_name()) if self.is_joined(): # TODO: Clean this up and then remove Cell.join_service() this_asc_sorter = (sorter_name, False, self.join_service()) this_desc_sorter = (sorter_name, True, self.join_service()) else: this_asc_sorter = (sorter_name, False) this_desc_sorter = (sorter_name, True) if user_sort and this_asc_sorter == user_sort[0]: # Second click: Change from asc to desc order sorter[sorter.index(this_asc_sorter)] = this_desc_sorter elif user_sort and this_desc_sorter == user_sort[0]: # Third click: Remove this sorter sorter.remove(this_desc_sorter) else: # First click: add this sorter as primary user sorter # Maybe the sorter is already in the user sorters or view sorters, remove it for s in [ user_sort, view_sort ]: if this_asc_sorter in s: s.remove(this_asc_sorter) if this_desc_sorter in s: s.remove(this_desc_sorter) # Now add the sorter as primary user sorter sorter = group_sort + [this_asc_sorter] + user_sort + view_sort p = [] for s in sorter: if len(s) == 2: p.append((s[1] and '-' or '') + s[0]) else: p.append((s[1] and '-' or '') + s[0] + '~' + s[2]) return ','.join(p) def render(self, row): row = join_row(row, self) try: tdclass, content = self.render_content(row) except: logger.exception("Failed to render painter '%s' (Row: %r)" % (self._painter_name, row)) raise if tdclass == None: tdclass = "" if tdclass == "" and content == "": return "", "" # Add the optional link to another view if content and self._has_link(): content = link_to_view(content, row, self._link_view_name) # Add the optional mouseover tooltip if content and self.has_tooltip(): tooltip_cell = Cell(self._view, (self.tooltip_painter_name(), None)) tooltip_tdclass, tooltip_content = tooltip_cell.render_content(row) tooltip_text = html.strip_tags(tooltip_content) content = '<span title="%s">%s</span>' % (tooltip_text, content) return tdclass, content # Same as self.render() for HTML output: Gets a painter and a data # row and creates the text for being painted. def render_for_pdf(self, row, time_range): # TODO: Move this somewhere else! def find_htdocs_image_path(filename): dirs = [ cmk.paths.local_web_dir + "/htdocs/", cmk.paths.web_dir + "/htdocs/", ] for d in dirs: if os.path.exists(d + filename): return d + filename try: row = join_row(row, self) css_classes, txt = self.render_content(row) if txt is None: return css_classes, "" txt = txt.strip() # Handle <img...>. Our PDF writer cannot draw arbitrary # images, but all that we need for showing simple icons. # Current limitation: *one* image if txt.lower().startswith("<img"): img_filename = re.sub('.*src=["\']([^\'"]*)["\'].*', "\\1", str(txt)) img_path = find_htdocs_image_path(img_filename) if img_path: txt = ("icon", img_path) else: txt = img_filename if isinstance(txt, HTML): txt = "%s" % txt elif not isinstance(txt, tuple): txt = html.escaper.unescape_attributes(txt) txt = html.strip_tags(txt) return css_classes, txt except Exception: raise MKGeneralException('Failed to paint "%s": %s' % (self.painter_name(), traceback.format_exc())) def render_content(self, row): if not row: return "", "" # nothing to paint painter = self.painter() paint_func = painter["paint"] # Painters can request to get the cell object handed over. # Detect that and give the painter this argument. arg_names = inspect.getargspec(paint_func)[0] painter_args = [] for arg_name in arg_names: if arg_name == "row": painter_args.append(row) elif arg_name == "cell": painter_args.append(self) # Add optional painter arguments from painter specification if "args" in painter: painter_args += painter["args"] return painter["paint"](*painter_args) def paint(self, row, tdattrs="", is_last_cell=False): tdclass, content = self.render(row) has_content = content != "" if is_last_cell: if tdclass == None: tdclass = "last_col" else: tdclass += " last_col" if tdclass: html.write("<td %s class=\"%s\">" % (tdattrs, tdclass)) html.write(content) html.close_td() else: html.write("<td %s>" % (tdattrs)) html.write(content) html.close_td() #html.guitest_record_output("view", ("cell", content)) return has_content class JoinCell(Cell): def __init__(self, view, painter_spec): self._join_service_descr = None self._custom_title = None super(JoinCell, self).__init__(view, painter_spec) def _from_view(self, painter_spec): super(JoinCell, self)._from_view(painter_spec) if len(painter_spec) >= 4: self._join_service_descr = painter_spec[3] if len(painter_spec) == 5: self._custom_title = painter_spec[4] def is_joined(self): return True def join_service(self): return self._join_service_descr def livestatus_filter(self, join_column_name): return "Filter: %s = %s" % \ (livestatus.lqencode(join_column_name), livestatus.lqencode(self._join_service_descr)) def title(self, use_short=True): if self._custom_title: return self._custom_title else: return self._join_service_descr def export_title(self): return "%s.%s" % (self._painter_name, self.join_service()) class EmptyCell(Cell): def __init__(self, view): super(EmptyCell, self).__init__(view) def render(self, row): return "", "" def paint(self, row): return False #. # .--Table of views------------------------------------------------------. # | _____ _ _ __ _ | # | |_ _|_ _| |__ | | ___ ___ / _| __ _(_) _____ _____ | # | | |/ _` | '_ \| |/ _ \ / _ \| |_ \ \ / / |/ _ \ \ /\ / / __| | # | | | (_| | |_) | | __/ | (_) | _| \ V /| | __/\ V V /\__ \ | # | |_|\__,_|_.__/|_|\___| \___/|_| \_/ |_|\___| \_/\_/ |___/ | # | | # +----------------------------------------------------------------------+ # | Show list of all views with buttons for editing | # '----------------------------------------------------------------------' def page_edit_views(): load_views() cols = [ (_('Datasource'), lambda v: multisite_datasources[v["datasource"]]['title']) ] visuals.page_list('views', _("Edit Views"), multisite_views, cols) #. # .--Create View---------------------------------------------------------. # | ____ _ __ ___ | # | / ___|_ __ ___ __ _| |_ ___ \ \ / (_) _____ __ | # | | | | '__/ _ \/ _` | __/ _ \ \ \ / /| |/ _ \ \ /\ / / | # | | |___| | | __/ (_| | || __/ \ V / | | __/\ V V / | # | \____|_| \___|\__,_|\__\___| \_/ |_|\___| \_/\_/ | # | | # +----------------------------------------------------------------------+ # | Select the view type of the new view | # '----------------------------------------------------------------------' # First step: Select the data source # Create datasource selection valuespec, also for other modules # FIXME: Sort the datasources by (assumed) common usage def DatasourceSelection(): # FIXME: Sort the datasources by (assumed) common usage datasources = [] for ds_name, ds in multisite_datasources.items(): datasources.append((ds_name, ds['title'])) return DropdownChoice( title = _('Datasource'), help = _('The datasources define which type of objects should be displayed with this view.'), choices = datasources, sorted = True, columns = 1, default_value = 'services', ) def page_create_view(next_url = None): vs_ds = DatasourceSelection() ds = 'services' # Default selection html.header(_('Create View'), stylesheets=["pages"]) html.begin_context_buttons() back_url = html.var("back", "") html.context_button(_("Back"), back_url or "edit_views.py", "back") html.end_context_buttons() if html.var('save') and html.check_transaction(): try: ds = vs_ds.from_html_vars('ds') vs_ds.validate_value(ds, 'ds') if not next_url: next_url = html.makeuri([('datasource', ds)], filename = "create_view_infos.py") else: next_url = next_url + '&datasource=%s' % ds html.http_redirect(next_url) return except MKUserError, e: html.div(e, class_=["error"]) html.add_user_error(e.varname, e) html.begin_form('create_view') html.hidden_field('mode', 'create') forms.header(_('Select Datasource')) forms.section(vs_ds.title()) vs_ds.render_input('ds', ds) html.help(vs_ds.help()) forms.end() html.button('save', _('Continue'), 'submit') html.hidden_fields() html.end_form() html.footer() def page_create_view_infos(): ds_name = html.var('datasource') if ds_name not in multisite_datasources: raise MKGeneralException(_('The given datasource is not supported')) visuals.page_create_visual('views', multisite_datasources[ds_name]['infos'], next_url = 'edit_view.py?mode=create&datasource=%s&single_infos=%%s' % ds_name) #. # .--Edit View-----------------------------------------------------------. # | _____ _ _ _ __ ___ | # | | ____|__| (_) |_ \ \ / (_) _____ __ | # | | _| / _` | | __| \ \ / /| |/ _ \ \ /\ / / | # | | |__| (_| | | |_ \ V / | | __/\ V V / | # | |_____\__,_|_|\__| \_/ |_|\___| \_/\_/ | # | | # +----------------------------------------------------------------------+ # | | # '----------------------------------------------------------------------' # Return list of available datasources (used to render filters) def get_view_infos(view): ds_name = view.get('datasource', html.var('datasource')) return multisite_datasources[ds_name]['infos'] def page_edit_view(): load_views() visuals.page_edit_visual('views', multisite_views, custom_field_handler = render_view_config, load_handler = transform_view_to_valuespec_value, create_handler = create_view_from_valuespec, info_handler = get_view_infos, ) def view_choices(only_with_hidden = False): choices = [("", "")] for name, view in available_views.items(): if not only_with_hidden or view['single_infos']: title = format_view_title(view) choices.append(("%s" % name, title)) return choices def format_view_title(view): if view.get('mobile', False): return _('Mobile: ') + _u(view["title"]) else: return _u(view["title"]) def view_editor_options(): return [ ('mobile', _('Show this view in the Mobile GUI')), ('mustsearch', _('Show data only on search')), ('force_checkboxes', _('Always show the checkboxes')), ('user_sortable', _('Make view sortable by user')), ('play_sounds', _('Play alarm sounds')), ] def view_editor_specs(ds_name, general_properties=True): load_views() # make sure that available_views is present specs = [] if general_properties: specs.append( ('view', Dictionary( title = _('View Properties'), render = 'form', optional_keys = None, elements = [ ('datasource', FixedValue(ds_name, title = _('Datasource'), totext = multisite_datasources[ds_name]['title'], help = _('The datasource of a view cannot be changed.'), )), ('options', ListChoice( title = _('Options'), choices = view_editor_options(), default_value = ['user_sortable'], )), ('browser_reload', Integer( title = _('Automatic page reload'), unit = _('seconds'), minvalue = 0, help = _('Leave this empty or at 0 for no automatic reload.'), )), ('layout', DropdownChoice( title = _('Basic Layout'), choices = [ (k, v["title"]) for k,v in multisite_layouts.items() if not v.get("hide")], default_value = 'table', sorted = True, )), ('num_columns', Integer( title = _('Number of Columns'), default_value = 1, minvalue = 1, maxvalue = 50, )), ('column_headers', DropdownChoice( title = _('Column Headers'), choices = [ ("off", _("off")), ("pergroup", _("once per group")), ("repeat", _("repeat every 20'th row")), ], default_value = 'pergroup', )), ], )) ) def column_spec(ident, title, ds_name): painters = painters_of_datasource(ds_name) allow_empty = True empty_text = None if ident == 'columns': allow_empty = False empty_text = _("Please add at least one column to your view.") vs_column = Tuple( title = _('Column'), elements = [ CascadingDropdown( title = _('Column'), choices = painter_choices_with_params(painters), no_preselect = True, ), DropdownChoice( title = _('Link'), choices = view_choices, sorted = True, ), DropdownChoice( title = _('Tooltip'), choices = [(None, "")] + painter_choices(painters), ), ], ) join_painters = join_painters_of_datasource(ds_name) if ident == 'columns' and join_painters: join_painters = join_painters_of_datasource(ds_name) vs_column = Alternative( elements = [ vs_column, Tuple( title = _('Joined column'), help = _("A joined column can display information about specific services for " "host objects in a view showing host objects. You need to specify the " "service description of the service you like to show the data for."), elements = [ CascadingDropdown( title = _('Column'), choices = painter_choices_with_params(join_painters), no_preselect = True, ), TextUnicode( title = _('of Service'), allow_empty = False, ), DropdownChoice( title = _('Link'), choices = view_choices, sorted = True, ), DropdownChoice( title = _('Tooltip'), choices = [(None, "")] + painter_choices(join_painters), ), TextUnicode( title = _('Title'), ), ], ), ], style = 'dropdown', match = lambda x: 1 * (x is not None and len(x) == 5), ) return (ident, Dictionary( title = title, render = 'form', optional_keys = None, elements = [ (ident, ListOf(vs_column, title = title, add_label = _('Add column'), allow_empty = allow_empty, empty_text = empty_text, )), ], )) specs.append(column_spec('columns', _('Columns'), ds_name)) specs.append( ('sorting', Dictionary( title = _('Sorting'), render = 'form', optional_keys = None, elements = [ ('sorters', ListOf( Tuple( elements = [ DropdownChoice( title = _('Column'), choices = [ (name, get_painter_title_for_choices(p)) for name, p in sorters_of_datasource(ds_name).items() ], sorted = True, no_preselect = True, ), DropdownChoice( title = _('Order'), choices = [(False, _("Ascending")), (True, _("Descending"))], ), ], orientation = 'horizontal', ), title = _('Sorting'), add_label = _('Add sorter'), )), ], )), ) specs.append(column_spec('grouping', _('Grouping'), ds_name)) return specs def render_view_config(view, general_properties=True): ds_name = view.get("datasource", html.var("datasource")) if not ds_name: raise MKInternalError(_("No datasource defined.")) if ds_name not in multisite_datasources: raise MKInternalError(_('The given datasource is not supported.')) view['datasource'] = ds_name for ident, vs in view_editor_specs(ds_name, general_properties): vs.render_input(ident, view.get(ident)) # Is used to change the view structure to be compatible to # the valuespec This needs to perform the inverted steps of the # transform_valuespec_value_to_view() function. FIXME: One day we should # rewrite this to make no transform needed anymore def transform_view_to_valuespec_value(view): view["view"] = {} # Several global variables are put into a sub-dict # Only copy our known keys. Reporting element, etc. might have their own keys as well for key in [ "datasource", "browser_reload", "layout", "num_columns", "column_headers" ]: if key in view: view["view"][key] = view[key] view["view"]['options'] = [] for key, title in view_editor_options(): if view.get(key): view['view']['options'].append(key) view['visibility'] = {} for key in [ 'hidden', 'hidebutton', 'public' ]: if view.get(key): view['visibility'][key] = view[key] view['grouping'] = { "grouping" : view.get('group_painters', []) } view['sorting'] = { "sorters" : view.get('sorters', {}) } columns = [] view['columns'] = { "columns" : columns } for entry in view.get('painters', []): if len(entry) == 5: pname, viewname, tooltip, join_index, col_title = entry columns.append((pname, join_index, viewname, tooltip or None, col_title)) elif len(entry) == 4: pname, viewname, tooltip, join_index = entry columns.append((pname, join_index, viewname, tooltip or None, '')) elif len(entry) == 3: pname, viewname, tooltip = entry columns.append((pname, viewname, tooltip or None)) else: pname, viewname = entry columns.append((pname, viewname, None)) def transform_valuespec_value_to_view(view): for ident, attrs in view.items(): # Transform some valuespec specific options to legacy view # format. We do not want to change the view data structure # at the moment. if ident == 'view': if "options" in attrs: # First set all options to false for option in dict(view_editor_options()).keys(): view[option] = False # Then set the selected single options for option in attrs['options']: view[option] = True # And cleanup del attrs['options'] view.update(attrs) del view["view"] elif ident == 'sorting': view.update(attrs) del view["sorting"] elif ident == 'grouping': view['group_painters'] = attrs['grouping'] del view["grouping"] elif ident == 'columns': painters = [] for column in attrs['columns']: if len(column) == 5: pname, join_index, viewname, tooltip, col_title = column else: pname, viewname, tooltip = column join_index, col_title = None, None viewname = viewname if viewname else None if join_index and col_title: painters.append((pname, viewname, tooltip, join_index, col_title)) elif join_index: painters.append((pname, viewname, tooltip, join_index)) else: painters.append((pname, viewname, tooltip)) view['painters'] = painters del view["columns"] # Extract properties of view from HTML variables and construct # view object, to be used for saving or displaying # # old_view is the old view dict which might be loaded from storage. # view is the new dict object to be updated. def create_view_from_valuespec(old_view, view): ds_name = old_view.get('datasource', html.var('datasource')) view['datasource'] = ds_name vs_value = {} for ident, vs in view_editor_specs(ds_name): attrs = vs.from_html_vars(ident) vs.validate_value(attrs, ident) vs_value[ident] = attrs transform_valuespec_value_to_view(vs_value) view.update(vs_value) return view #. # .--Display View--------------------------------------------------------. # | ____ _ _ __ ___ | # | | _ \(_)___ _ __ | | __ _ _ _ \ \ / (_) _____ __ | # | | | | | / __| '_ \| |/ _` | | | | \ \ / /| |/ _ \ \ /\ / / | # | | |_| | \__ \ |_) | | (_| | |_| | \ V / | | __/\ V V / | # | |____/|_|___/ .__/|_|\__,_|\__, | \_/ |_|\___| \_/\_/ | # | |_| |___/ | # +----------------------------------------------------------------------+ # | | # '----------------------------------------------------------------------' def show_filter(f): if not f.visible(): html.open_div(style="display:none;") f.display() html.close_div() else: visuals.show_filter(f) def show_filter_form(is_open, filters): # Table muss einen anderen Namen, als das Formular html.open_div(id_="filters", class_=["view_form"], style="display: none;" if not is_open else None) html.begin_form("filter") html.open_table(class_=["filterform"], cellpadding="0", cellspacing="0", border="0") html.open_tr() html.open_td() # sort filters according to title s = [(f.sort_index, f.title, f) for f in filters if f.available()] s.sort() # First show filters with double height (due to better floating # layout) for sort_index, title, f in s: if f.double_height(): show_filter(f) # Now single height filters for sort_index, title, f in s: if not f.double_height(): show_filter(f) html.close_td() html.close_tr() html.open_tr() html.open_td() html.button("search", _("Search"), "submit") html.close_td() html.close_tr() html.close_table() html.hidden_fields() html.end_form() html.close_div() def page_view(): bi.reset_cache_status() # needed for status icon load_views() view_name = html.var("view_name") if view_name == None: raise MKGeneralException(_("Missing the variable view_name in the URL.")) view = available_views.get(view_name) if not view: raise MKGeneralException(_("No view defined with the name '%s'.") % html.attrencode(view_name)) # Gather the page context which is needed for the "add to visual" popup menu # to add e.g. views to dashboards or reports datasource = multisite_datasources[view['datasource']] context = visuals.get_context_from_uri_vars(datasource['infos']) context.update(visuals.get_singlecontext_html_vars(view)) html.set_page_context(context) prepare_painter_options(view_name) painter_options.update_from_url(view) show_view(view, True, True, True) def get_painter_columns(painter): if type(lambda: None) == type(painter["columns"]): return painter["columns"]() else: return painter["columns"] # Display view with real data. This is *the* function everying # is about. def show_view(view, show_heading = False, show_buttons = True, show_footer = True, render_function = None, only_count=False, all_filters_active=False, limit=None): weblib.prepare_display_options(globals()) # Load from hard painter options > view > hard coded default num_columns = painter_options.get("num_columns", view.get("num_columns", 1)) browser_reload = painter_options.get("refresh", view.get("browser_reload", None)) force_checkboxes = view.get("force_checkboxes", False) show_checkboxes = force_checkboxes or html.var('show_checkboxes', '0') == '1' # Get the datasource (i.e. the logical table) try: datasource = multisite_datasources[view["datasource"]] except KeyError: if view["datasource"].startswith("mkeventd_"): raise MKUserError(None, _("The Event Console view '%s' can not be rendered. The Event Console is possibly " "disabled.") % view["name"]) else: raise MKUserError(None, _("The view '%s' using the datasource '%s' can not be rendered " "because the datasource does not exist.") % (view["name"], view["datasource"])) tablename = datasource["table"] # Filters to use in the view # In case of single object views, the needed filters are fixed, but not always present # in context. In this case, take them from the context type definition. use_filters = visuals.filters_of_visual(view, datasource['infos'], all_filters_active, datasource.get('link_filters', {})) # Not all filters are really shown later in show_filter_form(), because filters which # have a hardcoded value are not changeable by the user show_filters = visuals.visible_filters_of_visual(view, use_filters) # FIXME TODO HACK to make grouping single contextes possible on host/service infos # Is hopefully cleaned up soon. if view['datasource'] in ['hosts', 'services']: if html.has_var('hostgroup') and not html.has_var("opthost_group"): html.set_var("opthost_group", html.var("hostgroup")) if html.has_var('servicegroup') and not html.has_var("optservice_group"): html.set_var("optservice_group", html.var("servicegroup")) # TODO: Another hack :( Just like the above one: When opening the view "ec_events_of_host", # which is of single context "host" using a host name of a unrelated event, the list of # events is always empty since the single context filter "host" is sending a "host_name = ..." # filter to livestatus which is not matching a "unrelated event". Instead the filter event_host # needs to be used. # But this may only be done for the unrelated events view. The "ec_events_of_monhost" view still # needs the filter. :-/ # Another idea: We could change these views to non single context views, but then we would not # be able to show the buttons to other host related views, which is also bad. So better stick # with the current mode. if view["datasource"] in [ "mkeventd_events", "mkeventd_history" ] \ and "host" in view["single_infos"] and view["name"] != "ec_events_of_monhost": # Remove the original host name filter use_filters = [ f for f in use_filters if f.name != "host" ] # Set the value for the event host filter if not html.has_var("event_host"): html.set_var("event_host", html.var("host")) # Now populate the HTML vars with context vars from the view definition. Hard # coded default values are treated differently: # # a) single context vars of the view are enforced # b) multi context vars can be overwritten by existing HTML vars visuals.add_context_to_uri_vars(view, datasource["infos"], only_count) # Check that all needed information for configured single contexts are available visuals.verify_single_contexts('views', view, datasource.get('link_filters', {})) # Prepare Filter headers for Livestatus # TODO: When this is used by the reporting then *all* filters are # active. That way the inventory data will always be loaded. When # we convert this to the visuals principle the we need to optimize # this. filterheaders = "" all_active_filters = [ f for f in use_filters if f.available() ] for filt in all_active_filters: header = filt.filter(tablename) filterheaders += header # Apply the site hint / filter if html.var("site"): only_sites = [html.var("site")] else: only_sites = None # Prepare limit: # We had a problem with stats queries on the logtable where # the limit was not applied on the resulting rows but on the # lines of the log processed. This resulted in wrong stats. # For these datasources we ignore the query limits. if limit == None: # Otherwise: specified as argument if not datasource.get('ignore_limit', False): limit = get_limit() # Fork to availability view. We just need the filter headers, since we do not query the normal # hosts and service table, but "statehist". This is *not* true for BI availability, though (see later) if html.var("mode") == "availability" and ( "aggr" not in datasource["infos"] or html.var("timeline_aggr")): context = visuals.get_context_from_uri_vars(datasource['infos']) context.update(visuals.get_singlecontext_html_vars(view)) return render_availability_page(view, datasource, context, filterheaders, only_sites, limit) query = filterheaders + view.get("add_headers", "") # Sorting - use view sorters and URL supplied sorters if not only_count: user_sorters = parse_url_sorters(html.var("sort")) if user_sorters: sorter_list = user_sorters else: sorter_list = view["sorters"] sorters = [ (multisite_sorters[s[0]],) + s[1:] for s in sorter_list if s[0] in multisite_sorters ] else: sorters = [] # Prepare cells of the view # Group cells: Are displayed as titles of grouped rows # Regular cells: Are displaying information about the rows of the type the view is about # Join cells: Are displaying information of a joined source (e.g.service data on host views) group_cells = get_group_cells(view) cells = get_cells(view) regular_cells = get_regular_cells(cells) join_cells = get_join_cells(cells) # Now compute the list of all columns we need to query via Livestatus. # Those are: (1) columns used by the sorters in use, (2) columns use by # column- and group-painters in use and - note - (3) columns used to # satisfy external references (filters) of views we link to. The last bit # is the trickiest. Also compute this list of view options use by the # painters columns = get_needed_regular_columns(group_cells + cells, sorters, datasource) join_columns = get_needed_join_columns(join_cells, sorters, datasource) # Fetch data. Some views show data only after pressing [Search] if (only_count or (not view.get("mustsearch")) or html.var("filled_in") in ["filter", 'actions', 'confirm', 'painteroptions']): # names for additional columns (through Stats: headers) add_columns = datasource.get("add_columns", []) # tablename may be a function instead of a livestatus tablename # In that case that function is used to compute the result. # It may also be a tuple. In this case the first element is a function and the second element # is a list of argument to hand over to the function together with all other arguments that # are passed to query_data(). if type(tablename) == type(lambda x:None): rows = tablename(columns, query, only_sites, limit, all_active_filters) elif type(tablename) == tuple: func, args = tablename rows = func(datasource, columns, add_columns, query, only_sites, limit, *args) else: rows = query_data(datasource, columns, add_columns, query, only_sites, limit) # Now add join information, if there are join columns if join_cells: do_table_join(datasource, rows, filterheaders, join_cells, join_columns, only_sites) # If any painter, sorter or filter needs the information about the host's # inventory, then we load it and attach it as column "host_inventory" if is_inventory_data_needed(group_cells, cells, sorters, all_active_filters): for row in rows: if "host_name" in row: row["host_inventory"] = inventory.load_tree(row["host_name"]) sort_data(rows, sorters) else: rows = [] # Apply non-Livestatus filters for filter in all_active_filters: rows = filter.filter_table(rows) if html.var("mode") == "availability": render_bi_availability(view_title(view), rows) return # TODO: Use livestatus Stats: instead of fetching rows! if only_count: for fname, filter_vars in view["context"].items(): for varname, value in filter_vars.items(): html.del_var(varname) return len(rows) # The layout of the view: it can be overridden by several specifying # an output format (like json or python). Note: the layout is not # always needed. In case of an embedded view in the reporting this # field is simply missing, because the rendering is done by the # report itself. # TODO: CSV export should be handled by the layouts. It cannot # be done generic in most cases if html.output_format == "html": if "layout" in view: layout = multisite_layouts[view["layout"]] else: layout = None else: if "layout" in view and "csv_export" in multisite_layouts[view["layout"]]: multisite_layouts[view["layout"]]["csv_export"](rows, view, group_cells, cells) return else: # Generic layout of export layout = multisite_layouts.get(html.output_format) if not layout: layout = multisite_layouts["json"] # Set browser reload if browser_reload and display_options.enabled(display_options.R) and not only_count: html.set_browser_reload(browser_reload) # Until now no single byte of HTML code has been output. # Now let's render the view. The render_function will be # replaced by the mobile interface for an own version. if not render_function: render_function = render_view render_function(view, rows, datasource, group_cells, cells, show_heading, show_buttons, show_checkboxes, layout, num_columns, show_filters, show_footer, browser_reload) def get_group_cells(view): return [ Cell(view, e) for e in view["group_painters"] if Cell.painter_exists(e) ] def get_cells(view): cells = [] for e in view["painters"]: if not Cell.painter_exists(e): continue if Cell.is_join_cell(e): cells.append(JoinCell(view, e)) else: cells.append(Cell(view, e)) return cells def get_join_cells(cell_list): return filter(lambda x: type(x) == JoinCell, cell_list) def get_regular_cells(cell_list): return filter(lambda x: type(x) == Cell, cell_list) def get_needed_regular_columns(cells, sorters, datasource): # BI availability needs aggr_tree # TODO: wtf? a full reset of the list? Move this far away to a special place! if html.var("mode") == "availability" and "aggr" in datasource["infos"]: return [ "aggr_tree", "aggr_name", "aggr_group" ] columns = columns_of_cells(cells) # Columns needed for sorters # TODO: Move sorter parsing and logic to something like Cells() for s in sorters: if len(s) == 2: columns.update(s[0]["columns"]) # Add key columns, needed for executing commands columns.update(datasource["keys"]) # Add idkey columns, needed for identifying the row columns.update(datasource["idkeys"]) # Remove (implicit) site column try: columns.remove("site") except KeyError: pass return list(columns) def get_needed_join_columns(join_cells, sorters, datasource): join_columns = columns_of_cells(join_cells) # Columns needed for sorters # TODO: Move sorter parsing and logic to something like Cells() for s in sorters: if len(s) != 2: join_columns.update(s[0]["columns"]) return list(join_columns) def is_inventory_data_needed(group_cells, cells, sorters, all_active_filters): for cell in cells: if cell.has_tooltip(): if cell.tooltip_painter_name().startswith("inv_"): return True for s in sorters: if s[0].get("load_inv"): return True for cell in group_cells + cells: if cell.painter().get("load_inv"): return True for filt in all_active_filters: if filt.need_inventory(): return True return False def columns_of_cells(cells): columns = set([]) for cell in cells: columns.update(cell.needed_columns()) return columns # Output HTML code of a view. If you add or remove paramters here, # then please also do this in htdocs/mobile.py! def render_view(view, rows, datasource, group_painters, painters, show_heading, show_buttons, show_checkboxes, layout, num_columns, show_filters, show_footer, browser_reload): if html.transaction_valid() and html.do_actions(): html.set_browser_reload(0) # Show heading (change between "preview" mode and full page mode) if show_heading: # Show/Hide the header with page title, MK logo, etc. if display_options.enabled(display_options.H): # FIXME: view/layout/module related stylesheets/javascripts e.g. in case of BI? html.body_start(view_title(view), stylesheets=["pages","views","status","bi"]) if display_options.enabled(display_options.T): html.top_heading(view_title(view)) has_done_actions = False row_count = len(rows) # This is a general flag which makes the command form render when the current # view might be able to handle commands. When no commands are possible due missing # permissions or datasources without commands, the form is not rendered command_form = should_show_command_form(datasource) if command_form: weblib.init_selection() # Is the layout able to display checkboxes? can_display_checkboxes = layout.get('checkboxes', False) if show_buttons: show_combined_graphs_button = \ ("host" in datasource["infos"] or "service" in datasource["infos"]) and \ (type(datasource["table"]) == str) and \ ("host" in datasource["table"] or "service" in datasource["table"]) show_context_links(view, datasource, show_filters, # Take into account: permissions, display_options row_count > 0 and command_form, # Take into account: layout capabilities can_display_checkboxes and not view.get("force_checkboxes"), show_checkboxes, # Show link to availability datasource["table"] in [ "hosts", "services" ] or "aggr" in datasource["infos"], # Show link to combined graphs show_combined_graphs_button,) # User errors in filters html.show_user_errors() # Filter form filter_isopen = view.get("mustsearch") and not html.var("filled_in") if display_options.enabled(display_options.F) and len(show_filters) > 0: show_filter_form(filter_isopen, show_filters) # Actions if command_form: # If we are currently within an action (confirming or executing), then # we display only the selected rows (if checkbox mode is active) if show_checkboxes and html.do_actions(): rows = filter_selected_rows(view, rows, weblib.get_rowselection('view-' + view['name'])) # There are one shot actions which only want to affect one row, filter the rows # by this id during actions if html.has_var("_row_id") and html.do_actions(): rows = filter_by_row_id(view, rows) if html.do_actions() and html.transaction_valid(): # submit button pressed, no reload try: # Create URI with all actions variables removed backurl = html.makeuri([], delvars=['filled_in', 'actions']) has_done_actions = do_actions(view, datasource["infos"][0], rows, backurl) except MKUserError, e: html.show_error(e) html.add_user_error(e.varname, e) if display_options.enabled(display_options.C): show_command_form(True, datasource) elif display_options.enabled(display_options.C): # (*not* display open, if checkboxes are currently shown) show_command_form(False, datasource) # Also execute commands in cases without command form (needed for Python- # web service e.g. for NagStaMon) elif row_count > 0 and config.user.may("general.act") \ and html.do_actions() and html.transaction_valid(): # There are one shot actions which only want to affect one row, filter the rows # by this id during actions if html.has_var("_row_id") and html.do_actions(): rows = filter_by_row_id(view, rows) try: do_actions(view, datasource["infos"][0], rows, '') except: pass # currently no feed back on webservice painter_options.show_form(view) # The refreshing content container if display_options.enabled(display_options.R): html.open_div(id_="data_container") if not has_done_actions: # Limit exceeded? Show warning if display_options.enabled(display_options.W): check_limit(rows, get_limit()) layout["render"](rows, view, group_painters, painters, num_columns, show_checkboxes and not html.do_actions()) headinfo = "%d %s" % (row_count, _("row") if row_count == 1 else _("rows")) if show_checkboxes: selected = filter_selected_rows(view, rows, weblib.get_rowselection('view-' + view['name'])) headinfo = "%d/%s" % (len(selected), headinfo) if html.output_format == "html": html.javascript("update_headinfo('%s');" % headinfo) # The number of rows might have changed to enable/disable actions and checkboxes if show_buttons: update_context_links( # don't take display_options into account here ('c' is set during reload) row_count > 0 and should_show_command_form(datasource, ignore_display_option=True), # and not html.do_actions(), can_display_checkboxes ) # Play alarm sounds, if critical events have been displayed if display_options.enabled(display_options.S) and view.get("play_sounds"): play_alarm_sounds() else: # Always hide action related context links in this situation update_context_links(False, False) # In multi site setups error messages of single sites do not block the # output and raise now exception. We simply print error messages here. # In case of the web service we show errors only on single site installations. if config.show_livestatus_errors \ and display_options.enabled(display_options.W) \ and html.output_format == "html": for sitename, info in sites.live().dead_sites().items(): html.show_error("<b>%s - %s</b><br>%s" % (info["site"]["alias"], _('Livestatus error'), info["exception"])) # FIXME: Sauberer waere noch die Status Icons hier mit aufzunehmen if display_options.enabled(display_options.R): html.close_div() if show_footer: pid = os.getpid() if sites.live().successfully_persisted(): html.add_status_icon("persist", _("Reused persistent livestatus connection from earlier request (PID %d)") % pid) if bi.reused_compilation(): html.add_status_icon("aggrcomp", _("Reused cached compiled BI aggregations (PID %d)") % pid) html.bottom_focuscode() if display_options.enabled(display_options.Z): html.bottom_footer() if display_options.enabled(display_options.H): html.body_end() def check_limit(rows, limit): count = len(rows) if limit != None and count >= limit + 1: text = _("Your query produced more than %d results. ") % limit if html.var("limit", "soft") == "soft" and config.user.may("general.ignore_soft_limit"): text += html.render_a(_('Repeat query and allow more results.'), target="_self", href=html.makeuri([("limit", "hard")])) elif html.var("limit") == "hard" and config.user.may("general.ignore_hard_limit"): text += html.render_a(_('Repeat query without limit.'), target="_self", href=html.makeuri([("limit", "none")])) text += " " + _("<b>Note:</b> the shown results are incomplete and do not reflect the sort order.") html.show_warning(text) del rows[limit:] return False return True def do_table_join(master_ds, master_rows, master_filters, join_cells, join_columns, only_sites): join_table, join_master_column = master_ds["join"] slave_ds = multisite_datasources[join_table] join_slave_column = slave_ds["joinkey"] # Create additional filters join_filters = [] for cell in join_cells: join_filters.append(cell.livestatus_filter(join_slave_column)) join_filters.append("Or: %d" % len(join_filters)) query = "%s%s\n" % (master_filters, "\n".join(join_filters)) rows = query_data(slave_ds, [join_master_column, join_slave_column] + join_columns, [], query, only_sites, None) per_master_entry = {} current_key = None current_entry = None for row in rows: master_key = (row["site"], row[join_master_column]) if master_key != current_key: current_key = master_key current_entry = {} per_master_entry[current_key] = current_entry current_entry[row[join_slave_column]] = row # Add this information into master table in artificial column "JOIN" for row in master_rows: key = (row["site"], row[join_master_column]) joininfo = per_master_entry.get(key, {}) row["JOIN"] = joininfo g_alarm_sound_states = set([]) def clear_alarm_sound_states(): g_alarm_sound_states.clear() def save_state_for_playing_alarm_sounds(row): if not config.enable_sounds or not config.sounds: return # TODO: Move this to a generic place. What about -1? host_state_map = { 0: "up", 1: "down", 2: "unreachable"} service_state_map = { 0: "up", 1: "warning", 2: "critical", 3: "unknown"} for state_map, state in [ (host_state_map, row.get("host_hard_state", row.get("host_state"))), (service_state_map, row.get("service_last_hard_state", row.get("service_state"))) ]: if state is None: continue try: state_name = state_map[int(state)] except KeyError: continue g_alarm_sound_states.add(state_name) def play_alarm_sounds(): if not config.enable_sounds or not config.sounds: return url = config.sound_url if not url.endswith("/"): url += "/" for state_name, wav in config.sounds: if not state_name or state_name in g_alarm_sound_states: html.play_sound(url + wav) break # only one sound at one time # How many data rows may the user query? def get_limit(): limitvar = html.var("limit", "soft") if limitvar == "hard" and config.user.may("general.ignore_soft_limit"): return config.hard_query_limit elif limitvar == "none" and config.user.may("general.ignore_hard_limit"): return None else: return config.soft_query_limit def view_title(view): return visuals.visual_title('view', view) def view_optiondial(view, option, choices, help): # Darn: The option "refresh" has the name "browser_reload" in the # view definition if option == "refresh": name = "browser_reload" else: name = option # Take either the first option of the choices, the view value or the # configured painter option. value = painter_options.get(option, dflt=view.get(name, choices[0][0])) title = dict(choices).get(value, value) html.begin_context_buttons() # just to be sure # Remove unicode strings choices = [ [c[0], str(c[1])] for c in choices ] html.open_div(id_="optiondial_%s" % option, class_=["optiondial", option, "val_%s" % value], title=help, onclick="view_dial_option(this, \'%s\', \'%s\', %r)" % (view["name"], option, choices)) html.div(title) html.close_div() html.final_javascript("init_optiondial('optiondial_%s');" % option) def view_optiondial_off(option): html.div('', class_=["optiondial", "off", option]) # FIXME: Consolidate with html.toggle_button() rendering functions def toggler(id, icon, help, onclick, value, hidden = False): html.begin_context_buttons() # just to be sure hide = ' style="display:none"' if hidden else '' html.write('<div id="%s_on" title="%s" class="togglebutton %s %s" %s>' '<a href="javascript:void(0)" onclick="%s"><img src="images/icon_%s.png"></a></div>' % ( id, help, icon, value and "down" or "up", hide, onclick, icon)) # Will be called when the user presses the upper button, in order # to persist the new setting - and to make it active before the # browser reload of the DIV containing the actual status data is done. def ajax_set_viewoption(): view_name = html.var("view_name") option = html.var("option") value = html.var("value") value = { 'true' : True, 'false' : False }.get(value, value) if type(value) == str and value[0].isdigit(): try: value = int(value) except: pass po = PainterOptions(view_name) po.load() po.set(option, value) po.save_to_config() def show_context_links(thisview, datasource, show_filters, enable_commands, enable_checkboxes, show_checkboxes, show_availability, show_combined_graphs): # html.begin_context_buttons() called automatically by html.context_button() # That way if no button is painted we avoid the empty container if display_options.enabled(display_options.B): execute_hooks('buttons-begin') filter_isopen = html.var("filled_in") != "filter" and thisview.get("mustsearch") if display_options.enabled(display_options.F): if html.var("filled_in") == "filter": icon = "filters_set" help = _("The current data is being filtered") else: icon = "filters" help = _("Set a filter for refining the shown data") html.toggle_button("filters", filter_isopen, icon, help, disabled=not show_filters) if display_options.enabled(display_options.D): html.toggle_button("painteroptions", False, "painteroptions", _("Modify display options"), disabled=not painter_options.painter_option_form_enabled()) if display_options.enabled(display_options.C): html.toggle_button("commands", False, "commands", _("Execute commands on hosts, services and other objects"), hidden = not enable_commands) html.toggle_button("commands", False, "commands", "", hidden=enable_commands, disabled=True) selection_enabled = (enable_commands and enable_checkboxes) or thisview.get("force_checkboxes") if not thisview.get("force_checkboxes"): toggler("checkbox", "checkbox", _("Enable/Disable checkboxes for selecting rows for commands"), "location.href='%s';" % html.makeuri([('show_checkboxes', show_checkboxes and '0' or '1')]), show_checkboxes, hidden = True) # not selection_enabled) html.toggle_button("checkbox", False, "checkbox", "", hidden=not thisview.get("force_checkboxes"), disabled=True) html.javascript('g_selection_enabled = %s;' % ('true' if selection_enabled else 'false')) if display_options.enabled(display_options.O): if config.user.may("general.view_option_columns"): choices = [ [x, "%s" % x] for x in config.view_option_columns ] view_optiondial(thisview, "num_columns", choices, _("Change the number of display columns")) else: view_optiondial_off("num_columns") if display_options.enabled(display_options.R) and config.user.may("general.view_option_refresh"): choices = [ [x, {0:_("off")}.get(x, str(x) + "s") ] for x in config.view_option_refreshes ] view_optiondial(thisview, "refresh", choices, _("Change the refresh rate")) else: view_optiondial_off("refresh") if display_options.enabled(display_options.B): # WATO: If we have a host context, then show button to WATO, if permissions allow this if html.has_var("host") \ and config.wato_enabled \ and config.user.may("wato.use") \ and (config.user.may("wato.hosts") or config.user.may("wato.seeall")): host = html.var("host") if host: url = wato.link_to_host_by_name(host) else: url = wato.link_to_folder_by_path(html.var("wato_folder", "")) html.context_button(_("WATO"), url, "wato", id="wato", bestof = config.context_buttons_to_show) # Button for creating an instant report (if reporting is available) if config.reporting_available() and config.user.may("general.reporting"): html.context_button(_("Export as PDF"), html.makeuri([], filename="report_instant.py"), "report", class_="context_pdf_export") # Buttons to other views, dashboards, etc. links = visuals.collect_context_links(thisview) for linktitle, uri, icon, buttonid in links: html.context_button(linktitle, url=uri, icon=icon, id=buttonid, bestof=config.context_buttons_to_show) # Customize/Edit view button if display_options.enabled(display_options.E) and config.user.may("general.edit_views"): url_vars = [ ("back", html.requested_url()), ("load_name", thisview["name"]), ] if thisview["owner"] != config.user.id: url_vars.append(("load_user", thisview["owner"])) url = html.makeuri_contextless(url_vars, filename="edit_view.py") html.context_button(_("Edit View"), url, "edit", id="edit", bestof=config.context_buttons_to_show) if display_options.enabled(display_options.E): if show_availability: html.context_button(_("Availability"), html.makeuri([("mode", "availability")]), "availability") if show_combined_graphs and config.combined_graphs_available(): html.context_button(_("Combined graphs"), html.makeuri([ ("single_infos", ",".join(thisview["single_infos"])), ("datasource", thisview["datasource"]), ("view_title", view_title(thisview)), ], filename="combined_graphs.py"), "pnp") if display_options.enabled(display_options.B): execute_hooks('buttons-end') html.end_context_buttons() def update_context_links(enable_command_toggle, enable_checkbox_toggle): html.javascript("update_togglebutton('commands', %d);" % (enable_command_toggle and 1 or 0)) html.javascript("update_togglebutton('checkbox', %d);" % (enable_command_toggle and enable_checkbox_toggle and 1 or 0, )) def ajax_count_button(): id = html.var("id") counts = config.user.load_file("buttoncounts", {}) for i in counts: counts[i] *= 0.95 counts.setdefault(id, 0) counts[id] += 1 config.user.save_file("buttoncounts", counts) # Retrieve data via livestatus, convert into list of dicts, # prepare row-function needed for painters # datasource: the datasource object as defined in plugins/views/datasources.py # columns: the list of livestatus columns to query # add_columns: list of columns the datasource is known to add itself # (couldn't we get rid of this parameter by looking that up ourselves?) # add_headers: additional livestatus headers to add # only_sites: list of sites the query is limited to # limit: maximum number of data rows to query def query_data(datasource, columns, add_columns, add_headers, only_sites = None, limit = None, tablename=None): if only_sites is None: only_sites = [] if tablename == None: tablename = datasource["table"] add_headers += datasource.get("add_headers", "") merge_column = datasource.get("merge_by") if merge_column: columns = [merge_column] + columns # Most layouts need current state of object in order to # choose background color - even if no painter for state # is selected. Make sure those columns are fetched. This # must not be done for the table 'log' as it cannot correctly # distinguish between service_state and host_state if "log" not in datasource["infos"]: state_columns = [] if "service" in datasource["infos"]: state_columns += [ "service_has_been_checked", "service_state" ] if "host" in datasource["infos"]: state_columns += [ "host_has_been_checked", "host_state" ] for c in state_columns: if c not in columns: columns.append(c) auth_domain = datasource.get("auth_domain", "read") # Remove columns which are implicitely added by the datasource columns = [ c for c in columns if c not in add_columns ] query = "GET %s\n" % tablename rows = do_query_data(query, columns, add_columns, merge_column, add_headers, only_sites, limit, auth_domain) # Datasource may have optional post processing function to filter out rows post_process_func = datasource.get("post_process") if post_process_func: return post_process_func(rows) else: return rows def do_query_data(query, columns, add_columns, merge_column, add_headers, only_sites, limit, auth_domain): query += "Columns: %s\n" % " ".join(columns) query += add_headers sites.live().set_prepend_site(True) if limit != None: sites.live().set_limit(limit + 1) # + 1: We need to know, if limit is exceeded else: sites.live().set_limit(None) if config.debug_livestatus_queries \ and html.output_format == "html" and display_options.enabled(display_options.W): html.open_div(class_=["livestatus", "message"]) html.tt(query.replace('\n', '<br>\n')) html.close_div() if only_sites: sites.live().set_only_sites(only_sites) sites.live().set_auth_domain(auth_domain) data = sites.live().query(query) sites.live().set_auth_domain("read") sites.live().set_only_sites(None) sites.live().set_prepend_site(False) sites.live().set_limit() # removes limit if merge_column: data = merge_data(data, columns) # convert lists-rows into dictionaries. # performance, but makes live much easier later. columns = ["site"] + columns + add_columns rows = [ dict(zip(columns, row)) for row in data ] return rows # Merge all data rows with different sites but the same value # in merge_column. We require that all column names are prefixed # with the tablename. The column with the merge key is required # to be the *second* column (right after the site column) def merge_data(data, columns): merged = {} mergefuncs = [lambda a,b: ""] # site column is not merged def worst_service_state(a, b): if a == 2 or b == 2: return 2 else: return max(a, b) def worst_host_state(a, b): if a == 1 or b == 1: return 1 else: return max(a, b) for c in columns: tablename, col = c.split("_", 1) if col.startswith("num_") or col.startswith("members"): mergefunc = lambda a,b: a+b elif col.startswith("worst_service"): return worst_service_state elif col.startswith("worst_host"): return worst_host_state else: mergefunc = lambda a,b: a mergefuncs.append(mergefunc) for row in data: mergekey = row[1] if mergekey in merged: oldrow = merged[mergekey] merged[mergekey] = [ f(a,b) for f,a,b in zip(mergefuncs, oldrow, row) ] else: merged[mergekey] = row # return all rows sorted according to merge key mergekeys = merged.keys() mergekeys.sort() return [ merged[k] for k in mergekeys ] # Sort data according to list of sorters. The tablename # is needed in order to handle different column names # for same objects (e.g. host_name in table services and # simply name in table hosts) def sort_data(data, sorters): if len(sorters) == 0: return # Handle case where join columns are not present for all rows def save_compare(compfunc, row1, row2, args): if row1 == None and row2 == None: return 0 elif row1 == None: return -1 elif row2 == None: return 1 else: if args: return compfunc(row1, row2, *args) else: return compfunc(row1, row2) sort_cmps = [] for s in sorters: cmpfunc = s[0]["cmp"] negate = -1 if s[1] else 1 if len(s) > 2: joinkey = s[2] # e.g. service description else: joinkey = None sort_cmps.append((cmpfunc, negate, joinkey, s[0].get('args'))) def multisort(e1, e2): for func, neg, joinkey, args in sort_cmps: if joinkey: # Sorter for join column, use JOIN info c = neg * save_compare(func, e1["JOIN"].get(joinkey), e2["JOIN"].get(joinkey), args) else: if args: c = neg * func(e1, e2, *args) else: c = neg * func(e1, e2) if c != 0: return c return 0 # equal data.sort(multisort) def sorters_of_datasource(ds_name): return allowed_for_datasource(multisite_sorters, ds_name) def painters_of_datasource(ds_name): return allowed_for_datasource(multisite_painters, ds_name) def join_painters_of_datasource(ds_name): ds = multisite_datasources[ds_name] if "join" not in ds: return {} # no joining with this datasource # Get the painters allowed for the join "source" and "target" painters = painters_of_datasource(ds_name) join_painters_unfiltered = allowed_for_datasource(multisite_painters, ds['join'][0]) # Filter out painters associated with the "join source" datasource join_painters = {} for key, val in join_painters_unfiltered.items(): if key not in painters: join_painters[key] = val return join_painters # Filters a list of sorters or painters and decides which of # those are available for a certain data source def allowed_for_datasource(collection, datasourcename): datasource = multisite_datasources[datasourcename] infos_available = set(datasource["infos"]) add_columns = datasource.get("add_columns", []) allowed = {} for name, item in collection.items(): infos_needed = infos_needed_by_painter(item, add_columns) if len(infos_needed.difference(infos_available)) == 0: allowed[name] = item return allowed def infos_needed_by_painter(painter, add_columns=None): if add_columns is None: add_columns = [] columns = get_painter_columns(painter) return set([ c.split("_", 1)[0] for c in columns if c != "site" and c not in add_columns]) # Returns either the valuespec of the painter parameters or None def get_painter_params_valuespec(painter): if "params" not in painter: return if type(lambda: None) == type(painter["params"]): return painter["params"]() else: return painter["params"] def painter_choices(painters, add_params=False): choices = [] for name, painter in painters.items(): title = get_painter_title_for_choices(painter) # Add the optional valuespec for painter parameters if add_params and "params" in painter: vs_params = get_painter_params_valuespec(painter) choices.append((name, title, vs_params)) else: choices.append((name, title)) return sorted(choices, key=lambda x: x[1]) def get_painter_title_for_choices(painter): info_title = "/".join([ visuals.infos[info_name]["title_plural"] for info_name in sorted(infos_needed_by_painter(painter)) ]) # TODO: Cleanup the special case for sites. How? Add an info for it? if painter["columns"] == ["site"]: info_title = _("Site") return "%s: %s" % (info_title, painter["title"]) def painter_choices_with_params(painters): return painter_choices(painters, add_params=True) #. # .--Commands------------------------------------------------------------. # | ____ _ | # | / ___|___ _ __ ___ _ __ ___ __ _ _ __ __| |___ | # | | | / _ \| '_ ` _ \| '_ ` _ \ / _` | '_ \ / _` / __| | # | | |__| (_) | | | | | | | | | | | (_| | | | | (_| \__ \ | # | \____\___/|_| |_| |_|_| |_| |_|\__,_|_| |_|\__,_|___/ | # | | # +----------------------------------------------------------------------+ # | Functions dealing with external commands send to the monitoring | # | core. The commands themselves are defined as a plugin. Shipped | # | command definitions are in plugins/views/commands.py. | # | We apologize for the fact that we one time speak of "commands" and | # | the other time of "action". Both is the same here... | # '----------------------------------------------------------------------' # Checks whether or not this view handles commands for the current user # When it does not handle commands the command tab, command form, row # selection and processing commands is disabled. def should_show_command_form(datasource, ignore_display_option=False): if not ignore_display_option and display_options.disabled(display_options.C): return False if not config.user.may("general.act"): return False # What commands are available depends on the Livestatus table we # deal with. If a data source provides information about more # than one table, (like services datasource also provide host # information) then the first info is the primary table. So 'what' # will be one of "host", "service", "command" or "downtime". what = datasource["infos"][0] for command in multisite_commands: if what in command["tables"] and config.user.may(command["permission"]): return True return False def show_command_form(is_open, datasource): # What commands are available depends on the Livestatus table we # deal with. If a data source provides information about more # than one table, (like services datasource also provide host # information) then the first info is the primary table. So 'what' # will be one of "host", "service", "command" or "downtime". what = datasource["infos"][0] html.open_div(id_="commands", class_=["view_form"], style="display:none;" if not is_open else None) html.begin_form("actions") html.hidden_field("_do_actions", "yes") html.hidden_field("actions", "yes") html.hidden_fields() # set all current variables, exception action vars # Show command forms, grouped by (optional) command group by_group = {} for command in multisite_commands: if what in command["tables"] and config.user.may(command["permission"]): # Some special commands can be shown on special views using this option. # It is currently only used in custom views, not shipped with check_mk. if command.get('only_view') and html.var('view_name') != command['only_view']: continue group = command.get("group", "various") by_group.setdefault(group, []).append(command) for group_ident, group_commands in sorted(by_group.items(), key=lambda x: multisite_command_groups[x[0]]["sort_index"]): forms.header(multisite_command_groups[group_ident]["title"], narrow=True) for command in group_commands: forms.section(command["title"]) command["render"]() forms.end() html.end_form() html.close_div() # Examine the current HTML variables in order determine, which # command the user has selected. The fetch ids from a data row # (host name, service description, downtime/commands id) and # construct one or several core command lines and a descriptive # title. def core_command(what, row, row_nr, total_rows): host = row.get("host_name") descr = row.get("service_description") if what == "host": spec = host cmdtag = "HOST" elif what == "service": spec = "%s;%s" % (host, descr) cmdtag = "SVC" else: spec = row.get(what + "_id") if descr: cmdtag = "SVC" else: cmdtag = "HOST" commands = None title = None # Call all command actions. The first one that detects # itself to be executed (by examining the HTML variables) # will return a command to execute and a title for the # confirmation dialog. for cmd in multisite_commands: if config.user.may(cmd["permission"]): # Does the command need information about the total number of rows # and the number of the current row? Then specify that if cmd.get("row_stats"): result = cmd["action"](cmdtag, spec, row, row_nr, total_rows) else: result = cmd["action"](cmdtag, spec, row) if result: executor = cmd.get("executor", command_executor_livestatus) commands, title = result break # Use the title attribute to determine if a command exists, since the list # of commands might be empty (e.g. in case of "remove all downtimes" where) # no downtime exists in a selection of rows. if not title: raise MKUserError(None, _("Sorry. This command is not implemented.")) # Some commands return lists of commands, others # just return one basic command. Convert those if type(commands) != list: commands = [commands] return commands, title, executor def command_executor_livestatus(command, site): sites.live().command("[%d] %s" % (int(time.time()), command), site) # make gettext localize some magic texts _("services") _("hosts") _("commands") _("downtimes") _("aggregations") # Returns: # True -> Actions have been done # False -> No actions done because now rows selected # [...] new rows -> Rows actions (shall/have) be performed on def do_actions(view, what, action_rows, backurl): if not config.user.may("general.act"): html.show_error(_("You are not allowed to perform actions. " "If you think this is an error, please ask " "your administrator grant you the permission to do so.")) return False # no actions done if not action_rows: message = _("No rows selected to perform actions for.") if html.output_format == "html": # sorry for this hack message += '<br><a href="%s">%s</a>' % (backurl, _('Back to view')) html.show_error(message) return False # no actions done command = None title, executor = core_command(what, action_rows[0], 0, len(action_rows))[1:3] # just get the title and executor if not html.confirm(_("Do you really want to %(title)s the following %(count)d %(what)s?") % { "title" : title, "count" : len(action_rows), "what" : visuals.infos[what]["title_plural"], }, method = 'GET'): return False count = 0 already_executed = set([]) for nr, row in enumerate(action_rows): core_commands, title, executor = core_command(what, row, nr, len(action_rows)) for command_entry in core_commands: site = row.get("site") # site is missing for BI rows (aggregations can spawn several sites) if (site, command_entry) not in already_executed: # Some command functions return the information about the site per-command (e.g. for BI) if type(command_entry) == tuple: site, command = command_entry else: command = command_entry if type(command) == unicode: command = command.encode("utf-8") executor(command, site) already_executed.add((site, command_entry)) count += 1 message = None if command: message = _("Successfully sent %d commands.") % count if config.debug: message += _("The last one was: <pre>%s</pre>") % command elif count == 0: message = _("No matching data row. No command sent.") if message: if html.output_format == "html": # sorry for this hack message += '<br><a href="%s">%s</a>' % (backurl, _('Back to view')) if html.var("show_checkboxes") == "1": html.del_var("selection") weblib.selection_id() backurl += "&selection=" + html.var("selection") message += '<br><a href="%s">%s</a>' % (backurl, _('Back to view with checkboxes reset')) if html.var("_show_result") == "0": html.immediate_browser_redirect(0.5, backurl) html.message(message) return True def filter_by_row_id(view, rows): wanted_row_id = html.var("_row_id") for row in rows: if row_id(view, row) == wanted_row_id: return [row] return [] def filter_selected_rows(view, rows, selected_ids): action_rows = [] for row in rows: if row_id(view, row) in selected_ids: action_rows.append(row) return action_rows def get_context_link(user, viewname): if viewname in available_views: return "view.py?view_name=%s" % viewname else: return None def ajax_export(): load_views() for name, view in available_views.items(): view["owner"] = '' view["public"] = True html.write(pprint.pformat(available_views)) def get_view_by_name(view_name): load_views() return available_views[view_name] #. # .--Plugin Helpers------------------------------------------------------. # | ____ _ _ _ _ _ | # | | _ \| |_ _ __ _(_)_ __ | | | | ___| |_ __ ___ _ __ ___ | # | | |_) | | | | |/ _` | | '_ \ | |_| |/ _ \ | '_ \ / _ \ '__/ __| | # | | __/| | |_| | (_| | | | | | | _ | __/ | |_) | __/ | \__ \ | # | |_| |_|\__,_|\__, |_|_| |_| |_| |_|\___|_| .__/ \___|_| |___/ | # | |___/ |_| | # +----------------------------------------------------------------------+ # | | # '----------------------------------------------------------------------' def register_command_group(ident, title, sort_index): multisite_command_groups[ident] = { "title" : title, "sort_index" : sort_index, } def register_hook(hook, func): if not hook in view_hooks: view_hooks[hook] = [] if func not in view_hooks[hook]: view_hooks[hook].append(func) def execute_hooks(hook): for hook_func in view_hooks.get(hook, []): try: hook_func() except: if config.debug: raise MKGeneralException(_('Problem while executing hook function %s in hook %s: %s') % (hook_func.__name__, hook, traceback.format_exc())) else: pass def join_row(row, cell): if type(cell) == JoinCell: return row.get("JOIN", {}).get(cell.join_service()) else: return row def url_to_view(row, view_name): if display_options.disabled(display_options.I): return None view = permitted_views().get(view_name) if view: # Get the context type of the view to link to, then get the parameters of this # context type and try to construct the context from the data of the row url_vars = [] datasource = multisite_datasources[view['datasource']] for info_key in datasource['infos']: if info_key in view['single_infos']: # Determine which filters (their names) need to be set # for specifying in order to select correct context for the # target view. for filter_name in visuals.info_params(info_key): filter_object = visuals.get_filter(filter_name) # Get the list of URI vars to be set for that filter new_vars = filter_object.variable_settings(row) url_vars += new_vars # See get_link_filter_names() comment for details for src_key, dst_key in visuals.get_link_filter_names(view, datasource['infos'], datasource.get('link_filters', {})): try: url_vars += visuals.get_filter(src_key).variable_settings(row) except KeyError: pass try: url_vars += visuals.get_filter(dst_key).variable_settings(row) except KeyError: pass # Some special handling for the site filter which is meant as optional hint # Always add the site filter var when some useful information is available add_site_hint = True for filter_key in datasource.get('multiple_site_filters', []): if filter_key in dict(url_vars): add_site_hint = False # Hack for servicedesc view which is meant to show all services with the given # description: Don't add the site filter for this view. if view_name == "servicedesc": add_site_hint = False if add_site_hint and row.get('site'): url_vars.append(('site', row['site'])) do = html.var("display_options") if do: url_vars.append(("display_options", do)) filename = "mobile_view.py" if html.mobile else "view.py" return filename + "?" + html.urlencode_vars([("view_name", view_name)] + url_vars) def link_to_view(content, row, view_name): if display_options.disabled(display_options.I): return content url = url_to_view(row, view_name) if url: return "<a href=\"%s\">%s</a>" % (url, content) else: return content def docu_link(topic, text): return '<a href="%s" target="_blank">%s</a>' % (config.doculink_urlformat % topic, text) # Calculates a uniq id for each data row which identifies the current # row accross different page loadings. def row_id(view, row): key = u'' for col in multisite_datasources[view['datasource']]['idkeys']: key += u'~%s' % row[col] return hashlib.sha256(key.encode('utf-8')).hexdigest() def paint_stalified(row, text): if is_stale(row): return "stale", text else: return "", text def substract_sorters(base, remove): for s in remove: if s in base: base.remove(s) elif (s[0], not s[1]) in base: base.remove((s[0], not s[1])) def parse_url_sorters(sort): sorters = [] if not sort: return sorters for s in sort.split(','): if not '~' in s: sorters.append((s.replace('-', ''), s.startswith('-'))) else: sorter, join_index = s.split('~', 1) sorters.append((sorter.replace('-', ''), sorter.startswith('-'), join_index)) return sorters def get_sorter_name_of_painter(painter_name): painter = multisite_painters[painter_name] if 'sorter' in painter: return painter['sorter'] elif painter_name in multisite_sorters: return painter_name def get_primary_sorter_order(view, painter_name): sorter_name = get_sorter_name_of_painter(painter_name) this_asc_sorter = (sorter_name, False) this_desc_sorter = (sorter_name, True) group_sort, user_sort, view_sort = get_separated_sorters(view) if user_sort and this_asc_sorter == user_sort[0]: return 'asc' elif user_sort and this_desc_sorter == user_sort[0]: return 'desc' else: return '' def get_separated_sorters(view): group_sort = [ (get_sorter_name_of_painter(p[0]), False) for p in view['group_painters'] if p[0] in multisite_painters and get_sorter_name_of_painter(p[0]) is not None ] view_sort = [ s for s in view['sorters'] if not s[0] in group_sort ] # Get current url individual sorters. Parse the "sort" url parameter, # then remove the group sorters. The left sorters must be the user # individual sorters for this view. # Then remove the user sorters from the view sorters user_sort = parse_url_sorters(html.var('sort')) substract_sorters(user_sort, group_sort) substract_sorters(view_sort, user_sort) return group_sort, user_sort, view_sort # The Group-value of a row is used for deciding whether # two rows are in the same group or not def group_value(row, group_cells): group = [] for cell in group_cells: painter = cell.painter() groupvalfunc = painter.get("groupby") if groupvalfunc: if "args" in painter: group.append(groupvalfunc(row, *painter["args"])) else: group.append(groupvalfunc(row)) else: for c in get_painter_columns(painter): if c in row: group.append(row[c]) return create_dict_key(group) def create_dict_key(value): if type(value) in (list, tuple): return tuple(map(create_dict_key, value)) elif type(value) == dict: return tuple([ (k, create_dict_key(v)) for (k, v) in sorted(value.items()) ]) else: return value def get_host_tags(row): if type(row.get("host_custom_variables")) == dict: return row["host_custom_variables"].get("TAGS", "") if type(row.get("host_custom_variable_names")) != list: return "" for name, val in zip(row["host_custom_variable_names"], row["host_custom_variable_values"]): if name == "TAGS": return val return "" # Get the definition of a tag group g_taggroups_by_id = {} def get_tag_group(tgid): # Build a cache if not g_taggroups_by_id: for entry in config.host_tag_groups(): g_taggroups_by_id[entry[0]] = (entry[1], entry[2]) return g_taggroups_by_id.get(tgid, (_("N/A"), [])) def get_custom_var(row, key): for name, val in zip(row["custom_variable_names"], row["custom_variable_values"]): if name == key: return val return "" def is_stale(row): return row.get('service_staleness', row.get('host_staleness', 0)) >= config.staleness_threshold def cmp_insensitive_string(v1, v2): c = cmp(v1.lower(), v2.lower()) # force a strict order in case of equal spelling but different # case! if c == 0: return cmp(v1, v2) else: return c # Sorting def cmp_ip_address(column, r1, r2): def split_ip(ip): try: return tuple(int(part) for part in ip.split('.')) except: return ip v1, v2 = split_ip(r1.get(column, '')), split_ip(r2.get(column, '')) return cmp(v1, v2) def cmp_simple_string(column, r1, r2): v1, v2 = r1.get(column, ''), r2.get(column, '') return cmp_insensitive_string(v1, v2) def cmp_num_split(column, r1, r2): return utils.cmp_num_split(r1[column].lower(), r2[column].lower()) def cmp_string_list(column, r1, r2): v1 = ''.join(r1.get(column, [])) v2 = ''.join(r2.get(column, [])) return cmp_insensitive_string(v1, v2) def cmp_simple_number(column, r1, r2): return cmp(r1.get(column), r2.get(column)) def cmp_custom_variable(r1, r2, key, cmp_func): return cmp(get_custom_var(r1, key), get_custom_var(r2, key)) def cmp_service_name_equiv(r): if r == "Check_MK": return -6 elif r == "Check_MK Agent": return -5 elif r == "Check_MK Discovery": return -4 elif r == "Check_MK inventory": return -3 # FIXME: Remove old name one day elif r == "Check_MK HW/SW Inventory": return -2 else: return 0 def declare_simple_sorter(name, title, column, func): multisite_sorters[name] = { "title" : title, "columns" : [ column ], "cmp" : lambda r1, r2: func(column, r1, r2) } def declare_1to1_sorter(painter_name, func, col_num = 0, reverse = False): multisite_sorters[painter_name] = { "title" : multisite_painters[painter_name]['title'], "columns" : multisite_painters[painter_name]['columns'], } if not reverse: multisite_sorters[painter_name]["cmp"] = \ lambda r1, r2: func(multisite_painters[painter_name]['columns'][col_num], r1, r2) else: multisite_sorters[painter_name]["cmp"] = \ lambda r1, r2: func(multisite_painters[painter_name]['columns'][col_num], r2, r1) return painter_name # Ajax call for fetching parts of the tree def ajax_inv_render_tree(): hostname = html.var("host") invpath = html.var("path") tree_id = html.var("treeid", "") if html.var("show_internal_tree_paths"): show_internal_tree_paths = True else: show_internal_tree_paths = False if tree_id: struct_tree = inventory.load_delta_tree(hostname, int(tree_id[1:])) tree_renderer = DeltaNodeRenderer(hostname, tree_id, invpath) else: struct_tree = inventory.load_tree(hostname) tree_renderer = AttributeRenderer(hostname, "", invpath, show_internal_tree_paths=show_internal_tree_paths) if struct_tree is None: html.show_error(_("No such inventory tree.")) struct_tree = struct_tree.get_filtered_tree(inventory.get_permitted_inventory_paths()) parsed_path, attributes_key = inventory.parse_tree_path(invpath) if parsed_path: children = struct_tree.get_sub_children(parsed_path) else: children = [struct_tree.get_root_container()] if children is None: html.show_error(_("Invalid path in inventory tree: '%s' >> %s") % (invpath, repr(parsed_path))) else: for child in inventory.sort_children(children): child.show(tree_renderer, path=invpath) def output_csv_headers(view): filename = '%s-%s.csv' % (view['name'], time.strftime('%Y-%m-%d_%H-%M-%S', time.localtime(time.time()))) if type(filename) == unicode: filename = filename.encode("utf-8") html.req.headers_out['Content-Disposition'] = 'Attachment; filename="%s"' % filename def paint_host_list(site, hosts): entries = [] for host in hosts: args = [ ("view_name", "hoststatus"), ("site", site), ("host", host), ] if html.var("display_options"): args.append(("display_options", html.var("display_options"))) url = html.makeuri_contextless(args, filename="view.py") entries.append(html.render_a(host, href=url)) return "", HTML(", ").join(entries) # There is common code with modules/events.py:format_plugin_output(). Please check # whether or not that function needs to be changed too # TODO(lm): Find a common place to unify this functionality. def format_plugin_output(output, row = None): ok_marker = '<b class="stmark state0">OK</b>' warn_marker = '<b class="stmark state1">WARN</b>' crit_marker = '<b class="stmark state2">CRIT</b>' unknown_marker = '<b class="stmark state3">UNKN</b>' shall_escape = config.escape_plugin_output # In case we have a host or service row use the optional custom attribute # ESCAPE_PLUGIN_OUTPUT (set by host / service ruleset) to override the global # setting. if row: custom_vars = row.get("service_custom_variables", row.get("host_custom_variables", {})) if "ESCAPE_PLUGIN_OUTPUT" in custom_vars: shall_escape = custom_vars["ESCAPE_PLUGIN_OUTPUT"] == "1" if shall_escape: output = html.attrencode(output) output = output.replace("(!)", warn_marker) \ .replace("(!!)", crit_marker) \ .replace("(?)", unknown_marker) \ .replace("(.)", ok_marker) if row and "[running on" in output: a = output.index("[running on") e = output.index("]", a) hosts = output[a+12:e].replace(" ","").split(",") css, h = paint_host_list(row["site"], hosts) output = output[:a] + "running on " + h + output[e+1:] if shall_escape: # (?:&lt;A HREF=&quot;), (?: target=&quot;_blank&quot;&gt;)? and endswith(" </A>") is a special # handling for the HTML code produced by check_http when "clickable URL" option is active. output = re.sub("(?:&lt;A HREF=&quot;)?(http[s]?://[^\"'>\t\s\n,]+)(?: target=&quot;_blank&quot;&gt;)?", lambda p: '<a href="%s"><img class=pluginurl align=absmiddle title="%s" src="images/pluginurl.png"></a>' % (p.group(1).replace('&quot;', ''), p.group(1).replace('&quot;', '')), output) if output.endswith(" &lt;/A&gt;"): output = output[:-11] return output #. # .--Icon Selector-------------------------------------------------------. # | ___ ____ _ _ | # | |_ _|___ ___ _ __ / ___| ___| | ___ ___| |_ ___ _ __ | # | | |/ __/ _ \| '_ \ \___ \ / _ \ |/ _ \/ __| __/ _ \| '__| | # | | | (_| (_) | | | | ___) | __/ | __/ (__| || (_) | | | # | |___\___\___/|_| |_| |____/ \___|_|\___|\___|\__\___/|_| | # | | # +----------------------------------------------------------------------+ # | AJAX API call for rendering the icon selector | # '----------------------------------------------------------------------' def ajax_popup_icon_selector(): varprefix = html.var('varprefix') value = html.var('value') allow_empty = html.var('allow_empty') == '1' vs = IconSelector(allow_empty=allow_empty) vs.render_popup_input(varprefix, value) #. # .--Action Menu---------------------------------------------------------. # | _ _ _ __ __ | # | / \ ___| |_(_) ___ _ __ | \/ | ___ _ __ _ _ | # | / _ \ / __| __| |/ _ \| '_ \ | |\/| |/ _ \ '_ \| | | | | # | / ___ \ (__| |_| | (_) | | | | | | | | __/ | | | |_| | | # | /_/ \_\___|\__|_|\___/|_| |_| |_| |_|\___|_| |_|\__,_| | # | | # +----------------------------------------------------------------------+ # | Realizes the popup action menu for hosts/services in views | # '----------------------------------------------------------------------' def query_action_data(what, host, site, svcdesc): # Now fetch the needed data from livestatus columns = list(iconpainter_columns(what, toplevel=False)) try: columns.remove('site') except KeyError: pass if site: sites.live().set_only_sites([site]) sites.live().set_prepend_site(True) query = 'GET %ss\n' \ 'Columns: %s\n' \ 'Filter: host_name = %s\n' \ % (what, ' '.join(columns), host) if what == 'service': query += 'Filter: service_description = %s\n' % svcdesc row = sites.live().query_row(query) sites.live().set_prepend_site(False) sites.live().set_only_sites(None) return dict(zip(['site'] + columns, row)) def ajax_popup_action_menu(): site = html.var('site') host = html.var('host') svcdesc = html.var('service') what = 'service' if svcdesc else 'host' weblib.prepare_display_options(globals()) row = query_action_data(what, host, site, svcdesc) icons = get_icons(what, row, toplevel=False) html.open_ul() for icon in icons: if len(icon) != 4: html.open_li() html.write(icon[1]) html.close_li() else: html.open_li() icon_name, title, url_spec = icon[1:] if url_spec: url, target_frame = sanitize_action_url(url_spec) url = replace_action_url_macros(url, what, row) onclick = None if url.startswith('onclick:'): onclick = url[8:] url = 'javascript:void(0);' target = None if target_frame and target_frame != "_self": target = target_frame html.open_a(href=url, target=target, onclick=onclick) html.icon('', icon_name) if title: html.write(title) else: html.write_text(_("No title")) if url_spec: html.close_a() html.close_li() html.close_ul() def sanitize_action_url(url_spec): if type(url_spec) == tuple: return url_spec else: return (url_spec, None) #. # .--Reschedule----------------------------------------------------------. # | ____ _ _ _ | # | | _ \ ___ ___ ___| |__ ___ __| |_ _| | ___ | # | | |_) / _ \/ __|/ __| '_ \ / _ \/ _` | | | | |/ _ \ | # | | _ < __/\__ \ (__| | | | __/ (_| | |_| | | __/ | # | |_| \_\___||___/\___|_| |_|\___|\__,_|\__,_|_|\___| | # | | # +----------------------------------------------------------------------+ # | Ajax webservice for reschedulung host- and service checks | # '----------------------------------------------------------------------' def ajax_reschedule(): try: do_reschedule() except Exception, e: html.write("['ERROR', '%s']\n" % e) def do_reschedule(): if not config.user.may("action.reschedule"): raise MKGeneralException("You are not allowed to reschedule checks.") site = html.var("site") host = html.var("host", "") if not host: raise MKGeneralException("Action reschedule: missing host name") service = html.get_unicode_input("service", "") wait_svc = html.get_unicode_input("wait_svc", "") if service: cmd = "SVC" what = "service" spec = "%s;%s" % (host, service.encode("utf-8")) if wait_svc: wait_spec = u'%s;%s' % (host, wait_svc) add_filter = "Filter: service_description = %s\n" % livestatus.lqencode(wait_svc) else: wait_spec = spec add_filter = "Filter: service_description = %s\n" % livestatus.lqencode(service) else: cmd = "HOST" what = "host" spec = host wait_spec = spec add_filter = "" try: now = int(time.time()) sites.live().command("[%d] SCHEDULE_FORCED_%s_CHECK;%s;%d" % (now, cmd, livestatus.lqencode(spec), now), site) sites.live().set_only_sites([site]) query = u"GET %ss\n" \ "WaitObject: %s\n" \ "WaitCondition: last_check >= %d\n" \ "WaitTimeout: %d\n" \ "WaitTrigger: check\n" \ "Columns: last_check state plugin_output\n" \ "Filter: host_name = %s\n%s" \ % (what, livestatus.lqencode(wait_spec), now, config.reschedule_timeout * 1000, livestatus.lqencode(host), add_filter) row = sites.live().query_row(query) sites.live().set_only_sites() last_check = row[0] if last_check < now: html.write("['TIMEOUT', 'Check not executed within %d seconds']\n" % (config.reschedule_timeout)) else: if service == "Check_MK": # Passive services triggered by Check_MK often are updated # a few ms later. We introduce a small wait time in order # to increase the chance for the passive services already # updated also when we return. time.sleep(0.7); html.write("['OK', %d, %d, %r]\n" % (row[0], row[1], row[2].encode("utf-8"))) except Exception, e: sites.live().set_only_sites() raise MKGeneralException(_("Cannot reschedule check: %s") % e)
huiyiqun/check_mk
web/htdocs/views.py
Python
gpl-2.0
129,902
# PushSwap Ce projet réalisé seul est un programme prenant une liste de nombres en paramètres et affiche les déplacement des éléments de la liste pour les trier en ayant le droit seulement à un jeu d'instructions limité.
elominp/PushSwap
README.md
Markdown
gpl-2.0
230
/* sigaltstack definitions. Copyright (C) 1998 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. The GNU C 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 Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with the GNU C Library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ /* Modified for MiNTLib by Frank Naumann <fnaumann@freemint.de>. */ #ifndef _SIGNAL_H # error "Never include this file directly. Use <signal.h> instead" #endif /* Possible values for `ss_flags.'. */ enum { SS_ONSTACK = 1, #define SS_ONSTACK SS_ONSTACK SS_DISABLE #define SS_DISABLE SS_DISABLE }; /* Minimum stack size for a signal handler. */ #define MINSIGSTKSZ 2048 /* System default stack size. */ #define SIGSTKSZ 8192 /* Alternate, preferred interface. */ typedef struct sigaltstack { __ptr_t ss_sp; int ss_flags; size_t ss_size; } stack_t;
ArmstrongJ/MiNTLib
include/bits/sigstack.h
C
gpl-2.0
1,488
//! A class to represent the Rating state #ifndef RATINGSTATE_H #define RATINGSTATE_H #include <vector> #include <string> #include "../StateModule/GameState.h" #include "../ToolKit/Singleton.h" namespace GfxModule { class BGObject; class SurfaceWrapper; class FontWrapper; } namespace SoundModule { class ChunkWrapper; } class RatingState : public GameStateModule::GameState, public Singleton<RatingState> { private: //! Surface Wrapper for the background GfxModule::SurfaceWrapper * _BackgroundSurface, * _ClearedSurface, * _FailedSurface; //! BGObject for the background GfxModule::BGObject * _BackgroundObject, * _ForegroundObject; //! Pointers to store the forward and back sound effects SoundModule::ChunkWrapper *_ForwardSfx; //! Font Wrapper for the text GfxModule::FontWrapper * _Font; //! Vector of strings to store the ratings to be shown on screen std::vector<std::string> _VectorOfRatings; //! Did the player fail bool _NotFailFlag; public: //! Standard constructor RatingState(void); //! Standard desconstructor ~RatingState(void); //! Pass the ratings to be shown on screen void SetRatings( unsigned int HighestCombo, unsigned int NumberOfMissSteps, unsigned int NumberOfBooSteps, unsigned int NumberOfGoodSteps, unsigned int NumberOfGreatSteps, unsigned int NumberOfPerfectSteps, unsigned int NumberOfMarvelousSteps, unsigned int CurrentScore, bool NotFailFlag ); //! Initialise the state when the state is pushed on top the stack void PushInitialise( GfxModule::GfxModuleWrapper* AGfxModule, SoundModule::SoundModuleWrapper* ASoundModule ); //! Cleanup up the state when it is pushed then further into the stack void PushCleanup( GfxModule::GfxModuleWrapper* AGfxModule, SoundModule::SoundModuleWrapper* ASoundModule ); //! When the state is popped up to the top of the stack void PopInitialise( GfxModule::GfxModuleWrapper* AGfxModule, SoundModule::SoundModuleWrapper* ASoundModule ); //! When the state is popped off the stack void PopCleanup( GfxModule::GfxModuleWrapper* AGfxModule, SoundModule::SoundModuleWrapper* ASoundModule ); //! Gets called once per frame when it is on top of the stack void Update( GfxModule::GfxModuleWrapper* AGfxModule, SoundModule::SoundModuleWrapper* ASoundModule, InputModule::Input* AInputModule, GameStateModule::GameStateManager* AGameStateManager ); }; #endif // SONGSELECTIONSTATE_H /* History ======= 2006-08-03: Created file and base functionality. */
blchinezu/EZX-Projects
Games/Dance2X/Source/Game/RatingState.h
C
gpl-2.0
2,763
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <!-- NewPage --> <html lang="es"> <head> <!-- Generated by javadoc (version 1.7.0_45) on Fri Nov 22 15:43:22 CST 2013 --> <title>Uses of Class datastructs.graphs.Vertex</title> <meta name="date" content="2013-11-22"> <link rel="stylesheet" type="text/css" href="../../../stylesheet.css" title="Style"> </head> <body> <script type="text/javascript"><!-- if (location.href.indexOf('is-external=true') == -1) { parent.document.title="Uses of Class datastructs.graphs.Vertex"; } //--> </script> <noscript> <div>JavaScript is disabled on your browser.</div> </noscript> <!-- ========= START OF TOP NAVBAR ======= --> <div class="topNav"><a name="navbar_top"> <!-- --> </a><a href="#skip-navbar_top" title="Skip navigation links"></a><a name="navbar_top_firstrow"> <!-- --> </a> <ul class="navList" title="Navigation"> <li><a href="../../../overview-summary.html">Overview</a></li> <li><a href="../package-summary.html">Package</a></li> <li><a href="../../../datastructs/graphs/Vertex.html" title="class in datastructs.graphs">Class</a></li> <li class="navBarCell1Rev">Use</li> <li><a href="../package-tree.html">Tree</a></li> <li><a href="../../../deprecated-list.html">Deprecated</a></li> <li><a href="../../../index-files/index-1.html">Index</a></li> <li><a href="../../../help-doc.html">Help</a></li> </ul> </div> <div class="subNav"> <ul class="navList"> <li>Prev</li> <li>Next</li> </ul> <ul class="navList"> <li><a href="../../../index.html?datastructs/graphs/class-use/Vertex.html" target="_top">Frames</a></li> <li><a href="Vertex.html" target="_top">No Frames</a></li> </ul> <ul class="navList" id="allclasses_navbar_top"> <li><a href="../../../allclasses-noframe.html">All Classes</a></li> </ul> <div> <script type="text/javascript"><!-- allClassesLink = document.getElementById("allclasses_navbar_top"); if(window==top) { allClassesLink.style.display = "block"; } else { allClassesLink.style.display = "none"; } //--> </script> </div> <a name="skip-navbar_top"> <!-- --> </a></div> <!-- ========= END OF TOP NAVBAR ========= --> <div class="header"> <h2 title="Uses of Class datastructs.graphs.Vertex" class="title">Uses of Class<br>datastructs.graphs.Vertex</h2> </div> <div class="classUseContainer"> <ul class="blockList"> <li class="blockList"> <table border="0" cellpadding="3" cellspacing="0" summary="Use table, listing packages, and an explanation"> <caption><span>Packages that use <a href="../../../datastructs/graphs/Vertex.html" title="class in datastructs.graphs">Vertex</a></span><span class="tabEnd">&nbsp;</span></caption> <tr> <th class="colFirst" scope="col">Package</th> <th class="colLast" scope="col">Description</th> </tr> <tbody> <tr class="altColor"> <td class="colFirst"><a href="#datastructs.graphs">datastructs.graphs</a></td> <td class="colLast">&nbsp;</td> </tr> <tr class="rowColor"> <td class="colFirst"><a href="#projectstructures">projectstructures</a></td> <td class="colLast">&nbsp;</td> </tr> </tbody> </table> </li> <li class="blockList"> <ul class="blockList"> <li class="blockList"><a name="datastructs.graphs"> <!-- --> </a> <h3>Uses of <a href="../../../datastructs/graphs/Vertex.html" title="class in datastructs.graphs">Vertex</a> in <a href="../../../datastructs/graphs/package-summary.html">datastructs.graphs</a></h3> <table border="0" cellpadding="3" cellspacing="0" summary="Use table, listing methods, and an explanation"> <caption><span>Methods in <a href="../../../datastructs/graphs/package-summary.html">datastructs.graphs</a> that return <a href="../../../datastructs/graphs/Vertex.html" title="class in datastructs.graphs">Vertex</a></span><span class="tabEnd">&nbsp;</span></caption> <tr> <th class="colFirst" scope="col">Modifier and Type</th> <th class="colLast" scope="col">Method and Description</th> </tr> <tbody> <tr class="altColor"> <td class="colFirst"><code><a href="../../../datastructs/graphs/Vertex.html" title="class in datastructs.graphs">Vertex</a>&lt;<a href="../../../datastructs/graphs/Edge.html" title="type parameter in Edge">K</a>&gt;</code></td> <td class="colLast"><span class="strong">Edge.</span><code><strong><a href="../../../datastructs/graphs/Edge.html#getFromNode()">getFromNode</a></strong>()</code>&nbsp;</td> </tr> <tr class="rowColor"> <td class="colFirst"><code><a href="../../../datastructs/graphs/Vertex.html" title="class in datastructs.graphs">Vertex</a>&lt;<a href="../../../datastructs/graphs/Edge.html" title="type parameter in Edge">K</a>&gt;</code></td> <td class="colLast"><span class="strong">Edge.</span><code><strong><a href="../../../datastructs/graphs/Edge.html#getToNode()">getToNode</a></strong>()</code>&nbsp;</td> </tr> <tr class="altColor"> <td class="colFirst"><code><a href="../../../datastructs/graphs/Vertex.html" title="class in datastructs.graphs">Vertex</a>&lt;<a href="../../../datastructs/graphs/Graph.html" title="type parameter in Graph">K</a>&gt;</code></td> <td class="colLast"><span class="strong">Graph.</span><code><strong><a href="../../../datastructs/graphs/Graph.html#getVertexThatContains(K)">getVertexThatContains</a></strong>(<a href="../../../datastructs/graphs/Graph.html" title="type parameter in Graph">K</a>&nbsp;pk)</code> <div class="block">Checks if there is a vertex that contains the data specified</div> </td> </tr> <tr class="rowColor"> <td class="colFirst"><code><a href="../../../datastructs/graphs/Vertex.html" title="class in datastructs.graphs">Vertex</a>&lt;<a href="../../../datastructs/graphs/Graph.html" title="type parameter in Graph">K</a>&gt;</code></td> <td class="colLast"><span class="strong">Graph.</span><code><strong><a href="../../../datastructs/graphs/Graph.html#removeVertex(K)">removeVertex</a></strong>(<a href="../../../datastructs/graphs/Graph.html" title="type parameter in Graph">K</a>&nbsp;pData)</code> <div class="block">Removes a vertex that contains the data specified.</div> </td> </tr> </tbody> </table> <table border="0" cellpadding="3" cellspacing="0" summary="Use table, listing methods, and an explanation"> <caption><span>Methods in <a href="../../../datastructs/graphs/package-summary.html">datastructs.graphs</a> that return types with arguments of type <a href="../../../datastructs/graphs/Vertex.html" title="class in datastructs.graphs">Vertex</a></span><span class="tabEnd">&nbsp;</span></caption> <tr> <th class="colFirst" scope="col">Modifier and Type</th> <th class="colLast" scope="col">Method and Description</th> </tr> <tbody> <tr class="altColor"> <td class="colFirst"><code><a href="../../../datastructs/simplelist/SimpleList.html" title="class in datastructs.simplelist">SimpleList</a>&lt;<a href="../../../datastructs/graphs/Vertex.html" title="class in datastructs.graphs">Vertex</a>&lt;<a href="../../../datastructs/graphs/Vertex.html" title="type parameter in Vertex">K</a>&gt;&gt;</code></td> <td class="colLast"><span class="strong">Vertex.</span><code><strong><a href="../../../datastructs/graphs/Vertex.html#getAdjacentVertexes()">getAdjacentVertexes</a></strong>()</code>&nbsp;</td> </tr> <tr class="rowColor"> <td class="colFirst"><code><a href="../../../datastructs/simplelist/SimpleList.html" title="class in datastructs.simplelist">SimpleList</a>&lt;<a href="../../../datastructs/graphs/Vertex.html" title="class in datastructs.graphs">Vertex</a>&lt;<a href="../../../datastructs/graphs/Graph.html" title="type parameter in Graph">K</a>&gt;&gt;</code></td> <td class="colLast"><span class="strong">Graph.</span><code><strong><a href="../../../datastructs/graphs/Graph.html#getProcessedOnes()">getProcessedOnes</a></strong>()</code>&nbsp;</td> </tr> <tr class="altColor"> <td class="colFirst"><code><a href="../../../datastructs/simplelist/SimpleList.html" title="class in datastructs.simplelist">SimpleList</a>&lt;<a href="../../../datastructs/graphs/Vertex.html" title="class in datastructs.graphs">Vertex</a>&lt;<a href="../../../datastructs/graphs/Graph.html" title="type parameter in Graph">K</a>&gt;&gt;</code></td> <td class="colLast"><span class="strong">Graph.</span><code><strong><a href="../../../datastructs/graphs/Graph.html#getUnprocessedOnes()">getUnprocessedOnes</a></strong>()</code>&nbsp;</td> </tr> <tr class="rowColor"> <td class="colFirst"><code><a href="../../../datastructs/simplelist/SimpleList.html" title="class in datastructs.simplelist">SimpleList</a>&lt;<a href="../../../datastructs/graphs/Vertex.html" title="class in datastructs.graphs">Vertex</a>&lt;<a href="../../../datastructs/graphs/Graph.html" title="type parameter in Graph">K</a>&gt;&gt;</code></td> <td class="colLast"><span class="strong">Graph.</span><code><strong><a href="../../../datastructs/graphs/Graph.html#getVertexes()">getVertexes</a></strong>()</code> <div class="block">To know the list of vertexes.</div> </td> </tr> </tbody> </table> <table border="0" cellpadding="3" cellspacing="0" summary="Use table, listing methods, and an explanation"> <caption><span>Methods in <a href="../../../datastructs/graphs/package-summary.html">datastructs.graphs</a> with parameters of type <a href="../../../datastructs/graphs/Vertex.html" title="class in datastructs.graphs">Vertex</a></span><span class="tabEnd">&nbsp;</span></caption> <tr> <th class="colFirst" scope="col">Modifier and Type</th> <th class="colLast" scope="col">Method and Description</th> </tr> <tbody> <tr class="altColor"> <td class="colFirst"><code>void</code></td> <td class="colLast"><span class="strong">Graph.</span><code><strong><a href="../../../datastructs/graphs/Graph.html#addNode(datastructs.graphs.Vertex)">addNode</a></strong>(<a href="../../../datastructs/graphs/Vertex.html" title="class in datastructs.graphs">Vertex</a>&lt;<a href="../../../datastructs/graphs/Graph.html" title="type parameter in Graph">K</a>&gt;&nbsp;pNewNode)</code> <div class="block">Adds a new node to the graph, not connected.</div> </td> </tr> <tr class="rowColor"> <td class="colFirst"><code>void</code></td> <td class="colLast"><span class="strong">Vertex.</span><code><strong><a href="../../../datastructs/graphs/Vertex.html#connectTo(datastructs.graphs.Vertex, int)">connectTo</a></strong>(<a href="../../../datastructs/graphs/Vertex.html" title="class in datastructs.graphs">Vertex</a>&lt;<a href="../../../datastructs/graphs/Vertex.html" title="type parameter in Vertex">K</a>&gt;&nbsp;pOtherNode, int&nbsp;pWeight)</code> <div class="block">Connects two graph nodes with the given weight.</div> </td> </tr> <tr class="altColor"> <td class="colFirst"><code>void</code></td> <td class="colLast"><span class="strong">Edge.</span><code><strong><a href="../../../datastructs/graphs/Edge.html#setFromNode(datastructs.graphs.Vertex)">setFromNode</a></strong>(<a href="../../../datastructs/graphs/Vertex.html" title="class in datastructs.graphs">Vertex</a>&lt;<a href="../../../datastructs/graphs/Edge.html" title="type parameter in Edge">K</a>&gt;&nbsp;pFromNode)</code>&nbsp;</td> </tr> </tbody> </table> <table border="0" cellpadding="3" cellspacing="0" summary="Use table, listing constructors, and an explanation"> <caption><span>Constructors in <a href="../../../datastructs/graphs/package-summary.html">datastructs.graphs</a> with parameters of type <a href="../../../datastructs/graphs/Vertex.html" title="class in datastructs.graphs">Vertex</a></span><span class="tabEnd">&nbsp;</span></caption> <tr> <th class="colOne" scope="col">Constructor and Description</th> </tr> <tbody> <tr class="altColor"> <td class="colLast"><code><strong><a href="../../../datastructs/graphs/Edge.html#Edge(datastructs.graphs.Vertex, datastructs.graphs.Vertex)">Edge</a></strong>(<a href="../../../datastructs/graphs/Vertex.html" title="class in datastructs.graphs">Vertex</a>&lt;<a href="../../../datastructs/graphs/Edge.html" title="type parameter in Edge">K</a>&gt;&nbsp;pConnectFromNode, <a href="../../../datastructs/graphs/Vertex.html" title="class in datastructs.graphs">Vertex</a>&lt;<a href="../../../datastructs/graphs/Edge.html" title="type parameter in Edge">K</a>&gt;&nbsp;pConnectToNode)</code>&nbsp;</td> </tr> <tr class="rowColor"> <td class="colLast"><code><strong><a href="../../../datastructs/graphs/Edge.html#Edge(datastructs.graphs.Vertex, datastructs.graphs.Vertex)">Edge</a></strong>(<a href="../../../datastructs/graphs/Vertex.html" title="class in datastructs.graphs">Vertex</a>&lt;<a href="../../../datastructs/graphs/Edge.html" title="type parameter in Edge">K</a>&gt;&nbsp;pConnectFromNode, <a href="../../../datastructs/graphs/Vertex.html" title="class in datastructs.graphs">Vertex</a>&lt;<a href="../../../datastructs/graphs/Edge.html" title="type parameter in Edge">K</a>&gt;&nbsp;pConnectToNode)</code>&nbsp;</td> </tr> <tr class="altColor"> <td class="colLast"><code><strong><a href="../../../datastructs/graphs/Edge.html#Edge(datastructs.graphs.Vertex, datastructs.graphs.Vertex, int)">Edge</a></strong>(<a href="../../../datastructs/graphs/Vertex.html" title="class in datastructs.graphs">Vertex</a>&lt;<a href="../../../datastructs/graphs/Edge.html" title="type parameter in Edge">K</a>&gt;&nbsp;pConnectFromNode, <a href="../../../datastructs/graphs/Vertex.html" title="class in datastructs.graphs">Vertex</a>&lt;<a href="../../../datastructs/graphs/Edge.html" title="type parameter in Edge">K</a>&gt;&nbsp;pConnectToNode, int&nbsp;pDistance)</code>&nbsp;</td> </tr> <tr class="rowColor"> <td class="colLast"><code><strong><a href="../../../datastructs/graphs/Edge.html#Edge(datastructs.graphs.Vertex, datastructs.graphs.Vertex, int)">Edge</a></strong>(<a href="../../../datastructs/graphs/Vertex.html" title="class in datastructs.graphs">Vertex</a>&lt;<a href="../../../datastructs/graphs/Edge.html" title="type parameter in Edge">K</a>&gt;&nbsp;pConnectFromNode, <a href="../../../datastructs/graphs/Vertex.html" title="class in datastructs.graphs">Vertex</a>&lt;<a href="../../../datastructs/graphs/Edge.html" title="type parameter in Edge">K</a>&gt;&nbsp;pConnectToNode, int&nbsp;pDistance)</code>&nbsp;</td> </tr> </tbody> </table> </li> <li class="blockList"><a name="projectstructures"> <!-- --> </a> <h3>Uses of <a href="../../../datastructs/graphs/Vertex.html" title="class in datastructs.graphs">Vertex</a> in <a href="../../../projectstructures/package-summary.html">projectstructures</a></h3> <table border="0" cellpadding="3" cellspacing="0" summary="Use table, listing subclasses, and an explanation"> <caption><span>Subclasses of <a href="../../../datastructs/graphs/Vertex.html" title="class in datastructs.graphs">Vertex</a> in <a href="../../../projectstructures/package-summary.html">projectstructures</a></span><span class="tabEnd">&nbsp;</span></caption> <tr> <th class="colFirst" scope="col">Modifier and Type</th> <th class="colLast" scope="col">Class and Description</th> </tr> <tbody> <tr class="altColor"> <td class="colFirst"><code>class&nbsp;</code></td> <td class="colLast"><code><strong><a href="../../../projectstructures/ClientRegion.html" title="class in projectstructures">ClientRegion</a>&lt;K&gt;</strong></code>&nbsp;</td> </tr> <tr class="rowColor"> <td class="colFirst"><code>class&nbsp;</code></td> <td class="colLast"><code><strong><a href="../../../projectstructures/Region.html" title="class in projectstructures">Region</a>&lt;K&gt;</strong></code> <div class="block">Class that create a region</div> </td> </tr> <tr class="altColor"> <td class="colFirst"><code>class&nbsp;</code></td> <td class="colLast"><code><strong><a href="../../../projectstructures/ServerRegion.html" title="class in projectstructures">ServerRegion</a>&lt;K&gt;</strong></code>&nbsp;</td> </tr> </tbody> </table> </li> </ul> </li> </ul> </div> <!-- ======= START OF BOTTOM NAVBAR ====== --> <div class="bottomNav"><a name="navbar_bottom"> <!-- --> </a><a href="#skip-navbar_bottom" title="Skip navigation links"></a><a name="navbar_bottom_firstrow"> <!-- --> </a> <ul class="navList" title="Navigation"> <li><a href="../../../overview-summary.html">Overview</a></li> <li><a href="../package-summary.html">Package</a></li> <li><a href="../../../datastructs/graphs/Vertex.html" title="class in datastructs.graphs">Class</a></li> <li class="navBarCell1Rev">Use</li> <li><a href="../package-tree.html">Tree</a></li> <li><a href="../../../deprecated-list.html">Deprecated</a></li> <li><a href="../../../index-files/index-1.html">Index</a></li> <li><a href="../../../help-doc.html">Help</a></li> </ul> </div> <div class="subNav"> <ul class="navList"> <li>Prev</li> <li>Next</li> </ul> <ul class="navList"> <li><a href="../../../index.html?datastructs/graphs/class-use/Vertex.html" target="_top">Frames</a></li> <li><a href="Vertex.html" target="_top">No Frames</a></li> </ul> <ul class="navList" id="allclasses_navbar_bottom"> <li><a href="../../../allclasses-noframe.html">All Classes</a></li> </ul> <div> <script type="text/javascript"><!-- allClassesLink = document.getElementById("allclasses_navbar_bottom"); if(window==top) { allClassesLink.style.display = "block"; } else { allClassesLink.style.display = "none"; } //--> </script> </div> <a name="skip-navbar_bottom"> <!-- --> </a></div> <!-- ======== END OF BOTTOM NAVBAR ======= --> </body> </html>
Zyoruk/3rdProject
doc/datastructs/graphs/class-use/Vertex.html
HTML
gpl-2.0
17,274
<?php namespace Drupal\message_subscribe; use Drupal\Core\Entity\EntityInterface; use Drupal\Core\Session\AccountInterface; use Drupal\message\MessageInterface; /** * Subscribers service. */ interface SubscribersInterface { /** * Process a message and send to subscribed users. * * @param \Drupal\Core\Entity\EntityInterface $entity * The entity object to process subscriptions and send notifications for. * @param \Drupal\message\MessageInterface $message * The message object. * @param array $notify_options * (optional) An array of options to be passed to the message notifier * service. See `\Drupal\message_notify\MessageNotifier::send()`. * @param array $subscribe_options * (optional) Array with the following optional values: * - 'save message' (defaults to TRUE) Determine if the Message should be * saved. * - 'skip context' (defaults to FALSE) determine if extracting basic * context should be skipped in `self::getSubscribers()`. * - 'last uid' (defaults to 0) Only query UIDs greater than this UID. * - 'uids': Array of user IDs to be processed. Setting this, will cause * skipping `self::getSubscribers()` to get the subscribed * users. * - 'range': (defaults to FALSE) limit the number of items to fetch in the * subscribers query. * - 'end time': The timestamp of the time limit for the function to * execute. Defaults to FALSE, meaning there is no time limitation. * - 'use queue': Determine if queue API should be used to * - 'queue': Set to TRUE to indicate the processing is done via a queue * worker. * - 'entity access: (defaults to TRUE) determine if access to view the * entity should be applied when getting the list of subscribed users. * - 'notify blocked users' (defaults to the global setting in * `message_subscribe.settings`) determine whether blocked users * should be notified. Typically this should be used in conjunction with * 'entity access' to ensure that blocked users don't receive * notifications about entities which they used to have access to * before they were blocked. * - 'notify message owner' (defaults to the global setting in * `message_subscribe.settings`) determines if the user that created the * entity gets notified of their own action. If TRUE the author will get * notified. * @param array $context * (optional) array keyed with the entity type and array of entity IDs as * the value. For example, if the event is related to a node * entity, the implementing module might pass along with the node * itself, the node author and related taxonomy terms. * * Example usage. * * @code * $subscribe_options['uids'] = array( * 1 => array( * 'notifiers' => array('email'), * ), * ); * $context = array( * 'node' => array(1), * // The node author. * 'user' => array(10), * // Related taxonomy terms. * 'taxonomy_term' => array(100, 200, 300) * ); * @endcode */ public function sendMessage(EntityInterface $entity, MessageInterface $message, array $notify_options = [], array $subscribe_options = [], array $context = []); /** * Retrieve a list of subscribers for a given entity. * * @param \Drupal\Core\Entity\EntityInterface $entity * The entity to retrieve subscribers for. * @param \Drupal\message\MessageInterface $message * The message entity. * @param array $options * (optional) An array of options with the same elements as the * `$subscribe_options` array for `self::sendMessage()`. * @param array $context * (optional) The context array, passed by reference. This has the same * elements as the `$context` paramater for `self::sendMessage()`. * * @return \Drupal\message_subscribe\Subscribers\DeliveryCandidateInterface[] * Array of delivery candidate objects keyed with the user IDs to send * notifications to. */ public function getSubscribers(EntityInterface $entity, MessageInterface $message, array $options = [], array &$context = []); /** * Get context from a given entity type. * * This is a naive implementation, which extracts context from an entity. * For example, given a node we extract the node author and related * taxonomy terms. * * @param \Drupal\Core\Entity\EntityInterface $entity * The entity object. * @param bool $skip_detailed_context * (optional) Skip detailed context detection and just use entity ID/type. * Defaults to FALSE. * @param array $context * (optional) The starting context array to modify. * * @return array * Array keyed with the entity type and array of entity IDs as the value. */ public function getBasicContext(EntityInterface $entity, $skip_detailed_context = FALSE, array $context = []); /** * Get Message subscribe related flags. * * Return Flags related to message subscribe using a name convention -- * the flag name should start with "subscribe_". * * @param string $entity_type * (optional) The entity type for which to load the flags. * @param string $bundle * (optional) The bundle for which to load the flags. * @param \Drupal\Core\Session\AccountInterface $account * (optional) The user account to filter available flags. If not set, all * flags for the given entity and bundle will be returned. * * @return \Drupal\flag\FlagInterface[] * An array of the structure [fid] = flag_object. * * @see \Drupal\flag\FlagServiceInterface::getAllFlags() */ public function getFlags($entity_type = NULL, $bundle = NULL, AccountInterface $account = NULL); }
rahulrasgon/Music-Store-Theme
modules/message_subscribe/src/SubscribersInterface.php
PHP
gpl-2.0
5,817
<?php /** * Table Definition for Items_Translations * * PHP version 5 * * Copyright (C) Demian Katz 2012. * * 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. * * 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 * * @category GeebyDeeby * @package Db_Table * @author Demian Katz <demian.katz@villanova.edu> * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License * @link https://github.com/demiankatz/Geeby-Deeby Main Site */ namespace GeebyDeeby\Db\Table; use Laminas\Db\Adapter\Adapter; use Laminas\Db\RowGateway\RowGateway; use Laminas\Db\Sql\Expression; use Laminas\Db\Sql\Select; /** * Table Definition for Items_Translations * * @category GeebyDeeby * @package Db_Table * @author Demian Katz <demian.katz@villanova.edu> * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License * @link https://github.com/demiankatz/Geeby-Deeby Main Site */ class ItemsTranslations extends Gateway { /** * Constructor * * @param Adapter $adapter Database adapter * @param PluginManager $tm Table manager * @param RowGateway $rowObj Row prototype object (null for default) */ public function __construct(Adapter $adapter, PluginManager $tm, RowGateway $rowObj = null ) { parent::__construct($adapter, $tm, $rowObj, 'Items_Translations'); } /** * Support method to add language information to a query. * * @param \Laminas\Db\Sql\Select $select Query to modify * * @return void */ public static function addLanguageToSelect($select) { $select->join( ['eds' => 'Editions'], 'eds.Item_ID = i.Item_ID', [], Select::JOIN_LEFT ); $select->join( ['s' => 'Series'], 's.Series_ID = eds.Series_ID', [], Select::JOIN_LEFT ); $select->join( ['l' => 'Languages'], 'l.Language_ID = s.Language_ID', [ 'Language_Name' => new Expression( 'min(?)', ['Language_Name'], [Expression::TYPE_IDENTIFIER] ) ], Select::JOIN_LEFT ); $select->group('i.Item_ID'); } /** * Get a list of items translated from the specified item. * * @param int $itemID Item ID * @param bool $includeLang Should we also load language information? * * @return mixed */ public function getTranslatedFrom($itemID, $includeLang = false) { $callback = function ($select) use ($itemID, $includeLang) { $select->join( ['i' => 'Items'], 'Items_Translations.Trans_Item_ID = i.Item_ID' ); $select->where->equalTo('Source_Item_ID', $itemID); $select->order('i.Item_Name'); if ($includeLang) { ItemsTranslations::addLanguageToSelect($select); } }; return $this->select($callback); } /** * Get a list of items translated into the specified item. * * @param int $itemID Item ID * @param bool $includeLang Should we also load language information? * * @return mixed */ public function getTranslatedInto($itemID, $includeLang = false) { $callback = function ($select) use ($itemID, $includeLang) { $select->join( ['i' => 'Items'], 'Items_Translations.Source_Item_ID = i.Item_ID' ); $select->where->equalTo('Trans_Item_ID', $itemID); $select->order('i.Item_Name'); if ($includeLang) { ItemsTranslations::addLanguageToSelect($select); } }; return $this->select($callback); } }
demiankatz/Geeby-Deeby
module/GeebyDeeby/src/GeebyDeeby/Db/Table/ItemsTranslations.php
PHP
gpl-2.0
4,351
/* * irctabitem.cpp * * Copyright 2008 David Vachulka <david@konstrukce-cad.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. */ #ifdef WIN32 #define WIN32_LEAN_AND_MEAN #include <windows.h> #include <shellapi.h> #endif #include "irctabitem.h" #include "tetristabitem.h" #include "icons.h" #include "config.h" #include "i18n.h" FXDEFMAP(DccSendDialog) DccSendDialogMap[] = { FXMAPFUNC(SEL_COMMAND, DccSendDialog_FILE, DccSendDialog::onFile), FXMAPFUNC(SEL_COMMAND, DccSendDialog_SEND, DccSendDialog::onSend), FXMAPFUNC(SEL_COMMAND, DccSendDialog_CANCEL, DccSendDialog::onCancel), FXMAPFUNC(SEL_CLOSE, 0, DccSendDialog::onCancel), FXMAPFUNC(SEL_KEYPRESS, 0, DccSendDialog::onKeyPress) }; FXIMPLEMENT(DccSendDialog, FXDialogBox, DccSendDialogMap, ARRAYNUMBER(DccSendDialogMap)) DccSendDialog::DccSendDialog(FXMainWindow* owner, FXString nick) : FXDialogBox(owner, FXStringFormat(_("Send file to %s"), nick.text()), DECOR_RESIZE|DECOR_TITLE|DECOR_BORDER, 0,0,0,0, 0,0,0,0, 0,0) { m_mainFrame = new FXVerticalFrame(this, LAYOUT_FILL_X|LAYOUT_FILL_Y); m_fileFrame = new FXHorizontalFrame(m_mainFrame, LAYOUT_FILL_X); new FXLabel(m_fileFrame, _("File:")); m_fileText = new FXTextField(m_fileFrame, 25, NULL, 0, TEXTFIELD_READONLY|FRAME_THICK|FRAME_SUNKEN|LAYOUT_FILL_X); m_buttonFile = new dxEXButton(m_fileFrame, "...", NULL, this, DccSendDialog_FILE, FRAME_RAISED|FRAME_THICK|LAYOUT_CENTER_X, 0,0,0,0, 10,10,2,2); m_passiveFrame = new FXHorizontalFrame(m_mainFrame, LAYOUT_FILL_X); m_checkPassive = new FXCheckButton(m_passiveFrame, _("Send passive"), NULL, 0); m_buttonFrame = new FXHorizontalFrame(m_mainFrame, LAYOUT_FILL_X|PACK_UNIFORM_WIDTH); m_buttonCancel = new dxEXButton(m_buttonFrame, _("&Cancel"), NULL, this, DccSendDialog_CANCEL, FRAME_RAISED|FRAME_THICK|LAYOUT_RIGHT, 0,0,0,0, 10,10,2,2); m_buttonSend = new dxEXButton(m_buttonFrame, _("&Send file"), NULL, this, DccSendDialog_SEND, BUTTON_INITIAL|BUTTON_DEFAULT|FRAME_RAISED|FRAME_THICK|LAYOUT_RIGHT, 0,0,0,0, 10,10,2,2); } DccSendDialog::~DccSendDialog() { } FXuint DccSendDialog::execute(FXuint placement) { create(); show(placement); getApp()->refresh(); dxEXFileDialog dialog(this, _("Select file")); if(dialog.execute()) { m_fileText->setText(dialog.getFilename()); } return getApp()->runModalFor(this); } long DccSendDialog::onFile(FXObject*, FXSelector, void*) { dxEXFileDialog dialog(this, _("Select file")); if(dialog.execute()) { m_fileText->setText(dialog.getFilename()); } return 1; } long DccSendDialog::onSend(FXObject*, FXSelector, void*) { getApp()->stopModal(this,TRUE); hide(); return 1; } long DccSendDialog::onCancel(FXObject*, FXSelector, void*) { getApp()->stopModal(this,FALSE); hide(); return 1; } long DccSendDialog::onKeyPress(FXObject *sender, FXSelector sel, void *ptr) { if(FXTopWindow::onKeyPress(sender,sel,ptr)) return 1; if(((FXEvent*)ptr)->code == KEY_Escape) { handle(this,FXSEL(SEL_COMMAND,DccSendDialog_CANCEL),NULL); return 1; } return 0; } FXDEFMAP(NickList) NickListMap [] = { FXMAPFUNC(SEL_QUERY_TIP, 0, NickList::onQueryTip) }; FXIMPLEMENT(NickList, FXList, NickListMap, ARRAYNUMBER(NickListMap)) NickList::NickList(FXComposite* p, IrcTabItem* tgt, FXSelector sel, FXuint opts, FXint x, FXint y, FXint w, FXint h) : FXList(p, tgt, sel, opts, x, y, w, h), m_parent(tgt) { } long NickList::onQueryTip(FXObject *sender, FXSelector sel, void *ptr) { if(FXWindow::onQueryTip(sender, sel, ptr)) return 1; if((flags&FLAG_TIP) && !(options&LIST_AUTOSELECT) && (0<=cursor)) // No tip when autoselect! { FXString string = items[cursor]->getText(); string.append('\n'); NickInfo nick = m_parent->m_engine->getNickInfo(items[cursor]->getText()); string.append(FXStringFormat(_("User: %s@%s\n"), nick.user.text(), nick.host.text())); string.append(FXStringFormat(_("Realname: %s"), nick.real.text())); sender->handle(this, FXSEL(SEL_COMMAND,ID_SETSTRINGVALUE), (void*)&string); return 1; } return 0; } FXIMPLEMENT(NickListItem, FXListItem, NULL, 0) void NickListItem::setUserMode(UserMode mode) { m_mode = mode; FXbool away = m_tab->m_engine->getNickInfo(getText()).away; m_parent->recalc(); switch(m_mode){ case ADMIN: setIcon(away? ICO_IRCAWAYADMIN:ICO_IRCADMIN);break; case OWNER: setIcon(away? ICO_IRCAWAYOWNER:ICO_IRCOWNER);break; case OP: setIcon(away? ICO_IRCAWAYOP:ICO_IRCOP);break; case HALFOP: setIcon(away? ICO_IRCAWAYHALFOP:ICO_IRCHALFOP);break; case VOICE: setIcon(away? ICO_IRCAWAYVOICE:ICO_IRCVOICE);break; case NONE: setIcon(away? ICO_IRCAWAYNORMAL:ICO_IRCNORMAL);break; } } void NickListItem::changeAway(FXbool away) { m_parent->recalc(); switch(m_mode){ case ADMIN: setIcon(away? ICO_IRCAWAYADMIN:ICO_IRCADMIN);break; case OWNER: setIcon(away? ICO_IRCAWAYOWNER:ICO_IRCOWNER);break; case OP: setIcon(away? ICO_IRCAWAYOP:ICO_IRCOP);break; case HALFOP: setIcon(away? ICO_IRCAWAYHALFOP:ICO_IRCHALFOP);break; case VOICE: setIcon(away? ICO_IRCAWAYVOICE:ICO_IRCVOICE);break; case NONE: setIcon(away? ICO_IRCAWAYNORMAL:ICO_IRCNORMAL);break; } } FXDEFMAP(IrcTabItem) IrcTabItemMap[] = { FXMAPFUNC(SEL_COMMAND, IrcTabItem_COMMANDLINE, IrcTabItem::onCommandline), FXMAPFUNC(SEL_KEYPRESS, IrcTabItem_COMMANDLINE, IrcTabItem::onKeyPress), FXMAPFUNC(SEL_COMMAND, IrcEngine_SERVER, IrcTabItem::onIrcEvent), FXMAPFUNC(SEL_TIMEOUT, IrcTabItem_PTIME, IrcTabItem::onPipeTimeout), FXMAPFUNC(SEL_TIMEOUT, IrcTabItem_ETIME, IrcTabItem::onEggTimeout), FXMAPFUNC(SEL_TEXTLINK, IrcTabItem_TEXT, IrcTabItem::onTextLink), FXMAPFUNC(SEL_RIGHTBUTTONRELEASE, IrcTabItem_USERS, IrcTabItem::onRightMouse), FXMAPFUNC(SEL_DOUBLECLICKED, IrcTabItem_USERS, IrcTabItem::onDoubleclick), FXMAPFUNC(SEL_COMMAND, IrcTabItem_NEWQUERY, IrcTabItem::onNewQuery), FXMAPFUNC(SEL_COMMAND, IrcTabItem_WHOIS, IrcTabItem::onWhois), FXMAPFUNC(SEL_COMMAND, IrcTabItem_DCCCHAT, IrcTabItem::onDccChat), FXMAPFUNC(SEL_COMMAND, IrcTabItem_DCCSEND, IrcTabItem::onDccSend), FXMAPFUNC(SEL_COMMAND, IrcTabItem_OP, IrcTabItem::onOp), FXMAPFUNC(SEL_COMMAND, IrcTabItem_DEOP, IrcTabItem::onDeop), FXMAPFUNC(SEL_COMMAND, IrcTabItem_VOICE, IrcTabItem::onVoice), FXMAPFUNC(SEL_COMMAND, IrcTabItem_DEVOICE, IrcTabItem::onDevoice), FXMAPFUNC(SEL_COMMAND, IrcTabItem_KICK, IrcTabItem::onKick), FXMAPFUNC(SEL_COMMAND, IrcTabItem_BAN, IrcTabItem::onBan), FXMAPFUNC(SEL_COMMAND, IrcTabItem_KICKBAN, IrcTabItem::onKickban), FXMAPFUNC(SEL_COMMAND, IrcTabItem_IGNORE, IrcTabItem::onIgnore), FXMAPFUNC(SEL_COMMAND, IrcTabItem_TOPIC, IrcTabItem::onTopic), FXMAPFUNC(SEL_LINK, IrcTabItem_TOPIC, IrcTabItem::onTopicLink), FXMAPFUNC(SEL_COMMAND, dxPipe::ID_PIPE, IrcTabItem::onPipe), FXMAPFUNC(SEL_COMMAND, IrcTabItem_AWAY, IrcTabItem::onSetAway), FXMAPFUNC(SEL_COMMAND, IrcTabItem_DEAWAY, IrcTabItem::onRemoveAway), FXMAPFUNC(SEL_COMMAND, IrcTabItem_SPELL, IrcTabItem::onSpellLang) }; FXIMPLEMENT(IrcTabItem, dxTabItem, IrcTabItemMap, ARRAYNUMBER(IrcTabItemMap)) IrcTabItem::IrcTabItem(dxTabBook *tab, const FXString &tabtext, FXIcon *icon, FXuint opts, FXint id, TYPE type, IrcEngine *socket, FXbool ownServerWindow, FXbool usersShown, FXbool logging, FXString commandsList, FXString logPath, FXint maxAway, IrcColor colors, FXString nickChar, FXFont *font, FXbool sameCommand, FXbool sameList, FXbool coloredNick, FXbool stripColors, FXbool useSpell, FXbool showSpellCombo) : dxTabItem(tab, tabtext, icon, opts, id), m_engine(socket), m_parent(tab), m_type(type), m_usersShown(usersShown), m_logging(logging), m_ownServerWindow(ownServerWindow), m_sameCmd(sameCommand), m_sameList(sameList), m_coloredNick(coloredNick), m_stripColors(stripColors), m_useSpell(useSpell), m_showSpellCombo(showSpellCombo), m_colors(colors), m_commandsList(commandsList), m_logPath(logPath), m_maxAway(maxAway), m_nickCompletionChar(nickChar), m_logstream(NULL) { m_currentPosition = 0; m_historyMax = 25; m_numberUsers = 0; m_maxLen = 460; m_iamOp = FALSE; m_topic = _("No topic is set"); m_editableTopic = TRUE; m_pipe = NULL; m_sendPipe = FALSE; m_scriptHasAll = FALSE; m_scriptHasMyMsg = FALSE; m_unreadColor = FXRGB(0,0,255); m_highlightColor = FXRGB(255,0,0); if(m_type == CHANNEL && m_engine->getConnected()) { m_engine->sendMode(getText()); } m_mainframe = new FXVerticalFrame(m_parent, FRAME_RAISED|LAYOUT_SIDE_TOP|LAYOUT_FILL_X|LAYOUT_FILL_Y); m_splitter = new FXSplitter(m_mainframe, LAYOUT_SIDE_TOP|LAYOUT_FILL_X|LAYOUT_FILL_Y|SPLITTER_REVERSED|SPLITTER_TRACKING); m_textframe = new FXVerticalFrame(m_splitter, FRAME_SUNKEN|FRAME_THICK|LAYOUT_FILL_X|LAYOUT_FILL_Y); m_topicline = new dxTextField(m_textframe, 50, this, IrcTabItem_TOPIC, FRAME_SUNKEN|TEXTFIELD_ENTER_ONLY|JUSTIFY_LEFT|LAYOUT_FILL_X); m_topicline->setFont(font); m_topicline->setLinkColor(m_colors.link); m_topicline->setText(m_topic); m_topicline->setUseLink(TRUE); m_topicline->setTopicline(TRUE); if(m_type != CHANNEL) { m_topicline->hide(); } m_text = new dxText(m_textframe, this, IrcTabItem_TEXT, FRAME_SUNKEN|LAYOUT_FILL_X|LAYOUT_FILL_Y|TEXT_READONLY|TEXT_WORDWRAP|TEXT_SHOWACTIVE|TEXT_AUTOSCROLL); m_text->setFont(font); m_text->setSelTextColor(getApp()->getSelforeColor()); m_text->setSelBackColor(getApp()->getSelbackColor()); m_usersframe = new FXVerticalFrame(m_splitter, FRAME_SUNKEN|FRAME_THICK|LAYOUT_FILL_X|LAYOUT_FILL_Y|LAYOUT_FIX_WIDTH); m_users = new NickList(m_usersframe, this, IrcTabItem_USERS, LAYOUT_FILL_X|LAYOUT_FILL_Y); m_users->setSortFunc(FXList::ascendingCase); m_users->setScrollStyle(HSCROLLING_OFF); if(m_sameList) m_users->setFont(font); if(m_type != CHANNEL || !m_usersShown) { m_usersframe->hide(); m_users->hide(); } m_commandframe = new FXHorizontalFrame(m_mainframe, LAYOUT_FILL_X, 0,0,0,0, 0,0,0,0); m_commandline = new dxTextField(m_commandframe, 25, this, IrcTabItem_COMMANDLINE, TEXTFIELD_ENTER_ONLY|FRAME_SUNKEN|JUSTIFY_LEFT|LAYOUT_FILL_X|LAYOUT_BOTTOM, 0, 0, 0, 0, 1, 1, 1, 1); if(m_sameCmd) m_commandline->setFont(font); m_spellLangs = new FXComboBox(m_commandframe, 6, this, IrcTabItem_SPELL, COMBOBOX_STATIC); m_spellLangs->setTipText(_("Spellchecking language list")); m_spellLangs->hide(); if(m_sameCmd) m_spellLangs->setFont(font); if(m_useSpell && (m_type==CHANNEL || m_type==QUERY) && utils::instance().getLangsNum()) { dxStringArray langs = utils::instance().getLangs(); FXString lang = utils::instance().getChannelLang(getText()); for(FXint i=0; i<langs.no(); i++) { m_spellLangs->appendItem(langs[i]); if(langs[i]==lang) m_spellLangs->setCurrentItem(i);; } if(m_showSpellCombo) m_spellLangs->show(); m_commandline->setUseSpell(TRUE); m_commandline->setLanguage(lang); m_commandline->setTipText(FXStringFormat(_("Current spellchecking language: %s"),lang.text())); } dxHiliteStyle style = {m_colors.text,m_colors.back,getApp()->getSelforeColor(),getApp()->getSelbackColor(),0,FALSE}; for(int i=0; i<17; i++) { m_textStyleList.append(style); } //gray text - user commands m_textStyleList[0].normalForeColor = m_colors.user; //orange text - Actions m_textStyleList[1].normalForeColor = m_colors.action; //blue text - Notice m_textStyleList[2].normalForeColor = m_colors.notice; //red text - Errors m_textStyleList[3].normalForeColor = m_colors.error; //bold style m_textStyleList[4].style = FXText::STYLE_BOLD; //underline style m_textStyleList[5].style = FXText::STYLE_UNDERLINE; //bold & underline m_textStyleList[6].style = FXText::STYLE_UNDERLINE; m_textStyleList[6].style ^=FXText::STYLE_BOLD; //highlight text m_textStyleList[7].normalForeColor = m_colors.hilight; //link style m_textStyleList[8].normalForeColor = m_colors.link; m_textStyleList[8].link = TRUE; //next styles for colored nicks m_textStyleList[9].normalForeColor = FXRGB(196, 160, 0); m_textStyleList[10].normalForeColor = FXRGB(206, 92, 0); m_textStyleList[11].normalForeColor = FXRGB(143, 89, 2); m_textStyleList[12].normalForeColor = FXRGB(78, 154, 6); m_textStyleList[13].normalForeColor = FXRGB(32, 74, 135); m_textStyleList[14].normalForeColor = FXRGB(117, 80, 123); m_textStyleList[15].normalForeColor = FXRGB(164, 0, 0); m_textStyleList[16].normalForeColor = FXRGB(85, 87, 83); //text->setStyled(TRUE); m_text->setHiliteStyles(m_textStyleList.data()); m_text->setBackColor(m_colors.back); m_commandline->setBackColor(m_colors.back); m_topicline->setBackColor(m_colors.back); m_users->setBackColor(m_colors.back); m_text->setTextColor(m_colors.text); m_commandline->setTextColor(m_colors.text); m_commandline->setCursorColor(m_colors.text); m_topicline->setTextColor(m_colors.text); m_topicline->setCursorColor(m_colors.text); m_users->setTextColor(m_colors.text); m_spellLangs->setBackColor(m_colors.back); m_spellLangs->setTextColor(m_colors.text); this->setIconPosition(ICON_BEFORE_TEXT); } IrcTabItem::~IrcTabItem() { this->stopLogging(); if(m_pipe) m_pipe->stopCmd(); m_pipeStrings.clear(); getApp()->removeTimeout(this, IrcTabItem_PTIME); } void IrcTabItem::createGeom() { m_mainframe->create(); m_commandline->setFocus(); } void IrcTabItem::clearChat() { m_textStyleList.no(17); m_text->setHiliteStyles(m_textStyleList.data()); m_text->clearText(); } //usefull for set tab current void IrcTabItem::makeLastRowVisible() { m_text->makeLastRowVisible(TRUE); } FXString IrcTabItem::getSpellLang() { #ifdef HAVE_ENCHANT if(m_spellLangs->getNumItems()) return m_spellLangs->getItemText(m_spellLangs->getCurrentItem()); #endif return ""; } void IrcTabItem::reparentTab() { reparent(m_parent); m_mainframe->reparent(m_parent); } void IrcTabItem::hideUsers() { m_usersShown = !m_usersShown; if(m_type == CHANNEL) { m_usersframe->hide(); m_users->hide(); m_splitter->setSplit(1, 0); } } void IrcTabItem::showUsers() { m_usersShown = !m_usersShown; if(m_type == CHANNEL) { m_usersframe->show(); m_users->show(); m_splitter->recalc(); } } void IrcTabItem::setType(const TYPE &typ, const FXString &tabtext) { if(typ == CHANNEL) { if(m_usersShown) m_usersframe->show(); if(m_usersShown) m_users->show(); m_topicline->show(); m_topicline->setText(m_topic); m_splitter->recalc(); setText(tabtext); if(m_engine->getConnected()) m_engine->sendMode(getText()); m_type = typ; } else if(typ == SERVER || typ == QUERY) { m_usersframe->hide(); m_users->hide(); m_topicline->setText(""); m_topicline->hide(); m_topic = _("No topic is set"); setText(tabtext); m_splitter->setSplit(1, 0); if(m_type == CHANNEL) { m_users->clearItems(); m_numberUsers = 0; } m_type = typ; } this->stopLogging(); if(m_type == SERVER) this->setIcon(ICO_SERVER); else if(m_type == CHANNEL) this->setIcon(ICO_CHANNEL); else this->setIcon(ICO_QUERY); if(m_useSpell && (m_type==CHANNEL || m_type==QUERY) && utils::instance().getLangsNum()) { dxStringArray langs = utils::instance().getLangs(); FXString lang = utils::instance().getChannelLang(getText()); for(FXint i=0; i<langs.no(); i++) { m_spellLangs->appendItem(langs[i]); if(langs[i]==lang) m_spellLangs->setCurrentItem(i);; } if(m_showSpellCombo) m_spellLangs->show(); m_commandline->setUseSpell(TRUE); m_commandline->setLanguage(lang); m_commandline->setTipText(FXStringFormat(_("Current spellchecking language: %s"),lang.text())); } else { m_commandline->setUseSpell(FALSE); m_commandline->setTipText(""); m_spellLangs->hide(); m_commandframe->recalc(); } } void IrcTabItem::setColor(IrcColor clrs) { m_colors = clrs; setTextForeColor(clrs.text); setTextBackColor(clrs.back); setUserColor(clrs.user); setActionsColor(clrs.action); setNoticeColor(clrs.notice); setErrorColor(clrs.error); setHilightColor(clrs.hilight); setLinkColor(m_colors.link); } void IrcTabItem::setTextBackColor(FXColor clr) { for(FXint i=0; i<m_textStyleList.no(); i++) { m_textStyleList[i].normalBackColor = clr; } m_text->setBackColor(clr); m_commandline->setBackColor(clr); m_topicline->setBackColor(clr); m_users->setBackColor(clr); m_spellLangs->setBackColor(clr); } void IrcTabItem::setTextForeColor(FXColor clr) { m_textStyleList[4].normalForeColor = clr; m_textStyleList[5].normalForeColor = clr; m_textStyleList[6].normalForeColor = clr; m_text->setTextColor(clr); m_commandline->setTextColor(clr); m_commandline->setCursorColor(clr); m_topicline->setTextColor(clr); m_topicline->setCursorColor(clr); m_users->setTextColor(clr); m_spellLangs->setTextColor(clr); } void IrcTabItem::setUserColor(FXColor clr) { m_textStyleList[0].normalForeColor = clr; } void IrcTabItem::setActionsColor(FXColor clr) { m_textStyleList[1].normalForeColor = clr; } void IrcTabItem::setNoticeColor(FXColor clr) { m_textStyleList[2].normalForeColor = clr; } void IrcTabItem::setErrorColor(FXColor clr) { m_textStyleList[3].normalForeColor = clr; } void IrcTabItem::setHilightColor(FXColor clr) { m_textStyleList[7].normalForeColor = clr; } void IrcTabItem::setLinkColor(FXColor clr) { m_textStyleList[8].normalForeColor = clr; m_topicline->setLinkColor(clr); } void IrcTabItem::setUnreadTabColor(FXColor clr) { if(m_unreadColor!=clr) { FXbool update = this->getTextColor()==m_unreadColor; m_unreadColor = clr; if(update) this->setTextColor(m_unreadColor); } } void IrcTabItem::setHighlightTabColor(FXColor clr) { if(m_highlightColor!=clr) { FXbool update = this->getTextColor()==m_highlightColor; m_highlightColor = clr; if(update) this->setTextColor(m_highlightColor); } } void IrcTabItem::setCommandsList(FXString clst) { m_commandsList = clst; } void IrcTabItem::setMaxAway(FXint maxa) { m_maxAway = maxa; } void IrcTabItem::setLogging(FXbool log) { m_logging = log; } void IrcTabItem::setLogPath(FXString pth) { m_logPath = pth; this->stopLogging(); } void IrcTabItem::setNickCompletionChar(FXString nichr) { m_nickCompletionChar = nichr; } void IrcTabItem::setIrcFont(FXFont *fnt) { if(m_text->getFont() != fnt) { m_text->setFont(fnt); m_text->recalc(); } if(m_topicline->getFont() != fnt) { m_topicline->setFont(fnt); m_topicline->recalc(); } if(m_sameCmd && m_commandline->getFont() != fnt) { m_commandline->setFont(fnt); m_commandline->recalc(); m_spellLangs->setFont(fnt); m_spellLangs->recalc(); } else { m_commandline->setFont(getApp()->getNormalFont()); m_commandline->recalc(); m_spellLangs->setFont(getApp()->getNormalFont()); m_spellLangs->recalc(); } if(m_sameList && m_users->getFont() != fnt) { m_users->setFont(fnt); m_users->recalc(); } else { m_users->setFont(getApp()->getNormalFont()); m_users->recalc(); } } void IrcTabItem::setSameCmd(FXbool scmd) { m_sameCmd = scmd; } void IrcTabItem::setSameList(FXbool slst) { m_sameList = slst; } void IrcTabItem::setColoredNick(FXbool cnick) { m_coloredNick = cnick; } void IrcTabItem::setStripColors(FXbool sclr) { m_stripColors = sclr; } void IrcTabItem::setSmileys(FXbool smiley, dxSmileyArray nsmileys) { m_text->setSmileys(smiley, nsmileys); } void IrcTabItem::setUseSpell(FXbool useSpell) { m_useSpell = useSpell; if(m_useSpell && (m_type==CHANNEL || m_type==QUERY) && utils::instance().getLangsNum()) { dxStringArray langs = utils::instance().getLangs(); FXString lang = utils::instance().getChannelLang(getText()); for(FXint i=0; i<langs.no(); i++) { m_spellLangs->appendItem(langs[i]); if(langs[i]==lang) m_spellLangs->setCurrentItem(i);; } if(m_showSpellCombo) m_spellLangs->show(); m_commandline->setUseSpell(TRUE); m_commandline->setLanguage(lang); m_commandline->setTipText(FXStringFormat(_("Current spellchecking language: %s"),lang.text())); } else { m_commandline->setUseSpell(FALSE); m_commandline->setTipText(""); m_spellLangs->hide(); } m_commandframe->recalc(); } void IrcTabItem::setShowSpellCombo(FXbool showSpellCombo) { if(m_showSpellCombo!=showSpellCombo) { m_showSpellCombo = showSpellCombo; if(m_showSpellCombo) m_spellLangs->show(); else m_spellLangs->hide(); m_commandframe->recalc(); } } void IrcTabItem::removeSmileys() { m_text->removeSmileys(); } //if highlight==TRUE, highlight tab void IrcTabItem::appendText(FXString msg, FXbool highlight, FXbool logLine) { appendIrcText(msg, 0, FALSE, logLine); if(highlight && m_highlightColor != this->getTextColor() && m_parent->getCurrent()*2 != m_parent->indexOfChild(this)) { if(msg.contains(getNickName())) { this->setTextColor(m_highlightColor); if(m_type == CHANNEL) this->setIcon(ICO_CHANNELNEWMSG); } else this->setTextColor(m_unreadColor); if(m_type == QUERY) this->setIcon(ICO_QUERYNEWMSG); } } void IrcTabItem::appendIrcText(FXString msg, FXTime time, FXbool disableStrip, FXbool logLine) { if(!time) time = FXSystem::now(); if(m_type != OTHER) m_text->appendText("["+FXSystem::time("%H:%M:%S", time) +"] "); appendLinkText(m_stripColors && !disableStrip ? stripColors(msg, FALSE) : msg, 0); if(logLine) this->logLine(stripColors(msg, TRUE), time); } void IrcTabItem::appendIrcNickText(FXString nick, FXString msg, FXint style, FXTime time, FXbool logLine) { if(!time) time = FXSystem::now(); if(m_type != OTHER) m_text->appendText("["+FXSystem::time("%H:%M:%S", time) +"] "); m_text->appendStyledText(nick+": ", style); appendLinkText(m_stripColors ? stripColors(msg, FALSE) : msg, 0); if(logLine) this->logLine(stripColors("<"+nick+"> "+msg, TRUE), time); } /* if highlight==TRUE, highlight tab * disableStrip is for dxirc.Print */ void IrcTabItem::appendStyledText(FXString text, FXint style, FXbool highlight, FXbool disableStrip, FXbool logLine) { if(style) appendIrcStyledText(text, style, 0, disableStrip, logLine); else appendIrcText(text, 0, disableStrip, logLine); if(highlight && m_highlightColor != this->getTextColor() && m_parent->getCurrent()*2 != m_parent->indexOfChild(this)) { if(m_type != OTHER && text.contains(getNickName())) { this->setTextColor(m_highlightColor); if(m_type == CHANNEL) this->setIcon(ICO_CHANNELNEWMSG); } else this->setTextColor(m_unreadColor); if(m_type == QUERY) this->setIcon(ICO_QUERYNEWMSG); } } void IrcTabItem::appendIrcStyledText(FXString styled, FXint stylenum, FXTime time, FXbool disableStrip, FXbool logLine) { if(!time) time = FXSystem::now(); if(m_type != OTHER) m_text->appendText("["+FXSystem::time("%H:%M:%S", time) +"] "); appendLinkText(m_stripColors && !disableStrip ? stripColors(styled, TRUE) : styled, stylenum); if(logLine) this->logLine(stripColors(styled, TRUE), time); } static FXbool isBadchar(FXchar c) { switch(c) { case ' ': case ',': case '\0': case '\02': case '\03': case '\017': case '\021': case '\026': case '\035': case '\037': case '\n': case '\r': case '<': case '>': case '"': case '\'': return TRUE; default: return FALSE; } } // checks is char nick/word delimiter static FXbool isDelimiter(FXchar c) { switch(c) { case ' ': case '.': case ',': case '/': case '\\': case '`': case '\'': case '!': case '(': case ')': case '{': case '}': case '|': case '[': case ']': case '\"': case ':': case ';': case '<': case '>': case '?': return TRUE; default: return FALSE; } } void IrcTabItem::appendLinkText(const FXString &txt, FXint stylenum) { FXint i = 0; FXint linkLength = 0; FXbool bold = FALSE; FXbool under = FALSE; FXint lastStyle = stylenum; FXColor foreColor = stylenum && stylenum<=m_textStyleList.no() ? m_textStyleList[stylenum-1].normalForeColor : m_colors.text; FXColor backColor = stylenum && stylenum<=m_textStyleList.no() ? m_textStyleList[stylenum-1].normalBackColor : m_colors.back; FXString normalText = ""; FXint length = txt.length(); while(i<length) { if(txt[i]=='h' && !comparecase(txt.mid(i,7),"http://")) { if(!normalText.empty()) { m_text->appendStyledText(normalText, lastStyle); normalText.clear(); } for(FXint j=i; j<length; j++) { if(isBadchar(txt[j])) { break; } linkLength++; } m_text->appendStyledText(txt.mid(i, linkLength), linkLength>7 ? 9 : stylenum); i+=linkLength-1; linkLength=0; } else if(txt[i]=='h' && !comparecase(txt.mid(i,8),"https://")) { if(!normalText.empty()) { m_text->appendStyledText(normalText, lastStyle); normalText.clear(); } for(FXint j=i; j<length; j++) { if(isBadchar(txt[j])) { break; } linkLength++; } m_text->appendStyledText(txt.mid(i, linkLength), linkLength>8 ? 9 : stylenum); i+=linkLength-1; linkLength=0; } else if(txt[i]=='f' && !comparecase(txt.mid(i,6),"ftp://")) { if(!normalText.empty()) { m_text->appendStyledText(normalText, lastStyle); normalText.clear(); } for(FXint j=i; j<length; j++) { if(isBadchar(txt[j])) { break; } linkLength++; } m_text->appendStyledText(txt.mid(i, linkLength), linkLength>6 ? 9 : stylenum); i+=linkLength-1; linkLength=0; } else if(txt[i]=='w' && !comparecase(txt.mid(i,4),"www.")) { if(!normalText.empty()) { m_text->appendStyledText(normalText, lastStyle); normalText.clear(); } for(FXint j=i; j<length; j++) { if(isBadchar(txt[j])) { break; } linkLength++; } m_text->appendStyledText(txt.mid(i, linkLength), linkLength>4 ? 9 : stylenum); i+=linkLength-1; linkLength=0; } else { if(txt[i] == '\002') //bold { if(!normalText.empty()) { m_text->appendStyledText(normalText, lastStyle); normalText.clear(); } bold = !bold; FXuint style = 0; if(bold && under) style = FXText::STYLE_BOLD|FXText::STYLE_UNDERLINE; else if(bold && !under) style = FXText::STYLE_BOLD; else if(!bold && under) style = FXText::STYLE_UNDERLINE; lastStyle = hiliteStyleExist(foreColor, backColor, style); if(lastStyle == -1) { //dxText has available max. 255 styles if(m_textStyleList.no()<256) { createHiliteStyle(foreColor, backColor, style); lastStyle = m_textStyleList.no(); } else lastStyle = 0; } } else if(txt[i] == '\026') //reverse { if(!normalText.empty()) { m_text->appendStyledText(normalText, lastStyle); normalText.clear(); } FXuint style = 0; if(bold && under) style = FXText::STYLE_BOLD|FXText::STYLE_UNDERLINE; else if(bold && !under) style = FXText::STYLE_BOLD; else if(!bold && under) style = FXText::STYLE_UNDERLINE; FXColor tempColor = foreColor; foreColor = backColor; backColor = tempColor; lastStyle = hiliteStyleExist(foreColor, backColor, style); if(lastStyle == -1) { //dxText has available max. 255 styles if(m_textStyleList.no()<256) { createHiliteStyle(foreColor, backColor, style); lastStyle = m_textStyleList.no(); } else lastStyle = 0; } } else if(txt[i] == '\037') //underline { if(!normalText.empty()) { m_text->appendStyledText(normalText, lastStyle); normalText.clear(); } under = !under; FXuint style = 0; if(bold && under) style = FXText::STYLE_BOLD|FXText::STYLE_UNDERLINE; else if(bold && !under) style = FXText::STYLE_BOLD; else if(!bold && under) style = FXText::STYLE_UNDERLINE; lastStyle = hiliteStyleExist(foreColor, backColor, style); if(lastStyle == -1) { //dxText has available max. 255 styles if(m_textStyleList.no()<256) { createHiliteStyle(foreColor, backColor, style); lastStyle = m_textStyleList.no(); } else lastStyle = 0; } } else if(txt[i] == '\021') //fixed { utils::instance().debugLine("Poslan fixed styl"); } else if(txt[i] == '\035') //italic { utils::instance().debugLine("Poslan italic styl"); } else if(txt[i] == '\003') //color { if(!normalText.empty()) { m_text->appendStyledText(normalText, lastStyle); normalText.clear(); } FXuint style=0; if(bold && under) style = FXText::STYLE_BOLD|FXText::STYLE_UNDERLINE; else if(bold && !under) style = FXText::STYLE_BOLD; else if(!bold && under) style = FXText::STYLE_UNDERLINE; FXbool isHexColor = FALSE; FXint colorLength = 0; foreColor = m_colors.text; backColor = m_colors.back; if(i+1<length) { if(txt[i+1] == '#') isHexColor = TRUE; } if(isHexColor) { if(FXRex("^\\h\\h\\h\\h\\h\\h+$").match(txt.mid(i+2,6))) { foreColor = FXRGB(FXIntVal(txt.mid(i+2,2),16),FXIntVal(txt.mid(i+4,2),16),FXIntVal(txt.mid(i+6,2),16)); colorLength +=7; } if(i+8 < length && txt[i+8] == ',' && FXRex("^\\h\\h\\h\\h\\h\\h+$").match(txt.mid(i+10,6))) { backColor = FXRGB(FXIntVal(txt.mid(i+10,2),16),FXIntVal(txt.mid(i+12,2),16),FXIntVal(txt.mid(i+14,2),16)); colorLength +=8; } } else { if(i+2<length) { FXint code = -1; if(isdigit(txt[i+1])) { if(isdigit(txt[i+2])) { code = (txt[i+1]-48)*10+txt[i+2]-48; colorLength +=2; } else { code = txt[i+1]-48; colorLength ++; } } if(code!=-1) foreColor = getIrcColor(code%16); } if(i+colorLength+1 < length && txt[i+colorLength+1] == ',') { FXint code = -1; if(isdigit(txt[i+colorLength+2])) { if(isdigit(txt[i+colorLength+3])) { code = (txt[i+colorLength+2]-48)*10+txt[i+colorLength+3]-48; colorLength +=3; } else { code = txt[i+colorLength+2]-48; colorLength +=2; } } if(code!=-1) backColor = getIrcColor(code%16); } } lastStyle = hiliteStyleExist(foreColor, backColor, style); if(lastStyle == -1) { //dxText has available max. 255 styles if(m_textStyleList.no()<256) { createHiliteStyle(foreColor, backColor, style); lastStyle = m_textStyleList.no(); } else lastStyle = 0; }; i +=colorLength; } else if(txt[i] == '\017') //reset { if(!normalText.empty()) { m_text->appendStyledText(normalText, lastStyle); normalText.clear(); } bold = FALSE; under = FALSE; foreColor = m_colors.text; backColor = m_colors.back; lastStyle = stylenum; } else { normalText.append(txt[i]); } } i++; } if(!normalText.empty()) { m_text->appendStyledText(normalText, lastStyle); } m_text->appendText("\n"); } void IrcTabItem::startLogging() { if(m_logstream && FXStat::exists(m_logPath+PATHSEPSTRING+m_engine->getNetworkName()+PATHSEPSTRING+getText()+PATHSEPSTRING+FXSystem::time("%Y-%m-%d", FXSystem::now()))) return; if(m_logging && m_type != SERVER) { if(!FXStat::exists(m_logPath+PATHSEPSTRING+m_engine->getNetworkName())) FXDir::create(m_logPath+PATHSEPSTRING+m_engine->getNetworkName()); if(!FXStat::exists(m_logPath+PATHSEPSTRING+m_engine->getNetworkName()+PATHSEPSTRING+getText())) FXDir::create(m_logPath+PATHSEPSTRING+m_engine->getNetworkName()+PATHSEPSTRING+getText()); m_logstream = new std::ofstream(FXString(m_logPath+PATHSEPSTRING+m_engine->getNetworkName()+PATHSEPSTRING+getText()+PATHSEPSTRING+FXSystem::time("%Y-%m-%d", FXSystem::now())).text(), std::ios::out|std::ios::app); } } void IrcTabItem::stopLogging() { if(m_logstream) { m_logstream->close(); delete m_logstream; m_logstream = NULL; } } void IrcTabItem::logLine(const FXString &line, const FXTime &time) { if(m_logging && m_type != SERVER) { this->startLogging(); *m_logstream << "[" << FXSystem::time("%H:%M:%S", time).text() << "] " << line.text() << std::endl; } } FXbool IrcTabItem::isChannel(const FXString &text) { if(text.length()) return m_engine->getChanTypes().contains(text[0]); return FALSE; } long IrcTabItem::onCommandline(FXObject *, FXSelector, void *) { FXString commandtext = m_commandline->getText(); if(commandtext.empty()) return 1; m_commandsHistory.append(commandtext); if (m_commandsHistory.no() > m_historyMax) m_commandsHistory.erase(0); m_currentPosition = m_commandsHistory.no()-1; m_commandline->setText(""); if(comparecase(commandtext.left(4),"/say") != 0) commandtext.substitute("^B", "\002").substitute("^C", "\003").substitute("^O", "\017").substitute("^V", "\026").substitute("^_", "\037"); for(FXint i=0; i<=commandtext.contains('\n'); i++) { FXString text = commandtext.section('\n', i).before('\r'); if(comparecase(text.after('/').before(' '), "quit") == 0 || comparecase(text.after('/').before(' '), "lua") == 0) { processLine(text); return 1; } #ifdef HAVE_LUA if(text[0] != '/') m_parent->getParent()->getParent()->handle(this, FXSEL(SEL_COMMAND, IrcTabItem_MYMSG), &text); m_parent->getParent()->getParent()->handle(this, FXSEL(SEL_COMMAND, IrcTabItem_COMMAND), &text); if(text[0] == '/' && !m_scriptHasAll) processLine(text); else if(!m_scriptHasMyMsg && !m_scriptHasAll) processLine(text); #else processLine(text); #endif } return 1; } FXbool IrcTabItem::processLine(const FXString& commandtext) { FXString command = (commandtext[0] == '/' ? commandtext.before(' ') : ""); if(!utils::instance().getAlias(command).empty()) { FXString acommand = utils::instance().getAlias(command); if(acommand.contains("%s")) acommand.substitute("%s", commandtext.after(' ')); else acommand += commandtext.after(' '); FXint num = acommand.contains("&&"); if(num) { FXbool result = FALSE; for(FXint i=0; i<=acommand.contains('&'); i++) { if(!acommand.section('&',i).trim().empty()) result = processCommand(acommand.section('&',i).trim()); } return result; } else { return processCommand(acommand); } } return processCommand(commandtext); } FXbool IrcTabItem::processCommand(const FXString& commandtext) { FXString command = (commandtext[0] == '/' ? commandtext.after('/').before(' ').lower() : ""); if(m_type == OTHER) { if(utils::instance().isScriptCommand(command)) { LuaRequest lua; lua.type = LUA_COMMAND; lua.text = commandtext.after('/'); m_parent->getParent()->getParent()->handle(this, FXSEL(SEL_COMMAND, IrcTabItem_LUA), &lua); return TRUE; } if(command == "commands") { appendIrcStyledText(utils::instance().availableScriptsCommands(), 3, FXSystem::now(), FALSE, FALSE); return TRUE; } if(command == "egg") { m_text->clearText(); m_text->appendStyledText(FXString("ahoj sem pan Vajíčko.\n"), 3); getApp()->addTimeout(this, IrcTabItem_ETIME, 1000); m_pics = 0; return TRUE; } if(command == "help") { return showHelp(commandtext.after(' ').lower().trim()); } if(command == "tetris") { m_parent->getParent()->getParent()->handle(this, FXSEL(SEL_COMMAND, IrcTabItem_NEWTETRIS), NULL); return TRUE; } return TRUE; } if(commandtext[0] == '/') { if(utils::instance().isScriptCommand(command)) { LuaRequest lua; lua.type = LUA_COMMAND; lua.text = commandtext.after('/'); m_parent->getParent()->getParent()->handle(this, FXSEL(SEL_COMMAND, IrcTabItem_LUA), &lua); return TRUE; } if(command == "admin") { if(m_engine->getConnected()) return m_engine->sendAdmin(commandtext.after(' ')); else { appendIrcStyledText(_("You aren't connected"), 4, FXSystem::now(), FALSE, FALSE); m_parent->getParent()->getParent()->handle(this, FXSEL(SEL_COMMAND, IrcTabItem_CDIALOG), NULL); return TRUE; } } if(command == "away") { if(m_engine->getConnected()) { if(commandtext.after(' ').length() > m_engine->getAwayLen()) { appendIrcStyledText(FXStringFormat(_("Warning: Away message is too long. Max. away message length is %d."), m_engine->getAwayLen()), 4, FXSystem::now(), FALSE, FALSE); return m_engine->sendAway(commandtext.after(' ')); } else return m_engine->sendAway(commandtext.after(' ')); } else { appendIrcStyledText(_("You aren't connected"), 4, FXSystem::now(), FALSE, FALSE); m_parent->getParent()->getParent()->handle(this, FXSEL(SEL_COMMAND, IrcTabItem_CDIALOG), NULL); return TRUE; } } if(command == "banlist") { if(m_engine->getConnected()) { FXString channel = commandtext.after(' '); if(channel.empty() && m_type == CHANNEL) return m_engine->sendBanlist(getText()); else if(!isChannel(channel) && m_type != CHANNEL) { appendIrcStyledText(_("/banlist <channel>, shows banlist for channel."), 4, FXSystem::now(), FALSE, FALSE); return FALSE; } else return m_engine->sendBanlist(channel); } else { appendIrcStyledText(_("You aren't connected"), 4, FXSystem::now(), FALSE, FALSE); m_parent->getParent()->getParent()->handle(this, FXSEL(SEL_COMMAND, IrcTabItem_CDIALOG), NULL); return TRUE; } } if(command == "connect") { if(commandtext.after(' ').empty()) { appendIrcStyledText(_("/connect <server> [port] [nick] [password] [realname] [channels], connects for given server."), 4, FXSystem::now(), FALSE, FALSE); return FALSE; } else { ServerInfo srv; srv.hostname = commandtext.after(' ').section(' ', 0); srv.port = commandtext.after(' ').section(' ', 1).empty() ? 6667 : FXIntVal(commandtext.after(' ').section(' ', 1)); srv.nick = commandtext.after(' ').section(' ', 2).empty() ? FXSystem::currentUserName() : commandtext.after(' ').section(' ', 2); srv.passwd = commandtext.after(' ').section(' ', 3).empty() ? "" : commandtext.after(' ').section(' ', 3); srv.realname = commandtext.after(' ').section(' ', 4).empty() ? FXSystem::currentUserName() : commandtext.after(' ').section(' ', 4); srv.channels = commandtext.after(' ').section(' ', 5).empty() ? "" : commandtext.after(' ').section(' ', 5); m_parent->getParent()->getParent()->handle(this, FXSEL(SEL_COMMAND, IrcTabItem_CSERVER), &srv); return TRUE; } } if(command == "commands") { appendIrcStyledText(utils::instance().availableCommands(), 3, FXSystem::now(), FALSE, FALSE); return TRUE; } if(command == "ctcp") { if(m_engine->getConnected()) { FXString to = commandtext.after(' ').before(' '); FXString msg = commandtext.after(' ', 2); if(to.empty() || msg.empty()) { appendIrcStyledText(_("/ctcp <nick> <message>, sends a CTCP message to a user."), 4, FXSystem::now(), FALSE, FALSE); return FALSE; } else if(msg.length() > m_maxLen-12-to.length()) { appendIrcStyledText(FXStringFormat(_("Warning: ctcp message is too long. Max. ctcp message length is %d."), m_maxLen-12-to.length()), 4, FXSystem::now(), FALSE, FALSE); return m_engine->sendCtcp(to, msg); } else return m_engine->sendCtcp(to, msg); } else { appendIrcStyledText(_("You aren't connected"), 4, FXSystem::now(), FALSE, FALSE); m_parent->getParent()->getParent()->handle(this, FXSEL(SEL_COMMAND, IrcTabItem_CDIALOG), NULL); return TRUE; } } if(command == "cycle") { if(m_engine->getConnected()) { if(m_type == CHANNEL) { if(isChannel(commandtext.after(' '))) { FXString channel = commandtext.after(' ').before(' '); FXString reason = commandtext.after(' ', 2); reason.empty() ? m_engine->sendPart(channel) : m_engine->sendPart(channel, reason); return m_engine->sendJoin(channel); } else { commandtext.after(' ').empty() ? m_engine->sendPart(getText()) : m_engine->sendPart(getText(), commandtext.after(' ')); return m_engine->sendJoin(getText()); } } else { if(isChannel(commandtext.after(' '))) { FXString channel = commandtext.after(' ').before(' '); FXString reason = commandtext.after(' ', 2); reason.empty() ? m_engine->sendPart(channel) : m_engine->sendPart(channel, reason); return m_engine->sendJoin(channel); } else { appendIrcStyledText(_("/cycle <channel> [message], leaves and join channel."), 4, FXSystem::now(), FALSE, FALSE); return FALSE; } } } else { appendIrcStyledText(_("You aren't connected"), 4, FXSystem::now(), FALSE, FALSE); m_parent->getParent()->getParent()->handle(this, FXSEL(SEL_COMMAND, IrcTabItem_CDIALOG), NULL); return TRUE; } } if(command == "dcc") { if(m_engine->getConnected()) { FXString dccCommand = utils::instance().getParam(commandtext, 2, FALSE).lower(); if(dccCommand == "chat") { FXString nick = utils::instance().getParam(commandtext, 3, FALSE); if(!comparecase(nick, "chat")) { appendIrcStyledText(_("Nick for chat wasn't entered."), 4, FXSystem::now(), FALSE, FALSE); return FALSE; } if(!comparecase(nick, getNickName())) { appendIrcStyledText(_("Chat with yourself isn't good idea."), 4, FXSystem::now(), FALSE, FALSE); return FALSE; } IrcEvent ev; ev.eventType = IRC_DCCSERVER; ev.param1 = nick; m_parent->getParent()->getParent()->handle(m_engine, FXSEL(SEL_COMMAND, IrcEngine_SERVER), &ev); return TRUE; } else if(dccCommand == "send") { FXString nick = utils::instance().getParam(commandtext, 3, FALSE); FXString file = utils::instance().getParam(commandtext, 4, TRUE); if(!comparecase(nick, "send")) { appendIrcStyledText(_("Nick for sending file wasn't entered."), 4, FXSystem::now(), FALSE, FALSE); return FALSE; } if(!comparecase(nick, getNickName())) { appendIrcStyledText(_("Sending to yourself isn't good idea."), 4, FXSystem::now(), FALSE, FALSE); return FALSE; } if(!comparecase(nick, file)) { appendIrcStyledText(_("Filename wasn't entered"), 4, FXSystem::now(), FALSE, FALSE); return FALSE; } if(!FXStat::exists(file)) { appendIrcStyledText(FXStringFormat(_("File '%s' doesn't exist"), file.text()), 4, FXSystem::now(), FALSE, FALSE); return FALSE; } IrcEvent ev; ev.eventType = IRC_DCCOUT; ev.param1 = nick; ev.param2 = file; m_parent->getParent()->getParent()->handle(m_engine, FXSEL(SEL_COMMAND, IrcEngine_SERVER), &ev); return TRUE; } else if(dccCommand == "psend") { FXString nick = utils::instance().getParam(commandtext, 3, FALSE); FXString file = utils::instance().getParam(commandtext, 4, TRUE); if(!comparecase(nick, "psend")) { appendIrcStyledText(_("Nick for sending file wasn't entered."), 4, FXSystem::now(), FALSE, FALSE); return FALSE; } if(!comparecase(nick, getNickName())) { appendIrcStyledText(_("Sending to yourself isn't good idea."), 4, FXSystem::now(), FALSE, FALSE); return FALSE; } if(!comparecase(nick, file)) { appendIrcStyledText(_("Filename wasn't entered"), 4, FXSystem::now(), FALSE, FALSE); return FALSE; } if(!FXStat::exists(file)) { appendIrcStyledText(FXStringFormat(_("File '%s' doesn't exist"), file.text()), 4, FXSystem::now(), FALSE, FALSE); return FALSE; } IrcEvent ev; ev.eventType = IRC_DCCPOUT; ev.param1 = nick; ev.param2 = file; m_parent->getParent()->getParent()->handle(m_engine, FXSEL(SEL_COMMAND, IrcEngine_SERVER), &ev); return TRUE; } else { appendIrcStyledText(FXStringFormat(_("'%s' isn't dcc command <chat|send|psend>"), dccCommand.text()), 4, FXSystem::now(), FALSE, FALSE); return FALSE; } } else { appendIrcStyledText(_("You aren't connected"), 4, FXSystem::now(), FALSE, FALSE); m_parent->getParent()->getParent()->handle(this, FXSEL(SEL_COMMAND, IrcTabItem_CDIALOG), NULL); return TRUE; } } if(command == "deop") { if(m_engine->getConnected()) { FXString params = commandtext.after(' '); if(m_type == CHANNEL) { if(params.empty()) { appendIrcStyledText(_("/deop <nicks>, removes operator status from one or more nicks."), 4, FXSystem::now(), FALSE, FALSE); return FALSE; } else if(isChannel(params) && params.after(' ').empty()) { appendIrcStyledText(_("/deop <channel> <nicks>, removes operator status from one or more nicks."), 4, FXSystem::now(), FALSE, FALSE); return FALSE; } else if(isChannel(params) && !params.after(' ').empty()) { FXString channel = params.before(' '); FXString nicks = params.after(' '); FXString modeparams = utils::instance().createModes('-', 'o', nicks); return m_engine->sendMode(channel+" "+modeparams); } else { FXString channel = getText(); FXString nicks = params; FXString modeparams = utils::instance().createModes('-', 'o', nicks); return m_engine->sendMode(channel+" "+modeparams); } } else { if(isChannel(params) && !params.after(' ').empty()) { FXString channel = params.before(' '); FXString nicks = params.after(' '); FXString modeparams = utils::instance().createModes('-', 'o', nicks); return m_engine->sendMode(channel+" "+modeparams); } else { appendIrcStyledText(_("/deop <channel> <nicks>, removes operator status from one or more nicks."), 4, FXSystem::now(), FALSE, FALSE); return FALSE; } } } else { appendIrcStyledText(_("You aren't connected"), 4, FXSystem::now(), FALSE, FALSE); m_parent->getParent()->getParent()->handle(this, FXSEL(SEL_COMMAND, IrcTabItem_CDIALOG), NULL); return TRUE; } } if(command == "devoice") { if(m_engine->getConnected()) { FXString params = commandtext.after(' '); if(m_type == CHANNEL) { if(params.empty()) { appendIrcStyledText(_("/devoice <nicks>, removes voice from one or more nicks."), 4, FXSystem::now(), FALSE, FALSE); return FALSE; } else if(isChannel(params) && params.after(' ').empty()) { appendIrcStyledText(_("/devoice <channel> <nicks>, removes voice from one or more nicks."), 4, FXSystem::now(), FALSE, FALSE); return FALSE; } else if(isChannel(params) && !params.after(' ').empty()) { FXString channel = params.before(' '); FXString nicks = params.after(' '); FXString modeparams = utils::instance().createModes('-', 'v', nicks); return m_engine->sendMode(channel+" "+modeparams); } else { FXString channel = getText(); FXString nicks = params; FXString modeparams = utils::instance().createModes('-', 'v', nicks); return m_engine->sendMode(channel+" "+modeparams); } } else { if(isChannel(params) && !params.after(' ').empty()) { FXString channel = params.before(' '); FXString nicks = params.after(' '); FXString modeparams = utils::instance().createModes('-', 'v', nicks); return m_engine->sendMode(channel+" "+modeparams); } else { appendIrcStyledText(_("/devoice <channel> <nicks>, removes voice from one or more nicks."), 4, FXSystem::now(), FALSE, FALSE); return FALSE; } } } else { appendIrcStyledText(_("You aren't connected"), 4, FXSystem::now(), FALSE, FALSE); m_parent->getParent()->getParent()->handle(this, FXSEL(SEL_COMMAND, IrcTabItem_CDIALOG), NULL); return TRUE; } } if(command == "disconnect") { if(m_engine->getConnected()) { if(commandtext.after(' ').empty()) m_engine->disconnect(); else m_engine->disconnect(commandtext.after(' ')); return TRUE; } else { m_engine->closeConnection(TRUE); return TRUE; } } if(command == "dxirc") { for(FXint i=0; i<5+rand()%5; i++) { appendIrcText("", FXSystem::now(), FALSE, FALSE); } appendIrcText(" __ __ _", FXSystem::now(), FALSE, FALSE); appendIrcText(" _/__//__/|_ | | _", FXSystem::now(), FALSE, FALSE); appendIrcText(" /_| |_| |/_/| __| |__ __|_| _ _ ___", FXSystem::now(), FALSE, FALSE); appendIrcText(" |_ _ _|/ / _ |\\ \\/ /| || '_)/ __)", FXSystem::now(), FALSE, FALSE); appendIrcText(" /_| |_| |/_/| | (_| | | | | || | | (__", FXSystem::now(), FALSE, FALSE); appendIrcText(" |_ _ _|/ \\____|/_/\\_\\|_||_| \\___)", FXSystem::now(), FALSE, FALSE); appendIrcText(" |_|/|_|/ (c) 2008~ David Vachulka", FXSystem::now(), FALSE, FALSE); appendIrcText(" http://dxirc.org", FXSystem::now(), FALSE, FALSE); for(FXint i=0; i<5+rand()%5; i++) { appendIrcText("", FXSystem::now(), FALSE, FALSE); } return TRUE; } if(command == "egg") { m_text->clearText(); m_text->appendStyledText(FXString("ahoj sem pan Vajíčko.\n"), 3); getApp()->addTimeout(this, IrcTabItem_ETIME, 1000); m_pics = 0; return TRUE; } if(command == "exec") { FXString params = commandtext.after(' '); if(params.empty()) { appendIrcStyledText(_("/exec [-o|-c] <command>, executes command, -o sends output to channel/query, -c closes running command."), 4, FXSystem::now(), FALSE, FALSE); return FALSE; } else { if(!m_pipe) m_pipe = new dxPipe(getApp(), this); m_pipeStrings.clear(); if(params.before(' ').contains("-o")) { m_sendPipe = TRUE; m_pipe->execCmd(params.after(' ')); } else if(params.before(' ').contains("-c")) { m_sendPipe = FALSE; m_pipeStrings.clear(); m_pipe->stopCmd(); } else { m_sendPipe = FALSE; m_pipe->execCmd(params); } return TRUE; } } if(command == "help") { return showHelp(commandtext.after(' ').lower().trim()); } if(command == "ignore") { FXString ignorecommand = commandtext.after(' ').before(' '); FXString ignoretext = commandtext.after(' ').after(' '); if(ignorecommand.empty()) { appendIrcStyledText(_("/ignore <list|addcmd|rmcmd|addusr|rmusr> [command|user] [channel] [server]"), 4, FXSystem::now(), FALSE, FALSE); return FALSE; } if(comparecase(ignorecommand, "list")==0) { appendIrcStyledText(_("Ignored commands:"), 7, FXSystem::now(), FALSE, FALSE); if(m_commandsList.empty()) appendIrcText(_("No ignored commands"), FXSystem::now(), FALSE, FALSE); else appendIrcText(m_commandsList.rbefore(';'), FXSystem::now(), FALSE, FALSE); appendIrcStyledText(_("Ignored users:"), 7, FXSystem::now(), FALSE, FALSE); dxIgnoreUserArray users = m_engine->getUsersList(); if(!users.no()) appendIrcText(_("No ignored users"), FXSystem::now(), FALSE, FALSE); else { for(FXint i=0; i<users.no(); i++) { appendIrcText(FXStringFormat(_("%s on channel(s): %s and network: %s"), users[i].nick.text(), users[i].channel.text(), users[i].network.text()), FXSystem::now(), FALSE, FALSE); } } return TRUE; } else if(comparecase(ignorecommand, "addcmd")==0) { if(ignoretext.empty()) { appendIrcStyledText(_("/ignore addcmd <command>, adds command to ignored commands."), 4, FXSystem::now(), FALSE, FALSE); return FALSE; } m_parent->getParent()->getParent()->handle(this, FXSEL(SEL_COMMAND, IrcTabItem_ADDICOMMAND), &ignoretext); return TRUE; } else if(comparecase(ignorecommand, "rmcmd")==0) { if(ignoretext.empty()) { appendIrcStyledText(_("/ignore rmcmd <command>, removes command from ignored commands."), 4, FXSystem::now(), FALSE, FALSE); return FALSE; } m_parent->getParent()->getParent()->handle(this, FXSEL(SEL_COMMAND, IrcTabItem_RMICOMMAND), &ignoretext); return TRUE; } else if(comparecase(ignorecommand, "addusr")==0) { if(ignoretext.empty()) { appendIrcStyledText(_("/ignore addusr <user> [channel] [server], adds user to ignored users."), 4, FXSystem::now(), FALSE, FALSE); return FALSE; } m_parent->getParent()->getParent()->handle(this, FXSEL(SEL_COMMAND, IrcTabItem_ADDIUSER), &ignoretext); return TRUE; } else if(comparecase(ignorecommand, "rmusr")==0) { if(ignoretext.empty()) { appendIrcStyledText(_("/ignore rmusr <user>, removes user from ignored users."), 4, FXSystem::now(), FALSE, FALSE); return FALSE; } m_parent->getParent()->getParent()->handle(this, FXSEL(SEL_COMMAND, IrcTabItem_RMIUSER), &ignoretext); return TRUE; } else { appendIrcStyledText(FXStringFormat(_("'%s' isn't <list|addcmd|rmcmd|addusr|rmusr>"), ignorecommand.text()), 4, FXSystem::now(), FALSE, FALSE); return FALSE; } } if(command == "invite") { if(m_engine->getConnected()) { FXString params = commandtext.after(' '); if(params.empty()) { appendIrcStyledText(_("/invite <nick> <channel>, invites someone to a channel."), 4, FXSystem::now(), FALSE, FALSE); return FALSE; } else if(isChannel(params) && params.after(' ').empty()) { appendIrcStyledText(_("/invite <nick> <channel>, invites someone to a channel."), 4, FXSystem::now(), FALSE, FALSE); return FALSE; } else { FXString nick = params.before(' '); FXString channel = params.after(' '); return m_engine->sendInvite(nick, channel); } } else { appendIrcStyledText(_("You aren't connected"), 4, FXSystem::now(), FALSE, FALSE); m_parent->getParent()->getParent()->handle(this, FXSEL(SEL_COMMAND, IrcTabItem_CDIALOG), NULL); return TRUE; } } if(command == "join") { if(m_engine->getConnected()) { FXString channel = commandtext.after(' '); if(!isChannel(channel)) { appendIrcStyledText(_("/join <channel>, joins a channel."), 4, FXSystem::now(), FALSE, FALSE); appendIrcStyledText(FXStringFormat(_("'%c' isn't valid char for channel."), channel[0]), 4, FXSystem::now(), FALSE, FALSE); return FALSE; } else return m_engine->sendJoin(channel); } else { appendIrcStyledText(_("You aren't connected"), 4, FXSystem::now(), FALSE, FALSE); m_parent->getParent()->getParent()->handle(this, FXSEL(SEL_COMMAND, IrcTabItem_CDIALOG), NULL); return TRUE; } } if(command == "kick") { if(m_engine->getConnected()) { FXString params = commandtext.after(' '); if(m_type == CHANNEL) { if(params.empty()) { appendIrcStyledText(_("/kick <nick>, kicks a user from a channel."), 4, FXSystem::now(), FALSE, FALSE); return FALSE; } else if(isChannel(params) && params.after(' ').empty()) { appendIrcStyledText(_("/kick <channel> <nick>, kicks a user from a channel."), 4, FXSystem::now(), FALSE, FALSE); return FALSE; } else if(isChannel(params) && !params.after(' ').empty()) { FXString channel = params.before(' '); FXString nick = params.after(' '); FXString reason = params.after(' ', 2); if(reason.length() > m_engine->getKickLen()) { appendIrcStyledText(FXStringFormat(_("Warning: reason of kick is too long. Max. reason length is %d."), m_engine->getKickLen()), 4, FXSystem::now(), FALSE, FALSE); return m_engine->sendKick(channel, nick, reason); } else return m_engine->sendKick(channel, nick, reason); } else { FXString channel = getText(); FXString nick = params.before(' '); FXString reason = params.after(' '); if(reason.length() > m_engine->getKickLen()) { appendIrcStyledText(FXStringFormat(_("Warning: reason of kick is too long. Max. reason length is %d."), m_engine->getKickLen()), 4, FXSystem::now(), FALSE, FALSE); return m_engine->sendKick(channel, nick, reason); } else return m_engine->sendKick(channel, nick, reason); } } else { if(isChannel(params) && !params.after(' ').empty()) { FXString channel = params.before(' '); FXString nick = params.after(' '); FXString reason = params.after(' ', 2); if(reason.length() > m_engine->getKickLen()) { appendIrcStyledText(FXStringFormat(_("Warning: reason of kick is too long. Max. reason length is %d."), m_engine->getKickLen()), 4, FXSystem::now(), FALSE, FALSE); return m_engine->sendKick(channel, nick, reason); } else return m_engine->sendKick(channel, nick, reason); } else { appendIrcStyledText(_("/kick <channel> <nick>, kicks a user from a channel."), 4, FXSystem::now(), FALSE, FALSE); return FALSE; } } } else { appendIrcStyledText(_("You aren't connected"), 4, FXSystem::now(), FALSE, FALSE); m_parent->getParent()->getParent()->handle(this, FXSEL(SEL_COMMAND, IrcTabItem_CDIALOG), NULL); return TRUE; } } if(command == "kill") { if(m_engine->getConnected()) { FXString params = commandtext.after(' '); FXString nick = params.before(' '); FXString reason = params.after(' '); if(params.empty()) { appendIrcStyledText(_("/kill <user> [reason], kills a user from the network."), 4, FXSystem::now(), FALSE, FALSE); return FALSE; } if(reason.length() > m_maxLen-7-nick.length()) { appendIrcStyledText(FXStringFormat(_("Warning: reason of kill is too long. Max. reason length is %d."), m_maxLen-7-nick.length()), 4, FXSystem::now(), FALSE, FALSE); return m_engine->sendKill(nick, reason); } else return m_engine->sendKill(nick, reason); } else { appendIrcStyledText(_("You aren't connected"), 4, FXSystem::now(), FALSE, FALSE); m_parent->getParent()->getParent()->handle(this, FXSEL(SEL_COMMAND, IrcTabItem_CDIALOG), NULL); return TRUE; } } if(command == "list") { if(m_engine->getConnected()) return m_engine->sendList(commandtext.after(' ')); else { appendIrcStyledText(_("You aren't connected"), 4, FXSystem::now(), FALSE, FALSE); m_parent->getParent()->getParent()->handle(this, FXSEL(SEL_COMMAND, IrcTabItem_CDIALOG), NULL); return TRUE; } } if(command == "lua") { #ifdef HAVE_LUA FXString luacommand = commandtext.after(' ').before(' '); FXString luatext = commandtext.after(' ').after(' '); LuaRequest lua; if(luacommand.empty()) { appendIrcStyledText(_("/lua <help|load|unload|list> [scriptpath|scriptname]"), 4, FXSystem::now(), FALSE, FALSE); return FALSE; } if(comparecase(luacommand, "help")==0) { appendIrcStyledText(FXStringFormat(_("For help about Lua scripting visit: %s"), LUA_HELP_PATH), 3, FXSystem::now(), FALSE, FALSE); return TRUE; } else if(comparecase(luacommand, "load")==0) lua.type = LUA_LOAD; else if(comparecase(luacommand, "unload")==0) lua.type = LUA_UNLOAD; else if(comparecase(luacommand, "list")==0) lua.type = LUA_LIST; else { appendIrcStyledText(FXStringFormat(_("'%s' isn't <help|load|unload|list>"), luacommand.text()), 4, FXSystem::now(), FALSE, FALSE); return FALSE; } lua.text = luatext; m_parent->getParent()->getParent()->handle(this, FXSEL(SEL_COMMAND, IrcTabItem_LUA), &lua); return TRUE; #else appendIrcStyledText(_("dxirc is compiled without support for Lua scripting"), 4, FXSystem::now(), FALSE, FALSE); return FALSE; #endif } if(command == "me") { if(m_engine->getConnected()) { FXString params = commandtext.after(' '); if(m_type == CHANNEL) { if(params.empty()) { appendIrcStyledText(_("/me <message>, sends the action to the current channel."), 4, FXSystem::now(), FALSE, FALSE); return FALSE; } else if(isChannel(params) && !params.after(' ').empty()) { FXString channel = params.before(' '); FXString message = params.after(' '); if(channel == getText()) { appendIrcStyledText(getNickName()+" "+message, 2, FXSystem::now()); IrcEvent ev; ev.eventType = IRC_ACTION; ev.param1 = getNickName(); ev.param2 = channel; ev.param3 = message; m_parent->getParent()->getParent()->handle(m_engine, FXSEL(SEL_COMMAND, IrcEngine_SERVER), &ev); } if(message.length() > m_maxLen-19-channel.length()) { dxStringArray messages = cutText(message, m_maxLen-19-channel.length()); FXbool result = TRUE; for(FXint i=0; i<messages.no(); i++) { result = m_engine->sendMe(channel, messages[i]) &result; } return result; } else return m_engine->sendMe(channel, message); } else { appendIrcStyledText(getNickName()+" "+params, 2, FXSystem::now()); IrcEvent ev; ev.eventType = IRC_ACTION; ev.param1 = getNickName(); ev.param2 = getText(); ev.param3 = params; m_parent->getParent()->getParent()->handle(m_engine, FXSEL(SEL_COMMAND, IrcEngine_SERVER), &ev); if(params.length() > m_maxLen-19-getText().length()) { dxStringArray messages = cutText(params, m_maxLen-19-getText().length()); FXbool result = TRUE; for(FXint i=0; i<messages.no(); i++) { result = m_engine->sendMe(getText(), messages[i]) &result; } return result; } else return m_engine->sendMe(getText(), params); } } else if(m_type == QUERY) { if(params.empty()) { appendIrcStyledText(_("/me <message>, sends the action to the current query."), 4, FXSystem::now(), FALSE, FALSE); return FALSE; } else { appendIrcStyledText(getNickName()+" "+params, 2, FXSystem::now()); IrcEvent ev; ev.eventType = IRC_ACTION; ev.param1 = getNickName(); ev.param2 = getText(); ev.param3 = params; m_parent->getParent()->getParent()->handle(m_engine, FXSEL(SEL_COMMAND, IrcEngine_SERVER), &ev); if(params.length() > m_maxLen-19-getText().length()) { dxStringArray messages = cutText(params, m_maxLen-19-getText().length()); FXbool result = TRUE; for(FXint i=0; i<messages.no(); i++) { result = m_engine->sendMe(getText(), messages[i]) &result; } return result; } else return m_engine->sendMe(getText(), params); } } else { if(!params.after(' ').empty()) { FXString to = params.before(' '); FXString message = params.after(' '); if(message.length() > m_maxLen-19-to.length()) { dxStringArray messages = cutText(message, m_maxLen-19-to.length()); FXbool result = TRUE; for(FXint i=0; i<messages.no(); i++) { result = m_engine->sendMe(to, messages[i]) &result; } return result; } else return m_engine->sendMe(to, message); } else { appendIrcStyledText(_("/me <to> <message>, sends the action."), 4, FXSystem::now(), FALSE, FALSE); return FALSE; } } } else { appendIrcStyledText(_("You aren't connected"), 4, FXSystem::now(), FALSE, FALSE); m_parent->getParent()->getParent()->handle(this, FXSEL(SEL_COMMAND, IrcTabItem_CDIALOG), NULL); return TRUE; } } if(command == "mode") { if(m_engine->getConnected()) { FXString params = commandtext.after(' '); if(params.empty()) { appendIrcStyledText(_("/mode <channel> <modes>, sets modes for a channel."), 4, FXSystem::now(), FALSE, FALSE); return FALSE; } else return m_engine->sendMode(params); } else { appendIrcStyledText(_("You aren't connected"), 4, FXSystem::now(), FALSE, FALSE); m_parent->getParent()->getParent()->handle(this, FXSEL(SEL_COMMAND, IrcTabItem_CDIALOG), NULL); return TRUE; } } if(command == "msg") { if(m_engine->getConnected()) { FXString params = commandtext.after(' '); FXString to = params.before(' '); FXString message = params.after(' '); if(!to.empty() && !message.empty()) { if(to == getText()) { if(m_coloredNick) appendIrcNickText(getNickName(), message, getNickColor(getNickName()), FXSystem::now()); else appendIrcNickText(getNickName(), message, 5, FXSystem::now()); IrcEvent ev; ev.eventType = IRC_PRIVMSG; ev.param1 = getNickName(); ev.param2 = to; ev.param3 = message; m_parent->getParent()->getParent()->handle(m_engine, FXSEL(SEL_COMMAND, IrcEngine_SERVER), &ev); } if(message.length() > m_maxLen-10-to.length()) { dxStringArray messages = cutText(message, m_maxLen-10-to.length()); FXbool result = TRUE; for(FXint i=0; i<messages.no(); i++) { result = m_engine->sendMsg(to, messages[i]) &result; } return result; } else return m_engine->sendMsg(to, message); } else { appendIrcStyledText(_("/msg <nick/channel> <message>, sends a normal message."), 4, FXSystem::now(), FALSE, FALSE); return FALSE; } } else { appendIrcStyledText(_("You aren't connected"), 4, FXSystem::now(), FALSE, FALSE); m_parent->getParent()->getParent()->handle(this, FXSEL(SEL_COMMAND, IrcTabItem_CDIALOG), NULL); return TRUE; } } if(command == "names") { if(m_engine->getConnected()) { FXString params = commandtext.after(' '); if(m_type == CHANNEL) { if(params.empty()) return m_engine->sendNames(getText()); else return m_engine->sendNames(params); } else { if(params.empty()) { appendIrcStyledText(_("/names <channel>, for nicks on a channel."), 4, FXSystem::now(), FALSE, FALSE); return FALSE; } else return m_engine->sendNames(params); } } else { appendIrcStyledText(_("You aren't connected"), 4, FXSystem::now(), FALSE, FALSE); m_parent->getParent()->getParent()->handle(this, FXSEL(SEL_COMMAND, IrcTabItem_CDIALOG), NULL); return TRUE; } } if(command == "nick") { if(m_engine->getConnected()) { FXString nick = commandtext.after(' '); if(nick.empty()) { appendIrcStyledText(_("/nick <nick>, changes nick."), 4, FXSystem::now(), FALSE, FALSE); return FALSE; } else if(nick.length() > m_engine->getNickLen()) { appendIrcStyledText(FXStringFormat(_("Warning: nick is too long. Max. nick length is %d."), m_engine->getNickLen()), 4, FXSystem::now(), FALSE, FALSE); return m_engine->sendNick(nick); } else { return m_engine->sendNick(nick); } } else { appendIrcStyledText(_("You aren't connected"), 4, FXSystem::now(), FALSE, FALSE); m_parent->getParent()->getParent()->handle(this, FXSEL(SEL_COMMAND, IrcTabItem_CDIALOG), NULL); return TRUE; } } if(command == "notice") { if(m_engine->getConnected()) { FXString params = commandtext.after(' '); FXString to = params.before(' '); FXString message = params.after(' '); if(!to.empty() && !message.empty()) { appendIrcStyledText(FXStringFormat(_("NOTICE to %s: %s"), to.text(), message.text()), 2, FXSystem::now()); if(message.length() > m_maxLen-9-to.length()) { dxStringArray messages = cutText(message, m_maxLen-9-to.length()); FXbool result = TRUE; for(FXint i=0; i<messages.no(); i++) { result = m_engine->sendNotice(to, messages[i]) &result; } return result; } return m_engine->sendNotice(to, message); } else { appendIrcStyledText(_("/notice <nick/channel> <message>, sends a notice."), 4, FXSystem::now(), FALSE, FALSE); return FALSE; } } else { appendIrcStyledText(_("You aren't connected"), 4, FXSystem::now(), FALSE, FALSE); m_parent->getParent()->getParent()->handle(this, FXSEL(SEL_COMMAND, IrcTabItem_CDIALOG), NULL); return TRUE; } } if(command == "op") { if(m_engine->getConnected()) { FXString params = commandtext.after(' '); if(m_type == CHANNEL) { if(params.empty()) { appendIrcStyledText(_("/op <nicks>, gives operator status for one or more nicks."), 4, FXSystem::now(), FALSE, FALSE); return FALSE; } else if(isChannel(params) && params.after(' ').empty()) { appendIrcStyledText(_("/op <channel> <nicks>, gives operator status for one or more nicks."), 4, FXSystem::now(), FALSE, FALSE); return FALSE; } else if(isChannel(params) && !params.after(' ').empty()) { FXString channel = params.before(' '); FXString nicks = params.after(' '); FXString modeparams = utils::instance().createModes('+', 'o', nicks); return m_engine->sendMode(channel+" "+modeparams); } else { FXString channel = getText(); FXString nicks = params; FXString modeparams = utils::instance().createModes('+', 'o', nicks); return m_engine->sendMode(channel+" "+modeparams); } } else { if(isChannel(params) && !params.after(' ').empty()) { FXString channel = params.before(' '); FXString nicks = params.after(' '); FXString modeparams = utils::instance().createModes('+', 'o', nicks); return m_engine->sendMode(channel+" "+modeparams); } else { appendIrcStyledText(_("/op <channel> <nicks>, gives operator status for one or more nicks."), 4, FXSystem::now(), FALSE, FALSE); return FALSE; } } } else { appendIrcStyledText(_("You aren't connected"), 4, FXSystem::now(), FALSE, FALSE); m_parent->getParent()->getParent()->handle(this, FXSEL(SEL_COMMAND, IrcTabItem_CDIALOG), NULL); return TRUE; } } if(command == "oper") { if(m_engine->getConnected()) { FXString params = commandtext.after(' '); FXString login = params.before(' '); FXString password = params.after(' '); if(!login.empty() && !password.empty()) return m_engine->sendOper(login, password); else { appendIrcStyledText(_("/oper <login> <password>, oper up."), 4, FXSystem::now(), FALSE, FALSE); return FALSE; } } else { appendIrcStyledText(_("You aren't connected"), 4, FXSystem::now(), FALSE, FALSE); m_parent->getParent()->getParent()->handle(this, FXSEL(SEL_COMMAND, IrcTabItem_CDIALOG), NULL); return TRUE; } } if(command == "part") { if(m_engine->getConnected()) { if(m_type == CHANNEL) { if(commandtext.after(' ').empty()) return m_engine->sendPart(getText()); else return m_engine->sendPart(getText(), commandtext.after(' ')); } else { if(isChannel(commandtext.after(' '))) { FXString channel = commandtext.after(' ').before(' '); FXString reason = commandtext.after(' ', 2); if(reason.empty()) return m_engine->sendPart(channel); else return m_engine->sendPart(channel, reason); } else { appendIrcStyledText(_("/part <channel> [reason], leaves channel."), 4, FXSystem::now(), FALSE, FALSE); return FALSE; } } } else { appendIrcStyledText(_("You aren't connected"), 4, FXSystem::now(), FALSE, FALSE); m_parent->getParent()->getParent()->handle(this, FXSEL(SEL_COMMAND, IrcTabItem_CDIALOG), NULL); return TRUE; } } if(command == "query") { if(m_engine->getConnected()) { if(commandtext.after(' ').empty()) { appendIrcStyledText(_("/query <nick>, opens query with nick."), 4, FXSystem::now(), FALSE, FALSE); return FALSE; } else { IrcEvent ev; ev.eventType = IRC_QUERY; ev.param1 = commandtext.after(' ').before(' '); ev.param2 = getNickName(); m_parent->getParent()->getParent()->handle(m_engine, FXSEL(SEL_COMMAND, IrcEngine_SERVER), &ev); return TRUE; } } else { appendIrcStyledText(_("You aren't connected"), 4, FXSystem::now(), FALSE, FALSE); m_parent->getParent()->getParent()->handle(this, FXSEL(SEL_COMMAND, IrcTabItem_CDIALOG), NULL); return TRUE; } } if(command == "quit") { m_parent->getParent()->getParent()->handle(this, FXSEL(SEL_COMMAND, IrcTabItem_CQUIT), NULL); return TRUE; } if(command == "quote") { if(m_engine->getConnected()) return m_engine->sendQuote(commandtext.after(' ')); else { appendIrcStyledText(_("You aren't connected"), 4, FXSystem::now(), FALSE, FALSE); m_parent->getParent()->getParent()->handle(this, FXSEL(SEL_COMMAND, IrcTabItem_CDIALOG), NULL); return TRUE; } } if(command == "say") { if(m_engine->getConnected()) { if (m_type != SERVER && !commandtext.after(' ').empty()) { if(m_coloredNick) appendIrcNickText(getNickName(), commandtext.after(' '), getNickColor(getNickName()), FXSystem::now()); else appendIrcNickText(getNickName(), commandtext.after(' '), 5, FXSystem::now()); IrcEvent ev; ev.eventType = IRC_PRIVMSG; ev.param1 = getNickName(); ev.param2 = getText(); ev.param3 = commandtext.after(' '); m_parent->getParent()->getParent()->handle(m_engine, FXSEL(SEL_COMMAND, IrcEngine_SERVER), &ev); if(commandtext.after(' ').length() > m_maxLen-10-getText().length()) { dxStringArray messages = cutText(commandtext.after(' '), m_maxLen-10-getText().length()); FXbool result = TRUE; for(FXint i=0; i<messages.no(); i++) { result = m_engine->sendMsg(getText(), messages[i]) &result; } return result; } else return m_engine->sendMsg(getText(), commandtext.after(' ')); } return FALSE; } else { appendIrcStyledText(_("You aren't connected"), 4, FXSystem::now(), FALSE, FALSE); m_parent->getParent()->getParent()->handle(this, FXSEL(SEL_COMMAND, IrcTabItem_CDIALOG), NULL); return TRUE; } } if(command == "stats") { if(m_engine->getConnected()) return m_engine->sendStats(commandtext.after(' ')); else { appendIrcStyledText(_("You aren't connected"), 4, FXSystem::now(), FALSE, FALSE); m_parent->getParent()->getParent()->handle(this, FXSEL(SEL_COMMAND, IrcTabItem_CDIALOG), NULL); return TRUE; } } if(command == "tetris") { m_parent->getParent()->getParent()->handle(this, FXSEL(SEL_COMMAND, IrcTabItem_NEWTETRIS), NULL); return TRUE; } if(command == "time") { if(m_engine->getConnected()) return m_engine->sendQuote("TIME"); else { appendIrcStyledText(_("You aren't connected"), 4, FXSystem::now(), FALSE, FALSE); m_parent->getParent()->getParent()->handle(this, FXSEL(SEL_COMMAND, IrcTabItem_CDIALOG), NULL); return TRUE; } } if(command == "topic") { if(m_engine->getConnected()) { FXString params = commandtext.after(' '); if(m_type == CHANNEL) { if(params.empty()) return m_engine->sendTopic(getText()); else if(isChannel(params) && !params.after(' ').empty()) { FXString channel = params.before(' '); FXString topic = params.after(' '); if(topic.length() > m_engine->getTopicLen()) { appendIrcStyledText(FXStringFormat(_("Warning: topic is too long. Max. topic length is %d."), m_engine->getTopicLen()), 4, FXSystem::now(), FALSE, FALSE); return m_engine->sendTopic(channel, topic); } else return m_engine->sendTopic(channel, topic); } else { if(params.length() > m_engine->getTopicLen()) { appendIrcStyledText(FXStringFormat(_("Warning: topic is too long. Max. topic length is %d."), m_engine->getTopicLen()), 4, FXSystem::now(), FALSE, FALSE); return m_engine->sendTopic(getText(), params); } else return m_engine->sendTopic(getText(), params); } } else { if(isChannel(params)) { FXString channel = params.before(' '); FXString topic = params.after(' '); if(topic.length() > m_engine->getTopicLen()) { appendIrcStyledText(FXStringFormat(_("Warning: topic is too long. Max. topic length is %d."), m_engine->getTopicLen()), 4, FXSystem::now(), FALSE, FALSE); return m_engine->sendTopic(channel, params); } else return m_engine->sendTopic(channel, topic); } else { appendIrcStyledText(_("/topic <channel> [topic], views or changes channel topic."), 4, FXSystem::now(), FALSE, FALSE); return FALSE; } } } else { appendIrcStyledText(_("You aren't connected"), 4, FXSystem::now(), FALSE, FALSE); m_parent->getParent()->getParent()->handle(this, FXSEL(SEL_COMMAND, IrcTabItem_CDIALOG), NULL); return TRUE; } } if(command == "voice") { if(m_engine->getConnected()) { FXString params = commandtext.after(' '); if(m_type == CHANNEL) { if(params.empty()) { appendIrcStyledText(_("/voice <nicks>, gives voice for one or more nicks."), 4, FXSystem::now(), FALSE, FALSE); return FALSE; } else if(isChannel(params) && params.after(' ').empty()) { appendIrcStyledText(_("/voice <channel> <nicks>, gives voice for one or more nicks."), 4, FXSystem::now(), FALSE, FALSE); return FALSE; } else if(isChannel(params) && !params.after(' ').empty()) { FXString channel = params.before(' '); FXString nicks = params.after(' '); FXString modeparams = utils::instance().createModes('+', 'v', nicks); return m_engine->sendMode(channel+" "+modeparams); } else { FXString channel = getText(); FXString nicks = params; FXString modeparams = utils::instance().createModes('+', 'v', nicks); return m_engine->sendMode(channel+" "+modeparams); } } else { if(isChannel(params) && !params.after(' ').empty()) { FXString channel = params.before(' '); FXString nicks = params.after(' '); FXString modeparams = utils::instance().createModes('+', 'v', nicks); return m_engine->sendMode(channel+" "+modeparams); } else { appendIrcStyledText(_("/voice <channel> <nicks>, gives voice for one or more nicks."), 4, FXSystem::now(), FALSE, FALSE); return FALSE; } } } else { appendIrcStyledText(_("You aren't connected"), 4, FXSystem::now(), FALSE, FALSE); m_parent->getParent()->getParent()->handle(this, FXSEL(SEL_COMMAND, IrcTabItem_CDIALOG), NULL); return TRUE; } } if(command == "wallops") { if(m_engine->getConnected()) { FXString params = commandtext.after(' '); if(params.empty()) { appendIrcStyledText(_("/wallops <message>, sends wallop message."), 4, FXSystem::now(), FALSE, FALSE); return FALSE; } else { if(params.length() > m_maxLen-9) { dxStringArray messages = cutText(params, m_maxLen-9); FXbool result = TRUE; for(FXint i=0; i<messages.no(); i++) { result = m_engine->sendWallops(messages[i]) &result; } return result; } else return m_engine->sendWallops(params); } } else { appendIrcStyledText(_("You aren't connected"), 4, FXSystem::now(), FALSE, FALSE); m_parent->getParent()->getParent()->handle(this, FXSEL(SEL_COMMAND, IrcTabItem_CDIALOG), NULL); return TRUE; } } if(command == "who") { if(m_engine->getConnected()) { FXString params = commandtext.after(' '); if(params.empty()) { appendIrcStyledText(_("/who <mask> [o], searchs for mask on network, if o is supplied, only search for opers."), 4, FXSystem::now(), FALSE, FALSE); return FALSE; } else return m_engine->sendWho(params); } else { appendIrcStyledText(_("You aren't connected"), 4, FXSystem::now(), FALSE, FALSE); m_parent->getParent()->getParent()->handle(this, FXSEL(SEL_COMMAND, IrcTabItem_CDIALOG), NULL); return TRUE; } } if(command == "whoami") { if(m_engine->getConnected()) return m_engine->sendWhoami(); else { appendIrcStyledText(_("You aren't connected"), 4, FXSystem::now(), FALSE, FALSE); m_parent->getParent()->getParent()->handle(this, FXSEL(SEL_COMMAND, IrcTabItem_CDIALOG), NULL); return TRUE; } } if(command == "whois") { if(m_engine->getConnected()) { FXString params = commandtext.after(' '); if(params.empty()) { if(m_type == QUERY) return m_engine->sendWhois(getText()); appendIrcStyledText(_("/whois <nick>, whois nick."), 4, FXSystem::now(), FALSE, FALSE); return FALSE; } else return m_engine->sendWhois(params); } else { appendIrcStyledText(_("You aren't connected"), 4, FXSystem::now(), FALSE, FALSE); m_parent->getParent()->getParent()->handle(this, FXSEL(SEL_COMMAND, IrcTabItem_CDIALOG), NULL); return TRUE; } } if(command == "whowas") { if(m_engine->getConnected()) { FXString params = commandtext.after(' '); if(params.empty()) { appendIrcStyledText(_("/whowas <nick>, whowas nick."), 4, FXSystem::now(), FALSE, FALSE); return FALSE; } else return m_engine->sendWhowas(params); } else { appendIrcStyledText(_("You aren't connected"), 4, FXSystem::now(), FALSE, FALSE); m_parent->getParent()->getParent()->handle(this, FXSEL(SEL_COMMAND, IrcTabItem_CDIALOG), NULL); return TRUE; } } appendIrcStyledText(FXStringFormat(_("Unknown command '%s', type /commands for available commands"), command.text()), 4, FXSystem::now(), FALSE, FALSE); return FALSE; } else { if (command.empty() && m_type != SERVER && !commandtext.empty() && m_engine->getConnected()) { if(m_coloredNick) appendIrcNickText(getNickName(), commandtext, getNickColor(getNickName()), FXSystem::now()); else appendIrcNickText(getNickName(), commandtext, 5, FXSystem::now()); IrcEvent ev; ev.eventType = IRC_PRIVMSG; ev.param1 = getNickName(); ev.param2 = getText(); ev.param3 = commandtext; m_parent->getParent()->getParent()->handle(m_engine, FXSEL(SEL_COMMAND, IrcEngine_SERVER), &ev); if(commandtext.length() > m_maxLen-10-getText().length()) { dxStringArray messages = cutText(commandtext, m_maxLen-10-getText().length()); FXbool result = TRUE; for(FXint i=0; i<messages.no(); i++) { result = m_engine->sendMsg(getText(), messages[i]) &result; } return result; } else return m_engine->sendMsg(getText(), commandtext); } if(!m_engine->getConnected()) { appendIrcStyledText(_("You aren't connected"), 4, FXSystem::now(), FALSE, FALSE); m_parent->getParent()->getParent()->handle(this, FXSEL(SEL_COMMAND, IrcTabItem_CDIALOG), NULL); return TRUE; } return FALSE; } return FALSE; } FXbool IrcTabItem::showHelp(FXString command) { if(utils::instance().isScriptCommand(command)) { appendIrcStyledText(utils::instance().getHelpText(command), 3, FXSystem::now(), FALSE, FALSE); return TRUE; } if(command == "admin") { appendIrcStyledText(_("ADMIN [server], finds information about administrator for current server or [server]."), 3, FXSystem::now(), FALSE, FALSE); return TRUE; } if(command == "away") { appendIrcStyledText(_("AWAY [message], sets away status."), 3, FXSystem::now(), FALSE, FALSE); return TRUE; } if(command == "banlist") { appendIrcStyledText(_("BANLIST <channel>, shows banlist for channel."), 3, FXSystem::now(), FALSE, FALSE); return TRUE; } if(command == "commands") { appendIrcStyledText(_("COMMANDS, shows available commands"), 3, FXSystem::now(), FALSE, FALSE); return TRUE; } if(command == "connect") { appendIrcStyledText(_("CONNECT <server> [port] [nick] [password] [realname] [channels], connects for given server."), 3, FXSystem::now(), FALSE, FALSE); return TRUE; } if(command == "ctcp") { appendIrcStyledText(_("CTCP <nick> <message>, sends a CTCP message to a user."), 3, FXSystem::now(), FALSE, FALSE); return TRUE; } if(command == "cycle") { appendIrcStyledText(_("CYCLE <channel> [message], leaves and join channel."), 3, FXSystem::now(), FALSE, FALSE); return TRUE; } if(command == "dcc") { appendIrcStyledText(_("DCC chat <nick>, starts DCC chat."), 3, FXSystem::now(), FALSE, FALSE); appendIrcStyledText(_("DCC send <nick> <filename>, sends file over DCC."), 3, FXSystem::now(), FALSE, FALSE); appendIrcStyledText(_("DCC psend <nick> <filename>, sends file passive over DCC."), 3, FXSystem::now(), FALSE, FALSE); appendIrcStyledText(_("More information about passive DCC on http://en.wikipedia.org/wiki/Direct_Client-to-Client#Passive_DCC"), 3, FXSystem::now(), FALSE, FALSE); return TRUE; } if(command == "deop") { appendIrcStyledText(_("DEOP <channel> <nicks>, removes operator status from one or more nicks."), 3, FXSystem::now(), FALSE, FALSE); return TRUE; } if(command == "devoice") { appendIrcStyledText(_("DEVOICE <channel> <nicks>, removes voice from one or more nicks."), 3, FXSystem::now(), FALSE, FALSE); return TRUE; } if(command == "disconnect") { appendIrcStyledText(_("DISCONNECT [reason], leaves server."), 3, FXSystem::now(), FALSE, FALSE); return TRUE; } #ifndef WIN32 if(command == "exec") { appendIrcStyledText(_("EXEC [-o|-c] <command>, executes command, -o sends output to channel/query, -c closes running command."), 3, FXSystem::now(), FALSE, FALSE); return TRUE; } #endif if(command == "help") { appendIrcStyledText(_("HELP <command>, shows help for command."), 3, FXSystem::now(), FALSE, FALSE); return TRUE; } if(command == "ignore") { appendIrcStyledText(_("IGNORE list, shows list ignored commands and users."), 3, FXSystem::now(), FALSE, FALSE); appendIrcStyledText(_("IGNORE addcmd <command>, adds command to ignored commands."), 3, FXSystem::now(), FALSE, FALSE); appendIrcStyledText(_("IGNORE rmcmd <command>, removes command from ignored commands."), 3, FXSystem::now(), FALSE, FALSE); appendIrcStyledText(_("IGNORE addusr <user> [channel] [server], adds user to ignored users."), 3, FXSystem::now(), FALSE, FALSE); appendIrcStyledText(_("IGNORE rmusr <user>, removes user from ignored users."), 3, FXSystem::now(), FALSE, FALSE); return TRUE; } if(command == "invite") { appendIrcStyledText(_("INVITE <nick> <channel>, invites someone to a channel."), 3, FXSystem::now(), FALSE, FALSE); return TRUE; } if(command == "join") { appendIrcStyledText(_("JOIN <channel>, joins a channel."), 3, FXSystem::now(), FALSE, FALSE); return TRUE; } if(command == "kick") { appendIrcStyledText(_("KICK <channel> <nick>, kicks a user from a channel."), 3, FXSystem::now(), FALSE, FALSE); return TRUE; } if(command == "kill") { appendIrcStyledText(_("KILL <user> [reason], kills a user from the network."), 3, FXSystem::now(), FALSE, FALSE); return TRUE; } if(command == "list") { appendIrcStyledText(_("LIST [channel], lists channels and their topics."), 3, FXSystem::now(), FALSE, FALSE); return TRUE; } #ifdef HAVE_LUA if(command == "lua") { appendIrcStyledText(_("LUA help, shows help for lua scripting."), 3, FXSystem::now(), FALSE, FALSE); appendIrcStyledText(_("LUA load <path>, loads script."), 3, FXSystem::now(), FALSE, FALSE); appendIrcStyledText(_("Example: /lua load /home/dvx/test.lua"), 3, FXSystem::now(), FALSE, FALSE); appendIrcStyledText(_("LUA unload <name>, unloads script."), 3, FXSystem::now(), FALSE, FALSE); appendIrcStyledText(_("Example: /lua unload test"), 3, FXSystem::now(), FALSE, FALSE); appendIrcStyledText(_("LUA list, shows list of loaded scripts"), 3, FXSystem::now(), FALSE, FALSE); return TRUE; } #else if(command == "lua") { appendIrcStyledText(_("dxirc is compiled without support for Lua scripting"), 4, FXSystem::now(), FALSE, FALSE); return TRUE; } #endif if(command == "me") { appendIrcStyledText(_("ME <to> <message>, sends the action."), 3, FXSystem::now(), FALSE, FALSE); return TRUE; } if(command == "mode") { appendIrcStyledText(_("MODE <channel> <modes>, sets modes for a channel."), 3, FXSystem::now(), FALSE, FALSE); return TRUE; } if(command == "msg") { appendIrcStyledText(_("MSG <nick/channel> <message>, sends a normal message."), 3, FXSystem::now(), FALSE, FALSE); return TRUE; } if(command == "names") { appendIrcStyledText(_("NAMES <channel>, for nicks on a channel."), 3, FXSystem::now(), FALSE, FALSE); return TRUE; } if(command == "nick") { appendIrcStyledText(_("NICK <nick>, changes nick."), 3, FXSystem::now(), FALSE, FALSE); return TRUE; } if(command == "notice") { appendIrcStyledText(_("NOTICE <nick/channel> <message>, sends a notice."), 3, FXSystem::now(), FALSE, FALSE); return TRUE; } if(command == "op") { appendIrcStyledText(_("OP <channel> <nicks>, gives operator status for one or more nicks."), 3, FXSystem::now(), FALSE, FALSE); return TRUE; } if(command == "oper") { appendIrcStyledText(_("OPER <login> <password>, oper up."), 3, FXSystem::now(), FALSE, FALSE); return TRUE; } if(command == "part") { appendIrcStyledText(_("PART <channel> [reason], leaves channel."), 3, FXSystem::now(), FALSE, FALSE); return TRUE; } if(command == "query") { appendIrcStyledText(_("QUERY <nick>, opens query with nick."), 3, FXSystem::now(), FALSE, FALSE); return TRUE; } if(command == "quit") { appendIrcStyledText(_("QUIT, closes application."), 3, FXSystem::now(), FALSE, FALSE); return TRUE; } if(command == "quote") { appendIrcStyledText(_("QUOTE [text], sends text to server."), 3, FXSystem::now(), FALSE, FALSE); return TRUE; } if(command == "say") { appendIrcStyledText(_("SAY [text], sends text to current tab."), 3, FXSystem::now(), FALSE, FALSE); return TRUE; } if(command == "stats") { appendIrcStyledText(_("STATS <type>, shows some irc server usage statistics. Available types vary slightly per server; some common ones are:"), 3, FXSystem::now(), FALSE, FALSE); appendIrcStyledText(_("c - shows C and N lines for a given server. These are the names of the servers that are allowed to connect."), 3, FXSystem::now(), FALSE, FALSE); appendIrcStyledText(_("h - shows H and L lines for a given server (Hubs and Leaves)."), 3, FXSystem::now(), FALSE, FALSE); appendIrcStyledText(_("k - show K lines for a server. This shows who is not allowed to connect and possibly at what time they are not allowed to connect."), 3, FXSystem::now(), FALSE, FALSE); appendIrcStyledText(_("i - shows I lines. This is who CAN connect to a server."), 3, FXSystem::now(), FALSE, FALSE); appendIrcStyledText(_("l - shows information about amount of information passed to servers and users."), 3, FXSystem::now(), FALSE, FALSE); appendIrcStyledText(_("m - shows a count for the number of times the various commands have been used since the server was booted."), 3, FXSystem::now(), FALSE, FALSE); appendIrcStyledText(_("o - shows the list of authorized operators on the server."), 3, FXSystem::now(), FALSE, FALSE); appendIrcStyledText(_("p - shows online operators and their idle times."), 3, FXSystem::now(), FALSE, FALSE); appendIrcStyledText(_("u - shows the uptime for a server."), 3, FXSystem::now(), FALSE, FALSE); appendIrcStyledText(_("y - shows Y lines, which lists the various connection classes for a given server."), 3, FXSystem::now(), FALSE, FALSE); return TRUE; } if(command == "tetris") { appendIrcStyledText(_("TETRIS, start small easteregg."), 3, FXSystem::now(), FALSE, FALSE); appendIrcStyledText(_("Keys for playing:"), 3, FXSystem::now(), FALSE, FALSE); appendIrcStyledText(_("n .. new game"), 3, FXSystem::now(), FALSE, FALSE); appendIrcStyledText(_("p .. pause game"), 3, FXSystem::now(), FALSE, FALSE); appendIrcStyledText(_("i .. rotate piece"), 3, FXSystem::now(), FALSE, FALSE); appendIrcStyledText(_("l .. move piece right"), 3, FXSystem::now(), FALSE, FALSE); appendIrcStyledText(_("k .. drop piece"), 3, FXSystem::now(), FALSE, FALSE); appendIrcStyledText(_("j .. move piece left"), 3, FXSystem::now(), FALSE, FALSE); return TRUE; } if(command == "time") { appendIrcStyledText(_("TIME, displays the time of day, local to server."), 3, FXSystem::now(), FALSE, FALSE); return TRUE; } if(command == "topic") { appendIrcStyledText(_("TOPIC [topic], sets or shows topic."), 3, FXSystem::now(), FALSE, FALSE); return TRUE; } if(command == "voice") { appendIrcStyledText(_("VOICE <channel> <nicks>, gives voice for one or more nicks."), 3, FXSystem::now(), FALSE, FALSE); return TRUE; } if(command == "wallops") { appendIrcStyledText(_("WALLOPS <message>, sends wallop message."), 3, FXSystem::now(), FALSE, FALSE); return TRUE; } if(command == "who") { appendIrcStyledText(_("WHO <mask> [o], searchs for mask on network, if o is supplied, only search for opers."), 3, FXSystem::now(), FALSE, FALSE); return TRUE; } if(command == "whoami") { appendIrcStyledText(_("WHOAMI, whois about you."), 3, FXSystem::now(), FALSE, FALSE); return TRUE; } if(command == "whois") { appendIrcStyledText(_("WHOIS <nick>, whois nick."), 3, FXSystem::now(), FALSE, FALSE); return TRUE; } if(command == "whowas") { appendIrcStyledText(_("WHOWAS <nick>, whowas nick."), 3, FXSystem::now(), FALSE, FALSE); return TRUE; } if(!utils::instance().getAlias(command[0] == '/' ? command:"/"+command).empty()) { appendIrcStyledText(FXStringFormat("%s: %s", command.upper().text(), utils::instance().getAlias(command[0] == '/' ? command:"/"+command).text()), 3, FXSystem::now(), FALSE, FALSE); return TRUE; } if(command.empty()) appendIrcStyledText(_("Command is empty, type /commands for available commands"), 4, FXSystem::now(), FALSE, FALSE); else appendIrcStyledText(FXStringFormat(_("Unknown command '%s', type /commands for available commands"), command.text()), 4, FXSystem::now(), FALSE, FALSE); return FALSE; } long IrcTabItem::onKeyPress(FXObject *, FXSelector, void *ptr) { if (m_commandline->hasFocus()) { FXEvent* event = (FXEvent*)ptr; FXString line = m_commandline->getText(); switch(event->code){ case KEY_Tab: if(event->state&CONTROLMASK) { m_parent->getParent()->getParent()->handle(this, FXSEL(SEL_COMMAND, IrcTabItem_NEXTTAB), NULL); return 1; } if(line[0] == '/' && line.after(' ').empty()) { for(FXint i = 0; i < utils::instance().commandsNo(); i++) { if(comparecase(line.after('/').before(' '), utils::instance().commandsAt(i)) == 0) { if((i+1) < utils::instance().commandsNo()) m_commandline->setText("/"+utils::instance().commandsAt(++i)+" "); else m_commandline->setText("/"+utils::instance().commandsAt(0)+" "); break; } else if(comparecase(line.after('/'), utils::instance().commandsAt(i).left(line.after('/').length())) == 0) { m_commandline->setText("/"+utils::instance().commandsAt(i)+" "); break; } } return 1; } if(line[0] != '/' && line.after(' ').empty()) { if(line.empty()) { m_commandline->setText(getNick(0)+m_nickCompletionChar+" "); return 1; } for(FXint j = 0; j < m_users->getNumItems() ; j++) { if(comparecase(line, getNick(j).left(line.length())) == 0) { m_commandline->setText(getNick(j)+m_nickCompletionChar+" "); break; } else if(comparecase(line.section(m_nickCompletionChar, 0, 1), getNick(j)) == 0) { if((j+1) < m_users->getNumItems()) m_commandline->setText(getNick(++j)+m_nickCompletionChar+" "); else m_commandline->setText(getNick(0)+m_nickCompletionChar+" "); break; } } return 1; } if(line.find(' ') != -1) { FXint curpos; line[m_commandline->getCursorPos()] == ' ' ? curpos = m_commandline->getCursorPos()-1 : curpos = m_commandline->getCursorPos(); FXint pos = line.rfind(' ', curpos)+1; FXint n = line.find(' ', curpos)>0 ? line.find(' ', curpos)-pos : line.length()-pos; FXString toCompletion = line.mid(pos, n); for(FXint j = 0; j < m_users->getNumItems(); j++) { if(comparecase(toCompletion, getNick(j)) == 0) { if((j+1) < m_users->getNumItems()) { m_commandline->setText(line.replace(pos, n, getNick(j+1))); m_commandline->setCursorPos(pos+getNick(j+1).length()); } else { m_commandline->setText(line.replace(pos, n, getNick(0))); m_commandline->setCursorPos(pos+getNick(0).length()); } break; } else if(comparecase(toCompletion, getNick(j).left(toCompletion.length())) == 0) { m_commandline->setText(line.replace(pos, n, getNick(j))); m_commandline->setCursorPos(pos+getNick(j).length()); break; } } return 1; } return 1; case KEY_Up: if(m_currentPosition!=-1 && m_currentPosition<m_commandsHistory.no()) { if(!line.empty() && line!=m_commandsHistory[m_currentPosition]) { m_commandsHistory.append(line); if(m_commandsHistory.no() > m_historyMax) m_commandsHistory.erase(0); m_currentPosition = m_commandsHistory.no()-1; } if(m_currentPosition > 0 && !line.empty()) --m_currentPosition; m_commandline->setText(m_commandsHistory[m_currentPosition]); } return 1; case KEY_Down: if(m_currentPosition!=-1 && m_currentPosition<m_commandsHistory.no()) { if(!line.empty() && line!=m_commandsHistory[m_currentPosition]) { m_commandsHistory.append(line); if(m_commandsHistory.no() > m_historyMax) m_commandsHistory.erase(0); m_currentPosition = m_commandsHistory.no()-1; } if(m_currentPosition < m_commandsHistory.no()-1) { ++m_currentPosition; m_commandline->setText(m_commandsHistory[m_currentPosition]); } else m_commandline->setText(""); } return 1; case KEY_k: case KEY_K: if(event->state&CONTROLMASK) { FXint pos = m_commandline->getCursorPos(); m_commandline->setText(line.insert(pos, "^C")); //color m_commandline->setCursorPos(pos+2); return 1; } case KEY_b: case KEY_B: if(event->state&CONTROLMASK) { FXint pos = m_commandline->getCursorPos(); m_commandline->setText(line.insert(pos, "^B")); //bold m_commandline->setCursorPos(pos+2); return 1; } case KEY_i: case KEY_I: if(event->state&CONTROLMASK) { FXint pos = m_commandline->getCursorPos(); m_commandline->setText(line.insert(pos, "^_")); //underline m_commandline->setCursorPos(pos+2); return 1; } case KEY_r: case KEY_R: if(event->state&CONTROLMASK) { FXint pos = m_commandline->getCursorPos(); m_commandline->setText(line.insert(pos, "^V")); //reverse m_commandline->setCursorPos(pos+2); return 1; } case KEY_o: case KEY_O: if(event->state&CONTROLMASK) { FXint pos = m_commandline->getCursorPos(); m_commandline->setText(line.insert(m_commandline->getCursorPos(), "^O")); //reset m_commandline->setCursorPos(pos+2); return 1; } } } return 0; } //Check is this tab right for server message (e.g. not for IRC_SERVERREPLY) FXbool IrcTabItem::isRightForServerMsg() { //Check if current tab is in server targets if(m_engine->findTarget(m_parent->childAtIndex(m_parent->getCurrent()*2))) { return m_parent->indexOfChild(this) == m_parent->getCurrent()*2; } else { FXint indexOfThis = m_parent->indexOfChild(this); for(FXint i = 0; i<m_parent->numChildren(); i+=2) { if(m_engine->findTarget(m_parent->childAtIndex(i))) { if(i == indexOfThis) return TRUE; else return FALSE; } } } return FALSE; } FXbool IrcTabItem::isCommandIgnored(const FXString &command) { if(m_commandsList.contains(command)) return TRUE; return FALSE; } void IrcTabItem::addUser(const FXString& user, UserMode mode) { if(mode == ADMIN && m_users->findItem(user) == -1) { NickListItem *item = new NickListItem(user, m_users, this, mode, ICO_IRCADMIN); m_users->appendItem(item); m_numberUsers++; m_users->sortItems(); return; } if(mode == OWNER && m_users->findItem(user) == -1) { NickListItem *item = new NickListItem(user, m_users, this, mode, ICO_IRCOWNER); m_users->appendItem(item); m_numberUsers++; m_users->sortItems(); return; } if(mode == OP && m_users->findItem(user) == -1) { NickListItem *item = new NickListItem(user, m_users, this, mode, ICO_IRCOP); m_users->appendItem(item); m_numberUsers++; m_users->sortItems(); return; } if(mode == VOICE && m_users->findItem(user) == -1) { NickListItem *item = new NickListItem(user, m_users, this, mode, ICO_IRCVOICE); m_users->appendItem(item); m_numberUsers++; m_users->sortItems(); return; } if(mode == HALFOP && m_users->findItem(user) == -1) { NickListItem *item = new NickListItem(user, m_users, this, mode, ICO_IRCHALFOP); m_users->appendItem(item); m_numberUsers++; m_users->sortItems(); return; } if(mode == NONE && m_users->findItem(user) == -1) { NickListItem *item = new NickListItem(user, m_users, this, mode, ICO_IRCNORMAL); m_users->appendItem(item); m_numberUsers++; m_users->sortItems(); return; } } void IrcTabItem::removeUser(const FXString& user) { if(m_users->findItem(user) != -1) { m_users->removeItem(m_users->findItem(user)); } m_numberUsers--; m_users->sortItems(); } void IrcTabItem::changeNickUser(const FXString& nick, const FXString& newnick) { FXint i = m_users->findItem(nick); if(i != -1) { m_users->getItem(i)->setText(newnick); m_users->sortItems(); } } void IrcTabItem::setUserMode(const FXString& nick, UserMode mode) { FXint i = m_users->findItem(nick); if(i != -1) { ((NickListItem*)m_users->getItem(i))->setUserMode(mode); } } UserMode IrcTabItem::getUserMode(const FXchar mode) { if(mode == m_engine->getAdminPrefix()) return ADMIN; if(mode == m_engine->getOwnerPrefix()) return OWNER; if(mode == m_engine->getOpPrefix()) return OP; if(mode == m_engine->getHalfopPrefix()) return HALFOP; if(mode == m_engine->getVoicePrefix()) return VOICE; return NONE; } long IrcTabItem::onIrcEvent(FXObject *, FXSelector, void *data) { IrcEvent *ev = (IrcEvent *) data; if(ev->eventType == IRC_PRIVMSG) { onIrcPrivmsg(ev); return 1; } if(ev->eventType == IRC_ACTION) { onIrcAction(ev); return 1; } if(ev->eventType == IRC_CTCPREPLY) { onIrcCtpcReply(ev); return 1; } if(ev->eventType == IRC_CTCPREQUEST) { onIrcCtcpRequest(ev); return 1; } if(ev->eventType == IRC_JOIN) { onIrcJoin(ev); return 1; } if(ev->eventType == IRC_QUIT) { onIrcQuit(ev); return 1; } if(ev->eventType == IRC_PART) { onIrcPart(ev); return 1; } if(ev->eventType == IRC_CHNOTICE) { onIrcChnotice(ev); return 1; } if(ev->eventType == IRC_NOTICE) { onIrcNotice(ev); return 1; } if(ev->eventType == IRC_NICK) { onIrcNick(ev); return 1; } if(ev->eventType == IRC_TOPIC) { onIrcTopic(ev); return 1; } if(ev->eventType == IRC_INVITE) { onIrcInvite(ev); return 1; } if(ev->eventType == IRC_KICK) { onIrcKick(ev); return 1; } if(ev->eventType == IRC_MODE) { onIrcMode(ev); return 1; } if(ev->eventType == IRC_UMODE) { onIrcUmode(ev); return 1; } if(ev->eventType == IRC_CHMODE) { onIrcChmode(ev); return 1; } if(ev->eventType == IRC_SERVERREPLY) { onIrcServerReply(ev); return 1; } if(ev->eventType == IRC_CONNECT) { onIrcConnect(ev); return 1; } if(ev->eventType == IRC_ERROR) { onIrcError(ev); return 1; } if(ev->eventType == IRC_SERVERERROR) { onIrcServerError(ev); return 1; } if(ev->eventType == IRC_DISCONNECT) { onIrcDisconnect(ev); return 1; } if(ev->eventType == IRC_RECONNECT) { onIrcReconnect(ev); return 1; } if(ev->eventType == IRC_UNKNOWN) { onIrcUnknown(ev); return 1; } if(ev->eventType == IRC_301) { onIrc301(ev); return 1; } if(ev->eventType == IRC_305) { onIrc305(ev); return 1; } if(ev->eventType == IRC_306) { onIrc306(ev); return 1; } if(ev->eventType == IRC_331 || ev->eventType == IRC_332 || ev->eventType == IRC_333) { onIrc331332333(ev); return 1; } if(ev->eventType == IRC_353) { onIrc353(ev); return 1; } if(ev->eventType == IRC_366) { onIrc366(ev); return 1; } if(ev->eventType == IRC_372) { onIrc372(ev); return 1; } if(ev->eventType == IRC_AWAY) { onIrcAway(ev); return 1; } if(ev->eventType == IRC_ENDMOTD) { onIrcEndMotd(); return 1; } return 1; } //handle IrcEvent IRC_PRIVMSG void IrcTabItem::onIrcPrivmsg(IrcEvent* ev) { if((comparecase(ev->param2, getText()) == 0 && m_type == CHANNEL) || (ev->param1 == getText() && m_type == QUERY && ev->param2 == getNickName())) { FXbool needHighlight = FALSE; if(ev->param3.contains(getNickName())) needHighlight = highlightNeeded(ev->param3); if(m_coloredNick) { if(needHighlight) appendIrcStyledText(ev->param1+": "+ev->param3, 8, ev->time); else appendIrcNickText(ev->param1, ev->param3, getNickColor(ev->param1), ev->time); } else { if(needHighlight) appendIrcStyledText(ev->param1+": "+ev->param3, 8, ev->time); else appendIrcNickText(ev->param1, ev->param3, 5, ev->time); } if(m_highlightColor != this->getTextColor() && m_parent->getCurrent()*2 != m_parent->indexOfChild(this)) { if(needHighlight) { this->setTextColor(m_highlightColor); if(m_type == CHANNEL) this->setIcon(ICO_CHANNELNEWMSG); } else this->setTextColor(m_unreadColor); if(m_type == QUERY) this->setIcon(ICO_QUERYNEWMSG); } if((m_type == CHANNEL && needHighlight) || m_type == QUERY) m_parent->getParent()->getParent()->handle(this, FXSEL(SEL_COMMAND, IrcTabItem_NEWMSG), NULL); } } //handle IrcEvent IRC_ACTION void IrcTabItem::onIrcAction(IrcEvent* ev) { if((comparecase(ev->param2, getText()) == 0 && m_type == CHANNEL) || (ev->param1 == getText() && m_type == QUERY && ev->param2 == getNickName())) { if(!isCommandIgnored("me")) { FXbool needHighlight = FALSE; if(ev->param3.contains(getNickName())) needHighlight = highlightNeeded(ev->param3); appendIrcStyledText(ev->param1+" "+ev->param3, 2, ev->time); if(m_highlightColor != this->getTextColor() && m_parent->getCurrent()*2 != m_parent->indexOfChild(this)) { if(needHighlight) { this->setTextColor(m_highlightColor); if(m_type == CHANNEL) this->setIcon(ICO_CHANNELNEWMSG); } else this->setTextColor(m_unreadColor); if(m_type == QUERY) this->setIcon(ICO_QUERYNEWMSG); } if((m_type == CHANNEL && needHighlight) || m_type == QUERY) m_parent->getParent()->getParent()->handle(this, FXSEL(SEL_COMMAND, IrcTabItem_NEWMSG), NULL); } } } //handle IrcEvent IRC_CTCPREPLY void IrcTabItem::onIrcCtpcReply(IrcEvent* ev) { if(isRightForServerMsg()) { if(!isCommandIgnored("ctcp")) { appendIrcStyledText(FXStringFormat(_("CTCP %s reply from %s: %s"), utils::instance().getParam(ev->param2, 1, FALSE).text(), ev->param1.text(), utils::instance().getParam(ev->param2, 2, TRUE).text()), 2, ev->time, FALSE, FALSE); if(m_highlightColor != this->getTextColor() && m_parent->getCurrent()*2 != m_parent->indexOfChild(this)) this->setTextColor(m_unreadColor); } } } //handle IrcEvent IRC_CTCPREQUEST void IrcTabItem::onIrcCtcpRequest(IrcEvent* ev) { if(isRightForServerMsg()) { if(!isCommandIgnored("ctcp")) { appendIrcStyledText(FXStringFormat(_("CTCP %s request from %s"), ev->param2.text(), ev->param1.text()), 2, ev->time, FALSE, FALSE); if(m_highlightColor != this->getTextColor() && m_parent->getCurrent()*2 != m_parent->indexOfChild(this)) this->setTextColor(m_unreadColor); } } } //handle IrcEvent IRC_JOIN void IrcTabItem::onIrcJoin(IrcEvent* ev) { if(comparecase(ev->param2, getText()) == 0 && ev->param1 != getNickName()) { if(!isCommandIgnored("join") && !m_engine->isUserIgnored(ev->param1, getText())) appendIrcStyledText(FXStringFormat(_("%s has joined to %s"), ev->param1.text(), ev->param2.text()), 1, ev->time); addUser(ev->param1, NONE); } } //handle IrcEvent IRC_QUIT void IrcTabItem::onIrcQuit(IrcEvent* ev) { if(m_type == CHANNEL && m_users->findItem(ev->param1) != -1) { removeUser(ev->param1); if(ev->param2.empty()) { if(!isCommandIgnored("quit") && !m_engine->isUserIgnored(ev->param1, getText())) appendIrcStyledText(FXStringFormat(_("%s has quit"), ev->param1.text()), 1, ev->time); } else { if(!isCommandIgnored("quit") && !m_engine->isUserIgnored(ev->param1, getText()))appendIrcStyledText(FXStringFormat(_("%s has quit (%s)"), ev->param1.text(), +ev->param2.text()), 1, ev->time); } } else if(m_type == QUERY && getText() == ev->param1) { appendIrcStyledText(FXStringFormat(_("%s has quit"), ev->param1.text()), 1, ev->time, FALSE, FALSE); } } //handle IrcEvent IRC_PART void IrcTabItem::onIrcPart(IrcEvent* ev) { if(comparecase(ev->param2, getText()) == 0) { if(ev->param3.empty() && !isCommandIgnored("part") && !m_engine->isUserIgnored(ev->param1, getText())) appendIrcStyledText(FXStringFormat(_("%s has parted %s"), ev->param1.text(), ev->param2.text()), 1, ev->time); else if(!isCommandIgnored("part") && !m_engine->isUserIgnored(ev->param1, getText())) appendIrcStyledText(FXStringFormat(_("%s has parted %s (%s)"), ev->param1.text(), ev->param2.text(), ev->param3.text()), 1, ev->time); removeUser(ev->param1); } } //handle IrcEvent IRC_CHNOTICE void IrcTabItem::onIrcChnotice(IrcEvent* ev) { if(!isCommandIgnored("notice")) { FXbool tabExist = FALSE; for(FXint i = 0; i<m_parent->numChildren(); i+=2) { if(m_parent->childAtIndex(i)->getMetaClass()==&IrcTabItem::metaClass && m_engine->findTarget(static_cast<IrcTabItem*>(m_parent->childAtIndex(i)))) { if((comparecase(ev->param2, static_cast<IrcTabItem*>(m_parent->childAtIndex(i))->getText()) == 0 && static_cast<IrcTabItem*>(m_parent->childAtIndex(i))->getType() == CHANNEL) || (ev->param1 == static_cast<IrcTabItem*>(m_parent->childAtIndex(i))->getText() && static_cast<IrcTabItem*>(m_parent->childAtIndex(i))->getType() == QUERY && ev->param2 == static_cast<IrcTabItem*>(m_parent->childAtIndex(i))->getNickName())) { tabExist = TRUE; break; } } } if(tabExist) { if((comparecase(ev->param2, getText()) == 0 && m_type == CHANNEL) || (ev->param1 == getText() && m_type == QUERY && ev->param2 == getNickName())) { FXbool needHighlight = FALSE; if(ev->param3.contains(getNickName())) needHighlight = highlightNeeded(ev->param3); appendIrcStyledText(FXStringFormat(_("%s's NOTICE: %s"), ev->param1.text(), ev->param3.text()), 2, ev->time); if(m_highlightColor != this->getTextColor() && m_parent->getCurrent()*2 != m_parent->indexOfChild(this)) { if(needHighlight) { this->setTextColor(m_highlightColor); if(m_type == CHANNEL) this->setIcon(ICO_CHANNELNEWMSG); } else this->setTextColor(m_unreadColor); if(m_type == QUERY) this->setIcon(ICO_QUERYNEWMSG); } if((m_type == CHANNEL && needHighlight) || m_type == QUERY) m_parent->getParent()->getParent()->handle(this, FXSEL(SEL_COMMAND, IrcTabItem_NEWMSG), NULL); } } else { if(isRightForServerMsg()) { appendIrcStyledText(FXStringFormat(_("%s's NOTICE: %s"), ev->param1.text(), ev->param3.text()), 3, ev->time); } } } } //handle IrcEvent IRC_NOTICE void IrcTabItem::onIrcNotice(IrcEvent* ev) { if(isRightForServerMsg()) { if(ev->param1 == getNickName() && !isCommandIgnored("notice")) { appendIrcStyledText(FXStringFormat(_("NOTICE for you: %s"), ev->param2.text()), 3, ev->time); if(m_highlightColor != this->getTextColor() && m_parent->getCurrent()*2 != m_parent->indexOfChild(this)) this->setTextColor(m_unreadColor); } else if(!isCommandIgnored("notice")) { appendIrcStyledText(FXStringFormat(_("%s's NOTICE: %s"), ev->param1.text(), ev->param2.text()), 3, ev->time); if(m_highlightColor != this->getTextColor() && m_parent->getCurrent()*2 != m_parent->indexOfChild(this)) this->setTextColor(m_unreadColor); } } } //handle IrcEvent IRC_NICK void IrcTabItem::onIrcNick(IrcEvent* ev) { if(m_users->findItem(ev->param1) != -1) { if(ev->param2 == getNickName() && !isCommandIgnored("nick")) appendIrcStyledText(FXStringFormat(_("You're now known as %s"), ev->param2.text()), 1, ev->time); else if(!isCommandIgnored("nick") && !m_engine->isUserIgnored(ev->param1, getText())) appendIrcStyledText(FXStringFormat(_("%s is now known as %s"), ev->param1.text(), ev->param2.text()), 1, ev->time); changeNickUser(ev->param1, ev->param2); } if(m_type == QUERY && ev->param1 == getText()) { this->setText(ev->param2); stopLogging(); } } //handle IrcEvent IRC_TOPIC void IrcTabItem::onIrcTopic(IrcEvent* ev) { if(comparecase(ev->param2, getText()) == 0) { appendIrcText(FXStringFormat(_("%s set new topic for %s: %s"), ev->param1.text(), ev->param2.text(), ev->param3.text()), ev->time); m_topic = stripColors(ev->param3, TRUE); m_topicline->setText(m_topic); m_topicline->setCursorPos(0); m_topicline->makePositionVisible(0); } } //handle IrcEvent IRC_INVITE void IrcTabItem::onIrcInvite(IrcEvent* ev) { if(isRightForServerMsg()) { appendIrcStyledText(FXStringFormat(_("%s invites you to: %s"), ev->param1.text(), ev->param3.text()), 3, ev->time, FALSE, FALSE); if(m_highlightColor != this->getTextColor() && m_parent->getCurrent()*2 != m_parent->indexOfChild(this)) this->setTextColor(m_unreadColor); } } //handle IrcEvent IRC_KICK void IrcTabItem::onIrcKick(IrcEvent* ev) { if(comparecase(ev->param3, getText()) == 0) { if(ev->param2 != getNickName()) { if(ev->param4.empty()) appendIrcStyledText(FXStringFormat(_("%s was kicked from %s by %s"), ev->param2.text(), ev->param3.text(), ev->param1.text()), 1, ev->time, FALSE, FALSE); else appendIrcStyledText(FXStringFormat(_("%s was kicked from %s by %s (%s)"), ev->param2.text(), ev->param3.text(), ev->param1.text(), ev->param4.text()), 1, ev->time, FALSE, FALSE); removeUser(ev->param2); } } if(ev->param2 == getNickName() && isRightForServerMsg()) { if(ev->param4.empty()) appendIrcStyledText(FXStringFormat(_("You were kicked from %s by %s"), ev->param3.text(), ev->param1.text()), 1, ev->time, FALSE, FALSE); else appendIrcStyledText(FXStringFormat(_("You were kicked from %s by %s (%s)"), ev->param3.text(), ev->param1.text(), ev->param4.text()), 1, ev->time, FALSE, FALSE); if(m_highlightColor != this->getTextColor() && m_parent->getCurrent()*2 != m_parent->indexOfChild(this)) this->setTextColor(m_unreadColor); } } //handle IrcEvent IRC_MODE void IrcTabItem::onIrcMode(IrcEvent* ev) { if(isRightForServerMsg()) { appendIrcStyledText(FXStringFormat(_("Mode change [%s] for %s"), ev->param1.text(), ev->param2.text()), 1, ev->time, FALSE, FALSE); if(m_highlightColor != this->getTextColor() && m_parent->getCurrent()*2 != m_parent->indexOfChild(this)) this->setTextColor(m_unreadColor); } } //handle IrcEvent IRC_UMODE void IrcTabItem::onIrcUmode(IrcEvent* ev) { FXString moderator = ev->param1; FXString channel = ev->param2; FXString modes = ev->param3; FXString args = ev->param4; if(comparecase(channel, getText()) == 0) { FXbool sign = FALSE; int argsiter = 1; for(int i =0; i < modes.count(); i++) { switch(modes[i]) { case '+': sign = TRUE; break; case '-': sign = FALSE; break; case 'a': //admin { FXString nick = utils::instance().getParam(args, argsiter, FALSE); setUserMode(nick, sign?ADMIN:NONE); if(sign) { if(!isCommandIgnored("mode") && !m_engine->isUserIgnored(nick, getText())) { if(nick == getNickName()) appendIrcStyledText(FXStringFormat(_("%s gave you admin"), moderator.text()), 1, ev->time, FALSE, FALSE); else appendIrcStyledText(FXStringFormat(_("%s gave %s admin"), moderator.text(), nick.text()), 1, ev->time, FALSE, FALSE); } } else { if(!isCommandIgnored("mode") && !m_engine->isUserIgnored(nick, getText())) { if(nick == getNickName()) appendIrcStyledText(FXStringFormat(_("%s removed you admin"), moderator.text()), 1, ev->time, FALSE, FALSE); else appendIrcStyledText(FXStringFormat(_("%s removed %s admin"), moderator.text(), nick.text()), 1, ev->time, FALSE, FALSE); } } argsiter++; }break; case 'o': //op { FXString nick = utils::instance().getParam(args, argsiter, FALSE); setUserMode(nick, sign?OP:NONE); if(sign) { if(!isCommandIgnored("mode") && !m_engine->isUserIgnored(nick, getText())) { if(nick == getNickName()) appendIrcStyledText(FXStringFormat(_("%s gave you op"), moderator.text()), 1, ev->time, FALSE, FALSE); else appendIrcStyledText(FXStringFormat(_("%s gave %s op"), moderator.text(), nick.text()), 1, ev->time, FALSE, FALSE); } } else { if(!isCommandIgnored("mode") && !m_engine->isUserIgnored(nick, getText())) { if(nick == getNickName()) appendIrcStyledText(FXStringFormat(_("%s removed you op"), moderator.text()), 1, ev->time, FALSE, FALSE); else appendIrcStyledText(FXStringFormat(_("%s removed %s op"), moderator.text(), nick.text()), 1, ev->time, FALSE, FALSE); } } if(getNickName() == nick) sign ? m_iamOp = TRUE : m_iamOp = FALSE; argsiter++; }break; case 'v': //voice { FXString nick = utils::instance().getParam(args, argsiter, FALSE); setUserMode(nick, sign?VOICE:NONE); if(sign) { if(!isCommandIgnored("mode") && !m_engine->isUserIgnored(nick, getText())) { if(nick == getNickName()) appendIrcStyledText(FXStringFormat(_("%s gave you voice"), moderator.text()), 1, ev->time, FALSE, FALSE); else appendIrcStyledText(FXStringFormat(_("%s gave %s voice"), moderator.text(), nick.text()), 1, ev->time, FALSE, FALSE); } } else { if(!isCommandIgnored("mode") && !m_engine->isUserIgnored(nick, getText())) { if(nick == getNickName()) appendIrcStyledText(FXStringFormat(_("%s removed you voice"), moderator.text()), 1, ev->time, FALSE, FALSE); else appendIrcStyledText(FXStringFormat(_("%s removed %s voice"), moderator.text(), nick.text()), 1, ev->time, FALSE, FALSE); } } argsiter++; }break; case 'h': //halfop { FXString nick = utils::instance().getParam(args, argsiter, FALSE); setUserMode(nick, sign?HALFOP:NONE); if(sign) { if(!isCommandIgnored("mode") && !m_engine->isUserIgnored(nick, getText())) { if(nick == getNickName()) appendIrcStyledText(FXStringFormat(_("%s gave you halfop"), moderator.text()), 1, ev->time, FALSE, FALSE); else appendIrcStyledText(FXStringFormat(_("%s gave %s halfop"), moderator.text(), nick.text()), 1, ev->time, FALSE, FALSE); } } else { if(!isCommandIgnored("mode") && !m_engine->isUserIgnored(nick, getText())) { if(nick == getNickName()) appendIrcStyledText(FXStringFormat(_("%s removed you halfop"), moderator.text()), 1, ev->time, FALSE, FALSE); else appendIrcStyledText(FXStringFormat(_("%s removed %s halfop"), moderator.text(), nick.text()), 1, ev->time, FALSE, FALSE); } } argsiter++; }break; case 'b': //ban { FXString banmask = utils::instance().getParam(args, argsiter, FALSE); onBan(banmask, sign, moderator, ev->time); argsiter++; }break; case 't': //topic settable by channel operator { sign ? m_editableTopic = FALSE : m_editableTopic = TRUE; } default: { appendIrcStyledText(FXStringFormat(_("%s set Mode: %s"), moderator.text(), FXString(modes+" "+args).text()), 1, ev->time, FALSE, FALSE); } } } } } //handle IrcEvent IRC_CHMODE void IrcTabItem::onIrcChmode(IrcEvent* ev) { FXString channel = ev->param1; FXString modes = ev->param2; if(comparecase(channel, getText()) == 0) { if(modes.contains('t')) m_editableTopic = FALSE; appendIrcStyledText(FXStringFormat(_("Mode for %s: %s"), channel.text(), modes.text()), 1, ev->time, FALSE, FALSE); } } //handle IrcEvent IRC_SERVERREPLY void IrcTabItem::onIrcServerReply(IrcEvent* ev) { if(m_ownServerWindow) { if(m_type == SERVER) { //this->setText(server->GetRealServerName()); appendIrcText(ev->param1, ev->time); if(getApp()->getForeColor() == this->getTextColor() && m_parent->getCurrent()*2 != m_parent->indexOfChild(this)) this->setTextColor(m_unreadColor); } } else { if(isRightForServerMsg()) { appendIrcText(ev->param1, ev->time, FALSE, FALSE); if(m_highlightColor != this->getTextColor() && m_parent->getCurrent()*2 != m_parent->indexOfChild(this)) this->setTextColor(m_unreadColor); } } } //handle IrcEvent IRC_CONNECT void IrcTabItem::onIrcConnect(IrcEvent* ev) { appendIrcStyledText(ev->param1, 3, ev->time, FALSE, FALSE); } //handle IrcEvent IRC_ERROR void IrcTabItem::onIrcError(IrcEvent* ev) { appendIrcStyledText(ev->param1, 4, ev->time, FALSE, FALSE); } //handle IrcEvent IRC_SERVERERROR void IrcTabItem::onIrcServerError(IrcEvent* ev) { if(isRightForServerMsg()) { appendIrcStyledText(ev->param1, 4, ev->time, FALSE, FALSE); if(m_highlightColor != this->getTextColor() && m_parent->getCurrent()*2 != m_parent->indexOfChild(this)) this->setTextColor(m_unreadColor); } } //handle IrcEvent IRC_DISCONNECT void IrcTabItem::onIrcDisconnect(IrcEvent* ev) { appendIrcStyledText(ev->param1, 4, ev->time, FALSE, FALSE); if(isRightForServerMsg()) { if(m_parent->getCurrent()*2 != m_parent->indexOfChild(this)) this->setTextColor(m_highlightColor); } if(m_type == CHANNEL) { m_users->clearItems(); m_iamOp = FALSE; } } //handle IrcEvent IRC_RECONNECT void IrcTabItem::onIrcReconnect(IrcEvent* ev) { appendIrcStyledText(ev->param1, 4, ev->time, FALSE, FALSE); if(isRightForServerMsg()) { if(m_parent->getCurrent()*2 != m_parent->indexOfChild(this)) this->setTextColor(m_highlightColor); } if(m_type == CHANNEL) { m_users->clearItems(); m_iamOp = FALSE; } } //handle IrcEvent IRC_UNKNOWN void IrcTabItem::onIrcUnknown(IrcEvent* ev) { if(isRightForServerMsg()) { appendIrcStyledText(FXStringFormat(_("Unhandled command '%s' params: %s"), ev->param1.text(), ev->param2.text()), 4, ev->time, FALSE, FALSE); if(m_highlightColor != this->getTextColor() && m_parent->getCurrent()*2 != m_parent->indexOfChild(this)) this->setTextColor(m_unreadColor); } } //handle IrcEvent IRC_301 void IrcTabItem::onIrc301(IrcEvent* ev) { if(m_parent->getCurrent()*2 == m_parent->indexOfChild(this) || getText() == ev->param1) { if(!isCommandIgnored("away") && !m_engine->isUserIgnored(ev->param1, getText())) appendIrcStyledText(FXStringFormat(_("%s is away: %s"),ev->param1.text(), ev->param2.text()), 1, ev->time); } } //handle IrcEvent IRC_305 void IrcTabItem::onIrc305(IrcEvent* ev) { FXint i = m_users->findItem(getNickName()); if(i != -1) { appendIrcStyledText(ev->param1, 1, ev->time, FALSE, FALSE); ((NickListItem*)m_users->getItem(i))->changeAway(FALSE); } } //handle IrcEvent IRC_306 void IrcTabItem::onIrc306(IrcEvent* ev) { FXint i = m_users->findItem(getNickName()); if(i != -1) { appendIrcStyledText(ev->param1, 1, ev->time, FALSE, FALSE); ((NickListItem*)m_users->getItem(i))->changeAway(TRUE); } } //handle IrcEvent IRC_331, IRC_332 and IRC_333 void IrcTabItem::onIrc331332333(IrcEvent* ev) { if(comparecase(ev->param1, getText()) == 0) { appendIrcText(ev->param2, ev->time); if(ev->eventType == IRC_331) { m_topic = stripColors(ev->param2, TRUE); m_topicline->setText(m_topic); m_topicline->setCursorPos(0); m_topicline->makePositionVisible(0); } if(ev->eventType == IRC_332) { m_topic = stripColors(utils::instance().getParam(ev->param2, 2, TRUE, ':').after(' '), TRUE); m_topicline->setText(m_topic); m_topicline->setCursorPos(0); m_topicline->makePositionVisible(0); } } } //handle IrcEvent IRC_353 void IrcTabItem::onIrc353(IrcEvent* ev) { FXString channel = ev->param1; FXString usersStr = ev->param2; FXString myNick = getNickName(); if(usersStr.right(1) != " ") usersStr.append(" "); if(comparecase(channel, getText()) == 0) { while (usersStr.contains(' ')) { FXString nick = usersStr.before(' '); UserMode mode = getUserMode(nick[0]); if(mode != NONE) nick = nick.after(nick[0]); addUser(nick, mode); if(mode == OP && nick == myNick) m_iamOp = TRUE; usersStr = usersStr.after(' '); } } else { FXbool channelOn = FALSE; for(FXint i = 0; i<m_parent->numChildren(); i+=2) { if(m_engine->findTarget(static_cast<IrcTabItem*>(m_parent->childAtIndex(i))) && comparecase(static_cast<FXTabItem*>(m_parent->childAtIndex(i))->getText(), channel) == 0) { channelOn = TRUE; break; } } if(!channelOn && !isCommandIgnored("numeric")) appendIrcText(FXStringFormat(_("Users on %s: %s"), channel.text(), usersStr.text()), ev->time, FALSE, FALSE); } } //handle IrcEvent IRC_366 void IrcTabItem::onIrc366(IrcEvent* ev) { if(comparecase(ev->param1, getText()) == 0) { m_engine->addIgnoreWho(getText()); } } //handle IrcEvent IRC_372 void IrcTabItem::onIrc372(IrcEvent* ev) { if(m_ownServerWindow) { if(m_type == SERVER) { appendIrcText(ev->param1, ev->time); if(getApp()->getForeColor() == this->getTextColor() && m_parent->getCurrent()*2 != m_parent->indexOfChild(this)) this->setTextColor(m_unreadColor); } } else { if(isRightForServerMsg()) { appendIrcText(ev->param1, ev->time, FALSE, FALSE); if(m_highlightColor != this->getTextColor() && m_parent->getCurrent()*2 != m_parent->indexOfChild(this)) this->setTextColor(m_unreadColor); } } } //handle IrcEvent IRC_AWAY void IrcTabItem::onIrcAway(IrcEvent* ev) { if(comparecase(ev->param1, getText()) == 0) { onAway(); } } //handle IrcEvent IRC_ENDMOTD void IrcTabItem::onIrcEndMotd() { m_text->makeLastRowVisible(TRUE); if(m_type == SERVER && !m_engine->getNetworkName().empty()) setText(m_engine->getNetworkName()); } long IrcTabItem::onPipe(FXObject*, FXSelector, void *ptr) { FXString text = *(FXString*)ptr; if(m_sendPipe && (m_type == CHANNEL || m_type == QUERY)) { if(!getApp()->hasTimeout(this, IrcTabItem_PTIME)) getApp()->addTimeout(this, IrcTabItem_PTIME); m_pipeStrings.append(text); } else appendIrcText(text, FXSystem::now()); return 1; } //checking away in channel void IrcTabItem::checkAway() { if(m_type == CHANNEL && m_engine->getConnected() && m_numberUsers < m_maxAway) { m_engine->addIgnoreWho(getText()); } } long IrcTabItem::onPipeTimeout(FXObject*, FXSelector, void*) { if(m_type == CHANNEL || m_type == QUERY) { if(m_pipeStrings.no() > 3) { if(m_pipeStrings[0].empty()) m_pipeStrings[0] = " "; if(m_pipeStrings[0].length() > m_maxLen-10-getText().length()) { dxStringArray messages = cutText(m_pipeStrings[0], m_maxLen-10-getText().length()); for(FXint i=0; i<messages.no(); i++) { if(m_coloredNick) appendIrcNickText(getNickName(), messages[i], getNickColor(getNickName()), FXSystem::now()); else appendIrcNickText(getNickName(), messages[i], 5, FXSystem::now()); m_engine->sendMsg(getText(), messages[i]); } } else { if(m_coloredNick) appendIrcNickText(getNickName(), m_pipeStrings[0], getNickColor(getNickName()), FXSystem::now()); else appendIrcNickText(getNickName(), m_pipeStrings[0], 5, FXSystem::now()); m_engine->sendMsg(getText(), m_pipeStrings[0]); } m_pipeStrings.erase(0); getApp()->addTimeout(this, IrcTabItem_PTIME, 3000); } else { while(m_pipeStrings.no()) { if(m_pipeStrings[0].empty()) m_pipeStrings[0] = " "; if(m_pipeStrings[0].length() > m_maxLen-10-getText().length()) { dxStringArray messages = cutText(m_pipeStrings[0], m_maxLen-10-getText().length()); for(FXint i=0; i<messages.no(); i++) { if(m_coloredNick) appendIrcNickText(getNickName(), messages[i], getNickColor(getNickName()), FXSystem::now()); else appendIrcNickText(getNickName(), messages[i], 5, FXSystem::now()); m_engine->sendMsg(getText(), messages[i]); } } else { if(m_coloredNick) appendIrcNickText(getNickName(), m_pipeStrings[0], getNickColor(getNickName()), FXSystem::now()); else appendIrcNickText(getNickName(), m_pipeStrings[0], 5, FXSystem::now()); m_engine->sendMsg(getText(), m_pipeStrings[0]); } m_pipeStrings.erase(0); } } } return 1; } long IrcTabItem::onEggTimeout(FXObject*, FXSelector, void*) { if(m_pics<24) { getApp()->addTimeout(this, IrcTabItem_ETIME, 222); FXString replace = "\n"; FXint max = rand()%30; for(FXint i=0; i<max; i++) replace.append(' '); FXString pic = "\n ©©©©©©\n © ©\n © ©\n © ©\n©©©©©©©©©©©©©©\n©©©©©©©©©©©©©©\n©©©©©©©©©©©©©©\n © ©\n © ©\n © ©\n ©©©©©©"; pic.substitute("\n", replace); pic.append('\n'); m_text->clearText(); max = rand()%15; for(FXint i=0; i<max; i++) pic.prepend('\n'); max = rand()%7; m_text->appendStyledText(pic, max+10); m_pics++; } return 1; } void IrcTabItem::onAway() { if(m_numberUsers < m_maxAway) { for(FXint i = 0; i < m_users->getNumItems(); i++) { FXbool away = m_engine->getNickInfo(m_users->getItemText(i)).away; ((NickListItem*)m_users->getItem(i))->changeAway(away); } } else { for(FXint i = 0; i < m_users->getNumItems(); i++) { ((NickListItem*)m_users->getItem(i))->changeAway(FALSE); } } } long IrcTabItem::onTextLink(FXObject *, FXSelector, void *data) { utils::instance().launchLink(static_cast<FXchar*>(data)); return 1; } long IrcTabItem::onRightMouse(FXObject *, FXSelector, void *ptr) { //focus(); FXEvent* event = (FXEvent*)ptr; if(event->moved) return 1; FXint index = m_users->getItemAt(event->win_x,event->win_y); if(index >= 0) { NickInfo nick = m_engine->getNickInfo(m_users->getItemText(index)); m_nickOnRight = nick; FXString flagpath = DXIRC_DATADIR PATHSEPSTRING "icons" PATHSEPSTRING "flags"; delete ICO_FLAG; ICO_FLAG = NULL; if(FXStat::exists(flagpath+PATHSEPSTRING+nick.host.rafter('.')+".png")) ICO_FLAG = makeIcon(getApp(), flagpath, nick.host.rafter('.')+".png", TRUE); else ICO_FLAG = makeIcon(getApp(), flagpath, "unknown.png", TRUE); FXMenuPane opmenu(this); new FXMenuCommand(&opmenu, _("Give op"), NULL, this, IrcTabItem_OP); new FXMenuCommand(&opmenu, _("Remove op"), NULL, this, IrcTabItem_DEOP); new FXMenuSeparator(&opmenu); new FXMenuCommand(&opmenu, _("Give voice"), NULL, this, IrcTabItem_VOICE); new FXMenuCommand(&opmenu, _("Remove voice"), NULL, this, IrcTabItem_DEVOICE); new FXMenuSeparator(&opmenu); new FXMenuCommand(&opmenu, _("Kick"), NULL, this, IrcTabItem_KICK); new FXMenuSeparator(&opmenu); new FXMenuCommand(&opmenu, _("Ban"), NULL, this, IrcTabItem_BAN); new FXMenuCommand(&opmenu, _("KickBan"), NULL, this, IrcTabItem_KICKBAN); FXMenuPane popup(this); new FXMenuCommand(&popup, FXStringFormat(_("User: %s@%s"), nick.user.text(), nick.host.text()), ICO_FLAG); new FXMenuCommand(&popup, FXStringFormat(_("Realname: %s"), nick.real.text())); if(nick.nick != getNickName()) { new FXMenuSeparator(&popup); new FXMenuCommand(&popup, _("Query"), NULL, this, IrcTabItem_NEWQUERY); new FXMenuCommand(&popup, _("User information (WHOIS)"), NULL, this, IrcTabItem_WHOIS); new FXMenuCommand(&popup, _("DCC chat"), NULL, this, IrcTabItem_DCCCHAT); new FXMenuCommand(&popup, _("Send file"), NULL, this, IrcTabItem_DCCSEND); new FXMenuCommand(&popup, _("Ignore"), NULL, this, IrcTabItem_IGNORE); if(m_iamOp) new FXMenuCascade(&popup, _("Operator actions"), NULL, &opmenu); } else { new FXMenuSeparator(&popup); if(m_engine->isAway(getNickName())) new FXMenuCommand(&popup, _("Remove Away"), NULL, this, IrcTabItem_DEAWAY); else new FXMenuCommand(&popup, _("Set Away"), NULL, this, IrcTabItem_AWAY); } popup.create(); popup.popup(NULL,event->root_x,event->root_y); getApp()->runModalWhileShown(&popup); } return 1; } long IrcTabItem::onDoubleclick(FXObject*, FXSelector, void*) { FXint index = m_users->getCursorItem(); if(index >= 0) { if(m_users->getItemText(index) == getNickName()) return 1; IrcEvent ev; ev.eventType = IRC_QUERY; ev.param1 = m_users->getItemText(index); ev.param2 = getNickName(); m_parent->getParent()->getParent()->handle(m_engine, FXSEL(SEL_COMMAND, IrcEngine_SERVER), &ev); } return 1; } long IrcTabItem::onNewQuery(FXObject *, FXSelector, void *) { IrcEvent ev; ev.eventType = IRC_QUERY; ev.param1 = m_nickOnRight.nick; ev.param2 = getNickName(); m_parent->getParent()->getParent()->handle(m_engine, FXSEL(SEL_COMMAND, IrcEngine_SERVER), &ev); return 1; } long IrcTabItem::onWhois(FXObject *, FXSelector, void *) { m_engine->sendWhois(m_nickOnRight.nick); return 1; } long IrcTabItem::onDccChat(FXObject*, FXSelector, void*) { IrcEvent ev; ev.eventType = IRC_DCCSERVER; ev.param1 = m_nickOnRight.nick; m_parent->getParent()->getParent()->handle(m_engine, FXSEL(SEL_COMMAND, IrcEngine_SERVER), &ev); return 1; } long IrcTabItem::onDccSend(FXObject*, FXSelector, void*) { DccSendDialog dialog((FXMainWindow*)m_parent->getParent()->getParent(), m_nickOnRight.nick); if(dialog.execute()) { IrcEvent ev; ev.eventType = dialog.getPassive() ? IRC_DCCPOUT: IRC_DCCOUT; ev.param1 = m_nickOnRight.nick; ev.param2 = dialog.getFilename(); m_parent->getParent()->getParent()->handle(m_engine, FXSEL(SEL_COMMAND, IrcEngine_SERVER), &ev); } return 1; } long IrcTabItem::onOp(FXObject *, FXSelector, void *) { m_engine->sendMode(getText()+" +o "+m_nickOnRight.nick); return 1; } long IrcTabItem::onDeop(FXObject *, FXSelector, void *) { m_engine->sendMode(getText()+" -o "+m_nickOnRight.nick); return 1; } long IrcTabItem::onVoice(FXObject *, FXSelector, void *) { m_engine->sendMode(getText()+" +v "+m_nickOnRight.nick); return 1; } long IrcTabItem::onDevoice(FXObject *, FXSelector, void *) { m_engine->sendMode(getText()+" -v "+m_nickOnRight.nick); return 1; } long IrcTabItem::onKick(FXObject *, FXSelector, void *) { FXDialogBox kickDialog(this, _("Kick dialog"), DECOR_TITLE|DECOR_BORDER, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); FXVerticalFrame *contents = new FXVerticalFrame(&kickDialog, LAYOUT_SIDE_LEFT|LAYOUT_FILL_X|LAYOUT_FILL_Y, 0, 0, 0, 0, 10, 10, 10, 10, 0, 0); FXHorizontalFrame *kickframe = new FXHorizontalFrame(contents, LAYOUT_FILL_X|LAYOUT_FILL_Y); new FXLabel(kickframe, _("Kick reason:"), 0, JUSTIFY_LEFT|LAYOUT_FILL_X|LAYOUT_FILL_Y); FXTextField *reasonEdit = new FXTextField(kickframe, 25, NULL, 0, FRAME_SUNKEN|FRAME_THICK|LAYOUT_FILL_COLUMN|LAYOUT_FILL_ROW); FXHorizontalFrame *buttonframe = new FXHorizontalFrame(contents, LAYOUT_FILL_X|LAYOUT_FILL_Y|PACK_UNIFORM_WIDTH); new dxEXButton(buttonframe, _("&Cancel"), NULL, &kickDialog, FXDialogBox::ID_CANCEL, FRAME_RAISED|FRAME_THICK|LAYOUT_RIGHT, 0, 0, 0, 0, 10, 10, 2, 2); new dxEXButton(buttonframe, _("&OK"), NULL, &kickDialog, FXDialogBox::ID_ACCEPT, BUTTON_INITIAL|BUTTON_DEFAULT|FRAME_RAISED|FRAME_THICK|LAYOUT_RIGHT, 0, 0, 0, 0, 10, 10, 2, 2); if(kickDialog.execute(PLACEMENT_CURSOR)) { m_engine->sendKick(getText(), m_nickOnRight.nick, reasonEdit->getText()); } return 1; } long IrcTabItem::onBan(FXObject *, FXSelector, void *) { FXDialogBox banDialog(this, _("Ban dialog"), DECOR_TITLE|DECOR_BORDER, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); FXVerticalFrame *contents = new FXVerticalFrame(&banDialog, LAYOUT_SIDE_LEFT|LAYOUT_FILL_X|LAYOUT_FILL_Y, 0, 0, 0, 0, 10, 10, 10, 10, 0, 0); FXHorizontalFrame *banframe = new FXHorizontalFrame(contents, LAYOUT_FILL_X|LAYOUT_FILL_Y); new FXLabel(banframe, _("Banmask:"), 0, JUSTIFY_LEFT|LAYOUT_FILL_X|LAYOUT_FILL_Y); FXTextField *banEdit = new FXTextField(banframe, 25, NULL, 0, FRAME_SUNKEN|FRAME_THICK|LAYOUT_FILL_COLUMN|LAYOUT_FILL_ROW); banEdit->setText(m_nickOnRight.nick+"!"+m_nickOnRight.user+"@"+m_nickOnRight.host); FXHorizontalFrame *buttonframe = new FXHorizontalFrame(contents, LAYOUT_FILL_X|LAYOUT_FILL_Y|PACK_UNIFORM_WIDTH); new dxEXButton(buttonframe, _("&Cancel"), NULL, &banDialog, FXDialogBox::ID_CANCEL, FRAME_RAISED|FRAME_THICK|LAYOUT_RIGHT, 0, 0, 0, 0, 10, 10, 2, 2); new dxEXButton(buttonframe, _("&OK"), NULL, &banDialog, FXDialogBox::ID_ACCEPT, BUTTON_INITIAL|BUTTON_DEFAULT|FRAME_RAISED|FRAME_THICK|LAYOUT_RIGHT, 0, 0, 0, 0, 10, 10, 2, 2); if(banDialog.execute(PLACEMENT_CURSOR)) { m_engine->sendMode(getText()+" +b "+banEdit->getText()); } return 1; } long IrcTabItem::onKickban(FXObject *, FXSelector, void *) { FXDialogBox banDialog(this, _("Kick/Ban dialog"), DECOR_TITLE|DECOR_BORDER, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); FXVerticalFrame *contents = new FXVerticalFrame(&banDialog, LAYOUT_SIDE_LEFT|LAYOUT_FILL_X|LAYOUT_FILL_Y, 0, 0, 0, 0, 10, 10, 10, 10, 0, 0); FXHorizontalFrame *kickframe = new FXHorizontalFrame(contents, LAYOUT_FILL_X|LAYOUT_FILL_Y); new FXLabel(kickframe, _("Kick reason:"), 0, JUSTIFY_LEFT|LAYOUT_FILL_X|LAYOUT_FILL_Y); FXTextField *reasonEdit = new FXTextField(kickframe, 25, NULL, 0, FRAME_SUNKEN|FRAME_THICK|LAYOUT_FILL_COLUMN|LAYOUT_FILL_ROW); FXHorizontalFrame *banframe = new FXHorizontalFrame(contents, LAYOUT_FILL_X|LAYOUT_FILL_Y); new FXLabel(banframe, _("Banmask:"), 0, JUSTIFY_LEFT|LAYOUT_FILL_X|LAYOUT_FILL_Y); FXTextField *banEdit = new FXTextField(banframe, 25, NULL, 0, FRAME_SUNKEN|FRAME_THICK|LAYOUT_FILL_COLUMN|LAYOUT_FILL_ROW); banEdit->setText(m_nickOnRight.nick+"!"+m_nickOnRight.user+"@"+m_nickOnRight.host); FXHorizontalFrame *buttonframe = new FXHorizontalFrame(contents, LAYOUT_FILL_X|LAYOUT_FILL_Y|PACK_UNIFORM_WIDTH); new dxEXButton(buttonframe, _("&Cancel"), NULL, &banDialog, FXDialogBox::ID_CANCEL, FRAME_RAISED|FRAME_THICK|LAYOUT_RIGHT, 0, 0, 0, 0, 10, 10, 2, 2); new dxEXButton(buttonframe, _("&OK"), NULL, &banDialog, FXDialogBox::ID_ACCEPT, BUTTON_INITIAL|BUTTON_DEFAULT|FRAME_RAISED|FRAME_THICK|LAYOUT_RIGHT, 0, 0, 0, 0, 10, 10, 2, 2); if(banDialog.execute(PLACEMENT_CURSOR)) { m_engine->sendKick(getText(), m_nickOnRight.nick, reasonEdit->getText()); m_engine->sendMode(getText()+" +b "+banEdit->getText()); } return 1; } //handle popup Ignore long IrcTabItem::onIgnore(FXObject*, FXSelector, void*) { FXDialogBox dialog(this, _("Add ignore user"), DECOR_TITLE|DECOR_BORDER, 0,0,0,0, 0,0,0,0, 0,0); FXVerticalFrame *contents = new FXVerticalFrame(&dialog, LAYOUT_SIDE_LEFT|LAYOUT_FILL_X|LAYOUT_FILL_Y, 0,0,0,0, 10,10,10,10, 0,0); FXMatrix *matrix = new FXMatrix(contents,2,MATRIX_BY_COLUMNS|LAYOUT_SIDE_TOP|LAYOUT_FILL_X|LAYOUT_FILL_Y); new FXLabel(matrix, _("Nick:"), NULL, JUSTIFY_LEFT|LAYOUT_FILL_COLUMN|LAYOUT_FILL_ROW); FXTextField *nick = new FXTextField(matrix, 25, NULL, 0, FRAME_THICK|FRAME_SUNKEN|LAYOUT_FILL_COLUMN|LAYOUT_FILL_ROW); nick->setText(m_nickOnRight.nick+"!"+m_nickOnRight.user+"@"+m_nickOnRight.host); new FXLabel(matrix, _("Channel(s):\tChannels need to be comma separated"), NULL,JUSTIFY_LEFT|LAYOUT_FILL_COLUMN|LAYOUT_FILL_ROW); FXTextField *channel = new FXTextField(matrix, 25, NULL, 0, FRAME_THICK|FRAME_SUNKEN|LAYOUT_FILL_COLUMN|LAYOUT_FILL_ROW); channel->setText(getText()); channel->setTipText(_("Channels need to be comma separated")); new FXLabel(matrix, _("Server:"), NULL,JUSTIFY_LEFT|LAYOUT_FILL_COLUMN|LAYOUT_FILL_ROW); FXTextField *server = new FXTextField(matrix, 25, NULL, 0, FRAME_THICK|FRAME_SUNKEN|LAYOUT_FILL_COLUMN|LAYOUT_FILL_ROW); server->setText(getServerName()); FXHorizontalFrame *buttonframe = new FXHorizontalFrame(contents,LAYOUT_FILL_X|LAYOUT_FILL_Y|PACK_UNIFORM_WIDTH); new dxEXButton(buttonframe, _("&Cancel"), NULL, &dialog, FXDialogBox::ID_CANCEL, FRAME_RAISED|FRAME_THICK|LAYOUT_RIGHT, 0,0,0,0, 10,10,2,2); new dxEXButton(buttonframe, _("&OK"), NULL, &dialog, FXDialogBox::ID_ACCEPT, BUTTON_INITIAL|BUTTON_DEFAULT|FRAME_RAISED|FRAME_THICK|LAYOUT_RIGHT, 0,0,0,0, 10,10,2,2); if(dialog.execute(PLACEMENT_CURSOR)) { FXString ignoretext = nick->getText()+" "+channel->getText()+" "+server->getText(); m_parent->getParent()->getParent()->handle(this, FXSEL(SEL_COMMAND, IrcTabItem_ADDIUSER), &ignoretext); } return 1; } //handle IrcTabItem_AWAY long IrcTabItem::onSetAway(FXObject*, FXSelector, void*) { FXDialogBox awayDialog(this, _("Away dialog"), DECOR_TITLE|DECOR_BORDER, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); FXVerticalFrame *contents = new FXVerticalFrame(&awayDialog, LAYOUT_SIDE_LEFT|LAYOUT_FILL_X|LAYOUT_FILL_Y, 0, 0, 0, 0, 10, 10, 10, 10, 0, 0); FXHorizontalFrame *msgframe = new FXHorizontalFrame(contents, LAYOUT_FILL_X|LAYOUT_FILL_Y); new FXLabel(msgframe, _("Message:"), 0, JUSTIFY_LEFT|LAYOUT_FILL_X|LAYOUT_FILL_Y); FXTextField *msgEdit = new FXTextField(msgframe, 25, NULL, 0, FRAME_SUNKEN|FRAME_THICK|LAYOUT_FILL_COLUMN|LAYOUT_FILL_ROW); msgEdit->setText(_("away")); FXHorizontalFrame *buttonframe = new FXHorizontalFrame(contents, LAYOUT_FILL_X|LAYOUT_FILL_Y|PACK_UNIFORM_WIDTH); new dxEXButton(buttonframe, _("&Cancel"), NULL, &awayDialog, FXDialogBox::ID_CANCEL, FRAME_RAISED|FRAME_THICK|LAYOUT_RIGHT, 0, 0, 0, 0, 10, 10, 2, 2); new dxEXButton(buttonframe, _("&OK"), NULL, &awayDialog, FXDialogBox::ID_ACCEPT, BUTTON_INITIAL|BUTTON_DEFAULT|FRAME_RAISED|FRAME_THICK|LAYOUT_RIGHT, 0, 0, 0, 0, 10, 10, 2, 2); if(awayDialog.execute(PLACEMENT_CURSOR)) { m_engine->sendAway(msgEdit->getText().empty() ? _("away"): msgEdit->getText()); } return 1; } //handle IrcTabItem_DEAWAY long IrcTabItem::onRemoveAway(FXObject*, FXSelector, void*) { m_engine->sendAway(""); return 1; } //handle change in spellLang combobox long IrcTabItem::onSpellLang(FXObject*, FXSelector, void*) { m_commandline->setLanguage(m_spellLangs->getItemText(m_spellLangs->getCurrentItem())); m_commandline->setTipText(FXStringFormat(_("Current spellchecking language: %s"),m_spellLangs->getItemText(m_spellLangs->getCurrentItem()).text())); return 1; } long IrcTabItem::onTopic(FXObject*, FXSelector, void*) { if(m_editableTopic || m_iamOp) { if(m_topicline->getText().length() > m_engine->getTopicLen()) { appendIrcStyledText(FXStringFormat(_("Warning: topic is too long. Max. topic length is %d."), m_engine->getTopicLen()), 4, FXSystem::now(), FALSE, FALSE); m_engine->sendTopic(getText(), m_topicline->getText()); return 1; } m_engine->sendTopic(getText(), m_topicline->getText()); } else { m_topicline->setText(m_topic); m_topicline->setCursorPos(0); m_topicline->makePositionVisible(0); } return 1; } long IrcTabItem::onTopicLink(FXObject*, FXSelector, void *data) { utils::instance().launchLink(static_cast<FXchar*>(data)); return 1; } void IrcTabItem::onBan(const FXString &banmask, const FXbool &sign, const FXString &sender, const FXTime &time) { if(sign) { FXString nicks = m_engine->getBannedNick(banmask); FXString myNick = getNickName(); while(nicks.contains(';')) { for(FXint i=m_users->getNumItems()-1; i>-1; i--) { if(nicks.before(';') == m_users->getItemText(i)) { if(m_users->getItemText(i) == myNick) appendIrcStyledText(FXStringFormat(_("You was banned by %s"), sender.text()), 1, time, FALSE, FALSE); else { if(!isCommandIgnored("ban") && !m_engine->isUserIgnored(m_users->getItemText(i), getText())) appendIrcStyledText(FXStringFormat(_("%s was banned by %s"), m_users->getItemText(i).text(), sender.text()), 1, time, FALSE, FALSE); //RemoveUser(users->getItemText(i)); } } } nicks = nicks.after(';'); } } } FXString IrcTabItem::stripColors(const FXString &text, const FXbool stripOther) { FXString newstr; FXbool color = FALSE; FXint numbers = 0; FXint i = 0; while(text[i] != '\0') { if(text[i] == '\017') //reset { color = FALSE; } else if(stripOther && text[i] == '\002') { //remove bold mark } else if(stripOther && text[i] == '\037') { //remove underline mark } else if(text[i] == '\035') { //remove italic mark } else if(text[i] == '\021') { //remove fixed mark } else if(text[i] == '\026') { //remove reverse mark } else if(text[i] == '\003') //color { color = TRUE; } else if(color && isdigit(text[i]) && numbers < 2) { numbers++; } else if(color && text[i] == ',' && numbers < 3) { numbers = 0; } else { numbers = 0; color = FALSE; newstr += text[i]; } i++; } return newstr; } FXString IrcTabItem::getNick(FXint i) { return m_users->getItemText(i); } FXint IrcTabItem::getNickColor(const FXString &nick) { //10 is first colored nick style return 10+nick.hash()%8; } FXColor IrcTabItem::getIrcColor(FXint code) { switch(code){ case 0: return fxcolorfromname("white"); case 1: return fxcolorfromname("black"); case 2: return FXRGB(0,0,128); //blue case 3: return FXRGB(0,128,0); //green case 4: return FXRGB(255,0,0); //lightred case 5: return FXRGB(128,0,64); //brown case 6: return FXRGB(128,0,128); //purple case 7: return FXRGB(255,128,64); //orange case 8: return FXRGB(255,255,0); //yellow case 9: return FXRGB(128,255,0); //lightgreen case 10: return FXRGB(0,128,128); //cyan case 11: return FXRGB(0,255,255); //lightcyan case 12: return FXRGB(0,0,255); //lightblue case 13: return FXRGB(255,0,255); //pink case 14: return FXRGB(128,128,128); //grey case 15: return FXRGB(192,192,192); //lightgrey default: return m_colors.text; } } FXint IrcTabItem::hiliteStyleExist(FXColor foreColor, FXColor backColor, FXuint style) { for(FXint i=0; i<m_textStyleList.no(); i++) { if(m_textStyleList[i].normalForeColor == foreColor && m_textStyleList[i].normalBackColor == backColor && m_textStyleList[i].style == style) return i+1; } return -1; } void IrcTabItem::createHiliteStyle(FXColor foreColor, FXColor backColor, FXuint style) { dxHiliteStyle nstyle = {foreColor,backColor,getApp()->getSelforeColor(),getApp()->getSelbackColor(),style,FALSE}; m_textStyleList.append(nstyle); m_text->setHiliteStyles(m_textStyleList.data()); } dxStringArray IrcTabItem::cutText(FXString text, FXint len) { FXint textLen = text.length(); FXint previous = 0; dxStringArray texts; while(textLen>len) { texts.append(text.mid(previous, len)); previous += len; textLen -= len; } texts.append(text.mid(previous, len)); return texts; } void IrcTabItem::setCommandFocus() { m_commandline->setFocus(); } //for "handle" checking, if script contains "all". Send from dxirc. void IrcTabItem::hasAllCommand(FXbool result) { m_scriptHasAll = result; } //for "handle" checking, if script contains "mymsg". Send from dxirc. void IrcTabItem::hasMyMsg(FXbool result) { m_scriptHasMyMsg = result; } //check need of highlight in msg FXbool IrcTabItem::highlightNeeded(const FXString &msg) { FXint pos = msg.find(getNickName()); if(pos==-1) return FALSE; FXbool before = TRUE; FXbool after = FALSE; if(pos) before = isDelimiter(msg[pos-1]); if(pos+getNickName().length() == msg.length()) after = TRUE; if(pos+getNickName().length() < msg.length()) after = isDelimiter(msg[pos+getNickName().length()]); return before && after; }
rofl0r/dxirc
src/irctabitem.cpp
C++
gpl-2.0
183,742
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <!--NewPage--> <HTML> <HEAD> <TITLE> Uses of Interface com.google.gwt.typedarrays.shared.Int16Array (Google Web Toolkit Javadoc) </TITLE> <LINK REL ="stylesheet" TYPE="text/css" HREF="../../../../../../stylesheet.css" TITLE="Style"> <SCRIPT type="text/javascript"> function windowTitle() { if (location.href.indexOf('is-external=true') == -1) { parent.document.title="Uses of Interface com.google.gwt.typedarrays.shared.Int16Array (Google Web Toolkit Javadoc)"; } } </SCRIPT> <NOSCRIPT> </NOSCRIPT> </HEAD> <BODY BGCOLOR="white" onload="windowTitle();"> <HR> <!-- ========= START OF TOP NAVBAR ======= --> <A NAME="navbar_top"><!-- --></A> <A HREF="#skip-navbar_top" title="Skip navigation links"></A> <TABLE BORDER="0" WIDTH="100%" CELLPADDING="1" CELLSPACING="0" SUMMARY=""> <TR> <TD COLSPAN=2 BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A NAME="navbar_top_firstrow"><!-- --></A> <TABLE BORDER="0" CELLPADDING="0" CELLSPACING="3" SUMMARY=""> <TR ALIGN="center" VALIGN="top"> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../../../overview-summary.html"><FONT CLASS="NavBarFont1"><B>Overview</B></FONT></A>&nbsp;</TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../package-summary.html"><FONT CLASS="NavBarFont1"><B>Package</B></FONT></A>&nbsp;</TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../../../com/google/gwt/typedarrays/shared/Int16Array.html" title="interface in com.google.gwt.typedarrays.shared"><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> GWT 2.6.0</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?com/google/gwt/typedarrays/shared//class-useInt16Array.html" target="_top"><B>FRAMES</B></A> &nbsp; &nbsp;<A HREF="Int16Array.html" target="_top"><B>NO FRAMES</B></A> &nbsp; &nbsp;<SCRIPT type="text/javascript"> <!-- if(window==top) { document.writeln('<A HREF="../../../../../../allclasses-noframe.html"><B>All Classes</B></A>'); } //--> </SCRIPT> <NOSCRIPT> <A HREF="../../../../../../allclasses-noframe.html"><B>All Classes</B></A> </NOSCRIPT> </FONT></TD> </TR> </TABLE> <A NAME="skip-navbar_top"></A> <!-- ========= END OF TOP NAVBAR ========= --> <HR> <CENTER> <H2> <B>Uses of Interface<br>com.google.gwt.typedarrays.shared.Int16Array</B></H2> </CENTER> <TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY=""> <TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor"> <TH ALIGN="left" COLSPAN="2"><FONT SIZE="+2"> Packages that use <A HREF="../../../../../../com/google/gwt/typedarrays/shared/Int16Array.html" title="interface in com.google.gwt.typedarrays.shared">Int16Array</A></FONT></TH> </TR> <TR BGCOLOR="white" CLASS="TableRowColor"> <TD><A HREF="#com.google.gwt.typedarrays.client"><B>com.google.gwt.typedarrays.client</B></A></TD> <TD>&nbsp;&nbsp;</TD> </TR> <TR BGCOLOR="white" CLASS="TableRowColor"> <TD><A HREF="#com.google.gwt.typedarrays.server"><B>com.google.gwt.typedarrays.server</B></A></TD> <TD>&nbsp;&nbsp;</TD> </TR> <TR BGCOLOR="white" CLASS="TableRowColor"> <TD><A HREF="#com.google.gwt.typedarrays.shared"><B>com.google.gwt.typedarrays.shared</B></A></TD> <TD>&nbsp;&nbsp;</TD> </TR> </TABLE> &nbsp; <P> <A NAME="com.google.gwt.typedarrays.client"><!-- --></A> <TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY=""> <TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor"> <TH ALIGN="left" COLSPAN="2"><FONT SIZE="+2"> Uses of <A HREF="../../../../../../com/google/gwt/typedarrays/shared/Int16Array.html" title="interface in com.google.gwt.typedarrays.shared">Int16Array</A> in <A HREF="../../../../../../com/google/gwt/typedarrays/client/package-summary.html">com.google.gwt.typedarrays.client</A></FONT></TH> </TR> </TABLE> &nbsp; <P> <TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY=""> <TR BGCOLOR="#CCCCFF" CLASS="TableSubHeadingColor"> <TH ALIGN="left" COLSPAN="2">Classes in <A HREF="../../../../../../com/google/gwt/typedarrays/client/package-summary.html">com.google.gwt.typedarrays.client</A> that implement <A HREF="../../../../../../com/google/gwt/typedarrays/shared/Int16Array.html" title="interface in com.google.gwt.typedarrays.shared">Int16Array</A></FONT></TH> </TR> <TR BGCOLOR="white" CLASS="TableRowColor"> <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> <CODE>&nbsp;class</CODE></FONT></TD> <TD><CODE><B><A HREF="../../../../../../com/google/gwt/typedarrays/client/Int16ArrayNative.html" title="class in com.google.gwt.typedarrays.client">Int16ArrayNative</A></B></CODE> <BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;JS native implementation of <A HREF="../../../../../../com/google/gwt/typedarrays/shared/Int16Array.html" title="interface in com.google.gwt.typedarrays.shared"><CODE>Int16Array</CODE></A>.</TD> </TR> </TABLE> &nbsp; <P> <TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY=""> <TR BGCOLOR="#CCCCFF" CLASS="TableSubHeadingColor"> <TH ALIGN="left" COLSPAN="2">Methods in <A HREF="../../../../../../com/google/gwt/typedarrays/client/package-summary.html">com.google.gwt.typedarrays.client</A> that return <A HREF="../../../../../../com/google/gwt/typedarrays/shared/Int16Array.html" title="interface in com.google.gwt.typedarrays.shared">Int16Array</A></FONT></TH> </TR> <TR BGCOLOR="white" CLASS="TableRowColor"> <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> <CODE>&nbsp;<A HREF="../../../../../../com/google/gwt/typedarrays/shared/Int16Array.html" title="interface in com.google.gwt.typedarrays.shared">Int16Array</A></CODE></FONT></TD> <TD><CODE><B>NoSupportImpl.</B><B><A HREF="../../../../../../com/google/gwt/typedarrays/client/NoSupportImpl.html#createInt16Array(com.google.gwt.typedarrays.shared.ArrayBuffer, int, int)">createInt16Array</A></B>(<A HREF="../../../../../../com/google/gwt/typedarrays/shared/ArrayBuffer.html" title="interface in com.google.gwt.typedarrays.shared">ArrayBuffer</A>&nbsp;buffer, int&nbsp;byteOffset, int&nbsp;length)</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/google/gwt/typedarrays/shared/Int16Array.html" title="interface in com.google.gwt.typedarrays.shared">Int16Array</A></CODE></FONT></TD> <TD><CODE><B>Int16ArrayNative.</B><B><A HREF="../../../../../../com/google/gwt/typedarrays/client/Int16ArrayNative.html#subarray(int)">subarray</A></B>(int&nbsp;begin)</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/google/gwt/typedarrays/shared/Int16Array.html" title="interface in com.google.gwt.typedarrays.shared">Int16Array</A></CODE></FONT></TD> <TD><CODE><B>Int16ArrayNative.</B><B><A HREF="../../../../../../com/google/gwt/typedarrays/client/Int16ArrayNative.html#subarray(int, int)">subarray</A></B>(int&nbsp;begin, int&nbsp;end)</CODE> <BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</TD> </TR> </TABLE> &nbsp; <P> <TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY=""> <TR BGCOLOR="#CCCCFF" CLASS="TableSubHeadingColor"> <TH ALIGN="left" COLSPAN="2">Methods in <A HREF="../../../../../../com/google/gwt/typedarrays/client/package-summary.html">com.google.gwt.typedarrays.client</A> with parameters of type <A HREF="../../../../../../com/google/gwt/typedarrays/shared/Int16Array.html" title="interface in com.google.gwt.typedarrays.shared">Int16Array</A></FONT></TH> </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>Int16ArrayNative.</B><B><A HREF="../../../../../../com/google/gwt/typedarrays/client/Int16ArrayNative.html#set(com.google.gwt.typedarrays.shared.Int16Array)">set</A></B>(<A HREF="../../../../../../com/google/gwt/typedarrays/shared/Int16Array.html" title="interface in com.google.gwt.typedarrays.shared">Int16Array</A>&nbsp;array)</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>Int16ArrayNative.</B><B><A HREF="../../../../../../com/google/gwt/typedarrays/client/Int16ArrayNative.html#set(com.google.gwt.typedarrays.shared.Int16Array, int)">set</A></B>(<A HREF="../../../../../../com/google/gwt/typedarrays/shared/Int16Array.html" title="interface in com.google.gwt.typedarrays.shared">Int16Array</A>&nbsp;array, int&nbsp;offset)</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>static&nbsp;void</CODE></FONT></TD> <TD><CODE><B>JsUtils.</B><B><A HREF="../../../../../../com/google/gwt/typedarrays/client/JsUtils.html#set(com.google.gwt.typedarrays.shared.Int16Array, com.google.gwt.core.client.JsArrayInteger)">set</A></B>(<A HREF="../../../../../../com/google/gwt/typedarrays/shared/Int16Array.html" title="interface in com.google.gwt.typedarrays.shared">Int16Array</A>&nbsp;dest, <A HREF="../../../../../../com/google/gwt/core/client/JsArrayInteger.html" title="class in com.google.gwt.core.client">JsArrayInteger</A>&nbsp;array)</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>static&nbsp;void</CODE></FONT></TD> <TD><CODE><B>JsUtils.</B><B><A HREF="../../../../../../com/google/gwt/typedarrays/client/JsUtils.html#set(com.google.gwt.typedarrays.shared.Int16Array, com.google.gwt.core.client.JsArrayInteger, int)">set</A></B>(<A HREF="../../../../../../com/google/gwt/typedarrays/shared/Int16Array.html" title="interface in com.google.gwt.typedarrays.shared">Int16Array</A>&nbsp;dest, <A HREF="../../../../../../com/google/gwt/core/client/JsArrayInteger.html" title="class in com.google.gwt.core.client">JsArrayInteger</A>&nbsp;array, int&nbsp;offset)</CODE> <BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</TD> </TR> </TABLE> &nbsp; <P> <A NAME="com.google.gwt.typedarrays.server"><!-- --></A> <TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY=""> <TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor"> <TH ALIGN="left" COLSPAN="2"><FONT SIZE="+2"> Uses of <A HREF="../../../../../../com/google/gwt/typedarrays/shared/Int16Array.html" title="interface in com.google.gwt.typedarrays.shared">Int16Array</A> in <A HREF="../../../../../../com/google/gwt/typedarrays/server/package-summary.html">com.google.gwt.typedarrays.server</A></FONT></TH> </TR> </TABLE> &nbsp; <P> <TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY=""> <TR BGCOLOR="#CCCCFF" CLASS="TableSubHeadingColor"> <TH ALIGN="left" COLSPAN="2">Classes in <A HREF="../../../../../../com/google/gwt/typedarrays/server/package-summary.html">com.google.gwt.typedarrays.server</A> that implement <A HREF="../../../../../../com/google/gwt/typedarrays/shared/Int16Array.html" title="interface in com.google.gwt.typedarrays.shared">Int16Array</A></FONT></TH> </TR> <TR BGCOLOR="white" CLASS="TableRowColor"> <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> <CODE>&nbsp;class</CODE></FONT></TD> <TD><CODE><B><A HREF="../../../../../../com/google/gwt/typedarrays/server/Int16ArrayImpl.html" title="class in com.google.gwt.typedarrays.server">Int16ArrayImpl</A></B></CODE> <BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Pure Java implementation of <A HREF="../../../../../../com/google/gwt/typedarrays/shared/Int16Array.html" title="interface in com.google.gwt.typedarrays.shared"><CODE>Int16Array</CODE></A>.</TD> </TR> </TABLE> &nbsp; <P> <TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY=""> <TR BGCOLOR="#CCCCFF" CLASS="TableSubHeadingColor"> <TH ALIGN="left" COLSPAN="2">Methods in <A HREF="../../../../../../com/google/gwt/typedarrays/server/package-summary.html">com.google.gwt.typedarrays.server</A> that return <A HREF="../../../../../../com/google/gwt/typedarrays/shared/Int16Array.html" title="interface in com.google.gwt.typedarrays.shared">Int16Array</A></FONT></TH> </TR> <TR BGCOLOR="white" CLASS="TableRowColor"> <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> <CODE>&nbsp;<A HREF="../../../../../../com/google/gwt/typedarrays/shared/Int16Array.html" title="interface in com.google.gwt.typedarrays.shared">Int16Array</A></CODE></FONT></TD> <TD><CODE><B>JavaImpl.</B><B><A HREF="../../../../../../com/google/gwt/typedarrays/server/JavaImpl.html#createInt16Array(com.google.gwt.typedarrays.shared.ArrayBuffer, int, int)">createInt16Array</A></B>(<A HREF="../../../../../../com/google/gwt/typedarrays/shared/ArrayBuffer.html" title="interface in com.google.gwt.typedarrays.shared">ArrayBuffer</A>&nbsp;buffer, int&nbsp;byteOffset, int&nbsp;length)</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/google/gwt/typedarrays/shared/Int16Array.html" title="interface in com.google.gwt.typedarrays.shared">Int16Array</A></CODE></FONT></TD> <TD><CODE><B>Int16ArrayImpl.</B><B><A HREF="../../../../../../com/google/gwt/typedarrays/server/Int16ArrayImpl.html#subarray(int)">subarray</A></B>(int&nbsp;begin)</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/google/gwt/typedarrays/shared/Int16Array.html" title="interface in com.google.gwt.typedarrays.shared">Int16Array</A></CODE></FONT></TD> <TD><CODE><B>Int16ArrayImpl.</B><B><A HREF="../../../../../../com/google/gwt/typedarrays/server/Int16ArrayImpl.html#subarray(int, int)">subarray</A></B>(int&nbsp;begin, int&nbsp;end)</CODE> <BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</TD> </TR> </TABLE> &nbsp; <P> <TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY=""> <TR BGCOLOR="#CCCCFF" CLASS="TableSubHeadingColor"> <TH ALIGN="left" COLSPAN="2">Methods in <A HREF="../../../../../../com/google/gwt/typedarrays/server/package-summary.html">com.google.gwt.typedarrays.server</A> with parameters of type <A HREF="../../../../../../com/google/gwt/typedarrays/shared/Int16Array.html" title="interface in com.google.gwt.typedarrays.shared">Int16Array</A></FONT></TH> </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>Int16ArrayImpl.</B><B><A HREF="../../../../../../com/google/gwt/typedarrays/server/Int16ArrayImpl.html#set(com.google.gwt.typedarrays.shared.Int16Array)">set</A></B>(<A HREF="../../../../../../com/google/gwt/typedarrays/shared/Int16Array.html" title="interface in com.google.gwt.typedarrays.shared">Int16Array</A>&nbsp;array)</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>Int16ArrayImpl.</B><B><A HREF="../../../../../../com/google/gwt/typedarrays/server/Int16ArrayImpl.html#set(com.google.gwt.typedarrays.shared.Int16Array, int)">set</A></B>(<A HREF="../../../../../../com/google/gwt/typedarrays/shared/Int16Array.html" title="interface in com.google.gwt.typedarrays.shared">Int16Array</A>&nbsp;array, int&nbsp;offset)</CODE> <BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</TD> </TR> </TABLE> &nbsp; <P> <A NAME="com.google.gwt.typedarrays.shared"><!-- --></A> <TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY=""> <TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor"> <TH ALIGN="left" COLSPAN="2"><FONT SIZE="+2"> Uses of <A HREF="../../../../../../com/google/gwt/typedarrays/shared/Int16Array.html" title="interface in com.google.gwt.typedarrays.shared">Int16Array</A> in <A HREF="../../../../../../com/google/gwt/typedarrays/shared/package-summary.html">com.google.gwt.typedarrays.shared</A></FONT></TH> </TR> </TABLE> &nbsp; <P> <TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY=""> <TR BGCOLOR="#CCCCFF" CLASS="TableSubHeadingColor"> <TH ALIGN="left" COLSPAN="2">Methods in <A HREF="../../../../../../com/google/gwt/typedarrays/shared/package-summary.html">com.google.gwt.typedarrays.shared</A> that return <A HREF="../../../../../../com/google/gwt/typedarrays/shared/Int16Array.html" title="interface in com.google.gwt.typedarrays.shared">Int16Array</A></FONT></TH> </TR> <TR BGCOLOR="white" CLASS="TableRowColor"> <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> <CODE>static&nbsp;<A HREF="../../../../../../com/google/gwt/typedarrays/shared/Int16Array.html" title="interface in com.google.gwt.typedarrays.shared">Int16Array</A></CODE></FONT></TD> <TD><CODE><B>TypedArrays.</B><B><A HREF="../../../../../../com/google/gwt/typedarrays/shared/TypedArrays.html#createInt16Array(com.google.gwt.typedarrays.shared.ArrayBuffer)">createInt16Array</A></B>(<A HREF="../../../../../../com/google/gwt/typedarrays/shared/ArrayBuffer.html" title="interface in com.google.gwt.typedarrays.shared">ArrayBuffer</A>&nbsp;buffer)</CODE> <BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Create a <A HREF="../../../../../../com/google/gwt/typedarrays/shared/Int16Array.html" title="interface in com.google.gwt.typedarrays.shared"><CODE>Int16Array</CODE></A> instance on <code>buffer</code>, starting at starting at the beginning of the buffer and continuing to the end (which must be an integral number of elements).</TD> </TR> <TR BGCOLOR="white" CLASS="TableRowColor"> <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> <CODE>&nbsp;<A HREF="../../../../../../com/google/gwt/typedarrays/shared/Int16Array.html" title="interface in com.google.gwt.typedarrays.shared">Int16Array</A></CODE></FONT></TD> <TD><CODE><B>TypedArrays.Impl.</B><B><A HREF="../../../../../../com/google/gwt/typedarrays/shared/TypedArrays.Impl.html#createInt16Array(com.google.gwt.typedarrays.shared.ArrayBuffer)">createInt16Array</A></B>(<A HREF="../../../../../../com/google/gwt/typedarrays/shared/ArrayBuffer.html" title="interface in com.google.gwt.typedarrays.shared">ArrayBuffer</A>&nbsp;buffer)</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>static&nbsp;<A HREF="../../../../../../com/google/gwt/typedarrays/shared/Int16Array.html" title="interface in com.google.gwt.typedarrays.shared">Int16Array</A></CODE></FONT></TD> <TD><CODE><B>TypedArrays.</B><B><A HREF="../../../../../../com/google/gwt/typedarrays/shared/TypedArrays.html#createInt16Array(com.google.gwt.typedarrays.shared.ArrayBuffer, int)">createInt16Array</A></B>(<A HREF="../../../../../../com/google/gwt/typedarrays/shared/ArrayBuffer.html" title="interface in com.google.gwt.typedarrays.shared">ArrayBuffer</A>&nbsp;buffer, int&nbsp;byteOffset)</CODE> <BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Create a <A HREF="../../../../../../com/google/gwt/typedarrays/shared/Int16Array.html" title="interface in com.google.gwt.typedarrays.shared"><CODE>Int16Array</CODE></A> instance on <code>buffer</code>, starting at <code>byteOffset</code> into the buffer, continuing to the end of the buffer (which must be an integral number of elements).</TD> </TR> <TR BGCOLOR="white" CLASS="TableRowColor"> <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> <CODE>&nbsp;<A HREF="../../../../../../com/google/gwt/typedarrays/shared/Int16Array.html" title="interface in com.google.gwt.typedarrays.shared">Int16Array</A></CODE></FONT></TD> <TD><CODE><B>TypedArrays.Impl.</B><B><A HREF="../../../../../../com/google/gwt/typedarrays/shared/TypedArrays.Impl.html#createInt16Array(com.google.gwt.typedarrays.shared.ArrayBuffer, int)">createInt16Array</A></B>(<A HREF="../../../../../../com/google/gwt/typedarrays/shared/ArrayBuffer.html" title="interface in com.google.gwt.typedarrays.shared">ArrayBuffer</A>&nbsp;buffer, int&nbsp;byteOffset)</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>static&nbsp;<A HREF="../../../../../../com/google/gwt/typedarrays/shared/Int16Array.html" title="interface in com.google.gwt.typedarrays.shared">Int16Array</A></CODE></FONT></TD> <TD><CODE><B>TypedArrays.</B><B><A HREF="../../../../../../com/google/gwt/typedarrays/shared/TypedArrays.html#createInt16Array(com.google.gwt.typedarrays.shared.ArrayBuffer, int, int)">createInt16Array</A></B>(<A HREF="../../../../../../com/google/gwt/typedarrays/shared/ArrayBuffer.html" title="interface in com.google.gwt.typedarrays.shared">ArrayBuffer</A>&nbsp;buffer, int&nbsp;byteOffset, int&nbsp;length)</CODE> <BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Create a <A HREF="../../../../../../com/google/gwt/typedarrays/shared/Int16Array.html" title="interface in com.google.gwt.typedarrays.shared"><CODE>Int16Array</CODE></A> instance on <code>buffer</code>, starting at <code>byteOffset</code> into the buffer, continuing for <code>length</code> elements.</TD> </TR> <TR BGCOLOR="white" CLASS="TableRowColor"> <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> <CODE>abstract &nbsp;<A HREF="../../../../../../com/google/gwt/typedarrays/shared/Int16Array.html" title="interface in com.google.gwt.typedarrays.shared">Int16Array</A></CODE></FONT></TD> <TD><CODE><B>TypedArrays.Impl.</B><B><A HREF="../../../../../../com/google/gwt/typedarrays/shared/TypedArrays.Impl.html#createInt16Array(com.google.gwt.typedarrays.shared.ArrayBuffer, int, int)">createInt16Array</A></B>(<A HREF="../../../../../../com/google/gwt/typedarrays/shared/ArrayBuffer.html" title="interface in com.google.gwt.typedarrays.shared">ArrayBuffer</A>&nbsp;buffer, int&nbsp;byteOffset, int&nbsp;length)</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>static&nbsp;<A HREF="../../../../../../com/google/gwt/typedarrays/shared/Int16Array.html" title="interface in com.google.gwt.typedarrays.shared">Int16Array</A></CODE></FONT></TD> <TD><CODE><B>TypedArrays.</B><B><A HREF="../../../../../../com/google/gwt/typedarrays/shared/TypedArrays.html#createInt16Array(int)">createInt16Array</A></B>(int&nbsp;length)</CODE> <BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Create a <A HREF="../../../../../../com/google/gwt/typedarrays/shared/Int16Array.html" title="interface in com.google.gwt.typedarrays.shared"><CODE>Int16Array</CODE></A> instance of <code>length</code> elements, backed by a new <A HREF="../../../../../../com/google/gwt/typedarrays/shared/ArrayBuffer.html" title="interface in com.google.gwt.typedarrays.shared"><CODE>ArrayBuffer</CODE></A>.</TD> </TR> <TR BGCOLOR="white" CLASS="TableRowColor"> <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> <CODE>&nbsp;<A HREF="../../../../../../com/google/gwt/typedarrays/shared/Int16Array.html" title="interface in com.google.gwt.typedarrays.shared">Int16Array</A></CODE></FONT></TD> <TD><CODE><B>TypedArrays.Impl.</B><B><A HREF="../../../../../../com/google/gwt/typedarrays/shared/TypedArrays.Impl.html#createInt16Array(int)">createInt16Array</A></B>(int&nbsp;length)</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/google/gwt/typedarrays/shared/Int16Array.html" title="interface in com.google.gwt.typedarrays.shared">Int16Array</A></CODE></FONT></TD> <TD><CODE><B>TypedArrays.Impl.</B><B><A HREF="../../../../../../com/google/gwt/typedarrays/shared/TypedArrays.Impl.html#createInt16Array(short[])">createInt16Array</A></B>(short[]&nbsp;array)</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/google/gwt/typedarrays/shared/Int16Array.html" title="interface in com.google.gwt.typedarrays.shared">Int16Array</A></CODE></FONT></TD> <TD><CODE><B>Int16Array.</B><B><A HREF="../../../../../../com/google/gwt/typedarrays/shared/Int16Array.html#subarray(int)">subarray</A></B>(int&nbsp;begin)</CODE> <BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Create a new view from the same array, from <code>offset</code> to the end of this view.</TD> </TR> <TR BGCOLOR="white" CLASS="TableRowColor"> <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> <CODE>&nbsp;<A HREF="../../../../../../com/google/gwt/typedarrays/shared/Int16Array.html" title="interface in com.google.gwt.typedarrays.shared">Int16Array</A></CODE></FONT></TD> <TD><CODE><B>Int16Array.</B><B><A HREF="../../../../../../com/google/gwt/typedarrays/shared/Int16Array.html#subarray(int, int)">subarray</A></B>(int&nbsp;begin, int&nbsp;end)</CODE> <BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Create a new view from the same array, from <code>offset</code> to (but not including) <code>end</code> in this view.</TD> </TR> </TABLE> &nbsp; <P> <TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY=""> <TR BGCOLOR="#CCCCFF" CLASS="TableSubHeadingColor"> <TH ALIGN="left" COLSPAN="2">Methods in <A HREF="../../../../../../com/google/gwt/typedarrays/shared/package-summary.html">com.google.gwt.typedarrays.shared</A> with parameters of type <A HREF="../../../../../../com/google/gwt/typedarrays/shared/Int16Array.html" title="interface in com.google.gwt.typedarrays.shared">Int16Array</A></FONT></TH> </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>Int16Array.</B><B><A HREF="../../../../../../com/google/gwt/typedarrays/shared/Int16Array.html#set(com.google.gwt.typedarrays.shared.Int16Array)">set</A></B>(<A HREF="../../../../../../com/google/gwt/typedarrays/shared/Int16Array.html" title="interface in com.google.gwt.typedarrays.shared">Int16Array</A>&nbsp;array)</CODE> <BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Set multiple elements in this view from another view, storing starting at 0.</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>Int16Array.</B><B><A HREF="../../../../../../com/google/gwt/typedarrays/shared/Int16Array.html#set(com.google.gwt.typedarrays.shared.Int16Array, int)">set</A></B>(<A HREF="../../../../../../com/google/gwt/typedarrays/shared/Int16Array.html" title="interface in com.google.gwt.typedarrays.shared">Int16Array</A>&nbsp;array, int&nbsp;offset)</CODE> <BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Set multiple elements in this view from another view, storing starting at the requested offset.</TD> </TR> </TABLE> &nbsp; <P> <HR> <!-- ======= START OF BOTTOM NAVBAR ====== --> <A NAME="navbar_bottom"><!-- --></A> <A HREF="#skip-navbar_bottom" title="Skip navigation links"></A> <TABLE BORDER="0" WIDTH="100%" CELLPADDING="1" CELLSPACING="0" SUMMARY=""> <TR> <TD COLSPAN=2 BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A NAME="navbar_bottom_firstrow"><!-- --></A> <TABLE BORDER="0" CELLPADDING="0" CELLSPACING="3" SUMMARY=""> <TR ALIGN="center" VALIGN="top"> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../../../overview-summary.html"><FONT CLASS="NavBarFont1"><B>Overview</B></FONT></A>&nbsp;</TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../package-summary.html"><FONT CLASS="NavBarFont1"><B>Package</B></FONT></A>&nbsp;</TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../../../com/google/gwt/typedarrays/shared/Int16Array.html" title="interface in com.google.gwt.typedarrays.shared"><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> GWT 2.6.0</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?com/google/gwt/typedarrays/shared//class-useInt16Array.html" target="_top"><B>FRAMES</B></A> &nbsp; &nbsp;<A HREF="Int16Array.html" target="_top"><B>NO FRAMES</B></A> &nbsp; &nbsp;<SCRIPT type="text/javascript"> <!-- if(window==top) { document.writeln('<A HREF="../../../../../../allclasses-noframe.html"><B>All Classes</B></A>'); } //--> </SCRIPT> <NOSCRIPT> <A HREF="../../../../../../allclasses-noframe.html"><B>All Classes</B></A> </NOSCRIPT> </FONT></TD> </TR> </TABLE> <A NAME="skip-navbar_bottom"></A> <!-- ======== END OF BOTTOM NAVBAR ======= --> <HR> </BODY> </HTML>
JakaCikac/dScrum
web/WEB-INF/classes/gwt-2.6.0/doc/javadoc/com/google/gwt/typedarrays/shared/class-use/Int16Array.html
HTML
gpl-2.0
31,584
<html> <head> <title>Pueblo Minecraft</title> <script type="text/javascript" src="js/jquery.min.js"></script> <script type="text/javascript" src="js/jquery.cycle.all.js"></script> <link rel="stylesheet" type="text/css" href="css/style.css" /> <link rel="stylesheet" type="text/css" href="css/inicio.css" /> </head> <body> <header> <div id="sitename"> <h1>Galegolas</h1> </div> <div id="subname"> <h2>El pueblo de los elfos y los gallegos</h2> </div> </header> <div class="clearfix"></div> <nav class="menu"> <ul> <li><a href="index.html">Inicio</a></li> <li><a>Lugares de interes</a> <ul> <li><a href="faro.html">Faro</a></li> <li><a href="puerto.html">Puerto</a></li> <li><a href="muralla.html">Muralla</a></li> </ul> </li> <li><a href="historia.html">Historia</a></li> <li><a href="ayuntamiento.html">Ayuntamiento</a></li> <li><a href="contacto.html">Contacto</a></li> </ul> </nav> <div class="clearfix"></div> <div class="slideshow"> <img src="img/slide/img1.jpg" width="960" height="260"> <img src="img/slide/img2.jpg" width="960" height="260"> <img src="img/slide/img3.jpg" width="960" height="260"> <img src="img/slide/img4.jpg" width="960" height="260"> <img src="img/slide/img5.jpg" width="960" height="260"> </div> <div class="clearfix"></div> <div class="middle-wrapper"> <aside> <div class="sidebar-column"> <h3>Titulo 1</h3> <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse in metus quis neque congue malesuada nec eu dui. Nullam tincidunt euismod tincidunt. Aliquam venenatis enim in ligula tempus, non vehicula diam imperdiet. Morbi velit orci, adipiscing non elementum vitae, congue vitae elit.</p> </div> <div class="sidebar-column"> <h3>Titulo 2</h3> <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse in metus quis neque congue malesuada nec eu dui. Nullam tincidunt euismod tincidunt. Aliquam venenatis enim in ligula tempus, non vehicula diam imperdiet. Morbi velit orci, adipiscing non elementum vitae, congue vitae elit.</p> </div> </aside> <content> <article> <p>En el a&ntilde;o 857d.c. Royal-Town se estableci&oacute; como comunidad de la ciudad estado de York como puerto para la llegada de especias desde extremo oriente. en el a&ntilde;o 927 Royal-Town se consolido como ciudad estado independiente y Toc el grande se autoproclamo rey de Royal-Town en los a&ntilde;os siguientes Royal-Town creci&oacute; a econ&oacute;micamente a gran velocidad llegando a convertirse en la principal entrada de especias de toda la isla de Breta&ntilde;a.</p> <p>En el a&ntilde;o 1129 tras una gran tensi&oacute;n entre Royal-Town y York, York ataco Royal-Town diezmando a la poblaci&oacute;n haciendo caer a la ciudad en el olvido.</p> <p>En el a&ntilde;o 1998 un equipo arqueol&oacute;gico descubri&oacute; la ciudad y se a convertido en atracci&oacute;n tur&iacute;stica y patrimonio de la humanidad por la UNESCO.</p> </article> </content> </div> <div class="clearfix"></div> <footer> <div id="contacto"> <p>Telefono: 666 666 666</p> <p>Email: sdfasdf@fasdlfnsad.com</p> </div> <div id="copyright"> <p>&copy; Copyleft 2013</p> </div> </footer> <script> // Hay que recordar la importancia de comenzar // a ejecutar javascript cuando termine de cargar // la página para evitar inconscistencias. $(document).ready(function() { var menu = $('nav'); var contenedor = $('menu'); var menu_offset = menu.offset(); // Cada vez que se haga scroll en la página // haremos un chequeo del estado del menú // y lo vamos a alternar entre 'fixed' y 'static'. $(window).on('scroll', function() { if($(window).scrollTop() > menu_offset.top) { menu.addClass('menu-fijo'); } else { menu.removeClass('menu-fijo'); } }); }); </script> <script type="text/javascript" > $(document).ready(function() { $('.slideshow').cycle({ fx: 'fade', timeout: '2000' }); }); </script> </html>
carroca/clase
diseno/Pueblo/historia.html
HTML
gpl-2.0
4,332
<?php # i think this class should go somewhere in a common PEAR-place, # because a lot of classes use options, at least PEAR::DB does # but since it is not very fancy to crowd the PEAR-namespace too much i dont know where to put it yet :-( // // +----------------------------------------------------------------------+ // | PHP Version 4 | // +----------------------------------------------------------------------+ // | Copyright (c) 1997-2003 The PHP Group | // +----------------------------------------------------------------------+ // | This source file is subject to version 2.02 of the PHP license, | // | that is bundled with this package in the file LICENSE, and is | // | available at through the world-wide-web at | // | http://www.php.net/license/2_02.txt. | // | If you did not receive a copy of the PHP license and are unable to | // | obtain it through the world-wide-web, please send a note to | // | license@php.net so we can mail you a copy immediately. | // +----------------------------------------------------------------------+ // | Authors: Wolfram Kriesing <wolfram@kriesing.de> | // +----------------------------------------------------------------------+ // // $Id: Options.php,v 1.4 2003/01/04 11:56:27 mj Exp $ require_once('PEAR.php'); /** * this class only defines commonly used methods, etc. * it is worthless without being extended * * @package Tree * @access public * @author Wolfram Kriesing <wolfram@kriesing.de> * */ class Tree_Options extends PEAR { /** * @var array $options you need to overwrite this array and give the keys, that are allowed */ var $options = array(); var $_forceSetOption = false; /** * this constructor sets the options, since i normally need this and * in case the constructor doesnt need to do anymore i already have it done :-) * * @version 02/01/08 * @access public * @author Wolfram Kriesing <wolfram@kriesing.de> * @param array the key-value pairs of the options that shall be set * @param boolean if set to true options are also set * even if no key(s) was/were found in the options property */ function Tree_Options( $options=array() , $force=false ) { $this->_forceSetOption = $force; if( is_array($options) && sizeof($options) ) foreach( $options as $key=>$value ) $this->setOption( $key , $value ); } /** * * @access public * @author Stig S. Baaken * @param * @param * @param boolean if set to true options are also set * even if no key(s) was/were found in the options property */ function setOption( $option , $value , $force=false ) { if( is_array($value) ) // if the value is an array extract the keys and apply only each value that is set { // so we dont override existing options inside an array, if an option is an array foreach( $value as $key=>$aValue ) $this->setOption( array($option , $key) , $aValue ); return true; } if( is_array($option) ) { $mainOption = $option[0]; $options = "['".implode("']['",$option)."']"; $evalCode = "\$this->options".$options." = \$value;"; } else { $evalCode = "\$this->options[\$option] = \$value;"; $mainOption = $option; } if( $this->_forceSetOption==true || $force==true || isset($this->options[$mainOption]) ) { eval($evalCode); return true; } return false; } /** * set a number of options which are simply given in an array * * @access public * @author * @param * @param boolean if set to true options are also set * even if no key(s) was/were found in the options property */ function setOptions( $options , $force=false ) { if( is_array($options) && sizeof($options) ) { foreach( $options as $key=>$value ) { $this->setOption( $key , $value , $force ); } } } /** * * @access public * @author copied from PEAR: DB/commmon.php * @param boolean true on success */ function getOption($option) { if( func_num_args() > 1 && is_array($this->options[$option])) { $args = func_get_args(); $evalCode = "\$ret = \$this->options['".implode( "']['" , $args )."'];"; eval( $evalCode ); return $ret; } if (isset($this->options[$option])) { return $this->options[$option]; } # return $this->raiseError("unknown option $option"); return false; } /** * returns all the options * * @version 02/05/20 * @access public * @author Wolfram Kriesing <wolfram@kriesing.de> * @return string all options as an array */ function getOptions() { return $this->options; } } // end of class ?>
Esleelkartea/kz-adeada-talleres-electricos-
kzadeadatallereselectricos_v1.0.0_linux32_installer/linux/lampp/lib/php/Tree/Options.php
PHP
gpl-2.0
5,542
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Using Glossary &mdash; mooclms 2.6.1 documentation</title> <link rel="stylesheet" href="_static/default.css" type="text/css" /> <link rel="stylesheet" href="_static/pygments.css" type="text/css" /> <script type="text/javascript"> var DOCUMENTATION_OPTIONS = { URL_ROOT: './', VERSION: '2.6.1', COLLAPSE_INDEX: false, FILE_SUFFIX: '.html', HAS_SOURCE: true }; </script> <script type="text/javascript" src="_static/jquery.js"></script> <script type="text/javascript" src="_static/underscore.js"></script> <script type="text/javascript" src="_static/doctools.js"></script> <link rel="top" title="mooclms 2.6.1 documentation" href="index.html" /> </head> <body> <div class="related"> <h3>Navigation</h3> <ul> <li class="right" style="margin-right: 10px"> <a href="genindex.html" title="General Index" accesskey="I">index</a></li> <li><a href="index.html">mooclms 2.6.1 documentation</a> &raquo;</li> </ul> </div> <div class="document"> <div class="documentwrapper"> <div class="bodywrapper"> <div class="body"> <div class="section" id="using-glossary"> <span id="id1"></span><h1>Using Glossary<a class="headerlink" href="#using-glossary" title="Permalink to this headline">¶</a></h1> <div class="section" id="adding-a-glossary-entry"> <h2>Adding a glossary entry<a class="headerlink" href="#adding-a-glossary-entry" title="Permalink to this headline">¶</a></h2> <blockquote> <div><ul class="simple"> <li>When you first create a glossary, click &#8220;Save and display&#8221; to be taken to the &#8220;Add a new entry&#8221; screen.</li> <li>Alternatively,click on the glossary link and click the &#8220;Add a new entry&#8221; button in the centre of the screen or the Administration block.</li> </ul> <blockquote> <div><img alt="_images/glossary_6.png" src="_images/glossary_6.png" /> </div></blockquote> <ul class="simple"> <li>Enter the word you want to define in the Concept text field.</li> <li>Add the definition of the word or concept.</li> <li>If you want to add an attachment, such as a picture or an article, you can either drag/drop it or click the &#8220;Add&#8221; button to upload via the <a class="reference internal" href="file_picker.html#file-picker"><em>File picker</em></a></li> </ul> <blockquote> <div><img alt="_images/glossary_7.png" src="_images/glossary_7.png" /> </div></blockquote> <ul class="simple"> <li>You can add or edit categories by clicking the &#8220;Browse by category&#8221; tab</li> </ul> <blockquote> <div><img alt="_images/glossary_8.png" src="_images/glossary_8.png" /> </div></blockquote> <ul class="simple"> <li>If there are synonyms you want to include with the entry, add them to the Keyword(s) text area. Enter one word per line.</li> <li>Select the auto-linking options (see below) and save the changes.</li> </ul> </div></blockquote> <p><strong>This entry should be automatically linked</strong></p> <p>If site-wide glossary auto-linking has been enabled by an administrator and this is set to &#8220;yes&#8221;, the entry will be automatically linked wherever it appears.</p> <p><strong>This entry is case sensitive</strong></p> <p>This setting specifies whether matching exact upper and lower case is necessary when performing automatic linking to these entries. For example, if this is turned on, then a word like &#8220;html&#8221; in a forum posting will NOT be linked to a glossary entry called &#8220;HTML&#8221;.</p> <p><strong>Match whole words only</strong></p> <p>If automatic linking is enabled, then turning this setting on will force only whole words to be linked. For example, a glossary entry named &#8220;construct&#8221; will not create a link inside the word &#8220;constructivism&#8221;.</p> </div> <div class="section" id="editing-glossary-entries-adding-categories"> <h2>Editing glossary entries / Adding categories<a class="headerlink" href="#editing-glossary-entries-adding-categories" title="Permalink to this headline">¶</a></h2> <p>Categories may be created to help organize your glossary entries. If you&#8217;ve enabled autolinking, the category names can be linked along with individual entries.</p> <p>To create a glossary category:</p> <blockquote> <div><ul class="simple"> <li>Click the &#8220;Browse by category&#8221; tab in the main page of the glossary.</li> <li>Click the &#8220;Edit categories&#8221; button on the left side of the page.</li> <li>Click the &#8220;Add category&#8221; button on the resulting Categories page.</li> <li>Give the category a name.</li> <li>Choose whether you want the category name autolinked as well.</li> <li>Click the &#8220;Save changes&#8221; button.</li> </ul> </div></blockquote> <p>If you autolink the category name, any occurrence of those words will be linked. When a student clicks on the link, they will be taken to the &#8220;Browse by category&#8221; page of the glossary.</p> </div> <div class="section" id="browse-options"> <h2>Browse options<a class="headerlink" href="#browse-options" title="Permalink to this headline">¶</a></h2> <p>You can browse glossaries according to the following options:</p> <blockquote> <div><ul class="simple"> <li>Browse by alphabet</li> <li>Browse by category (if there are any categories added)</li> <li>Browse by date (you can sort entries by last update or by creation date)</li> <li>Browse by author</li> </ul> </div></blockquote> </div> <div class="section" id="search-options"> <h2>Search options<a class="headerlink" href="#search-options" title="Permalink to this headline">¶</a></h2> <p>You can also search for a given word using the Search field. Checking the &#8216;Search full text&#8217; option (on the right side of the Search box) allows searching for a given word in any position in the text. This can take longer and return more entries than you might wish, but it is thorough. If you do not check the &#8220;Search full text&#8221; box, the search only looks for the term names. The index below lets you browse the glossary according to a given letter.</p> </div> <div class="section" id="waiting-approval"> <h2>Waiting approval<a class="headerlink" href="#waiting-approval" title="Permalink to this headline">¶</a></h2> <img alt="_images/glossary_9.png" src="_images/glossary_9.png" /> <p>If entries require teacher approval before being publicly posted, the number of entries will appear in a link.</p> <p>To approve the teacher clicks the link and then the &#8216;approve&#8217; tick/checkmark icon.</p> <p>If an entry is approved by mistake, it can be undone by clicking the &#8216;undo approval&#8217; circle with a line through it icon.</p> </div> <div class="section" id="printing-a-glossary"> <h2>Printing a glossary<a class="headerlink" href="#printing-a-glossary" title="Permalink to this headline">¶</a></h2> <p>At the top right of the main glossary page, you&#8217;ll see a little printer icon. If you click the icon, Moodle will open a new browser window and present all the words and definitions in a printer-friendly format.</p> <p>To print the glossary:</p> <blockquote> <div><ol class="arabic simple"> <li>Click the printer icon at the top of the main glossary page.</li> <li>From the newly opened window, choose Print from the File menu of your browser.</li> <li>Once the word list has printed, close the printer-friendly format window.</li> </ol> </div></blockquote> <p><strong>Note:</strong> Teachers are always provided with a printer-friendly format link. To enable students to print a glossary, set &#8220;Allow print view&#8221; to Yes on the edit glossary page.</p> </div> <div class="section" id="glossary-comments"> <h2>Glossary comments<a class="headerlink" href="#glossary-comments" title="Permalink to this headline">¶</a></h2> <img alt="_images/glossary_10.png" src="_images/glossary_10.png" /> <p>If you enabled comments on the glossary entries, users can annotate the definitions in the word list. When you look at a word in the glossary list, you&#8217;ll see a blue &#8220;Comments&#8221; link in the lower left-hand corner.</p> <p>When you click the link, a comments box opens up. Add your comment then click the &#8220;Save changes&#8221; button.</p> <p>Once you&#8217;ve saved your comment, Moodle will display all of the comments for the entry. When you return to the main glossary page, you&#8217;ll see a new message next to the speech balloon telling you how many comments there are for the entry.</p> </div> <div class="section" id="exporting-glossary-entries-to-another-glossary"> <h2>Exporting glossary entries to another glossary<a class="headerlink" href="#exporting-glossary-entries-to-another-glossary" title="Permalink to this headline">¶</a></h2> <p>Glossary entries can be exported and then imported into another glossary.</p> <blockquote> <div><ol class="arabic simple"> <li>In <em>Administration &gt; Glossary administration &gt; Export entries</em> click the &#8220;Export entries to file&#8221; button.</li> <li>Save the automatically generated XML file on your computer.</li> </ol> </div></blockquote> <p>When the entries are imported into another glossary, the user performing the import will be listed as author of all the entries.</p> <p>A copy of a glossary may also be made by backing up the activity. To include glossary entries in the backup, &#8216;Include enrolled users&#8217; must be ticked in the initial backup settings. When the glossary is restored, the authors of the entries will be the same as in the original glossary.</p> </div> <div class="section" id="exporting-glossary-entries-to-a-portfolio"> <h2>Exporting glossary entries to a portfolio<a class="headerlink" href="#exporting-glossary-entries-to-a-portfolio" title="Permalink to this headline">¶</a></h2> <p>Users with permissions to export glossary entries to a portfolio such as Mahara or Google Docs can do this via the export icon at the bottom of each glossary entry.</p> </div> <div class="section" id="importing-glossary-entries"> <h2>Importing glossary entries<a class="headerlink" href="#importing-glossary-entries" title="Permalink to this headline">¶</a></h2> <p>Glossary entries can be imported via XML file in <em>Administration &gt; Glossary administration &gt; Import entries</em>. See <a class="reference internal" href="import_glossary_entries.html#import-glossary-entries"><em>Import glossary entries</em></a> for details.</p> </div> <div class="section" id="turning-off-links-to-glossary-terms"> <h2>Turning off links to glossary terms<a class="headerlink" href="#turning-off-links-to-glossary-terms" title="Permalink to this headline">¶</a></h2> <p>In places such as forum posts and quizzes, terms will be automatically highlighted and linked if they are in the glossary. Sometimes, this may be unwanted. To avoid this on a case-by-case basis, click on the blue Filters link in the activity&#8217;s Settings block. There you will be able to turn off the glossary auto-linking feature for that particular activity while keeping it enabled elsewhere on the course.</p> </div> </div> </div> </div> </div> <div class="sphinxsidebar"> <div class="sphinxsidebarwrapper"> <h3><a href="index.html">Table Of Contents</a></h3> <ul> <li><a class="reference internal" href="#">Using Glossary</a><ul> <li><a class="reference internal" href="#adding-a-glossary-entry">Adding a glossary entry</a></li> <li><a class="reference internal" href="#editing-glossary-entries-adding-categories">Editing glossary entries / Adding categories</a></li> <li><a class="reference internal" href="#browse-options">Browse options</a></li> <li><a class="reference internal" href="#search-options">Search options</a></li> <li><a class="reference internal" href="#waiting-approval">Waiting approval</a></li> <li><a class="reference internal" href="#printing-a-glossary">Printing a glossary</a></li> <li><a class="reference internal" href="#glossary-comments">Glossary comments</a></li> <li><a class="reference internal" href="#exporting-glossary-entries-to-another-glossary">Exporting glossary entries to another glossary</a></li> <li><a class="reference internal" href="#exporting-glossary-entries-to-a-portfolio">Exporting glossary entries to a portfolio</a></li> <li><a class="reference internal" href="#importing-glossary-entries">Importing glossary entries</a></li> <li><a class="reference internal" href="#turning-off-links-to-glossary-terms">Turning off links to glossary terms</a></li> </ul> </li> </ul> <h3>This Page</h3> <ul class="this-page-menu"> <li><a href="_sources/using_glossary.txt" rel="nofollow">Show Source</a></li> </ul> <div id="searchbox" style="display: none"> <h3>Quick search</h3> <form class="search" action="search.html" method="get"> <input type="text" name="q" /> <input type="submit" value="Go" /> <input type="hidden" name="check_keywords" value="yes" /> <input type="hidden" name="area" value="default" /> </form> <p class="searchtip" style="font-size: 90%"> Enter search terms or a module, class or function name. </p> </div> <script type="text/javascript">$('#searchbox').show(0);</script> </div> </div> <div class="clearer"></div> </div> <div class="related"> <h3>Navigation</h3> <ul> <li class="right" style="margin-right: 10px"> <a href="genindex.html" title="General Index" >index</a></li> <li><a href="index.html">mooclms 2.6.1 documentation</a> &raquo;</li> </ul> </div> <div class="footer"> &copy; Copyright 2014, Sakshi. Created using <a href="http://sphinx-doc.org/">Sphinx</a> 1.2.1. </div> </body> </html>
sakshi1107/mooclms
docs/build/html/using_glossary.html
HTML
gpl-2.0
14,073
<?php // $Id$ /*! * Dynamic display block module template: custom40-a - content template * Copyright (c) 2008 - 2009 P. Blaauw All rights reserved. * Version 1.1 (11-FEB-2009) * Licenced under GPL license * http://www.gnu.org/licenses/gpl.html */ /** * @file * Dynamic display block module template: custom40-a - content template * * Available variables: * - $origin: From which module comes the block. * - $delta: Block number of the block. * * - $custom_template: template name * - $output_type: type of content * * - $slider_items: array with slidecontent * - $slide_text_position of the text in the slider (top | right | bottom | left) * - $slide_direction: direction of the text in the slider (horizontal | vertical ) * - * - $pager_content: Themed pager content * - $pager_position: position of the pager (top | bottom) * * notes: don't change the ID names, they are used by the jQuery script. */ // add Cascading style sheet drupal_add_css($directory .'/custom/modules/ddblock/'.$custom_template. '/ddblock-cycle-'.$custom_template. '.css', 'template', 'all', FALSE); ?> <!-- dynamic display block slideshow --> <div id="ddblock-<?php print $delta ?>" class="ddblock-cycle-<?php print $custom_template ?> clear-block"> <div class="container clear-block border"> <div class="container-inner clear-block border"> <?php if ($pager_position == "top") : ?> <!-- custom pager image --> <?php print $pager_content ?> <?php endif; ?> <!-- slider content --> <div class="slider clear-block border"> <div class="slider-inner clear-block border"> <?php if ($output_type == 'view_fields') : ?> <?php foreach ($slider_items as $slider_item): ?> <div class="slide clear-block border"> <div class="slide-inner clear-block border"> <?php print $slider_item['slide_image']; ?> <div class="slide-text slide-text-<?php print $slide_direction ?> slide-text-<?php print $slide_text_position ?> clear-block border"> <div class="slide-text-inner clear-block border"> <div class="slide-title slide-title-<?php print $slide_direction ?> clear-block border"> <div class="slide-title-inner clear-block border"> <h2><?php print $slider_item['slide_title'] ?></h2> </div> <!-- slide-title-inner--> </div> <!-- slide-title--> <div class="slide-body-<?php print $slide_direction ?> clear-block border"> <div class="slide-body-inner clear-block border"> <p><?php print $slider_item['slide_text'] ?></p> </div> <!-- slide-body-inner--> </div> <!-- slide-body--> <div class="slide-read-more slide-read-more-<?php print $slide_direction ?> clear-block border"> <p><?php print $slider_item['slide_read_more'] ?></p> </div><!-- slide-read-more--> </div> <!-- slide-text-inner--> </div> <!-- slide-text--> </div> <!-- slide-inner--> </div> <!-- slide--> <?php endforeach; ?> <?php endif; ?> </div> <!-- slider-inner--> </div> <!-- slider--> <?php if ($pager_position == "bottom") : ?> <!-- custom pager image --> <?php print $pager_content ?> <?php endif; ?> </div> <!-- container-inner--> </div> <!--container--> </div> <!-- template -->
pgrayove/mcpl-site-backup
sites/all/themes/mcpl/custom/modules/ddblock/ddblock-cycle-block-content-custom40-a.tpl.php
PHP
gpl-2.0
3,422
/* * #%L * OME Metadata Editor application for exploration and editing of OME-XML and * OME-TIFF metadata. * %% * Copyright (C) 2006 - 2012 Open Microscopy Environment: * - Board of Regents of the University of Wisconsin-Madison * - Glencoe Software, Inc. * - University of Dundee * %% * 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/gpl-2.0.html>. * #L% */ package loci.ome.editor; import java.awt.Component; import javax.swing.JTable; import javax.swing.JTextField; import javax.swing.table.TableCellEditor; /** * A class that handles editing of a cell that is defined in * the template as having no Type attribute, e.g. it is neither * of type "Ref" or type "Desc". Creates a JTextField to edit * this cell instead of something fancy. * * <dl><dt><b>Source code:</b></dt> * <dd><a href="http://trac.openmicroscopy.org.uk/ome/browser/bioformats.git/components/legacy/ome-editor/src/loci/ome/editor/VariableTextFieldEditor.java">Trac</a>, * <a href="http://git.openmicroscopy.org/?p=bioformats.git;a=blob;f=components/legacy/ome-editor/src/loci/ome/editor/VariableTextFieldEditor.java;hb=HEAD">Gitweb</a></dd></dl> * * @author Christopher Peterson crpeterson2 at wisc.edu */ public class VariableTextFieldEditor extends VariableTextEditor implements TableCellEditor { /** Construct a new VariableTextFieldEditor.*/ public VariableTextFieldEditor(MetadataPane.TablePanel tp) { super(tp); } // -- TableCellEditor API methods -- /** * The method a table calls to get the editing component for a * particular cell. */ public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) { JTextField text = new JTextField(new RowDoc(row), (String) value, 1); text.getDocument().addDocumentListener(this); text.addFocusListener(this); text.addMouseListener(this); text.addActionListener(this); return text; } }
mtbc/bioformats
components/legacy/ome-editor/src/loci/ome/editor/VariableTextFieldEditor.java
Java
gpl-2.0
2,545
<?php /* Plugin Name: Huge IT Portfolio Gallery Plugin URI: http://huge-it.com/portfolio-gallery Description: Portfolio Gallery is a great plugin for adding specialized portfolios or gallery to your site. There are various view options for the images to choose from. Version: 1.3.6 Author: http://huge-it.com/ License: GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html */ add_action('media_buttons_context', 'add_portfolio_my_custom_button'); add_action('admin_footer', 'add_portfolio_inline_popup_content'); function add_portfolio_my_custom_button($context) { $img = plugins_url( '/images/post.button.png' , __FILE__ ); $container_id = 'huge_it_portfolio'; $title = 'Select Huge IT Portfolio Gallery to insert into post.'; $context .= '<a class="button thickbox" title="Select portfolio gallery to insert into post" href="#TB_inline?width=400&inlineId='.$container_id.'"> <span class="wp-media-buttons-icon" style="background: url('.$img.'); background-repeat: no-repeat; background-position: left bottom;"></span> Add Portfolio Gallery </a>'; return $context; } function add_portfolio_inline_popup_content() { ?> <script type="text/javascript"> jQuery(document).ready(function() { jQuery('#hugeitportfolioinsert').on('click', function() { var id = jQuery('#huge_it_portfolio-select option:selected').val(); window.send_to_editor('[huge_it_portfolio id="' + id + '"]'); tb_remove(); }) }); </script> <div id="huge_it_portfolio" style="display:none;"> <h3>Select Huge IT Portfolio Gallery to insert into post</h3> <?php global $wpdb; $query="SELECT * FROM ".$wpdb->prefix."huge_itportfolio_portfolios order by id ASC"; $shortcodeportfolios=$wpdb->get_results($query); ?> <?php if (count($shortcodeportfolios)) { echo "<select id='huge_it_portfolio-select'>"; foreach ($shortcodeportfolios as $shortcodeportfolio) { echo "<option value='".$shortcodeportfolio->id."'>".$shortcodeportfolio->name."</option>"; } echo "</select>"; echo "<button class='button primary' id='hugeitportfolioinsert'>Insert portfolio gallery</button>"; } else { echo "No slideshows found", "huge_it_portfolio"; } ?> </div> <?php } ///////////////////////////////////shortcode update///////////////////////////////////////////// add_action('init', 'hugesl_portfolio_do_output_buffer'); function hugesl_portfolio_do_output_buffer() { ob_start(); } add_action('init', 'portfolio_lang_load'); function portfolio_lang_load() { load_plugin_textdomain('sp_portfolio', false, basename(dirname(__FILE__)) . '/Languages'); } function huge_it_portfolio_images_list_shotrcode($atts) { extract(shortcode_atts(array( 'id' => 'no huge_it portfolio', ), $atts)); return huge_it_portfolio_images_list($atts['id']); } /////////////// Filter portfolio gallery function portfolio_after_search_results($query) { global $wpdb; if (isset($_REQUEST['s']) && $_REQUEST['s']) { $serch_word = htmlspecialchars(($_REQUEST['s'])); $query = str_replace($wpdb->prefix . "posts.post_content", gen_string_portfolio_search($serch_word, $wpdb->prefix . 'posts.post_content') . " " . $wpdb->prefix . "posts.post_content", $query); } return $query; } add_filter('posts_request', 'portfolio_after_search_results'); function gen_string_portfolio_search($serch_word, $wordpress_query_post) { $string_search = ''; global $wpdb; if ($serch_word) { $rows_portfolio = $wpdb->get_results($wpdb->prepare("SELECT * FROM " . $wpdb->prefix . "huge_itportfolio_portfolios WHERE (description LIKE %s) OR (name LIKE %s)", '%' . $serch_word . '%', "%" . $serch_word . "%")); $count_cat_rows = count($rows_portfolio); for ($i = 0; $i < $count_cat_rows; $i++) { $string_search .= $wordpress_query_post . ' LIKE \'%[huge_it_portfolio id="' . $rows_portfolio[$i]->id . '" details="1" %\' OR ' . $wordpress_query_post . ' LIKE \'%[huge_it_portfolio id="' . $rows_portfolio[$i]->id . '" details="1"%\' OR '; } $rows_portfolio = $wpdb->get_results($wpdb->prepare("SELECT * FROM " . $wpdb->prefix . "huge_itportfolio_portfolios WHERE (name LIKE %s)","'%" . $serch_word . "%'")); $count_cat_rows = count($rows_portfolio); for ($i = 0; $i < $count_cat_rows; $i++) { $string_search .= $wordpress_query_post . ' LIKE \'%[huge_it_portfolio id="' . $rows_portfolio[$i]->id . '" details="0"%\' OR ' . $wordpress_query_post . ' LIKE \'%[huge_it_portfolio id="' . $rows_portfolio[$i]->id . '" details="0"%\' OR '; } $rows_single = $wpdb->get_results($wpdb->prepare("SELECT * FROM " . $wpdb->prefix . "huge_itportfolio_images WHERE name LIKE %s","'%" . $serch_word . "%'")); $count_sing_rows = count($rows_single); if ($count_sing_rows) { for ($i = 0; $i < $count_sing_rows; $i++) { $string_search .= $wordpress_query_post . ' LIKE \'%[huge_it_portfolio_Product id="' . $rows_single[$i]->id . '"]%\' OR '; } } } return $string_search; } ///////////////////// end filter add_shortcode('huge_it_portfolio', 'huge_it_portfolio_images_list_shotrcode'); function huge_it_portfolio_images_list($id) { require_once("Front_end/portfolio_front_end_view.php"); require_once("Front_end/portfolio_front_end_func.php"); if (isset($_GET['product_id'])) { if (isset($_GET['view'])) { if ($_GET['view'] == 'huge_itportfolio') { return showPublishedportfolios_1($id); } else { return front_end_single_product($_GET['product_id']); } } else { return front_end_single_product($_GET['product_id']); } } else { return showPublishedportfolios_1($id); } } add_filter('admin_head', 'huge_it_portfolio_ShowTinyMCE'); function huge_it_portfolio_ShowTinyMCE() { // conditions here wp_enqueue_script('common'); wp_enqueue_script('jquery-color'); wp_print_scripts('editor'); if (function_exists('add_thickbox')) add_thickbox(); wp_print_scripts('media-upload'); if (version_compare(get_bloginfo('version'), 3.3) < 0) { if (function_exists('wp_tiny_mce')) wp_tiny_mce(); } wp_admin_css(); wp_enqueue_script('utils'); do_action("admin_print_styles-post-php"); do_action('admin_print_styles'); } function portfolio_frontend_scripts_and_styles() { wp_register_script( 'jquery', 'https://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js', array('jquery'),'1.0.0',true ); wp_enqueue_script( 'jquery' ); wp_register_script( 'portfolio-all-js', plugins_url('/js/portfolio-all.js', __FILE__), array('jquery'),'1.0.0',true ); wp_enqueue_script( 'portfolio-all-js' ); wp_register_style( 'portfolio-all-css', plugins_url('/style/portfolio-all.css', __FILE__) ); wp_enqueue_style( 'portfolio-all-css' ); wp_register_script( 'jquery.colorbox-js', plugins_url('/js/jquery.colorbox.js', __FILE__), array('jquery'),'1.0.0',true ); wp_enqueue_script( 'jquery.colorbox-js' ); wp_register_script( 'hugeitmicro-min-js', plugins_url('/js/jquery.hugeitmicro.min.js', __FILE__), array('jquery'),'1.0.0',true ); wp_enqueue_script( 'hugeitmicro-min-js' ); wp_register_style( 'style2-os-css', plugins_url('/style/style2-os.css', __FILE__) ); wp_enqueue_style( 'style2-os-css' ); wp_register_style( 'lightbox-css', plugins_url('/style/lightbox.css', __FILE__) ); wp_enqueue_style( 'lightbox-css' ); } add_action('wp_enqueue_scripts', 'portfolio_frontend_scripts_and_styles'); add_action('admin_menu', 'huge_it_portfolio_options_panel'); function huge_it_portfolio_options_panel() { $page_cat = add_menu_page('Theme page title', 'Huge IT Portfolio', 'manage_options', 'portfolios_huge_it_portfolio', 'portfolios_huge_it_portfolio', plugins_url('images/huge_it_portfolioLogoHover -for_menu.png', __FILE__)); add_submenu_page('portfolios_huge_it_portfolio', 'Portfolios', 'Portfolios', 'manage_options', 'portfolios_huge_it_portfolio', 'portfolios_huge_it_portfolio'); $page_option = add_submenu_page('portfolios_huge_it_portfolio', 'General Options', 'General Options', 'manage_options', 'Options_portfolio_styles', 'Options_portfolio_styles'); $lightbox_options = add_submenu_page('portfolios_huge_it_portfolio', 'Lightbox Options', 'Lightbox Options', 'manage_options', 'Options_portfolio_lightbox_styles', 'Options_portfolio_lightbox_styles'); add_submenu_page( 'portfolios_huge_it_portfolio', 'Licensing', 'Licensing', 'manage_options', 'huge_it_portfolio_Licensing', 'huge_it_portfolio_Licensing'); add_submenu_page('portfolios_huge_it_portfolio', 'Featured Plugins', 'Featured Plugins', 'manage_options', 'huge_it__portfolio_featured_plugins', 'huge_it__portfolio_featured_plugins'); add_action('admin_print_styles-' . $page_cat, 'huge_it_portfolio_admin_script'); add_action('admin_print_styles-' . $page_option, 'huge_it_portfolio_option_admin_script'); add_action('admin_print_styles-' . $lightbox_options, 'huge_it_portfolio_option_admin_script'); } function huge_it__portfolio_featured_plugins() { include_once("admin/huge_it_featured_plugins.php"); } function huge_it_portfolio_Licensing(){ ?> <div style="width:95%"> <p> This plugin is the non-commercial version of the Huge IT Portfolio / Gallery. If you want to customize to the styles and colors of your website,than you need to buy a license. Purchasing a license will add possibility to customize the general options and lightbox of the Huge IT Portfolio / Gallery. </p> <br /><br /> <a href="http://huge-it.com/portfolio-gallery/" class="button-primary" target="_blank">Purchase a License</a> <br /><br /><br /> <p>After the purchasing the commercial version follow this steps:</p> <ol> <li>Deactivate Huge IT Portfolio / Gallery Plugin</li> <li>Delete Huge IT Portfolio / Gallery Plugin</li> <li>Install the downloaded commercial version of the plugin</li> </ol> </div> <?php } function huge_it_portfolio_admin_script() { wp_enqueue_media(); wp_enqueue_style("jquery_ui", "http://code.jquery.com/ui/1.10.4/themes/smoothness/jquery-ui.css", FALSE); wp_enqueue_style("admin_css", plugins_url("style/admin.style.css", __FILE__), FALSE); wp_enqueue_script("admin_js", plugins_url("js/admin.js", __FILE__), FALSE); } function huge_it_portfolio_option_admin_script() { wp_enqueue_script("jquery_old", "http://ajax.googleapis.com/ajax/libs/jquery/1.8.1/jquery.min.js", FALSE); wp_enqueue_script("simple_slider_js", plugins_url("js/simple-slider.js", __FILE__), FALSE); wp_enqueue_style("simple_slider_css", plugins_url("style/simple-slider.css", __FILE__), FALSE); wp_enqueue_style("admin_css", plugins_url("style/admin.style.css", __FILE__), FALSE); wp_enqueue_script("admin_js", plugins_url("js/admin.js", __FILE__), FALSE); wp_enqueue_script('param_block2', plugins_url("elements/jscolor/jscolor.js", __FILE__)); } function portfolios_huge_it_portfolio() { require_once("admin/portfolios_func.php"); require_once("admin/portfolios_view.php"); if (!function_exists('print_html_nav')) require_once("portfolio_function/html_portfolio_func.php"); if (isset($_GET["task"])) $task = $_GET["task"]; else $task = ''; if (isset($_GET["id"])) $id = $_GET["id"]; else $id = 0; global $wpdb; switch ($task) { case 'add_cat': add_portfolio(); break; case 'edit_cat': if ($id) editportfolio($id); else { $id = $wpdb->get_var("SELECT MAX( id ) FROM " . $wpdb->prefix . "huge_itportfolio_portfolios"); editportfolio($id); } break; case 'save': if ($id) apply_cat($id); case 'apply': if ($id) { apply_cat($id); editportfolio($id); } break; case 'remove_cat': removeportfolio($id); showportfolio(); break; default: showportfolio(); break; } } function Options_portfolio_styles() { require_once("admin/portfolio_Options_func.php"); require_once("admin/portfolio_Options_view.php"); if (isset($_GET['task'])) if ($_GET['task'] == 'save') save_styles_options(); showStyles(); } function Options_portfolio_lightbox_styles() { require_once("admin/portfolio_lightbox_func.php"); require_once("admin/portfolio_lightbox_view.php"); if (isset($_GET['task'])) if ($_GET['task'] == 'save') save_styles_options(); showStyles(); } class Huge_it_portfolio_Widget extends WP_Widget { public function __construct() { parent::__construct( 'Huge_it_portfolio_Widget', 'Huge IT Portfolio', array( 'description' => __( 'Huge IT Portfolio', 'huge_it_portfolio' ), ) ); } public function widget( $args, $instance ) { extract($args); if (isset($instance['portfolio_id'])) { $portfolio_id = $instance['portfolio_id']; $title = apply_filters( 'widget_title', $instance['title'] ); echo $before_widget; if ( ! empty( $title ) ) echo $before_title . $title . $after_title; echo do_shortcode("[huge_it_portfolio id={$portfolio_id}]"); echo $after_widget; } } public function update( $new_instance, $old_instance ) { $instance = array(); $instance['portfolio_id'] = strip_tags( $new_instance['portfolio_id'] ); $instance['title'] = strip_tags( $new_instance['title'] ); return $instance; } public function form( $instance ) { $selected_portfolio = 0; $title = ""; $portfolios = false; if (isset($instance['portfolio_id'])) { $selected_portfolio = $instance['portfolio_id']; } if (isset($instance['title'])) { $title = $instance['title']; } ?> <p> <p> <label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php _e( 'Title:' ); ?></label> <input class="widefat" id="<?php echo $this->get_field_id( 'title' ); ?>" name="<?php echo $this->get_field_name( 'title' ); ?>" type="text" value="<?php echo esc_attr( $title ); ?>" /> </p> <label for="<?php echo $this->get_field_id('portfolio_id'); ?>"><?php _e('Select portfolio:', 'huge_it_portfolio'); ?></label> <select id="<?php echo $this->get_field_id('portfolio_id'); ?>" name="<?php echo $this->get_field_name('portfolio_id'); ?>"> <?php global $wpdb; $query="SELECT * FROM ".$wpdb->prefix."huge_itportfolio_portfolios "; $rowwidget=$wpdb->get_results($query); foreach($rowwidget as $rowwidgetecho){ ?> <option <?php if($rowwidgetecho->id == $instance['portfolio_id']){ echo 'selected'; } ?> value="<?php echo $rowwidgetecho->id; ?>"><?php echo $rowwidgetecho->name; ?></option> <?php } ?> </select> </p> <?php } } add_action('widgets_init', 'register_Huge_it_portfolio_Widget'); function register_Huge_it_portfolio_Widget() { register_widget('Huge_it_portfolio_Widget'); } ////////////////////////////////////////////////////// /////////////////////////////////////////////////////// ////////////////////////////////////////////////////// Activate portfolio gallery /////////////////////////////////////////////////////// ////////////////////////////////////////////////////// /////////////////////////////////////////////////////// function huge_it_portfolio_activate() { global $wpdb; /// creat database tables $sql_huge_itportfolio_images = " CREATE TABLE IF NOT EXISTS `" . $wpdb->prefix . "huge_itportfolio_images` ( `id` int(11) unsigned NOT NULL AUTO_INCREMENT, `name` varchar(100) DEFAULT NULL, `portfolio_id` varchar(200) DEFAULT NULL, `description` text, `image_url` text, `sl_url` varchar(128) DEFAULT NULL, `sl_type` text NOT NULL, `link_target` text NOT NULL, `ordering` int(11) NOT NULL, `published` tinyint(4) unsigned DEFAULT NULL, `published_in_sl_width` tinyint(4) unsigned DEFAULT NULL, `category` varchar(200) NOT NULL, PRIMARY KEY (`id`), UNIQUE KEY `id` (`id`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=5"; $sql_huge_itportfolio_portfolios = " CREATE TABLE IF NOT EXISTS `" . $wpdb->prefix . "huge_itportfolio_portfolios` ( `id` int(11) unsigned NOT NULL AUTO_INCREMENT, `name` varchar(200) NOT NULL, `sl_height` int(11) unsigned DEFAULT NULL, `sl_width` int(11) unsigned DEFAULT NULL, `pause_on_hover` text, `portfolio_list_effects_s` text, `description` text, `param` text, `sl_position` text NOT NULL, `ordering` int(11) NOT NULL, `published` text, `categories` text NOT NULL, `ht_show_sorting` text NOT NULL, `ht_show_filtering` text NOT NULL, PRIMARY KEY (`id`), UNIQUE KEY `id` (`id`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=2 "; $table_name = $wpdb->prefix . "huge_itportfolio_images"; $sql_2 = " INSERT INTO `" . $table_name . "` (`id`, `name`, `portfolio_id`, `description`, `image_url`, `sl_url`, `sl_type`, `link_target`, `ordering`, `published`, `published_in_sl_width`) VALUES (1, 'Cutthroat & Cavalier', '1', '<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. </p><p>Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>', '".plugins_url("Front_images/projects/1.jpg", __FILE__).";".plugins_url("Front_images/projects/1.1.jpg", __FILE__).";".plugins_url("Front_images/projects/1.2.jpg", __FILE__).";', 'http://huge-it.com/fields/order-website-maintenance/', 'image', 'on', 0, 1, NULL), (2, 'Cone Music', '1', '<ul><li>lorem ipsumdolor sit amet</li><li>lorem ipsum dolor sit amet</li></ul><p>Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>', '".plugins_url("Front_images/projects/5.jpg", __FILE__).";".plugins_url("Front_images/projects/5.1.jpg", __FILE__).";".plugins_url("Front_images/projects/5.2.jpg", __FILE__).";', 'http://huge-it.com/fields/order-website-maintenance/', 'image', 'on', 1, 1, NULL), (3, 'Nexus', '1', '<h6>Lorem Ipsum </h6><p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. </p><p>Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p><ul><li>lorem ipsum</li><li>dolor sit amet</li><li>lorem ipsum</li><li>dolor sit amet</li></ul>', '".plugins_url("Front_images/projects/3.jpg", __FILE__).";".plugins_url("Front_images/projects/3.1.jpg", __FILE__).";".plugins_url("Front_images/projects/3.2.jpg", __FILE__).";', 'http://huge-it.com/fields/order-website-maintenance/', 'image', 'on', 2, 1, NULL), (4, 'De7igner', '1', '<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. </p><h7>Dolor sit amet</h7><p>Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>', '".plugins_url("Front_images/projects/4.jpg", __FILE__).";".plugins_url("Front_images/projects/4.1.jpg", __FILE__).";".plugins_url("Front_images/projects/4.2.jpg", __FILE__).";', 'http://huge-it.com/fields/order-website-maintenance/', 'image', 'on', 3, 1, NULL), (5, 'Autumn / Winter Collection', '1', '<h6>Lorem Ipsum</h6><p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>', '".plugins_url("Front_images/projects/2.jpg", __FILE__).";', 'http://huge-it.com/fields/order-website-maintenance/', 'image', 'on', 4, 1, NULL), (6, 'Retro Headphones', '1', '<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. </p><p>Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>', '".plugins_url("Front_images/projects/6.jpg", __FILE__).";".plugins_url("Front_images/projects/6.1.jpg", __FILE__).";".plugins_url("Front_images/projects/6.2.jpg", __FILE__).";', 'http://huge-it.com/fields/order-website-maintenance/', 'image', 'on', 5, 1, NULL), (7, 'Take Fight', '1', '<h6>Lorem Ipsum</h6><p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. </p><p>Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>', '".plugins_url("Front_images/projects/7.jpg", __FILE__).";".plugins_url("Front_images/projects/7.2.jpg", __FILE__).";".plugins_url("Front_images/projects/7.3.jpg", __FILE__).";', 'http://huge-it.com/fields/order-website-maintenance/', 'image', 'on', 6, 1, NULL), (8, 'The Optic', '1', '<h6>Lorem Ipsum </h6><p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. </p><p>Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p><ul><li>lorem ipsum</li><li>dolor sit amet</li><li>lorem ipsum</li><li>dolor sit amet</li></ul>', '".plugins_url("Front_images/projects/8.jpg", __FILE__).";".plugins_url("Front_images/projects/8.1.jpg", __FILE__).";".plugins_url("Front_images/projects/8.3.jpg", __FILE__).";', 'http://huge-it.com/fields/order-website-maintenance/', 'image', 'on', 7, 1, NULL)"; $table_name = $wpdb->prefix . "huge_itportfolio_portfolios"; $sql_3 = " INSERT INTO `$table_name` (`id`, `name`, `sl_height`, `sl_width`, `pause_on_hover`, `portfolio_list_effects_s`, `description`, `param`, `sl_position`, `ordering`, `published`) VALUES (1, 'My First Portfolio', 375, 600, 'on', '2', '4000', '1000', 'center', 1, '300')"; $wpdb->query($sql_huge_itportfolio_params); $wpdb->query($sql_huge_itportfolio_images); $wpdb->query($sql_huge_itportfolio_portfolios); if (!$wpdb->get_var("select count(*) from " . $wpdb->prefix . "huge_itportfolio_images")) { $wpdb->query($sql_2); } if (!$wpdb->get_var("select count(*) from " . $wpdb->prefix . "huge_itportfolio_portfolios")) { $wpdb->query($sql_3); } ///////////////////////////update//////////////////////////////////// $imagesAllFieldsInArray = $wpdb->get_results("DESCRIBE " . $wpdb->prefix . "huge_itportfolio_images", ARRAY_A); $forUpdate = 0; foreach ($imagesAllFieldsInArray as $portfoliosField) { if ($portfoliosField['Field'] == 'category') { // "ka category field.<br>"; $forUpdate = 1; $catValues = $wpdb->get_results( "SELECT category FROM ".$wpdb->prefix."huge_itportfolio_images" ); $needToUpdate=0; foreach($catValues as $catValue){ if($catValue->category !== '') { $needToUpdate=1; //echo "category field - y datark chi.<br>"; } } if($needToUpdate == 0){ $wpdb->query("UPDATE ".$wpdb->prefix."huge_itportfolio_images SET category = 'My First Category,My Third Category,' WHERE id='1'"); $wpdb->query("UPDATE ".$wpdb->prefix."huge_itportfolio_images SET category = 'My Second Category,' WHERE id='2'"); $wpdb->query("UPDATE ".$wpdb->prefix."huge_itportfolio_images SET category = 'My Third Category,' WHERE id='3'"); $wpdb->query("UPDATE ".$wpdb->prefix."huge_itportfolio_images SET category = 'My First Category,My Second Category,' WHERE id='4'"); $wpdb->query("UPDATE ".$wpdb->prefix."huge_itportfolio_images SET category = 'My Second Category,My Third Category,' WHERE id='5'"); $wpdb->query("UPDATE ".$wpdb->prefix."huge_itportfolio_images SET category = 'My Third Category,' WHERE id='6'"); $wpdb->query("UPDATE ".$wpdb->prefix."huge_itportfolio_images SET category = 'My Second Category,' WHERE id='7'"); $wpdb->query("UPDATE ".$wpdb->prefix."huge_itportfolio_images SET category = 'My First Category,' WHERE id='8'"); } break; } } if ($forUpdate == '0') { $wpdb->query("ALTER TABLE ".$wpdb->prefix."huge_itportfolio_images ADD category text"); $wpdb->query("UPDATE ".$wpdb->prefix."huge_itportfolio_images SET category = 'My First Category,My Third Category,' WHERE id='1'"); $wpdb->query("UPDATE ".$wpdb->prefix."huge_itportfolio_images SET category = 'My Second Category,' WHERE id='2'"); $wpdb->query("UPDATE ".$wpdb->prefix."huge_itportfolio_images SET category = 'My Third Category,' WHERE id='3'"); $wpdb->query("UPDATE ".$wpdb->prefix."huge_itportfolio_images SET category = 'My First Category,My Second Category,' WHERE id='4'"); $wpdb->query("UPDATE ".$wpdb->prefix."huge_itportfolio_images SET category = 'My Second Category,My Third Category,' WHERE id='5'"); $wpdb->query("UPDATE ".$wpdb->prefix."huge_itportfolio_images SET category = 'My Third Category,' WHERE id='6'"); $wpdb->query("UPDATE ".$wpdb->prefix."huge_itportfolio_images SET category = 'My Second Category,' WHERE id='7'"); $wpdb->query("UPDATE ".$wpdb->prefix."huge_itportfolio_images SET category = 'My First Category,' WHERE id='8'"); } $productPortfolio = $wpdb->get_results("DESCRIBE " . $wpdb->prefix . "huge_itportfolio_portfolios", ARRAY_A); $isUpdate = 0; foreach ($productPortfolio as $prodPortfolio) { if ($prodPortfolio['Field'] == 'categories' && $prodPortfolio['Type'] == 'text') { $isUpdate = 1; $allCats = $wpdb->get_results( "SELECT categories FROM ".$wpdb->prefix."huge_itportfolio_portfolios" ); $needToUpdateAllCats=0; foreach($allCats as $AllCatsVal){ if($AllCatsVal->categories !== '') { $needToUpdateAllCats=1; } } if($needToUpdateAllCats == 0){ $wpdb->query("UPDATE ".$wpdb->prefix."huge_itportfolio_portfolios SET categories = 'My First Category,My Second Category,My Third Category,' "); $wpdb->query("UPDATE ".$wpdb->prefix."huge_itportfolio_portfolios SET ht_show_sorting = 'off' "); $wpdb->query("UPDATE ".$wpdb->prefix."huge_itportfolio_portfolios SET ht_show_filtering = 'off' "); } break; } } if ($isUpdate == '0') { $wpdb->query("ALTER TABLE ".$wpdb->prefix."huge_itportfolio_portfolios ADD categories text"); $wpdb->query("UPDATE ".$wpdb->prefix."huge_itportfolio_portfolios SET categories = 'My First Category,My Second Category,My Third Category,'"); $wpdb->query("ALTER TABLE ".$wpdb->prefix."huge_itportfolio_portfolios ADD ht_show_sorting text"); $wpdb->query("UPDATE ".$wpdb->prefix."huge_itportfolio_portfolios SET ht_show_sorting = 'off'"); $wpdb->query("ALTER TABLE ".$wpdb->prefix."huge_itportfolio_portfolios ADD ht_show_filtering text"); $wpdb->query("UPDATE ".$wpdb->prefix."huge_itportfolio_portfolios SET ht_show_filtering = 'off'"); } } register_activation_hook(__FILE__, 'huge_it_portfolio_activate');
YeongeunHeo/wordpress
wp-content/plugins/portfolio-gallery/portfolio-gallery.php
PHP
gpl-2.0
29,406
/* * This file is part of the OpenJML project. * Author: David R. Cok */ package org.jmlspecs.openjml.proverinterface; import org.jmlspecs.openjml.proverinterface.IProverResult.ICounterexample; import com.sun.tools.javac.code.Type; import com.sun.tools.javac.tree.JCTree.JCExpression; /** * A prover can be used to check if a formula is satisfiable, * given a set of assumptions. The prover may need to be restarted * before being reused. * <P> * The assume calls take a JCExpression encoding the logical expression * that the prover is to assume. This is a OpenJDK AST but of restricted * form. In particular, only the following AST nodes are allowed (there is * no runtime check of this restriction): * <UL> * <LI>JCBinary - with any Java operator * <LI>JmlBinary - with any JML operator * <LI>JCUnary - with any Java operator * <LI>JCIdent - the identifier for a logical variable, with the * type field giving the Java type of the variable * <LI>JCConditional - an if-then-else (i.e. ?:) construct * <LI>JmlBBFieldAccess - encodes field access (replaces JCFieldAccess) * <LI>JmlBBArrayAccess - array access, replacing JCArrayAccess * <LI>JCParens - not needed but helps to keep pretty printed expressions less confusing * <LI>JCLiteral - for boolean, integer, null literals * <LI>JCMethodInvocation - FIXME - needs explanation * </UL> * * * * TODO add properties, like timelimit * * @author David Cok, based on previous work by rgrig */ public interface IProver { /** Returns an identifying name for the prover */ public String name(); /** * Adds {@code tree} as an assumption; the concrete IProver is * responsible to translate the AST into prover-dependent form. * @param tree the assumption * @return an integer id for the assumption (or 0 if ids are not supported) * @throws ProverException if something goes wrong */ public int assume(/*@ non_null*/JCExpression tree) throws ProverException; /** * Adds {@code tree} as an assumption; the concrete IProver is * responsible to translate the AST into prover-dependent form. * @param tree the assumption * @param weight a weight to be associated with the assertion (may be * ignored if the prover does not support weights) * @return an integer id for the assumption (or 0 if ids are not supported) * @throws ProverException if something goes wrong */ public int assume(/*@ non_null*/JCExpression tree, int weight) throws ProverException; /** Tells the prover to define a given variable as the stated type * (not all provers need this) * @param id the name of the variable * @param type the type of the variable * @throws ProverException if something goes wrong */ public void define(/*@ non_null*/String id, /*@ non_null*/Type type) throws ProverException; /** Tells the prover to define a given variable as the stated type and with the given value * (not all provers need this) * @param id the name of the variable * @param type the type of the variable * @param value the value the variable is an abbreviation for * @throws ProverException if something goes wrong */ public void define(/*@ non_null*/String id, /*@ non_null*/Type type, /*@ non_null*/ JCExpression value) throws ProverException; /** * Retract the last assumption. * @throws ProverException if something goes wrong */ public void retract() throws ProverException; /** * Retracts a specific assumption. * @param i the assertion to retract * @throws ProverException if something goes wrong */ public void retract(int i) throws ProverException; /** * Make a new frame of assumptions. * @throws ProverException if something goes wrong */ public void push() throws ProverException; /** * Removes the last frame of assumptions. * @throws ProverException if something goes wrong */ public void pop() throws ProverException; /** Checks whether the set of assertions known to the prover so far * is satisfiable or not * @return an object containing the details of the prover answer * @throws ProverException if something goes wrong */ // /*@ non_null*/ // public IProverResult check() throws ProverException; /*@ non_null*/ public IProverResult check(boolean details) throws ProverException; /** * Kills and restarts the prover process. Then it resends * all the assumptions that are on the stack. * @throws ProverException if something goes wrong */ public void restartProver() throws ProverException; /** Kills the prover * @throws ProverException if something goes wrong */ public void kill() throws ProverException; public void reassertCounterexample(ICounterexample ce); public Supports supports(); static public class Supports { public Supports() { retract = false; unsatcore = false; } public boolean retract; public boolean unsatcore; } }
shunghsiyu/OpenJML_XOR
OpenJML/src/org/jmlspecs/openjml/proverinterface/IProver.java
Java
gpl-2.0
5,173
/* $Id: colors.c,v 1.5 2005/06/08 23:58:41 chris Exp $ */ /* skf - shit keeps falling * Copyright (C) 2005 Chris Lumens * * 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., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include <stdlib.h> #include <SDL/SDL.h> #include "colors.h" #include "skf.h" /* +=====================================================================+ * | PUBLIC FUNCTIONS | * +=====================================================================+ */ colors_t rand_color() { return rnd(NCOLORS); }
clumens/skf
src/colors.c
C
gpl-2.0
1,123
package org.mo.logic.deploy; import org.mo.com.xml.IXmlObject; import org.mo.eng.store.IXmlConfigConsole; public interface IDeployConsole extends IXmlConfigConsole<IXmlObject> { void install(EDeploySource type); void installAll(EDeploySource type); void uninstall(EDeploySource type); void uninstallAll(EDeploySource type); }
favedit/MoPlatform
mo-3-logic/src/logic-java/org/mo/logic/deploy/IDeployConsole.java
Java
gpl-2.0
358
package com.sales.service; import java.util.List; import com.sales.model.TCurrency; public interface K3EntryService { public List getPayCondition(); public List getCurrency(); public TCurrency getCurrencyById(Integer fCurrencyID); public List getEmp(String fName); public List getDepartList(); public List getStaff(); public List getUser(); public List getEmpList(); /** * @return 销售报价单开票方式 */ public List getInvoiceTypeList(); /** * @return 销售报价单运输方式 */ public List getTransTypeList(); }
goulin2k/salesManager
salesManagerServer/src/com/sales/service/K3EntryService.java
Java
gpl-2.0
604
# Dota2-Invoker-Keys ### Table of contents * [Introduction](#introduction) * [Customizing the Script](#customizing-the-script) * [Version Changes](#version-changes) * [Authors](#authors) ### Introduction Dota2 Invoker Keys is basically a shortcut to play Invoker. Invoker is a complex hero, one has to be so quick but some people despite of how much they try cant make it up to the mark. Threfore I wrote this simple script which allows you to play Invoker very easily. Lets suppose I want to use the sun-strike now if I was not using this script I would have to press ```.net E => E => E => R ``` to invoke the spell and then press ``` T ``` (the spell cast key) to cast the spell. Now if I am using this script all I have to do is press ``` (Left-Alt + T) ``` to invoke the spell and then press ``` T ``` (the spell cast key) to use the spell. <span style="color:red">Remember *Left-Alt* key and the spell-cast key are to be pressed simultaneously.</span> ### Customizing the Script In case if someone wants to modifyy the script, enhance it for some other hero or to modify existing code for their ease e.g. change the key to something else like from *Left-Alt* to *space-bar* key etc. they can do so. The script is written in [**AutoHotkey**](https://autohotkey.com/) scripting language. You will have to download and install AutoHotkey on your computer. After installation, modify the script as needed and then save the file. Then *right-click* the script file and select "Compile script" from the menu. This will generate an executable binary file with the same name as the script-file in the same directory. Run this executable and enjoy the game. ### Version Changes Current Version: 1.0 * Invoker Script has been completed * Mouse Scroll Script has been completed ## ### Authors *Umer javaid*
DSMorpher/Dota2-Invoker-Keys
README.md
Markdown
gpl-2.0
1,829
/* * org.openmicroscopy.shoola.agents.fsimporter.AnnotationDataLoader * *------------------------------------------------------------------------------ * Copyright (C) 2013 University of Dundee & Open Microscopy Environment. * 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 as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * *------------------------------------------------------------------------------ */ package org.openmicroscopy.shoola.agents.fsimporter; //Java imports import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; import java.util.List; import java.util.Map; import org.openmicroscopy.shoola.agents.fsimporter.view.Importer; import org.openmicroscopy.shoola.agents.treeviewer.DataBrowserLoader; import omero.gateway.SecurityContext; import org.openmicroscopy.shoola.env.data.views.CallHandle; import pojos.FileAnnotationData; import pojos.FilesetData; /** * Loads the annotations of a given type linked to the specified image. * * @author Jean-Marie Burel &nbsp;&nbsp;&nbsp;&nbsp; * <a href="mailto:j.burel@dundee.ac.uk">j.burel@dundee.ac.uk</a> * @since 4.4 */ public class AnnotationDataLoader extends DataImporterLoader { /** Handle to the asynchronous call so that we can cancel it.*/ private CallHandle handle; /** The index of the UI element.*/ private int index; /** The identifier of the image.*/ private long fileSetID; /** * Creates a new instance. * * @param viewer The Importer this data loader is for. * Mustn't be <code>null</code>. * @param ctx The security context. * @param imageID The identifier of the image. * @param index The index of the UI element. */ public AnnotationDataLoader(Importer viewer, SecurityContext ctx, long fileSetID, int index) { super(viewer, ctx); this.fileSetID = fileSetID; this.index = index; } /** * Loads the annotations. * @see DataImporterLoader#load() */ public void load() { List<String> nsInclude = new ArrayList<String>(); nsInclude.add(FileAnnotationData.LOG_FILE_NS); handle = mhView.loadAnnotations(ctx, FilesetData.class, Arrays.asList(fileSetID), FileAnnotationData.class, nsInclude, null, this); } /** * Cancels the data loading. * @see DataImporterLoader#load() */ public void cancel() { handle.cancel(); } /** * Feeds the result back to the viewer. * @see DataBrowserLoader#handleResult(Object) */ public void handleResult(Object result) { if (viewer.getState() == Importer.DISCARDED) return; Map<Long, Collection<FileAnnotationData>> map = (Map<Long, Collection<FileAnnotationData>>) result; viewer.setImportLogFile(map.get(fileSetID), fileSetID, index); } }
stelfrich/openmicroscopy
components/insight/SRC/org/openmicroscopy/shoola/agents/fsimporter/AnnotationDataLoader.java
Java
gpl-2.0
3,360