code stringlengths 4 1.01M | language stringclasses 2 values |
|---|---|
/*
* Copyright (C) 2008-2014 TrinityCore <http://www.trinitycore.org/>
* Copyright (C) 2006-2009 ScriptDev2 <https://scriptdev2.svn.sourceforge.net/>
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at your
* option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/* ScriptData
SDName: Npc_Taxi
SD%Complete: 0%
SDComment: To be used for taxi NPCs that are located globally.
SDCategory: NPCs
EndScriptData
*/
#include "ScriptMgr.h"
#include "ScriptedCreature.h"
#include "ScriptedGossip.h"
#include "Player.h"
#include "WorldSession.h"
#define GOSSIP_SUSURRUS "I am ready."
#define GOSSIP_NETHER_DRAKE "I'm ready to fly! Take me up, dragon!"
#define GOSSIP_BRAZEN "I am ready to go to Durnholde Keep."
#define GOSSIP_IRONWING "I'd like to take a flight around Stormwind Harbor."
#define GOSSIP_DABIREE1 "Fly me to Murketh and Shaadraz Gateways"
#define GOSSIP_DABIREE2 "Fly me to Shatter Point"
#define GOSSIP_WINDBELLOW1 "Fly me to The Abyssal Shelf"
#define GOSSIP_WINDBELLOW2 "Fly me to Honor Point"
#define GOSSIP_BRACK1 "Fly me to Murketh and Shaadraz Gateways"
#define GOSSIP_BRACK2 "Fly me to The Abyssal Shelf"
#define GOSSIP_BRACK3 "Fly me to Spinebreaker Post"
#define GOSSIP_IRENA "Fly me to Skettis please"
#define GOSSIP_CLOUDBREAKER1 "Speaking of action, I've been ordered to undertake an air strike."
#define GOSSIP_CLOUDBREAKER2 "I need to intercept the Dawnblade reinforcements."
#define GOSSIP_DRAGONHAWK "<Ride the dragonhawk to Sun's Reach>"
#define GOSSIP_VERONIA "Fly me to Manaforge Coruu please"
#define GOSSIP_DEESAK "Fly me to Ogri'la please"
#define GOSSIP_AFRASASTRASZ1 "I would like to take a flight to the ground, Lord Of Afrasastrasz."
#define GOSSIP_AFRASASTRASZ2 "My Lord, I must go to the upper floor of the temple."
#define GOSSIP_TARIOLSTRASZ1 "My Lord, I must go to the upper floor of the temple."
#define GOSSIP_TARIOLSTRASZ2 "Can you spare a drake to travel to Lord Of Afrasastrasz, in the middle of the temple?"
#define GOSSIP_TORASTRASZA1 "I would like to see Lord Of Afrasastrasz, in the middle of the temple."
#define GOSSIP_TORASTRASZA2 "Yes, Please. I would like to return to the ground floor of the temple."
#define GOSSIP_CRIMSONWING "<Ride the gryphons to Survey Alcaz Island>"
#define GOSSIP_WILLIAMKEILAR1 "Take me to Northpass Tower."
#define GOSSIP_WILLIAMKEILAR2 "Take me to Eastwall Tower."
#define GOSSIP_WILLIAMKEILAR3 "Take me to Crown Guard Tower."
class npc_taxi : public CreatureScript
{
public:
npc_taxi() : CreatureScript("npc_taxi") { }
bool OnGossipHello(Player* player, Creature* creature) override
{
if (creature->IsQuestGiver())
player->PrepareQuestMenu(creature->GetGUID());
switch (creature->GetEntry())
{
case 17435: // Azuremyst Isle - Susurrus
if (player->HasItemCount(23843, 1, true))
player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_SUSURRUS, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF);
break;
case 20903: // Netherstorm - Protectorate Nether Drake
if (player->GetQuestStatus(10438) == QUEST_STATUS_INCOMPLETE && player->HasItemCount(29778))
player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_NETHER_DRAKE, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 1);
break;
case 18725: // Old Hillsbrad Foothills - Brazen
player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_BRAZEN, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 2);
break;
case 29154: // Stormwind City - Thargold Ironwing
player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_IRONWING, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 3);
break;
case 19409: // Hellfire Peninsula - Wing Commander Dabir'ee
//Mission: The Murketh and Shaadraz Gateways
if (player->GetQuestStatus(10146) == QUEST_STATUS_INCOMPLETE)
player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_DABIREE1, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 4);
//Shatter Point
if (!player->GetQuestRewardStatus(10340))
player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_DABIREE2, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 5);
break;
case 20235: // Hellfire Peninsula - Gryphoneer Windbellow
//Mission: The Abyssal Shelf || Return to the Abyssal Shelf
if (player->GetQuestStatus(10163) == QUEST_STATUS_INCOMPLETE || player->GetQuestStatus(10346) == QUEST_STATUS_INCOMPLETE)
player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_WINDBELLOW1, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 6);
//Go to the Front
if (player->GetQuestStatus(10382) != QUEST_STATUS_NONE && !player->GetQuestRewardStatus(10382))
player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_WINDBELLOW2, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 7);
break;
case 19401: // Hellfire Peninsula - Wing Commander Brack
//Mission: The Murketh and Shaadraz Gateways
if (player->GetQuestStatus(10129) == QUEST_STATUS_INCOMPLETE)
player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_BRACK1, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 8);
//Mission: The Abyssal Shelf || Return to the Abyssal Shelf
if (player->GetQuestStatus(10162) == QUEST_STATUS_INCOMPLETE || player->GetQuestStatus(10347) == QUEST_STATUS_INCOMPLETE)
player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_BRACK2, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 9);
//Spinebreaker Post
if (player->GetQuestStatus(10242) == QUEST_STATUS_COMPLETE)
player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_BRACK3, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 10);
break;
case 23413: // Blade's Edge Mountains - Skyguard Handler Irena
if (player->GetReputationRank(1031) >= REP_HONORED)
player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_IRENA, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 11);
break;
case 25059: // Isle of Quel'Danas - Ayren Cloudbreaker
if (player->GetQuestStatus(11532) == QUEST_STATUS_INCOMPLETE || player->GetQuestStatus(11533) == QUEST_STATUS_INCOMPLETE)
player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_CLOUDBREAKER1, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 12);
if (player->GetQuestStatus(11542) == QUEST_STATUS_INCOMPLETE || player->GetQuestStatus(11543) == QUEST_STATUS_INCOMPLETE)
player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_CLOUDBREAKER2, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 13);
break;
case 25236: // Isle of Quel'Danas - Unrestrained Dragonhawk
if (player->GetQuestStatus(11542) == QUEST_STATUS_COMPLETE || player->GetQuestStatus(11543) == QUEST_STATUS_COMPLETE)
player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_DRAGONHAWK, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 14);
break;
case 20162: // Netherstorm - Veronia
//Behind Enemy Lines
if (player->GetQuestStatus(10652) != QUEST_STATUS_REWARDED)
player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_VERONIA, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 15);
break;
case 23415: // Terokkar Forest - Skyguard Handler Deesak
if (player->GetReputationRank(1031) >= REP_HONORED)
player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_DEESAK, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 16);
break;
case 27575: // Dragonblight - Lord Afrasastrasz
// middle -> ground
player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_AFRASASTRASZ1, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 17);
// middle -> top
player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_AFRASASTRASZ2, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 18);
break;
case 26443: // Dragonblight - Tariolstrasz //need to check if quests are required before gossip available (12123, 12124)
// ground -> top
player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_TARIOLSTRASZ1, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 19);
// ground -> middle
player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_TARIOLSTRASZ2, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 20);
break;
case 26949: // Dragonblight - Torastrasza
// top -> middle
player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_TORASTRASZA1, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 21);
// top -> ground
player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_TORASTRASZA2, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 22);
break;
case 23704: // Dustwallow Marsh - Cassa Crimsonwing
if (player->GetQuestStatus(11142) == QUEST_STATUS_INCOMPLETE)
player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_CRIMSONWING, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+25);
break;
case 17209:
player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_WILLIAMKEILAR1, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 28);
player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_WILLIAMKEILAR2, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 29);
player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_WILLIAMKEILAR3, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 30);
break;
}
player->SEND_GOSSIP_MENU(player->GetGossipTextId(creature), creature->GetGUID());
return true;
}
bool OnGossipSelect(Player* player, Creature* creature, uint32 /*sender*/, uint32 action) override
{
player->PlayerTalkClass->ClearMenus();
switch (action)
{
case GOSSIP_ACTION_INFO_DEF:
//spellId is correct, however it gives flight a somewhat funny effect //TaxiPath 506.
player->CLOSE_GOSSIP_MENU();
player->CastSpell(player, 32474, true);
break;
case GOSSIP_ACTION_INFO_DEF + 1:
player->CLOSE_GOSSIP_MENU();
player->ActivateTaxiPathTo(627); //TaxiPath 627 (possibly 627+628(152->153->154->155))
break;
case GOSSIP_ACTION_INFO_DEF + 2:
if (!player->HasItemCount(25853))
player->SEND_GOSSIP_MENU(9780, creature->GetGUID());
else
{
player->CLOSE_GOSSIP_MENU();
player->ActivateTaxiPathTo(534); //TaxiPath 534
}
break;
case GOSSIP_ACTION_INFO_DEF + 3:
player->CLOSE_GOSSIP_MENU();
player->CastSpell(player, 53335, true); //TaxiPath 1041 (Stormwind Harbor)
break;
case GOSSIP_ACTION_INFO_DEF + 4:
player->CLOSE_GOSSIP_MENU();
player->CastSpell(player, 33768, true); //TaxiPath 585 (Gateways Murket and Shaadraz)
break;
case GOSSIP_ACTION_INFO_DEF + 5:
player->CLOSE_GOSSIP_MENU();
player->CastSpell(player, 35069, true); //TaxiPath 612 (Taxi - Hellfire Peninsula - Expedition Point to Shatter Point)
break;
case GOSSIP_ACTION_INFO_DEF + 6:
player->CLOSE_GOSSIP_MENU();
player->CastSpell(player, 33899, true); //TaxiPath 589 (Aerial Assault Flight (Alliance))
break;
case GOSSIP_ACTION_INFO_DEF + 7:
player->CLOSE_GOSSIP_MENU();
player->CastSpell(player, 35065, true); //TaxiPath 607 (Taxi - Hellfire Peninsula - Shatter Point to Beach Head)
break;
case GOSSIP_ACTION_INFO_DEF + 8:
player->CLOSE_GOSSIP_MENU();
player->CastSpell(player, 33659, true); //TaxiPath 584 (Gateways Murket and Shaadraz)
break;
case GOSSIP_ACTION_INFO_DEF + 9:
player->CLOSE_GOSSIP_MENU();
player->CastSpell(player, 33825, true); //TaxiPath 587 (Aerial Assault Flight (Horde))
break;
case GOSSIP_ACTION_INFO_DEF + 10:
player->CLOSE_GOSSIP_MENU();
player->CastSpell(player, 34578, true); //TaxiPath 604 (Taxi - Reaver's Fall to Spinebreaker Ridge)
break;
case GOSSIP_ACTION_INFO_DEF + 11:
player->CLOSE_GOSSIP_MENU();
player->CastSpell(player, 41278, true); //TaxiPath 706
break;
case GOSSIP_ACTION_INFO_DEF + 12:
player->CLOSE_GOSSIP_MENU();
player->CastSpell(player, 45071, true); //TaxiPath 779
break;
case GOSSIP_ACTION_INFO_DEF + 13:
player->CLOSE_GOSSIP_MENU();
player->CastSpell(player, 45113, true); //TaxiPath 784
break;
case GOSSIP_ACTION_INFO_DEF + 14:
player->CLOSE_GOSSIP_MENU();
player->CastSpell(player, 45353, true); //TaxiPath 788
break;
case GOSSIP_ACTION_INFO_DEF + 15:
player->CLOSE_GOSSIP_MENU();
player->CastSpell(player, 34905, true); //TaxiPath 606
break;
case GOSSIP_ACTION_INFO_DEF + 16:
player->CLOSE_GOSSIP_MENU();
player->CastSpell(player, 41279, true); //TaxiPath 705 (Taxi - Skettis to Skyguard Outpost)
break;
case GOSSIP_ACTION_INFO_DEF + 17:
player->CLOSE_GOSSIP_MENU();
player->ActivateTaxiPathTo(882);
break;
case GOSSIP_ACTION_INFO_DEF + 18:
player->CLOSE_GOSSIP_MENU();
player->ActivateTaxiPathTo(881);
break;
case GOSSIP_ACTION_INFO_DEF + 19:
player->CLOSE_GOSSIP_MENU();
player->ActivateTaxiPathTo(878);
break;
case GOSSIP_ACTION_INFO_DEF + 20:
player->CLOSE_GOSSIP_MENU();
player->ActivateTaxiPathTo(883);
break;
case GOSSIP_ACTION_INFO_DEF + 21:
player->CLOSE_GOSSIP_MENU();
player->ActivateTaxiPathTo(880);
break;
case GOSSIP_ACTION_INFO_DEF + 22:
player->CLOSE_GOSSIP_MENU();
player->ActivateTaxiPathTo(879);
break;
case GOSSIP_ACTION_INFO_DEF + 23:
player->CLOSE_GOSSIP_MENU();
player->CastSpell(player, 43074, true); //TaxiPath 736
break;
case GOSSIP_ACTION_INFO_DEF + 24:
player->CLOSE_GOSSIP_MENU();
//player->ActivateTaxiPathTo(738);
player->CastSpell(player, 43136, false);
break;
case GOSSIP_ACTION_INFO_DEF + 25:
player->CLOSE_GOSSIP_MENU();
player->CastSpell(player, 42295, true);
break;
case GOSSIP_ACTION_INFO_DEF + 26:
player->CLOSE_GOSSIP_MENU();
player->ActivateTaxiPathTo(494);
break;
case GOSSIP_ACTION_INFO_DEF + 27:
player->CLOSE_GOSSIP_MENU();
player->ActivateTaxiPathTo(495);
break;
case GOSSIP_ACTION_INFO_DEF + 28:
player->CLOSE_GOSSIP_MENU();
player->ActivateTaxiPathTo(496);
break;
}
return true;
}
};
void AddSC_npc_taxi()
{
new npc_taxi;
}
| Java |
/**
* UGENE - Integrated Bioinformatics Tools.
* Copyright (C) 2008-2022 UniPro <ugene@unipro.ru>
* http://ugene.net
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301, USA.
*/
#include "ScriptEditorWidget.h"
#include <QBoxLayout>
#include <QLineEdit>
#include <QSplitter>
#include <QTextEdit>
#include "ScriptHighlighter.h"
const char* SCRIPT_TEXT_PROPERTY_NAME = "script text";
namespace U2 {
ScriptEditorWidget::ScriptEditorWidget(QWidget* parent, ScriptEditorType typeOfField)
: QWidget(parent) {
scriptContainer = new QSplitter(Qt::Vertical, this);
scriptContainer->setFocusPolicy(Qt::NoFocus);
QBoxLayout* layout = new QBoxLayout(QBoxLayout::TopToBottom, this);
layout->setMargin(0);
layout->addWidget(scriptContainer);
variablesEdit = new QTextEdit(scriptContainer);
variablesEdit->setReadOnly(true);
new ScriptHighlighter(variablesEdit->document());
scriptEdit = AbstractScriptEditorDelegate::createInstance(scriptContainer, typeOfField);
scriptEdit->installScriptHighlighter();
connect(scriptEdit, SIGNAL(si_textChanged()), SIGNAL(si_textChanged()));
connect(scriptEdit, SIGNAL(si_cursorPositionChanged()), SIGNAL(si_cursorPositionChanged()));
}
void ScriptEditorWidget::setVariablesText(const QString& variablesText) {
variablesEdit->setText(variablesText);
}
QString ScriptEditorWidget::variablesText() const {
return variablesEdit->toPlainText();
}
void ScriptEditorWidget::setScriptText(const QString& text) {
scriptEdit->setText(text);
}
QString ScriptEditorWidget::scriptText() const {
return scriptEdit->text();
}
int ScriptEditorWidget::scriptEditCursorLineNumber() const {
return scriptEdit->cursorLineNumber();
}
} // namespace U2
| Java |
/*
YUI 3.7.3 (build 5687)
Copyright 2012 Yahoo! Inc. All rights reserved.
Licensed under the BSD License.
http://yuilibrary.com/license/
*/
YUI.add('dom-class', function(Y) {
var addClass, hasClass, removeClass;
Y.mix(Y.DOM, {
/**
* Determines whether a DOM element has the given className.
* @method hasClass
* @for DOM
* @param {HTMLElement} element The DOM element.
* @param {String} className the class name to search for
* @return {Boolean} Whether or not the element has the given class.
*/
hasClass: function(node, className) {
var re = Y.DOM._getRegExp('(?:^|\\s+)' + className + '(?:\\s+|$)');
return re.test(node.className);
},
/**
* Adds a class name to a given DOM element.
* @method addClass
* @for DOM
* @param {HTMLElement} element The DOM element.
* @param {String} className the class name to add to the class attribute
*/
addClass: function(node, className) {
if (!Y.DOM.hasClass(node, className)) { // skip if already present
node.className = Y.Lang.trim([node.className, className].join(' '));
}
},
/**
* Removes a class name from a given element.
* @method removeClass
* @for DOM
* @param {HTMLElement} element The DOM element.
* @param {String} className the class name to remove from the class attribute
*/
removeClass: function(node, className) {
if (className && hasClass(node, className)) {
node.className = Y.Lang.trim(node.className.replace(Y.DOM._getRegExp('(?:^|\\s+)' +
className + '(?:\\s+|$)'), ' '));
if ( hasClass(node, className) ) { // in case of multiple adjacent
removeClass(node, className);
}
}
},
/**
* Replace a class with another class for a given element.
* If no oldClassName is present, the newClassName is simply added.
* @method replaceClass
* @for DOM
* @param {HTMLElement} element The DOM element
* @param {String} oldClassName the class name to be replaced
* @param {String} newClassName the class name that will be replacing the old class name
*/
replaceClass: function(node, oldC, newC) {
//Y.log('replaceClass replacing ' + oldC + ' with ' + newC, 'info', 'Node');
removeClass(node, oldC); // remove first in case oldC === newC
addClass(node, newC);
},
/**
* If the className exists on the node it is removed, if it doesn't exist it is added.
* @method toggleClass
* @for DOM
* @param {HTMLElement} element The DOM element
* @param {String} className the class name to be toggled
* @param {Boolean} addClass optional boolean to indicate whether class
* should be added or removed regardless of current state
*/
toggleClass: function(node, className, force) {
var add = (force !== undefined) ? force :
!(hasClass(node, className));
if (add) {
addClass(node, className);
} else {
removeClass(node, className);
}
}
});
hasClass = Y.DOM.hasClass;
removeClass = Y.DOM.removeClass;
addClass = Y.DOM.addClass;
}, '3.7.3' ,{requires:['dom-core']});
| Java |
import { Injectable } from '@angular/core';
import { of } from 'rxjs';
import { Resolve, ActivatedRouteSnapshot } from '@angular/router';
import { catchError } from 'rxjs/operators';
import { CatalogoService } from './catalogo.service';
@Injectable()
export class EdicaoNovoResolverService implements Resolve<any> {
constructor(private catalogoService: CatalogoService) {}
resolve(snapshot: ActivatedRouteSnapshot) {
const params = snapshot.queryParams;
return this.catalogoService.getModelo(params['id'])
.pipe(catchError((error) => of({error: error})));
}
}
| Java |
package agaroyun.view;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import java.util.ArrayList;
import javax.swing.JPanel;
import agaroyun.Model.GameObject;
import agaroyun.Model.Player;
/**
* draws GameObjects to panel
* @author varyok
* @version 1.0
*/
public class GamePanel extends JPanel {
private ArrayList<GameObject> gameObjects;
/**
* Keeps gameObjects ArrayList
* @param gameObjects
*/
public GamePanel(ArrayList<GameObject> gameObjects) {
this.gameObjects=gameObjects;
}
/**
* draws GameObjects to panel
*/
@Override
protected synchronized void paintComponent(Graphics g) {
super.paintComponent(g);
Graphics2D g2d=(Graphics2D)g; //Graphics 2d daha fazla özellik sağlayabilir. daha kolaydır
for (GameObject gameObject : gameObjects) {
gameObject.draw(g2d);
}
}
}
| Java |
package net.sf.memoranda.util;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import net.sf.memoranda.ui.AppFrame;
/**
* <p>
* Title:
* </p>
* <p>
* Description:
* </p>
* <p>
* Copyright: Copyright (c) 2002
* </p>
* <p>
* Company:
* </p>
*
* @author unascribed
* @version 1.0
*/
/* $Id: Context.java,v 1.3 2004/01/30 12:17:42 alexeya Exp $ */
public class Context {
public static LoadableProperties context = new LoadableProperties();
static {
CurrentStorage.get().restoreContext();
AppFrame.addExitListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
CurrentStorage.get().storeContext();
}
});
}
public static Object get(Object key) {
return context.get(key);
}
public static void put(Object key, Object value) {
context.put(key, value);
}
} | Java |
## 1.8.0 (September 2015)
- New MATERIAL DESIGN theme
- Updated FILE TYPE ICONS
- Preview TXT files within the app
- COPY files & folders
- Preview the full file/folder name from the long press menu
- Set a file as FAVORITE (kept-in-sync) from the CONTEXT MENU
- Updated CONFLICT RESOLUTION dialog (wording)
- Images with TRANSPARENT background are previewed correctly
- Hidden files are not taken into account for enforcing or not the list VIEW
- Several bugs fixed
## 1.7.2 (July 2015)
- New navigation drawer
- Improved Passcode
- Automatic grid view just for folders full of images
- More characters allowed in file names
- Support for servers in same domain, different path
- Bugs fixed:
+ Frequent crashes in folder with several images
+ Sync error in servers with huge quota and external storage enable
+ Share by link error
+ Some other crashes and minor bugs
## 1.7.1 (April 2015)
- Share link even with password enforced by server
- Get the app ready for oc 8.1 servers
- Added option to create new folder in uploads from external apps
- Improved management of deleted users
- Bugs fixed
+ Fixed crash on Android 2.x devices
+ Improvements on uploads
## 1.7.0 (February 2015)
- Download full folders
- Grid view for images
- Remote thumbnails (OC Server 8.0+)
- Added number of files and folders at the end of the list
- "Open with" in contextual menu
- Downloads added to Media Provider
- Uploads:
+ Local thumbnails in section "Files"
+ Multiple selection in "Content from other apps" (Android 4.3+)
- Gallery:
+ proper handling of EXIF
+ obey sorting in the list of files
- Settings view updated
- Improved subjects in e-mails
- Bugs fixed
| Java |
joomla_wisco_p
==============
joomla .wisco.templates
| Java |
#ifndef SPRINGLOBBY_HEADERGUARD_USER_H
#define SPRINGLOBBY_HEADERGUARD_USER_H
#include <wx/string.h>
#include <wx/colour.h>
#include "utils/mixins.hh"
class Server;
const unsigned int SYNC_UNKNOWN = 0;
const unsigned int SYNC_SYNCED = 1;
const unsigned int SYNC_UNSYNCED = 2;
//! @brief Struct used to store a client's status.
struct UserStatus
{
enum RankContainer
{
RANK_1,
RANK_2,
RANK_3,
RANK_4,
RANK_5,
RANK_6,
RANK_7,
RANK_8
};
bool in_game;
bool away;
RankContainer rank;
bool moderator;
bool bot;
UserStatus(): in_game(false), away(false), rank(RANK_1), moderator(false), bot(false) {}
wxString GetDiffString ( const UserStatus& other ) const;
};
struct UserPosition
{
int x;
int y;
UserPosition(): x(-1), y(-1) {}
};
struct UserBattleStatus
{
//!!! when adding something to this struct, also modify User::UpdateBattleStatus() !!
// total 17 members here
int team;
int ally;
wxColour colour;
int color_index;
int handicap;
int side;
unsigned int sync;
bool spectator;
bool ready;
bool isfromdemo;
UserPosition pos; // for startpos = 4
// bot-only stuff
wxString owner;
wxString aishortname;
wxString airawname;
wxString aiversion;
int aitype;
// for nat holepunching
wxString ip;
unsigned int udpport;
wxString scriptPassword;
bool IsBot() const { return !aishortname.IsEmpty(); }
UserBattleStatus(): team(0),ally(0),colour(wxColour(0,0,0)),color_index(-1),handicap(0),side(0),sync(SYNC_UNKNOWN),spectator(false),ready(false), isfromdemo(false), aitype(-1), udpport(0) {}
bool operator == ( const UserBattleStatus& s ) const
{
return ( ( team == s.team ) && ( colour == s.colour ) && ( handicap == s.handicap ) && ( side == s.side ) && ( sync == s.sync ) && ( spectator == s.spectator ) && ( ready == s.ready ) && ( owner == s.owner ) && ( aishortname == s.aishortname ) && ( isfromdemo == s.isfromdemo ) && ( aitype == s.aitype ) );
}
bool operator != ( const UserBattleStatus& s ) const
{
return ( ( team != s.team ) || ( colour != s.colour ) || ( handicap != s.handicap ) || ( side != s.side ) || ( sync != s.sync ) || ( spectator != s.spectator ) || ( ready != s.ready ) || ( owner != s.owner ) || ( aishortname != s.aishortname ) || ( isfromdemo != s.isfromdemo ) || ( aitype != s.aitype ) );
}
};
class ChatPanel;
class Battle;
struct UiUserData {
UiUserData(): panel(0) {}
ChatPanel* panel;
};
//! parent class leaving out server related functionality
class CommonUser
{
public:
CommonUser(const wxString& nick, const wxString& country, const int& cpu)
: m_nick(wxString(nick)), m_country(wxString(country)), m_cpu(cpu) {}
virtual ~CommonUser(){}
const wxString& GetNick() const { return m_nick; }
virtual void SetNick( const wxString& nick ) { m_nick = nick; }
const wxString& GetCountry() const { return m_country; }
virtual void SetCountry( const wxString& country ) { m_country = country; }
int GetCpu() const { return m_cpu; }
void SetCpu( const int& cpu ) { m_cpu = cpu; }
const wxString& GetID() const { return m_id; }
void SetID( const wxString& id ) { m_id = id; }
UserStatus& Status() { return m_status; }
UserStatus GetStatus() const { return m_status; }
virtual void SetStatus( const UserStatus& status );
UserBattleStatus& BattleStatus() { return m_bstatus; }
UserBattleStatus GetBattleStatus() const { return m_bstatus; }
/** Read-only variant of BattleStatus() above.
*/
const UserBattleStatus&
BattleStatus() const {
return m_bstatus;
}
//void SetBattleStatus( const UserBattleStatus& status );/// dont use this to avoid overwriting data like ip and port, use following method.
void UpdateBattleStatus( const UserBattleStatus& status );
/* void SetUserData( void* userdata ) { m_data = userdata; }
void* GetUserData() { return m_data; }*/
bool Equals( const CommonUser& other ) const { return ( m_nick == other.GetNick() ); }
protected:
wxString m_nick;
wxString m_country;
wxString m_id;
int m_cpu;
UserStatus m_status;
UserBattleStatus m_bstatus;
//void* m_data;
};
//! Class containing all the information about a user
class User : public CommonUser
{
public:
mutable UiUserData uidata;
User( Server& serv );
User( const wxString& nick, Server& serv );
User( const wxString& nick, const wxString& country, const int& cpu, Server& serv);
User( const wxString& nick );
User( const wxString& nick, const wxString& country, const int& cpu );
User();
virtual ~User();
// User interface
Server& GetServer() const { return *m_serv; }
void Said( const wxString& message ) const;
void Say( const wxString& message ) const;
void DoAction( const wxString& message ) const;
Battle* GetBattle() const;
void SetBattle( Battle* battle );
void SendMyUserStatus() const;
void SetStatus( const UserStatus& status );
void SetCountry( const wxString& country );
bool ExecuteSayCommand( const wxString& cmd ) const;
static wxString GetRankName(UserStatus::RankContainer rank);
float GetBalanceRank();
UserStatus::RankContainer GetRank();
wxString GetClan();
int GetFlagIconIndex() const { return m_flagicon_idx; }
int GetRankIconIndex() const { return m_rankicon_idx; }
int GetStatusIconIndex() const { return m_statusicon_idx; }
//bool operator< ( const User& other ) const { return m_nick < other.GetNick() ; }
//User& operator= ( const User& other );
int GetSideiconIndex() const { return m_sideicon_idx; }
void SetSideiconIndex( const int idx ) { m_sideicon_idx = idx; }
protected:
// User variables
Server* m_serv;
Battle* m_battle;
int m_flagicon_idx;
int m_rankicon_idx;
int m_statusicon_idx;
int m_sideicon_idx;
//! copy-semantics?
};
#endif // SPRINGLOBBY_HEADERGUARD_USER_H
/**
This file is part of SpringLobby,
Copyright (C) 2007-2011
SpringLobby is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License version 2 as published by
the Free Software Foundation.
SpringLobby is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with SpringLobby. If not, see <http://www.gnu.org/licenses/>.
**/
| Java |
<?php
/**
*
*
* Created on Jan 4, 2008
*
* Copyright © 2008 Yuri Astrakhan <Firstname><Lastname>@gmail.com,
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
* http://www.gnu.org/copyleft/gpl.html
*
* @file
*/
/**
* API module to allow users to watch a page
*
* @ingroup API
*/
class ApiWatch extends ApiBase {
public function __construct( $main, $action ) {
parent::__construct( $main, $action );
}
public function execute() {
$user = $this->getUser();
if ( !$user->isLoggedIn() ) {
$this->dieUsage( 'You must be logged-in to have a watchlist', 'notloggedin' );
}
$params = $this->extractRequestParams();
$title = Title::newFromText( $params['title'] );
if ( !$title || $title->getNamespace() < 0 ) {
$this->dieUsageMsg( array( 'invalidtitle', $params['title'] ) );
}
$res = array( 'title' => $title->getPrefixedText() );
if ( $params['unwatch'] ) {
$res['unwatched'] = '';
$res['message'] = wfMsgExt( 'removedwatchtext', array( 'parse' ), $title->getPrefixedText() );
$success = UnwatchAction::doUnwatch( $title, $user );
} else {
$res['watched'] = '';
$res['message'] = wfMsgExt( 'addedwatchtext', array( 'parse' ), $title->getPrefixedText() );
$success = WatchAction::doWatch( $title, $user );
}
if ( !$success ) {
$this->dieUsageMsg( 'hookaborted' );
}
$this->getResult()->addValue( null, $this->getModuleName(), $res );
}
public function mustBePosted() {
return true;
}
public function isWriteMode() {
return true;
}
public function needsToken() {
return true;
}
public function getTokenSalt() {
return 'watch';
}
public function getAllowedParams() {
return array(
'title' => array(
ApiBase::PARAM_TYPE => 'string',
ApiBase::PARAM_REQUIRED => true
),
'unwatch' => false,
'token' => null,
);
}
public function getParamDescription() {
return array(
'title' => 'The page to (un)watch',
'unwatch' => 'If set the page will be unwatched rather than watched',
'token' => 'A token previously acquired via prop=info',
);
}
public function getDescription() {
return 'Add or remove a page from/to the current user\'s watchlist';
}
public function getPossibleErrors() {
return array_merge( parent::getPossibleErrors(), array(
array( 'code' => 'notloggedin', 'info' => 'You must be logged-in to have a watchlist' ),
array( 'invalidtitle', 'title' ),
array( 'hookaborted' ),
) );
}
public function getExamples() {
return array(
'api.php?action=watch&title=Main_Page' => 'Watch the page "Main Page"',
'api.php?action=watch&title=Main_Page&unwatch=' => 'Unwatch the page "Main Page"',
);
}
public function getHelpUrls() {
return 'https://www.mediawiki.org/wiki/API:Watch';
}
public function getVersion() {
return __CLASS__ . ': $Id$';
}
}
| Java |
/* -*- c -*- */
/* $Id: sha.h 6172 2011-03-27 12:40:30Z cher $ */
#ifndef __SHA_H__
#define __SHA_H__ 1
/*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/* This file is taken from textutils-2.1. Cher. */
/* sha.h - Declaration of functions and datatypes for SHA1 sum computing
library functions.
Copyright (C) 1999, Scott G. Miller
*/
#include "reuse_integral.h"
#include <stdio.h>
/* Structure to save state of computation between the single steps. */
struct sha_ctx
{
ruint32_t A;
ruint32_t B;
ruint32_t C;
ruint32_t D;
ruint32_t E;
ruint32_t total[2];
ruint32_t buflen;
char buffer[128];
};
/* Starting with the result of former calls of this function (or the
initialization function update the context for the next LEN bytes
starting at BUFFER.
It is necessary that LEN is a multiple of 64!!! */
void sha_process_block(const void *buffer, size_t len, struct sha_ctx *ctx);
/* Starting with the result of former calls of this function (or the
initialization function update the context for the next LEN bytes
starting at BUFFER.
It is NOT required that LEN is a multiple of 64. */
void sha_process_bytes(const void *buffer, size_t len, struct sha_ctx *ctx);
/* Initialize structure containing state of computation. */
void sha_init_ctx(struct sha_ctx *ctx);
/* Process the remaining bytes in the buffer and put result from CTX
in first 20 bytes following RESBUF. The result is always in little
endian byte order, so that a byte-wise output yields to the wanted
ASCII representation of the message digest.
IMPORTANT: On some systems it is required that RESBUF is correctly
aligned for a 32 bits value. */
void *sha_finish_ctx(struct sha_ctx *ctx, void *resbuf);
/* Put result from CTX in first 20 bytes following RESBUF. The result is
always in little endian byte order, so that a byte-wise output yields
to the wanted ASCII representation of the message digest.
IMPORTANT: On some systems it is required that RESBUF is correctly
aligned for a 32 bits value. */
void *sha_read_ctx(const struct sha_ctx *ctx, void *resbuf);
/* Compute SHA1 message digest for bytes read from STREAM. The
resulting message digest number will be written into the 20 bytes
beginning at RESBLOCK. */
int sha_stream(FILE *stream, void *resblock);
/* Compute SHA1 message digest for LEN bytes beginning at BUFFER. The
result is always in little endian byte order, so that a byte-wise
output yields to the wanted ASCII representation of the message
digest. */
void *sha_buffer(const char *buffer, size_t len, void *resblock);
#endif /* __SHA_H__ */
| Java |
/* SET.C - performing :set - command
*
* NOTE: Edit this file with tabstop=4 !
*
* 1996-02-29 created;
* 1998-03-14 V 1.0.1
* 1999-01-14 V 1.1.0
* 1999-03-17 V 1.1.1
* 1999-07-02 V 1.2.0 beta
* 1999-08-14 V 1.2.0 final
* 2000-07-15 V 1.3.0 final
* 2001-10-10 V 1.3.1
* 2003-07-03 V 1.3.2
*
* Copyright 1996-2003 by Gerhard Buergmann
* gerhard@puon.at
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2, or (at your option) any
* later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* See file COPYING for information on distribution conditions.
*/
#include "bvi.h"
#include "set.h"
extern struct BLOCK_ data_block[BLK_COUNT];
static int from_file = 0;
static FILE *ffp;
static char fbuf[256];
static char buf[64];
struct {
short r;
short g;
short b;
} original_colors[8];
struct {
short f;
short b;
} original_colorpairs[8];
struct param params[] = {
{"autowrite", "aw", FALSE, "", P_BOOL},
{"columns", "cm", 16, "", P_NUM},
{"errorbells", "eb", FALSE, "", P_BOOL},
{"ignorecase", "ic", FALSE, "", P_BOOL},
{"magic", "ma", TRUE, "", P_BOOL},
{"memmove", "mm", FALSE, "", P_BOOL},
{"offset", "of", 0, "", P_NUM},
{"readonly", "ro", FALSE, "", P_BOOL},
{"scroll", "scroll", 12, "", P_NUM},
{"showmode", "mo", TRUE, "", P_BOOL},
{"term", "term", 0, "", P_TEXT},
{"terse", "terse", FALSE, "", P_BOOL},
{"unixstyle", "us", FALSE, "", P_BOOL},
{"window", "window", 25, "", P_NUM},
{"wordlength", "wl", 4, "", P_NUM},
{"wrapscan", "ws", TRUE, "", P_BOOL},
{"", "", 0, "", 0,} /* end marker */
};
struct color colors[] = { /* RGB definitions and default value, if have no support of 256 colors */
{"background", "bg", 50, 50, 50, COLOR_BLACK},
{"addresses", "addr", 335, 506, 700, COLOR_BLUE},
{"hex", "hex", 600, 600, 600, COLOR_MAGENTA},
{"data", "data", 0, 800, 400, COLOR_GREEN},
{"error", "err", 999, 350, 0, COLOR_RED},
{"status", "stat", 255, 255, 255, COLOR_WHITE},
{"command", "comm", 255, 255, 255, COLOR_WHITE},
{"window", "win", 0, 800, 900, COLOR_YELLOW},
{"addrbg", "addrbg", 0, 0, 0, COLOR_CYAN},
{"", "", 0, 0, 0, 0} /* end marker */
};
int doset(arg)
char *arg; /* parameter string */
{
int i;
char *s;
int did_window = FALSE;
int state = TRUE; /* new state of boolean parms. */
char string[80];
if (arg == NULL) {
showparms(FALSE);
return 0;
}
if (!strcmp(arg, "all")) {
showparms(TRUE);
return 0;
}
if (!strncmp(arg, "no", 2)) {
state = FALSE;
arg += 2;
}
/* extract colors section */
if (!strncmp(arg, "color", 5)) {
arg = substr(arg, 6, -1);
for (i = 0; colors[i].fullname[0] != '\0'; i++) {
s = colors[i].fullname;
if (strncmp(arg, s, strlen(s)) == 0)
break;
s = colors[i].shortname;
if (strncmp(arg, s, strlen(s)) == 0)
break;
}
if (i == 0) {
emsg("Wrong color name!");
return 0;
} else {
colors[i].r = atoi(substr(arg, strlen(s) + 1, 3));
colors[i].g = atoi(substr(arg, strlen(s) + 5, 3));
colors[i].b = atoi(substr(arg, strlen(s) + 9, 3));
set_palette();
repaint();
}
return 0;
} else {
emsg(arg);
return 1;
}
for (i = 0; params[i].fullname[0] != '\0'; i++) {
s = params[i].fullname;
if (strncmp(arg, s, strlen(s)) == 0) /* matched full name */
break;
s = params[i].shortname;
if (strncmp(arg, s, strlen(s)) == 0) /* matched short name */
break;
}
if (params[i].fullname[0] != '\0') { /* found a match */
if (arg[strlen(s)] == '?') {
if (params[i].flags & P_BOOL)
sprintf(buf, " %s%s",
(params[i].nvalue ? " " : "no"),
params[i].fullname);
else if (params[i].flags & P_TEXT)
sprintf(buf, " %s=%s", params[i].fullname,
params[i].svalue);
else
sprintf(buf, " %s=%ld", params[i].fullname,
params[i].nvalue);
msg(buf);
return 0;
}
if (!strcmp(params[i].fullname, "term")) {
emsg("Can't change type of terminal from within bvi");
return 1;
}
if (params[i].flags & P_NUM) {
if ((i == P_LI) || (i == P_OF))
did_window++;
if (arg[strlen(s)] != '=' || state == FALSE) {
sprintf(string, "Option %s is not a toggle",
params[i].fullname);
emsg(string);
return 1;
} else {
s = arg + strlen(s) + 1;
if (*s == '0') {
params[i].nvalue = strtol(s, &s, 16);
} else {
params[i].nvalue = strtol(s, &s, 10);
}
params[i].flags |= P_CHANGED;
if (i == P_CM) {
if (((COLS - AnzAdd - 1) / 4) >=
P(P_CM)) {
COLUMNS_DATA = P(P_CM);
} else {
COLUMNS_DATA = P(P_CM) =
((COLS - AnzAdd - 1) / 4);
}
maxx = COLUMNS_DATA * 4 + AnzAdd + 1;
COLUMNS_HEX = COLUMNS_DATA * 3;
status = COLUMNS_HEX + COLUMNS_DATA - 17;
screen = COLUMNS_DATA * (maxy - 1);
did_window++;
stuffin("H"); /* set cursor at HOME */
}
}
} else { /* boolean */
if (arg[strlen(s)] == '=') {
emsg("Invalid set of boolean parameter");
return 1;
} else {
params[i].nvalue = state;
params[i].flags |= P_CHANGED;
}
}
} else {
emsg("No such option@- `set all' gives all option values");
return 1;
}
if (did_window) {
maxy = P(P_LI) - 1;
new_screen();
}
return 0;
}
/* show ALL parameters */
void showparms(all)
int all;
{
struct param *p;
int n;
n = 2;
msg("Parameters:\n");
for (p = ¶ms[0]; p->fullname[0] != '\0'; p++) {
if (!all && ((p->flags & P_CHANGED) == 0))
continue;
if (p->flags & P_BOOL)
sprintf(buf, " %s%s\n",
(p->nvalue ? " " : "no"), p->fullname);
else if (p->flags & P_TEXT)
sprintf(buf, " %s=%s\n", p->fullname, p->svalue);
else
sprintf(buf, " %s=%ld\n", p->fullname, p->nvalue);
msg(buf);
n++;
if (n == params[P_LI].nvalue) {
if (wait_return(FALSE))
return;
n = 1;
}
}
wait_return(TRUE);
}
void save_orig_palette()
{
int i;
for (i = 0; colors[i].fullname[0] != '\0'; i++) {
color_content(colors[i].short_value, &original_colors[i].r, &original_colors[i].g, &original_colors[i].b);
}
for (i = 1; i < 8; i++) {
pair_content(i, &original_colorpairs[i].f, &original_colorpairs[i].b);
}
}
void load_orig_palette()
{
int i;
for (i = 0; colors[i].fullname[0] != '\0'; i++) {
init_color(colors[i].short_value, original_colors[i].r, original_colors[i].g, original_colors[i].b);
}
for (i = 1; i < 8; i++) {
init_pair(i, original_colorpairs[i].f, original_colorpairs[i].b);
}
}
void set_palette()
{
int i;
if (can_change_color()) {
for (i = 0; colors[i].fullname[0] != '\0'; i++) {
if (init_color
(colors[i].short_value, C_r(i), C_g(i),
C_b(i)) == ERR)
fprintf(stderr, "Failed to set [%d] color!\n",
i);
if (C_s(i) <= 7) {
init_pair(i + 1, C_s(i), C_s(0));
} else {
colors[i].short_value = COLOR_WHITE;
init_pair(i + 1, C_s(i), C_s(0));
}
}
init_pair(C_AD + 1, C_s(C_AD), COLOR_CYAN);
} else { /* if have no support of changing colors */
for (i = 0; colors[i].fullname[0] != '\0'; i++) {
if (C_s(i) <= 7) {
init_pair(i + 1, C_s(i), C_s(0));
} else {
colors[i].short_value = COLOR_WHITE;
init_pair(i + 1, C_s(i), C_s(0));
}
}
}
}
/* reads the init file (.bvirc) */
int read_rc(fn)
char *fn;
{
if ((ffp = fopen(fn, "r")) == NULL)
return -1;
from_file = 1;
while (fgets(fbuf, 255, ffp) != NULL) {
strtok(fbuf, "\n\r");
docmdline(fbuf);
}
fclose(ffp);
from_file = 0;
return 0;
}
int do_logic(mode, str)
int mode;
char *str;
{
int a, b;
int value;
size_t n;
char *err_str = "Invalid value@for bit manipulation";
if (mode == LSHIFT || mode == RSHIFT || mode == LROTATE
|| mode == RROTATE) {
value = atoi(str);
if (value < 1 || value > 8) {
emsg(err_str);
return 1;
}
} else {
if (strlen(str) == 8) {
value = strtol(str, NULL, 2);
for (n = 0; n < 8; n++) {
if (str[n] != '0' && str[n] != '1') {
value = -1;
break;
}
}
} else if (str[0] == 'b' || str[0] == 'B') {
value = strtol(str + 1, NULL, 2);
} else if (str[0] == '0') {
value = strtol(str, NULL, 16);
for (n = 0; n < strlen(str); n++) {
if (!isxdigit(str[n])) {
value = -1;
break;
}
}
} else {
value = atoi(str);
}
if (value < 0 || value > 255) {
emsg(err_str);
return 1;
}
}
if ((undo_count =
alloc_buf((off_t) (end_addr - start_addr + 1), &undo_buf))) {
memcpy(undo_buf, start_addr, undo_count);
}
undo_start = start_addr;
edits = U_EDIT;
while (start_addr <= end_addr) {
a = *start_addr;
a &= 0xff;
switch (mode) {
case LSHIFT:
a <<= value;
break;
case RSHIFT:
a >>= value;
break;
case LROTATE:
a <<= value;
b = a >> 8;
a |= b;
break;
case RROTATE:
b = a << 8;
a |= b;
a >>= value;
/*
b = a << (8 - value);
a >>= value;
a |= b;
*/
break;
case AND:
a &= value;
break;
case OR:
a |= value;
break;
case XOR:
case NOT:
a ^= value;
break;
case NEG:
a ^= value;
a++; /* Is this true */
break;
}
*start_addr++ = (char)(a & 0xff);
}
repaint();
return (0);
}
int do_logic_block(mode, str, block_number)
int mode;
char *str;
int block_number;
{
int a, b;
int value;
size_t n;
char *err_str = "Invalid value@for bit manipulation";
if ((block_number >= BLK_COUNT) & (!(data_block[block_number].pos_start < data_block[block_number].pos_end))) {
emsg("Invalid block for bit manipulation!");
return 1;
}
if (mode == LSHIFT || mode == RSHIFT || mode == LROTATE
|| mode == RROTATE) {
value = atoi(str);
if (value < 1 || value > 8) {
emsg(err_str);
return 1;
}
} else {
if (strlen(str) == 8) {
value = strtol(str, NULL, 2);
for (n = 0; n < 8; n++) {
if (str[n] != '0' && str[n] != '1') {
value = -1;
break;
}
}
} else if (str[0] == 'b' || str[0] == 'B') {
value = strtol(str + 1, NULL, 2);
} else if (str[0] == '0') {
value = strtol(str, NULL, 16);
for (n = 0; n < strlen(str); n++) {
if (!isxdigit(str[n])) {
value = -1;
break;
}
}
} else {
value = atoi(str);
}
if (value < 0 || value > 255) {
emsg(err_str);
return 1;
}
}
if ((undo_count =
alloc_buf((off_t) (data_block[block_number].pos_end -
data_block[block_number].pos_start + 1), &undo_buf))) {
memcpy(undo_buf, start_addr + data_block[block_number].pos_start, undo_count);
}
undo_start = start_addr + data_block[block_number].pos_start;
edits = U_EDIT;
start_addr = start_addr + data_block[block_number].pos_start;
end_addr = start_addr + data_block[block_number].pos_end - data_block[block_number].pos_start;
while (start_addr <= end_addr) {
a = *start_addr;
a &= 0xff;
switch (mode) {
case LSHIFT:
a <<= value;
break;
case RSHIFT:
a >>= value;
break;
case LROTATE:
a <<= value;
b = a >> 8;
a |= b;
break;
case RROTATE:
b = a << 8;
a |= b;
a >>= value;
/*
b = a << (8 - value);
a >>= value;
a |= b;
*/
break;
case AND:
a &= value;
break;
case OR:
a |= value;
break;
case XOR:
case NOT:
a ^= value;
break;
case NEG:
a ^= value;
a++; /* Is this true */
break;
}
*start_addr++ = (char)(a & 0xff);
}
repaint();
return (0);
}
int getcmdstr(p, x)
char *p;
int x;
{
int c;
int n;
char *buff, *q;
attron(COLOR_PAIR(C_CM + 1));
if (from_file) {
if (fgets(p, 255, ffp) != NULL) {
strtok(p, "\n\r");
return 0;
} else {
return 1;
}
}
signal(SIGINT, jmpproc);
buff = p;
move(maxy, x);
do {
switch (c = vgetc()) {
case BVICTRL('H'):
case KEY_BACKSPACE:
case KEY_LEFT:
if (p > buff) {
p--;
move(maxy, x);
n = x;
for (q = buff; q < p; q++) {
addch(*q);
n++;
}
addch(' ');
move(maxy, n);
} else {
*buff = '\0';
msg("");
attroff(COLOR_PAIR(C_CM + 1));
signal(SIGINT, SIG_IGN);
return 1;
}
break;
case ESC: /* abandon command */
*buff = '\0';
msg("");
attroff(COLOR_PAIR(C_CM + 1));
signal(SIGINT, SIG_IGN);
return 1;
#if NL != KEY_ENTER
case NL:
#endif
#if CR != KEY_ENTER
case CR:
#endif
case KEY_ENTER:
break;
default: /* a normal character */
addch(c);
*p++ = c;
break;
}
refresh();
} while (c != NL && c != CR && c != KEY_ENTER);
attroff(COLOR_PAIR(C_CM + 1));
*p = '\0';
signal(SIGINT, SIG_IGN);
return 0;
}
| Java |
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
function onCreatureAppear(cid) npcHandler:onCreatureAppear(cid) end
function onCreatureDisappear(cid) npcHandler:onCreatureDisappear(cid) end
function onCreatureSay(cid, type, msg) npcHandler:onCreatureSay(cid, type, msg) end
local lastSound = 0
function onThink()
if lastSound < os.time() then
lastSound = (os.time() + 5)
if math.random(100) < 25 then
Npc():say("Come into my tavern and share some stories!", TALKTYPE_SAY)
end
end
npcHandler:onThink()
end
npcHandler:setMessage(MESSAGE_GREET, "Welcome to Frodo's Hut. You heard about the {news}?")
npcHandler:setMessage(MESSAGE_FAREWELL, "Please come back from time to time.")
npcHandler:setMessage(MESSAGE_WALKAWAY, "Please come back from time to time.")
npcHandler:addModule(FocusModule:new())
| Java |
/* coff object file format
Copyright 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2009
Free Software Foundation, Inc.
This file is part of GAS.
GAS is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3, or (at your option)
any later version.
GAS is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with GAS; see the file COPYING. If not, write to the Free
Software Foundation, 51 Franklin Street - Fifth Floor, Boston, MA
02110-1301, USA. */
#ifndef OBJ_FORMAT_H
#define OBJ_FORMAT_H
#define OBJ_COFF 1
#include "targ-cpu.h"
/* This internal_lineno crap is to stop namespace pollution from the
bfd internal coff headerfile. */
#define internal_lineno bfd_internal_lineno
#include "coff/internal.h"
#undef internal_lineno
/* CPU-specific setup: */
#ifdef TC_ARM
#include "coff/arm.h"
#ifndef TARGET_FORMAT
#define TARGET_FORMAT "coff-arm"
#endif
#endif
#ifdef TC_PPC
#ifdef TE_PE
#include "coff/powerpc.h"
#else
#include "coff/rs6000.h"
#endif
#endif
#ifdef TC_SPARC
#include "coff/sparc.h"
#endif
#ifdef TC_I386
#ifdef TE_PEP
#include "coff/x86_64.h"
#else
#include "coff/i386.h"
#endif
#ifndef TARGET_FORMAT
#ifdef TE_PEP
#define TARGET_FORMAT "coff-x86-64"
#else
#define TARGET_FORMAT "coff-i386"
#endif
#endif
#endif
#ifdef TC_M68K
#include "coff/m68k.h"
#ifndef TARGET_FORMAT
#define TARGET_FORMAT "coff-m68k"
#endif
#endif
#ifdef TC_OR32
#include "coff/or32.h"
#define TARGET_FORMAT "coff-or32-big"
#endif
#ifdef TC_I960
#include "coff/i960.h"
#define TARGET_FORMAT "coff-Intel-little"
#endif
#ifdef TC_Z80
#include "coff/z80.h"
#define TARGET_FORMAT "coff-z80"
#endif
#ifdef TC_Z8K
#include "coff/z8k.h"
#define TARGET_FORMAT "coff-z8k"
#endif
#ifdef TC_H8300
#include "coff/h8300.h"
#define TARGET_FORMAT "coff-h8300"
#endif
#ifdef TC_H8500
#include "coff/h8500.h"
#define TARGET_FORMAT "coff-h8500"
#endif
#ifdef TC_SH
#ifdef TE_PE
#define COFF_WITH_PE
#endif
#include "coff/sh.h"
#ifdef TE_PE
#define TARGET_FORMAT "pe-shl"
#else
#define TARGET_FORMAT \
(!target_big_endian \
? (sh_small ? "coff-shl-small" : "coff-shl") \
: (sh_small ? "coff-sh-small" : "coff-sh"))
#endif
#endif
#ifdef TC_MIPS
#define COFF_WITH_PE
#include "coff/mipspe.h"
#undef TARGET_FORMAT
#define TARGET_FORMAT "pe-mips"
#endif
#ifdef TC_TIC30
#include "coff/tic30.h"
#define TARGET_FORMAT "coff-tic30"
#endif
#ifdef TC_TIC4X
#include "coff/tic4x.h"
#define TARGET_FORMAT "coff2-tic4x"
#endif
#ifdef TC_TIC54X
#include "coff/tic54x.h"
#define TARGET_FORMAT "coff1-c54x"
#endif
#ifdef TC_TIC6X
#include "coff/tic6x.h"
//#define TARGET_FORMAT "coff2-c6x"
#endif
#ifdef TC_MCORE
#include "coff/mcore.h"
#ifndef TARGET_FORMAT
#define TARGET_FORMAT "pe-mcore"
#endif
#endif
#ifdef TE_PE
#define obj_set_weak_hook pecoff_obj_set_weak_hook
#define obj_clear_weak_hook pecoff_obj_clear_weak_hook
#endif
#ifndef OBJ_COFF_MAX_AUXENTRIES
#define OBJ_COFF_MAX_AUXENTRIES 1
#endif
#define obj_symbol_new_hook coff_obj_symbol_new_hook
#define obj_symbol_clone_hook coff_obj_symbol_clone_hook
#define obj_read_begin_hook coff_obj_read_begin_hook
#include "bfd/libcoff.h"
#define OUTPUT_FLAVOR bfd_target_coff_flavour
/* Alter the field names, for now, until we've fixed up the other
references to use the new name. */
#ifdef TC_I960
#define TC_SYMFIELD_TYPE symbolS *
#define sy_tc bal
#endif
#define OBJ_SYMFIELD_TYPE unsigned long
#define sy_obj sy_obj_flags
/* We can't use the predefined section symbols in bfd/section.c, as
COFF symbols have extra fields. See bfd/libcoff.h:coff_symbol_type. */
#ifndef obj_sec_sym_ok_for_reloc
#define obj_sec_sym_ok_for_reloc(SEC) ((SEC)->owner != 0)
#endif
#define SYM_AUXENT(S) \
(&coffsymbol (symbol_get_bfdsym (S))->native[1].u.auxent)
#define SYM_AUXINFO(S) \
(&coffsymbol (symbol_get_bfdsym (S))->native[1])
/* The number of auxiliary entries. */
#define S_GET_NUMBER_AUXILIARY(s) \
(coffsymbol (symbol_get_bfdsym (s))->native->u.syment.n_numaux)
/* The number of auxiliary entries. */
#define S_SET_NUMBER_AUXILIARY(s, v) (S_GET_NUMBER_AUXILIARY (s) = (v))
/* True if a symbol name is in the string table, i.e. its length is > 8. */
#define S_IS_STRING(s) (strlen (S_GET_NAME (s)) > 8 ? 1 : 0)
/* Auxiliary entry macros. SA_ stands for symbol auxiliary. */
/* Omit the tv related fields. */
/* Accessors. */
#define SA_GET_SYM_TAGNDX(s) (SYM_AUXENT (s)->x_sym.x_tagndx.l)
#define SA_GET_SYM_LNNO(s) (SYM_AUXENT (s)->x_sym.x_misc.x_lnsz.x_lnno)
#define SA_GET_SYM_SIZE(s) (SYM_AUXENT (s)->x_sym.x_misc.x_lnsz.x_size)
#define SA_GET_SYM_FSIZE(s) (SYM_AUXENT (s)->x_sym.x_misc.x_fsize)
#define SA_GET_SYM_LNNOPTR(s) (SYM_AUXENT (s)->x_sym.x_fcnary.x_fcn.x_lnnoptr)
#define SA_GET_SYM_ENDNDX(s) (SYM_AUXENT (s)->x_sym.x_fcnary.x_fcn.x_endndx)
#define SA_GET_SYM_DIMEN(s,i) (SYM_AUXENT (s)->x_sym.x_fcnary.x_ary.x_dimen[(i)])
#define SA_GET_FILE_FNAME(s) (SYM_AUXENT (s)->x_file.x_fname)
#define SA_GET_SCN_SCNLEN(s) (SYM_AUXENT (s)->x_scn.x_scnlen)
#define SA_GET_SCN_NRELOC(s) (SYM_AUXENT (s)->x_scn.x_nreloc)
#define SA_GET_SCN_NLINNO(s) (SYM_AUXENT (s)->x_scn.x_nlinno)
#define SA_SET_SYM_LNNO(s,v) (SYM_AUXENT (s)->x_sym.x_misc.x_lnsz.x_lnno = (v))
#define SA_SET_SYM_SIZE(s,v) (SYM_AUXENT (s)->x_sym.x_misc.x_lnsz.x_size = (v))
#define SA_SET_SYM_FSIZE(s,v) (SYM_AUXENT (s)->x_sym.x_misc.x_fsize = (v))
#define SA_SET_SYM_LNNOPTR(s,v) (SYM_AUXENT (s)->x_sym.x_fcnary.x_fcn.x_lnnoptr = (v))
#define SA_SET_SYM_DIMEN(s,i,v) (SYM_AUXENT (s)->x_sym.x_fcnary.x_ary.x_dimen[(i)] = (v))
#define SA_SET_FILE_FNAME(s,v) strncpy (SYM_AUXENT (s)->x_file.x_fname, (v), FILNMLEN)
#define SA_SET_SCN_SCNLEN(s,v) (SYM_AUXENT (s)->x_scn.x_scnlen = (v))
#define SA_SET_SCN_NRELOC(s,v) (SYM_AUXENT (s)->x_scn.x_nreloc = (v))
#define SA_SET_SCN_NLINNO(s,v) (SYM_AUXENT (s)->x_scn.x_nlinno = (v))
/* Internal use only definitions. SF_ stands for symbol flags.
These values can be assigned to sy_symbol.ost_flags field of a symbolS.
You'll break i960 if you shift the SYSPROC bits anywhere else. for
more on the balname/callname hack, see tc-i960.h. b.out is done
differently. */
#define SF_I960_MASK 0x000001ff /* Bits 0-8 are used by the i960 port. */
#define SF_SYSPROC 0x0000003f /* bits 0-5 are used to store the sysproc number. */
#define SF_IS_SYSPROC 0x00000040 /* bit 6 marks symbols that are sysprocs. */
#define SF_BALNAME 0x00000080 /* bit 7 marks BALNAME symbols. */
#define SF_CALLNAME 0x00000100 /* bit 8 marks CALLNAME symbols. */
#define SF_NORMAL_MASK 0x0000ffff /* bits 12-15 are general purpose. */
#define SF_STATICS 0x00001000 /* Mark the .text & all symbols. */
#define SF_DEFINED 0x00002000 /* Symbol is defined in this file. */
#define SF_STRING 0x00004000 /* Symbol name length > 8. */
#define SF_LOCAL 0x00008000 /* Symbol must not be emitted. */
#define SF_DEBUG_MASK 0xffff0000 /* bits 16-31 are debug info. */
#define SF_FUNCTION 0x00010000 /* The symbol is a function. */
#define SF_PROCESS 0x00020000 /* Process symbol before write. */
#define SF_TAGGED 0x00040000 /* Is associated with a tag. */
#define SF_TAG 0x00080000 /* Is a tag. */
#define SF_DEBUG 0x00100000 /* Is in debug or abs section. */
#define SF_GET_SEGMENT 0x00200000 /* Get the section of the forward symbol. */
/* All other bits are unused. */
/* Accessors. */
#define SF_GET(s) (* symbol_get_obj (s))
#define SF_GET_DEBUG(s) (symbol_get_bfdsym (s)->flags & BSF_DEBUGGING)
#define SF_SET_DEBUG(s) (symbol_get_bfdsym (s)->flags |= BSF_DEBUGGING)
#define SF_GET_NORMAL_FIELD(s) (SF_GET (s) & SF_NORMAL_MASK)
#define SF_GET_DEBUG_FIELD(s) (SF_GET (s) & SF_DEBUG_MASK)
#define SF_GET_FILE(s) (SF_GET (s) & SF_FILE)
#define SF_GET_STATICS(s) (SF_GET (s) & SF_STATICS)
#define SF_GET_DEFINED(s) (SF_GET (s) & SF_DEFINED)
#define SF_GET_STRING(s) (SF_GET (s) & SF_STRING)
#define SF_GET_LOCAL(s) (SF_GET (s) & SF_LOCAL)
#define SF_GET_FUNCTION(s) (SF_GET (s) & SF_FUNCTION)
#define SF_GET_PROCESS(s) (SF_GET (s) & SF_PROCESS)
#define SF_GET_TAGGED(s) (SF_GET (s) & SF_TAGGED)
#define SF_GET_TAG(s) (SF_GET (s) & SF_TAG)
#define SF_GET_GET_SEGMENT(s) (SF_GET (s) & SF_GET_SEGMENT)
#define SF_GET_I960(s) (SF_GET (s) & SF_I960_MASK) /* Used by i960. */
#define SF_GET_BALNAME(s) (SF_GET (s) & SF_BALNAME) /* Used by i960. */
#define SF_GET_CALLNAME(s) (SF_GET (s) & SF_CALLNAME) /* Used by i960. */
#define SF_GET_IS_SYSPROC(s) (SF_GET (s) & SF_IS_SYSPROC) /* Used by i960. */
#define SF_GET_SYSPROC(s) (SF_GET (s) & SF_SYSPROC) /* Used by i960. */
/* Modifiers. */
#define SF_SET(s,v) (SF_GET (s) = (v))
#define SF_SET_NORMAL_FIELD(s,v)(SF_GET (s) |= ((v) & SF_NORMAL_MASK))
#define SF_SET_DEBUG_FIELD(s,v) (SF_GET (s) |= ((v) & SF_DEBUG_MASK))
#define SF_SET_FILE(s) (SF_GET (s) |= SF_FILE)
#define SF_SET_STATICS(s) (SF_GET (s) |= SF_STATICS)
#define SF_SET_DEFINED(s) (SF_GET (s) |= SF_DEFINED)
#define SF_SET_STRING(s) (SF_GET (s) |= SF_STRING)
#define SF_SET_LOCAL(s) (SF_GET (s) |= SF_LOCAL)
#define SF_CLEAR_LOCAL(s) (SF_GET (s) &= ~SF_LOCAL)
#define SF_SET_FUNCTION(s) (SF_GET (s) |= SF_FUNCTION)
#define SF_SET_PROCESS(s) (SF_GET (s) |= SF_PROCESS)
#define SF_SET_TAGGED(s) (SF_GET (s) |= SF_TAGGED)
#define SF_SET_TAG(s) (SF_GET (s) |= SF_TAG)
#define SF_SET_GET_SEGMENT(s) (SF_GET (s) |= SF_GET_SEGMENT)
#define SF_SET_I960(s,v) (SF_GET (s) |= ((v) & SF_I960_MASK)) /* Used by i960. */
#define SF_SET_BALNAME(s) (SF_GET (s) |= SF_BALNAME) /* Used by i960. */
#define SF_SET_CALLNAME(s) (SF_GET (s) |= SF_CALLNAME) /* Used by i960. */
#define SF_SET_IS_SYSPROC(s) (SF_GET (s) |= SF_IS_SYSPROC) /* Used by i960. */
#define SF_SET_SYSPROC(s,v) (SF_GET (s) |= ((v) & SF_SYSPROC)) /* Used by i960. */
/* Line number handling. */
extern int text_lineno_number;
extern int coff_line_base;
extern int coff_n_line_nos;
extern symbolS *coff_last_function;
#define obj_emit_lineno(WHERE, LINE, FILE_START) abort ()
#define obj_app_file(name, app) c_dot_file_symbol (name, app)
#define obj_frob_symbol(S,P) coff_frob_symbol (S, & P)
#define obj_frob_section(S) coff_frob_section (S)
#define obj_frob_file_after_relocs() coff_frob_file_after_relocs ()
#ifndef obj_adjust_symtab
#define obj_adjust_symtab() coff_adjust_symtab ()
#endif
/* Forward the segment of a forwarded symbol, handle assignments that
just copy symbol values, etc. */
#ifndef OBJ_COPY_SYMBOL_ATTRIBUTES
#ifndef TE_I386AIX
#define OBJ_COPY_SYMBOL_ATTRIBUTES(dest, src) \
(SF_GET_GET_SEGMENT (dest) \
? (S_SET_SEGMENT (dest, S_GET_SEGMENT (src)), 0) \
: 0)
#else
#define OBJ_COPY_SYMBOL_ATTRIBUTES(dest, src) \
(SF_GET_GET_SEGMENT (dest) && S_GET_SEGMENT (dest) == SEG_UNKNOWN \
? (S_SET_SEGMENT (dest, S_GET_SEGMENT (src)), 0) \
: 0)
#endif
#endif
/* Sanity check. */
#ifdef TC_I960
#ifndef C_LEAFSTAT
hey ! Where is the C_LEAFSTAT definition ? i960 - coff support is depending on it.
#endif /* no C_LEAFSTAT */
#endif /* TC_I960 */
extern const pseudo_typeS coff_pseudo_table[];
#ifndef obj_pop_insert
#define obj_pop_insert() pop_insert (coff_pseudo_table)
#endif
/* In COFF, if a symbol is defined using .def/.val SYM/.endef, it's OK
to redefine the symbol later on. This can happen if C symbols use
a prefix, and a symbol is defined both with and without the prefix,
as in start/_start/__start in gcc/libgcc1-test.c. */
#define RESOLVE_SYMBOL_REDEFINITION(sym) \
(SF_GET_GET_SEGMENT (sym) \
? (sym->sy_frag = frag_now, \
S_SET_VALUE (sym, frag_now_fix ()), \
S_SET_SEGMENT (sym, now_seg), \
0) \
: 0)
/* Stabs in a coff file go into their own section. */
#define SEPARATE_STAB_SECTIONS 1
/* We need 12 bytes at the start of the section to hold some initial
information. */
#define INIT_STAB_SECTION(seg) obj_coff_init_stab_section (seg)
/* Store the number of relocations in the section aux entry. */
#define SET_SECTION_RELOCS(sec, relocs, n) \
SA_SET_SCN_NRELOC (section_symbol (sec), n)
#define obj_app_file(name, app) c_dot_file_symbol (name, app)
extern int S_SET_DATA_TYPE (symbolS *, int);
extern int S_SET_STORAGE_CLASS (symbolS *, int);
extern int S_GET_STORAGE_CLASS (symbolS *);
extern void SA_SET_SYM_ENDNDX (symbolS *, symbolS *);
extern void coff_add_linesym (symbolS *);
extern void c_dot_file_symbol (const char *, int);
extern void coff_frob_symbol (symbolS *, int *);
extern void coff_adjust_symtab (void);
extern void coff_frob_section (segT);
extern void coff_adjust_section_syms (bfd *, asection *, void *);
extern void coff_frob_file_after_relocs (void);
extern void coff_obj_symbol_new_hook (symbolS *);
extern void coff_obj_symbol_clone_hook (symbolS *, symbolS *);
extern void coff_obj_read_begin_hook (void);
#ifdef TE_PE
extern void pecoff_obj_set_weak_hook (symbolS *);
extern void pecoff_obj_clear_weak_hook (symbolS *);
#endif
extern void obj_coff_section (int);
extern segT obj_coff_add_segment (const char *);
extern void obj_coff_section (int);
extern void c_dot_file_symbol (const char *, int);
extern segT s_get_segment (symbolS *);
#ifndef tc_coff_symbol_emit_hook
extern void tc_coff_symbol_emit_hook (symbolS *);
#endif
extern void obj_coff_pe_handle_link_once (void);
extern void obj_coff_init_stab_section (segT);
extern void c_section_header (struct internal_scnhdr *,
char *, long, long, long, long,
long, long, long, long);
extern void obj_coff_seh_do_final (void);
#ifndef obj_coff_generate_pdata
#define obj_coff_generate_pdata obj_coff_seh_do_final
#endif
#endif /* OBJ_FORMAT_H */
| Java |
/**************************************************************
* Copyright (C) 2010 STMicroelectronics. All Rights Reserved.
* This file is part of the latest release of the Multicom4 project. This release
* is fully functional and provides all of the original MME functionality.This
* release is now considered stable and ready for integration with other software
* components.
* Multicom4 is a free software; you can redistribute it and/or modify it under the
* terms of the GNU General Public License as published by the Free Software Foundation
* version 2.
* Multicom4 is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details.
* You should have received a copy of the GNU General Public License along with Multicom4;
* see the file COPYING. If not, write to the Free Software Foundation, 59 Temple Place -
* Suite 330, Boston, MA 02111-1307, USA.
* Written by Multicom team at STMicroelectronics in November 2010.
* Contact multicom.support@st.com.
**************************************************************/
/*
*
*/
/*
* sti7200 ST231 Video1
*/
#include <bsp/_bsp.h>
const char *bsp_cpu_name = "video1";
/*
* Local Variables:
* tab-width: 8
* c-indent-level: 2
* c-basic-offset: 2
* End:
*/
| Java |
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<!--NewPage-->
<HTML>
<HEAD>
<!-- Generated by javadoc (build 1.6.0_18) on Tue Nov 02 13:16:47 CET 2010 -->
<TITLE>
Filter
</TITLE>
<META NAME="date" CONTENT="2010-11-02">
<LINK REL ="stylesheet" TYPE="text/css" HREF="../../../../../../stylesheet.css" TITLE="Style">
<SCRIPT type="text/javascript">
function windowTitle()
{
if (location.href.indexOf('is-external=true') == -1) {
parent.document.title="Filter";
}
}
</SCRIPT>
<NOSCRIPT>
</NOSCRIPT>
</HEAD>
<BODY BGCOLOR="white" onload="windowTitle();">
<HR>
<!-- ========= START OF TOP NAVBAR ======= -->
<A NAME="navbar_top"><!-- --></A>
<A HREF="#skip-navbar_top" title="Skip navigation links"></A>
<TABLE BORDER="0" WIDTH="100%" CELLPADDING="1" CELLSPACING="0" SUMMARY="">
<TR>
<TD COLSPAN=2 BGCOLOR="#EEEEFF" CLASS="NavBarCell1">
<A NAME="navbar_top_firstrow"><!-- --></A>
<TABLE BORDER="0" CELLPADDING="0" CELLSPACING="3" SUMMARY="">
<TR ALIGN="center" VALIGN="top">
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../../../overview-summary.html"><FONT CLASS="NavBarFont1"><B>Overview</B></FONT></A> </TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-summary.html"><FONT CLASS="NavBarFont1"><B>Package</B></FONT></A> </TD>
<TD BGCOLOR="#FFFFFF" CLASS="NavBarCell1Rev"> <FONT CLASS="NavBarFont1Rev"><B>Class</B></FONT> </TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-tree.html"><FONT CLASS="NavBarFont1"><B>Tree</B></FONT></A> </TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../../../deprecated-list.html"><FONT CLASS="NavBarFont1"><B>Deprecated</B></FONT></A> </TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../../../index-all.html"><FONT CLASS="NavBarFont1"><B>Index</B></FONT></A> </TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../../../help-doc.html"><FONT CLASS="NavBarFont1"><B>Help</B></FONT></A> </TD>
</TR>
</TABLE>
</TD>
<TD ALIGN="right" VALIGN="top" ROWSPAN=3><EM>
</EM>
</TD>
</TR>
<TR>
<TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">
<A HREF="../../../../../../com/redhat/rhn/domain/monitoring/notification/Criteria.html" title="class in com.redhat.rhn.domain.monitoring.notification"><B>PREV CLASS</B></A>
<A HREF="../../../../../../com/redhat/rhn/domain/monitoring/notification/FilterType.html" title="class in com.redhat.rhn.domain.monitoring.notification"><B>NEXT CLASS</B></A></FONT></TD>
<TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">
<A HREF="../../../../../../index.html?com/redhat/rhn/domain/monitoring/notification/Filter.html" target="_top"><B>FRAMES</B></A>
<A HREF="Filter.html" target="_top"><B>NO FRAMES</B></A>
<SCRIPT type="text/javascript">
<!--
if(window==top) {
document.writeln('<A HREF="../../../../../../allclasses-noframe.html"><B>All Classes</B></A>');
}
//-->
</SCRIPT>
<NOSCRIPT>
<A HREF="../../../../../../allclasses-noframe.html"><B>All Classes</B></A>
</NOSCRIPT>
</FONT></TD>
</TR>
<TR>
<TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">
SUMMARY: NESTED | FIELD | <A HREF="#constructor_summary">CONSTR</A> | <A HREF="#method_summary">METHOD</A></FONT></TD>
<TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">
DETAIL: FIELD | <A HREF="#constructor_detail">CONSTR</A> | <A HREF="#method_detail">METHOD</A></FONT></TD>
</TR>
</TABLE>
<A NAME="skip-navbar_top"></A>
<!-- ========= END OF TOP NAVBAR ========= -->
<HR>
<!-- ======== START OF CLASS DATA ======== -->
<H2>
<FONT SIZE="-1">
com.redhat.rhn.domain.monitoring.notification</FONT>
<BR>
Class Filter</H2>
<PRE>
java.lang.Object
<IMG SRC="../../../../../../resources/inherit.gif" ALT="extended by "><B>com.redhat.rhn.domain.monitoring.notification.Filter</B>
</PRE>
<HR>
<DL>
<DT><PRE>public class <B>Filter</B><DT>extends java.lang.Object</DL>
</PRE>
<P>
Filter - Class representation of the table rhn_redirects.
<P>
<P>
<HR>
<P>
<!-- ======== CONSTRUCTOR SUMMARY ======== -->
<A NAME="constructor_summary"><!-- --></A>
<TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY="">
<TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor">
<TH ALIGN="left" COLSPAN="2"><FONT SIZE="+2">
<B>Constructor Summary</B></FONT></TH>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD><CODE><B><A HREF="../../../../../../com/redhat/rhn/domain/monitoring/notification/Filter.html#Filter()">Filter</A></B>()</CODE>
<BR>
</TD>
</TR>
</TABLE>
<!-- ========== METHOD SUMMARY =========== -->
<A NAME="method_summary"><!-- --></A>
<TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY="">
<TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor">
<TH ALIGN="left" COLSPAN="2"><FONT SIZE="+2">
<B>Method Summary</B></FONT></TH>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE> <A HREF="../../../../../../com/redhat/rhn/domain/monitoring/notification/Criteria.html" title="class in com.redhat.rhn.domain.monitoring.notification">Criteria</A></CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../../../com/redhat/rhn/domain/monitoring/notification/Filter.html#addCriteria(com.redhat.rhn.domain.monitoring.notification.MatchType, java.lang.String)">addCriteria</A></B>(<A HREF="../../../../../../com/redhat/rhn/domain/monitoring/notification/MatchType.html" title="class in com.redhat.rhn.domain.monitoring.notification">MatchType</A> matchType,
java.lang.String value)</CODE>
<BR>
Add a match criteria of the given type that matches
against <code>value</code></TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE> java.util.Set</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../../../com/redhat/rhn/domain/monitoring/notification/Filter.html#getCriteria()">getCriteria</A></B>()</CODE>
<BR>
</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE> java.lang.String</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../../../com/redhat/rhn/domain/monitoring/notification/Filter.html#getDescription()">getDescription</A></B>()</CODE>
<BR>
Getter for description</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE> java.util.Set</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../../../com/redhat/rhn/domain/monitoring/notification/Filter.html#getEmailAddresses()">getEmailAddresses</A></B>()</CODE>
<BR>
</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE> java.util.Date</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../../../com/redhat/rhn/domain/monitoring/notification/Filter.html#getExpiration()">getExpiration</A></B>()</CODE>
<BR>
Getter for expiration</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE> java.lang.Long</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../../../com/redhat/rhn/domain/monitoring/notification/Filter.html#getId()">getId</A></B>()</CODE>
<BR>
</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE> java.util.Date</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../../../com/redhat/rhn/domain/monitoring/notification/Filter.html#getLastUpdateDate()">getLastUpdateDate</A></B>()</CODE>
<BR>
Getter for lastUpdateDate</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE> java.lang.String</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../../../com/redhat/rhn/domain/monitoring/notification/Filter.html#getLastUpdateUser()">getLastUpdateUser</A></B>()</CODE>
<BR>
Getter for lastUpdateUser</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE> <A HREF="../../../../../../com/redhat/rhn/domain/org/Org.html" title="class in com.redhat.rhn.domain.org">Org</A></CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../../../com/redhat/rhn/domain/monitoring/notification/Filter.html#getOrg()">getOrg</A></B>()</CODE>
<BR>
</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE> java.lang.String</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../../../com/redhat/rhn/domain/monitoring/notification/Filter.html#getReason()">getReason</A></B>()</CODE>
<BR>
Getter for reason</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE> java.lang.Boolean</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../../../com/redhat/rhn/domain/monitoring/notification/Filter.html#getRecurring()">getRecurring</A></B>()</CODE>
<BR>
</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE> java.lang.Long</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../../../com/redhat/rhn/domain/monitoring/notification/Filter.html#getRecurringDuration()">getRecurringDuration</A></B>()</CODE>
<BR>
Get the number of minutes we want the recurring filter
to run for.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE> java.lang.Long</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../../../com/redhat/rhn/domain/monitoring/notification/Filter.html#getRecurringDurationType()">getRecurringDurationType</A></B>()</CODE>
<BR>
</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE> java.lang.Long</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../../../com/redhat/rhn/domain/monitoring/notification/Filter.html#getRecurringFrequency()">getRecurringFrequency</A></B>()</CODE>
<BR>
How often this Filter recurrs.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE> java.util.Date</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../../../com/redhat/rhn/domain/monitoring/notification/Filter.html#getStartDate()">getStartDate</A></B>()</CODE>
<BR>
Getter for startDate</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE> <A HREF="../../../../../../com/redhat/rhn/domain/monitoring/notification/FilterType.html" title="class in com.redhat.rhn.domain.monitoring.notification">FilterType</A></CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../../../com/redhat/rhn/domain/monitoring/notification/Filter.html#getType()">getType</A></B>()</CODE>
<BR>
</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE> <A HREF="../../../../../../com/redhat/rhn/domain/user/User.html" title="interface in com.redhat.rhn.domain.user">User</A></CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../../../com/redhat/rhn/domain/monitoring/notification/Filter.html#getUser()">getUser</A></B>()</CODE>
<BR>
</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE> void</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../../../com/redhat/rhn/domain/monitoring/notification/Filter.html#setDescription(java.lang.String)">setDescription</A></B>(java.lang.String descriptionIn)</CODE>
<BR>
Setter for description</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE> void</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../../../com/redhat/rhn/domain/monitoring/notification/Filter.html#setExpiration(java.util.Date)">setExpiration</A></B>(java.util.Date expirationIn)</CODE>
<BR>
Setter for expiration</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE> void</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../../../com/redhat/rhn/domain/monitoring/notification/Filter.html#setId(java.lang.Long)">setId</A></B>(java.lang.Long idIn)</CODE>
<BR>
</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE> void</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../../../com/redhat/rhn/domain/monitoring/notification/Filter.html#setLastUpdateDate(java.util.Date)">setLastUpdateDate</A></B>(java.util.Date lastUpdateDateIn)</CODE>
<BR>
Setter for lastUpdateDate</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE> void</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../../../com/redhat/rhn/domain/monitoring/notification/Filter.html#setLastUpdateUser(java.lang.String)">setLastUpdateUser</A></B>(java.lang.String lastUpdateUserIn)</CODE>
<BR>
Setter for lastUpdateUser</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE> void</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../../../com/redhat/rhn/domain/monitoring/notification/Filter.html#setOrg(com.redhat.rhn.domain.org.Org)">setOrg</A></B>(<A HREF="../../../../../../com/redhat/rhn/domain/org/Org.html" title="class in com.redhat.rhn.domain.org">Org</A> orgIn)</CODE>
<BR>
</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE> void</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../../../com/redhat/rhn/domain/monitoring/notification/Filter.html#setReason(java.lang.String)">setReason</A></B>(java.lang.String reasonIn)</CODE>
<BR>
Setter for reason</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE> void</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../../../com/redhat/rhn/domain/monitoring/notification/Filter.html#setRecurring(java.lang.Boolean)">setRecurring</A></B>(java.lang.Boolean recurringIn)</CODE>
<BR>
</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE> void</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../../../com/redhat/rhn/domain/monitoring/notification/Filter.html#setRecurringDuration(java.lang.Long)">setRecurringDuration</A></B>(java.lang.Long recurringDurationIn)</CODE>
<BR>
Set the number of minutes we want the recurring filter
to run for.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE> void</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../../../com/redhat/rhn/domain/monitoring/notification/Filter.html#setRecurringDurationType(java.lang.Long)">setRecurringDurationType</A></B>(java.lang.Long recurringDurationTypeIn)</CODE>
<BR>
</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE> void</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../../../com/redhat/rhn/domain/monitoring/notification/Filter.html#setRecurringFrequency(java.lang.Long)">setRecurringFrequency</A></B>(java.lang.Long recurringFrequencyIn)</CODE>
<BR>
How often this Filter recurrs.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE> void</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../../../com/redhat/rhn/domain/monitoring/notification/Filter.html#setStartDate(java.util.Date)">setStartDate</A></B>(java.util.Date startDateIn)</CODE>
<BR>
Setter for startDate</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE> void</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../../../com/redhat/rhn/domain/monitoring/notification/Filter.html#setType(com.redhat.rhn.domain.monitoring.notification.FilterType)">setType</A></B>(<A HREF="../../../../../../com/redhat/rhn/domain/monitoring/notification/FilterType.html" title="class in com.redhat.rhn.domain.monitoring.notification">FilterType</A> typeIn)</CODE>
<BR>
</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE> void</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../../../com/redhat/rhn/domain/monitoring/notification/Filter.html#setUser(com.redhat.rhn.domain.user.User)">setUser</A></B>(<A HREF="../../../../../../com/redhat/rhn/domain/user/User.html" title="interface in com.redhat.rhn.domain.user">User</A> userIn)</CODE>
<BR>
</TD>
</TR>
</TABLE>
<A NAME="methods_inherited_from_class_java.lang.Object"><!-- --></A>
<TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY="">
<TR BGCOLOR="#EEEEFF" CLASS="TableSubHeadingColor">
<TH ALIGN="left"><B>Methods inherited from class java.lang.Object</B></TH>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD><CODE>clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait</CODE></TD>
</TR>
</TABLE>
<P>
<!-- ========= CONSTRUCTOR DETAIL ======== -->
<A NAME="constructor_detail"><!-- --></A>
<TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY="">
<TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor">
<TH ALIGN="left" COLSPAN="1"><FONT SIZE="+2">
<B>Constructor Detail</B></FONT></TH>
</TR>
</TABLE>
<A NAME="Filter()"><!-- --></A><H3>
Filter</H3>
<PRE>
public <B>Filter</B>()</PRE>
<DL>
</DL>
<!-- ============ METHOD DETAIL ========== -->
<A NAME="method_detail"><!-- --></A>
<TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY="">
<TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor">
<TH ALIGN="left" COLSPAN="1"><FONT SIZE="+2">
<B>Method Detail</B></FONT></TH>
</TR>
</TABLE>
<A NAME="addCriteria(com.redhat.rhn.domain.monitoring.notification.MatchType, java.lang.String)"><!-- --></A><H3>
addCriteria</H3>
<PRE>
public <A HREF="../../../../../../com/redhat/rhn/domain/monitoring/notification/Criteria.html" title="class in com.redhat.rhn.domain.monitoring.notification">Criteria</A> <B>addCriteria</B>(<A HREF="../../../../../../com/redhat/rhn/domain/monitoring/notification/MatchType.html" title="class in com.redhat.rhn.domain.monitoring.notification">MatchType</A> matchType,
java.lang.String value)</PRE>
<DL>
<DD>Add a match criteria of the given type that matches
against <code>value</code>
<P>
<DD><DL>
<DT><B>Parameters:</B><DD><CODE>matchType</CODE> - the type of match for the criteria<DD><CODE>value</CODE> - the value to match against
<DT><B>Returns:</B><DD>the new criteria that has been added to this filter</DL>
</DD>
</DL>
<HR>
<A NAME="getId()"><!-- --></A><H3>
getId</H3>
<PRE>
public java.lang.Long <B>getId</B>()</PRE>
<DL>
<DD><DL>
<DT><B>Returns:</B><DD>Returns the id.</DL>
</DD>
</DL>
<HR>
<A NAME="setId(java.lang.Long)"><!-- --></A><H3>
setId</H3>
<PRE>
public void <B>setId</B>(java.lang.Long idIn)</PRE>
<DL>
<DD><DL>
<DT><B>Parameters:</B><DD><CODE>idIn</CODE> - The id to set.</DL>
</DD>
</DL>
<HR>
<A NAME="getDescription()"><!-- --></A><H3>
getDescription</H3>
<PRE>
public java.lang.String <B>getDescription</B>()</PRE>
<DL>
<DD>Getter for description
<P>
<DD><DL>
<DT><B>Returns:</B><DD>String to get</DL>
</DD>
</DL>
<HR>
<A NAME="setDescription(java.lang.String)"><!-- --></A><H3>
setDescription</H3>
<PRE>
public void <B>setDescription</B>(java.lang.String descriptionIn)</PRE>
<DL>
<DD>Setter for description
<P>
<DD><DL>
<DT><B>Parameters:</B><DD><CODE>descriptionIn</CODE> - to set</DL>
</DD>
</DL>
<HR>
<A NAME="getReason()"><!-- --></A><H3>
getReason</H3>
<PRE>
public java.lang.String <B>getReason</B>()</PRE>
<DL>
<DD>Getter for reason
<P>
<DD><DL>
<DT><B>Returns:</B><DD>String to get</DL>
</DD>
</DL>
<HR>
<A NAME="setReason(java.lang.String)"><!-- --></A><H3>
setReason</H3>
<PRE>
public void <B>setReason</B>(java.lang.String reasonIn)</PRE>
<DL>
<DD>Setter for reason
<P>
<DD><DL>
<DT><B>Parameters:</B><DD><CODE>reasonIn</CODE> - to set</DL>
</DD>
</DL>
<HR>
<A NAME="getExpiration()"><!-- --></A><H3>
getExpiration</H3>
<PRE>
public java.util.Date <B>getExpiration</B>()</PRE>
<DL>
<DD>Getter for expiration
<P>
<DD><DL>
<DT><B>Returns:</B><DD>Date to get</DL>
</DD>
</DL>
<HR>
<A NAME="setExpiration(java.util.Date)"><!-- --></A><H3>
setExpiration</H3>
<PRE>
public void <B>setExpiration</B>(java.util.Date expirationIn)</PRE>
<DL>
<DD>Setter for expiration
<P>
<DD><DL>
<DT><B>Parameters:</B><DD><CODE>expirationIn</CODE> - to set</DL>
</DD>
</DL>
<HR>
<A NAME="getLastUpdateUser()"><!-- --></A><H3>
getLastUpdateUser</H3>
<PRE>
public java.lang.String <B>getLastUpdateUser</B>()</PRE>
<DL>
<DD>Getter for lastUpdateUser
<P>
<DD><DL>
<DT><B>Returns:</B><DD>String to get</DL>
</DD>
</DL>
<HR>
<A NAME="setLastUpdateUser(java.lang.String)"><!-- --></A><H3>
setLastUpdateUser</H3>
<PRE>
public void <B>setLastUpdateUser</B>(java.lang.String lastUpdateUserIn)</PRE>
<DL>
<DD>Setter for lastUpdateUser
<P>
<DD><DL>
<DT><B>Parameters:</B><DD><CODE>lastUpdateUserIn</CODE> - to set</DL>
</DD>
</DL>
<HR>
<A NAME="getLastUpdateDate()"><!-- --></A><H3>
getLastUpdateDate</H3>
<PRE>
public java.util.Date <B>getLastUpdateDate</B>()</PRE>
<DL>
<DD>Getter for lastUpdateDate
<P>
<DD><DL>
<DT><B>Returns:</B><DD>Date to get</DL>
</DD>
</DL>
<HR>
<A NAME="setLastUpdateDate(java.util.Date)"><!-- --></A><H3>
setLastUpdateDate</H3>
<PRE>
public void <B>setLastUpdateDate</B>(java.util.Date lastUpdateDateIn)</PRE>
<DL>
<DD>Setter for lastUpdateDate
<P>
<DD><DL>
<DT><B>Parameters:</B><DD><CODE>lastUpdateDateIn</CODE> - to set</DL>
</DD>
</DL>
<HR>
<A NAME="getStartDate()"><!-- --></A><H3>
getStartDate</H3>
<PRE>
public java.util.Date <B>getStartDate</B>()</PRE>
<DL>
<DD>Getter for startDate
<P>
<DD><DL>
<DT><B>Returns:</B><DD>Date to get</DL>
</DD>
</DL>
<HR>
<A NAME="setStartDate(java.util.Date)"><!-- --></A><H3>
setStartDate</H3>
<PRE>
public void <B>setStartDate</B>(java.util.Date startDateIn)</PRE>
<DL>
<DD>Setter for startDate
<P>
<DD><DL>
<DT><B>Parameters:</B><DD><CODE>startDateIn</CODE> - to set</DL>
</DD>
</DL>
<HR>
<A NAME="getRecurring()"><!-- --></A><H3>
getRecurring</H3>
<PRE>
public java.lang.Boolean <B>getRecurring</B>()</PRE>
<DL>
<DD><DL>
<DT><B>Returns:</B><DD>Returns the recurring.</DL>
</DD>
</DL>
<HR>
<A NAME="setRecurring(java.lang.Boolean)"><!-- --></A><H3>
setRecurring</H3>
<PRE>
public void <B>setRecurring</B>(java.lang.Boolean recurringIn)</PRE>
<DL>
<DD><DL>
<DT><B>Parameters:</B><DD><CODE>recurringIn</CODE> - The recurring to set.</DL>
</DD>
</DL>
<HR>
<A NAME="getRecurringDuration()"><!-- --></A><H3>
getRecurringDuration</H3>
<PRE>
public java.lang.Long <B>getRecurringDuration</B>()</PRE>
<DL>
<DD>Get the number of minutes we want the recurring filter
to run for. So, if we say the filter is for 30 minutes
then each time it runs, it will run for 30 minutes.
<P>
<DD><DL>
<DT><B>Returns:</B><DD>Returns the recurringDuration.</DL>
</DD>
</DL>
<HR>
<A NAME="setRecurringDuration(java.lang.Long)"><!-- --></A><H3>
setRecurringDuration</H3>
<PRE>
public void <B>setRecurringDuration</B>(java.lang.Long recurringDurationIn)</PRE>
<DL>
<DD>Set the number of minutes we want the recurring filter
to run for. So, if we say the filter is for 30 minutes
then each time it runs, it will run for 30 minutes.
<P>
<DD><DL>
<DT><B>Parameters:</B><DD><CODE>recurringDurationIn</CODE> - The recurringDuration to set.</DL>
</DD>
</DL>
<HR>
<A NAME="getRecurringDurationType()"><!-- --></A><H3>
getRecurringDurationType</H3>
<PRE>
public java.lang.Long <B>getRecurringDurationType</B>()</PRE>
<DL>
<DD><DL>
<DT><B>Returns:</B><DD>Returns the recurringDurationType.</DL>
</DD>
</DL>
<HR>
<A NAME="setRecurringDurationType(java.lang.Long)"><!-- --></A><H3>
setRecurringDurationType</H3>
<PRE>
public void <B>setRecurringDurationType</B>(java.lang.Long recurringDurationTypeIn)</PRE>
<DL>
<DD><DL>
<DT><B>Parameters:</B><DD><CODE>recurringDurationTypeIn</CODE> - The recurringDurationType to set.</DL>
</DD>
</DL>
<HR>
<A NAME="getRecurringFrequency()"><!-- --></A><H3>
getRecurringFrequency</H3>
<PRE>
public java.lang.Long <B>getRecurringFrequency</B>()</PRE>
<DL>
<DD>How often this Filter recurrs.
These values correspond to the constants defined in java.util.Calendar:
public final static int DAY_OF_YEAR = 6;
public final static int WEEK_OF_YEAR = 3;
public final static int MONTH = 2;
<P>
<DD><DL>
<DT><B>Returns:</B><DD>Returns the recurringFrequency.</DL>
</DD>
</DL>
<HR>
<A NAME="setRecurringFrequency(java.lang.Long)"><!-- --></A><H3>
setRecurringFrequency</H3>
<PRE>
public void <B>setRecurringFrequency</B>(java.lang.Long recurringFrequencyIn)</PRE>
<DL>
<DD>How often this Filter recurrs.
These values correspond to the constants defined in java.util.Calendar:
public final static int DAY_OF_YEAR = 6;
public final static int WEEK_OF_YEAR = 3;
public final static int MONTH = 2;
<P>
<DD><DL>
<DT><B>Parameters:</B><DD><CODE>recurringFrequencyIn</CODE> - The recurringFrequency to set.</DL>
</DD>
</DL>
<HR>
<A NAME="getOrg()"><!-- --></A><H3>
getOrg</H3>
<PRE>
public <A HREF="../../../../../../com/redhat/rhn/domain/org/Org.html" title="class in com.redhat.rhn.domain.org">Org</A> <B>getOrg</B>()</PRE>
<DL>
<DD><DL>
<DT><B>Returns:</B><DD>Returns the org.</DL>
</DD>
</DL>
<HR>
<A NAME="setOrg(com.redhat.rhn.domain.org.Org)"><!-- --></A><H3>
setOrg</H3>
<PRE>
public void <B>setOrg</B>(<A HREF="../../../../../../com/redhat/rhn/domain/org/Org.html" title="class in com.redhat.rhn.domain.org">Org</A> orgIn)</PRE>
<DL>
<DD><DL>
<DT><B>Parameters:</B><DD><CODE>orgIn</CODE> - The org to set.</DL>
</DD>
</DL>
<HR>
<A NAME="getUser()"><!-- --></A><H3>
getUser</H3>
<PRE>
public <A HREF="../../../../../../com/redhat/rhn/domain/user/User.html" title="interface in com.redhat.rhn.domain.user">User</A> <B>getUser</B>()</PRE>
<DL>
<DD><DL>
<DT><B>Returns:</B><DD>Returns the user.</DL>
</DD>
</DL>
<HR>
<A NAME="setUser(com.redhat.rhn.domain.user.User)"><!-- --></A><H3>
setUser</H3>
<PRE>
public void <B>setUser</B>(<A HREF="../../../../../../com/redhat/rhn/domain/user/User.html" title="interface in com.redhat.rhn.domain.user">User</A> userIn)</PRE>
<DL>
<DD><DL>
<DT><B>Parameters:</B><DD><CODE>userIn</CODE> - The user to set.</DL>
</DD>
</DL>
<HR>
<A NAME="getType()"><!-- --></A><H3>
getType</H3>
<PRE>
public <A HREF="../../../../../../com/redhat/rhn/domain/monitoring/notification/FilterType.html" title="class in com.redhat.rhn.domain.monitoring.notification">FilterType</A> <B>getType</B>()</PRE>
<DL>
<DD><DL>
<DT><B>Returns:</B><DD>Returns the type.</DL>
</DD>
</DL>
<HR>
<A NAME="setType(com.redhat.rhn.domain.monitoring.notification.FilterType)"><!-- --></A><H3>
setType</H3>
<PRE>
public void <B>setType</B>(<A HREF="../../../../../../com/redhat/rhn/domain/monitoring/notification/FilterType.html" title="class in com.redhat.rhn.domain.monitoring.notification">FilterType</A> typeIn)</PRE>
<DL>
<DD><DL>
<DT><B>Parameters:</B><DD><CODE>typeIn</CODE> - The type to set.</DL>
</DD>
</DL>
<HR>
<A NAME="getCriteria()"><!-- --></A><H3>
getCriteria</H3>
<PRE>
public java.util.Set <B>getCriteria</B>()</PRE>
<DL>
<DD><DL>
<DT><B>Returns:</B><DD>Returns the criteria.</DL>
</DD>
</DL>
<HR>
<A NAME="getEmailAddresses()"><!-- --></A><H3>
getEmailAddresses</H3>
<PRE>
public java.util.Set <B>getEmailAddresses</B>()</PRE>
<DL>
<DD><DL>
<DT><B>Returns:</B><DD>Returns the emailAddresses.</DL>
</DD>
</DL>
<!-- ========= END OF CLASS DATA ========= -->
<HR>
<!-- ======= START OF BOTTOM NAVBAR ====== -->
<A NAME="navbar_bottom"><!-- --></A>
<A HREF="#skip-navbar_bottom" title="Skip navigation links"></A>
<TABLE BORDER="0" WIDTH="100%" CELLPADDING="1" CELLSPACING="0" SUMMARY="">
<TR>
<TD COLSPAN=2 BGCOLOR="#EEEEFF" CLASS="NavBarCell1">
<A NAME="navbar_bottom_firstrow"><!-- --></A>
<TABLE BORDER="0" CELLPADDING="0" CELLSPACING="3" SUMMARY="">
<TR ALIGN="center" VALIGN="top">
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../../../overview-summary.html"><FONT CLASS="NavBarFont1"><B>Overview</B></FONT></A> </TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-summary.html"><FONT CLASS="NavBarFont1"><B>Package</B></FONT></A> </TD>
<TD BGCOLOR="#FFFFFF" CLASS="NavBarCell1Rev"> <FONT CLASS="NavBarFont1Rev"><B>Class</B></FONT> </TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-tree.html"><FONT CLASS="NavBarFont1"><B>Tree</B></FONT></A> </TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../../../deprecated-list.html"><FONT CLASS="NavBarFont1"><B>Deprecated</B></FONT></A> </TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../../../index-all.html"><FONT CLASS="NavBarFont1"><B>Index</B></FONT></A> </TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../../../help-doc.html"><FONT CLASS="NavBarFont1"><B>Help</B></FONT></A> </TD>
</TR>
</TABLE>
</TD>
<TD ALIGN="right" VALIGN="top" ROWSPAN=3><EM>
</EM>
</TD>
</TR>
<TR>
<TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">
<A HREF="../../../../../../com/redhat/rhn/domain/monitoring/notification/Criteria.html" title="class in com.redhat.rhn.domain.monitoring.notification"><B>PREV CLASS</B></A>
<A HREF="../../../../../../com/redhat/rhn/domain/monitoring/notification/FilterType.html" title="class in com.redhat.rhn.domain.monitoring.notification"><B>NEXT CLASS</B></A></FONT></TD>
<TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">
<A HREF="../../../../../../index.html?com/redhat/rhn/domain/monitoring/notification/Filter.html" target="_top"><B>FRAMES</B></A>
<A HREF="Filter.html" target="_top"><B>NO FRAMES</B></A>
<SCRIPT type="text/javascript">
<!--
if(window==top) {
document.writeln('<A HREF="../../../../../../allclasses-noframe.html"><B>All Classes</B></A>');
}
//-->
</SCRIPT>
<NOSCRIPT>
<A HREF="../../../../../../allclasses-noframe.html"><B>All Classes</B></A>
</NOSCRIPT>
</FONT></TD>
</TR>
<TR>
<TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">
SUMMARY: NESTED | FIELD | <A HREF="#constructor_summary">CONSTR</A> | <A HREF="#method_summary">METHOD</A></FONT></TD>
<TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">
DETAIL: FIELD | <A HREF="#constructor_detail">CONSTR</A> | <A HREF="#method_detail">METHOD</A></FONT></TD>
</TR>
</TABLE>
<A NAME="skip-navbar_bottom"></A>
<!-- ======== END OF BOTTOM NAVBAR ======= -->
<HR>
</BODY>
</HTML>
| Java |
<?php
/**
* @version $Id: #component#.php 125 2012-10-09 11:09:48Z michel $ 1 2014-05-11Z FT $
* @package Kepviselojeloltek
* @copyright Copyright (C) 2014, Fogler Tibor. All rights reserved.
* @license #GNU/GPL
*/
//--No direct access
defined('_JEXEC') or die('=;)');
// DS has removed from J 3.0
if(!defined('DS')) {
define('DS','/');
}
// Require the base controller
require_once( JPATH_COMPONENT.'/controller.php' );
jimport('joomla.application.component.model');
require_once( JPATH_COMPONENT.'/models/model.php' );
jimport('joomla.application.component.helper');
JHTML::addIncludePath(JPATH_COMPONENT_ADMINISTRATOR.'/helpers' );
//set the default view
$task = JRequest::getWord('task');
$config =& JComponentHelper::getParams( 'com_kepviselojeloltek' );
$controller = JRequest::getWord('view', 'kepviselojeloltek');
$ControllerConfig = array();
// Require specific controller if requested
if ($controller) {
$path = JPATH_COMPONENT.'/controllers/'.$controller.'.php';
$ControllerConfig = array('viewname'=>strtolower($controller),'mainmodel'=>strtolower($controller),'itemname'=>ucfirst(strtolower($controller)));
if (file_exists($path)) {
require_once $path;
} else {
$controller = '';
}
}
// Create the controller
$classname = 'KepviselojeloltekController'.$controller;
$controller = new $classname($ControllerConfig );
// Perform the Request task
$controller->execute( JRequest::getVar( 'task' ) );
// Redirect if set by the controller
$controller->redirect(); | Java |
package org.emulinker.kaillera.controller.v086.action;
import java.util.*;
import org.apache.commons.logging.*;
import org.emulinker.kaillera.access.AccessManager;
import org.emulinker.kaillera.controller.messaging.MessageFormatException;
import org.emulinker.kaillera.controller.v086.V086Controller;
import org.emulinker.kaillera.controller.v086.protocol.*;
import org.emulinker.kaillera.model.exception.ActionException;
import org.emulinker.kaillera.model.impl.*;
import org.emulinker.kaillera.model.*;
import org.emulinker.util.EmuLang;
import org.emulinker.util.WildcardStringPattern;
public class GameOwnerCommandAction implements V086Action
{
public static final String COMMAND_HELP = "/help"; //$NON-NLS-1$
public static final String COMMAND_DETECTAUTOFIRE = "/detectautofire"; //$NON-NLS-1$
private static Log log = LogFactory.getLog(GameOwnerCommandAction.class);
private static final String desc = "GameOwnerCommandAction"; //$NON-NLS-1$
private static GameOwnerCommandAction singleton = new GameOwnerCommandAction();
public static GameOwnerCommandAction getInstance()
{
return singleton;
}
private int actionCount = 0;
private GameOwnerCommandAction()
{
}
public int getActionPerformedCount()
{
return actionCount;
}
public String toString()
{
return desc;
}
public void performAction(V086Message message, V086Controller.V086ClientHandler clientHandler) throws FatalActionException
{
GameChat chatMessage = (GameChat) message;
String chat = chatMessage.getMessage();
KailleraUserImpl user = (KailleraUserImpl) clientHandler.getUser();
KailleraGameImpl game = user.getGame();
if(game == null)
{
throw new FatalActionException("GameOwner Command Failed: Not in a game: " + chat); //$NON-NLS-1$
}
if(!user.equals(game.getOwner()))
{
log.warn("GameOwner Command Denied: Not game owner: " + game + ": " + user + ": " + chat); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
return;
}
try
{
if (chat.startsWith(COMMAND_HELP))
{
processHelp(chat, game, user, clientHandler);
}
else if (chat.startsWith(COMMAND_DETECTAUTOFIRE))
{
processDetectAutoFire(chat, game, user, clientHandler);
}
else
{
log.info("Unknown GameOwner Command: " + game + ": " + user + ": " + chat); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
}
}
catch (ActionException e)
{
log.info("GameOwner Command Failed: " + game + ": " + user + ": " + chat); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
game.announce(EmuLang.getString("GameOwnerCommandAction.CommandFailed", e.getMessage())); //$NON-NLS-1$
}
catch (MessageFormatException e)
{
log.error("Failed to contruct message: " + e.getMessage(), e); //$NON-NLS-1$
}
}
private void processHelp(String message, KailleraGameImpl game, KailleraUserImpl admin, V086Controller.V086ClientHandler clientHandler) throws ActionException, MessageFormatException
{
game.announce(EmuLang.getString("GameOwnerCommandAction.AvailableCommands")); //$NON-NLS-1$
game.announce(EmuLang.getString("GameOwnerCommandAction.SetAutofireDetection")); //$NON-NLS-1$
}
private void autoFireHelp(KailleraGameImpl game)
{
int cur = game.getAutoFireDetector().getSensitivity();
game.announce(EmuLang.getString("GameOwnerCommandAction.HelpSensitivity")); //$NON-NLS-1$
game.announce(EmuLang.getString("GameOwnerCommandAction.HelpDisable")); //$NON-NLS-1$
game.announce(EmuLang.getString("GameOwnerCommandAction.HelpCurrentSensitivity", cur) + (cur == 0 ? (EmuLang.getString("GameOwnerCommandAction.HelpDisabled")) : "")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
}
private void processDetectAutoFire(String message, KailleraGameImpl game, KailleraUserImpl admin, V086Controller.V086ClientHandler clientHandler) throws ActionException, MessageFormatException
{
if(game.getStatus() != KailleraGame.STATUS_WAITING)
{
game.announce(EmuLang.getString("GameOwnerCommandAction.AutoFireChangeDeniedInGame")); //$NON-NLS-1$
return;
}
StringTokenizer st = new StringTokenizer(message, " "); //$NON-NLS-1$
if(st.countTokens() != 2)
{
autoFireHelp(game);
return;
}
String command = st.nextToken();
String sensitivityStr = st.nextToken();
int sensitivity = -1;
try
{
sensitivity = Integer.parseInt(sensitivityStr);
}
catch(NumberFormatException e) {}
if(sensitivity > 5 || sensitivity < 0)
{
autoFireHelp(game);
return;
}
game.getAutoFireDetector().setSensitivity(sensitivity);
game.announce(EmuLang.getString("GameOwnerCommandAction.HelpCurrentSensitivity", sensitivity) + (sensitivity == 0 ? (EmuLang.getString("GameOwnerCommandAction.HelpDisabled")) : "")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
}
}
| Java |
<?php
/**
* Manages the social plugins.
*
* @copyright 2009-2019 Vanilla Forums Inc.
* @license GPL-2.0-only
* @package Dashboard
* @since 2.1
*/
/**
* Handles /social endpoint, so it must be an extrovert.
*/
class SocialController extends DashboardController {
/** @var array Models to automatically instantiate. */
public $Uses = ['Form', 'Database'];
/**
* Runs before every call to this controller.
*/
public function initialize() {
parent::initialize();
Gdn_Theme::section('Settings');
}
/**
* Default method.
*/
public function index() {
redirectTo('social/manage');
}
/**
* Settings page.
*/
public function manage() {
$this->permission('Garden.Settings.Manage');
$this->title("Social Connect Addons");
$this->setHighlightRoute('/social/manage');
$connections = $this->getConnections();
$this->setData('Connections', $connections);
$this->render();
}
/**
* Find available social plugins.
*
* @return array|mixed
* @throws Exception
*/
protected function getConnections() {
$this->fireEvent('GetConnections');
$connections = [];
$addons = Gdn::addonManager()->lookupAllByType(\Vanilla\Addon::TYPE_ADDON);
foreach ($addons as $addonName => $addon) {
/* @var \Vanilla\Addon $addon */
$addonInfo = $addon->getInfo();
// Limit to designated social addons.
if (!array_key_exists('socialConnect', $addonInfo)) {
continue;
}
// See if addon is enabled.
$isEnabled = Gdn::addonManager()->isEnabled($addonName, \Vanilla\Addon::TYPE_ADDON);
setValue('enabled', $addonInfo, $isEnabled);
if (!$isEnabled && !empty($addonInfo['hidden'])) {
// Don't show hidden addons unless they are enabled.
continue;
}
// See if we can detect whether connection is configured.
$isConfigured = null;
if ($isEnabled) {
$pluginInstance = Gdn::pluginManager()->getPluginInstance($addonName, Gdn_PluginManager::ACCESS_PLUGINNAME);
if (method_exists($pluginInstance, 'isConfigured')) {
$isConfigured = $pluginInstance->isConfigured();
}
}
setValue('configured', $addonInfo, $isConfigured);
// Add the connection.
$connections[$addonName] = $addonInfo;
}
return $connections;
}
}
| Java |
<?php
// if( isset( $_POST ) ) {
// echo '<code><pre>';
// var_dump( $_POST );
// echo '</pre></code>';
// }
class SpeoOptions
{
/**
* Holds the values to be used in the fields callbacks
*/
private $options;
/**
* Start up
*/
public function __construct()
{
add_action( 'admin_menu', array( $this, 'add_plugin_page' ) );
add_action( 'admin_init', array( $this, 'page_init' ) );
}
/**
* Add options page
*/
public function add_plugin_page()
{
// This page will be under "Settings"
add_options_page(
'Settings Admin',
'Exiftool Options',
'manage_options',
'speo_exif_options',
array( $this, 'create_admin_page' )
);
}
/**
* Options page callback
*/
public function create_admin_page()
{
// Set class property
$this->options = get_option( 'speo_options' );
?>
<div class="wrap">
<?php screen_icon(); ?>
<h2>Exiftools Settings</h2>
<form method="post" action="options.php">
<?php
// This prints out all hidden setting fields
settings_fields( 'speo_options_group' );
do_settings_sections( 'speo_exif_options' );
echo '</ol>';
submit_button();
?>
</form>
</div>
<?php
}
/**
* Register and add settings
*/
public function page_init()
{
register_setting(
'speo_options_group', // Option group
'speo_options', // Option name
array( $this, 'sanitize' ) // Sanitize
);
add_settings_section(
'speo_options_all', // ID
'Options', // Title
array( $this, 'print_section_info' ), // Callback
'speo_exif_options' // Page
);
//get the blog language
$this_lang = get_locale();
//get the values from the list.xml
$xmldoc = new DOMDocument();
$xmldoc->load( plugin_dir_path( __FILE__ ) . 'list.xml' );
$xpathvar = new Domxpath($xmldoc);
$queryResult = $xpathvar->query('//tag/@name');
$possible_values = array();
foreach( $queryResult as $result ){
if( substr( $result->textContent, 0, 9 ) === 'MakerNote' )
continue;
$possible_values[ $result->textContent ] = 0;
ksort( $possible_values );
}
foreach( $possible_values as $value => $bool ) {
// $xpath = new Domxpath($xmldoc);
// $descs = $xpath->query('//tag[@name="' . $value . '"]/desc[@lang="en"]');
// $titles = $xpath->query('//tag[@name="' . $value . '"]/desc[@lang="' . substr( $this_lang, 0, 2 ) . '"]');
// foreach( $descs as $desc ) {
// $i=1;
// $opt_title = '<li>' . $value;
// foreach( $titles as $title ) {
// if( $i > 1 )
// continue;
// $opt_title .= '<br />(' . $title->textContent . ')';
// $i++;
// }
// $opt_title .= '</li>';
//add the actual setting
add_settings_field(
'speo_exif_' . $value, // ID
$value, // Title
array( $this, 'speo_callback' ), // Callback
'speo_exif_options', // Page
'speo_options_all', // Section
$value //args
);
// }
}
}
/**
* Sanitize each setting field as needed
*
* @param array $input Contains all settings fields as array keys
*/
public function sanitize( $inputs )
{
return $inputs;
}
/**
* Print the Section text
*/
public function print_section_info()
{
print 'Check the values you want to retreive from images:<ol>';
}
/**
* Get the settings option array and print one of its values
*/
public function speo_callback( $value ) {
// echo '<code><pre>';
// var_dump($this->options);
// echo '</pre></code>';
printf(
'<input type="checkbox" id="speo_exif_' . $value . '" name="speo_options[' . $value . ']" %s />',
checked( isset( $this->options[$value] ), true, false )
// ( isset( $this->options[$value] ) ? $this->options[$value] : 'none' )
);
}
}
if( is_admin() )
$my_settings_page = new SpeoOptions();
| Java |
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Management;
using ProductMan.Utilities;
using ProductMan.Win32;
using System.Reflection;
namespace ProductMan
{
public class WMIVendor : IDisposable
{
protected static WMIVendor instance;
protected ManagementScope scope;
protected ConnectionOptions conn;
protected ComputerSystem computer;
protected NetworkAdapterConfiguration networkAdapterConfig;
protected ProductMan.Win32.OperatingSystem os;
protected static volatile object syncRoot = new object();
private WMIVendor()
{
conn = new ConnectionOptions();
scope = new ManagementScope("\\\\localhost", conn);
scope.Options.Impersonation = ImpersonationLevel.Impersonate;
}
public ComputerSystem GetComputerSystem()
{
if (computer != null) return computer;
computer = new ComputerSystem();
try
{
ManagementObjectCollection res = Query("select * from win32_ComputerSystem");
FieldInfo[] fields = typeof(ComputerSystem).GetFields();
foreach (ManagementObject item in res)
{
foreach (FieldInfo info in fields)
{
try
{
info.SetValue(computer, item[info.Name]);
}
catch { }
}
break;
}
}
catch (Exception ex)
{
LoggerBase.Instance.Error(ex.ToString());
}
return computer;
}
public NetworkAdapterConfiguration GetNetworkConfig()
{
if (networkAdapterConfig != null) return networkAdapterConfig;
networkAdapterConfig = new NetworkAdapterConfiguration();
try
{
ManagementObjectCollection res = Query("select * from win32_NetworkAdapterConfiguration WHERE IPEnabled = 'TRUE'");
FieldInfo[] fields = typeof(NetworkAdapterConfiguration).GetFields();
foreach (ManagementObject item in res)
{
foreach (FieldInfo info in fields)
{
try
{
info.SetValue(networkAdapterConfig, item[info.Name]);
}
catch { }
}
break;
}
}
catch (Exception ex)
{
LoggerBase.Instance.Error(ex.ToString());
}
return networkAdapterConfig;
}
public ProductMan.Win32.OperatingSystem GetOS()
{
if (os != null) return os;
os = new ProductMan.Win32.OperatingSystem();
try
{
ManagementObjectCollection res = Query("select * from win32_OperatingSystem");
FieldInfo[] fields = typeof(ProductMan.Win32.OperatingSystem).GetFields();
foreach (ManagementObject item in res)
{
foreach (FieldInfo info in fields)
{
try
{
info.SetValue(os, item[info.Name]);
}
catch { }
}
break;
}
}
catch (Exception ex)
{
LoggerBase.Instance.Error(ex.ToString());
}
return os;
}
private ManagementObjectCollection Query(string queryString)
{
try
{
ObjectQuery query = new ObjectQuery(queryString);
ManagementObjectSearcher searcher = new ManagementObjectSearcher(scope, query);
return searcher.Get();
}
catch (Exception ex)
{
LoggerBase.Instance.Error(ex.ToString());
}
return null;
}
public static WMIVendor Instance
{
get
{
if (instance == null)
{
lock (syncRoot)
{
if (instance == null) instance = new WMIVendor();
}
}
return instance;
}
}
#region IDisposable Members
public void Dispose()
{
//TODO
}
#endregion
}
}
| Java |
/*
* linux/drivers/mmc/core/core.c
*
* Copyright (C) 2003-2004 Russell King, All Rights Reserved.
* SD support Copyright (C) 2004 Ian Molton, All Rights Reserved.
* Copyright (C) 2005-2008 Pierre Ossman, All Rights Reserved.
* MMCv4 support Copyright (C) 2006 Philip Langdale, All Rights Reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*/
#include <linux/module.h>
#include <linux/init.h>
#include <linux/interrupt.h>
#include <linux/completion.h>
#include <linux/device.h>
#include <linux/delay.h>
#include <linux/pagemap.h>
#include <linux/err.h>
#include <linux/leds.h>
#include <linux/scatterlist.h>
#include <linux/log2.h>
#include <linux/regulator/consumer.h>
#include <linux/pm_runtime.h>
#include <linux/suspend.h>
#include <linux/fault-inject.h>
#include <linux/random.h>
#include <linux/wakelock.h>
#include <linux/pm.h>
#include <linux/slab.h>
#include <linux/jiffies.h>
#include <linux/mmc/card.h>
#include <linux/mmc/host.h>
#include <linux/mmc/mmc.h>
#include <linux/mmc/sd.h>
#include "core.h"
#include "bus.h"
#include "host.h"
#include "sdio_bus.h"
#include "mmc_ops.h"
#include "sd_ops.h"
#include "sdio_ops.h"
#define CREATE_TRACE_POINTS
#include <trace/events/mmc.h>
/* If the device is not responding */
#define MMC_CORE_TIMEOUT_MS (10 * 60 * 1000) /* 10 minute timeout */
static void mmc_clk_scaling(struct mmc_host *host, bool from_wq);
/*
* Background operations can take a long time, depending on the housekeeping
* operations the card has to perform.
*/
#define MMC_BKOPS_MAX_TIMEOUT (30 * 1000) /* max time to wait in ms */
/* Flushing a large amount of cached data may take a long time. */
#define MMC_FLUSH_REQ_TIMEOUT_MS 30000 /* msec */
static struct workqueue_struct *workqueue;
/*
* Enabling software CRCs on the data blocks can be a significant (30%)
* performance cost, and for other reasons may not always be desired.
* So we allow it it to be disabled.
*/
bool use_spi_crc = 0;
module_param(use_spi_crc, bool, 0755);
/*
* We normally treat cards as removed during suspend if they are not
* known to be on a non-removable bus, to avoid the risk of writing
* back data to a different card after resume. Allow this to be
* overridden if necessary.
*/
#ifdef CONFIG_MMC_UNSAFE_RESUME
bool mmc_assume_removable;
#else
bool mmc_assume_removable = 1;
#endif
EXPORT_SYMBOL(mmc_assume_removable);
module_param_named(removable, mmc_assume_removable, bool, 0644);
MODULE_PARM_DESC(
removable,
"MMC/SD cards are removable and may be removed during suspend");
/*
* Internal function. Schedule delayed work in the MMC work queue.
*/
static int mmc_schedule_delayed_work(struct delayed_work *work,
unsigned long delay)
{
return queue_delayed_work(workqueue, work, delay);
}
/*
* Internal function. Flush all scheduled work from the MMC work queue.
*/
static void mmc_flush_scheduled_work(void)
{
flush_workqueue(workqueue);
}
#ifdef CONFIG_FAIL_MMC_REQUEST
/*
* Internal function. Inject random data errors.
* If mmc_data is NULL no errors are injected.
*/
static void mmc_should_fail_request(struct mmc_host *host,
struct mmc_request *mrq)
{
struct mmc_command *cmd = mrq->cmd;
struct mmc_data *data = mrq->data;
static const int data_errors[] = {
-ETIMEDOUT,
-EILSEQ,
-EIO,
};
if (!data)
return;
if (cmd->error || data->error ||
!should_fail(&host->fail_mmc_request, data->blksz * data->blocks))
return;
data->error = data_errors[random32() % ARRAY_SIZE(data_errors)];
data->bytes_xfered = (random32() % (data->bytes_xfered >> 9)) << 9;
data->fault_injected = true;
}
#else /* CONFIG_FAIL_MMC_REQUEST */
static inline void mmc_should_fail_request(struct mmc_host *host,
struct mmc_request *mrq)
{
}
#endif /* CONFIG_FAIL_MMC_REQUEST */
/**
* mmc_request_done - finish processing an MMC request
* @host: MMC host which completed request
* @mrq: MMC request which request
*
* MMC drivers should call this function when they have completed
* their processing of a request.
*/
void mmc_request_done(struct mmc_host *host, struct mmc_request *mrq)
{
struct mmc_command *cmd = mrq->cmd;
int err = cmd->error;
#ifdef CONFIG_MMC_PERF_PROFILING
ktime_t diff;
#endif
if (host->card && host->clk_scaling.enable)
host->clk_scaling.busy_time_us +=
ktime_to_us(ktime_sub(ktime_get(),
host->clk_scaling.start_busy));
if (err && cmd->retries && mmc_host_is_spi(host)) {
if (cmd->resp[0] & R1_SPI_ILLEGAL_COMMAND)
cmd->retries = 0;
}
if (err && cmd->retries && !mmc_card_removed(host->card)) {
/*
* Request starter must handle retries - see
* mmc_wait_for_req_done().
*/
if (mrq->done)
mrq->done(mrq);
} else {
mmc_should_fail_request(host, mrq);
led_trigger_event(host->led, LED_OFF);
pr_debug("%s: req done (CMD%u): %d: %08x %08x %08x %08x\n",
mmc_hostname(host), cmd->opcode, err,
cmd->resp[0], cmd->resp[1],
cmd->resp[2], cmd->resp[3]);
if (mrq->data) {
#ifdef CONFIG_MMC_PERF_PROFILING
if (host->perf_enable) {
diff = ktime_sub(ktime_get(), host->perf.start);
if (mrq->data->flags == MMC_DATA_READ) {
host->perf.rbytes_drv +=
mrq->data->bytes_xfered;
host->perf.rtime_drv =
ktime_add(host->perf.rtime_drv,
diff);
} else {
host->perf.wbytes_drv +=
mrq->data->bytes_xfered;
host->perf.wtime_drv =
ktime_add(host->perf.wtime_drv,
diff);
}
}
#endif
pr_debug("%s: %d bytes transferred: %d\n",
mmc_hostname(host),
mrq->data->bytes_xfered, mrq->data->error);
}
if (mrq->stop) {
pr_debug("%s: (CMD%u): %d: %08x %08x %08x %08x\n",
mmc_hostname(host), mrq->stop->opcode,
mrq->stop->error,
mrq->stop->resp[0], mrq->stop->resp[1],
mrq->stop->resp[2], mrq->stop->resp[3]);
}
if (mrq->done)
mrq->done(mrq);
mmc_host_clk_release(host);
}
}
EXPORT_SYMBOL(mmc_request_done);
static void
mmc_start_request(struct mmc_host *host, struct mmc_request *mrq)
{
#ifdef CONFIG_MMC_DEBUG
unsigned int i, sz;
struct scatterlist *sg;
#endif
if (mrq->sbc) {
pr_debug("<%s: starting CMD%u arg %08x flags %08x>\n",
mmc_hostname(host), mrq->sbc->opcode,
mrq->sbc->arg, mrq->sbc->flags);
}
pr_debug("%s: starting CMD%u arg %08x flags %08x\n",
mmc_hostname(host), mrq->cmd->opcode,
mrq->cmd->arg, mrq->cmd->flags);
if (mrq->data) {
pr_debug("%s: blksz %d blocks %d flags %08x "
"tsac %d ms nsac %d\n",
mmc_hostname(host), mrq->data->blksz,
mrq->data->blocks, mrq->data->flags,
mrq->data->timeout_ns / 1000000,
mrq->data->timeout_clks);
}
if (mrq->stop) {
pr_debug("%s: CMD%u arg %08x flags %08x\n",
mmc_hostname(host), mrq->stop->opcode,
mrq->stop->arg, mrq->stop->flags);
}
WARN_ON(!host->claimed);
mrq->cmd->error = 0;
mrq->cmd->mrq = mrq;
if (mrq->data) {
BUG_ON(mrq->data->blksz > host->max_blk_size);
BUG_ON(mrq->data->blocks > host->max_blk_count);
BUG_ON(mrq->data->blocks * mrq->data->blksz >
host->max_req_size);
#ifdef CONFIG_MMC_DEBUG
sz = 0;
for_each_sg(mrq->data->sg, sg, mrq->data->sg_len, i)
sz += sg->length;
BUG_ON(sz != mrq->data->blocks * mrq->data->blksz);
#endif
mrq->cmd->data = mrq->data;
mrq->data->error = 0;
mrq->data->mrq = mrq;
if (mrq->stop) {
mrq->data->stop = mrq->stop;
mrq->stop->error = 0;
mrq->stop->mrq = mrq;
}
#ifdef CONFIG_MMC_PERF_PROFILING
if (host->perf_enable)
host->perf.start = ktime_get();
#endif
}
mmc_host_clk_hold(host);
led_trigger_event(host->led, LED_FULL);
if (host->card && host->clk_scaling.enable) {
/*
* Check if we need to scale the clocks. Clocks
* will be scaled up immediately if necessary
* conditions are satisfied. Scaling down the
* frequency will be done after current thread
* releases host.
*/
mmc_clk_scaling(host, false);
host->clk_scaling.start_busy = ktime_get();
}
host->ops->request(host, mrq);
}
/**
* mmc_start_delayed_bkops() - Start a delayed work to check for
* the need of non urgent BKOPS
*
* @card: MMC card to start BKOPS on
*/
void mmc_start_delayed_bkops(struct mmc_card *card)
{
if (!card || !card->ext_csd.bkops_en || mmc_card_doing_bkops(card))
return;
if (card->bkops_info.sectors_changed <
card->bkops_info.min_sectors_to_queue_delayed_work)
return;
pr_debug("%s: %s: queueing delayed_bkops_work\n",
mmc_hostname(card->host), __func__);
/*
* cancel_delayed_bkops_work will prevent a race condition between
* fetching a request by the mmcqd and the delayed work, in case
* it was removed from the queue work but not started yet
*/
card->bkops_info.cancel_delayed_work = false;
queue_delayed_work(system_nrt_wq, &card->bkops_info.dw,
msecs_to_jiffies(
card->bkops_info.delay_ms));
}
EXPORT_SYMBOL(mmc_start_delayed_bkops);
/**
* mmc_start_bkops - start BKOPS for supported cards
* @card: MMC card to start BKOPS
* @from_exception: A flag to indicate if this function was
* called due to an exception raised by the card
*
* Start background operations whenever requested.
* When the urgent BKOPS bit is set in a R1 command response
* then background operations should be started immediately.
*/
void mmc_start_bkops(struct mmc_card *card, bool from_exception)
{
int err;
BUG_ON(!card);
if (!card->ext_csd.bkops_en)
return;
if ((card->bkops_info.cancel_delayed_work) && !from_exception) {
pr_debug("%s: %s: cancel_delayed_work was set, exit\n",
mmc_hostname(card->host), __func__);
card->bkops_info.cancel_delayed_work = false;
return;
}
/* In case of delayed bkops we might be in race with suspend. */
if (!mmc_try_claim_host(card->host))
return;
/*
* Since the cancel_delayed_work can be changed while we are waiting
* for the lock we will to re-check it
*/
if ((card->bkops_info.cancel_delayed_work) && !from_exception) {
pr_debug("%s: %s: cancel_delayed_work was set, exit\n",
mmc_hostname(card->host), __func__);
card->bkops_info.cancel_delayed_work = false;
goto out;
}
if (mmc_card_doing_bkops(card)) {
pr_debug("%s: %s: already doing bkops, exit\n",
mmc_hostname(card->host), __func__);
goto out;
}
if (from_exception && mmc_card_need_bkops(card))
goto out;
/*
* If the need BKOPS flag is set, there is no need to check if BKOPS
* is needed since we already know that it does
*/
if (!mmc_card_need_bkops(card)) {
err = mmc_read_bkops_status(card);
if (err) {
pr_err("%s: %s: Failed to read bkops status: %d\n",
mmc_hostname(card->host), __func__, err);
goto out;
}
if (!card->ext_csd.raw_bkops_status)
goto out;
pr_info("%s: %s: raw_bkops_status=0x%x, from_exception=%d\n",
mmc_hostname(card->host), __func__,
card->ext_csd.raw_bkops_status,
from_exception);
}
/*
* If the function was called due to exception, BKOPS will be performed
* after handling the last pending request
*/
if (from_exception) {
pr_debug("%s: %s: Level %d from exception, exit",
mmc_hostname(card->host), __func__,
card->ext_csd.raw_bkops_status);
mmc_card_set_need_bkops(card);
goto out;
}
pr_info("%s: %s: Starting bkops\n", mmc_hostname(card->host), __func__);
err = __mmc_switch(card, EXT_CSD_CMD_SET_NORMAL,
EXT_CSD_BKOPS_START, 1, 0, false, false);
if (err) {
pr_warn("%s: Error %d starting bkops\n",
mmc_hostname(card->host), err);
goto out;
}
mmc_card_clr_need_bkops(card);
mmc_card_set_doing_bkops(card);
out:
mmc_release_host(card->host);
}
EXPORT_SYMBOL(mmc_start_bkops);
/**
* mmc_start_idle_time_bkops() - check if a non urgent BKOPS is
* needed
* @work: The idle time BKOPS work
*/
void mmc_start_idle_time_bkops(struct work_struct *work)
{
struct mmc_card *card = container_of(work, struct mmc_card,
bkops_info.dw.work);
/*
* Prevent a race condition between mmc_stop_bkops and the delayed
* BKOPS work in case the delayed work is executed on another CPU
*/
if (card->bkops_info.cancel_delayed_work)
return;
mmc_start_bkops(card, false);
}
EXPORT_SYMBOL(mmc_start_idle_time_bkops);
static void mmc_wait_done(struct mmc_request *mrq)
{
complete(&mrq->completion);
}
static int __mmc_start_req(struct mmc_host *host, struct mmc_request *mrq)
{
init_completion(&mrq->completion);
mrq->done = mmc_wait_done;
if (mmc_card_removed(host->card)) {
mrq->cmd->error = -ENOMEDIUM;
complete(&mrq->completion);
return -ENOMEDIUM;
}
mmc_start_request(host, mrq);
return 0;
}
static void mmc_wait_for_req_done(struct mmc_host *host,
struct mmc_request *mrq)
{
struct mmc_command *cmd;
while (1) {
wait_for_completion_io(&mrq->completion);
cmd = mrq->cmd;
/*
* If host has timed out waiting for the commands which can be
* HPIed then let the caller handle the timeout error as it may
* want to send the HPI command to bring the card out of
* programming state.
*/
if (cmd->ignore_timeout && cmd->error == -ETIMEDOUT)
break;
if (!cmd->error || !cmd->retries ||
mmc_card_removed(host->card))
break;
pr_debug("%s: req failed (CMD%u): %d, retrying...\n",
mmc_hostname(host), cmd->opcode, cmd->error);
cmd->retries--;
cmd->error = 0;
host->ops->request(host, mrq);
}
}
/**
* mmc_pre_req - Prepare for a new request
* @host: MMC host to prepare command
* @mrq: MMC request to prepare for
* @is_first_req: true if there is no previous started request
* that may run in parellel to this call, otherwise false
*
* mmc_pre_req() is called in prior to mmc_start_req() to let
* host prepare for the new request. Preparation of a request may be
* performed while another request is running on the host.
*/
static void mmc_pre_req(struct mmc_host *host, struct mmc_request *mrq,
bool is_first_req)
{
if (host->ops->pre_req) {
mmc_host_clk_hold(host);
host->ops->pre_req(host, mrq, is_first_req);
mmc_host_clk_release(host);
}
}
/**
* mmc_post_req - Post process a completed request
* @host: MMC host to post process command
* @mrq: MMC request to post process for
* @err: Error, if non zero, clean up any resources made in pre_req
*
* Let the host post process a completed request. Post processing of
* a request may be performed while another reuqest is running.
*/
static void mmc_post_req(struct mmc_host *host, struct mmc_request *mrq,
int err)
{
if (host->ops->post_req) {
mmc_host_clk_hold(host);
host->ops->post_req(host, mrq, err);
mmc_host_clk_release(host);
}
}
/**
* mmc_start_req - start a non-blocking request
* @host: MMC host to start command
* @areq: async request to start
* @error: out parameter returns 0 for success, otherwise non zero
*
* Start a new MMC custom command request for a host.
* If there is on ongoing async request wait for completion
* of that request and start the new one and return.
* Does not wait for the new request to complete.
*
* Returns the completed request, NULL in case of none completed.
* Wait for the an ongoing request (previoulsy started) to complete and
* return the completed request. If there is no ongoing request, NULL
* is returned without waiting. NULL is not an error condition.
*/
struct mmc_async_req *mmc_start_req(struct mmc_host *host,
struct mmc_async_req *areq, int *error)
{
int err = 0;
int start_err = 0;
struct mmc_async_req *data = host->areq;
/* Prepare a new request */
if (areq)
mmc_pre_req(host, areq->mrq, !host->areq);
if (host->areq) {
mmc_wait_for_req_done(host, host->areq->mrq);
err = host->areq->err_check(host->card, host->areq);
/*
* Check BKOPS urgency for each R1 response
*/
if (host->card && mmc_card_mmc(host->card) &&
((mmc_resp_type(host->areq->mrq->cmd) == MMC_RSP_R1) ||
(mmc_resp_type(host->areq->mrq->cmd) == MMC_RSP_R1B)) &&
(host->areq->mrq->cmd->resp[0] & R1_EXCEPTION_EVENT))
mmc_start_bkops(host->card, true);
}
if (!err && areq)
start_err = __mmc_start_req(host, areq->mrq);
if (host->areq)
mmc_post_req(host, host->areq->mrq, 0);
/* Cancel a prepared request if it was not started. */
if ((err || start_err) && areq)
mmc_post_req(host, areq->mrq, -EINVAL);
if (err)
host->areq = NULL;
else
host->areq = areq;
if (error)
*error = err;
return data;
}
EXPORT_SYMBOL(mmc_start_req);
/**
* mmc_wait_for_req - start a request and wait for completion
* @host: MMC host to start command
* @mrq: MMC request to start
*
* Start a new MMC custom command request for a host, and wait
* for the command to complete. Does not attempt to parse the
* response.
*/
void mmc_wait_for_req(struct mmc_host *host, struct mmc_request *mrq)
{
__mmc_start_req(host, mrq);
mmc_wait_for_req_done(host, mrq);
}
EXPORT_SYMBOL(mmc_wait_for_req);
bool mmc_card_is_prog_state(struct mmc_card *card)
{
bool rc;
struct mmc_command cmd;
mmc_claim_host(card->host);
memset(&cmd, 0, sizeof(struct mmc_command));
cmd.opcode = MMC_SEND_STATUS;
if (!mmc_host_is_spi(card->host))
cmd.arg = card->rca << 16;
cmd.flags = MMC_RSP_R1 | MMC_CMD_AC;
rc = mmc_wait_for_cmd(card->host, &cmd, 0);
if (rc) {
pr_err("%s: Get card status fail. rc=%d\n",
mmc_hostname(card->host), rc);
rc = false;
goto out;
}
if (R1_CURRENT_STATE(cmd.resp[0]) == R1_STATE_PRG)
rc = true;
else
rc = false;
out:
mmc_release_host(card->host);
return rc;
}
EXPORT_SYMBOL(mmc_card_is_prog_state);
/**
* mmc_interrupt_hpi - Issue for High priority Interrupt
* @card: the MMC card associated with the HPI transfer
*
* Issued High Priority Interrupt, and check for card status
* until out-of prg-state.
*/
int mmc_interrupt_hpi(struct mmc_card *card)
{
int err;
u32 status;
BUG_ON(!card);
if (!card->ext_csd.hpi_en) {
pr_info("%s: HPI enable bit unset\n", mmc_hostname(card->host));
return 1;
}
mmc_claim_host(card->host);
err = mmc_send_status(card, &status);
if (err) {
pr_err("%s: Get card status fail\n", mmc_hostname(card->host));
goto out;
}
/*
* If the card status is in PRG-state, we can send the HPI command.
*/
if (R1_CURRENT_STATE(status) == R1_STATE_PRG) {
do {
/*
* We don't know when the HPI command will finish
* processing, so we need to resend HPI until out
* of prg-state, and keep checking the card status
* with SEND_STATUS. If a timeout error occurs when
* sending the HPI command, we are already out of
* prg-state.
*/
err = mmc_send_hpi_cmd(card, &status);
if (err)
pr_debug("%s: abort HPI (%d error)\n",
mmc_hostname(card->host), err);
err = mmc_send_status(card, &status);
if (err)
break;
} while (R1_CURRENT_STATE(status) == R1_STATE_PRG);
} else
pr_debug("%s: Left prg-state\n", mmc_hostname(card->host));
out:
mmc_release_host(card->host);
return err;
}
EXPORT_SYMBOL(mmc_interrupt_hpi);
/**
* mmc_wait_for_cmd - start a command and wait for completion
* @host: MMC host to start command
* @cmd: MMC command to start
* @retries: maximum number of retries
*
* Start a new MMC command for a host, and wait for the command
* to complete. Return any error that occurred while the command
* was executing. Do not attempt to parse the response.
*/
int mmc_wait_for_cmd(struct mmc_host *host, struct mmc_command *cmd, int retries)
{
struct mmc_request mrq = {NULL};
WARN_ON(!host->claimed);
memset(cmd->resp, 0, sizeof(cmd->resp));
cmd->retries = retries;
mrq.cmd = cmd;
cmd->data = NULL;
mmc_wait_for_req(host, &mrq);
return cmd->error;
}
EXPORT_SYMBOL(mmc_wait_for_cmd);
/**
* mmc_stop_bkops - stop ongoing BKOPS
* @card: MMC card to check BKOPS
*
* Send HPI command to stop ongoing background operations to
* allow rapid servicing of foreground operations, e.g. read/
* writes. Wait until the card comes out of the programming state
* to avoid errors in servicing read/write requests.
*
* The function should be called with host claimed.
*/
int mmc_stop_bkops(struct mmc_card *card)
{
int err = 0;
BUG_ON(!card);
/*
* Notify the delayed work to be cancelled, in case it was already
* removed from the queue, but was not started yet
*/
card->bkops_info.cancel_delayed_work = true;
if (delayed_work_pending(&card->bkops_info.dw))
cancel_delayed_work_sync(&card->bkops_info.dw);
if (!mmc_card_doing_bkops(card))
goto out;
/*
* If idle time bkops is running on the card, let's not get into
* suspend.
*/
if (mmc_card_doing_bkops(card)
&& (card->host->parent->power.runtime_status == RPM_SUSPENDING)
&& mmc_card_is_prog_state(card)) {
err = -EBUSY;
goto out;
}
err = mmc_interrupt_hpi(card);
/*
* If err is EINVAL, we can't issue an HPI.
* It should complete the BKOPS.
*/
if (!err || (err == -EINVAL)) {
mmc_card_clr_doing_bkops(card);
err = 0;
}
out:
return err;
}
EXPORT_SYMBOL(mmc_stop_bkops);
int mmc_read_bkops_status(struct mmc_card *card)
{
int err;
u8 *ext_csd;
/*
* In future work, we should consider storing the entire ext_csd.
*/
ext_csd = kmalloc(512, GFP_KERNEL);
if (!ext_csd) {
pr_err("%s: could not allocate buffer to receive the ext_csd.\n",
mmc_hostname(card->host));
return -ENOMEM;
}
mmc_claim_host(card->host);
err = mmc_send_ext_csd(card, ext_csd);
mmc_release_host(card->host);
if (err)
goto out;
card->ext_csd.raw_bkops_status = ext_csd[EXT_CSD_BKOPS_STATUS];
card->ext_csd.raw_exception_status = ext_csd[EXT_CSD_EXP_EVENTS_STATUS];
out:
kfree(ext_csd);
return err;
}
EXPORT_SYMBOL(mmc_read_bkops_status);
/**
* mmc_set_data_timeout - set the timeout for a data command
* @data: data phase for command
* @card: the MMC card associated with the data transfer
*
* Computes the data timeout parameters according to the
* correct algorithm given the card type.
*/
void mmc_set_data_timeout(struct mmc_data *data, const struct mmc_card *card)
{
unsigned int mult;
/*
* SDIO cards only define an upper 1 s limit on access.
*/
if (mmc_card_sdio(card)) {
data->timeout_ns = 1000000000;
data->timeout_clks = 0;
return;
}
/*
* SD cards use a 100 multiplier rather than 10
*/
mult = mmc_card_sd(card) ? 100 : 10;
/*
* Scale up the multiplier (and therefore the timeout) by
* the r2w factor for writes.
*/
if (data->flags & MMC_DATA_WRITE)
mult <<= card->csd.r2w_factor;
data->timeout_ns = card->csd.tacc_ns * mult;
data->timeout_clks = card->csd.tacc_clks * mult;
/*
* SD cards also have an upper limit on the timeout.
*/
if (mmc_card_sd(card)) {
unsigned int timeout_us, limit_us;
timeout_us = data->timeout_ns / 1000;
if (mmc_host_clk_rate(card->host))
timeout_us += data->timeout_clks * 1000 /
(mmc_host_clk_rate(card->host) / 1000);
if (data->flags & MMC_DATA_WRITE)
/*
* The MMC spec "It is strongly recommended
* for hosts to implement more than 500ms
* timeout value even if the card indicates
* the 250ms maximum busy length." Even the
* previous value of 300ms is known to be
* insufficient for some cards.
*/
limit_us = 3000000;
else
limit_us = 100000;
/*
* SDHC cards always use these fixed values.
*/
if (timeout_us > limit_us || mmc_card_blockaddr(card)) {
data->timeout_ns = limit_us * 1000;
data->timeout_clks = 0;
}
}
/*
* Some cards require longer data read timeout than indicated in CSD.
* Address this by setting the read timeout to a "reasonably high"
* value. For the cards tested, 300ms has proven enough. If necessary,
* this value can be increased if other problematic cards require this.
*/
if (mmc_card_long_read_time(card) && data->flags & MMC_DATA_READ) {
data->timeout_ns = 300000000;
data->timeout_clks = 0;
}
/*
* Some cards need very high timeouts if driven in SPI mode.
* The worst observed timeout was 900ms after writing a
* continuous stream of data until the internal logic
* overflowed.
*/
if (mmc_host_is_spi(card->host)) {
if (data->flags & MMC_DATA_WRITE) {
if (data->timeout_ns < 1000000000)
data->timeout_ns = 1000000000; /* 1s */
} else {
if (data->timeout_ns < 100000000)
data->timeout_ns = 100000000; /* 100ms */
}
}
/* Increase the timeout values for some bad INAND MCP devices */
if (card->quirks & MMC_QUIRK_INAND_DATA_TIMEOUT) {
data->timeout_ns = 4000000000u; /* 4s */
data->timeout_clks = 0;
}
}
EXPORT_SYMBOL(mmc_set_data_timeout);
/**
* mmc_align_data_size - pads a transfer size to a more optimal value
* @card: the MMC card associated with the data transfer
* @sz: original transfer size
*
* Pads the original data size with a number of extra bytes in
* order to avoid controller bugs and/or performance hits
* (e.g. some controllers revert to PIO for certain sizes).
*
* Returns the improved size, which might be unmodified.
*
* Note that this function is only relevant when issuing a
* single scatter gather entry.
*/
unsigned int mmc_align_data_size(struct mmc_card *card, unsigned int sz)
{
/*
* FIXME: We don't have a system for the controller to tell
* the core about its problems yet, so for now we just 32-bit
* align the size.
*/
sz = ((sz + 3) / 4) * 4;
return sz;
}
EXPORT_SYMBOL(mmc_align_data_size);
/**
* __mmc_claim_host - exclusively claim a host
* @host: mmc host to claim
* @abort: whether or not the operation should be aborted
*
* Claim a host for a set of operations. If @abort is non null and
* dereference a non-zero value then this will return prematurely with
* that non-zero value without acquiring the lock. Returns zero
* with the lock held otherwise.
*/
int __mmc_claim_host(struct mmc_host *host, atomic_t *abort)
{
DECLARE_WAITQUEUE(wait, current);
unsigned long flags;
int stop;
might_sleep();
add_wait_queue(&host->wq, &wait);
spin_lock_irqsave(&host->lock, flags);
while (1) {
set_current_state(TASK_UNINTERRUPTIBLE);
stop = abort ? atomic_read(abort) : 0;
if (stop || !host->claimed || host->claimer == current)
break;
spin_unlock_irqrestore(&host->lock, flags);
schedule();
spin_lock_irqsave(&host->lock, flags);
}
set_current_state(TASK_RUNNING);
if (!stop) {
host->claimed = 1;
host->claimer = current;
host->claim_cnt += 1;
} else
wake_up(&host->wq);
spin_unlock_irqrestore(&host->lock, flags);
remove_wait_queue(&host->wq, &wait);
if (host->ops->enable && !stop && host->claim_cnt == 1)
host->ops->enable(host);
return stop;
}
EXPORT_SYMBOL(__mmc_claim_host);
/**
* mmc_try_claim_host - try exclusively to claim a host
* @host: mmc host to claim
*
* Returns %1 if the host is claimed, %0 otherwise.
*/
int mmc_try_claim_host(struct mmc_host *host)
{
int claimed_host = 0;
unsigned long flags;
spin_lock_irqsave(&host->lock, flags);
if (!host->claimed || host->claimer == current) {
host->claimed = 1;
host->claimer = current;
host->claim_cnt += 1;
claimed_host = 1;
}
spin_unlock_irqrestore(&host->lock, flags);
if (host->ops->enable && claimed_host && host->claim_cnt == 1)
host->ops->enable(host);
return claimed_host;
}
EXPORT_SYMBOL(mmc_try_claim_host);
/**
* mmc_release_host - release a host
* @host: mmc host to release
*
* Release a MMC host, allowing others to claim the host
* for their operations.
*/
void mmc_release_host(struct mmc_host *host)
{
unsigned long flags;
WARN_ON(!host->claimed);
if (host->ops->disable && host->claim_cnt == 1)
host->ops->disable(host);
spin_lock_irqsave(&host->lock, flags);
if (--host->claim_cnt) {
/* Release for nested claim */
spin_unlock_irqrestore(&host->lock, flags);
} else {
host->claimed = 0;
host->claimer = NULL;
spin_unlock_irqrestore(&host->lock, flags);
wake_up(&host->wq);
}
}
EXPORT_SYMBOL(mmc_release_host);
/*
* Internal function that does the actual ios call to the host driver,
* optionally printing some debug output.
*/
void mmc_set_ios(struct mmc_host *host)
{
struct mmc_ios *ios = &host->ios;
pr_debug("%s: clock %uHz busmode %u powermode %u cs %u Vdd %u "
"width %u timing %u\n",
mmc_hostname(host), ios->clock, ios->bus_mode,
ios->power_mode, ios->chip_select, ios->vdd,
ios->bus_width, ios->timing);
if (ios->clock > 0)
mmc_set_ungated(host);
host->ops->set_ios(host, ios);
if (ios->old_rate != ios->clock) {
if (likely(ios->clk_ts)) {
char trace_info[80];
snprintf(trace_info, 80,
"%s: freq_KHz %d --> %d | t = %d",
mmc_hostname(host), ios->old_rate / 1000,
ios->clock / 1000, jiffies_to_msecs(
(long)jiffies - (long)ios->clk_ts));
trace_mmc_clk(trace_info);
}
ios->old_rate = ios->clock;
ios->clk_ts = jiffies;
}
}
EXPORT_SYMBOL(mmc_set_ios);
/*
* Control chip select pin on a host.
*/
void mmc_set_chip_select(struct mmc_host *host, int mode)
{
mmc_host_clk_hold(host);
host->ios.chip_select = mode;
mmc_set_ios(host);
mmc_host_clk_release(host);
}
/*
* Sets the host clock to the highest possible frequency that
* is below "hz".
*/
static void __mmc_set_clock(struct mmc_host *host, unsigned int hz)
{
WARN_ON(hz < host->f_min);
if (hz > host->f_max)
hz = host->f_max;
host->ios.clock = hz;
mmc_set_ios(host);
}
void mmc_set_clock(struct mmc_host *host, unsigned int hz)
{
mmc_host_clk_hold(host);
__mmc_set_clock(host, hz);
mmc_host_clk_release(host);
}
#ifdef CONFIG_MMC_CLKGATE
/*
* This gates the clock by setting it to 0 Hz.
*/
void mmc_gate_clock(struct mmc_host *host)
{
unsigned long flags;
WARN_ON(!host->ios.clock);
spin_lock_irqsave(&host->clk_lock, flags);
host->clk_old = host->ios.clock;
host->ios.clock = 0;
host->clk_gated = true;
spin_unlock_irqrestore(&host->clk_lock, flags);
mmc_set_ios(host);
}
/*
* This restores the clock from gating by using the cached
* clock value.
*/
void mmc_ungate_clock(struct mmc_host *host)
{
/*
* We should previously have gated the clock, so the clock shall
* be 0 here! The clock may however be 0 during initialization,
* when some request operations are performed before setting
* the frequency. When ungate is requested in that situation
* we just ignore the call.
*/
if (host->clk_old) {
WARN_ON(host->ios.clock);
/* This call will also set host->clk_gated to false */
__mmc_set_clock(host, host->clk_old);
}
}
void mmc_set_ungated(struct mmc_host *host)
{
unsigned long flags;
/*
* We've been given a new frequency while the clock is gated,
* so make sure we regard this as ungating it.
*/
spin_lock_irqsave(&host->clk_lock, flags);
host->clk_gated = false;
spin_unlock_irqrestore(&host->clk_lock, flags);
}
#else
void mmc_set_ungated(struct mmc_host *host)
{
}
#endif
/*
* Change the bus mode (open drain/push-pull) of a host.
*/
void mmc_set_bus_mode(struct mmc_host *host, unsigned int mode)
{
mmc_host_clk_hold(host);
host->ios.bus_mode = mode;
mmc_set_ios(host);
mmc_host_clk_release(host);
}
/*
* Change data bus width of a host.
*/
void mmc_set_bus_width(struct mmc_host *host, unsigned int width)
{
mmc_host_clk_hold(host);
host->ios.bus_width = width;
mmc_set_ios(host);
mmc_host_clk_release(host);
}
/**
* mmc_vdd_to_ocrbitnum - Convert a voltage to the OCR bit number
* @vdd: voltage (mV)
* @low_bits: prefer low bits in boundary cases
*
* This function returns the OCR bit number according to the provided @vdd
* value. If conversion is not possible a negative errno value returned.
*
* Depending on the @low_bits flag the function prefers low or high OCR bits
* on boundary voltages. For example,
* with @low_bits = true, 3300 mV translates to ilog2(MMC_VDD_32_33);
* with @low_bits = false, 3300 mV translates to ilog2(MMC_VDD_33_34);
*
* Any value in the [1951:1999] range translates to the ilog2(MMC_VDD_20_21).
*/
static int mmc_vdd_to_ocrbitnum(int vdd, bool low_bits)
{
const int max_bit = ilog2(MMC_VDD_35_36);
int bit;
if (vdd < 1650 || vdd > 3600)
return -EINVAL;
if (vdd >= 1650 && vdd <= 1950)
return ilog2(MMC_VDD_165_195);
if (low_bits)
vdd -= 1;
/* Base 2000 mV, step 100 mV, bit's base 8. */
bit = (vdd - 2000) / 100 + 8;
if (bit > max_bit)
return max_bit;
return bit;
}
/**
* mmc_vddrange_to_ocrmask - Convert a voltage range to the OCR mask
* @vdd_min: minimum voltage value (mV)
* @vdd_max: maximum voltage value (mV)
*
* This function returns the OCR mask bits according to the provided @vdd_min
* and @vdd_max values. If conversion is not possible the function returns 0.
*
* Notes wrt boundary cases:
* This function sets the OCR bits for all boundary voltages, for example
* [3300:3400] range is translated to MMC_VDD_32_33 | MMC_VDD_33_34 |
* MMC_VDD_34_35 mask.
*/
u32 mmc_vddrange_to_ocrmask(int vdd_min, int vdd_max)
{
u32 mask = 0;
if (vdd_max < vdd_min)
return 0;
/* Prefer high bits for the boundary vdd_max values. */
vdd_max = mmc_vdd_to_ocrbitnum(vdd_max, false);
if (vdd_max < 0)
return 0;
/* Prefer low bits for the boundary vdd_min values. */
vdd_min = mmc_vdd_to_ocrbitnum(vdd_min, true);
if (vdd_min < 0)
return 0;
/* Fill the mask, from max bit to min bit. */
while (vdd_max >= vdd_min)
mask |= 1 << vdd_max--;
return mask;
}
EXPORT_SYMBOL(mmc_vddrange_to_ocrmask);
#ifdef CONFIG_REGULATOR
/**
* mmc_regulator_get_ocrmask - return mask of supported voltages
* @supply: regulator to use
*
* This returns either a negative errno, or a mask of voltages that
* can be provided to MMC/SD/SDIO devices using the specified voltage
* regulator. This would normally be called before registering the
* MMC host adapter.
*/
int mmc_regulator_get_ocrmask(struct regulator *supply)
{
int result = 0;
int count;
int i;
count = regulator_count_voltages(supply);
if (count < 0)
return count;
for (i = 0; i < count; i++) {
int vdd_uV;
int vdd_mV;
vdd_uV = regulator_list_voltage(supply, i);
if (vdd_uV <= 0)
continue;
vdd_mV = vdd_uV / 1000;
result |= mmc_vddrange_to_ocrmask(vdd_mV, vdd_mV);
}
return result;
}
EXPORT_SYMBOL(mmc_regulator_get_ocrmask);
/**
* mmc_regulator_set_ocr - set regulator to match host->ios voltage
* @mmc: the host to regulate
* @supply: regulator to use
* @vdd_bit: zero for power off, else a bit number (host->ios.vdd)
*
* Returns zero on success, else negative errno.
*
* MMC host drivers may use this to enable or disable a regulator using
* a particular supply voltage. This would normally be called from the
* set_ios() method.
*/
int mmc_regulator_set_ocr(struct mmc_host *mmc,
struct regulator *supply,
unsigned short vdd_bit)
{
int result = 0;
int min_uV, max_uV;
if (vdd_bit) {
int tmp;
int voltage;
/* REVISIT mmc_vddrange_to_ocrmask() may have set some
* bits this regulator doesn't quite support ... don't
* be too picky, most cards and regulators are OK with
* a 0.1V range goof (it's a small error percentage).
*/
tmp = vdd_bit - ilog2(MMC_VDD_165_195);
if (tmp == 0) {
min_uV = 1650 * 1000;
max_uV = 1950 * 1000;
} else {
min_uV = 1900 * 1000 + tmp * 100 * 1000;
max_uV = min_uV + 100 * 1000;
}
/* avoid needless changes to this voltage; the regulator
* might not allow this operation
*/
voltage = regulator_get_voltage(supply);
if (mmc->caps2 & MMC_CAP2_BROKEN_VOLTAGE)
min_uV = max_uV = voltage;
if (voltage < 0)
result = voltage;
else if (voltage < min_uV || voltage > max_uV)
result = regulator_set_voltage(supply, min_uV, max_uV);
else
result = 0;
if (result == 0 && !mmc->regulator_enabled) {
result = regulator_enable(supply);
if (!result)
mmc->regulator_enabled = true;
}
} else if (mmc->regulator_enabled) {
result = regulator_disable(supply);
if (result == 0)
mmc->regulator_enabled = false;
}
if (result)
dev_err(mmc_dev(mmc),
"could not set regulator OCR (%d)\n", result);
return result;
}
EXPORT_SYMBOL(mmc_regulator_set_ocr);
#endif /* CONFIG_REGULATOR */
/*
* Mask off any voltages we don't support and select
* the lowest voltage
*/
u32 mmc_select_voltage(struct mmc_host *host, u32 ocr)
{
int bit;
ocr &= host->ocr_avail;
bit = ffs(ocr);
if (bit) {
bit -= 1;
ocr &= 3 << bit;
mmc_host_clk_hold(host);
host->ios.vdd = bit;
mmc_set_ios(host);
mmc_host_clk_release(host);
} else {
pr_warning("%s: host doesn't support card's voltages\n",
mmc_hostname(host));
ocr = 0;
}
return ocr;
}
int mmc_set_signal_voltage(struct mmc_host *host, int signal_voltage, bool cmd11)
{
struct mmc_command cmd = {0};
int err = 0;
BUG_ON(!host);
/*
* Send CMD11 only if the request is to switch the card to
* 1.8V signalling.
*/
if ((signal_voltage != MMC_SIGNAL_VOLTAGE_330) && cmd11) {
cmd.opcode = SD_SWITCH_VOLTAGE;
cmd.arg = 0;
cmd.flags = MMC_RSP_R1 | MMC_CMD_AC;
err = mmc_wait_for_cmd(host, &cmd, 0);
if (err)
return err;
if (!mmc_host_is_spi(host) && (cmd.resp[0] & R1_ERROR))
return -EIO;
}
host->ios.signal_voltage = signal_voltage;
if (host->ops->start_signal_voltage_switch) {
mmc_host_clk_hold(host);
err = host->ops->start_signal_voltage_switch(host, &host->ios);
mmc_host_clk_release(host);
}
return err;
}
/*
* Select timing parameters for host.
*/
void mmc_set_timing(struct mmc_host *host, unsigned int timing)
{
mmc_host_clk_hold(host);
host->ios.timing = timing;
mmc_set_ios(host);
mmc_host_clk_release(host);
}
/*
* Select appropriate driver type for host.
*/
void mmc_set_driver_type(struct mmc_host *host, unsigned int drv_type)
{
mmc_host_clk_hold(host);
host->ios.drv_type = drv_type;
mmc_set_ios(host);
mmc_host_clk_release(host);
}
/*
* Apply power to the MMC stack. This is a two-stage process.
* First, we enable power to the card without the clock running.
* We then wait a bit for the power to stabilise. Finally,
* enable the bus drivers and clock to the card.
*
* We must _NOT_ enable the clock prior to power stablising.
*
* If a host does all the power sequencing itself, ignore the
* initial MMC_POWER_UP stage.
*/
void mmc_power_up(struct mmc_host *host)
{
int bit;
mmc_host_clk_hold(host);
/* If ocr is set, we use it */
if (host->ocr)
bit = ffs(host->ocr) - 1;
else
bit = fls(host->ocr_avail) - 1;
host->ios.vdd = bit;
if (mmc_host_is_spi(host))
host->ios.chip_select = MMC_CS_HIGH;
else {
host->ios.chip_select = MMC_CS_DONTCARE;
host->ios.bus_mode = MMC_BUSMODE_OPENDRAIN;
}
host->ios.power_mode = MMC_POWER_UP;
host->ios.bus_width = MMC_BUS_WIDTH_1;
host->ios.timing = MMC_TIMING_LEGACY;
mmc_set_ios(host);
/*
* This delay should be sufficient to allow the power supply
* to reach the minimum voltage.
*/
mmc_delay(10);
host->ios.clock = host->f_init;
host->ios.power_mode = MMC_POWER_ON;
mmc_set_ios(host);
/*
* This delay must be at least 74 clock sizes, or 1 ms, or the
* time required to reach a stable voltage.
*/
mmc_delay(10);
mmc_host_clk_release(host);
}
void mmc_power_off(struct mmc_host *host)
{
mmc_host_clk_hold(host);
host->ios.clock = 0;
host->ios.vdd = 0;
/*
* Reset ocr mask to be the highest possible voltage supported for
* this mmc host. This value will be used at next power up.
*/
host->ocr = 1 << (fls(host->ocr_avail) - 1);
if (!mmc_host_is_spi(host)) {
host->ios.bus_mode = MMC_BUSMODE_OPENDRAIN;
host->ios.chip_select = MMC_CS_DONTCARE;
}
host->ios.power_mode = MMC_POWER_OFF;
host->ios.bus_width = MMC_BUS_WIDTH_1;
host->ios.timing = MMC_TIMING_LEGACY;
mmc_set_ios(host);
/*
* Some configurations, such as the 802.11 SDIO card in the OLPC
* XO-1.5, require a short delay after poweroff before the card
* can be successfully turned on again.
*/
mmc_delay(1);
mmc_host_clk_release(host);
}
/*
* Cleanup when the last reference to the bus operator is dropped.
*/
static void __mmc_release_bus(struct mmc_host *host)
{
BUG_ON(!host);
BUG_ON(host->bus_refs);
BUG_ON(!host->bus_dead);
host->bus_ops = NULL;
}
/*
* Increase reference count of bus operator
*/
static inline void mmc_bus_get(struct mmc_host *host)
{
unsigned long flags;
spin_lock_irqsave(&host->lock, flags);
host->bus_refs++;
spin_unlock_irqrestore(&host->lock, flags);
}
/*
* Decrease reference count of bus operator and free it if
* it is the last reference.
*/
static inline void mmc_bus_put(struct mmc_host *host)
{
unsigned long flags;
spin_lock_irqsave(&host->lock, flags);
host->bus_refs--;
if ((host->bus_refs == 0) && host->bus_ops)
__mmc_release_bus(host);
spin_unlock_irqrestore(&host->lock, flags);
}
int mmc_resume_bus(struct mmc_host *host)
{
unsigned long flags;
if (!mmc_bus_needs_resume(host))
return -EINVAL;
printk("%s: Starting deferred resume\n", mmc_hostname(host));
spin_lock_irqsave(&host->lock, flags);
host->bus_resume_flags &= ~MMC_BUSRESUME_NEEDS_RESUME;
host->rescan_disable = 0;
spin_unlock_irqrestore(&host->lock, flags);
mmc_bus_get(host);
if (host->bus_ops && !host->bus_dead) {
mmc_power_up(host);
BUG_ON(!host->bus_ops->resume);
host->bus_ops->resume(host);
}
if (host->bus_ops->detect && !host->bus_dead)
host->bus_ops->detect(host);
mmc_bus_put(host);
printk("%s: Deferred resume completed\n", mmc_hostname(host));
return 0;
}
EXPORT_SYMBOL(mmc_resume_bus);
/*
* Assign a mmc bus handler to a host. Only one bus handler may control a
* host at any given time.
*/
void mmc_attach_bus(struct mmc_host *host, const struct mmc_bus_ops *ops)
{
unsigned long flags;
BUG_ON(!host);
BUG_ON(!ops);
WARN_ON(!host->claimed);
spin_lock_irqsave(&host->lock, flags);
BUG_ON(host->bus_ops);
BUG_ON(host->bus_refs);
host->bus_ops = ops;
host->bus_refs = 1;
host->bus_dead = 0;
spin_unlock_irqrestore(&host->lock, flags);
}
/*
* Remove the current bus handler from a host.
*/
void mmc_detach_bus(struct mmc_host *host)
{
unsigned long flags;
BUG_ON(!host);
WARN_ON(!host->claimed);
WARN_ON(!host->bus_ops);
spin_lock_irqsave(&host->lock, flags);
host->bus_dead = 1;
spin_unlock_irqrestore(&host->lock, flags);
mmc_bus_put(host);
}
/**
* mmc_detect_change - process change of state on a MMC socket
* @host: host which changed state.
* @delay: optional delay to wait before detection (jiffies)
*
* MMC drivers should call this when they detect a card has been
* inserted or removed. The MMC layer will confirm that any
* present card is still functional, and initialize any newly
* inserted.
*/
void mmc_detect_change(struct mmc_host *host, unsigned long delay)
{
#ifdef CONFIG_MMC_DEBUG
unsigned long flags;
spin_lock_irqsave(&host->lock, flags);
WARN_ON(host->removed);
spin_unlock_irqrestore(&host->lock, flags);
#endif
host->detect_change = 1;
wake_lock(&host->detect_wake_lock);
mmc_schedule_delayed_work(&host->detect, delay);
}
EXPORT_SYMBOL(mmc_detect_change);
void mmc_init_erase(struct mmc_card *card)
{
unsigned int sz;
if (is_power_of_2(card->erase_size))
card->erase_shift = ffs(card->erase_size) - 1;
else
card->erase_shift = 0;
/*
* It is possible to erase an arbitrarily large area of an SD or MMC
* card. That is not desirable because it can take a long time
* (minutes) potentially delaying more important I/O, and also the
* timeout calculations become increasingly hugely over-estimated.
* Consequently, 'pref_erase' is defined as a guide to limit erases
* to that size and alignment.
*
* For SD cards that define Allocation Unit size, limit erases to one
* Allocation Unit at a time. For MMC cards that define High Capacity
* Erase Size, whether it is switched on or not, limit to that size.
* Otherwise just have a stab at a good value. For modern cards it
* will end up being 4MiB. Note that if the value is too small, it
* can end up taking longer to erase.
*/
if (mmc_card_sd(card) && card->ssr.au) {
card->pref_erase = card->ssr.au;
card->erase_shift = ffs(card->ssr.au) - 1;
} else if (card->ext_csd.hc_erase_size) {
card->pref_erase = card->ext_csd.hc_erase_size;
} else {
sz = (card->csd.capacity << (card->csd.read_blkbits - 9)) >> 11;
if (sz < 128)
card->pref_erase = 512 * 1024 / 512;
else if (sz < 512)
card->pref_erase = 1024 * 1024 / 512;
else if (sz < 1024)
card->pref_erase = 2 * 1024 * 1024 / 512;
else
card->pref_erase = 4 * 1024 * 1024 / 512;
if (card->pref_erase < card->erase_size)
card->pref_erase = card->erase_size;
else {
sz = card->pref_erase % card->erase_size;
if (sz)
card->pref_erase += card->erase_size - sz;
}
}
}
static unsigned int mmc_mmc_erase_timeout(struct mmc_card *card,
unsigned int arg, unsigned int qty)
{
unsigned int erase_timeout;
if (arg == MMC_DISCARD_ARG ||
(arg == MMC_TRIM_ARG && card->ext_csd.rev >= 6)) {
erase_timeout = card->ext_csd.trim_timeout;
} else if (card->ext_csd.erase_group_def & 1) {
/* High Capacity Erase Group Size uses HC timeouts */
if (arg == MMC_TRIM_ARG)
erase_timeout = card->ext_csd.trim_timeout;
else
erase_timeout = card->ext_csd.hc_erase_timeout;
} else {
/* CSD Erase Group Size uses write timeout */
unsigned int mult = (10 << card->csd.r2w_factor);
unsigned int timeout_clks = card->csd.tacc_clks * mult;
unsigned int timeout_us;
/* Avoid overflow: e.g. tacc_ns=80000000 mult=1280 */
if (card->csd.tacc_ns < 1000000)
timeout_us = (card->csd.tacc_ns * mult) / 1000;
else
timeout_us = (card->csd.tacc_ns / 1000) * mult;
/*
* ios.clock is only a target. The real clock rate might be
* less but not that much less, so fudge it by multiplying by 2.
*/
timeout_clks <<= 1;
timeout_us += (timeout_clks * 1000) /
(mmc_host_clk_rate(card->host) / 1000);
erase_timeout = timeout_us / 1000;
/*
* Theoretically, the calculation could underflow so round up
* to 1ms in that case.
*/
if (!erase_timeout)
erase_timeout = 1;
}
/* Multiplier for secure operations */
if (arg & MMC_SECURE_ARGS) {
if (arg == MMC_SECURE_ERASE_ARG)
erase_timeout *= card->ext_csd.sec_erase_mult;
else
erase_timeout *= card->ext_csd.sec_trim_mult;
}
erase_timeout *= qty;
/*
* Ensure at least a 1 second timeout for SPI as per
* 'mmc_set_data_timeout()'
*/
if (mmc_host_is_spi(card->host) && erase_timeout < 1000)
erase_timeout = 1000;
return erase_timeout;
}
static unsigned int mmc_sd_erase_timeout(struct mmc_card *card,
unsigned int arg,
unsigned int qty)
{
unsigned int erase_timeout;
if (card->ssr.erase_timeout) {
/* Erase timeout specified in SD Status Register (SSR) */
erase_timeout = card->ssr.erase_timeout * qty +
card->ssr.erase_offset;
} else {
/*
* Erase timeout not specified in SD Status Register (SSR) so
* use 250ms per write block.
*/
erase_timeout = 250 * qty;
}
/* Must not be less than 1 second */
if (erase_timeout < 1000)
erase_timeout = 1000;
return erase_timeout;
}
static unsigned int mmc_erase_timeout(struct mmc_card *card,
unsigned int arg,
unsigned int qty)
{
if (mmc_card_sd(card))
return mmc_sd_erase_timeout(card, arg, qty);
else
return mmc_mmc_erase_timeout(card, arg, qty);
}
static int mmc_do_erase(struct mmc_card *card, unsigned int from,
unsigned int to, unsigned int arg)
{
struct mmc_command cmd = {0};
unsigned int qty = 0;
unsigned long timeout;
int err;
/*
* qty is used to calculate the erase timeout which depends on how many
* erase groups (or allocation units in SD terminology) are affected.
* We count erasing part of an erase group as one erase group.
* For SD, the allocation units are always a power of 2. For MMC, the
* erase group size is almost certainly also power of 2, but it does not
* seem to insist on that in the JEDEC standard, so we fall back to
* division in that case. SD may not specify an allocation unit size,
* in which case the timeout is based on the number of write blocks.
*
* Note that the timeout for secure trim 2 will only be correct if the
* number of erase groups specified is the same as the total of all
* preceding secure trim 1 commands. Since the power may have been
* lost since the secure trim 1 commands occurred, it is generally
* impossible to calculate the secure trim 2 timeout correctly.
*/
if (card->erase_shift)
qty += ((to >> card->erase_shift) -
(from >> card->erase_shift)) + 1;
else if (mmc_card_sd(card))
qty += to - from + 1;
else
qty += ((to / card->erase_size) -
(from / card->erase_size)) + 1;
if (!mmc_card_blockaddr(card)) {
from <<= 9;
to <<= 9;
}
if (mmc_card_sd(card))
cmd.opcode = SD_ERASE_WR_BLK_START;
else
cmd.opcode = MMC_ERASE_GROUP_START;
cmd.arg = from;
cmd.flags = MMC_RSP_SPI_R1 | MMC_RSP_R1 | MMC_CMD_AC;
err = mmc_wait_for_cmd(card->host, &cmd, 0);
if (err) {
pr_err("mmc_erase: group start error %d, "
"status %#x\n", err, cmd.resp[0]);
err = -EIO;
goto out;
}
memset(&cmd, 0, sizeof(struct mmc_command));
if (mmc_card_sd(card))
cmd.opcode = SD_ERASE_WR_BLK_END;
else
cmd.opcode = MMC_ERASE_GROUP_END;
cmd.arg = to;
cmd.flags = MMC_RSP_SPI_R1 | MMC_RSP_R1 | MMC_CMD_AC;
err = mmc_wait_for_cmd(card->host, &cmd, 0);
if (err) {
pr_err("mmc_erase: group end error %d, status %#x\n",
err, cmd.resp[0]);
err = -EIO;
goto out;
}
memset(&cmd, 0, sizeof(struct mmc_command));
cmd.opcode = MMC_ERASE;
cmd.arg = arg;
cmd.flags = MMC_RSP_SPI_R1B | MMC_RSP_R1B | MMC_CMD_AC;
cmd.cmd_timeout_ms = mmc_erase_timeout(card, arg, qty);
err = mmc_wait_for_cmd(card->host, &cmd, 0);
if (err) {
pr_err("mmc_erase: erase error %d, status %#x\n",
err, cmd.resp[0]);
err = -EIO;
goto out;
}
if (mmc_host_is_spi(card->host))
goto out;
timeout = jiffies + msecs_to_jiffies(MMC_CORE_TIMEOUT_MS);
do {
memset(&cmd, 0, sizeof(struct mmc_command));
cmd.opcode = MMC_SEND_STATUS;
cmd.arg = card->rca << 16;
cmd.flags = MMC_RSP_R1 | MMC_CMD_AC;
/* Do not retry else we can't see errors */
err = mmc_wait_for_cmd(card->host, &cmd, 0);
if (err || (cmd.resp[0] & 0xFDF92000)) {
pr_err("error %d requesting status %#x\n",
err, cmd.resp[0]);
err = -EIO;
goto out;
}
/* Timeout if the device never becomes ready for data and
* never leaves the program state.
*/
if (time_after(jiffies, timeout)) {
pr_err("%s: Card stuck in programming state! %s\n",
mmc_hostname(card->host), __func__);
err = -EIO;
goto out;
}
} while (!(cmd.resp[0] & R1_READY_FOR_DATA) ||
(R1_CURRENT_STATE(cmd.resp[0]) == R1_STATE_PRG));
out:
return err;
}
/**
* mmc_erase - erase sectors.
* @card: card to erase
* @from: first sector to erase
* @nr: number of sectors to erase
* @arg: erase command argument (SD supports only %MMC_ERASE_ARG)
*
* Caller must claim host before calling this function.
*/
int mmc_erase(struct mmc_card *card, unsigned int from, unsigned int nr,
unsigned int arg)
{
unsigned int rem, to = from + nr;
if (!(card->host->caps & MMC_CAP_ERASE) ||
!(card->csd.cmdclass & CCC_ERASE))
return -EOPNOTSUPP;
if (!card->erase_size)
return -EOPNOTSUPP;
if (mmc_card_sd(card) && arg != MMC_ERASE_ARG)
return -EOPNOTSUPP;
if ((arg & MMC_SECURE_ARGS) &&
!(card->ext_csd.sec_feature_support & EXT_CSD_SEC_ER_EN))
return -EOPNOTSUPP;
if ((arg & MMC_TRIM_ARGS) &&
!(card->ext_csd.sec_feature_support & EXT_CSD_SEC_GB_CL_EN))
return -EOPNOTSUPP;
if (arg == MMC_SECURE_ERASE_ARG) {
if (from % card->erase_size || nr % card->erase_size)
return -EINVAL;
}
if (arg == MMC_ERASE_ARG) {
rem = from % card->erase_size;
if (rem) {
rem = card->erase_size - rem;
from += rem;
if (nr > rem)
nr -= rem;
else
return 0;
}
rem = nr % card->erase_size;
if (rem)
nr -= rem;
}
if (nr == 0)
return 0;
to = from + nr;
if (to <= from)
return -EINVAL;
/* 'from' and 'to' are inclusive */
to -= 1;
return mmc_do_erase(card, from, to, arg);
}
EXPORT_SYMBOL(mmc_erase);
int mmc_can_erase(struct mmc_card *card)
{
if ((card->host->caps & MMC_CAP_ERASE) &&
(card->csd.cmdclass & CCC_ERASE) && card->erase_size)
return 1;
return 0;
}
EXPORT_SYMBOL(mmc_can_erase);
int mmc_can_trim(struct mmc_card *card)
{
if (card->ext_csd.sec_feature_support & EXT_CSD_SEC_GB_CL_EN)
return 1;
return 0;
}
EXPORT_SYMBOL(mmc_can_trim);
int mmc_can_discard(struct mmc_card *card)
{
/*
* As there's no way to detect the discard support bit at v4.5
* use the s/w feature support filed.
*/
if (card->ext_csd.feature_support & MMC_DISCARD_FEATURE)
return 1;
return 0;
}
EXPORT_SYMBOL(mmc_can_discard);
int mmc_can_sanitize(struct mmc_card *card)
{
if (!mmc_can_trim(card) && !mmc_can_erase(card))
return 0;
if (card->ext_csd.sec_feature_support & EXT_CSD_SEC_SANITIZE)
return 1;
return 0;
}
EXPORT_SYMBOL(mmc_can_sanitize);
int mmc_can_secure_erase_trim(struct mmc_card *card)
{
if (card->ext_csd.sec_feature_support & EXT_CSD_SEC_ER_EN)
return 1;
return 0;
}
EXPORT_SYMBOL(mmc_can_secure_erase_trim);
int mmc_erase_group_aligned(struct mmc_card *card, unsigned int from,
unsigned int nr)
{
if (!card->erase_size)
return 0;
if (from % card->erase_size || nr % card->erase_size)
return 0;
return 1;
}
EXPORT_SYMBOL(mmc_erase_group_aligned);
static unsigned int mmc_do_calc_max_discard(struct mmc_card *card,
unsigned int arg)
{
struct mmc_host *host = card->host;
unsigned int max_discard, x, y, qty = 0, max_qty, timeout;
unsigned int last_timeout = 0;
if (card->erase_shift)
max_qty = UINT_MAX >> card->erase_shift;
else if (mmc_card_sd(card))
max_qty = UINT_MAX;
else
max_qty = UINT_MAX / card->erase_size;
/* Find the largest qty with an OK timeout */
do {
y = 0;
for (x = 1; x && x <= max_qty && max_qty - x >= qty; x <<= 1) {
timeout = mmc_erase_timeout(card, arg, qty + x);
if (timeout > host->max_discard_to)
break;
if (timeout < last_timeout)
break;
last_timeout = timeout;
y = x;
}
qty += y;
} while (y);
if (!qty)
return 0;
if (qty == 1)
return 1;
/* Convert qty to sectors */
if (card->erase_shift)
max_discard = --qty << card->erase_shift;
else if (mmc_card_sd(card))
max_discard = qty;
else
max_discard = --qty * card->erase_size;
return max_discard;
}
unsigned int mmc_calc_max_discard(struct mmc_card *card)
{
struct mmc_host *host = card->host;
unsigned int max_discard, max_trim;
if (!host->max_discard_to)
return UINT_MAX;
/*
* Without erase_group_def set, MMC erase timeout depends on clock
* frequence which can change. In that case, the best choice is
* just the preferred erase size.
*/
if (mmc_card_mmc(card) && !(card->ext_csd.erase_group_def & 1))
return card->pref_erase;
max_discard = mmc_do_calc_max_discard(card, MMC_ERASE_ARG);
if (mmc_can_trim(card)) {
max_trim = mmc_do_calc_max_discard(card, MMC_TRIM_ARG);
if (max_trim < max_discard)
max_discard = max_trim;
} else if (max_discard < card->erase_size) {
max_discard = 0;
}
pr_debug("%s: calculated max. discard sectors %u for timeout %u ms\n",
mmc_hostname(host), max_discard, host->max_discard_to);
return max_discard;
}
EXPORT_SYMBOL(mmc_calc_max_discard);
int mmc_set_blocklen(struct mmc_card *card, unsigned int blocklen)
{
struct mmc_command cmd = {0};
if (mmc_card_blockaddr(card) || mmc_card_ddr_mode(card))
return 0;
cmd.opcode = MMC_SET_BLOCKLEN;
cmd.arg = blocklen;
cmd.flags = MMC_RSP_SPI_R1 | MMC_RSP_R1 | MMC_CMD_AC;
return mmc_wait_for_cmd(card->host, &cmd, 5);
}
EXPORT_SYMBOL(mmc_set_blocklen);
static void mmc_hw_reset_for_init(struct mmc_host *host)
{
if (!(host->caps & MMC_CAP_HW_RESET) || !host->ops->hw_reset)
return;
mmc_host_clk_hold(host);
host->ops->hw_reset(host);
mmc_host_clk_release(host);
}
int mmc_can_reset(struct mmc_card *card)
{
u8 rst_n_function;
if (mmc_card_sdio(card))
return 0;
if (mmc_card_mmc(card)) {
rst_n_function = card->ext_csd.rst_n_function;
if ((rst_n_function & EXT_CSD_RST_N_EN_MASK) !=
EXT_CSD_RST_N_ENABLED)
return 0;
}
return 1;
}
EXPORT_SYMBOL(mmc_can_reset);
static int mmc_do_hw_reset(struct mmc_host *host, int check)
{
struct mmc_card *card = host->card;
if (!host->bus_ops->power_restore)
return -EOPNOTSUPP;
if (!(host->caps & MMC_CAP_HW_RESET) || !host->ops->hw_reset)
return -EOPNOTSUPP;
if (!card)
return -EINVAL;
if (!mmc_can_reset(card))
return -EOPNOTSUPP;
mmc_host_clk_hold(host);
mmc_set_clock(host, host->f_init);
host->ops->hw_reset(host);
/* If the reset has happened, then a status command will fail */
if (check) {
struct mmc_command cmd = {0};
int err;
cmd.opcode = MMC_SEND_STATUS;
if (!mmc_host_is_spi(card->host))
cmd.arg = card->rca << 16;
cmd.flags = MMC_RSP_SPI_R2 | MMC_RSP_R1 | MMC_CMD_AC;
err = mmc_wait_for_cmd(card->host, &cmd, 0);
if (!err) {
mmc_host_clk_release(host);
return -ENOSYS;
}
}
host->card->state &= ~(MMC_STATE_HIGHSPEED | MMC_STATE_HIGHSPEED_DDR);
if (mmc_host_is_spi(host)) {
host->ios.chip_select = MMC_CS_HIGH;
host->ios.bus_mode = MMC_BUSMODE_PUSHPULL;
} else {
host->ios.chip_select = MMC_CS_DONTCARE;
host->ios.bus_mode = MMC_BUSMODE_OPENDRAIN;
}
host->ios.bus_width = MMC_BUS_WIDTH_1;
host->ios.timing = MMC_TIMING_LEGACY;
mmc_set_ios(host);
mmc_host_clk_release(host);
return host->bus_ops->power_restore(host);
}
int mmc_hw_reset(struct mmc_host *host)
{
return mmc_do_hw_reset(host, 0);
}
EXPORT_SYMBOL(mmc_hw_reset);
int mmc_hw_reset_check(struct mmc_host *host)
{
return mmc_do_hw_reset(host, 1);
}
EXPORT_SYMBOL(mmc_hw_reset_check);
/**
* mmc_reset_clk_scale_stats() - reset clock scaling statistics
* @host: pointer to mmc host structure
*/
void mmc_reset_clk_scale_stats(struct mmc_host *host)
{
host->clk_scaling.busy_time_us = 0;
host->clk_scaling.window_time = jiffies;
}
EXPORT_SYMBOL_GPL(mmc_reset_clk_scale_stats);
/**
* mmc_get_max_frequency() - get max. frequency supported
* @host: pointer to mmc host structure
*
* Returns max. frequency supported by card/host. If the
* timing mode is SDR50/SDR104/HS200/DDR50 return appropriate
* max. frequency in these modes else, use the current frequency.
* Also, allow host drivers to overwrite the frequency in case
* they support "get_max_frequency" host ops.
*/
unsigned long mmc_get_max_frequency(struct mmc_host *host)
{
unsigned long freq;
if (host->ops && host->ops->get_max_frequency) {
freq = host->ops->get_max_frequency(host);
goto out;
}
switch (host->ios.timing) {
case MMC_TIMING_UHS_SDR50:
freq = UHS_SDR50_MAX_DTR;
break;
case MMC_TIMING_UHS_SDR104:
freq = UHS_SDR104_MAX_DTR;
break;
case MMC_TIMING_MMC_HS200:
freq = MMC_HS200_MAX_DTR;
break;
case MMC_TIMING_UHS_DDR50:
freq = UHS_DDR50_MAX_DTR;
break;
default:
mmc_host_clk_hold(host);
freq = host->ios.clock;
mmc_host_clk_release(host);
break;
}
out:
return freq;
}
EXPORT_SYMBOL_GPL(mmc_get_max_frequency);
/**
* mmc_get_min_frequency() - get min. frequency supported
* @host: pointer to mmc host structure
*
* Returns min. frequency supported by card/host which doesn't impair
* performance for most usecases. If the timing mode is SDR50/SDR104/HS200
* return 50MHz value. If timing mode is DDR50 return 25MHz so that
* throughput would be equivalent to SDR50/SDR104 in 50MHz. Also, allow
* host drivers to overwrite the frequency in case they support
* "get_min_frequency" host ops.
*/
static unsigned long mmc_get_min_frequency(struct mmc_host *host)
{
unsigned long freq;
if (host->ops && host->ops->get_min_frequency) {
freq = host->ops->get_min_frequency(host);
goto out;
}
switch (host->ios.timing) {
case MMC_TIMING_UHS_SDR50:
case MMC_TIMING_UHS_SDR104:
freq = UHS_SDR25_MAX_DTR;
break;
case MMC_TIMING_MMC_HS200:
freq = MMC_HIGH_52_MAX_DTR;
break;
case MMC_TIMING_UHS_DDR50:
freq = UHS_DDR50_MAX_DTR / 2;
break;
default:
mmc_host_clk_hold(host);
freq = host->ios.clock;
mmc_host_clk_release(host);
break;
}
out:
return freq;
}
/*
* Scale down clocks to minimum frequency supported.
* The delayed work re-arms itself in case it cannot
* claim the host.
*/
static void mmc_clk_scale_work(struct work_struct *work)
{
struct mmc_host *host = container_of(work, struct mmc_host,
clk_scaling.work.work);
if (!host->card || !host->bus_ops ||
!host->bus_ops->change_bus_speed ||
!host->clk_scaling.enable || !host->ios.clock)
goto out;
if (!mmc_try_claim_host(host)) {
/* retry after a timer tick */
queue_delayed_work(system_nrt_wq, &host->clk_scaling.work, 1);
goto out;
}
mmc_clk_scaling(host, true);
mmc_release_host(host);
out:
return;
}
static bool mmc_is_vaild_state_for_clk_scaling(struct mmc_host *host)
{
struct mmc_card *card = host->card;
u32 status;
bool ret = false;
if (!card)
goto out;
if (mmc_send_status(card, &status)) {
pr_err("%s: Get card status fail\n", mmc_hostname(card->host));
goto out;
}
switch (R1_CURRENT_STATE(status)) {
case R1_STATE_TRAN:
ret = true;
break;
default:
break;
}
out:
return ret;
}
static int mmc_clk_update_freq(struct mmc_host *host,
unsigned long freq, enum mmc_load state)
{
int err = 0;
if (host->ops->notify_load) {
err = host->ops->notify_load(host, state);
if (err)
goto out;
}
if (freq != host->clk_scaling.curr_freq) {
if (!mmc_is_vaild_state_for_clk_scaling(host)) {
err = -EAGAIN;
goto error;
}
err = host->bus_ops->change_bus_speed(host, &freq);
if (!err)
host->clk_scaling.curr_freq = freq;
else
pr_err("%s: %s: failed (%d) at freq=%lu\n",
mmc_hostname(host), __func__, err, freq);
}
error:
if (err) {
/* restore previous state */
if (host->ops->notify_load)
host->ops->notify_load(host, host->clk_scaling.state);
}
out:
return err;
}
/**
* mmc_clk_scaling() - clock scaling decision algorithm
* @host: pointer to mmc host structure
* @from_wq: variable that specifies the context in which
* mmc_clk_scaling() is called.
*
* Calculate load percentage based on host busy time
* and total sampling interval and decide clock scaling
* based on scale up/down thresholds.
* If load is greater than up threshold increase the
* frequency to maximum as supported by host. Else,
* if load is less than down threshold, scale down the
* frequency to minimum supported by the host. Otherwise,
* retain current frequency and do nothing.
*/
static void mmc_clk_scaling(struct mmc_host *host, bool from_wq)
{
int err = 0;
struct mmc_card *card = host->card;
unsigned long total_time_ms = 0;
unsigned long busy_time_ms = 0;
unsigned long freq;
unsigned int up_threshold = host->clk_scaling.up_threshold;
unsigned int down_threshold = host->clk_scaling.down_threshold;
bool queue_scale_down_work = false;
enum mmc_load state;
if (!card || !host->bus_ops || !host->bus_ops->change_bus_speed) {
pr_err("%s: %s: invalid entry\n", mmc_hostname(host), __func__);
goto out;
}
/* Check if the clocks are already gated. */
if (!host->ios.clock)
goto out;
if (time_is_after_jiffies(host->clk_scaling.window_time +
msecs_to_jiffies(host->clk_scaling.polling_delay_ms)))
goto out;
/* handle time wrap */
total_time_ms = jiffies_to_msecs((long)jiffies -
(long)host->clk_scaling.window_time);
/* Check if we re-enter during clock switching */
if (unlikely(host->clk_scaling.in_progress))
goto out;
host->clk_scaling.in_progress = true;
busy_time_ms = host->clk_scaling.busy_time_us / USEC_PER_MSEC;
freq = host->clk_scaling.curr_freq;
state = host->clk_scaling.state;
/*
* Note that the max. and min. frequency should be based
* on the timing modes that the card and host handshake
* during initialization.
*/
if ((busy_time_ms * 100 > total_time_ms * up_threshold)) {
freq = mmc_get_max_frequency(host);
state = MMC_LOAD_HIGH;
} else if ((busy_time_ms * 100 < total_time_ms * down_threshold)) {
if (!from_wq)
queue_scale_down_work = true;
freq = mmc_get_min_frequency(host);
state = MMC_LOAD_LOW;
}
if (state != host->clk_scaling.state) {
if (!queue_scale_down_work) {
if (!from_wq)
cancel_delayed_work_sync(
&host->clk_scaling.work);
err = mmc_clk_update_freq(host, freq, state);
if (!err)
host->clk_scaling.state = state;
else if (err == -EAGAIN)
goto no_reset_stats;
} else {
/*
* We hold claim host while queueing the scale down
* work, so delay atleast one timer tick to release
* host and re-claim while scaling down the clocks.
*/
queue_delayed_work(system_nrt_wq,
&host->clk_scaling.work, 1);
goto no_reset_stats;
}
}
mmc_reset_clk_scale_stats(host);
no_reset_stats:
host->clk_scaling.in_progress = false;
out:
return;
}
/**
* mmc_disable_clk_scaling() - Disable clock scaling
* @host: pointer to mmc host structure
*
* Disables clock scaling temporarily by setting enable
* property to false. To disable completely, one also
* need to set 'initialized' variable to false.
*/
void mmc_disable_clk_scaling(struct mmc_host *host)
{
cancel_delayed_work_sync(&host->clk_scaling.work);
host->clk_scaling.enable = false;
}
EXPORT_SYMBOL_GPL(mmc_disable_clk_scaling);
/**
* mmc_can_scale_clk() - Check if clock scaling is initialized
* @host: pointer to mmc host structure
*/
bool mmc_can_scale_clk(struct mmc_host *host)
{
return host->clk_scaling.initialized;
}
EXPORT_SYMBOL_GPL(mmc_can_scale_clk);
/**
* mmc_init_clk_scaling() - Initialize clock scaling
* @host: pointer to mmc host structure
*
* Initialize clock scaling for supported hosts.
* It is assumed that the caller ensure clock is
* running at maximum possible frequency before
* calling this function.
*/
void mmc_init_clk_scaling(struct mmc_host *host)
{
if (!host->card || !(host->caps2 & MMC_CAP2_CLK_SCALE))
return;
INIT_DELAYED_WORK(&host->clk_scaling.work, mmc_clk_scale_work);
host->clk_scaling.curr_freq = mmc_get_max_frequency(host);
if (host->ops->notify_load)
host->ops->notify_load(host, MMC_LOAD_HIGH);
host->clk_scaling.state = MMC_LOAD_HIGH;
mmc_reset_clk_scale_stats(host);
host->clk_scaling.enable = true;
host->clk_scaling.initialized = true;
pr_debug("%s: clk scaling enabled\n", mmc_hostname(host));
}
EXPORT_SYMBOL_GPL(mmc_init_clk_scaling);
/**
* mmc_exit_clk_scaling() - Disable clock scaling
* @host: pointer to mmc host structure
*
* Disable clock scaling permanently.
*/
void mmc_exit_clk_scaling(struct mmc_host *host)
{
cancel_delayed_work_sync(&host->clk_scaling.work);
memset(&host->clk_scaling, 0, sizeof(host->clk_scaling));
}
EXPORT_SYMBOL_GPL(mmc_exit_clk_scaling);
static int mmc_rescan_try_freq(struct mmc_host *host, unsigned freq)
{
host->f_init = freq;
#ifdef CONFIG_MMC_DEBUG
pr_info("%s: %s: trying to init card at %u Hz\n",
mmc_hostname(host), __func__, host->f_init);
#endif
mmc_power_up(host);
/*
* Some eMMCs (with VCCQ always on) may not be reset after power up, so
* do a hardware reset if possible.
*/
mmc_hw_reset_for_init(host);
/* Initialization should be done at 3.3 V I/O voltage. */
mmc_set_signal_voltage(host, MMC_SIGNAL_VOLTAGE_330, 0);
/*
* sdio_reset sends CMD52 to reset card. Since we do not know
* if the card is being re-initialized, just send it. CMD52
* should be ignored by SD/eMMC cards.
*/
sdio_reset(host);
mmc_go_idle(host);
mmc_send_if_cond(host, host->ocr_avail);
/* Order's important: probe SDIO, then SD, then MMC */
if (!mmc_attach_sdio(host))
return 0;
if (!host->ios.vdd)
mmc_power_up(host);
if (!mmc_attach_sd(host))
return 0;
if (!host->ios.vdd)
mmc_power_up(host);
if (!mmc_attach_mmc(host))
return 0;
mmc_power_off(host);
return -EIO;
}
int _mmc_detect_card_removed(struct mmc_host *host)
{
int ret;
if ((host->caps & MMC_CAP_NONREMOVABLE) || !host->bus_ops->alive)
return 0;
if (!host->card || mmc_card_removed(host->card))
return 1;
ret = host->bus_ops->alive(host);
if (ret) {
mmc_card_set_removed(host->card);
pr_debug("%s: card remove detected\n", mmc_hostname(host));
}
return ret;
}
int mmc_detect_card_removed(struct mmc_host *host)
{
struct mmc_card *card = host->card;
int ret;
WARN_ON(!host->claimed);
if (!card)
return 1;
ret = mmc_card_removed(card);
/*
* The card will be considered unchanged unless we have been asked to
* detect a change or host requires polling to provide card detection.
*/
if (!host->detect_change && !(host->caps & MMC_CAP_NEEDS_POLL) &&
!(host->caps2 & MMC_CAP2_DETECT_ON_ERR))
return ret;
host->detect_change = 0;
if (!ret) {
ret = _mmc_detect_card_removed(host);
if (ret && (host->caps2 & MMC_CAP2_DETECT_ON_ERR)) {
/*
* Schedule a detect work as soon as possible to let a
* rescan handle the card removal.
*/
cancel_delayed_work(&host->detect);
mmc_detect_change(host, 0);
}
}
return ret;
}
EXPORT_SYMBOL(mmc_detect_card_removed);
void mmc_rescan(struct work_struct *work)
{
struct mmc_host *host =
container_of(work, struct mmc_host, detect.work);
bool extend_wakelock = false;
if (host->rescan_disable)
return;
mmc_bus_get(host);
/*
* if there is a _removable_ card registered, check whether it is
* still present
*/
if (host->bus_ops && host->bus_ops->detect && !host->bus_dead
&& !(host->caps & MMC_CAP_NONREMOVABLE))
host->bus_ops->detect(host);
host->detect_change = 0;
/* If the card was removed the bus will be marked
* as dead - extend the wakelock so userspace
* can respond */
if (host->bus_dead)
extend_wakelock = 1;
/* If the card was removed the bus will be marked
* as dead - extend the wakelock so userspace
* can respond */
if (host->bus_dead)
extend_wakelock = 1;
/*
* Let mmc_bus_put() free the bus/bus_ops if we've found that
* the card is no longer present.
*/
mmc_bus_put(host);
mmc_bus_get(host);
/* if there still is a card present, stop here */
if (host->bus_ops != NULL) {
mmc_bus_put(host);
goto out;
}
/*
* Only we can add a new handler, so it's safe to
* release the lock here.
*/
mmc_bus_put(host);
if (host->ops->get_cd && host->ops->get_cd(host) == 0)
goto out;
mmc_claim_host(host);
if (!mmc_rescan_try_freq(host, host->f_min))
extend_wakelock = true;
mmc_release_host(host);
out:
if (extend_wakelock)
wake_lock_timeout(&host->detect_wake_lock, HZ / 2);
else
wake_unlock(&host->detect_wake_lock);
if (host->caps & MMC_CAP_NEEDS_POLL) {
wake_lock(&host->detect_wake_lock);
mmc_schedule_delayed_work(&host->detect, HZ);
}
}
void mmc_start_host(struct mmc_host *host)
{
mmc_power_off(host);
mmc_detect_change(host, 0);
}
void mmc_stop_host(struct mmc_host *host)
{
#ifdef CONFIG_MMC_DEBUG
unsigned long flags;
spin_lock_irqsave(&host->lock, flags);
host->removed = 1;
spin_unlock_irqrestore(&host->lock, flags);
#endif
if (cancel_delayed_work_sync(&host->detect))
wake_unlock(&host->detect_wake_lock);
mmc_flush_scheduled_work();
/* clear pm flags now and let card drivers set them as needed */
host->pm_flags = 0;
mmc_bus_get(host);
if (host->bus_ops && !host->bus_dead) {
/* Calling bus_ops->remove() with a claimed host can deadlock */
if (host->bus_ops->remove)
host->bus_ops->remove(host);
mmc_claim_host(host);
mmc_detach_bus(host);
mmc_power_off(host);
mmc_release_host(host);
mmc_bus_put(host);
return;
}
mmc_bus_put(host);
BUG_ON(host->card);
mmc_power_off(host);
}
int mmc_power_save_host(struct mmc_host *host)
{
int ret = 0;
#ifdef CONFIG_MMC_DEBUG
pr_info("%s: %s: powering down\n", mmc_hostname(host), __func__);
#endif
mmc_bus_get(host);
if (!host->bus_ops || host->bus_dead || !host->bus_ops->power_restore) {
mmc_bus_put(host);
return -EINVAL;
}
if (host->bus_ops->power_save)
ret = host->bus_ops->power_save(host);
mmc_bus_put(host);
mmc_power_off(host);
return ret;
}
EXPORT_SYMBOL(mmc_power_save_host);
int mmc_power_restore_host(struct mmc_host *host)
{
int ret;
#ifdef CONFIG_MMC_DEBUG
pr_info("%s: %s: powering up\n", mmc_hostname(host), __func__);
#endif
mmc_bus_get(host);
if (!host->bus_ops || host->bus_dead || !host->bus_ops->power_restore) {
mmc_bus_put(host);
return -EINVAL;
}
mmc_power_up(host);
ret = host->bus_ops->power_restore(host);
mmc_bus_put(host);
return ret;
}
EXPORT_SYMBOL(mmc_power_restore_host);
int mmc_card_awake(struct mmc_host *host)
{
int err = -ENOSYS;
if (host->caps2 & MMC_CAP2_NO_SLEEP_CMD)
return 0;
mmc_bus_get(host);
if (host->bus_ops && !host->bus_dead && host->bus_ops->awake)
err = host->bus_ops->awake(host);
mmc_bus_put(host);
return err;
}
EXPORT_SYMBOL(mmc_card_awake);
int mmc_card_sleep(struct mmc_host *host)
{
int err = -ENOSYS;
if (host->caps2 & MMC_CAP2_NO_SLEEP_CMD)
return 0;
mmc_bus_get(host);
if (host->bus_ops && !host->bus_dead && host->bus_ops->sleep)
err = host->bus_ops->sleep(host);
mmc_bus_put(host);
return err;
}
EXPORT_SYMBOL(mmc_card_sleep);
int mmc_card_can_sleep(struct mmc_host *host)
{
struct mmc_card *card = host->card;
if (card && mmc_card_mmc(card) && card->ext_csd.rev >= 3)
return 1;
return 0;
}
EXPORT_SYMBOL(mmc_card_can_sleep);
/*
* Flush the cache to the non-volatile storage.
*/
int mmc_flush_cache(struct mmc_card *card)
{
struct mmc_host *host = card->host;
int err = 0, rc;
if (!(host->caps2 & MMC_CAP2_CACHE_CTRL))
return err;
if (mmc_card_mmc(card) &&
(card->ext_csd.cache_size > 0) &&
(card->ext_csd.cache_ctrl & 1)) {
err = mmc_switch_ignore_timeout(card, EXT_CSD_CMD_SET_NORMAL,
EXT_CSD_FLUSH_CACHE, 1,
MMC_FLUSH_REQ_TIMEOUT_MS);
if (err == -ETIMEDOUT) {
pr_debug("%s: cache flush timeout\n",
mmc_hostname(card->host));
rc = mmc_interrupt_hpi(card);
if (rc)
pr_err("%s: mmc_interrupt_hpi() failed (%d)\n",
mmc_hostname(host), rc);
} else if (err) {
pr_err("%s: cache flush error %d\n",
mmc_hostname(card->host), err);
}
}
return err;
}
EXPORT_SYMBOL(mmc_flush_cache);
/*
* Turn the cache ON/OFF.
* Turning the cache OFF shall trigger flushing of the data
* to the non-volatile storage.
* This function should be called with host claimed
*/
int mmc_cache_ctrl(struct mmc_host *host, u8 enable)
{
struct mmc_card *card = host->card;
unsigned int timeout = card->ext_csd.generic_cmd6_time;
int err = 0, rc;
if (!(host->caps2 & MMC_CAP2_CACHE_CTRL) ||
mmc_card_is_removable(host))
return err;
if (card && mmc_card_mmc(card) &&
(card->ext_csd.cache_size > 0)) {
enable = !!enable;
if (card->ext_csd.cache_ctrl ^ enable) {
if (!enable)
timeout = MMC_FLUSH_REQ_TIMEOUT_MS;
err = mmc_switch_ignore_timeout(card,
EXT_CSD_CMD_SET_NORMAL,
EXT_CSD_CACHE_CTRL, enable, timeout);
if (err == -ETIMEDOUT && !enable) {
pr_debug("%s:cache disable operation timeout\n",
mmc_hostname(card->host));
rc = mmc_interrupt_hpi(card);
if (rc)
pr_err("%s: mmc_interrupt_hpi() failed (%d)\n",
mmc_hostname(host), rc);
} else if (err) {
pr_err("%s: cache %s error %d\n",
mmc_hostname(card->host),
enable ? "on" : "off",
err);
} else {
card->ext_csd.cache_ctrl = enable;
}
}
}
return err;
}
EXPORT_SYMBOL(mmc_cache_ctrl);
#ifdef CONFIG_PM
/**
* mmc_suspend_host - suspend a host
* @host: mmc host
*/
int mmc_suspend_host(struct mmc_host *host)
{
int err = 0;
if (mmc_bus_needs_resume(host))
return 0;
mmc_bus_get(host);
if (host->bus_ops && !host->bus_dead) {
/*
* A long response time is not acceptable for device drivers
* when doing suspend. Prevent mmc_claim_host in the suspend
* sequence, to potentially wait "forever" by trying to
* pre-claim the host.
*
* Skip try claim host for SDIO cards, doing so fixes deadlock
* conditions. The function driver suspend may again call into
* SDIO driver within a different context for enabling power
* save mode in the card and hence wait in mmc_claim_host
* causing deadlock.
*/
if (!(host->card && mmc_card_sdio(host->card)))
if (!mmc_try_claim_host(host))
err = -EBUSY;
if (!err) {
if (host->bus_ops->suspend) {
err = mmc_stop_bkops(host->card);
if (err)
goto stop_bkops_err;
err = host->bus_ops->suspend(host);
}
if (!(host->card && mmc_card_sdio(host->card)))
mmc_release_host(host);
if (err == -ENOSYS || !host->bus_ops->resume) {
/*
* We simply "remove" the card in this case.
* It will be redetected on resume. (Calling
* bus_ops->remove() with a claimed host can
* deadlock.)
* It will be redetected on resume.
*/
if (host->bus_ops->remove)
host->bus_ops->remove(host);
mmc_claim_host(host);
mmc_detach_bus(host);
mmc_power_off(host);
mmc_release_host(host);
host->pm_flags = 0;
err = 0;
}
}
}
mmc_bus_put(host);
if (!err && !mmc_card_keep_power(host))
mmc_power_off(host);
return err;
stop_bkops_err:
if (!(host->card && mmc_card_sdio(host->card)))
mmc_release_host(host);
return err;
}
EXPORT_SYMBOL(mmc_suspend_host);
/**
* mmc_resume_host - resume a previously suspended host
* @host: mmc host
*/
int mmc_resume_host(struct mmc_host *host)
{
int err = 0;
mmc_bus_get(host);
if (mmc_bus_manual_resume(host)) {
host->bus_resume_flags |= MMC_BUSRESUME_NEEDS_RESUME;
mmc_bus_put(host);
return 0;
}
if (host->bus_ops && !host->bus_dead) {
if (!mmc_card_keep_power(host)) {
mmc_power_up(host);
mmc_select_voltage(host, host->ocr);
/*
* Tell runtime PM core we just powered up the card,
* since it still believes the card is powered off.
* Note that currently runtime PM is only enabled
* for SDIO cards that are MMC_CAP_POWER_OFF_CARD
*/
if (mmc_card_sdio(host->card) &&
(host->caps & MMC_CAP_POWER_OFF_CARD)) {
pm_runtime_disable(&host->card->dev);
pm_runtime_set_active(&host->card->dev);
pm_runtime_enable(&host->card->dev);
}
}
BUG_ON(!host->bus_ops->resume);
err = host->bus_ops->resume(host);
if (err) {
pr_warning("%s: error %d during resume "
"(card was removed?)\n",
mmc_hostname(host), err);
err = 0;
}
}
host->pm_flags &= ~MMC_PM_KEEP_POWER;
mmc_bus_put(host);
return err;
}
EXPORT_SYMBOL(mmc_resume_host);
/* Do the card removal on suspend if card is assumed removeable
* Do that in pm notifier while userspace isn't yet frozen, so we will be able
to sync the card.
*/
int mmc_pm_notify(struct notifier_block *notify_block,
unsigned long mode, void *unused)
{
struct mmc_host *host = container_of(
notify_block, struct mmc_host, pm_notify);
unsigned long flags;
int err = 0;
switch (mode) {
case PM_HIBERNATION_PREPARE:
case PM_SUSPEND_PREPARE:
if (host->card && mmc_card_mmc(host->card)) {
mmc_claim_host(host);
err = mmc_stop_bkops(host->card);
mmc_release_host(host);
if (err) {
pr_err("%s: didn't stop bkops\n",
mmc_hostname(host));
return err;
}
}
spin_lock_irqsave(&host->lock, flags);
if (mmc_bus_needs_resume(host)) {
spin_unlock_irqrestore(&host->lock, flags);
break;
}
host->rescan_disable = 1;
spin_unlock_irqrestore(&host->lock, flags);
if (cancel_delayed_work_sync(&host->detect))
wake_unlock(&host->detect_wake_lock);
if (!host->bus_ops || host->bus_ops->suspend)
break;
/* Calling bus_ops->remove() with a claimed host can deadlock */
if (host->bus_ops->remove)
host->bus_ops->remove(host);
mmc_claim_host(host);
mmc_detach_bus(host);
mmc_power_off(host);
mmc_release_host(host);
host->pm_flags = 0;
break;
case PM_POST_SUSPEND:
case PM_POST_HIBERNATION:
case PM_POST_RESTORE:
spin_lock_irqsave(&host->lock, flags);
if (mmc_bus_manual_resume(host)) {
spin_unlock_irqrestore(&host->lock, flags);
break;
}
host->rescan_disable = 0;
spin_unlock_irqrestore(&host->lock, flags);
mmc_detect_change(host, 0);
}
return 0;
}
#endif
#ifdef CONFIG_MMC_EMBEDDED_SDIO
void mmc_set_embedded_sdio_data(struct mmc_host *host,
struct sdio_cis *cis,
struct sdio_cccr *cccr,
struct sdio_embedded_func *funcs,
int num_funcs)
{
host->embedded_sdio_data.cis = cis;
host->embedded_sdio_data.cccr = cccr;
host->embedded_sdio_data.funcs = funcs;
host->embedded_sdio_data.num_funcs = num_funcs;
}
EXPORT_SYMBOL(mmc_set_embedded_sdio_data);
#endif
static int __init mmc_init(void)
{
int ret;
workqueue = alloc_ordered_workqueue("kmmcd", 0);
if (!workqueue)
return -ENOMEM;
ret = mmc_register_bus();
if (ret)
goto destroy_workqueue;
ret = mmc_register_host_class();
if (ret)
goto unregister_bus;
ret = sdio_register_bus();
if (ret)
goto unregister_host_class;
return 0;
unregister_host_class:
mmc_unregister_host_class();
unregister_bus:
mmc_unregister_bus();
destroy_workqueue:
destroy_workqueue(workqueue);
return ret;
}
static void __exit mmc_exit(void)
{
sdio_unregister_bus();
mmc_unregister_host_class();
mmc_unregister_bus();
destroy_workqueue(workqueue);
}
subsys_initcall(mmc_init);
module_exit(mmc_exit);
MODULE_LICENSE("GPL");
| Java |
var options={}; options.login=true;
LoginRadius_SocialLogin.util.ready(function ()
{ $ui = LoginRadius_SocialLogin.lr_login_settings;
$ui.interfacesize = Drupal.settings.lrsociallogin.interfacesize;
$ui.lrinterfacebackground=Drupal.settings.lrsociallogin.lrinterfacebackground;
$ui.noofcolumns= Drupal.settings.lrsociallogin.noofcolumns;
$ui.apikey = Drupal.settings.lrsociallogin.apikey;
$ui.is_access_token=true;
$ui.callback=Drupal.settings.lrsociallogin.location;
$ui.lrinterfacecontainer ="interfacecontainerdiv"; LoginRadius_SocialLogin.init(options); });
LoginRadiusSDK.setLoginCallback(function () {
var token = LoginRadiusSDK.getToken();
var form = document.createElement('form');
form.action = Drupal.settings.lrsociallogin.location;
form.method = 'POST';
var hiddenToken = document.createElement('input');
hiddenToken.type = 'hidden';
hiddenToken.value = token;
hiddenToken.name = 'token';
form.appendChild(hiddenToken);
document.body.appendChild(form);
form.submit();
}); | Java |
<?php
namespace Drupal\materialize\Plugin\Setting\General\Tables;
use Drupal\materialize\Annotation\MaterializeSetting;
use Drupal\materialize\Plugin\Setting\SettingBase;
use Drupal\Core\Annotation\Translation;
/**
* The "table_bordered" theme setting.
*
* @ingroup plugins_setting
*
* @MaterializeSetting(
* id = "table_bordered",
* type = "checkbox",
* title = @Translation("Bordered table"),
* description = @Translation("Add borders on all sides of the table and cells."),
* defaultValue = 0,
* groups = {
* "general" = @Translation("General"),
* "tables" = @Translation("Tables"),
* },
* )
*/
class TableBordered extends SettingBase {}
| Java |
package net.senmori.customtextures.events;
import net.senmori.customtextures.util.MovementType;
import org.bukkit.entity.Player;
import org.bukkit.event.player.PlayerEvent;
import com.sk89q.worldguard.protection.regions.ProtectedRegion;
/**
* event that is triggered after a player entered a WorldGuard region
* @author mewin<mewin001@hotmail.de>
*/
public class RegionEnteredEvent extends RegionEvent
{
/**
* creates a new RegionEnteredEvent
* @param region the region the player entered
* @param player the player who triggered the event
* @param movement the type of movement how the player entered the region
*/
public RegionEnteredEvent(ProtectedRegion region, Player player, MovementType movement, PlayerEvent parent)
{
super(player, region, parent, movement);
}
} | Java |
<?php
/*
* @package Joomla.Framework
* @copyright Copyright (C) 2005 - 2010 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*
* @component Phoca Component
* @copyright Copyright (C) Jan Pavelka www.phoca.cz
* @license http://www.gnu.org/copyleft/gpl.html GNU General Public License version 2 or later;
*/
defined('_JEXEC') or die();
jimport('joomla.application.component.modeladmin');
phocagalleryimport('phocagallery.tag.tag');
class PhocaGalleryCpModelPhocaGalleryImg extends JModelAdmin
{
protected $option = 'com_phocagallery';
protected $text_prefix = 'com_phocagallery';
protected function canDelete($record)
{
$user = JFactory::getUser();
if ($record->catid) {
return $user->authorise('core.delete', 'com_phocagallery.phocagalleryimg.'.(int) $record->catid);
} else {
return parent::canDelete($record);
}
}
protected function canEditState($record)
{
$user = JFactory::getUser();
if ($record->catid) {
return $user->authorise('core.edit.state', 'com_phocagallery.phocagalleryimg.'.(int) $record->catid);
} else {
return parent::canEditState($record);
}
}
public function getTable($type = 'PhocaGallery', $prefix = 'Table', $config = array())
{
return JTable::getInstance($type, $prefix, $config);
}
public function getForm($data = array(), $loadData = true) {
$app = JFactory::getApplication();
$form = $this->loadForm('com_phocagallery.phocagalleryimg', 'phocagalleryimg', array('control' => 'jform', 'load_data' => $loadData));
if (empty($form)) {
return false;
}
return $form;
}
protected function loadFormData()
{
// Check the session for previously entered form data.
$data = JFactory::getApplication()->getUserState('com_phocagallery.edit.phocagallery.data', array());
if (empty($data)) {
$data = $this->getItem();
}
return $data;
}
public function getItem($pk = null)
{
if ($item = parent::getItem($pk)) {
// Convert the params field to an array.
$registry = new JRegistry;
$registry->loadJSON($item->metadata);
$item->metadata = $registry->toArray();
}
return $item;
}
protected function prepareTable(&$table)
{
jimport('joomla.filter.output');
$date = JFactory::getDate();
$user = JFactory::getUser();
$table->title = htmlspecialchars_decode($table->title, ENT_QUOTES);
$table->alias = JApplication::stringURLSafe($table->alias);
if (empty($table->alias)) {
$table->alias = JApplication::stringURLSafe($table->title);
}
if (empty($table->id)) {
// Set the values
//$table->created = $date->toMySQL();
// Set ordering to the last item if not set
if (empty($table->ordering)) {
$db = JFactory::getDbo();
$db->setQuery('SELECT MAX(ordering) FROM #__phocagallery WHERE catid = '.(int)$table->catid);
$max = $db->loadResult();
$table->ordering = $max+1;
}
}
else {
// Set the values
//$table->modified = $date->toMySQL();
//$table->modified_by = $user->get('id');
}
}
protected function getReorderConditions($table = null)
{
$condition = array();
$condition[] = 'catid = '. (int) $table->catid;
//$condition[] = 'state >= 0';
return $condition;
}
function approve(&$pks, $value = 1)
{
// Initialise variables.
$dispatcher = JDispatcher::getInstance();
$user = JFactory::getUser();
$table = $this->getTable('phocagallery');
$pks = (array) $pks;
// Include the content plugins for the change of state event.
JPluginHelper::importPlugin('content');
// Access checks.
foreach ($pks as $i => $pk) {
if ($table->load($pk)) {
if (!$this->canEditState($table)) {
// Prune items that you can't change.
unset($pks[$i]);
JError::raiseWarning(403, JText::_('JLIB_APPLICATION_ERROR_EDIT_STATE_NOT_PERMITTED'));
}
}
}
// Attempt to change the state of the records.
if (!$table->approve($pks, $value, $user->get('id'))) {
$this->setError($table->getError());
return false;
}
$context = $this->option.'.'.$this->name;
// Trigger the onContentChangeState event.
/*$result = $dispatcher->trigger($this->event_change_state, array($context, $pks, $value));
if (in_array(false, $result, true)) {
$this->setError($table->getError());
return false;
}*/
return true;
}
function save($data) {
$params = &JComponentHelper::getParams( 'com_phocagallery' );
$clean_thumbnails = $params->get( 'clean_thumbnails', 0 );
$fileOriginalNotExist = 0;
if ((int)$data['extid'] > 0) {
$data['imgorigsize'] = 0;
if ($data['title'] == '') {
$data['title'] = 'External Image';
}
} else {
//If this file doesn't exists don't save it
if (!PhocaGalleryFile::existsFileOriginal($data['filename'])) {
//$this->setError('Original File does not exist');
//return false;
$fileOriginalNotExist = 1;
$errorMsg = JText::_('COM_PHOCAGALLERY_ORIGINAL_IMAGE_NOT_EXIST');
}
$data['imgorigsize'] = PhocaGalleryFile::getFileSize($data['filename'], 0);
//If there is no title and no alias, use filename as title and alias
if ($data['title'] == '') {
$data['title'] = PhocaGalleryFile::getTitleFromFile($data['filename']);
}
}
if ($data['extlink1link'] != '') {
$extlink1 = str_replace('http://','', $data['extlink1link']);
$data['extlink1'] = $extlink1 . '|'.$data['extlink1title'].'|'.$data['extlink1target'].'|'.$data['extlink1icon'];
} else {
$data['extlink1'] = $data['extlink1link'] . '|'.$data['extlink1title'].'|'.$data['extlink1target'].'|'.$data['extlink1icon'];
}
if ($data['extlink2link'] != '') {
$extlink2 = str_replace('http://','', $data['extlink2link']);
$data['extlink2'] = $extlink2 . '|'.$data['extlink2title'].'|'.$data['extlink2target'].'|'.$data['extlink2icon'];
} else {
$data['extlink2'] = $data['extlink2link'] . '|'.$data['extlink2title'].'|'.$data['extlink2target'].'|'.$data['extlink2icon'];
}
// Geo
if($data['longitude'] == '' || $data['latitude'] == '') {
phocagalleryimport('phocagallery.geo.geo');
$coords = PhocaGalleryGeo::getGeoCoords($data['filename']);
if ($data['longitude'] == '' ){
$data['longitude'] = $coords['longitude'];
}
if ($data['latitude'] == '' ){
$data['latitude'] = $coords['latitude'];
}
if ($data['latitude'] != '' && $data['longitude'] != '' && $data['zoom'] == ''){
$data['zoom'] = PhocaGallerySettings::getAdvancedSettings('geozoom');
}
}
if ($data['alias'] == '') {
$data['alias'] = $data['title'];
}
//clean alias name (no bad characters)
//$data['alias'] = PhocaGalleryText::getAliasName($data['alias']);
// if new item, order last in appropriate group
//if (!$row->id) {
// $where = 'catid = ' . (int) $row->catid ;
// $row->ordering = $row->getNextOrder( $where );
//}
// = = = = = = = = = =
// Initialise variables;
$dispatcher = JDispatcher::getInstance();
$table = $this->getTable();
$pk = (!empty($data['id'])) ? $data['id'] : (int)$this->getState($this->getName().'.id');
$isNew = true;
// Include the content plugins for the on save events.
JPluginHelper::importPlugin('content');
// Load the row if saving an existing record.
if ($pk > 0) {
$table->load($pk);
$isNew = false;
}
// Bind the data.
if (!$table->bind($data)) {
$this->setError($table->getError());
return false;
}
if(intval($table->date) == 0) {
$table->date = JFactory::getDate()->toMySQL();
}
// Prepare the row for saving
$this->prepareTable($table);
// Check the data.
if (!$table->check()) {
$this->setError($table->getError());
return false;
}
// Trigger the onContentBeforeSave event.
/*$result = $dispatcher->trigger($this->event_before_save, array($this->option.'.'.$this->name, $table, $isNew));
if (in_array(false, $result, true)) {
$this->setError($table->getError());
return false;
}*/
// Store the data.
if (!$table->store()) {
$this->setError($table->getError());
return false;
}
// Store to ref table
if (!isset($data['tags'])) {
$data['tags'] = array();
}
if ((int)$table->id > 0) {
PhocaGalleryTag::storeTags($data['tags'], (int)$table->id);
}
// Clean the cache.
$cache = JFactory::getCache($this->option);
$cache->clean();
// Trigger the onContentAfterSave event.
//$dispatcher->trigger($this->event_after_save, array($this->option.'.'.$this->name, $table, $isNew));
$pkName = $table->getKeyName();
if (isset($table->$pkName)) {
$this->setState($this->getName().'.id', $table->$pkName);
}
$this->setState($this->getName().'.new', $isNew);
// = = = = = =
$task = JRequest::getVar('task');
if (isset($table->$pkName)) {
$id = $table->$pkName;
}
if ((int)$data['extid'] > 0 || $fileOriginalNotExist == 1) {
} else {
// - - - - - - - - - - - - - - - - - -
//Create thumbnail small, medium, large
//file - abc.img, file_no - folder/abc.img
//Get folder variables from Helper
//Create thumbnails small, medium, large
$refresh_url = 'index.php?option=com_phocagallery&task=phocagalleryimg.thumbs';
$task = JRequest::getVar('task');
if (isset($table->$pkName) && $task == 'apply') {
$id = $table->$pkName;
$refresh_url = 'index.php?option=com_phocagallery&task=phocagalleryimg.edit&id='.(int)$id;
}
if ($task = 'save2new') {
// Don't create automatically thumbnails in case, we are going to add new image
} else {
$file_thumb = PhocaGalleryFileThumbnail::getOrCreateThumbnail($data['filename'], $refresh_url, 1, 1, 1);
}
//Clean Thumbs Folder if there are thumbnail files but not original file
if ($clean_thumbnails == 1) {
phocagalleryimport('phocagallery.file.filefolder');
PhocaGalleryFileFolder::cleanThumbsFolder();
}
// - - - - - - - - - - - - - - - - - - - - -
}
return true;
}
function delete($cid = array()) {
$params = &JComponentHelper::getParams( 'com_phocagallery' );
$clean_thumbnails = $params->get( 'clean_thumbnails', 0 );
$result = false;
if (count( $cid )) {
JArrayHelper::toInteger($cid);
$cids = implode( ',', $cid );
// - - - - - - - - - - - - -
// Get all filenames we want to delete from database, we delete all thumbnails from server of this file
$queryd = 'SELECT filename as filename FROM #__phocagallery WHERE id IN ( '.$cids.' )';
$this->_db->setQuery($queryd);
$fileObject = $this->_db->loadObjectList();
// - - - - - - - - - - - - -
//Delete it from DB
$query = 'DELETE FROM #__phocagallery'
. ' WHERE id IN ( '.$cids.' )';
$this->_db->setQuery( $query );
if(!$this->_db->query()) {
$this->setError($this->_db->getErrorMsg());
return false;
}
// - - - - - - - - - - - - - -
// Delete thumbnails - medium and large, small from server
// All id we want to delete - gel all filenames
foreach ($fileObject as $key => $value) {
//The file can be stored in other category - don't delete it from server because other category use it
$querys = "SELECT id as id FROM #__phocagallery WHERE filename='".$value->filename."' ";
$this->_db->setQuery($queryd);
$sameFileObject = $this->_db->loadObject();
// same file in other category doesn't exist - we can delete it
if (!$sameFileObject) {
PhocaGalleryFileThumbnail::deleteFileThumbnail($value->filename, 1, 1, 1);
}
}
// Clean Thumbs Folder if there are thumbnail files but not original file
if ($clean_thumbnails == 1) {
phocagalleryimport('phocagallery.file.filefolder');
PhocaGalleryFileFolder::cleanThumbsFolder();
}
// - - - - - - - - - - - - - -
}
return true;
}
function recreate($cid = array(), &$message) {
if (count( $cid )) {
JArrayHelper::toInteger($cid);
$cids = implode( ',', $cid );
$query = 'SELECT a.filename, a.extid'.
' FROM #__phocagallery AS a' .
' WHERE a.id IN ( '.$cids.' )';
$this->_db->setQuery($query);
$files = $this->_db->loadObjectList();
if (isset($files) && count($files)) {
foreach($files as $key => $value) {
if (isset($value->extid) && ((int)$value->extid > 0)) {
// Picasa cannot be recreated
$message = JText::_('COM_PHOCAGALLERY_ERROR_EXT_IMG_NOT_RECREATE');
return false;
} else if (isset($value->filename) && $value->filename != '') {
$original = PhocaGalleryFile::existsFileOriginal($value->filename);
if (!$original) {
// Original does not exist - cannot generate new thumbnail
$message = JText::_('COM_PHOCAGALLERY_FILEORIGINAL_NOT_EXISTS');
return false;
}
// Delete old thumbnails
$deleteThubms = PhocaGalleryFileThumbnail::deleteFileThumbnail($value->filename, 1, 1, 1);
} else {
$message = JText::_('COM_PHOCAGALLERY_FILENAME_NOT_EXISTS');
return false;
}
if (!$deleteThubms) {
$message = JText::_('COM_PHOCAGALLERY_ERROR_DELETE_THUMBNAIL');
return false;
}
}
} else {
$message = JText::_('COM_PHOCAGALLERY_ERROR_LOADING_DATA_DB');
return false;
}
} else {
$message = JText::_('COM_PHOCAGALLERY_ERROR_ITEM_NOT_SELECTED');
return false;
}
return true;
}
/*
function deletethumbs($id) {
if ($id > 0) {
$query = 'SELECT a.filename as filename'.
' FROM #__phocagallery AS a' .
' WHERE a.id = '.(int) $id;
$this->_db->setQuery($query);
$file = $this->_db->loadObject();
if (isset($file->filename) && $file->filename != '') {
$deleteThubms = PhocaGalleryFileThumbnail::deleteFileThumbnail($file->filename, 1, 1, 1);
if ($deleteThubms) {
return true;
} else {
return false;
}
} return false;
} return false;
}*/
public function disableThumbs() {
$component = 'com_phocagallery';
$paramsC = JComponentHelper::getParams($component) ;
$paramsC->setValue('enable_thumb_creation', 0);
$data['params'] = $paramsC->toArray();
$table = JTable::getInstance('extension');
$idCom = $table->find( array('element' => $component ));
$table->load($idCom);
if (!$table->bind($data)) {
JError::raiseWarning( 500, 'Not a valid component' );
return false;
}
// pre-save checks
if (!$table->check()) {
JError::raiseWarning( 500, $table->getError('Check Problem') );
return false;
}
// save the changes
if (!$table->store()) {
JError::raiseWarning( 500, $table->getError('Store Problem') );
return false;
}
return true;
}
function rotate($id, $angle, &$errorMsg) {
phocagalleryimport('phocagallery.image.imagerotate');
if ($id > 0 && $angle !='') {
$query = 'SELECT a.filename as filename'.
' FROM #__phocagallery AS a' .
' WHERE a.id = '.(int) $id;
$this->_db->setQuery($query);
$file = $this->_db->loadObject();
if (isset($file->filename) && $file->filename != '') {
$thumbNameL = PhocaGalleryFileThumbnail::getThumbnailName ($file->filename, 'large');
$thumbNameM = PhocaGalleryFileThumbnail::getThumbnailName ($file->filename, 'medium');
$thumbNameS = PhocaGalleryFileThumbnail::getThumbnailName ($file->filename, 'small');
$errorMsg = $errorMsgS = $errorMsgM = $errorMsgL ='';
PhocaGalleryImageRotate::rotateImage($thumbNameL, 'large', $angle, $errorMsgS);
if ($errorMsgS != '') {
$errorMsg = $errorMsgS;
return false;
}
PhocaGalleryImageRotate::rotateImage($thumbNameM, 'medium', $angle, $errorMsgM);
if ($errorMsgM != '') {
$errorMsg = $errorMsgM;
return false;
}
PhocaGalleryImageRotate::rotateImage($thumbNameS, 'small', $angle, $errorMsgL);
if ($errorMsgL != '') {
$errorMsg = $errorMsgL;
return false;
}
if ($errorMsgL == '' && $errorMsgM == '' && $errorMsgS == '' ) {
return true;
} else {
$errorMsg = ' ('.$errorMsg.')';
return false;
}
}
$errorMsg = JText::_('COM_PHOCAGALLERY_FILENAME_NOT_EXISTS');
return false;
}
$errorMsg = JText::_('COM_PHOCAGALLERY_ERROR_ITEM_NOT_SELECTED');
return false;
}
function deletethumbs($id) {
if ($id > 0) {
$query = 'SELECT a.filename as filename'.
' FROM #__phocagallery AS a' .
' WHERE a.id = '.(int) $id;
$this->_db->setQuery($query);
$file = $this->_db->loadObject();
if (isset($file->filename) && $file->filename != '') {
$deleteThubms = PhocaGalleryFileThumbnail::deleteFileThumbnail($file->filename, 1, 1, 1);
if ($deleteThubms) {
return true;
} else {
return false;
}
} return false;
} return false;
}
protected function batchCopy($value, $pks, $contexts)
{
$categoryId = (int) $value;
$table = $this->getTable();
$db = $this->getDbo();
// Check that the category exists
if ($categoryId) {
$categoryTable = JTable::getInstance('PhocaGalleryC', 'Table');
if (!$categoryTable->load($categoryId)) {
if ($error = $categoryTable->getError()) {
// Fatal error
$this->setError($error);
return false;
}
else {
$this->setError(JText::_('JLIB_APPLICATION_ERROR_BATCH_MOVE_CATEGORY_NOT_FOUND'));
return false;
}
}
}
if (empty($categoryId)) {
$this->setError(JText::_('JLIB_APPLICATION_ERROR_BATCH_MOVE_CATEGORY_NOT_FOUND'));
return false;
}
// Check that the user has create permission for the component
$extension = JRequest::getCmd('option');
$user = JFactory::getUser();
if (!$user->authorise('core.create', $extension)) {
$this->setError(JText::_('JLIB_APPLICATION_ERROR_BATCH_CANNOT_CREATE'));
return false;
}
//NEW
$i = 0;
//ENDNEW
// Parent exists so we let's proceed
while (!empty($pks))
{
// Pop the first ID off the stack
$pk = array_shift($pks);
$table->reset();
// Check that the row actually exists
if (!$table->load($pk)) {
if ($error = $table->getError()) {
// Fatal error
$this->setError($error);
return false;
}
else {
// Not fatal error
$this->setError(JText::sprintf('JLIB_APPLICATION_ERROR_BATCH_MOVE_ROW_NOT_FOUND', $pk));
continue;
}
}
// Alter the title & alias
$data = $this->generateNewTitle($categoryId, $table->alias, $table->title);
$table->title = $data['0'];
$table->alias = $data['1'];
// Reset the ID because we are making a copy
$table->id = 0;
// New category ID
$table->catid = $categoryId;
// Ordering
$table->ordering = $this->increaseOrdering($categoryId);
$table->hits = 0;
// Check the row.
if (!$table->check()) {
$this->setError($table->getError());
return false;
}
// Store the row.
if (!$table->store()) {
$this->setError($table->getError());
return false;
}
//NEW
// Get the new item ID
$newId = $table->get('id');
// Add the new ID to the array
$newIds[$i] = $newId;
$i++;
//ENDNEW
}
// Clean the cache
$this->cleanCache();
//NEW
return $newIds;
//END NEW
}
/**
* Batch move articles to a new category
*
* @param integer $value The new category ID.
* @param array $pks An array of row IDs.
*
* @return booelan True if successful, false otherwise and internal error is set.
*
* @since 11.1
*/
protected function batchMove($value, $pks, $contexts)
{
$categoryId = (int) $value;
$table = $this->getTable();
//$db = $this->getDbo();
// Check that the category exists
if ($categoryId) {
$categoryTable = JTable::getInstance('PhocaGalleryC', 'Table');
if (!$categoryTable->load($categoryId)) {
if ($error = $categoryTable->getError()) {
// Fatal error
$this->setError($error);
return false;
}
else {
$this->setError(JText::_('JLIB_APPLICATION_ERROR_BATCH_MOVE_CATEGORY_NOT_FOUND'));
return false;
}
}
}
if (empty($categoryId)) {
$this->setError(JText::_('JLIB_APPLICATION_ERROR_BATCH_MOVE_CATEGORY_NOT_FOUND'));
return false;
}
// Check that user has create and edit permission for the component
$extension = JRequest::getCmd('option');
$user = JFactory::getUser();
if (!$user->authorise('core.create', $extension)) {
$this->setError(JText::_('JLIB_APPLICATION_ERROR_BATCH_CANNOT_CREATE'));
return false;
}
if (!$user->authorise('core.edit', $extension)) {
$this->setError(JText::_('JLIB_APPLICATION_ERROR_BATCH_CANNOT_EDIT'));
return false;
}
// Parent exists so we let's proceed
foreach ($pks as $pk)
{
// Check that the row actually exists
if (!$table->load($pk)) {
if ($error = $table->getError()) {
// Fatal error
$this->setError($error);
return false;
}
else {
// Not fatal error
$this->setError(JText::sprintf('JLIB_APPLICATION_ERROR_BATCH_MOVE_ROW_NOT_FOUND', $pk));
continue;
}
}
// Set the new category ID
$table->catid = $categoryId;
// Check the row.
if (!$table->check()) {
$this->setError($table->getError());
return false;
}
// Store the row.
if (!$table->store()) {
$this->setError($table->getError());
return false;
}
}
// Clean the cache
$this->cleanCache();
return true;
}
protected function batchTag($value, $pks, $contexts)
{
foreach ($value as $categoryId){
foreach ($pks as $pk)
{
$query = 'DELETE FROM #__phocagallery_tags_ref'
. ' WHERE imgid ='.$pk .' and tagid = '.$categoryId;
$this->_db->setQuery( $query );
if(!$this->_db->query()) {
$this->setError($this->_db->getErrorMsg());
return false;
}
$query = 'insert into #__phocagallery_tags_ref(imgid,tagid) values('
. $pk .', '.$categoryId.')';
$this->_db->setQuery( $query );
if(!$this->_db->query()) {
$this->setError($this->_db->getErrorMsg());
return false;
}
}
}
return true;
}
public function increaseOrdering($categoryId) {
$ordering = 1;
$this->_db->setQuery('SELECT MAX(ordering) FROM #__phocagallery WHERE catid='.(int)$categoryId);
$max = $this->_db->loadResult();
$ordering = $max + 1;
return $ordering;
}
}
?> | Java |
#include "config.h"
#include <arki/tests/tests.h>
#include <arki/iotrace.h>
namespace {
using namespace std;
using namespace arki;
using namespace arki::tests;
class Tests : public TestCase
{
using TestCase::TestCase;
void register_tests() override;
} test("arki_iotrace");
void Tests::register_tests() {
add_method("empty", [] {
});
}
}
| Java |
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>widget-locale - YUI 3</title>
<link rel="stylesheet" href="http://yui.yahooapis.com/3.5.0pr4/build/cssgrids/cssgrids-min.css">
<link rel="stylesheet" href="../assets/vendor/prettify/prettify-min.css">
<link rel="stylesheet" href="../assets/css/main.css" id="site_styles">
<script src="http://yui.yahooapis.com/3.5.0pr4/build/yui/yui-min.js"></script>
</head>
<body class="yui3-skin-sam">
<div id="doc">
<div id="hd" class="yui3-g header">
<div class="yui3-u-3-4">
<h1><img src="../assets/css/logo.png" title="YUI 3"></h1>
</div>
<div class="yui3-u-1-4 version">
<em>API Docs for: 3.5.0</em>
</div>
</div>
<div id="bd" class="yui3-g">
<div class="yui3-u-1-4">
<div id="docs-sidebar" class="sidebar apidocs">
<div id="api-list">
<h2 class="off-left">APIs</h2>
<div id="api-tabview" class="tabview">
<ul class="tabs">
<li><a href="#api-classes">Classes</a></li>
<li><a href="#api-modules">Modules</a></li>
</ul>
<div id="api-tabview-filter">
<input type="search" id="api-filter" placeholder="Type to filter APIs">
</div>
<div id="api-tabview-panel">
<ul id="api-classes" class="apis classes">
<li><a href="../classes/Anim.html">Anim</a></li>
<li><a href="../classes/App.html">App</a></li>
<li><a href="../classes/App.Base.html">App.Base</a></li>
<li><a href="../classes/App.Transitions.html">App.Transitions</a></li>
<li><a href="../classes/App.TransitionsNative.html">App.TransitionsNative</a></li>
<li><a href="../classes/AreaSeries.html">AreaSeries</a></li>
<li><a href="../classes/AreaSplineSeries.html">AreaSplineSeries</a></li>
<li><a href="../classes/Array.html">Array</a></li>
<li><a href="../classes/ArrayList.html">ArrayList</a></li>
<li><a href="../classes/ArraySort.html">ArraySort</a></li>
<li><a href="../classes/AsyncQueue.html">AsyncQueue</a></li>
<li><a href="../classes/Attribute.html">Attribute</a></li>
<li><a href="../classes/AttributeCore.html">AttributeCore</a></li>
<li><a href="../classes/AttributeEvents.html">AttributeEvents</a></li>
<li><a href="../classes/AttributeExtras.html">AttributeExtras</a></li>
<li><a href="../classes/AttributeLite.html">AttributeLite</a></li>
<li><a href="../classes/AutoComplete.html">AutoComplete</a></li>
<li><a href="../classes/AutoCompleteBase.html">AutoCompleteBase</a></li>
<li><a href="../classes/AutoCompleteFilters.html">AutoCompleteFilters</a></li>
<li><a href="../classes/AutoCompleteHighlighters.html">AutoCompleteHighlighters</a></li>
<li><a href="../classes/AutoCompleteList.html">AutoCompleteList</a></li>
<li><a href="../classes/Axis.html">Axis</a></li>
<li><a href="../classes/AxisType.html">AxisType</a></li>
<li><a href="../classes/BarSeries.html">BarSeries</a></li>
<li><a href="../classes/Base.html">Base</a></li>
<li><a href="../classes/BaseCore.html">BaseCore</a></li>
<li><a href="../classes/BottomAxisLayout.html">BottomAxisLayout</a></li>
<li><a href="../classes/Button.html">Button</a></li>
<li><a href="../classes/ButtonCore.html">ButtonCore</a></li>
<li><a href="../classes/ButtonGroup.html">ButtonGroup</a></li>
<li><a href="../classes/ButtonPlugin.html">ButtonPlugin</a></li>
<li><a href="../classes/Cache.html">Cache</a></li>
<li><a href="../classes/CacheOffline.html">CacheOffline</a></li>
<li><a href="../classes/Calendar.html">Calendar</a></li>
<li><a href="../classes/CalendarBase.html">CalendarBase</a></li>
<li><a href="../classes/CanvasCircle.html">CanvasCircle</a></li>
<li><a href="../classes/CanvasDrawing.html">CanvasDrawing</a></li>
<li><a href="../classes/CanvasEllipse.html">CanvasEllipse</a></li>
<li><a href="../classes/CanvasGraphic.html">CanvasGraphic</a></li>
<li><a href="../classes/CanvasPath.html">CanvasPath</a></li>
<li><a href="../classes/CanvasPieSlice.html">CanvasPieSlice</a></li>
<li><a href="../classes/CanvasRect.html">CanvasRect</a></li>
<li><a href="../classes/CanvasShape.html">CanvasShape</a></li>
<li><a href="../classes/CartesianChart.html">CartesianChart</a></li>
<li><a href="../classes/CartesianSeries.html">CartesianSeries</a></li>
<li><a href="../classes/CategoryAxis.html">CategoryAxis</a></li>
<li><a href="../classes/Chart.html">Chart</a></li>
<li><a href="../classes/ChartBase.html">ChartBase</a></li>
<li><a href="../classes/ChartLegend.html">ChartLegend</a></li>
<li><a href="../classes/Circle.html">Circle</a></li>
<li><a href="../classes/ClassNameManager.html">ClassNameManager</a></li>
<li><a href="../classes/ClickableRail.html">ClickableRail</a></li>
<li><a href="../classes/ColumnSeries.html">ColumnSeries</a></li>
<li><a href="../classes/ComboSeries.html">ComboSeries</a></li>
<li><a href="../classes/ComboSplineSeries.html">ComboSplineSeries</a></li>
<li><a href="../classes/config.html">config</a></li>
<li><a href="../classes/Console.html">Console</a></li>
<li><a href="../classes/Controller.html">Controller</a></li>
<li><a href="../classes/Cookie.html">Cookie</a></li>
<li><a href="../classes/CurveUtil.html">CurveUtil</a></li>
<li><a href="../classes/CustomEvent.html">CustomEvent</a></li>
<li><a href="../classes/DataSchema.Array.html">DataSchema.Array</a></li>
<li><a href="../classes/DataSchema.Base.html">DataSchema.Base</a></li>
<li><a href="../classes/DataSchema.JSON.html">DataSchema.JSON</a></li>
<li><a href="../classes/DataSchema.Text.html">DataSchema.Text</a></li>
<li><a href="../classes/DataSchema.XML.html">DataSchema.XML</a></li>
<li><a href="../classes/DataSource.Function.html">DataSource.Function</a></li>
<li><a href="../classes/DataSource.Get.html">DataSource.Get</a></li>
<li><a href="../classes/DataSource.IO.html">DataSource.IO</a></li>
<li><a href="../classes/DataSource.Local.html">DataSource.Local</a></li>
<li><a href="../classes/DataSourceArraySchema.html">DataSourceArraySchema</a></li>
<li><a href="../classes/DataSourceCache.html">DataSourceCache</a></li>
<li><a href="../classes/DataSourceCacheExtension.html">DataSourceCacheExtension</a></li>
<li><a href="../classes/DataSourceJSONSchema.html">DataSourceJSONSchema</a></li>
<li><a href="../classes/DataSourceTextSchema.html">DataSourceTextSchema</a></li>
<li><a href="../classes/DataSourceXMLSchema.html">DataSourceXMLSchema</a></li>
<li><a href="../classes/DataTable.html">DataTable</a></li>
<li><a href="../classes/DataTable.Base.html">DataTable.Base</a></li>
<li><a href="../classes/DataTable.BodyView.html">DataTable.BodyView</a></li>
<li><a href="../classes/DataTable.ColumnWidths.html">DataTable.ColumnWidths</a></li>
<li><a href="../classes/DataTable.Core.html">DataTable.Core</a></li>
<li><a href="../classes/DataTable.HeaderView.html">DataTable.HeaderView</a></li>
<li><a href="../classes/DataTable.Message.html">DataTable.Message</a></li>
<li><a href="../classes/DataTable.Mutable.html">DataTable.Mutable</a></li>
<li><a href="../classes/DataTable.Scrollable.html">DataTable.Scrollable</a></li>
<li><a href="../classes/DataTable.Sortable.html">DataTable.Sortable</a></li>
<li><a href="../classes/DataType.Date.html">DataType.Date</a></li>
<li><a href="../classes/DataType.Date.Locale.html">DataType.Date.Locale</a></li>
<li><a href="../classes/DataType.Number.html">DataType.Number</a></li>
<li><a href="../classes/DataType.XML.html">DataType.XML</a></li>
<li><a href="../classes/DD.DDM.html">DD.DDM</a></li>
<li><a href="../classes/DD.Delegate.html">DD.Delegate</a></li>
<li><a href="../classes/DD.Drag.html">DD.Drag</a></li>
<li><a href="../classes/DD.Drop.html">DD.Drop</a></li>
<li><a href="../classes/DD.Plugin.DDWindowScroll.html">DD.Plugin.DDWindowScroll</a></li>
<li><a href="../classes/DD.Scroll.html">DD.Scroll</a></li>
<li><a href="../classes/Dial.html">Dial</a></li>
<li><a href="../classes/Do.html">Do</a></li>
<li><a href="../classes/Do.AlterArgs.html">Do.AlterArgs</a></li>
<li><a href="../classes/Do.AlterReturn.html">Do.AlterReturn</a></li>
<li><a href="../classes/Do.Error.html">Do.Error</a></li>
<li><a href="../classes/Do.Halt.html">Do.Halt</a></li>
<li><a href="../classes/Do.Method.html">Do.Method</a></li>
<li><a href="../classes/Do.Prevent.html">Do.Prevent</a></li>
<li><a href="../classes/DOM.html">DOM</a></li>
<li><a href="../classes/DOMEventFacade.html">DOMEventFacade</a></li>
<li><a href="../classes/Drawing.html">Drawing</a></li>
<li><a href="../classes/Easing.html">Easing</a></li>
<li><a href="../classes/EditorBase.html">EditorBase</a></li>
<li><a href="../classes/EditorSelection.html">EditorSelection</a></li>
<li><a href="../classes/Ellipse.html">Ellipse</a></li>
<li><a href="../classes/EllipseGroup.html">EllipseGroup</a></li>
<li><a href="../classes/Escape.html">Escape</a></li>
<li><a href="../classes/Event.html">Event</a></li>
<li><a href="../classes/EventFacade.html">EventFacade</a></li>
<li><a href="../classes/EventHandle.html">EventHandle</a></li>
<li><a href="../classes/EventTarget.html">EventTarget</a></li>
<li><a href="../classes/ExecCommand.html">ExecCommand</a></li>
<li><a href="../classes/Features.html">Features</a></li>
<li><a href="../classes/File.html">File</a></li>
<li><a href="../classes/FileFlash.html">FileFlash</a></li>
<li><a href="../classes/FileHTML5.html">FileHTML5</a></li>
<li><a href="../classes/Fills.html">Fills</a></li>
<li><a href="../classes/Frame.html">Frame</a></li>
<li><a href="../classes/Get.html">Get</a></li>
<li><a href="../classes/Get.Transaction.html">Get.Transaction</a></li>
<li><a href="../classes/GetNodeJS.html">GetNodeJS</a></li>
<li><a href="../classes/Graph.html">Graph</a></li>
<li><a href="../classes/Graphic.html">Graphic</a></li>
<li><a href="../classes/GraphicBase.html">GraphicBase</a></li>
<li><a href="../classes/Gridlines.html">Gridlines</a></li>
<li><a href="../classes/GroupCircle.html">GroupCircle</a></li>
<li><a href="../classes/GroupDiamond.html">GroupDiamond</a></li>
<li><a href="../classes/GroupRect.html">GroupRect</a></li>
<li><a href="../classes/Handlebars.html">Handlebars</a></li>
<li><a href="../classes/Highlight.html">Highlight</a></li>
<li><a href="../classes/Histogram.html">Histogram</a></li>
<li><a href="../classes/HistoryBase.html">HistoryBase</a></li>
<li><a href="../classes/HistoryHash.html">HistoryHash</a></li>
<li><a href="../classes/HistoryHTML5.html">HistoryHTML5</a></li>
<li><a href="../classes/HorizontalLegendLayout.html">HorizontalLegendLayout</a></li>
<li><a href="../classes/ImgLoadGroup.html">ImgLoadGroup</a></li>
<li><a href="../classes/ImgLoadImgObj.html">ImgLoadImgObj</a></li>
<li><a href="../classes/Intl.html">Intl</a></li>
<li><a href="../classes/IO.html">IO</a></li>
<li><a href="../classes/json.html">json</a></li>
<li><a href="../classes/JSONPRequest.html">JSONPRequest</a></li>
<li><a href="../classes/Lang.html">Lang</a></li>
<li><a href="../classes/LeftAxisLayout.html">LeftAxisLayout</a></li>
<li><a href="../classes/Lines.html">Lines</a></li>
<li><a href="../classes/LineSeries.html">LineSeries</a></li>
<li><a href="../classes/Loader.html">Loader</a></li>
<li><a href="../classes/MarkerSeries.html">MarkerSeries</a></li>
<li><a href="../classes/Matrix.html">Matrix</a></li>
<li><a href="../classes/Model.html">Model</a></li>
<li><a href="../classes/ModelList.html">ModelList</a></li>
<li><a href="../classes/Node.html">Node</a></li>
<li><a href="../classes/NodeList.html">NodeList</a></li>
<li><a href="../classes/NumericAxis.html">NumericAxis</a></li>
<li><a href="../classes/Object.html">Object</a></li>
<li><a href="../classes/Overlay.html">Overlay</a></li>
<li><a href="../classes/Panel.html">Panel</a></li>
<li><a href="../classes/Parallel.html">Parallel</a></li>
<li><a href="../classes/Path.html">Path</a></li>
<li><a href="../classes/PieChart.html">PieChart</a></li>
<li><a href="../classes/PieSeries.html">PieSeries</a></li>
<li><a href="../classes/Pjax.html">Pjax</a></li>
<li><a href="../classes/PjaxBase.html">PjaxBase</a></li>
<li><a href="../classes/Plots.html">Plots</a></li>
<li><a href="../classes/Plugin.Align.html">Plugin.Align</a></li>
<li><a href="../classes/Plugin.AutoComplete.html">Plugin.AutoComplete</a></li>
<li><a href="../classes/Plugin.Base.html">Plugin.Base</a></li>
<li><a href="../classes/Plugin.Cache.html">Plugin.Cache</a></li>
<li><a href="../classes/Plugin.CalendarNavigator.html">Plugin.CalendarNavigator</a></li>
<li><a href="../classes/Plugin.ConsoleFilters.html">Plugin.ConsoleFilters</a></li>
<li><a href="../classes/Plugin.CreateLinkBase.html">Plugin.CreateLinkBase</a></li>
<li><a href="../classes/Plugin.DataTableDataSource.html">Plugin.DataTableDataSource</a></li>
<li><a href="../classes/Plugin.DDConstrained.html">Plugin.DDConstrained</a></li>
<li><a href="../classes/Plugin.DDNodeScroll.html">Plugin.DDNodeScroll</a></li>
<li><a href="../classes/Plugin.DDProxy.html">Plugin.DDProxy</a></li>
<li><a href="../classes/Plugin.Drag.html">Plugin.Drag</a></li>
<li><a href="../classes/Plugin.Drop.html">Plugin.Drop</a></li>
<li><a href="../classes/Plugin.EditorBidi.html">Plugin.EditorBidi</a></li>
<li><a href="../classes/Plugin.EditorBR.html">Plugin.EditorBR</a></li>
<li><a href="../classes/Plugin.EditorLists.html">Plugin.EditorLists</a></li>
<li><a href="../classes/Plugin.EditorPara.html">Plugin.EditorPara</a></li>
<li><a href="../classes/Plugin.EditorParaBase.html">Plugin.EditorParaBase</a></li>
<li><a href="../classes/Plugin.EditorParaIE.html">Plugin.EditorParaIE</a></li>
<li><a href="../classes/Plugin.EditorTab.html">Plugin.EditorTab</a></li>
<li><a href="../classes/Plugin.ExecCommand.html">Plugin.ExecCommand</a></li>
<li><a href="../classes/Plugin.Flick.html">Plugin.Flick</a></li>
<li><a href="../classes/Plugin.Host.html">Plugin.Host</a></li>
<li><a href="../classes/plugin.NodeFocusManager.html">plugin.NodeFocusManager</a></li>
<li><a href="../classes/Plugin.NodeFX.html">Plugin.NodeFX</a></li>
<li><a href="../classes/plugin.NodeMenuNav.html">plugin.NodeMenuNav</a></li>
<li><a href="../classes/Plugin.Pjax.html">Plugin.Pjax</a></li>
<li><a href="../classes/Plugin.Resize.html">Plugin.Resize</a></li>
<li><a href="../classes/Plugin.ResizeConstrained.html">Plugin.ResizeConstrained</a></li>
<li><a href="../classes/Plugin.ResizeProxy.html">Plugin.ResizeProxy</a></li>
<li><a href="../classes/Plugin.ScrollViewList.html">Plugin.ScrollViewList</a></li>
<li><a href="../classes/Plugin.ScrollViewPaginator.html">Plugin.ScrollViewPaginator</a></li>
<li><a href="../classes/Plugin.ScrollViewScrollbars.html">Plugin.ScrollViewScrollbars</a></li>
<li><a href="../classes/Plugin.Shim.html">Plugin.Shim</a></li>
<li><a href="../classes/Plugin.SortScroll.html">Plugin.SortScroll</a></li>
<li><a href="../classes/Plugin.WidgetAnim.html">Plugin.WidgetAnim</a></li>
<li><a href="../classes/Pollable.html">Pollable</a></li>
<li><a href="../classes/Profiler.html">Profiler</a></li>
<li><a href="../classes/QueryString.html">QueryString</a></li>
<li><a href="../classes/Queue.html">Queue</a></li>
<li><a href="../classes/Record.html">Record</a></li>
<li><a href="../classes/Recordset.html">Recordset</a></li>
<li><a href="../classes/RecordsetFilter.html">RecordsetFilter</a></li>
<li><a href="../classes/RecordsetIndexer.html">RecordsetIndexer</a></li>
<li><a href="../classes/RecordsetSort.html">RecordsetSort</a></li>
<li><a href="../classes/Rect.html">Rect</a></li>
<li><a href="../classes/Renderer.html">Renderer</a></li>
<li><a href="../classes/Resize.html">Resize</a></li>
<li><a href="../classes/RightAxisLayout.html">RightAxisLayout</a></li>
<li><a href="../classes/Router.html">Router</a></li>
<li><a href="../classes/ScrollView.html">ScrollView</a></li>
<li><a href="../classes/Selector.html">Selector</a></li>
<li><a href="../classes/Shape.html">Shape</a></li>
<li><a href="../classes/ShapeGroup.html">ShapeGroup</a></li>
<li><a href="../classes/Slider.html">Slider</a></li>
<li><a href="../classes/SliderBase.html">SliderBase</a></li>
<li><a href="../classes/SliderValueRange.html">SliderValueRange</a></li>
<li><a href="../classes/Sortable.html">Sortable</a></li>
<li><a href="../classes/SplineSeries.html">SplineSeries</a></li>
<li><a href="../classes/StackedAreaSeries.html">StackedAreaSeries</a></li>
<li><a href="../classes/StackedAreaSplineSeries.html">StackedAreaSplineSeries</a></li>
<li><a href="../classes/StackedAxis.html">StackedAxis</a></li>
<li><a href="../classes/StackedBarSeries.html">StackedBarSeries</a></li>
<li><a href="../classes/StackedColumnSeries.html">StackedColumnSeries</a></li>
<li><a href="../classes/StackedComboSeries.html">StackedComboSeries</a></li>
<li><a href="../classes/StackedComboSplineSeries.html">StackedComboSplineSeries</a></li>
<li><a href="../classes/StackedLineSeries.html">StackedLineSeries</a></li>
<li><a href="../classes/StackedMarkerSeries.html">StackedMarkerSeries</a></li>
<li><a href="../classes/StackedSplineSeries.html">StackedSplineSeries</a></li>
<li><a href="../classes/StackingUtil.html">StackingUtil</a></li>
<li><a href="../classes/State.html">State</a></li>
<li><a href="../classes/StyleSheet.html">StyleSheet</a></li>
<li><a href="../classes/Subscriber.html">Subscriber</a></li>
<li><a href="../classes/SVGCircle.html">SVGCircle</a></li>
<li><a href="../classes/SVGDrawing.html">SVGDrawing</a></li>
<li><a href="../classes/SVGEllipse.html">SVGEllipse</a></li>
<li><a href="../classes/SVGGraphic.html">SVGGraphic</a></li>
<li><a href="../classes/SVGPath.html">SVGPath</a></li>
<li><a href="../classes/SVGPieSlice.html">SVGPieSlice</a></li>
<li><a href="../classes/SVGRect.html">SVGRect</a></li>
<li><a href="../classes/SVGShape.html">SVGShape</a></li>
<li><a href="../classes/SWF.html">SWF</a></li>
<li><a href="../classes/SWFDetect.html">SWFDetect</a></li>
<li><a href="../classes/SyntheticEvent.html">SyntheticEvent</a></li>
<li><a href="../classes/SyntheticEvent.Notifier.html">SyntheticEvent.Notifier</a></li>
<li><a href="../classes/SynthRegistry.html">SynthRegistry</a></li>
<li><a href="../classes/Tab.html">Tab</a></li>
<li><a href="../classes/TabView.html">TabView</a></li>
<li><a href="../classes/Test.html">Test</a></li>
<li><a href="../classes/Test.ArrayAssert.html">Test.ArrayAssert</a></li>
<li><a href="../classes/Test.Assert.html">Test.Assert</a></li>
<li><a href="../classes/Test.AssertionError.html">Test.AssertionError</a></li>
<li><a href="../classes/Test.ComparisonFailure.html">Test.ComparisonFailure</a></li>
<li><a href="../classes/Test.Console.html">Test.Console</a></li>
<li><a href="../classes/Test.CoverageFormat.CoverageFormat.html">Test.CoverageFormat.CoverageFormat</a></li>
<li><a href="../classes/Test.DateAssert.html">Test.DateAssert</a></li>
<li><a href="../classes/Test.EventTarget.html">Test.EventTarget</a></li>
<li><a href="../classes/Test.Mock.Mock.html">Test.Mock.Mock</a></li>
<li><a href="../classes/Test.Mock.Value.html">Test.Mock.Value</a></li>
<li><a href="../classes/Test.ObjectAssert.html">Test.ObjectAssert</a></li>
<li><a href="../classes/Test.Reporter.html">Test.Reporter</a></li>
<li><a href="../classes/Test.Results.html">Test.Results</a></li>
<li><a href="../classes/Test.Runner.html">Test.Runner</a></li>
<li><a href="../classes/Test.ShouldError.html">Test.ShouldError</a></li>
<li><a href="../classes/Test.ShouldFail.html">Test.ShouldFail</a></li>
<li><a href="../classes/Test.TestCase.html">Test.TestCase</a></li>
<li><a href="../classes/Test.TestFormat.html">Test.TestFormat</a></li>
<li><a href="../classes/Test.TestNode.html">Test.TestNode</a></li>
<li><a href="../classes/Test.TestRunner.html">Test.TestRunner</a></li>
<li><a href="../classes/Test.TestSuite.html">Test.TestSuite</a></li>
<li><a href="../classes/Test.UnexpectedError.html">Test.UnexpectedError</a></li>
<li><a href="../classes/Test.UnexpectedValue.html">Test.UnexpectedValue</a></li>
<li><a href="../classes/Test.Wait.html">Test.Wait</a></li>
<li><a href="../classes/Text.AccentFold.html">Text.AccentFold</a></li>
<li><a href="../classes/Text.WordBreak.html">Text.WordBreak</a></li>
<li><a href="../classes/TimeAxis.html">TimeAxis</a></li>
<li><a href="../classes/ToggleButton.html">ToggleButton</a></li>
<li><a href="../classes/TopAxisLayout.html">TopAxisLayout</a></li>
<li><a href="../classes/Transition.html">Transition</a></li>
<li><a href="../classes/UA.html">UA</a></li>
<li><a href="../classes/Uploader.html">Uploader</a></li>
<li><a href="../classes/Uploader.Queue.html">Uploader.Queue</a></li>
<li><a href="../classes/UploaderFlash.html">UploaderFlash</a></li>
<li><a href="../classes/UploaderHTML5.html">UploaderHTML5</a></li>
<li><a href="../classes/ValueChange.html">ValueChange</a></li>
<li><a href="../classes/VerticalLegendLayout.html">VerticalLegendLayout</a></li>
<li><a href="../classes/View.html">View</a></li>
<li><a href="../classes/View.NodeMap.html">View.NodeMap</a></li>
<li><a href="../classes/VMLCircle.html">VMLCircle</a></li>
<li><a href="../classes/VMLDrawing.html">VMLDrawing</a></li>
<li><a href="../classes/VMLEllipse.html">VMLEllipse</a></li>
<li><a href="../classes/VMLGraphic.html">VMLGraphic</a></li>
<li><a href="../classes/VMLPath.html">VMLPath</a></li>
<li><a href="../classes/VMLPieSlice.html">VMLPieSlice</a></li>
<li><a href="../classes/VMLRect.html">VMLRect</a></li>
<li><a href="../classes/VMLShape.html">VMLShape</a></li>
<li><a href="../classes/Widget.html">Widget</a></li>
<li><a href="../classes/WidgetAutohide.html">WidgetAutohide</a></li>
<li><a href="../classes/WidgetButtons.html">WidgetButtons</a></li>
<li><a href="../classes/WidgetChild.html">WidgetChild</a></li>
<li><a href="../classes/WidgetModality.html">WidgetModality</a></li>
<li><a href="../classes/WidgetParent.html">WidgetParent</a></li>
<li><a href="../classes/WidgetPosition.html">WidgetPosition</a></li>
<li><a href="../classes/WidgetPositionAlign.html">WidgetPositionAlign</a></li>
<li><a href="../classes/WidgetPositionConstrain.html">WidgetPositionConstrain</a></li>
<li><a href="../classes/WidgetStack.html">WidgetStack</a></li>
<li><a href="../classes/WidgetStdMod.html">WidgetStdMod</a></li>
<li><a href="../classes/YQL.html">YQL</a></li>
<li><a href="../classes/YQLRequest.html">YQLRequest</a></li>
<li><a href="../classes/YUI.html">YUI</a></li>
<li><a href="../classes/YUI~substitute.html">YUI~substitute</a></li>
</ul>
<ul id="api-modules" class="apis modules">
<li><a href="../modules/align-plugin.html">align-plugin</a></li>
<li><a href="../modules/anim.html">anim</a></li>
<li><a href="../modules/anim-base.html">anim-base</a></li>
<li><a href="../modules/anim-color.html">anim-color</a></li>
<li><a href="../modules/anim-curve.html">anim-curve</a></li>
<li><a href="../modules/anim-easing.html">anim-easing</a></li>
<li><a href="../modules/anim-node-plugin.html">anim-node-plugin</a></li>
<li><a href="../modules/anim-scroll.html">anim-scroll</a></li>
<li><a href="../modules/anim-xy.html">anim-xy</a></li>
<li><a href="../modules/app.html">app</a></li>
<li><a href="../modules/app-base.html">app-base</a></li>
<li><a href="../modules/app-transitions.html">app-transitions</a></li>
<li><a href="../modules/app-transitions-native.html">app-transitions-native</a></li>
<li><a href="../modules/array-extras.html">array-extras</a></li>
<li><a href="../modules/array-invoke.html">array-invoke</a></li>
<li><a href="../modules/arraylist.html">arraylist</a></li>
<li><a href="../modules/arraylist-add.html">arraylist-add</a></li>
<li><a href="../modules/arraylist-filter.html">arraylist-filter</a></li>
<li><a href="../modules/arraysort.html">arraysort</a></li>
<li><a href="../modules/async-queue.html">async-queue</a></li>
<li><a href="../modules/attribute.html">attribute</a></li>
<li><a href="../modules/attribute-base.html">attribute-base</a></li>
<li><a href="../modules/attribute-complex.html">attribute-complex</a></li>
<li><a href="../modules/attribute-core.html">attribute-core</a></li>
<li><a href="../modules/attribute-events.html">attribute-events</a></li>
<li><a href="../modules/attribute-extras.html">attribute-extras</a></li>
<li><a href="../modules/autocomplete.html">autocomplete</a></li>
<li><a href="../modules/autocomplete-base.html">autocomplete-base</a></li>
<li><a href="../modules/autocomplete-filters.html">autocomplete-filters</a></li>
<li><a href="../modules/autocomplete-filters-accentfold.html">autocomplete-filters-accentfold</a></li>
<li><a href="../modules/autocomplete-highlighters.html">autocomplete-highlighters</a></li>
<li><a href="../modules/autocomplete-highlighters-accentfold.html">autocomplete-highlighters-accentfold</a></li>
<li><a href="../modules/autocomplete-list.html">autocomplete-list</a></li>
<li><a href="../modules/autocomplete-list-keys.html">autocomplete-list-keys</a></li>
<li><a href="../modules/autocomplete-plugin.html">autocomplete-plugin</a></li>
<li><a href="../modules/autocomplete-sources.html">autocomplete-sources</a></li>
<li><a href="../modules/base.html">base</a></li>
<li><a href="../modules/base-base.html">base-base</a></li>
<li><a href="../modules/base-build.html">base-build</a></li>
<li><a href="../modules/base-core.html">base-core</a></li>
<li><a href="../modules/base-pluginhost.html">base-pluginhost</a></li>
<li><a href="../modules/button.html">button</a></li>
<li><a href="../modules/button-core.html">button-core</a></li>
<li><a href="../modules/button-group.html">button-group</a></li>
<li><a href="../modules/button-plugin.html">button-plugin</a></li>
<li><a href="../modules/cache.html">cache</a></li>
<li><a href="../modules/cache-base.html">cache-base</a></li>
<li><a href="../modules/cache-offline.html">cache-offline</a></li>
<li><a href="../modules/cache-plugin.html">cache-plugin</a></li>
<li><a href="../modules/calendar.html">calendar</a></li>
<li><a href="../modules/calendar-base.html">calendar-base</a></li>
<li><a href="../modules/calendarnavigator.html">calendarnavigator</a></li>
<li><a href="../modules/charts.html">charts</a></li>
<li><a href="../modules/charts-legend.html">charts-legend</a></li>
<li><a href="../modules/classnamemanager.html">classnamemanager</a></li>
<li><a href="../modules/clickable-rail.html">clickable-rail</a></li>
<li><a href="../modules/collection.html">collection</a></li>
<li><a href="../modules/console.html">console</a></li>
<li><a href="../modules/console-filters.html">console-filters</a></li>
<li><a href="../modules/cookie.html">cookie</a></li>
<li><a href="../modules/createlink-base.html">createlink-base</a></li>
<li><a href="../modules/dataschema.html">dataschema</a></li>
<li><a href="../modules/dataschema-array.html">dataschema-array</a></li>
<li><a href="../modules/dataschema-base.html">dataschema-base</a></li>
<li><a href="../modules/dataschema-json.html">dataschema-json</a></li>
<li><a href="../modules/dataschema-text.html">dataschema-text</a></li>
<li><a href="../modules/dataschema-xml.html">dataschema-xml</a></li>
<li><a href="../modules/datasource.html">datasource</a></li>
<li><a href="../modules/datasource-arrayschema.html">datasource-arrayschema</a></li>
<li><a href="../modules/datasource-cache.html">datasource-cache</a></li>
<li><a href="../modules/datasource-function.html">datasource-function</a></li>
<li><a href="../modules/datasource-get.html">datasource-get</a></li>
<li><a href="../modules/datasource-io.html">datasource-io</a></li>
<li><a href="../modules/datasource-jsonschema.html">datasource-jsonschema</a></li>
<li><a href="../modules/datasource-local.html">datasource-local</a></li>
<li><a href="../modules/datasource-polling.html">datasource-polling</a></li>
<li><a href="../modules/datasource-textschema.html">datasource-textschema</a></li>
<li><a href="../modules/datasource-xmlschema.html">datasource-xmlschema</a></li>
<li><a href="../modules/datatable.html">datatable</a></li>
<li><a href="../modules/datatable-base.html">datatable-base</a></li>
<li><a href="../modules/datatable-base-deprecated.html">datatable-base-deprecated</a></li>
<li><a href="../modules/datatable-body.html">datatable-body</a></li>
<li><a href="../modules/datatable-column-widths.html">datatable-column-widths</a></li>
<li><a href="../modules/datatable-core.html">datatable-core</a></li>
<li><a href="../modules/datatable-datasource.html">datatable-datasource</a></li>
<li><a href="../modules/datatable-datasource-deprecated.html">datatable-datasource-deprecated</a></li>
<li><a href="../modules/datatable-deprecated.html">datatable-deprecated</a></li>
<li><a href="../modules/datatable-head.html">datatable-head</a></li>
<li><a href="../modules/datatable-message.html">datatable-message</a></li>
<li><a href="../modules/datatable-mutable.html">datatable-mutable</a></li>
<li><a href="../modules/datatable-scroll.html">datatable-scroll</a></li>
<li><a href="../modules/datatable-scroll-deprecated.html">datatable-scroll-deprecated</a></li>
<li><a href="../modules/datatable-sort.html">datatable-sort</a></li>
<li><a href="../modules/datatable-sort-deprecated.html">datatable-sort-deprecated</a></li>
<li><a href="../modules/datatype.html">datatype</a></li>
<li><a href="../modules/datatype-date.html">datatype-date</a></li>
<li><a href="../modules/datatype-date-format.html">datatype-date-format</a></li>
<li><a href="../modules/datatype-date-math.html">datatype-date-math</a></li>
<li><a href="../modules/datatype-date-parse.html">datatype-date-parse</a></li>
<li><a href="../modules/datatype-number.html">datatype-number</a></li>
<li><a href="../modules/datatype-number-format.html">datatype-number-format</a></li>
<li><a href="../modules/datatype-number-parse.html">datatype-number-parse</a></li>
<li><a href="../modules/datatype-xml.html">datatype-xml</a></li>
<li><a href="../modules/datatype-xml-format.html">datatype-xml-format</a></li>
<li><a href="../modules/datatype-xml-parse.html">datatype-xml-parse</a></li>
<li><a href="../modules/dd.html">dd</a></li>
<li><a href="../modules/dd-constrain.html">dd-constrain</a></li>
<li><a href="../modules/dd-ddm.html">dd-ddm</a></li>
<li><a href="../modules/dd-ddm-base.html">dd-ddm-base</a></li>
<li><a href="../modules/dd-ddm-drop.html">dd-ddm-drop</a></li>
<li><a href="../modules/dd-delegate.html">dd-delegate</a></li>
<li><a href="../modules/dd-drag.html">dd-drag</a></li>
<li><a href="../modules/dd-drop.html">dd-drop</a></li>
<li><a href="../modules/dd-drop-plugin.html">dd-drop-plugin</a></li>
<li><a href="../modules/dd-plugin.html">dd-plugin</a></li>
<li><a href="../modules/dd-proxy.html">dd-proxy</a></li>
<li><a href="../modules/dd-scroll.html">dd-scroll</a></li>
<li><a href="../modules/dial.html">dial</a></li>
<li><a href="../modules/dom.html">dom</a></li>
<li><a href="../modules/dom-base.html">dom-base</a></li>
<li><a href="../modules/dom-screen.html">dom-screen</a></li>
<li><a href="../modules/dom-style.html">dom-style</a></li>
<li><a href="../modules/dump.html">dump</a></li>
<li><a href="../modules/editor.html">editor</a></li>
<li><a href="../modules/editor-base.html">editor-base</a></li>
<li><a href="../modules/editor-bidi.html">editor-bidi</a></li>
<li><a href="../modules/editor-br.html">editor-br</a></li>
<li><a href="../modules/editor-lists.html">editor-lists</a></li>
<li><a href="../modules/editor-para.html">editor-para</a></li>
<li><a href="../modules/editor-para-base.html">editor-para-base</a></li>
<li><a href="../modules/editor-para-ie.html">editor-para-ie</a></li>
<li><a href="../modules/editor-tab.html">editor-tab</a></li>
<li><a href="../modules/escape.html">escape</a></li>
<li><a href="../modules/event.html">event</a></li>
<li><a href="../modules/event-base.html">event-base</a></li>
<li><a href="../modules/event-contextmenu.html">event-contextmenu</a></li>
<li><a href="../modules/event-custom.html">event-custom</a></li>
<li><a href="../modules/event-custom-base.html">event-custom-base</a></li>
<li><a href="../modules/event-custom-complex.html">event-custom-complex</a></li>
<li><a href="../modules/event-delegate.html">event-delegate</a></li>
<li><a href="../modules/event-flick.html">event-flick</a></li>
<li><a href="../modules/event-focus.html">event-focus</a></li>
<li><a href="../modules/event-gestures.html">event-gestures</a></li>
<li><a href="../modules/event-hover.html">event-hover</a></li>
<li><a href="../modules/event-key.html">event-key</a></li>
<li><a href="../modules/event-mouseenter.html">event-mouseenter</a></li>
<li><a href="../modules/event-mousewheel.html">event-mousewheel</a></li>
<li><a href="../modules/event-move.html">event-move</a></li>
<li><a href="../modules/event-outside.html">event-outside</a></li>
<li><a href="../modules/event-resize.html">event-resize</a></li>
<li><a href="../modules/event-simulate.html">event-simulate</a></li>
<li><a href="../modules/event-synthetic.html">event-synthetic</a></li>
<li><a href="../modules/event-touch.html">event-touch</a></li>
<li><a href="../modules/event-valuechange.html">event-valuechange</a></li>
<li><a href="../modules/exec-command.html">exec-command</a></li>
<li><a href="../modules/features.html">features</a></li>
<li><a href="../modules/file.html">file</a></li>
<li><a href="../modules/file-flash.html">file-flash</a></li>
<li><a href="../modules/file-html5.html">file-html5</a></li>
<li><a href="../modules/frame.html">frame</a></li>
<li><a href="../modules/get.html">get</a></li>
<li><a href="../modules/get-nodejs.html">get-nodejs</a></li>
<li><a href="../modules/graphics.html">graphics</a></li>
<li><a href="../modules/handlebars.html">handlebars</a></li>
<li><a href="../modules/handlebars-base.html">handlebars-base</a></li>
<li><a href="../modules/handlebars-compiler.html">handlebars-compiler</a></li>
<li><a href="../modules/highlight.html">highlight</a></li>
<li><a href="../modules/highlight-accentfold.html">highlight-accentfold</a></li>
<li><a href="../modules/highlight-base.html">highlight-base</a></li>
<li><a href="../modules/history.html">history</a></li>
<li><a href="../modules/history-base.html">history-base</a></li>
<li><a href="../modules/history-hash.html">history-hash</a></li>
<li><a href="../modules/history-hash-ie.html">history-hash-ie</a></li>
<li><a href="../modules/history-html5.html">history-html5</a></li>
<li><a href="../modules/imageloader.html">imageloader</a></li>
<li><a href="../modules/intl.html">intl</a></li>
<li><a href="../modules/io.html">io</a></li>
<li><a href="../modules/io-base.html">io-base</a></li>
<li><a href="../modules/io-form.html">io-form</a></li>
<li><a href="../modules/io-queue.html">io-queue</a></li>
<li><a href="../modules/io-upload-iframe.html">io-upload-iframe</a></li>
<li><a href="../modules/io-xdr.html">io-xdr</a></li>
<li><a href="../modules/json.html">json</a></li>
<li><a href="../modules/json-parse.html">json-parse</a></li>
<li><a href="../modules/json-stringify.html">json-stringify</a></li>
<li><a href="../modules/jsonp.html">jsonp</a></li>
<li><a href="../modules/jsonp-url.html">jsonp-url</a></li>
<li><a href="../modules/loader.html">loader</a></li>
<li><a href="../modules/loader-base.html">loader-base</a></li>
<li><a href="../modules/matrix.html">matrix</a></li>
<li><a href="../modules/model.html">model</a></li>
<li><a href="../modules/model-list.html">model-list</a></li>
<li><a href="../modules/node.html">node</a></li>
<li><a href="../modules/node-base.html">node-base</a></li>
<li><a href="../modules/node-core.html">node-core</a></li>
<li><a href="../modules/node-data.html">node-data</a></li>
<li><a href="../modules/node-deprecated.html">node-deprecated</a></li>
<li><a href="../modules/node-event-delegate.html">node-event-delegate</a></li>
<li><a href="../modules/node-event-html5.html">node-event-html5</a></li>
<li><a href="../modules/node-event-simulate.html">node-event-simulate</a></li>
<li><a href="../modules/node-flick.html">node-flick</a></li>
<li><a href="../modules/node-focusmanager.html">node-focusmanager</a></li>
<li><a href="../modules/node-load.html">node-load</a></li>
<li><a href="../modules/node-menunav.html">node-menunav</a></li>
<li><a href="../modules/node-pluginhost.html">node-pluginhost</a></li>
<li><a href="../modules/node-screen.html">node-screen</a></li>
<li><a href="../modules/node-style.html">node-style</a></li>
<li><a href="../modules/oop.html">oop</a></li>
<li><a href="../modules/overlay.html">overlay</a></li>
<li><a href="../modules/panel.html">panel</a></li>
<li><a href="../modules/parallel.html">parallel</a></li>
<li><a href="../modules/pjax.html">pjax</a></li>
<li><a href="../modules/pjax-base.html">pjax-base</a></li>
<li><a href="../modules/pjax-plugin.html">pjax-plugin</a></li>
<li><a href="../modules/plugin.html">plugin</a></li>
<li><a href="../modules/pluginhost.html">pluginhost</a></li>
<li><a href="../modules/pluginhost-base.html">pluginhost-base</a></li>
<li><a href="../modules/pluginhost-config.html">pluginhost-config</a></li>
<li><a href="../modules/profiler.html">profiler</a></li>
<li><a href="../modules/querystring.html">querystring</a></li>
<li><a href="../modules/querystring-parse.html">querystring-parse</a></li>
<li><a href="../modules/querystring-parse-simple.html">querystring-parse-simple</a></li>
<li><a href="../modules/querystring-stringify.html">querystring-stringify</a></li>
<li><a href="../modules/querystring-stringify-simple.html">querystring-stringify-simple</a></li>
<li><a href="../modules/queue-promote.html">queue-promote</a></li>
<li><a href="../modules/range-slider.html">range-slider</a></li>
<li><a href="../modules/recordset.html">recordset</a></li>
<li><a href="../modules/recordset-base.html">recordset-base</a></li>
<li><a href="../modules/recordset-filter.html">recordset-filter</a></li>
<li><a href="../modules/recordset-indexer.html">recordset-indexer</a></li>
<li><a href="../modules/recordset-sort.html">recordset-sort</a></li>
<li><a href="../modules/resize.html">resize</a></li>
<li><a href="../modules/resize-contrain.html">resize-contrain</a></li>
<li><a href="../modules/resize-plugin.html">resize-plugin</a></li>
<li><a href="../modules/resize-proxy.html">resize-proxy</a></li>
<li><a href="../modules/rollup.html">rollup</a></li>
<li><a href="../modules/router.html">router</a></li>
<li><a href="../modules/scrollview.html">scrollview</a></li>
<li><a href="../modules/scrollview-base.html">scrollview-base</a></li>
<li><a href="../modules/scrollview-base-ie.html">scrollview-base-ie</a></li>
<li><a href="../modules/scrollview-list.html">scrollview-list</a></li>
<li><a href="../modules/scrollview-paginator.html">scrollview-paginator</a></li>
<li><a href="../modules/scrollview-scrollbars.html">scrollview-scrollbars</a></li>
<li><a href="../modules/selection.html">selection</a></li>
<li><a href="../modules/selector-css2.html">selector-css2</a></li>
<li><a href="../modules/selector-css3.html">selector-css3</a></li>
<li><a href="../modules/selector-native.html">selector-native</a></li>
<li><a href="../modules/shim-plugin.html">shim-plugin</a></li>
<li><a href="../modules/slider.html">slider</a></li>
<li><a href="../modules/slider-base.html">slider-base</a></li>
<li><a href="../modules/slider-value-range.html">slider-value-range</a></li>
<li><a href="../modules/sortable.html">sortable</a></li>
<li><a href="../modules/sortable-scroll.html">sortable-scroll</a></li>
<li><a href="../modules/stylesheet.html">stylesheet</a></li>
<li><a href="../modules/substitute.html">substitute</a></li>
<li><a href="../modules/swf.html">swf</a></li>
<li><a href="../modules/swfdetect.html">swfdetect</a></li>
<li><a href="../modules/tabview.html">tabview</a></li>
<li><a href="../modules/test.html">test</a></li>
<li><a href="../modules/test-console.html">test-console</a></li>
<li><a href="../modules/text.html">text</a></li>
<li><a href="../modules/text-accentfold.html">text-accentfold</a></li>
<li><a href="../modules/text-wordbreak.html">text-wordbreak</a></li>
<li><a href="../modules/transition.html">transition</a></li>
<li><a href="../modules/uploader.html">uploader</a></li>
<li><a href="../modules/uploader-deprecated.html">uploader-deprecated</a></li>
<li><a href="../modules/uploader-flash.html">uploader-flash</a></li>
<li><a href="../modules/uploader-html5.html">uploader-html5</a></li>
<li><a href="../modules/uploader-queue.html">uploader-queue</a></li>
<li><a href="../modules/view.html">view</a></li>
<li><a href="../modules/view-node-map.html">view-node-map</a></li>
<li><a href="../modules/widget.html">widget</a></li>
<li><a href="../modules/widget-anim.html">widget-anim</a></li>
<li><a href="../modules/widget-autohide.html">widget-autohide</a></li>
<li><a href="../modules/widget-base.html">widget-base</a></li>
<li><a href="../modules/widget-base-ie.html">widget-base-ie</a></li>
<li><a href="../modules/widget-buttons.html">widget-buttons</a></li>
<li><a href="../modules/widget-child.html">widget-child</a></li>
<li><a href="../modules/widget-htmlparser.html">widget-htmlparser</a></li>
<li><a href="../modules/widget-locale.html">widget-locale</a></li>
<li><a href="../modules/widget-modality.html">widget-modality</a></li>
<li><a href="../modules/widget-parent.html">widget-parent</a></li>
<li><a href="../modules/widget-position.html">widget-position</a></li>
<li><a href="../modules/widget-position-align.html">widget-position-align</a></li>
<li><a href="../modules/widget-position-constrain.html">widget-position-constrain</a></li>
<li><a href="../modules/widget-skin.html">widget-skin</a></li>
<li><a href="../modules/widget-stack.html">widget-stack</a></li>
<li><a href="../modules/widget-stdmod.html">widget-stdmod</a></li>
<li><a href="../modules/widget-uievents.html">widget-uievents</a></li>
<li><a href="../modules/yql.html">yql</a></li>
<li><a href="../modules/yui.html">yui</a></li>
<li><a href="../modules/yui-base.html">yui-base</a></li>
<li><a href="../modules/yui-later.html">yui-later</a></li>
<li><a href="../modules/yui-log.html">yui-log</a></li>
<li><a href="../modules/yui-throttle.html">yui-throttle</a></li>
<li><a href="../modules/yui3.html">yui3</a></li>
</ul>
</div>
</div>
</div>
</div>
</div>
<div class="yui3-u-3-4">
<div id="api-options">
Show:
<label for="api-show-inherited">
<input type="checkbox" id="api-show-inherited" checked>
Inherited
</label>
<label for="api-show-protected">
<input type="checkbox" id="api-show-protected">
Protected
</label>
<label for="api-show-private">
<input type="checkbox" id="api-show-private">
Private
</label>
</div>
<div class="apidocs">
<div id="docs-main">
<div class="content">
<h1>widget-locale Module</h1>
<div class="box clearfix meta">
<a class="button link-docs" href="/yui/docs/widget">User Guide & Examples</a>
<div class="foundat">
Defined in: <a href="../files/widget_js_WidgetLocale.js.html#l1"><code>widget/js/WidgetLocale.js:1</code></a>
</div>
</div>
<div class="box deprecated">
<p>
<strong>Deprecated:</strong> This module has been deprecated. It's replaced by the "intl" module which provides generic internationalization and BCP 47 language tag support with externalization.
</p>
</div>
<div class="box intro">
<p>Provides string support for widget with BCP 47 language tag lookup. This module has been deprecated. It's replaced by the "intl" module which provides generic internationalization and BCP 47 language tag support with externalization.</p>
</div>
<div class="yui3-g">
<div class="yui3-u-1-2">
</div>
<div class="yui3-u-1-2">
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<script src="../assets/vendor/prettify/prettify-min.js"></script>
<script>prettyPrint();</script>
<script src="../assets/js/yui-prettify.js"></script>
<script src="../assets/../api.js"></script>
<script src="../assets/js/api-filter.js"></script>
<script src="../assets/js/api-list.js"></script>
<script src="../assets/js/api-search.js"></script>
<script src="../assets/js/apidocs.js"></script>
</body>
</html>
| Java |
/*
* Xiphos Bible Study Tool
* sword.cc - glue
*
* Copyright (C) 2000-2020 Xiphos Developer Team
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Library General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include <gtk/gtk.h>
#include <glib.h>
#include <glib/gstdio.h>
#include <swmgr.h>
#include <swmodule.h>
#include <stringmgr.h>
#include <localemgr.h>
extern "C" {
#include "gui/bibletext.h"
#include "main/gtk_compat.h"
}
#include <ctype.h>
#include <time.h>
#include "gui/main_window.h"
#include "gui/font_dialog.h"
#include "gui/widgets.h"
#include "gui/commentary.h"
#include "gui/dialog.h"
#include "gui/parallel_dialog.h"
#include "gui/parallel_tab.h"
#include "gui/parallel_view.h"
#include "gui/tabbed_browser.h"
#include "gui/xiphos.h"
#include "gui/sidebar.h"
#include "gui/utilities.h"
#include "gui/cipher_key_dialog.h"
#include "gui/main_menu.h"
#include "main/biblesync_glue.h"
#include "main/display.hh"
#include "main/lists.h"
#include "main/navbar.h"
#include "main/navbar_book.h"
#include "main/search_sidebar.h"
#include "main/previewer.h"
#include "main/settings.h"
#include "main/sidebar.h"
#include "main/sword.h"
#include "main/url.hh"
#include "main/xml.h"
#include "main/parallel_view.h"
#include "main/modulecache.hh"
#include "backend/sword_main.hh"
#include "backend/gs_stringmgr.h"
#include "biblesync/biblesync.hh"
#include "gui/debug_glib_null.h"
#ifdef HAVE_DBUS
#include "gui/ipc.h"
#endif
extern BibleSync *biblesync;
using namespace sword;
char *sword_locale = NULL;
gboolean companion_activity = FALSE;
/* Unicode collation necessities. */
UCollator* collator;
UErrorCode collator_status;
extern gboolean valid_scripture_key;
// these track together. when one changes, so does the other.
static std::map<string, string> abbrev_name2abbrev, abbrev_abbrev2name;
typedef std::map<string, string>::iterator abbrev_iter;
/******************************************************************************
* Name
* main_add_abbreviation
*
* Synopsis
* #include "main/sword.h"
*
* void main_add_abbreviation(char *name, char *abbreviation)
*
* Description
* adds an element to each of the abbreviation maps.
*
* Return value
* void
*/
void main_add_abbreviation(const char *name, const char *abbreviation)
{
// let's not be stupid about abbreviations chosen, ok?
if (!strchr(abbreviation, '(')) {
abbrev_name2abbrev[name] = abbreviation;
abbrev_abbrev2name[abbreviation] = name;
}
}
/******************************************************************************
* Name
* main_get_abbreviation
*
* Synopsis
* #include "main/sword.h"
*
* const char * main_get_abbreviation(const char *name)
*
* Description
* gets abbreviation from real module, if available.
*
* Return value
* const char *
*/
const char *main_get_abbreviation(const char *name)
{
if (name == NULL)
return NULL;
abbrev_iter it = abbrev_name2abbrev.find(name);
if (it != abbrev_name2abbrev.end()) {
return it->second.c_str();
}
return NULL;
}
/******************************************************************************
* Name
* main_get_name
*
* Synopsis
* #include "main/sword.h"
*
* const char * main_get_name(const char *abbreviation)
*
* Description
* gets real module name from abbreviation, if available.
*
* Return value
* const char *
*/
const char *main_get_name(const char *abbreviation)
{
if (abbreviation == NULL)
return NULL;
abbrev_iter it = abbrev_abbrev2name.find(abbreviation);
if (it != abbrev_abbrev2name.end()) {
return it->second.c_str();
}
return NULL;
}
/******************************************************************************
* Name
* main_book_heading
*
* Synopsis
* #include "main/sword.h"
*
* void main_book_heading(char * mod_name)
*
* Description
*
*
* Return value
* void
*/
void main_book_heading(char *mod_name)
{
VerseKey *vkey;
SWMgr *mgr = backend->get_mgr();
backend->display_mod = mgr->Modules[mod_name];
vkey = (VerseKey *)(SWKey *)(*backend->display_mod);
vkey->setIntros(1);
vkey->setAutoNormalize(0);
vkey->setChapter(0);
vkey->setVerse(0);
backend->display_mod->display();
}
/******************************************************************************
* Name
* main_chapter_heading
*
* Synopsis
* #include "main/module_dialogs.h"
*
* void main_chapter_heading(char * mod_name)
*
* Description
*
*
* Return value
* void
*/
void main_chapter_heading(char *mod_name)
{
VerseKey *vkey;
SWMgr *mgr = backend->get_mgr();
backend->display_mod = mgr->Modules[mod_name];
backend->display_mod->setKey(settings.currentverse);
vkey = (VerseKey *)(SWKey *)(*backend->display_mod);
vkey->setIntros(1);
vkey->setAutoNormalize(0);
vkey->setVerse(0);
backend->display_mod->display();
}
/******************************************************************************
* Name
* main_save_note
*
* Synopsis
* #include "main/sword.h"
*
* void main_save_note(const gchar * module_name,
* const gchar * key_str ,
* const gchar * note_str )
*
* Description
*
*
* Return value
* void
*/
void main_save_note(const gchar *module_name,
const gchar *key_str,
const gchar *note_str)
{
// Massage encoded spaces ("%20") back to real spaces.
// This is a sick. unreliable hack that should be removed
// after the underlying problem is fixed in Sword.
gchar *rework;
for (rework = (char *)strstr(note_str, "%20");
rework;
rework = strstr(rework + 1, "%20")) {
*rework = ' ';
(void)strcpy(rework + 1, rework + 3);
}
XI_message(("note module %s\nnote key %s\nnote text%s",
module_name,
key_str,
note_str));
backend->save_note_entry(module_name, key_str, note_str);
main_display_commentary(module_name, settings.currentverse);
}
/******************************************************************************
* Name
* main_delete_note
*
* Synopsis
* #include "main/sword.h"
*
* void main_delete_note(DIALOG_DATA * d)
*
* Description
*
*
* Return value
* void
*/
void main_delete_note(const gchar *module_name,
const gchar *key_str)
{
backend->set_module_key(module_name, key_str);
XI_message(("note module %s\nnote key %s\n",
module_name,
key_str));
backend->delete_entry();
if ((!strcmp(settings.CommWindowModule, module_name)) &&
(!strcmp(settings.currentverse, key_str)))
main_display_commentary(module_name, key_str);
}
/******************************************************************************
* Name
* set_module_unlocked
*
* Synopsis
* #include "bibletext.h"
*
* void set_module_unlocked(char *mod_name, char *key)
*
* Description
* unlocks locked module -
*
* Return value
* void
*/
void main_set_module_unlocked(const char *mod_name, char *key)
{
SWMgr *mgr = backend->get_mgr();
mgr->setCipherKey(mod_name, key);
}
/******************************************************************************
* Name
* main_save_module_key
*
* Synopsis
* #include "main/configs.h"
*
* void main_save_module_key(gchar * mod_name, gchar * key)
*
* Description
* to unlock locked modules
*
* Return value
* void
*/
void main_save_module_key(const char *mod_name, char *key)
{
backend->save_module_key((char *)mod_name, key);
}
/******************************************************************************
* Name
* main_getText
*
* Synopsis
* #include "main/sword.h"
* void main_getText(gchar * key)
*
* Description
* get unabbreviated key
*
* Return value
* char *
*/
char *main_getText(char *key)
{
VerseKey vkey(key);
return strdup((char *)vkey.getText());
}
/******************************************************************************
* Name
* main_getShortText
*
* Synopsis
* #include "main/sword.h"
* void main_getShortText(gchar * key)
*
* Description
* get short-name key
*
* Return value
* char *
*/
char *main_getShortText(char *key)
{
VerseKey vkey(key);
return strdup((char *)vkey.getShortText());
}
/******************************************************************************
* Name
* main_update_nav_controls
*
* Synopsis
* #include "toolbar_nav.h"
*
* gchar *main_update_nav_controls(const gchar * key)
*
* Description
* updates the nav toolbar controls
*
* Return value
* gchar *
*/
gchar *main_update_nav_controls(const char *module_name, const gchar *key)
{
char *val_key = backend->get_valid_key(module_name, key);
// we got a valid key. but was it really a valid key within v11n?
// for future use in determining whether to show normal navbar content.
navbar_versekey.valid_key = main_is_Bible_key(module_name, key);
/*
* remember verse
*/
xml_set_value("Xiphos", "keys", "verse", val_key);
settings.currentverse = xml_get_value("keys", "verse");
settings.apply_change = FALSE;
navbar_versekey.module_name = g_string_assign(navbar_versekey.module_name, settings.MainWindowModule);
navbar_versekey.key = g_string_assign(navbar_versekey.key, val_key);
main_navbar_versekey_set(navbar_versekey, val_key);
settings.apply_change = TRUE;
#ifdef HAVE_DBUS
IpcObject *ipc = ipc_get_main_ipc();
if (ipc)
ipc_object_navigation_signal(ipc, (const gchar *)val_key, NULL);
#endif
return val_key;
}
/******************************************************************************
* Name
* get_module_key
*
* Synopsis
* #include "main/module.h"
*
* char *get_module_key(void)
*
* Description
* returns module key
*
* Return value
* char *
*/
char *main_get_active_pane_key(void)
{
if (settings.havebible) {
switch (settings.whichwindow) {
case MAIN_TEXT_WINDOW:
case COMMENTARY_WINDOW:
return (char *)settings.currentverse;
break;
case DICTIONARY_WINDOW:
return (char *)settings.dictkey;
break;
case parallel_WINDOW:
return (char *)settings.cvparallel;
break;
case BOOK_WINDOW:
return (char *)settings.book_key;
break;
}
}
return NULL;
}
/******************************************************************************
* Name
* get_module_name
*
* Synopsis
* #include "main/module.h"
*
* char *get_module_name(void)
*
* Description
* returns module name
*
* Return value
* char *
*/
char *main_get_active_pane_module(void)
{
if (settings.havebible) {
switch (settings.whichwindow) {
case MAIN_TEXT_WINDOW:
return (char *)xml_get_value("modules",
"bible");
break;
case COMMENTARY_WINDOW:
return (char *)xml_get_value("modules",
"comm");
break;
case DICTIONARY_WINDOW:
return (char *)settings.DictWindowModule;
break;
case BOOK_WINDOW:
return (char *)settings.book_mod;
break;
}
}
return NULL;
}
/******************************************************************************
* Name
* module_name_from_description
*
* Synopsis
* #include ".h"
*
* void module_name_from_description(gchar *mod_name, gchar *description)
*
* Description
*
*
* Return value
* void
*/
char *main_module_name_from_description(char *description)
{
return backend->module_name_from_description(description);
}
/******************************************************************************
* Name
* main_get_sword_version
*
* Synopsis
* #include "sword.h"
*
* const char *main_get_sword_version(void)
*
* Description
*
*
* Return value
* const char *
*/
const char *main_get_sword_version(void)
{
return backend->get_sword_version();
}
/******************************************************************************
* Name
* get_search_results_text
*
* Synopsis
* #include "sword.h"
*
* char *get_search_results_text(char * mod_name, char * key)
*
* Description
*
*
* Return value
* char *
*/
char *main_get_search_results_text(char *mod_name, char *key)
{
return backend->get_render_text((char *)mod_name, (char *)key);
}
/******************************************************************************
* Name
* main_get_path_to_mods
*
* Synopsis
* #include "sword.h"
*
* gchar *main_get_path_to_mods(void)
*
* Description
* returns the path to the sword modules
*
* Return value
* gchar *
*/
char *main_get_path_to_mods(void)
{
SWMgr *mgr = backend->get_mgr();
char *path = mgr->prefixPath;
return (path ? g_strdup(path) : NULL);
}
/******************************************************************************
* Name
* main_init_language_map
*
* Synopsis
* #include "sword.h"
*
* void main_init_language_map(void)
*
* Description
* initializes the hard-coded abbrev->name mapping.
*
* Return value
* void
*/
typedef std::map<SWBuf, SWBuf> ModLanguageMap;
ModLanguageMap languageMap;
void main_init_language_map()
{
gchar *language_file;
FILE *language;
gchar *s, *end, *abbrev, *name, *newline;
gchar *mapspace;
size_t length;
if ((language_file = gui_general_user_file("languages", FALSE)) == NULL) {
gui_generic_warning(_("Xiphos's file for language\nabbreviations is missing."));
return;
}
XI_message(("%s", language_file));
if ((language = g_fopen(language_file, "r")) == NULL) {
gui_generic_warning(_("Xiphos's language abbreviation\nfile cannot be opened."));
g_free(language_file);
return;
}
g_free(language_file);
(void)fseek(language, 0L, SEEK_END);
length = ftell(language);
rewind(language);
if ((length == 0) ||
(mapspace = (gchar *)g_malloc(length + 2)) == NULL) {
fclose(language);
gui_generic_warning(_("Xiphos cannot allocate space\nfor language abbreviations."));
return;
}
if (fread(mapspace, 1, length, language) != length) {
fclose(language);
g_free(mapspace);
gui_generic_warning(_("Xiphos cannot read the\nlanguage abbreviation file."));
return;
}
fclose(language);
end = length + mapspace;
*end = '\0';
for (s = mapspace; s < end; ++s) {
if ((newline = strchr(s, '\n')) == NULL) {
XI_message(("incomplete last line in languages"));
break;
}
*newline = '\0';
if ((*s == '#') || (s == newline)) {
s = newline; // comment or empty line.
continue;
}
abbrev = s;
if ((name = strchr(s, '\t')) == NULL) {
XI_message(("tab-less line in languages"));
break;
}
*(name++) = '\0'; // NUL-terminate abbrev, mark name.
languageMap[SWBuf(abbrev)] = SWBuf(name);
s = newline;
}
g_free(mapspace);
}
const char *main_get_language_map(const char *language)
{
if (language == NULL)
return "Unknown";
return languageMap[language].c_str();
}
char **main_get_module_language_list(void)
{
return backend->get_module_language_list();
}
/******************************************************************************
* Name
* set_sword_locale
*
* Synopsis
* #include "main/sword.h"
*
* char *set_sword_locale(const char *sys_locale)
*
* Description
* set sword's idea of the locale in which the user operates
*
* Return value
* char *
*/
char *set_sword_locale(const char *sys_locale)
{
if (sys_locale) {
SWBuf locale;
StringList localelist = LocaleMgr::getSystemLocaleMgr()->getAvailableLocales();
StringList::iterator it;
int ncmp[3] = {100, 5, 2}; // fixed data
// length-limited match
for (int i = 0; i < 3; ++i) {
for (it = localelist.begin(); it != localelist.end(); ++it) {
locale = *it;
if (!strncmp(sys_locale, locale.c_str(), ncmp[i])) {
LocaleMgr::getSystemLocaleMgr()->setDefaultLocaleName(locale.c_str());
return g_strdup(locale.c_str());
}
}
}
}
// either we were given a null sys_locale, or it didn't match anything.
char *err = g_strdup_printf(_("No matching locale found for `%s'.\n%s"),
sys_locale,
_("Book names and menus may not be translated."));
gui_generic_warning(err);
g_free(err);
return NULL;
}
/******************************************************************************
* Name
* backend_init
*
* Synopsis
* #include "main/sword.h"
*
* void main_init_backend(void)
*
* Description
* start sword
*
* Return value
* void
*/
void main_init_backend(void)
{
StringMgr::setSystemStringMgr(new GS_StringMgr());
const char *lang = getenv("LANG");
if (!lang)
lang = "C";
sword_locale = set_sword_locale(lang);
collator = ucol_open(sword_locale, &collator_status);
lang = LocaleMgr::getSystemLocaleMgr()->getDefaultLocaleName();
backend = new BackEnd();
backend->init_SWORD(0);
settings.path_to_mods = main_get_path_to_mods();
//#ifndef DEBUG
g_chdir(settings.path_to_mods);
//#else
// XI_warning(("no chdir(SWORD_PATH) => modmgr 'archive' may not work"));
//#endif
XI_print(("%s sword-%s\n", "Starting", backend->get_sword_version()));
XI_print(("%s\n", "Initiating SWORD"));
XI_print(("%s: %s\n", "path to sword", settings.path_to_mods));
XI_print(("%s %s\n", "SWORD locale is", lang));
XI_print(("%s\n", "Checking for SWORD Modules"));
settings.spell_language = strdup(lang);
main_init_lists();
//
// BibleSync backend startup. identify the user by name.
//
biblesync = new BibleSync("Xiphos", VERSION,
#ifdef WIN32
// in win32 glib, get_real_name and get_user_name are the same.
(string)g_get_real_name()
#else
(string)g_get_real_name() + " (" + g_get_user_name() + ")"
#endif
);
}
/******************************************************************************
* Name
* shutdown_sword
*
* Synopsis
* #include "sword.h"
*
* void shutdown_sword(void)
*
* Description
* close down sword by deleting backend;
*
* Return value
* void
*/
void main_shutdown_backend(void)
{
if (sword_locale)
free((char *)sword_locale);
sword_locale = NULL;
if (backend)
delete backend;
backend = NULL;
XI_print(("%s\n", "SWORD is shutdown"));
}
/******************************************************************************
* Name
* main_dictionary_entry_changed
*
* Synopsis
* #include "main/sword.h"
*
* void main_dictionary_entry_changed(char * mod_name)
*
* Description
* text in the dictionary entry has changed and the entry activated
*
* Return value
* void
*/
void main_dictionary_entry_changed(char *mod_name)
{
gchar *key = NULL;
if (!mod_name)
return;
if (strcmp(settings.DictWindowModule, mod_name)) {
xml_set_value("Xiphos", "modules", "dict", mod_name);
settings.DictWindowModule = xml_get_value("modules", "dict");
}
key = g_strdup((gchar *)gtk_entry_get_text(GTK_ENTRY(widgets.entry_dict)));
backend->set_module_key(mod_name, key);
g_free(key);
key = backend->get_module_key();
xml_set_value("Xiphos", "keys", "dictionary", key);
settings.dictkey = xml_get_value("keys", "dictionary");
main_check_unlock(mod_name, TRUE);
backend->set_module_key(mod_name, key);
backend->display_mod->display();
gtk_entry_set_text(GTK_ENTRY(widgets.entry_dict), key);
g_free(key);
}
static void dict_key_list_select(GtkMenuItem *menuitem, gpointer user_data)
{
gtk_entry_set_text(GTK_ENTRY(widgets.entry_dict), (gchar *)user_data);
gtk_widget_activate(widgets.entry_dict);
}
/******************************************************************************
* Name
*
*
* Synopsis
* #include "main/sword.h"
*
*
*
* Description
* text in the dictionary entry has changed and the entry activated
*
* Return value
* void
*/
GtkWidget *main_dictionary_drop_down_new(char *mod_name, char *old_key)
{
gint count = 9, i;
gchar *new_key;
gchar *key = NULL;
GtkWidget *menu;
menu = gtk_menu_new();
if (!settings.havedict || !mod_name)
return NULL;
if (strcmp(settings.DictWindowModule, mod_name)) {
xml_set_value("Xiphos", "modules", "dict",
mod_name);
settings.DictWindowModule = xml_get_value(
"modules", "dict");
}
key = g_strdup((gchar *)gtk_entry_get_text(GTK_ENTRY(widgets.entry_dict)));
XI_message(("\nold_key: %s\nkey: %s", old_key, key));
backend->set_module_key(mod_name, key);
g_free(key);
key = backend->get_module_key();
xml_set_value("Xiphos", "keys", "dictionary", key);
settings.dictkey = xml_get_value("keys", "dictionary");
main_check_unlock(mod_name, TRUE);
backend->set_module_key(mod_name, key);
backend->display_mod->display();
new_key = g_strdup((char *)backend->display_mod->getKeyText());
for (i = 0; i < (count / 2) + 1; i++) {
(*backend->display_mod)--;
}
for (i = 0; i < count; i++) {
free(new_key);
(*backend->display_mod)++;
new_key = g_strdup((char *)backend->display_mod->getKeyText());
/* add menu item */
GtkWidget *item =
gtk_menu_item_new_with_label((gchar *)new_key);
gtk_widget_show(item);
g_signal_connect(G_OBJECT(item), "activate",
G_CALLBACK(dict_key_list_select),
g_strdup(new_key));
gtk_container_add(GTK_CONTAINER(menu), item);
}
free(new_key);
g_free(key);
return menu;
}
/******************************************************************************
* Name
* main_dictionary_button_clicked
*
* Synopsis
* #include "main/sword.h"
*
* void main_dictionary_button_clicked(gint direction)
*
* Description
* The back or foward dictinary key button was clicked.
* the module key is set to the current dictkey.
* then the module is incremented or decremented.
* the new key is returned from the module and the dictionary entry is set
* to the new key. The entry is then activated.
*
* Return value
* void
*/
void main_dictionary_button_clicked(gint direction)
{
gchar *key = NULL;
if (!settings.havedict || !settings.DictWindowModule)
return;
backend->set_module_key(settings.DictWindowModule,
settings.dictkey);
if (direction == 0)
(*backend->display_mod)--;
else
(*backend->display_mod)++;
key = g_strdup((char *)backend->display_mod->getKeyText());
gtk_entry_set_text(GTK_ENTRY(widgets.entry_dict), key);
gtk_widget_activate(widgets.entry_dict);
g_free(key);
}
void main_display_book(const char *mod_name,
const char *key)
{
if (!settings.havebook || !mod_name)
return;
if (key == NULL)
key = "0";
XI_message(("main_display_book\nmod_name: %s\nkey: %s", mod_name, key));
if (!backend->is_module(mod_name))
return;
if (!settings.book_mod)
settings.book_mod = g_strdup((char *)mod_name);
if (strcmp(settings.book_mod, mod_name)) {
xml_set_value("Xiphos", "modules", "book", mod_name);
gui_reassign_strdup(&settings.book_mod, (gchar *)mod_name);
}
if (!isdigit(key[0])) {
xml_set_value("Xiphos", "keys", "book", key);
settings.book_key = xml_get_value("keys", "book");
backend->set_module(mod_name);
backend->set_treekey(0);
settings.book_offset = backend->treekey_set_key((char *)key);
} else {
settings.book_offset = atol(key);
if (settings.book_offset < 4)
settings.book_offset = 4;
xml_set_value("Xiphos", "keys", "book", key);
settings.book_key = xml_get_value("keys", "book");
xml_set_value("Xiphos", "keys", "offset", key);
backend->set_module(mod_name);
backend->set_treekey(settings.book_offset);
}
main_check_unlock(mod_name, TRUE);
backend->display_mod->display();
main_setup_navbar_book(settings.book_mod, settings.book_offset);
//if (settings.browsing)
gui_update_tab_struct(NULL,
NULL,
NULL,
mod_name,
NULL,
key,
FALSE,
settings.showtexts,
settings.showpreview,
settings.showcomms,
settings.showdicts);
}
void main_display_commentary(const char *mod_name,
const char *key)
{
if (!settings.havecomm || !settings.comm_showing)
return;
if (!mod_name)
mod_name = ((settings.browsing && (cur_passage_tab != NULL))
? g_strdup(cur_passage_tab->commentary_mod)
: xml_get_value("modules", "comm"));
if (!mod_name || !backend->is_module(mod_name))
return;
int modtype = backend->module_type(mod_name);
if ((modtype != COMMENTARY_TYPE) && (modtype != PERCOM_TYPE))
return; // what are we doing here?
if (!settings.CommWindowModule)
settings.CommWindowModule = g_strdup((gchar *)mod_name);
settings.comm_showing = TRUE;
settings.whichwindow = COMMENTARY_WINDOW;
if (strcmp(settings.CommWindowModule, mod_name)) {
xml_set_value("Xiphos", "modules", "comm", mod_name);
gui_reassign_strdup(&settings.CommWindowModule, (gchar *)mod_name);
// handle a conf directive "Companion=This,That,TheOther"
char *companion = main_get_mod_config_entry(mod_name, "Companion");
gchar **name_set = (companion ? g_strsplit(companion, ",", -1) : NULL);
if (companion &&
(!companion_activity) &&
name_set[0] &&
*name_set[0] &&
backend->is_module(name_set[0]) &&
((settings.MainWindowModule == NULL) ||
strcmp(name_set[0], settings.MainWindowModule))) {
companion_activity = TRUE;
gint name_length = g_strv_length(name_set);
char *companion_question =
g_strdup_printf(_("Module %s has companion modules:\n%s.\n"
"Would you like to open these as well?%s"),
mod_name, companion,
((name_length > 1)
? _("\n\nThe first will open in the main window\n"
"and others in separate windows.")
: ""));
if (gui_yes_no_dialog(companion_question, NULL)) {
main_display_bible(name_set[0], key);
for (int i = 1; i < name_length; i++) {
main_dialogs_open(name_set[i], key, FALSE);
}
}
g_free(companion_question);
companion_activity = FALSE;
}
if (name_set)
g_strfreev(name_set);
if (companion)
g_free(companion);
}
main_check_unlock(mod_name, TRUE);
valid_scripture_key = main_is_Bible_key(mod_name, key);
backend->set_module_key(mod_name, key);
backend->display_mod->display();
valid_scripture_key = TRUE; // leave nice for future use.
//if (settings.browsing)
gui_update_tab_struct(NULL,
mod_name,
NULL,
NULL,
NULL,
NULL,
TRUE,
settings.showtexts,
settings.showpreview,
settings.showcomms,
settings.showdicts);
}
void main_display_dictionary(const char *mod_name,
const char *key)
{
const gchar *old_key, *feature;
// for devotional use.
gchar buf[10];
if (!settings.havedict || !mod_name)
return;
XI_message(("main_display_dictionary\nmod_name: %s\nkey: %s", mod_name, key));
if (!backend->is_module(mod_name))
return;
if (!settings.DictWindowModule)
settings.DictWindowModule = g_strdup((gchar *)mod_name);
if (key == NULL)
key = (char *)"Grace";
feature = (char *)backend->get_mgr()->getModule(mod_name)->getConfigEntry("Feature");
// turn on "all strong's" iff we have that kind of dictionary.
if (feature && (!strcmp(feature, "HebrewDef") || !strcmp(feature, "GreekDef")))
gtk_widget_show(widgets.all_strongs);
else
gtk_widget_hide(widgets.all_strongs);
if (strcmp(settings.DictWindowModule, mod_name)) {
// new dict -- is it actually a devotional?
time_t curtime;
if (feature && !strcmp(feature, "DailyDevotion")) {
if ((strlen(key) != 5) || // blunt tests.
(key[0] < '0') || (key[0] > '9') ||
(key[1] < '0') || (key[1] > '9') ||
(key[2] != '.') ||
(key[3] < '0') || (key[3] > '9') ||
(key[4] < '0') || (key[4] > '9')) { // not MM.DD
struct tm *loctime;
curtime = time(NULL);
loctime = localtime(&curtime);
strftime(buf, 10, "%m.%d", loctime);
key = buf;
}
}
xml_set_value("Xiphos", "modules", "dict", mod_name);
gui_reassign_strdup(&settings.DictWindowModule, (gchar *)mod_name);
}
// old_key is uppercase
key = g_utf8_strup(key, -1);
old_key = gtk_entry_get_text(GTK_ENTRY(widgets.entry_dict));
if (!strcmp(old_key, key))
main_dictionary_entry_changed(settings.DictWindowModule);
else {
gtk_entry_set_text(GTK_ENTRY(widgets.entry_dict), key);
gtk_widget_activate(widgets.entry_dict);
}
//if (settings.browsing)
gui_update_tab_struct(NULL,
NULL,
mod_name,
NULL,
key,
NULL,
settings.comm_showing,
settings.showtexts,
settings.showpreview,
settings.showcomms,
settings.showdicts);
}
void main_display_bible(const char *mod_name,
const char *key)
{
gchar *bs_key = g_strdup(key); // avoid tab data corruption problem.
/* keeps us out of a crash causing loop */
extern guint scroll_adj_signal;
extern GtkAdjustment *adjustment;
if (adjustment)
g_signal_handler_block(adjustment, scroll_adj_signal);
if (!gtk_widget_get_realized(GTK_WIDGET(widgets.html_text)))
return;
if (!mod_name)
mod_name = ((settings.browsing && (cur_passage_tab != NULL))
? g_strdup(cur_passage_tab->text_mod)
: xml_get_value("modules", "bible"));
if (!settings.havebible || !mod_name)
return;
if (!backend->is_module(mod_name))
return;
int modtype = backend->module_type(mod_name);
if (modtype != TEXT_TYPE)
return; // what are we doing here?
if (!settings.MainWindowModule)
settings.MainWindowModule = g_strdup((gchar *)mod_name);
if (strcmp(settings.currentverse, key)) {
xml_set_value("Xiphos", "keys", "verse",
key);
settings.currentverse = xml_get_value(
"keys", "verse");
}
if (strcmp(settings.MainWindowModule, mod_name)) {
xml_set_value("Xiphos", "modules", "bible", mod_name);
gui_reassign_strdup(&settings.MainWindowModule, (gchar *)mod_name);
// handle a conf directive "Companion=This,That,TheOther"
char *companion = main_get_mod_config_entry(mod_name, "Companion");
gchar **name_set = (companion ? g_strsplit(companion, ",", -1) : NULL);
if (companion &&
(!companion_activity) &&
name_set[0] &&
*name_set[0] &&
backend->is_module(name_set[0]) &&
((settings.CommWindowModule == NULL) ||
strcmp(name_set[0], settings.CommWindowModule))) {
companion_activity = TRUE;
gint name_length = g_strv_length(name_set);
char *companion_question =
g_strdup_printf(_("Module %s has companion modules:\n%s.\n"
"Would you like to open these as well?%s"),
mod_name, companion,
((name_length > 1)
? _("\n\nThe first will open in the main window\n"
"and others in separate windows.")
: ""));
if (gui_yes_no_dialog(companion_question, NULL)) {
main_display_commentary(name_set[0], key);
for (int i = 1; i < name_length; i++) {
main_dialogs_open(name_set[i], key, FALSE);
}
}
g_free(companion_question);
companion_activity = FALSE;
}
if (name_set)
g_strfreev(name_set);
if (companion)
g_free(companion);
navbar_versekey.module_name = g_string_assign(navbar_versekey.module_name,
settings.MainWindowModule);
navbar_versekey.key = g_string_assign(navbar_versekey.key,
settings.currentverse);
main_search_sidebar_fill_bounds_combos();
}
settings.whichwindow = MAIN_TEXT_WINDOW;
main_check_unlock(mod_name, TRUE);
valid_scripture_key = main_is_Bible_key(mod_name, key);
if (backend->module_has_testament(mod_name,
backend->get_key_testament(mod_name, key))) {
backend->set_module_key(mod_name, key);
backend->display_mod->display();
} else {
gchar *val_key = NULL;
if (backend->get_key_testament(mod_name, key) == 1)
val_key = main_update_nav_controls(mod_name, "Matthew 1:1");
else
val_key = main_update_nav_controls(mod_name, "Genesis 1:1");
backend->set_module_key(mod_name, val_key);
backend->display_mod->display();
g_free(val_key);
}
valid_scripture_key = TRUE; // leave nice for future use.
XI_message(("mod_name = %s", mod_name));
//if (settings.browsing) {
gui_update_tab_struct(mod_name,
NULL,
NULL,
NULL,
NULL,
NULL,
settings.comm_showing,
settings.showtexts,
settings.showpreview,
settings.showcomms,
settings.showdicts);
gui_set_tab_label(settings.currentverse, FALSE);
//}
gui_change_window_title(settings.MainWindowModule);
// (called _after_ tab data updated so not overwritten with old tab)
/*
* change parallel verses
*/
if (settings.dockedInt)
main_update_parallel_page();
else {
if (settings.showparatab)
gui_keep_parallel_tab_in_sync();
else
gui_keep_parallel_dialog_in_sync();
}
// multicast now, iff user has not asked for keyboard-only xmit.
if (!settings.bs_keyboard)
biblesync_prep_and_xmit(mod_name, bs_key);
g_free(bs_key);
if (adjustment)
g_signal_handler_unblock(adjustment, scroll_adj_signal);
}
/******************************************************************************
* Name
* main_display_devotional
*
* Synopsis
* #include "main/sword.h"
*
* void main_display_devotional(void)
*
* Description
*
*
* Return value
* void
*/
void main_display_devotional(void)
{
gchar buf[10];
gchar *prettybuf;
time_t curtime;
struct tm *loctime;
gchar *text;
/*
* This makes sense only if you've installed & defined one.
*/
if (settings.devotionalmod == NULL) {
GList *glist = get_list(DEVOTION_LIST);
if (g_list_length(glist) != 0) {
xml_set_value("Xiphos", "modules", "devotional",
(char *)glist->data);
gui_reassign_strdup(&settings.devotionalmod, (gchar *)glist->data);
} else {
gui_generic_warning(_("Daily devotional was requested, but there are none installed."));
}
}
/*
* Get the current time, converted to local time.
*/
curtime = time(NULL);
loctime = localtime(&curtime);
strftime(buf, 10, "%m.%d", loctime);
prettybuf = g_strdup_printf("<b>%s %d</b>",
gettext(month_names[loctime->tm_mon]),
loctime->tm_mday);
text = backend->get_render_text(settings.devotionalmod, buf);
if (text) {
main_entry_display(settings.show_previewer_in_sidebar
? sidebar.html_viewer_widget
: widgets.html_previewer_text,
settings.devotionalmod, text, prettybuf, TRUE);
g_free(text);
}
g_free(prettybuf);
}
void main_setup_displays(void)
{
backend->textDisplay = new GTKChapDisp(widgets.html_text, backend);
backend->commDisplay = new GTKEntryDisp(widgets.html_comm, backend);
backend->bookDisplay = new GTKEntryDisp(widgets.html_book, backend);
backend->dictDisplay = new GTKEntryDisp(widgets.html_dict, backend);
}
const char *main_get_module_language(const char *module_name)
{
return backend->module_get_language(module_name);
}
/******************************************************************************
* Name
* main_check_for_option
*
* Synopsis
* #include ".h"
*
* gint main_check_for_option(const gchar * mod_name, const gchar * key, const gchar * option)
*
* Description
* get any option for a module
*
* Return value
* gint
*/
gint main_check_for_option(const gchar *mod_name, const gchar *key, const gchar *option)
{
return backend->has_option(mod_name, key, option);
}
/******************************************************************************
* Name
* main_check_for_global_option
*
* Synopsis
* #include ".h"
*
* gint main_check_for_global_option(const gchar * mod_name, const gchar * option)
*
* Description
* get global options for a module
*
* Return value
* gint
*/
gint main_check_for_global_option(const gchar *mod_name, const gchar *option)
{
return backend->has_global_option(mod_name, option);
}
/******************************************************************************
* Name
* main_is_module
*
* Synopsis
* #include "main/module.h"
*
* int main_is_module(char * mod_name)
*
* Description
* check for presents of a module by name
*
* Return value
* int
*/
int main_is_module(char *mod_name)
{
return backend->is_module(mod_name);
}
/******************************************************************************
* Name
* main_has_search_framework
*
* Synopsis
* #include "main/module.h"
*
* int main_has_search_framework(char * mod_name)
*
* Description
* tells us whether CLucene is available
*
* Return value
* int (boolean)
*/
int main_has_search_framework(char *mod_name)
{
SWMgr *mgr = backend->get_mgr();
SWModule *mod = mgr->getModule(mod_name);
return (mod && mod->hasSearchFramework());
}
/******************************************************************************
* Name
* main_optimal_search
*
* Synopsis
* #include "main/module.h"
*
* int main_optimal_search(char * mod_name)
*
* Description
* tells us whether a CLucene index exists
*
* Return value
* int (boolean)
*/
int main_optimal_search(char *mod_name)
{
SWMgr *mgr = backend->get_mgr();
SWModule *mod = mgr->Modules.find(mod_name)->second;
return mod->isSearchOptimallySupported("God", -4, 0, 0);
}
char *main_get_mod_config_entry(const char *module_name,
const char *entry)
{
return backend->get_config_entry((char *)module_name, (char *)entry);
}
char *main_get_mod_config_file(const char *module_name,
const char *moddir)
{
#ifdef SWORD_SHOULD_HAVE_A_WAY_TO_GET_A_CONF_FILENAME_FROM_A_MODNAME
return backend->get_config_file((char *)module_name, (char *)moddir);
#else
GDir *dir;
SWBuf name;
name = moddir;
name += "/mods.d";
if ((dir = g_dir_open(name, 0, NULL))) {
const gchar *ent;
g_dir_rewind(dir);
while ((ent = g_dir_read_name(dir))) {
name = moddir;
name += "/mods.d/";
name += ent;
SWConfig *config = new SWConfig(name.c_str());
if (config->getSections().find(module_name) !=
config->getSections().end()) {
gchar *ret_name = g_strdup(ent);
g_dir_close(dir);
delete config;
return ret_name;
} else
delete config;
}
g_dir_close(dir);
}
return NULL;
#endif
}
int main_is_mod_rtol(const char *module_name)
{
char *direction = backend->get_config_entry((char *)module_name, (char *)"Direction");
return (direction && !strcmp(direction, "RtoL"));
}
/******************************************************************************
* Name
* main_has_cipher_tag
*
* Synopsis
* #include "main/.h"
*
* int main_has_cipher_tag(char *mod_name)
*
* Description
*
*
* Return value
* int
*/
int main_has_cipher_tag(char *mod_name)
{
gchar *cipherkey = backend->get_config_entry(mod_name, (char *)"CipherKey");
int retval = (cipherkey != NULL);
g_free(cipherkey);
return retval;
}
#define CIPHER_INTRO \
_("<b>Locked Module.</b>\n\n<u>You are opening a module which requires a <i>key</i>.</u>\n\nThe module is locked, meaning that the content is encrypted by its publisher, and you must enter its key in order for the content to become useful. This key should have been received by you on the web page which confirmed your purchase, or perhaps sent via email after purchase.\n\nPlease enter the key in the dialog.")
/******************************************************************************
* Name
* main_check_unlock
*
* Synopsis
* #include "main/.h"
*
* int main_check_unlock(const char *mod_name)
*
* Description
*
*
* Return value
* int
*/
void main_check_unlock(const char *mod_name, gboolean conditional)
{
gchar *cipher_old = main_get_mod_config_entry(mod_name, "CipherKey");
/* if forced by the unlock menu item, or it's present but empty... */
if (!conditional ||
((cipher_old != NULL) && (*cipher_old == '\0'))) {
if (conditional) {
GtkWidget *dialog;
dialog = gtk_message_dialog_new_with_markup(NULL, /* no need for a parent window */
GTK_DIALOG_DESTROY_WITH_PARENT,
GTK_MESSAGE_INFO,
GTK_BUTTONS_OK,
CIPHER_INTRO);
g_signal_connect_swapped(dialog, "response",
G_CALLBACK(gtk_widget_destroy),
dialog);
gtk_widget_show(dialog);
}
gchar *cipher_key = gui_add_cipher_key(mod_name, cipher_old);
if (cipher_key) {
ModuleCacheErase(mod_name);
redisplay_to_realign();
g_free(cipher_key);
}
}
g_free(cipher_old);
}
/******************************************************************************
* Name
* main_get_striptext
*
* Synopsis
* #include "main/sword.h"
*
* char *main_get_striptext(char *module_name, char *key)
*
* Description
*
*
* Return value
* char *
*/
char *main_get_striptext(char *module_name, char *key)
{
return backend->get_strip_text(module_name, key);
}
/******************************************************************************
* Name
* main_get_rendered_text
*
* Synopsis
* #include "main/sword.h"
*
* char *main_get_rendered_text(char *module_name, char *key)
*
* Description
*
*
* Return value
* char *
*/
char *main_get_rendered_text(const char *module_name, const char *key)
{
return backend->get_render_text(module_name, key);
}
/******************************************************************************
* Name
* main_get_raw_text
*
* Synopsis
* #include "main/sword.h"
*
* char *main_get_raw_text(char *module_name, char *key)
*
* Description
*
*
* Return value
* char *
*/
char *main_get_raw_text(char *module_name, char *key)
{
return backend->get_raw_text(module_name, key);
}
/******************************************************************************
* Name
* main_get_mod_type
*
* Synopsis
* #include "main/module.h"
*
* int main_get_mod_type(char * mod_name)
*
* Description
*
*
* Return value
* int
*/
int main_get_mod_type(char *mod_name)
{
return backend->module_type(mod_name);
}
/******************************************************************************
* Name
* main_get_module_description
*
* Synopsis
* #include "main/module.h"
*
* gchar *main_get_module_description(gchar * module_name)
*
* Description
*
*
* Return value
* gchar *
*/
const char *main_get_module_description(const char *module_name)
{
return backend->module_description(module_name);
}
/******************************************************************************
* Name
* main_format_number
*
* Synopsis
* #include "main/sword.h"
* char *main_format_number(int x)
*
* Description
* returns a digit string in either "latinate arabic" (normal) or
* farsi characters.
* re_encode_digits is chosen at startup in settings.c.
* caller must free allocated string space when finished with it.
*
* Return value
* char *
*/
int re_encode_digits = FALSE;
char *
main_format_number(int x)
{
char *digits = g_strdup_printf("%d", x);
if (re_encode_digits) {
//
// "\333\260" is farsi "zero".
//
char *d, *f, *farsi = g_new(char, 2 * (strlen(digits) + 1));
// 2 "chars" per farsi-displayed digit + slop.
for (d = digits, f = farsi; *d; ++d) {
*(f++) = '\333';
*(f++) = '\260' + ((*d) - '0');
}
*f = '\0';
g_free(digits);
return farsi;
}
return digits;
}
/******************************************************************************
* Name
* main_flush_widgets_content
*
* Synopsis
* #include "main/sword.h"
* void main_flush_widgets_content()
*
* Description
* cleans content from all subwindow widgets.
*
* Return value
* int
*/
void main_flush_widgets_content(void)
{
GString *blank_html_content = g_string_new(NULL);
g_string_printf(blank_html_content,
"<html><head></head><body bgcolor=\"%s\" text=\"%s\"> </body></html>",
settings.bible_bg_color, settings.bible_text_color);
if (gtk_widget_get_realized(GTK_WIDGET(widgets.html_text)))
HtmlOutput(blank_html_content->str, widgets.html_text, NULL, NULL);
if (gtk_widget_get_realized(GTK_WIDGET(widgets.html_comm)))
HtmlOutput(blank_html_content->str, widgets.html_comm, NULL, NULL);
if (gtk_widget_get_realized(GTK_WIDGET(widgets.html_dict)))
HtmlOutput(blank_html_content->str, widgets.html_dict, NULL, NULL);
if (gtk_widget_get_realized(GTK_WIDGET(widgets.html_book)))
HtmlOutput(blank_html_content->str, widgets.html_book, NULL, NULL);
g_string_free(blank_html_content, TRUE);
}
/******************************************************************************
* Name
* main_is_Bible_key
*
* Synopsis
* #include "main/sword.h"
* void main_is_Bible_key()
*
* Description
* returns boolean status of whether input is a legit Bible key.
*
* Return value
* gboolean
*/
gboolean main_is_Bible_key(const gchar *name, const gchar *key)
{
return (gboolean)(backend->is_Bible_key(name, key, settings.currentverse) != 0);
}
/******************************************************************************
* Name
* main_get_osisref_from_key
*
* Synopsis
* #include "main/sword.h"
* void main_get_osisref_from_key()
*
* Description
* returns OSISRef-formatted key value.
*
* Return value
* const char *
*/
const char *
main_get_osisref_from_key(const char *module, const char *key)
{
return backend->get_osisref_from_key(module, key);
}
| Java |
<?php
global $PPT,$PPTDesign;
PremiumPress_Header(); ?>
<div id="premiumpress_box1" class="premiumpress_box premiumpress_box-100"><div class="premiumpress_boxin"><div class="header">
<h3><img src="<?php echo $GLOBALS['template_url']; ?>/images/premiumpress/h-ico/GeneralPreferences.png" align="middle"> Display Setup</h3>
<ul>
<li><a rel="premiumpress_tab1" href="#" class="active">Layout</a></li>
<li><a rel="premiumpress_tab6" href="#">Home</a></li>
<!--<li><a rel="premiumpress_tab2" href="#">Search</a></li>-->
<li><a rel="premiumpress_tab3" href="#">Sidebar</a></li>
<li><a rel="premiumpress_tab4" href="#">Coupon Page</a></li>
<li><a rel="premiumpress_tab5" href="#">Sliders</a></li>
</ul>
</div>
<style>
select { border-radius: 0px; -webkit-border-radius: 0px; -moz-border-radius: 0px; }
</style>
<form method="post" name="directorypress" target="_self" >
<input name="admin_page" type="hidden" value="directorypress_setup" />
<input name="submitted" type="hidden" value="yes" />
<input name="setup" type="hidden" value="1" />
<input name="featured" type="hidden" value="1" />
<input name="featured1" type="hidden" value="1" />
<input name="listbox" type="hidden" value="yes" />
<input name="featuredstores" type="hidden" value="yes" />
<div id="premiumpress_tab1" class="content">
<table class="maintable" style="background:white;">
<tr class="mainrow">
<td></td>
<td class="forminp">
<p><b>Coupon Display</b></p>
<select name="adminArray[system]" class="small-input" style="width: 240px; font-size:14px;">
<option value="clicktoreveal" <?php if(get_option("system") == "clicktoreveal"){ echo "selected='selected'"; } ?>>Click To Reveal</option>
<option value="normal" <?php if(get_option("system") == "normal"){ echo "selected='selected'"; } ?>>Click To Copy</option>
<option value="link" <?php if(get_option("system") == "link"){ echo "selected='selected'"; } ?>>Link Display</option>
</select>
<br />
<small>Select which type of coupon display you wish to use.</small> </td>
<td class="forminp"><img src="<?php echo IMAGE_PATH; ?>/help1/c3.png">
</td>
</tr>
<tr class="mainrow"><td></td><td class="forminp">
<b>Select theme layout (2 or 3 columns)</b>
<table width="100%" border="1">
<tr>
<td style="width:150px;"><img src="<?php echo $GLOBALS['template_url']; ?>/PPT/img/layout2.gif" /><br /><center>
<input name="display_themecolumns" type="radio" value="2" <?php if(get_option("display_themecolumns") =="2" || get_option("display_themecolumns") =="" ){ print "checked";} ?> /> </center></td>
<td style="width:150px;"><img src="<?php echo $GLOBALS['template_url']; ?>/PPT/img/layout3.gif" /><br /><center>
<input name="display_themecolumns" type="radio" value="3" <?php if(get_option("display_themecolumns") =="3"){ print "checked";} ?> /> </center>
</td>
</tr>
</table>
</td><td class="forminp"><img src="<?php echo IMAGE_PATH; ?>/help1/c4.png"></td></tr>
<?php /***************************************** */ ?>
<tr class="mainrow"><td></td>
<td class="forminp">
<p><b>Footer Text</b></p>
<textarea name="adminArray[footer_text]" type="text" style="width:240px;height:150px;"><?php echo stripslashes(get_option("footer_text")); ?></textarea><br />
<small>This will be added to the bottom of your website.</small>
</td><td class="forminp"><img src="<?php echo IMAGE_PATH; ?>/help1/a16.png"></td></tr>
<?php /***************************************** */ ?>
<tr>
<td colspan="3"><p><input class="premiumpress_button" type="submit" value="<?php _e('Save changes','cp')?>" style="color:white;" /></p></td>
</tr>
</table>
</div>
<div id="premiumpress_tab6" class="content">
<table class="maintable" style="background:white;">
<?php /***************************************** */ ?>
<tr class="mainrow"><td></td><td class="forminp">
<p><b>Website Categories Box</b></p>
<select name="adminArray[display_homecats]" style="width: 240px; font-size:14px;">
<option value="yes" <?php if(get_option("display_homecats") =="yes"){ print "selected";} ?>>Show</option>
<option value="no" <?php if(get_option("display_homecats") =="no"){ print "selected";} ?>>Hide</option>
</select><br />
<small>Show/Hide the home page categories area.</small>
</td><td class="forminp"><img src="<?php echo IMAGE_PATH; ?>/help1/a1.png"></td></tr>
<?php /***************************************** */ ?>
<?php if(get_option("display_homecats") =="yes"){ ?>
<tr class="mainrow"><td></td><td class="forminp">
<p><b>Order Categories By </b></p>
<select name="adminArray[display_homecats_orderby]" style="width: 240px; font-size:14px;">
<option value="id" <?php if(get_option("display_homecats_orderby") =="id"){ print "selected";} ?>>ID (Ascending Order)</option>
<option value="id&order=desc" <?php if(get_option("display_homecats_orderby") =="id&order=desc"){ print "selected";} ?>>ID (Descending Order)</option>
<option value="name" <?php if(get_option("display_homecats_orderby") =="name"){ print "selected";} ?>>Name (Ascending Order)</option>
<option value="name&order=desc" <?php if(get_option("display_homecats_orderby") =="name&order=desc"){ print "selected";} ?>>Name (Descending Order)</option>
<option value="slug" <?php if(get_option("display_homecats_orderby") =="slug"){ print "selected";} ?>>Slug (Ascending Order)</option>
<option value="slug&order=desc" <?php if(get_option("display_homecats_orderby") =="slug&order=desc"){ print "selected";} ?>>Slug (Descending Order)</option>
<option value="count" <?php if(get_option("display_homecats_orderby") =="count"){ print "selected";} ?>>Count (Ascending Order)</option>
<option value="count&order=desc" <?php if(get_option("display_homecats_orderby") =="count&order=desc"){ print "selected";} ?>>Count (Descending Order)</option>
<!-- <option value="group" <?php if(get_option("display_homecats_orderby") =="group"){ print "selected";} ?>>Group (Ascending Order)</option>
<option value="group&order=desc" <?php if(get_option("display_homecats_orderby") =="group&order=desc"){ print "selected";} ?>>Group (Descending Order)</option>-->
</select><br />
<small>select in what order to display the categories.</small>
</td><td class="forminp"><img src="<?php echo IMAGE_PATH; ?>/help1/a2.png"></td></tr>
<?php /***************************************** */ ?>
<tr class="mainrow">
<td></td>
<td class="forminp">
<p><b>Display Sub Categories</b></p>
<select name="adminArray[display_50_subcategories]" style="width: 240px; font-size:14px;">
<option value="yes" <?php if(get_option("display_50_subcategories") =="yes"){ print "selected";} ?>>Show</option>
<option value="no" <?php if(get_option("display_50_subcategories") =="no"){ print "selected";} ?>>Hide</option>
</select><br />
<small>Show/Hide the list of sub categories under the main category link.</small>
</td><td class="forminp"><img src="<?php echo IMAGE_PATH; ?>/help1/a3.png"></td></tr>
<?php } ?>
<tr class="mainrow"><td></td><td class="forminp">
<b>Home Page Image</b>
<p style="width: 240px;"><input type="checkbox" class="checkbox" name="display_featured_image_enable" value="1" <?php if(get_option("display_featured_image_enable") =="1"){ print "checked";} ?> /> Enable Featured Image</p><br />
<small>Add your own image to the front page</small>
<?php if(get_option("display_featured_image_enable") =="1"){ ?>
<b>Featured Image URL</b><br />
<input name="adminArray[display_featured_image_url]" type="text" style="width: 240px; font-size:14px;" value="<?php echo get_option("display_featured_image_url"); ?>" /><br />
<small>Enter the full URL for the image you would like to display.</small>
<br /><b>Featured Image Link URL</b><br />
<input name="adminArray[display_featured_image_link]" type="text" style="width: 240px; font-size:14px;" value="<?php echo get_option("display_featured_image_link"); ?>" /><br />
<small>Enter the link you would like to have when someone clicks on the image.</small>
<?php } ?>
</td><td class="forminp"><img src="<?php echo IMAGE_PATH; ?>/help1/a0.png"></td></tr>
<tr>
<td colspan="3"><p><input class="premiumpress_button" type="submit" value="<?php _e('Save changes','cp')?>" style="color:white;" /></p></td>
</tr>
</table>
</div>
<div id="premiumpress_tab2" class="content">
<table class="maintable" style="background:white;">
<tr>
<td colspan="4"><p><input class="premiumpress_button" type="submit" value="<?php _e('Save changes','cp')?>" style="color:white;" /></p></td>
</tr>
</table>
</div>
<div id="premiumpress_tab3" class="content">
<table class="maintable" style="background:white;">
<?php /***************************************** */ ?>
<tr class="mainrow">
<td></td>
<td class="forminp">
<p><b>Display Recent Articles</b></p>
<select name="adminArray[display_sidebar_articles]" style="width: 240px; font-size:14px;">
<option value="yes" <?php if(get_option("display_sidebar_articles") =="yes"){ print "selected";} ?>>Show</option>
<option value="no" <?php if(get_option("display_sidebar_articles") =="no"){ print "selected";} ?>>Hide</option>
</select><br /><small>Show/Hide the sidebar articles box.</small> <br />
<input name="adminArray[display_sidebar_articles_count]" value="<?php echo get_option("display_sidebar_articles_count"); ?>" class="txt" style="width:50px; font-size:14px;" type="text"> # Articles
</td><td class="forminp"><img src="<?php echo IMAGE_PATH; ?>/help1/a7.png"></td></tr>
<?php /***************************************** */ ?>
<tr class="mainrow">
<td class="titledesc" valign="top">Featured Stores <br /><br />
<small>Select the stores you wish to be displayed as featured on your sidebar. </small> </td>
<td class="forminp" valign="top">
<?php
$Maincategories= get_categories('use_desc_for_title=1&hide_empty=0&hierarchical=1');
$Maincatcount = count($Maincategories);
$SAVED_DISPLAY = get_option("featured_stores");
$i=0;
foreach ($Maincategories as $Maincat) {
if($Maincat->parent !=0){
print '<div style="background:#efefef; padding:8px; border:1px solid #ddd; font-size:12px; font-weight:bold; float:left; width:270px; margin-right:10px; ">
<input name="featured_stores['.$i.'][ID]" type="checkbox"
value="'.$Maincat->cat_ID.'"';
if( isset($SAVED_DISPLAY[$i][ID]) ){ print 'checked="checked"'; }
print 'style="margin-right:10px;">' . $Maincat->cat_name.' ';
print '<br><small>Order: <input name="featured_stores['.$i.'][ORDER]" type="text" value="';
if(isset($SAVED_DISPLAY[$i][ORDER]) && is_numeric($SAVED_DISPLAY[$i][ORDER]) ){ print $SAVED_DISPLAY[$i][ORDER]; }
print '" style="width:30px;font-size:11px;"> </small>';
print ' </div> ';
$i++;
}
}
?>
</td>
</tr>
<tr class="mainrow"><td colspan="3">
<center><a href="widgets.php"><img src="<?php echo $GLOBALS['template_url']; ?>/template_couponpress/images/help1/a23.png"></a></center>
</td> <tr>
<tr>
<td colspan="3"><p><input class="premiumpress_button" type="submit" value="<?php _e('Save changes','cp')?>" style="color:white;" /></p></td>
</tr>
</table>
</div>
<div id="premiumpress_tab4" class="content">
<table class="maintable" style="background:white;">
<tr class="mainrow">
<td></td>
<td class="forminp">
<p><b>Member information box</b></p>
<select name="adminArray[display_sidebar_memberinfo]" style="width: 240px; font-size:14px;">
<option value="yes" <?php if(get_option("display_sidebar_memberinfo") =="yes"){ print "selected";} ?>>Show</option>
<option value="no" <?php if(get_option("display_sidebar_memberinfo") =="no"){ print "selected";} ?>>Hide</option>
</select><br /><small>Show/Hide the sidebar member information box.</small> <br />
</td><td class="forminp"><img src="<?php echo IMAGE_PATH; ?>/help1/c1.png"></td></tr>
<tr class="mainrow">
<td></td>
<td class="forminp">
<p><b>Related Coupons</b></p>
<select name="adminArray[display_related_coupons]" style="width: 240px; font-size:14px;">
<option value="yes" <?php if(get_option("display_related_coupons") =="yes"){ print "selected";} ?>>Show</option>
<option value="no" <?php if(get_option("display_related_coupons") =="no"){ print "selected";} ?>>Hide</option>
</select><br /><small>Show/Hide the related coupons on the coupon page.</small> <br />
</td><td class="forminp"><img src="<?php echo IMAGE_PATH; ?>/help1/c4.png"></td></tr>
<?php /***************************************** */ ?>
<tr class="mainrow"> <td></td><td class="forminp">
<p><b> Google Maps Box</b></p>
<select name="adminArray[display_googlemaps]" style="width: 240px; font-size:14px;">
<option value="yes2" <?php if(get_option("display_googlemaps") =="yes2"){ print "selected";} ?>>Show - Interactive Map</option>
<option value="no" <?php if(get_option("display_googlemaps") =="no"){ print "selected";} ?>>Hide Google Maps</option>
</select><br />
<small><b>Remember</b>Google maps will only display for listings that have a map_location custom field value entered. The interative map requires long/Lat coordinates and isnt recommended for unexperienced users.</small>
</td><td class="forminp"><img src="<?php echo IMAGE_PATH; ?>/help1/c2.png"></td></tr>
<?php /***************************************** */ ?>
<tr>
<td colspan="3"><p><input class="premiumpress_button" type="submit" value="Save Changes" style="color:white;" /></p></td>
</tr>
</table>
</div>
<div id="premiumpress_tab5" class="content">
<table class="maintable" style="background:white;">
<?php /***************************************** */ ?>
<tr class="mainrow"> <td></td><td class="forminp">
<p><b> Enable Home Page Slider </b></p>
<select name="adminArray[PPT_slider]" style="width: 240px; font-size:14px;">
<option value="off" <?php if(get_option("PPT_slider") =="off"){ print "selected";} ?>>Disable All Sliders</option>
<option value="s1" <?php if(get_option("PPT_slider") =="s1"){ print "selected";} ?>>Featured Content Slider (Full Width)</option>
<option value="s2" <?php if(get_option("PPT_slider") =="s2"){ print "selected";} ?>>Half Content Slider</option>
</select>
<p><b> Slider Style</b></p>
<select name="adminArray[PPT_slider_style]" style="width: 240px; font-size:14px;">
<option value="1" <?php if(get_option("PPT_slider_style") =="1"){ print "selected";} ?>>Style 1 (image size: 650x X 265px)</option>
<option value="2" <?php if(get_option("PPT_slider_style") =="2"){ print "selected";} ?>>Style 2 (image size: 960x X 360px)</option>
<option value="3" <?php if(get_option("PPT_slider_style") =="3"){ print "selected";} ?>>Style 3 (image size: 960x X 360px)</option>
<option value="4" <?php if(get_option("PPT_slider_style") =="4"){ print "selected";} ?>>Style 4 (image size: 960x X 360px)</option>
<option value="5" <?php if(get_option("PPT_slider_style") =="5"){ print "selected";} ?>>Style 5 (image size: 960x X 360px)</option>
</select><br />
<p><b> Slider Content Source</b></p>
<select name="adminArray[PPT_slider_items]" style="width: 240px; font-size:14px;">
<option value="manual" <?php if(get_option("PPT_slider_items") =="manual"){ print "selected";} ?>>Manually Configure Slides</option>
<option value="featured" <?php if(get_option("PPT_slider_items") =="featured"){ print "selected";} ?>>Use Featured Posts</option>
</select><br />
</td><td class="forminp"><img src="<?php echo IMAGE_PATH; ?>/help1/a21.png"></td></tr>
<?php /***************************************** */ ?>
<tr>
<td colspan="3"><p><input class="premiumpress_button" type="submit" value="<?php _e('Save changes','cp')?>" style="color:white;" /></p></td>
</tr>
</table>
</form>
<div id="DisplayImages" style="display:none;"></div><input type="hidden" id="searchBox1" name="searchBox1" value="" />
<div id="PPT-sliderbox"></div>
<div id="PPT-sliderboxAdd" style="margin-left:20px;display:none">
<form method="post" target="_self" >
<input name="admin_slider" type="hidden" value="slider" />
<input type="hidden" id="ppsedit" value="0">
<table width="100%" border="0">
<tr>
<td valign="top"><b>Slider Title</b> <br /> <input type="text" name="s1" id="pps1" style="width: 200px; font-size:14px;" class="txt" /> </td>
<td><b>Title Description</b> <small>(max. 10 words)</small> <br /> <textarea name="s3" id="pps3" style="width: 200px; font-size:14px; height:70px;" class="txt"></textarea> </td>
<td><b>Main Description</b> <small>(max. 250 words)</small> <br /> <textarea name="s4" id="pps4" style="width: 200px; font-size:14px; height:70px;" class="txt"></textarea></td>
</tr>
<tr>
<td><b>Slider Image</b> <br/> <input type="text" name="s2" id="pps2" style="width: 200px; font-size:14px;" class="txt" />
<br/><br/>
<input type="hidden" value="" name="imgIdblock" id="imgIdblock" />
<script type="text/javascript">
function ChangeImgBlock(divname){
document.getElementById("imgIdblock").value = divname;
}
jQuery(document).ready(function() {
jQuery('#upload_sliderimage').click(function() {
ChangeImgBlock('pps2');
formfield = jQuery('#pps2').attr('name');
tb_show('', <?php if(defined('MULTISITE') && MULTISITE != false){ ?>'admin.php?page=images&tab=nw&TB_iframe=true'<?php }else{ ?>'media-upload.php?type=image&TB_iframe=true'<?php } ?>);
return false;
});
window.send_to_editor = function(html) {
imgurl = jQuery('img',html).attr('src');
jQuery('#'+document.getElementById("imgIdblock").value).val(imgurl);
tb_remove();
}
});
</script>
<input id="upload_sliderimage" type="button" size="36" name="upload_sliderimage" value="Upload Image" />
<input onClick="toggleLayer('DisplayImages'); add_image_next(0,'<?php echo get_option("imagestorage_path"); ?>','<?php echo get_option("imagestorage_link"); ?>','pps2');" type="button" value="View Images" />
</td>
<td valign="top"><b>Slider Clickable Link</b> <br /> <input type="text" name="s5" id="pps5" style="width: 200px; font-size:14px;" class="txt" value="http://" /> </td>
<td valign="top"><b>Display Order</b><br /><select id="pps6" name="s6" style="width: 100px; font-size:14px;"><?php $i=1; while($i<20){ echo '<option>'.$i.'</option>'; $i++; } ?></select></td>
</tr>
<tr>
<td colspan="3"><p><input class="premiumpress_button" type="submit" value="Create New Slide" style="color:white;" /></p></td>
</tr>
</table>
</form>
</div>
<div id="addBtn1" style="display:visible"><a href="javascript:void();" onClick="jQuery('#PPT-sliderboxAdd').show();jQuery('#addBtn1').hide();" class="premiumpress_button" style=" float:right; margin-right:10px;" >Add Slider Item</a></div>
<h2 style="margin-left:10px;">Website Slider Items</h2>
<p style="margin-left:10px;">Here you can setup and create new items for your website slider.</p>
<?php $sliderData = get_option("slider_array"); if(is_array($sliderData) && count($sliderData) > 0 ){ ?>
<table id="ct"><thead><tr id="ct_sort">
<th width="90" class="first">Title</th>
<th width="100">Short Description</th>
<th width="40"class="last">Display Order</th>
<th width="40"class="last">Actions</th>
</tr></thead><tbody>
<?php
$sortedSlider = $PPTDesign->array_sort($sliderData, 'order', SORT_ASC);
$i=-1; foreach($sortedSlider as $hh => $slide){ ?>
<tr id="srow<?php echo $i; ?>">
<td width="90" class="first"><?php echo $slide['s1']; ?></td>
<td width="80"><?php echo $slide['s3']; ?></td>
<td width="50"><?php echo $slide['order']; ?></td>
<td width="80" class="last">
<a href='#' Onclick="EditsliderItem('<?php echo $hh; ?>');jQuery('#PPT-sliderbox').show();" style="padding:5px; background:#dcffe1; border:1px solid #57b564; color:green;"><img src="<?php echo $GLOBALS['template_url']; ?>/images/premiumpress/led-ico/find.png" align="middle"> Edit </a>
- <a href='#' Onclick="DeleteSliderItem('<?php echo $hh; ?>');jQuery('#PPT-sliderbox').show();jQuery('#srow<?php echo $i; ?>').hide();" style="padding:5px; background:#ffb9ba; border:1px solid #bd2e2f; color:red;"><img src="<?php echo $GLOBALS['template_url']; ?>/images/premiumpress/led-ico/delete.png" align="middle"> Delete </a></td>
</tr>
<?php $i++; } ?>
</tbody> </table>
<br />
<form method="post" target="_self" >
<input name="admin_slider" type="hidden" value="reset" />
<input class="premiumpress_button" type="submit" value="Reset Slider (Delete All Slides)" style="color:white;" />
</form>
<?php } ?>
</div>
| Java |
# 考勤
----
考勤信息查询 <br>
http://yun.kqapi.com/Default/Index/index | Java |
/**
* AuthenticationUserLibraryPortType.java
*
* This file was auto-generated from WSDL
* by the Apache Axis 1.4 Apr 22, 2006 (06:55:48 PDT) WSDL2Java emitter.
*/
package it.depositolegale.www.webservice_authenticationUserLibrary;
public interface AuthenticationUserLibraryPortType extends java.rmi.Remote {
public it.depositolegale.www.authenticationUserOutput.AuthenticationUserOutput authenticationUserLibraryOperation(it.depositolegale.www.authenticationUserInput.AuthenticationUserInput authenticationUserInput) throws java.rmi.RemoteException;
}
| Java |
/*
* linux/arch/arm/kernel/traps.c
*
* Copyright (C) 1995-2009 Russell King
* Fragments that appear the same as linux/arch/i386/kernel/traps.c (C) Linus Torvalds
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
* 'traps.c' handles hardware exceptions after we have saved some state in
* 'linux/arch/arm/lib/traps.S'. Mostly a debugging aid, but will probably
* kill the offending process.
*/
#include <linux/module.h>
#include <linux/signal.h>
#include <linux/spinlock.h>
#include <linux/personality.h>
#include <linux/kallsyms.h>
#include <linux/delay.h>
#include <linux/hardirq.h>
#include <linux/init.h>
#include <linux/uaccess.h>
#include <asm/atomic.h>
#include <asm/cacheflush.h>
#include <asm/system.h>
#include <asm/unistd.h>
#include <asm/traps.h>
#include <asm/unwind.h>
#include "ptrace.h"
#include "signal.h"
static const char *handler[]= { "prefetch abort", "data abort", "address exception", "interrupt" };
void *vectors_page;
#ifdef CONFIG_DEBUG_USER
unsigned int user_debug;
static int __init user_debug_setup(char *str)
{
get_option(&str, &user_debug);
return 1;
}
__setup("user_debug=", user_debug_setup);
#endif
static void dump_mem(const char *, const char *, unsigned long, unsigned long);
void dump_backtrace_entry(unsigned long where, unsigned long from, unsigned long frame)
{
#ifdef CONFIG_KALLSYMS
char sym1[KSYM_SYMBOL_LEN], sym2[KSYM_SYMBOL_LEN];
sprint_symbol(sym1, where);
sprint_symbol(sym2, from);
printk("[<%08lx>] (%s) from [<%08lx>] (%s)\n", where, sym1, from, sym2);
#else
printk("Function entered at [<%08lx>] from [<%08lx>]\n", where, from);
#endif
if (in_exception_text(where))
dump_mem("", "Exception stack", frame + 4, frame + 4 + sizeof(struct pt_regs));
}
#ifndef CONFIG_ARM_UNWIND
/*
* Stack pointers should always be within the kernels view of
* physical memory. If it is not there, then we can't dump
* out any information relating to the stack.
*/
static int verify_stack(unsigned long sp)
{
if (sp < PAGE_OFFSET ||
(sp > (unsigned long)high_memory && high_memory != NULL))
return -EFAULT;
return 0;
}
#endif
/*
* Dump out the contents of some memory nicely...
*/
static void dump_mem(const char *lvl, const char *str, unsigned long bottom,
unsigned long top)
{
unsigned long first;
mm_segment_t fs;
int i;
/*
* We need to switch to kernel mode so that we can use __get_user
* to safely read from kernel space. Note that we now dump the
* code first, just in case the backtrace kills us.
*/
fs = get_fs();
set_fs(KERNEL_DS);
printk("%s%s(0x%08lx to 0x%08lx)\n", lvl, str, bottom, top);
for (first = bottom & ~31; first < top; first += 32) {
unsigned long p;
char str[sizeof(" 12345678") * 8 + 1];
memset(str, ' ', sizeof(str));
str[sizeof(str) - 1] = '\0';
for (p = first, i = 0; i < 8 && p < top; i++, p += 4) {
if (p >= bottom && p < top) {
unsigned long val;
if (__get_user(val, (unsigned long *)p) == 0)
sprintf(str + i * 9, " %08lx", val);
else
sprintf(str + i * 9, " ????????");
}
}
printk("%s%04lx:%s\n", lvl, first & 0xffff, str);
}
set_fs(fs);
}
static void dump_instr(const char *lvl, struct pt_regs *regs)
{
unsigned long addr = instruction_pointer(regs);
const int thumb = thumb_mode(regs);
const int width = thumb ? 4 : 8;
mm_segment_t fs;
char str[sizeof("00000000 ") * 5 + 2 + 1], *p = str;
int i;
/*
* We need to switch to kernel mode so that we can use __get_user
* to safely read from kernel space. Note that we now dump the
* code first, just in case the backtrace kills us.
*/
fs = get_fs();
set_fs(KERNEL_DS);
for (i = -4; i < 1; i++) {
unsigned int val, bad;
if (thumb)
bad = __get_user(val, &((u16 *)addr)[i]);
else
bad = __get_user(val, &((u32 *)addr)[i]);
if (!bad)
p += sprintf(p, i == 0 ? "(%0*x) " : "%0*x ",
width, val);
else {
p += sprintf(p, "bad PC value");
break;
}
}
printk("%sCode: %s\n", lvl, str);
set_fs(fs);
}
#ifdef CONFIG_ARM_UNWIND
static inline void dump_backtrace(struct pt_regs *regs, struct task_struct *tsk)
{
unwind_backtrace(regs, tsk);
}
#else
static void dump_backtrace(struct pt_regs *regs, struct task_struct *tsk)
{
unsigned int fp, mode;
int ok = 1;
printk("Backtrace: ");
if (!tsk)
tsk = current;
if (regs) {
fp = regs->ARM_fp;
mode = processor_mode(regs);
} else if (tsk != current) {
fp = thread_saved_fp(tsk);
mode = 0x10;
} else {
asm("mov %0, fp" : "=r" (fp) : : "cc");
mode = 0x10;
}
if (!fp) {
printk("no frame pointer");
ok = 0;
} else if (verify_stack(fp)) {
printk("invalid frame pointer 0x%08x", fp);
ok = 0;
} else if (fp < (unsigned long)end_of_stack(tsk))
printk("frame pointer underflow");
printk("\n");
if (ok)
c_backtrace(fp, mode);
}
#endif
void dump_stack(void)
{
dump_backtrace(NULL, NULL);
}
EXPORT_SYMBOL(dump_stack);
void show_stack(struct task_struct *tsk, unsigned long *sp)
{
dump_backtrace(NULL, tsk);
barrier();
}
#ifdef CONFIG_PREEMPT
#define S_PREEMPT " PREEMPT"
#else
#define S_PREEMPT ""
#endif
#ifdef CONFIG_SMP
#define S_SMP " SMP"
#else
#define S_SMP ""
#endif
static void __die(const char *str, int err, struct thread_info *thread, struct pt_regs *regs)
{
struct task_struct *tsk = thread->task;
static int die_counter;
#if defined(CONFIG_MACH_STAR)
set_default_loglevel(); /* 20100916 set default loglevel */
#endif
printk(KERN_EMERG "Internal error: %s: %x [#%d]" S_PREEMPT S_SMP "\n",
str, err, ++die_counter);
sysfs_printk_last_file();
print_modules();
__show_regs(regs);
printk(KERN_EMERG "Process %.*s (pid: %d, stack limit = 0x%p)\n",
TASK_COMM_LEN, tsk->comm, task_pid_nr(tsk), thread + 1);
if (!user_mode(regs) || in_interrupt()) {
dump_mem(KERN_EMERG, "Stack: ", regs->ARM_sp,
THREAD_SIZE + (unsigned long)task_stack_page(tsk));
dump_backtrace(regs, tsk);
dump_instr(KERN_EMERG, regs);
}
}
DEFINE_SPINLOCK(die_lock);
/*
* This function is protected against re-entrancy.
*/
NORET_TYPE void die(const char *str, struct pt_regs *regs, int err)
{
struct thread_info *thread = current_thread_info();
oops_enter();
spin_lock_irq(&die_lock);
console_verbose();
bust_spinlocks(1);
__die(str, err, thread, regs);
bust_spinlocks(0);
add_taint(TAINT_DIE);
spin_unlock_irq(&die_lock);
oops_exit();
if (in_interrupt())
panic("Fatal exception in interrupt");
if (panic_on_oops)
panic("Fatal exception");
do_exit(SIGSEGV);
}
void arm_notify_die(const char *str, struct pt_regs *regs,
struct siginfo *info, unsigned long err, unsigned long trap)
{
if (user_mode(regs)) {
current->thread.error_code = err;
current->thread.trap_no = trap;
force_sig_info(info->si_signo, info, current);
} else {
die(str, regs, err);
}
}
static LIST_HEAD(undef_hook);
static DEFINE_SPINLOCK(undef_lock);
void register_undef_hook(struct undef_hook *hook)
{
unsigned long flags;
spin_lock_irqsave(&undef_lock, flags);
list_add(&hook->node, &undef_hook);
spin_unlock_irqrestore(&undef_lock, flags);
}
void unregister_undef_hook(struct undef_hook *hook)
{
unsigned long flags;
spin_lock_irqsave(&undef_lock, flags);
list_del(&hook->node);
spin_unlock_irqrestore(&undef_lock, flags);
}
static int call_undef_hook(struct pt_regs *regs, unsigned int instr)
{
struct undef_hook *hook;
unsigned long flags;
int (*fn)(struct pt_regs *regs, unsigned int instr) = NULL;
spin_lock_irqsave(&undef_lock, flags);
list_for_each_entry(hook, &undef_hook, node)
if ((instr & hook->instr_mask) == hook->instr_val &&
(regs->ARM_cpsr & hook->cpsr_mask) == hook->cpsr_val)
fn = hook->fn;
spin_unlock_irqrestore(&undef_lock, flags);
return fn ? fn(regs, instr) : 1;
}
asmlinkage void __exception do_undefinstr(struct pt_regs *regs)
{
unsigned int correction = thumb_mode(regs) ? 2 : 4;
unsigned int instr;
siginfo_t info;
void __user *pc;
/*
* According to the ARM ARM, PC is 2 or 4 bytes ahead,
* depending whether we're in Thumb mode or not.
* Correct this offset.
*/
regs->ARM_pc -= correction;
pc = (void __user *)instruction_pointer(regs);
if (processor_mode(regs) == SVC_MODE) {
instr = *(u32 *) pc;
} else if (thumb_mode(regs)) {
get_user(instr, (u16 __user *)pc);
} else {
get_user(instr, (u32 __user *)pc);
}
if (call_undef_hook(regs, instr) == 0)
return;
#ifdef CONFIG_DEBUG_USER
if (user_debug & UDBG_UNDEFINED) {
printk(KERN_INFO "%s (%d): undefined instruction: pc=%p\n",
current->comm, task_pid_nr(current), pc);
dump_instr(KERN_INFO, regs);
}
#endif
info.si_signo = SIGILL;
info.si_errno = 0;
info.si_code = ILL_ILLOPC;
info.si_addr = pc;
arm_notify_die("Oops - undefined instruction", regs, &info, 0, 6);
}
asmlinkage void do_unexp_fiq (struct pt_regs *regs)
{
printk("Hmm. Unexpected FIQ received, but trying to continue\n");
printk("You may have a hardware problem...\n");
}
/*
* bad_mode handles the impossible case in the vectors. If you see one of
* these, then it's extremely serious, and could mean you have buggy hardware.
* It never returns, and never tries to sync. We hope that we can at least
* dump out some state information...
*/
asmlinkage void bad_mode(struct pt_regs *regs, int reason)
{
console_verbose();
printk(KERN_CRIT "Bad mode in %s handler detected\n", handler[reason]);
die("Oops - bad mode", regs, 0);
local_irq_disable();
panic("bad mode");
}
static int bad_syscall(int n, struct pt_regs *regs)
{
struct thread_info *thread = current_thread_info();
siginfo_t info;
if (current->personality != PER_LINUX &&
current->personality != PER_LINUX_32BIT &&
thread->exec_domain->handler) {
thread->exec_domain->handler(n, regs);
return regs->ARM_r0;
}
#ifdef CONFIG_DEBUG_USER
if (user_debug & UDBG_SYSCALL) {
printk(KERN_ERR "[%d] %s: obsolete system call %08x.\n",
task_pid_nr(current), current->comm, n);
dump_instr(KERN_ERR, regs);
}
#endif
info.si_signo = SIGILL;
info.si_errno = 0;
info.si_code = ILL_ILLTRP;
info.si_addr = (void __user *)instruction_pointer(regs) -
(thumb_mode(regs) ? 2 : 4);
arm_notify_die("Oops - bad syscall", regs, &info, n, 0);
return regs->ARM_r0;
}
static inline void
do_cache_op(unsigned long start, unsigned long end, int flags)
{
struct mm_struct *mm = current->active_mm;
struct vm_area_struct *vma;
if (end < start || flags)
return;
down_read(&mm->mmap_sem);
vma = find_vma(mm, start);
if (vma && vma->vm_start < end) {
if (start < vma->vm_start)
start = vma->vm_start;
if (end > vma->vm_end)
end = vma->vm_end;
up_read(&mm->mmap_sem);
flush_cache_user_range(start, end);
return;
}
up_read(&mm->mmap_sem);
}
/*
* Handle all unrecognised system calls.
* 0x9f0000 - 0x9fffff are some more esoteric system calls
*/
#define NR(x) ((__ARM_NR_##x) - __ARM_NR_BASE)
asmlinkage int arm_syscall(int no, struct pt_regs *regs)
{
struct thread_info *thread = current_thread_info();
siginfo_t info;
if ((no >> 16) != (__ARM_NR_BASE>> 16))
return bad_syscall(no, regs);
switch (no & 0xffff) {
case 0: /* branch through 0 */
info.si_signo = SIGSEGV;
info.si_errno = 0;
info.si_code = SEGV_MAPERR;
info.si_addr = NULL;
arm_notify_die("branch through zero", regs, &info, 0, 0);
return 0;
case NR(breakpoint): /* SWI BREAK_POINT */
regs->ARM_pc -= thumb_mode(regs) ? 2 : 4;
ptrace_break(current, regs);
return regs->ARM_r0;
/*
* Flush a region from virtual address 'r0' to virtual address 'r1'
* _exclusive_. There is no alignment requirement on either address;
* user space does not need to know the hardware cache layout.
*
* r2 contains flags. It should ALWAYS be passed as ZERO until it
* is defined to be something else. For now we ignore it, but may
* the fires of hell burn in your belly if you break this rule. ;)
*
* (at a later date, we may want to allow this call to not flush
* various aspects of the cache. Passing '0' will guarantee that
* everything necessary gets flushed to maintain consistency in
* the specified region).
*/
case NR(cacheflush):
do_cache_op(regs->ARM_r0, regs->ARM_r1, regs->ARM_r2);
return 0;
case NR(usr26):
if (!(elf_hwcap & HWCAP_26BIT))
break;
regs->ARM_cpsr &= ~MODE32_BIT;
return regs->ARM_r0;
case NR(usr32):
if (!(elf_hwcap & HWCAP_26BIT))
break;
regs->ARM_cpsr |= MODE32_BIT;
return regs->ARM_r0;
case NR(set_tls):
thread->tp_value = regs->ARM_r0;
#if defined(CONFIG_HAS_TLS_REG)
#if defined(CONFIG_TEGRA_ERRATA_657451)
BUG_ON(regs->ARM_r0 & 0x1);
asm ("mcr p15, 0, %0, c13, c0, 3" : :
"r" ((regs->ARM_r0) | ((regs->ARM_r0>>20) & 0x1)));
#else
asm ("mcr p15, 0, %0, c13, c0, 3" : : "r" (regs->ARM_r0) );
#endif
#elif !defined(CONFIG_TLS_REG_EMUL)
/*
* User space must never try to access this directly.
* Expect your app to break eventually if you do so.
* The user helper at 0xffff0fe0 must be used instead.
* (see entry-armv.S for details)
*/
*((unsigned int *)0xffff0ff0) = regs->ARM_r0;
#endif
return 0;
#ifdef CONFIG_NEEDS_SYSCALL_FOR_CMPXCHG
/*
* Atomically store r1 in *r2 if *r2 is equal to r0 for user space.
* Return zero in r0 if *MEM was changed or non-zero if no exchange
* happened. Also set the user C flag accordingly.
* If access permissions have to be fixed up then non-zero is
* returned and the operation has to be re-attempted.
*
* *NOTE*: This is a ghost syscall private to the kernel. Only the
* __kuser_cmpxchg code in entry-armv.S should be aware of its
* existence. Don't ever use this from user code.
*/
case NR(cmpxchg):
for (;;) {
extern void do_DataAbort(unsigned long addr, unsigned int fsr,
struct pt_regs *regs);
unsigned long val;
unsigned long addr = regs->ARM_r2;
struct mm_struct *mm = current->mm;
pgd_t *pgd; pmd_t *pmd; pte_t *pte;
spinlock_t *ptl;
regs->ARM_cpsr &= ~PSR_C_BIT;
down_read(&mm->mmap_sem);
pgd = pgd_offset(mm, addr);
if (!pgd_present(*pgd))
goto bad_access;
pmd = pmd_offset(pgd, addr);
if (!pmd_present(*pmd))
goto bad_access;
pte = pte_offset_map_lock(mm, pmd, addr, &ptl);
if (!pte_present(*pte) || !pte_dirty(*pte)) {
pte_unmap_unlock(pte, ptl);
goto bad_access;
}
val = *(unsigned long *)addr;
val -= regs->ARM_r0;
if (val == 0) {
*(unsigned long *)addr = regs->ARM_r1;
regs->ARM_cpsr |= PSR_C_BIT;
}
pte_unmap_unlock(pte, ptl);
up_read(&mm->mmap_sem);
return val;
bad_access:
up_read(&mm->mmap_sem);
/* simulate a write access fault */
do_DataAbort(addr, 15 + (1 << 11), regs);
}
#endif
default:
/* Calls 9f00xx..9f07ff are defined to return -ENOSYS
if not implemented, rather than raising SIGILL. This
way the calling program can gracefully determine whether
a feature is supported. */
if ((no & 0xffff) <= 0x7ff)
return -ENOSYS;
break;
}
#ifdef CONFIG_DEBUG_USER
/*
* experience shows that these seem to indicate that
* something catastrophic has happened
*/
if (user_debug & UDBG_SYSCALL) {
printk("[%d] %s: arm syscall %d\n",
task_pid_nr(current), current->comm, no);
dump_instr("", regs);
if (user_mode(regs)) {
__show_regs(regs);
c_backtrace(regs->ARM_fp, processor_mode(regs));
}
}
#endif
info.si_signo = SIGILL;
info.si_errno = 0;
info.si_code = ILL_ILLTRP;
info.si_addr = (void __user *)instruction_pointer(regs) -
(thumb_mode(regs) ? 2 : 4);
arm_notify_die("Oops - bad syscall(2)", regs, &info, no, 0);
return 0;
}
#ifdef CONFIG_TLS_REG_EMUL
/*
* We might be running on an ARMv6+ processor which should have the TLS
* register but for some reason we can't use it, or maybe an SMP system
* using a pre-ARMv6 processor (there are apparently a few prototypes like
* that in existence) and therefore access to that register must be
* emulated.
*/
static int get_tp_trap(struct pt_regs *regs, unsigned int instr)
{
int reg = (instr >> 12) & 15;
if (reg == 15)
return 1;
regs->uregs[reg] = current_thread_info()->tp_value;
regs->ARM_pc += 4;
return 0;
}
static struct undef_hook arm_mrc_hook = {
.instr_mask = 0x0fff0fff,
.instr_val = 0x0e1d0f70,
.cpsr_mask = PSR_T_BIT,
.cpsr_val = 0,
.fn = get_tp_trap,
};
static int __init arm_mrc_hook_init(void)
{
register_undef_hook(&arm_mrc_hook);
return 0;
}
late_initcall(arm_mrc_hook_init);
#endif
void __bad_xchg(volatile void *ptr, int size)
{
printk("xchg: bad data size: pc 0x%p, ptr 0x%p, size %d\n",
__builtin_return_address(0), ptr, size);
BUG();
}
EXPORT_SYMBOL(__bad_xchg);
/*
* A data abort trap was taken, but we did not handle the instruction.
* Try to abort the user program, or panic if it was the kernel.
*/
asmlinkage void
baddataabort(int code, unsigned long instr, struct pt_regs *regs)
{
unsigned long addr = instruction_pointer(regs);
siginfo_t info;
#ifdef CONFIG_DEBUG_USER
if (user_debug & UDBG_BADABORT) {
printk(KERN_ERR "[%d] %s: bad data abort: code %d instr 0x%08lx\n",
task_pid_nr(current), current->comm, code, instr);
dump_instr(KERN_ERR, regs);
show_pte(current->mm, addr);
}
#endif
info.si_signo = SIGILL;
info.si_errno = 0;
info.si_code = ILL_ILLOPC;
info.si_addr = (void __user *)addr;
arm_notify_die("unknown data abort code", regs, &info, instr, 0);
}
void __attribute__((noreturn)) __bug(const char *file, int line)
{
printk(KERN_CRIT"kernel BUG at %s:%d!\n", file, line);
*(int *)0 = 0;
/* Avoid "noreturn function does return" */
for (;;);
}
EXPORT_SYMBOL(__bug);
void __readwrite_bug(const char *fn)
{
printk("%s called, but not implemented\n", fn);
BUG();
}
EXPORT_SYMBOL(__readwrite_bug);
void __pte_error(const char *file, int line, unsigned long val)
{
printk("%s:%d: bad pte %08lx.\n", file, line, val);
}
void __pmd_error(const char *file, int line, unsigned long val)
{
printk("%s:%d: bad pmd %08lx.\n", file, line, val);
}
void __pgd_error(const char *file, int line, unsigned long val)
{
printk("%s:%d: bad pgd %08lx.\n", file, line, val);
}
asmlinkage void __div0(void)
{
printk("Division by zero in kernel.\n");
dump_stack();
}
EXPORT_SYMBOL(__div0);
void abort(void)
{
BUG();
/* if that doesn't kill us, halt */
panic("Oops failed to kill thread");
}
EXPORT_SYMBOL(abort);
void __init trap_init(void)
{
return;
}
void __init early_trap_init(void)
{
#if defined(CONFIG_CPU_USE_DOMAINS)
unsigned long vectors = CONFIG_VECTORS_BASE;
#else
unsigned long vectors = (unsigned long)vectors_page;
#endif
extern char __stubs_start[], __stubs_end[];
extern char __vectors_start[], __vectors_end[];
extern char __kuser_helper_start[], __kuser_helper_end[];
int kuser_sz = __kuser_helper_end - __kuser_helper_start;
/*
* Copy the vectors, stubs and kuser helpers (in entry-armv.S)
* into the vector page, mapped at 0xffff0000, and ensure these
* are visible to the instruction stream.
*/
memcpy((void *)vectors, __vectors_start, __vectors_end - __vectors_start);
memcpy((void *)vectors + 0x200, __stubs_start, __stubs_end - __stubs_start);
memcpy((void *)vectors + 0x1000 - kuser_sz, __kuser_helper_start, kuser_sz);
/*
* Copy signal return handlers into the vector page, and
* set sigreturn to be a pointer to these.
*/
memcpy((void *)(vectors + KERN_SIGRETURN_CODE - CONFIG_VECTORS_BASE),
sigreturn_codes, sizeof(sigreturn_codes));
memcpy((void *)(vectors + KERN_RESTART_CODE - CONFIG_VECTORS_BASE),
syscall_restart_code, sizeof(syscall_restart_code));
flush_icache_range(vectors, vectors + PAGE_SIZE);
modify_domain(DOMAIN_USER, DOMAIN_CLIENT);
}
| Java |
/*
Theme Name: Metaspace Mobile
Theme URI: http://metaspace.co
Description: Metaspace for Dettol MHSD
Version: 1
Author: Metaspace
Author URI: http://metaspace.co
*/ | Java |
<?php
/**
* @copyright Ilch 2.0
* @package ilch
*/
namespace Modules\Admin\Models;
/**
* The layout model class.
*/
class Layout extends \Ilch\Model
{
/**
* Key of the layout.
*
* @var string
*/
protected $key;
/**
* Name of the layout.
*
* @var string
*/
protected $name;
/**
* Author of the layout.
*
* @var string
*/
protected $author;
/**
* Link of the layout.
*
* @var string
*/
protected $link;
/**
* Description of the layout.
*
* @var string
*/
protected $desc;
/**
* Module of the layout.
*
* @var string
*/
protected $modulekey;
/**
* Gets the key.
*
* @return string
*/
public function getKey()
{
return $this->key;
}
/**
* Sets the key.
*
* @param string $key
*/
public function setKey($key)
{
$this->key = (string)$key;
}
/**
* Gets the name.
*
* @return string
*/
public function getName()
{
return $this->name;
}
/**
* Sets the name.
*
* @param string $key
*/
public function setName($name)
{
$this->name = (string)$name;
}
/**
* Gets the author.
*
* @return string
*/
public function getAuthor()
{
return $this->author;
}
/**
* Sets the author.
*
* @param string $author
*/
public function setAuthor($author)
{
$this->author = (string)$author;
}
/**
* Gets the link.
*
* @return string
*/
public function getLink()
{
return $this->link;
}
/**
* Sets the link.
*
* @param string $link
*/
public function setLink($link)
{
$this->link = (string)$link;
}
/**
* Gets the desc.
*
* @return string
*/
public function getDesc()
{
return $this->desc;
}
/**
* Sets the author.
*
* @param string $desc
*/
public function setDesc($desc)
{
$this->desc = (string)$desc;
}
/**
* Gets the modulekey.
*
* @return string
*/
public function getModulekey()
{
return $this->modulekey;
}
/**
* Sets the modulekey.
*
* @param string $modulekey
*/
public function setModulekey($modulekey)
{
$this->modulekey = (string)$modulekey;
}
}
| Java |
.NoInherit {
font-style: oblique;
opacity: 0.5;
}
.AccessTableHeading {
padding-top: 0.5em;
padding-bottom: 0.25em;
font-weight: bold;
}
.AccessTable th {
white-space: nowrap;
}
.AccessTable .GroupName {
width: 40%;
}
.AccessTable .Narrow {
width: 10%;
}
| Java |
#
#
# (C) Copyright 2001 The Internet (Aust) Pty Ltd
# ACN: 082 081 472 ABN: 83 082 081 472
# All Rights Reserved
#
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
# Author: Andrew Milton <akm@theinternet.com.au>
# $Id: Plugins.py,v 1.5 2004/11/10 14:15:33 akm Exp $
import App, Globals, OFS
import string
import time
from Globals import ImageFile, HTMLFile, HTML, MessageDialog, package_home
from OFS.Folder import Folder
class PluginRegister:
def __init__(self, name, description, pluginClass,
pluginStartForm, pluginStartMethod,
pluginEditForm=None, pluginEditMethod=None):
self.name=name #No Spaces please...
self.description=description
self.plugin=pluginClass
self.manage_addForm=pluginStartForm
self.manage_addMethod=pluginStartMethod
self.manage_editForm=pluginEditForm
self.manage_editMethod=pluginEditMethod
class CryptoPluginRegister:
def __init__(self, name, crypto, description, pluginMethod):
self.name = name #No Spaces please...
self.cryptoMethod = crypto
self.description = description
self.plugin = pluginMethod
| Java |
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<script src="js/jquery.min.js"></script>
<script type="text/javascript" src="js/js.cookie.js"></script>
<title>BenchmarkTest00199</title>
</head>
<body>
<form action="/benchmark/BenchmarkTest00199" method="POST" id="FormBenchmarkTest00199">
<div><label>Please explain your answer:</label></div>
<br/>
<div><textarea rows="4" cols="50" id="vectorArea" name="vectorArea"></textarea></div>
<div><label>Any additional note for the reviewer:</label></div>
<div><input type="text" id="answer" name="answer"></input></div>
<br/>
<div><label>An AJAX request will be sent with a header named vector and value:</label>
<input type="text" id="vector" name="vector" value="bar" class="safe"></input></div>
<div><input type="button" id="login-btn" value="Login" /></div>
</form>
<div id="ajax-form-msg1"><pre><code class="prettyprint" id="code"></code></pre></div>
<script>
$('.safe').keypress(function (e) {
if (e.which == 13) {
$('#login-btn').trigger('click');
return false;
}
});
$("#login-btn").click(function(){
var formData = $("#FormBenchmarkTest00199").serializeArray();
var URL = $("#FormBenchmarkTest00199").attr("action");
var text = $("#FormBenchmarkTest00199 input[id=vector]").val();
$.ajax({
url : URL,
headers: { 'vector': text },
type: "POST",
data : formData,
success: function(data, textStatus, jqXHR){
$("#code").text(data);
},
error: function (jqXHR, textStatus, errorThrown){ console.error(errorThrown);}
});
});
</script>
</body>
</html>
| Java |
/* BGP-4, BGP-4+ daemon program
Copyright (C) 1996, 97, 98, 99, 2000 Kunihiro Ishiguro
This file is part of GNU Kroute.
GNU Kroute is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2, or (at your option) any
later version.
GNU Kroute is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Kroute; see the file COPYING. If not, write to the Free
Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
02111-1307, USA. */
#include <kroute.h>
#include "prefix.h"
#include "thread.h"
#include "buffer.h"
#include "stream.h"
#include "command.h"
#include "sockunion.h"
#include "network.h"
#include "memory.h"
#include "filter.h"
#include "routemap.h"
#include "str.h"
#include "log.h"
#include "plist.h"
#include "linklist.h"
#include "workqueue.h"
#include "bgpd/bgpd.h"
#include "bgpd/bgp_table.h"
#include "bgpd/bgp_aspath.h"
#include "bgpd/bgp_route.h"
#include "bgpd/bgp_dump.h"
#include "bgpd/bgp_debug.h"
#include "bgpd/bgp_community.h"
#include "bgpd/bgp_attr.h"
#include "bgpd/bgp_regex.h"
#include "bgpd/bgp_clist.h"
#include "bgpd/bgp_fsm.h"
#include "bgpd/bgp_packet.h"
#include "bgpd/bgp_kroute.h"
#include "bgpd/bgp_open.h"
#include "bgpd/bgp_filter.h"
#include "bgpd/bgp_nexthop.h"
#include "bgpd/bgp_damp.h"
#include "bgpd/bgp_mplsvpn.h"
#include "bgpd/bgp_advertise.h"
#include "bgpd/bgp_network.h"
#include "bgpd/bgp_vty.h"
#include "bgpd/bgp_mpath.h"
#ifdef HAVE_SNMP
#include "bgpd/bgp_snmp.h"
#endif /* HAVE_SNMP */
/* BGP process wide configuration. */
static struct bgp_master bgp_master;
extern struct in_addr router_id_kroute;
/* BGP process wide configuration pointer to export. */
struct bgp_master *bm;
/* BGP community-list. */
struct community_list_handler *bgp_clist;
/* BGP global flag manipulation. */
int
bgp_option_set (int flag)
{
switch (flag)
{
case BGP_OPT_NO_FIB:
case BGP_OPT_MULTIPLE_INSTANCE:
case BGP_OPT_CONFIG_CISCO:
SET_FLAG (bm->options, flag);
break;
default:
return BGP_ERR_INVALID_FLAG;
}
return 0;
}
int
bgp_option_unset (int flag)
{
switch (flag)
{
case BGP_OPT_MULTIPLE_INSTANCE:
if (listcount (bm->bgp) > 1)
return BGP_ERR_MULTIPLE_INSTANCE_USED;
/* Fall through. */
case BGP_OPT_NO_FIB:
case BGP_OPT_CONFIG_CISCO:
UNSET_FLAG (bm->options, flag);
break;
default:
return BGP_ERR_INVALID_FLAG;
}
return 0;
}
int
bgp_option_check (int flag)
{
return CHECK_FLAG (bm->options, flag);
}
/* BGP flag manipulation. */
int
bgp_flag_set (struct bgp *bgp, int flag)
{
SET_FLAG (bgp->flags, flag);
return 0;
}
int
bgp_flag_unset (struct bgp *bgp, int flag)
{
UNSET_FLAG (bgp->flags, flag);
return 0;
}
int
bgp_flag_check (struct bgp *bgp, int flag)
{
return CHECK_FLAG (bgp->flags, flag);
}
/* Internal function to set BGP structure configureation flag. */
static void
bgp_config_set (struct bgp *bgp, int config)
{
SET_FLAG (bgp->config, config);
}
static void
bgp_config_unset (struct bgp *bgp, int config)
{
UNSET_FLAG (bgp->config, config);
}
static int
bgp_config_check (struct bgp *bgp, int config)
{
return CHECK_FLAG (bgp->config, config);
}
/* Set BGP router identifier. */
int
bgp_router_id_set (struct bgp *bgp, struct in_addr *id)
{
struct peer *peer;
struct listnode *node, *nnode;
if (bgp_config_check (bgp, BGP_CONFIG_ROUTER_ID)
&& IPV4_ADDR_SAME (&bgp->router_id, id))
return 0;
IPV4_ADDR_COPY (&bgp->router_id, id);
bgp_config_set (bgp, BGP_CONFIG_ROUTER_ID);
/* Set all peer's local identifier with this value. */
for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer))
{
IPV4_ADDR_COPY (&peer->local_id, id);
if (peer->status == Established)
{
peer->last_reset = PEER_DOWN_RID_CHANGE;
bgp_notify_send (peer, BGP_NOTIFY_CEASE,
BGP_NOTIFY_CEASE_CONFIG_CHANGE);
}
}
return 0;
}
/* BGP's cluster-id control. */
int
bgp_cluster_id_set (struct bgp *bgp, struct in_addr *cluster_id)
{
struct peer *peer;
struct listnode *node, *nnode;
if (bgp_config_check (bgp, BGP_CONFIG_CLUSTER_ID)
&& IPV4_ADDR_SAME (&bgp->cluster_id, cluster_id))
return 0;
IPV4_ADDR_COPY (&bgp->cluster_id, cluster_id);
bgp_config_set (bgp, BGP_CONFIG_CLUSTER_ID);
/* Clear all IBGP peer. */
for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer))
{
if (peer_sort (peer) != BGP_PEER_IBGP)
continue;
if (peer->status == Established)
{
peer->last_reset = PEER_DOWN_CLID_CHANGE;
bgp_notify_send (peer, BGP_NOTIFY_CEASE,
BGP_NOTIFY_CEASE_CONFIG_CHANGE);
}
}
return 0;
}
int
bgp_cluster_id_unset (struct bgp *bgp)
{
struct peer *peer;
struct listnode *node, *nnode;
if (! bgp_config_check (bgp, BGP_CONFIG_CLUSTER_ID))
return 0;
bgp->cluster_id.s_addr = 0;
bgp_config_unset (bgp, BGP_CONFIG_CLUSTER_ID);
/* Clear all IBGP peer. */
for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer))
{
if (peer_sort (peer) != BGP_PEER_IBGP)
continue;
if (peer->status == Established)
{
peer->last_reset = PEER_DOWN_CLID_CHANGE;
bgp_notify_send (peer, BGP_NOTIFY_CEASE,
BGP_NOTIFY_CEASE_CONFIG_CHANGE);
}
}
return 0;
}
/* time_t value that is monotonicly increasing
* and uneffected by adjustments to system clock
*/
time_t bgp_clock (void)
{
struct timeval tv;
bane_gettime(BANE_CLK_MONOTONIC, &tv);
return tv.tv_sec;
}
/* BGP timer configuration. */
int
bgp_timers_set (struct bgp *bgp, u_int32_t keepalive, u_int32_t holdtime)
{
bgp->default_keepalive = (keepalive < holdtime / 3
? keepalive : holdtime / 3);
bgp->default_holdtime = holdtime;
return 0;
}
int
bgp_timers_unset (struct bgp *bgp)
{
bgp->default_keepalive = BGP_DEFAULT_KEEPALIVE;
bgp->default_holdtime = BGP_DEFAULT_HOLDTIME;
return 0;
}
/* BGP confederation configuration. */
int
bgp_confederation_id_set (struct bgp *bgp, as_t as)
{
struct peer *peer;
struct listnode *node, *nnode;
int already_confed;
if (as == 0)
return BGP_ERR_INVALID_AS;
/* Remember - were we doing confederation before? */
already_confed = bgp_config_check (bgp, BGP_CONFIG_CONFEDERATION);
bgp->confed_id = as;
bgp_config_set (bgp, BGP_CONFIG_CONFEDERATION);
/* If we were doing confederation already, this is just an external
AS change. Just Reset EBGP sessions, not CONFED sessions. If we
were not doing confederation before, reset all EBGP sessions. */
for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer))
{
/* We're looking for peers who's AS is not local or part of our
confederation. */
if (already_confed)
{
if (peer_sort (peer) == BGP_PEER_EBGP)
{
peer->local_as = as;
if (peer->status == Established)
{
peer->last_reset = PEER_DOWN_CONFED_ID_CHANGE;
bgp_notify_send (peer, BGP_NOTIFY_CEASE,
BGP_NOTIFY_CEASE_CONFIG_CHANGE);
}
else
BGP_EVENT_ADD (peer, BGP_Stop);
}
}
else
{
/* Not doign confederation before, so reset every non-local
session */
if (peer_sort (peer) != BGP_PEER_IBGP)
{
/* Reset the local_as to be our EBGP one */
if (peer_sort (peer) == BGP_PEER_EBGP)
peer->local_as = as;
if (peer->status == Established)
{
peer->last_reset = PEER_DOWN_CONFED_ID_CHANGE;
bgp_notify_send (peer, BGP_NOTIFY_CEASE,
BGP_NOTIFY_CEASE_CONFIG_CHANGE);
}
else
BGP_EVENT_ADD (peer, BGP_Stop);
}
}
}
return 0;
}
int
bgp_confederation_id_unset (struct bgp *bgp)
{
struct peer *peer;
struct listnode *node, *nnode;
bgp->confed_id = 0;
bgp_config_unset (bgp, BGP_CONFIG_CONFEDERATION);
for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer))
{
/* We're looking for peers who's AS is not local */
if (peer_sort (peer) != BGP_PEER_IBGP)
{
peer->local_as = bgp->as;
if (peer->status == Established)
{
peer->last_reset = PEER_DOWN_CONFED_ID_CHANGE;
bgp_notify_send (peer, BGP_NOTIFY_CEASE,
BGP_NOTIFY_CEASE_CONFIG_CHANGE);
}
else
BGP_EVENT_ADD (peer, BGP_Stop);
}
}
return 0;
}
/* Is an AS part of the confed or not? */
int
bgp_confederation_peers_check (struct bgp *bgp, as_t as)
{
int i;
if (! bgp)
return 0;
for (i = 0; i < bgp->confed_peers_cnt; i++)
if (bgp->confed_peers[i] == as)
return 1;
return 0;
}
/* Add an AS to the confederation set. */
int
bgp_confederation_peers_add (struct bgp *bgp, as_t as)
{
struct peer *peer;
struct listnode *node, *nnode;
if (! bgp)
return BGP_ERR_INVALID_BGP;
if (bgp->as == as)
return BGP_ERR_INVALID_AS;
if (bgp_confederation_peers_check (bgp, as))
return -1;
if (bgp->confed_peers)
bgp->confed_peers = XREALLOC (MTYPE_BGP_CONFED_LIST,
bgp->confed_peers,
(bgp->confed_peers_cnt + 1) * sizeof (as_t));
else
bgp->confed_peers = XMALLOC (MTYPE_BGP_CONFED_LIST,
(bgp->confed_peers_cnt + 1) * sizeof (as_t));
bgp->confed_peers[bgp->confed_peers_cnt] = as;
bgp->confed_peers_cnt++;
if (bgp_config_check (bgp, BGP_CONFIG_CONFEDERATION))
{
for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer))
{
if (peer->as == as)
{
peer->local_as = bgp->as;
if (peer->status == Established)
{
peer->last_reset = PEER_DOWN_CONFED_PEER_CHANGE;
bgp_notify_send (peer, BGP_NOTIFY_CEASE,
BGP_NOTIFY_CEASE_CONFIG_CHANGE);
}
else
BGP_EVENT_ADD (peer, BGP_Stop);
}
}
}
return 0;
}
/* Delete an AS from the confederation set. */
int
bgp_confederation_peers_remove (struct bgp *bgp, as_t as)
{
int i;
int j;
struct peer *peer;
struct listnode *node, *nnode;
if (! bgp)
return -1;
if (! bgp_confederation_peers_check (bgp, as))
return -1;
for (i = 0; i < bgp->confed_peers_cnt; i++)
if (bgp->confed_peers[i] == as)
for(j = i + 1; j < bgp->confed_peers_cnt; j++)
bgp->confed_peers[j - 1] = bgp->confed_peers[j];
bgp->confed_peers_cnt--;
if (bgp->confed_peers_cnt == 0)
{
if (bgp->confed_peers)
XFREE (MTYPE_BGP_CONFED_LIST, bgp->confed_peers);
bgp->confed_peers = NULL;
}
else
bgp->confed_peers = XREALLOC (MTYPE_BGP_CONFED_LIST,
bgp->confed_peers,
bgp->confed_peers_cnt * sizeof (as_t));
/* Now reset any peer who's remote AS has just been removed from the
CONFED */
if (bgp_config_check (bgp, BGP_CONFIG_CONFEDERATION))
{
for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer))
{
if (peer->as == as)
{
peer->local_as = bgp->confed_id;
if (peer->status == Established)
{
peer->last_reset = PEER_DOWN_CONFED_PEER_CHANGE;
bgp_notify_send (peer, BGP_NOTIFY_CEASE,
BGP_NOTIFY_CEASE_CONFIG_CHANGE);
}
else
BGP_EVENT_ADD (peer, BGP_Stop);
}
}
}
return 0;
}
/* Local preference configuration. */
int
bgp_default_local_preference_set (struct bgp *bgp, u_int32_t local_pref)
{
if (! bgp)
return -1;
bgp->default_local_pref = local_pref;
return 0;
}
int
bgp_default_local_preference_unset (struct bgp *bgp)
{
if (! bgp)
return -1;
bgp->default_local_pref = BGP_DEFAULT_LOCAL_PREF;
return 0;
}
/* If peer is RSERVER_CLIENT in at least one address family and is not member
of a peer_group for that family, return 1.
Used to check wether the peer is included in list bgp->rsclient. */
int
peer_rsclient_active (struct peer *peer)
{
int i;
int j;
for (i=AFI_IP; i < AFI_MAX; i++)
for (j=SAFI_UNICAST; j < SAFI_MAX; j++)
if (CHECK_FLAG(peer->af_flags[i][j], PEER_FLAG_RSERVER_CLIENT)
&& ! peer->af_group[i][j])
return 1;
return 0;
}
/* Peer comparison function for sorting. */
static int
peer_cmp (struct peer *p1, struct peer *p2)
{
return sockunion_cmp (&p1->su, &p2->su);
}
int
peer_af_flag_check (struct peer *peer, afi_t afi, safi_t safi, u_int32_t flag)
{
return CHECK_FLAG (peer->af_flags[afi][safi], flag);
}
/* Reset all address family specific configuration. */
static void
peer_af_flag_reset (struct peer *peer, afi_t afi, safi_t safi)
{
int i;
struct bgp_filter *filter;
char orf_name[BUFSIZ];
filter = &peer->filter[afi][safi];
/* Clear neighbor filter and route-map */
for (i = FILTER_IN; i < FILTER_MAX; i++)
{
if (filter->dlist[i].name)
{
free (filter->dlist[i].name);
filter->dlist[i].name = NULL;
}
if (filter->plist[i].name)
{
free (filter->plist[i].name);
filter->plist[i].name = NULL;
}
if (filter->aslist[i].name)
{
free (filter->aslist[i].name);
filter->aslist[i].name = NULL;
}
}
for (i = RMAP_IN; i < RMAP_MAX; i++)
{
if (filter->map[i].name)
{
free (filter->map[i].name);
filter->map[i].name = NULL;
}
}
/* Clear unsuppress map. */
if (filter->usmap.name)
free (filter->usmap.name);
filter->usmap.name = NULL;
filter->usmap.map = NULL;
/* Clear neighbor's all address family flags. */
peer->af_flags[afi][safi] = 0;
/* Clear neighbor's all address family sflags. */
peer->af_sflags[afi][safi] = 0;
/* Clear neighbor's all address family capabilities. */
peer->af_cap[afi][safi] = 0;
/* Clear ORF info */
peer->orf_plist[afi][safi] = NULL;
sprintf (orf_name, "%s.%d.%d", peer->host, afi, safi);
prefix_bgp_orf_remove_all (orf_name);
/* Set default neighbor send-community. */
if (! bgp_option_check (BGP_OPT_CONFIG_CISCO))
{
SET_FLAG (peer->af_flags[afi][safi], PEER_FLAG_SEND_COMMUNITY);
SET_FLAG (peer->af_flags[afi][safi], PEER_FLAG_SEND_EXT_COMMUNITY);
}
/* Clear neighbor default_originate_rmap */
if (peer->default_rmap[afi][safi].name)
free (peer->default_rmap[afi][safi].name);
peer->default_rmap[afi][safi].name = NULL;
peer->default_rmap[afi][safi].map = NULL;
/* Clear neighbor maximum-prefix */
peer->pmax[afi][safi] = 0;
peer->pmax_threshold[afi][safi] = MAXIMUM_PREFIX_THRESHOLD_DEFAULT;
}
/* peer global config reset */
static void
peer_global_config_reset (struct peer *peer)
{
peer->weight = 0;
peer->change_local_as = 0;
peer->ttl = (peer_sort (peer) == BGP_PEER_IBGP ? 255 : 1);
if (peer->update_source)
{
sockunion_free (peer->update_source);
peer->update_source = NULL;
}
if (peer->update_if)
{
XFREE (MTYPE_PEER_UPDATE_SOURCE, peer->update_if);
peer->update_if = NULL;
}
if (peer_sort (peer) == BGP_PEER_IBGP)
peer->v_routeadv = BGP_DEFAULT_IBGP_ROUTEADV;
else
peer->v_routeadv = BGP_DEFAULT_EBGP_ROUTEADV;
peer->flags = 0;
peer->config = 0;
peer->holdtime = 0;
peer->keepalive = 0;
peer->connect = 0;
peer->v_connect = BGP_DEFAULT_CONNECT_RETRY;
}
/* Check peer's AS number and determin is this peer IBGP or EBGP */
int
peer_sort (struct peer *peer)
{
struct bgp *bgp;
bgp = peer->bgp;
/* Peer-group */
if (CHECK_FLAG (peer->sflags, PEER_STATUS_GROUP))
{
if (peer->as)
return (bgp->as == peer->as ? BGP_PEER_IBGP : BGP_PEER_EBGP);
else
{
struct peer *peer1;
peer1 = listnode_head (peer->group->peer);
if (peer1)
return (peer1->local_as == peer1->as
? BGP_PEER_IBGP : BGP_PEER_EBGP);
}
return BGP_PEER_INTERNAL;
}
/* Normal peer */
if (bgp && CHECK_FLAG (bgp->config, BGP_CONFIG_CONFEDERATION))
{
if (peer->local_as == 0)
return BGP_PEER_INTERNAL;
if (peer->local_as == peer->as)
{
if (peer->local_as == bgp->confed_id)
return BGP_PEER_EBGP;
else
return BGP_PEER_IBGP;
}
if (bgp_confederation_peers_check (bgp, peer->as))
return BGP_PEER_CONFED;
return BGP_PEER_EBGP;
}
else
{
return (peer->local_as == 0
? BGP_PEER_INTERNAL : peer->local_as == peer->as
? BGP_PEER_IBGP : BGP_PEER_EBGP);
}
}
static void
peer_free (struct peer *peer)
{
assert (peer->status == Deleted);
bgp_unlock(peer->bgp);
/* this /ought/ to have been done already through bgp_stop earlier,
* but just to be sure..
*/
bgp_timer_set (peer);
BGP_READ_OFF (peer->t_read);
BGP_WRITE_OFF (peer->t_write);
BGP_EVENT_FLUSH (peer);
if (peer->desc)
XFREE (MTYPE_PEER_DESC, peer->desc);
/* Free allocated host character. */
if (peer->host)
XFREE (MTYPE_BGP_PEER_HOST, peer->host);
/* Update source configuration. */
if (peer->update_source)
sockunion_free (peer->update_source);
if (peer->update_if)
XFREE (MTYPE_PEER_UPDATE_SOURCE, peer->update_if);
if (peer->clear_node_queue)
work_queue_free (peer->clear_node_queue);
bgp_sync_delete (peer);
memset (peer, 0, sizeof (struct peer));
XFREE (MTYPE_BGP_PEER, peer);
}
/* increase reference count on a struct peer */
struct peer *
peer_lock (struct peer *peer)
{
assert (peer && (peer->lock >= 0));
peer->lock++;
return peer;
}
/* decrease reference count on a struct peer
* struct peer is freed and NULL returned if last reference
*/
struct peer *
peer_unlock (struct peer *peer)
{
assert (peer && (peer->lock > 0));
peer->lock--;
if (peer->lock == 0)
{
#if 0
zlog_debug ("unlocked and freeing");
zlog_backtrace (LOG_DEBUG);
#endif
peer_free (peer);
return NULL;
}
#if 0
if (peer->lock == 1)
{
zlog_debug ("unlocked to 1");
zlog_backtrace (LOG_DEBUG);
}
#endif
return peer;
}
/* Allocate new peer object, implicitely locked. */
static struct peer *
peer_new (struct bgp *bgp)
{
afi_t afi;
safi_t safi;
struct peer *peer;
struct servent *sp;
/* bgp argument is absolutely required */
assert (bgp);
if (!bgp)
return NULL;
/* Allocate new peer. */
peer = XCALLOC (MTYPE_BGP_PEER, sizeof (struct peer));
/* Set default value. */
peer->fd = -1;
peer->v_start = BGP_INIT_START_TIMER;
peer->v_connect = BGP_DEFAULT_CONNECT_RETRY;
peer->v_asorig = BGP_DEFAULT_ASORIGINATE;
peer->status = Idle;
peer->ostatus = Idle;
peer->weight = 0;
peer->password = NULL;
peer->bgp = bgp;
peer = peer_lock (peer); /* initial reference */
bgp_lock (bgp);
/* Set default flags. */
for (afi = AFI_IP; afi < AFI_MAX; afi++)
for (safi = SAFI_UNICAST; safi < SAFI_MAX; safi++)
{
if (! bgp_option_check (BGP_OPT_CONFIG_CISCO))
{
SET_FLAG (peer->af_flags[afi][safi], PEER_FLAG_SEND_COMMUNITY);
SET_FLAG (peer->af_flags[afi][safi], PEER_FLAG_SEND_EXT_COMMUNITY);
}
peer->orf_plist[afi][safi] = NULL;
}
SET_FLAG (peer->sflags, PEER_STATUS_CAPABILITY_OPEN);
/* Create buffers. */
peer->ibuf = stream_new (BGP_MAX_PACKET_SIZE);
peer->obuf = stream_fifo_new ();
peer->work = stream_new (BGP_MAX_PACKET_SIZE);
bgp_sync_init (peer);
/* Get service port number. */
sp = getservbyname ("bgp", "tcp");
peer->port = (sp == NULL) ? BGP_PORT_DEFAULT : ntohs (sp->s_port);
return peer;
}
/* Create new BGP peer. */
static struct peer *
peer_create (union sockunion *su, struct bgp *bgp, as_t local_as,
as_t remote_as, afi_t afi, safi_t safi)
{
int active;
struct peer *peer;
char buf[SU_ADDRSTRLEN];
peer = peer_new (bgp);
peer->su = *su;
peer->local_as = local_as;
peer->as = remote_as;
peer->local_id = bgp->router_id;
peer->v_holdtime = bgp->default_holdtime;
peer->v_keepalive = bgp->default_keepalive;
if (peer_sort (peer) == BGP_PEER_IBGP)
peer->v_routeadv = BGP_DEFAULT_IBGP_ROUTEADV;
else
peer->v_routeadv = BGP_DEFAULT_EBGP_ROUTEADV;
peer = peer_lock (peer); /* bgp peer list reference */
listnode_add_sort (bgp->peer, peer);
active = peer_active (peer);
if (afi && safi)
peer->afc[afi][safi] = 1;
/* Last read and reset time set */
peer->readtime = peer->resettime = bgp_clock ();
/* Default TTL set. */
peer->ttl = (peer_sort (peer) == BGP_PEER_IBGP ? 255 : 1);
/* Make peer's address string. */
sockunion2str (su, buf, SU_ADDRSTRLEN);
peer->host = XSTRDUP (MTYPE_BGP_PEER_HOST, buf);
/* Set up peer's events and timers. */
if (! active && peer_active (peer))
bgp_timer_set (peer);
return peer;
}
/* Make accept BGP peer. Called from bgp_accept (). */
struct peer *
peer_create_accept (struct bgp *bgp)
{
struct peer *peer;
peer = peer_new (bgp);
peer = peer_lock (peer); /* bgp peer list reference */
listnode_add_sort (bgp->peer, peer);
return peer;
}
/* Change peer's AS number. */
static void
peer_as_change (struct peer *peer, as_t as)
{
int type;
/* Stop peer. */
if (! CHECK_FLAG (peer->sflags, PEER_STATUS_GROUP))
{
if (peer->status == Established)
{
peer->last_reset = PEER_DOWN_REMOTE_AS_CHANGE;
bgp_notify_send (peer, BGP_NOTIFY_CEASE,
BGP_NOTIFY_CEASE_CONFIG_CHANGE);
}
else
BGP_EVENT_ADD (peer, BGP_Stop);
}
type = peer_sort (peer);
peer->as = as;
if (bgp_config_check (peer->bgp, BGP_CONFIG_CONFEDERATION)
&& ! bgp_confederation_peers_check (peer->bgp, as)
&& peer->bgp->as != as)
peer->local_as = peer->bgp->confed_id;
else
peer->local_as = peer->bgp->as;
/* Advertisement-interval reset */
if (peer_sort (peer) == BGP_PEER_IBGP)
peer->v_routeadv = BGP_DEFAULT_IBGP_ROUTEADV;
else
peer->v_routeadv = BGP_DEFAULT_EBGP_ROUTEADV;
/* TTL reset */
if (peer_sort (peer) == BGP_PEER_IBGP)
peer->ttl = 255;
else if (type == BGP_PEER_IBGP)
peer->ttl = 1;
/* reflector-client reset */
if (peer_sort (peer) != BGP_PEER_IBGP)
{
UNSET_FLAG (peer->af_flags[AFI_IP][SAFI_UNICAST],
PEER_FLAG_REFLECTOR_CLIENT);
UNSET_FLAG (peer->af_flags[AFI_IP][SAFI_MULTICAST],
PEER_FLAG_REFLECTOR_CLIENT);
UNSET_FLAG (peer->af_flags[AFI_IP][SAFI_MPLS_VPN],
PEER_FLAG_REFLECTOR_CLIENT);
UNSET_FLAG (peer->af_flags[AFI_IP6][SAFI_UNICAST],
PEER_FLAG_REFLECTOR_CLIENT);
UNSET_FLAG (peer->af_flags[AFI_IP6][SAFI_MULTICAST],
PEER_FLAG_REFLECTOR_CLIENT);
}
/* local-as reset */
if (peer_sort (peer) != BGP_PEER_EBGP)
{
peer->change_local_as = 0;
UNSET_FLAG (peer->flags, PEER_FLAG_LOCAL_AS_NO_PREPEND);
}
}
/* If peer does not exist, create new one. If peer already exists,
set AS number to the peer. */
int
peer_remote_as (struct bgp *bgp, union sockunion *su, as_t *as,
afi_t afi, safi_t safi)
{
struct peer *peer;
as_t local_as;
peer = peer_lookup (bgp, su);
if (peer)
{
/* When this peer is a member of peer-group. */
if (peer->group)
{
if (peer->group->conf->as)
{
/* Return peer group's AS number. */
*as = peer->group->conf->as;
return BGP_ERR_PEER_GROUP_MEMBER;
}
if (peer_sort (peer->group->conf) == BGP_PEER_IBGP)
{
if (bgp->as != *as)
{
*as = peer->as;
return BGP_ERR_PEER_GROUP_PEER_TYPE_DIFFERENT;
}
}
else
{
if (bgp->as == *as)
{
*as = peer->as;
return BGP_ERR_PEER_GROUP_PEER_TYPE_DIFFERENT;
}
}
}
/* Existing peer's AS number change. */
if (peer->as != *as)
peer_as_change (peer, *as);
}
else
{
/* If the peer is not part of our confederation, and its not an
iBGP peer then spoof the source AS */
if (bgp_config_check (bgp, BGP_CONFIG_CONFEDERATION)
&& ! bgp_confederation_peers_check (bgp, *as)
&& bgp->as != *as)
local_as = bgp->confed_id;
else
local_as = bgp->as;
/* If this is IPv4 unicast configuration and "no bgp default
ipv4-unicast" is specified. */
if (bgp_flag_check (bgp, BGP_FLAG_NO_DEFAULT_IPV4)
&& afi == AFI_IP && safi == SAFI_UNICAST)
peer = peer_create (su, bgp, local_as, *as, 0, 0);
else
peer = peer_create (su, bgp, local_as, *as, afi, safi);
}
return 0;
}
/* Activate the peer or peer group for specified AFI and SAFI. */
int
peer_activate (struct peer *peer, afi_t afi, safi_t safi)
{
int active;
if (peer->afc[afi][safi])
return 0;
/* Activate the address family configuration. */
if (CHECK_FLAG (peer->sflags, PEER_STATUS_GROUP))
peer->afc[afi][safi] = 1;
else
{
active = peer_active (peer);
peer->afc[afi][safi] = 1;
if (! active && peer_active (peer))
bgp_timer_set (peer);
else
{
if (peer->status == Established)
{
if (CHECK_FLAG (peer->cap, PEER_CAP_DYNAMIC_RCV))
{
peer->afc_adv[afi][safi] = 1;
bgp_capability_send (peer, afi, safi,
CAPABILITY_CODE_MP,
CAPABILITY_ACTION_SET);
if (peer->afc_recv[afi][safi])
{
peer->afc_nego[afi][safi] = 1;
bgp_announce_route (peer, afi, safi);
}
}
else
{
peer->last_reset = PEER_DOWN_AF_ACTIVATE;
bgp_notify_send (peer, BGP_NOTIFY_CEASE,
BGP_NOTIFY_CEASE_CONFIG_CHANGE);
}
}
}
}
return 0;
}
int
peer_deactivate (struct peer *peer, afi_t afi, safi_t safi)
{
struct peer_group *group;
struct peer *peer1;
struct listnode *node, *nnode;
if (CHECK_FLAG (peer->sflags, PEER_STATUS_GROUP))
{
group = peer->group;
for (ALL_LIST_ELEMENTS (group->peer, node, nnode, peer1))
{
if (peer1->af_group[afi][safi])
return BGP_ERR_PEER_GROUP_MEMBER_EXISTS;
}
}
else
{
if (peer->af_group[afi][safi])
return BGP_ERR_PEER_BELONGS_TO_GROUP;
}
if (! peer->afc[afi][safi])
return 0;
/* De-activate the address family configuration. */
peer->afc[afi][safi] = 0;
peer_af_flag_reset (peer, afi, safi);
if (! CHECK_FLAG (peer->sflags, PEER_STATUS_GROUP))
{
if (peer->status == Established)
{
if (CHECK_FLAG (peer->cap, PEER_CAP_DYNAMIC_RCV))
{
peer->afc_adv[afi][safi] = 0;
peer->afc_nego[afi][safi] = 0;
if (peer_active_nego (peer))
{
bgp_capability_send (peer, afi, safi,
CAPABILITY_CODE_MP,
CAPABILITY_ACTION_UNSET);
bgp_clear_route (peer, afi, safi, BGP_CLEAR_ROUTE_NORMAL);
peer->pcount[afi][safi] = 0;
}
else
{
peer->last_reset = PEER_DOWN_NEIGHBOR_DELETE;
bgp_notify_send (peer, BGP_NOTIFY_CEASE,
BGP_NOTIFY_CEASE_CONFIG_CHANGE);
}
}
else
{
peer->last_reset = PEER_DOWN_NEIGHBOR_DELETE;
bgp_notify_send (peer, BGP_NOTIFY_CEASE,
BGP_NOTIFY_CEASE_CONFIG_CHANGE);
}
}
}
return 0;
}
static void
peer_nsf_stop (struct peer *peer)
{
afi_t afi;
safi_t safi;
UNSET_FLAG (peer->sflags, PEER_STATUS_NSF_WAIT);
UNSET_FLAG (peer->sflags, PEER_STATUS_NSF_MODE);
for (afi = AFI_IP ; afi < AFI_MAX ; afi++)
for (safi = SAFI_UNICAST ; safi < SAFI_RESERVED_3 ; safi++)
peer->nsf[afi][safi] = 0;
if (peer->t_gr_restart)
{
BGP_TIMER_OFF (peer->t_gr_restart);
if (BGP_DEBUG (events, EVENTS))
zlog_debug ("%s graceful restart timer stopped", peer->host);
}
if (peer->t_gr_stale)
{
BGP_TIMER_OFF (peer->t_gr_stale);
if (BGP_DEBUG (events, EVENTS))
zlog_debug ("%s graceful restart stalepath timer stopped", peer->host);
}
bgp_clear_route_all (peer);
}
/* Delete peer from confguration.
*
* The peer is moved to a dead-end "Deleted" neighbour-state, to allow
* it to "cool off" and refcounts to hit 0, at which state it is freed.
*
* This function /should/ take care to be idempotent, to guard against
* it being called multiple times through stray events that come in
* that happen to result in this function being called again. That
* said, getting here for a "Deleted" peer is a bug in the neighbour
* FSM.
*/
int
peer_delete (struct peer *peer)
{
int i;
afi_t afi;
safi_t safi;
struct bgp *bgp;
struct bgp_filter *filter;
struct listnode *pn;
assert (peer->status != Deleted);
bgp = peer->bgp;
if (CHECK_FLAG (peer->sflags, PEER_STATUS_NSF_WAIT))
peer_nsf_stop (peer);
/* If this peer belongs to peer group, clear up the
relationship. */
if (peer->group)
{
if ((pn = listnode_lookup (peer->group->peer, peer)))
{
peer = peer_unlock (peer); /* group->peer list reference */
list_delete_node (peer->group->peer, pn);
}
peer->group = NULL;
}
/* Withdraw all information from routing table. We can not use
* BGP_EVENT_ADD (peer, BGP_Stop) at here. Because the event is
* executed after peer structure is deleted.
*/
peer->last_reset = PEER_DOWN_NEIGHBOR_DELETE;
bgp_stop (peer);
bgp_fsm_change_status (peer, Deleted);
/* Password configuration */
if (peer->password)
{
XFREE (MTYPE_PEER_PASSWORD, peer->password);
peer->password = NULL;
if (! CHECK_FLAG (peer->sflags, PEER_STATUS_GROUP))
bgp_md5_set (peer);
}
bgp_timer_set (peer); /* stops all timers for Deleted */
/* Delete from all peer list. */
if (! CHECK_FLAG (peer->sflags, PEER_STATUS_GROUP)
&& (pn = listnode_lookup (bgp->peer, peer)))
{
peer_unlock (peer); /* bgp peer list reference */
list_delete_node (bgp->peer, pn);
}
if (peer_rsclient_active (peer)
&& (pn = listnode_lookup (bgp->rsclient, peer)))
{
peer_unlock (peer); /* rsclient list reference */
list_delete_node (bgp->rsclient, pn);
/* Clear our own rsclient ribs. */
for (afi = AFI_IP; afi < AFI_MAX; afi++)
for (safi = SAFI_UNICAST; safi < SAFI_MAX; safi++)
if (CHECK_FLAG(peer->af_flags[afi][safi],
PEER_FLAG_RSERVER_CLIENT))
bgp_clear_route (peer, afi, safi, BGP_CLEAR_ROUTE_MY_RSCLIENT);
}
/* Free RIB for any family in which peer is RSERVER_CLIENT, and is not
member of a peer_group. */
for (afi = AFI_IP; afi < AFI_MAX; afi++)
for (safi = SAFI_UNICAST; safi < SAFI_MAX; safi++)
if (peer->rib[afi][safi] && ! peer->af_group[afi][safi])
bgp_table_finish (&peer->rib[afi][safi]);
/* Buffers. */
if (peer->ibuf)
stream_free (peer->ibuf);
if (peer->obuf)
stream_fifo_free (peer->obuf);
if (peer->work)
stream_free (peer->work);
peer->obuf = NULL;
peer->work = peer->ibuf = NULL;
/* Local and remote addresses. */
if (peer->su_local)
sockunion_free (peer->su_local);
if (peer->su_remote)
sockunion_free (peer->su_remote);
peer->su_local = peer->su_remote = NULL;
/* Free filter related memory. */
for (afi = AFI_IP; afi < AFI_MAX; afi++)
for (safi = SAFI_UNICAST; safi < SAFI_MAX; safi++)
{
filter = &peer->filter[afi][safi];
for (i = FILTER_IN; i < FILTER_MAX; i++)
{
if (filter->dlist[i].name)
free (filter->dlist[i].name);
if (filter->plist[i].name)
free (filter->plist[i].name);
if (filter->aslist[i].name)
free (filter->aslist[i].name);
filter->dlist[i].name = NULL;
filter->plist[i].name = NULL;
filter->aslist[i].name = NULL;
}
for (i = RMAP_IN; i < RMAP_MAX; i++)
{
if (filter->map[i].name)
free (filter->map[i].name);
filter->map[i].name = NULL;
}
if (filter->usmap.name)
free (filter->usmap.name);
if (peer->default_rmap[afi][safi].name)
free (peer->default_rmap[afi][safi].name);
filter->usmap.name = NULL;
peer->default_rmap[afi][safi].name = NULL;
}
peer_unlock (peer); /* initial reference */
return 0;
}
static int
peer_group_cmp (struct peer_group *g1, struct peer_group *g2)
{
return strcmp (g1->name, g2->name);
}
/* If peer is configured at least one address family return 1. */
static int
peer_group_active (struct peer *peer)
{
if (peer->af_group[AFI_IP][SAFI_UNICAST]
|| peer->af_group[AFI_IP][SAFI_MULTICAST]
|| peer->af_group[AFI_IP][SAFI_MPLS_VPN]
|| peer->af_group[AFI_IP6][SAFI_UNICAST]
|| peer->af_group[AFI_IP6][SAFI_MULTICAST])
return 1;
return 0;
}
/* Peer group cofiguration. */
static struct peer_group *
peer_group_new (void)
{
return (struct peer_group *) XCALLOC (MTYPE_PEER_GROUP,
sizeof (struct peer_group));
}
static void
peer_group_free (struct peer_group *group)
{
XFREE (MTYPE_PEER_GROUP, group);
}
struct peer_group *
peer_group_lookup (struct bgp *bgp, const char *name)
{
struct peer_group *group;
struct listnode *node, *nnode;
for (ALL_LIST_ELEMENTS (bgp->group, node, nnode, group))
{
if (strcmp (group->name, name) == 0)
return group;
}
return NULL;
}
struct peer_group *
peer_group_get (struct bgp *bgp, const char *name)
{
struct peer_group *group;
group = peer_group_lookup (bgp, name);
if (group)
return group;
group = peer_group_new ();
group->bgp = bgp;
group->name = strdup (name);
group->peer = list_new ();
group->conf = peer_new (bgp);
if (! bgp_flag_check (bgp, BGP_FLAG_NO_DEFAULT_IPV4))
group->conf->afc[AFI_IP][SAFI_UNICAST] = 1;
group->conf->host = XSTRDUP (MTYPE_BGP_PEER_HOST, name);
group->conf->group = group;
group->conf->as = 0;
group->conf->ttl = 1;
group->conf->gtsm_hops = 0;
group->conf->v_routeadv = BGP_DEFAULT_EBGP_ROUTEADV;
UNSET_FLAG (group->conf->config, PEER_CONFIG_TIMER);
UNSET_FLAG (group->conf->config, PEER_CONFIG_CONNECT);
group->conf->keepalive = 0;
group->conf->holdtime = 0;
group->conf->connect = 0;
SET_FLAG (group->conf->sflags, PEER_STATUS_GROUP);
listnode_add_sort (bgp->group, group);
return 0;
}
static void
peer_group2peer_config_copy (struct peer_group *group, struct peer *peer,
afi_t afi, safi_t safi)
{
int in = FILTER_IN;
int out = FILTER_OUT;
struct peer *conf;
struct bgp_filter *pfilter;
struct bgp_filter *gfilter;
conf = group->conf;
pfilter = &peer->filter[afi][safi];
gfilter = &conf->filter[afi][safi];
/* remote-as */
if (conf->as)
peer->as = conf->as;
/* remote-as */
if (conf->change_local_as)
peer->change_local_as = conf->change_local_as;
/* TTL */
peer->ttl = conf->ttl;
/* GTSM hops */
peer->gtsm_hops = conf->gtsm_hops;
/* Weight */
peer->weight = conf->weight;
/* peer flags apply */
peer->flags = conf->flags;
/* peer af_flags apply */
peer->af_flags[afi][safi] = conf->af_flags[afi][safi];
/* peer config apply */
peer->config = conf->config;
/* peer timers apply */
peer->holdtime = conf->holdtime;
peer->keepalive = conf->keepalive;
peer->connect = conf->connect;
if (CHECK_FLAG (conf->config, PEER_CONFIG_CONNECT))
peer->v_connect = conf->connect;
else
peer->v_connect = BGP_DEFAULT_CONNECT_RETRY;
/* advertisement-interval reset */
if (peer_sort (peer) == BGP_PEER_IBGP)
peer->v_routeadv = BGP_DEFAULT_IBGP_ROUTEADV;
else
peer->v_routeadv = BGP_DEFAULT_EBGP_ROUTEADV;
/* password apply */
if (peer->password)
XFREE (MTYPE_PEER_PASSWORD, peer->password);
if (conf->password)
peer->password = XSTRDUP (MTYPE_PEER_PASSWORD, conf->password);
else
peer->password = NULL;
bgp_md5_set (peer);
/* maximum-prefix */
peer->pmax[afi][safi] = conf->pmax[afi][safi];
peer->pmax_threshold[afi][safi] = conf->pmax_threshold[afi][safi];
peer->pmax_restart[afi][safi] = conf->pmax_restart[afi][safi];
/* allowas-in */
peer->allowas_in[afi][safi] = conf->allowas_in[afi][safi];
/* route-server-client */
if (CHECK_FLAG(conf->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT))
{
/* Make peer's RIB point to group's RIB. */
peer->rib[afi][safi] = group->conf->rib[afi][safi];
/* Import policy. */
if (pfilter->map[RMAP_IMPORT].name)
free (pfilter->map[RMAP_IMPORT].name);
if (gfilter->map[RMAP_IMPORT].name)
{
pfilter->map[RMAP_IMPORT].name = strdup (gfilter->map[RMAP_IMPORT].name);
pfilter->map[RMAP_IMPORT].map = gfilter->map[RMAP_IMPORT].map;
}
else
{
pfilter->map[RMAP_IMPORT].name = NULL;
pfilter->map[RMAP_IMPORT].map = NULL;
}
/* Export policy. */
if (gfilter->map[RMAP_EXPORT].name && ! pfilter->map[RMAP_EXPORT].name)
{
pfilter->map[RMAP_EXPORT].name = strdup (gfilter->map[RMAP_EXPORT].name);
pfilter->map[RMAP_EXPORT].map = gfilter->map[RMAP_EXPORT].map;
}
}
/* default-originate route-map */
if (conf->default_rmap[afi][safi].name)
{
if (peer->default_rmap[afi][safi].name)
free (peer->default_rmap[afi][safi].name);
peer->default_rmap[afi][safi].name = strdup (conf->default_rmap[afi][safi].name);
peer->default_rmap[afi][safi].map = conf->default_rmap[afi][safi].map;
}
/* update-source apply */
if (conf->update_source)
{
if (peer->update_source)
sockunion_free (peer->update_source);
if (peer->update_if)
{
XFREE (MTYPE_PEER_UPDATE_SOURCE, peer->update_if);
peer->update_if = NULL;
}
peer->update_source = sockunion_dup (conf->update_source);
}
else if (conf->update_if)
{
if (peer->update_if)
XFREE (MTYPE_PEER_UPDATE_SOURCE, peer->update_if);
if (peer->update_source)
{
sockunion_free (peer->update_source);
peer->update_source = NULL;
}
peer->update_if = XSTRDUP (MTYPE_PEER_UPDATE_SOURCE, conf->update_if);
}
/* inbound filter apply */
if (gfilter->dlist[in].name && ! pfilter->dlist[in].name)
{
if (pfilter->dlist[in].name)
free (pfilter->dlist[in].name);
pfilter->dlist[in].name = strdup (gfilter->dlist[in].name);
pfilter->dlist[in].alist = gfilter->dlist[in].alist;
}
if (gfilter->plist[in].name && ! pfilter->plist[in].name)
{
if (pfilter->plist[in].name)
free (pfilter->plist[in].name);
pfilter->plist[in].name = strdup (gfilter->plist[in].name);
pfilter->plist[in].plist = gfilter->plist[in].plist;
}
if (gfilter->aslist[in].name && ! pfilter->aslist[in].name)
{
if (pfilter->aslist[in].name)
free (pfilter->aslist[in].name);
pfilter->aslist[in].name = strdup (gfilter->aslist[in].name);
pfilter->aslist[in].aslist = gfilter->aslist[in].aslist;
}
if (gfilter->map[RMAP_IN].name && ! pfilter->map[RMAP_IN].name)
{
if (pfilter->map[RMAP_IN].name)
free (pfilter->map[RMAP_IN].name);
pfilter->map[RMAP_IN].name = strdup (gfilter->map[RMAP_IN].name);
pfilter->map[RMAP_IN].map = gfilter->map[RMAP_IN].map;
}
/* outbound filter apply */
if (gfilter->dlist[out].name)
{
if (pfilter->dlist[out].name)
free (pfilter->dlist[out].name);
pfilter->dlist[out].name = strdup (gfilter->dlist[out].name);
pfilter->dlist[out].alist = gfilter->dlist[out].alist;
}
else
{
if (pfilter->dlist[out].name)
free (pfilter->dlist[out].name);
pfilter->dlist[out].name = NULL;
pfilter->dlist[out].alist = NULL;
}
if (gfilter->plist[out].name)
{
if (pfilter->plist[out].name)
free (pfilter->plist[out].name);
pfilter->plist[out].name = strdup (gfilter->plist[out].name);
pfilter->plist[out].plist = gfilter->plist[out].plist;
}
else
{
if (pfilter->plist[out].name)
free (pfilter->plist[out].name);
pfilter->plist[out].name = NULL;
pfilter->plist[out].plist = NULL;
}
if (gfilter->aslist[out].name)
{
if (pfilter->aslist[out].name)
free (pfilter->aslist[out].name);
pfilter->aslist[out].name = strdup (gfilter->aslist[out].name);
pfilter->aslist[out].aslist = gfilter->aslist[out].aslist;
}
else
{
if (pfilter->aslist[out].name)
free (pfilter->aslist[out].name);
pfilter->aslist[out].name = NULL;
pfilter->aslist[out].aslist = NULL;
}
if (gfilter->map[RMAP_OUT].name)
{
if (pfilter->map[RMAP_OUT].name)
free (pfilter->map[RMAP_OUT].name);
pfilter->map[RMAP_OUT].name = strdup (gfilter->map[RMAP_OUT].name);
pfilter->map[RMAP_OUT].map = gfilter->map[RMAP_OUT].map;
}
else
{
if (pfilter->map[RMAP_OUT].name)
free (pfilter->map[RMAP_OUT].name);
pfilter->map[RMAP_OUT].name = NULL;
pfilter->map[RMAP_OUT].map = NULL;
}
/* RS-client's import/export route-maps. */
if (gfilter->map[RMAP_IMPORT].name)
{
if (pfilter->map[RMAP_IMPORT].name)
free (pfilter->map[RMAP_IMPORT].name);
pfilter->map[RMAP_IMPORT].name = strdup (gfilter->map[RMAP_IMPORT].name);
pfilter->map[RMAP_IMPORT].map = gfilter->map[RMAP_IMPORT].map;
}
else
{
if (pfilter->map[RMAP_IMPORT].name)
free (pfilter->map[RMAP_IMPORT].name);
pfilter->map[RMAP_IMPORT].name = NULL;
pfilter->map[RMAP_IMPORT].map = NULL;
}
if (gfilter->map[RMAP_EXPORT].name && ! pfilter->map[RMAP_EXPORT].name)
{
if (pfilter->map[RMAP_EXPORT].name)
free (pfilter->map[RMAP_EXPORT].name);
pfilter->map[RMAP_EXPORT].name = strdup (gfilter->map[RMAP_EXPORT].name);
pfilter->map[RMAP_EXPORT].map = gfilter->map[RMAP_EXPORT].map;
}
if (gfilter->usmap.name)
{
if (pfilter->usmap.name)
free (pfilter->usmap.name);
pfilter->usmap.name = strdup (gfilter->usmap.name);
pfilter->usmap.map = gfilter->usmap.map;
}
else
{
if (pfilter->usmap.name)
free (pfilter->usmap.name);
pfilter->usmap.name = NULL;
pfilter->usmap.map = NULL;
}
}
/* Peer group's remote AS configuration. */
int
peer_group_remote_as (struct bgp *bgp, const char *group_name, as_t *as)
{
struct peer_group *group;
struct peer *peer;
struct listnode *node, *nnode;
group = peer_group_lookup (bgp, group_name);
if (! group)
return -1;
if (group->conf->as == *as)
return 0;
/* When we setup peer-group AS number all peer group member's AS
number must be updated to same number. */
peer_as_change (group->conf, *as);
for (ALL_LIST_ELEMENTS (group->peer, node, nnode, peer))
{
if (peer->as != *as)
peer_as_change (peer, *as);
}
return 0;
}
int
peer_group_delete (struct peer_group *group)
{
struct bgp *bgp;
struct peer *peer;
struct listnode *node, *nnode;
bgp = group->bgp;
for (ALL_LIST_ELEMENTS (group->peer, node, nnode, peer))
{
peer->group = NULL;
peer_delete (peer);
}
list_delete (group->peer);
free (group->name);
group->name = NULL;
group->conf->group = NULL;
peer_delete (group->conf);
/* Delete from all peer_group list. */
listnode_delete (bgp->group, group);
peer_group_free (group);
return 0;
}
int
peer_group_remote_as_delete (struct peer_group *group)
{
struct peer *peer;
struct listnode *node, *nnode;
if (! group->conf->as)
return 0;
for (ALL_LIST_ELEMENTS (group->peer, node, nnode, peer))
{
peer->group = NULL;
peer_delete (peer);
}
list_delete_all_node (group->peer);
group->conf->as = 0;
return 0;
}
/* Bind specified peer to peer group. */
int
peer_group_bind (struct bgp *bgp, union sockunion *su,
struct peer_group *group, afi_t afi, safi_t safi, as_t *as)
{
struct peer *peer;
int first_member = 0;
/* Check peer group's address family. */
if (! group->conf->afc[afi][safi])
return BGP_ERR_PEER_GROUP_AF_UNCONFIGURED;
/* Lookup the peer. */
peer = peer_lookup (bgp, su);
/* Create a new peer. */
if (! peer)
{
if (! group->conf->as)
return BGP_ERR_PEER_GROUP_NO_REMOTE_AS;
peer = peer_create (su, bgp, bgp->as, group->conf->as, afi, safi);
peer->group = group;
peer->af_group[afi][safi] = 1;
peer = peer_lock (peer); /* group->peer list reference */
listnode_add (group->peer, peer);
peer_group2peer_config_copy (group, peer, afi, safi);
return 0;
}
/* When the peer already belongs to peer group, check the consistency. */
if (peer->af_group[afi][safi])
{
if (strcmp (peer->group->name, group->name) != 0)
return BGP_ERR_PEER_GROUP_CANT_CHANGE;
return 0;
}
/* Check current peer group configuration. */
if (peer_group_active (peer)
&& strcmp (peer->group->name, group->name) != 0)
return BGP_ERR_PEER_GROUP_MISMATCH;
if (! group->conf->as)
{
if (peer_sort (group->conf) != BGP_PEER_INTERNAL
&& peer_sort (group->conf) != peer_sort (peer))
{
if (as)
*as = peer->as;
return BGP_ERR_PEER_GROUP_PEER_TYPE_DIFFERENT;
}
if (peer_sort (group->conf) == BGP_PEER_INTERNAL)
first_member = 1;
}
peer->af_group[afi][safi] = 1;
peer->afc[afi][safi] = 1;
if (! peer->group)
{
peer->group = group;
peer = peer_lock (peer); /* group->peer list reference */
listnode_add (group->peer, peer);
}
else
assert (group && peer->group == group);
if (first_member)
{
/* Advertisement-interval reset */
if (peer_sort (group->conf) == BGP_PEER_IBGP)
group->conf->v_routeadv = BGP_DEFAULT_IBGP_ROUTEADV;
else
group->conf->v_routeadv = BGP_DEFAULT_EBGP_ROUTEADV;
/* ebgp-multihop reset */
if (peer_sort (group->conf) == BGP_PEER_IBGP)
group->conf->ttl = 255;
/* local-as reset */
if (peer_sort (group->conf) != BGP_PEER_EBGP)
{
group->conf->change_local_as = 0;
UNSET_FLAG (peer->flags, PEER_FLAG_LOCAL_AS_NO_PREPEND);
}
}
if (CHECK_FLAG(peer->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT))
{
struct listnode *pn;
/* If it's not configured as RSERVER_CLIENT in any other address
family, without being member of a peer_group, remove it from
list bgp->rsclient.*/
if (! peer_rsclient_active (peer)
&& (pn = listnode_lookup (bgp->rsclient, peer)))
{
peer_unlock (peer); /* peer rsclient reference */
list_delete_node (bgp->rsclient, pn);
/* Clear our own rsclient rib for this afi/safi. */
bgp_clear_route (peer, afi, safi, BGP_CLEAR_ROUTE_MY_RSCLIENT);
}
bgp_table_finish (&peer->rib[afi][safi]);
/* Import policy. */
if (peer->filter[afi][safi].map[RMAP_IMPORT].name)
{
free (peer->filter[afi][safi].map[RMAP_IMPORT].name);
peer->filter[afi][safi].map[RMAP_IMPORT].name = NULL;
peer->filter[afi][safi].map[RMAP_IMPORT].map = NULL;
}
/* Export policy. */
if (! CHECK_FLAG(group->conf->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT)
&& peer->filter[afi][safi].map[RMAP_EXPORT].name)
{
free (peer->filter[afi][safi].map[RMAP_EXPORT].name);
peer->filter[afi][safi].map[RMAP_EXPORT].name = NULL;
peer->filter[afi][safi].map[RMAP_EXPORT].map = NULL;
}
}
peer_group2peer_config_copy (group, peer, afi, safi);
if (peer->status == Established)
{
peer->last_reset = PEER_DOWN_RMAP_BIND;
bgp_notify_send (peer, BGP_NOTIFY_CEASE,
BGP_NOTIFY_CEASE_CONFIG_CHANGE);
}
else
BGP_EVENT_ADD (peer, BGP_Stop);
return 0;
}
int
peer_group_unbind (struct bgp *bgp, struct peer *peer,
struct peer_group *group, afi_t afi, safi_t safi)
{
if (! peer->af_group[afi][safi])
return 0;
if (group != peer->group)
return BGP_ERR_PEER_GROUP_MISMATCH;
peer->af_group[afi][safi] = 0;
peer->afc[afi][safi] = 0;
peer_af_flag_reset (peer, afi, safi);
if (peer->rib[afi][safi])
peer->rib[afi][safi] = NULL;
if (! peer_group_active (peer))
{
assert (listnode_lookup (group->peer, peer));
peer_unlock (peer); /* peer group list reference */
listnode_delete (group->peer, peer);
peer->group = NULL;
if (group->conf->as)
{
peer_delete (peer);
return 0;
}
peer_global_config_reset (peer);
}
if (peer->status == Established)
{
peer->last_reset = PEER_DOWN_RMAP_UNBIND;
bgp_notify_send (peer, BGP_NOTIFY_CEASE,
BGP_NOTIFY_CEASE_CONFIG_CHANGE);
}
else
BGP_EVENT_ADD (peer, BGP_Stop);
return 0;
}
/* BGP instance creation by `router bgp' commands. */
static struct bgp *
bgp_create (as_t *as, const char *name)
{
struct bgp *bgp;
afi_t afi;
safi_t safi;
if ( (bgp = XCALLOC (MTYPE_BGP, sizeof (struct bgp))) == NULL)
return NULL;
bgp_lock (bgp);
bgp->peer_self = peer_new (bgp);
bgp->peer_self->host = XSTRDUP (MTYPE_BGP_PEER_HOST, "Static announcement");
bgp->peer = list_new ();
bgp->peer->cmp = (int (*)(void *, void *)) peer_cmp;
bgp->group = list_new ();
bgp->group->cmp = (int (*)(void *, void *)) peer_group_cmp;
bgp->rsclient = list_new ();
bgp->rsclient->cmp = (int (*)(void*, void*)) peer_cmp;
for (afi = AFI_IP; afi < AFI_MAX; afi++)
for (safi = SAFI_UNICAST; safi < SAFI_MAX; safi++)
{
bgp->route[afi][safi] = bgp_table_init (afi, safi);
bgp->aggregate[afi][safi] = bgp_table_init (afi, safi);
bgp->rib[afi][safi] = bgp_table_init (afi, safi);
bgp->maxpaths[afi][safi].maxpaths_ebgp = BGP_DEFAULT_MAXPATHS;
bgp->maxpaths[afi][safi].maxpaths_ibgp = BGP_DEFAULT_MAXPATHS;
}
bgp->default_local_pref = BGP_DEFAULT_LOCAL_PREF;
bgp->default_holdtime = BGP_DEFAULT_HOLDTIME;
bgp->default_keepalive = BGP_DEFAULT_KEEPALIVE;
bgp->restart_time = BGP_DEFAULT_RESTART_TIME;
bgp->stalepath_time = BGP_DEFAULT_STALEPATH_TIME;
bgp->as = *as;
if (name)
bgp->name = strdup (name);
return bgp;
}
/* Return first entry of BGP. */
struct bgp *
bgp_get_default (void)
{
if (bm->bgp->head)
return (listgetdata (listhead (bm->bgp)));
return NULL;
}
/* Lookup BGP entry. */
struct bgp *
bgp_lookup (as_t as, const char *name)
{
struct bgp *bgp;
struct listnode *node, *nnode;
for (ALL_LIST_ELEMENTS (bm->bgp, node, nnode, bgp))
if (bgp->as == as
&& ((bgp->name == NULL && name == NULL)
|| (bgp->name && name && strcmp (bgp->name, name) == 0)))
return bgp;
return NULL;
}
/* Lookup BGP structure by view name. */
struct bgp *
bgp_lookup_by_name (const char *name)
{
struct bgp *bgp;
struct listnode *node, *nnode;
for (ALL_LIST_ELEMENTS (bm->bgp, node, nnode, bgp))
if ((bgp->name == NULL && name == NULL)
|| (bgp->name && name && strcmp (bgp->name, name) == 0))
return bgp;
return NULL;
}
/* Called from VTY commands. */
int
bgp_get (struct bgp **bgp_val, as_t *as, const char *name)
{
struct bgp *bgp;
/* Multiple instance check. */
if (bgp_option_check (BGP_OPT_MULTIPLE_INSTANCE))
{
if (name)
bgp = bgp_lookup_by_name (name);
else
bgp = bgp_get_default ();
/* Already exists. */
if (bgp)
{
if (bgp->as != *as)
{
*as = bgp->as;
return BGP_ERR_INSTANCE_MISMATCH;
}
*bgp_val = bgp;
return 0;
}
}
else
{
/* BGP instance name can not be specified for single instance. */
if (name)
return BGP_ERR_MULTIPLE_INSTANCE_NOT_SET;
/* Get default BGP structure if exists. */
bgp = bgp_get_default ();
if (bgp)
{
if (bgp->as != *as)
{
*as = bgp->as;
return BGP_ERR_AS_MISMATCH;
}
*bgp_val = bgp;
return 0;
}
}
bgp = bgp_create (as, name);
bgp_router_id_set(bgp, &router_id_kroute);
*bgp_val = bgp;
/* Create BGP server socket, if first instance. */
if (list_isempty(bm->bgp))
{
if (bgp_socket (bm->port, bm->address) < 0)
return BGP_ERR_INVALID_VALUE;
}
listnode_add (bm->bgp, bgp);
return 0;
}
/* Delete BGP instance. */
int
bgp_delete (struct bgp *bgp)
{
struct peer *peer;
struct peer_group *group;
struct listnode *node;
struct listnode *next;
afi_t afi;
int i;
/* Delete static route. */
bgp_static_delete (bgp);
/* Unset redistribution. */
for (afi = AFI_IP; afi < AFI_MAX; afi++)
for (i = 0; i < KROUTE_ROUTE_MAX; i++)
if (i != KROUTE_ROUTE_BGP)
bgp_redistribute_unset (bgp, afi, i);
for (ALL_LIST_ELEMENTS (bgp->peer, node, next, peer))
peer_delete (peer);
for (ALL_LIST_ELEMENTS (bgp->group, node, next, group))
peer_group_delete (group);
assert (listcount (bgp->rsclient) == 0);
if (bgp->peer_self) {
peer_delete(bgp->peer_self);
bgp->peer_self = NULL;
}
/* Remove visibility via the master list - there may however still be
* routes to be processed still referencing the struct bgp.
*/
listnode_delete (bm->bgp, bgp);
if (list_isempty(bm->bgp))
bgp_close ();
bgp_unlock(bgp); /* initial reference */
return 0;
}
static void bgp_free (struct bgp *);
void
bgp_lock (struct bgp *bgp)
{
++bgp->lock;
}
void
bgp_unlock(struct bgp *bgp)
{
assert(bgp->lock > 0);
if (--bgp->lock == 0)
bgp_free (bgp);
}
static void
bgp_free (struct bgp *bgp)
{
afi_t afi;
safi_t safi;
list_delete (bgp->group);
list_delete (bgp->peer);
list_delete (bgp->rsclient);
if (bgp->name)
free (bgp->name);
for (afi = AFI_IP; afi < AFI_MAX; afi++)
for (safi = SAFI_UNICAST; safi < SAFI_MAX; safi++)
{
if (bgp->route[afi][safi])
bgp_table_finish (&bgp->route[afi][safi]);
if (bgp->aggregate[afi][safi])
bgp_table_finish (&bgp->aggregate[afi][safi]) ;
if (bgp->rib[afi][safi])
bgp_table_finish (&bgp->rib[afi][safi]);
}
XFREE (MTYPE_BGP, bgp);
}
struct peer *
peer_lookup (struct bgp *bgp, union sockunion *su)
{
struct peer *peer;
struct listnode *node, *nnode;
if (bgp != NULL)
{
for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer))
if (sockunion_same (&peer->su, su)
&& ! CHECK_FLAG (peer->sflags, PEER_STATUS_ACCEPT_PEER))
return peer;
}
else if (bm->bgp != NULL)
{
struct listnode *bgpnode, *nbgpnode;
for (ALL_LIST_ELEMENTS (bm->bgp, bgpnode, nbgpnode, bgp))
for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer))
if (sockunion_same (&peer->su, su)
&& ! CHECK_FLAG (peer->sflags, PEER_STATUS_ACCEPT_PEER))
return peer;
}
return NULL;
}
struct peer *
peer_lookup_with_open (union sockunion *su, as_t remote_as,
struct in_addr *remote_id, int *as)
{
struct peer *peer;
struct listnode *node;
struct listnode *bgpnode;
struct bgp *bgp;
if (! bm->bgp)
return NULL;
for (ALL_LIST_ELEMENTS_RO (bm->bgp, bgpnode, bgp))
{
for (ALL_LIST_ELEMENTS_RO (bgp->peer, node, peer))
{
if (sockunion_same (&peer->su, su)
&& ! CHECK_FLAG (peer->sflags, PEER_STATUS_ACCEPT_PEER))
{
if (peer->as == remote_as
&& peer->remote_id.s_addr == remote_id->s_addr)
return peer;
if (peer->as == remote_as)
*as = 1;
}
}
for (ALL_LIST_ELEMENTS_RO (bgp->peer, node, peer))
{
if (sockunion_same (&peer->su, su)
&& ! CHECK_FLAG (peer->sflags, PEER_STATUS_ACCEPT_PEER))
{
if (peer->as == remote_as
&& peer->remote_id.s_addr == 0)
return peer;
if (peer->as == remote_as)
*as = 1;
}
}
}
return NULL;
}
/* If peer is configured at least one address family return 1. */
int
peer_active (struct peer *peer)
{
if (peer->afc[AFI_IP][SAFI_UNICAST]
|| peer->afc[AFI_IP][SAFI_MULTICAST]
|| peer->afc[AFI_IP][SAFI_MPLS_VPN]
|| peer->afc[AFI_IP6][SAFI_UNICAST]
|| peer->afc[AFI_IP6][SAFI_MULTICAST])
return 1;
return 0;
}
/* If peer is negotiated at least one address family return 1. */
int
peer_active_nego (struct peer *peer)
{
if (peer->afc_nego[AFI_IP][SAFI_UNICAST]
|| peer->afc_nego[AFI_IP][SAFI_MULTICAST]
|| peer->afc_nego[AFI_IP][SAFI_MPLS_VPN]
|| peer->afc_nego[AFI_IP6][SAFI_UNICAST]
|| peer->afc_nego[AFI_IP6][SAFI_MULTICAST])
return 1;
return 0;
}
/* peer_flag_change_type. */
enum peer_change_type
{
peer_change_none,
peer_change_reset,
peer_change_reset_in,
peer_change_reset_out,
};
static void
peer_change_action (struct peer *peer, afi_t afi, safi_t safi,
enum peer_change_type type)
{
if (CHECK_FLAG (peer->sflags, PEER_STATUS_GROUP))
return;
if (type == peer_change_reset)
bgp_notify_send (peer, BGP_NOTIFY_CEASE,
BGP_NOTIFY_CEASE_CONFIG_CHANGE);
else if (type == peer_change_reset_in)
{
if (CHECK_FLAG (peer->cap, PEER_CAP_REFRESH_OLD_RCV)
|| CHECK_FLAG (peer->cap, PEER_CAP_REFRESH_NEW_RCV))
bgp_route_refresh_send (peer, afi, safi, 0, 0, 0);
else
bgp_notify_send (peer, BGP_NOTIFY_CEASE,
BGP_NOTIFY_CEASE_CONFIG_CHANGE);
}
else if (type == peer_change_reset_out)
bgp_announce_route (peer, afi, safi);
}
struct peer_flag_action
{
/* Peer's flag. */
u_int32_t flag;
/* This flag can be set for peer-group member. */
u_char not_for_member;
/* Action when the flag is changed. */
enum peer_change_type type;
/* Peer down cause */
u_char peer_down;
};
static const struct peer_flag_action peer_flag_action_list[] =
{
{ PEER_FLAG_PASSIVE, 0, peer_change_reset },
{ PEER_FLAG_SHUTDOWN, 0, peer_change_reset },
{ PEER_FLAG_DONT_CAPABILITY, 0, peer_change_none },
{ PEER_FLAG_OVERRIDE_CAPABILITY, 0, peer_change_none },
{ PEER_FLAG_STRICT_CAP_MATCH, 0, peer_change_none },
{ PEER_FLAG_DYNAMIC_CAPABILITY, 0, peer_change_reset },
{ PEER_FLAG_DISABLE_CONNECTED_CHECK, 0, peer_change_reset },
{ 0, 0, 0 }
};
static const struct peer_flag_action peer_af_flag_action_list[] =
{
{ PEER_FLAG_NEXTHOP_SELF, 1, peer_change_reset_out },
{ PEER_FLAG_SEND_COMMUNITY, 1, peer_change_reset_out },
{ PEER_FLAG_SEND_EXT_COMMUNITY, 1, peer_change_reset_out },
{ PEER_FLAG_SOFT_RECONFIG, 0, peer_change_reset_in },
{ PEER_FLAG_REFLECTOR_CLIENT, 1, peer_change_reset },
{ PEER_FLAG_RSERVER_CLIENT, 1, peer_change_reset },
{ PEER_FLAG_AS_PATH_UNCHANGED, 1, peer_change_reset_out },
{ PEER_FLAG_NEXTHOP_UNCHANGED, 1, peer_change_reset_out },
{ PEER_FLAG_MED_UNCHANGED, 1, peer_change_reset_out },
{ PEER_FLAG_REMOVE_PRIVATE_AS, 1, peer_change_reset_out },
{ PEER_FLAG_ALLOWAS_IN, 0, peer_change_reset_in },
{ PEER_FLAG_ORF_PREFIX_SM, 1, peer_change_reset },
{ PEER_FLAG_ORF_PREFIX_RM, 1, peer_change_reset },
{ PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED, 0, peer_change_reset_out },
{ 0, 0, 0 }
};
/* Proper action set. */
static int
peer_flag_action_set (const struct peer_flag_action *action_list, int size,
struct peer_flag_action *action, u_int32_t flag)
{
int i;
int found = 0;
int reset_in = 0;
int reset_out = 0;
const struct peer_flag_action *match = NULL;
/* Check peer's frag action. */
for (i = 0; i < size; i++)
{
match = &action_list[i];
if (match->flag == 0)
break;
if (match->flag & flag)
{
found = 1;
if (match->type == peer_change_reset_in)
reset_in = 1;
if (match->type == peer_change_reset_out)
reset_out = 1;
if (match->type == peer_change_reset)
{
reset_in = 1;
reset_out = 1;
}
if (match->not_for_member)
action->not_for_member = 1;
}
}
/* Set peer clear type. */
if (reset_in && reset_out)
action->type = peer_change_reset;
else if (reset_in)
action->type = peer_change_reset_in;
else if (reset_out)
action->type = peer_change_reset_out;
else
action->type = peer_change_none;
return found;
}
static void
peer_flag_modify_action (struct peer *peer, u_int32_t flag)
{
if (flag == PEER_FLAG_SHUTDOWN)
{
if (CHECK_FLAG (peer->flags, flag))
{
if (CHECK_FLAG (peer->sflags, PEER_STATUS_NSF_WAIT))
peer_nsf_stop (peer);
UNSET_FLAG (peer->sflags, PEER_STATUS_PREFIX_OVERFLOW);
if (peer->t_pmax_restart)
{
BGP_TIMER_OFF (peer->t_pmax_restart);
if (BGP_DEBUG (events, EVENTS))
zlog_debug ("%s Maximum-prefix restart timer canceled",
peer->host);
}
if (CHECK_FLAG (peer->sflags, PEER_STATUS_NSF_WAIT))
peer_nsf_stop (peer);
if (peer->status == Established)
bgp_notify_send (peer, BGP_NOTIFY_CEASE,
BGP_NOTIFY_CEASE_ADMIN_SHUTDOWN);
else
BGP_EVENT_ADD (peer, BGP_Stop);
}
else
{
peer->v_start = BGP_INIT_START_TIMER;
BGP_EVENT_ADD (peer, BGP_Stop);
}
}
else if (peer->status == Established)
{
if (flag == PEER_FLAG_DYNAMIC_CAPABILITY)
peer->last_reset = PEER_DOWN_CAPABILITY_CHANGE;
else if (flag == PEER_FLAG_PASSIVE)
peer->last_reset = PEER_DOWN_PASSIVE_CHANGE;
else if (flag == PEER_FLAG_DISABLE_CONNECTED_CHECK)
peer->last_reset = PEER_DOWN_MULTIHOP_CHANGE;
bgp_notify_send (peer, BGP_NOTIFY_CEASE,
BGP_NOTIFY_CEASE_CONFIG_CHANGE);
}
else
BGP_EVENT_ADD (peer, BGP_Stop);
}
/* Change specified peer flag. */
static int
peer_flag_modify (struct peer *peer, u_int32_t flag, int set)
{
int found;
int size;
struct peer_group *group;
struct listnode *node, *nnode;
struct peer_flag_action action;
memset (&action, 0, sizeof (struct peer_flag_action));
size = sizeof peer_flag_action_list / sizeof (struct peer_flag_action);
found = peer_flag_action_set (peer_flag_action_list, size, &action, flag);
/* No flag action is found. */
if (! found)
return BGP_ERR_INVALID_FLAG;
/* Not for peer-group member. */
if (action.not_for_member && peer_group_active (peer))
return BGP_ERR_INVALID_FOR_PEER_GROUP_MEMBER;
/* When unset the peer-group member's flag we have to check
peer-group configuration. */
if (! set && peer_group_active (peer))
if (CHECK_FLAG (peer->group->conf->flags, flag))
{
if (flag == PEER_FLAG_SHUTDOWN)
return BGP_ERR_PEER_GROUP_SHUTDOWN;
else
return BGP_ERR_PEER_GROUP_HAS_THE_FLAG;
}
/* Flag conflict check. */
if (set
&& CHECK_FLAG (peer->flags | flag, PEER_FLAG_STRICT_CAP_MATCH)
&& CHECK_FLAG (peer->flags | flag, PEER_FLAG_OVERRIDE_CAPABILITY))
return BGP_ERR_PEER_FLAG_CONFLICT;
if (! CHECK_FLAG (peer->sflags, PEER_STATUS_GROUP))
{
if (set && CHECK_FLAG (peer->flags, flag) == flag)
return 0;
if (! set && ! CHECK_FLAG (peer->flags, flag))
return 0;
}
if (set)
SET_FLAG (peer->flags, flag);
else
UNSET_FLAG (peer->flags, flag);
if (! CHECK_FLAG (peer->sflags, PEER_STATUS_GROUP))
{
if (action.type == peer_change_reset)
peer_flag_modify_action (peer, flag);
return 0;
}
/* peer-group member updates. */
group = peer->group;
for (ALL_LIST_ELEMENTS (group->peer, node, nnode, peer))
{
if (set && CHECK_FLAG (peer->flags, flag) == flag)
continue;
if (! set && ! CHECK_FLAG (peer->flags, flag))
continue;
if (set)
SET_FLAG (peer->flags, flag);
else
UNSET_FLAG (peer->flags, flag);
if (action.type == peer_change_reset)
peer_flag_modify_action (peer, flag);
}
return 0;
}
int
peer_flag_set (struct peer *peer, u_int32_t flag)
{
return peer_flag_modify (peer, flag, 1);
}
int
peer_flag_unset (struct peer *peer, u_int32_t flag)
{
return peer_flag_modify (peer, flag, 0);
}
static int
peer_is_group_member (struct peer *peer, afi_t afi, safi_t safi)
{
if (peer->af_group[afi][safi])
return 1;
return 0;
}
static int
peer_af_flag_modify (struct peer *peer, afi_t afi, safi_t safi, u_int32_t flag,
int set)
{
int found;
int size;
struct listnode *node, *nnode;
struct peer_group *group;
struct peer_flag_action action;
memset (&action, 0, sizeof (struct peer_flag_action));
size = sizeof peer_af_flag_action_list / sizeof (struct peer_flag_action);
found = peer_flag_action_set (peer_af_flag_action_list, size, &action, flag);
/* No flag action is found. */
if (! found)
return BGP_ERR_INVALID_FLAG;
/* Adress family must be activated. */
if (! peer->afc[afi][safi])
return BGP_ERR_PEER_INACTIVE;
/* Not for peer-group member. */
if (action.not_for_member && peer_is_group_member (peer, afi, safi))
return BGP_ERR_INVALID_FOR_PEER_GROUP_MEMBER;
/* Spcecial check for reflector client. */
if (flag & PEER_FLAG_REFLECTOR_CLIENT
&& peer_sort (peer) != BGP_PEER_IBGP)
return BGP_ERR_NOT_INTERNAL_PEER;
/* Spcecial check for remove-private-AS. */
if (flag & PEER_FLAG_REMOVE_PRIVATE_AS
&& peer_sort (peer) == BGP_PEER_IBGP)
return BGP_ERR_REMOVE_PRIVATE_AS;
/* When unset the peer-group member's flag we have to check
peer-group configuration. */
if (! set && peer->af_group[afi][safi])
if (CHECK_FLAG (peer->group->conf->af_flags[afi][safi], flag))
return BGP_ERR_PEER_GROUP_HAS_THE_FLAG;
/* When current flag configuration is same as requested one. */
if (! CHECK_FLAG (peer->sflags, PEER_STATUS_GROUP))
{
if (set && CHECK_FLAG (peer->af_flags[afi][safi], flag) == flag)
return 0;
if (! set && ! CHECK_FLAG (peer->af_flags[afi][safi], flag))
return 0;
}
if (set)
SET_FLAG (peer->af_flags[afi][safi], flag);
else
UNSET_FLAG (peer->af_flags[afi][safi], flag);
/* Execute action when peer is established. */
if (! CHECK_FLAG (peer->sflags, PEER_STATUS_GROUP)
&& peer->status == Established)
{
if (! set && flag == PEER_FLAG_SOFT_RECONFIG)
bgp_clear_adj_in (peer, afi, safi);
else
{
if (flag == PEER_FLAG_REFLECTOR_CLIENT)
peer->last_reset = PEER_DOWN_RR_CLIENT_CHANGE;
else if (flag == PEER_FLAG_RSERVER_CLIENT)
peer->last_reset = PEER_DOWN_RS_CLIENT_CHANGE;
else if (flag == PEER_FLAG_ORF_PREFIX_SM)
peer->last_reset = PEER_DOWN_CAPABILITY_CHANGE;
else if (flag == PEER_FLAG_ORF_PREFIX_RM)
peer->last_reset = PEER_DOWN_CAPABILITY_CHANGE;
peer_change_action (peer, afi, safi, action.type);
}
}
/* Peer group member updates. */
if (CHECK_FLAG (peer->sflags, PEER_STATUS_GROUP))
{
group = peer->group;
for (ALL_LIST_ELEMENTS (group->peer, node, nnode, peer))
{
if (! peer->af_group[afi][safi])
continue;
if (set && CHECK_FLAG (peer->af_flags[afi][safi], flag) == flag)
continue;
if (! set && ! CHECK_FLAG (peer->af_flags[afi][safi], flag))
continue;
if (set)
SET_FLAG (peer->af_flags[afi][safi], flag);
else
UNSET_FLAG (peer->af_flags[afi][safi], flag);
if (peer->status == Established)
{
if (! set && flag == PEER_FLAG_SOFT_RECONFIG)
bgp_clear_adj_in (peer, afi, safi);
else
{
if (flag == PEER_FLAG_REFLECTOR_CLIENT)
peer->last_reset = PEER_DOWN_RR_CLIENT_CHANGE;
else if (flag == PEER_FLAG_RSERVER_CLIENT)
peer->last_reset = PEER_DOWN_RS_CLIENT_CHANGE;
else if (flag == PEER_FLAG_ORF_PREFIX_SM)
peer->last_reset = PEER_DOWN_CAPABILITY_CHANGE;
else if (flag == PEER_FLAG_ORF_PREFIX_RM)
peer->last_reset = PEER_DOWN_CAPABILITY_CHANGE;
peer_change_action (peer, afi, safi, action.type);
}
}
}
}
return 0;
}
int
peer_af_flag_set (struct peer *peer, afi_t afi, safi_t safi, u_int32_t flag)
{
return peer_af_flag_modify (peer, afi, safi, flag, 1);
}
int
peer_af_flag_unset (struct peer *peer, afi_t afi, safi_t safi, u_int32_t flag)
{
return peer_af_flag_modify (peer, afi, safi, flag, 0);
}
/* EBGP multihop configuration. */
int
peer_ebgp_multihop_set (struct peer *peer, int ttl)
{
struct peer_group *group;
struct listnode *node, *nnode;
struct peer *peer1;
if (peer_sort (peer) == BGP_PEER_IBGP)
return 0;
/* see comment in peer_ttl_security_hops_set() */
if (ttl != MAXTTL)
{
if (CHECK_FLAG (peer->sflags, PEER_STATUS_GROUP))
{
group = peer->group;
if (group->conf->gtsm_hops != 0)
return BGP_ERR_NO_EBGP_MULTIHOP_WITH_TTLHACK;
for (ALL_LIST_ELEMENTS (group->peer, node, nnode, peer1))
{
if (peer_sort (peer1) == BGP_PEER_IBGP)
continue;
if (peer1->gtsm_hops != 0)
return BGP_ERR_NO_EBGP_MULTIHOP_WITH_TTLHACK;
}
}
else
{
if (peer->gtsm_hops != 0)
return BGP_ERR_NO_EBGP_MULTIHOP_WITH_TTLHACK;
}
}
peer->ttl = ttl;
if (! CHECK_FLAG (peer->sflags, PEER_STATUS_GROUP))
{
if (peer->fd >= 0 && peer_sort (peer) != BGP_PEER_IBGP)
sockopt_ttl (peer->su.sa.sa_family, peer->fd, peer->ttl);
}
else
{
group = peer->group;
for (ALL_LIST_ELEMENTS (group->peer, node, nnode, peer))
{
if (peer_sort (peer) == BGP_PEER_IBGP)
continue;
peer->ttl = group->conf->ttl;
if (peer->fd >= 0)
sockopt_ttl (peer->su.sa.sa_family, peer->fd, peer->ttl);
}
}
return 0;
}
int
peer_ebgp_multihop_unset (struct peer *peer)
{
struct peer_group *group;
struct listnode *node, *nnode;
if (peer_sort (peer) == BGP_PEER_IBGP)
return 0;
if (peer->gtsm_hops != 0 && peer->ttl != MAXTTL)
return BGP_ERR_NO_EBGP_MULTIHOP_WITH_TTLHACK;
if (peer_group_active (peer))
peer->ttl = peer->group->conf->ttl;
else
peer->ttl = 1;
if (! CHECK_FLAG (peer->sflags, PEER_STATUS_GROUP))
{
if (peer->fd >= 0 && peer_sort (peer) != BGP_PEER_IBGP)
sockopt_ttl (peer->su.sa.sa_family, peer->fd, peer->ttl);
}
else
{
group = peer->group;
for (ALL_LIST_ELEMENTS (group->peer, node, nnode, peer))
{
if (peer_sort (peer) == BGP_PEER_IBGP)
continue;
peer->ttl = 1;
if (peer->fd >= 0)
sockopt_ttl (peer->su.sa.sa_family, peer->fd, peer->ttl);
}
}
return 0;
}
/* Neighbor description. */
int
peer_description_set (struct peer *peer, char *desc)
{
if (peer->desc)
XFREE (MTYPE_PEER_DESC, peer->desc);
peer->desc = XSTRDUP (MTYPE_PEER_DESC, desc);
return 0;
}
int
peer_description_unset (struct peer *peer)
{
if (peer->desc)
XFREE (MTYPE_PEER_DESC, peer->desc);
peer->desc = NULL;
return 0;
}
/* Neighbor update-source. */
int
peer_update_source_if_set (struct peer *peer, const char *ifname)
{
struct peer_group *group;
struct listnode *node, *nnode;
if (peer->update_if)
{
if (! CHECK_FLAG (peer->sflags, PEER_STATUS_GROUP)
&& strcmp (peer->update_if, ifname) == 0)
return 0;
XFREE (MTYPE_PEER_UPDATE_SOURCE, peer->update_if);
peer->update_if = NULL;
}
if (peer->update_source)
{
sockunion_free (peer->update_source);
peer->update_source = NULL;
}
peer->update_if = XSTRDUP (MTYPE_PEER_UPDATE_SOURCE, ifname);
if (! CHECK_FLAG (peer->sflags, PEER_STATUS_GROUP))
{
if (peer->status == Established)
{
peer->last_reset = PEER_DOWN_UPDATE_SOURCE_CHANGE;
bgp_notify_send (peer, BGP_NOTIFY_CEASE,
BGP_NOTIFY_CEASE_CONFIG_CHANGE);
}
else
BGP_EVENT_ADD (peer, BGP_Stop);
return 0;
}
/* peer-group member updates. */
group = peer->group;
for (ALL_LIST_ELEMENTS (group->peer, node, nnode, peer))
{
if (peer->update_if)
{
if (strcmp (peer->update_if, ifname) == 0)
continue;
XFREE (MTYPE_PEER_UPDATE_SOURCE, peer->update_if);
peer->update_if = NULL;
}
if (peer->update_source)
{
sockunion_free (peer->update_source);
peer->update_source = NULL;
}
peer->update_if = XSTRDUP (MTYPE_PEER_UPDATE_SOURCE, ifname);
if (peer->status == Established)
{
peer->last_reset = PEER_DOWN_UPDATE_SOURCE_CHANGE;
bgp_notify_send (peer, BGP_NOTIFY_CEASE,
BGP_NOTIFY_CEASE_CONFIG_CHANGE);
}
else
BGP_EVENT_ADD (peer, BGP_Stop);
}
return 0;
}
int
peer_update_source_addr_set (struct peer *peer, union sockunion *su)
{
struct peer_group *group;
struct listnode *node, *nnode;
if (peer->update_source)
{
if (! CHECK_FLAG (peer->sflags, PEER_STATUS_GROUP)
&& sockunion_cmp (peer->update_source, su) == 0)
return 0;
sockunion_free (peer->update_source);
peer->update_source = NULL;
}
if (peer->update_if)
{
XFREE (MTYPE_PEER_UPDATE_SOURCE, peer->update_if);
peer->update_if = NULL;
}
peer->update_source = sockunion_dup (su);
if (! CHECK_FLAG (peer->sflags, PEER_STATUS_GROUP))
{
if (peer->status == Established)
{
peer->last_reset = PEER_DOWN_UPDATE_SOURCE_CHANGE;
bgp_notify_send (peer, BGP_NOTIFY_CEASE,
BGP_NOTIFY_CEASE_CONFIG_CHANGE);
}
else
BGP_EVENT_ADD (peer, BGP_Stop);
return 0;
}
/* peer-group member updates. */
group = peer->group;
for (ALL_LIST_ELEMENTS (group->peer, node, nnode, peer))
{
if (peer->update_source)
{
if (sockunion_cmp (peer->update_source, su) == 0)
continue;
sockunion_free (peer->update_source);
peer->update_source = NULL;
}
if (peer->update_if)
{
XFREE (MTYPE_PEER_UPDATE_SOURCE, peer->update_if);
peer->update_if = NULL;
}
peer->update_source = sockunion_dup (su);
if (peer->status == Established)
{
peer->last_reset = PEER_DOWN_UPDATE_SOURCE_CHANGE;
bgp_notify_send (peer, BGP_NOTIFY_CEASE,
BGP_NOTIFY_CEASE_CONFIG_CHANGE);
}
else
BGP_EVENT_ADD (peer, BGP_Stop);
}
return 0;
}
int
peer_update_source_unset (struct peer *peer)
{
union sockunion *su;
struct peer_group *group;
struct listnode *node, *nnode;
if (! CHECK_FLAG (peer->sflags, PEER_STATUS_GROUP)
&& ! peer->update_source
&& ! peer->update_if)
return 0;
if (peer->update_source)
{
sockunion_free (peer->update_source);
peer->update_source = NULL;
}
if (peer->update_if)
{
XFREE (MTYPE_PEER_UPDATE_SOURCE, peer->update_if);
peer->update_if = NULL;
}
if (peer_group_active (peer))
{
group = peer->group;
if (group->conf->update_source)
{
su = sockunion_dup (group->conf->update_source);
peer->update_source = su;
}
else if (group->conf->update_if)
peer->update_if =
XSTRDUP (MTYPE_PEER_UPDATE_SOURCE, group->conf->update_if);
}
if (! CHECK_FLAG (peer->sflags, PEER_STATUS_GROUP))
{
if (peer->status == Established)
{
peer->last_reset = PEER_DOWN_UPDATE_SOURCE_CHANGE;
bgp_notify_send (peer, BGP_NOTIFY_CEASE,
BGP_NOTIFY_CEASE_CONFIG_CHANGE);
}
else
BGP_EVENT_ADD (peer, BGP_Stop);
return 0;
}
/* peer-group member updates. */
group = peer->group;
for (ALL_LIST_ELEMENTS (group->peer, node, nnode, peer))
{
if (! peer->update_source && ! peer->update_if)
continue;
if (peer->update_source)
{
sockunion_free (peer->update_source);
peer->update_source = NULL;
}
if (peer->update_if)
{
XFREE (MTYPE_PEER_UPDATE_SOURCE, peer->update_if);
peer->update_if = NULL;
}
if (peer->status == Established)
{
peer->last_reset = PEER_DOWN_UPDATE_SOURCE_CHANGE;
bgp_notify_send (peer, BGP_NOTIFY_CEASE,
BGP_NOTIFY_CEASE_CONFIG_CHANGE);
}
else
BGP_EVENT_ADD (peer, BGP_Stop);
}
return 0;
}
int
peer_default_originate_set (struct peer *peer, afi_t afi, safi_t safi,
const char *rmap)
{
struct peer_group *group;
struct listnode *node, *nnode;
/* Adress family must be activated. */
if (! peer->afc[afi][safi])
return BGP_ERR_PEER_INACTIVE;
/* Default originate can't be used for peer group memeber. */
if (peer_is_group_member (peer, afi, safi))
return BGP_ERR_INVALID_FOR_PEER_GROUP_MEMBER;
if (! CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_DEFAULT_ORIGINATE)
|| (rmap && ! peer->default_rmap[afi][safi].name)
|| (rmap && strcmp (rmap, peer->default_rmap[afi][safi].name) != 0))
{
SET_FLAG (peer->af_flags[afi][safi], PEER_FLAG_DEFAULT_ORIGINATE);
if (rmap)
{
if (peer->default_rmap[afi][safi].name)
free (peer->default_rmap[afi][safi].name);
peer->default_rmap[afi][safi].name = strdup (rmap);
peer->default_rmap[afi][safi].map = route_map_lookup_by_name (rmap);
}
}
if (! CHECK_FLAG (peer->sflags, PEER_STATUS_GROUP))
{
if (peer->status == Established && peer->afc_nego[afi][safi])
bgp_default_originate (peer, afi, safi, 0);
return 0;
}
/* peer-group member updates. */
group = peer->group;
for (ALL_LIST_ELEMENTS (group->peer, node, nnode, peer))
{
SET_FLAG (peer->af_flags[afi][safi], PEER_FLAG_DEFAULT_ORIGINATE);
if (rmap)
{
if (peer->default_rmap[afi][safi].name)
free (peer->default_rmap[afi][safi].name);
peer->default_rmap[afi][safi].name = strdup (rmap);
peer->default_rmap[afi][safi].map = route_map_lookup_by_name (rmap);
}
if (peer->status == Established && peer->afc_nego[afi][safi])
bgp_default_originate (peer, afi, safi, 0);
}
return 0;
}
int
peer_default_originate_unset (struct peer *peer, afi_t afi, safi_t safi)
{
struct peer_group *group;
struct listnode *node, *nnode;
/* Adress family must be activated. */
if (! peer->afc[afi][safi])
return BGP_ERR_PEER_INACTIVE;
/* Default originate can't be used for peer group memeber. */
if (peer_is_group_member (peer, afi, safi))
return BGP_ERR_INVALID_FOR_PEER_GROUP_MEMBER;
if (CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_DEFAULT_ORIGINATE))
{
UNSET_FLAG (peer->af_flags[afi][safi], PEER_FLAG_DEFAULT_ORIGINATE);
if (peer->default_rmap[afi][safi].name)
free (peer->default_rmap[afi][safi].name);
peer->default_rmap[afi][safi].name = NULL;
peer->default_rmap[afi][safi].map = NULL;
}
if (! CHECK_FLAG (peer->sflags, PEER_STATUS_GROUP))
{
if (peer->status == Established && peer->afc_nego[afi][safi])
bgp_default_originate (peer, afi, safi, 1);
return 0;
}
/* peer-group member updates. */
group = peer->group;
for (ALL_LIST_ELEMENTS (group->peer, node, nnode, peer))
{
UNSET_FLAG (peer->af_flags[afi][safi], PEER_FLAG_DEFAULT_ORIGINATE);
if (peer->default_rmap[afi][safi].name)
free (peer->default_rmap[afi][safi].name);
peer->default_rmap[afi][safi].name = NULL;
peer->default_rmap[afi][safi].map = NULL;
if (peer->status == Established && peer->afc_nego[afi][safi])
bgp_default_originate (peer, afi, safi, 1);
}
return 0;
}
int
peer_port_set (struct peer *peer, u_int16_t port)
{
peer->port = port;
return 0;
}
int
peer_port_unset (struct peer *peer)
{
peer->port = BGP_PORT_DEFAULT;
return 0;
}
/* neighbor weight. */
int
peer_weight_set (struct peer *peer, u_int16_t weight)
{
struct peer_group *group;
struct listnode *node, *nnode;
SET_FLAG (peer->config, PEER_CONFIG_WEIGHT);
peer->weight = weight;
if (! CHECK_FLAG (peer->sflags, PEER_STATUS_GROUP))
return 0;
/* peer-group member updates. */
group = peer->group;
for (ALL_LIST_ELEMENTS (group->peer, node, nnode, peer))
{
peer->weight = group->conf->weight;
}
return 0;
}
int
peer_weight_unset (struct peer *peer)
{
struct peer_group *group;
struct listnode *node, *nnode;
/* Set default weight. */
if (peer_group_active (peer))
peer->weight = peer->group->conf->weight;
else
peer->weight = 0;
UNSET_FLAG (peer->config, PEER_CONFIG_WEIGHT);
if (! CHECK_FLAG (peer->sflags, PEER_STATUS_GROUP))
return 0;
/* peer-group member updates. */
group = peer->group;
for (ALL_LIST_ELEMENTS (group->peer, node, nnode, peer))
{
peer->weight = 0;
}
return 0;
}
int
peer_timers_set (struct peer *peer, u_int32_t keepalive, u_int32_t holdtime)
{
struct peer_group *group;
struct listnode *node, *nnode;
/* Not for peer group memeber. */
if (peer_group_active (peer))
return BGP_ERR_INVALID_FOR_PEER_GROUP_MEMBER;
/* keepalive value check. */
if (keepalive > 65535)
return BGP_ERR_INVALID_VALUE;
/* Holdtime value check. */
if (holdtime > 65535)
return BGP_ERR_INVALID_VALUE;
/* Holdtime value must be either 0 or greater than 3. */
if (holdtime < 3 && holdtime != 0)
return BGP_ERR_INVALID_VALUE;
/* Set value to the configuration. */
SET_FLAG (peer->config, PEER_CONFIG_TIMER);
peer->holdtime = holdtime;
peer->keepalive = (keepalive < holdtime / 3 ? keepalive : holdtime / 3);
if (! CHECK_FLAG (peer->sflags, PEER_STATUS_GROUP))
return 0;
/* peer-group member updates. */
group = peer->group;
for (ALL_LIST_ELEMENTS (group->peer, node, nnode, peer))
{
SET_FLAG (peer->config, PEER_CONFIG_TIMER);
peer->holdtime = group->conf->holdtime;
peer->keepalive = group->conf->keepalive;
}
return 0;
}
int
peer_timers_unset (struct peer *peer)
{
struct peer_group *group;
struct listnode *node, *nnode;
if (peer_group_active (peer))
return BGP_ERR_INVALID_FOR_PEER_GROUP_MEMBER;
/* Clear configuration. */
UNSET_FLAG (peer->config, PEER_CONFIG_TIMER);
peer->keepalive = 0;
peer->holdtime = 0;
if (! CHECK_FLAG (peer->sflags, PEER_STATUS_GROUP))
return 0;
/* peer-group member updates. */
group = peer->group;
for (ALL_LIST_ELEMENTS (group->peer, node, nnode, peer))
{
UNSET_FLAG (peer->config, PEER_CONFIG_TIMER);
peer->holdtime = 0;
peer->keepalive = 0;
}
return 0;
}
int
peer_timers_connect_set (struct peer *peer, u_int32_t connect)
{
if (peer_group_active (peer))
return BGP_ERR_INVALID_FOR_PEER_GROUP_MEMBER;
if (connect > 65535)
return BGP_ERR_INVALID_VALUE;
/* Set value to the configuration. */
SET_FLAG (peer->config, PEER_CONFIG_CONNECT);
peer->connect = connect;
/* Set value to timer setting. */
peer->v_connect = connect;
return 0;
}
int
peer_timers_connect_unset (struct peer *peer)
{
if (peer_group_active (peer))
return BGP_ERR_INVALID_FOR_PEER_GROUP_MEMBER;
/* Clear configuration. */
UNSET_FLAG (peer->config, PEER_CONFIG_CONNECT);
peer->connect = 0;
/* Set timer setting to default value. */
peer->v_connect = BGP_DEFAULT_CONNECT_RETRY;
return 0;
}
int
peer_advertise_interval_set (struct peer *peer, u_int32_t routeadv)
{
if (peer_group_active (peer))
return BGP_ERR_INVALID_FOR_PEER_GROUP_MEMBER;
if (routeadv > 600)
return BGP_ERR_INVALID_VALUE;
SET_FLAG (peer->config, PEER_CONFIG_ROUTEADV);
peer->routeadv = routeadv;
peer->v_routeadv = routeadv;
return 0;
}
int
peer_advertise_interval_unset (struct peer *peer)
{
if (peer_group_active (peer))
return BGP_ERR_INVALID_FOR_PEER_GROUP_MEMBER;
UNSET_FLAG (peer->config, PEER_CONFIG_ROUTEADV);
peer->routeadv = 0;
if (peer_sort (peer) == BGP_PEER_IBGP)
peer->v_routeadv = BGP_DEFAULT_IBGP_ROUTEADV;
else
peer->v_routeadv = BGP_DEFAULT_EBGP_ROUTEADV;
return 0;
}
/* neighbor interface */
int
peer_interface_set (struct peer *peer, const char *str)
{
if (peer->ifname)
free (peer->ifname);
peer->ifname = strdup (str);
return 0;
}
int
peer_interface_unset (struct peer *peer)
{
if (peer->ifname)
free (peer->ifname);
peer->ifname = NULL;
return 0;
}
/* Allow-as in. */
int
peer_allowas_in_set (struct peer *peer, afi_t afi, safi_t safi, int allow_num)
{
struct peer_group *group;
struct listnode *node, *nnode;
if (allow_num < 1 || allow_num > 10)
return BGP_ERR_INVALID_VALUE;
if (peer->allowas_in[afi][safi] != allow_num)
{
peer->allowas_in[afi][safi] = allow_num;
SET_FLAG (peer->af_flags[afi][safi], PEER_FLAG_ALLOWAS_IN);
peer_change_action (peer, afi, safi, peer_change_reset_in);
}
if (! CHECK_FLAG (peer->sflags, PEER_STATUS_GROUP))
return 0;
group = peer->group;
for (ALL_LIST_ELEMENTS (group->peer, node, nnode, peer))
{
if (peer->allowas_in[afi][safi] != allow_num)
{
peer->allowas_in[afi][safi] = allow_num;
SET_FLAG (peer->af_flags[afi][safi], PEER_FLAG_ALLOWAS_IN);
peer_change_action (peer, afi, safi, peer_change_reset_in);
}
}
return 0;
}
int
peer_allowas_in_unset (struct peer *peer, afi_t afi, safi_t safi)
{
struct peer_group *group;
struct listnode *node, *nnode;
if (CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_ALLOWAS_IN))
{
peer->allowas_in[afi][safi] = 0;
peer_af_flag_unset (peer, afi, safi, PEER_FLAG_ALLOWAS_IN);
}
if (! CHECK_FLAG (peer->sflags, PEER_STATUS_GROUP))
return 0;
group = peer->group;
for (ALL_LIST_ELEMENTS (group->peer, node, nnode, peer))
{
if (CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_ALLOWAS_IN))
{
peer->allowas_in[afi][safi] = 0;
peer_af_flag_unset (peer, afi, safi, PEER_FLAG_ALLOWAS_IN);
}
}
return 0;
}
int
peer_local_as_set (struct peer *peer, as_t as, int no_prepend)
{
struct bgp *bgp = peer->bgp;
struct peer_group *group;
struct listnode *node, *nnode;
if (peer_sort (peer) != BGP_PEER_EBGP
&& peer_sort (peer) != BGP_PEER_INTERNAL)
return BGP_ERR_LOCAL_AS_ALLOWED_ONLY_FOR_EBGP;
if (bgp->as == as)
return BGP_ERR_CANNOT_HAVE_LOCAL_AS_SAME_AS;
if (peer_group_active (peer))
return BGP_ERR_INVALID_FOR_PEER_GROUP_MEMBER;
if (peer->change_local_as == as &&
((CHECK_FLAG (peer->flags, PEER_FLAG_LOCAL_AS_NO_PREPEND) && no_prepend)
|| (! CHECK_FLAG (peer->flags, PEER_FLAG_LOCAL_AS_NO_PREPEND) && ! no_prepend)))
return 0;
peer->change_local_as = as;
if (no_prepend)
SET_FLAG (peer->flags, PEER_FLAG_LOCAL_AS_NO_PREPEND);
else
UNSET_FLAG (peer->flags, PEER_FLAG_LOCAL_AS_NO_PREPEND);
if (! CHECK_FLAG (peer->sflags, PEER_STATUS_GROUP))
{
if (peer->status == Established)
{
peer->last_reset = PEER_DOWN_LOCAL_AS_CHANGE;
bgp_notify_send (peer, BGP_NOTIFY_CEASE,
BGP_NOTIFY_CEASE_CONFIG_CHANGE);
}
else
BGP_EVENT_ADD (peer, BGP_Stop);
return 0;
}
group = peer->group;
for (ALL_LIST_ELEMENTS (group->peer, node, nnode, peer))
{
peer->change_local_as = as;
if (no_prepend)
SET_FLAG (peer->flags, PEER_FLAG_LOCAL_AS_NO_PREPEND);
else
UNSET_FLAG (peer->flags, PEER_FLAG_LOCAL_AS_NO_PREPEND);
if (peer->status == Established)
{
peer->last_reset = PEER_DOWN_LOCAL_AS_CHANGE;
bgp_notify_send (peer, BGP_NOTIFY_CEASE,
BGP_NOTIFY_CEASE_CONFIG_CHANGE);
}
else
BGP_EVENT_ADD (peer, BGP_Stop);
}
return 0;
}
int
peer_local_as_unset (struct peer *peer)
{
struct peer_group *group;
struct listnode *node, *nnode;
if (peer_group_active (peer))
return BGP_ERR_INVALID_FOR_PEER_GROUP_MEMBER;
if (! peer->change_local_as)
return 0;
peer->change_local_as = 0;
UNSET_FLAG (peer->flags, PEER_FLAG_LOCAL_AS_NO_PREPEND);
if (! CHECK_FLAG (peer->sflags, PEER_STATUS_GROUP))
{
if (peer->status == Established)
{
peer->last_reset = PEER_DOWN_LOCAL_AS_CHANGE;
bgp_notify_send (peer, BGP_NOTIFY_CEASE,
BGP_NOTIFY_CEASE_CONFIG_CHANGE);
}
else
BGP_EVENT_ADD (peer, BGP_Stop);
return 0;
}
group = peer->group;
for (ALL_LIST_ELEMENTS (group->peer, node, nnode, peer))
{
peer->change_local_as = 0;
UNSET_FLAG (peer->flags, PEER_FLAG_LOCAL_AS_NO_PREPEND);
if (peer->status == Established)
{
peer->last_reset = PEER_DOWN_LOCAL_AS_CHANGE;
bgp_notify_send (peer, BGP_NOTIFY_CEASE,
BGP_NOTIFY_CEASE_CONFIG_CHANGE);
}
else
BGP_EVENT_ADD (peer, BGP_Stop);
}
return 0;
}
/* Set password for authenticating with the peer. */
int
peer_password_set (struct peer *peer, const char *password)
{
struct listnode *nn, *nnode;
int len = password ? strlen(password) : 0;
int ret = BGP_SUCCESS;
if ((len < PEER_PASSWORD_MINLEN) || (len > PEER_PASSWORD_MAXLEN))
return BGP_ERR_INVALID_VALUE;
if (peer->password && strcmp (peer->password, password) == 0
&& ! CHECK_FLAG (peer->sflags, PEER_STATUS_GROUP))
return 0;
if (peer->password)
XFREE (MTYPE_PEER_PASSWORD, peer->password);
peer->password = XSTRDUP (MTYPE_PEER_PASSWORD, password);
if (! CHECK_FLAG (peer->sflags, PEER_STATUS_GROUP))
{
if (peer->status == Established)
bgp_notify_send (peer, BGP_NOTIFY_CEASE, BGP_NOTIFY_CEASE_CONFIG_CHANGE);
else
BGP_EVENT_ADD (peer, BGP_Stop);
return (bgp_md5_set (peer) >= 0) ? BGP_SUCCESS : BGP_ERR_TCPSIG_FAILED;
}
for (ALL_LIST_ELEMENTS (peer->group->peer, nn, nnode, peer))
{
if (peer->password && strcmp (peer->password, password) == 0)
continue;
if (peer->password)
XFREE (MTYPE_PEER_PASSWORD, peer->password);
peer->password = XSTRDUP(MTYPE_PEER_PASSWORD, password);
if (peer->status == Established)
bgp_notify_send (peer, BGP_NOTIFY_CEASE, BGP_NOTIFY_CEASE_CONFIG_CHANGE);
else
BGP_EVENT_ADD (peer, BGP_Stop);
if (bgp_md5_set (peer) < 0)
ret = BGP_ERR_TCPSIG_FAILED;
}
return ret;
}
int
peer_password_unset (struct peer *peer)
{
struct listnode *nn, *nnode;
if (!peer->password
&& !CHECK_FLAG (peer->sflags, PEER_STATUS_GROUP))
return 0;
if (!CHECK_FLAG (peer->sflags, PEER_STATUS_GROUP))
{
if (peer_group_active (peer)
&& peer->group->conf->password
&& strcmp (peer->group->conf->password, peer->password) == 0)
return BGP_ERR_PEER_GROUP_HAS_THE_FLAG;
if (peer->status == Established)
bgp_notify_send (peer, BGP_NOTIFY_CEASE, BGP_NOTIFY_CEASE_CONFIG_CHANGE);
else
BGP_EVENT_ADD (peer, BGP_Stop);
if (peer->password)
XFREE (MTYPE_PEER_PASSWORD, peer->password);
peer->password = NULL;
bgp_md5_set (peer);
return 0;
}
XFREE (MTYPE_PEER_PASSWORD, peer->password);
peer->password = NULL;
for (ALL_LIST_ELEMENTS (peer->group->peer, nn, nnode, peer))
{
if (!peer->password)
continue;
if (peer->status == Established)
bgp_notify_send (peer, BGP_NOTIFY_CEASE, BGP_NOTIFY_CEASE_CONFIG_CHANGE);
else
BGP_EVENT_ADD (peer, BGP_Stop);
XFREE (MTYPE_PEER_PASSWORD, peer->password);
peer->password = NULL;
bgp_md5_set (peer);
}
return 0;
}
/* Set distribute list to the peer. */
int
peer_distribute_set (struct peer *peer, afi_t afi, safi_t safi, int direct,
const char *name)
{
struct bgp_filter *filter;
struct peer_group *group;
struct listnode *node, *nnode;
if (! peer->afc[afi][safi])
return BGP_ERR_PEER_INACTIVE;
if (direct != FILTER_IN && direct != FILTER_OUT)
return BGP_ERR_INVALID_VALUE;
if (direct == FILTER_OUT && peer_is_group_member (peer, afi, safi))
return BGP_ERR_INVALID_FOR_PEER_GROUP_MEMBER;
filter = &peer->filter[afi][safi];
if (filter->plist[direct].name)
return BGP_ERR_PEER_FILTER_CONFLICT;
if (filter->dlist[direct].name)
free (filter->dlist[direct].name);
filter->dlist[direct].name = strdup (name);
filter->dlist[direct].alist = access_list_lookup (afi, name);
if (! CHECK_FLAG (peer->sflags, PEER_STATUS_GROUP))
return 0;
group = peer->group;
for (ALL_LIST_ELEMENTS (group->peer, node, nnode, peer))
{
filter = &peer->filter[afi][safi];
if (! peer->af_group[afi][safi])
continue;
if (filter->dlist[direct].name)
free (filter->dlist[direct].name);
filter->dlist[direct].name = strdup (name);
filter->dlist[direct].alist = access_list_lookup (afi, name);
}
return 0;
}
int
peer_distribute_unset (struct peer *peer, afi_t afi, safi_t safi, int direct)
{
struct bgp_filter *filter;
struct bgp_filter *gfilter;
struct peer_group *group;
struct listnode *node, *nnode;
if (! peer->afc[afi][safi])
return BGP_ERR_PEER_INACTIVE;
if (direct != FILTER_IN && direct != FILTER_OUT)
return BGP_ERR_INVALID_VALUE;
if (direct == FILTER_OUT && peer_is_group_member (peer, afi, safi))
return BGP_ERR_INVALID_FOR_PEER_GROUP_MEMBER;
filter = &peer->filter[afi][safi];
/* apply peer-group filter */
if (peer->af_group[afi][safi])
{
gfilter = &peer->group->conf->filter[afi][safi];
if (gfilter->dlist[direct].name)
{
if (filter->dlist[direct].name)
free (filter->dlist[direct].name);
filter->dlist[direct].name = strdup (gfilter->dlist[direct].name);
filter->dlist[direct].alist = gfilter->dlist[direct].alist;
return 0;
}
}
if (filter->dlist[direct].name)
free (filter->dlist[direct].name);
filter->dlist[direct].name = NULL;
filter->dlist[direct].alist = NULL;
if (! CHECK_FLAG (peer->sflags, PEER_STATUS_GROUP))
return 0;
group = peer->group;
for (ALL_LIST_ELEMENTS (group->peer, node, nnode, peer))
{
filter = &peer->filter[afi][safi];
if (! peer->af_group[afi][safi])
continue;
if (filter->dlist[direct].name)
free (filter->dlist[direct].name);
filter->dlist[direct].name = NULL;
filter->dlist[direct].alist = NULL;
}
return 0;
}
/* Update distribute list. */
static void
peer_distribute_update (struct access_list *access)
{
afi_t afi;
safi_t safi;
int direct;
struct listnode *mnode, *mnnode;
struct listnode *node, *nnode;
struct bgp *bgp;
struct peer *peer;
struct peer_group *group;
struct bgp_filter *filter;
for (ALL_LIST_ELEMENTS (bm->bgp, mnode, mnnode, bgp))
{
for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer))
{
for (afi = AFI_IP; afi < AFI_MAX; afi++)
for (safi = SAFI_UNICAST; safi < SAFI_MAX; safi++)
{
filter = &peer->filter[afi][safi];
for (direct = FILTER_IN; direct < FILTER_MAX; direct++)
{
if (filter->dlist[direct].name)
filter->dlist[direct].alist =
access_list_lookup (afi, filter->dlist[direct].name);
else
filter->dlist[direct].alist = NULL;
}
}
}
for (ALL_LIST_ELEMENTS (bgp->group, node, nnode, group))
{
for (afi = AFI_IP; afi < AFI_MAX; afi++)
for (safi = SAFI_UNICAST; safi < SAFI_MAX; safi++)
{
filter = &group->conf->filter[afi][safi];
for (direct = FILTER_IN; direct < FILTER_MAX; direct++)
{
if (filter->dlist[direct].name)
filter->dlist[direct].alist =
access_list_lookup (afi, filter->dlist[direct].name);
else
filter->dlist[direct].alist = NULL;
}
}
}
}
}
/* Set prefix list to the peer. */
int
peer_prefix_list_set (struct peer *peer, afi_t afi, safi_t safi, int direct,
const char *name)
{
struct bgp_filter *filter;
struct peer_group *group;
struct listnode *node, *nnode;
if (! peer->afc[afi][safi])
return BGP_ERR_PEER_INACTIVE;
if (direct != FILTER_IN && direct != FILTER_OUT)
return BGP_ERR_INVALID_VALUE;
if (direct == FILTER_OUT && peer_is_group_member (peer, afi, safi))
return BGP_ERR_INVALID_FOR_PEER_GROUP_MEMBER;
filter = &peer->filter[afi][safi];
if (filter->dlist[direct].name)
return BGP_ERR_PEER_FILTER_CONFLICT;
if (filter->plist[direct].name)
free (filter->plist[direct].name);
filter->plist[direct].name = strdup (name);
filter->plist[direct].plist = prefix_list_lookup (afi, name);
if (! CHECK_FLAG (peer->sflags, PEER_STATUS_GROUP))
return 0;
group = peer->group;
for (ALL_LIST_ELEMENTS (group->peer, node, nnode, peer))
{
filter = &peer->filter[afi][safi];
if (! peer->af_group[afi][safi])
continue;
if (filter->plist[direct].name)
free (filter->plist[direct].name);
filter->plist[direct].name = strdup (name);
filter->plist[direct].plist = prefix_list_lookup (afi, name);
}
return 0;
}
int
peer_prefix_list_unset (struct peer *peer, afi_t afi, safi_t safi, int direct)
{
struct bgp_filter *filter;
struct bgp_filter *gfilter;
struct peer_group *group;
struct listnode *node, *nnode;
if (! peer->afc[afi][safi])
return BGP_ERR_PEER_INACTIVE;
if (direct != FILTER_IN && direct != FILTER_OUT)
return BGP_ERR_INVALID_VALUE;
if (direct == FILTER_OUT && peer_is_group_member (peer, afi, safi))
return BGP_ERR_INVALID_FOR_PEER_GROUP_MEMBER;
filter = &peer->filter[afi][safi];
/* apply peer-group filter */
if (peer->af_group[afi][safi])
{
gfilter = &peer->group->conf->filter[afi][safi];
if (gfilter->plist[direct].name)
{
if (filter->plist[direct].name)
free (filter->plist[direct].name);
filter->plist[direct].name = strdup (gfilter->plist[direct].name);
filter->plist[direct].plist = gfilter->plist[direct].plist;
return 0;
}
}
if (filter->plist[direct].name)
free (filter->plist[direct].name);
filter->plist[direct].name = NULL;
filter->plist[direct].plist = NULL;
if (! CHECK_FLAG (peer->sflags, PEER_STATUS_GROUP))
return 0;
group = peer->group;
for (ALL_LIST_ELEMENTS (group->peer, node, nnode, peer))
{
filter = &peer->filter[afi][safi];
if (! peer->af_group[afi][safi])
continue;
if (filter->plist[direct].name)
free (filter->plist[direct].name);
filter->plist[direct].name = NULL;
filter->plist[direct].plist = NULL;
}
return 0;
}
/* Update prefix-list list. */
static void
peer_prefix_list_update (struct prefix_list *plist)
{
struct listnode *mnode, *mnnode;
struct listnode *node, *nnode;
struct bgp *bgp;
struct peer *peer;
struct peer_group *group;
struct bgp_filter *filter;
afi_t afi;
safi_t safi;
int direct;
for (ALL_LIST_ELEMENTS (bm->bgp, mnode, mnnode, bgp))
{
for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer))
{
for (afi = AFI_IP; afi < AFI_MAX; afi++)
for (safi = SAFI_UNICAST; safi < SAFI_MAX; safi++)
{
filter = &peer->filter[afi][safi];
for (direct = FILTER_IN; direct < FILTER_MAX; direct++)
{
if (filter->plist[direct].name)
filter->plist[direct].plist =
prefix_list_lookup (afi, filter->plist[direct].name);
else
filter->plist[direct].plist = NULL;
}
}
}
for (ALL_LIST_ELEMENTS (bgp->group, node, nnode, group))
{
for (afi = AFI_IP; afi < AFI_MAX; afi++)
for (safi = SAFI_UNICAST; safi < SAFI_MAX; safi++)
{
filter = &group->conf->filter[afi][safi];
for (direct = FILTER_IN; direct < FILTER_MAX; direct++)
{
if (filter->plist[direct].name)
filter->plist[direct].plist =
prefix_list_lookup (afi, filter->plist[direct].name);
else
filter->plist[direct].plist = NULL;
}
}
}
}
}
int
peer_aslist_set (struct peer *peer, afi_t afi, safi_t safi, int direct,
const char *name)
{
struct bgp_filter *filter;
struct peer_group *group;
struct listnode *node, *nnode;
if (! peer->afc[afi][safi])
return BGP_ERR_PEER_INACTIVE;
if (direct != FILTER_IN && direct != FILTER_OUT)
return BGP_ERR_INVALID_VALUE;
if (direct == FILTER_OUT && peer_is_group_member (peer, afi, safi))
return BGP_ERR_INVALID_FOR_PEER_GROUP_MEMBER;
filter = &peer->filter[afi][safi];
if (filter->aslist[direct].name)
free (filter->aslist[direct].name);
filter->aslist[direct].name = strdup (name);
filter->aslist[direct].aslist = as_list_lookup (name);
if (! CHECK_FLAG (peer->sflags, PEER_STATUS_GROUP))
return 0;
group = peer->group;
for (ALL_LIST_ELEMENTS (group->peer, node, nnode, peer))
{
filter = &peer->filter[afi][safi];
if (! peer->af_group[afi][safi])
continue;
if (filter->aslist[direct].name)
free (filter->aslist[direct].name);
filter->aslist[direct].name = strdup (name);
filter->aslist[direct].aslist = as_list_lookup (name);
}
return 0;
}
int
peer_aslist_unset (struct peer *peer,afi_t afi, safi_t safi, int direct)
{
struct bgp_filter *filter;
struct bgp_filter *gfilter;
struct peer_group *group;
struct listnode *node, *nnode;
if (! peer->afc[afi][safi])
return BGP_ERR_PEER_INACTIVE;
if (direct != FILTER_IN && direct != FILTER_OUT)
return BGP_ERR_INVALID_VALUE;
if (direct == FILTER_OUT && peer_is_group_member (peer, afi, safi))
return BGP_ERR_INVALID_FOR_PEER_GROUP_MEMBER;
filter = &peer->filter[afi][safi];
/* apply peer-group filter */
if (peer->af_group[afi][safi])
{
gfilter = &peer->group->conf->filter[afi][safi];
if (gfilter->aslist[direct].name)
{
if (filter->aslist[direct].name)
free (filter->aslist[direct].name);
filter->aslist[direct].name = strdup (gfilter->aslist[direct].name);
filter->aslist[direct].aslist = gfilter->aslist[direct].aslist;
return 0;
}
}
if (filter->aslist[direct].name)
free (filter->aslist[direct].name);
filter->aslist[direct].name = NULL;
filter->aslist[direct].aslist = NULL;
if (! CHECK_FLAG (peer->sflags, PEER_STATUS_GROUP))
return 0;
group = peer->group;
for (ALL_LIST_ELEMENTS (group->peer, node, nnode, peer))
{
filter = &peer->filter[afi][safi];
if (! peer->af_group[afi][safi])
continue;
if (filter->aslist[direct].name)
free (filter->aslist[direct].name);
filter->aslist[direct].name = NULL;
filter->aslist[direct].aslist = NULL;
}
return 0;
}
static void
peer_aslist_update (void)
{
afi_t afi;
safi_t safi;
int direct;
struct listnode *mnode, *mnnode;
struct listnode *node, *nnode;
struct bgp *bgp;
struct peer *peer;
struct peer_group *group;
struct bgp_filter *filter;
for (ALL_LIST_ELEMENTS (bm->bgp, mnode, mnnode, bgp))
{
for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer))
{
for (afi = AFI_IP; afi < AFI_MAX; afi++)
for (safi = SAFI_UNICAST; safi < SAFI_MAX; safi++)
{
filter = &peer->filter[afi][safi];
for (direct = FILTER_IN; direct < FILTER_MAX; direct++)
{
if (filter->aslist[direct].name)
filter->aslist[direct].aslist =
as_list_lookup (filter->aslist[direct].name);
else
filter->aslist[direct].aslist = NULL;
}
}
}
for (ALL_LIST_ELEMENTS (bgp->group, node, nnode, group))
{
for (afi = AFI_IP; afi < AFI_MAX; afi++)
for (safi = SAFI_UNICAST; safi < SAFI_MAX; safi++)
{
filter = &group->conf->filter[afi][safi];
for (direct = FILTER_IN; direct < FILTER_MAX; direct++)
{
if (filter->aslist[direct].name)
filter->aslist[direct].aslist =
as_list_lookup (filter->aslist[direct].name);
else
filter->aslist[direct].aslist = NULL;
}
}
}
}
}
/* Set route-map to the peer. */
int
peer_route_map_set (struct peer *peer, afi_t afi, safi_t safi, int direct,
const char *name)
{
struct bgp_filter *filter;
struct peer_group *group;
struct listnode *node, *nnode;
if (! peer->afc[afi][safi])
return BGP_ERR_PEER_INACTIVE;
if (direct != RMAP_IN && direct != RMAP_OUT &&
direct != RMAP_IMPORT && direct != RMAP_EXPORT)
return BGP_ERR_INVALID_VALUE;
if ( (direct == RMAP_OUT || direct == RMAP_IMPORT)
&& peer_is_group_member (peer, afi, safi))
return BGP_ERR_INVALID_FOR_PEER_GROUP_MEMBER;
filter = &peer->filter[afi][safi];
if (filter->map[direct].name)
free (filter->map[direct].name);
filter->map[direct].name = strdup (name);
filter->map[direct].map = route_map_lookup_by_name (name);
if (! CHECK_FLAG (peer->sflags, PEER_STATUS_GROUP))
return 0;
group = peer->group;
for (ALL_LIST_ELEMENTS (group->peer, node, nnode, peer))
{
filter = &peer->filter[afi][safi];
if (! peer->af_group[afi][safi])
continue;
if (filter->map[direct].name)
free (filter->map[direct].name);
filter->map[direct].name = strdup (name);
filter->map[direct].map = route_map_lookup_by_name (name);
}
return 0;
}
/* Unset route-map from the peer. */
int
peer_route_map_unset (struct peer *peer, afi_t afi, safi_t safi, int direct)
{
struct bgp_filter *filter;
struct bgp_filter *gfilter;
struct peer_group *group;
struct listnode *node, *nnode;
if (! peer->afc[afi][safi])
return BGP_ERR_PEER_INACTIVE;
if (direct != RMAP_IN && direct != RMAP_OUT &&
direct != RMAP_IMPORT && direct != RMAP_EXPORT)
return BGP_ERR_INVALID_VALUE;
if ( (direct == RMAP_OUT || direct == RMAP_IMPORT)
&& peer_is_group_member (peer, afi, safi))
return BGP_ERR_INVALID_FOR_PEER_GROUP_MEMBER;
filter = &peer->filter[afi][safi];
/* apply peer-group filter */
if (peer->af_group[afi][safi])
{
gfilter = &peer->group->conf->filter[afi][safi];
if (gfilter->map[direct].name)
{
if (filter->map[direct].name)
free (filter->map[direct].name);
filter->map[direct].name = strdup (gfilter->map[direct].name);
filter->map[direct].map = gfilter->map[direct].map;
return 0;
}
}
if (filter->map[direct].name)
free (filter->map[direct].name);
filter->map[direct].name = NULL;
filter->map[direct].map = NULL;
if (! CHECK_FLAG (peer->sflags, PEER_STATUS_GROUP))
return 0;
group = peer->group;
for (ALL_LIST_ELEMENTS (group->peer, node, nnode, peer))
{
filter = &peer->filter[afi][safi];
if (! peer->af_group[afi][safi])
continue;
if (filter->map[direct].name)
free (filter->map[direct].name);
filter->map[direct].name = NULL;
filter->map[direct].map = NULL;
}
return 0;
}
/* Set unsuppress-map to the peer. */
int
peer_unsuppress_map_set (struct peer *peer, afi_t afi, safi_t safi,
const char *name)
{
struct bgp_filter *filter;
struct peer_group *group;
struct listnode *node, *nnode;
if (! peer->afc[afi][safi])
return BGP_ERR_PEER_INACTIVE;
if (peer_is_group_member (peer, afi, safi))
return BGP_ERR_INVALID_FOR_PEER_GROUP_MEMBER;
filter = &peer->filter[afi][safi];
if (filter->usmap.name)
free (filter->usmap.name);
filter->usmap.name = strdup (name);
filter->usmap.map = route_map_lookup_by_name (name);
if (! CHECK_FLAG (peer->sflags, PEER_STATUS_GROUP))
return 0;
group = peer->group;
for (ALL_LIST_ELEMENTS (group->peer, node, nnode, peer))
{
filter = &peer->filter[afi][safi];
if (! peer->af_group[afi][safi])
continue;
if (filter->usmap.name)
free (filter->usmap.name);
filter->usmap.name = strdup (name);
filter->usmap.map = route_map_lookup_by_name (name);
}
return 0;
}
/* Unset route-map from the peer. */
int
peer_unsuppress_map_unset (struct peer *peer, afi_t afi, safi_t safi)
{
struct bgp_filter *filter;
struct peer_group *group;
struct listnode *node, *nnode;
if (! peer->afc[afi][safi])
return BGP_ERR_PEER_INACTIVE;
if (peer_is_group_member (peer, afi, safi))
return BGP_ERR_INVALID_FOR_PEER_GROUP_MEMBER;
filter = &peer->filter[afi][safi];
if (filter->usmap.name)
free (filter->usmap.name);
filter->usmap.name = NULL;
filter->usmap.map = NULL;
if (! CHECK_FLAG (peer->sflags, PEER_STATUS_GROUP))
return 0;
group = peer->group;
for (ALL_LIST_ELEMENTS (group->peer, node, nnode, peer))
{
filter = &peer->filter[afi][safi];
if (! peer->af_group[afi][safi])
continue;
if (filter->usmap.name)
free (filter->usmap.name);
filter->usmap.name = NULL;
filter->usmap.map = NULL;
}
return 0;
}
int
peer_maximum_prefix_set (struct peer *peer, afi_t afi, safi_t safi,
u_int32_t max, u_char threshold,
int warning, u_int16_t restart)
{
struct peer_group *group;
struct listnode *node, *nnode;
if (! peer->afc[afi][safi])
return BGP_ERR_PEER_INACTIVE;
SET_FLAG (peer->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX);
peer->pmax[afi][safi] = max;
peer->pmax_threshold[afi][safi] = threshold;
peer->pmax_restart[afi][safi] = restart;
if (warning)
SET_FLAG (peer->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX_WARNING);
else
UNSET_FLAG (peer->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX_WARNING);
if (! CHECK_FLAG (peer->sflags, PEER_STATUS_GROUP))
return 0;
group = peer->group;
for (ALL_LIST_ELEMENTS (group->peer, node, nnode, peer))
{
if (! peer->af_group[afi][safi])
continue;
SET_FLAG (peer->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX);
peer->pmax[afi][safi] = max;
peer->pmax_threshold[afi][safi] = threshold;
peer->pmax_restart[afi][safi] = restart;
if (warning)
SET_FLAG (peer->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX_WARNING);
else
UNSET_FLAG (peer->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX_WARNING);
}
return 0;
}
int
peer_maximum_prefix_unset (struct peer *peer, afi_t afi, safi_t safi)
{
struct peer_group *group;
struct listnode *node, *nnode;
if (! peer->afc[afi][safi])
return BGP_ERR_PEER_INACTIVE;
/* apply peer-group config */
if (peer->af_group[afi][safi])
{
if (CHECK_FLAG (peer->group->conf->af_flags[afi][safi],
PEER_FLAG_MAX_PREFIX))
SET_FLAG (peer->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX);
else
UNSET_FLAG (peer->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX);
if (CHECK_FLAG (peer->group->conf->af_flags[afi][safi],
PEER_FLAG_MAX_PREFIX_WARNING))
SET_FLAG (peer->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX_WARNING);
else
UNSET_FLAG (peer->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX_WARNING);
peer->pmax[afi][safi] = peer->group->conf->pmax[afi][safi];
peer->pmax_threshold[afi][safi] = peer->group->conf->pmax_threshold[afi][safi];
peer->pmax_restart[afi][safi] = peer->group->conf->pmax_restart[afi][safi];
return 0;
}
UNSET_FLAG (peer->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX);
UNSET_FLAG (peer->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX_WARNING);
peer->pmax[afi][safi] = 0;
peer->pmax_threshold[afi][safi] = 0;
peer->pmax_restart[afi][safi] = 0;
if (! CHECK_FLAG (peer->sflags, PEER_STATUS_GROUP))
return 0;
group = peer->group;
for (ALL_LIST_ELEMENTS (group->peer, node, nnode, peer))
{
if (! peer->af_group[afi][safi])
continue;
UNSET_FLAG (peer->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX);
UNSET_FLAG (peer->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX_WARNING);
peer->pmax[afi][safi] = 0;
peer->pmax_threshold[afi][safi] = 0;
peer->pmax_restart[afi][safi] = 0;
}
return 0;
}
/* Set # of hops between us and BGP peer. */
int
peer_ttl_security_hops_set (struct peer *peer, int gtsm_hops)
{
struct peer_group *group;
struct listnode *node, *nnode;
struct peer *peer1;
int ret;
zlog_debug ("peer_ttl_security_hops_set: set gtsm_hops to %d for %s", gtsm_hops, peer->host);
if (peer_sort (peer) == BGP_PEER_IBGP)
return BGP_ERR_NO_IBGP_WITH_TTLHACK;
/* We cannot configure ttl-security hops when ebgp-multihop is already
set. For non peer-groups, the check is simple. For peer-groups, it's
slightly messy, because we need to check both the peer-group structure
and all peer-group members for any trace of ebgp-multihop configuration
before actually applying the ttl-security rules. Cisco really made a
mess of this configuration parameter, and OpenBGPD got it right.
*/
if (peer->gtsm_hops == 0) {
if (CHECK_FLAG (peer->sflags, PEER_STATUS_GROUP))
{
group = peer->group;
if (group->conf->ttl != 1)
return BGP_ERR_NO_EBGP_MULTIHOP_WITH_TTLHACK;
for (ALL_LIST_ELEMENTS (group->peer, node, nnode, peer1))
{
if (peer_sort (peer1) == BGP_PEER_IBGP)
continue;
if (peer1->ttl != 1)
return BGP_ERR_NO_EBGP_MULTIHOP_WITH_TTLHACK;
}
}
else
{
if (peer->ttl != 1)
return BGP_ERR_NO_EBGP_MULTIHOP_WITH_TTLHACK;
}
/* specify MAXTTL on outgoing packets */
ret = peer_ebgp_multihop_set (peer, MAXTTL);
if (ret != 0)
return ret;
}
peer->gtsm_hops = gtsm_hops;
if (! CHECK_FLAG (peer->sflags, PEER_STATUS_GROUP))
{
if (peer->fd >= 0 && peer_sort (peer) != BGP_PEER_IBGP)
sockopt_minttl (peer->su.sa.sa_family, peer->fd, MAXTTL + 1 - gtsm_hops);
}
else
{
group = peer->group;
for (ALL_LIST_ELEMENTS (group->peer, node, nnode, peer))
{
if (peer_sort (peer) == BGP_PEER_IBGP)
continue;
peer->gtsm_hops = group->conf->gtsm_hops;
/* Change setting of existing peer
* established then change value (may break connectivity)
* not established yet (teardown session and restart)
* no session then do nothing (will get handled by next connection)
*/
if (peer->status == Established)
{
if (peer->fd >= 0 && peer->gtsm_hops != 0)
sockopt_minttl (peer->su.sa.sa_family, peer->fd,
MAXTTL + 1 - peer->gtsm_hops);
}
else if (peer->status < Established)
{
if (BGP_DEBUG (events, EVENTS))
zlog_debug ("%s Min-ttl changed", peer->host);
BGP_EVENT_ADD (peer, BGP_Stop);
}
}
}
return 0;
}
int
peer_ttl_security_hops_unset (struct peer *peer)
{
struct peer_group *group;
struct listnode *node, *nnode;
struct peer *opeer;
zlog_debug ("peer_ttl_security_hops_unset: set gtsm_hops to zero for %s", peer->host);
if (peer_sort (peer) == BGP_PEER_IBGP)
return 0;
/* if a peer-group member, then reset to peer-group default rather than 0 */
if (peer_group_active (peer))
peer->gtsm_hops = peer->group->conf->gtsm_hops;
else
peer->gtsm_hops = 0;
opeer = peer;
if (! CHECK_FLAG (peer->sflags, PEER_STATUS_GROUP))
{
if (peer->fd >= 0 && peer_sort (peer) != BGP_PEER_IBGP)
sockopt_minttl (peer->su.sa.sa_family, peer->fd, 0);
}
else
{
group = peer->group;
for (ALL_LIST_ELEMENTS (group->peer, node, nnode, peer))
{
if (peer_sort (peer) == BGP_PEER_IBGP)
continue;
peer->gtsm_hops = 0;
if (peer->fd >= 0)
sockopt_minttl (peer->su.sa.sa_family, peer->fd, 0);
}
}
return peer_ebgp_multihop_unset (opeer);
}
int
peer_clear (struct peer *peer)
{
if (! CHECK_FLAG (peer->flags, PEER_FLAG_SHUTDOWN))
{
if (CHECK_FLAG (peer->sflags, PEER_STATUS_PREFIX_OVERFLOW))
{
UNSET_FLAG (peer->sflags, PEER_STATUS_PREFIX_OVERFLOW);
if (peer->t_pmax_restart)
{
BGP_TIMER_OFF (peer->t_pmax_restart);
if (BGP_DEBUG (events, EVENTS))
zlog_debug ("%s Maximum-prefix restart timer canceled",
peer->host);
}
BGP_EVENT_ADD (peer, BGP_Start);
return 0;
}
peer->v_start = BGP_INIT_START_TIMER;
if (peer->status == Established)
bgp_notify_send (peer, BGP_NOTIFY_CEASE,
BGP_NOTIFY_CEASE_ADMIN_RESET);
else
BGP_EVENT_ADD (peer, BGP_Stop);
}
return 0;
}
int
peer_clear_soft (struct peer *peer, afi_t afi, safi_t safi,
enum bgp_clear_type stype)
{
if (peer->status != Established)
return 0;
if (! peer->afc[afi][safi])
return BGP_ERR_AF_UNCONFIGURED;
if (stype == BGP_CLEAR_SOFT_RSCLIENT)
{
if (! CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT))
return 0;
bgp_check_local_routes_rsclient (peer, afi, safi);
bgp_soft_reconfig_rsclient (peer, afi, safi);
}
if (stype == BGP_CLEAR_SOFT_OUT || stype == BGP_CLEAR_SOFT_BOTH)
bgp_announce_route (peer, afi, safi);
if (stype == BGP_CLEAR_SOFT_IN_ORF_PREFIX)
{
if (CHECK_FLAG (peer->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV)
&& (CHECK_FLAG (peer->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_RCV)
|| CHECK_FLAG (peer->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_OLD_RCV)))
{
struct bgp_filter *filter = &peer->filter[afi][safi];
u_char prefix_type;
if (CHECK_FLAG (peer->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_RCV))
prefix_type = ORF_TYPE_PREFIX;
else
prefix_type = ORF_TYPE_PREFIX_OLD;
if (filter->plist[FILTER_IN].plist)
{
if (CHECK_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_ORF_PREFIX_SEND))
bgp_route_refresh_send (peer, afi, safi,
prefix_type, REFRESH_DEFER, 1);
bgp_route_refresh_send (peer, afi, safi, prefix_type,
REFRESH_IMMEDIATE, 0);
}
else
{
if (CHECK_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_ORF_PREFIX_SEND))
bgp_route_refresh_send (peer, afi, safi,
prefix_type, REFRESH_IMMEDIATE, 1);
else
bgp_route_refresh_send (peer, afi, safi, 0, 0, 0);
}
return 0;
}
}
if (stype == BGP_CLEAR_SOFT_IN || stype == BGP_CLEAR_SOFT_BOTH
|| stype == BGP_CLEAR_SOFT_IN_ORF_PREFIX)
{
/* If neighbor has soft reconfiguration inbound flag.
Use Adj-RIB-In database. */
if (CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_SOFT_RECONFIG))
bgp_soft_reconfig_in (peer, afi, safi);
else
{
/* If neighbor has route refresh capability, send route refresh
message to the peer. */
if (CHECK_FLAG (peer->cap, PEER_CAP_REFRESH_OLD_RCV)
|| CHECK_FLAG (peer->cap, PEER_CAP_REFRESH_NEW_RCV))
bgp_route_refresh_send (peer, afi, safi, 0, 0, 0);
else
return BGP_ERR_SOFT_RECONFIG_UNCONFIGURED;
}
}
return 0;
}
/* Display peer uptime.*/
/* XXX: why does this function return char * when it takes buffer? */
char *
peer_uptime (time_t uptime2, char *buf, size_t len)
{
time_t uptime1;
struct tm *tm;
/* Check buffer length. */
if (len < BGP_UPTIME_LEN)
{
zlog_warn ("peer_uptime (): buffer shortage %lu", (u_long)len);
/* XXX: should return status instead of buf... */
snprintf (buf, len, "<error> ");
return buf;
}
/* If there is no connection has been done before print `never'. */
if (uptime2 == 0)
{
snprintf (buf, len, "never ");
return buf;
}
/* Get current time. */
uptime1 = bgp_clock ();
uptime1 -= uptime2;
tm = gmtime (&uptime1);
/* Making formatted timer strings. */
#define ONE_DAY_SECOND 60*60*24
#define ONE_WEEK_SECOND 60*60*24*7
if (uptime1 < ONE_DAY_SECOND)
snprintf (buf, len, "%02d:%02d:%02d",
tm->tm_hour, tm->tm_min, tm->tm_sec);
else if (uptime1 < ONE_WEEK_SECOND)
snprintf (buf, len, "%dd%02dh%02dm",
tm->tm_yday, tm->tm_hour, tm->tm_min);
else
snprintf (buf, len, "%02dw%dd%02dh",
tm->tm_yday/7, tm->tm_yday - ((tm->tm_yday/7) * 7), tm->tm_hour);
return buf;
}
static void
bgp_config_write_filter (struct vty *vty, struct peer *peer,
afi_t afi, safi_t safi)
{
struct bgp_filter *filter;
struct bgp_filter *gfilter = NULL;
char *addr;
int in = FILTER_IN;
int out = FILTER_OUT;
addr = peer->host;
filter = &peer->filter[afi][safi];
if (peer->af_group[afi][safi])
gfilter = &peer->group->conf->filter[afi][safi];
/* distribute-list. */
if (filter->dlist[in].name)
if (! gfilter || ! gfilter->dlist[in].name
|| strcmp (filter->dlist[in].name, gfilter->dlist[in].name) != 0)
vty_out (vty, " neighbor %s distribute-list %s in%s", addr,
filter->dlist[in].name, VTY_NEWLINE);
if (filter->dlist[out].name && ! gfilter)
vty_out (vty, " neighbor %s distribute-list %s out%s", addr,
filter->dlist[out].name, VTY_NEWLINE);
/* prefix-list. */
if (filter->plist[in].name)
if (! gfilter || ! gfilter->plist[in].name
|| strcmp (filter->plist[in].name, gfilter->plist[in].name) != 0)
vty_out (vty, " neighbor %s prefix-list %s in%s", addr,
filter->plist[in].name, VTY_NEWLINE);
if (filter->plist[out].name && ! gfilter)
vty_out (vty, " neighbor %s prefix-list %s out%s", addr,
filter->plist[out].name, VTY_NEWLINE);
/* route-map. */
if (filter->map[RMAP_IN].name)
if (! gfilter || ! gfilter->map[RMAP_IN].name
|| strcmp (filter->map[RMAP_IN].name, gfilter->map[RMAP_IN].name) != 0)
vty_out (vty, " neighbor %s route-map %s in%s", addr,
filter->map[RMAP_IN].name, VTY_NEWLINE);
if (filter->map[RMAP_OUT].name && ! gfilter)
vty_out (vty, " neighbor %s route-map %s out%s", addr,
filter->map[RMAP_OUT].name, VTY_NEWLINE);
if (filter->map[RMAP_IMPORT].name && ! gfilter)
vty_out (vty, " neighbor %s route-map %s import%s", addr,
filter->map[RMAP_IMPORT].name, VTY_NEWLINE);
if (filter->map[RMAP_EXPORT].name)
if (! gfilter || ! gfilter->map[RMAP_EXPORT].name
|| strcmp (filter->map[RMAP_EXPORT].name,
gfilter->map[RMAP_EXPORT].name) != 0)
vty_out (vty, " neighbor %s route-map %s export%s", addr,
filter->map[RMAP_EXPORT].name, VTY_NEWLINE);
/* unsuppress-map */
if (filter->usmap.name && ! gfilter)
vty_out (vty, " neighbor %s unsuppress-map %s%s", addr,
filter->usmap.name, VTY_NEWLINE);
/* filter-list. */
if (filter->aslist[in].name)
if (! gfilter || ! gfilter->aslist[in].name
|| strcmp (filter->aslist[in].name, gfilter->aslist[in].name) != 0)
vty_out (vty, " neighbor %s filter-list %s in%s", addr,
filter->aslist[in].name, VTY_NEWLINE);
if (filter->aslist[out].name && ! gfilter)
vty_out (vty, " neighbor %s filter-list %s out%s", addr,
filter->aslist[out].name, VTY_NEWLINE);
}
/* BGP peer configuration display function. */
static void
bgp_config_write_peer (struct vty *vty, struct bgp *bgp,
struct peer *peer, afi_t afi, safi_t safi)
{
struct peer *g_peer = NULL;
char buf[SU_ADDRSTRLEN];
char *addr;
addr = peer->host;
if (peer_group_active (peer))
g_peer = peer->group->conf;
/************************************
****** Global to the neighbor ******
************************************/
if (afi == AFI_IP && safi == SAFI_UNICAST)
{
/* remote-as. */
if (! peer_group_active (peer))
{
if (CHECK_FLAG (peer->sflags, PEER_STATUS_GROUP))
vty_out (vty, " neighbor %s peer-group%s", addr,
VTY_NEWLINE);
if (peer->as)
vty_out (vty, " neighbor %s remote-as %u%s", addr, peer->as,
VTY_NEWLINE);
}
else
{
if (! g_peer->as)
vty_out (vty, " neighbor %s remote-as %u%s", addr, peer->as,
VTY_NEWLINE);
if (peer->af_group[AFI_IP][SAFI_UNICAST])
vty_out (vty, " neighbor %s peer-group %s%s", addr,
peer->group->name, VTY_NEWLINE);
}
/* local-as. */
if (peer->change_local_as)
if (! peer_group_active (peer))
vty_out (vty, " neighbor %s local-as %u%s%s", addr,
peer->change_local_as,
CHECK_FLAG (peer->flags, PEER_FLAG_LOCAL_AS_NO_PREPEND) ?
" no-prepend" : "", VTY_NEWLINE);
/* Description. */
if (peer->desc)
vty_out (vty, " neighbor %s description %s%s", addr, peer->desc,
VTY_NEWLINE);
/* Shutdown. */
if (CHECK_FLAG (peer->flags, PEER_FLAG_SHUTDOWN))
if (! peer_group_active (peer) ||
! CHECK_FLAG (g_peer->flags, PEER_FLAG_SHUTDOWN))
vty_out (vty, " neighbor %s shutdown%s", addr, VTY_NEWLINE);
/* Password. */
if (peer->password)
if (!peer_group_active (peer)
|| ! g_peer->password
|| strcmp (peer->password, g_peer->password) != 0)
vty_out (vty, " neighbor %s password %s%s", addr, peer->password,
VTY_NEWLINE);
/* BGP port. */
if (peer->port != BGP_PORT_DEFAULT)
vty_out (vty, " neighbor %s port %d%s", addr, peer->port,
VTY_NEWLINE);
/* Local interface name. */
if (peer->ifname)
vty_out (vty, " neighbor %s interface %s%s", addr, peer->ifname,
VTY_NEWLINE);
/* Passive. */
if (CHECK_FLAG (peer->flags, PEER_FLAG_PASSIVE))
if (! peer_group_active (peer) ||
! CHECK_FLAG (g_peer->flags, PEER_FLAG_PASSIVE))
vty_out (vty, " neighbor %s passive%s", addr, VTY_NEWLINE);
/* EBGP multihop. */
if (peer_sort (peer) != BGP_PEER_IBGP && peer->ttl != 1 &&
!(peer->gtsm_hops != 0 && peer->ttl == MAXTTL))
if (! peer_group_active (peer) ||
g_peer->ttl != peer->ttl)
vty_out (vty, " neighbor %s ebgp-multihop %d%s", addr, peer->ttl,
VTY_NEWLINE);
/* ttl-security hops */
if (peer_sort (peer) != BGP_PEER_IBGP && peer->gtsm_hops != 0)
if (! peer_group_active (peer) || g_peer->gtsm_hops != peer->gtsm_hops)
vty_out (vty, " neighbor %s ttl-security hops %d%s", addr,
peer->gtsm_hops, VTY_NEWLINE);
/* disable-connected-check. */
if (CHECK_FLAG (peer->flags, PEER_FLAG_DISABLE_CONNECTED_CHECK))
if (! peer_group_active (peer) ||
! CHECK_FLAG (g_peer->flags, PEER_FLAG_DISABLE_CONNECTED_CHECK))
vty_out (vty, " neighbor %s disable-connected-check%s", addr, VTY_NEWLINE);
/* Update-source. */
if (peer->update_if)
if (! peer_group_active (peer) || ! g_peer->update_if
|| strcmp (g_peer->update_if, peer->update_if) != 0)
vty_out (vty, " neighbor %s update-source %s%s", addr,
peer->update_if, VTY_NEWLINE);
if (peer->update_source)
if (! peer_group_active (peer) || ! g_peer->update_source
|| sockunion_cmp (g_peer->update_source,
peer->update_source) != 0)
vty_out (vty, " neighbor %s update-source %s%s", addr,
sockunion2str (peer->update_source, buf, SU_ADDRSTRLEN),
VTY_NEWLINE);
/* advertisement-interval */
if (CHECK_FLAG (peer->config, PEER_CONFIG_ROUTEADV))
vty_out (vty, " neighbor %s advertisement-interval %d%s",
addr, peer->v_routeadv, VTY_NEWLINE);
/* timers. */
if (CHECK_FLAG (peer->config, PEER_CONFIG_TIMER)
&& ! peer_group_active (peer))
vty_out (vty, " neighbor %s timers %d %d%s", addr,
peer->keepalive, peer->holdtime, VTY_NEWLINE);
if (CHECK_FLAG (peer->config, PEER_CONFIG_CONNECT))
vty_out (vty, " neighbor %s timers connect %d%s", addr,
peer->connect, VTY_NEWLINE);
/* Default weight. */
if (CHECK_FLAG (peer->config, PEER_CONFIG_WEIGHT))
if (! peer_group_active (peer) ||
g_peer->weight != peer->weight)
vty_out (vty, " neighbor %s weight %d%s", addr, peer->weight,
VTY_NEWLINE);
/* Dynamic capability. */
if (CHECK_FLAG (peer->flags, PEER_FLAG_DYNAMIC_CAPABILITY))
if (! peer_group_active (peer) ||
! CHECK_FLAG (g_peer->flags, PEER_FLAG_DYNAMIC_CAPABILITY))
vty_out (vty, " neighbor %s capability dynamic%s", addr,
VTY_NEWLINE);
/* dont capability negotiation. */
if (CHECK_FLAG (peer->flags, PEER_FLAG_DONT_CAPABILITY))
if (! peer_group_active (peer) ||
! CHECK_FLAG (g_peer->flags, PEER_FLAG_DONT_CAPABILITY))
vty_out (vty, " neighbor %s dont-capability-negotiate%s", addr,
VTY_NEWLINE);
/* override capability negotiation. */
if (CHECK_FLAG (peer->flags, PEER_FLAG_OVERRIDE_CAPABILITY))
if (! peer_group_active (peer) ||
! CHECK_FLAG (g_peer->flags, PEER_FLAG_OVERRIDE_CAPABILITY))
vty_out (vty, " neighbor %s override-capability%s", addr,
VTY_NEWLINE);
/* strict capability negotiation. */
if (CHECK_FLAG (peer->flags, PEER_FLAG_STRICT_CAP_MATCH))
if (! peer_group_active (peer) ||
! CHECK_FLAG (g_peer->flags, PEER_FLAG_STRICT_CAP_MATCH))
vty_out (vty, " neighbor %s strict-capability-match%s", addr,
VTY_NEWLINE);
if (! peer_group_active (peer))
{
if (bgp_flag_check (bgp, BGP_FLAG_NO_DEFAULT_IPV4))
{
if (peer->afc[AFI_IP][SAFI_UNICAST])
vty_out (vty, " neighbor %s activate%s", addr, VTY_NEWLINE);
}
else
{
if (! peer->afc[AFI_IP][SAFI_UNICAST])
vty_out (vty, " no neighbor %s activate%s", addr, VTY_NEWLINE);
}
}
}
/************************************
****** Per AF to the neighbor ******
************************************/
if (! (afi == AFI_IP && safi == SAFI_UNICAST))
{
if (peer->af_group[afi][safi])
vty_out (vty, " neighbor %s peer-group %s%s", addr,
peer->group->name, VTY_NEWLINE);
else
vty_out (vty, " neighbor %s activate%s", addr, VTY_NEWLINE);
}
/* ORF capability. */
if (CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_ORF_PREFIX_SM)
|| CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_ORF_PREFIX_RM))
if (! peer->af_group[afi][safi])
{
vty_out (vty, " neighbor %s capability orf prefix-list", addr);
if (CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_ORF_PREFIX_SM)
&& CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_ORF_PREFIX_RM))
vty_out (vty, " both");
else if (CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_ORF_PREFIX_SM))
vty_out (vty, " send");
else
vty_out (vty, " receive");
vty_out (vty, "%s", VTY_NEWLINE);
}
/* Route reflector client. */
if (peer_af_flag_check (peer, afi, safi, PEER_FLAG_REFLECTOR_CLIENT)
&& ! peer->af_group[afi][safi])
vty_out (vty, " neighbor %s route-reflector-client%s", addr,
VTY_NEWLINE);
/* Nexthop self. */
if (peer_af_flag_check (peer, afi, safi, PEER_FLAG_NEXTHOP_SELF)
&& ! peer->af_group[afi][safi])
vty_out (vty, " neighbor %s next-hop-self%s", addr, VTY_NEWLINE);
/* Remove private AS. */
if (peer_af_flag_check (peer, afi, safi, PEER_FLAG_REMOVE_PRIVATE_AS)
&& ! peer->af_group[afi][safi])
vty_out (vty, " neighbor %s remove-private-AS%s",
addr, VTY_NEWLINE);
/* send-community print. */
if (! peer->af_group[afi][safi])
{
if (bgp_option_check (BGP_OPT_CONFIG_CISCO))
{
if (peer_af_flag_check (peer, afi, safi, PEER_FLAG_SEND_COMMUNITY)
&& peer_af_flag_check (peer, afi, safi, PEER_FLAG_SEND_EXT_COMMUNITY))
vty_out (vty, " neighbor %s send-community both%s", addr, VTY_NEWLINE);
else if (peer_af_flag_check (peer, afi, safi, PEER_FLAG_SEND_EXT_COMMUNITY))
vty_out (vty, " neighbor %s send-community extended%s",
addr, VTY_NEWLINE);
else if (peer_af_flag_check (peer, afi, safi, PEER_FLAG_SEND_COMMUNITY))
vty_out (vty, " neighbor %s send-community%s", addr, VTY_NEWLINE);
}
else
{
if (! peer_af_flag_check (peer, afi, safi, PEER_FLAG_SEND_COMMUNITY)
&& ! peer_af_flag_check (peer, afi, safi, PEER_FLAG_SEND_EXT_COMMUNITY))
vty_out (vty, " no neighbor %s send-community both%s",
addr, VTY_NEWLINE);
else if (! peer_af_flag_check (peer, afi, safi, PEER_FLAG_SEND_EXT_COMMUNITY))
vty_out (vty, " no neighbor %s send-community extended%s",
addr, VTY_NEWLINE);
else if (! peer_af_flag_check (peer, afi, safi, PEER_FLAG_SEND_COMMUNITY))
vty_out (vty, " no neighbor %s send-community%s",
addr, VTY_NEWLINE);
}
}
/* Default information */
if (peer_af_flag_check (peer, afi, safi, PEER_FLAG_DEFAULT_ORIGINATE)
&& ! peer->af_group[afi][safi])
{
vty_out (vty, " neighbor %s default-originate", addr);
if (peer->default_rmap[afi][safi].name)
vty_out (vty, " route-map %s", peer->default_rmap[afi][safi].name);
vty_out (vty, "%s", VTY_NEWLINE);
}
/* Soft reconfiguration inbound. */
if (CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_SOFT_RECONFIG))
if (! peer->af_group[afi][safi] ||
! CHECK_FLAG (g_peer->af_flags[afi][safi], PEER_FLAG_SOFT_RECONFIG))
vty_out (vty, " neighbor %s soft-reconfiguration inbound%s", addr,
VTY_NEWLINE);
/* maximum-prefix. */
if (CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX))
if (! peer->af_group[afi][safi]
|| g_peer->pmax[afi][safi] != peer->pmax[afi][safi]
|| g_peer->pmax_threshold[afi][safi] != peer->pmax_threshold[afi][safi]
|| CHECK_FLAG (g_peer->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX_WARNING)
!= CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX_WARNING))
{
vty_out (vty, " neighbor %s maximum-prefix %ld", addr, peer->pmax[afi][safi]);
if (peer->pmax_threshold[afi][safi] != MAXIMUM_PREFIX_THRESHOLD_DEFAULT)
vty_out (vty, " %d", peer->pmax_threshold[afi][safi]);
if (CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX_WARNING))
vty_out (vty, " warning-only");
if (peer->pmax_restart[afi][safi])
vty_out (vty, " restart %d", peer->pmax_restart[afi][safi]);
vty_out (vty, "%s", VTY_NEWLINE);
}
/* Route server client. */
if (CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT)
&& ! peer->af_group[afi][safi])
vty_out (vty, " neighbor %s route-server-client%s", addr, VTY_NEWLINE);
/* Nexthop-local unchanged. */
if (CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED)
&& ! peer->af_group[afi][safi])
vty_out (vty, " neighbor %s nexthop-local unchanged%s", addr, VTY_NEWLINE);
/* Allow AS in. */
if (peer_af_flag_check (peer, afi, safi, PEER_FLAG_ALLOWAS_IN))
if (! peer_group_active (peer)
|| ! peer_af_flag_check (g_peer, afi, safi, PEER_FLAG_ALLOWAS_IN)
|| peer->allowas_in[afi][safi] != g_peer->allowas_in[afi][safi])
{
if (peer->allowas_in[afi][safi] == 3)
vty_out (vty, " neighbor %s allowas-in%s", addr, VTY_NEWLINE);
else
vty_out (vty, " neighbor %s allowas-in %d%s", addr,
peer->allowas_in[afi][safi], VTY_NEWLINE);
}
/* Filter. */
bgp_config_write_filter (vty, peer, afi, safi);
/* atribute-unchanged. */
if ((CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_AS_PATH_UNCHANGED)
|| CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_NEXTHOP_UNCHANGED)
|| CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_MED_UNCHANGED))
&& ! peer->af_group[afi][safi])
{
if (CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_AS_PATH_UNCHANGED)
&& CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_NEXTHOP_UNCHANGED)
&& CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_MED_UNCHANGED))
vty_out (vty, " neighbor %s attribute-unchanged%s", addr, VTY_NEWLINE);
else
vty_out (vty, " neighbor %s attribute-unchanged%s%s%s%s", addr,
(CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_AS_PATH_UNCHANGED)) ?
" as-path" : "",
(CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_NEXTHOP_UNCHANGED)) ?
" next-hop" : "",
(CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_MED_UNCHANGED)) ?
" med" : "", VTY_NEWLINE);
}
}
/* Display "address-family" configuration header. */
void
bgp_config_write_family_header (struct vty *vty, afi_t afi, safi_t safi,
int *write)
{
if (*write)
return;
if (afi == AFI_IP && safi == SAFI_UNICAST)
return;
vty_out (vty, "!%s address-family ", VTY_NEWLINE);
if (afi == AFI_IP)
{
if (safi == SAFI_MULTICAST)
vty_out (vty, "ipv4 multicast");
else if (safi == SAFI_MPLS_VPN)
vty_out (vty, "vpnv4 unicast");
}
else if (afi == AFI_IP6)
{
vty_out (vty, "ipv6");
if (safi == SAFI_MULTICAST)
vty_out (vty, " multicast");
}
vty_out (vty, "%s", VTY_NEWLINE);
*write = 1;
}
/* Address family based peer configuration display. */
static int
bgp_config_write_family (struct vty *vty, struct bgp *bgp, afi_t afi,
safi_t safi)
{
int write = 0;
struct peer *peer;
struct peer_group *group;
struct listnode *node, *nnode;
bgp_config_write_network (vty, bgp, afi, safi, &write);
bgp_config_write_redistribute (vty, bgp, afi, safi, &write);
for (ALL_LIST_ELEMENTS (bgp->group, node, nnode, group))
{
if (group->conf->afc[afi][safi])
{
bgp_config_write_family_header (vty, afi, safi, &write);
bgp_config_write_peer (vty, bgp, group->conf, afi, safi);
}
}
for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer))
{
if (peer->afc[afi][safi])
{
if (! CHECK_FLAG (peer->sflags, PEER_STATUS_ACCEPT_PEER))
{
bgp_config_write_family_header (vty, afi, safi, &write);
bgp_config_write_peer (vty, bgp, peer, afi, safi);
}
}
}
bgp_config_write_maxpaths (vty, bgp, afi, safi, &write);
if (write)
vty_out (vty, " exit-address-family%s", VTY_NEWLINE);
return write;
}
int
bgp_config_write (struct vty *vty)
{
int write = 0;
struct bgp *bgp;
struct peer_group *group;
struct peer *peer;
struct listnode *node, *nnode;
struct listnode *mnode, *mnnode;
/* BGP Multiple instance. */
if (bgp_option_check (BGP_OPT_MULTIPLE_INSTANCE))
{
vty_out (vty, "bgp multiple-instance%s", VTY_NEWLINE);
write++;
}
/* BGP Config type. */
if (bgp_option_check (BGP_OPT_CONFIG_CISCO))
{
vty_out (vty, "bgp config-type cisco%s", VTY_NEWLINE);
write++;
}
/* BGP configuration. */
for (ALL_LIST_ELEMENTS (bm->bgp, mnode, mnnode, bgp))
{
if (write)
vty_out (vty, "!%s", VTY_NEWLINE);
/* Router bgp ASN */
vty_out (vty, "router bgp %u", bgp->as);
if (bgp_option_check (BGP_OPT_MULTIPLE_INSTANCE))
{
if (bgp->name)
vty_out (vty, " view %s", bgp->name);
}
vty_out (vty, "%s", VTY_NEWLINE);
/* No Synchronization */
if (bgp_option_check (BGP_OPT_CONFIG_CISCO))
vty_out (vty, " no synchronization%s", VTY_NEWLINE);
/* BGP fast-external-failover. */
if (CHECK_FLAG (bgp->flags, BGP_FLAG_NO_FAST_EXT_FAILOVER))
vty_out (vty, " no bgp fast-external-failover%s", VTY_NEWLINE);
/* BGP router ID. */
if (CHECK_FLAG (bgp->config, BGP_CONFIG_ROUTER_ID))
vty_out (vty, " bgp router-id %s%s", inet_ntoa (bgp->router_id),
VTY_NEWLINE);
/* BGP log-neighbor-changes. */
if (bgp_flag_check (bgp, BGP_FLAG_LOG_NEIGHBOR_CHANGES))
vty_out (vty, " bgp log-neighbor-changes%s", VTY_NEWLINE);
/* BGP configuration. */
if (bgp_flag_check (bgp, BGP_FLAG_ALWAYS_COMPARE_MED))
vty_out (vty, " bgp always-compare-med%s", VTY_NEWLINE);
/* BGP default ipv4-unicast. */
if (bgp_flag_check (bgp, BGP_FLAG_NO_DEFAULT_IPV4))
vty_out (vty, " no bgp default ipv4-unicast%s", VTY_NEWLINE);
/* BGP default local-preference. */
if (bgp->default_local_pref != BGP_DEFAULT_LOCAL_PREF)
vty_out (vty, " bgp default local-preference %d%s",
bgp->default_local_pref, VTY_NEWLINE);
/* BGP client-to-client reflection. */
if (bgp_flag_check (bgp, BGP_FLAG_NO_CLIENT_TO_CLIENT))
vty_out (vty, " no bgp client-to-client reflection%s", VTY_NEWLINE);
/* BGP cluster ID. */
if (CHECK_FLAG (bgp->config, BGP_CONFIG_CLUSTER_ID))
vty_out (vty, " bgp cluster-id %s%s", inet_ntoa (bgp->cluster_id),
VTY_NEWLINE);
/* Confederation identifier*/
if (CHECK_FLAG (bgp->config, BGP_CONFIG_CONFEDERATION))
vty_out (vty, " bgp confederation identifier %i%s", bgp->confed_id,
VTY_NEWLINE);
/* Confederation peer */
if (bgp->confed_peers_cnt > 0)
{
int i;
vty_out (vty, " bgp confederation peers");
for (i = 0; i < bgp->confed_peers_cnt; i++)
vty_out(vty, " %u", bgp->confed_peers[i]);
vty_out (vty, "%s", VTY_NEWLINE);
}
/* BGP enforce-first-as. */
if (bgp_flag_check (bgp, BGP_FLAG_ENFORCE_FIRST_AS))
vty_out (vty, " bgp enforce-first-as%s", VTY_NEWLINE);
/* BGP deterministic-med. */
if (bgp_flag_check (bgp, BGP_FLAG_DETERMINISTIC_MED))
vty_out (vty, " bgp deterministic-med%s", VTY_NEWLINE);
/* BGP graceful-restart. */
if (bgp->stalepath_time != BGP_DEFAULT_STALEPATH_TIME)
vty_out (vty, " bgp graceful-restart stalepath-time %d%s",
bgp->stalepath_time, VTY_NEWLINE);
if (bgp_flag_check (bgp, BGP_FLAG_GRACEFUL_RESTART))
vty_out (vty, " bgp graceful-restart%s", VTY_NEWLINE);
/* BGP bestpath method. */
if (bgp_flag_check (bgp, BGP_FLAG_ASPATH_IGNORE))
vty_out (vty, " bgp bestpath as-path ignore%s", VTY_NEWLINE);
if (bgp_flag_check (bgp, BGP_FLAG_ASPATH_CONFED))
vty_out (vty, " bgp bestpath as-path confed%s", VTY_NEWLINE);
if (bgp_flag_check (bgp, BGP_FLAG_COMPARE_ROUTER_ID))
vty_out (vty, " bgp bestpath compare-routerid%s", VTY_NEWLINE);
if (bgp_flag_check (bgp, BGP_FLAG_MED_CONFED)
|| bgp_flag_check (bgp, BGP_FLAG_MED_MISSING_AS_WORST))
{
vty_out (vty, " bgp bestpath med");
if (bgp_flag_check (bgp, BGP_FLAG_MED_CONFED))
vty_out (vty, " confed");
if (bgp_flag_check (bgp, BGP_FLAG_MED_MISSING_AS_WORST))
vty_out (vty, " missing-as-worst");
vty_out (vty, "%s", VTY_NEWLINE);
}
/* BGP network import check. */
if (bgp_flag_check (bgp, BGP_FLAG_IMPORT_CHECK))
vty_out (vty, " bgp network import-check%s", VTY_NEWLINE);
/* BGP scan interval. */
bgp_config_write_scan_time (vty);
/* BGP flag dampening. */
if (CHECK_FLAG (bgp->af_flags[AFI_IP][SAFI_UNICAST],
BGP_CONFIG_DAMPENING))
bgp_config_write_damp (vty);
/* BGP static route configuration. */
bgp_config_write_network (vty, bgp, AFI_IP, SAFI_UNICAST, &write);
/* BGP redistribute configuration. */
bgp_config_write_redistribute (vty, bgp, AFI_IP, SAFI_UNICAST, &write);
/* BGP timers configuration. */
if (bgp->default_keepalive != BGP_DEFAULT_KEEPALIVE
&& bgp->default_holdtime != BGP_DEFAULT_HOLDTIME)
vty_out (vty, " timers bgp %d %d%s", bgp->default_keepalive,
bgp->default_holdtime, VTY_NEWLINE);
/* peer-group */
for (ALL_LIST_ELEMENTS (bgp->group, node, nnode, group))
{
bgp_config_write_peer (vty, bgp, group->conf, AFI_IP, SAFI_UNICAST);
}
/* Normal neighbor configuration. */
for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer))
{
if (! CHECK_FLAG (peer->sflags, PEER_STATUS_ACCEPT_PEER))
bgp_config_write_peer (vty, bgp, peer, AFI_IP, SAFI_UNICAST);
}
/* maximum-paths */
bgp_config_write_maxpaths (vty, bgp, AFI_IP, SAFI_UNICAST, &write);
/* Distance configuration. */
bgp_config_write_distance (vty, bgp);
/* No auto-summary */
if (bgp_option_check (BGP_OPT_CONFIG_CISCO))
vty_out (vty, " no auto-summary%s", VTY_NEWLINE);
/* IPv4 multicast configuration. */
write += bgp_config_write_family (vty, bgp, AFI_IP, SAFI_MULTICAST);
/* IPv4 VPN configuration. */
write += bgp_config_write_family (vty, bgp, AFI_IP, SAFI_MPLS_VPN);
/* IPv6 unicast configuration. */
write += bgp_config_write_family (vty, bgp, AFI_IP6, SAFI_UNICAST);
/* IPv6 multicast configuration. */
write += bgp_config_write_family (vty, bgp, AFI_IP6, SAFI_MULTICAST);
write++;
}
return write;
}
void
bgp_master_init (void)
{
memset (&bgp_master, 0, sizeof (struct bgp_master));
bm = &bgp_master;
bm->bgp = list_new ();
bm->listen_sockets = list_new ();
bm->port = BGP_PORT_DEFAULT;
bm->master = thread_master_create ();
bm->start_time = bgp_clock ();
}
void
bgp_init (void)
{
/* BGP VTY commands installation. */
bgp_vty_init ();
/* Init kroute. */
bgp_kroute_init ();
/* BGP inits. */
bgp_attr_init ();
bgp_debug_init ();
bgp_dump_init ();
bgp_route_init ();
bgp_route_map_init ();
bgp_scan_init ();
bgp_mplsvpn_init ();
/* Access list initialize. */
access_list_init ();
access_list_add_hook (peer_distribute_update);
access_list_delete_hook (peer_distribute_update);
/* Filter list initialize. */
bgp_filter_init ();
as_list_add_hook (peer_aslist_update);
as_list_delete_hook (peer_aslist_update);
/* Prefix list initialize.*/
prefix_list_init ();
prefix_list_add_hook (peer_prefix_list_update);
prefix_list_delete_hook (peer_prefix_list_update);
/* Community list initialize. */
bgp_clist = community_list_init ();
#ifdef HAVE_SNMP
bgp_snmp_init ();
#endif /* HAVE_SNMP */
}
void
bgp_terminate (void)
{
struct bgp *bgp;
struct peer *peer;
struct listnode *node, *nnode;
struct listnode *mnode, *mnnode;
for (ALL_LIST_ELEMENTS (bm->bgp, mnode, mnnode, bgp))
for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer))
if (peer->status == Established)
bgp_notify_send (peer, BGP_NOTIFY_CEASE,
BGP_NOTIFY_CEASE_PEER_UNCONFIG);
bgp_cleanup_routes ();
if (bm->process_main_queue)
{
work_queue_free (bm->process_main_queue);
bm->process_main_queue = NULL;
}
if (bm->process_rsclient_queue)
{
work_queue_free (bm->process_rsclient_queue);
bm->process_rsclient_queue = NULL;
}
}
| Java |
/****************************************************************************
**
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the examples of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** Commercial Usage
** Licensees holding valid Qt Commercial licenses may use this file in
** accordance with the Qt Commercial License Agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Nokia.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Nokia gives you certain additional
** rights. These rights are described in the Nokia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3.0 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU General Public License version 3.0 requirements will be
** met: http://www.gnu.org/copyleft/gpl.html.
**
** If you have questions regarding the use of this file, please contact
** Nokia at qt-info@nokia.com.
** $QT_END_LICENSE$
**
****************************************************************************/
#ifndef FLOWLAYOUT_H
#define FLOWLAYOUT_H
#include <QLayout>
#include <QRect>
#include <QWidgetItem>
//! [0]
class FlowLayout : public QLayout
{
public:
FlowLayout(QWidget *parent, int margin = -1, int hSpacing = -1, int vSpacing = -1);
FlowLayout(int margin = -1, int hSpacing = -1, int vSpacing = -1);
~FlowLayout();
void addItem(QLayoutItem *item);
int horizontalSpacing() const;
int verticalSpacing() const;
Qt::Orientations expandingDirections() const;
bool hasHeightForWidth() const;
int heightForWidth(int) const;
int count() const;
QLayoutItem *itemAt(int index) const;
QSize minimumSize() const;
void setGeometry(const QRect &rect);
QSize sizeHint() const;
QLayoutItem *takeAt(int index);
private:
int doLayout(const QRect &rect, bool testOnly) const;
int smartSpacing(QStyle::PixelMetric pm) const;
QList<QLayoutItem *> itemList;
int m_hSpace;
int m_vSpace;
};
//! [0]
#endif
| Java |
@charset "utf-8";
/* CSS Document */
/* Dark Categories */
#categories_container{
background:url(images/categories_bg.png) !important;
border:1px solid #4e4e4e !important;
border-right:0 !important;
border-left:0 !important;
}
#categories ul li a{
color:#fff !important;
text-shadow:1px 1px #000 !important;
border-right:1px solid #2d2d2d !important;
}
#categories .home_first_line{
border-left:1px solid #2d2d2d !important;
}
#categories .home_second_line{
border-left:1px solid #000000 !important;
}
#categories ul li{
border-right:1px solid #000000 !important;
}
#categories ul li a:hover{
background:url(images/categories_bg_hover.png) !important;
color:#ccc !important;
}
#categories .current-cat a{
background:url(images/categories_bg_hover.png) !important;
}
.secondnav-menu ul{
background:#000 !important;
border:1px solid #181818 !important;
}
.secondnav-menu li li a{
border-top:1px solid #181818 !important;
}
#categories ul li ul li a:hover{
background:none !important;
}
| Java |
<!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Strict//EN'
'http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd'>
<html xmlns='http://www.w3.org/1999/xhtml' xml:lang='en' lang='en'>
<head>
<meta http-equiv='Content-Type' content='text/html; charset=utf-8'/>
<title>Index of Types</title>
<link href='reno.css' type='text/css' rel='stylesheet'/>
</head>
<body>
<div class="body-0">
<div class="body-1">
<div class="body-2">
<div>
<h1>QVM: Quaternions, Vectors, Matrices</h1>
</div>
<!-- Copyright (c) 2008-2016 Emil Dotchevski and Reverge Studios, Inc. -->
<!-- Distributed under the Boost Software License, Version 1.0. (See accompanying -->
<!-- file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -->
<div class="RenoIncludeDIV"><div class="RenoAutoDIV"><h3>Index of Types</h3>
</div>
<div class="RenoIndex"><h3>d</h3>
<p><a href="deduce_mat.html">deduce_mat</a></p>
<p><a href="deduce_mat2.html">deduce_mat2</a></p>
<p><a href="deduce_quat.html">deduce_quat</a></p>
<p><a href="deduce_quat2.html">deduce_quat2</a></p>
<p><a href="deduce_scalar.html">deduce_scalar</a></p>
<p><a href="deduce_vec.html">deduce_vec</a></p>
<p><a href="deduce_vec2.html">deduce_vec2</a></p>
<h3>i</h3>
<p><a href="is_mat.html">is_mat</a></p>
<p><a href="is_quat.html">is_quat</a></p>
<p><a href="is_scalar.html">is_scalar</a></p>
<p><a href="is_vec.html">is_vec</a></p>
<h3>m</h3>
<p><a href="mat.html">mat</a></p>
<p><a href="mat_traits.html">mat_traits</a></p>
<p><a href="mat_traits_M_scalar_type.html">mat_traits<M>::scalar_type</a></p>
<h3>q</h3>
<p><a href="quat.html">quat</a></p>
<p><a href="quat_traits.html">quat_traits</a></p>
<p><a href="quat_traits_Q_scalar_type.html">quat_traits<Q>::scalar_type</a></p>
<h3>s</h3>
<p><a href="scalar.html">scalar</a></p>
<p><a href="scalar_traits.html">scalar_traits</a></p>
<h3>v</h3>
<p><a href="vec.html">vec</a></p>
<p><a href="vec_traits.html">vec_traits</a></p>
<p><a href="vec_traits_V_scalar_type.html">vec_traits<V>::scalar_type</a></p>
</div>
</div><div class="RenoAutoDIV"><div class="RenoHR"><hr/></div>
See also: <span class="RenoPageList"><a href="index.html">Boost QVM</a></span>
</div>
<!-- Copyright (c) 2008-2016 Emil Dotchevski and Reverge Studios, Inc. -->
<!-- Distributed under the Boost Software License, Version 1.0. (See accompanying -->
<!-- file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -->
<div id="footer">
<p>
<a class="logo" href="http://jigsaw.w3.org/css-validator/check/referer"><img class="logo_pic" src="valid-css.png" alt="Valid CSS" height="31" width="88"/></a>
<a class="logo" href="http://validator.w3.org/check?uri=referer"><img class="logo_pic" src="valid-xhtml.png" alt="Valid XHTML 1.0" height="31" width="88"/></a>
<small>Copyright (c) 2008-2016 by Emil Dotchevski and Reverge Studios, Inc.<br/>
Distributed under the <a href="http://www.boost.org/LICENSE_1_0.txt">Boost Software License, Version 1.0</a>.</small>
</p>
</div>
</div>
</div>
</div>
</body>
</html>
| Java |
using Mono.Data.Sqlite;
namespace Noised.Core.DB.Sqlite
{
/// <summary>
/// Factory for creating Sqlite connections
/// </summary>
public interface ISqliteConnectionFactory
{
/// <summary>
/// Creates a new, still closed connection
/// </summary>
SqliteConnection Create();
};
}
| Java |
module.exports = function(grunt) {
require("matchdep").filterDev("grunt-*").forEach(grunt.loadNpmTasks);
grunt.initConfig({
pkg: grunt.file.readJSON("package.json"),
copy: {
main: {
expand: true,
cwd: "src/",
src: ["**", "!css/**/*.scss", "!css/**/*.less"],
dest: "dist/"
}
},
less: {
options: {
paths: ["src/css"]
},
src: {
expand: true,
cwd: "src/css",
src: "*.less",
ext: ".css",
dest: "src/css"
}
},
sass: {
dist:{
options:{
style: 'expanded', // values: nested, expanded, compact, compressed
noCache: true
},
files:[{
expand: true,
cwd: "src/css",
src: ["*.scss"],
dest: "src/css",
ext: ".css"
}]
}
},
watch: {
options: {
nospawn: true,
livereload: true
},
less: {
files: ["src/css/**/*.less"],
tasks: ["less"]
},
sass: {
files: ["src/css/**/*.scss"],
tasks: ["sass"]
},
copy: {
files: ["src/**"],
tasks: ["copy:main"]
}
}
});
grunt.registerTask("default", ["watch"]);
};
| Java |
<div class="toggle-region"></div> | Java |
<!doctype html public "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
<html>
<head>
<title>PHPXRef 0.7.1 : Unnamed Project : Variable Reference: $force_regexp_dirname</title>
<link rel="stylesheet" href="../sample.css" type="text/css">
<link rel="stylesheet" href="../sample-print.css" type="text/css" media="print">
<style id="hilight" type="text/css"></style>
<meta http-equiv="content-type" content="text/html;charset=iso-8859-1">
</head>
<body bgcolor="#ffffff" text="#000000" link="#801800" vlink="#300540" alink="#ffffff">
<table class="pagetitle" width="100%">
<tr>
<td valign="top" class="pagetitle">
[ <a href="../index.html">Index</a> ]
</td>
<td align="right" class="pagetitle">
<h2 style="margin-bottom: 0px">PHP Cross Reference of Unnamed Project</h2>
</td>
</tr>
</table>
<!-- Generated by PHPXref 0.7.1 at Sat Nov 21 22:13:19 2015 -->
<!-- PHPXref (c) 2000-2010 Gareth Watts - 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='_variables';
filename='index.html';
cookiekey='phpxref';
handleNavFrame(relbase, subdir, filename);
logVariable('force_regexp_dirname');
// -->
</script>
<script language="JavaScript" type="text/javascript">
if (gwGetCookie('xrefnav')=='off')
document.write('<p class="navlinks">[ <a href="javascript:navOn()">Show Explorer<\/a> ]<\/p>');
else
document.write('<p class="navlinks">[ <a href="javascript:navOff()">Hide Explorer<\/a> ]<\/p>');
</script>
<noscript>
<p class="navlinks">
[ <a href="../nav.html" target="_top">Show Explorer</a> ]
[ <a href="index.html" target="_top">Hide Navbar</a> ]
</p>
</noscript>
[<a href="../index.html">Top level directory</a>]<br>
<script language="JavaScript" type="text/javascript">
<!--
document.writeln('<table align="right" class="searchbox-link"><tr><td><a class="searchbox-link" href="javascript:void(0)" onMouseOver="showSearchBox()">Search</a><br>');
document.writeln('<table border="0" cellspacing="0" cellpadding="0" class="searchbox" id="searchbox">');
document.writeln('<tr><td class="searchbox-title">');
document.writeln('<a class="searchbox-title" href="javascript:showSearchPopup()">Search History +</a>');
document.writeln('<\/td><\/tr>');
document.writeln('<tr><td class="searchbox-body" id="searchbox-body">');
document.writeln('<form name="search" style="margin:0px; padding:0px" onSubmit=\'return jump()\'>');
document.writeln('<a class="searchbox-body" href="../_classes/index.html">Class<\/a>: ');
document.writeln('<input type="text" size=10 value="" name="classname"><br>');
document.writeln('<a id="funcsearchlink" class="searchbox-body" href="../_functions/index.html">Function<\/a>: ');
document.writeln('<input type="text" size=10 value="" name="funcname"><br>');
document.writeln('<a class="searchbox-body" href="../_variables/index.html">Variable<\/a>: ');
document.writeln('<input type="text" size=10 value="" name="varname"><br>');
document.writeln('<a class="searchbox-body" href="../_constants/index.html">Constant<\/a>: ');
document.writeln('<input type="text" size=10 value="" name="constname"><br>');
document.writeln('<a class="searchbox-body" href="../_tables/index.html">Table<\/a>: ');
document.writeln('<input type="text" size=10 value="" name="tablename"><br>');
document.writeln('<input type="submit" class="searchbox-button" value="Search">');
document.writeln('<\/form>');
document.writeln('<\/td><\/tr><\/table>');
document.writeln('<\/td><\/tr><\/table>');
// -->
</script>
<div id="search-popup" class="searchpopup"><p id="searchpopup-title" class="searchpopup-title">title</p><div id="searchpopup-body" class="searchpopup-body">Body</div><p class="searchpopup-close"><a href="javascript:gwCloseActive()">[close]</a></p></div>
<h3>Variable Cross Reference</h3>
<h2><a href="index.html#force_regexp_dirname">$force_regexp_dirname</a></h2>
<b>Defined at:</b><ul>
<li><a href="../conf/_advanced.php.html">/conf/_advanced.php</A> -> <a href="../conf/_advanced.php.source.html#l661"> line 661</A></li>
</ul>
<br><b>Referenced 6 times:</b><ul>
<li><a href="../inc/files/views/_file_settings.form.php.html">/inc/files/views/_file_settings.form.php</a> -> <a href="../inc/files/views/_file_settings.form.php.source.html#l179"> line 179</a></li>
<li><a href="../inc/files/views/_file_settings.form.php.html">/inc/files/views/_file_settings.form.php</a> -> <a href="../inc/files/views/_file_settings.form.php.source.html#l193"> line 193</a></li>
<li><a href="../inc/files/model/_file.funcs.php.html">/inc/files/model/_file.funcs.php</a> -> <a href="../inc/files/model/_file.funcs.php.source.html#l634"> line 634</a></li>
<li><a href="../inc/files/model/_file.funcs.php.html">/inc/files/model/_file.funcs.php</a> -> <a href="../inc/files/model/_file.funcs.php.source.html#l643"> line 643</a></li>
<li><a href="../inc/files/model/_file.funcs.php.html">/inc/files/model/_file.funcs.php</a> -> <a href="../inc/files/model/_file.funcs.php.source.html#l645"> line 645</a></li>
<li><a href="../conf/_advanced.php.html">/conf/_advanced.php</a> -> <a href="../conf/_advanced.php.source.html#l661"> line 661</a></li>
</ul>
<!-- A link to the phpxref site in your customized footer file is appreciated ;-) -->
<br><hr>
<table width="100%">
<tr><td>Generated: Sat Nov 21 22:13:19 2015</td>
<td align="right"><i>Cross-referenced by <a href="http://phpxref.sourceforge.net/">PHPXref 0.7.1</a></i></td>
</tr>
</table>
</body></html>
| Java |
/* vi: set sw=4 ts=4: */
/*
* Utility routines.
*
* Copyright (C) 1999-2004 by Erik Andersen <andersen@codepoet.org>
*
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
*/
#include "libbb.h"
void bb_herror_msg(const char *s, ...)
{
va_list p;
va_start(p, s);
bb_vherror_msg(s, p);
va_end(p);
}
| Java |
#!/usr/bin/python
"feed fetcher"
from db import MySQLDatabase
from fetcher import FeedFetcher
def main():
db = MySQLDatabase()
fetcher = FeedFetcher()
feeds = db.get_feeds(offset=0, limit=10)
read_count = 10
while len(feeds) > 0:
for feed in feeds:
fid = feed[0]
url = feed[1]
title = feed[2]
print "fetching #{0}: {1}".format(fid, url)
entries = fetcher.fetch(url)
for entry in entries:
entry.feed_id = fid
try:
print "insert {0}".format(entry.url)
except UnicodeEncodeError:
print "insert {0}".format(entry.url.encode('utf-8'))
db.append_feed_content(entry)
feeds = db.get_feeds(offset=read_count, limit=10)
read_count += 10
if __name__ == '__main__':
main()
| Java |
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package sv.edu.uesocc.ingenieria.disenio2_2015.pymesell.presentacion.pymesellv1desktopclient;
/**
*
* @author David
*/
public class Main {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
System.out.println("Hola a todos!!!");
}
}
| Java |
<?php
global $post;
$date_format = get_option('date_format');
$author_id=$post->post_author;
$options = ST_Page_Builder::get_page_options($post->ID, array());
?>
<div <?php post_class(); ?>>
<?php
// show thumbnails
if(st_get_setting('sc_show_featured_img','y')!='n'){
$thumb = st_theme_post_thumbnail($post->ID,array('force_video_size'=> false), false); ?>
<?php if($thumb!=''){ ?>
<div class="entry-thumbnail main-img">
<?php
echo $thumb;
if (isset($options['count_lessons']) && ($caption = $options['caption_featured_image']) != '')
echo '<p class="lead">'. $caption .'</p>';
?>
</div>
<?php }
}
?>
<div class="entry-content">
<?php
// show the content
if(function_exists('st_the_builder_content')){
if(!st_the_builder_content($post->ID)){
the_content();
}
}else{
the_content();
}
?>
</div>
<?php
// pagination for single
$args = array(
'before' => '<p class="single-pagination">' . __('Pages:','smooththemes'),
'after' => '</p>',
'link_before' => '',
'link_after' => '',
'next_or_number' => 'number',
'nextpagelink' => __('Next page','smooththemes'),
'previouspagelink' => __('Previous page','smooththemes'),
'pagelink' => '%',
'echo' => 1
);
wp_link_pages( $args );
if(st_get_setting('sc_show_post_tag','y')!='n'){
echo get_the_term_list( $post->ID, 'course_category', '<div class="entry-tags"> '.__('Categories: '), ', ', '</div>' );
}
if(st_get_setting("sc_show_author_desc",'y') != 'n'){
st_theme_author_template($author_id);
};
if(st_get_setting("sc_show_comments",'y') != 'n'){
?>
<div id="comments">
<?php comments_template('', true ); ?>
</div><!-- /#comments-->
<?php } ?>
</div><!-- /. end post_class --> | Java |
INTERFACE:
#include "initcalls.h"
#include "types.h"
class Jdb_symbol_info;
class Jdb_lines_info;
class Jdb_dbinfo
{
};
//---------------------------------------------------------------------------
IMPLEMENTATION:
#include "config.h"
// We have to do this here because Jdb_symbol and Jdb_lines must not depend
// on Kmem_alloc.
PRIVATE static inline NOEXPORT
void
Jdb_dbinfo::init_symbols_lines ()
{
Mword p;
p = (sizeof(Jdb_symbol_info)*Jdb_symbol::Max_tasks) >> Config::PAGE_SHIFT;
Jdb_symbol::init(Kmem_alloc::allocator()
->unaligned_alloc(p*Config::PAGE_SIZE), p);
p = (sizeof(Jdb_lines_info) *Jdb_lines::Max_tasks) >> Config::PAGE_SHIFT;
Jdb_lines::init(Kmem_alloc::allocator()
->unaligned_alloc(p*Config::PAGE_SIZE), p);
}
//---------------------------------------------------------------------------
IMPLEMENTATION[ia32,amd64]:
#include "cpu_lock.h"
#include "jdb_lines.h"
#include "jdb_symbol.h"
#include "kmem.h"
#include "kmem_alloc.h"
#include "mem_layout.h"
#include "mem_unit.h"
#include "paging.h"
#include "space.h"
#include "static_init.h"
const Address area_start = Mem_layout::Jdb_debug_start;
const Address area_end = Mem_layout::Jdb_debug_end;
const unsigned area_size = area_end - area_start;
const unsigned bitmap_size = (area_size / Config::PAGE_SIZE) / 8;
// We don't use the amm library here anymore since it is nearly impossible
// to debug it and I got some strange behavior. Instead of this we use a
// simple bitfield here that takes 2k for a virtual memory size of 64MB
// which is enough for the Jdb debug info. Speed for allocating/deallocating
// pages is not an issue here.
static unsigned char bitmap[bitmap_size];
STATIC_INITIALIZE(Jdb_dbinfo);
//---------------------------------------------------------------------------
IMPLEMENTATION[ia32, amd64]:
PUBLIC static FIASCO_INIT
void
Jdb_dbinfo::init()
{
Address addr;
for (addr = area_start; addr < area_end; addr += Config::SUPERPAGE_SIZE)
Kmem::kdir->walk(Virt_addr(addr), 100, pdir_alloc(Kmem_alloc::allocator()));
init_symbols_lines();
}
PRIVATE static
Address
Jdb_dbinfo::reserve_pages(unsigned pages)
{
auto guard = lock_guard(cpu_lock);
Unsigned8 *ptr, bit;
for (ptr=bitmap, bit=0; ptr<bitmap+bitmap_size;)
{
Unsigned8 *ptr1, bit1, c;
unsigned pages1;
for (ptr1=ptr, bit1=bit, pages1=pages;;)
{
if (ptr1>=bitmap+bitmap_size)
return 0;
c = *ptr1 & (1<<bit1);
if (++bit1 >= 8)
{
bit1 = 0;
ptr1++;
}
if (c)
{
ptr = ptr1;
bit = bit1;
break;
}
if (!--pages1)
{
// found area -- make it as reserved
for (ptr1=ptr, bit1=bit, pages1=pages; pages1>0; pages1--)
{
*ptr1 |= (1<<bit1);
if (++bit1 >= 8)
{
bit1 = 0;
ptr1++;
}
}
return area_start + Config::PAGE_SIZE * (8*(ptr-bitmap) + bit);
}
}
}
return 0;
}
PRIVATE static
void
Jdb_dbinfo::return_pages(Address addr, unsigned pages)
{
auto guard = lock_guard(cpu_lock);
unsigned nr_page = (addr-area_start) / Config::PAGE_SIZE;
Unsigned8 *ptr = bitmap + nr_page/8, bit = nr_page % 8;
for (; pages && ptr < bitmap+bitmap_size; pages--)
{
assert (*ptr & (1<<bit));
*ptr &= ~(1<<bit);
if (++bit >= 8)
{
bit = 0;
ptr++;
}
}
}
//---------------------------------------------------------------------------
IMPLEMENTATION[ia32, amd64]:
PUBLIC static
bool
Jdb_dbinfo::map(Address phys, size_t &size, Address &virt)
{
Address offs = phys & ~Config::PAGE_MASK;
size = (offs + size + Config::PAGE_SIZE - 1) & Config::PAGE_MASK;
virt = reserve_pages (size / Config::PAGE_SIZE);
if (!virt)
return false;
phys &= Config::PAGE_MASK;
Kmem::kdir->map(phys, Virt_addr(virt), Virt_size(size),
Pt_entry::Valid | Pt_entry::Writable | Pt_entry::Referenced
| Pt_entry::Dirty, 100, Ptab::Null_alloc());
virt += offs;
return true;
}
PUBLIC static
void
Jdb_dbinfo::unmap(Address virt, size_t size)
{
if (virt && size)
{
virt &= Config::PAGE_MASK;
Kmem::kdir->unmap(Virt_addr(virt), Virt_size(size), 100);
Mem_unit::tlb_flush ();
return_pages(virt, size/Config::PAGE_SIZE);
}
}
PUBLIC static
void
Jdb_dbinfo::set(Jdb_symbol_info *sym, Address phys, size_t size)
{
Address virt;
if (!sym)
return;
if (!phys)
{
sym->get (virt, size);
if (! virt)
return;
unmap (virt, size);
sym->reset ();
return;
}
if (! map (phys, size, virt))
return;
if (! sym->set (virt, size))
{
unmap (virt, size);
sym->reset ();
}
}
PUBLIC static
void
Jdb_dbinfo::set(Jdb_lines_info *lin, Address phys, size_t size)
{
Address virt;
if (!lin)
return;
if (!phys)
{
lin->get(virt, size);
if (! virt)
return;
unmap(virt, size);
lin->reset ();
}
if (!map(phys, size, virt))
return;
if (!lin->set(virt, size))
{
unmap(virt, size);
lin->reset();
}
}
//---------------------------------------------------------------------------
IMPLEMENTATION[ux]:
// No special mapping required for UX since all physical memory is mapped
#include "jdb_lines.h"
#include "jdb_symbol.h"
#include "kmem_alloc.h"
#include "mem_layout.h"
#include "static_init.h"
STATIC_INITIALIZE(Jdb_dbinfo);
PUBLIC static
void
Jdb_dbinfo::init()
{
init_symbols_lines();
}
PUBLIC static
void
Jdb_dbinfo::set(Jdb_symbol_info *sym, Address phys, size_t size)
{
if (!sym)
return;
if (!phys)
sym->reset();
else
sym->set(Mem_layout::phys_to_pmem(phys), size);
}
PUBLIC static
void
Jdb_dbinfo::set(Jdb_lines_info *lin, Address phys, size_t size)
{
if (!lin)
return;
if (!phys)
lin->reset();
else
lin->set(Mem_layout::phys_to_pmem(phys), size);
}
| Java |
package org.booleanfloat.traveler.links;
import org.booleanfloat.traveler.Location;
import org.booleanfloat.traveler.interfaces.Traversable;
import java.util.ArrayList;
import java.util.concurrent.Callable;
public class OneWayLink {
public OneWayLink(Location start, Location end) {
this(start, end, new ArrayList<Traversable>(), null);
}
public OneWayLink(Location start, Location end, ArrayList<Traversable> steps) {
this(start, end, steps, null);
}
public OneWayLink(Location start, Location end, ArrayList<Traversable> steps, Callable<Boolean> requirement) {
new Link(start, end, steps, requirement);
}
}
| Java |
<?php
/**
* Template Name: Library
* @package mjv-theme
*/
if (is_home()) :
get_header();
else :
get_header('insiders');
endif;
?>
<div id="primary" class="content-area library">
<main id="main" class="site-main" role="main">
<?php
//carrega os cases, clients e content
get_template_part('template-parts/content', 'library');
?>
</main><!-- #main -->
</div><!-- #primary -->
<?php
get_sidebar();
get_footer();
| Java |
public class trace {
public void mnonnullelements(int[] a) {
int i = 0;
//@ assert i == 0 && \nonnullelements(a);
return ;
}
public void mnotmodified(int i) {
//@ assert \not_modified(i);
i = 4;
//@ assert i == 4 && \not_modified(i);
return ;
}
} | Java |
# จงเขียนโปรแกรมแสดงเลขคู่ในช่วง 0 ถึง 10 (รวม 10 ด้วย)
for i in range(11):
if (i % 2 == 0):
print(i) | Java |
# healthydesires.com.au
A Jekyll based website for healthydesires.com.au by [Bradly Sharpe IT](http://bradlysharpe.com.au)
### Build Status
[](https://travis-ci.org/brad7928/healthydesires.com.au) | Java |
// RUN: %clang_cc1 -analyze -inline-call -analyzer-store region -analyze-function f2 -verify %s
// Test parameter 'a' is registered to LiveVariables analysis data although it
// is not referenced in the function body.
// Before processing 'return 1;', in RemoveDeadBindings(), we query the liveness
// of 'a', because we have a binding for it due to parameter passing.
int f1(int a) {
return 1;
}
void f2() {
int x;
x = f1(1);
}
| Java |
<?php echo '<?xml version="1.0" encoding="utf-8"?>'; ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-ca">
<head>
<?php $this->RenderAsset('Head'); ?>
<meta property="qc:admins" content="266656217765113126654" />
</head>
<body id="<?php echo $BodyIdentifier; ?>" class="<?php echo $this->CssClass; ?>">
<div id="Frame">
<div id="Head">
<div class="Menu">
<h1><a class="Title" href="<?php echo Url('/'); ?>"><span><?php echo Gdn_Theme::Logo(); ?></span></a></h1>
<?php
$Session = Gdn::Session();
if ($this->Menu) {
$this->Menu->AddLink('Dashboard', T('Dashboard'), '/dashboard/settings', array('Garden.Settings.Manage'));
// $this->Menu->AddLink('Dashboard', T('Users'), '/user/browse', array('Garden.Users.Add', 'Garden.Users.Edit', 'Garden.Users.Delete'));
$this->Menu->AddLink('Activity', T('Activity'), '/activity');
if ($Session->IsValid()) {
$Name = $Session->User->Name;
$CountNotifications = $Session->User->CountNotifications;
if (is_numeric($CountNotifications) && $CountNotifications > 0)
$Name .= ' <span class="Alert">'.$CountNotifications.'</span>';
if (urlencode($Session->User->Name) == $Session->User->Name)
$ProfileSlug = $Session->User->Name;
else
$ProfileSlug = $Session->UserID.'/'.urlencode($Session->User->Name);
$this->Menu->AddLink('User', $Name, '/profile/'.$ProfileSlug, array('Garden.SignIn.Allow'), array('class' => 'UserNotifications'));
$this->Menu->AddLink('SignOut', T('Sign Out'), SignOutUrl(), FALSE, array('class' => 'NonTab SignOut'));
} else {
$Attribs = array();
if (SignInPopup() && strpos(Gdn::Request()->Url(), 'entry') === FALSE)
$Attribs['class'] = 'SignInPopup';
$this->Menu->AddLink('Entry', T('Sign In'), SignInUrl($this->SelfUrl), FALSE, array('class' => 'NonTab'), $Attribs);
}
echo $this->Menu->ToString();
}
?>
<div class="Search"><?php
$Form = Gdn::Factory('Form');
$Form->InputPrefix = '';
echo
$Form->Open(array('action' => Url('/search'), 'method' => 'get')),
$Form->TextBox('Search'),
$Form->Button('Go', array('Name' => '')),
$Form->Close();
?></div>
</div>
</div>
<div id="Body">
<div id="Content"><?php $this->RenderAsset('Content'); ?></div>
<div id="Panel"><?php $this->RenderAsset('Panel'); ?></div>
</div>
<div id="Foot">
<?php
$this->RenderAsset('Foot');
echo Wrap(Anchor(T('Powered by Vanilla'), C('Garden.VanillaUrl')), 'div');
?>
</div>
</div>
<?php $this->FireEvent('AfterBody'); ?>
</body>
</html>
| Java |
var ModuleManager = (function(){
//Directorio donde se encuentran los modulos
const BASE_PATH = "js/modules/";
//modules
var modules = {
"templateManager":{
"className":"TemplateManager",
"fileName":"templateManagerModule.js",
"order":1,
"loaded":false,
"dependences":null,
"instance":null
},
"preferences":{
"className":"Preferences",
"fileName":"preferencesModule.js",
"order":1,
"loaded":false,
"dependences":["templateManager"],
"instance":null
},
"logger":{
"className":"Logger",
"fileName":"logModule.js",
"order":2,
"loaded":false,
"dependences":null,
"instance":null
},
"webSpeech":{
"className":"WebSpeech",
"fileName":"webSpeechModule.js",
"order":3,
"loaded":false,
"dependences":null,
"instance":null
},
"utils":{
"className":"Utils",
"fileName":"utils.js",
"order":4,
"loaded":false,
"dependences":null,
"instance":null
},
"serviceLocator":{
"className":"ServiceLocator",
"fileName":"serviceLocatorModule.js",
"order":3,
"loaded":false,
"dependences":["logger","utils"],
"instance":null
},
"geoLocation":{
"className":"GeoLocation",
"fileName":"geolocationModule.js",
"order":4,
"loaded":false,
"dependences":["serviceLocator"],
"instance":null
},
"notificator":{
"className":"Notificator",
"fileName":"notificationsModule.js",
"order":5,
"loaded":false,
"dependences":["templateManager"],
"instance":null
},
"applicationsManager":{
"className":"ApplicationsManager",
"fileName":"applicationsModule.js",
"order":6,
"loaded":false,
"dependences":["templateManager","serviceLocator","notificator"],
"instance":null
},
"searchs":{
"className":"Searchs",
"fileName":"searchsModule.js",
"order":7,
"loaded":false,
"dependences":["templateManager","serviceLocator","webSpeech","applicationsManager","notificator"],
"instance":null
},
"contacts":{
"className":"Contacts",
"fileName":"contactsModule.js",
"order":8,
"loaded":false,
"dependences":["templateManager","serviceLocator","webSpeech","notificator","geoLocation"],
"instance":null
},
"gui":{
"className":"GUI",
"fileName":"guiModule.js",
"order":9,
"loaded":false,
"dependences":["serviceLocator","searchs","contacts","applicationsManager","notificator"],
"instance":null
}
};
/**
* Devuelve las dependencias a partir de los nombres.
*
* @param {Array} arr: names of the dependencies
* @return {Array} dependencies to bind
*/
var getDependencies = function(arr) {
return arr instanceof Array && arr.length ? arr.map(function (value) {
var o = modules[value] && modules[value].instance;
if (!o) {
throw new Error('Dependency ' + value + ' not found');
}else{
return o;
}
}) : false;
}
/**
* Extrae los nombres de las dependencias a inyectar.
*
* @param {Function} target: function to process
* @return {Array}
*/
var getArgs = function(target) {
if (!target instanceof Function) {
throw new TypeError('Target to process should be a Function');
}else{
var FN_ARGS = /^function\s*[^\(]*\(\s*([^\)]*)\)/m;
var COMMENTS = /((\/\/.*$)|(\/\*[\s\S]*?\*\/))/mg;
var SPACES = /[\s|\t|\n|\r]+/mg;
var result = target.toString().match(FN_ARGS);
//Comprobamos si existe alguna dependencia a inyectar
if(result && result[1])
var args = result[1].replace(COMMENTS,'').replace(SPACES,'').split(',');
else
var args = false;
return args;
}
}
/**
* Crea el objeto con las dependencias previamente inyectadas.
*
* @param {Function} constructor: function to call as constructor
* @return {Object} object created from its constructor
*/
var create = function(constructor) {
var args = getArgs(constructor);
if (args) {
var args = [null].concat(getDependencies(args));
var o = new (Function.prototype.bind.apply(constructor, args))();
}else{
var o = new (Function.prototype.bind.apply(constructor))();
}
return o;
}
var loadScript = function(src, callback) {
var s,r,t;
r = false ;
s = document. createElement ('script' );
s.type = 'text/javascript' ;
s.src = src;
s.onload = s.onreadystatechange = function () {
if ( !r && (!this .readyState || this .readyState == 'complete' )){
r = true ;
typeof(callback) == "function" && callback();
}
};
t = document.getElementsByTagName ('script')[0];
t.parentNode.insertBefore (s, t);
}
var downloadModules = function(callback){
console.log(modules);
for(var module in modules)
(function(currentModule){
loadScript(BASE_PATH+currentModule.fileName,function(){
currentModule.loaded = true;
Object.keys(modules).map(function(key){
return modules[key].loaded;
}).indexOf(false) == -1 && typeof(callback) == "function" && callback();
});
})(modules[module]);
}
var loadModules = function(callback){
downloadModules(function(){
for(var module in modules){
console.log("Cargando Módulo : " + modules[module].className);
modules[module].instance = create(window[modules[module].className]);
delete window[modules[module].className];
}
typeof(callback) == "function" && callback();
});
}
//API pública
return{
loadModules:loadModules
}
})(); | Java |
# ionic-audioguide
An audioguide app with geolocation and media streaming support for the ionic framework
# Howto
These files will not run standalone, you have to create a new ionic app to make use of them. The interesting code is in www/js/controllers.js and www/js/app.js
# Webserver and JSON
You will need a webserver which serves the media files and handles the JSON requests.
# Cordova plugins
Listing of needed cordova plugins in cordova-plugins.txt.
# License
Copyright (c) 2015 Felix Herrmann (github.com/hfx)
Licensed under GPL v2.
Code for the AudiostationsCtrl controller adapted from https://github.com/devgeeks/ExampleHTML5AudioStreaming/blob/master/www/scripts/html5audio.js, Copyright (c) 2011 Tommy-Carlos Williams (github.com/devgeeks).
This part of code is licensed under The MIT license by the original author, please see https://github.com/devgeeks/ExampleHTML5AudioStreaming#license
| Java |
<?xml version="1.0" encoding="UTF-8"?>
<!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" lang="en" xml:lang="en">
<head>
<title>DOM.Node</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="Content-Style-Type" content="text/css" />
<link rel="stylesheet" type="text/css" href="../common/doxygen.css" />
<link rel="stylesheet" media="screen" type="text/css" title="KDE Colors" href="../common/kde.css" />
</head>
<body>
<div id="container">
<div id="header">
<div id="header_top">
<div>
<div>
<img alt ="" src="../common/top-kde.jpg"/>
KDE 4.9 PyKDE API Reference
</div>
</div>
</div>
<div id="header_bottom">
<div id="location">
<ul>
<li>KDE's Python API</li>
</ul>
</div>
<div id="menu">
<ul>
<li><a href="../modules.html">Overview</a></li>
<li><a href="http://techbase.kde.org/Development/Languages/Python">PyKDE Home</a></li>
<li><a href="http://kde.org/family/">Sitemap</a></li>
<li><a href="http://kde.org/contact/">Contact Us</a></li>
</ul>
</div>
</div>
</div>
<div id="body_wrapper">
<div id="body">
<div id="right">
<div class="content">
<div id="main">
<div class="clearer"> </div>
<h1>Node Class Reference</h1>
<code>from PyKDE4.khtml import *</code>
<p>
Subclasses: <a href="../khtml/DOM.Document.html">DOM.Document</a>, <a href="../khtml/DOM.DocumentFragment.html">DOM.DocumentFragment</a>, <a href="../khtml/DOM.DocumentType.html">DOM.DocumentType</a>, <a href="../khtml/DOM.Attr.html">DOM.Attr</a>, <a href="../khtml/DOM.Element.html">DOM.Element</a>, <a href="../khtml/DOM.CharacterData.html">DOM.CharacterData</a>, <a href="../khtml/DOM.Entity.html">DOM.Entity</a>, <a href="../khtml/DOM.EntityReference.html">DOM.EntityReference</a>, <a href="../khtml/DOM.Notation.html">DOM.Notation</a>, <a href="../khtml/DOM.ProcessingInstruction.html">DOM.ProcessingInstruction</a><br />
Namespace: <a href="../khtml/DOM.html">DOM</a><br />
<h2>Detailed Description</h2>
<p>The Node interface is the primary datatype for the
entire Document Object Model. It represents a single node in the
document tree. While all objects implementing the Node
interface expose methods for dealing with children, not all
objects implementing the Node interface may have
children. For example, Text nodes may not have
children, and adding children to such nodes results in a
DOMException being raised.
</p>
<p>
The attributes nodeName , nodeValue
and attributes are included as a mechanism to get at
node information without casting down to the specific derived
interface. In cases where there is no obvious mapping of these
attributes for a specific nodeType (e.g.,
nodeValue for an Element or attributes for a
Comment), this returns null . Note that the
specialized interfaces may contain additional and more convenient
mechanisms to get and set the relevant information.
</p>
<table border="0" cellpadding="0" cellspacing="0"><tr><td colspan="2"><br><h2>Enumerations</h2></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="el" href="#DocumentPosition">DocumentPosition</a> </td><td class="memItemRight" valign="bottom">{ DOCUMENT_POSITION_DISCONNECTED, DOCUMENT_POSITION_PRECEDING, DOCUMENT_POSITION_FOLLOWING, DOCUMENT_POSITION_CONTAINS, DOCUMENT_POSITION_CONTAINED_BY, DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC }</td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="el" href="#NodeType">NodeType</a> </td><td class="memItemRight" valign="bottom">{ ELEMENT_NODE, ATTRIBUTE_NODE, TEXT_NODE, CDATA_SECTION_NODE, ENTITY_REFERENCE_NODE, ENTITY_NODE, PROCESSING_INSTRUCTION_NODE, COMMENT_NODE, DOCUMENT_NODE, DOCUMENT_TYPE_NODE, DOCUMENT_FRAGMENT_NODE, NOTATION_NODE, XPATH_NAMESPACE_NODE }</td></tr>
<tr><td colspan="2"><br><h2>Methods</h2></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top"> </td><td class="memItemRight" valign="bottom"><a class="el" href="#Node">__init__</a> (self)</td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top"> </td><td class="memItemRight" valign="bottom"><a class="el" href="#Node">__init__</a> (self, <a href="../khtml/DOM.Node.html">DOM.Node</a> other)</td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top"> </td><td class="memItemRight" valign="bottom"><a class="el" href="#addEventListener">addEventListener</a> (self, <a href="../khtml/DOM.DOMString.html">DOM.DOMString</a> type, <a href="../khtml/DOM.EventListener.html">DOM.EventListener</a> listener, bool useCapture)</td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top"><a href="../khtml/DOM.Node.html">DOM.Node</a> </td><td class="memItemRight" valign="bottom"><a class="el" href="#appendChild">appendChild</a> (self, <a href="../khtml/DOM.Node.html">DOM.Node</a> newChild)</td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top"> </td><td class="memItemRight" valign="bottom"><a class="el" href="#applyChanges">applyChanges</a> (self)</td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top"><a href="../khtml/DOM.NamedNodeMap.html">DOM.NamedNodeMap</a> </td><td class="memItemRight" valign="bottom"><a class="el" href="#attributes">attributes</a> (self)</td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top"><a href="../khtml/DOM.NodeList.html">DOM.NodeList</a> </td><td class="memItemRight" valign="bottom"><a class="el" href="#childNodes">childNodes</a> (self)</td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top"><a href="../khtml/DOM.Node.html">DOM.Node</a> </td><td class="memItemRight" valign="bottom"><a class="el" href="#cloneNode">cloneNode</a> (self, bool deep)</td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">unsigned </td><td class="memItemRight" valign="bottom"><a class="el" href="#compareDocumentPosition">compareDocumentPosition</a> (self, <a href="../khtml/DOM.Node.html">DOM.Node</a> other)</td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">bool </td><td class="memItemRight" valign="bottom"><a class="el" href="#dispatchEvent">dispatchEvent</a> (self, <a href="../khtml/DOM.Event.html">DOM.Event</a> evt)</td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">long </td><td class="memItemRight" valign="bottom"><a class="el" href="#elementId">elementId</a> (self)</td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top"><a href="../khtml/DOM.Node.html">DOM.Node</a> </td><td class="memItemRight" valign="bottom"><a class="el" href="#firstChild">firstChild</a> (self)</td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">int _x, int _y, int height </td><td class="memItemRight" valign="bottom"><a class="el" href="#getCursor">getCursor</a> (self, int offset)</td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">QRect </td><td class="memItemRight" valign="bottom"><a class="el" href="#getRect">getRect</a> (self)</td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">bool </td><td class="memItemRight" valign="bottom"><a class="el" href="#hasAttributes">hasAttributes</a> (self)</td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">bool </td><td class="memItemRight" valign="bottom"><a class="el" href="#hasChildNodes">hasChildNodes</a> (self)</td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">long </td><td class="memItemRight" valign="bottom"><a class="el" href="#index">index</a> (self)</td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top"><a href="../khtml/DOM.Node.html">DOM.Node</a> </td><td class="memItemRight" valign="bottom"><a class="el" href="#insertBefore">insertBefore</a> (self, <a href="../khtml/DOM.Node.html">DOM.Node</a> newChild, <a href="../khtml/DOM.Node.html">DOM.Node</a> refChild)</td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">bool </td><td class="memItemRight" valign="bottom"><a class="el" href="#isNull">isNull</a> (self)</td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">bool </td><td class="memItemRight" valign="bottom"><a class="el" href="#isSupported">isSupported</a> (self, <a href="../khtml/DOM.DOMString.html">DOM.DOMString</a> feature, <a href="../khtml/DOM.DOMString.html">DOM.DOMString</a> version)</td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top"><a href="../khtml/DOM.Node.html">DOM.Node</a> </td><td class="memItemRight" valign="bottom"><a class="el" href="#lastChild">lastChild</a> (self)</td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top"><a href="../khtml/DOM.DOMString.html">DOM.DOMString</a> </td><td class="memItemRight" valign="bottom"><a class="el" href="#localName">localName</a> (self)</td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top"><a href="../khtml/DOM.DOMString.html">DOM.DOMString</a> </td><td class="memItemRight" valign="bottom"><a class="el" href="#namespaceURI">namespaceURI</a> (self)</td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top"><a href="../khtml/DOM.Node.html">DOM.Node</a> </td><td class="memItemRight" valign="bottom"><a class="el" href="#nextSibling">nextSibling</a> (self)</td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top"><a href="../khtml/DOM.DOMString.html">DOM.DOMString</a> </td><td class="memItemRight" valign="bottom"><a class="el" href="#nodeName">nodeName</a> (self)</td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">int </td><td class="memItemRight" valign="bottom"><a class="el" href="#nodeType">nodeType</a> (self)</td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top"><a href="../khtml/DOM.DOMString.html">DOM.DOMString</a> </td><td class="memItemRight" valign="bottom"><a class="el" href="#nodeValue">nodeValue</a> (self)</td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top"> </td><td class="memItemRight" valign="bottom"><a class="el" href="#normalize">normalize</a> (self)</td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">bool </td><td class="memItemRight" valign="bottom"><a class="el" href="#operator !=">operator !=</a> (self, <a href="../khtml/DOM.Node.html">DOM.Node</a> other)</td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">bool </td><td class="memItemRight" valign="bottom"><a class="el" href="#operator ==">operator ==</a> (self, <a href="../khtml/DOM.Node.html">DOM.Node</a> other)</td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top"><a href="../khtml/DOM.Document.html">DOM.Document</a> </td><td class="memItemRight" valign="bottom"><a class="el" href="#ownerDocument">ownerDocument</a> (self)</td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top"><a href="../khtml/DOM.Node.html">DOM.Node</a> </td><td class="memItemRight" valign="bottom"><a class="el" href="#parentNode">parentNode</a> (self)</td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top"><a href="../khtml/DOM.DOMString.html">DOM.DOMString</a> </td><td class="memItemRight" valign="bottom"><a class="el" href="#prefix">prefix</a> (self)</td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top"><a href="../khtml/DOM.Node.html">DOM.Node</a> </td><td class="memItemRight" valign="bottom"><a class="el" href="#previousSibling">previousSibling</a> (self)</td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top"><a href="../khtml/DOM.Node.html">DOM.Node</a> </td><td class="memItemRight" valign="bottom"><a class="el" href="#removeChild">removeChild</a> (self, <a href="../khtml/DOM.Node.html">DOM.Node</a> oldChild)</td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top"> </td><td class="memItemRight" valign="bottom"><a class="el" href="#removeEventListener">removeEventListener</a> (self, <a href="../khtml/DOM.DOMString.html">DOM.DOMString</a> type, <a href="../khtml/DOM.EventListener.html">DOM.EventListener</a> listener, bool useCapture)</td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top"><a href="../khtml/DOM.Node.html">DOM.Node</a> </td><td class="memItemRight" valign="bottom"><a class="el" href="#replaceChild">replaceChild</a> (self, <a href="../khtml/DOM.Node.html">DOM.Node</a> newChild, <a href="../khtml/DOM.Node.html">DOM.Node</a> oldChild)</td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top"> </td><td class="memItemRight" valign="bottom"><a class="el" href="#setNodeValue">setNodeValue</a> (self, <a href="../khtml/DOM.DOMString.html">DOM.DOMString</a> a0)</td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top"> </td><td class="memItemRight" valign="bottom"><a class="el" href="#setPrefix">setPrefix</a> (self, <a href="../khtml/DOM.DOMString.html">DOM.DOMString</a> prefix)</td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top"> </td><td class="memItemRight" valign="bottom"><a class="el" href="#setTextContent">setTextContent</a> (self, <a href="../khtml/DOM.DOMString.html">DOM.DOMString</a> text)</td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top"><a href="../khtml/DOM.DOMString.html">DOM.DOMString</a> </td><td class="memItemRight" valign="bottom"><a class="el" href="#textContent">textContent</a> (self)</td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">QString </td><td class="memItemRight" valign="bottom"><a class="el" href="#toHTML">toHTML</a> (self)</td></tr>
</table>
<hr><h2>Method Documentation</h2><a class="anchor" name="Node"></a>
<div class="memitem">
<div class="memproto">
<table class="memname"><tr>
<td class="memname">__init__</td>
<td>(</td>
<td class="paramtype"> </td>
<td class="paramname"><em>self</em> )</td>
<td width="100%"> </td>
</tr>
</table>
</div>
<div class="memdoc"></div></div><a class="anchor" name="Node"></a>
<div class="memitem">
<div class="memproto">
<table class="memname"><tr>
<td class="memname">__init__</td>
<td>(</td>
<td class="paramtype"> <em>self</em>, </td>
<td class="paramname"></td>
</tr><tr>
<td class="memname"></td>
<td></td>
<td class="paramtype"><a href="../khtml/DOM.Node.html">DOM.Node</a> </td>
<td class="paramname"><em>other</em></td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td>
<td></td>
<td width="100%"> </td>
</tr></table>
</div>
<div class="memdoc"></div></div><a class="anchor" name="addEventListener"></a>
<div class="memitem">
<div class="memproto">
<table class="memname"><tr>
<td class="memname"> addEventListener</td>
<td>(</td>
<td class="paramtype"> <em>self</em>, </td>
<td class="paramname"></td>
</tr><tr>
<td class="memname"></td>
<td></td>
<td class="paramtype"><a href="../khtml/DOM.DOMString.html">DOM.DOMString</a> </td>
<td class="paramname"><em>type</em>, </td>
</tr>
<tr>
<td class="memname"></td>
<td></td>
<td class="paramtype"><a href="../khtml/DOM.EventListener.html">DOM.EventListener</a> </td>
<td class="paramname"><em>listener</em>, </td>
</tr>
<tr>
<td class="memname"></td>
<td></td>
<td class="paramtype">bool </td>
<td class="paramname"><em>useCapture</em></td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td>
<td></td>
<td width="100%"> </td>
</tr></table>
</div>
<div class="memdoc"><p>Introduced in DOM Level 2
This method is from the EventTarget interface
</p>
<p>
This method allows the registration of event listeners on the event
target. If an EventListener is added to an EventTarget while it is
processing an event, it will not be triggered by the current actions but
may be triggered during a later stage of event flow, such as the
bubbling phase.
</p>
<p>
If multiple identical EventListeners are registered on the same
EventTarget with the same parameters the duplicate instances are
discarded. They do not cause the EventListener to be called twice and
since they are discarded they do not need to be removed with the
removeEventListener method. Parameters
</p>
<p>
</p><dl compact><dt><b>Parameters:</b></dt><dd>
<table border="0" cellspacing="2" cellpadding="0">
<tr><td></td><td valign="top"><em>type</em> </td><td> The event type for which the user is registering
</td></tr>
<tr><td></td><td valign="top"><em>listener</em> </td><td> The listener parameter takes an interface implemented by
the user which contains the methods to be called when the event occurs.
</td></tr>
<tr><td></td><td valign="top"><em>useCapture</em> </td><td> If true, useCapture indicates that the user wishes to
initiate capture. After initiating capture, all events of the specified
type will be dispatched to the registered EventListener before being
dispatched to any EventTargets beneath them in the tree. Events which
are bubbling upward through the tree will not trigger an EventListener
designated to use capture.
</td></tr>
</table></dl>
<p>
</p></div></div><a class="anchor" name="appendChild"></a>
<div class="memitem">
<div class="memproto">
<table class="memname"><tr>
<td class="memname"><a href="../khtml/DOM.Node.html">DOM.Node</a> appendChild</td>
<td>(</td>
<td class="paramtype"> <em>self</em>, </td>
<td class="paramname"></td>
</tr><tr>
<td class="memname"></td>
<td></td>
<td class="paramtype"><a href="../khtml/DOM.Node.html">DOM.Node</a> </td>
<td class="paramname"><em>newChild</em></td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td>
<td></td>
<td width="100%"> </td>
</tr></table>
</div>
<div class="memdoc"><p>Adds the node newChild to the end of the list of
children of this node. If the newChild is
already in the tree, it is first removed.
</p>
<p>
</p><dl compact><dt><b>Parameters:</b></dt><dd>
<table border="0" cellspacing="2" cellpadding="0">
<tr><td></td><td valign="top"><em>newChild</em> </td><td> The node to add.
</td></tr>
</table></dl>
<p> If it is a DocumentFragment object, the entire
contents of the document fragment are moved into the child list
of this node
</p>
<p>
<dl class="return" compact><dt><b>Returns:</b></dt><dd> The node added.
</dd></dl> </p>
<p>
DOMException
HIERARCHY_REQUEST_ERR: Raised if this node is of a type that
does not allow children of the type of the newChild
node, or if the node to append is one of this node's
ancestors.
</p>
<p>
WRONG_DOCUMENT_ERR: Raised if newChild was
created from a different document than the one that created
this node.
</p>
<p>
NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly.
</p></div></div><a class="anchor" name="applyChanges"></a>
<div class="memitem">
<div class="memproto">
<table class="memname"><tr>
<td class="memname"> applyChanges</td>
<td>(</td>
<td class="paramtype"> </td>
<td class="paramname"><em>self</em> )</td>
<td width="100%"> </td>
</tr>
</table>
</div>
<div class="memdoc"></div></div><a class="anchor" name="attributes"></a>
<div class="memitem">
<div class="memproto">
<table class="memname"><tr>
<td class="memname"><a href="../khtml/DOM.NamedNodeMap.html">DOM.NamedNodeMap</a> attributes</td>
<td>(</td>
<td class="paramtype"> </td>
<td class="paramname"><em>self</em> )</td>
<td width="100%"> </td>
</tr>
</table>
</div>
<div class="memdoc"><p>A NamedNodeMap containing the attributes of this
node (if it is an Element ) or null
otherwise.
</p></div></div><a class="anchor" name="childNodes"></a>
<div class="memitem">
<div class="memproto">
<table class="memname"><tr>
<td class="memname"><a href="../khtml/DOM.NodeList.html">DOM.NodeList</a> childNodes</td>
<td>(</td>
<td class="paramtype"> </td>
<td class="paramname"><em>self</em> )</td>
<td width="100%"> </td>
</tr>
</table>
</div>
<div class="memdoc"><p>A NodeList that contains all children of this
node. If there are no children, this is a NodeList
containing no nodes. The content of the returned
NodeList is &quot;live&quot; in the sense that, for
instance, changes to the children of the node object that it
was created from are immediately reflected in the nodes
returned by the NodeList accessors; it is not a
static snapshot of the content of the node. This is true for
every NodeList , including the ones returned by
the getElementsByTagName method.
</p></div></div><a class="anchor" name="cloneNode"></a>
<div class="memitem">
<div class="memproto">
<table class="memname"><tr>
<td class="memname"><a href="../khtml/DOM.Node.html">DOM.Node</a> cloneNode</td>
<td>(</td>
<td class="paramtype"> <em>self</em>, </td>
<td class="paramname"></td>
</tr><tr>
<td class="memname"></td>
<td></td>
<td class="paramtype">bool </td>
<td class="paramname"><em>deep</em></td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td>
<td></td>
<td width="100%"> </td>
</tr></table>
</div>
<div class="memdoc"><p>Returns a duplicate of this node, i.e., serves as a generic
copy constructor for nodes. The duplicate node has no parent (
parentNode returns null .).
</p>
<p>
Cloning an Element copies all attributes and
their values, including those generated by the XML processor to
represent defaulted attributes, but this method does not copy
any text it contains unless it is a deep clone, since the text
is contained in a child Text node. Cloning any
other type of node simply returns a copy of this node.
</p>
<p>
</p><dl compact><dt><b>Parameters:</b></dt><dd>
<table border="0" cellspacing="2" cellpadding="0">
<tr><td></td><td valign="top"><em>deep</em> </td><td> If true , recursively clone the
subtree under the specified node; if false ,
clone only the node itself (and its attributes, if it is an
</td></tr> </table></dl>
<p> Element ).
</p>
<p>
<dl class="return" compact><dt><b>Returns:</b></dt><dd> The duplicate node.
</dd></dl>
</p></div></div><a class="anchor" name="compareDocumentPosition"></a>
<div class="memitem">
<div class="memproto">
<table class="memname"><tr>
<td class="memname">unsigned compareDocumentPosition</td>
<td>(</td>
<td class="paramtype"> <em>self</em>, </td>
<td class="paramname"></td>
</tr><tr>
<td class="memname"></td>
<td></td>
<td class="paramtype"><a href="../khtml/DOM.Node.html">DOM.Node</a> </td>
<td class="paramname"><em>other</em></td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td>
<td></td>
<td width="100%"> </td>
</tr></table>
</div>
<div class="memdoc"><p>Introduced in DOM Level 3.
</p>
<p>
This method compares the current node's position with that of 'other'
and returns it as a combination of DocumentPosition bitfields.
Here DOCUMENT_POSITION_FOLLOWING means that the 'other' is
after the current.
</p>
<p>
The notion of order here is a logical one; for example attributes
are viewed as if they were children of an element inserted
right before the real children. The method will also assign
some total order even if the nodes are not connected.
</p>
<p>
<dl class="since" compact><dt><b>Since:</b></dt><dd> 4.2.4
</dd></dl>
</p></div></div><a class="anchor" name="dispatchEvent"></a>
<div class="memitem">
<div class="memproto">
<table class="memname"><tr>
<td class="memname">bool dispatchEvent</td>
<td>(</td>
<td class="paramtype"> <em>self</em>, </td>
<td class="paramname"></td>
</tr><tr>
<td class="memname"></td>
<td></td>
<td class="paramtype"><a href="../khtml/DOM.Event.html">DOM.Event</a> </td>
<td class="paramname"><em>evt</em></td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td>
<td></td>
<td width="100%"> </td>
</tr></table>
</div>
<div class="memdoc"><p>Introduced in DOM Level 2
This method is from the EventTarget interface
</p>
<p>
This method allows the dispatch of events into the implementations event
model. Events dispatched in this manner will have the same capturing and
bubbling behavior as events dispatched directly by the implementation.
The target of the event is the EventTarget on which dispatchEvent is
called.
</p>
<p>
</p><dl compact><dt><b>Parameters:</b></dt><dd>
<table border="0" cellspacing="2" cellpadding="0">
<tr><td></td><td valign="top"><em>evt</em> </td><td> Specifies the event type, behavior, and contextual
information to be used in processing the event.
</td></tr>
</table></dl>
<p> <dl class="return" compact><dt><b>Returns:</b></dt><dd> The return value of dispatchEvent indicates whether any of the
listeners which handled the event called preventDefault. If
preventDefault was called the value is false, else the value is true.
</dd></dl> </p>
<p>
EventException
UNSPECIFIED_EVENT_TYPE_ERR: Raised if the Event's type was not specified
by initializing the event before dispatchEvent was called. Specification
of the Event's type as null or an empty string will also trigger this
exception.
</p></div></div><a class="anchor" name="elementId"></a>
<div class="memitem">
<div class="memproto">
<table class="memname"><tr>
<td class="memname">long elementId</td>
<td>(</td>
<td class="paramtype"> </td>
<td class="paramname"><em>self</em> )</td>
<td width="100%"> </td>
</tr>
</table>
</div>
<div class="memdoc"><p><dl class="internal" compact><dt><b>Internal:</b></dt><dd>
not part of the DOM.
</dd></dl> <dl class="return" compact><dt><b>Returns:</b></dt><dd> the element id, in case this is an element, 0 otherwise
</dd></dl>
</p></div></div><a class="anchor" name="firstChild"></a>
<div class="memitem">
<div class="memproto">
<table class="memname"><tr>
<td class="memname"><a href="../khtml/DOM.Node.html">DOM.Node</a> firstChild</td>
<td>(</td>
<td class="paramtype"> </td>
<td class="paramname"><em>self</em> )</td>
<td width="100%"> </td>
</tr>
</table>
</div>
<div class="memdoc"><p>The first child of this node. If there is no such node, this
returns null .
</p></div></div><a class="anchor" name="getCursor"></a>
<div class="memitem">
<div class="memproto">
<table class="memname"><tr>
<td class="memname">int _x, int _y, int height getCursor</td>
<td>(</td>
<td class="paramtype"> <em>self</em>, </td>
<td class="paramname"></td>
</tr><tr>
<td class="memname"></td>
<td></td>
<td class="paramtype">int </td>
<td class="paramname"><em>offset</em></td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td>
<td></td>
<td width="100%"> </td>
</tr></table>
</div>
<div class="memdoc"><p><dl class="deprecated" compact><dt><b>Deprecated:</b></dt><dd> without substitution since 3.2
</dd></dl>
</p></div></div><a class="anchor" name="getRect"></a>
<div class="memitem">
<div class="memproto">
<table class="memname"><tr>
<td class="memname">QRect getRect</td>
<td>(</td>
<td class="paramtype"> </td>
<td class="paramname"><em>self</em> )</td>
<td width="100%"> </td>
</tr>
</table>
</div>
<div class="memdoc"><p>not part of the DOM.
<dl class="return" compact><dt><b>Returns:</b></dt><dd> the exact coordinates and size of this element.
</dd></dl>
</p></div></div><a class="anchor" name="hasAttributes"></a>
<div class="memitem">
<div class="memproto">
<table class="memname"><tr>
<td class="memname">bool hasAttributes</td>
<td>(</td>
<td class="paramtype"> </td>
<td class="paramname"><em>self</em> )</td>
<td width="100%"> </td>
</tr>
</table>
</div>
<div class="memdoc"><p>Returns whether this node (if it is an element) has any attributes.
<dl class="return" compact><dt><b>Returns:</b></dt><dd> a boolean. True if this node has any attributes, false otherwise.
Introduced in DOM Level 2
</dd></dl>
</p></div></div><a class="anchor" name="hasChildNodes"></a>
<div class="memitem">
<div class="memproto">
<table class="memname"><tr>
<td class="memname">bool hasChildNodes</td>
<td>(</td>
<td class="paramtype"> </td>
<td class="paramname"><em>self</em> )</td>
<td width="100%"> </td>
</tr>
</table>
</div>
<div class="memdoc"><p>This is a convenience method to allow easy determination of
whether a node has any children.
</p>
<p>
<dl class="return" compact><dt><b>Returns:</b></dt><dd> true if the node has any children,
</dd></dl> false if the node has no children.
</p></div></div><a class="anchor" name="index"></a>
<div class="memitem">
<div class="memproto">
<table class="memname"><tr>
<td class="memname">long index</td>
<td>(</td>
<td class="paramtype"> </td>
<td class="paramname"><em>self</em> )</td>
<td width="100%"> </td>
</tr>
</table>
</div>
<div class="memdoc"><p><dl class="internal" compact><dt><b>Internal:</b></dt><dd> returns the index of a node
</dd></dl>
</p></div></div><a class="anchor" name="insertBefore"></a>
<div class="memitem">
<div class="memproto">
<table class="memname"><tr>
<td class="memname"><a href="../khtml/DOM.Node.html">DOM.Node</a> insertBefore</td>
<td>(</td>
<td class="paramtype"> <em>self</em>, </td>
<td class="paramname"></td>
</tr><tr>
<td class="memname"></td>
<td></td>
<td class="paramtype"><a href="../khtml/DOM.Node.html">DOM.Node</a> </td>
<td class="paramname"><em>newChild</em>, </td>
</tr>
<tr>
<td class="memname"></td>
<td></td>
<td class="paramtype"><a href="../khtml/DOM.Node.html">DOM.Node</a> </td>
<td class="paramname"><em>refChild</em></td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td>
<td></td>
<td width="100%"> </td>
</tr></table>
</div>
<div class="memdoc"><p>Inserts the node newChild before the existing
child node refChild . If refChild
is null , insert newChild at the
end of the list of children.
</p>
<p>
If newChild is a DocumentFragment
object, all of its children are inserted, in the same
order, before refChild . If the newChild
is already in the tree, it is first removed.
</p>
<p>
</p><dl compact><dt><b>Parameters:</b></dt><dd>
<table border="0" cellspacing="2" cellpadding="0">
<tr><td></td><td valign="top"><em>newChild</em> </td><td> The node to insert.
</td></tr>
<tr><td></td><td valign="top"><em>refChild</em> </td><td> The reference node, i.e., the node before which
the new node must be inserted.
</td></tr>
</table></dl>
<p> <dl class="return" compact><dt><b>Returns:</b></dt><dd> The node being inserted.
</dd></dl> </p>
<p>
DOMException
HIERARCHY_REQUEST_ERR: Raised if this node is of a type that
does not allow children of the type of the newChild
node, or if the node to insert is one of this node's
ancestors.
</p>
<p>
WRONG_DOCUMENT_ERR: Raised if newChild was
created from a different document than the one that created
this node.
</p>
<p>
NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly.
</p>
<p>
NOT_FOUND_ERR: Raised if refChild is not a
child of this node.
</p></div></div><a class="anchor" name="isNull"></a>
<div class="memitem">
<div class="memproto">
<table class="memname"><tr>
<td class="memname">bool isNull</td>
<td>(</td>
<td class="paramtype"> </td>
<td class="paramname"><em>self</em> )</td>
<td width="100%"> </td>
</tr>
</table>
</div>
<div class="memdoc"><p>tests if this Node is 0. Useful especially, if casting to a derived
class:
</p>
<p>
<pre class="fragment">
Node n = .....;
// try to convert into an Element:
Element e = n;
if( e.isNull() )
kDebug() << "node isn't an element node";
</pre>
</p></div></div><a class="anchor" name="isSupported"></a>
<div class="memitem">
<div class="memproto">
<table class="memname"><tr>
<td class="memname">bool isSupported</td>
<td>(</td>
<td class="paramtype"> <em>self</em>, </td>
<td class="paramname"></td>
</tr><tr>
<td class="memname"></td>
<td></td>
<td class="paramtype"><a href="../khtml/DOM.DOMString.html">DOM.DOMString</a> </td>
<td class="paramname"><em>feature</em>, </td>
</tr>
<tr>
<td class="memname"></td>
<td></td>
<td class="paramtype"><a href="../khtml/DOM.DOMString.html">DOM.DOMString</a> </td>
<td class="paramname"><em>version</em></td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td>
<td></td>
<td width="100%"> </td>
</tr></table>
</div>
<div class="memdoc"><p>Introduced in DOM Level 2
</p>
<p>
Tests whether the DOM implementation implements a specific feature and
that feature is supported by this node.
</p>
<p>
</p><dl compact><dt><b>Parameters:</b></dt><dd>
<table border="0" cellspacing="2" cellpadding="0">
<tr><td></td><td valign="top"><em>feature</em> </td><td> The name of the feature to test. This is the same name
which can be passed to the method hasFeature on DOMImplementation.
</td></tr>
<tr><td></td><td valign="top"><em>version</em> </td><td> This is the version number of the feature to test. In
Level 2, version 1, this is the string "2.0". If the version is not
specified, supporting any version of the feature will cause the method
to return true.
</td></tr>
</table></dl>
<p> <dl class="return" compact><dt><b>Returns:</b></dt><dd> Returns true if the specified feature is supported on this node,
false otherwise.
</dd></dl>
</p></div></div><a class="anchor" name="lastChild"></a>
<div class="memitem">
<div class="memproto">
<table class="memname"><tr>
<td class="memname"><a href="../khtml/DOM.Node.html">DOM.Node</a> lastChild</td>
<td>(</td>
<td class="paramtype"> </td>
<td class="paramname"><em>self</em> )</td>
<td width="100%"> </td>
</tr>
</table>
</div>
<div class="memdoc"><p>The last child of this node. If there is no such node, this
returns null .
</p></div></div><a class="anchor" name="localName"></a>
<div class="memitem">
<div class="memproto">
<table class="memname"><tr>
<td class="memname"><a href="../khtml/DOM.DOMString.html">DOM.DOMString</a> localName</td>
<td>(</td>
<td class="paramtype"> </td>
<td class="paramname"><em>self</em> )</td>
<td width="100%"> </td>
</tr>
</table>
</div>
<div class="memdoc"><p>Introduced in DOM Level 2
</p>
<p>
Returns the local part of the qualified name of this node.
For nodes of any type other than ELEMENT_NODE and ATTRIBUTE_NODE and
nodes created with a DOM Level 1 method, such as createElement from the
Document interface, this is always null.
</p></div></div><a class="anchor" name="namespaceURI"></a>
<div class="memitem">
<div class="memproto">
<table class="memname"><tr>
<td class="memname"><a href="../khtml/DOM.DOMString.html">DOM.DOMString</a> namespaceURI</td>
<td>(</td>
<td class="paramtype"> </td>
<td class="paramname"><em>self</em> )</td>
<td width="100%"> </td>
</tr>
</table>
</div>
<div class="memdoc"><p>Introduced in DOM Level 2
</p>
<p>
The namespace URI of this node, or null if it is unspecified.
This is not a computed value that is the result of a namespace lookup
based on an examination of the namespace declarations in scope. It is
merely the namespace URI given at creation time. For nodes of any type
other than ELEMENT_NODE and ATTRIBUTE_NODE and nodes created with a DOM
Level 1 method, such as createElement from the Document interface, this
is always null.
</p>
<p>
Note: Per the Namespaces in XML Specification [Namespaces] an attribute
does not inherit its namespace from the element it is attached to. If an
attribute is not explicitly given a namespace, it simply has no
namespace.
</p></div></div><a class="anchor" name="nextSibling"></a>
<div class="memitem">
<div class="memproto">
<table class="memname"><tr>
<td class="memname"><a href="../khtml/DOM.Node.html">DOM.Node</a> nextSibling</td>
<td>(</td>
<td class="paramtype"> </td>
<td class="paramname"><em>self</em> )</td>
<td width="100%"> </td>
</tr>
</table>
</div>
<div class="memdoc"><p>The node immediately following this node. If there is no such
node, this returns null .
</p></div></div><a class="anchor" name="nodeName"></a>
<div class="memitem">
<div class="memproto">
<table class="memname"><tr>
<td class="memname"><a href="../khtml/DOM.DOMString.html">DOM.DOMString</a> nodeName</td>
<td>(</td>
<td class="paramtype"> </td>
<td class="paramname"><em>self</em> )</td>
<td width="100%"> </td>
</tr>
</table>
</div>
<div class="memdoc"><p>The name of this node, depending on its type; see the table
above.
</p></div></div><a class="anchor" name="nodeType"></a>
<div class="memitem">
<div class="memproto">
<table class="memname"><tr>
<td class="memname">int nodeType</td>
<td>(</td>
<td class="paramtype"> </td>
<td class="paramname"><em>self</em> )</td>
<td width="100%"> </td>
</tr>
</table>
</div>
<div class="memdoc"><p>A code representing the type of the underlying object, as
defined above.
</p></div></div><a class="anchor" name="nodeValue"></a>
<div class="memitem">
<div class="memproto">
<table class="memname"><tr>
<td class="memname"><a href="../khtml/DOM.DOMString.html">DOM.DOMString</a> nodeValue</td>
<td>(</td>
<td class="paramtype"> </td>
<td class="paramname"><em>self</em> )</td>
<td width="100%"> </td>
</tr>
</table>
</div>
<div class="memdoc"><p>The value of this node, depending on its type; see the table
above.
</p>
<p>
DOMException
DOMSTRING_SIZE_ERR: Raised when it would return more characters
than fit in a DOMString variable on the
implementation platform.
</p></div></div><a class="anchor" name="normalize"></a>
<div class="memitem">
<div class="memproto">
<table class="memname"><tr>
<td class="memname"> normalize</td>
<td>(</td>
<td class="paramtype"> </td>
<td class="paramname"><em>self</em> )</td>
<td width="100%"> </td>
</tr>
</table>
</div>
<div class="memdoc"><p>Modified in DOM Level 2
</p>
<p>
Puts all Text nodes in the full depth of the sub-tree underneath this
Node, including attribute nodes, into a "normal" form where only
structure (e.g., elements, comments, processing instructions, CDATA
sections, and entity references) separates Text nodes, i.e., there are
neither adjacent Text nodes nor empty Text nodes. This can be used to
ensure that the DOM view of a document is the same as if it were saved
and re-loaded, and is useful when operations (such as XPointer
[XPointer] lookups) that depend on a particular document tree structure
are to be used.
</p>
<p>
Note: In cases where the document contains CDATASections, the normalize
operation alone may not be sufficient, since XPointers do not
differentiate between Text nodes and CDATASection nodes.
</p></div></div><a class="anchor" name="operator !="></a>
<div class="memitem">
<div class="memproto">
<table class="memname"><tr>
<td class="memname">bool operator !=</td>
<td>(</td>
<td class="paramtype"> <em>self</em>, </td>
<td class="paramname"></td>
</tr><tr>
<td class="memname"></td>
<td></td>
<td class="paramtype"><a href="../khtml/DOM.Node.html">DOM.Node</a> </td>
<td class="paramname"><em>other</em></td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td>
<td></td>
<td width="100%"> </td>
</tr></table>
</div>
<div class="memdoc"></div></div><a class="anchor" name="operator =="></a>
<div class="memitem">
<div class="memproto">
<table class="memname"><tr>
<td class="memname">bool operator ==</td>
<td>(</td>
<td class="paramtype"> <em>self</em>, </td>
<td class="paramname"></td>
</tr><tr>
<td class="memname"></td>
<td></td>
<td class="paramtype"><a href="../khtml/DOM.Node.html">DOM.Node</a> </td>
<td class="paramname"><em>other</em></td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td>
<td></td>
<td width="100%"> </td>
</tr></table>
</div>
<div class="memdoc"></div></div><a class="anchor" name="ownerDocument"></a>
<div class="memitem">
<div class="memproto">
<table class="memname"><tr>
<td class="memname"><a href="../khtml/DOM.Document.html">DOM.Document</a> ownerDocument</td>
<td>(</td>
<td class="paramtype"> </td>
<td class="paramname"><em>self</em> )</td>
<td width="100%"> </td>
</tr>
</table>
</div>
<div class="memdoc"><p>The Document object associated with this node.
This is also the Document object used to create
new nodes. When this node is a Document this is
null .
</p></div></div><a class="anchor" name="parentNode"></a>
<div class="memitem">
<div class="memproto">
<table class="memname"><tr>
<td class="memname"><a href="../khtml/DOM.Node.html">DOM.Node</a> parentNode</td>
<td>(</td>
<td class="paramtype"> </td>
<td class="paramname"><em>self</em> )</td>
<td width="100%"> </td>
</tr>
</table>
</div>
<div class="memdoc"><p>The parent of this node. All nodes, except Document
, DocumentFragment , and Attr
may have a parent. However, if a node has just been
created and not yet added to the tree, or if it has been
removed from the tree, this is null .
</p></div></div><a class="anchor" name="prefix"></a>
<div class="memitem">
<div class="memproto">
<table class="memname"><tr>
<td class="memname"><a href="../khtml/DOM.DOMString.html">DOM.DOMString</a> prefix</td>
<td>(</td>
<td class="paramtype"> </td>
<td class="paramname"><em>self</em> )</td>
<td width="100%"> </td>
</tr>
</table>
</div>
<div class="memdoc"><p>Introduced in DOM Level 2
</p>
<p>
The namespace prefix of this node, or null if it is unspecified.
Note that setting this attribute, when permitted, changes the nodeName
attribute, which holds the qualified name, as well as the tagName and
name attributes of the Element and Attr interfaces, when applicable.
Note also that changing the prefix of an attribute that is known to have
a default value, does not make a new attribute with the default value
and the original prefix appear, since the namespaceURI and localName do
not change.
For nodes of any type other than ELEMENT_NODE and ATTRIBUTE_NODE and
nodes created with a DOM Level 1 method, such as createElement from the
Document interface, this is always null.
</p></div></div><a class="anchor" name="previousSibling"></a>
<div class="memitem">
<div class="memproto">
<table class="memname"><tr>
<td class="memname"><a href="../khtml/DOM.Node.html">DOM.Node</a> previousSibling</td>
<td>(</td>
<td class="paramtype"> </td>
<td class="paramname"><em>self</em> )</td>
<td width="100%"> </td>
</tr>
</table>
</div>
<div class="memdoc"><p>The node immediately preceding this node. If there is no such
node, this returns null .
</p></div></div><a class="anchor" name="removeChild"></a>
<div class="memitem">
<div class="memproto">
<table class="memname"><tr>
<td class="memname"><a href="../khtml/DOM.Node.html">DOM.Node</a> removeChild</td>
<td>(</td>
<td class="paramtype"> <em>self</em>, </td>
<td class="paramname"></td>
</tr><tr>
<td class="memname"></td>
<td></td>
<td class="paramtype"><a href="../khtml/DOM.Node.html">DOM.Node</a> </td>
<td class="paramname"><em>oldChild</em></td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td>
<td></td>
<td width="100%"> </td>
</tr></table>
</div>
<div class="memdoc"><p>Removes the child node indicated by oldChild
from the list of children, and returns it.
</p>
<p>
</p><dl compact><dt><b>Parameters:</b></dt><dd>
<table border="0" cellspacing="2" cellpadding="0">
<tr><td></td><td valign="top"><em>oldChild</em> </td><td> The node being removed.
</td></tr>
</table></dl>
<p> <dl class="return" compact><dt><b>Returns:</b></dt><dd> The node removed.
</dd></dl> </p>
<p>
DOMException
NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly.
</p>
<p>
NOT_FOUND_ERR: Raised if oldChild is not a
child of this node.
</p></div></div><a class="anchor" name="removeEventListener"></a>
<div class="memitem">
<div class="memproto">
<table class="memname"><tr>
<td class="memname"> removeEventListener</td>
<td>(</td>
<td class="paramtype"> <em>self</em>, </td>
<td class="paramname"></td>
</tr><tr>
<td class="memname"></td>
<td></td>
<td class="paramtype"><a href="../khtml/DOM.DOMString.html">DOM.DOMString</a> </td>
<td class="paramname"><em>type</em>, </td>
</tr>
<tr>
<td class="memname"></td>
<td></td>
<td class="paramtype"><a href="../khtml/DOM.EventListener.html">DOM.EventListener</a> </td>
<td class="paramname"><em>listener</em>, </td>
</tr>
<tr>
<td class="memname"></td>
<td></td>
<td class="paramtype">bool </td>
<td class="paramname"><em>useCapture</em></td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td>
<td></td>
<td width="100%"> </td>
</tr></table>
</div>
<div class="memdoc"><p>Introduced in DOM Level 2
This method is from the EventTarget interface
</p>
<p>
This method allows the removal of event listeners from the event target.
If an EventListener is removed from an EventTarget while it is
processing an event, it will not be triggered by the current actions.
</p>
<p>
EventListeners can never be invoked after being removed.
</p>
<p>
Calling removeEventListener with arguments which do not identify any
currently registered EventListener on the EventTarget has no effect.
</p>
<p>
</p><dl compact><dt><b>Parameters:</b></dt><dd>
<table border="0" cellspacing="2" cellpadding="0">
<tr><td></td><td valign="top"><em>type</em> </td><td> Specifies the event type of the EventListener being removed.
</td></tr>
<tr><td></td><td valign="top"><em>listener</em> </td><td> The EventListener parameter indicates the EventListener
to be removed.
</td></tr>
<tr><td></td><td valign="top"><em>useCapture</em> </td><td> Specifies whether the EventListener being removed was
registered as a capturing listener or not. If a listener was registered
twice, one with capture and one without, each must be removed
separately. Removal of a capturing listener does not affect a
non-capturing version of the same listener, and vice versa.
</td></tr>
</table></dl>
<p>
</p></div></div><a class="anchor" name="replaceChild"></a>
<div class="memitem">
<div class="memproto">
<table class="memname"><tr>
<td class="memname"><a href="../khtml/DOM.Node.html">DOM.Node</a> replaceChild</td>
<td>(</td>
<td class="paramtype"> <em>self</em>, </td>
<td class="paramname"></td>
</tr><tr>
<td class="memname"></td>
<td></td>
<td class="paramtype"><a href="../khtml/DOM.Node.html">DOM.Node</a> </td>
<td class="paramname"><em>newChild</em>, </td>
</tr>
<tr>
<td class="memname"></td>
<td></td>
<td class="paramtype"><a href="../khtml/DOM.Node.html">DOM.Node</a> </td>
<td class="paramname"><em>oldChild</em></td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td>
<td></td>
<td width="100%"> </td>
</tr></table>
</div>
<div class="memdoc"><p>Replaces the child node oldChild with
newChild in the list of children, and returns the
oldChild node. If the newChild is
already in the tree, it is first removed.
</p>
<p>
</p><dl compact><dt><b>Parameters:</b></dt><dd>
<table border="0" cellspacing="2" cellpadding="0">
<tr><td></td><td valign="top"><em>newChild</em> </td><td> The new node to put in the child list.
</td></tr>
<tr><td></td><td valign="top"><em>oldChild</em> </td><td> The node being replaced in the list.
</td></tr>
</table></dl>
<p> <dl class="return" compact><dt><b>Returns:</b></dt><dd> The node replaced.
</dd></dl> </p>
<p>
DOMException
HIERARCHY_REQUEST_ERR: Raised if this node is of a type that
does not allow children of the type of the newChild
node, or it the node to put in is one of this node's
ancestors.
</p>
<p>
WRONG_DOCUMENT_ERR: Raised if newChild was
created from a different document than the one that created
this node.
</p>
<p>
NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly.
</p>
<p>
NOT_FOUND_ERR: Raised if oldChild is not a
child of this node.
</p></div></div><a class="anchor" name="setNodeValue"></a>
<div class="memitem">
<div class="memproto">
<table class="memname"><tr>
<td class="memname"> setNodeValue</td>
<td>(</td>
<td class="paramtype"> <em>self</em>, </td>
<td class="paramname"></td>
</tr><tr>
<td class="memname"></td>
<td></td>
<td class="paramtype"><a href="../khtml/DOM.DOMString.html">DOM.DOMString</a> </td>
<td class="paramname"><em>a0</em></td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td>
<td></td>
<td width="100%"> </td>
</tr></table>
</div>
<div class="memdoc"><p>see nodeValue
DOMException
NO_MODIFICATION_ALLOWED_ERR: Raised when the node is readonly.
</p></div></div><a class="anchor" name="setPrefix"></a>
<div class="memitem">
<div class="memproto">
<table class="memname"><tr>
<td class="memname"> setPrefix</td>
<td>(</td>
<td class="paramtype"> <em>self</em>, </td>
<td class="paramname"></td>
</tr><tr>
<td class="memname"></td>
<td></td>
<td class="paramtype"><a href="../khtml/DOM.DOMString.html">DOM.DOMString</a> </td>
<td class="paramname"><em>prefix</em></td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td>
<td></td>
<td width="100%"> </td>
</tr></table>
</div>
<div class="memdoc"><p>see prefix
</p>
<p>
DOMException
INVALID_CHARACTER_ERR: Raised if the specified prefix contains an
illegal character.
</p>
<p>
NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly.
</p>
<p>
NAMESPACE_ERR: Raised if the specified prefix is malformed, if the
namespaceURI of this node is null, if the specified prefix is "xml" and
the namespaceURI of this node is different from
"http://www.w3.org/XML/1998/namespace", if this node is an attribute and
the specified prefix is "xmlns" and the namespaceURI of this node is
different from "http://www.w3.org/2000/xmlns/", or if this node is an
attribute and the qualifiedName of this node is "xmlns" [Namespaces].
</p></div></div><a class="anchor" name="setTextContent"></a>
<div class="memitem">
<div class="memproto">
<table class="memname"><tr>
<td class="memname"> setTextContent</td>
<td>(</td>
<td class="paramtype"> <em>self</em>, </td>
<td class="paramname"></td>
</tr><tr>
<td class="memname"></td>
<td></td>
<td class="paramtype"><a href="../khtml/DOM.DOMString.html">DOM.DOMString</a> </td>
<td class="paramname"><em>text</em></td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td>
<td></td>
<td width="100%"> </td>
</tr></table>
</div>
<div class="memdoc"><p>see textContent()
</p>
<p>
DOMException
NO_MODIFICATION_ALLOWED_ERR: Raised when the node is readonly.
</p></div></div><a class="anchor" name="textContent"></a>
<div class="memitem">
<div class="memproto">
<table class="memname"><tr>
<td class="memname"><a href="../khtml/DOM.DOMString.html">DOM.DOMString</a> textContent</td>
<td>(</td>
<td class="paramtype"> </td>
<td class="paramname"><em>self</em> )</td>
<td width="100%"> </td>
</tr>
</table>
</div>
<div class="memdoc"><p>Introduced in DOM Level 3
</p>
<p>
This attribute returns the text content of this node and its
descendants. When it is defined to be null, setting it has no
effect. On setting, any possible children this node may have
are removed and, if it the new string is not empty or null,
replaced by a single Text node containing the string this
attribute is set to.
On getting, no serialization is performed, the returned string
does not contain any markup. No whitespace normalization is
performed and the returned string does not contain the white
spaces in element content (see the attribute
Text.isElementContentWhitespace). Similarly, on setting, no
parsing is performed either, the input string is taken as pure
textual content.
</p></div></div><a class="anchor" name="toHTML"></a>
<div class="memitem">
<div class="memproto">
<table class="memname"><tr>
<td class="memname">QString toHTML</td>
<td>(</td>
<td class="paramtype"> </td>
<td class="paramname"><em>self</em> )</td>
<td width="100%"> </td>
</tr>
</table>
</div>
<div class="memdoc"></div></div><hr><h2>Enumeration Documentation</h2><a class="anchor" name="DocumentPosition"></a>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr><td class="memname">DocumentPosition</td>
</tr>
</table>
</div>
<div class="memdoc"><p>Introduced in DOM Level 3.
</p>
<p>
These constants represent bitflags returned by the compareDocumentPosition
method.
</p>
<p>
<dl class="since" compact><dt><b>Since:</b></dt><dd> 4.2.4
</dd></dl>
</p><dl compact><dt><b>Enumerator: </b></dt><dd>
<table border="0" cellspacing="2" cellpadding="0"><tr><td valign="top"><em>DOCUMENT_POSITION_DISCONNECTED</em> = 0x01</td><td><tr><td valign="top"><em>DOCUMENT_POSITION_PRECEDING</em> = 0x02</td><td><tr><td valign="top"><em>DOCUMENT_POSITION_FOLLOWING</em> = 0x04</td><td><tr><td valign="top"><em>DOCUMENT_POSITION_CONTAINS</em> = 0x08</td><td><tr><td valign="top"><em>DOCUMENT_POSITION_CONTAINED_BY</em> = 0x10</td><td><tr><td valign="top"><em>DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC</em> = 0x20</td><td></table>
</dl>
</div></div><p><a class="anchor" name="NodeType"></a>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr><td class="memname">NodeType</td>
</tr>
</table>
</div>
<div class="memdoc"><p>An integer indicating which type of node this is.
</p>
<p>
<p>The values of nodeName, nodeValue,
and attributes vary according to the node type as follows:
<table border="1">
<tr>
<td></td>
<td>nodeName</td>
<td>nodeValue</td>
<td>attributes</td>
</tr>
<tr>
<td>Element</td>
<td>tagName</td>
<td>null</td>
<td>NamedNodeMap</td>
</tr>
<tr>
<td>Attr</td>
<td>name of attribute</td>
<td>value of attribute</td>
<td>null</td>
</tr>
<tr>
<td>Text</td>
<td>#text</td>
<td>content of the text node</td>
<td>null</td>
</tr>
<tr>
<td>CDATASection</td>
<td>#cdata-section</td>
<td>content of the CDATA Section</td>
<td>null</td>
</tr>
<tr>
<td>EntityReference</td>
<td>name of entity referenced</td>
<td>null</td>
<td>null</td>
</tr>
<tr>
<td>Entity</td>
<td>entity name</td>
<td>null</td>
<td>null</td>
</tr>
<tr>
<td>ProcessingInstruction</td>
<td>target</td>
<td>entire content excluding the target</td>
<td>null</td>
</tr>
<tr>
<td>Comment</td>
<td>#comment</td>
<td>content of the comment</td>
<td>null</td>
</tr>
<tr>
<td>Document</td>
<td>#document</td>
<td>null</td>
<td>null</td>
</tr>
<tr>
<td>DocumentType</td>
<td>document type name</td>
<td>null</td>
<td>null</td>
</tr>
<tr>
<td>DocumentFragment</td>
<td>#document-fragment</td>
<td>null</td>
<td>null</td>
</tr>
<tr>
<td>Notation</td>
<td>notation name</td>
<td>null</td>
<td>null</td>
</tr>
</table>
</p>
</p><dl compact><dt><b>Enumerator: </b></dt><dd>
<table border="0" cellspacing="2" cellpadding="0"><tr><td valign="top"><em>ELEMENT_NODE</em> = 1</td><td><tr><td valign="top"><em>ATTRIBUTE_NODE</em> = 2</td><td><tr><td valign="top"><em>TEXT_NODE</em> = 3</td><td><tr><td valign="top"><em>CDATA_SECTION_NODE</em> = 4</td><td><tr><td valign="top"><em>ENTITY_REFERENCE_NODE</em> = 5</td><td><tr><td valign="top"><em>ENTITY_NODE</em> = 6</td><td><tr><td valign="top"><em>PROCESSING_INSTRUCTION_NODE</em> = 7</td><td><tr><td valign="top"><em>COMMENT_NODE</em> = 8</td><td><tr><td valign="top"><em>DOCUMENT_NODE</em> = 9</td><td><tr><td valign="top"><em>DOCUMENT_TYPE_NODE</em> = 10</td><td><tr><td valign="top"><em>DOCUMENT_FRAGMENT_NODE</em> = 11</td><td><tr><td valign="top"><em>NOTATION_NODE</em> = 12</td><td><tr><td valign="top"><em>XPATH_NAMESPACE_NODE</em> = 13</td><td></table>
</dl>
</div></div><p>
</div>
</div>
</div>
<div id="left">
<div class="menu_box">
<div class="nav_list">
<ul>
<li><a href="../allclasses.html">Full Index</a></li>
</ul>
</div>
<a name="cp-menu" /><div class="menutitle"><div>
<h2 id="cp-menu-project">Modules</h2>
</div></div>
<div class="nav_list">
<ul><li><a href="../akonadi/index.html">akonadi</a></li>
<li><a href="../dnssd/index.html">dnssd</a></li>
<li><a href="../kdecore/index.html">kdecore</a></li>
<li><a href="../kdeui/index.html">kdeui</a></li>
<li><a href="../khtml/index.html">khtml</a></li>
<li><a href="../kio/index.html">kio</a></li>
<li><a href="../knewstuff/index.html">knewstuff</a></li>
<li><a href="../kparts/index.html">kparts</a></li>
<li><a href="../kutils/index.html">kutils</a></li>
<li><a href="../nepomuk/index.html">nepomuk</a></li>
<li><a href="../phonon/index.html">phonon</a></li>
<li><a href="../plasma/index.html">plasma</a></li>
<li><a href="../polkitqt/index.html">polkitqt</a></li>
<li><a href="../solid/index.html">solid</a></li>
<li><a href="../soprano/index.html">soprano</a></li>
</ul></div></div>
</div>
</div>
<div class="clearer"/>
</div>
<div id="end_body"></div>
</div>
<div id="footer"><div id="footer_text">
This documentation is maintained by <a href="mailto:simon@simonzone.com">Simon Edwards</a>.<br />
KDE<sup>®</sup> and <a href="../images/kde_gear_black.png">the K Desktop Environment<sup>®</sup> logo</a> are registered trademarks of <a href="http://ev.kde.org/" title="Homepage of the KDE non-profit Organization">KDE e.V.</a> |
<a href="http://www.kde.org/contact/impressum.php">Legal</a>
</div></div>
</body>
</html>
| Java |
<?php
/**
* H4PH - HTML4 PHP Helper
* @link https://github.com/Coft/H4PH
*/
class Td
{
/**
* contains all setted attributes
* @var array
*/
private $attrs = array();
/**
* keeps content
* @var string
*/
private $content = null;
/**
* holds markup name
* @var string
*/
private static $markupName = 'td';
/**
* tells is this markup can handle content
* @var bool
*/
private static $isContenerable = true;
/**
* __construct() - can add content to tag
* @param null|string $content
* @return Td
*/
public function __construct($content = null)
{
$argumentsNumber = func_num_args();
for ($i = 0; $i < $argumentsNumber; $i++) {
$this->addContent(func_get_arg($i));
}
}
/**
* renders tag and it content to string
* @param null|string $content
* @return Td
*/
public static function getInstance($content = null)
{
$markupTag = new Td;
$argumentsNumber = func_num_args();
for ($i = 0; $i < $argumentsNumber; $i++) {
$markupTag->addContent(func_get_arg($i));
}
return $markupTag;
}
/**
* adds content to tag
* @param null|string $content
* @return Td
*/
public function addContent($content = null)
{
$this->content .= (string) $content;
return $this;
}
/**
* renders tag and it content to string
* @return string
*/
public function __toString()
{
$parsedAttrs = '';
foreach ($this->attrs as $attrName => $attrValue) {
$parsedAttrs .= ' '.$attrName.'=\''.$attrValue.'\'';
}
return '<'.self::$markupName.$parsedAttrs.'>'.$this->content.'</'.self::$markupName.'>';
}
/**
* sets abbr attribute
* @param null|string $value
* @return Td
*/
public function abbr($value = null)
{
$this->attrs['abbr'] = $value;
return $this;
}
/**
* sets align attribute
* @param null|string $value
* @return Td
*/
public function align($value = null)
{
$this->attrs['align'] = $value;
return $this;
}
/**
* sets axis attribute
* @param null|string $value
* @return Td
*/
public function axis($value = null)
{
$this->attrs['axis'] = $value;
return $this;
}
/**
* sets char attribute
* @param null|string $value
* @return Td
*/
public function char($value = null)
{
$this->attrs['char'] = $value;
return $this;
}
/**
* sets charoff attribute
* @param null|string $value
* @return Td
*/
public function charoff($value = null)
{
$this->attrs['charoff'] = $value;
return $this;
}
/**
* sets colspan attribute
* @param null|string $value
* @return Td
*/
public function colspan($value = null)
{
$this->attrs['colspan'] = $value;
return $this;
}
/**
* sets headers attribute
* @param null|string $value
* @return Td
*/
public function headers($value = null)
{
$this->attrs['headers'] = $value;
return $this;
}
/**
* sets rowspan attribute
* @param null|string $value
* @return Td
*/
public function rowspan($value = null)
{
$this->attrs['rowspan'] = $value;
return $this;
}
/**
* sets scope attribute
* @param null|string $value
* @return Td
*/
public function scope($value = null)
{
$this->attrs['scope'] = $value;
return $this;
}
/**
* sets valign attribute
* @param null|string $value
* @return Td
*/
public function valign($value = null)
{
$this->attrs['valign'] = $value;
return $this;
}
/**
* sets classes attribute
* @param null|string $value
* @return Td
*/
public function classes($value = null)
{
$this->attrs['class'] = $value;
return $this;
}
/**
* sets dir attribute
* @param null|string $value
* @return Td
*/
public function dir($value = null)
{
$this->attrs['dir'] = $value;
return $this;
}
/**
* sets id attribute
* @param null|string $value
* @return Td
*/
public function id($value = null)
{
$this->attrs['id'] = $value;
return $this;
}
/**
* sets lang attribute
* @param null|string $value
* @return Td
*/
public function lang($value = null)
{
$this->attrs['lang'] = $value;
return $this;
}
/**
* sets style attribute
* @param null|string $value
* @return Td
*/
public function style($value = null)
{
$this->attrs['style'] = $value;
return $this;
}
/**
* sets title attribute
* @param null|string $value
* @return Td
*/
public function title($value = null)
{
$this->attrs['title'] = $value;
return $this;
}
/**
* sets xmlLang attribute
* @param null|string $value
* @return Td
*/
public function xmlLang($value = null)
{
$this->attrs['xml:lang'] = $value;
return $this;
}
/**
* sets onclick attribute
* @param null|string $value
* @return Td
*/
public function onclick($value = null)
{
$this->attrs['onclick'] = $value;
return $this;
}
/**
* sets ondblclick attribute
* @param null|string $value
* @return Td
*/
public function ondblclick($value = null)
{
$this->attrs['ondblclick'] = $value;
return $this;
}
/**
* sets onmousedown attribute
* @param null|string $value
* @return Td
*/
public function onmousedown($value = null)
{
$this->attrs['onmousedown'] = $value;
return $this;
}
/**
* sets onmousemove attribute
* @param null|string $value
* @return Td
*/
public function onmousemove($value = null)
{
$this->attrs['onmousemove'] = $value;
return $this;
}
/**
* sets onmouseout attribute
* @param null|string $value
* @return Td
*/
public function onmouseout($value = null)
{
$this->attrs['onmouseout'] = $value;
return $this;
}
/**
* sets onmouseover attribute
* @param null|string $value
* @return Td
*/
public function onmouseover($value = null)
{
$this->attrs['onmouseover'] = $value;
return $this;
}
/**
* sets onmouseup attribute
* @param null|string $value
* @return Td
*/
public function onmouseup($value = null)
{
$this->attrs['onmouseup'] = $value;
return $this;
}
/**
* sets onkeydown attribute
* @param null|string $value
* @return Td
*/
public function onkeydown($value = null)
{
$this->attrs['onkeydown'] = $value;
return $this;
}
/**
* sets onkeypress attribute
* @param null|string $value
* @return Td
*/
public function onkeypress($value = null)
{
$this->attrs['onkeypress'] = $value;
return $this;
}
/**
* sets onkeyup attribute
* @param null|string $value
* @return Td
*/
public function onkeyup($value = null)
{
$this->attrs['onkeyup'] = $value;
return $this;
}
}
?> | Java |
var SPHERE = {
getSphereVertex: function (radius, res) { // Se obtienen los vértices, normales y coordenadas de textura
var vertexData = [], alpha, beta, x, y, z, u, v;
for (var i = 0; i <= res; i++) { // Se recorren las latitudes
alpha = i * Math.PI / res; // Ángulo latitud
for (var j = 0; j <= res; j++) { // Se recorren las longitudes
beta = j * 2 * Math.PI / res; // Ángulo longitud
// Cálculo de x, y, z para vértices y normales
x = Math.cos(beta) * Math.sin(alpha);
y = Math.cos(alpha);
z = Math.sin(beta) * Math.sin(alpha);
// Cálculo de u, v para las coordenadas de textura
u = 1 - (j / res);
v = 1 - (i / res);
// Vértices
vertexData.push(radius * x);
vertexData.push(radius * y);
vertexData.push(radius * z);
// Normales
vertexData.push(x);
vertexData.push(y);
vertexData.push(z);
// Coordenadas de textura
vertexData.push(u);
vertexData.push(v);
}
}
return vertexData;
},
getShereFaces: function (res) { // Se obtienen los índices para crear las caras
var indexData = [], first, second;
for (var i = 0; i < res; i++) { // Se recorren las latitudes
for (var j = 0; j < res; j++) { // Se recorren las longitudes
// Cálculo de las esquinas superior e inferior izquierda
first = (i * (res + 1)) + j;
second = first + res + 1;
// Cara par
indexData.push(first); // Esquina superior izquierda
indexData.push(second); // Esquina inferior izquierda
indexData.push(first + 1); // Esquina superior derecha
// Cara impar
indexData.push(second); // Esquina inferior izquierda
indexData.push(second + 1); // Esquina inferior derecha
indexData.push(first + 1); // Esquina superior derecha
}
}
return indexData;
}
}; | Java |
/**
*
*/
package org.sylvani.io.voice.http;
import java.io.IOException;
import java.util.List;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.eclipse.emf.common.util.EList;
import org.eclipse.smarthome.model.sitemap.Sitemap;
import org.eclipse.smarthome.model.sitemap.SitemapProvider;
import org.eclipse.smarthome.model.sitemap.Widget;
import org.eclipse.smarthome.ui.items.ItemUIRegistry;
/**
* Varianten
* - Simple and Stupid HAL9000
* - Volltext
* - Tagged Analyse
*
* @author hkuhn
*
*/
public class RecognitionRelayServlet extends HttpServlet {
private static final long serialVersionUID = 1L;
private ItemUIRegistry itemUIRegistry;
private List<SitemapProvider> sitemaps;
public RecognitionRelayServlet(ItemUIRegistry itemUIRegistry, List<SitemapProvider> sitemaps) {
this.itemUIRegistry = itemUIRegistry;
this.sitemaps = sitemaps;
}
@Override
protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
super.doPost(req, resp);
}
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
for (SitemapProvider sitemapProvider : sitemaps) {
for (String sitemapName : sitemapProvider.getSitemapNames()) {
System.out.println("sitemap " + sitemapName);
Sitemap sitemap = sitemapProvider.getSitemap(sitemapName);
EList<Widget> list = sitemap.getChildren();
for (Widget widget : list) {
System.out.println("#Widget " + widget.getLabel() + " " + widget.getItem());
}
}
}
}
}
| Java |
class Class3_Sub28 extends Class3 {
static Class94[] aClass94Array2566 = new Class94[200];
static int anInt2567 = -1;
private static Class94 aClass94_2568 = Class3_Sub4.buildString("Started 3d Library");
long aLong2569;
Class3_Sub28 aClass3_Sub28_2570;
static int anInt2571;
static int anInt2572;
static Class153 aClass153_2573;
static int[] anIntArray2574 = new int[14];
static int anInt2575;
static Class94 aClass94_2576 = aClass94_2568;
static int anInt2577 = 0;
Class3_Sub28 aClass3_Sub28_2578;
static final void method518(Class140_Sub4_Sub1 var0, int var1) {
try {
Class3_Sub9 var2 = (Class3_Sub9)Class3_Sub28_Sub7_Sub1.aClass130_4046.method1780(var0.aClass94_3967.method1578(-121), 0);
if(var1 >= -85) {
method523(40, -17, -52, -32, 9, -51, -85, -84, -19);
}
if(var2 != null) {
var2.method134(1);
} else {
Class70.method1286(var0.anIntArray2755[0], false, (Class111)null, 0, (Class140_Sub4_Sub2)null, var0.anIntArray2767[0], Class26.anInt501, var0);
}
} catch (RuntimeException var3) {
throw Class44.method1067(var3, "rg.UA(" + (var0 != null?"{...}":"null") + ',' + var1 + ')');
}
}
static final int method519(int var0, boolean var1, int var2, int var3) {
try {
var0 &= 3;
if(!var1) {
method520((byte)-89);
}
return 0 != var0?(~var0 != -2?(~var0 == -3?-var3 + 7:-var2 + 7):var2):var3;
} catch (RuntimeException var5) {
throw Class44.method1067(var5, "rg.RA(" + var0 + ',' + var1 + ',' + var2 + ',' + var3 + ')');
}
}
static final Class3_Sub28_Sub3 method520(byte var0) {
try {
int var1 = -122 % ((var0 - -48) / 33);
return Class3_Sub30.aClass3_Sub28_Sub3_2600;
} catch (RuntimeException var2) {
throw Class44.method1067(var2, "rg.OA(" + var0 + ')');
}
}
public static void method521(int var0) {
try {
aClass153_2573 = null;
if(var0 == -3) {
aClass94Array2566 = null;
aClass94_2568 = null;
anIntArray2574 = null;
aClass94_2576 = null;
}
} catch (RuntimeException var2) {
throw Class44.method1067(var2, "rg.QA(" + var0 + ')');
}
}
static final Class90 method522(int var0, int var1) {
try {
Class90 var2 = (Class90)Class3_Sub28_Sub7_Sub1.aClass93_4043.method1526((long)var0, (byte)121);
if(null == var2) {
byte[] var3 = Class29.aClass153_557.method2133(Class38_Sub1.method1031(var0, 2), (byte)-122, Canvas_Sub1.method54(var0, false));
var2 = new Class90();
if(var1 != 27112) {
anInt2572 = -67;
}
var2.anInt1284 = var0;
if(null != var3) {
var2.method1478(new Class3_Sub30(var3), 74);
}
var2.method1481(98);
Class3_Sub28_Sub7_Sub1.aClass93_4043.method1515((byte)-95, var2, (long)var0);
return var2;
} else {
return var2;
}
} catch (RuntimeException var4) {
throw Class44.method1067(var4, "rg.PA(" + var0 + ',' + var1 + ')');
}
}
static final void method523(int var0, int var1, int var2, int var3, int var4, int var5, int var6, int var7, int var8) {
try {
int var9 = var3 - var8;
int var11 = (-var5 + var0 << 16) / var9;
int var10 = -var4 + var6;
int var12 = (var7 + -var1 << 16) / var10;
Class83.method1410(var1, 0, var6, var4, var3, var5, var8, var12, var11, var2, -12541);
} catch (RuntimeException var13) {
throw Class44.method1067(var13, "rg.SA(" + var0 + ',' + var1 + ',' + var2 + ',' + var3 + ',' + var4 + ',' + var5 + ',' + var6 + ',' + var7 + ',' + var8 + ')');
}
}
final void method524(byte var1) {
try {
if(this.aClass3_Sub28_2570 != null) {
this.aClass3_Sub28_2570.aClass3_Sub28_2578 = this.aClass3_Sub28_2578;
this.aClass3_Sub28_2578.aClass3_Sub28_2570 = this.aClass3_Sub28_2570;
this.aClass3_Sub28_2578 = null;
this.aClass3_Sub28_2570 = null;
if(var1 != -107) {
this.aClass3_Sub28_2578 = (Class3_Sub28)null;
}
}
} catch (RuntimeException var3) {
throw Class44.method1067(var3, "rg.TA(" + var1 + ')');
}
}
}
| Java |
/*
Kvalobs - Free Quality Control Software for Meteorological Observations
$Id: Data.h,v 1.2.6.2 2007/09/27 09:02:22 paule Exp $
Copyright (C) 2007 met.no
Contact information:
Norwegian Meteorological Institute
Box 43 Blindern
0313 OSLO
NORWAY
email: kvalobs-dev@met.no
This file is part of KVALOBS
KVALOBS 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.
KVALOBS 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 KVALOBS; if not, write to the Free Software Foundation Inc.,
51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include <boost/assign.hpp>
#include "EncodeBufr302053.h"
EncodeBufr302053::
EncodeBufr302053()
{
}
std::string
EncodeBufr302053::
logIdentifier() const
{
return "302053";
}
std::list<int>
EncodeBufr302053::
encodeIds()const
{
std::list<int> ids;
boost::assign::push_back( ids )(302053);
return ids;
}
void
EncodeBufr302053::
encode( )
{
bufr->addValue( 7032, stationInfo->heightVisability(), "h_V, height of visibility sensor above marine deck.", false );
bufr->addValue( 7033, FLT_MAX, "h_V, height of visibility sensor above water surface.", false );
bufr->addValue( 20001, data->VV, "VV, horisental visibility" );
}
| Java |
## PostgreSQL 拒绝服务DDOS攻击与防范
### 作者
digoal
### 日期
2018-12-02
### 标签
PostgreSQL , ddos , 拒绝服务 , 锁 , SLOT
----
## 背景
连接数据库的过程中,需要数据库有足够的SLOT(连接槽,通过max_connections配置),认证。如果把连接槽位占用,或者在认证过程加锁(使得认证过程被锁),则可以制造DDOS攻击。
占用连接槽的攻击与防范方法:
[《PostgreSQL 连接攻击(类似DDoS)》](../201706/20170629_02.md)
认证过程加锁的攻击方法,本文会提到。
https://paquier.xyz/postgresql-2/postgres-12-dos-prevention/
https://www.postgresql.org/message-id/152512087100.19803.12733865831237526317@wrigleys.postgresql.org
```
BUG #15182: Canceling authentication due to timeout aka Denial of Service Attack
From: PG Bug reporting form <noreply(at)postgresql(dot)org>
To: pgsql-bugs(at)lists(dot)postgresql(dot)org
Cc: lalbin(at)scharp(dot)org
Subject: BUG #15182: Canceling authentication due to timeout aka Denial of Service Attack
Date: 2018-04-30 20:41:11
Message-ID: 152512087100.19803.12733865831237526317@wrigleys.postgresql.org
Views: Raw Message | Whole Thread | Download mbox
Thread:
Lists: pgsql-bugs pgsql-hackers
The following bug has been logged on the website:
Bug reference: 15182
Logged by: Lloyd Albin
Email address: lalbin(at)scharp(dot)org
PostgreSQL version: 10.3
Operating system: OpenSUSE
Description:
Over the last several weeks our developers caused a Denial of Service Attack
against ourselves by accident. When looking at the log files, I noticed that
we had authentication timeouts during these time periods. In researching the
problem I found this is due to locks being held on shared system catalog
items, aka system catalog items that are shared between all databases on the
same cluster/server. This can be caused by beginning a long running
transaction that queries pg_stat_activity, pg_roles, pg_database, etc and
then another connection that runs either a REINDEX DATABASE, REINDEX SYSTEM,
or VACUUM FULL. This issue is of particular importance to database resellers
who use the same cluster/server for multiple clients, as two clients can
cause this issue to happen inadvertently or a single client can either cause
it to happen maliciously or inadvertently. Note: The large cloud providers
give each of their clients their own cluster/server so this will not affect
across cloud clients but can affect an individual client. The problem is
that traditional hosting companies will have all clients from one or more
web servers share the same PostgreSQL cluster/server. This means that one or
two clients could inadvertently stop all the other clients from being able
to connect to their databases until the first client does either a COMMIT or
ROLLBACK of their transaction which they could hold open for hours, which is
what happened to us internally.
In Connection 1 we need to BEGIN a transaction and then query a shared
system item; pg_authid, pg_database, etc; or a view that depends on a shared
system item; pg_stat_activity, pg_roles, etc. Our developers were accessing
pg_roles.
Connection 1 (Any database, Any User)
BEGIN;
SELECT * FROM pg_stat_activity;
Connection 2 (Any database will do as long as you are the database owner)
REINDEX DATABASE postgres;
Connection 3 (Any Database, Any User)
psql -h sqltest-alt -d sandbox
All future Connection 3's will hang for however long the transaction in
Connection 1 runs. In our case this was hours and denied everybody else the
ability to log into the server until Connection 1 was committed. psql will
just hang for hours, even overnight in my testing, but our apps would get
the "Canceling authentication due to timeout" after 1 minute.
Connection 2 can also do any of these commands to also cause the same
issue:
REINDEX SYSTEM postgres;
VACUUM FULL pg_authid;
vacuumdb -f -h sqltest-alt -d lloyd -U lalbin
Even worse is that the VACUUM FULL pg_authid; can be started by an
unprivileged user and it will wait for the AccessShareLock by connection 1
to be released before returning the error that you don't have permission to
perform this action, so even an unprivileged user can cause this to happen.
The privilege check needs to happen before the waiting for the
AccessExclusiveLock happens.
This bug report has been simplified and shorted drastically. To read the
full information about this issue please see my blog post:
http://lloyd.thealbins.com/Canceling%20authentication%20due%20to%20timeout
Lloyd Albin
Database Administrator
Statistical Center for HIV/AIDS Research and Prevention (SCHARP)
Fred Hutchinson Cancer Research Center
```
复现方法如上。
## 防范
1、对于连接占用DDOS攻击的防范(1,设置认证超时参数。2,不要在公网监听。3,设置网络层防火墙。)
2、对于锁攻击(通常是无意识攻击),建议在操作大锁的SQL前,加锁超时,或者语句超时(尽量减少等待时长)。 (lock_timeout, statement_timeout都可以)
## 参考
[《PostgreSQL 锁等待监控 珍藏级SQL - 谁堵塞了谁》](../201705/20170521_01.md)
[《PostgreSQL 设置单条SQL的执行超时 - 防雪崩》](../201712/20171211_02.md)
[《如何防止数据库雪崩(泛洪 flood)》](../201609/20160909_01.md)
https://paquier.xyz/postgresql-2/postgres-12-dos-prevention/
[《PostgreSQL 连接攻击(类似DDoS)》](../201706/20170629_02.md)
#### [PostgreSQL 许愿链接](https://github.com/digoal/blog/issues/76 "269ac3d1c492e938c0191101c7238216")
您的愿望将传达给PG kernel hacker、数据库厂商等, 帮助提高数据库产品质量和功能, 说不定下一个PG版本就有您提出的功能点. 针对非常好的提议,奖励限量版PG文化衫、纪念品、贴纸、PG热门书籍等,奖品丰富,快来许愿。[开不开森](https://github.com/digoal/blog/issues/76 "269ac3d1c492e938c0191101c7238216").
#### [9.9元购买3个月阿里云RDS PostgreSQL实例](https://www.aliyun.com/database/postgresqlactivity "57258f76c37864c6e6d23383d05714ea")
#### [PostgreSQL 解决方案集合](https://yq.aliyun.com/topic/118 "40cff096e9ed7122c512b35d8561d9c8")
#### [德哥 / digoal's github - 公益是一辈子的事.](https://github.com/digoal/blog/blob/master/README.md "22709685feb7cab07d30f30387f0a9ae")

| Java |
using System;
namespace WIC
{
public enum DXGI_FORMAT
{
DXGI_FORMAT_UNKNOWN,
DXGI_FORMAT_R32G32B32A32_TYPELESS,
DXGI_FORMAT_R32G32B32A32_FLOAT,
DXGI_FORMAT_R32G32B32A32_UINT,
DXGI_FORMAT_R32G32B32A32_SINT,
DXGI_FORMAT_R32G32B32_TYPELESS,
DXGI_FORMAT_R32G32B32_FLOAT,
DXGI_FORMAT_R32G32B32_UINT,
DXGI_FORMAT_R32G32B32_SINT,
DXGI_FORMAT_R16G16B16A16_TYPELESS,
DXGI_FORMAT_R16G16B16A16_FLOAT,
DXGI_FORMAT_R16G16B16A16_UNORM,
DXGI_FORMAT_R16G16B16A16_UINT,
DXGI_FORMAT_R16G16B16A16_SNORM,
DXGI_FORMAT_R16G16B16A16_SINT,
DXGI_FORMAT_R32G32_TYPELESS,
DXGI_FORMAT_R32G32_FLOAT,
DXGI_FORMAT_R32G32_UINT,
DXGI_FORMAT_R32G32_SINT,
DXGI_FORMAT_R32G8X24_TYPELESS,
DXGI_FORMAT_D32_FLOAT_S8X24_UINT,
DXGI_FORMAT_R32_FLOAT_X8X24_TYPELESS,
DXGI_FORMAT_X32_TYPELESS_G8X24_UINT,
DXGI_FORMAT_R10G10B10A2_TYPELESS,
DXGI_FORMAT_R10G10B10A2_UNORM,
DXGI_FORMAT_R10G10B10A2_UINT,
DXGI_FORMAT_R11G11B10_FLOAT,
DXGI_FORMAT_R8G8B8A8_TYPELESS,
DXGI_FORMAT_R8G8B8A8_UNORM,
DXGI_FORMAT_R8G8B8A8_UNORM_SRGB,
DXGI_FORMAT_R8G8B8A8_UINT,
DXGI_FORMAT_R8G8B8A8_SNORM,
DXGI_FORMAT_R8G8B8A8_SINT,
DXGI_FORMAT_R16G16_TYPELESS,
DXGI_FORMAT_R16G16_FLOAT,
DXGI_FORMAT_R16G16_UNORM,
DXGI_FORMAT_R16G16_UINT,
DXGI_FORMAT_R16G16_SNORM,
DXGI_FORMAT_R16G16_SINT,
DXGI_FORMAT_R32_TYPELESS,
DXGI_FORMAT_D32_FLOAT,
DXGI_FORMAT_R32_FLOAT,
DXGI_FORMAT_R32_UINT,
DXGI_FORMAT_R32_SINT,
DXGI_FORMAT_R24G8_TYPELESS,
DXGI_FORMAT_D24_UNORM_S8_UINT,
DXGI_FORMAT_R24_UNORM_X8_TYPELESS,
DXGI_FORMAT_X24_TYPELESS_G8_UINT,
DXGI_FORMAT_R8G8_TYPELESS,
DXGI_FORMAT_R8G8_UNORM,
DXGI_FORMAT_R8G8_UINT,
DXGI_FORMAT_R8G8_SNORM,
DXGI_FORMAT_R8G8_SINT,
DXGI_FORMAT_R16_TYPELESS,
DXGI_FORMAT_R16_FLOAT,
DXGI_FORMAT_D16_UNORM,
DXGI_FORMAT_R16_UNORM,
DXGI_FORMAT_R16_UINT,
DXGI_FORMAT_R16_SNORM,
DXGI_FORMAT_R16_SINT,
DXGI_FORMAT_R8_TYPELESS,
DXGI_FORMAT_R8_UNORM,
DXGI_FORMAT_R8_UINT,
DXGI_FORMAT_R8_SNORM,
DXGI_FORMAT_R8_SINT,
DXGI_FORMAT_A8_UNORM,
DXGI_FORMAT_R1_UNORM,
DXGI_FORMAT_R9G9B9E5_SHAREDEXP,
DXGI_FORMAT_R8G8_B8G8_UNORM,
DXGI_FORMAT_G8R8_G8B8_UNORM,
DXGI_FORMAT_BC1_TYPELESS,
DXGI_FORMAT_BC1_UNORM,
DXGI_FORMAT_BC1_UNORM_SRGB,
DXGI_FORMAT_BC2_TYPELESS,
DXGI_FORMAT_BC2_UNORM,
DXGI_FORMAT_BC2_UNORM_SRGB,
DXGI_FORMAT_BC3_TYPELESS,
DXGI_FORMAT_BC3_UNORM,
DXGI_FORMAT_BC3_UNORM_SRGB,
DXGI_FORMAT_BC4_TYPELESS,
DXGI_FORMAT_BC4_UNORM,
DXGI_FORMAT_BC4_SNORM,
DXGI_FORMAT_BC5_TYPELESS,
DXGI_FORMAT_BC5_UNORM,
DXGI_FORMAT_BC5_SNORM,
DXGI_FORMAT_B5G6R5_UNORM,
DXGI_FORMAT_B5G5R5A1_UNORM,
DXGI_FORMAT_B8G8R8A8_UNORM,
DXGI_FORMAT_B8G8R8X8_UNORM,
DXGI_FORMAT_R10G10B10_XR_BIAS_A2_UNORM,
DXGI_FORMAT_B8G8R8A8_TYPELESS,
DXGI_FORMAT_B8G8R8A8_UNORM_SRGB,
DXGI_FORMAT_B8G8R8X8_TYPELESS,
DXGI_FORMAT_B8G8R8X8_UNORM_SRGB,
DXGI_FORMAT_BC6H_TYPELESS,
DXGI_FORMAT_BC6H_UF16,
DXGI_FORMAT_BC6H_SF16,
DXGI_FORMAT_BC7_TYPELESS,
DXGI_FORMAT_BC7_UNORM,
DXGI_FORMAT_BC7_UNORM_SRGB,
DXGI_FORMAT_AYUV,
DXGI_FORMAT_Y410,
DXGI_FORMAT_Y416,
DXGI_FORMAT_NV12,
DXGI_FORMAT_P010,
DXGI_FORMAT_P016,
DXGI_FORMAT_420_OPAQUE,
DXGI_FORMAT_YUY2,
DXGI_FORMAT_Y210,
DXGI_FORMAT_Y216,
DXGI_FORMAT_NV11,
DXGI_FORMAT_AI44,
DXGI_FORMAT_IA44,
DXGI_FORMAT_P8,
DXGI_FORMAT_A8P8,
DXGI_FORMAT_B4G4R4A4_UNORM,
DXGI_FORMAT_FORCE_UINT = -1
}
}
| Java |
/***************************************************************************
getfmtast.cpp - returns the AST for formatted IO
-------------------
begin : July 22 2002
copyright : (C) 2002 by Marc Schellens
email : m_schellens@users.sf.net
***************************************************************************/
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
//#define FMT_DEBUG
#undef FMT_DEBUG
#include "includefirst.hpp"
#include "basegdl.hpp"
#include "fmtnode.hpp"
#include "print_tree.hpp"
#include "FMTLexer.hpp"
#include "FMTParser.hpp"
#include <antlr/ASTFactory.hpp>
using namespace std;
antlr::ASTFactory FMTNodeFactory("FMTNode",FMTNode::factory);
RefFMTNode GetFMTAST( DString fmtString)
{
istringstream istr(fmtString); //+"\n");
RefFMTNode fmtAST;
try {
antlr::TokenStreamSelector selector;
FMTLexer lexer( istr);
lexer.SetSelector( selector);
CFMTLexer cLexer( lexer.getInputState());
cLexer.SetSelector( selector);
lexer.SetCLexer( cLexer);
selector.select( &lexer);
FMTParser parser( selector);
// because we use the standard (ANTLR generated) constructor here
// we cannot do it in the constructor
parser.initializeASTFactory( FMTNodeFactory);
parser.setASTFactory( &FMTNodeFactory );
parser.format( 1);
fmtAST=parser.getAST();
#ifdef FMT_DEBUG
antlr::print_tree pt;
pt.pr_tree(static_cast<antlr::RefAST>(fmtAST));
cout << endl;
#endif
}
catch( GDLException& ex)
{
throw GDLException("Format: "+ex.getMessage());
}
catch( antlr::ANTLRException& ex)
{
throw GDLException("Format parser: "+ex.getMessage());
}
catch( exception& ex)
{
throw GDLException("Format exception: "+string(ex.what()));
}
catch(...)
{
throw GDLException("Format: general exception.");
}
return fmtAST;
}
| Java |
#
# \brief Download and unpack upstream library source codes
# \author Norman Feske
# \date 2009-10-16
#
#
# Print help information by default
#
help::
VERBOSE ?= @
ECHO = @echo
DOWNLOAD_DIR = download
CONTRIB_DIR = contrib
GNU_FIND = find
SHELL = bash
#
# Create download and contrib directory so that '<port>.mk' files
# do not need to care for them.
#
prepare:: $(DOWNLOAD_DIR) $(CONTRIB_DIR)
#
# Utility to check if a tool is installed
#
check_tool = $(if $(shell which $(1)),,$(error Need to have '$(1)' installed.))
$(call check_tool,wget)
$(call check_tool,patch)
#
# Include information about available ports
#
# Each '<port>.mk' file in the 'ports/' directory extends the following
# variables:
#
# PORTS - list names of the available ports, e.g., 'freetype-2.3.9'
# GEN_DIRS - list of automatically generated directories
# GEN_FILES - list of automatically generated files
#
# Furthermore, each '<port>.mk' file extends the 'prepare' rule for
# downloading and unpacking the corresponding upstream sources.
#
PKG ?= *
include $(addprefix ports/,$(addsuffix .mk,$(PKG)))
help::
$(ECHO) ""
$(ECHO) "Download and unpack upstream source codes:"
@for i in $(PORTS); do echo " $$i"; done
$(ECHO) ""
$(ECHO) "Downloads will be placed into the '$(DOWNLOAD_DIR)/' directory."
$(ECHO) "Source codes will be unpacked in the '$(CONTRIB_DIR)/' directory."
$(ECHO) ""
$(ECHO) "--- available commands ---"
$(ECHO) "prepare - download and unpack upstream source codes"
$(ECHO) "clean - remove upstream source codes"
$(ECHO) "cleanall - remove upstream source codes and downloads"
$(ECHO) ""
$(ECHO) "--- available arguments ---"
$(ECHO) "PKG=<package-list> - prepare only the specified packages,"
$(ECHO) " each package specified w/o version number"
#
# Remove download and contrib directories if empty
#
prepare::
$(VERBOSE)$(GNU_FIND) $(DOWNLOAD_DIR) -depth -type d -empty -delete
$(VERBOSE)$(GNU_FIND) $(CONTRIB_DIR) -depth -type d -empty -delete
$(DOWNLOAD_DIR) $(CONTRIB_DIR):
$(VERBOSE)mkdir -p $@
clean::
$(VERBOSE)rm -rf $(CONTRIB_DIR)
cleanall: clean
$(VERBOSE)rm -rf $(DOWNLOAD_DIR)
.NOTPARALLEL:
| Java |
/*
* psgp_settings.h
*
* Created on: 21 Jan 2012
* Author: barillrl
*/
#ifndef PSGP_SETTINGS_H_
#define PSGP_SETTINGS_H_
//-----------------------------------------------------------------------------
// CONSTANTS AND OTHER GENERAL PARAMETERS
//-----------------------------------------------------------------------------
// Max number of parameters for PSGP (this limit is set by the R code)
#define NUM_PSGP_PARAMETERS 16
// Maximum number of observations kept for param estimation
#define MAX_OBS 1000
// Maximum number of active points
#define MAX_ACTIVE_POINTS 400
// Likelihood to nugget ratio
#define LIKELIHOOD_NUGGET_RATIO 0.01
// Number of sweeps through data with changing/fixed active set
#define NUM_SWEEPS_CHANGING 1
#define NUM_SWEEPS_FIXED 1
// Whether to use a GP instead of PSGP for parameter estimation
#define PARAMETER_ESTIMATION_USING_GP false
// Outer loops in parameter estimation for PSGP
#define PSGP_PARAM_ITERATIONS 3
// Inner loop (i.e. SCG iterations in each outer loop) for PSGP
#define PSGP_SCG_ITERATIONS 5
// Define whether to use full prediction (all data at once) or
// split prediction (by chunks of data)
#define USING_CHUNK_PREDICTION true
// Size of prediction chunk (in number of observations)
#define CHUNK_SIZE 1000
#endif /* PSGP_SETTINGS_H_ */
| Java |
<!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>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js" type="text/javascript" charset="utf-8"></script>
<script src="specimen_files/easytabs.js" type="text/javascript" charset="utf-8"></script>
<link rel="stylesheet" href="specimen_files/specimen_stylesheet.css" type="text/css" charset="utf-8" />
<link rel="stylesheet" href="stylesheet.css" type="text/css" charset="utf-8" />
<style type="text/css">
body{
font-family: 'ralewaythin';
}
</style>
<title>Raleway Thin Specimen</title>
<script type="text/javascript" charset="utf-8">
$(document).ready(function() {
$('#container').easyTabs({defaultContent:1});
});
</script>
</head>
<body>
<div id="container">
<div id="header">
Raleway Thin </div>
<ul class="tabs">
<li><a href="#specimen">Specimen</a></li>
<li><a href="#layout">Sample Layout</a></li>
<li><a href="#glyphs">Glyphs & Languages</a></li>
<li><a href="#installing">Installing Webfonts</a></li>
</ul>
<div id="main_content">
<div id="specimen">
<div class="section">
<div class="grid12 firstcol">
<div class="huge">AaBb</div>
</div>
</div>
<div class="section">
<div class="glyph_range">A​B​C​D​E​F​G​H​I​J​K​L​M​N​O​P​Q​R​S​T​U​V​W​X​Y​Z​a​b​c​d​e​f​g​h​i​j​k​l​m​n​o​p​q​r​s​t​u​v​w​x​y​z​1​2​3​4​5​6​7​8​9​0​&​.​,​?​!​@​(​)​#​$​%​*​+​-​=​:​;</div>
</div>
<div class="section">
<div class="grid12 firstcol">
<table class="sample_table">
<tr><td>10</td><td class="size10">abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ</td></tr>
<tr><td>11</td><td class="size11">abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ</td></tr>
<tr><td>12</td><td class="size12">abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ</td></tr>
<tr><td>13</td><td class="size13">abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ</td></tr>
<tr><td>14</td><td class="size14">abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ</td></tr>
<tr><td>16</td><td class="size16">abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ</td></tr>
<tr><td>18</td><td class="size18">abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ</td></tr>
<tr><td>20</td><td class="size20">abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ</td></tr>
<tr><td>24</td><td class="size24">abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ</td></tr>
<tr><td>30</td><td class="size30">abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ</td></tr>
<tr><td>36</td><td class="size36">abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ</td></tr>
<tr><td>48</td><td class="size48">abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ</td></tr>
<tr><td>60</td><td class="size60">abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ</td></tr>
<tr><td>72</td><td class="size72">abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ</td></tr>
<tr><td>90</td><td class="size90">abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ</td></tr>
</table>
</div>
</div>
<div class="section" id="bodycomparison">
<div id="xheight">
<div class="fontbody">◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼body</div><div class="arialbody">body</div><div class="verdanabody">body</div><div class="georgiabody">body</div></div>
<div class="fontbody" style="z-index:1">
body<span>Raleway Thin</span>
</div>
<div class="arialbody" style="z-index:1">
body<span>Arial</span>
</div>
<div class="verdanabody" style="z-index:1">
body<span>Verdana</span>
</div>
<div class="georgiabody" style="z-index:1">
body<span>Georgia</span>
</div>
</div>
<div class="section psample psample_row1" id="">
<div class="grid2 firstcol">
<p class="size10"><span>10.</span>Aenean lacinia bibendum nulla sed consectetur. Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit amet risus. Nullam id dolor id nibh ultricies vehicula ut id elit. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Nulla vitae elit libero, a pharetra augue.</p>
</div>
<div class="grid3">
<p class="size11"><span>11.</span>Aenean lacinia bibendum nulla sed consectetur. Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit amet risus. Nullam id dolor id nibh ultricies vehicula ut id elit. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Nulla vitae elit libero, a pharetra augue.</p>
</div>
<div class="grid3">
<p class="size12"><span>12.</span>Aenean lacinia bibendum nulla sed consectetur. Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit amet risus. Nullam id dolor id nibh ultricies vehicula ut id elit. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Nulla vitae elit libero, a pharetra augue.</p>
</div>
<div class="grid4">
<p class="size13"><span>13.</span>Aenean lacinia bibendum nulla sed consectetur. Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit amet risus. Nullam id dolor id nibh ultricies vehicula ut id elit. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Nulla vitae elit libero, a pharetra augue.</p>
</div>
<div class="white_blend"></div>
</div>
<div class="section psample psample_row2" id="">
<div class="grid3 firstcol">
<p class="size14"><span>14.</span>Aenean lacinia bibendum nulla sed consectetur. Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit amet risus. Nullam id dolor id nibh ultricies vehicula ut id elit. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Nulla vitae elit libero, a pharetra augue.</p>
</div>
<div class="grid4">
<p class="size16"><span>16.</span>Aenean lacinia bibendum nulla sed consectetur. Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit amet risus. Nullam id dolor id nibh ultricies vehicula ut id elit. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Nulla vitae elit libero, a pharetra augue.</p>
</div>
<div class="grid5">
<p class="size18"><span>18.</span>Aenean lacinia bibendum nulla sed consectetur. Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit amet risus. Nullam id dolor id nibh ultricies vehicula ut id elit. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Nulla vitae elit libero, a pharetra augue.</p>
</div>
<div class="white_blend"></div>
</div>
<div class="section psample psample_row3" id="">
<div class="grid5 firstcol">
<p class="size20"><span>20.</span>Aenean lacinia bibendum nulla sed consectetur. Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit amet risus. Nullam id dolor id nibh ultricies vehicula ut id elit. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Nulla vitae elit libero, a pharetra augue.</p>
</div>
<div class="grid7">
<p class="size24"><span>24.</span>Aenean lacinia bibendum nulla sed consectetur. Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit amet risus. Nullam id dolor id nibh ultricies vehicula ut id elit. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Nulla vitae elit libero, a pharetra augue.</p>
</div>
<div class="white_blend"></div>
</div>
<div class="section psample psample_row4" id="">
<div class="grid12 firstcol">
<p class="size30"><span>30.</span>Aenean lacinia bibendum nulla sed consectetur. Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit amet risus. Nullam id dolor id nibh ultricies vehicula ut id elit. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Nulla vitae elit libero, a pharetra augue.</p>
</div>
<div class="white_blend"></div>
</div>
<div class="section psample psample_row1 fullreverse">
<div class="grid2 firstcol">
<p class="size10"><span>10.</span>Aenean lacinia bibendum nulla sed consectetur. Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit amet risus. Nullam id dolor id nibh ultricies vehicula ut id elit. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Nulla vitae elit libero, a pharetra augue.</p>
</div>
<div class="grid3">
<p class="size11"><span>11.</span>Aenean lacinia bibendum nulla sed consectetur. Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit amet risus. Nullam id dolor id nibh ultricies vehicula ut id elit. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Nulla vitae elit libero, a pharetra augue.</p>
</div>
<div class="grid3">
<p class="size12"><span>12.</span>Aenean lacinia bibendum nulla sed consectetur. Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit amet risus. Nullam id dolor id nibh ultricies vehicula ut id elit. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Nulla vitae elit libero, a pharetra augue.</p>
</div>
<div class="grid4">
<p class="size13"><span>13.</span>Aenean lacinia bibendum nulla sed consectetur. Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit amet risus. Nullam id dolor id nibh ultricies vehicula ut id elit. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Nulla vitae elit libero, a pharetra augue.</p>
</div>
<div class="black_blend"></div>
</div>
<div class="section psample psample_row2 fullreverse">
<div class="grid3 firstcol">
<p class="size14"><span>14.</span>Aenean lacinia bibendum nulla sed consectetur. Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit amet risus. Nullam id dolor id nibh ultricies vehicula ut id elit. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Nulla vitae elit libero, a pharetra augue.</p>
</div>
<div class="grid4">
<p class="size16"><span>16.</span>Aenean lacinia bibendum nulla sed consectetur. Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit amet risus. Nullam id dolor id nibh ultricies vehicula ut id elit. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Nulla vitae elit libero, a pharetra augue.</p>
</div>
<div class="grid5">
<p class="size18"><span>18.</span>Aenean lacinia bibendum nulla sed consectetur. Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit amet risus. Nullam id dolor id nibh ultricies vehicula ut id elit. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Nulla vitae elit libero, a pharetra augue.</p>
</div>
<div class="black_blend"></div>
</div>
<div class="section psample fullreverse psample_row3" id="">
<div class="grid5 firstcol">
<p class="size20"><span>20.</span>Aenean lacinia bibendum nulla sed consectetur. Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit amet risus. Nullam id dolor id nibh ultricies vehicula ut id elit. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Nulla vitae elit libero, a pharetra augue.</p>
</div>
<div class="grid7">
<p class="size24"><span>24.</span>Aenean lacinia bibendum nulla sed consectetur. Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit amet risus. Nullam id dolor id nibh ultricies vehicula ut id elit. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Nulla vitae elit libero, a pharetra augue.</p>
</div>
<div class="black_blend"></div>
</div>
<div class="section psample fullreverse psample_row4" id="" style="border-bottom: 20px #000 solid;">
<div class="grid12 firstcol">
<p class="size30"><span>30.</span>Aenean lacinia bibendum nulla sed consectetur. Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit amet risus. Nullam id dolor id nibh ultricies vehicula ut id elit. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Nulla vitae elit libero, a pharetra augue.</p>
</div>
<div class="black_blend"></div>
</div>
</div>
<div id="layout">
<div class="section">
<div class="grid12 firstcol">
<h1>Lorem Ipsum Dolor</h1>
<h2>Etiam porta sem malesuada magna mollis euismod</h2>
<p class="byline">By <a href="#link">Aenean Lacinia</a></p>
</div>
</div>
<div class="section">
<div class="grid8 firstcol">
<p class="large">Donec sed odio dui. Morbi leo risus, porta ac consectetur ac, vestibulum at eros. Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit amet risus. </p>
<h3>Pellentesque ornare sem</h3>
<p>Maecenas sed diam eget risus varius blandit sit amet non magna. Maecenas faucibus mollis interdum. Donec ullamcorper nulla non metus auctor fringilla. Nullam id dolor id nibh ultricies vehicula ut id elit. Nullam id dolor id nibh ultricies vehicula ut id elit. </p>
<p>Aenean eu leo quam. Pellentesque ornare sem lacinia quam venenatis vestibulum. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. </p>
<p>Nulla vitae elit libero, a pharetra augue. Praesent commodo cursus magna, vel scelerisque nisl consectetur et. Aenean lacinia bibendum nulla sed consectetur. </p>
<p>Nullam quis risus eget urna mollis ornare vel eu leo. Nullam quis risus eget urna mollis ornare vel eu leo. Maecenas sed diam eget risus varius blandit sit amet non magna. Donec ullamcorper nulla non metus auctor fringilla. </p>
<h3>Cras mattis consectetur</h3>
<p>Aenean eu leo quam. Pellentesque ornare sem lacinia quam venenatis vestibulum. Aenean lacinia bibendum nulla sed consectetur. Integer posuere erat a ante venenatis dapibus posuere velit aliquet. Cras mattis consectetur purus sit amet fermentum. </p>
<p>Nullam id dolor id nibh ultricies vehicula ut id elit. Nullam quis risus eget urna mollis ornare vel eu leo. Cras mattis consectetur purus sit amet fermentum.</p>
</div>
<div class="grid4 sidebar">
<div class="box reverse">
<p class="last">Nullam quis risus eget urna mollis ornare vel eu leo. Donec ullamcorper nulla non metus auctor fringilla. Cras mattis consectetur purus sit amet fermentum. Sed posuere consectetur est at lobortis. Lorem ipsum dolor sit amet, consectetur adipiscing elit. </p>
</div>
<p class="caption">Maecenas sed diam eget risus varius.</p>
<p>Vestibulum id ligula porta felis euismod semper. Integer posuere erat a ante venenatis dapibus posuere velit aliquet. Vestibulum id ligula porta felis euismod semper. Sed posuere consectetur est at lobortis. Maecenas sed diam eget risus varius blandit sit amet non magna. Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit amet risus. </p>
<p>Duis mollis, est non commodo luctus, nisi erat porttitor ligula, eget lacinia odio sem nec elit. Aenean lacinia bibendum nulla sed consectetur. Vivamus sagittis lacus vel augue laoreet rutrum faucibus dolor auctor. Aenean lacinia bibendum nulla sed consectetur. Nullam quis risus eget urna mollis ornare vel eu leo. </p>
<p>Praesent commodo cursus magna, vel scelerisque nisl consectetur et. Donec ullamcorper nulla non metus auctor fringilla. Maecenas faucibus mollis interdum. Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit amet risus. </p>
</div>
</div>
</div>
<div id="glyphs">
<div class="section">
<div class="grid12 firstcol">
<h1>Language Support</h1>
<p>The subset of Raleway Thin in this kit supports the following languages:<br />
Albanian, Basque, Breton, Chamorro, Danish, Dutch, English, Faroese, Finnish, French, Frisian, Galician, German, Icelandic, Italian, Malagasy, Norwegian, Portuguese, Spanish, Swedish </p>
<h1>Glyph Chart</h1>
<p>The subset of Raleway Thin in this kit includes all the glyphs listed below. Unicode entities are included above each glyph to help you insert individual characters into your layout.</p>
<div id="glyph_chart">
<div><p>&#13;</p> </div>
<div><p>&#32;</p> </div>
<div><p>&#33;</p>!</div>
<div><p>&#34;</p>"</div>
<div><p>&#35;</p>#</div>
<div><p>&#36;</p>$</div>
<div><p>&#37;</p>%</div>
<div><p>&#38;</p>&</div>
<div><p>&#39;</p>'</div>
<div><p>&#40;</p>(</div>
<div><p>&#41;</p>)</div>
<div><p>&#42;</p>*</div>
<div><p>&#43;</p>+</div>
<div><p>&#44;</p>,</div>
<div><p>&#45;</p>-</div>
<div><p>&#46;</p>.</div>
<div><p>&#47;</p>/</div>
<div><p>&#48;</p>0</div>
<div><p>&#49;</p>1</div>
<div><p>&#50;</p>2</div>
<div><p>&#51;</p>3</div>
<div><p>&#52;</p>4</div>
<div><p>&#53;</p>5</div>
<div><p>&#54;</p>6</div>
<div><p>&#55;</p>7</div>
<div><p>&#56;</p>8</div>
<div><p>&#57;</p>9</div>
<div><p>&#58;</p>:</div>
<div><p>&#59;</p>;</div>
<div><p>&#60;</p><</div>
<div><p>&#61;</p>=</div>
<div><p>&#62;</p>></div>
<div><p>&#63;</p>?</div>
<div><p>&#64;</p>@</div>
<div><p>&#65;</p>A</div>
<div><p>&#66;</p>B</div>
<div><p>&#67;</p>C</div>
<div><p>&#68;</p>D</div>
<div><p>&#69;</p>E</div>
<div><p>&#70;</p>F</div>
<div><p>&#71;</p>G</div>
<div><p>&#72;</p>H</div>
<div><p>&#73;</p>I</div>
<div><p>&#74;</p>J</div>
<div><p>&#75;</p>K</div>
<div><p>&#76;</p>L</div>
<div><p>&#77;</p>M</div>
<div><p>&#78;</p>N</div>
<div><p>&#79;</p>O</div>
<div><p>&#80;</p>P</div>
<div><p>&#81;</p>Q</div>
<div><p>&#82;</p>R</div>
<div><p>&#83;</p>S</div>
<div><p>&#84;</p>T</div>
<div><p>&#85;</p>U</div>
<div><p>&#86;</p>V</div>
<div><p>&#87;</p>W</div>
<div><p>&#88;</p>X</div>
<div><p>&#89;</p>Y</div>
<div><p>&#90;</p>Z</div>
<div><p>&#91;</p>[</div>
<div><p>&#92;</p>\</div>
<div><p>&#93;</p>]</div>
<div><p>&#94;</p>^</div>
<div><p>&#95;</p>_</div>
<div><p>&#96;</p>`</div>
<div><p>&#97;</p>a</div>
<div><p>&#98;</p>b</div>
<div><p>&#99;</p>c</div>
<div><p>&#100;</p>d</div>
<div><p>&#101;</p>e</div>
<div><p>&#102;</p>f</div>
<div><p>&#103;</p>g</div>
<div><p>&#104;</p>h</div>
<div><p>&#105;</p>i</div>
<div><p>&#106;</p>j</div>
<div><p>&#107;</p>k</div>
<div><p>&#108;</p>l</div>
<div><p>&#109;</p>m</div>
<div><p>&#110;</p>n</div>
<div><p>&#111;</p>o</div>
<div><p>&#112;</p>p</div>
<div><p>&#113;</p>q</div>
<div><p>&#114;</p>r</div>
<div><p>&#115;</p>s</div>
<div><p>&#116;</p>t</div>
<div><p>&#117;</p>u</div>
<div><p>&#118;</p>v</div>
<div><p>&#119;</p>w</div>
<div><p>&#120;</p>x</div>
<div><p>&#121;</p>y</div>
<div><p>&#122;</p>z</div>
<div><p>&#123;</p>{</div>
<div><p>&#124;</p>|</div>
<div><p>&#125;</p>}</div>
<div><p>&#126;</p>~</div>
<div><p>&#160;</p> </div>
<div><p>&#161;</p>¡</div>
<div><p>&#162;</p>¢</div>
<div><p>&#163;</p>£</div>
<div><p>&#165;</p>¥</div>
<div><p>&#166;</p>¦</div>
<div><p>&#167;</p>§</div>
<div><p>&#168;</p>¨</div>
<div><p>&#169;</p>©</div>
<div><p>&#170;</p>ª</div>
<div><p>&#171;</p>«</div>
<div><p>&#172;</p>¬</div>
<div><p>&#173;</p>­</div>
<div><p>&#174;</p>®</div>
<div><p>&#175;</p>¯</div>
<div><p>&#176;</p>°</div>
<div><p>&#177;</p>±</div>
<div><p>&#178;</p>²</div>
<div><p>&#179;</p>³</div>
<div><p>&#180;</p>´</div>
<div><p>&#181;</p>µ</div>
<div><p>&#182;</p>¶</div>
<div><p>&#183;</p>·</div>
<div><p>&#184;</p>¸</div>
<div><p>&#185;</p>¹</div>
<div><p>&#186;</p>º</div>
<div><p>&#187;</p>»</div>
<div><p>&#188;</p>¼</div>
<div><p>&#189;</p>½</div>
<div><p>&#190;</p>¾</div>
<div><p>&#191;</p>¿</div>
<div><p>&#192;</p>À</div>
<div><p>&#193;</p>Á</div>
<div><p>&#194;</p>Â</div>
<div><p>&#195;</p>Ã</div>
<div><p>&#196;</p>Ä</div>
<div><p>&#197;</p>Å</div>
<div><p>&#198;</p>Æ</div>
<div><p>&#199;</p>Ç</div>
<div><p>&#200;</p>È</div>
<div><p>&#201;</p>É</div>
<div><p>&#202;</p>Ê</div>
<div><p>&#203;</p>Ë</div>
<div><p>&#204;</p>Ì</div>
<div><p>&#205;</p>Í</div>
<div><p>&#206;</p>Î</div>
<div><p>&#207;</p>Ï</div>
<div><p>&#208;</p>Ð</div>
<div><p>&#209;</p>Ñ</div>
<div><p>&#210;</p>Ò</div>
<div><p>&#211;</p>Ó</div>
<div><p>&#212;</p>Ô</div>
<div><p>&#213;</p>Õ</div>
<div><p>&#214;</p>Ö</div>
<div><p>&#215;</p>×</div>
<div><p>&#216;</p>Ø</div>
<div><p>&#217;</p>Ù</div>
<div><p>&#218;</p>Ú</div>
<div><p>&#219;</p>Û</div>
<div><p>&#220;</p>Ü</div>
<div><p>&#221;</p>Ý</div>
<div><p>&#222;</p>Þ</div>
<div><p>&#223;</p>ß</div>
<div><p>&#224;</p>à</div>
<div><p>&#225;</p>á</div>
<div><p>&#226;</p>â</div>
<div><p>&#227;</p>ã</div>
<div><p>&#228;</p>ä</div>
<div><p>&#229;</p>å</div>
<div><p>&#230;</p>æ</div>
<div><p>&#231;</p>ç</div>
<div><p>&#232;</p>è</div>
<div><p>&#233;</p>é</div>
<div><p>&#234;</p>ê</div>
<div><p>&#235;</p>ë</div>
<div><p>&#236;</p>ì</div>
<div><p>&#237;</p>í</div>
<div><p>&#238;</p>î</div>
<div><p>&#239;</p>ï</div>
<div><p>&#240;</p>ð</div>
<div><p>&#241;</p>ñ</div>
<div><p>&#242;</p>ò</div>
<div><p>&#243;</p>ó</div>
<div><p>&#244;</p>ô</div>
<div><p>&#245;</p>õ</div>
<div><p>&#246;</p>ö</div>
<div><p>&#247;</p>÷</div>
<div><p>&#248;</p>ø</div>
<div><p>&#249;</p>ù</div>
<div><p>&#250;</p>ú</div>
<div><p>&#251;</p>û</div>
<div><p>&#252;</p>ü</div>
<div><p>&#253;</p>ý</div>
<div><p>&#254;</p>þ</div>
<div><p>&#255;</p>ÿ</div>
<div><p>&#338;</p>Œ</div>
<div><p>&#339;</p>œ</div>
<div><p>&#376;</p>Ÿ</div>
<div><p>&#710;</p>ˆ</div>
<div><p>&#732;</p>˜</div>
<div><p>&#8192;</p> </div>
<div><p>&#8193;</p> </div>
<div><p>&#8194;</p> </div>
<div><p>&#8195;</p> </div>
<div><p>&#8196;</p> </div>
<div><p>&#8197;</p> </div>
<div><p>&#8198;</p> </div>
<div><p>&#8199;</p> </div>
<div><p>&#8200;</p> </div>
<div><p>&#8201;</p> </div>
<div><p>&#8202;</p> </div>
<div><p>&#8208;</p>‐</div>
<div><p>&#8209;</p>‑</div>
<div><p>&#8210;</p>‒</div>
<div><p>&#8211;</p>–</div>
<div><p>&#8212;</p>—</div>
<div><p>&#8216;</p>‘</div>
<div><p>&#8217;</p>’</div>
<div><p>&#8218;</p>‚</div>
<div><p>&#8220;</p>“</div>
<div><p>&#8221;</p>”</div>
<div><p>&#8222;</p>„</div>
<div><p>&#8226;</p>•</div>
<div><p>&#8230;</p>…</div>
<div><p>&#8239;</p> </div>
<div><p>&#8249;</p>‹</div>
<div><p>&#8250;</p>›</div>
<div><p>&#8287;</p> </div>
<div><p>&#8364;</p>€</div>
<div><p>&#8482;</p>™</div>
<div><p>&#9724;</p>◼</div>
<div><p>&#64257;</p>fi</div>
<div><p>&#64258;</p>fl</div>
<div><p>&#64259;</p>ffi</div>
<div><p>&#64260;</p>ffl</div>
</div>
</div>
</div>
</div>
<div id="specs">
</div>
<div id="installing">
<div class="section">
<div class="grid7 firstcol">
<h1>Installing Webfonts</h1>
<p>Webfonts are supported by all major browser platforms but not all in the same way. There are currently four different font formats that must be included in order to target all browsers. This includes TTF, WOFF, EOT and SVG.</p>
<h2>1. Upload your webfonts</h2>
<p>You must upload your webfont kit to your website. They should be in or near the same directory as your CSS files.</p>
<h2>2. Include the webfont stylesheet</h2>
<p>A special CSS @font-face declaration helps the various browsers select the appropriate font it needs without causing you a bunch of headaches. Learn more about this syntax by reading the <a href="http://www.fontspring.com/blog/further-hardening-of-the-bulletproof-syntax">Fontspring blog post</a> about it. The code for it is as follows:</p>
<code>
@font-face{
font-family: 'MyWebFont';
src: url('WebFont.eot');
src: url('WebFont.eot?#iefix') format('embedded-opentype'),
url('WebFont.woff') format('woff'),
url('WebFont.ttf') format('truetype'),
url('WebFont.svg#webfont') format('svg');
}
</code>
<p>We've already gone ahead and generated the code for you. All you have to do is link to the stylesheet in your HTML, like this:</p>
<code><link rel="stylesheet" href="stylesheet.css" type="text/css" charset="utf-8" /></code>
<h2>3. Modify your own stylesheet</h2>
<p>To take advantage of your new fonts, you must tell your stylesheet to use them. Look at the original @font-face declaration above and find the property called "font-family." The name linked there will be what you use to reference the font. Prepend that webfont name to the font stack in the "font-family" property, inside the selector you want to change. For example:</p>
<code>p { font-family: 'WebFont', Arial, sans-serif; }</code>
<h2>4. Test</h2>
<p>Getting webfonts to work cross-browser <em>can</em> be tricky. Use the information in the sidebar to help you if you find that fonts aren't loading in a particular browser.</p>
</div>
<div class="grid5 sidebar">
<div class="box">
<h2>Troubleshooting<br />Font-Face Problems</h2>
<p>Having trouble getting your webfonts to load in your new website? Here are some tips to sort out what might be the problem.</p>
<h3>Fonts not showing in any browser</h3>
<p>This sounds like you need to work on the plumbing. You either did not upload the fonts to the correct directory, or you did not link the fonts properly in the CSS. If you've confirmed that all this is correct and you still have a problem, take a look at your .htaccess file and see if requests are getting intercepted.</p>
<h3>Fonts not loading in iPhone or iPad</h3>
<p>The most common problem here is that you are serving the fonts from an IIS server. IIS refuses to serve files that have unknown MIME types. If that is the case, you must set the MIME type for SVG to "image/svg+xml" in the server settings. Follow these instructions from Microsoft if you need help.</p>
<h3>Fonts not loading in Firefox</h3>
<p>The primary reason for this failure? You are still using a version Firefox older than 3.5. So upgrade already! If that isn't it, then you are very likely serving fonts from a different domain. Firefox requires that all font assets be served from the same domain. Lastly it is possible that you need to add WOFF to your list of MIME types (if you are serving via IIS.)</p>
<h3>Fonts not loading in IE</h3>
<p>Are you looking at Internet Explorer on an actual Windows machine or are you cheating by using a service like Adobe BrowserLab? Many of these screenshot services do not render @font-face for IE. Best to test it on a real machine.</p>
<h3>Fonts not loading in IE9</h3>
<p>IE9, like Firefox, requires that fonts be served from the same domain as the website. Make sure that is the case.</p>
</div>
</div>
</div>
</div>
</div>
<div id="footer">
<p>©2010-2011 Font Squirrel. All rights reserved.</p>
</div>
</div>
</body>
</html>
| Java |
<?php
/**
* Created by PhpStorm.
* User: Sheila
* Date: 12/12/2014
* Time: 6:51 AM
*/
| Java |
.club_logo {
text-align: center;
}
.club_name {
text-align: center;
}
.club_teams {
text-align: center;
}
.club_address {
text-align: center;
} | Java |
#!/usr/bin/env python
import math
fin = open('figs/single-rod-in-water.dat', 'r')
fout = open('figs/single-rods-calculated-density.dat', 'w')
kB = 3.16681539628059e-6 # This is Boltzmann's constant in Hartree/Kelvin
first = 1
nm = 18.8972613
for line in fin:
current = str(line)
pieces = current.split('\t')
if first:
r2 = float(pieces[0])/2*nm
E2 = float(pieces[1])
first = 0
else:
if ((float(pieces[0])/2*nm - r2) > 0.25):
r1 = r2
r2 = float(pieces[0])/2*nm
E1 = E2
E2 = float(pieces[1]) # actually it's energy per unit length!
length = 1 # arbitrary
r = (r1 + r2)/2
dEdR = (E2-E1)/(r2-r1)*length
area = 2*math.pi*r*length
force = dEdR
pressure = force/area
kT = kB*298 # about this
ncontact = pressure/kT
fout.write(str(r)+'\t'+str(ncontact)+'\n')
fin.close()
fout.close()
| Java |
/*
This is a File System Recognizer for IRIG 106 Ch10 Filesystem
Copyright (C) 2014 Arthur Walton.
Heavily derived from the File System Recognizer for RomFs
Copyright (C) 2001 Bo Brantén.
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 _ROM_FS_
#define _ROM_FS_
#define SECTOR_SIZE 512
#define CH10_MAGIC "FORTYtwo"
#define CH10_MAGIC_OFFSET 512
//
// Types used by Linux
//
#include "ltypes.h"
//
// Use 1 byte packing of on-disk structures
//
#include <pshpack1.h>
//
// The following is a subset of linux/include/linux/ch10fs_fs.h from
// version 2.2.14
//
/* The basic structures of the ch10fs filesystem */
#define CH10_BLOCK_SIZE 512
#define CH10_MAXFN 48
#define MAX_FILES_PER_DIR 4
#define CH10_MAX_DIR_BLOCKS 64
/*
* Ch10 Directory Entry
*/
struct ch10_dir_entry {
__u8 name[56]; // name of the directory entry
__u64 blockNum; // block number that the entry starts at
__u64 numBlocks; // length of the entry in blocks
__u64 size; // length of the entry in bytes
__u8 createDate[8]; // date entry was created
__u8 createTime[8]; // time entry was created
__u8 timeType; // time system the previous date and time were stored in
__u8 reserved[7]; // currently unused, reserved for future use
__u8 closeTime[8]; // time this entry was finished being written
};
/*
* Ch10 Directory Block
*/
struct ch10_dir_block {
__u8 magicNumAscii[8]; // Identifies this as being a directory block, always set to FORTYtwo
__u8 revNum; // revision number of the data recording standard in use
__u8 shutdown; // flag to indicate filesystem was not properly shutdown while writing to this directory
__u16 numEntries; // number of directory entries/files that are in this block
__u32 bytesPerBlock; // number of bytes per block
__u8 volName[32]; // name of this directory block
__u64 forwardLink:64; // block address of next directory block
__u64 reverseLink:64; // block address of previous directory block
struct ch10_dir_entry dirEntries[MAX_FILES_PER_DIR]; // all entries/files in the block
};
#include <poppack.h>
#endif
| Java |
dojo.require("dijit.Dialog");
dojo.require("dijit.form.FilteringSelect");
dojo.require('dijit.form.Button');
dojo.require('dijit.TooltipDialog');
dojo.require('dijit.form.DropDownButton');
dojo.require('dijit.form.CheckBox');
dojo.require('dojox.grid.DataGrid');
dojo.require('dojo.data.ItemFileWriteStore');
dojo.require('openils.widget.OrgUnitFilteringSelect');
dojo.require('openils.acq.CurrencyType');
dojo.require('openils.Event');
dojo.require('openils.Util');
dojo.require('openils.User');
dojo.require('openils.CGI');
dojo.require('openils.PermaCrud');
dojo.require('openils.widget.AutoGrid');
dojo.require('openils.widget.ProgressDialog');
dojo.require('fieldmapper.OrgUtils');
dojo.requireLocalization('openils.acq', 'acq');
var localeStrings = dojo.i18n.getLocalization('openils.acq', 'acq');
var contextOrg;
var rolloverResponses;
var rolloverMode = false;
var fundFleshFields = [
'spent_balance',
'combined_balance',
'spent_total',
'encumbrance_total',
'debit_total',
'allocation_total'
];
var adminPermOrgs = [];
var cachedFunds = [];
function initPage() {
contextOrg = openils.User.user.ws_ou();
/* Reveal controls for rollover without money if org units say ok.
* Actual ability to do the operation is controlled in the database, of
* course. */
var ouSettings = fieldmapper.aou.fetchOrgSettingBatch(
openils.User.user.ws_ou(), ["acq.fund.allow_rollover_without_money"]
);
if (
ouSettings["acq.fund.allow_rollover_without_money"] &&
ouSettings["acq.fund.allow_rollover_without_money"].value
) {
dojo.query(".encumb_only").forEach(
function(o) { openils.Util.show(o, "table-row"); }
);
}
var connect = function() {
dojo.connect(contextOrgSelector, 'onChange',
function() {
contextOrg = this.attr('value');
dojo.byId('oils-acq-rollover-ctxt-org').innerHTML =
fieldmapper.aou.findOrgUnit(contextOrg).shortname();
rolloverMode = false;
gridDataLoader();
}
);
};
dojo.connect(refreshButton, 'onClick',
function() { rolloverMode = false; gridDataLoader(); });
new openils.User().buildPermOrgSelector(
['ADMIN_ACQ_FUND', 'VIEW_FUND'],
contextOrgSelector, contextOrg, connect);
dojo.byId('oils-acq-rollover-ctxt-org').innerHTML =
fieldmapper.aou.findOrgUnit(contextOrg).shortname();
loadYearSelector();
lfGrid.onItemReceived = function(item) {cachedFunds.push(item)};
new openils.User().getPermOrgList(
'ADMIN_ACQ_FUND',
function(list) {
adminPermOrgs = list;
loadFundGrid(
new openils.CGI().param('year')
|| new Date().getFullYear().toString());
},
true, true
);
}
function gridDataLoader() {
lfGrid.resetStore();
if(rolloverMode) {
var offset = lfGrid.displayOffset;
for(var i = offset; i < (offset + lfGrid.displayLimit - 1); i++) {
var fund = rolloverResponses[i];
if(!fund) break;
lfGrid.store.newItem(fieldmapper.acqf.toStoreItem(fund));
}
} else {
loadFundGrid();
}
}
function getBalanceInfo(rowIdx, item) {
if (!item) return '';
var fundId = this.grid.store.getValue(item, 'id');
var fund = cachedFunds.filter(function(f) { return f.id() == fundId })[0];
var cb = fund.combined_balance();
return cb ? cb.amount() : '0';
}
function loadFundGrid(year) {
openils.Util.hide('acq-fund-list-rollover-summary');
year = year || fundFilterYearSelect.attr('value');
cachedFunds = [];
lfGrid.loadAll(
{
flesh : 1,
flesh_fields : {acqf : fundFleshFields},
// by default, sort funds I can edit to the front
order_by : [
{ 'class' : 'acqf',
field : 'org',
compare : {'in' : adminPermOrgs},
direction : 'desc'
},
{ 'class' : 'acqf',
field : 'name'
}
]
}, {
year : year,
org : fieldmapper.aou.descendantNodeList(contextOrg, true)
}
);
}
function loadYearSelector() {
fieldmapper.standardRequest(
['open-ils.acq', 'open-ils.acq.fund.org.years.retrieve'],
{ async : true,
params : [openils.User.authtoken, {}, {limit_perm : 'VIEW_FUND'}],
oncomplete : function(r) {
var yearList = openils.Util.readResponse(r);
if(!yearList) return;
yearList = yearList.map(function(year){return {year:year+''};}); // dojo wants strings
var yearStore = {identifier:'year', name:'year', items:yearList};
yearStore.items = yearStore.items.sort().reverse();
fundFilterYearSelect.store = new dojo.data.ItemFileWriteStore({data:yearStore});
// default to this year
fundFilterYearSelect.setValue(new Date().getFullYear().toString());
dojo.connect(
fundFilterYearSelect,
'onChange',
function() {
rolloverMode = false;
gridDataLoader();
}
);
}
}
);
}
function performRollover(args) {
rolloverMode = true;
progressDialog.show(true, "Processing...");
rolloverResponses = [];
var method = 'open-ils.acq.fiscal_rollover';
if(args.rollover[0] == 'on') {
method += '.combined';
} else {
method += '.propagate';
}
var dryRun = args.dry_run[0] == 'on';
if(dryRun) method += '.dry_run';
var encumbOnly = args.encumb_only[0] == 'on';
var count = 0;
var amount_rolled = 0;
var year = fundFilterYearSelect.attr('value'); // TODO alternate selector?
fieldmapper.standardRequest(
['open-ils.acq', method],
{
async : true,
params : [
openils.User.authtoken,
year,
contextOrg,
(args.child_orgs[0] == 'on'),
{ encumb_only : encumbOnly }
],
onresponse : function(r) {
var resp = openils.Util.readResponse(r);
rolloverResponses.push(resp.fund);
count += 1;
amount_rolled += Number(resp.rollover_amount);
},
oncomplete : function() {
var nextYear = Number(year) + 1;
rolloverResponses = rolloverResponses.sort(
function(a, b) {
if(a.code() > b.code())
return 1;
return -1;
}
)
// add the new, rolled funds to the cache. Note that in dry-run
// mode, these are ephemeral and no longer exist on the server.
cachedFunds = cachedFunds.concat(rolloverResponses);
dojo.byId('acq-fund-list-rollover-summary-header').innerHTML =
dojo.string.substitute(
localeStrings.FUND_LIST_ROLLOVER_SUMMARY,
[nextYear]
);
dojo.byId('acq-fund-list-rollover-summary-funds').innerHTML =
dojo.string.substitute(
localeStrings.FUND_LIST_ROLLOVER_SUMMARY_FUNDS,
[nextYear, count]
);
dojo.byId('acq-fund-list-rollover-summary-rollover-amount').innerHTML =
dojo.string.substitute(
localeStrings.FUND_LIST_ROLLOVER_SUMMARY_ROLLOVER_AMOUNT,
[nextYear, amount_rolled]
);
if(!dryRun) {
openils.Util.hide('acq-fund-list-rollover-summary-dry-run');
// add the new year to the year selector if it's not already there
fundFilterYearSelect.store.fetch({
query : {year : nextYear},
onComplete:
function(list) {
if(list && list.length > 0) return;
fundFilterYearSelect.store.newItem({year : nextYear});
}
});
}
openils.Util.show('acq-fund-list-rollover-summary');
progressDialog.hide();
gridDataLoader();
}
}
);
}
openils.Util.addOnLoad(initPage);
| Java |
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("Sims")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Sims")]
[assembly: AssemblyCopyright("Copyright © 2015")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("69611fa1-6403-4862-abd4-bd4e91c43d06")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
| Java |
<!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.core.ext.soyc.HasDependencies (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.core.ext.soyc.HasDependencies (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> </TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../package-summary.html"><FONT CLASS="NavBarFont1"><B>Package</B></FONT></A> </TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../../../../com/google/gwt/core/ext/soyc/HasDependencies.html" title="interface in com.google.gwt.core.ext.soyc"><FONT CLASS="NavBarFont1"><B>Class</B></FONT></A> </TD>
<TD BGCOLOR="#FFFFFF" CLASS="NavBarCell1Rev"> <FONT CLASS="NavBarFont1Rev"><B>Use</B></FONT> </TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../package-tree.html"><FONT CLASS="NavBarFont1"><B>Tree</B></FONT></A> </TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../../../../deprecated-list.html"><FONT CLASS="NavBarFont1"><B>Deprecated</B></FONT></A> </TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../../../../index-all.html"><FONT CLASS="NavBarFont1"><B>Index</B></FONT></A> </TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../../../../help-doc.html"><FONT CLASS="NavBarFont1"><B>Help</B></FONT></A> </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">
PREV
NEXT</FONT></TD>
<TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">
<A HREF="../../../../../../../index.html?com/google/gwt/core/ext/soyc//class-useHasDependencies.html" target="_top"><B>FRAMES</B></A>
<A HREF="HasDependencies.html" target="_top"><B>NO FRAMES</B></A>
<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.core.ext.soyc.HasDependencies</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/core/ext/soyc/HasDependencies.html" title="interface in com.google.gwt.core.ext.soyc">HasDependencies</A></FONT></TH>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD><A HREF="#com.google.gwt.core.ext.soyc"><B>com.google.gwt.core.ext.soyc</B></A></TD>
<TD>This package contains interfaces that provide access to
"Story of Your Compile" information. </TD>
</TR>
</TABLE>
<P>
<A NAME="com.google.gwt.core.ext.soyc"><!-- --></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/core/ext/soyc/HasDependencies.html" title="interface in com.google.gwt.core.ext.soyc">HasDependencies</A> in <A HREF="../../../../../../../com/google/gwt/core/ext/soyc/package-summary.html">com.google.gwt.core.ext.soyc</A></FONT></TH>
</TR>
</TABLE>
<P>
<TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY="">
<TR BGCOLOR="#CCCCFF" CLASS="TableSubHeadingColor">
<TH ALIGN="left" COLSPAN="2">Subinterfaces of <A HREF="../../../../../../../com/google/gwt/core/ext/soyc/HasDependencies.html" title="interface in com.google.gwt.core.ext.soyc">HasDependencies</A> in <A HREF="../../../../../../../com/google/gwt/core/ext/soyc/package-summary.html">com.google.gwt.core.ext.soyc</A></FONT></TH>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE> interface</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../../../../com/google/gwt/core/ext/soyc/ClassMember.html" title="interface in com.google.gwt.core.ext.soyc">ClassMember</A></B></CODE>
<BR>
Represents a reference type, such as a class or interface, in the compiled
output.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE> interface</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../../../../com/google/gwt/core/ext/soyc/MethodMember.html" title="interface in com.google.gwt.core.ext.soyc">MethodMember</A></B></CODE>
<BR>
Represents compiled JS code derived from a Java method.</TD>
</TR>
</TABLE>
<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> </TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../package-summary.html"><FONT CLASS="NavBarFont1"><B>Package</B></FONT></A> </TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../../../../com/google/gwt/core/ext/soyc/HasDependencies.html" title="interface in com.google.gwt.core.ext.soyc"><FONT CLASS="NavBarFont1"><B>Class</B></FONT></A> </TD>
<TD BGCOLOR="#FFFFFF" CLASS="NavBarCell1Rev"> <FONT CLASS="NavBarFont1Rev"><B>Use</B></FONT> </TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../package-tree.html"><FONT CLASS="NavBarFont1"><B>Tree</B></FONT></A> </TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../../../../deprecated-list.html"><FONT CLASS="NavBarFont1"><B>Deprecated</B></FONT></A> </TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../../../../index-all.html"><FONT CLASS="NavBarFont1"><B>Index</B></FONT></A> </TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../../../../help-doc.html"><FONT CLASS="NavBarFont1"><B>Help</B></FONT></A> </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">
PREV
NEXT</FONT></TD>
<TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">
<A HREF="../../../../../../../index.html?com/google/gwt/core/ext/soyc//class-useHasDependencies.html" target="_top"><B>FRAMES</B></A>
<A HREF="HasDependencies.html" target="_top"><B>NO FRAMES</B></A>
<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>
| Java |
<!DOCTYPE html>
<!-- Website template by freewebsitetemplates.com -->
<html>
<head>
<meta charset="UTF-8">
<title>Blog - Astronomy Website Template</title>
<link rel="stylesheet" href="css/style.css" type="text/css">
</head>
<body>
<div id="header">
<div class="wrapper clearfix">
<div id="logo">
<a href="index.html"><img src="images/logo.png" alt="LOGO"></a>
</div>
<ul id="navigation">
<li>
<a href="index.html">Home</a>
</li>
<li>
<a href="about.html">About</a>
</li>
<li class="selected">
<a href="blog.html">Blog</a>
</li>
<li>
<a href="gallery.html">Gallery</a>
</li>
<li>
<a href="contact.html">Contact Us</a>
</li>
</ul>
</div>
</div>
<div id="contents">
<div class="wrapper clearfix">
<div id="sidebar">
<ul>
<li>
<a href="blog.html"><img src="images/earth-small.jpg" alt="Img" height="154" width="213"></a>
</li>
<li>
<a href="blog.html"><img src="images/spaceshuttle-closeup.jpg" alt="Img" height="154" width="213"></a>
</li>
</ul>
<div class="click-here">
<h1>Lorem Ipsum Dolor!</h1>
<a href="index.html" class="btn1">Click Here!</a>
</div>
</div>
<div class="main">
<h1>Blog</h1>
<ul class="list">
<li>
<span class="time">01-01-2012</span>
<h4>Blog Title One</h4>
<p>
This website template has been designed by <a href="http://www.freewebsitetemplates.com/">Free Website Templates</a> for you, for free. You can replace all this text with your
own text.This website template has been designed by <a href="http://www.freewebsitetemplates.com/">Free Website Templates</a> for you, for free. You can replace all this text with
your own text.
</p>
<a href="blog.html" class="more">Read more>></a>
</li>
<li>
<span class="time">01-01-2012</span>
<h4>Blog Title One</h4>
<p>
This website template has been designed by <a href="http://www.freewebsitetemplates.com/">Free Website Templates</a> for you, for free. You can replace all this text with your
own text.This website template has been designed by <a href="http://www.freewebsitetemplates.com/">Free Website Templates</a> for you, for free. You can replace all this text with
your own text.
</p>
<a href="blog.html" class="more">Read more>></a>
</li>
<li>
<span class="time">01-01-2012</span>
<h4>Blog Title One</h4>
<p>
This website template has been designed by <a href="http://www.freewebsitetemplates.com/">Free Website Templates</a> for you, for free. You can replace all this text with your
own text.This website template has been designed by <a href="http://www.freewebsitetemplates.com/">Free Website Templates</a> for you, for free. You can replace all this text with
your own text.
</p>
<a href="blog.html" class="more">Read more>></a>
</li>
</ul>
<ul class="pagination">
<li>
<a href="blog.html"><<</a>
</li>
<li>
<a href="blog.html">First</a>
</li>
<li class="selected">
<a href="blog.html">1</a>
</li>
<li>
<a href="blog.html">2</a>
</li>
<li>
<a href="blog.html">3</a>
</li>
<li>
<a href="blog.html">4</a>
</li>
<li>
<a href="blog.html">5</a>
</li>
<li>
<a href="blog.html">6</a>
</li>
<li>
<a href="blog.html">7</a>
</li>
<li>
<a href="blog.html">8</a>
</li>
<li>
<a href="blog.html">9</a>
</li>
<li>
<a href="blog.html">10</a>
</li>
<li>
<a href="blog.html">11</a>
</li>
<li>
<a href="blog.html">12</a>
</li>
<li>
<a href="blog.html">13</a>
</li>
<li>
<a href="blog.html">14</a>
</li>
<li>
<a href="blog.html">15</a>
</li>
<li>
<a href="blog.html">16</a>
</li>
<li>
<a href="blog.html">17</a>
</li>
<li>
<a href="blog.html">18</a>
</li>
<li>
<a href="blog.html">19</a>
</li>
<li>
<a href="blog.html">20</a>
</li>
<li>
<a href="blog.html">Last</a>
</li>
<li>
<a href="blog.html">>></a>
</li>
</ul>
<!-- /.pagination -->
</div>
</div>
</div>
<div id="footer">
<ul id="featured" class="wrapper clearfix">
<li>
<img src="images/astronaut.jpg" alt="Img" height="204" width="220">
<h3><a href="blog.html">Category 1</a></h3>
<p>
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Quisque nec mi tortor. Phasellus commodo semper vehicula.
</p>
</li>
<li>
<img src="images/earth.jpg" alt="Img" height="204" width="220">
<h3><a href="blog.html">Category 2</a></h3>
<p>
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Quisque nec mi tortor. Phasellus commodo semper vehicula.
</p>
</li>
<li>
<img src="images/spacecraft-small.jpg" alt="Img" height="204" width="220">
<h3><a href="blog.html">Category 3</a></h3>
<p>
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Quisque nec mi tortor. Phasellus commodo semper vehicula.
</p>
</li>
<li>
<img src="images/space-shuttle.jpg" alt="Img" height="204" width="220">
<h3><a href="blog.html">Category 4</a></h3>
<p>
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Quisque nec mi tortor. Phasellus commodo semper vehicula.
</p>
</li>
</ul>
<div class="body">
<div class="wrapper clearfix">
<div id="links">
<div>
<h4>Social</h4>
<ul>
<li>
<a href="http://freewebsitetemplates.com/go/googleplus/" target="_blank">Google +</a>
</li>
<li>
<a href="http://freewebsitetemplates.com/go/facebook/" target="_blank">Facebook</a>
</li>
<li>
<a href="http://freewebsitetemplates.com/go/youtube/" target="_blank">Youtube</a>
</li>
</ul>
</div>
<div>
<h4>Heading placeholder</h4>
<ul>
<li>
<a href="index.html">Link Title 1</a>
</li>
<li>
<a href="index.html">Link Title 2</a>
</li>
<li>
<a href="index.html">Link Title 3</a>
</li>
</ul>
</div>
</div>
<div id="newsletter">
<h4>Newsletter</h4>
<p>
Sign up for Our Newsletter
</p>
<form action="index.html" method="post">
<input type="text" value="">
<input type="submit" value="Sign Up!">
</form>
</div>
<p class="footnote">
© Copyright © 2023.Company name all rights reserved
</p>
</div>
</div>
</div>
</body>
</html> | Java |
package lionse.client.stage;
import java.util.ArrayList;
import java.util.List;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.badlogic.gdx.graphics.g2d.TextureRegion;
import com.badlogic.gdx.scenes.scene2d.ui.Label;
import com.badlogic.gdx.scenes.scene2d.ui.Label.LabelStyle;
import lionse.client.Display;
import lionse.client.asset.Asset;
import lionse.client.net.Header;
import lionse.client.net.Server;
public class Character implements Renderable {
// character format constant values
public static final float RESOLUTION = 1.5f;
public static final float C_HEAD = 0 * RESOLUTION;
public static final float C_FACE = 10 * RESOLUTION;
public static final float C_BODY = 24 * RESOLUTION;
public static final float C_HAND = 29 * RESOLUTION;
public static final float C_LEG = 30 * RESOLUTION;
public static LabelStyle NAME_TAG_STYLE;
public static float[] SINE_WAVE = { 0, 0.27f, 0.52f, 0.74f, 0.89f, 0.98f, 0.99f, 0.93f, 0.79f, 0.59f, 0.35f, 0.08f, -0.19f, -0.45f, -0.67f, -0.85f, -0.96f,
-0.99f, -0.95f, -0.84f, -0.66f, -0.43f, -0.17f };
static {
NAME_TAG_STYLE = new LabelStyle();
NAME_TAG_STYLE.font = Asset.Font.get(Asset.NanumGothic);
NAME_TAG_STYLE.fontColor = Color.BLACK;
}
public boolean me = false;
// character property
public String name;
public int head;
public int face;
public int body;
public int clothes;
public int weapon;
public float speed = 200f;
// positioning property
public Point position;
public Point target;
public Point bottom;
// character graphics
public Label nameTag;
// ��dz�� ���
public TalkBalloon talkBalloon;
// ��ũ ���߱� ���
public List<Path> path;
public int pathIndex = 0;
public int direction = 0;
public boolean moving = false;
private int step = 0;
// graphics variables
private float stepTime = 0;
private int next = -1;
// graphics cache
private TextureRegion[] texture_head;
private TextureRegion[] texture_face;
private TextureRegion[] texture_body;
private TextureRegion[] texture_hand;
private TextureRegion[] texture_leg_stop;
private TextureRegion[] texture_leg_step1;
private TextureRegion[] texture_leg_step2;
private TextureRegion[] texture_leg_step3;
private TextureRegion[] texture_leg_step4;
// animated character format (sine-wave)
private float p_head;
private float p_face;
private float p_body;
private float p_hand;
// name, head, face, body, clothes, weapon
public Character(String name, int head, int face, int body, int weapon) {
this.name = name;
this.head = head;
this.face = face;
this.body = body;
this.weapon = weapon;
this.position = new Point();
this.bottom = new Point();
this.talkBalloon = new TalkBalloon(this);
this.nameTag = new Label(name, NAME_TAG_STYLE);
this.path = new ArrayList<Path>();
cache();
}
// cache values. if this method is not called when texture value is
// changed.noting happens to the graphic
public void cache() {
texture_head = Asset.Character.get("HEAD");
texture_face = Asset.Character.get("FACE");
texture_body = Asset.Character.get("BODY");
texture_hand = Asset.Character.get("HAND");
texture_leg_stop = Asset.Character.get("LEG_STAND");
texture_leg_step1 = Asset.Character.get("LEG_STEP1");
texture_leg_step2 = Asset.Character.get("LEG_STEP2");
texture_leg_step3 = Asset.Character.get("LEG_STEP3");
texture_leg_step4 = Asset.Character.get("LEG_STEP4");
}
public void talk(String message) {
talkBalloon.show(message);
}
@Override
public void draw(SpriteBatch spriteBatch, float delta) {
// Debugger.log(texture_head.length);
// draw leg
if (moving) {
switch (step) {
case 0:
spriteBatch.draw(texture_leg_step1[direction], position.x, Display.HEIGHT - (position.y + C_LEG));
break;
case 1:
spriteBatch.draw(texture_leg_step2[direction], position.x, Display.HEIGHT - (position.y + C_LEG));
break;
case 2:
spriteBatch.draw(texture_leg_stop[direction], position.x, Display.HEIGHT - (position.y + C_LEG));
break;
case 3:
spriteBatch.draw(texture_leg_step3[direction], position.x, Display.HEIGHT - (position.y + C_LEG));
break;
case 4:
spriteBatch.draw(texture_leg_step4[direction], position.x, Display.HEIGHT - (position.y + C_LEG));
break;
case 5:
spriteBatch.draw(texture_leg_step3[direction], position.x, Display.HEIGHT - (position.y + C_LEG));
break;
}
} else {
spriteBatch.draw(texture_leg_stop[direction], position.x, Display.HEIGHT - (position.y + C_LEG));
}
// draw body
spriteBatch.draw(texture_body[direction], position.x, Display.HEIGHT - (position.y + p_body));
// draw hands
spriteBatch.draw(texture_hand[direction], position.x, Display.HEIGHT - (position.y + p_hand));
// draw face
spriteBatch.draw(texture_face[direction], position.x, Display.HEIGHT - (position.y + p_face));
// draw head
spriteBatch.draw(texture_head[direction], position.x, Display.HEIGHT - (position.y + p_head));
// draw name tag
nameTag.draw(spriteBatch, 1);
// draw talk balloon
if (talkBalloon.talking)
talkBalloon.draw(spriteBatch, delta);
}
@Override
public void update(float delta) {
// update time values.
stepTime += delta;
next += 1;
if (next >= SINE_WAVE.length)
next = 0;
// increase step if moving.
if (stepTime > 0.05f && moving) {
step += 1;
stepTime = 0;
if (step > 5)
step = 0;
}
// �̵����̶�� ��ǥ�� ������Ʈ�Ѵ�.
// if (moving) {
// updatePosition(delta);
// �̵� ���� �� ��ũ ������ ���Ѵ�.
if (me && moving) {
updatePosition(delta);
} else if (this.path.size() > 0 && !me && this.path.size() > pathIndex) {
Path path = this.path.get(pathIndex);
if (path.disabled) {
pathIndex++;
} else {
this.direction = path.direction;
if (path.target == null) {
updatePosition(delta);
} else {
// moveTo(path, delta);
updatePosition(delta);
}
// ���� ��ǥ�� Ÿ�� ��ǥ�� �˻��ؼ� ���� �ȿ� ������ �Ϸ�
if (path.check(position)) {
// �Ϸ� ��, ���ÿ��� �����Ͱ� 0�̸� ������ �ʱ�ȭ�Ѵ� (�� ���)
if (this.path.size() - 1 <= pathIndex) {
this.path.clear();
pathIndex = 0;
} else {
pathIndex++;
}
// ���̰� �ʹ� ũ�� �� ��� �ϵ弼���Ѵ�.
} else if (path.previousDistance > 2000 && path.target != null) {
// ������ ���� ����
position.x = path.target.x;
position.y = path.target.y;
}
}
}
nameTag.setPosition(position.x - (nameTag.getWidth() / 2) + 27, Display.HEIGHT - position.y + 27);
if (talkBalloon.talking)
talkBalloon.update(delta);
// ���� ������ ���� ������ ���� �Ųٱ� ���� ��δ� �������� �̺�Ʈ�� ���� �� �̸� ����� ���´�.
// ���� �Ųٴ� ���� move �̺�Ʈ�� ���Դٸ� ���ÿ� �״´�.
// ��� ������ �����̹Ƿ�, ��ǥ üũ�� �����ϴ�! ^^
// animation effect. (sine wave)
p_head = C_HEAD + SINE_WAVE[next] * 2f;
p_face = C_FACE + SINE_WAVE[next] * 2f;
p_body = C_BODY + SINE_WAVE[next] * 2;
p_hand = C_HAND + SINE_WAVE[next] * 2;
}
private void updatePosition(float delta) {
switch (direction) {
case 0:
position.x -= speed * delta;
position.y += speed * delta / 2;
break;
case 1:
position.x -= speed * delta;
break;
case 2:
position.x -= speed * delta;
position.y -= speed * delta / 2;
break;
case 3:
position.y -= speed * delta / 2;
break;
case 4:
position.x += speed * delta;
position.y -= speed * delta / 2;
break;
case 5:
position.x += speed * delta;
break;
case 6:
position.x += speed * delta;
position.y += speed * delta / 2;
break;
case 7:
position.y += speed * delta / 2;
break;
}
}
@Override
public Point getPosition() {
bottom.x = position.x;
bottom.y = position.y + 150;
bottom.z = position.z;
return bottom;
}
public void move(int targetDirection) {
this.direction = targetDirection;
Server.send(Header.MOVE + Server.H_L + direction + Server.H_L + Math.round(speed) + Server.H_L + Math.round(position.x) + Server.H_L
+ Math.round(position.y) + Server.H_L + Math.round(position.z));
}
public void stop() {
Server.send(Header.STOP + Server.H_L + Math.round(position.x) + Server.H_L + Math.round(position.y) + Server.H_L + Math.round(position.z));
}
public int getDirection(Point point) {
int xdet = 0; // -1-����, 0-���� ����, 1-������
int ydet = 0; // -1-�Ʒ���, 0-���� ����, 1-����
if (point.x - position.x > 0) { // �����ʿ� �ִ�.
xdet = 1;
} else if (point.x == position.x) { // ����.
} else {// ���ʿ� �ִ�.
xdet = -1;
}
if (point.y - position.y > 0) { // ���ʿ� �ִ�.
ydet = -1;
} else if (point.y == position.y) { // ����.
} else {// �Ʒ��ʿ� �ִ�.
ydet = 1;
}
if (xdet > 0) { // ������
if (ydet > 0) { // ������ ��
return 4;
} else if (ydet == 0) { // �׳� ������
return 5;
} else { // ������ �Ʒ�
return 6;
}
} else if (xdet == 0) { // y�� ������
if (ydet > 0) { // ��
return 3;
} else if (ydet == 0) { // �� ������ (����Ʈ ��ũ!)
return -1;
} else { // �Ʒ�
return 7;
}
} else { // ����
if (ydet > 0) { // ���� ��
return 2;
} else if (ydet == 0) { // �׳� ����
return 1;
} else { // ���� �Ʒ�
return 0;
}
}
}
}
| Java |
#include <linux/module.h>
#include <linux/init.h>
#include <linux/skbuff.h>
#include <linux/netfilter/x_tables.h>
#include <linux/netfilter/xt_NFLOG.h>
#include <net/netfilter/nf_log.h>
#include <net/netfilter/nfnetlink_log.h>
MODULE_AUTHOR("Patrick McHardy <kaber@trash.net>");
MODULE_DESCRIPTION("Xtables: packet logging to netlink using NFLOG");
MODULE_LICENSE("GPL");
MODULE_ALIAS("ipt_NFLOG");
MODULE_ALIAS("ip6t_NFLOG");
static unsigned int
nflog_tg(struct sk_buff *skb, const struct xt_target_param *par)
{
const struct xt_nflog_info *info = par->targinfo;
struct nf_loginfo li;
li.type = NF_LOG_TYPE_ULOG;
li.u.ulog.copy_len = info->len;
li.u.ulog.group = info->group;
li.u.ulog.qthreshold = info->threshold;
nfulnl_log_packet(par->family, par->hooknum, skb, par->in,
par->out, &li, info->prefix);
return XT_CONTINUE;
}
static bool nflog_tg_check(const struct xt_tgchk_param *par)
{
const struct xt_nflog_info *info = par->targinfo;
if (info->flags & ~XT_NFLOG_MASK)
return false;
if (info->prefix[sizeof(info->prefix) - 1] != '\0')
return false;
return true;
}
static struct xt_target nflog_tg_reg __read_mostly = {
.name = "NFLOG",
.revision = 0,
.family = NFPROTO_UNSPEC,
.checkentry = nflog_tg_check,
.target = nflog_tg,
.targetsize = sizeof(struct xt_nflog_info),
.me = THIS_MODULE,
};
static int __init nflog_tg_init(void)
{
return xt_register_target(&nflog_tg_reg);
}
static void __exit nflog_tg_exit(void)
{
xt_unregister_target(&nflog_tg_reg);
}
module_init(nflog_tg_init);
module_exit(nflog_tg_exit);
| Java |
package com.lami.tuomatuo.mq.zookeeper.server;
import com.lami.tuomatuo.mq.zookeeper.jmx.ZKMBeanInfo;
/**
* This class implements the data tree MBean
*
* Created by xujiankang on 2017/3/19.
*/
public class DataTreeBean implements DataTreeMXBean, ZKMBeanInfo{
public DataTree dataTree;
public DataTreeBean(DataTree dataTree) {
this.dataTree = dataTree;
}
@Override
public int getNodeCount() {
return dataTree.getNodeCount();
}
@Override
public long approximateDataSize() {
return dataTree.approximateDataSize();
}
@Override
public int countEphemerals() {
return dataTree.getEphemeralsCount();
}
public int getWatchCount(){
return dataTree.getWatchCount();
}
@Override
public String getName() {
return "InMemoryDataTree";
}
@Override
public boolean isHidden() {
return false;
}
@Override
public String getLastZxid() {
return "0x" + Long.toHexString(dataTree.lastProcessedZxid);
}
}
| Java |
/*
* linux/arch/arm/kernel/setup.c
*
* Copyright (C) 1995-2001 Russell King
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*/
#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/stddef.h>
#include <linux/ioport.h>
#include <linux/delay.h>
#include <linux/utsname.h>
#include <linux/initrd.h>
#include <linux/console.h>
#include <linux/bootmem.h>
#include <linux/seq_file.h>
#include <linux/screen_info.h>
#include <linux/init.h>
#include <linux/kexec.h>
#include <linux/of_fdt.h>
#include <linux/crash_dump.h>
#include <linux/root_dev.h>
#include <linux/cpu.h>
#include <linux/interrupt.h>
#include <linux/smp.h>
#include <linux/fs.h>
#include <linux/proc_fs.h>
#include <linux/memblock.h>
#include <asm/unified.h>
#include <asm/cpu.h>
#include <asm/cputype.h>
#include <asm/elf.h>
#include <asm/procinfo.h>
#include <asm/sections.h>
#include <asm/setup.h>
#include <asm/smp_plat.h>
#include <asm/mach-types.h>
#include <asm/cacheflush.h>
#include <asm/cachetype.h>
#include <asm/tlbflush.h>
#include <asm/prom.h>
#include <asm/mach/arch.h>
#include <asm/mach/irq.h>
#include <asm/mach/time.h>
#include <asm/traps.h>
#include <asm/unwind.h>
#if defined(CONFIG_DEPRECATED_PARAM_STRUCT)
#include "compat.h"
#endif
#include "atags.h"
#include "tcm.h"
#ifndef MEM_SIZE
#define MEM_SIZE (16*1024*1024)
#endif
#if defined(CONFIG_FPE_NWFPE) || defined(CONFIG_FPE_FASTFPE)
char fpe_type[8];
static int __init fpe_setup(char *line)
{
memcpy(fpe_type, line, 8);
return 1;
}
__setup("fpe=", fpe_setup);
#endif
extern void paging_init(struct machine_desc *desc);
extern void sanity_check_meminfo(void);
extern void reboot_setup(char *str);
unsigned int processor_id;
EXPORT_SYMBOL(processor_id);
unsigned int __machine_arch_type __read_mostly;
EXPORT_SYMBOL(__machine_arch_type);
unsigned int cacheid __read_mostly;
EXPORT_SYMBOL(cacheid);
unsigned int __atags_pointer __initdata;
unsigned int system_rev;
EXPORT_SYMBOL(system_rev);
unsigned int system_serial_low;
EXPORT_SYMBOL(system_serial_low);
unsigned int system_serial_high;
EXPORT_SYMBOL(system_serial_high);
unsigned int elf_hwcap __read_mostly;
EXPORT_SYMBOL(elf_hwcap);
#ifdef MULTI_CPU
struct processor processor __read_mostly;
#endif
#ifdef MULTI_TLB
struct cpu_tlb_fns cpu_tlb __read_mostly;
#endif
#ifdef MULTI_USER
struct cpu_user_fns cpu_user __read_mostly;
#endif
#ifdef MULTI_CACHE
struct cpu_cache_fns cpu_cache __read_mostly;
#endif
#ifdef CONFIG_OUTER_CACHE
struct outer_cache_fns outer_cache __read_mostly;
EXPORT_SYMBOL(outer_cache);
#endif
struct stack {
u32 irq[3];
u32 abt[3];
u32 und[3];
} ____cacheline_aligned;
static struct stack stacks[NR_CPUS];
char elf_platform[ELF_PLATFORM_SIZE];
EXPORT_SYMBOL(elf_platform);
static const char *cpu_name;
static const char *machine_name;
static char __initdata cmd_line[COMMAND_LINE_SIZE];
struct machine_desc *machine_desc __initdata;
static char default_command_line[COMMAND_LINE_SIZE] __initdata = CONFIG_CMDLINE;
static union { char c[4]; unsigned long l; } endian_test __initdata = { { 'l', '?', '?', 'b' } };
#define ENDIANNESS ((char)endian_test.l)
DEFINE_PER_CPU(struct cpuinfo_arm, cpu_data);
/*
* Standard memory resources
*/
static struct resource mem_res[] = {
{
.name = "Video RAM",
.start = 0,
.end = 0,
.flags = IORESOURCE_MEM
},
{
.name = "Kernel text",
.start = 0,
.end = 0,
.flags = IORESOURCE_MEM
},
{
.name = "Kernel data",
.start = 0,
.end = 0,
.flags = IORESOURCE_MEM
}
};
#define video_ram mem_res[0]
#define kernel_code mem_res[1]
#define kernel_data mem_res[2]
static struct resource io_res[] = {
{
.name = "reserved",
.start = 0x3bc,
.end = 0x3be,
.flags = IORESOURCE_IO | IORESOURCE_BUSY
},
{
.name = "reserved",
.start = 0x378,
.end = 0x37f,
.flags = IORESOURCE_IO | IORESOURCE_BUSY
},
{
.name = "reserved",
.start = 0x278,
.end = 0x27f,
.flags = IORESOURCE_IO | IORESOURCE_BUSY
}
};
#define lp0 io_res[0]
#define lp1 io_res[1]
#define lp2 io_res[2]
static const char *proc_arch[] = {
"undefined/unknown",
"3",
"4",
"4T",
"5",
"5T",
"5TE",
"5TEJ",
"6TEJ",
"7",
"?(11)",
"?(12)",
"?(13)",
"?(14)",
"?(15)",
"?(16)",
"?(17)",
};
int cpu_architecture(void)
{
int cpu_arch;
if ((read_cpuid_id() & 0x0008f000) == 0) {
cpu_arch = CPU_ARCH_UNKNOWN;
} else if ((read_cpuid_id() & 0x0008f000) == 0x00007000) {
cpu_arch = (read_cpuid_id() & (1 << 23)) ? CPU_ARCH_ARMv4T : CPU_ARCH_ARMv3;
} else if ((read_cpuid_id() & 0x00080000) == 0x00000000) {
cpu_arch = (read_cpuid_id() >> 16) & 7;
if (cpu_arch)
cpu_arch += CPU_ARCH_ARMv3;
} else if ((read_cpuid_id() & 0x000f0000) == 0x000f0000) {
unsigned int mmfr0;
/* Revised CPUID format. Read the Memory Model Feature
* Register 0 and check for VMSAv7 or PMSAv7 */
asm("mrc p15, 0, %0, c0, c1, 4"
: "=r" (mmfr0));
if ((mmfr0 & 0x0000000f) >= 0x00000003 ||
(mmfr0 & 0x000000f0) >= 0x00000030)
cpu_arch = CPU_ARCH_ARMv7;
else if ((mmfr0 & 0x0000000f) == 0x00000002 ||
(mmfr0 & 0x000000f0) == 0x00000020)
cpu_arch = CPU_ARCH_ARMv6;
else
cpu_arch = CPU_ARCH_UNKNOWN;
} else
cpu_arch = CPU_ARCH_UNKNOWN;
return cpu_arch;
}
static int cpu_has_aliasing_icache(unsigned int arch)
{
int aliasing_icache;
unsigned int id_reg, num_sets, line_size;
/* arch specifies the register format */
switch (arch) {
case CPU_ARCH_ARMv7:
asm("mcr p15, 2, %0, c0, c0, 0 @ set CSSELR"
: /* No output operands */
: "r" (1));
isb();
asm("mrc p15, 1, %0, c0, c0, 0 @ read CCSIDR"
: "=r" (id_reg));
line_size = 4 << ((id_reg & 0x7) + 2);
num_sets = ((id_reg >> 13) & 0x7fff) + 1;
aliasing_icache = (line_size * num_sets) > PAGE_SIZE;
break;
case CPU_ARCH_ARMv6:
aliasing_icache = read_cpuid_cachetype() & (1 << 11);
break;
default:
/* I-cache aliases will be handled by D-cache aliasing code */
aliasing_icache = 0;
}
return aliasing_icache;
}
static void __init cacheid_init(void)
{
unsigned int cachetype = read_cpuid_cachetype();
unsigned int arch = cpu_architecture();
if (arch >= CPU_ARCH_ARMv6) {
if ((cachetype & (7 << 29)) == 4 << 29) {
/* ARMv7 register format */
cacheid = CACHEID_VIPT_NONALIASING;
if ((cachetype & (3 << 14)) == 1 << 14)
cacheid |= CACHEID_ASID_TAGGED;
else if (cpu_has_aliasing_icache(CPU_ARCH_ARMv7))
cacheid |= CACHEID_VIPT_I_ALIASING;
} else if (cachetype & (1 << 23)) {
cacheid = CACHEID_VIPT_ALIASING;
} else {
cacheid = CACHEID_VIPT_NONALIASING;
if (cpu_has_aliasing_icache(CPU_ARCH_ARMv6))
cacheid |= CACHEID_VIPT_I_ALIASING;
}
} else {
cacheid = CACHEID_VIVT;
}
printk("CPU: %s data cache, %s instruction cache\n",
cache_is_vivt() ? "VIVT" :
cache_is_vipt_aliasing() ? "VIPT aliasing" :
cache_is_vipt_nonaliasing() ? "VIPT nonaliasing" : "unknown",
cache_is_vivt() ? "VIVT" :
icache_is_vivt_asid_tagged() ? "VIVT ASID tagged" :
icache_is_vipt_aliasing() ? "VIPT aliasing" :
cache_is_vipt_nonaliasing() ? "VIPT nonaliasing" : "unknown");
}
/*
* These functions re-use the assembly code in head.S, which
* already provide the required functionality.
*/
extern struct proc_info_list *lookup_processor_type(unsigned int);
void __init early_print(const char *str, ...)
{
extern void printascii(const char *);
char buf[256];
va_list ap;
va_start(ap, str);
vsnprintf(buf, sizeof(buf), str, ap);
va_end(ap);
#ifdef CONFIG_DEBUG_LL
printascii(buf);
#endif
printk("%s", buf);
}
static void __init feat_v6_fixup(void)
{
int id = read_cpuid_id();
if ((id & 0xff0f0000) != 0x41070000)
return;
/*
* HWCAP_TLS is available only on 1136 r1p0 and later,
* see also kuser_get_tls_init.
*/
if ((((id >> 4) & 0xfff) == 0xb36) && (((id >> 20) & 3) == 0))
elf_hwcap &= ~HWCAP_TLS;
}
static void __init setup_processor(void)
{
struct proc_info_list *list;
/*
* locate processor in the list of supported processor
* types. The linker builds this table for us from the
* entries in arch/arm/mm/proc-*.S
*/
list = lookup_processor_type(read_cpuid_id());
if (!list) {
printk("CPU configuration botched (ID %08x), unable "
"to continue.\n", read_cpuid_id());
while (1);
}
cpu_name = list->cpu_name;
#ifdef MULTI_CPU
processor = *list->proc;
#endif
#ifdef MULTI_TLB
cpu_tlb = *list->tlb;
#endif
#ifdef MULTI_USER
cpu_user = *list->user;
#endif
#ifdef MULTI_CACHE
cpu_cache = *list->cache;
#endif
printk("CPU: %s [%08x] revision %d (ARMv%s), cr=%08lx\n",
cpu_name, read_cpuid_id(), read_cpuid_id() & 15,
proc_arch[cpu_architecture()], cr_alignment);
sprintf(init_utsname()->machine, "%s%c", list->arch_name, ENDIANNESS);
sprintf(elf_platform, "%s%c", list->elf_name, ENDIANNESS);
elf_hwcap = list->elf_hwcap;
#ifndef CONFIG_ARM_THUMB
elf_hwcap &= ~HWCAP_THUMB;
#endif
feat_v6_fixup();
cacheid_init();
cpu_proc_init();
}
/*
* cpu_init - initialise one CPU.
*
* cpu_init sets up the per-CPU stacks.
*/
void cpu_init(void)
{
unsigned int cpu = smp_processor_id();
struct stack *stk = &stacks[cpu];
if (cpu >= NR_CPUS) {
printk(KERN_CRIT "CPU%u: bad primary CPU number\n", cpu);
BUG();
}
/*
* Define the placement constraint for the inline asm directive below.
* In Thumb-2, msr with an immediate value is not allowed.
*/
#ifdef CONFIG_THUMB2_KERNEL
#define PLC "r"
#else
#define PLC "I"
#endif
/*
* setup stacks for re-entrant exception handlers
*/
__asm__ (
"msr cpsr_c, %1\n\t"
"add r14, %0, %2\n\t"
"mov sp, r14\n\t"
"msr cpsr_c, %3\n\t"
"add r14, %0, %4\n\t"
"mov sp, r14\n\t"
"msr cpsr_c, %5\n\t"
"add r14, %0, %6\n\t"
"mov sp, r14\n\t"
"msr cpsr_c, %7"
:
: "r" (stk),
PLC (PSR_F_BIT | PSR_I_BIT | IRQ_MODE),
"I" (offsetof(struct stack, irq[0])),
PLC (PSR_F_BIT | PSR_I_BIT | ABT_MODE),
"I" (offsetof(struct stack, abt[0])),
PLC (PSR_F_BIT | PSR_I_BIT | UND_MODE),
"I" (offsetof(struct stack, und[0])),
PLC (PSR_F_BIT | PSR_I_BIT | SVC_MODE)
: "r14");
}
void __init dump_machine_table(void)
{
struct machine_desc *p;
early_print("Available machine support:\n\nID (hex)\tNAME\n");
for_each_machine_desc(p)
early_print("%08x\t%s\n", p->nr, p->name);
early_print("\nPlease check your kernel config and/or bootloader.\n");
while (true)
/* can't use cpu_relax() here as it may require MMU setup */;
}
int __init arm_add_memory(phys_addr_t start, unsigned long size)
{
struct membank *bank = &meminfo.bank[meminfo.nr_banks];
if (meminfo.nr_banks >= NR_BANKS) {
printk(KERN_CRIT "NR_BANKS too low, "
"ignoring memory at 0x%08llx\n", (long long)start);
return -EINVAL;
}
/*
* Ensure that start/size are aligned to a page boundary.
* Size is appropriately rounded down, start is rounded up.
*/
size -= start & ~PAGE_MASK;
bank->start = PAGE_ALIGN(start);
bank->size = size & PAGE_MASK;
/*
* Check whether this memory region has non-zero size or
* invalid node number.
*/
if (bank->size == 0)
return -EINVAL;
meminfo.nr_banks++;
return 0;
}
/*
* Pick out the memory size. We look for mem=size@start,
* where start and size are "size[KkMm]"
*/
static int __init early_mem(char *p)
{
static int usermem __initdata = 0;
unsigned long size;
phys_addr_t start;
char *endp;
/*
* If the user specifies memory size, we
* blow away any automatically generated
* size.
*/
if (usermem == 0) {
usermem = 1;
meminfo.nr_banks = 0;
}
start = PHYS_OFFSET;
size = memparse(p, &endp);
if (*endp == '@')
start = memparse(endp + 1, NULL);
arm_add_memory(start, size);
return 0;
}
early_param("mem", early_mem);
static void __init
setup_ramdisk(int doload, int prompt, int image_start, unsigned int rd_sz)
{
#ifdef CONFIG_BLK_DEV_RAM
extern int rd_size, rd_image_start, rd_prompt, rd_doload;
rd_image_start = image_start;
rd_prompt = prompt;
rd_doload = doload;
if (rd_sz)
rd_size = rd_sz;
#endif
}
static void __init request_standard_resources(struct machine_desc *mdesc)
{
struct memblock_region *region;
struct resource *res;
kernel_code.start = virt_to_phys(_text);
kernel_code.end = virt_to_phys(_etext - 1);
kernel_data.start = virt_to_phys(_sdata);
kernel_data.end = virt_to_phys(_end - 1);
for_each_memblock(memory, region) {
res = alloc_bootmem_low(sizeof(*res));
res->name = "System RAM";
res->start = __pfn_to_phys(memblock_region_memory_base_pfn(region));
res->end = __pfn_to_phys(memblock_region_memory_end_pfn(region)) - 1;
res->flags = IORESOURCE_MEM | IORESOURCE_BUSY;
request_resource(&iomem_resource, res);
if (kernel_code.start >= res->start &&
kernel_code.end <= res->end)
request_resource(res, &kernel_code);
if (kernel_data.start >= res->start &&
kernel_data.end <= res->end)
request_resource(res, &kernel_data);
}
if (mdesc->video_start) {
video_ram.start = mdesc->video_start;
video_ram.end = mdesc->video_end;
request_resource(&iomem_resource, &video_ram);
}
/*
* Some machines don't have the possibility of ever
* possessing lp0, lp1 or lp2
*/
if (mdesc->reserve_lp0)
request_resource(&ioport_resource, &lp0);
if (mdesc->reserve_lp1)
request_resource(&ioport_resource, &lp1);
if (mdesc->reserve_lp2)
request_resource(&ioport_resource, &lp2);
}
/*
* Tag parsing.
*
* This is the new way of passing data to the kernel at boot time. Rather
* than passing a fixed inflexible structure to the kernel, we pass a list
* of variable-sized tags to the kernel. The first tag must be a ATAG_CORE
* tag for the list to be recognised (to distinguish the tagged list from
* a param_struct). The list is terminated with a zero-length tag (this tag
* is not parsed in any way).
*/
static int __init parse_tag_core(const struct tag *tag)
{
if (tag->hdr.size > 2) {
if ((tag->u.core.flags & 1) == 0)
root_mountflags &= ~MS_RDONLY;
ROOT_DEV = old_decode_dev(tag->u.core.rootdev);
}
return 0;
}
__tagtable(ATAG_CORE, parse_tag_core);
static int __init parse_tag_mem32(const struct tag *tag)
{
return arm_add_memory(tag->u.mem.start, tag->u.mem.size);
}
__tagtable(ATAG_MEM, parse_tag_mem32);
#if defined(CONFIG_VGA_CONSOLE) || defined(CONFIG_DUMMY_CONSOLE)
struct screen_info screen_info = {
.orig_video_lines = 30,
.orig_video_cols = 80,
.orig_video_mode = 0,
.orig_video_ega_bx = 0,
.orig_video_isVGA = 1,
.orig_video_points = 8
};
static int __init parse_tag_videotext(const struct tag *tag)
{
screen_info.orig_x = tag->u.videotext.x;
screen_info.orig_y = tag->u.videotext.y;
screen_info.orig_video_page = tag->u.videotext.video_page;
screen_info.orig_video_mode = tag->u.videotext.video_mode;
screen_info.orig_video_cols = tag->u.videotext.video_cols;
screen_info.orig_video_ega_bx = tag->u.videotext.video_ega_bx;
screen_info.orig_video_lines = tag->u.videotext.video_lines;
screen_info.orig_video_isVGA = tag->u.videotext.video_isvga;
screen_info.orig_video_points = tag->u.videotext.video_points;
return 0;
}
__tagtable(ATAG_VIDEOTEXT, parse_tag_videotext);
#endif
static int __init parse_tag_ramdisk(const struct tag *tag)
{
setup_ramdisk((tag->u.ramdisk.flags & 1) == 0,
(tag->u.ramdisk.flags & 2) == 0,
tag->u.ramdisk.start, tag->u.ramdisk.size);
return 0;
}
__tagtable(ATAG_RAMDISK, parse_tag_ramdisk);
static int __init parse_tag_serialnr(const struct tag *tag)
{
system_serial_low = tag->u.serialnr.low;
system_serial_high = tag->u.serialnr.high;
return 0;
}
__tagtable(ATAG_SERIAL, parse_tag_serialnr);
static int __init parse_tag_revision(const struct tag *tag)
{
system_rev = tag->u.revision.rev;
return 0;
}
__tagtable(ATAG_REVISION, parse_tag_revision);
static int __init parse_tag_cmdline(const struct tag *tag)
{
#if defined(CONFIG_CMDLINE_EXTEND)
strlcat(default_command_line, " ", COMMAND_LINE_SIZE);
strlcat(default_command_line, tag->u.cmdline.cmdline,
COMMAND_LINE_SIZE);
#elif defined(CONFIG_CMDLINE_FORCE)
pr_warning("Ignoring tag cmdline (using the default kernel command line)\n");
#else
strlcpy(default_command_line, tag->u.cmdline.cmdline,
COMMAND_LINE_SIZE);
#endif
return 0;
}
__tagtable(ATAG_CMDLINE, parse_tag_cmdline);
/*
* Scan the tag table for this tag, and call its parse function.
* The tag table is built by the linker from all the __tagtable
* declarations.
*/
static int __init parse_tag(const struct tag *tag)
{
extern struct tagtable __tagtable_begin, __tagtable_end;
struct tagtable *t;
for (t = &__tagtable_begin; t < &__tagtable_end; t++)
if (tag->hdr.tag == t->tag) {
t->parse(tag);
break;
}
return t < &__tagtable_end;
}
/*
* Parse all tags in the list, checking both the global and architecture
* specific tag tables.
*/
static void __init parse_tags(const struct tag *t)
{
for (; t->hdr.size; t = tag_next(t))
if (!parse_tag(t))
printk(KERN_WARNING
"Ignoring unrecognised tag 0x%08x\n",
t->hdr.tag);
}
/*
* This holds our defaults.
*/
static struct init_tags {
struct tag_header hdr1;
struct tag_core core;
struct tag_header hdr2;
struct tag_mem32 mem;
struct tag_header hdr3;
} init_tags __initdata = {
{ tag_size(tag_core), ATAG_CORE },
{ 1, PAGE_SIZE, 0xff },
{ tag_size(tag_mem32), ATAG_MEM },
{ MEM_SIZE },
{ 0, ATAG_NONE }
};
static int __init customize_machine(void)
{
/* customizes platform devices, or adds new ones */
if (machine_desc->init_machine)
machine_desc->init_machine();
return 0;
}
arch_initcall(customize_machine);
#ifdef CONFIG_KEXEC
static inline unsigned long long get_total_mem(void)
{
unsigned long total;
total = max_low_pfn - min_low_pfn;
return total << PAGE_SHIFT;
}
/**
* reserve_crashkernel() - reserves memory are for crash kernel
*
* This function reserves memory area given in "crashkernel=" kernel command
* line parameter. The memory reserved is used by a dump capture kernel when
* primary kernel is crashing.
*/
static void __init reserve_crashkernel(void)
{
unsigned long long crash_size, crash_base;
unsigned long long total_mem;
int ret;
total_mem = get_total_mem();
ret = parse_crashkernel(boot_command_line, total_mem,
&crash_size, &crash_base);
if (ret)
return;
ret = reserve_bootmem(crash_base, crash_size, BOOTMEM_EXCLUSIVE);
if (ret < 0) {
printk(KERN_WARNING "crashkernel reservation failed - "
"memory is in use (0x%lx)\n", (unsigned long)crash_base);
return;
}
printk(KERN_INFO "Reserving %ldMB of memory at %ldMB "
"for crashkernel (System RAM: %ldMB)\n",
(unsigned long)(crash_size >> 20),
(unsigned long)(crash_base >> 20),
(unsigned long)(total_mem >> 20));
crashk_res.start = crash_base;
crashk_res.end = crash_base + crash_size - 1;
insert_resource(&iomem_resource, &crashk_res);
}
#else
static inline void reserve_crashkernel(void) {}
#endif /* CONFIG_KEXEC */
static void __init squash_mem_tags(struct tag *tag)
{
for (; tag->hdr.size; tag = tag_next(tag))
if (tag->hdr.tag == ATAG_MEM)
tag->hdr.tag = ATAG_NONE;
}
static struct machine_desc * __init setup_machine_tags(unsigned int nr)
{
struct tag *tags = (struct tag *)&init_tags;
struct machine_desc *mdesc = NULL, *p;
char *from = default_command_line;
init_tags.mem.start = PHYS_OFFSET;
/*
* locate machine in the list of supported machines.
*/
for_each_machine_desc(p)
if (nr == p->nr) {
printk("Machine: %s\n", p->name);
mdesc = p;
break;
}
if (!mdesc) {
early_print("\nError: unrecognized/unsupported machine ID"
" (r1 = 0x%08x).\n\n", nr);
dump_machine_table(); /* does not return */
}
if (__atags_pointer)
tags = phys_to_virt(__atags_pointer);
else if (mdesc->boot_params) {
#ifdef CONFIG_MMU
/*
* We still are executing with a minimal MMU mapping created
* with the presumption that the machine default for this
* is located in the first MB of RAM. Anything else will
* fault and silently hang the kernel at this point.
*/
if (mdesc->boot_params < PHYS_OFFSET ||
mdesc->boot_params >= PHYS_OFFSET + SZ_1M) {
printk(KERN_WARNING
"Default boot params at physical 0x%08lx out of reach\n",
mdesc->boot_params);
} else
#endif
{
tags = phys_to_virt(mdesc->boot_params);
}
}
#if defined(CONFIG_DEPRECATED_PARAM_STRUCT)
/*
* If we have the old style parameters, convert them to
* a tag list.
*/
if (tags->hdr.tag != ATAG_CORE)
convert_to_tag_list(tags);
#endif
if (tags->hdr.tag != ATAG_CORE) {
#if defined(CONFIG_OF)
/*
* If CONFIG_OF is set, then assume this is a reasonably
* modern system that should pass boot parameters
*/
early_print("Warning: Neither atags nor dtb found\n");
#endif
tags = (struct tag *)&init_tags;
}
if (mdesc->fixup)
mdesc->fixup(mdesc, tags, &from, &meminfo);
if (tags->hdr.tag == ATAG_CORE) {
if (meminfo.nr_banks != 0)
squash_mem_tags(tags);
save_atags(tags);
parse_tags(tags);
}
/* parse_early_param needs a boot_command_line */
strlcpy(boot_command_line, from, COMMAND_LINE_SIZE);
return mdesc;
}
void __init setup_arch(char **cmdline_p)
{
struct machine_desc *mdesc;
unwind_init();
setup_processor();
mdesc = setup_machine_fdt(__atags_pointer);
if (!mdesc)
mdesc = setup_machine_tags(machine_arch_type);
machine_desc = mdesc;
machine_name = mdesc->name;
#ifdef CONFIG_ZONE_DMA
if (mdesc->dma_zone_size) {
extern unsigned long arm_dma_zone_size;
arm_dma_zone_size = mdesc->dma_zone_size;
}
#endif
if (mdesc->soft_reboot)
reboot_setup("s");
init_mm.start_code = (unsigned long) _text;
init_mm.end_code = (unsigned long) _etext;
init_mm.end_data = (unsigned long) _edata;
init_mm.brk = (unsigned long) _end;
/* populate cmd_line too for later use, preserving boot_command_line */
strlcpy(cmd_line, boot_command_line, COMMAND_LINE_SIZE);
*cmdline_p = cmd_line;
parse_early_param();
sanity_check_meminfo();
arm_memblock_init(&meminfo, mdesc);
paging_init(mdesc);
request_standard_resources(mdesc);
unflatten_device_tree();
#ifdef CONFIG_SMP
if (is_smp())
smp_init_cpus();
#endif
reserve_crashkernel();
cpu_init();
tcm_init();
#ifdef CONFIG_MULTI_IRQ_HANDLER
handle_arch_irq = mdesc->handle_irq;
#endif
#ifdef CONFIG_VT
#if defined(CONFIG_VGA_CONSOLE)
conswitchp = &vga_con;
#elif defined(CONFIG_DUMMY_CONSOLE)
conswitchp = &dummy_con;
#endif
#endif
early_trap_init();
if (mdesc->init_early)
mdesc->init_early();
}
static int __init topology_init(void)
{
int cpu;
for_each_possible_cpu(cpu) {
struct cpuinfo_arm *cpuinfo = &per_cpu(cpu_data, cpu);
cpuinfo->cpu.hotpluggable = 1;
register_cpu(&cpuinfo->cpu, cpu);
}
return 0;
}
subsys_initcall(topology_init);
#ifdef CONFIG_HAVE_PROC_CPU
static int __init proc_cpu_init(void)
{
struct proc_dir_entry *res;
res = proc_mkdir("cpu", NULL);
if (!res)
return -ENOMEM;
return 0;
}
fs_initcall(proc_cpu_init);
#endif
static const char *hwcap_str[] = {
"swp",
"half",
"thumb",
"26bit",
"fastmult",
"fpa",
"vfp",
"edsp",
"java",
"iwmmxt",
"crunch",
"thumbee",
"neon",
"vfpv3",
"vfpv3d16",
"tls",
"vfpv4",
"idiva",
"idivt",
NULL
};
static int c_show(struct seq_file *m, void *v)
{
int i;
seq_printf(m, "Processor\t: %s rev %d (%s)\n",
cpu_name, read_cpuid_id() & 15, elf_platform);
#if defined(CONFIG_SMP)
for_each_online_cpu(i) {
/*
* glibc reads /proc/cpuinfo to determine the number of
* online processors, looking for lines beginning with
* "processor". Give glibc what it expects.
*/
seq_printf(m, "processor\t: %d\n", i);
seq_printf(m, "BogoMIPS\t: %lu.%02lu\n\n",
per_cpu(cpu_data, i).loops_per_jiffy / (500000UL/HZ),
(per_cpu(cpu_data, i).loops_per_jiffy / (5000UL/HZ)) % 100);
}
#else /* CONFIG_SMP */
seq_printf(m, "BogoMIPS\t: %lu.%02lu\n",
loops_per_jiffy / (500000/HZ),
(loops_per_jiffy / (5000/HZ)) % 100);
#endif
/* dump out the processor features */
seq_puts(m, "Features\t: ");
for (i = 0; hwcap_str[i]; i++)
if (elf_hwcap & (1 << i))
seq_printf(m, "%s ", hwcap_str[i]);
seq_printf(m, "\nCPU implementer\t: 0x%02x\n", read_cpuid_id() >> 24);
seq_printf(m, "CPU architecture: %s\n", proc_arch[cpu_architecture()]);
if ((read_cpuid_id() & 0x0008f000) == 0x00000000) {
/* pre-ARM7 */
seq_printf(m, "CPU part\t: %07x\n", read_cpuid_id() >> 4);
} else {
if ((read_cpuid_id() & 0x0008f000) == 0x00007000) {
/* ARM7 */
seq_printf(m, "CPU variant\t: 0x%02x\n",
(read_cpuid_id() >> 16) & 127);
} else {
/* post-ARM7 */
seq_printf(m, "CPU variant\t: 0x%x\n",
(read_cpuid_id() >> 20) & 15);
}
seq_printf(m, "CPU part\t: 0x%03x\n",
(read_cpuid_id() >> 4) & 0xfff);
}
seq_printf(m, "CPU revision\t: %d\n", read_cpuid_id() & 15);
seq_puts(m, "\n");
seq_printf(m, "Hardware\t: %s\n", machine_name);
seq_printf(m, "Revision\t: %04x\n", system_rev);
seq_printf(m, "Serial\t\t: %08x%08x\n",
system_serial_high, system_serial_low);
return 0;
}
static void *c_start(struct seq_file *m, loff_t *pos)
{
return *pos < 1 ? (void *)1 : NULL;
}
static void *c_next(struct seq_file *m, void *v, loff_t *pos)
{
++*pos;
return NULL;
}
static void c_stop(struct seq_file *m, void *v)
{
}
const struct seq_operations cpuinfo_op = {
.start = c_start,
.next = c_next,
.stop = c_stop,
.show = c_show
};
| Java |
/**
* Copyright (C) SiteSupra SIA, Riga, Latvia, 2015
*
* 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.
*/
YUI.add('itemmanager.itemlist-uploader', function (Y) {
//Invoke strict mode
"use strict";
//Shortcut
var Manager = Supra.Manager,
Action = Manager.PageContent;
/*
* Editable content
*/
function ItemListUploader (config) {
ItemListUploader.superclass.constructor.apply(this, arguments);
}
ItemListUploader.NAME = 'itemmanager-itemlist-uploader';
ItemListUploader.NS = 'uploader';
ItemListUploader.ATTRS = {};
Y.extend(ItemListUploader, Y.Plugin.Base, {
/**
* Supra.Uploader instance
* @type {Object}
* @private
*/
uploader: null,
/**
* File uploader ids to item ids
* @type {Object}
* @private
*/
ids: null,
/**
*
*/
initializer: function () {
var itemlist = this.get('host'),
container = itemlist.get('contentElement');
this.ids = {};
this.listeners = [];
this.listeners.push(itemlist.after('contentElementChange', this.reattachListeners, this));
if (container) {
this.reattachListeners();
}
},
destructor: function () {
this.resetAll();
// Listeners
var listeners = this.listeners,
i = 0,
ii = listeners.length;
for (; i < ii; i++) listeners[i].detach();
this.listeners = null;
},
/**
* Attach drag and drop listeners
*/
reattachListeners: function () {
var itemlist = this.get('host'),
container = itemlist.get('contentElement'),
//doc = null,
target = null;
if (this.uploader) {
this.uploader.destroy();
this.uploader = null;
}
if (!container) {
return false;
}
//Create uploader
target = itemlist.get('iframe').one('.supra-itemmanager-wrapper');
this.uploader = new Supra.Uploader({
'dropTarget': target,
'allowBrowse': false,
'allowMultiple': true,
'accept': 'image/*',
'requestUri': Supra.Url.generate('media_library_upload'),
'uploadFolderId': itemlist.get('host').options.imageUploadFolder
});
this.uploader.on('file:upload', this.onFileUploadStart, this);
this.uploader.on('file:complete', this.onFileUploadEnd, this);
this.uploader.on('file:error', this.onFileUploadError, this);
},
/**
* Reset all iframe content bindings, etc.
*/
resetAll: function () {
var uploader = this.uploader;
if (uploader) {
uploader.destroy(true);
this.uploader = null;
}
},
/* ------------------------ FILE UPLOAD ------------------------ */
/**
* Handle file upload start
*/
onFileUploadStart: function (e) {
var data = e.details[0],
itemlist = this.get('host'),
item = null;
// Prevent item from being opened for editing
itemlist.initializing = true;
item = itemlist.addItem({'title': e.title.replace(/\..+$/, '')});
itemlist.initializing = false;
this.ids[e.id] = item.__suid;
},
/**
* Handle file upload end
*/
onFileUploadEnd: function (e) {
var data = e.details[0],
itemlist = this.get('host'),
itemdrop = itemlist.drop;
if (e.old_id in this.ids) {
itemdrop.updateItemInCollection(data, this.ids[e.old_id]);
delete(this.ids[e.old_id]);
} else {
itemdrop.addItemToCollection(data);
}
},
/**
* Handle file upload error
*/
onFileUploadError: function (e) {
var itemlist = this.get('host');
itemlist.removeItem(this.ids[e.id]);
delete(this.ids[e.id]);
}
});
Supra.ItemManagerItemListUploader = ItemListUploader;
//Since this widget has Supra namespace, it doesn't need to be bound to each YUI instance
//Make sure this constructor function is called only once
delete(this.fn); this.fn = function () {};
}, YUI.version, {requires: ['plugin', 'supra.uploader']});
| Java |
<?php
/* vim: set expandtab tabstop=4 shiftwidth=4: */
// +----------------------------------------------------------------------+
// | Fez - Digital Repository System |
// +----------------------------------------------------------------------+
// | Copyright (c) 2005, 2006, 2007 The University of Queensland, |
// | Australian Partnership for Sustainable Repositories, |
// | eScholarship Project |
// | |
// | Some of the Fez code was derived from Eventum (Copyright 2003, 2004 |
// | MySQL AB - http://dev.mysql.com/downloads/other/eventum/ - GPL) |
// | |
// | 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: |
// | |
// | Free Software Foundation, Inc. |
// | 59 Temple Place - Suite 330 |
// | Boston, MA 02111-1307, USA. |
// +----------------------------------------------------------------------+
// | Authors: Christiaan Kortekaas <c.kortekaas@library.uq.edu.au>, |
// | Matthew Smith <m.smith@library.uq.edu.au> |
// +----------------------------------------------------------------------+
//
//
include_once("config.inc.php");
include_once(APP_INC_PATH . "class.lister.php");
include_once(APP_INC_PATH . "class.auth.php");
if (APP_AUTHOR_PROFILE_REDIRECT == 'ON') {
// Send to the new eSpace search profile page when only the author_id is supplied PT: #176474178
if (count($_GET) === 2 &&
array_key_exists('browse', $_GET) &&
$_GET['browse'] === 'author_id' &&
array_key_exists('value', $_GET) &&
is_numeric($_GET['value'])
) {
Lister::authorProfileRedirect($_GET['value']);
}
}
$res = Lister::getList($_GET, true);
$pids = array();
if (is_array($res['list'])) {
foreach ($res['list'] as $record) {
if (array_key_exists('rek_pid', $record)) {
$pids[] = $record['rek_pid'];
}
}
}
/*
* If this is a logged in user we want to save this data for view pages, so when can create
* 'prev' and 'next' links
*/
$username = Auth::getUsername();
if (!empty($username)) {
$_SESSION['list'] = $pids;
$_SESSION['list_params'] = $_GET;
$_SESSION['script_name'] = $_SERVER['SCRIPT_NAME'];
$_SESSION['last_page'] = $res['list_info']['last_page'];
$_SESSION['view_page'] = $res['list_info']['current_page'];
}
| Java |
using System.Collections.Generic;
using System.Xml.Linq;
using UnityEngine;
namespace IaS.Xml
{
public class XmlTrackNode
{
public const string ElementTrackNode = "node";
private const string AttrTrackNodeId = "id";
private const string AttrTrackNodePosition = "p";
public Vector3 Position { get; private set; }
public string Id { get; private set; }
public XmlTrackNode Previous { get; private set; }
public XmlTrackNode Next { get; private set; }
public static XmlTrackNode FromElement(XElement element, Dictionary<string, int> counts)
{
string id = XmlValueMapper.FromAttribute(element, AttrTrackNodeId).AsIdValue("t_node", counts);
Vector3 position = XmlValueMapper.FromAttribute(element, AttrTrackNodePosition).AsVector3().MandatoryValue();
return new XmlTrackNode(id, position);
}
public XmlTrackNode(string id, Vector3 position)
{
Id = id;
Position = position;
}
}
}
| Java |
##
# This file is part of WhatWeb and may be subject to
# redistribution and commercial restrictions. Please see the WhatWeb
# web site for more information on licensing and terms of use.
# https://morningstarsecurity.com/research/whatweb
##
Plugin.define do
name "Movable-Type"
authors [
"Andrew Horton",
# v0.2 # remove :certainty.
# v0.3 # Uses :version=>//.
"Brendan Coles <bcoles@gmail.com>", # v0.4 # 2011-07-07 # updated regex. added example urls, google dorks and version/path detection with mt-check.cgi.
]
version "0.4"
description "Blogging platform"
website "http://www.movabletype.org/"
# Google results as at 2011-07-07 #
# 122 for "Powered by Movable Type"
# 89 for inurl:/mt-check.cgi intitle:"Movable Type System Check [mt-check.cgi]"
# 26 for inurl:/mt/mt-check.cgi
# More examples:
# www.movabletype.com/showcase/
# Dorks #
dorks [
'"Powered by Movable Type"',
'inurl:/mt-check.cgi intitle:"Movable Type System Check [mt-check.cgi]"'
]
# Matches #
matches [
# javascript with 'mt' in the filename
{:name=>"javascript with 'mt' in the name",
:certainty=>50, :regexp=>/<script type="text\/javascript" src="[^"]+mt(-site)?\.js"><\/script>/},
# mt-tags|mt-tb|mt-cp|mt-search|mt-user-login|mt-recommend cgi
{:name=>"mt-tags|mt-tb|mt-cp|mt-search|mt-user-login|mt-recommend cgi",
:certainty=>75,
:regexp=>/"[^"]+\/mt-(tags|tb|cp|search|user-login|recommend)\.[f]?cgi[^"]*"/},
# Meta Generator
{:name=>"meta generator tag", :regexp=>/<meta name="generator" content="http:\/\/www\.movabletype\.org\/" \/>/},
# mt-check.cgi # Title
{ :text=>'<title>Movable Type System Check [mt-check.cgi]</title>' },
# Version Detection # mt-check.cgi
{ :version=>/<li><strong>Movable Type version:<\/strong> <code>([^<]+)<\/code><\/li>/ },
# Local Path Detection # mt-check.cgi
{ :filepath=>/<li><strong>Current working directory:<\/strong> <code>([^<]+)<\/code><\/li>/ },
# Powered by link
{:name=>"Powered by link", :regexp=>/<a href="http:\/\/sixapart\.com">Powered by Movable Type<\/a>/},
{:name=>"Powered by link", :regexp=>/Powered by <a href="http:\/\/www\.movabletype\.com\/"[^>]*>Movable Type<\/a>/ },
# Version Detection # Meta Generator
{:version=>/<meta name="generator" content="Movable Type ([^"]*)/, :name=>"meta generator tag" }
]
end
=begin
# An aggressive plugin could check the following paths for confirmation:
# /mt or /mt/mt-check.cgi (discloses versions, paths)
# /mt/mt-tags.fcgi
# /mt-tb.fcgi
# /mt-cp.[f]?cgi
# /mt-search.cgi
# /mt-user-login.cgi
# /mt-recommend.cgi
# can't detect:
barackobama.com
blogs.oracle.com
electricartists.com/corporate
muledesign.com
www.radaronline.com
www.theatlantic.com
www.thehuffingtonpost.com
=end
| Java |
import { apiBase, versionApi } from '../commons';
const apiMonitoringBeta = `${apiBase}/beta/monitoring`;
const apiMonitoring = `${apiBase}/${versionApi}/monitoring`;
export { apiMonitoringBeta, apiMonitoring };
| Java |
require("map/level")
local levellist = {}
levellist[LEVELTYPE.SURVIVAL] = {}
levellist[LEVELTYPE.CAVE] = {}
levellist[LEVELTYPE.ADVENTURE] = {}
levellist[LEVELTYPE.TEST] = {}
levellist[LEVELTYPE.CUSTOM] = {}
function AddLevel(type, data)
table.insert(levellist[type], Level(data))
end
require("map/levels/adventure")
require("map/levels/caves")
require("map/levels/survival")
function GetTypeForLevelID(id)
if id == nil or id:lower() == "unknown" then
return LEVELTYPE.UNKNOWN
end
id = id:lower()
for type, levels in pairs(levellist) do
for idx, level in ipairs(levels) do
if level.id:lower() == id then
return type
end
end
end
return LEVELTYPE.UNKNOWN
end
AddLevel(LEVELTYPE.TEST, {
name="TEST_LEVEL",
id="TEST",
overrides={
{"world_size", "tiny"},
{"day", "onlynight"},
{"waves", "off"},
{"location", "cave"},
{"boons", "never"},
{"poi", "never"},
{"traps", "never"},
{"protected", "never"},
{"start_setpeice", "CaveStart"},
{"start_node", "BGSinkholeRoom"},
},
tasks={
"CavesStart",
"CavesAlternateStart",
"FungalBatCave",
"BatCaves",
"TentacledCave",
"LargeFungalComplex",
"SingleBatCaveTask",
"RabbitsAndFungs",
"FungalPlain",
"Cavern",
},
numoptionaltasks = 1,
optionaltasks = {
"CaveBase",
"MushBase",
"SinkBase",
"RabbitTown",
},
override_triggers = {
-- ["RuinsStart"] = {
-- {"SeasonColourCube", "caves"},
-- -- {"SeasonColourCube", SEASONS.CAVES},
-- },
-- ["TheLabyrinth"] = {
-- {"SeasonColourCube", "caves_ruins"},
-- -- {"SeasonColourCube", { DAY = "images/colour_cubes/ruins_light_cc.tex",
-- -- DUSK = "images/colour_cubes/ruins_dim_cc.tex",
-- -- NIGHT = "images/colour_cubes/ruins_dark_cc.tex",
-- -- },
-- -- },
-- },
-- ["CityInRuins"] = {
-- {"SeasonColourCube", "caves_ruins"},
-- -- {"SeasonColourCube", { DAY = "images/colour_cubes/ruins_light_cc.tex",
-- -- DUSK = "images/colour_cubes/ruins_dim_cc.tex",
-- -- NIGHT = "images/colour_cubes/ruins_dark_cc.tex",
-- -- },
-- -- },
-- },
},
})
return { story_levels=levellist[LEVELTYPE.ADVENTURE],
sandbox_levels=levellist[LEVELTYPE.SURVIVAL],
cave_levels = levellist[LEVELTYPE.CAVE],
--free_level=levellist[LEVELTYPE.SURVIVAL][1],
test_level=levellist[LEVELTYPE.TEST][1],
custom_levels = levellist[LEVELTYPE.CUSTOM],
CAMPAIGN_LENGTH=CAMPAIGN_LENGTH,
GetTypeForLevelID = GetTypeForLevelID
}
| Java |
import tests.util.*;
import java.util.Map;
// Test case for Issue 134:
// http://code.google.com/p/checker-framework/issues/detail?id=134
// Handling of generics from different enclosing classes.
// TODO: revisit with nested types in 1.3.
// @skip-test
class GenericTest4 {
public interface Foo {}
class Outer<O> {
O getOuter() { return null; }
class Inner<I> {
O getInner() { return null; }
I setter1(O p) { return null; }
O setter2(I p) { return null; }
Map<O, I> wow(Map<O, I> p) { return null; }
}
}
class OuterImpl extends Outer<Foo> {
void test() {
Foo foo = getOuter();
}
class InnerImpl extends Inner<@Odd String> {
void test() {
Foo foo = getInner();
String s = setter1(foo);
foo = setter2(s);
}
void testWow(Map<Foo, String> p) {
p = wow(p);
}
}
}
// Add uses from outside of both classes.
}
| Java |
<?php
/**
* Themes shortcode image options go here
*
* @package Omega
* @subpackage Core
* @since 1.0
*
* @copyright (c) 2014 Oxygenna.com
* @license http://wiki.envato.com/support/legal-terms/licensing-terms/
* @version 1.7.3
*/
return array(
'title' => __('Image options', 'omega-admin-td'),
'fields' => array(
array(
'name' => __('Image Shape', 'omega-admin-td'),
'desc' => __('Choose the shape of the image', 'omega-admin-td'),
'id' => 'image_shape',
'type' => 'select',
'options' => array(
'box-round' => __('Round', 'omega-admin-td'),
'box-rect' => __('Rectangle', 'omega-admin-td'),
'box-square' => __('Square', 'omega-admin-td'),
),
'default' => 'box-round',
),
array(
'name' => __('Image Size', 'omega-admin-td'),
'desc' => __('Choose the size of the image', 'omega-admin-td'),
'id' => 'image_size',
'type' => 'select',
'options' => array(
'box-mini' => __('Mini', 'omega-admin-td'),
'no-small' => __('Small', 'omega-admin-td'),
'box-medium' => __('Medium', 'omega-admin-td'),
'box-big' => __('Big', 'omega-admin-td'),
'box-huge' => __('Huge', 'omega-admin-td'),
),
'default' => 'box-medium',
),
)
); | Java |
<?php
/*
Template Name: Products Template
*
*/
?>
<?php get_header(); ?>
<div class="wrap-full banner-background cf" style="<?php if( get_field('background_banner')){ echo "background-image: url('". get_field('background_banner')."')"; } ?>">
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<div class="products-container cf">
<h1><?php the_title(); ?> <span class="tagline"><?php the_field('tagline'); ?></span></h1>
<?php if($_GET['ativo'] == "tilbud") : ?>
<div class="price-table-column blue" style="display: block; margin: 0 auto 50px;">
<div class="price-table-header slim">
<span class="price-table-header-value"><h2>Ativo Medlemstilbud</h2></span>
</div>
<div class="price-table-price-row">
<span class="price-value price-eksl">Månedspris: 350,- <span style="color: #7f7f7f; font-size: 22px; text-decoration: line-through;">450,-</span></span>
</div>
<div class="price-table-cell">
<div class=""></div>
<span class="price-table-cell-value">Vedligeholdelse + Fuld Service</span>
<div class="price-table-cell-info">Alt fra pakken til 450,- her under, til en venlig pris :-)</div>
</div>
<div class="price-table-cell">
<div class=""></div>
<span class="price-table-cell-value">TILMELD</span>
<div class="price-table-cell-info">
<?php echo do_shortcode("[stripeform serviceid='service350']"); ?>
</div>
</div>
<div class="price-table-footer"></div>
</div>
<?php endif; ?>
<?php
// check if any products are created
if( have_rows('product') ):
// loop through products
while( have_rows('product') ): the_row(); ?>
<div class="price-table-column <?php the_sub_field('product_color'); ?>">
<div class="price-table-header slim">
<?php if(get_sub_field('product_link')) { ?><a href="<?php the_sub_field('product_link'); ?>"><?php } ?>
<span class="price-table-header-value"><h2><?php the_sub_field('product_name'); ?></h2></span>
<?php if(get_sub_field('product_link')) { ?></a><?php } ?>
</div>
<div class="price-table-price-row">
<?php if(get_sub_field('price_label') == 'from') { ?> <span class="price-value price-from price-eksl"><?php the_sub_field('product_price'); ?>,-</span><?php } ?>
<?php if(get_sub_field('price_label') == 'more') { ?> <span class="price-readmore"><?php the_sub_field('product_price'); ?></span><?php } ?>
<?php if(get_sub_field('price_label') == 'none') { ?> <span class="price-value price-eksl"><?php the_sub_field('product_price'); ?>,-</span><?php } ?>
</div>
<?php
if( get_sub_field('product_description') ):
?>
<div class="price-table-description">
<span><?php the_sub_field('product_description'); ?></span>
</div>
<?php endif; ?>
<?php
// check if any product items exists
if( have_rows('product_items') ):
// loop through product items
while( have_rows('product_items') ): the_row(); ?>
<div class="price-table-cell">
<div class="<?php the_sub_field('class'); ?>"></div>
<span class="price-table-cell-value"><?php the_sub_field('label'); ?></span>
<div class="price-table-cell-info"><?php echo do_shortcode(get_sub_field('description')); ?></div>
</div>
<?php endwhile; ?>
<?php endif; ?>
<div class="price-table-footer">
<?php if(get_sub_field('product_link')) { ?>
<a href="<?php the_sub_field('product_link'); ?>">
<span class="price-table-footer-value">Læs mere</span></a>
</a><?php } ?>
</div>
</div>
<?php endwhile; ?>
<?php endif; ?>
</div>
<?php endwhile; endif; ?>
</div>
<?php include (TEMPLATEPATH . '/contact-ribbon.php'); ?>
<div id="content">
<div id="inner-content" class="wrap cf">
<main id="main" class="m-all t-2of3 d-5of7 cf" role="main" itemscope itemprop="mainContentOfPage" itemtype="http://schema.org/Blog">
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<article id="post-<?php the_ID(); ?>" <?php post_class( 'cf' ); ?> role="article" itemscope itemtype="http://schema.org/BlogPosting">
<section class="entry-content cf" itemprop="articleBody">
<?php the_content(); ?>
</section> <?php // end article section ?>
<footer class="article-footer cf">
</footer>
</article>
<?php endwhile; endif; ?>
</main>
<!--
<?php get_sidebar(); ?>
-->
</div>
</div>
<?php get_footer(); ?>
| Java |
/* ----------------------------------------------------------------------
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
http://lammps.sandia.gov, Sandia National Laboratories
Steve Plimpton, sjplimp@sandia.gov
This software is distributed under the GNU General Public License.
See the README file in the top-level LAMMPS directory.
------------------------------------------------------------------------- */
/* ----------------------------------------------------------------------
Contributing author: Axel Kohlmeyer (Temple U)
------------------------------------------------------------------------- */
#include "omp_compat.h"
#include <cmath>
#include "pair_lj_charmm_coul_long_omp.h"
#include "atom.h"
#include "comm.h"
#include "force.h"
#include "neighbor.h"
#include "neigh_list.h"
#include "suffix.h"
using namespace LAMMPS_NS;
/* ---------------------------------------------------------------------- */
PairLJCharmmCoulLongOMP::PairLJCharmmCoulLongOMP(LAMMPS *lmp) :
PairLJCharmmCoulLong(lmp), ThrOMP(lmp, THR_PAIR)
{
suffix_flag |= Suffix::OMP;
respa_enable = 0;
cut_respa = NULL;
}
/* ---------------------------------------------------------------------- */
void PairLJCharmmCoulLongOMP::compute(int eflag, int vflag)
{
ev_init(eflag,vflag);
const int nall = atom->nlocal + atom->nghost;
const int nthreads = comm->nthreads;
const int inum = list->inum;
#if defined(_OPENMP)
#pragma omp parallel LMP_DEFAULT_NONE LMP_SHARED(eflag,vflag)
#endif
{
int ifrom, ito, tid;
loop_setup_thr(ifrom, ito, tid, inum, nthreads);
ThrData *thr = fix->get_thr(tid);
thr->timer(Timer::START);
ev_setup_thr(eflag, vflag, nall, eatom, vatom, NULL, thr);
if (evflag) {
if (eflag) {
if (force->newton_pair) eval<1,1,1>(ifrom, ito, thr);
else eval<1,1,0>(ifrom, ito, thr);
} else {
if (force->newton_pair) eval<1,0,1>(ifrom, ito, thr);
else eval<1,0,0>(ifrom, ito, thr);
}
} else {
if (force->newton_pair) eval<0,0,1>(ifrom, ito, thr);
else eval<0,0,0>(ifrom, ito, thr);
}
thr->timer(Timer::PAIR);
reduce_thr(this, eflag, vflag, thr);
} // end of omp parallel region
}
/* ---------------------------------------------------------------------- */
template <int EVFLAG, int EFLAG, int NEWTON_PAIR>
void PairLJCharmmCoulLongOMP::eval(int iifrom, int iito, ThrData * const thr)
{
const dbl3_t * _noalias const x = (dbl3_t *) atom->x[0];
dbl3_t * _noalias const f = (dbl3_t *) thr->get_f()[0];
const double * _noalias const q = atom->q;
const int * _noalias const type = atom->type;
const double * _noalias const special_coul = force->special_coul;
const double * _noalias const special_lj = force->special_lj;
const double qqrd2e = force->qqrd2e;
const double inv_denom_lj = 1.0/denom_lj;
const int * const ilist = list->ilist;
const int * const numneigh = list->numneigh;
const int * const * const firstneigh = list->firstneigh;
const int nlocal = atom->nlocal;
// loop over neighbors of my atoms
for (int ii = iifrom; ii < iito; ++ii) {
const int i = ilist[ii];
const int itype = type[i];
const double qtmp = q[i];
const double xtmp = x[i].x;
const double ytmp = x[i].y;
const double ztmp = x[i].z;
double fxtmp,fytmp,fztmp;
fxtmp=fytmp=fztmp=0.0;
const int * const jlist = firstneigh[i];
const int jnum = numneigh[i];
const double * _noalias const lj1i = lj1[itype];
const double * _noalias const lj2i = lj2[itype];
const double * _noalias const lj3i = lj3[itype];
const double * _noalias const lj4i = lj4[itype];
for (int jj = 0; jj < jnum; jj++) {
double forcecoul, forcelj, evdwl, ecoul;
forcecoul = forcelj = evdwl = ecoul = 0.0;
const int sbindex = sbmask(jlist[jj]);
const int j = jlist[jj] & NEIGHMASK;
const double delx = xtmp - x[j].x;
const double dely = ytmp - x[j].y;
const double delz = ztmp - x[j].z;
const double rsq = delx*delx + dely*dely + delz*delz;
const int jtype = type[j];
if (rsq < cut_bothsq) {
const double r2inv = 1.0/rsq;
if (rsq < cut_coulsq) {
if (!ncoultablebits || rsq <= tabinnersq) {
const double A1 = 0.254829592;
const double A2 = -0.284496736;
const double A3 = 1.421413741;
const double A4 = -1.453152027;
const double A5 = 1.061405429;
const double EWALD_F = 1.12837917;
const double INV_EWALD_P = 1.0/0.3275911;
const double r = sqrt(rsq);
const double grij = g_ewald * r;
const double expm2 = exp(-grij*grij);
const double t = INV_EWALD_P / (INV_EWALD_P + grij);
const double erfc = t * (A1+t*(A2+t*(A3+t*(A4+t*A5)))) * expm2;
const double prefactor = qqrd2e * qtmp*q[j]/r;
forcecoul = prefactor * (erfc + EWALD_F*grij*expm2);
if (EFLAG) ecoul = prefactor*erfc;
if (sbindex) {
const double adjust = (1.0-special_coul[sbindex])*prefactor;
forcecoul -= adjust;
if (EFLAG) ecoul -= adjust;
}
} else {
union_int_float_t rsq_lookup;
rsq_lookup.f = rsq;
const int itable = (rsq_lookup.i & ncoulmask) >> ncoulshiftbits;
const double fraction = (rsq_lookup.f - rtable[itable]) * drtable[itable];
const double table = ftable[itable] + fraction*dftable[itable];
forcecoul = qtmp*q[j] * table;
if (EFLAG) ecoul = qtmp*q[j] * (etable[itable] + fraction*detable[itable]);
if (sbindex) {
const double table2 = ctable[itable] + fraction*dctable[itable];
const double prefactor = qtmp*q[j] * table2;
const double adjust = (1.0-special_coul[sbindex])*prefactor;
forcecoul -= adjust;
if (EFLAG) ecoul -= adjust;
}
}
}
if (rsq < cut_ljsq) {
const double r6inv = r2inv*r2inv*r2inv;
forcelj = r6inv * (lj1i[jtype]*r6inv - lj2i[jtype]);
const double philj = r6inv*(lj3i[jtype]*r6inv-lj4i[jtype]);
if (EFLAG) evdwl = philj;
if (rsq > cut_lj_innersq) {
const double drsq = cut_ljsq - rsq;
const double cut2 = (rsq - cut_lj_innersq) * drsq;
const double switch1 = drsq * (drsq*drsq + 3.0*cut2) * inv_denom_lj;
const double switch2 = 12.0*rsq * cut2 * inv_denom_lj;
forcelj = forcelj*switch1 + philj*switch2;
if (EFLAG) evdwl *= switch1;
}
if (sbindex) {
const double factor_lj = special_lj[sbindex];
forcelj *= factor_lj;
if (EFLAG) evdwl *= factor_lj;
}
}
const double fpair = (forcecoul + forcelj) * r2inv;
fxtmp += delx*fpair;
fytmp += dely*fpair;
fztmp += delz*fpair;
if (NEWTON_PAIR || j < nlocal) {
f[j].x -= delx*fpair;
f[j].y -= dely*fpair;
f[j].z -= delz*fpair;
}
if (EVFLAG) ev_tally_thr(this,i,j,nlocal,NEWTON_PAIR,
evdwl,ecoul,fpair,delx,dely,delz,thr);
}
}
f[i].x += fxtmp;
f[i].y += fytmp;
f[i].z += fztmp;
}
}
/* ---------------------------------------------------------------------- */
double PairLJCharmmCoulLongOMP::memory_usage()
{
double bytes = memory_usage_thr();
bytes += PairLJCharmmCoulLong::memory_usage();
return bytes;
}
| Java |
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>Backends</title>
<link rel="stylesheet" type="text/css" media="screen" href="../general/css/style.css" />
</head>
<body>
<h1>Backends</h1>
<h2>General Information</h2>
<p>The NagVis code is separated into several layers. One of these layers is
the "data layer". The data layer is used to handle requests for
information from third party sources like the socket of MKLivestatus. We
call this layer "backend" in general. There are some components
inside NagVis to manage these backends which act as the glue between the
single backends and the other layers.</p>
<h2>Default backend</h2>
<p>At the moment there are a few backends delivered with the NagVis core
packages: the most important ones are the mklivestatus and ndomy backends. All backend
configuration parameters are described in detail on their own pages.</p>
<p>The ndomy backend has been the default backend from NagVis 1.0 to NagVis 1.5.
It fetches Nagios information from the NDO MySQL database. Since NagVis 1.5
the default backend has been switched to MKLivestatus backend.</p>
<p>In NagVis 1.9, the pgsql backend has been added to fetch the Nagios information
from a PostgreSQL database as used by e.g. Icinga 2.</p>
<h2>Backend types</h2>
<ul>
<li><a href=backend_mklivestatus.html>MKLivestatus</a></li>
<li><a href=backend_ndomy.html>NDOMy</a></li>
<li><a href=backend_nagiosbp.html>NagiosBP</a></li>
<li><a href=backend_pgsql.html>PgSQL</a></li>
<li>MerlinMy</li>
</ul>
<h2>Configuring backends</h2>
<p>The backends are defined in the main configuration file. See
<a href="nagvis_config_format_description.html#backend">main configuration format description</a>
on how to define backends.</p>
</body>
</html>
| Java |
MyRaspberry-Utilities
====================
Bash Scripts for Raspberry 24/7
| Java |
/* $Id: memuserkernel-r0drv-darwin.cpp $ */
/** @file
* IPRT - User & Kernel Memory, Ring-0 Driver, Darwin.
*/
/*
* Copyright (C) 2009 Oracle Corporation
*
* This file is part of VirtualBox Open Source Edition (OSE), as
* available from http://www.virtualbox.org. This file is free software;
* you can redistribute it and/or modify it under the terms of the GNU
* General Public License (GPL) as published by the Free Software
* Foundation, in version 2 as it comes in the "COPYING" file of the
* VirtualBox OSE distribution. VirtualBox OSE is distributed in the
* hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
*
* The contents of this file may alternatively be used under the terms
* of the Common Development and Distribution License Version 1.0
* (CDDL) only, as it comes in the "COPYING.CDDL" file of the
* VirtualBox OSE distribution, in which case the provisions of the
* CDDL are applicable instead of those of the GPL.
*
* You may elect to license modified versions of this file under the
* terms and conditions of either the GPL or the CDDL or both.
*/
/*******************************************************************************
* Header Files *
*******************************************************************************/
#include "the-darwin-kernel.h"
#include "internal/iprt.h"
#include <iprt/mem.h>
#include <iprt/assert.h>
#if defined(RT_ARCH_AMD64) || defined(RT_ARCH_X86)
# include <iprt/asm-amd64-x86.h>
#endif
#include <iprt/err.h>
RTR0DECL(int) RTR0MemUserCopyFrom(void *pvDst, RTR3PTR R3PtrSrc, size_t cb)
{
RT_ASSERT_INTS_ON();
int rc = copyin((const user_addr_t)R3PtrSrc, pvDst, cb);
if (RT_LIKELY(rc == 0))
return VINF_SUCCESS;
return VERR_ACCESS_DENIED;
}
RTR0DECL(int) RTR0MemUserCopyTo(RTR3PTR R3PtrDst, void const *pvSrc, size_t cb)
{
RT_ASSERT_INTS_ON();
int rc = copyout(pvSrc, R3PtrDst, cb);
if (RT_LIKELY(rc == 0))
return VINF_SUCCESS;
return VERR_ACCESS_DENIED;
}
RTR0DECL(bool) RTR0MemUserIsValidAddr(RTR3PTR R3Ptr)
{
/* the commpage is above this. */
#ifdef RT_ARCH_X86
return R3Ptr < VM_MAX_ADDRESS;
#else
return R3Ptr < VM_MAX_PAGE_ADDRESS;
#endif
}
RTR0DECL(bool) RTR0MemKernelIsValidAddr(void *pv)
{
/* Found no public #define or symbol for checking this, so we'll
have to make do with thing found in the debugger and the sources. */
#ifdef RT_ARCH_X86
NOREF(pv);
return true; /* Almost anything is a valid kernel address here. */
#elif defined(RT_ARCH_AMD64)
return (uintptr_t)pv >= UINT64_C(0xffff800000000000);
#else
# error "PORTME"
#endif
}
RTR0DECL(bool) RTR0MemAreKrnlAndUsrDifferent(void)
{
/* As mentioned in RTR0MemKernelIsValidAddr, found no way of checking
this at compiler or runtime. */
#ifdef RT_ARCH_X86
return false;
#else
return true;
#endif
}
| Java |
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.18444
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace SteamShift.Properties
{
/// <summary>
/// A strongly-typed resource class, for looking up localized strings, etc.
/// </summary>
// This class was auto-generated by the StronglyTypedResourceBuilder
// class via a tool like ResGen or Visual Studio.
// To add or remove a member, edit your .ResX file then rerun ResGen
// with the /str option, or rebuild your VS project.
[global::System.CodeDom.Compiler.GeneratedCodeAttribute( "System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0" )]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
internal class Resources
{
private static global::System.Resources.ResourceManager resourceMan;
private static global::System.Globalization.CultureInfo resourceCulture;
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute( "Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode" )]
internal Resources()
{
}
/// <summary>
/// Returns the cached ResourceManager instance used by this class.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute( global::System.ComponentModel.EditorBrowsableState.Advanced )]
internal static global::System.Resources.ResourceManager ResourceManager
{
get
{
if ( ( resourceMan == null ) )
{
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager( "SteamShift.Properties.Resources", typeof( Resources ).Assembly );
resourceMan = temp;
}
return resourceMan;
}
}
/// <summary>
/// Overrides the current thread's CurrentUICulture property for all
/// resource lookups using this strongly typed resource class.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute( global::System.ComponentModel.EditorBrowsableState.Advanced )]
internal static global::System.Globalization.CultureInfo Culture
{
get
{
return resourceCulture;
}
set
{
resourceCulture = value;
}
}
}
}
| Java |
<div id="obligee_volumen" class="viz" data-viz="treemap-a" data-graph="treemap-a">
<div class="row">
<div class="col-sm-12">
<h3>Volumen de recursos de revisión, por sujeto obligado y por sentido de la resolución: <span class="year-range">2007 - 2015</span></h3>
<p class="lead">Recursos de revisión que se realizan por sujeto obligado, tanto de acceso a la información como de datos personales</p>
<!--<a href="#" class="download" download><b></b>Descargar datos</a>-->
</div>
<div class="col-sm-10 col-sm-offset-1">
<p class="instructions">Da clic sobre un sector para observar la distribución del número de solicitudes por sujeto obligado
y tipo de solicitud. Para regresar, da clic sobre el área gris en la parte superior de la gráfica.
</p>
</div>
</div>
<section id="treemap-a"></section>
<!--source-->
<div class="row">
<div class="col-sm-10 col-sm-offset-1">
<!--source-->
<?php include "templates/source.php";?>
<p class="lead info">Distribución de la gráfica</p>
<ul class="info row">
<li class="col-sm-3">Primer nivel: <strong>Sector</strong></li>
<li class="col-sm-3">Segundo nivel: <strong>Sujeto obligado</strong></li>
<li class="col-sm-3">Tercer nivel: <strong>Sentido de la resolución</strong>
</li>
<li class="col-sm-3">Tamaño: <strong>Número de solicitudes</strong></li>
</ul>
</div>
</div>
</div>
| Java |
#ifndef LAC_DIFFERENCE_NEIGHBOR_SET_H
#define LAC_DIFFERENCE_NEIGHBOR_SET_H 1
#include <utility>
#include <list>
#include <algorithm>
namespace LAC {
namespace Difference {
template<typename T>
struct NeighborSet {
typedef T data_t;
typedef std::list<T> queue_t;
typedef typename queue_t::iterator it_t;
typedef typename queue_t::const_iterator const_it_t;
NeighborSet(size_t count) : m_count(std::max((size_t)1,count)) {}
~NeighborSet(){}
void Append(const T& d){
it_t it = std::lower_bound(m_queue.begin(),
m_queue.end(),
d);
m_queue.insert(it, d);
if(m_queue.size() > m_count)
m_queue.pop_back();
}
const_it_t Begin() const { return m_queue.begin(); }
const_it_t End() const { return m_queue.end(); }
size_t m_count;
queue_t m_queue;
};
}
}
#endif
| Java |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.