answer
stringlengths 15
1.25M
|
|---|
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif /* HAVE_CONFIG_H */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <signal.h>
#include <sys/param.h>
#include <sys/uio.h>
#include <sys/time.h>
#include <sys/socket.h>
#include <sys/poll.h>
#include <errno.h>
#include <sys/wait.h>
#include <sys/resource.h>
#include <atalk/logger.h>
#include <atalk/adouble.h>
#include <atalk/compat.h>
#include <atalk/dsi.h>
#include <atalk/afp.h>
#include <atalk/paths.h>
#include <atalk/util.h>
#include <atalk/server_child.h>
#include <atalk/server_ipc.h>
#include <atalk/errchk.h>
#include <atalk/globals.h>
#include <atalk/netatalk_conf.h>
#include "afp_config.h"
#include "status.h"
#include "fork.h"
#include "uam_auth.h"
#include "afp_zeroconf.h"
#define AFP_LISTENERS 32
#define FDSET_SAFETY 5
unsigned char nologin = 0;
static AFPObj obj;
static server_child *server_children;
static sig_atomic_t reloadconfig = 0;
static sig_atomic_t gotsigchld = 0;
/* Two pointers to dynamic allocated arrays which store pollfds and associated data */
static struct pollfd *fdset;
static struct polldata *polldata;
static int fdset_size; /* current allocated size */
static int fdset_used; /* number of used elements */
static int disasociated_ipc_fd; /* disasociated sessions uses this fd for IPC */
static afp_child_t *dsi_start(AFPObj *obj, DSI *dsi, server_child *server_children);
static void afp_exit(int ret)
{
exit(ret);
}
static void <API key>(const AFPObj *config)
{
DSI *dsi;
for (dsi = config->dsi; dsi; dsi = dsi->next) {
fdset_add_fd(config->options.connections + AFP_LISTENERS + FDSET_SAFETY,
&fdset,
&polldata,
&fdset_used,
&fdset_size,
dsi->serversock,
LISTEN_FD,
dsi);
}
if (config->options.flags & OPTION_KEEPSESSIONS)
fdset_add_fd(config->options.connections + AFP_LISTENERS + FDSET_SAFETY,
&fdset,
&polldata,
&fdset_used,
&fdset_size,
disasociated_ipc_fd,
DISASOCIATED_IPC_FD,
NULL);
}
static void <API key>(const AFPObj *config)
{
const DSI *dsi;
for (dsi = config->dsi; dsi; dsi = dsi->next) {
fdset_del_fd(&fdset, &polldata, &fdset_used, &fdset_size, dsi->serversock);
}
if (config->options.flags & OPTION_KEEPSESSIONS)
fdset_del_fd(&fdset, &polldata, &fdset_used, &fdset_size, disasociated_ipc_fd);
}
static void afp_goaway(int sig)
{
switch( sig ) {
case SIGTERM:
case SIGQUIT:
switch (sig) {
case SIGTERM:
LOG(log_note, logtype_afpd, "AFP Server shutting down on SIGTERM");
break;
case SIGQUIT:
if (obj.options.flags & OPTION_KEEPSESSIONS) {
LOG(log_note, logtype_afpd, "AFP Server shutting down on SIGQUIT, NOT disconnecting clients");
} else {
LOG(log_note, logtype_afpd, "AFP Server shutting down on SIGQUIT");
sig = SIGTERM;
}
break;
}
if (server_children)
server_child_kill(server_children, CHILD_DSIFORK, sig);
_exit(0);
break;
case SIGUSR1 :
nologin++;
auth_unload();
LOG(log_info, logtype_afpd, "disallowing logins");
if (server_children)
server_child_kill(server_children, CHILD_DSIFORK, sig);
break;
case SIGHUP :
/* w/ a configuration file, we can force a re-read if we want */
reloadconfig = 1;
break;
case SIGCHLD:
/* w/ a configuration file, we can force a re-read if we want */
gotsigchld = 1;
break;
default :
LOG(log_error, logtype_afpd, "afp_goaway: bad signal" );
}
return;
}
static void child_handler(void)
{
int fd;
int status, i;
pid_t pid;
#ifndef WAIT_ANY
#define WAIT_ANY (-1)
#endif /* ! WAIT_ANY */
while ((pid = waitpid(WAIT_ANY, &status, WNOHANG)) > 0) {
for (i = 0; i < server_children->nforks; i++) {
if ((fd = server_child_remove(server_children, i, pid)) != -1) {
fdset_del_fd(&fdset, &polldata, &fdset_used, &fdset_size, fd);
break;
}
}
if (WIFEXITED(status)) {
if (WEXITSTATUS(status))
LOG(log_info, logtype_afpd, "child[%d]: exited %d", pid, WEXITSTATUS(status));
else
LOG(log_info, logtype_afpd, "child[%d]: done", pid);
} else {
if (WIFSIGNALED(status))
LOG(log_info, logtype_afpd, "child[%d]: killed by signal %d", pid, WTERMSIG(status));
else
LOG(log_info, logtype_afpd, "child[%d]: died", pid);
}
}
}
static int setlimits(void)
{
struct rlimit rlim;
if (getrlimit(RLIMIT_NOFILE, &rlim) != 0) {
LOG(log_warning, logtype_afpd, "setlimits: reading current limits failed: %s", strerror(errno));
return -1;
}
if (rlim.rlim_cur != RLIM_INFINITY && rlim.rlim_cur < 65535) {
rlim.rlim_cur = 65535;
if (rlim.rlim_max != RLIM_INFINITY && rlim.rlim_max < 65535)
rlim.rlim_max = 65535;
if (setrlimit(RLIMIT_NOFILE, &rlim) != 0) {
LOG(log_warning, logtype_afpd, "setlimits: increasing limits failed: %s", strerror(errno));
return -1;
}
}
return 0;
}
int main(int ac, char **av)
{
fd_set rfds;
void *ipc;
struct sigaction sv;
sigset_t sigs;
int ret;
/* Parse argv args and initialize default options */
<API key>(&obj, ac, av);
if (!(obj.cmdlineflags & OPTION_DEBUG) && (daemonize(0, 0) != 0))
exit(EXITERR_SYS);
/* Log SIGBUS/SIGSEGV SBT */
fault_setup(NULL);
if (afp_config_parse(&obj, "afpd") != 0)
afp_exit(EXITERR_CONF);
/* Save the user's current umask */
obj.options.save_mask = umask(obj.options.umask);
/* install child handler for asp and dsi. we do this before afp_goaway
* as afp_goaway references stuff from here.
* XXX: this should really be setup after the initial connections. */
if (!(server_children = server_child_alloc(obj.options.connections, CHILD_NFORKS))) {
LOG(log_error, logtype_afpd, "main: server_child alloc: %s", strerror(errno) );
afp_exit(EXITERR_SYS);
}
sigemptyset(&sigs);
pthread_sigmask(SIG_SETMASK, &sigs, NULL);
memset(&sv, 0, sizeof(sv));
/* linux at least up to 2.4.22 send a SIGXFZ for vfat fs,
even if the file is open with O_LARGEFILE ! */
#ifdef SIGXFSZ
sv.sa_handler = SIG_IGN;
sigemptyset( &sv.sa_mask );
if (sigaction(SIGXFSZ, &sv, NULL ) < 0 ) {
LOG(log_error, logtype_afpd, "main: sigaction: %s", strerror(errno) );
afp_exit(EXITERR_SYS);
}
#endif
sv.sa_handler = afp_goaway; /* handler for all sigs */
sigemptyset( &sv.sa_mask );
sigaddset(&sv.sa_mask, SIGALRM);
sigaddset(&sv.sa_mask, SIGHUP);
sigaddset(&sv.sa_mask, SIGTERM);
sigaddset(&sv.sa_mask, SIGUSR1);
sigaddset(&sv.sa_mask, SIGQUIT);
sv.sa_flags = SA_RESTART;
if ( sigaction( SIGCHLD, &sv, NULL ) < 0 ) {
LOG(log_error, logtype_afpd, "main: sigaction: %s", strerror(errno) );
afp_exit(EXITERR_SYS);
}
sigemptyset( &sv.sa_mask );
sigaddset(&sv.sa_mask, SIGALRM);
sigaddset(&sv.sa_mask, SIGTERM);
sigaddset(&sv.sa_mask, SIGHUP);
sigaddset(&sv.sa_mask, SIGCHLD);
sigaddset(&sv.sa_mask, SIGQUIT);
sv.sa_flags = SA_RESTART;
if ( sigaction( SIGUSR1, &sv, NULL ) < 0 ) {
LOG(log_error, logtype_afpd, "main: sigaction: %s", strerror(errno) );
afp_exit(EXITERR_SYS);
}
sigemptyset( &sv.sa_mask );
sigaddset(&sv.sa_mask, SIGALRM);
sigaddset(&sv.sa_mask, SIGTERM);
sigaddset(&sv.sa_mask, SIGUSR1);
sigaddset(&sv.sa_mask, SIGCHLD);
sigaddset(&sv.sa_mask, SIGQUIT);
sv.sa_flags = SA_RESTART;
if ( sigaction( SIGHUP, &sv, NULL ) < 0 ) {
LOG(log_error, logtype_afpd, "main: sigaction: %s", strerror(errno) );
afp_exit(EXITERR_SYS);
}
sigemptyset( &sv.sa_mask );
sigaddset(&sv.sa_mask, SIGALRM);
sigaddset(&sv.sa_mask, SIGHUP);
sigaddset(&sv.sa_mask, SIGUSR1);
sigaddset(&sv.sa_mask, SIGCHLD);
sigaddset(&sv.sa_mask, SIGQUIT);
sv.sa_flags = SA_RESTART;
if ( sigaction( SIGTERM, &sv, NULL ) < 0 ) {
LOG(log_error, logtype_afpd, "main: sigaction: %s", strerror(errno) );
afp_exit(EXITERR_SYS);
}
sigemptyset( &sv.sa_mask );
sigaddset(&sv.sa_mask, SIGALRM);
sigaddset(&sv.sa_mask, SIGHUP);
sigaddset(&sv.sa_mask, SIGUSR1);
sigaddset(&sv.sa_mask, SIGCHLD);
sigaddset(&sv.sa_mask, SIGTERM);
sv.sa_flags = SA_RESTART;
if (sigaction(SIGQUIT, &sv, NULL ) < 0 ) {
LOG(log_error, logtype_afpd, "main: sigaction: %s", strerror(errno) );
afp_exit(EXITERR_SYS);
}
/* afp.conf: not in config file: lockfile, configfile
* preference: command-line provides defaults.
* config file over-writes defaults.
*
* we also need to make sure that killing afpd during startup
* won't leave any lingering registered names around.
*/
sigemptyset(&sigs);
sigaddset(&sigs, SIGALRM);
sigaddset(&sigs, SIGHUP);
sigaddset(&sigs, SIGUSR1);
#if 0
/* don't block SIGTERM */
sigaddset(&sigs, SIGTERM);
#endif
sigaddset(&sigs, SIGCHLD);
pthread_sigmask(SIG_BLOCK, &sigs, NULL);
if (configinit(&obj) != 0) {
LOG(log_error, logtype_afpd, "main: no servers configured");
afp_exit(EXITERR_CONF);
}
pthread_sigmask(SIG_UNBLOCK, &sigs, NULL);
/* Initialize */
cnid_init();
/* watch atp, dsi sockets and ipc parent/child file descriptor. */
if (obj.options.flags & OPTION_KEEPSESSIONS) {
LOG(log_note, logtype_afpd, "Activating continous service");
disasociated_ipc_fd = ipc_server_uds(_PATH_AFP_IPC);
}
<API key>(&obj);
/* set limits */
(void)setlimits();
afp_child_t *child;
int recon_ipc_fd;
pid_t pid;
int saveerrno;
/* wait for an appleshare connection. parent remains in the loop
* while the children get handled by afp_over_{asp,dsi}. this is
* currently vulnerable to a denial-of-service attack if a
* connection is made without an actual login attempt being made
* afterwards. establishing timeouts for logins is a possible
* solution. */
while (1) {
LOG(log_maxdebug, logtype_afpd, "main: polling %i fds", fdset_used);
pthread_sigmask(SIG_UNBLOCK, &sigs, NULL);
ret = poll(fdset, fdset_used, -1);
pthread_sigmask(SIG_BLOCK, &sigs, NULL);
saveerrno = errno;
if (gotsigchld) {
gotsigchld = 0;
child_handler();
continue;
}
if (reloadconfig) {
nologin++;
auth_unload();
<API key>(&obj);
LOG(log_info, logtype_afpd, "re-reading configuration file");
configfree(&obj, NULL);
if (configinit(&obj) != 0) {
LOG(log_error, logtype_afpd, "config re-read: no servers configured");
afp_exit(EXITERR_CONF);
}
<API key>(&obj);
nologin = 0;
reloadconfig = 0;
errno = saveerrno;
continue;
}
if (ret == 0)
continue;
if (ret < 0) {
if (errno == EINTR)
continue;
LOG(log_error, logtype_afpd, "main: can't wait for input: %s", strerror(errno));
break;
}
for (int i = 0; i < fdset_used; i++) {
if (fdset[i].revents & (POLLIN | POLLERR | POLLHUP | POLLNVAL)) {
switch (polldata[i].fdtype) {
case LISTEN_FD:
if (child = dsi_start(&obj, (DSI *)polldata[i].data, server_children)) {
/* Add IPC fd to select fd set */
fdset_add_fd(obj.options.connections + AFP_LISTENERS + FDSET_SAFETY,
&fdset,
&polldata,
&fdset_used,
&fdset_size,
child->ipc_fd,
IPC_FD,
child);
}
break;
case IPC_FD:
child = (afp_child_t *)polldata[i].data;
LOG(log_debug, logtype_afpd, "main: IPC request from child[%u]", child->pid);
if (ipc_server_read(server_children, child->ipc_fd) != 0) {
fdset_del_fd(&fdset, &polldata, &fdset_used, &fdset_size, child->ipc_fd);
close(child->ipc_fd);
child->ipc_fd = -1;
if ((obj.options.flags & OPTION_KEEPSESSIONS) && child->disasociated) {
LOG(log_note, logtype_afpd, "main: removing reattached child[%u]", child->pid);
server_child_remove(server_children, CHILD_DSIFORK, child->pid);
}
}
break;
case DISASOCIATED_IPC_FD:
LOG(log_debug, logtype_afpd, "main: IPC reconnect request");
if ((recon_ipc_fd = accept(disasociated_ipc_fd, NULL, NULL)) == -1) {
LOG(log_error, logtype_afpd, "main: accept: %s", strerror(errno));
break;
}
if (readt(recon_ipc_fd, &pid, sizeof(pid_t), 0, 1) != sizeof(pid_t)) {
LOG(log_error, logtype_afpd, "main: readt: %s", strerror(errno));
close(recon_ipc_fd);
break;
}
LOG(log_note, logtype_afpd, "main: IPC reconnect from pid [%u]", pid);
if ((child = server_child_add(server_children, CHILD_DSIFORK, pid, recon_ipc_fd)) == NULL) {
LOG(log_error, logtype_afpd, "main: server_child_add");
close(recon_ipc_fd);
break;
}
child->disasociated = 1;
fdset_add_fd(obj.options.connections + AFP_LISTENERS + FDSET_SAFETY,
&fdset,
&polldata,
&fdset_used,
&fdset_size,
recon_ipc_fd,
IPC_FD,
child);
break;
default:
LOG(log_debug, logtype_afpd, "main: IPC request for unknown type");
break;
} /* switch */
}
} /* for (i)*/
} /* while (1) */
return 0;
}
static afp_child_t *dsi_start(AFPObj *obj, DSI *dsi, server_child *server_children)
{
afp_child_t *child = NULL;
if (dsi_getsession(dsi, server_children, obj->options.tickleval, &child) != 0) {
LOG(log_error, logtype_afpd, "dsi_start: session error: %s", strerror(errno));
return NULL;
}
/* we've forked. */
if (child == NULL) {
configfree(obj, dsi);
afp_over_dsi(obj); /* start a session */
exit (0);
}
return child;
}
|
var express = require('express');
var path = require('path');
var tilestrata = require('tilestrata');
var disk = require('tilestrata-disk');
var mapnik = require('tilestrata-mapnik');
var dependency = require('<API key>');
var strata = tilestrata();
var app = express();
// define layers
strata.layer('hillshade')
.route('shade.png')
.use(disk.cache({dir: './tiles/shade/'}))
.use(mapnik({
pathname: './styles/hillshade.xml',
tileSize: 256,
scale: 1
}));
strata.layer('dem')
.route('dem.png')
.use(disk.cache({dir: './tiles/dem/'}))
.use(mapnik({
pathname: './styles/dem.xml',
tileSize: 256,
scale: 1
}));
strata.layer('sim1')
.route('sim1.png')
.use(disk.cache({dir: './tiles/sim1/'}))
.use(mapnik({
pathname: './styles/sim1.xml',
tileSize: 256,
scale: 1
}));
strata.layer('sim2')
.route('sim2.png')
.use(disk.cache({dir: './tiles/sim2/'}))
.use(mapnik({
pathname: './styles/sim2.xml',
tileSize: 256,
scale: 1
}));
strata.layer('sim3')
.route('sim3.png')
.use(disk.cache({dir: './tiles/sim3/'}))
.use(mapnik({
pathname: './styles/sim3.xml',
tileSize: 256,
scale: 1
}));
strata.layer('slope')
.route('slope.png')
.use(disk.cache({dir: './tiles/slope/'}))
.use(mapnik({
pathname: './styles/slope.xml',
tileSize: 256,
scale: 1
}));
var staticPath = path.resolve(__dirname, './public/');
app.use(express.static(staticPath));
app.use(tilestrata.middleware({
server: strata,
prefix: ''
}));
app.listen(8080, function() {
console.log('Express server running on port 8080.');
});
|
#include "platform/OSXUchrKeyResource.h"
#include <Carbon/Carbon.h>
// OSXUchrKeyResource
OSXUchrKeyResource::OSXUchrKeyResource(const void* resource,
UInt32 keyboardType) :
m_m(NULL),
m_cti(NULL),
m_sdi(NULL),
m_sri(NULL),
m_st(NULL)
{
m_resource = reinterpret_cast<const UCKeyboardLayout*>(resource);
if (m_resource == NULL) {
return;
}
// find the keyboard info for the current keyboard type
const <API key>* th = NULL;
const UCKeyboardLayout* r = m_resource;
for (ItemCount i = 0; i < r->keyboardTypeCount; ++i) {
if (keyboardType >= r->keyboardTypeList[i].keyboardTypeFirst &&
keyboardType <= r->keyboardTypeList[i].keyboardTypeLast) {
th = r->keyboardTypeList + i;
break;
}
if (r->keyboardTypeList[i].keyboardTypeFirst == 0) {
// found the default. use it unless we find a match.
th = r->keyboardTypeList + i;
}
}
if (th == NULL) {
// cannot find a suitable keyboard type
return;
}
// get tables for keyboard type
const UInt8* base = reinterpret_cast<const UInt8*>(m_resource);
m_m = reinterpret_cast<const <API key>*>(base +
th-><API key>);
m_cti = reinterpret_cast<const <API key>*>(base +
th-><API key>);
m_sdi = reinterpret_cast<const <API key>*>(base +
th-><API key>);
if (th-><API key> != 0) {
m_sri = reinterpret_cast<const <API key>*>(base +
th-><API key>);
}
if (th-><API key> != 0) {
m_st = reinterpret_cast<const <API key>*>(base +
th-><API key>);
}
// find the space key, but only if it can combine with dead keys.
// a dead key followed by a space yields the non-dead version of
// the dead key.
m_spaceOutput = 0xffffu;
UInt32 table = getTableForModifier(0);
for (UInt32 button = 0, n = getNumButtons(); button < n; ++button) {
KeyID id = getKey(table, button);
if (id == 0x20) {
UCKeyOutput c =
reinterpret_cast<const UCKeyOutput*>(base +
m_cti-><API key>[table])[button];
if ((c & <API key>) ==
<API key>) {
m_spaceOutput = (c & <API key>);
break;
}
}
}
}
bool
OSXUchrKeyResource::isValid() const
{
return (m_m != NULL);
}
UInt32
OSXUchrKeyResource::<API key>() const
{
// only 32 (not 256) because the righthanded modifier bits are ignored
return 32;
}
UInt32
OSXUchrKeyResource::getNumTables() const
{
return m_cti->keyToCharTableCount;
}
UInt32
OSXUchrKeyResource::getNumButtons() const
{
return m_cti->keyToCharTableSize;
}
UInt32
OSXUchrKeyResource::getTableForModifier(UInt32 mask) const
{
if (mask >= m_m->modifiersCount) {
return m_m->defaultTableNum;
}
else {
return m_m->tableNum[mask];
}
}
KeyID
OSXUchrKeyResource::getKey(UInt32 table, UInt32 button) const
{
assert(table < getNumTables());
assert(button < getNumButtons());
const UInt8* base = reinterpret_cast<const UInt8*>(m_resource);
const UCKeyOutput* cPtr = reinterpret_cast<const UCKeyOutput*>(base +
m_cti-><API key>[table]);
const UCKeyOutput c = cPtr[button];
KeySequence keys;
switch (c & <API key>) {
case <API key>:
if (!getDeadKey(keys, c & <API key>)) {
return kKeyNone;
}
break;
case <API key>:
default:
if (!addSequence(keys, c)) {
return kKeyNone;
}
break;
}
// XXX -- no support for multiple characters
if (keys.size() != 1) {
return kKeyNone;
}
return keys.front();
}
bool
OSXUchrKeyResource::getDeadKey(
KeySequence& keys, UInt16 index) const
{
if (m_sri == NULL || index >= m_sri->keyStateRecordCount) {
// XXX -- should we be using some other fallback?
return false;
}
UInt16 state = 0;
if (!getKeyRecord(keys, index, state)) {
return false;
}
if (state == 0) {
// not a dead key
return true;
}
// no dead keys if we couldn't find the space key
if (m_spaceOutput == 0xffffu) {
return false;
}
// the dead key should not have put anything in the key list
if (!keys.empty()) {
return false;
}
// get the character generated by pressing the space key after the
// dead key. if we're still in a compose state afterwards then we're
// confused so we bail.
if (!getKeyRecord(keys, m_spaceOutput, state) || state != 0) {
return false;
}
// convert keys to their dead counterparts
for (KeySequence::iterator i = keys.begin(); i != keys.end(); ++i) {
*i = synergy::KeyMap::getDeadKey(*i);
}
return true;
}
bool
OSXUchrKeyResource::getKeyRecord(
KeySequence& keys, UInt16 index, UInt16& state) const
{
const UInt8* base = reinterpret_cast<const UInt8*>(m_resource);
const UCKeyStateRecord* sr =
reinterpret_cast<const UCKeyStateRecord*>(base +
m_sri-><API key>[index]);
const <API key>* kset =
reinterpret_cast<const <API key>*>(sr->stateEntryData);
UInt16 nextState = 0;
bool found = false;
if (state == 0) {
found = true;
nextState = sr->stateZeroNextState;
if (!addSequence(keys, sr->stateZeroCharData)) {
return false;
}
}
else {
// we have a next entry
switch (sr->stateEntryFormat) {
case <API key>:
for (UInt16 j = 0; j < sr->stateEntryCount; ++j) {
if (kset[j].curState == state) {
if (!addSequence(keys, kset[j].charData)) {
return false;
}
nextState = 0;
found = true;
break;
}
}
break;
case <API key>:
// XXX -- not supported yet
break;
default:
// XXX -- unknown format
return false;
}
}
if (!found) {
// use a terminator
if (m_st != NULL && state < m_st-><API key>) {
if (!addSequence(keys, m_st->keyStateTerminators[state - 1])) {
return false;
}
}
nextState = sr->stateZeroNextState;
if (!addSequence(keys, sr->stateZeroCharData)) {
return false;
}
}
// next
state = nextState;
return true;
}
bool
OSXUchrKeyResource::addSequence(
KeySequence& keys, UCKeyCharSeq c) const
{
if ((c & <API key>) == <API key>) {
UInt16 index = (c & <API key>);
if (index < m_sdi->charSequenceCount &&
m_sdi->charSequenceOffsets[index] !=
m_sdi->charSequenceOffsets[index + 1]) {
// XXX -- sequences not supported yet
return false;
}
}
if (c != 0xfffe && c != 0xffff) {
KeyID id = unicharToKeyID(c);
if (id != kKeyNone) {
keys.push_back(id);
}
}
return true;
}
|
<?php
include_once "srcPHP/View/View.php";
include_once "srcPHP/Model/ResearchModel.php";
class Mosaic implements View{
var $model = NULL;
var $array = NULL;
function Mosaic(){
$this->model = new ResearchModel("dbserver", "xjouveno", "xjouveno", "pdp");
$this->array = $this->model->getAllVideo();
}
function linkCSS(){ echo "<link rel=\"stylesheet\" type=\"text/css\" href=\"css/mosaic.css\">"; }
function linkJS(){ }
function onLoadJS(){ }
function draw(){
echo "<section>";
echo "<ul class=\"patients\">";
echo $tmp = NULL;
for($i=0; $i<count($this->array); $i++){
// Patient suivant
if($tmp != $this->array[$i]["IdPatient"]){
$tmp = $this->array[$i]["IdPatient"];
if($i != 0){
echo "</ul>";
echo "</li>";
}
echo "<li>";
echo "<h3>".$this->array[$i]["Name"]." - ".$this->array[$i]["IdPatient"]."</h3>";
echo "<ul>";
}
//Video Suivante
echo "<li>";
echo "<span>";
// echo "<a href=\"index.php?play=".$this->array[$i]["IdVideo"]."\" ><img src=\"modules/jQuery-File-Upload/server/php/files/video_thumbnails/video.png\" /></a>";
echo "<a href=\"index.php?play=".$this->array[$i]["IdVideo"]."\" ><img src=\"modules/jQuery-File-Upload/server/php/files/video_thumbnails/".$this->array[$i]["IdVideo"].".jpg\" /></a>";
echo "<label>".$this->array[$i]["Title"]."</label>";
echo "</span>";
echo "</li>";
}
echo "</ul>";
echo "</section>";
}
}
?>
|
<?php
/**
* Description of Resume
*
* @author greg
* @package
*/
class <API key> extends <API key>
{
protected $_custom = "wpjb_form_resume";
protected $_key = "resume";
protected $_model = "Wpjb_Model_Resume";
public function _exclude()
{
if($this->_object->getId()) {
return array("id" => $this->_object->getId());
} else {
return array();
}
}
public function init()
{
$this->_upload = array(
"path" => wpjb_upload_dir("{object}", "{field}", "{id}", "basedir"),
"object" => "resume",
"field" => null,
"id" => wpjb_upload_id($this->getId())
);
$this->addGroup("_internal", "");
$this->addGroup("default", __("Account Information", "wpjobboard"));
$this->addGroup("location", __("Address", "wpjobboard"));
$this->addGroup("resume", __("Resume", "wpjobboard"));
$this->addGroup("experience", __("Experience", "wpjobboard"));
$this->addGroup("education", __("Education", "wpjobboard"));
$this->_group["experience"]->setAlwaysVisible(true);
$this->_group["education"]->setAlwaysVisible(true);
$user = new WP_User($this->getObject()->user_id);
$e = $this->create("first_name");
$e->setLabel(__("First Name", "wpjobboard"));
$e->setRequired(true);
$e->setValue($user->first_name);
$this->addElement($e, "default");
$e = $this->create("last_name");
$e->setLabel(__("Last Name", "wpjobboard"));
$e->setRequired(true);
$e->setValue($user->last_name);
$this->addElement($e, "default");
$def = wpjb_locale();
$e = $this->create("candidate_country", "select");
$e->setLabel(__("Country", "wpjobboard"));
$e->setValue(($this->_object->candidate_country) ? $this->_object->candidate_country : $def);
$e->addOptions(<API key>());
$e->addClass("<API key>");
$this->addElement($e, "location");
$e = $this->create("candidate_state");
$e->setLabel(__("State", "wpjobboard"));
$e->setValue($this->_object->candidate_state);
$e->addClass("wpjb-location-state");
$this->addElement($e, "location");
$e = $this->create("candidate_zip_code");
$e->setLabel(__("Zip-Code", "wpjobboard"));
$e->addValidator(new <API key>(null, 20));
$e->setValue($this->_object->candidate_zip_code);
$this->addElement($e, "location");
$e = $this->create("candidate_location");
$e->setValue($this->_object->candidate_location);
$e->setRequired(true);
$e->setLabel(__("City", "wpjobboard"));
$e->setHint(__('For example: "Chicago", "London", "Anywhere" or "Telecommute".', "wpjobboard"));
$e->addValidator(new <API key>(null, 120));
$e->addClass("wpjb-location-city");
$this->addElement($e, "location");
$e = $this->create("user_email");
$e->setRequired(true);
$e->setLabel(__("Email Address", "wpjobboard"));
$e->setHint(__('This field will be shown only to registered employers.', "wpjobboard"));
$e->addValidator(new Daq_Validate_Email(array("exclude"=>$user->ID)));
$e->setValue($user->user_email);
$this->addElement($e, "default");
$e = $this->create("phone");
$e->setLabel(__("Phone Number", "wpjobboard"));
$e->setHint(__('This field will be shown only to registered employers.', "wpjobboard"));
$e->setValue($this->_object->phone);
$this->addElement($e, "default");
$e = $this->create("user_url");
$e->setLabel(__("Website", "wpjobboard"));
$e->setHint(__('This field will be shown only to registered employers.', "wpjobboard"));
$e->addFilter(new Daq_Filter_WP_Url());
$e->addValidator(new Daq_Validate_Url());
$e->setValue($user->user_url);
$this->addElement($e, "default");
$e = $this->create("is_public", "checkbox");
$e->setLabel(__("Privacy", "wpjobboard"));
$e->addOption(1, 1, __("Show my resume in search results.", "wpjobboard"));
$e->setValue($this->_object->is_public);
$e->addFilter(new Daq_Filter_Int());
$this->addElement($e, "default");
$e = $this->create("is_active", "checkbox");
$e->setValue($this->_object->is_active);
$e->setLabel(__("Status", "wpjobboard"));
$e->addOption(1, 1, __("Resume is approved.", "wpjobboard"));
$this->addElement($e, "_internal");
$e = $this->create("modified_at", "text_date");
$e->setDateFormat(wpjb_date_format());
$e->setValue($this->ifNew(date("Y-m-d"), $this->_object->modified_at));
$this->addElement($e, "_internal");
$e = $this->create("created_at", "text_date");
$e->setDateFormat(wpjb_date_format());
$e->setValue($this->ifNew(date("Y-m-d"), $this->_object->created_at));
$this->addElement($e, "_internal");
$e = $this->create("image", "file");
$e->setLabel(__("Your Photo", "wpjobboard"));;
$e->addValidator(new <API key>());
$e->addValidator(new <API key>("jpg,jpeg,gif,png"));
$e->addValidator(new <API key>(300000));
$e->setUploadPath($this->_upload);
$e->setRenderer("<API key>");
$this->addElement($e, "default");
$e = $this->create("category", "select");
$e->setLabel(__("Category", "wpjobboard"));
$e->setValue($this->_object->getTagIds("category"));
$e->addOptions(<API key>());
$this->addElement($e, "resume");
$this->addTag($e);
$e = $this->create("headline");
$e->setLabel(__("Professional Headline", "wpjobboard"));
$e->setHint(__("Describe yourself in few words, for example: Experienced Web Developer", "wpjobboard"));
$e->addValidator(new <API key>(1, 120));
$e->setValue($this->_object->headline);
$this->addElement($e, "resume");
$e = $this->create("description", "textarea");
$e->setLabel(__("Profile Summary", "wpjobboard"));
$e->setHint(__("Use this field to list your skills, specialities, experience or goals", "wpjobboard"));
$e->setValue($this->_object->description);
$e->setEditor(<API key>::EDITOR_TINY);
$this->addElement($e, "resume");
}
public function save($append = array())
{
parent::save($append);
$user = $this->getObject()->getUser(true);
$names = array_merge($user->getFieldNames(), array("first_name", "last_name"));
$userdata = array("ID"=>$user->ID);
$user = new WP_User($this->getObject(true)->ID);
$update = false;
foreach($names as $key) {
if($this->hasElement($key) && !in_array($key, array("user_login", "user_pass"))) {
$userdata[$key] = $this->value($key);
$update = true;
}
}
if($update) {
wp_update_user($userdata);
}
$temp = wpjb_upload_dir("resume", "", null, "basedir");
$finl = dirname($temp)."/".$this->getId();
wpjb_rename_dir($temp, $finl);
}
public function dump()
{
$dump = parent::dump();
$count = count($dump);
for($i=0; $i<$count; $i++) {
if(in_array($dump[$i]->name, array("experience", "education"))) {
$dump[$i]->editable = false;
}
}
return $dump;
}
}
?>
|
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "utility.hh"
#include "packetcache.hh"
#include "logger.hh"
#include "arguments.hh"
#include "statbag.hh"
#include <map>
#include <boost/algorithm/string.hpp>
extern StatBag S;
PacketCache::PacketCache()
{
d_ops=0;
d_maps.resize(1024);
for(auto& mc : d_maps) {
pthread_rwlock_init(&mc.d_mut, 0);
}
d_ttl=-1;
d_recursivettl=-1;
S.declare("packetcache-hit");
S.declare("packetcache-miss");
S.declare("packetcache-size");
d_statnumhit=S.getPointer("packetcache-hit");
d_statnummiss=S.getPointer("packetcache-miss");
d_statnumentries=S.getPointer("packetcache-size");
d_doRecursion=false;
}
PacketCache::~PacketCache()
{
// WriteLock l(&d_mut);
vector<WriteLock*> locks;
for(auto& mc : d_maps) {
locks.push_back(new WriteLock(&mc.d_mut));
}
for(auto wl : locks) {
delete wl;
}
}
int PacketCache::get(DNSPacket *p, DNSPacket *cached, bool recursive)
{
extern StatBag S;
if(d_ttl<0)
getTTLS();
cleanupIfNeeded();
if(d_doRecursion && p->d.rd) { // wants recursion
if(!d_recursivettl) {
(*d_statnummiss)++;
return 0;
}
}
else { // does not
if(!d_ttl) {
(*d_statnummiss)++;
return 0;
}
}
if(ntohs(p->d.qdcount)!=1) // we get confused by packets with more than one question
return 0;
unsigned int age=0;
string value;
bool haveSomething;
{
auto& mc=getMap(p->qdomain);
TryReadLock l(&mc.d_mut); // take a readlock here
if(!l.gotIt()) {
S.inc("<API key>");
return 0;
}
uint16_t maxReplyLen = p->d_tcp ? 0xffff : p->getMaxReplyLen();
haveSomething=getEntryLocked(p->qdomain, p->qtype, PacketCache::PACKETCACHE, value, -1, recursive, maxReplyLen, p->d_dnssecOk, p->hasEDNS(), &age);
}
if(haveSomething) {
(*d_statnumhit)++;
if (recursive)
ageDNSPacket(value, age);
if(cached->noparse(value.c_str(), value.size()) < 0)
return 0;
cached->spoofQuestion(p); // for correct case
cached->qdomain=p->qdomain;
cached->qtype=p->qtype;
return 1;
}
// cerr<<"Packet cache miss for '"<<p->qdomain<<"', merits: "<<<API key><<endl;
(*d_statnummiss)++;
return 0; // bummer
}
void PacketCache::getTTLS()
{
d_ttl=::arg().asNum("cache-ttl");
d_recursivettl=::arg().asNum("recursive-cache-ttl");
d_doRecursion=::arg().mustDo("recursor");
}
void PacketCache::insert(DNSPacket *q, DNSPacket *r, bool recursive, unsigned int maxttl)
{
if(d_ttl < 0)
getTTLS();
if(ntohs(q->d.qdcount)!=1) {
return; // do not try to cache packets with multiple questions
}
if(q->qclass != QClass::IN) // we only cache the INternet
return;
uint16_t maxReplyLen = q->d_tcp ? 0xffff : q->getMaxReplyLen();
unsigned int ourttl = recursive ? d_recursivettl : d_ttl;
if(!recursive) {
if(maxttl<ourttl)
ourttl=maxttl;
} else {
unsigned int minttl = r->getMinTTL();
if(minttl<ourttl)
ourttl=minttl;
}
insert(q->qdomain, q->qtype, PacketCache::PACKETCACHE, r->getString(), ourttl, -1, recursive,
maxReplyLen, q->d_dnssecOk, q->hasEDNS());
}
// universal key appears to be: qname, qtype, kind (packet, query cache), optionally zoneid, meritsRecursion
void PacketCache::insert(const DNSName &qname, const QType& qtype, CacheEntryType cet, const string& value, unsigned int ttl, int zoneID,
bool meritsRecursion, unsigned int maxReplyLen, bool dnssecOk, bool EDNS)
{
cleanupIfNeeded();
if(!ttl)
return;
//cerr<<"Inserting qname '"<<qname<<"', cet: "<<(int)cet<<", qtype: "<<qtype.getName()<<", ttl: "<<ttl<<", maxreplylen: "<<maxReplyLen<<", hasEDNS: "<<EDNS<<endl;
CacheEntry val;
val.created=time(0);
val.ttd=val.created+ttl;
val.qname=qname;
val.qtype=qtype.getCode();
val.value=value;
val.ctype=cet;
val.meritsRecursion=meritsRecursion;
val.maxReplyLen = maxReplyLen;
val.dnssecOk = dnssecOk;
val.zoneID = zoneID;
val.hasEDNS = EDNS;
auto& mc = getMap(val.qname);
TryWriteLock l(&mc.d_mut);
if(l.gotIt()) {
bool success;
cmap_t::iterator place;
tie(place, success)=mc.d_map.insert(val);
if(!success)
mc.d_map.replace(place, val);
}
else
S.inc("<API key>");
}
void PacketCache::insert(const DNSName &qname, const QType& qtype, CacheEntryType cet, const vector<DNSZoneRecord>& value, unsigned int ttl, int zoneID)
{
cleanupIfNeeded();
if(!ttl)
return;
//cerr<<"Inserting qname '"<<qname<<"', cet: "<<(int)cet<<", qtype: "<<qtype.getName()<<", ttl: "<<ttl<<", maxreplylen: "<<maxReplyLen<<", hasEDNS: "<<EDNS<<endl;
CacheEntry val;
val.created=time(0);
val.ttd=val.created+ttl;
val.qname=qname;
val.qtype=qtype.getCode();
val.drs=value;
val.ctype=cet;
val.meritsRecursion=false;
val.maxReplyLen = 0;
val.dnssecOk = false;
val.zoneID = zoneID;
val.hasEDNS = false;
auto& mc = getMap(val.qname);
TryWriteLock l(&mc.d_mut);
if(l.gotIt()) {
bool success;
cmap_t::iterator place;
tie(place, success)=mc.d_map.insert(val);
if(!success)
mc.d_map.replace(place, val);
}
else
S.inc("<API key>");
}
/* clears the entire packetcache. */
int PacketCache::purge()
{
int delcount=0;
for(auto& mc : d_maps) {
WriteLock l(&mc.d_mut);
delcount+=mc.d_map.size();
mc.d_map.clear();
}
d_statnumentries->store(0);
return delcount;
}
int PacketCache::purgeExact(const DNSName& qname)
{
int delcount=0;
auto& mc = getMap(qname);
WriteLock l(&mc.d_mut);
auto range = mc.d_map.equal_range(tie(qname));
if(range.first != range.second) {
delcount+=distance(range.first, range.second);
mc.d_map.erase(range.first, range.second);
}
*d_statnumentries-=delcount; // XXX FIXME NEEDS TO BE ADJUSTED (for packetcache shards)
return delcount;
}
/* purges entries from the packetcache. If match ends on a $, it is treated as a suffix */
int PacketCache::purge(const string &match)
{
if(ends_with(match, "$")) {
int delcount=0;
string prefix(match);
prefix.resize(prefix.size()-1);
DNSName dprefix(prefix);
for(auto& mc : d_maps) {
WriteLock l(&mc.d_mut);
cmap_t::const_iterator iter = mc.d_map.lower_bound(tie(dprefix));
auto start=iter;
for(; iter != mc.d_map.end(); ++iter) {
if(!iter->qname.isPartOf(dprefix)) {
break;
}
delcount++;
}
mc.d_map.erase(start, iter);
}
*d_statnumentries-=delcount; // XXX FIXME NEEDS TO BE ADJUSTED (for packetcache shards)
return delcount;
}
else {
return purgeExact(DNSName(match));
}
}
// called from ueberbackend
bool PacketCache::getEntry(const DNSName &qname, const QType& qtype, CacheEntryType cet, vector<DNSZoneRecord>& value, int zoneID)
{
if(d_ttl<0)
getTTLS();
cleanupIfNeeded();
auto& mc=getMap(qname);
TryReadLock l(&mc.d_mut); // take a readlock here
if(!l.gotIt()) {
S.inc( "<API key>");
return false;
}
return getEntryLocked(qname, qtype, cet, value, zoneID);
}
bool PacketCache::getEntryLocked(const DNSName &qname, const QType& qtype, CacheEntryType cet, string& value, int zoneID, bool meritsRecursion,
unsigned int maxReplyLen, bool dnssecOK, bool hasEDNS, unsigned int *age)
{
uint16_t qt = qtype.getCode();
//cerr<<"Lookup for maxReplyLen: "<<maxReplyLen<<endl;
auto& mc=getMap(qname);
// cmap_t::const_iterator i=mc.d_map.find(tie(qname, qt, cet, zoneID, meritsRecursion, maxReplyLen, dnssecOK, hasEDNS, *age));
auto& idx = boost::multi_index::get<UnorderedNameTag>(mc.d_map);
auto range=idx.equal_range(tie(qname, qt, cet, zoneID));
if(range.first == range.second)
return false;
time_t now=time(0);
for(auto iter = range.first ; iter != range.second; ++iter) {
if(meritsRecursion == iter->meritsRecursion && maxReplyLen == iter->maxReplyLen && dnssecOK == iter->dnssecOk && hasEDNS == iter->hasEDNS ) {
if(iter->ttd > now) {
if (age)
*age = now - iter->created;
value = iter->value;
return true;
}
}
}
return false;
}
bool PacketCache::getEntryLocked(const DNSName &qname, const QType& qtype, CacheEntryType cet, vector<DNSZoneRecord>& value, int zoneID)
{
uint16_t qt = qtype.getCode();
//cerr<<"Lookup for maxReplyLen: "<<maxReplyLen<<endl;
auto& mc=getMap(qname);
auto& idx = boost::multi_index::get<UnorderedNameTag>(mc.d_map);
auto i=idx.find(tie(qname, qt, cet, zoneID));
if(i==idx.end())
return false;
time_t now=time(0);
if(i->ttd > now) {
value = i->drs;
return true;
}
return false;
}
map<char,int> PacketCache::getCounts()
{
int recursivePackets=0, nonRecursivePackets=0, queryCacheEntries=0, <API key>=0;
for(auto& mc : d_maps) {
ReadLock l(&mc.d_mut);
for(cmap_t::const_iterator iter = mc.d_map.begin() ; iter != mc.d_map.end(); ++iter) {
if(iter->ctype == PACKETCACHE)
if(iter->meritsRecursion)
recursivePackets++;
else
nonRecursivePackets++;
else if(iter->ctype == QUERYCACHE) {
if(iter->value.empty())
<API key>++;
else
queryCacheEntries++;
}
}
}
map<char,int> ret;
ret['!']=<API key>;
ret['Q']=queryCacheEntries;
ret['n']=nonRecursivePackets;
ret['r']=recursivePackets;
return ret;
}
int PacketCache::size()
{
uint64_t ret=0;
for(auto& mc : d_maps) {
ReadLock l(&mc.d_mut);
ret+=mc.d_map.size();
}
return ret;
}
/** readlock for figuring out which iterators to delete, upgrade to writelock when actually cleaning */
void PacketCache::cleanup()
{
d_statnumentries->store(0);
for(auto& mc : d_maps) {
ReadLock l(&mc.d_mut);
*d_statnumentries+=mc.d_map.size();
}
unsigned int maxCached=::arg().asNum("max-cache-entries");
unsigned int toTrim=0;
unsigned long cacheSize=*d_statnumentries;
if(maxCached && cacheSize > maxCached) {
toTrim = cacheSize - maxCached;
}
unsigned int lookAt=0;
// two modes - if toTrim is 0, just look through 10% of the cache and nuke everything that is expired
// otherwise, scan first 5*toTrim records, and stop once we've nuked enough
if(toTrim)
lookAt=5*toTrim;
else
lookAt=cacheSize/10;
// cerr<<"cacheSize: "<<cacheSize<<", lookAt: "<<lookAt<<", toTrim: "<<toTrim<<endl;
time_t now=time(0);
DLOG(L<<"Starting cache clean"<<endl);
//unsigned int totErased=0;
for(auto& mc : d_maps) {
WriteLock wl(&mc.d_mut);
typedef cmap_t::nth_index<1>::type sequence_t;
sequence_t& sidx=mc.d_map.get<1>();
unsigned int erased=0, lookedAt=0;
for(sequence_t::iterator i=sidx.begin(); i != sidx.end(); lookedAt++) {
if(i->ttd < now) {
sidx.erase(i++);
erased++;
}
else {
++i;
}
if(toTrim && erased > toTrim / d_maps.size())
break;
if(lookedAt > lookAt / d_maps.size())
break;
}
//totErased += erased;
}
// if(totErased)
// cerr<<"erased: "<<totErased<<endl;
d_statnumentries->store(0);
for(auto& mc : d_maps) {
ReadLock l(&mc.d_mut);
*d_statnumentries+=mc.d_map.size();
}
DLOG(L<<"Done with cache clean"<<endl);
}
|
<?php
/**
* BackPress Styles Procedural API
*
* @since 2.6.0
*
* @package WordPress
* @subpackage BackPress
*/
/**
* Initialize $wp_styles if it has not been set.
*
* @global WP_Styles $wp_styles
*
* @since 4.2.0
*
* @return WP_Styles WP_Styles instance.
*/
function wp_styles() {
global $wp_styles;
if ( ! ( $wp_styles instanceof WP_Styles ) ) {
$wp_styles = new WP_Styles();
}
return $wp_styles;
}
/**
* Display styles that are in the $handles queue.
*
* Passing an empty array to $handles prints the queue,
* passing an array with one string prints that style,
* and passing an array of strings prints those styles.
*
* @global WP_Styles $wp_styles The WP_Styles object for printing styles.
*
* @since 2.6.0
*
* @param string|bool|array $handles Styles to be printed. Default 'false'.
* @return array On success, a processed array of WP_Dependencies items; otherwise, an empty array.
*/
function wp_print_styles( $handles = false ) {
if ( '' === $handles ) { // for wp_head
$handles = false;
}
/**
* Fires before styles in the $handles queue are printed.
*
* @since 2.6.0
*/
if ( ! $handles ) {
do_action( 'wp_print_styles' );
}
<API key>( __FUNCTION__ );
global $wp_styles;
if ( ! ( $wp_styles instanceof WP_Styles ) ) {
if ( ! $handles ) {
return array(); // No need to instantiate if nothing is there.
}
}
return wp_styles()->do_items( $handles );
}
/**
* Add extra CSS styles to a registered stylesheet.
*
* Styles will only be added if the stylesheet in already in the queue.
* Accepts a string $data containing the CSS. If two or more CSS code blocks
* are added to the same stylesheet $handle, they will be printed in the order
* they were added, i.e. the latter added styles can redeclare the previous.
*
* @see WP_Styles::add_inline_style()
*
* @since 3.3.0
*
* @param string $handle Name of the stylesheet to add the extra styles to. Must be lowercase.
* @param string $data String containing the CSS styles to be added.
* @return bool True on success, false on failure.
*/
function wp_add_inline_style( $handle, $data ) {
<API key>( __FUNCTION__ );
if ( false !== stripos( $data, '</style>' ) ) {
_doing_it_wrong( __FUNCTION__, __( 'Do not pass style tags to wp_add_inline_style().' ), '3.7' );
$data = trim( preg_replace( '#<style[^>]*>(.*)</style>#is', '$1', $data ) );
}
return wp_styles()->add_inline_style( $handle, $data );
}
function wp_register_style( $handle, $src, $deps = array(), $ver = false, $media = 'all' ) {
<API key>( __FUNCTION__ );
return wp_styles()->add( $handle, $src, $deps, $ver, $media );
}
/**
* Remove a registered stylesheet.
*
* @see WP_Dependencies::remove()
*
* @since 2.1.0
*
* @param string $handle Name of the stylesheet to be removed.
*/
function wp_deregister_style( $handle ) {
<API key>( __FUNCTION__ );
wp_styles()->remove( $handle );
}
function wp_enqueue_style( $handle, $src = false, $deps = array(), $ver = false, $media = 'all' ) {
<API key>( __FUNCTION__ );
$wp_styles = wp_styles();
if ( $src ) {
$_handle = explode('?', $handle);
$wp_styles->add( $_handle[0], $src, $deps, $ver, $media );
}
$wp_styles->enqueue( $handle );
}
/**
* Remove a previously enqueued CSS stylesheet.
*
* @see WP_Dependencies::dequeue()
*
* @since 3.1.0
*
* @param string $handle Name of the stylesheet to be removed.
*/
function wp_dequeue_style( $handle ) {
<API key>( __FUNCTION__ );
wp_styles()->dequeue( $handle );
}
/**
* Check whether a CSS stylesheet has been added to the queue.
*
* @since 2.8.0
*
* @param string $handle Name of the stylesheet.
* @param string $list Optional. Status of the stylesheet to check. Default 'enqueued'.
* Accepts 'enqueued', 'registered', 'queue', 'to_do', and 'done'.
* @return bool Whether style is queued.
*/
function wp_style_is( $handle, $list = 'enqueued' ) {
<API key>( __FUNCTION__ );
return (bool) wp_styles()->query( $handle, $list );
}
/**
* Add metadata to a CSS stylesheet.
*
* Works only if the stylesheet has already been added.
*
* Possible values for $key and $value:
* 'conditional' string Comments for IE 6, lte IE 7 etc.
* 'rtl' bool|string To declare an RTL stylesheet.
* 'suffix' string Optional suffix, used in combination with RTL.
* 'alt' bool For rel="alternate stylesheet".
* 'title' string For preferred/alternate stylesheets.
*
* @see WP_Dependency::add_data()
*
* @since 3.6.0
*
* @param string $handle Name of the stylesheet.
* @param string $key Name of data point for which we're storing a value.
* Accepts 'conditional', 'rtl' and 'suffix', 'alt' and 'title'.
* @param mixed $value String containing the CSS data to be added.
* @return bool True on success, false on failure.
*/
function wp_style_add_data( $handle, $key, $value ) {
return wp_styles()->add_data( $handle, $key, $value );
}
|
// TransformPatternDlg.cpp : implementation file
#include <psycle/host/detail/project.private.hpp>
#include "TransformPatternDlg.hpp"
#include "Song.hpp"
#include "ChildView.hpp"
#include "MainFrm.hpp"
namespace psycle { namespace host {
static const char notes[12][3]={"C-","C#","D-","D#","E-","F-","F#","G-","G#","A-","A#","B-"};
static const char *empty ="Empty";
static const char *nonempty="Nonempty";
static const char *all="All";
static const char *same="Same";
static const char *off="off";
static const char *twk="twk";
static const char *tws="tws";
static const char *mcm="mcm";
// <API key> dialog
IMPLEMENT_DYNAMIC(<API key>, CDialog)
<API key>::<API key>(Song& _pSong, CChildView& _cview, CWnd* pParent /*=NULL*/)
: CDialog(<API key>::IDD, pParent)
, song(_pSong), cview(_cview), m_applyto(0)
{
}
<API key>::~<API key>()
{
}
void <API key>::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
DDX_Control(pDX, IDC_SEARCHNOTECOMB, m_searchnote);
DDX_Control(pDX, IDC_SEARCHINSTCOMB, m_searchinst);
DDX_Control(pDX, IDC_SEARCHMACHCOMB, m_searchmach);
DDX_Control(pDX, IDC_REPLNOTECOMB, m_replacenote);
DDX_Control(pDX, IDC_REPLINSTCOMB, m_replaceinst);
DDX_Control(pDX, IDC_REPLMACHCOMB, m_replacemach);
DDX_Control(pDX, IDC_REPLTWEAKCHECK, m_replacetweak);
DDX_Radio(pDX,IDC_APPLYTOSONG, m_applyto);
DDX_Control(pDX, IDC_CH_INCLUDEPAT, <API key>);
}
BEGIN_MESSAGE_MAP(<API key>, CDialog)
ON_BN_CLICKED(IDD_SEARCH, &<API key>::OnBnClickedSearch)
ON_BN_CLICKED(IDD_REPLACE, &<API key>::OnBnClickedReplace)
END_MESSAGE_MAP()
BOOL <API key>::OnInitDialog()
{
CDialog::OnInitDialog();
//Note (search and replace)
m_searchnote.AddString(all); m_searchnote.SetItemData(0,1003);
m_searchnote.AddString(empty); m_searchnote.SetItemData(1,1001);
m_searchnote.AddString(nonempty); m_searchnote.SetItemData(2,1002);
m_replacenote.AddString(same); m_replacenote.SetItemData(0,1002);
m_replacenote.AddString(empty); m_replacenote.SetItemData(1,1001);
bool is440 = PsycleGlobal::conf().patView().showA440;
for (int i=notecommands::c0; i <= notecommands::b9;i++) {
std::ostringstream os;
os << notes[i%12];
if (is440) os << (i/12)-1;
else os << (i/12);
m_searchnote.AddString(os.str().c_str()); m_searchnote.SetItemData(3+i,i);
m_replacenote.AddString(os.str().c_str()); m_replacenote.SetItemData(2+i,i);
}
m_searchnote.AddString(off); m_searchnote.SetItemData(123,notecommands::release);
m_searchnote.AddString(twk); m_searchnote.SetItemData(124,notecommands::tweak);
m_searchnote.AddString(tws); m_searchnote.SetItemData(125,notecommands::tweakslide);
m_searchnote.AddString(mcm); m_searchnote.SetItemData(126,notecommands::midicc);
m_replacenote.AddString(off); m_replacenote.SetItemData(122,notecommands::release);
m_replacenote.AddString(twk); m_replacenote.SetItemData(123,notecommands::tweak);
m_replacenote.AddString(tws); m_replacenote.SetItemData(124,notecommands::tweakslide);
m_replacenote.AddString(mcm); m_replacenote.SetItemData(125,notecommands::midicc);
m_searchnote.SetCurSel(0);
m_replacenote.SetCurSel(0);
//Inst (search and replace)
m_searchinst.AddString(all); m_searchinst.SetItemData(0,1003);
m_searchinst.AddString(empty); m_searchinst.SetItemData(1,1001);
m_searchinst.AddString(nonempty); m_searchinst.SetItemData(2,1002);
m_replaceinst.AddString(same); m_replaceinst.SetItemData(0,1002);
m_replaceinst.AddString(empty); m_replaceinst.SetItemData(1,1001);
for (int i=0; i < 0xFF; i++) {
std::ostringstream os;
if (i < 16) os << "0";
os << std::uppercase << std::hex << i;
m_searchinst.AddString(os.str().c_str()); m_searchinst.SetItemData(3+i,i);
m_replaceinst.AddString(os.str().c_str()); m_replaceinst.SetItemData(2+i,i);
}
m_searchinst.SetCurSel(0);
m_replaceinst.SetCurSel(0);
//Mach (search and replace)
m_searchmach.AddString(all); m_searchmach.SetItemData(0,1003);
m_searchmach.AddString(empty); m_searchmach.SetItemData(1,1001);
m_searchmach.AddString(nonempty); m_searchmach.SetItemData(2,1002);
m_replacemach.AddString(same); m_replacemach.SetItemData(0,1002);
m_replacemach.AddString(empty); m_replacemach.SetItemData(1,1001);
for (int i=0; i < 0xFF; i++) {
std::ostringstream os;
if (i < 16) os << "0";
os << std::uppercase << std::hex << i;
m_searchmach.AddString(os.str().c_str()); m_searchmach.SetItemData(3+i,i);
m_replacemach.AddString(os.str().c_str()); m_replacemach.SetItemData(2+i,i);
}
m_searchmach.SetCurSel(0);
m_replacemach.SetCurSel(0);
if (cview.blockSelected) m_applyto = 2;
UpdateData(FALSE);
return true; // return true unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return false
}
// <API key> message handlers
void <API key>::OnBnClickedSearch()
{
CSearchReplaceMode mode = cview.<API key>(
m_searchnote.GetItemData(m_searchnote.GetCurSel()),
m_searchinst.GetItemData(m_searchinst.GetCurSel()),
m_searchmach.GetItemData(m_searchmach.GetCurSel()));
CCursor cursor;
cursor.line = -1;
int pattern = -1;
UpdateData (TRUE);
if (m_applyto == 0) {
bool includeOther = <API key>.GetCheck() > 0;
int lastPatternUsed = (includeOther )? song.<API key>() : MAX_PATTERNS;
for (int currentPattern = 0; currentPattern <= lastPatternUsed; currentPattern++)
{
if (song.IsPatternUsed(currentPattern, !includeOther))
{
CSelection sel;
sel.start.line = 0; sel.start.track = 0;
sel.end.line = song.patternLines[currentPattern];
sel.end.track = MAX_TRACKS;
cursor = cview.SearchInPattern(currentPattern, sel , mode);
if (cursor.line != -1) {
pattern=currentPattern;
break;
}
}
}
}
else if (m_applyto == 1) {
CSelection sel;
sel.start.line = 0; sel.start.track = 0;
sel.end.line = song.patternLines[cview._ps()];
sel.end.track = MAX_TRACKS;
cursor = cview.SearchInPattern(cview._ps(), sel , mode);
pattern = cview._ps();
}
else if (m_applyto == 2 && cview.blockSelected) {
cursor = cview.SearchInPattern(cview._ps(), cview.blockSel , mode);
pattern = cview._ps();
}
else {
MessageBox("No block selected for action","Search and replace",MB_ICONWARNING);
return;
}
if (cursor.line == -1) {
MessageBox("Nothing found that matches the selected options","Search and replace",MB_ICONINFORMATION);
}
else {
cview.editcur = cursor;
if (cview._ps() != pattern) {
int pos = -1;
for (int i=0; i < MAX_SONG_POSITIONS; i++) {
if (song.playOrder[i] == pattern) {
pos = i;
break;
}
}
if (pos == -1){
pos = song.playLength;
++song.playLength;
song.playOrder[pos]=pattern;
((CMainFrame*)cview.pParentFrame)->UpdateSequencer();
}
cview.editPosition = pos;
memset(song.playOrderSel,0,MAX_SONG_POSITIONS*sizeof(bool));
song.playOrderSel[cview.editPosition]=true;
((CMainFrame*)cview.pParentFrame)->UpdatePlayOrder(true);
cview.Repaint(draw_modes::pattern);
}
else {
cview.Repaint(draw_modes::cursor);
}
}
}
void <API key>::OnBnClickedReplace()
{
CSearchReplaceMode mode = cview.<API key>(
m_searchnote.GetItemData(m_searchnote.GetCurSel()),
m_searchinst.GetItemData(m_searchinst.GetCurSel()),
m_searchmach.GetItemData(m_searchmach.GetCurSel()),
m_replacenote.GetItemData(m_replacenote.GetCurSel()),
m_replaceinst.GetItemData(m_replaceinst.GetCurSel()),
m_replacemach.GetItemData(m_replacemach.GetCurSel()),
m_replacetweak.GetCheck());
bool replaced=false;
UpdateData (TRUE);
if (m_applyto == 0) {
bool includeOther = <API key>.GetCheck() > 0;
int lastPatternUsed = (includeOther )? song.<API key>() : MAX_PATTERNS;
for (int currentPattern = 0; currentPattern <= lastPatternUsed; currentPattern++)
{
if (song.IsPatternUsed(currentPattern, !includeOther))
{
CSelection sel;
sel.start.line = 0; sel.start.track = 0;
sel.end.line = song.patternLines[currentPattern];
sel.end.track = MAX_TRACKS;
replaced=cview.SearchReplace(currentPattern, sel , mode);
}
}
}
else if (m_applyto == 1) {
CSelection sel;
sel.start.line = 0; sel.start.track = 0;
sel.end.line = song.patternLines[cview._ps()];
sel.end.track = MAX_TRACKS;
replaced=cview.SearchReplace(cview._ps(), sel, mode);
}
else if (m_applyto == 2 && cview.blockSelected) {
replaced=cview.SearchReplace(cview._ps(), cview.blockSel , mode);
}
else {
MessageBox("No block selected for action","Search and replace",MB_ICONWARNING);
return;
}
if (replaced) {
cview.Repaint(draw_modes::pattern);
}
else {
MessageBox("Nothing found that matches the selected options","Search and replace",MB_ICONINFORMATION);
}
}
} // namespace
} // namespace
|
<!DOCTYPE HTML PUBLIC "-
<!-- NewPage -->
<html lang="en">
<head>
<!-- Generated by javadoc (version 1.7.0_67) on Thu Apr 09 10:31:52 MDT 2015 -->
<meta http-equiv="Content-Type" content="text/html" charset="utf-8">
<title>Uses of Class org.apache.lucene.analysis.custom.CustomAnalyzer (Lucene 5.1.0 API)</title>
<meta name="date" content="2015-04-09">
<link rel="stylesheet" type="text/css" href="../../../../../../stylesheet.css" title="Style">
</head>
<body>
<script type="text/javascript"><!
if (location.href.indexOf('is-external=true') == -1) {
parent.document.title="Uses of Class org.apache.lucene.analysis.custom.CustomAnalyzer (Lucene 5.1.0 API)";
}
</script>
<noscript>
<div>JavaScript is disabled on your browser.</div>
</noscript>
<div class="topNav"><a name="navbar_top">
</a><a href="#skip-navbar_top" title="Skip navigation links"></a><a name="navbar_top_firstrow">
</a>
<ul class="navList" title="Navigation">
<li><a href="../../../../../../overview-summary.html">Overview</a></li>
<li><a href="../package-summary.html">Package</a></li>
<li><a href="../../../../../../org/apache/lucene/analysis/custom/CustomAnalyzer.html" title="class in org.apache.lucene.analysis.custom">Class</a></li>
<li class="navBarCell1Rev">Use</li>
<li><a href="../package-tree.html">Tree</a></li>
<li><a href="../../../../../../deprecated-list.html">Deprecated</a></li>
<li><a href="../../../../../../help-doc.html">Help</a></li>
</ul>
</div>
<div class="subNav">
<ul class="navList">
<li>Prev</li>
<li>Next</li>
</ul>
<ul class="navList">
<li><a href="../../../../../../index.html?org/apache/lucene/analysis/custom/class-use/CustomAnalyzer.html" target="_top">Frames</a></li>
<li><a href="CustomAnalyzer.html" target="_top">No Frames</a></li>
</ul>
<ul class="navList" id="<API key>">
<li><a href="../../../../../../allclasses-noframe.html">All Classes</a></li>
</ul>
<div>
<script type="text/javascript"><!
allClassesLink = document.getElementById("<API key>");
if(window==top) {
allClassesLink.style.display = "block";
}
else {
allClassesLink.style.display = "none";
}
</script>
</div>
<a name="skip-navbar_top">
</a></div>
<div class="header">
<h2 title="Uses of Class org.apache.lucene.analysis.custom.CustomAnalyzer" class="title">Uses of Class<br>org.apache.lucene.analysis.custom.CustomAnalyzer</h2>
</div>
<div class="classUseContainer">
<ul class="blockList">
<li class="blockList">
<table border="0" cellpadding="3" cellspacing="0" summary="Use table, listing packages, and an explanation">
<caption><span>Packages that use <a href="../../../../../../org/apache/lucene/analysis/custom/CustomAnalyzer.html" title="class in org.apache.lucene.analysis.custom">CustomAnalyzer</a></span><span class="tabEnd"> </span></caption>
<tr>
<th class="colFirst" scope="col">Package</th>
<th class="colLast" scope="col">Description</th>
</tr>
<tbody>
<tr class="altColor">
<td class="colFirst"><a href="#org.apache.lucene.analysis.custom">org.apache.lucene.analysis.custom</a></td>
<td class="colLast">
<div class="block">A general-purpose Analyzer that can be created with a builder-style API.</div>
</td>
</tr>
</tbody>
</table>
</li>
<li class="blockList">
<ul class="blockList">
<li class="blockList"><a name="org.apache.lucene.analysis.custom">
</a>
<h3>Uses of <a href="../../../../../../org/apache/lucene/analysis/custom/CustomAnalyzer.html" title="class in org.apache.lucene.analysis.custom">CustomAnalyzer</a> in <a href="../../../../../../org/apache/lucene/analysis/custom/package-summary.html">org.apache.lucene.analysis.custom</a></h3>
<table border="0" cellpadding="3" cellspacing="0" summary="Use table, listing methods, and an explanation">
<caption><span>Methods in <a href="../../../../../../org/apache/lucene/analysis/custom/package-summary.html">org.apache.lucene.analysis.custom</a> that return <a href="../../../../../../org/apache/lucene/analysis/custom/CustomAnalyzer.html" title="class in org.apache.lucene.analysis.custom">CustomAnalyzer</a></span><span class="tabEnd"> </span></caption>
<tr>
<th class="colFirst" scope="col">Modifier and Type</th>
<th class="colLast" scope="col">Method and Description</th>
</tr>
<tbody>
<tr class="altColor">
<td class="colFirst"><code><a href="../../../../../../org/apache/lucene/analysis/custom/CustomAnalyzer.html" title="class in org.apache.lucene.analysis.custom">CustomAnalyzer</a></code></td>
<td class="colLast"><span class="strong">CustomAnalyzer.Builder.</span><code><strong><a href="../../../../../../org/apache/lucene/analysis/custom/CustomAnalyzer.Builder.html#build()">build</a></strong>()</code>
<div class="block">Builds the analyzer.</div>
</td>
</tr>
</tbody>
</table>
</li>
</ul>
</li>
</ul>
</div>
<div class="bottomNav"><a name="navbar_bottom">
</a><a href="#skip-navbar_bottom" title="Skip navigation links"></a><a name="<API key>">
</a>
<ul class="navList" title="Navigation">
<li><a href="../../../../../../overview-summary.html">Overview</a></li>
<li><a href="../package-summary.html">Package</a></li>
<li><a href="../../../../../../org/apache/lucene/analysis/custom/CustomAnalyzer.html" title="class in org.apache.lucene.analysis.custom">Class</a></li>
<li class="navBarCell1Rev">Use</li>
<li><a href="../package-tree.html">Tree</a></li>
<li><a href="../../../../../../deprecated-list.html">Deprecated</a></li>
<li><a href="../../../../../../help-doc.html">Help</a></li>
</ul>
</div>
<div class="subNav">
<ul class="navList">
<li>Prev</li>
<li>Next</li>
</ul>
<ul class="navList">
<li><a href="../../../../../../index.html?org/apache/lucene/analysis/custom/class-use/CustomAnalyzer.html" target="_top">Frames</a></li>
<li><a href="CustomAnalyzer.html" target="_top">No Frames</a></li>
</ul>
<ul class="navList" id="<API key>">
<li><a href="../../../../../../allclasses-noframe.html">All Classes</a></li>
</ul>
<div>
<script type="text/javascript"><!
allClassesLink = document.getElementById("<API key>");
if(window==top) {
allClassesLink.style.display = "block";
}
else {
allClassesLink.style.display = "none";
}
</script>
</div>
<a name="skip-navbar_bottom">
</a></div>
<p class="legalCopy"><small>
<i>Copyright © 2000-2015 Apache Software Foundation. All Rights Reserved.</i>
<script src='../../../../../../prettify.js' type='text/javascript'></script>
<script type='text/javascript'>
(function(){
var oldonload = window.onload;
if (typeof oldonload != 'function') {
window.onload = prettyPrint;
} else {
window.onload = function() {
oldonload();
prettyPrint();
}
}
})();
</script>
</small></p>
</body>
</html>
|
var express = require('express'),
Weapon = require('../models/Weapon'),
router = express.Router();
// HOMEPAGE
router.get('/', function(req, res) {
res.render('index', {
title:'Weapons Guide | Fire Emblem | Awakening',
credit: 'Matt.Dodson.Digital',
msg: 'Hello Word!'
});
});
// WEAPON
router.get('/weapon', function(req, res) {
var schema = {};
Weapon.schema.eachPath(function (pathname, schemaType) {
schema[pathname] = schemaType.instance;
});
res.render('weapon', {
title:'Weapons Guide | Fire Emblem | Awakening',
credit: 'Matt.Dodson.Digital',
msg: 'This is a form.',
schema: schema
});
});
module.exports = router;
|
#include <stdio.h>
#pragma data_seg("dsec")
static char greeting[] = "Hello";
#pragma code_seg("asection")
void report()
{
printf("%s, world\n", greeting);
}
#pragma code_seg(".text")
int main ()
{
report();
return 0;
}
|
function isCompatible(){if(navigator.appVersion.indexOf('MSIE')!==-1&&parseFloat(navigator.appVersion.split('MSIE')[1])<6){return false;}return true;}var startUp=function(){mw.config=new mw.Map(true);mw.loader.addSource({"local":{"loadScript":"//bits.wikimedia.org/he.wikipedia.org/load.php","apiScript":"/w/api.php"}});mw.loader.register([["site","1349976191",[],"site"],["noscript","1347062400",[],"noscript"],["startup","1351588618",[],"startup"],["filepage","1347062400"],["user.groups","1347062400",[],"user"],["user","1347062400",[],"user"],["user.cssprefs","1347062400",["mediawiki.user"],"private"],["user.options","1347062400",[],"private"],["user.tokens","1347062400",[],"private"],["mediawiki.language.data","1351588618",["mediawiki.language.init"]],["skins.chick","1350311539"],["skins.cologneblue","1350311539"],["skins.modern","1350311539"],["skins.monobook","1350311539"],["skins.nostalgia","1350311539"],["skins.simple","1350311539"],["skins.standard","1350311539"],["skins.vector",
"1350311539"],["jquery","1350311539"],["jquery.appear","1350311539"],["jquery.arrowSteps","1350311539"],["jquery.async","1350311539"],["jquery.autoEllipsis","1350334340",["jquery.highlightText"]],["jquery.badge","1350311539"],["jquery.byteLength","1350311539"],["jquery.byteLimit","1350311539",["jquery.byteLength"]],["jquery.checkboxShiftClick","1350311539"],["jquery.client","1350311539"],["jquery.collapsibleTabs","1350311539"],["jquery.color","1350311539",["jquery.colorUtil"]],["jquery.colorUtil","1350311539"],["jquery.cookie","1350311539"],["jquery.delayedBind","1350311539"],["jquery.expandableField","1350311539",["jquery.delayedBind"]],["jquery.farbtastic","1350311539",["jquery.colorUtil"]],["jquery.footHovzer","1350311539"],["jquery.form","1350311539"],["jquery.getAttrs","1350311539"],["jquery.hidpi","1350311539"],["jquery.highlightText","1350334340",["jquery.mwExtension"]],["jquery.hoverIntent","1350311539"],["jquery.json","1350311539"],["jquery.localize","1350311539"],[
"jquery.makeCollapsible","1351565405"],["jquery.mockjax","1350311539"],["jquery.mw-jump","1350311539"],["jquery.mwExtension","1350311539"],["jquery.placeholder","1350311539"],["jquery.qunit","1350311539"],["jquery.qunit.completenessTest","1350311539",["jquery.qunit"]],["jquery.spinner","1350311539"],["jquery.jStorage","1350311539",["jquery.json"]],["jquery.suggestions","1350311539",["jquery.autoEllipsis"]],["jquery.tabIndex","1350311539"],["jquery.tablesorter","1351565484",["jquery.mwExtension"]],["jquery.textSelection","1350311539",["jquery.client"]],["jquery.validate","1350311539"],["jquery.xmldom","1350311539"],["jquery.tipsy","1350311539"],["jquery.ui.core","1350311539",["jquery"],"jquery.ui"],["jquery.ui.widget","1350311539",[],"jquery.ui"],["jquery.ui.mouse","1350311539",["jquery.ui.widget"],"jquery.ui"],["jquery.ui.position","1350311539",[],"jquery.ui"],["jquery.ui.draggable","1350311539",["jquery.ui.core","jquery.ui.mouse","jquery.ui.widget"],"jquery.ui"],["jquery.ui.droppable"
,"1350311539",["jquery.ui.core","jquery.ui.mouse","jquery.ui.widget","jquery.ui.draggable"],"jquery.ui"],["jquery.ui.resizable","1350311539",["jquery.ui.core","jquery.ui.widget","jquery.ui.mouse"],"jquery.ui"],["jquery.ui.selectable","1350311539",["jquery.ui.core","jquery.ui.widget","jquery.ui.mouse"],"jquery.ui"],["jquery.ui.sortable","1350311539",["jquery.ui.core","jquery.ui.widget","jquery.ui.mouse"],"jquery.ui"],["jquery.ui.accordion","1350311539",["jquery.ui.core","jquery.ui.widget"],"jquery.ui"],["jquery.ui.autocomplete","1350311539",["jquery.ui.core","jquery.ui.widget","jquery.ui.position"],"jquery.ui"],["jquery.ui.button","1350311539",["jquery.ui.core","jquery.ui.widget"],"jquery.ui"],["jquery.ui.datepicker","1350311539",["jquery.ui.core"],"jquery.ui"],["jquery.ui.dialog","1350311539",["jquery.ui.core","jquery.ui.widget","jquery.ui.button","jquery.ui.draggable","jquery.ui.mouse","jquery.ui.position","jquery.ui.resizable"],"jquery.ui"],["jquery.ui.progressbar","1350311539",[
"jquery.ui.core","jquery.ui.widget"],"jquery.ui"],["jquery.ui.slider","1350311539",["jquery.ui.core","jquery.ui.widget","jquery.ui.mouse"],"jquery.ui"],["jquery.ui.tabs","1350311539",["jquery.ui.core","jquery.ui.widget"],"jquery.ui"],["jquery.effects.core","1350311539",["jquery"],"jquery.ui"],["jquery.effects.blind","1350311539",["jquery.effects.core"],"jquery.ui"],["jquery.effects.bounce","1350311539",["jquery.effects.core"],"jquery.ui"],["jquery.effects.clip","1350311539",["jquery.effects.core"],"jquery.ui"],["jquery.effects.drop","1350311539",["jquery.effects.core"],"jquery.ui"],["jquery.effects.explode","1350311539",["jquery.effects.core"],"jquery.ui"],["jquery.effects.fade","1350311539",["jquery.effects.core"],"jquery.ui"],["jquery.effects.fold","1350311539",["jquery.effects.core"],"jquery.ui"],["jquery.effects.highlight","1350311539",["jquery.effects.core"],"jquery.ui"],["jquery.effects.pulsate","1350311539",["jquery.effects.core"],"jquery.ui"],["jquery.effects.scale",
"1350311539",["jquery.effects.core"],"jquery.ui"],["jquery.effects.shake","1350311539",["jquery.effects.core"],"jquery.ui"],["jquery.effects.slide","1350311539",["jquery.effects.core"],"jquery.ui"],["jquery.effects.transfer","1350311539",["jquery.effects.core"],"jquery.ui"],["mediawiki","1350311539"],["mediawiki.api","1350311539",["mediawiki.util"]],["mediawiki.api.category","1350311539",["mediawiki.api","mediawiki.Title"]],["mediawiki.api.edit","1350311539",["mediawiki.api","mediawiki.Title"]],["mediawiki.api.parse","1350311539",["mediawiki.api"]],["mediawiki.api.titleblacklist","1350311539",["mediawiki.api","mediawiki.Title"]],["mediawiki.api.watch","1350311539",["mediawiki.api","user.tokens"]],["mediawiki.debug","1350311539",["jquery.footHovzer"]],["mediawiki.debug.init","1350311539",["mediawiki.debug"]],["mediawiki.feedback","1350311539",["mediawiki.api.edit","mediawiki.Title","mediawiki.jqueryMsg","jquery.ui.dialog"]],["mediawiki.hidpi","1350311539",["jquery.hidpi"]],[
"mediawiki.htmlform","1350311539"],["mediawiki.notification","1350311539",["mediawiki.page.startup"]],["mediawiki.notify","1350311539"],["mediawiki.searchSuggest","1351565405",["jquery.autoEllipsis","jquery.client","jquery.placeholder","jquery.suggestions"]],["mediawiki.Title","1350311539",["mediawiki.util"]],["mediawiki.Uri","1350311539"],["mediawiki.user","1350311539",["jquery.cookie","mediawiki.api","user.options","user.tokens"]],["mediawiki.util","1351565428",["jquery.client","jquery.cookie","jquery.mwExtension","mediawiki.notify"]],["mediawiki.action.edit","1350311539",["jquery.textSelection","jquery.byteLimit"]],["mediawiki.action.edit.preview","1350311539",["jquery.form","jquery.spinner"]],["mediawiki.action.history","1350311539",[],"mediawiki.action.history"],["mediawiki.action.history.diff","1350311539",[],"mediawiki.action.history"],["mediawiki.action.view.dblClickEdit","1350311539",["mediawiki.util","mediawiki.page.startup"]],["mediawiki.action.view.metadata","1351565405"],[
"mediawiki.action.view.rightClickEdit","1350311539"],["mediawiki.action.watch.ajax","1347062400",["mediawiki.page.watch.ajax"]],["mediawiki.language","1350311539",["mediawiki.language.data","mediawiki.cldr"]],["mediawiki.cldr","1350311539",["mediawiki.libs.pluralruleparser"]],["mediawiki.libs.pluralruleparser","1350311539"],["mediawiki.language.init","1350311539"],["mediawiki.jqueryMsg","1350311539",["mediawiki.util","mediawiki.language"]],["mediawiki.libs.jpegmeta","1350311539"],["mediawiki.page.ready","1350311539",["jquery.checkboxShiftClick","jquery.makeCollapsible","jquery.placeholder","jquery.mw-jump","mediawiki.util"]],["mediawiki.page.startup","1350311539",["jquery.client","mediawiki.util"]],["mediawiki.page.watch.ajax","1351565428",["mediawiki.page.startup","mediawiki.api.watch","mediawiki.util","mediawiki.notify","jquery.mwExtension"]],["mediawiki.special","1350311539"],["mediawiki.special.block","1350311539",["mediawiki.util"]],["mediawiki.special.changeemail","1350311539",[
"mediawiki.util"]],["mediawiki.special.changeslist","1350311539",["jquery.makeCollapsible"]],["mediawiki.special.movePage","1350311539",["jquery.byteLimit"]],["mediawiki.special.preferences","1350311539"],["mediawiki.special.recentchanges","1350311539",["mediawiki.special"]],["mediawiki.special.search","1351565552"],["mediawiki.special.undelete","1350311539"],["mediawiki.special.upload","1351573522",["mediawiki.libs.jpegmeta","mediawiki.util"]],["mediawiki.special.javaScriptTest","1350311539",["jquery.qunit"]],["mediawiki.tests.qunit.testrunner","1350311539",["jquery.qunit","jquery.qunit.completenessTest","mediawiki.page.startup","mediawiki.page.ready"]],["mediawiki.legacy.ajax","1350311539",["mediawiki.util","mediawiki.legacy.wikibits"]],["mediawiki.legacy.commonPrint","1350311539"],["mediawiki.legacy.config","1350311539",["mediawiki.legacy.wikibits"]],["mediawiki.legacy.IEFixes","1350311539",["mediawiki.legacy.wikibits"]],["mediawiki.legacy.protect","1350311539",[
"mediawiki.legacy.wikibits","jquery.byteLimit"]],["mediawiki.legacy.shared","1350311539"],["mediawiki.legacy.oldshared","1350311539"],["mediawiki.legacy.upload","1350311539",["mediawiki.legacy.wikibits","mediawiki.util"]],["mediawiki.legacy.wikibits","1350311539",["mediawiki.util"]],["mediawiki.legacy.wikiprintable","1350311539"],["ext.gadget.Checkty","1349240575",["jquery.ui.button","jquery.ui.dialog"]],["ext.gadget.SubsetMenu","1347062400",["mediawiki.api"]],["ext.gadget.OrphanCheck","1347062400"],["ext.gadget.Revert","1347062400"],["ext.gadget.autocomplete","1347062400",["jquery.ui.widget","jquery.ui.autocomplete","jquery.textSelection"]],["ext.gadget.TemplateParamWizard","1349813783",["jquery.ui.widget","jquery.tipsy","jquery.textSelection","jquery.ui.autocomplete","jquery.ui.dialog"]],["ext.gadget.<API key>","1351381284",["jquery.ui.dialog","jquery.textSelection"]],["ext.gadget.Summarieslist","1347062400"],["ext.gadget.ReferencesWarn","1347062400"],[
"ext.gadget.CustomSideBarLinks","1347062400"],["ext.gadget.Dwim","1351288385",["jquery.suggestions","mediawiki.user"]],["ext.gadget.mySandbox","1347062400",["mediawiki.util"]],["ext.gadget.<API key>","1347062400"],["ext.gadget.FixedMenu","1347062400"],["ext.gadget.FixedSidebar","1347062400"],["ext.gadget.refStyle","1347062400"],["ext.gadget.CiteTooltip","1350413007",["jquery.tipsy","mediawiki.user"]],["ext.gadget.ExternalLinkIcon","1347062400"],["ext.gadget.updateMarker","1348209888"],["ext.gadget.watchlistMark","1347062400"],["ext.gadget.DeleteRequest","1347062400",["mediawiki.util"]],["ext.gadget.rollBackSummary","1347062400"],["ext.gadget.ajaxRC","1347062400"],["ext.gadget.patrolAlarm","1347062400"],["ext.gadget.disableFeedback","1347062400"],["ext.gadget.microblog","1347062400"],["ext.gadget.mychat","1347062400"],["ext.gadget.MoveToCommons","1351028833"],["mobile.device.default","1350311691"],["mobile.device.webkit","1351099404"],["mobile.device.android","1351099404"]
,["mobile.device.iphone","1351099404"],["mobile.device.iphone2","1351099404"],["mobile.device.palm_pre","1350311691"],["mobile.device.kindle","1350311691"],["mobile.device.blackberry","1351099404"],["mobile.device.simple","1350311691"],["mobile.device.psp","1350311691"],["mobile.device.wii","1350311691"],["mobile.device.operamini","1350311691"],["mobile.device.operamobile","1350311691"],["mobile.device.nokia","1350311691"],["ext.wikihiero","1350311861"],["ext.wikihiero.Special","1350311861",["jquery.spinner"]],["ext.cite","1350311592",["jquery.tooltip"]],["jquery.tooltip","1350311592"],["ext.specialcite","1350311592"],["ext.geshi.local","1347062400"],["ext.categoryTree","1351565722"],["ext.categoryTree.css","1350311573"],["ext.nuke","1350311699"],["ext.centralauth","1351583215"],["ext.centralauth.noflash","1350311583"],["ext.centralauth.globalusers","1350311583"],["ext.centralauth.<API key>","1350311583"],["ext.centralNotice.interface","1350311586",["jquery.ui.datepicker"]
],["ext.centralNotice.bannerStats","1350311586"],["ext.centralNotice.bannerController","1351218499"],["ext.collection.jquery.jstorage","1350311605",["jquery.json"]],["ext.collection.suggest","1350311605",["ext.collection.bookcreator"]],["ext.collection","1350311605",["ext.collection.bookcreator","jquery.ui.sortable"]],["ext.collection.bookcreator","1350311605",["ext.collection.jquery.jstorage"]],["ext.collection.<API key>","1350311605",["ext.collection.jquery.jstorage"]],["ext.abuseFilter","1350311550"],["ext.abuseFilter.edit","1351260433",["mediawiki.util","jquery.textSelection","jquery.spinner"]],["ext.abuseFilter.tools","1351261611",["mediawiki.util","jquery.spinner"]],["ext.abuseFilter.examine","1351261611",["mediawiki.util"]],["ext.vector.collapsibleNav","1351565552",["mediawiki.util","jquery.client","jquery.cookie","jquery.tabIndex"],"ext.vector"],["ext.vector.collapsibleTabs","1350311790",["jquery.collapsibleTabs","jquery.delayedBind"],"ext.vector"],[
"ext.vector.editWarning","1351565552",[],"ext.vector"],["ext.vector.expandableSearch","1350311790",["jquery.client","jquery.expandableField","jquery.delayedBind"],"ext.vector"],["ext.vector.footerCleanup","1351196615",["mediawiki.jqueryMsg","jquery.cookie"],"ext.vector"],["ext.vector.sectionEditLinks","1350311790",["jquery.cookie","jquery.clickTracking"],"ext.vector"],["contentCollector","1350311833",[],"ext.wikiEditor"],["jquery.wikiEditor","1351565399",["jquery.client","jquery.textSelection","jquery.delayedBind"],"ext.wikiEditor"],["jquery.wikiEditor.iframe","1350311833",["jquery.wikiEditor","contentCollector"],"ext.wikiEditor"],["jquery.wikiEditor.dialogs","1350311833",["jquery.wikiEditor","jquery.wikiEditor.toolbar","jquery.ui.dialog","jquery.ui.button","jquery.ui.draggable","jquery.ui.resizable","jquery.tabIndex"],"ext.wikiEditor"],["jquery.wikiEditor.dialogs.config","1351565399",["jquery.wikiEditor","jquery.wikiEditor.dialogs","jquery.wikiEditor.toolbar.i18n","jquery.suggestions"
,"mediawiki.Title"],"ext.wikiEditor"],["jquery.wikiEditor.highlight","1350311833",["jquery.wikiEditor","jquery.wikiEditor.iframe"],"ext.wikiEditor"],["jquery.wikiEditor.preview","1350311833",["jquery.wikiEditor"],"ext.wikiEditor"],["jquery.wikiEditor.previewDialog","1350311833",["jquery.wikiEditor","jquery.wikiEditor.dialogs"],"ext.wikiEditor"],["jquery.wikiEditor.publish","1350311833",["jquery.wikiEditor","jquery.wikiEditor.dialogs"],"ext.wikiEditor"],["jquery.wikiEditor.templateEditor","1350311833",["jquery.wikiEditor","jquery.wikiEditor.iframe","jquery.wikiEditor.dialogs"],"ext.wikiEditor"],["jquery.wikiEditor.templates","1350311833",["jquery.wikiEditor","jquery.wikiEditor.iframe"],"ext.wikiEditor"],["jquery.wikiEditor.toc","1350311833",["jquery.wikiEditor","jquery.wikiEditor.iframe","jquery.ui.draggable","jquery.ui.resizable","jquery.autoEllipsis","jquery.color"],"ext.wikiEditor"],["jquery.wikiEditor.toolbar","1350311833",["jquery.wikiEditor","jquery.wikiEditor.toolbar.i18n"],
"ext.wikiEditor"],["jquery.wikiEditor.toolbar.config","1350311833",["jquery.wikiEditor","jquery.wikiEditor.toolbar.i18n","jquery.wikiEditor.toolbar","jquery.cookie","jquery.async"],"ext.wikiEditor"],["jquery.wikiEditor.toolbar.i18n","1347062400",[],"ext.wikiEditor"],["ext.wikiEditor","1350311833",["jquery.wikiEditor"],"ext.wikiEditor"],["ext.wikiEditor.dialogs","1350311833",["ext.wikiEditor","ext.wikiEditor.toolbar","jquery.wikiEditor.dialogs","jquery.wikiEditor.dialogs.config"],"ext.wikiEditor"],["ext.wikiEditor.highlight","1350311833",["ext.wikiEditor","jquery.wikiEditor.highlight"],"ext.wikiEditor"],["ext.wikiEditor.preview","1350311833",["ext.wikiEditor","jquery.wikiEditor.preview"],"ext.wikiEditor"],["ext.wikiEditor.previewDialog","1350311833",["ext.wikiEditor","jquery.wikiEditor.previewDialog"],"ext.wikiEditor"],["ext.wikiEditor.publish","1350311833",["ext.wikiEditor","jquery.wikiEditor.publish"],"ext.wikiEditor"],["ext.wikiEditor.templateEditor","1350311833",["ext.wikiEditor",
"ext.wikiEditor.highlight","jquery.wikiEditor.templateEditor"],"ext.wikiEditor"],["ext.wikiEditor.templates","1350311833",["ext.wikiEditor","ext.wikiEditor.highlight","jquery.wikiEditor.templates"],"ext.wikiEditor"],["ext.wikiEditor.toc","1350311833",["ext.wikiEditor","ext.wikiEditor.highlight","jquery.wikiEditor.toc"],"ext.wikiEditor"],["ext.wikiEditor.tests.toolbar","1350311833",["ext.wikiEditor.toolbar"],"ext.wikiEditor"],["ext.wikiEditor.toolbar","1350311833",["ext.wikiEditor","jquery.wikiEditor.toolbar","jquery.wikiEditor.toolbar.config"],"ext.wikiEditor"],["ext.wikiEditor.toolbar.hideSig","1350311833",[],"ext.wikiEditor"],["ext.wikiLove.icon","1350311835"],["ext.wikiLove.defaultOptions","1351566772"],["ext.wikiLove.startup","1351566772",["ext.wikiLove.defaultOptions","jquery.ui.dialog","jquery.ui.button","jquery.localize","jquery.elastic"]],["ext.wikiLove.local","1351571152"],["ext.wikiLove.init","1350311835",["ext.wikiLove.startup"]],["jquery.elastic","1350311835"],[
"mobile.head","1351099404"],["mobile","1351190119"],["mobile.beta.jquery","1351187517"],["mobile.beta.jquery.eventlog","1351099404"],["mobile.production-only","1351190119"],["mobile.beta","1351190119"],["mobile.filePage","1351037747"],["mobile.references","1351187517"],["mobile.site","1347062400",[],"site"],["mobile.desktop","1351037747",["jquery.cookie"]],["ext.math.mathjax","1350311683",[],"ext.math.mathjax"],["ext.math.mathjax.enabler","1350311683"],["ext.babel","1350311571"],["ext.apiSandbox","1350311555",["mediawiki.util","jquery.ui.button"]],["ext.interwiki.specialpage","1350311669",["jquery.makeCollapsible"]],["ext.postEdit","1351565462",["jquery.cookie"]],["ext.checkUser","1350311590",["mediawiki.util"]]]);mw.config.set({"wgLoadScript":"//bits.wikimedia.org/he.wikipedia.org/load.php","debug":false,"skin":"vector","stylepath":"//bits.wikimedia.org/static-1.21wmf2/skins","wgUrlProtocols":
"http\\:\\/\\/|https\\:\\/\\/|ftp\\:\\/\\/|irc\\:\\/\\/|ircs\\:\\/\\/|gopher\\:\\/\\/|telnet\\:\\/\\/|nntp\\:\\/\\/|worldwind\\:\\/\\/|mailto\\:|news\\:|svn\\:\\/\\/|git\\:\\/\\/|mms\\:\\/\\/|\\/\\/","wgArticlePath":"/wiki/$1","wgScriptPath":"/w","wgScriptExtension":".php","wgScript":"/w/index.php","<API key>":false,"wgActionPaths":{},"wgServer":"
"ספר","109":"שיחת ספר"},"wgNamespaceIds":{"מדיה":-2,"מיוחד":-1,"":0,"שיחה":1,"משתמש":2,"שיחת_משתמש":3,"ויקיפדיה":4,"שיחת_ויקיפדיה":5,"קובץ":6,"שיחת_קובץ":7,"מדיה_ויקי":8,"שיחת_מדיה_ויקי":9,"תבנית":10,"שיחת_תבנית":11,"עזרה":12,"שיחת_עזרה":13,"קטגוריה":14,"שיחת_קטגוריה":15,"פורטל":100,"שיחת_פורטל":101,"ספר":108,"שיחת_ספר":109,"תמונה":6,"שיחת_תמונה":7,"משתמשת":2,"שיחת_משתמשת":3,"image":6,"image_talk":7,"media":-2,"special":-1,"talk":1,"user":2,"user_talk":3,"project":4,"project_talk":5,"file":6,"file_talk":7,"mediawiki":8,"mediawiki_talk":9,"template":10,"template_talk":11,"help":12,"help_talk":13,"category":14,"category_talk":15},"wgSiteName":"ויקיפדיה","wgFileExtensions":["png","gif","jpg","jpeg","xcf","pdf","mid","ogg","ogv","svg","djvu","tiff","tif","oga"],"wgDBname":"hewiki","wgFileCanRotate"
:true,"wgAvailableSkins":{"chick":"Chick","cologneblue":"CologneBlue","modern":"Modern","monobook":"MonoBook","myskin":"MySkin","nostalgia":"Nostalgia","simple":"Simple","standard":"Standard","vector":"Vector"},"<API key>":"//bits.wikimedia.org/static-1.21wmf2/extensions","wgCookiePrefix":"hewiki","<API key>":-1,"<API key>":[],"wgCollectionVersion":"1.6.1","<API key>":false,"<API key>":false,"<API key>":false,"<API key>":{"redirect":"
"//meta.wikimedia.org/wiki/Special:BannerLoader","wgCookiePath":"/","<API key>":".wikipedia.org"});};if(isCompatible()){document.write("\x3cscript src=\"//bits.wikimedia.org/he.wikipedia.org/load.php?debug=false\x26amp;lang=he\x26amp;modules=jquery%2Cmediawiki\x26amp;only=scripts\x26amp;skin=vector\x26amp;version=20121015T143219Z\"\x3e\x3c/script\x3e");}delete isCompatible;
/* cache key: hewiki:resourceloader:filter:minify-js:7:<API key> */
|
/* $Id: transaction.h,v 1.13 1997/05/28 23:19:52 viktor Exp $ */
#ifndef _TRANSACTION_H
#define _TRANSACTION_H
#include <dbi.h>
#include <tcl.h>
typedef enum {NORESTORE, RESTOREDATA, RESTORESCHEMA} RestoreMode;
/*
* item_class NON-NULL iff template is for a 'unameit_item'
*/
extern DB_OBJECT *Udb_Finish_Object(
DB_OBJECT *item_class,
DB_OTMPL *template,
int item_deleted
);
extern RestoreMode Udb_Restore_Mode(RestoreMode *new);
extern Tcl_CmdProc Udb_Syscall;
extern Tcl_CmdProc Udb_Transaction;
extern Tcl_CmdProc Udb_Version;
extern Tcl_CmdProc Udb_Rollback;
extern Tcl_CmdProc Udb_Commit;
extern void Udb_OpenLog(const char *logPrefix);
extern void Udb_CloseLog(void);
extern void Udb_Force_Rollback(Tcl_Interp *interp);
extern int Udb_Do_Rollback(Tcl_Interp *interp);
extern int Udb_Do_Commit(Tcl_Interp *interp, const char *logEntry);
#endif
|
<?php
namespace Icinga\Module\Monitoring\DataView;
class Contactgroup extends DataView
{
/**
* {@inheritdoc}
*/
public function isValidFilterTarget($column)
{
if ($column[0] === '_' && preg_match('/^_(?:host|service)_/', $column)) {
return true;
}
return parent::isValidFilterTarget($column);
}
/**
* {@inheritdoc}
*/
public function getColumns()
{
return array(
'contactgroup_name',
'contactgroup_alias',
'contact_object_id',
'contact_id',
'contact_name',
'contact_alias',
'contact_email',
'contact_pager',
'<API key>',
'<API key>',
'<API key>',
'<API key>',
'<API key>',
'<API key>',
'<API key>',
'<API key>',
'<API key>',
'<API key>',
'<API key>',
'<API key>',
'<API key>',
'<API key>',
'<API key>',
'<API key>'
);
}
/**
* {@inheritdoc}
*/
public function getSortRules()
{
return array(
'contactgroup_name' => array(
'order' => self::SORT_ASC
),
'contactgroup_alias' => array(
'order' => self::SORT_ASC
)
);
}
/**
* {@inheritdoc}
*/
public function getFilterColumns()
{
return array(
'contactgroup', 'contact',
'host', 'host_name', 'host_display_name', 'host_alias',
'hostgroup', 'hostgroup_alias', 'hostgroup_name',
'service', 'service_description', '<API key>',
'servicegroup', 'servicegroup_alias', 'servicegroup_name'
);
}
/**
* {@inheritdoc}
*/
public function getSearchColumns()
{
return array('contactgroup_alias');
}
}
|
import configparser
CONFIG_PATH = 'accounting.conf'
class MyConfigParser():
def __init__(self, config_path=CONFIG_PATH):
self.config = configparser.ConfigParser(allow_no_value=True)
self.config.read(config_path)
def config_section_map(self, section):
""" returns all configuration options in 'section' in a dict with
key: config_option and value: the read value in the file"""
dict1 = {}
options = self.config.options(section)
for option in options:
try:
dict1[option] = self.config.get(section, option)
if dict1[option] == -1:
DebugPrint("skip: %s" % option)
except:
dict1[option] = None
return dict1
# getint(section, option)
# getboolean(section, option)
|
// Name: imagpnm.h
// Purpose: wxImage PNM handler
// RCS-ID: $Id: imagpnm.h,v 1.1 1999/12/15 22:37:51 VS Exp $
// Licence: wxWindows licence
// read/write pnm image
#ifndef _BG_IMAGPNM_H_
#define _BG_IMAGPNM_H_
#ifdef __GNUG__
#pragma interface "BgImagPNM.h"
#endif
#include <wx/image.h>
// bgPGMHandler
class bgPNMHandler : public wxImageHandler
{
<API key>(bgPNMHandler)
public:
inline bgPNMHandler()
{
m_name = "PNM file";
m_extension = "pnm";
m_type = wxBITMAP_TYPE_PNM;
m_mime = "image/pnm";
};
virtual bool LoadFile( wxImage *image, wxInputStream& stream, bool verbose=TRUE, int index=0 );
virtual bool SaveFile( wxImage *image, wxOutputStream& stream, bool verbose=TRUE );
virtual bool DoCanRead( wxInputStream& stream );
void Skip_Comment(wxInputStream &stream);
};
#endif
|
# codingInPython
Github space for my experiments with programming, learning Python and git alongside.
Much of what I have in here are some code examples of exercies I have been trying to complete.
As of 4/6, most of the effort has been on data manipulation or rather list manipulation.
4/7 : Updated files :
|
<h2><?php print $node->title; ?></h2>
<h3><?php print content_format('field_subtitle', $field_subtitle[0]); ?></h3>
<? print l('Back', 'node/'.$node->field_case_project[0]['nid'], array('html'=>TRUE, 'attributes'=>array('class'=>'back-link'))); ?>
<? print content_format('<API key>', $<API key>[0]); ?>
<? print content_format('<API key>', $<API key>[0]); ?>
<? print content_format('field_case_video', $field_case_video[0]); ?>
<?
$distribution_body = strip_tags($<API key>[0]['value']);
if (!empty($distribution_body))
print content_format('<API key>', $<API key>[0]);
?>
<? if (!empty($<API key>[0]['filename'])) print content_format('<API key>', $<API key>[0], 'image_plain'); ?>
<?
$finance_body = strip_tags($<API key>[0]['value']);
if (!empty($finance_body))
print content_format('<API key>', $<API key>[0]);
?>
<? if (!empty($<API key>[0]['filename'])) print content_format('<API key>', $<API key>[0], 'image_plain'); ?>
<?
$multiplatform_body = strip_tags($<API key>[0]['value']);
if (!empty($multiplatform_body))
print content_format('<API key>', $<API key>[0]);
?>
<? if (!empty($<API key>[0]['filename'])) print content_format('<API key>', $<API key>[0], 'image_plain'); ?>
<?
$ad_body = strip_tags($field_case_ad_body[0]['value']);
if (!empty($ad_body))
print content_format('field_case_ad_body', $field_case_ad_body[0]);
?>
<? if (!empty($field_case_ad_image[0]['filename'])) print content_format('field_case_ad_image', $field_case_ad_image[0], 'image_plain'); ?>
<?
$international_body = strip_tags($<API key>[0]['value']);
if (!empty($international_body))
print content_format('<API key>', $<API key>[0]);
?>
<? if (!empty($<API key>[0]['filename'])) print content_format('<API key>', $<API key>[0], 'image_plain'); ?>
<?
$format_body = strip_tags($<API key>[0]['value']);
if (!empty($format_body))
print content_format('<API key>', $<API key>[0]);
?>
<? if (!empty($<API key>[0]['filename'])) print content_format('<API key>', $<API key>[0], 'image_plain'); ?>
<? print content_format('<API key>', $<API key>[0]); ?>
<div class="sponsor-logos">
<? print views_embed_view('sponsor_logos', 'block_1', $field_case_project[0]['nid']); ?>
</div>
|
package ms.aurora.browser.wrapper;
import org.apache.log4j.Logger;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import org.w3c.tidy.Tidy;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.<API key>;
import javax.xml.transform.Result;
import javax.xml.transform.Source;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.stream.StreamResult;
import javax.xml.xpath.*;
import java.io.<API key>;
import java.io.<API key>;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.List;
/**
* A parser / access layer for HTML pages
* @author Rick
*/
public final class HTML {
private static Logger logger = Logger.getLogger(HTML.class);
private Document dom;
public HTML(Document dom) {
this.dom = dom;
}
public Document getDOM() {
return dom;
}
public List<Node> searchXPath(String expression) {
List<Node> matchingElements = new ArrayList<Node>();
try {
XPathExpression expressionObj = getExpression(expression);
NodeList resultingNodeList = (NodeList) expressionObj.evaluate(dom,
XPathConstants.NODESET);
for (int index = 0; index < resultingNodeList.getLength(); index++) {
matchingElements.add(resultingNodeList.item(index));
}
} catch (<API key> e) {
logger.error("Incorrect XPath expression", e);
}
return matchingElements;
}
public List<Node> searchXPath(Node base, String expression) {
List<Node> matchingElements = new ArrayList<Node>();
try {
XPathExpression expressionObj = getExpression(expression);
NodeList resultingNodeList = (NodeList) expressionObj.evaluate(base,
XPathConstants.NODESET);
for (int index = 0; index < resultingNodeList.getLength(); index++) {
matchingElements.add(resultingNodeList.item(index));
}
} catch (<API key> e) {
logger.error("Incorrect XPath expression", e);
}
return matchingElements;
}
private XPathExpression getExpression(String expression) throws <API key> {
XPath xpath = XPathFactory.newInstance().newXPath();
return xpath.compile(expression);
}
public static HTML fromStream(InputStream stream) {
try {
/*
* UGLY ASS W3C API IS UGLY
*/
Tidy tidy = new Tidy();
tidy.setXHTML(true);
Document dom = tidy.parseDOM(stream, null);
dom.getDocumentElement().normalize();
<API key> dbf = <API key>.newInstance();
DocumentBuilder db = dbf.newDocumentBuilder();
<API key> outputStream = new <API key>();
Source xmlSource = new DOMSource(dom);
Result outputTarget = new StreamResult(outputStream);
TransformerFactory.newInstance().newTransformer().transform(xmlSource, outputTarget);
InputStream is = new <API key>(outputStream.toByteArray());
return new HTML(db.parse(is));
} catch (Exception e) {
logger.error("Failed to parse HTML properly", e);
}
return null;
}
}
|
<!DOCTYPE HTML PUBLIC "-
<!--NewPage
<HTML>
<HEAD>
<!-- Generated by javadoc (build 1.6.0_43) on Tue Dec 15 22:07:49 NZDT 2015 -->
<TITLE>
weka.core.stemmers
</TITLE>
<META NAME="date" CONTENT="2015-12-15">
<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="weka.core.stemmers";
}
}
</SCRIPT>
<NOSCRIPT>
</NOSCRIPT>
</HEAD>
<BODY BGCOLOR="white" onload="windowTitle();">
<HR>
<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="#FFFFFF" CLASS="NavBarCell1Rev"> <FONT CLASS="NavBarFont1Rev"><B>Package</B></FONT> </TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <FONT CLASS="NavBarFont1">Class</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="
</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="../../../weka/core/pmml/package-summary.html"><B>PREV PACKAGE</B></A>
<A HREF="../../../weka/core/tokenizers/package-summary.html"><B>NEXT PACKAGE</B></A></FONT></TD>
<TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">
<A HREF="../../../index.html?weka/core/stemmers/package-summary.html" target="_top"><B>FRAMES</B></A>
<A HREF="package-summary.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>
<HR>
<H2>
Package weka.core.stemmers
</H2>
<TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY="">
<TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor">
<TH ALIGN="left" COLSPAN="2"><FONT SIZE="+2">
<B>Interface Summary</B></FONT></TH>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD WIDTH="15%"><B><A HREF="../../../weka/core/stemmers/Stemmer.html" title="interface in weka.core.stemmers">Stemmer</A></B></TD>
<TD>Interface for all stemming algorithms.</TD>
</TR>
</TABLE>
<P>
<TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY="">
<TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor">
<TH ALIGN="left" COLSPAN="2"><FONT SIZE="+2">
<B>Class Summary</B></FONT></TH>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD WIDTH="15%"><B><A HREF="../../../weka/core/stemmers/<API key>.html" title="class in weka.core.stemmers"><API key></A></B></TD>
<TD>An iterated version of the Lovins stemmer.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD WIDTH="15%"><B><A HREF="../../../weka/core/stemmers/LovinsStemmer.html" title="class in weka.core.stemmers">LovinsStemmer</A></B></TD>
<TD>A stemmer based on the Lovins stemmer, described here:<br/>
<br/>
Julie Beth Lovins (1968).</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD WIDTH="15%"><B><A HREF="../../../weka/core/stemmers/NullStemmer.html" title="class in weka.core.stemmers">NullStemmer</A></B></TD>
<TD>A dummy stemmer that performs no stemming at all.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD WIDTH="15%"><B><A HREF="../../../weka/core/stemmers/SnowballStemmer.html" title="class in weka.core.stemmers">SnowballStemmer</A></B></TD>
<TD>A wrapper class for the Snowball stemmers.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD WIDTH="15%"><B><A HREF="../../../weka/core/stemmers/Stemming.html" title="class in weka.core.stemmers">Stemming</A></B></TD>
<TD>A helper class for using the stemmers.</TD>
</TR>
</TABLE>
<P>
<DL>
</DL>
<HR>
<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="<API key>"></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="#FFFFFF" CLASS="NavBarCell1Rev"> <FONT CLASS="NavBarFont1Rev"><B>Package</B></FONT> </TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <FONT CLASS="NavBarFont1">Class</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="
</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="../../../weka/core/pmml/package-summary.html"><B>PREV PACKAGE</B></A>
<A HREF="../../../weka/core/tokenizers/package-summary.html"><B>NEXT PACKAGE</B></A></FONT></TD>
<TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">
<A HREF="../../../index.html?weka/core/stemmers/package-summary.html" target="_top"><B>FRAMES</B></A>
<A HREF="package-summary.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>
<HR>
</BODY>
</HTML>
|
<html>
<head>
<title>Transverse Ray Aberration Diagram</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="generator" content="HelpNDoc Personal Edition 4.3.1.364">
<link type="text/css" rel="stylesheet" media="all" href="css/reset.css" />
<link type="text/css" rel="stylesheet" media="all" href="css/base.css" />
<link type="text/css" rel="stylesheet" media="all" href="css/hnd.css" />
<!--[if lte IE 8]>
<link type="text/css" rel="stylesheet" media="all" href="css/ielte8.css" />
<![endif]
<style type="text/css">
#topic_header
{
background-color: #EFEFEF;
}
</style>
<script type="text/javascript" src="js/jquery.min.js"></script>
<script type="text/javascript" src="js/hnd.js"></script>
<script type="text/javascript">
$(document).ready(function()
{
if (top.frames.length == 0)
{
var sTopicUrl = top.location.href.substring(top.location.href.lastIndexOf("/") + 1, top.location.href.length);
top.location.href = "Programming and Algorithms Reference MATLAB Based Optical Analysis Toolbox V 3.0.html?" + sTopicUrl;
}
else if (top && top.FrameTOC && top.FrameTOC.SelectTocItem)
{
top.FrameTOC.SelectTocItem("<API key>");
}
});
</script>
</head>
<body>
<div id="topic_header">
<div id="<API key>">
<h1 id="topic_header_text">Transverse Ray Aberration Diagram</h1>
<div id="topic_breadcrumb">
<a href="<API key>.html">Examples of Extending the Toolbox</a> ›› <a href="<API key>.html">Method 1: As part of the toolbox</a> ›› </div>
</div>
<div id="topic_header_nav">
<a href="<API key>.html"><img src="img/arrow_up.png" alt="Parent"/></a>
<a href="<API key>.html"><img src="img/arrow_left.png" alt="Previous"/></a>
<a href="Procedures.html"><img src="img/arrow_right.png" alt="Next"/></a>
</div>
<div class="clear"></div>
</div>
<div id="topic_content">
<p></p>
<h1 class="rvps11"><span class="rvts0"><span class="rvts59">Toolbox Extension Example: Transverse Ray Aberration Diagram</span></span></h1>
<p class="rvps10"><span class="rvts37">Purpose:</span></p>
<p class="rvps10"><span class="rvts38">To add an analysis window to the toolbox which shows ray aberrations as a function of pupil coordinate. </span></p>
<p class="rvps10"><span class="rvts38"><br/></span></p>
<p></p>
<p class="rvps6"><span class="rvts20">Created with the Personal Edition of HelpNDoc: </span><a class="rvts21" href="http:
</div>
<div id="topic_footer">
<div id="<API key>">
Copyright © <2014> by <Norman G. Worku (normangirma2012@gmail.com), Optical System Design Research Group, FSU, Jena>. All Rights Reserved.</div>
</div>
</body>
</html>
|
#ifndef __LINUX_RCUPDATE_H
#define __LINUX_RCUPDATE_H
#include <linux/cache.h>
#include <linux/spinlock.h>
#include <linux/threads.h>
#include <linux/cpumask.h>
#include <linux/seqlock.h>
#include <linux/lockdep.h>
#include <linux/completion.h>
/**
* struct rcu_head - callback structure for use with RCU
* @next: next update requests in a list
* @func: actual update function to call after the grace period.
*/
struct rcu_head {
struct rcu_head *next;
void (*func)(struct rcu_head *head);
};
/* Exported common interfaces */
#ifdef <API key>
extern void synchronize_rcu(void);
#else /* #ifdef <API key> */
#define synchronize_rcu synchronize_sched
#endif /* #else #ifdef <API key> */
extern void synchronize_rcu_bh(void);
extern void synchronize_sched(void);
extern void rcu_barrier(void);
extern void rcu_barrier_bh(void);
extern void rcu_barrier_sched(void);
extern void <API key>(void);
extern int <API key>(char *page);
/* Internal to kernel */
extern void rcu_init(void);
extern void <API key>(void);
#ifndef CONFIG_TINY_RCU
extern int rcu_needs_cpu(int cpu);
#else
static inline int rcu_needs_cpu(int cpu) { return 0; }
#endif
extern int <API key>;
#include "rcutiny.h" /* Figure out why later. */
// #if defined(CONFIG_TREE_RCU) || defined(<API key>)
// #include <linux/rcutree.h>
#ifdef CONFIG_TINY_RCU
#include <linux/rcutiny.h>
#else
#error "Unknown RCU implementation specified to kernel configuration"
#endif
#define RCU_HEAD_INIT { .next = NULL, .func = NULL }
#define RCU_HEAD(head) struct rcu_head head = RCU_HEAD_INIT
#define INIT_RCU_HEAD(ptr) do { \
(ptr)->next = NULL; (ptr)->func = NULL; \
} while (0)
#ifdef <API key>
extern struct lockdep_map rcu_lock_map;
# define rcu_read_acquire() \
lock_acquire(&rcu_lock_map, 0, 0, 2, 1, NULL, _THIS_IP_)
# define rcu_read_release() lock_release(&rcu_lock_map, 1, _THIS_IP_)
#else
# define rcu_read_acquire() do { } while (0)
# define rcu_read_release() do { } while (0)
#endif
static inline void rcu_read_lock(void)
{
__rcu_read_lock();
__acquire(RCU);
rcu_read_acquire();
}
/*
* So where is rcu_write_lock()? It does not exist, as there is no
* way for writers to lock out RCU readers. This is a feature, not
* a bug -- this property is what provides RCU's performance benefits.
* Of course, writers must coordinate with each other. The normal
* spinlock primitives work well for this, but any other technique may be
* used as well. RCU does not care how the writers keep out of each
* others' way, as long as they do so.
*/
/**
* rcu_read_unlock - marks the end of an RCU read-side critical section.
*
* See rcu_read_lock() for more information.
*/
static inline void rcu_read_unlock(void)
{
rcu_read_release();
__release(RCU);
__rcu_read_unlock();
}
/**
* rcu_read_lock_bh - mark the beginning of a softirq-only RCU critical section
*
* This is equivalent of rcu_read_lock(), but to be used when updates
* are being done using call_rcu_bh(). Since call_rcu_bh() callbacks
* consider completion of a softirq handler to be a quiescent state,
* a process in RCU read-side critical section must be protected by
* disabling softirqs. Read-side critical sections in interrupt context
* can use just rcu_read_lock().
*
*/
static inline void rcu_read_lock_bh(void)
{
__rcu_read_lock_bh();
__acquire(RCU_BH);
rcu_read_acquire();
}
/*
* rcu_read_unlock_bh - marks the end of a softirq-only RCU critical section
*
* See rcu_read_lock_bh() for more information.
*/
static inline void rcu_read_unlock_bh(void)
{
rcu_read_release();
__release(RCU_BH);
<API key>();
}
/**
* rcu_read_lock_sched - mark the beginning of a RCU-classic critical section
*
* Should be used with either
* - synchronize_sched()
* or
* - call_rcu_sched() and rcu_barrier_sched()
* on the write-side to insure proper synchronization.
*/
static inline void rcu_read_lock_sched(void)
{
preempt_disable();
__acquire(RCU_SCHED);
rcu_read_acquire();
}
/* Used by lockdep and tracing: cannot be traced, cannot call lockdep. */
static inline notrace void <API key>(void)
{
<API key>();
__acquire(RCU_SCHED);
}
/*
* <API key> - marks the end of a RCU-classic critical section
*
* See rcu_read_lock_sched for more information.
*/
static inline void <API key>(void)
{
rcu_read_release();
__release(RCU_SCHED);
preempt_enable();
}
/* Used by lockdep and tracing: cannot be traced, cannot call lockdep. */
static inline notrace void <API key>(void)
{
__release(RCU_SCHED);
<API key>();
}
/**
* rcu_dereference - fetch an RCU-protected pointer in an
* RCU read-side critical section. This pointer may later
* be safely dereferenced.
*
* Inserts memory barriers on architectures that require them
* (currently only the Alpha), and, more importantly, documents
* exactly which pointers are protected by RCU.
*/
#define rcu_dereference(p) ({ \
typeof(p) _________p1 = ACCESS_ONCE(p); \
<API key>(); \
(_________p1); \
})
/**
* rcu_assign_pointer - assign (publicize) a pointer to a newly
* initialized structure that will be dereferenced by RCU read-side
* critical sections. Returns the value assigned.
*
* Inserts memory barriers on architectures that require them
* (pretty much all of them other than x86), and also prevents
* the compiler from reordering the code that initializes the
* structure after the pointer assignment. More importantly, this
* call documents which pointers will be dereferenced by RCU read-side
* code.
*/
#define rcu_assign_pointer(p, v) \
({ \
if (!<API key>(v) || \
((v) != NULL)) \
smp_wmb(); \
(p) = (v); \
})
/* Infrastructure to implement the synchronize_() primitives. */
struct rcu_synchronize {
struct rcu_head head;
struct completion completion;
};
extern void wakeme_after_rcu(struct rcu_head *head);
/**
* call_rcu - Queue an RCU callback for invocation after a grace period.
* @head: structure to be used for queueing the RCU updates.
* @func: actual update function to be invoked after the grace period
*
* The update function will be invoked some time after a full grace
* period elapses, in other words after all currently executing RCU
* read-side critical sections have completed. RCU read-side critical
* sections are delimited by rcu_read_lock() and rcu_read_unlock(),
* and may be nested.
*/
extern void call_rcu(struct rcu_head *head,
void (*func)(struct rcu_head *head));
/**
* call_rcu_bh - Queue an RCU for invocation after a quicker grace period.
* @head: structure to be used for queueing the RCU updates.
* @func: actual update function to be invoked after the grace period
*
* The update function will be invoked some time after a full grace
* period elapses, in other words after all currently executing RCU
* read-side critical sections have completed. call_rcu_bh() assumes
* that the read-side critical sections end on completion of a softirq
* handler. This means that read-side critical sections in process
* context must not be interrupted by softirqs. This interface is to be
* used when most of the read-side critical sections are in softirq context.
* RCU read-side critical sections are delimited by :
* - rcu_read_lock() and rcu_read_unlock(), if in interrupt context.
* OR
* - rcu_read_lock_bh() and rcu_read_unlock_bh(), if in process context.
* These may be nested.
*/
extern void call_rcu_bh(struct rcu_head *head,
void (*func)(struct rcu_head *head));
#endif /* __LINUX_RCUPDATE_H */
|
<?php
global $wp_version;
if(version_compare($wp_version,'3.6.1','<'))
{
exit('This is plugin requice Wordpress Version 3.6 on highter. Please update now!');
}
<API key>(__FILE__,'mq_register_setting');
<API key>(__FILE__,'mq_delete_setting');
function enque_register()
{
wp_register_script('mq_register_ajax',plugins_url('inc/js/init.js',__FILE__),array('jquery'),true);
wp_localize_script('mq_register_ajax','mq_register_ajax',array('mq_ajax_url' => admin_url( 'admin-ajax.php' )));
wp_enqueue_script('mq_register_ajax');
}
add_action('wp_enqueue_scripts','enque_register');
function <API key>()
{
add_menu_page('Register Form Setting','Register Form','update_plugins','<API key>','mq_registerform_set','',1);
}
add_action('admin_menu','<API key>');
function mq_register_setting()
{
add_option('<API key>','','255','yes');
add_option('<API key>','','255','yes');
add_option('<API key>','','255','yes');
add_option('<API key>','','255','yes');
add_option('<API key>','','255','yes');
}
function mq_delete_setting()
{
delete_option('<API key>');
delete_option('<API key>');
delete_option('<API key>');
delete_option('<API key>');
delete_option('<API key>');
remove_shortcode('mq_register');
}
include_once('inc/mq_shortcode.php');
include_once('inc/mq_ajax.php');
include_once('inc/form_setting.php');
include_once('inc/form_create.php');
include_once('inc/script/register_action.php');
|
<?php
class <API key>{
private $db = false;
private $user;
private $edit_color = '#FFFFFF';
public function __construct(){
$this->db = Connection::getDB();
$this->user = new administrator();
if($this->user->role=='pupil' || $this->user->role=='parent'){
$this->edit_color = '#AAAAAA';
}
$this->db->query("START TRANSACTION");
error_reporting(E_ALL ^ E_NOTICE);
switch ($_POST['action']) {
case 'editresult':
$this->editResult($_POST['id'],$_POST['value'],$_POST['pass']);
break;
case 'editgrade':
$this->editGrade($_POST['id'],$_POST['value'],$_POST['pass']);
break;
case 'editassessment':
$this->editAssessment($_POST['id'],$_POST['assessment']);
break;
case 'deactive':
$this->deactivePerformance($_POST['id']);
break;
case 'reactive':
$this->reactivePerformance($_POST['id']);
break;
case 'editstatus':
$this->editStutus($_POST['assid'],$_POST['pid'],$_POST['value']);
break;
case 'makeassubmitted':
$this->makeAsSubmitted($_POST['assid'],$_POST['pid']);
break;
case 'makeasnotsubmitted':
$this->makeAsNotSubmitted($_POST['assid'],$_POST['pid']);
break;
case 'activate':
$this->activate($_POST['assid'],$_POST['pid'],$_POST['type']);
break;
case 'remove':
$this->remove($_POST['assid'],$_POST['pid'],$_POST['type']);
break;
case 'deactivate':
$this->deactivate($_POST['assid'],$_POST['pid'],$_POST['type']);
break;
default:
$this->getAssignmentsGrid();
break;
}
$this->db->query("COMMIT");
}
private function editStutus($id,$pid,$val){
$result = $this->db->query("UPDATE <API key> SET status='$val' WHERE assignment_id=$id AND pupil_id=$pid");
}
private function makeAsSubmitted($id,$pid){
$result = $this->db->query("UPDATE <API key> SET status='1', submission_date = NOW() WHERE assignment_id=$id AND pupil_id=$pid");
}
private function makeAsNotSubmitted($id,$pid){
$ns = dlang("grids_not_subm_text","Not subm.");
$result = $this->db->query("UPDATE <API key> SET status='$ns' WHERE assignment_id=$id AND pupil_id=$pid");
}
private function editResult($id,$val,$pass){
@session_start();
$_SESSION['submissions_update']=$this->user->id;
session_write_close();
$this->db->query("UPDATE <API key> SET result='$val', pass='$pass' WHERE <API key>=$id");
if($val=='A' || $val=='B'|| $val=='C'||$val=='D'||$val=='E'||$val=='F'||$val=='Fx'||$val==dlang("passvalue","Pass")||$val==dlang("npassvalue","NPass")){
$result = $this->db->query("UPDATE <API key> SET assessment='$val' WHERE <API key>=$id");
}
$this->db->query("UPDATE <API key>,<API key> SET <API key>.status='1' WHERE <API key>.submission_slot_id = <API key>.submission_slot_id
AND <API key>.<API key> = $id");
echo 1;
}
private function editGrade($id,$val,$pass){
$result = $this->db->query("UPDATE <API key> SET assessment='$assess', pass=$val WHERE <API key>=$id");
}
private function editAssessment($id, $assess){
$result = $this->db->query("UPDATE <API key> SET assessment='$assess' WHERE <API key>=$id");
}
private function remove($id,$pid,$type){
if($type=="performance"){
$result = $this->db->query("DELETE FROM <API key> WHERE pupil_id=$pid AND performance_id=$id");
}else{
$result = $this->db->query("DELETE FROM <API key> WHERE pupil_id=$pid AND assignment_id=$id");
}
}
private function activate($id,$pid,$type){
if($type=="performance"){
$this->db->query("UPDATE <API key> SET active=1, activation_date=NOW() WHERE pupil_id=$pid AND performance_id=$id");
}else{
$this->db->query("UPDATE <API key> SET active=1, activation_date=NOW() WHERE pupil_id=$pid AND assignment_id=$id");
}
}
private function deactivate($id,$pid,$type){
if($type=="performance"){
$this->db->query("UPDATE <API key> SET active=0 WHERE pupil_id=$pid AND performance_id=$id");
}else{
$this->db->query("UPDATE <API key> SET active=0 WHERE pupil_id=$pid AND assignment_id=$id");
}
}
private function getPerformanceArray($result,$rows){
//$rows = array();
while($row = mysql_fetch_assoc($result)){
$rows[$row['acyear_id']][$row['subject_id']][$row['s_id']]['performancep_'.$row['performance_id']][12] = $row['performance_id'];
$rows[$row['acyear_id']][$row['subject_id']][$row['s_id']]['performancep_'.$row['performance_id']][1] = $row['perf_title'];
$rows[$row['acyear_id']][$row['subject_id']][$row['s_id']]['performancep_'.$row['performance_id']][7] = $row['sid'];
$rows[$row['acyear_id']][$row['subject_id']][$row['s_id']]['performancep_'.$row['performance_id']][8] = $row['s_id'];
$rows[$row['acyear_id']][$row['subject_id']][$row['s_id']]['performancep_'.$row['performance_id']][11] = $row['active']?"1":"0.5";
$rows[$row['acyear_id']][$row['subject_id']][$row['s_id']]['performancep_'.$row['performance_id']][13] = $row['active'];
$rows[$row['acyear_id']][$row['subject_id']][$row['s_id']]['performancep_'.$row['performance_id']][10] = $row['active']?"#FFFFFF":"#F5F5F5";
$rows[$row['acyear_id']][$row['subject_id']][$row['s_id']]['performancep_'.$row['performance_id']][14][$row['pid']][0] = $row['pid'];
$rows[$row['acyear_id']][$row['subject_id']][$row['s_id']]['performancep_'.$row['performance_id']][14][$row['pid']][3]= $row['ass'];
$rows[$row['acyear_id']][$row['subject_id']][$row['s_id']]['performancep_'.$row['performance_id']][14][$row['pid']][13] = $row['active'];
$rows[$row['acyear_id']][$row['subject_id']][$row['s_id']]['performancep_'.$row['performance_id']][14][$row['pid']][10] = $row['active']?"#FFFFFF":"#F5F5F5";
$rows[$row['acyear_id']][$row['subject_id']][$row['s_id']]['performancep_'.$row['performance_id']][14][$row['pid']][11] = $row['active']?"1":"0.5";
$rows[$row['acyear_id']][$row['subject_id']][$row['s_id']]['performancep_'.$row['performance_id']][14][$row['pid']][4][] = $row['obj_title'];
if($row['ass'] == "" || $row['ass'] == "na"){
$rows[$row['acyear_id']][$row['subject_id']][$row['s_id']]['performancep_'.$row['performance_id']][14][$row['pid']][5] = $this->edit_color;
}elseif($row['ass'] == "F" || $row['ass'] == "Fx"){
$rows[$row['acyear_id']][$row['subject_id']][$row['s_id']]['performancep_'.$row['performance_id']][14][$row['pid']][5] = "#ff8888";
}else{
$rows[$row['acyear_id']][$row['subject_id']][$row['s_id']]['performancep_'.$row['performance_id']][14][$row['pid']][5] = "#88ff88";
}
}
//print_r($rows);
return $rows;
}
private function getAssignmentsGrid(){
header("Content-type:text/xml");
print('<?xml version="1.0" encoding="UTF-8"?>');
$id = $_GET['id'];
$and = "";
if(isset($_GET['stg']) && $_GET['stg']!=""){
$and = "AND studygroups.studygroup_id = ".$_GET['stg'];
}
$result = $this->db->query("
SELECT <API key>.number as numb, <API key>.title_en as title_assignment,
<API key>.assignment_id as aid,
DATEDIFF(<API key>.deadline_date, CURDATE()) as dl_date,
DATEDIFF(<API key>.deadline_date, <API key>.submission_date) as submission_date,
<API key>.deadline_date as deadline_date2,
<API key>.submission_date as submission_date2,
course_objectives.title_en as title_course_obj,
<API key>.deadline as deadline,
<API key>.deadline_passed as dp,
<API key>.content_en as pcont,
<API key>.status as status,
<API key>.active as active,
resultsets.result_max as max_rs,
resultsets.result_pass as pass_rs,
resultsets.studygroup_ids as studygroup_ids,
result_units.result_unit_en as unit_rs,
<API key>.result as subm_result,
<API key>.assessment as assessment,
<API key>.<API key> as psr,
studygroups.title_en as sid,
studygroups.studygroup_id as s_id,
result_units.result_unit_id as result_unit_id,
academic_years.title_en as acyear,
subjects.title_en as subject,
academic_years.academic_year_id as acyear_id,
subjects.subject_id as subject_id,
resultsets.castom_name as castom_name
FROM course_rooms,<API key>, <API key>, resultsets,
studygroups, course_objectives, result_units, <API key>, <API key>, academic_years, subjects
WHERE <API key>.assignment_id = <API key>.assignment_id
AND <API key>.course_room_id = course_rooms.course_room_id
AND course_rooms.course_room_id = studygroups.course_room_id
AND resultsets.assignment_id = <API key>.assignment_id
AND <API key>.resultset_id = resultsets.resultset_id
AND course_objectives.objective_id = <API key>.objective_id
AND result_units.result_unit_id = resultsets.result_unit_id
AND <API key>.result_set_id = resultsets.resultset_id
AND <API key>.submission_slot_id = <API key>.submission_slot_id
AND <API key>.pupil_id=$id
AND studygroups.subject_id=subjects.subject_id
AND subjects.academic_year_id = academic_years.academic_year_id
AND <API key>.type = 'assignment'
{$and}
");
$result_perf = $this->db->query("
SELECT performance.title_en as perf_title, <API key>.<API key> as pid,
course_objectives.title_en as obj_title,<API key>.assessment as ass,
<API key>.passed as passed,
<API key>.active as active,
studygroups.title_en as sid, studygroups.studygroup_id as s_id,
<API key>.performance_id as performance_id,
resultsets.resultset_id as resultset_id,
academic_years.title_en as acyear,
subjects.title_en as subject,
academic_years.academic_year_id as acyear_id,
subjects.subject_id as subject_id
FROM course_rooms, <API key>, performance, studygroups,resultsets,course_objectives,<API key>, academic_years, subjects
WHERE <API key>.performance_id = performance.performance_id
AND performance.course_room_id = course_rooms.course_room_id
AND course_rooms.course_room_id = studygroups.course_room_id
AND resultsets.resultset_id = <API key>.resultset_id
AND <API key>.resultset_id = resultsets.resultset_id
AND course_objectives.objective_id = <API key>.objective_id
AND <API key>.pupil_id = $id
AND studygroups.subject_id=subjects.subject_id
AND subjects.academic_year_id = academic_years.academic_year_id
AND <API key>.type = 'performance'
");
echo '<rows>';
$assarr = $this->getAssignmentsArray($result);
$perfarr = $this->getPerformanceArray($result_perf,$assarr);
//$perform = $this->outPerformanceArray($this->getPerformanceArray($result_perf));
$this->outAssignmentsArray($perfarr);
echo '</rows>';
}
private function outPerformanceArray($value2){
$perf_xml = '
<row id="performance_'.$value2[12].'">
<cell bgColor="'.$value2[10].'" style="opacity: '.$value2[11].';" sid="performance_'.$value2[12].'" image="assessment.png">'.$value2[1].'</cell>
<cell bgColor="'.$value2[10].'" style="opacity: '.$value2[11].';"/><cell style="opacity: '.$value2[11].';" bgColor="'.$value2[10].'"/>
<cell style="opacity: '.$value2[11].';" bgColor="'.$value2[10].'"/><cell style="opacity: '.$value2[11].';" bgColor="'.$value2[10].'"/>
<cell style="opacity: '.$value2[11].';" bgColor="'.$value2[10].'"/><cell bgColor="'.$value2[10].'"/>';
foreach ($value2[14] as $value3) {
$perf_xml.= '
<row id="p_'.$value3[0].'" style="opacity: '.$value3[11].';">
<cell bgColor="#FFFFFF" style="color:rgb(73, 74, 75); opacity: '.$value3[11].';" image="objective.png" >'.$value2[7].': '.implode(', ',$value3[4]).'</cell>
<cell bgColor="#FFFFFF" style="opacity: '.$value3[11].';"></cell>
<cell bgColor="#FFFFFF" style="opacity: '.$value3[11].';"></cell>
<cell bgColor="#FFFFFF" style="opacity: '.$value3[11].';"></cell>
<cell bgColor="#FFFFFF" style="opacity: '.$value3[11].';"></cell>
<cell bgColor="#FFFFFF" style="opacity: '.$value3[11].';">'.$value3[6].'</cell>
<cell style="opacity: '.$value3[11].';" xmlcontent="1" bgColor="'.$value3[5].'">'.$value3[3].'<option value="A">'."A".'</option>
<option value="B">'."B".'</option>
<option value="C">'."C".'</option>
<option value="D">'."D".'</option>
<option value="E">'."E".'</option>
<option value="F">'."F".'</option>
<option value="Fx">'."Fx".'</option>
<option value="">'."".'</option>
</cell>
</row>
';
}
$perf_xml.= '<userdata name="activate">'.$value2[13].'</userdata></row>';
return $perf_xml;
}
private function getAssignmentsArray($result){
$rows = array();
$graeds = array('A','B','C','D','E','F');
while($row = mysql_fetch_assoc($result)){
$rows[$row['acyear_id']][$row['subject_id']][$row['s_id']][0] = $row['sid'];
$rows[$row['acyear_id']][0] = $row['acyear'];
$rows[$row['acyear_id']][$row['subject_id']][0] = $row['subject'];
$rows[$row['acyear_id']][$row['subject_id']][$row['s_id']]['assignment_'.$row['aid']][0] = $row['aid'];
$rows[$row['acyear_id']][$row['subject_id']][$row['s_id']]['assignment_'.$row['aid']][2] = $row['title_assignment'];
$rows[$row['acyear_id']][$row['subject_id']][$row['s_id']]['assignment_'.$row['aid']][3] = $row['dp'];
$rows[$row['acyear_id']][$row['subject_id']][$row['s_id']]['assignment_'.$row['aid']][4] = $row['pcont'];
$rows[$row['acyear_id']][$row['subject_id']][$row['s_id']]['assignment_'.$row['aid']][5] = $row['dl_date'];
$rows[$row['acyear_id']][$row['subject_id']][$row['s_id']]['assignment_'.$row['aid']][20] = $row['deadline_date2'];
$rows[$row['acyear_id']][$row['subject_id']][$row['s_id']]['assignment_'.$row['aid']][21] = $row['submission_date2'];
$rows[$row['acyear_id']][$row['subject_id']][$row['s_id']]['assignment_'.$row['aid']][16] = $row['deadline'];
$rows[$row['acyear_id']][$row['subject_id']][$row['s_id']]['assignment_'.$row['aid']][6] = $row['status'];
$rows[$row['acyear_id']][$row['subject_id']][$row['s_id']]['assignment_'.$row['aid']][7] = $row['title_course'];
$rows[$row['acyear_id']][$row['subject_id']][$row['s_id']]['assignment_'.$row['aid']][9] = $row['sid'];
$rows[$row['acyear_id']][$row['subject_id']][$row['s_id']]['assignment_'.$row['aid']][10] = $row['active']?"#FFFFFF":"#F5F5F5";
$rows[$row['acyear_id']][$row['subject_id']][$row['s_id']]['assignment_'.$row['aid']][11] = $row['active']?"1":"0.5";
$rows[$row['acyear_id']][$row['subject_id']][$row['s_id']]['assignment_'.$row['aid']][12] = $row['active'];
$rows[$row['acyear_id']][$row['subject_id']][$row['s_id']]['assignment_'.$row['aid']][15] = $row['submission_date'];
$rows[$row['acyear_id']][$row['subject_id']][$row['s_id']]['assignment_'.$row['aid']][8][$row['psr']][0] = $row['psr'];
$rows[$row['acyear_id']][$row['subject_id']][$row['s_id']]['assignment_'.$row['aid']][8][$row['psr']][1] = $row['castom_name'];
$rows[$row['acyear_id']][$row['subject_id']][$row['s_id']]['assignment_'.$row['aid']][8][$row['psr']][2] = $row['max_rs'];
$rows[$row['acyear_id']][$row['subject_id']][$row['s_id']]['assignment_'.$row['aid']][8][$row['psr']][3] = $row['pass_rs'];
$rows[$row['acyear_id']][$row['subject_id']][$row['s_id']]['assignment_'.$row['aid']][8][$row['psr']][4] = $row['subm_result'];
$rows[$row['acyear_id']][$row['subject_id']][$row['s_id']]['assignment_'.$row['aid']][8][$row['psr']][6] = $row['dl_date'];
$rows[$row['acyear_id']][$row['subject_id']][$row['s_id']]['assignment_'.$row['aid']][8][$row['psr']][7] = $row['sid'];
$rows[$row['acyear_id']][$row['subject_id']][$row['s_id']]['assignment_'.$row['aid']][8][$row['psr']][8] = $row['s_id'];
$rows[$row['acyear_id']][$row['subject_id']][$row['s_id']]['assignment_'.$row['aid']][8][$row['psr']][9] = $row['assessment'];
$rows[$row['acyear_id']][$row['subject_id']][$row['s_id']]['assignment_'.$row['aid']][8][$row['psr']][12] = $row['result_unit_id'];
$rows[$row['acyear_id']][$row['subject_id']][$row['s_id']]['assignment_'.$row['aid']][8][$row['psr']][14] = $row['studygroup_ids'];
if($row['assessment']=="p"){
$rows[$row['acyear_id']][$row['subject_id']][$row['s_id']]['assignment_'.$row['aid']][8][$row['psr']][9] = dlang("passvalue","Pass");
}
if($row['assessment']=="np"){
$rows[$row['acyear_id']][$row['subject_id']][$row['s_id']]['assignment_'.$row['aid']][8][$row['psr']][9] = dlang("npassvalue","NPass");
}
$rows[$row['acyear_id']][$row['subject_id']][$row['s_id']]['assignment_'.$row['aid']][8][$row['psr']][10] = $row['title_course'];
$pass = $row['pass_rs'];
$res = $row['subm_result'];
switch ($row['result_unit_id']) {
case '1':
if((int)$pass <= (int)$res){
$rows[$row['acyear_id']][$row['subject_id']][$row['s_id']]['assignment_'.$row['aid']][8][$row['psr']][11] = "#88ff88";
}else{
$rows[$row['acyear_id']][$row['subject_id']][$row['s_id']]['assignment_'.$row['aid']][8][$row['psr']][11] = "#ff8888";
}
break;
case '2':
if((int)$pass <= (int)$res){
$rows[$row['acyear_id']][$row['subject_id']][$row['s_id']]['assignment_'.$row['aid']][8][$row['psr']][11] = "#88ff88";
}else{
$rows[$row['acyear_id']][$row['subject_id']][$row['s_id']]['assignment_'.$row['aid']][8][$row['psr']][11] = "#ff8888";
}
break;
case '3':
if(array_search($pass,$graeds)>=array_search($res,$graeds)){
$rows[$row['acyear_id']][$row['subject_id']][$row['s_id']]['assignment_'.$row['aid']][8][$row['psr']][11] = "#88ff88";
}else{
$rows[$row['acyear_id']][$row['subject_id']][$row['s_id']]['assignment_'.$row['aid']][8][$row['psr']][11] = "#ff8888";
}
break;
case '4':
if(strtolower($res)==dlang("passvalue","Pass")){
$rows[$row['acyear_id']][$row['subject_id']][$row['s_id']]['assignment_'.$row['aid']][8][$row['psr']][11] = "#88ff88";
}else{
$rows[$row['acyear_id']][$row['subject_id']][$row['s_id']]['assignment_'.$row['aid']][8][$row['psr']][11] = "#ff8888";
}
break;
}
if($res==""){
$rows[$row['acyear_id']][$row['subject_id']][$row['s_id']]['assignment_'.$row['aid']][8][$row['psr']][11] = $this->edit_color;
}
if($row['assessment']!=""){
if($row['assessment']=='F' || $row['assessment']=="Fx" || $row['assessment']==dlang("npassvalue","NPass")){
$rows[$row['acyear_id']][$row['subject_id']][$row['s_id']]['assignment_'.$row['aid']][8][$row['psr']][11] = "#ff8888";
}else{
$rows[$row['acyear_id']][$row['subject_id']][$row['s_id']]['assignment_'.$row['aid']][8][$row['psr']][11] = "#88ff88";
}
}
$rows[$row['acyear_id']][$row['subject_id']][$row['s_id']]['assignment_'.$row['aid']][8][$row['psr']][5][] = $row['title_course_obj'];
}
// print_r($rows);
return $rows;
}
private function outStgsArray($stg){
foreach ($stg as $key => $group){
if($key=="0")
continue;
echo '
<row id="stg_'.$key.'">
<cell style="color:rgb(73, 74, 75);" sid="stg_'.$key.'" image="studygroup.png">'.$group[0].'</cell>';
foreach ($group as $key2 => $assignment){
if($key2=="0"){
continue;
}
$tkey2 = explode('_',$key2);
if($tkey2[0] == 'performancep'){
echo $this->outPerformanceArray($assignment);
continue;
}
echo '<row style="color:rgb(73, 74, 75); opacity: '.$assignment[11].';" bgColor="'.$assignment[10].'" id="assignment_'.$assignment[0].'"><cell bgColor="'.$assignment[10].'" style="color:rgb(73, 74, 75); opacity: '.$assignment[11].';" image="submission.png">'.$assignment[2].'</cell>';
if($assignment[6]!="1" && $assignment[6]!=dlang("grids_not_subm_text","Not subm.") && $assignment[6]!="Not subm."){
echo '<cell bgColor="'.$this->edit_color.'" style="color:#006699; opacity: '.$assignment[11].';">'.$assignment[6].'</cell>';
}else{
if($assignment[5]>=0 && ($assignment[6]==dlang("grids_not_subm_text","Not subm.") || $assignment[6]=="Not subm.") ){
echo '<cell bgColor="'.$this->edit_color.'" style="color:#6495ED; opacity: '.$assignment[11].';">'.dlang("grids_not_subm_text","Not subm.").'</cell>';
}elseif($assignment[5]<0 && ($assignment[6]==dlang("grids_not_subm_text","Not subm."))){
echo '<cell bgColor="'.$this->edit_color.'" style="color:#EE6A50; opacity: '.$assignment[11].';">'.dlang("grids_not_subm_text","Not subm.").'</cell>';
}else{
if($assignment[16]=='No deadline'){
echo '<cell bgColor="'.$this->edit_color.'" style="color:green; opacity: '.$assignment[9].';">'.dlang("grids_subm_text","Subm.").'</cell>';
}else{
if($assignment[15]>=0){
if($assignment[21]<=$assignment[20]){
echo '<cell bgColor="'.$this->edit_color.'" style="color:green; opacity: '.$assignment[13].';">'.abs($assignment[15]).' '.dlang("grids_not_subm_daye","day early").'</cell>';
}else{
echo '<cell bgColor="'.$this->edit_color.'" style="color:red; opacity: '.$assignment[13].';">'.abs($assignment[15]).' '.dlang("grids_not_subm_dayl","day late").'</cell>';
}
}else{
echo '<cell bgColor="'.$this->edit_color.'" style="color:red; opacity: '.$assignment[13].';">'.abs($assignment[15]).' '.dlang("grids_not_subm_dayl","day late").'</cell>';
}
}
}
}
echo '<cell bgColor="'.$assignment[10].'"/><cell bgColor="'.$assignment[10].'"/><cell bgColor="'.$assignment[10].'"/><cell bgColor="'.$assignment[10].'"/><cell bgColor="'.$assignment[10].'"/>';
foreach ($assignment[8] as $key3 => $rset) {
$sql = "SELECT title_en FROM studygroups WHERE studygroup_id IN (".$rset[14].")";
$result = $this->db->query($sql);
$sgids = null;
while($row = mysql_fetch_assoc($result)){
$sgids[] = $row['title_en'];
}
echo '
<row id="a_'.$rset[0].'" style="opacity: '.$assignment[11].';">
<cell image="objective.png" bgColor="#FFFFFF" style="opacity: '.$assignment[11].'; color:rgb(73, 74, 75);">'.implode(', ', $sgids).': '.implode(', ',$rset[5]).'</cell>
<cell bgColor="#FFFFFF" style="color:rgb(73, 74, 75); opacity: '.$assignment[11].';"></cell>
<cell bgColor="#FFFFFF" style="color:rgb(73, 74, 75); opacity: '.$assignment[11].';">'.$rset[1].'</cell>
<cell bgColor="#FFFFFF" style="color:rgb(73, 74, 75); opacity: '.$assignment[11].';">'.$rset[2].'</cell>
<cell bgColor="#FFFFFF" style="color:rgb(73, 74, 75); opacity: '.$assignment[11].';">'.$rset[3].'</cell>
';
switch ($rset[12]) {
case '1':
echo '<cell type="ed" bgColor="'.$this->edit_color.'" style="color:rgb(73, 74, 75); opacity: '.$assignment[11].';">'.$rset[4].'</cell>';
break;
case '2':
echo '<cell type="ed" bgColor="'.$this->edit_color.'" style="color:rgb(73, 74, 75); opacity: '.$assignment[11].';">'.$rset[4].'</cell>';
break;
case '3':
echo '<cell type="co" xmlcontent="1" bgColor="'.$this->edit_color.'" style="color:rgb(73, 74, 75); opacity: '.$assignment[11].';">'.$rset[4].'<option value="'."A".'">'."A".'</option>
<option value="B">'."B".'</option>
<option value="C">'."C".'</option>
<option value="D">'."D".'</option>
<option value="E">'."E".'</option>
<option value="F">'."F".'</option>
<option value="Fx">'."Fx".'</option>
</cell>
';
break;
case '4':
echo '<cell type="co" xmlcontent="1" bgColor="'.$this->edit_color.'" style="color:rgb(73, 74, 75); opacity: '.$assignment[11].';">'.dlang($rset[4]).'<option value="'.dlang("passvalue","Pass").'">'.dlang("passvalue","Pass").'</option>
<option value="'.dlang("npassvalue","NPass").'">'.dlang("npassvalue","NPass").'</option>
<option value="">'."".'</option>
</cell>';
break;
default:
break;
}
if($rset[12]=='4'){
echo '<cell xmlcontent="1" bgColor="'.$rset[11].'" style="color:rgb(73, 74, 75); opacity: '.$assignment[11].';">'.$rset[9].'<option value="'.dlang("passvalue","Pass").'">'.dlang("passvalue","Pass").'</option>
<option value="'.dlang("npassvalue","NPass").'">'.dlang("npassvalue","NPass").'</option>
<option value="">'."".'</option>
</cell><userdata name="unit">'.$rset[12].'</userdata></row>';
}else{
echo '<cell xmlcontent="1" bgColor="'.$rset[11].'" style="color:rgb(73, 74, 75); opacity: '.$assignment[11].';">'.$rset[9].'<option value="'."A".'">'."A".'</option>
<option value="B">'."B".'</option>
<option value="C">'."C".'</option>
<option value="D">'."D".'</option>
<option value="E">'."E".'</option>
<option value="F">'."F".'</option>
<option value="Fx">'."Fx".'</option>
<option value="">'."".'</option>
</cell><userdata name="unit">'.$rset[12].'</userdata></row>';
}
}
echo "<userdata name='submitted'>".($assignment[6]=="1"?1:0)."</userdata>";
echo "<userdata name='activate'>".$assignment[12]."</userdata>";
echo '</row>';
}
echo '</row>';
}
}
private function outAssignmentsArray($acyears){
foreach($acyears as $yid => $year){
if($yid=="0")
continue;
echo '<row id="year_'.$yid.'">
<cell style="color:rgb(73, 74, 75);" sid="year_'.$yid.'" image="folder_closed.png">'.$year[0].'</cell>';
foreach($year as $subid => $subject){
if($subid=="0" || !$subject[0])
continue;
echo '<row id="subject_'.$subid.'">
<cell style="color:rgb(73, 74, 75);" sid="subject_'.$subid.'" image="folder_closed.png">'.$subject[0].'</cell>';
$this->outStgsArray($subject);
echo '</row>';
}
echo '</row>';
}
}
}
?>
|
.admanage-img p img{
width: 300px;
height:100px;
display: block;
float: left;
}
|
#include "stdinc.h"
#include "s_misc.h"
#include "client.h"
#include "common.h"
#include "irc_string.h"
#include "sprintf_irc.h"
#include "ircd.h"
#include "numeric.h"
#include "irc_res.h"
#include "fdlist.h"
#include "s_bsd.h"
#include "s_conf.h"
#include "s_serv.h"
#include "send.h"
#include "memory.h"
static const char *months[] =
{
"January", "February", "March", "April",
"May", "June", "July", "August",
"September", "October", "November","December"
};
static const char *weekdays[] =
{
"Sunday", "Monday", "Tuesday", "Wednesday",
"Thursday", "Friday", "Saturday"
};
char *
date(time_t lclock)
{
static char buf[80], plus;
struct tm *lt, *gm;
struct tm gmbuf;
int minswest;
if (!lclock)
lclock = CurrentTime;
gm = gmtime(&lclock);
memcpy(&gmbuf, gm, sizeof(gmbuf));
gm = &gmbuf;
lt = localtime(&lclock);
/*
* There is unfortunately no clean portable way to extract time zone
* offset information, so do ugly things.
*/
minswest = (gm->tm_hour - lt->tm_hour) * 60 + (gm->tm_min - lt->tm_min);
if (lt->tm_yday != gm->tm_yday)
{
if ((lt->tm_yday > gm->tm_yday && lt->tm_year == gm->tm_year) ||
(lt->tm_yday < gm->tm_yday && lt->tm_year != gm->tm_year))
minswest -= 24 * 60;
else
minswest += 24 * 60;
}
plus = (minswest > 0) ? '-' : '+';
if (minswest < 0)
minswest = -minswest;
ircsprintf(buf, "%s %s %d %d -- %02u:%02u:%02u %c%02u:%02u",
weekdays[lt->tm_wday], months[lt->tm_mon],lt->tm_mday,
lt->tm_year + 1900, lt->tm_hour, lt->tm_min, lt->tm_sec,
plus, minswest/60, minswest%60);
return buf;
}
const char *
smalldate(time_t lclock)
{
static char buf[MAX_DATE_STRING];
struct tm *lt, *gm;
struct tm gmbuf;
if (!lclock)
lclock = CurrentTime;
gm = gmtime(&lclock);
memcpy(&gmbuf, gm, sizeof(gmbuf));
gm = &gmbuf;
lt = localtime(&lclock);
ircsprintf(buf, "%d/%d/%d %02d.%02d",
lt->tm_year + 1900, lt->tm_mon + 1, lt->tm_mday,
lt->tm_hour, lt->tm_min);
return buf;
}
/* small_file_date()
* Make a small YYYYMMDD formatted string suitable for a
* dated file stamp.
*/
char *
small_file_date(time_t lclock)
{
static char timebuffer[MAX_DATE_STRING];
struct tm *tmptr;
if (!lclock)
time(&lclock);
tmptr = localtime(&lclock);
strftime(timebuffer, MAX_DATE_STRING, "%Y%m%d", tmptr);
return timebuffer;
}
#ifdef HAVE_LIBCRYPTO
char *
ssl_get_cipher(SSL *ssl)
{
static char buffer[128];
const char *name = NULL;
int bits;
switch (ssl->session->ssl_version)
{
case SSL2_VERSION:
name = "SSLv2";
break;
case SSL3_VERSION:
name = "SSLv3";
break;
case TLS1_VERSION:
name = "TLSv1";
break;
default:
name = "UNKNOWN";
}
SSL_CIPHER_get_bits(<API key>(ssl), &bits);
snprintf(buffer, sizeof(buffer), "%s %s-%d",
name, SSL_get_cipher(ssl), bits);
return buffer;
}
#endif
|
#ifndef <API key>
#define <API key>
#include <npm/gfx/Drawing.hpp>
namespace npm {
class RobotServer;
class TrajectoryDrawing
: public Drawing
{
public:
TrajectoryDrawing(const RobotServer * owner);
virtual void Draw();
private:
const RobotServer * m_owner;
};
}
#endif // <API key>
|
#include <extconf.h>
#include "rb_gsl_array.h"
#include <gsl/gsl_heapsort.h>
#include <gsl/gsl_sort.h>
EXTERN ID RBGSL_ID_call;
EXTERN VALUE cgsl_complex;
int <API key>(const void *aa, const void *bb);
int <API key>(const void *aa, const void *bb);
int <API key>(const void *aa, const void *bb)
{
double *a = NULL, *b = NULL;
a = (double *) aa;
b = (double *) bb;
return FIX2INT(rb_funcall(RB_GSL_MAKE_PROC, RBGSL_ID_call, 2, rb_float_new(*a), rb_float_new(*b)));
}
int <API key>(const void *aa, const void *bb)
{
gsl_complex *a = NULL, *b = NULL;
a = (gsl_complex *) aa;
b = (gsl_complex *) bb;
return FIX2INT(rb_funcall(RB_GSL_MAKE_PROC, RBGSL_ID_call, 2,
Data_Wrap_Struct(cgsl_complex, 0, NULL, a),
Data_Wrap_Struct(cgsl_complex, 0, NULL, b)));
}
static VALUE <API key>(VALUE obj)
{
gsl_vector *v = NULL;
if (!rb_block_given_p()) rb_raise(rb_eRuntimeError, "Proc is not given");
Data_Get_Struct(obj, gsl_vector, v);
gsl_heapsort(v->data, v->size, sizeof(double), <API key>);
return obj;
}
static VALUE <API key>(VALUE obj)
{
gsl_vector *v = NULL, *vnew = NULL;
if (!rb_block_given_p()) rb_raise(rb_eRuntimeError, "Proc is not given");
Data_Get_Struct(obj, gsl_vector, v);
vnew = gsl_vector_alloc(v->size);
gsl_vector_memcpy(vnew, v);
gsl_heapsort(vnew->data, vnew->size, sizeof(double), <API key>);
return Data_Wrap_Struct(cgsl_vector, 0, gsl_vector_free, vnew);
}
static VALUE <API key>(VALUE obj)
{
gsl_vector *v = NULL;
gsl_permutation *p = NULL;
if (!rb_block_given_p()) rb_raise(rb_eRuntimeError, "Proc is not given");
Data_Get_Struct(obj, gsl_vector, v);
p = <API key>(v->size);
gsl_heapsort_index(p->data, v->data, v->size, sizeof(double), <API key>);
return Data_Wrap_Struct(cgsl_permutation, 0, <API key>, p);
}
static VALUE <API key>(VALUE obj)
{
gsl_vector_complex *v = NULL;
if (!rb_block_given_p()) rb_raise(rb_eRuntimeError, "Proc is not given");
Data_Get_Struct(obj, gsl_vector_complex, v);
gsl_heapsort(v->data, v->size, sizeof(gsl_complex), <API key>);
return obj;
}
static VALUE <API key>(VALUE obj)
{
gsl_vector_complex *v = NULL, *vnew = NULL;
if (!rb_block_given_p()) rb_raise(rb_eRuntimeError, "Proc is not given");
Data_Get_Struct(obj, gsl_vector_complex, v);
vnew = <API key>(v->size);
<API key>(vnew, v);
gsl_heapsort(vnew->data, vnew->size, sizeof(gsl_complex), <API key>);
return Data_Wrap_Struct(cgsl_vector_complex, 0, <API key>, vnew);
}
static VALUE <API key>(VALUE obj)
{
gsl_vector_complex *v = NULL;
gsl_permutation *p = NULL;
if (!rb_block_given_p()) rb_raise(rb_eRuntimeError, "Proc is not given");
Data_Get_Struct(obj, gsl_vector_complex, v);
p = <API key>(v->size);
gsl_heapsort_index(p->data, v->data, v->size, sizeof(gsl_complex), <API key>);
return Data_Wrap_Struct(cgsl_permutation, 0, <API key>, p);
}
/* singleton */
static VALUE rb_gsl_heapsort(VALUE obj, VALUE vv)
{
if (!rb_block_given_p()) rb_raise(rb_eRuntimeError, "Proc is not given");
if (rb_obj_is_kind_of(vv, cgsl_vector_complex)) {
return <API key>(vv);
} else if (rb_obj_is_kind_of(vv, cgsl_vector)) {
return <API key>(vv);
} else {
rb_raise(rb_eTypeError, "wrong argument type %s (Vector or Vector::Complex expected)", rb_class2name(CLASS_OF(vv)));
}
return vv;
}
static VALUE rb_gsl_heapsort2(VALUE obj, VALUE vv)
{
if (!rb_block_given_p()) rb_raise(rb_eRuntimeError, "Proc is not given");
if (rb_obj_is_kind_of(vv, cgsl_vector_complex)) {
return <API key>(vv);
} else if (rb_obj_is_kind_of(vv, cgsl_vector)) {
return <API key>(vv);
} else {
rb_raise(rb_eTypeError, "wrong argument type %s (Vector or Vector::Complex expected)", rb_class2name(CLASS_OF(vv)));
}
return vv;
}
static VALUE <API key>(VALUE obj, VALUE vv)
{
if (!rb_block_given_p()) rb_raise(rb_eRuntimeError, "Proc is not given");
if (rb_obj_is_kind_of(vv, cgsl_vector_complex)) {
return <API key>(vv);
} else if (rb_obj_is_kind_of(vv, cgsl_vector)) {
return <API key>(vv);
} else {
rb_raise(rb_eTypeError, "wrong argument type %s (Vector or Vector::Complex expected)", rb_class2name(CLASS_OF(vv)));
}
return vv;
}
#ifdef HAVE_NARRAY_H
#include "narray.h"
static VALUE rb_gsl_sort_narray(VALUE obj)
{
struct NARRAY *na;
size_t size, stride;
double *ptr1, *ptr2;
VALUE ary;
GetNArray(obj, na);
ptr1 = (double*) na->ptr;
size = na->total;
stride = 1;
ary = na_make_object(NA_DFLOAT, na->rank, na->shape, CLASS_OF(obj));
ptr2 = NA_PTR_TYPE(ary, double*);
memcpy(ptr2, ptr1, sizeof(double)*size);
gsl_sort(ptr2, stride, size);
return ary;
}
static VALUE <API key>(VALUE obj)
{
struct NARRAY *na;
size_t size, stride;
double *ptr1;
GetNArray(obj, na);
ptr1 = (double*) na->ptr;
size = na->total;
stride = 1;
gsl_sort(ptr1, stride, size);
return obj;
}
static VALUE <API key>(VALUE obj)
{
struct NARRAY *na;
size_t size, stride;
double *ptr1;
gsl_permutation *p;
GetNArray(obj, na);
ptr1 = (double*) na->ptr;
size = na->total;
stride = 1;
p = <API key>(size);
gsl_sort_index(p->data, ptr1, stride, size);
return Data_Wrap_Struct(cgsl_permutation, 0, <API key>, p);
}
#endif
void Init_gsl_sort(VALUE module)
{
<API key>(module, "heapsort!", rb_gsl_heapsort, 1);
<API key>(module, "heapsort", rb_gsl_heapsort2, 1);
<API key>(module, "heapsort_index", <API key>, 1);
rb_define_method(cgsl_vector, "heapsort!", <API key>, 0);
rb_define_method(cgsl_vector, "heapsort", <API key>, 0);
rb_define_method(cgsl_vector, "heapsort_index", <API key>, 0);
rb_define_method(cgsl_vector_complex, "heapsort!", <API key>, 0);
rb_define_method(cgsl_vector_complex, "heapsort", <API key>, 0);
rb_define_method(cgsl_vector_complex, "heapsort_index", <API key>, 0);
#ifdef HAVE_NARRAY_H
rb_define_method(cNArray, "gsl_sort", rb_gsl_sort_narray, 0);
rb_define_method(cNArray, "gsl_sort!", <API key>, 0);
rb_define_method(cNArray, "gsl_sort_index", <API key>, 0);
#endif
}
|
#include "servercore.h"
#include "servercore_p.h"
#include "<API key>.h"
#include "serverconnection.h"
#ifdef BUILD_DBUS_SUPPORT
#include "dbus/dbuscontroller.h"
#endif
#include "modelpool.h"
#include "localserver.h"
#include "tcpserver.h"
#include "backend.h"
#include "storagemodel.h"
#include "global.h"
#include "asyncmodel.h"
#include <QtCore/QHash>
#include <QtCore/QDebug>
#include <QtCore/QDir>
#include <QtNetwork/QTcpServer>
#include <QtNetwork/QHostAddress>
#include <QtNetwork/QTcpSocket>
#include <QtDBus/QtDBus>
const quint16 Soprano::Server::ServerCore::DEFAULT_PORT = 5000;
void Soprano::Server::ServerCorePrivate::addConnection( ServerConnection* conn )
{
connections.append( conn );
QObject::connect( conn, SIGNAL(destroyed(QObject*)), q, SLOT(<API key>(QObject*)) );
conn->start();
qDebug() << Q_FUNC_INFO << "New connection. New count:" << connections.count();
}
Soprano::Server::ServerCore::ServerCore( QObject* parent )
: QObject( parent ),
d( new ServerCorePrivate() )
{
d->q = this;
// default backend
d->backend = Soprano::usedBackend();
d->modelPool = new ModelPool( this );
}
Soprano::Server::ServerCore::~ServerCore()
{
#ifdef BUILD_DBUS_SUPPORT
delete d->dbusController;
#endif
foreach(const Soprano::Server::ServerConnection* con, d->connections) {
delete con;
}
qDeleteAll( d->models );
delete d->modelPool;
delete d;
}
void Soprano::Server::ServerCore::setBackend( const Backend* backend )
{
d->backend = backend;
}
const Soprano::Backend* Soprano::Server::ServerCore::backend() const
{
return d->backend;
}
void Soprano::Server::ServerCore::setBackendSettings( const QList<BackendSetting>& settings )
{
d->settings = settings;
}
QList<Soprano::BackendSetting> Soprano::Server::ServerCore::backendSettings() const
{
return d->settings;
}
void Soprano::Server::ServerCore::<API key>( int max )
{
d->maxConnectionCount = max;
}
int Soprano::Server::ServerCore::<API key>() const
{
return d->maxConnectionCount;
}
Soprano::Model* Soprano::Server::ServerCore::model( const QString& name )
{
QHash<QString, Model*>::const_iterator it = d->models.constFind( name );
if ( it == d->models.constEnd() ) {
BackendSettings settings = d-><API key>( name );
if ( isOptionInSettings( settings, <API key> ) ) {
QDir().mkpath( valueInSettings( settings, <API key> ).toString() );
}
Model* model = createModel( settings );
d->models.insert( name, model );
return model;
}
else {
return *it;
}
}
void Soprano::Server::ServerCore::removeModel( const QString& name )
{
clearError();
QHash<QString, Model*>::iterator it = d->models.find( name );
if ( it == d->models.end() ) {
setError( QString( "Could not find model with name %1" ).arg( name ) );
}
else {
Model* model = *it;
d->models.erase( it );
// delete the model, removing any cached data
delete model;
if ( isOptionInSettings( d->settings, <API key> ) ) {
// remove the data on disk
backend()->deleteModelData( d-><API key>( name ) );
// remove the dir which should now be empty
QDir( valueInSettings( d->settings, <API key> ).toString() ).rmdir( name );
}
}
}
bool Soprano::Server::ServerCore::listen( quint16 port )
{
clearError();
if ( !d->tcpServer ) {
d->tcpServer = new TcpServer( d, this );
}
if ( !d->tcpServer->listen( QHostAddress::Any, port ) ) {
setError( QString( "Failed to start listening at port %1 on localhost." ).arg( port ) );
qDebug() << "Failed to start listening at port " << port;
return false;
}
else {
qDebug() << "Listening on port " << port;
return true;
}
}
void Soprano::Server::ServerCore::stop()
{
qDebug() << "Stopping and deleting";
foreach(const Soprano::Server::ServerConnection* con, d->connections) {
delete con;
}
qDeleteAll( d->models );
delete d->tcpServer;
d->tcpServer = 0;
delete d->socketServer;
d->socketServer = 0;
#ifdef BUILD_DBUS_SUPPORT
delete d->dbusController;
d->dbusController = 0;
#endif
}
quint16 Soprano::Server::ServerCore::serverPort() const
{
if ( d->tcpServer ) {
return d->tcpServer->serverPort();
}
else {
return 0;
}
}
bool Soprano::Server::ServerCore::start( const QString& name )
{
clearError();
if ( !d->socketServer ) {
d->socketServer = new LocalServer( d, this );
}
QString path( name );
if ( path.isEmpty() ) {
path = QDir::homePath() + QLatin1String( "/.soprano/socket" );
}
if ( !d->socketServer->listen( path ) ) {
setError( QString( "Failed to start listening at %1." ).arg( path ) );
return false;
}
else {
return true;
}
}
void Soprano::Server::ServerCore::<API key>( const QString& objectPath )
{
#ifdef BUILD_DBUS_SUPPORT
if ( !d->dbusController ) {
QString path( objectPath );
if ( path.isEmpty() ) {
path = "/org/soprano/Server";
}
d->dbusController = new Soprano::Server::DBusController( this, path );
}
#else
qFatal("Soprano has been built without D-Bus support!" );
#endif
}
void Soprano::Server::ServerCore::<API key>(QObject* obj)
{
qDebug() << Q_FUNC_INFO << d->connections.count();
// We use static_cast cause qobject_case will fail since the object has been destroyed
ServerConnection* conn = static_cast<ServerConnection*>( obj );
d->connections.removeAll( conn );
qDebug() << Q_FUNC_INFO << "Connection removed. Current count:" << d->connections.count();
}
Soprano::Model* Soprano::Server::ServerCore::createModel( const QList<BackendSetting>& settings )
{
Model* m = backend()->createModel( settings );
if ( m ) {
clearError();
}
else if ( backend()->lastError() ) {
setError( backend()->lastError() );
}
else {
setError( "Could not create new Model for unknown reason" );
}
return m;
}
QStringList Soprano::Server::ServerCore::allModels() const
{
return d->models.keys();
}
|
package es.uniovi.asw.gui.util.form.validator.specific;
import es.uniovi.asw.gui.util.form.validator.composite.CheckAllValidator;
import es.uniovi.asw.gui.util.form.validator.simple.LengthValidator;
import es.uniovi.asw.gui.util.form.validator.simple.NumberValidator;
public class TelephoneValidator extends CheckAllValidator {
public TelephoneValidator() {
super(new NumberValidator(), new LengthValidator(9));
}
@Override
public String help() {
return "Slo nmeros, 9 caracteres.";
}
}
|
Package.describe({
summary: "Next bike list package"
});
Package.on_use(function (api) {
api.use(['nb','underscore', 'templating', 'nb-autocomplete', 'nb-markers', 'nb-infowindow', 'nb-directions', 'nb-geocoder', 'nb-markerlabel', 'nb-citypicker'], ['client']);
api.add_files(['list.html', 'list.js'], ['client']);
});
|
<?php
if (!defined('IN_PHPBB'))
{
exit;
}
if (empty($lang) || !is_array($lang))
{
$lang = array();
}
$lang = array_merge($lang, array(
'ACP_POST_LINKS' => 'Post links',
'PL_ENABLE' => 'Tillåt inläggslänkar',
'PL_ENABLE_EXPLAIN' => 'Om tillåtna, varje länk kommer att innehålla kopierbara av de typer som tillåts nedan.',
'PL_LINK_ENABLE' => 'Tillåt normallänk',
'PL_BBCODE_ENABLE' => 'Tillåt BB-kodlänk',
'PL_HTML_ENABLE' => 'Tillåt HTML-länk',
));
|
package com.greenpineyu.fel.function.operator;
import java.lang.reflect.<API key>;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.greenpineyu.fel.Expression;
import com.greenpineyu.fel.common.ArrayUtils;
import com.greenpineyu.fel.common.Null;
import com.greenpineyu.fel.common.ReflectUtil;
import com.greenpineyu.fel.compile.FelMethod;
import com.greenpineyu.fel.compile.SourceBuilder;
import com.greenpineyu.fel.context.FelContext;
import com.greenpineyu.fel.function.CommonFunction;
import com.greenpineyu.fel.function.Function;
import com.greenpineyu.fel.parser.FelNode;
import com.greenpineyu.fel.security.SecurityMgr;
public class Dot implements Function {
private static final Logger logger = LoggerFactory.getLogger(Dot.class);
private SecurityMgr securityMgr;
public SecurityMgr getSecurityMgr() {
return securityMgr;
}
public void setSecurityMgr(SecurityMgr securityMgr) {
this.securityMgr = securityMgr;
}
static final Map<Class<?>, Class<?>> PRIMITIVE_TYPES;
static {
PRIMITIVE_TYPES = new HashMap<Class<?>, Class<?>>();
PRIMITIVE_TYPES.put(Boolean.class, Boolean.TYPE);
PRIMITIVE_TYPES.put(Byte.class, Byte.TYPE);
PRIMITIVE_TYPES.put(Character.class, Character.TYPE);
PRIMITIVE_TYPES.put(Double.class, Double.TYPE);
PRIMITIVE_TYPES.put(Float.class, Float.TYPE);
PRIMITIVE_TYPES.put(Integer.class, Integer.TYPE);
PRIMITIVE_TYPES.put(Long.class, Long.TYPE);
PRIMITIVE_TYPES.put(Short.class, Short.TYPE);
}
public static final String DOT = ".";
@Override
public String getName() {
return DOT;
}
@Override
public Object call(FelNode node, FelContext context) {
List<FelNode> children = node.getChildren();
Object left = children.get(0);
if (left instanceof Expression) {
Expression exp = (Expression) left;
left = exp.eval(context);
}
FelNode right = children.get(1);
FelNode exp = right;
Class<?>[] argsType = new Class<?>[0];
Object[] args = CommonFunction.evalArgs(right, context);
if (!ArrayUtils.isEmpty(args)) {
argsType = new Class[args.length];
for (int i = 0; i < args.length; i++) {
if (args[i] == null) {
argsType[i] = Null.class;
continue;
}
argsType[i] = args[i].getClass();
}
}
Method method = null;
Class<?> cls = left instanceof Class<?> ? (Class<?>) left : left.getClass();
String methodName = right.getText();
method = findMethod(cls, methodName, argsType);
if (method == null) {
String getMethod = "get";
method = findMethod(cls, getMethod, new Class<?>[] { String.class });
args = new Object[] { exp.getText() };
}
if (method != null) return invoke(left, method, args);
return null;
}
private Method findMethod(Class<?> cls, String methodName, Class<?>[] argsType) {
Method method = ReflectUtil.findMethod(cls, methodName, argsType);
return getCallableMethod(method);
}
private Method getMethod(Class<?> cls, String methodName, Class<?>[] argsType) {
Method method = ReflectUtil.getMethod(cls, methodName, argsType);
return getCallableMethod(method);
}
private Method getCallableMethod(Method m) {
if (m == null || securityMgr.isCallable(m)) return m;
throw new SecurityException("[" + securityMgr.getClass().getSimpleName() + "][" + m.toString() + "]");
}
/**
*
*
* @param obj
* @param method
* @param args
* @return
*/
public static Object invoke(Object obj, Method method, Object[] args) {
try {
return method.invoke(obj, args);
} catch (<API key> | <API key> e) {
logger.error("", e);
} catch (<API key> e) {
logger.error("", e.getTargetException());
}
return null;
}
@Override
public FelMethod toMethod(FelNode node, FelContext context) {
StringBuilder sb = new StringBuilder();
List<FelNode> children = node.getChildren();
FelNode l = children.get(0);
SourceBuilder leftMethod = l.toMethod(context);
Class<?> cls = leftMethod.returnType(context, l);
String leftSrc = leftMethod.source(context, l);
if (cls.isPrimitive()) {
Class<?> wrapperClass = ReflectUtil.toWrapperClass(cls);
// [eg:((Integer)1).doubleValue()]
sb.append("((").append(wrapperClass.getSimpleName()).append(")").append(leftSrc).append(")");
} else {
sb.append(leftSrc);
}
sb.append(".");
Method method = null;
FelNode rightNode = children.get(1);
List<FelNode> params = rightNode.getChildren();
List<SourceBuilder> paramMethods = new ArrayList<SourceBuilder>();
Class<?>[] paramValueTypes = null;
boolean hasParam = params != null && !params.isEmpty();
String rightMethod = rightNode.getText();
String rightMethodParam = "";
if (hasParam) {
paramValueTypes = new Class<?>[params.size()];
for (int i = 0; i < params.size(); i++) {
FelNode p = params.get(i);
SourceBuilder paramMethod = p.toMethod(context);
paramMethods.add(paramMethod);
paramValueTypes[i] = paramMethod.returnType(context, p);
}
method = findMethod(cls, rightNode.getText(), paramValueTypes);
if (method != null) {
Class<?>[] paramTypes = method.getParameterTypes();
for (int i = 0; i < paramTypes.length; i++) {
Class<?> paramType = paramTypes[i];
FelNode p = params.get(i);
String paramCode = getParamCode(paramType, p, context);
rightMethodParam += paramCode + ",";
}
rightMethod = method.getName();
}
} else {
method = findMethod(cls, rightNode.getText(), new Class<?>[0]);
if (method == null) {
// get
method = getMethod(cls, "get", new Class<?>[] { String.class });
if (method != null) {
rightMethod = "get";
rightMethodParam = "\"" + rightNode.getText() + "\"";
}
} else {
rightMethod = method.getName();
}
}
if (method != null) {}
if (rightMethodParam.endsWith(",")) {
rightMethodParam = rightMethodParam.substring(0, rightMethodParam.length() - 1);
}
rightMethod += "(" + rightMethodParam + ")";
sb.append(rightMethod);
FelMethod returnMe = new FelMethod(method == null ? null : method.getReturnType(), sb.toString());
return returnMe;
}
/**
*
*
* @param paramType
*
* @param paramValueType
*
* @param paramMethod
* @return
*/
public static String getParamCode(Class<?> paramType, FelNode node, FelContext ctx) {
// intInteger)
String paramCode = "";
SourceBuilder paramMethod = node.toMethod(ctx);
Class<?> paramValueType = paramMethod.returnType(ctx, node);
if (ReflectUtil.isTypeMatch(paramType, paramValueType)) {
paramCode = paramMethod.source(ctx, node);
} else {
String className = null;
Class<?> wrapperClass = ReflectUtil.toWrapperClass(paramType);
if (wrapperClass != null) {
className = wrapperClass.getName();
} else {
className = paramType.getName();
}
paramCode = "(" + className + ")" + paramMethod.source(ctx, node);
}
return paramCode;
}
}
|
function c8955148.initial_effect(c)
aux.<API key>(c,72566043)
--to deck
local e1=Effect.CreateEffect(c)
e1:SetCategory(CATEGORY_TODECK+CATEGORY_DRAW)
e1:SetType(<API key>)
e1:SetRange(LOCATION_GRAVE)
e1:SetProperty(<API key>)
e1:SetCountLimit(1,8955148)
e1:SetTarget(c8955148.tdtg)
e1:SetOperation(c8955148.tdop)
c:RegisterEffect(e1)
end
function c8955148.tdfilter(c)
return c:IsCode(72566043) and c:IsAbleToDeck()
end
function c8955148.tdtg(e,tp,eg,ep,ev,re,r,rp,chk,chkc)
if chkc then return chkc:IsLocation(LOCATION_GRAVE) and chkc:IsControler(tp) and c8955148.tdfilter(chkc) and chkc~=e:GetHandler() end
if chk==0 then return e:GetHandler():IsAbleToDeck()
and Duel.IsExistingTarget(c8955148.tdfilter,tp,LOCATION_GRAVE,LOCATION_GRAVE,1,e:GetHandler()) end
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_TODECK)
local g=Duel.SelectTarget(tp,c8955148.tdfilter,tp,LOCATION_GRAVE,LOCATION_GRAVE,1,1,e:GetHandler())
g:AddCard(e:GetHandler())
Duel.SetOperationInfo(0,CATEGORY_TODECK,g,2,0,0)
Duel.SetOperationInfo(0,CATEGORY_DRAW,nil,0,tp,1)
end
function c8955148.tdop(e,tp,eg,ep,ev,re,r,rp)
local c=e:GetHandler()
local tc=Duel.GetFirstTarget()
if c:IsRelateToEffect(e) and tc:IsRelateToEffect(e) then
local g=Group.FromCards(c,tc)
if Duel.SendtoDeck(g,nil,2,REASON_EFFECT)==0 then return end
Duel.ShuffleDeck(tp)
Duel.BreakEffect()
Duel.Draw(tp,1,REASON_EFFECT)
end
end
|
package gui;
import java.awt.Color;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.List;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.ListSelectionModel;
import javax.swing.border.EmptyBorder;
import javax.swing.table.DefaultTableModel;
import logic.DB.MongoUserManager;
import logic.model.Statistics;
import logic.model.User;
import javax.swing.JLabel;
import java.awt.Font;
import java.awt.Toolkit;
public class ListPlayers extends JFrame {
private static final long serialVersionUID = 1L;
private JPanel contentPane;
private JScrollPane spUsers;
private JTable tabUsers;
private MongoUserManager mongo = new MongoUserManager();
private List<User> users;
private JButton btnClose;
private JLabel lbListUsers;
/**
* Launch the application.
*/
/*public static void main(String[] args) {
EventQueue.invokeLater(new Runnable() {
public void run() {
try {
ListPlayers frame = new ListPlayers();
frame.setVisible(true);
} catch (Exception e) {
e.printStackTrace();
}
}
});
}*/
/**
* Create the frame.
*/
public ListPlayers() {
setIconImage(Toolkit.getDefaultToolkit().getImage("C:\\Users\\Raquel\\Desktop\\ASWProject\\Trivial_i1b\\Game\\src\\main\\resources\\Images\\icono.png"));
<API key>(JFrame.DISPOSE_ON_CLOSE);
setBounds(100, 100, 532, 340);
contentPane = new JPanel();
contentPane.setBackground(new Color(0,0,139));
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
setContentPane(contentPane);
contentPane.setLayout(null);
contentPane.add(getSpUsers());
contentPane.add(getBtnClose());
contentPane.setBackground(InitialWindow.pnFondo.getBackground());
JButton btnSeeStatistics = new JButton("See statistics");
btnSeeStatistics.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
users = mongo.getAllUsers();
StatisticsWindow statistics = new StatisticsWindow();
statistics.setVisible(true);
statistics.txPlayer.setText((String) tabUsers.getValueAt(tabUsers.getSelectedRow(), 0));
int row = tabUsers.getSelectedRow();
int newRow = 0;
for (User u : users){
if (u.getEmail().equals(tabUsers.getValueAt(row, 1))){
Statistics s = u.getStatistics();
statistics.tabStatistics.setValueAt(s.getQuestionsMatched(), newRow, 0);
statistics.tabStatistics.setValueAt(s.<API key>(), newRow, 1);
statistics.tabStatistics.setValueAt(s.getTimesPlayed(), newRow, 2);
newRow++;
}
}
}
});
btnSeeStatistics.setBounds(357, 42, 123, 23);
contentPane.add(btnSeeStatistics);
contentPane.add(getLbListUsers());
}
private JScrollPane getSpUsers() {
if (spUsers == null) {
spUsers = new JScrollPane();
spUsers.setBounds(42, 103, 306, 128);
spUsers.setViewportView(getTabUsers());
spUsers.setBackground(InitialWindow.pnFondo.getBackground());
}
return spUsers;
}
private JTable getTabUsers() {
if (tabUsers == null) {
tabUsers = new JTable();
tabUsers.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
tabUsers.setModel(new DefaultTableModel(
new Object[][] {
},
new String[] {
"Username", "Email"
}
));
}
DefaultTableModel model = (DefaultTableModel)tabUsers.getModel();
listUsers(model);
return tabUsers;
}
private JButton getBtnClose() {
if (btnClose == null) {
btnClose = new JButton("Close");
btnClose.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
dispose();
}
});
btnClose.setBounds(378, 230, 76, 23);
}
return btnClose;
}
private void listUsers(DefaultTableModel model) {
users = mongo.getAllUsers();
Object[] row = new Object[2];
for (int i = 0; i < users.size(); i++) {
row[0] = users.get(i).getUsername();
row[1] = users.get(i).getEmail();
model.addRow(row);
}
}
private JLabel getLbListUsers() {
if (lbListUsers == null) {
lbListUsers = new JLabel("List of users:");
lbListUsers.setFont(new Font("Arial", Font.PLAIN, 25));
lbListUsers.setBounds(142, 32, 195, 32);
}
return lbListUsers;
}
}
|
package sabstracta;
/**
* Represents an or operation in the syntax tree.
*
*/
public class Or extends <API key> {
public Or(Expresion _izq, Expresion _dch) {
super(_izq, _dch);
}
/**
* Returns the instruction code.
*/
@Override
protected String getInst() {
return "or";
}
}
|
<?php
defined('JPATH_PLATFORM') or die;
jimport('joomla.form.helper');
class <API key> extends JFormField
{
protected function getInput()
{
$html = array();
$provider = $this->element['provider'] ? (string)$this->element['provider'] : null;
$style = $this->element['style'] ? (string)$this->element['style'] . '"' : '';
// Initialize some field attributes.
$class = !empty($this->class) ? ' class="radio ' . $this->class . '"' : ' class="radio"';
$required = $this->required ? ' required aria-required="true"' : '';
$autofocus = $this->autofocus ? ' autofocus' : '';
$disabled = $this->disabled ? ' disabled' : '';
$readonly = $this->readonly;
$style = 'style="float:left;' . $style . '"';
$html[] = '<div style="clear: both"> </div>';
// Start the radio field output.
$html[] = '<fieldset id="' . $this->id . '"' . $class . $required . $autofocus . $disabled . $style . ' >';
// Get the field options.
$options = $this->getOptions();
$p = JFBCFactory::provider($provider);
// Build the radio field output.
$html[] = '<label class="providername">' . $p->name . '</label>';
foreach ($options as $i => $option)
{
// Initialize some option attributes.
$checked = ((string)$option->value == (string)$this->value) ? ' checked="checked"' : '';
$class = !empty($option->class) ? ' class="' . $option->class . '"' : '';
$disabled = !empty($option->disable) || ($readonly && !$checked);
$disabled = $disabled ? ' disabled' : '';
$html[] = '<input type="radio" id="' . $this->id . $i . '" name="' . $this->name . '" value="'
. htmlspecialchars($option->value, ENT_COMPAT, 'UTF-8') . '"' . $checked . $class . $required . $disabled . ' />';
$html[] = '<label for="' . $this->id . $i . '"' . $class . ' >' .
'<img src="' . JUri::root() . 'media/sourcecoast/images/provider/' . $provider . '/' . $option->value . '" />' .
#. JText::alt($option->text, preg_replace('/[^a-zA-Z0-9_\-]/', '_', $this->fieldname)) . '</label>'
'</label>' .
$required = '';
}
// End the radio field output.
$html[] = '</fieldset>';
$html[] = '<div style="clear: both"> </div>';
return implode($html);
}
protected function getOptions()
{
// Scan the /media/sourcecoast/images/provider directory for this provider's buttons
// Merge in any custom images from ??
$provider = $this->element['provider'] ? (string)$this->element['provider'] : null;
$options = array();
$buttons = $this->getButtons('/media/sourcecoast/images/provider/' . $provider);
if ($buttons)
{
foreach ($buttons as $button)
{
$options[] = JHtml::_('select.option', $button, $button, 'value', 'text', false);
}
}
reset($options);
return $options;
}
private function getButtons($folder)
{
$folder = JPATH_SITE . $folder;
$buttons = array();
if (JFolder::exists($folder))
{
$buttons = JFolder::files($folder, '^' . '.*(\.png|\.jpg|\.gif)$');
}
return $buttons;
}
}
|
\documentclass{report}
\usepackage{hyperref}
% WARNING: THIS SHOULD BE MODIFIED DEPENDING ON THE LETTER/A4 SIZE
\oddsidemargin 0cm
\evensidemargin 0cm
\marginparsep 0cm
\marginparwidth 0cm
\parindent 0cm
\textwidth 16.5cm
\ifpdf
\usepackage[pdftex]{graphicx}
\else
\usepackage[dvips]{graphicx}
\fi
\begin{document}
% special variable used for calculating some widths.
\newlength{\tmplength}
\chapter{Unit ok{\_}interface{\_}implicit}
\section{Overview}
\begin{description}
\item[\texttt{\begin{ttfamily}IMyInterface\end{ttfamily} Interface}]
\item[\texttt{\begin{ttfamily}TMyRecord\end{ttfamily} Record}]
\item[\texttt{\begin{ttfamily}TMyPackedRecord\end{ttfamily} Packed Record}]
\item[\texttt{\begin{ttfamily}TMyClass\end{ttfamily} Class}]
\end{description}
\section{Classes, Interfaces, Objects and Records}
\subsection*{IMyInterface Interface}
\subsubsection*{\large{\textbf{Hierarchy}}\normalsize\hspace{1ex}\hfill}
IMyInterface {$>$} IInterface
%%%%Description
\subsubsection*{\large{\textbf{Methods}}\normalsize\hspace{1ex}\hfill}
\paragraph*{PublicMethod}\hspace*{\fill}
\begin{list}{}{
\settowidth{\tmplength}{\textbf{Description}}
\setlength{\itemindent}{0cm}
\setlength{\listparindent}{0cm}
\setlength{\leftmargin}{\evensidemargin}
\addtolength{\leftmargin}{\tmplength}
\settowidth{\labelsep}{X}
\addtolength{\leftmargin}{\labelsep}
\setlength{\labelwidth}{\tmplength}
}
\begin{flushleft}
\item[\textbf{Declaration}\hfill]
\begin{ttfamily}
public procedure PublicMethod;\end{ttfamily}
\end{flushleft}
\end{list}
\subsection*{TMyRecord Record}
%%%%Description
\subsubsection*{\large{\textbf{Fields}}\normalsize\hspace{1ex}\hfill}
\paragraph*{PublicField}\hspace*{\fill}
\begin{list}{}{
\settowidth{\tmplength}{\textbf{Description}}
\setlength{\itemindent}{0cm}
\setlength{\listparindent}{0cm}
\setlength{\leftmargin}{\evensidemargin}
\addtolength{\leftmargin}{\tmplength}
\settowidth{\labelsep}{X}
\addtolength{\leftmargin}{\labelsep}
\setlength{\labelwidth}{\tmplength}
}
\begin{flushleft}
\item[\textbf{Declaration}\hfill]
\begin{ttfamily}
public PublicField: Integer;\end{ttfamily}
\end{flushleft}
\end{list}
\subsection*{TMyPackedRecord Packed Record}
%%%%Description
\subsubsection*{\large{\textbf{Fields}}\normalsize\hspace{1ex}\hfill}
\paragraph*{PublicField}\hspace*{\fill}
\begin{list}{}{
\settowidth{\tmplength}{\textbf{Description}}
\setlength{\itemindent}{0cm}
\setlength{\listparindent}{0cm}
\setlength{\leftmargin}{\evensidemargin}
\addtolength{\leftmargin}{\tmplength}
\settowidth{\labelsep}{X}
\addtolength{\leftmargin}{\labelsep}
\setlength{\labelwidth}{\tmplength}
}
\begin{flushleft}
\item[\textbf{Declaration}\hfill]
\begin{ttfamily}
public PublicField: Integer;\end{ttfamily}
\end{flushleft}
\end{list}
\subsection*{TMyClass Class}
\subsubsection*{\large{\textbf{Hierarchy}}\normalsize\hspace{1ex}\hfill}
TMyClass {$>$} TObject
%%%%Description
\subsubsection*{\large{\textbf{Fields}}\normalsize\hspace{1ex}\hfill}
\paragraph*{PublicField}\hspace*{\fill}
\begin{list}{}{
\settowidth{\tmplength}{\textbf{Description}}
\setlength{\itemindent}{0cm}
\setlength{\listparindent}{0cm}
\setlength{\leftmargin}{\evensidemargin}
\addtolength{\leftmargin}{\tmplength}
\settowidth{\labelsep}{X}
\addtolength{\leftmargin}{\labelsep}
\setlength{\labelwidth}{\tmplength}
}
\begin{flushleft}
\item[\textbf{Declaration}\hfill]
\begin{ttfamily}
public PublicField: Integer;\end{ttfamily}
\end{flushleft}
\end{list}
\end{document}
|
package org.oguz.servlet;
import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebInitParam;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
public class XMLServlet extends HttpServlet
{
private static final long serialVersionUID = 1L;
/**
* @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
*/
protected void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException
{
response.setContentType("text/html");
PrintWriter out = response.getWriter();
String userName = request.getParameter("username");
String fullName = request.getParameter("fullname");
String profession = request.getParameter("profession");
// HttpSession session =request.getSession();
ServletContext context = request.getServletContext();
if (userName != "" && userName != null)
{
// session.setAttribute("savedUser",userName);
context.setAttribute("savedUser", userName);
out.println("<p>Hello context parameter " + (String)context.getAttribute("savedUser") +
" from GET method</p>");
}
else
{
out.println("<p>Hello default user " +
this.getServletConfig().getInitParameter("username") + " from GET method</p>");
}
if (fullName != "" && fullName != null)
{
// session.setAttribute("savedFull", fullName);
context.setAttribute("savedFull", fullName);
out.println("<p> your full name is: " + (String)context.getAttribute("savedFull") +
"</p>");
}
else
{
out.println("<p>Hello default fullname " +
this.getServletConfig().getInitParameter("fullname") + " from GET method</p>");
}
}
protected void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException
{
response.setContentType("text/html");
PrintWriter out = response.getWriter();
String userName = request.getParameter("username");
String fullName = request.getParameter("fullname");
String profession = request.getParameter("profession");
// String location = request.getParameter("location");
String[] location = request.getParameterValues("location");
out.println("<p>Hello " + userName + " from POST method in XMLSERVLET response</p>");
out.println("<p> your full name is: " + fullName + "</p>");
out.println("<p>your profession is: " + profession + "</p>");
for (int i = 0; i < location.length; i++)
{
out.println("<p>your location is: " + location[i].toUpperCase() + "</p>");
}
}
}
|
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http:
<html lang="en">
<head>
<meta name="description" content="Dubstep indie music">
<meta name="keywords" content="dubstep, superman, indie, hollywood, maryland, soundtrack, a boy named su, a boy named sue, heart">
<meta name="author" content="Mike Su">
<script class="cssdeck" src="//cdnjs.cloudflare.com/ajax/libs/jquery/1.8.0/jquery.min.js"></script>
<title>A Boy Named Su ♥ the SoundCloud</title>
<link type="text/css" media="screen" rel="stylesheet" href="../../slabText/css/slabtext.css">
<link rel="stylesheet" href="../css/sc-player-artwork.css" type="text/css">
<link rel="stylesheet" href="../../css/style.css" type="text/css">
<style>
@font-face
{
font-family: 'LeagueGothicRegular';
src: url('../../fonts/<API key>.eot');
src: url('../../fonts/<API key>.eot?#iefix') format('embedded-opentype'),
url('../../fonts/<API key>.woff') format('woff'),
url('../../fonts/<API key>.ttf') format('truetype'),
url('../../fonts/<API key>.svg#LeagueGothicRegular') format('svg');
font-weight: normal;
font-style: normal;
}
html,
body
{
background:#000;
color:#444;
}
body
{
font: 16px/1.8 "HelveticaNeue-Light", "Helvetica Neue Light", "Helvetica Neue", Helvetica, Arial, "Lucida Grande", sans-serif;
width:80%;
padding:20px 0;
max-width:960px;
margin:0 auto;
}
hr
{
border: 0;
height: 1px;
background-image: -<API key>(left, rgba(0,0,0,0), rgba(0,0,0,0.75), rgba(0,0,0,0));
background-image: -moz-linear-gradient(left, rgba(0,0,0,0), rgba(0,0,0,0.75), rgba(0,0,0,0));
background-image: -ms-linear-gradient(left, rgba(0,0,0,0), rgba(0,0,0,0.75), rgba(0,0,0,0));
background-image: -o-linear-gradient(left, rgba(0,0,0,0), rgba(0,0,0,0.75), rgba(0,0,0,0));
}
.col-1
{
width:47.5%;
margin:0 2.5% 0 0;
float:left;
}
.col-2
{
width:47.5%;
margin:0 0 0 2.5%;
float:left;
}
.col-1 p,
.col-2 p
{
color:#888;
font-size:80%;
text-align:center;
}
a
{
color:#111;
}
h1 a
{
text-decoration:none;
}
p
{
margin:0 0 1.5em 0;
line-height:1.5em;
}
dt
{
font-family:monospace;
}
pre
{
line-height:1.2;
}
footer
{
border-top:3px double #aaa;
padding-top:1em;
}
footer section
{
border-bottom:3px double #aaa;
padding-bottom:1em;
margin-bottom:1em;
}
sup a
{
text-decoration:none;
}
{
clear:both;
}
.amp
{
font-family:Baskerville,'Goudy Old Style',Palatino,'Book Antiqua',serif;
font-style:italic;
font-weight:lighter;
}
/* Set font-sizes for the headings to be given the slabText treatment */
h1
{
text-align:left;
font-family:'LeagueGothicRegular', "Impact", Charcoal, Arial Black, Gadget, Sans serif;
text-transform: uppercase;
line-height:1;
color:#222;
font-size:300%;
/* Remember to set the correct font weight if using fontface */
font-weight:normal;
}
/* Smaller font-size for the side-by-side demo */
.col-1 h1,
.col-2 h1
{
font-size: 32px;
}
h2
{
font-size: 25px;
}
/* Adjust the line-height for all headlines that have been given the
slabtext treatment. Use a unitless line-height to stop sillyness */
.slabtexted h1
{
line-height:.9;
}
/* Target specific lines in the preset Studio One demo */
.slabtexted #studio-one span:nth-child(2)
{
line-height:.8;
}
.slabtexted #studio-one span:nth-child(3)
{
line-height:1.1;
}
/* Fun with media queries - resize your browser to view changes. */
@media screen and (max-width: 960px)
{
body
{
padding:10px 0;
min-width:20em;
}
.col-1,
.col-2
{
float:none;
margin:0;
width:100%;
}
h1
{
font-size:36px;
}
h2
{
font-size:22px;
}
}
@media screen and (max-width: 460px)
{
h1
{
font-size:26px;
}
h2
{
font-size:18px;
}
}
</style> <div class="menu">
<div id="logo"><a href="/">♥</a></div>
</div>
</head>
<body>
<div id="fb-root"></div>
<script>(function(d, s, id) {
var js, fjs = d.<API key>(s)[0];
if (d.getElementById(id)) return;
js = d.createElement(s); js.id = id;
js.src = "//connect.facebook.net/en_US/all.js#xfbml=1";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));</script>
<div class="menu">
<div id="logo"><a href="../../">♥</a></div>
<a href="../../album">/Album</a>
<a href="http://t.qkme.me/3st1se.jpg">ArchNemesis!</a>
<a href="http://listen.boynamedsumusic.com/">BandCamp</a>
<a href="../../covers">/Covers</a>
<a href="../../lekryptonite">/LeKryptonite</a>
<a href="../../lightshow/14hearts/155bpm"><span class="red155">/Lightshow/14♥</span></a>
<a href="http://sudocoda.com">RillyThickGlasses</a>
<a href="../../soundcloud/heart" class="active">/SoundCloud/♥</a>
<a href="../../album/heart/<API key>"><h1 style="padding:3px;">Exit</h1></a>
</div>
<div class="social">
<div class="footer-social"><a href="http:
<div class="footer-social"><a href="http://twitter.com/boynamedsumusic" target="_blank"><img src="../../images/footer_twitter.png" alt=""></a></div>
<div class="footer-social"><a href="http://plus.google.com/u/3/<API key>/" target="_blank"><img src="../../images/footer_google.png" alt=""></a></div>
</div>
<div class="fb-like" data-href="http://boynamedsumusic.com/soundcloud/heart" data-send="true" data-width="450" data-show-faces="true" data-font="lucida grande" data-colorscheme="dark"></div>
<a href="https://twitter.com/share" class="<TwitterConsumerkey>" data-via="boynamedsumusic">Tweet</a>
<script>!function(d,s,id){var js,fjs=d.<API key>(s)[0],p=/^http:/.test(d.location)?'http':'https';if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src=p+'://platform.twitter.com/widgets.js';fjs.parentNode.insertBefore(js,fjs);}}(document, 'script', 'twitter-wjs');</script>
<h1>I ♥ the SoundCloud. It was twue WubWubWub at first listen!</h1>
<div class="post">
<div class="sc-player">
<a href="http://soundcloud.com/aboynamedsu/sets/heart" class="sc-player">Heart</a>
</div>
</div>
<script type="text/javascript">
$(function(){
var menu = $('.menu'),
a = menu.find('a');
a.wrapInner($('<span />'));
a.each(function(){
var t = $(this), span = t.find('span');
for (i=0;i<2;i++){
span.clone().appendTo(t);
}
});
a.hover(function(){
var t = $(this), s = t.siblings('a');
t.toggleClass('shadow');
s.toggleClass('blur');
});
$(a[0]).delay(500).queue(function(n) {
$(this).mouseenter();
n();
});
$(a[0]).delay(500).queue(function(n) {
$(this).mouseleave();
n();
});
});
</script>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.0/jquery.min.js"></script>
<script type="text/javascript" src="../js/soundcloud.player.api.js"></script>
<script type="text/javascript" src="../js/sc-player.js"></script>
</body>
</html>
|
#ifndef <API key>
#define <API key>
#include <IceGrid/SessionI.h>
#include <IceGrid/Topics.h>
#include <IceGrid/ReapThread.h>
#include <IceGrid/Internal.h>
namespace IceGrid
{
class RegistryI;
typedef IceUtil::Handle<RegistryI> RegistryIPtr;
class FileIteratorI;
typedef IceUtil::Handle<FileIteratorI> FileIteratorIPtr;
class AdminSessionI : public BaseSessionI, public AdminSession
{
public:
AdminSessionI(const std::string&, const DatabasePtr&, int, const RegistryIPtr&);
virtual ~AdminSessionI();
Ice::ObjectPrx _register(const <API key>&, const Ice::ConnectionPtr&);
virtual void keepAlive(const Ice::Current& current) { BaseSessionI::keepAlive(current); }
virtual AdminPrx getAdmin(const Ice::Current&) const;
virtual Ice::ObjectPrx <API key>(const Ice::Current&) const;
virtual void setObservers(const RegistryObserverPrx&, const NodeObserverPrx&, const <API key>&,
const AdapterObserverPrx&, const ObjectObserverPrx&, const Ice::Current&);
virtual void <API key>(const Ice::Identity&, const Ice::Identity&, const Ice::Identity&,
const Ice::Identity&, const Ice::Identity&, const Ice::Current&);
virtual int startUpdate(const Ice::Current&);
virtual void finishUpdate(const Ice::Current&);
virtual std::string getReplicaName(const Ice::Current&) const;
virtual FileIteratorPrx openServerLog(const std::string&, const std::string&, int, const Ice::Current&);
virtual FileIteratorPrx openServerStdOut(const std::string&, int, const Ice::Current&);
virtual FileIteratorPrx openServerStdErr(const std::string&, int, const Ice::Current&);
virtual FileIteratorPrx openNodeStdOut(const std::string&, int, const Ice::Current&);
virtual FileIteratorPrx openNodeStdErr(const std::string&, int, const Ice::Current&);
virtual FileIteratorPrx openRegistryStdOut(const std::string&, int, const Ice::Current&);
virtual FileIteratorPrx openRegistryStdErr(const std::string&, int, const Ice::Current&);
virtual void destroy(const Ice::Current&);
void removeFileIterator(const Ice::Identity&, const Ice::Current&);
private:
void <API key>(TopicName, const Ice::ObjectPrx&, bool = false);
Ice::ObjectPrx addForwarder(const Ice::Identity&, const Ice::Current&);
Ice::ObjectPrx addForwarder(const Ice::ObjectPrx&);
FileIteratorPrx addFileIterator(const FileReaderPrx&, const std::string&, int, const Ice::Current&);
virtual void destroyImpl(bool);
const int _timeout;
const std::string _replicaName;
AdminPrx _admin;
std::map<TopicName, std::pair<Ice::ObjectPrx, bool> > _observers;
RegistryIPtr _registry;
Ice::ObjectPrx <API key>;
};
typedef IceUtil::Handle<AdminSessionI> AdminSessionIPtr;
class AdminSessionFactory : public virtual IceUtil::Shared
{
public:
AdminSessionFactory(const <API key>&, const DatabasePtr&, const ReapThreadPtr&, const RegistryIPtr&);
Glacier2::SessionPrx <API key>(const std::string&, const Glacier2::SessionControlPrx&);
AdminSessionIPtr <API key>(const std::string&);
const TraceLevelsPtr& getTraceLevels() const;
private:
const <API key> _servantManager;
const DatabasePtr _database;
const int _timeout;
const ReapThreadPtr _reaper;
const RegistryIPtr _registry;
const bool _filters;
};
typedef IceUtil::Handle<AdminSessionFactory> <API key>;
class <API key> : public virtual Glacier2::SessionManager
{
public:
<API key>(const <API key>&);
virtual Glacier2::SessionPrx create(const std::string&, const Glacier2::SessionControlPrx&, const Ice::Current&);
private:
const <API key> _factory;
};
class <API key> : public virtual Glacier2::SSLSessionManager
{
public:
<API key>(const <API key>&);
virtual Glacier2::SessionPrx create(const Glacier2::SSLInfo&, const Glacier2::SessionControlPrx&,
const Ice::Current&);
private:
const <API key> _factory;
};
class FileIteratorI : public FileIterator
{
public:
FileIteratorI(const AdminSessionIPtr&, const FileReaderPrx&, const std::string&, Ice::Long, int);
virtual bool read(int, Ice::StringSeq&, const Ice::Current&);
virtual void destroy(const Ice::Current&);
private:
const AdminSessionIPtr _session;
const FileReaderPrx _reader;
const std::string _filename;
Ice::Long _offset;
const int _messageSizeMax;
};
};
#endif
|
package fr.npellegrin.xebia.mower.parser.model;
/**
* Parsed position.
*/
public class PositionDefinition {
private int x;
private int y;
private <API key> orientation;
public int getX() {
return x;
}
public void setX(final int x) {
this.x = x;
}
public int getY() {
return y;
}
public void setY(final int y) {
this.y = y;
}
public <API key> getOrientation() {
return orientation;
}
public void setOrientation(final <API key> orientation) {
this.orientation = orientation;
}
}
|
# Pod::POM::Constants
# DESCRIPTION
# Constants used by Pod::POM.
# AUTHOR
# Andy Wardley <abw@kfs.org>
# Andrew Ford <a.ford@ford-mason.co.uk>
# This module is free software; you can redistribute it and/or
# modify it under the same terms as Perl itself.
# REVISION
# $Id: Constants.pm 89 2013-05-30 07:41:52Z ford $
package Pod::POM::Constants;
$Pod::POM::Constants::VERSION = '2.00';
require 5.006;
use strict;
use warnings;
use parent qw( Exporter );
our @SEQUENCE = qw( CMD LPAREN RPAREN FILE LINE CONTENT );
our @STATUS = qw( IGNORE REDUCE REJECT );
our @EXPORT_OK = ( @SEQUENCE, @STATUS );
our %EXPORT_TAGS = (
status => [ @STATUS ],
seq => [ @SEQUENCE ],
all => [ @STATUS, @SEQUENCE ],
);
# sequence items
use constant CMD => 0;
use constant LPAREN => 1;
use constant RPAREN => 2;
use constant FILE => 3;
use constant LINE => 4;
use constant CONTENT => 5;
# node add return values
use constant IGNORE => 0;
use constant REDUCE => 1;
use constant REJECT => 2;
1;
=head1 NAME
Pod::POM::Constants
=head1 DESCRIPTION
Constants used by Pod::POM.
=head1 AUTHOR
Andy Wardley E<lt>abw@kfs.orgE<gt>
Andrew Ford E<lt>a.ford@ford-mason.co.ukE<gt>
=head1 COPYRIGHT AND LICENSE
Copyright (C) 2000, 2001 Andy Wardley. All Rights Reserved.
Copyright (C) 2009 Andrew Ford. All Rights Reserved.
This module is free software; you can redistribute it and/or
modify it under the same terms as Perl itself.
=cut
|
#!/usr/bin/env python3
import sys
import numpy as np
from spc import SPC
import matplotlib.pyplot as plt
def plot(files, fac=1.0):
for f in files:
if f.split('.')[-1] == 'xy':
td = np.loadtxt(f)
plt.plot(td[:, 0], np.log(1. / td[:, 1]) * fac, label=f)
elif f.split('.')[-1] == 'spc':
td = SPC(f)
plt.plot(td.xdata, np.log(1. / np.array(td.ydata)), label=f)
plt.legend()
plt.show()
if __name__ == '__main__':
files = sys.argv[2:]
fac = float(sys.argv[1])
plot(files, fac)
|
<?php
namespace PHPExiftool\Driver\Tag\CanonVRD;
use PHPExiftool\Driver\AbstractTag;
class <API key> extends AbstractTag
{
protected $Id = 33;
protected $Name = '<API key>';
protected $FullName = 'CanonVRD::Ver2';
protected $GroupName = 'CanonVRD';
protected $g0 = 'CanonVRD';
protected $g1 = 'CanonVRD';
protected $g2 = 'Image';
protected $Type = 'int16s';
protected $Writable = true;
protected $Description = 'Landscape Raw Contrast';
}
|
#include <qtopia/private/qmimetypedata_p.h>
#include <qtopia/private/drmcontent_p.h>
#include <QApplication>
#include <QtDebug>
<API key>(QIcon,unknownDocumentIcon,(QLatin1String(":image/qpe/UnknownDocument")));
<API key>(QIcon,<API key>,(DrmContentPrivate::createIcon(
*unknownDocumentIcon(),
qApp->style()->pixelMetric( QStyle::PM_ListViewIconSize ),
qApp->style()->pixelMetric( QStyle::PM_LargeIconSize ),
true )));
<API key>(QIcon,<API key>,(DrmContentPrivate::createIcon(
*unknownDocumentIcon(),
qApp->style()->pixelMetric( QStyle::PM_ListViewIconSize ),
qApp->style()->pixelMetric( QStyle::PM_LargeIconSize ),
false )));
class <API key> : public QSharedData
{
public:
struct AppData
{
QContent application;
QString iconFile;
QIcon icon;
QIcon validDrmIcon;
QIcon invalidDrmIcon;
QDrmRights::Permission permission;
bool iconLoaded;
bool validDrmIconLoaded;
bool <API key>;
};
<API key>()
{
}
~<API key>()
{
qDeleteAll( applicationData.values() );
}
QString id;
QContentList applications;
QContent defaultApplication;
QMap< QContentId, AppData * > applicationData;
void loadIcon( AppData *data ) const;
void loadValidDrmIcon( AppData *data ) const;
void loadInvalidDrmIcon( AppData *data ) const;
};
void <API key>::loadIcon( AppData *data ) const
{
if( !data->iconFile.isEmpty() )
data->icon = QIcon( QLatin1String( ":icon/" ) + data->iconFile );
data->iconLoaded = true;
}
void <API key>::loadValidDrmIcon( AppData *data ) const
{
if( !data->icon.isNull() )
data->validDrmIcon = DrmContentPrivate::createIcon(
data->icon,
qApp->style()->pixelMetric( QStyle::PM_ListViewIconSize ),
qApp->style()->pixelMetric( QStyle::PM_LargeIconSize ),
true );
data->validDrmIconLoaded = true;
}
void <API key>::loadInvalidDrmIcon( AppData *data ) const
{
if( !data->icon.isNull() )
data->invalidDrmIcon = DrmContentPrivate::createIcon(
data->icon,
qApp->style()->pixelMetric( QStyle::PM_ListViewIconSize ),
qApp->style()->pixelMetric( QStyle::PM_LargeIconSize ),
false );
data-><API key> = true;
}
<API key>(QSharedDataPointer<<API key>>,<API key>,(new <API key>));
QMimeTypeData::QMimeTypeData()
{
d = *<API key>();
}
QMimeTypeData::QMimeTypeData( const QString &id )
{
if( !id.isEmpty() )
{
d = new <API key>;
d->id = id;
}
else
d = *<API key>();
}
QMimeTypeData::QMimeTypeData( const QMimeTypeData &other )
: d( other.d )
{
}
QMimeTypeData::~QMimeTypeData()
{
}
QMimeTypeData &QMimeTypeData::operator =( const QMimeTypeData &other )
{
d = other.d;
return *this;
}
bool QMimeTypeData::operator ==( const QMimeTypeData &other )
{
return d->id == other.d->id;
}
QString QMimeTypeData::id() const
{
return d->id;
}
QContentList QMimeTypeData::applications() const
{
return d->applications;
}
QContent QMimeTypeData::defaultApplication() const
{
return d->defaultApplication;
}
QIcon QMimeTypeData::icon( const QContent &application ) const
{
if( d->applicationData.contains( application.id() ) )
{
const <API key>::AppData *data = d->applicationData.value( application.id() );
if( !data->iconLoaded )
d->loadIcon( const_cast< <API key>::AppData * >( data ) );
return !data->icon.isNull() ? data->icon : data->application.icon();
}
else
return *unknownDocumentIcon();
}
QIcon QMimeTypeData::validDrmIcon( const QContent &application ) const
{
if( d->applicationData.contains( application.id() ) )
{
const <API key>::AppData *data = d->applicationData.value( application.id() );
if( !data->iconLoaded )
d->loadIcon( const_cast< <API key>::AppData * >( data ) );
if( !data->validDrmIconLoaded )
d->loadValidDrmIcon( const_cast< <API key>::AppData * >( data ) );
return !data->validDrmIcon.isNull() ? data->validDrmIcon : data->application.icon();
}
else
return *<API key>();
}
QIcon QMimeTypeData::invalidDrmIcon( const QContent &application ) const
{
if( d->applicationData.contains( application.id() ) )
{
const <API key>::AppData *data = d->applicationData.value( application.id() );
if( !data->iconLoaded )
d->loadIcon( const_cast< <API key>::AppData * >( data ) );
if( !data-><API key> )
d->loadInvalidDrmIcon( const_cast< <API key>::AppData * >( data ) );
return !data->invalidDrmIcon.isNull() ? data->invalidDrmIcon : data->application.icon();
}
else
return *<API key>();
}
QDrmRights::Permission QMimeTypeData::permission( const QContent &application ) const
{
if( d->applicationData.contains( application.id() ) )
{
const <API key>::AppData *data = d->applicationData.value( application.id() );
return data->permission;
}
else
return QDrmRights::Unrestricted;
}
void QMimeTypeData::addApplication( const QContent &application, const QString &iconFile, QDrmRights::Permission permission )
{
if( application.id() != QContent::InvalidId && !d->applicationData.contains( application.id() ) )
{
<API key>::AppData *data = new <API key>::AppData;
data->application = application;
data->iconFile = iconFile;
data->permission = permission;
data->iconLoaded = false;
data->validDrmIconLoaded = false;
data-><API key> = false;
d->applicationData.insert( application.id(), data );
d->applications.append( application );
if(d->defaultApplication.id() == QContent::InvalidId)
<API key>(application);
}
}
void QMimeTypeData::removeApplication( const QContent &application )
{
if(d->applicationData.contains( application.id() ))
{
delete d->applicationData.take(application.id());
d->applications.removeAll(application);
}
}
void QMimeTypeData::<API key>( const QContent &application )
{
if(application.id() != QContent::InvalidId)
d->defaultApplication = application;
}
template <typename Stream> void QMimeTypeData::serialize(Stream &stream) const
{
stream << d->id;
stream << d->defaultApplication.id();
stream << d->applicationData.count();
QList< QContentId > keys = d->applicationData.keys();
foreach( QContentId contentId, keys )
{
<API key>::AppData *data = d->applicationData.value( contentId );
stream << contentId;
stream << data->iconFile;
stream << data->permission;
}
}
template <typename Stream> void QMimeTypeData::deserialize(Stream &stream)
{
qDeleteAll( d->applicationData.values() );
d->applicationData.clear();
stream >> d->id;
{
QContentId contentId;
stream >> contentId;
d->defaultApplication = QContent( contentId );
}
int count;
stream >> count;
for( int i = 0; i < count; i++ )
{
QContentId contentId;
QString iconFile;
QDrmRights::Permission permission;
stream >> contentId;
stream >> iconFile;
stream >> permission;
addApplication( QContent( contentId ), iconFile, permission );
}
}
<API key>(QMimeTypeData);
|
#include "config.h"
#include <glib.h>
#include <wiretap/wtap.h>
#include <epan/frame_data.h>
#include <epan/packet.h>
#include <epan/emem.h>
#include <epan/timestamp.h>
/* Protocol-specific data attached to a frame_data structure - protocol
index and opaque pointer. */
typedef struct _frame_proto_data {
int proto;
void *proto_data;
} frame_proto_data;
/* XXX - I declared this static, because it only seems to be used by
* p_get_proto_data and p_add_proto_data
*/
static gint
p_compare(gconstpointer a, gconstpointer b)
{
const frame_proto_data *ap = (const frame_proto_data *)a;
const frame_proto_data *bp = (const frame_proto_data *)b;
if (ap -> proto > bp -> proto)
return 1;
else if (ap -> proto == bp -> proto)
return 0;
else
return -1;
}
void
p_add_proto_data(frame_data *fd, int proto, void *proto_data)
{
frame_proto_data *p1 = se_alloc(sizeof(frame_proto_data));
p1->proto = proto;
p1->proto_data = proto_data;
/* Add it to the GSLIST */
fd -> pfd = <API key>(fd -> pfd,
(gpointer *)p1,
p_compare);
}
void *
p_get_proto_data(frame_data *fd, int proto)
{
frame_proto_data temp, *p1;
GSList *item;
temp.proto = proto;
temp.proto_data = NULL;
item = g_slist_find_custom(fd->pfd, (gpointer *)&temp, p_compare);
if (item) {
p1 = (frame_proto_data *)item->data;
return p1->proto_data;
}
return NULL;
}
void
p_remove_proto_data(frame_data *fd, int proto)
{
frame_proto_data temp;
GSList *item;
temp.proto = proto;
temp.proto_data = NULL;
item = g_slist_find_custom(fd->pfd, (gpointer *)&temp, p_compare);
if (item) {
fd->pfd = g_slist_remove(fd->pfd, item->data);
}
}
#define COMPARE_FRAME_NUM() ((fdata1->num < fdata2->num) ? -1 : \
(fdata1->num > fdata2->num) ? 1 : \
0)
#define COMPARE_NUM(f) ((fdata1->f < fdata2->f) ? -1 : \
(fdata1->f > fdata2->f) ? 1 : \
COMPARE_FRAME_NUM())
/* Compare time stamps.
A packet whose time is a reference time is considered to have
a lower time stamp than any frame with a non-reference time;
if both packets' times are reference times, we compare the
times of the packets. */
#define COMPARE_TS_REAL(time1, time2) \
((fdata1->flags.ref_time && !fdata2->flags.ref_time) ? -1 : \
(!fdata1->flags.ref_time && fdata2->flags.ref_time) ? 1 : \
((time1).secs < (time2).secs) ? -1 : \
((time1).secs > (time2).secs) ? 1 : \
((time1).nsecs < (time2).nsecs) ? -1 :\
((time1).nsecs > (time2).nsecs) ? 1 : \
COMPARE_FRAME_NUM())
#define COMPARE_TS(ts) COMPARE_TS_REAL(fdata1->ts, fdata2->ts)
void
<API key>(const frame_data *fdata, const frame_data *prev, nstime_t *delta)
{
if (prev) {
nstime_delta(delta, &fdata->abs_ts, &prev->abs_ts);
} else {
/* If we don't have the time stamp of the previous packet,
it's because we have no displayed/captured packets prior to this.
Set the delta time to zero. */
nstime_set_zero(delta);
}
}
static gint
<API key>(const frame_data *fdata1, const frame_data *fdata2)
{
nstime_t del_cap_ts1, del_cap_ts2;
<API key>(fdata1, fdata1->prev_cap, &del_cap_ts1);
<API key>(fdata2, fdata2->prev_cap, &del_cap_ts2);
return COMPARE_TS_REAL(del_cap_ts1, del_cap_ts2);
}
static gint
<API key>(const frame_data *fdata1, const frame_data *fdata2)
{
nstime_t del_dis_ts1, del_dis_ts2;
<API key>(fdata1, fdata1->prev_dis, &del_dis_ts1);
<API key>(fdata2, fdata2->prev_dis, &del_dis_ts2);
return COMPARE_TS_REAL(del_dis_ts1, del_dis_ts2);
}
gint
frame_data_compare(const frame_data *fdata1, const frame_data *fdata2, int field)
{
switch (field) {
case COL_NUMBER:
return COMPARE_FRAME_NUM();
case COL_CLS_TIME:
switch (timestamp_get_type()) {
case TS_ABSOLUTE:
case <API key>:
case TS_UTC:
case TS_UTC_WITH_DATE:
case TS_EPOCH:
return COMPARE_TS(abs_ts);
case TS_RELATIVE:
return COMPARE_TS(rel_ts);
case TS_DELTA:
return <API key>(fdata1, fdata2);
case TS_DELTA_DIS:
return <API key>(fdata1, fdata2);
case TS_NOT_SET:
return 0;
}
return 0;
case COL_ABS_TIME:
case COL_ABS_DATE_TIME:
case COL_UTC_TIME:
case COL_UTC_DATE_TIME:
return COMPARE_TS(abs_ts);
case COL_REL_TIME:
return COMPARE_TS(rel_ts);
case COL_DELTA_TIME:
return <API key>(fdata1, fdata2);
case COL_DELTA_TIME_DIS:
return <API key>(fdata1, fdata2);
case COL_PACKET_LENGTH:
return COMPARE_NUM(pkt_len);
case <API key>:
return COMPARE_NUM(cum_bytes);
}
<API key>(0);
}
void
frame_data_init(frame_data *fdata, guint32 num,
const struct wtap_pkthdr *phdr, gint64 offset,
guint32 cum_bytes)
{
fdata->pfd = NULL;
fdata->num = num;
fdata->interface_id = phdr->interface_id;
fdata->pkt_len = phdr->len;
fdata->cum_bytes = cum_bytes + phdr->len;
fdata->cap_len = phdr->caplen;
fdata->file_off = offset;
fdata->subnum = 0;
/* To save some memory, we coerce it into a gint16 */
g_assert(phdr->pkt_encap <= G_MAXINT16);
fdata->lnk_t = (gint16) phdr->pkt_encap;
fdata->flags.passed_dfilter = 0;
fdata->flags.<API key> = 0;
fdata->flags.encoding = <API key>;
fdata->flags.visited = 0;
fdata->flags.marked = 0;
fdata->flags.ref_time = 0;
fdata->flags.ignored = 0;
fdata->flags.has_ts = (phdr->presence_flags & WTAP_HAS_TS) ? 1 : 0;
fdata->flags.has_if_id = (phdr->presence_flags & <API key>) ? 1 : 0;
fdata->color_filter = NULL;
fdata->abs_ts.secs = phdr->ts.secs;
fdata->abs_ts.nsecs = phdr->ts.nsecs;
fdata->shift_offset.secs = 0;
fdata->shift_offset.nsecs = 0;
fdata->rel_ts.secs = 0;
fdata->rel_ts.nsecs = 0;
fdata->prev_dis = NULL;
fdata->prev_cap = NULL;
fdata->opt_comment = phdr->opt_comment;
}
void
<API key>(frame_data *fdata,
nstime_t *elapsed_time,
nstime_t *first_ts,
const frame_data *prev_dis,
const frame_data *prev_cap)
{
/* If we don't have the time stamp of the first packet in the
capture, it's because this is the first packet. Save the time
stamp of this packet as the time stamp of the first packet. */
if (nstime_is_unset(first_ts))
*first_ts = fdata->abs_ts;
/* if this frames is marked as a reference time frame, reset
firstsec and firstusec to this frame */
if(fdata->flags.ref_time)
*first_ts = fdata->abs_ts;
/* Get the time elapsed between the first packet and this packet. */
nstime_delta(&fdata->rel_ts, &fdata->abs_ts, first_ts);
/* If it's greater than the current elapsed time, set the elapsed time
to it (we check for "greater than" so as not to be confused by
time moving backwards). */
if ((gint32)elapsed_time->secs < fdata->rel_ts.secs
|| ((gint32)elapsed_time->secs == fdata->rel_ts.secs && (gint32)elapsed_time->nsecs < fdata->rel_ts.nsecs)) {
*elapsed_time = fdata->rel_ts;
}
fdata->prev_dis = prev_dis;
fdata->prev_cap = prev_cap;
}
void
<API key>(frame_data *fdata,
guint32 *cum_bytes)
{
/* This frame either passed the display filter list or is marked as
a time reference frame. All time reference frames are displayed
even if they dont pass the display filter */
if(fdata->flags.ref_time){
/* if this was a TIME REF frame we should reset the cul bytes field */
*cum_bytes = fdata->pkt_len;
fdata->cum_bytes = *cum_bytes;
} else {
/* increase cum_bytes with this packets length */
*cum_bytes += fdata->pkt_len;
fdata->cum_bytes = *cum_bytes;
}
}
void
frame_data_cleanup(frame_data *fdata)
{
if (fdata->pfd) {
g_slist_free(fdata->pfd);
fdata->pfd = NULL;
}
/* XXX, frame_data_cleanup() is called when redissecting (rescan_packets()),
* which might be triggered by lot of things, like: preferences change,
* setting manual address resolve, etc.. (grep by redissect_packets)
* fdata->opt_comment can be set by user, which we must not discard when redissecting.
*/
#if 0
if (fdata->opt_comment) {
g_free(fdata->opt_comment);
fdata->opt_comment = NULL;
}
#endif
}
|
package org.iproduct.iptpi.domain.movement;
import static java.lang.Math.PI;
import static java.lang.Math.abs;
import static java.lang.Math.atan;
import static java.lang.Math.cbrt;
import static java.lang.Math.cos;
import static java.lang.Math.hypot;
import static java.lang.Math.min;
import static java.lang.Math.pow;
import static java.lang.Math.signum;
import static java.lang.Math.sin;
import static java.lang.Math.sqrt;
import static java.lang.Math.tan;
import static org.iproduct.iptpi.demo.robot.RobotParametrs.MAIN_AXE_LENGTH;
import static org.iproduct.iptpi.demo.robot.RobotParametrs.<API key>;
import static org.iproduct.iptpi.demo.robot.RobotParametrs.<API key>;
import static org.iproduct.iptpi.demo.robot.RobotParametrs.<API key>;
import static org.iproduct.iptpi.demo.robot.RobotParametrs.<API key>;
import static org.iproduct.iptpi.demo.robot.RobotParametrs.WHEEL_RADIUS;
import static org.iproduct.iptpi.domain.CommandName.STOP;
import static org.iproduct.iptpi.domain.CommandName.VOID;
import org.iproduct.iptpi.domain.Command;
import org.iproduct.iptpi.domain.arduino.LineReadings;
import org.iproduct.iptpi.domain.audio.AudioPlayer;
import org.iproduct.iptpi.domain.position.Position;
import org.iproduct.iptpi.domain.position.PositionsFlux;
import org.reactivestreams.Subscriber;
import org.reactivestreams.Subscription;
import com.pi4j.wiringpi.Gpio;
import reactor.core.publisher.EmitterProcessor;
import reactor.core.publisher.Flux;
import reactor.util.function.Tuple2;
import reactor.util.function.Tuple3;
import reactor.util.function.Tuple4;
import reactor.util.function.Tuples;
public class <API key> implements Subscriber<Command> {
public static final int MAX_SPEED = 1024;
public static final int CLOCK_DIVISOR = 2;
public static final double <API key> = 0.000000005;
public static final MotorsCommand STOP_COMMAND = new MotorsCommand(0, 0, 0, 0, 0);
private Subscription subscription;
private PositionsFlux positions;
private Flux<LineReadings> lineReadings;
// private SchedulerGroup eventLoops = SchedulerGroup.async();
//Create movement command broadcaster
private EmitterProcessor<Command> commandFlux = EmitterProcessor.create();
public <API key>(PositionsFlux positions, Flux<LineReadings> lineReadings) {
this.positions = positions;
this.lineReadings = lineReadings;
}
@Override
public void onNext(Command command) {
<API key>();
switch (command.getName()) {
case MOVE_FORWARD : moveForward(command); break;
case FOLLOW_LINE : followLine(command); break;
case MOVE_RELATIVE : moveRelative(command); break;
case STOP :
System.out.println("STOPPING THE ROBOT");
runMotors(STOP_COMMAND);
break;
default:
break;
}
}
protected void moveRelative(Command command) {
RelativeMovement relMove = (RelativeMovement) command.getData();
// start moving - and think later as it comes :)
int directionL, directionR;
if(relMove.getVelocity() < 0) {
directionL = directionR = -1;
} else {
directionL = directionR = 1;
}
double targetVelocity = abs(relMove.getVelocity());
int velocity = (int)(MAX_SPEED * targetVelocity / <API key>); // 50 mm/s max
MotorsCommand initialCommand = new MotorsCommand(directionL, directionR, velocity, velocity, Long.MAX_VALUE); //distance still unknown
System.out.println(initialCommand);
runMotors(initialCommand);
Position startPos = positions.elementAt(1).block();
double targetDeltaX = relMove.getDeltaX();
double targetDeltaY = relMove.getDeltaY();
double targetX = startPos.getX() + targetDeltaX;
double targetY = startPos.getY() + targetDeltaY;
double distance = hypot(targetDeltaX, targetDeltaY);
System.out.println("$$$$$$$$$$$$$$ TargetX=" + targetX );
System.out.println("$$$$$$$$$$$$$$ TargetY=" + targetY );
System.out.println("$$$$$$$$$$$$$$ Target Distance=" + distance);
double targetHeading, targetDeltaHeading, targetCurvature, h = 0;
if(relMove.getDeltaHeading() == 0 ) {
targetCurvature = targetDeltaHeading = 0;
targetHeading = startPos.getHeading();
} else {
targetDeltaHeading = relMove.getDeltaHeading();
targetHeading = startPos.getHeading() + targetDeltaHeading ;
targetCurvature = (2 * sin(targetDeltaHeading / 2) ) / distance ;
h = sqrt( 1/(targetCurvature * targetCurvature) - 0.25 * distance * distance );
}
double xC, yC; //circle center coordinates
double r = hypot(distance/2, h);
if(targetCurvature != 0) {
double q = hypot( targetX - startPos.getX(), targetY - startPos.getY() ),
x3 = (targetX + startPos.getX()) /2,
y3 = (targetY + startPos.getY()) /2;
if(targetCurvature > 0) {
xC = x3 + sqrt(r*r - (q*q/4)) * (startPos.getY() - targetY)/q;
yC = y3 + sqrt(r*r - (q*q/4)) * (targetX - startPos.getX() )/q;
} else {
xC = x3 - sqrt(r*r - (q*q/4)) * (startPos.getY() - targetY)/q;
yC = y3 - sqrt(r*r - (q*q/4)) * (targetX - startPos.getX() )/q;
}
} else {
xC = (targetX + startPos.getX()) /2;
yC = (targetY + startPos.getY()) /2;
}
System.out.println("$$$$$$$$$$$$$$ TargetHeading=" + targetHeading );
System.out.println("$$$$$$$$$$$$$$ TargetCurvature=" + targetCurvature );
double <API key>;
if (targetDeltaHeading != 0 && relMove.getAngularVelocity() == 0)
<API key> = targetVelocity * targetCurvature;
else
<API key> = relMove.getAngularVelocity();
double startH = startPos.getHeading();
System.out.println("START POSITION: " + startPos);
Flux<Position> skip1 = positions.skip(1);
Flux.zip(positions, skip1)
.scan(initialCommand, (last, tupple) -> {
Position prevPos = ((Position)tupple.getT1());
Position currPos = ((Position)tupple.getT2());
float prevX = prevPos.getX();
float prevY = prevPos.getY();
double prevH = prevPos.getHeading();
float currX = currPos.getX();
float currY = currPos.getY();
double currH = currPos.getHeading();
System.out.println(currPos + " - " + prevPos);
double dt = (currPos.getTimestamp() - prevPos.getTimestamp()) / 1000.0; //delta time in seconds between position redings
if(dt <= 0) return last; // if invalid sequence do nothing
double time = (currPos.getTimestamp() - startPos.getTimestamp()) /1000.0;
// calculating the ideal trajectory position
double tarX, tarY, tarH, remainingPathLength;
if(targetCurvature == 0) {
tarX = startPos.getX() + targetVelocity * time * cos(targetHeading);
tarY = startPos.getY() + targetVelocity * time * sin(targetHeading);
remainingPathLength = hypot(targetX - currX, targetY - currY) ;
tarH = targetHeading;
} else {
double deltaHeading = <API key> * time;
double startAng = atan((startPos.getY() - yC) / (startPos.getX() - xC));
double angle = startAng + deltaHeading;
if(signum(angle) != (startPos.getY() - yC))
angle -= PI;
tarX = cos(angle) * r + xC;
tarY = sin(angle) * r + yC;
tarH = startPos.getHeading() + deltaHeading;
remainingPathLength = (targetDeltaHeading - deltaHeading ) / targetCurvature;
}
//calculating current trajectory parameters
float dX = currX - prevX;
float dY = currY - prevY;
double currDist = hypot(dX, dY);
double currV = currDist / dt; // current velocity [mm/s]
double currAngV = (currH - prevH) / dt;
//calculating errors
double errX = (tarX - currX) * cos(tarH) + (tarY - currY) + sin(tarH);
double errY = (tarX - currX) * sin(tarH) + (tarY - currY) + cos(tarH);
double errH = tarH - currH;
//calculating landing curve
double Cx = <API key>;
double dlandY = 3 * Cx * pow(cbrt(abs(errY) / Cx), 2) * signum(errY);
double landH = tarH + atan(dlandY);
double dErrY = -<API key> * errX + currV * sin (errH);
double landAngV = <API key> + (2 * (1 / cbrt(abs(errY) / Cx)) * dErrY) /
(1 + tan(landH - tarH) * tan(landH - tarH));
//calculating the corrected trajectory control parameters
double switchAngV = landAngV - currAngV +
sqrt(2 * <API key> * abs(landH - currH))
* signum(landH - currH) * 0.2;
double switchAngA = min(abs(switchAngV / dt), <API key>) * signum(switchAngV);
double newAngV = currAngV + switchAngA * dt;
//calculating new velocity
double dErrX = targetVelocity - currV * cos(errH) + <API key> * errY;
double switchV = dErrX + sqrt( 2 * <API key> * abs(errX)) * signum(errX);
double switchA = min(abs(switchV / dt), <API key>) * signum(switchV);
//calculating delta motor speed control values
double k = 0.1;
double newDeltaLR = k* MAX_SPEED * MAIN_AXE_LENGTH * dt * switchAngA / (2 * WHEEL_RADIUS);
//calculating new motor speed control values
int newVL = (int) (last.getVelocityL() + switchA * dt / WHEEL_RADIUS - newDeltaLR * last.getDirL());
int newVR = (int) (last.getVelocityR() + switchA * dt / WHEEL_RADIUS + newDeltaLR * last.getDirL());
System.out.println("--> errH=" + errH + ", targetHeading=" + targetHeading + ", currH=" + currH + ", dist=" + currDist
);
// System.out.println("!!! landH=" + landH + ", dErrY=" + dErrY
// + ", currAngV=" + currAngV + ", landAngV=" + landAngV + ", switchAngV=" + switchAngV
// + ", switchAngA=" + switchAngA + ", newAngV=" + newAngV );
// System.out.println("!!! remainingPathLength=" + remainingPathLength + ", dErrX=" + dErrX + ", switchV=" + switchV + ", switchA=" + switchA );
// System.out.println("!!! newDeltaV=" + switchA * dt / WHEEL_RADIUS + ", newDelatLR=" + newDeltaLR + ", newVL=" + newVL + ", newVR=" + newVR);
double <API key> = targetHeading - currH;
if(remainingPathLength < last.getRemainingPath()
&& remainingPathLength > currV * currV / <API key>
|| targetDeltaHeading > 0.01
&& abs(<API key>) > 0.05 && <API key> * targetDeltaHeading > 0 ) { //drive until minimum distance to target
return new MotorsCommand(last.getDirL(), last.getDirR(), newVL, newVR, (float) remainingPathLength);
} else {
System.out.println("FINAL POSITION: " + currPos);
return STOP_COMMAND;
}
}).map((MotorsCommand motorsCommand) -> {
runMotors(motorsCommand);
return motorsCommand;
})
.takeUntil((MotorsCommand motorsCommand) -> motorsCommand.equals(STOP_COMMAND) )
.subscribe( (MotorsCommand motorsCommand) -> {
System.out.println(motorsCommand);
});
}
protected void followLine(Command command) {
{
ForwardMovement forwardMove = (ForwardMovement) command.getData();
// start moving - and think later as it comes :)
int directionL, directionR;
if(forwardMove.getVelocity() < 0) {
directionL = directionR = -1;
} else {
directionL = directionR = 1;
}
double targetVelocity = abs(forwardMove.getVelocity());
int velocity = (int)(MAX_SPEED * targetVelocity / <API key>); // 50 mm/s max
MotorsCommand initialCommand = new MotorsCommand(directionL, directionR, velocity, velocity, Long.MAX_VALUE); //distance still unknown
System.out.println(initialCommand);
runMotors(initialCommand);
Position startPos = positions.elementAt(1).block();
double distance = forwardMove.getDistance();
double targetHeading = startPos.getHeading();
double targetDeltaX = distance * cos(targetHeading);
double targetDeltaY = distance * sin(targetHeading);
double targetX = startPos.getX() + targetDeltaX;
double targetY = startPos.getY() + targetDeltaY;
System.out.println("$$$$$$$$$$$$$$ TargetX=" + targetX );
System.out.println("$$$$$$$$$$$$$$ TargetY=" + targetY );
System.out.println("$$$$$$$$$$$$$$ Target Distance=" + distance);
System.out.println("$$$$$$$$$$$$$$ TargetHeading=" + targetHeading );
double startH = startPos.getHeading();
System.out.println("START POSITION: " + startPos);
Flux<Position> skip1 = positions.skip(1);
Flux<Tuple2<Position, Position>> <API key> = Flux.zip(positions, skip1);
Flux<Tuple4<Position, Position, LineReadings, Command>> flux =
Flux.combineLatest(
<API key>,
lineReadings,
commandFlux.startWith(new Command(VOID, null)),
(Object[] args) ->
Tuples.of(((Tuple2<Position, Position>)args[0]).getT1(),
((Tuple2<Position, Position>)args[0]).getT2(),
(LineReadings)args[1],
(Command)args[2])
);
flux.scan(initialCommand, (last, tuple4) -> {
System.out.println("
Position prevPos = tuple4.getT1();
Position currPos = tuple4.getT2();
LineReadings lastReadings = tuple4.getT3();
Command lastCommand = tuple4.getT4();
float prevX = prevPos.getX();
float prevY = prevPos.getY();
double prevH = prevPos.getHeading();
float currX = currPos.getX();
float currY = currPos.getY();
double currH = currPos.getHeading();
System.out.println(currPos + " - " + prevPos);
double dt = (currPos.getTimestamp() - prevPos.getTimestamp()) / 1000.0; //delta time in seconds between position redings
if(dt <= 0) return last; // if invalid sequence do nothing
double time = (currPos.getTimestamp() - startPos.getTimestamp()) /1000.0;
// calculating the ideal trajectory position
double tarX, tarY, tarH, remainingPathLength;
tarX = startPos.getX() + targetVelocity * time * cos(targetHeading);
tarY = startPos.getY() + targetVelocity * time * sin(targetHeading);
remainingPathLength = hypot(targetX - currX, targetY - currY) ;
tarH = targetHeading;
//calculating current trajectory parameters
float dX = currX - prevX;
float dY = currY - prevY;
double currDist = hypot(dX, dY);
double currV = currDist / dt; // current velocity [mm/s]
double currAngV = (currH - prevH) / dt;
//calculating errors
double errX = (tarX - currX) * cos(tarH) + (tarY - currY) + sin(tarH);
double errY = (tarX - currX) * sin(tarH) + (tarY - currY) + cos(tarH);
double errH = tarH - currH;
//calculating landing curve
double Cx = <API key>;
double dlandY = 3 * Cx * pow(cbrt(abs(errY) / Cx), 2) * signum(errY);
double landH = tarH + atan(dlandY);
double dErrY = currV * sin (errH);
double landAngV = (2 * (1 / cbrt(abs(errY) / Cx)) * dErrY) /
(1 + tan(landH - tarH) * tan(landH - tarH));
//calculating the corrected trajectory control parameters
double switchAngV = landAngV - currAngV +
sqrt(2 * <API key> * abs(landH - currH))
* signum(landH - currH) * 0.2;
double switchAngA = min(abs(switchAngV / dt), <API key>) * signum(switchAngV);
double newAngV = currAngV + switchAngA * dt;
//calculating new velocity
double dErrX = targetVelocity - currV * cos(errH);
double switchV = dErrX + sqrt( 2 * <API key> * abs(errX)) * signum(errX);
double switchA = min(abs(switchV / dt), <API key>) * signum(switchV);
// double newV = currV + switchA * dt;
//calculating delta motor speed control values
double k = 0.1;
double newDeltaLR = k* MAX_SPEED * MAIN_AXE_LENGTH * dt * switchAngA / (2 * WHEEL_RADIUS);
//calculating new motor speed control values
int newVL = (int) (last.getVelocityL() + switchA * dt / WHEEL_RADIUS - newDeltaLR * last.getDirL());
int newVR = (int) (last.getVelocityR() + switchA * dt / WHEEL_RADIUS + newDeltaLR * last.getDirL());
System.out.println("!!! time=" + time + ", dt=" + dt + ", tarX=" + tarX + ", tarY=" + tarY
+ ", startH=" + startH + ", errH=" + errH + ", targetX=" + targetX + ", targetY=" + targetY + ", targetHeading=" + targetHeading
+ ", errX=" + errX + ", errY=" + errY + ", dlandY=" + dlandY + ", currV=" + currV + ", dist=" + currDist
+ ", switchAngV/dt=" + switchAngV / dt );
System.out.println("!!! remainingPathLength=" + remainingPathLength + ", dErrX=" + dErrX + ", switchV=" + switchV + ", switchA=" + switchA );
if(lastCommand.getName() != STOP && remainingPathLength < last.getRemainingPath()
&& remainingPathLength > currV * currV / <API key> ) { //drive until minimum distance to target
return new MotorsCommand(last.getDirL(), last.getDirR(), newVL, newVR, (float) remainingPathLength);
} else {
System.out.println("FINAL POSITION: " + currPos);
return STOP_COMMAND;
}
}).map((MotorsCommand motorsCommand) -> {
runMotors(motorsCommand);
return motorsCommand;
})
.takeUntil((MotorsCommand motorsCommand) -> motorsCommand.equals(STOP_COMMAND) )
.subscribe( (MotorsCommand motorsCommand) -> {
System.out.println(motorsCommand);
});
}
}
protected void moveForward(Command command) {
{
ForwardMovement forwardMove = (ForwardMovement) command.getData();
// start moving - and think later as it comes :)
int directionL, directionR;
if(forwardMove.getVelocity() < 0) {
directionL = directionR = -1;
} else {
directionL = directionR = 1;
}
double targetVelocity = abs(forwardMove.getVelocity());
int velocity = (int)(MAX_SPEED * targetVelocity / <API key>); // 50 mm/s max
MotorsCommand initialCommand = new MotorsCommand(directionL, directionR, velocity, velocity, Long.MAX_VALUE); //distance still unknown
System.out.println(initialCommand);
runMotors(initialCommand);
Position startPos = positions.elementAt(1).block();
double distance = forwardMove.getDistance();
double targetHeading = startPos.getHeading();
double targetDeltaX = distance * cos(targetHeading);
double targetDeltaY = distance * sin(targetHeading);
double targetX = startPos.getX() + targetDeltaX;
double targetY = startPos.getY() + targetDeltaY;
System.out.println("$$$$$$$$$$$$$$ TargetX=" + targetX );
System.out.println("$$$$$$$$$$$$$$ TargetY=" + targetY );
System.out.println("$$$$$$$$$$$$$$ Target Distance=" + distance);
System.out.println("$$$$$$$$$$$$$$ TargetHeading=" + targetHeading );
double startH = startPos.getHeading();
System.out.println("START POSITION: " + startPos);
Flux<Position> skip1 = positions.skip(1);
Flux<Tuple2<Position, Position>> <API key> = Flux.zip(positions, skip1);
Flux<Tuple3<Position, Position, Command>> flux =
Flux.combineLatest(
<API key>,
commandFlux.startWith(new Command(VOID, null)),
(tuple2, lastCommand) -> Tuples.of(tuple2.getT1(), tuple2.getT2(), lastCommand)
);
flux.scan(initialCommand, (last, tuple3) -> {
System.out.println("
Position prevPos = tuple3.getT1();
Position currPos = tuple3.getT2();
Command lastCommand = tuple3.getT3();
float prevX = prevPos.getX();
float prevY = prevPos.getY();
double prevH = prevPos.getHeading();
float currX = currPos.getX();
float currY = currPos.getY();
double currH = currPos.getHeading();
System.out.println(currPos + " - " + prevPos);
double dt = (currPos.getTimestamp() - prevPos.getTimestamp()) / 1000.0; //delta time in seconds between position redings
if(dt <= 0) return last; // if invalid sequence do nothing
double time = (currPos.getTimestamp() - startPos.getTimestamp()) /1000.0;
// calculating the ideal trajectory position
double tarX, tarY, tarH, remainingPathLength;
tarX = startPos.getX() + targetVelocity * time * cos(targetHeading);
tarY = startPos.getY() + targetVelocity * time * sin(targetHeading);
remainingPathLength = hypot(targetX - currX, targetY - currY) ;
tarH = targetHeading;
//calculating current trajectory parameters
float dX = currX - prevX;
float dY = currY - prevY;
double currDist = hypot(dX, dY);
double currV = currDist / dt; // current velocity [mm/s]
double currAngV = (currH - prevH) / dt;
//calculating errors
double errX = (tarX - currX) * cos(tarH) + (tarY - currY) + sin(tarH);
double errY = (tarX - currX) * sin(tarH) + (tarY - currY) + cos(tarH);
double errH = tarH - currH;
//calculating landing curve
double Cx = <API key>;
double dlandY = 3 * Cx * pow(cbrt(abs(errY) / Cx), 2) * signum(errY);
double landH = tarH + atan(dlandY);
double dErrY = currV * sin (errH);
double landAngV = (2 * (1 / cbrt(abs(errY) / Cx)) * dErrY) /
(1 + tan(landH - tarH) * tan(landH - tarH));
//calculating the corrected trajectory control parameters
double switchAngV = landAngV - currAngV +
sqrt(2 * <API key> * abs(landH - currH))
* signum(landH - currH) * 0.2;
double switchAngA = min(abs(switchAngV / dt), <API key>) * signum(switchAngV);
double newAngV = currAngV + switchAngA * dt;
//calculating new velocity
double dErrX = targetVelocity - currV * cos(errH);
double switchV = dErrX + sqrt( 2 * <API key> * abs(errX)) * signum(errX);
double switchA = min(abs(switchV / dt), <API key>) * signum(switchV);
// double newV = currV + switchA * dt;
//calculating delta motor speed control values
double k = 0.1;
double newDeltaLR = k* MAX_SPEED * MAIN_AXE_LENGTH * dt * switchAngA / (2 * WHEEL_RADIUS);
//calculating new motor speed control values
int newVL = (int) (last.getVelocityL() + switchA * dt / WHEEL_RADIUS - newDeltaLR * last.getDirL());
int newVR = (int) (last.getVelocityR() + switchA * dt / WHEEL_RADIUS + newDeltaLR * last.getDirL());
System.out.println("!!! time=" + time + ", dt=" + dt + ", tarX=" + tarX + ", tarY=" + tarY
+ ", startH=" + startH + ", errH=" + errH + ", targetX=" + targetX + ", targetY=" + targetY + ", targetHeading=" + targetHeading
+ ", errX=" + errX + ", errY=" + errY + ", dlandY=" + dlandY + ", currV=" + currV + ", dist=" + currDist
+ ", switchAngV/dt=" + switchAngV / dt );
System.out.println("!!! remainingPathLength=" + remainingPathLength + ", dErrX=" + dErrX + ", switchV=" + switchV + ", switchA=" + switchA );
if(lastCommand.getName() != STOP && remainingPathLength < last.getRemainingPath()
&& remainingPathLength > currV * currV / <API key> ) { //drive until minimum distance to target
return new MotorsCommand(last.getDirL(), last.getDirR(), newVL, newVR, (float) remainingPathLength);
} else {
System.out.println("FINAL POSITION: " + currPos);
return STOP_COMMAND;
}
}).map((MotorsCommand motorsCommand) -> {
runMotors(motorsCommand);
return motorsCommand;
})
.takeUntil((MotorsCommand motorsCommand) -> motorsCommand.equals(STOP_COMMAND) )
.subscribe( (MotorsCommand motorsCommand) -> {
System.out.println(motorsCommand);
});
}
}
protected void <API key>() {
// Motor direction pins
Gpio.pinMode(5, Gpio.OUTPUT);
Gpio.pinMode(6, Gpio.OUTPUT);
Gpio.pinMode(12, Gpio.PWM_OUTPUT);
Gpio.pinMode(13, Gpio.PWM_OUTPUT);
Gpio.pwmSetMode(Gpio.PWM_MODE_MS);
Gpio.pwmSetRange(MAX_SPEED);
Gpio.pwmSetClock(CLOCK_DIVISOR);
}
private void runMotors(MotorsCommand mc) {
//setting motor directions
Gpio.digitalWrite(5, mc.getDirR() > 0 ? 1 : 0);
Gpio.digitalWrite(6, mc.getDirL() > 0 ? 1 : 0);
//setting speed
if(mc.getVelocityR() >= 0 && mc.getVelocityR() <= MAX_SPEED)
Gpio.pwmWrite(12, mc.getVelocityR()); // speed up to MAX_SPEED
if(mc.getVelocityL() >= 0 && mc.getVelocityL() <= MAX_SPEED)
Gpio.pwmWrite(13, mc.getVelocityL());
}
@Override
public void onSubscribe(Subscription s) {
subscription = s;
subscription.request(Long.MAX_VALUE);
}
@Override
public void onError(Throwable t) {
// TODO Auto-generated method stub
}
@Override
public void onComplete() {
// TODO Auto-generated method stub
}
}
|
package cn.ac.iscas.cloudeploy.v2.puppet.transform.ast;
import java.util.List;
public class ASTCollExpr extends ASTBase{
private Object test1;
private Object test2;
private String oper;
private List<Object> children;
private String form;
private String type;
public Object getTest1() {
return test1;
}
public void setTest1(Object test1) {
this.test1 = test1;
}
public Object getTest2() {
return test2;
}
public void setTest2(Object test2) {
this.test2 = test2;
}
public String getOper() {
return oper;
}
public void setOper(String oper) {
this.oper = oper;
}
public List<Object> getChildren() {
return children;
}
public void setChildren(List<Object> children) {
this.children = children;
}
public String getForm() {
return form;
}
public void setForm(String form) {
this.form = form;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
}
|
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html PUBLIC "-
<html xmlns="http:
<head>
<!-- template designed by Marco Von Ballmoos -->
<title>Docs for page default.php</title>
<link rel="stylesheet" href="../../media/stylesheet.css" />
<script src="../../media/lib/classTree.js"></script>
<script language="javascript" type="text/javascript">
var imgPlus = new Image();
var imgMinus = new Image();
imgPlus.src = "../../media/images/plus.png";
imgMinus.src = "../../media/images/minus.png";
function showNode(Node){
switch(navigator.family){
case 'nn4':
// Nav 4.x code fork...
var oTable = document.layers["span" + Node];
var oImg = document.layers["img" + Node];
break;
case 'ie4':
// IE 4/5 code fork...
var oTable = document.all["span" + Node];
var oImg = document.all["img" + Node];
break;
case 'gecko':
// Standards Compliant code fork...
var oTable = document.getElementById("span" + Node);
var oImg = document.getElementById("img" + Node);
break;
}
oImg.src = imgMinus.src;
oTable.style.display = "block";
}
function hideNode(Node){
switch(navigator.family){
case 'nn4':
// Nav 4.x code fork...
var oTable = document.layers["span" + Node];
var oImg = document.layers["img" + Node];
break;
case 'ie4':
// IE 4/5 code fork...
var oTable = document.all["span" + Node];
var oImg = document.all["img" + Node];
break;
case 'gecko':
// Standards Compliant code fork...
var oTable = document.getElementById("span" + Node);
var oImg = document.getElementById("img" + Node);
break;
}
oImg.src = imgPlus.src;
oTable.style.display = "none";
}
function nodeIsVisible(Node){
switch(navigator.family){
case 'nn4':
// Nav 4.x code fork...
var oTable = document.layers["span" + Node];
break;
case 'ie4':
// IE 4/5 code fork...
var oTable = document.all["span" + Node];
break;
case 'gecko':
// Standards Compliant code fork...
var oTable = document.getElementById("span" + Node);
break;
}
return (oTable && oTable.style.display == "block");
}
function <API key>(Node){
if (nodeIsVisible(Node)){
hideNode(Node);
}else{
showNode(Node);
}
}
</script>
</head>
<body>
<div class="page-body">
<h2 class="file-name"><img src="../../media/images/Page_logo.png" alt="File" style="vertical-align: middle">/components/com_content/views/featured/tmpl/default.php</h2>
<a name="sec-description"></a>
<div class="info-box">
<div class="info-box-title">Description</div>
<div class="nav-bar">
</div>
<div class="info-box-body">
<ul class="tags">
<li><span class="field">copyright:</span> Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.</li>
<li><span class="field">filesource:</span> <a href="../../filesource/<API key>.php.html">Source Code for this file</a></li>
<li><span class="field">license:</span> GNU</li>
</ul>
</div>
</div>
<p class="notes" id="credit">
Documentation generated on Tue, 19 Nov 2013 14:58:39 +0100 by <a href="http:
</p>
</div></body>
</html>
|
package rb;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Random;
import java.util.Timer;
import java.util.TimerTask;
import javax.persistence.TypedQuery;
import rb.helpers.<API key>;
import rb.helpers.DBHandler;
import rb.helpers.StemmerHelper;
import rb.persistentobjects.Statement;
import rb.persistentobjects.Word;
import ca.uwo.csd.ai.nlp.common.SparseVector;
import ca.uwo.csd.ai.nlp.kernel.KernelManager;
import ca.uwo.csd.ai.nlp.kernel.LinearKernel;
import ca.uwo.csd.ai.nlp.libsvm.svm_model;
import ca.uwo.csd.ai.nlp.libsvm.ex.Instance;
import ca.uwo.csd.ai.nlp.libsvm.ex.SVMPredictor;
import com.cd.reddit.Reddit;
import com.cd.reddit.RedditException;
import com.cd.reddit.json.jackson.RedditJsonParser;
import com.cd.reddit.json.mapping.RedditComment;
import com.cd.reddit.json.mapping.RedditLink;
import com.cd.reddit.json.util.RedditComments;
import de.daslaboratorium.machinelearning.classifier.BayesClassifier;
import de.daslaboratorium.machinelearning.classifier.Classification;
public class Poster {
private static Random randomGenerator;
static Reddit reddit = new Reddit("machinelearningbot/0.1 by elggem");
static String subreddit = "";
static BayesClassifier<String, String> bayes = null;
static svm_model model = null;
static List<Statement> statements = null;
static List<Word> words = null;
static int max_reply_length = 25;
static int classifier = 0;
static ArrayList<String> <API key> = new ArrayList<String>();
/**
* @param args
*/
public static void main(String[] args) {
System.out.println("Reddit BOT Final stage. Armed and ready to go!");
randomGenerator = new Random();
if (args.length < 4) {
System.out.println(" usage: java -Xmx4g -jar JAR SUBREDDIT CLASSIFIER USER PASS\n" +
" with: SUBREDDIT = the subreddit to post to\n" +
" CLASSIFIER = 1:BN, 2:SVM 3:Random\n" +
" USER/PASS = username and password\n");
System.exit(1);
}
subreddit = args[0];
classifier = Integer.valueOf(args[1]);
try {
reddit.login(args[2], args[3]);
} catch (RedditException e) {
e.printStackTrace();
}
DBHandler.initializeHandler(args[0]);
if (statements == null) {
TypedQuery<Statement> query=DBHandler.em.createQuery("Select o from Statement o where o.text != \"[deleted]\" and o.parentStatement!= null and o.length>0 and o.length < " + max_reply_length,Statement.class);
statements = query.getResultList();
}
if (words == null) {
TypedQuery<Word> queryW=DBHandler.em.createQuery("Select o from Word o",Word.class);
words = queryW.getResultList();
}
//TIMER CODE
Timer timer = new Timer();
long thirty_minutes = 30*60*1000;
long one_hour = thirty_minutes*2;
long waiting_time = (long) (one_hour+(Math.random()*one_hour));
timer.schedule(new TimerTask() {
@Override
public void run() {
System.out.println("-> Awake from Hibernation");
RedditComment commentToReplyTo = <API key>(subreddit);
System.out.println("-> Generating Reply for " + commentToReplyTo.getBody());
String generatedReply = generateCommentFor(commentToReplyTo, classifier);
System.out.println("-> Generated " + generatedReply);
System.out.println("-> Posting..");
<API key>(generatedReply, commentToReplyTo);
System.out.println("-> Going Back to Sleep...");
}
}, waiting_time, waiting_time);
System.out.println("-> Awake from Hibernation");
RedditComment commentToReplyTo = <API key>(subreddit);
System.out.println("-> Generating Reply for " + commentToReplyTo.getBody());
String generatedReply = generateCommentFor(commentToReplyTo, classifier);
System.out.println("-> Generated " + generatedReply);
System.out.println("-> Posting..");
<API key>(generatedReply, commentToReplyTo);
System.out.println("-> Going Back to Sleep...");
//DBHandler.closeHandler();
}
public static RedditComment <API key>(String subreddit) {
//Get the first 25 posts.
try {
List<RedditLink> links = reddit.listingFor(subreddit, "");
Collections.shuffle(links);
RedditLink linkOfInterest = links.get(0);
System.out.println(" <API key> post: " + linkOfInterest);
List<RedditComment> comments = <API key>(linkOfInterest, subreddit);
ArrayList<<API key>> classifications = new ArrayList<<API key>>();
for (RedditComment redditComment : comments) {
classifications.add(<API key>(redditComment));
}
RedditComment bestComment = null;
double max_prob = 0;
int i=0;
for (RedditComment redditComment : comments) {
double prob = classifications.get(i).probability;
if (prob>max_prob && <API key>(redditComment.getBody()).size()>0) {
max_prob = prob;
bestComment = redditComment;
}
i++;
}
System.out.println(" <API key> comment: " + bestComment);
return bestComment;
} catch (Exception e) {
System.out.println("ERROR, trying next time: " + e.getLocalizedMessage());
}
return null;
}
public static RedditComment <API key>(String subreddit) {
//Get the first 25 posts.
try {
List<RedditLink> links = reddit.listingFor(subreddit, "");
Collections.shuffle(links);
RedditLink linkOfInterest = links.get(0);
System.out.println(" <API key> post: " + linkOfInterest);
List<RedditComment> comments = <API key>(linkOfInterest, subreddit);
RedditComment bestComment = null;
long max_karma = 0;
for (RedditComment redditComment : comments) {
if (redditComment.getUps()-redditComment.getDowns() > max_karma) {
//if (redditComment.getReplies().toString().length() <= 10) {
max_karma = redditComment.getUps()-redditComment.getDowns();
bestComment = redditComment;
}
}
System.out.println(" <API key> comment: " + bestComment);
return bestComment;
} catch (Exception e) {
System.out.println("ERROR, trying next time: " + e.getLocalizedMessage());
}
return null;
}
public static String generateCommentFor(RedditComment comment, int classifierID) {
String generated = "";
if (classifierID == 1) {
generated = <API key>(comment).resultString;
} else if (classifierID == 2) {
generated = classifyCommentSVM(comment);
} else if (classifierID == 3) {
generated = <API key>(comment);
} else {
System.out.println("Choose a valid classifier dude.");
System.exit(1);
}
return generated;
}
public static void <API key>(String comment, RedditComment parent) {
try {
System.out.println(" <API key> response: "+reddit.comment(comment, parent.getName()));
} catch (RedditException e) {
System.out.println("ERROR, trying next time: " + e.getLocalizedMessage());
}
}
public static String classifyCommentSVM(RedditComment comment) {
if (model == null) {
try {
model = SVMPredictor.loadModel(subreddit + ".model");
} catch (Exception e1) {
System.out.println("ERROR: Couldnt load SVM model. Exitting");
System.exit(1);
}
KernelManager.setCustomKernel(new LinearKernel());
System.out.println(" classifyCommentSVM: loaded model!!");
}
ArrayList<String> inputlist = <API key>(comment.getBody());
SparseVector vec = new SparseVector();
for (Word word : words) {
int value = 0;
if(inputlist.contains(word.word)) {
value = 1;
}
vec.add(words.indexOf(word), value);
}
Instance inst = new Instance(0, vec);
double result = SVMPredictor.predict(inst, model, false);
return statements.get((int) result).text;
}
public static <API key> <API key>(RedditComment comment) {
if (bayes == null) {
// Create a new bayes classifier with string categories and string features.
bayes = new BayesClassifier<String, String>();
// Change the memory capacity. New learned classifications (using
// learn method are stored in a queue with the size given here and
// used to classify unknown sentences.
bayes.setMemoryCapacity(50000);
TypedQuery<Statement> query=DBHandler.em.createQuery("Select o from Statement o where o.text != \"[deleted]\" and o.parentStatement!= null and o.length>0 and o.length < " + max_reply_length,Statement.class);
List<Statement> statements = query.getResultList();
System.out.println(" <API key> analyzing " + statements.size() + " statements... ");
for (Statement statement : statements) {
ArrayList<String> wordStrings = new ArrayList<String>();
for (Word word : statement.parentStatement.includedWords) {
wordStrings.add(word.word);
}
//LEARN
bayes.learn(statement.text, wordStrings);
}
}
ArrayList<String> list = <API key>(comment.getBody());
Classification<String,String> result = bayes.classify(list);
System.out.println(" <API key> " + list + " prob " + result.getProbability());
return new <API key>(result.getCategory(), result.getProbability());
}
public static String <API key>(RedditComment comment) {
String result = statements.get(randomGenerator.nextInt(statements.size())).text;
System.out.println(" <API key> ");
return result;
}
public static List<RedditComment><API key>(RedditComment redditComment) {
List<RedditComment> thelist = new ArrayList<RedditComment>();
try {
thelist.add(redditComment);
if (redditComment.getReplies().toString().length() >= 10) {
final RedditJsonParser parser = new RedditJsonParser(redditComment.getReplies());
List<RedditComment> redditReplies = parser.parseCommentsOnly();
for (RedditComment redditCommentReply : redditReplies) {
List<RedditComment> additionalList = <API key>(redditCommentReply);
for (RedditComment redditComment2 : additionalList) {
redditComment2.parent = redditComment;
}
thelist.addAll(additionalList);
}
}
} catch (RedditException e) {
e.printStackTrace();
}
return thelist;
}
public static List<RedditComment><API key>(RedditLink redditLink, String subreddit) {
List<RedditComment> thelist = new ArrayList<RedditComment>();
try {
if (redditLink.getNum_comments()>0) {
RedditComments comments;
comments = reddit.commentsFor(subreddit, redditLink.getId());
for (RedditComment redditComment : comments.getComments()) {
List<RedditComment> additionalList = <API key>(redditComment);
thelist.addAll(additionalList);
}
}
} catch (RedditException e) {
e.printStackTrace();
}
return thelist;
}
public static ArrayList<String> <API key>(String input) {
ArrayList<String> wordStrings = new ArrayList<String>();
for (String string : input.split("\\s+")) {
String pruned = string.replaceAll("[^a-zA-Z]", "").toLowerCase();
String stemmed = StemmerHelper.stemWord(pruned);
if (DBHandler.checkWord(stemmed)) {
wordStrings.add(stemmed);
}
}
return wordStrings;
}
}
|
<?php
class WebApplication extends CWebApplication
{
public $keywords;
public $description;
}
|
#ifndef __ANSI_H__
#define __ANSI_H__
#define STATE_ESC_SET 0x01
#define STATE_FONT_SET 0x02
#define STATE_NEW_LINE 0x04
#define STATE_QUOTE_LINE 0x08
#define STATE_NONE 0x00
#define STATE_UBB_START 0x10
#define STATE_UBB_MIDDLE 0x20
#define STATE_UBB_END 0x40
#define STATE_TEX_SET 0x80
enum UBBTYPE {UBB_TYPE_IMG,
UBB_TYPE_ITALICIZE,
UBB_TYPE_UNDERLINE,
UBB_TYPE_BOLD,
UBB_TYPE_FLY,
UBB_TYPE_RM,
UBB_TYPE_FLASH,
UBB_TYPE_CENTER,
UBB_TYPE_EMAIL,
UBB_TYPE_HTTPLINK,
UBB_TYPE_QUOTE,
UBB_TYPE_QUICKTIME,
UBB_TYPE_SHOCKWAVE,
UBB_TYPE_MOVE,
UBB_TYPE_GLOW,
UBB_TYPE_SHADOW,
UBB_TYPE_FACE,
UBB_TYPE_SOUND,
UBB_TYPE_ATTACH
};
enum ATTACHMENTTYPE {
ATTACH_IMG,
ATTACH_FLASH,
ATTACH_OTHERS
};
#define STATE_SET(s, b) ((s) |= (b))
#define STATE_CLR(s, b) ((s) &= ~(b))
#define STATE_ISSET(s, b) ((s) & (b))
#define STATE_ZERO(s) (s = 0)
#define STYLE_SET_FG(s, c) (s = (s & ~0x07) | (c & 0x07))
#define STYLE_SET_BG(s, c) (s = (s & ~0x70) | ((c & 0x07) << 4))
#define STYLE_GET_FG(s) (s & 0x0F)
#define STYLE_GET_BG(s) ((s & 0x70) >> 4)
#define STYLE_CLR_FG(s) (s &= ~0x0F)
#define STYLE_CLR_BG(s) (s &= ~0xF0)
#define STYLE_ZERO(s) (s = 0)
#define STYLE_SET(s, b) (s |= b)
#define STYLE_CLR(s, b) (s &= ~b)
#define STYLE_ISSET(s, b) (s & b)
#define FONT_STYLE_UL 0x0100
#define FONT_STYLE_BLINK 0x0200
#define FONT_STYLE_ITALIC 0x0400
#define FONT_FG_BOLD 0x08
#define FONT_COLOR_BLACK 0x00
#define FONT_COLOR_RED 0x01
#define FONT_COLOR_GREEN 0x02
#define FONT_COLOR_YELLOW 0x03
#define FONT_COLOR_BULE 0x04
#define FONT_COLOR_MAGENTA 0x05
#define FONT_COLOR_CYAN 0x06
#define FONT_COLOR_WHITE 0x07
//#define FONT_STYLE_QUOTE FONT_STYLE_ITALIC
#define FONT_STYLE_QUOTE 0x0000
#define FONT_COLOR_QUOTE FONT_COLOR_CYAN
#define FONT_BG_SET 0x80
#endif /* __ANSI_H__ */
|
using System;
using Server.Misc;
using Server.Network;
using System.Collections;
using Server.Items;
using Server.Targeting;
namespace Server.Mobiles
{
public class KhaldunZealot : BaseCreature
{
public override bool ClickTitle{ get{ return false; } }
public override bool ShowFameTitle{ get{ return false; } }
[Constructable]
public KhaldunZealot(): base( AIType.AI_Melee, FightMode.Closest, 10, 1, 0.2, 0.4 )
{
Body = 0x190;
Name = "Zealot of Khaldun";
Title = "the Knight";
Hue = 0;
SetStr( 351, 400 );
SetDex( 151, 165 );
SetInt( 76, 100 );
SetHits( 448, 470 );
SetDamage( 15, 25 );
SetDamageType( ResistanceType.Physical, 75 );
SetDamageType( ResistanceType.Cold, 25 );
SetResistance( ResistanceType.Physical, 35, 45 );
SetResistance( ResistanceType.Fire, 25, 30 );
SetResistance( ResistanceType.Cold, 50, 60 );
SetResistance( ResistanceType.Poison, 25, 35 );
SetResistance( ResistanceType.Energy, 25, 35 );
SetSkill( SkillName.Wrestling, 70.1, 80.0 );
SetSkill( SkillName.Swords, 120.1, 130.0 );
SetSkill( SkillName.Anatomy, 120.1, 130.0 );
SetSkill( SkillName.MagicResist, 90.1, 100.0 );
SetSkill( SkillName.Tactics, 90.1, 100.0 );
Fame = 10000;
Karma = -10000;
VirtualArmor = 40;
VikingSword weapon = new VikingSword();
weapon.Hue = 0x835;
weapon.Movable = false;
AddItem( weapon );
MetalShield shield = new MetalShield();
shield.Hue = 0x835;
shield.Movable = false;
AddItem( shield );
BoneHelm helm = new BoneHelm();
helm.Hue = 0x835;
AddItem( helm );
BoneArms arms = new BoneArms();
arms.Hue = 0x835;
AddItem( arms );
BoneGloves gloves = new BoneGloves();
gloves.Hue = 0x835;
AddItem( gloves );
BoneChest tunic = new BoneChest();
tunic.Hue = 0x835;
AddItem( tunic );
BoneLegs legs = new BoneLegs();
legs.Hue = 0x835;
AddItem( legs );
AddItem( new Boots() );
}
public override int GetIdleSound()
{
return 0x184;
}
public override int GetAngerSound()
{
return 0x286;
}
public override int GetDeathSound()
{
return 0x288;
}
public override int GetHurtSound()
{
return 0x19F;
}
public override bool AlwaysMurderer{ get{ return true; } }
public override bool Unprovokable{ get{ return true; } }
public override Poison PoisonImmune{ get{ return Poison.Deadly; } }
public KhaldunZealot( Serial serial ) : base( serial )
{
}
public override bool OnBeforeDeath()
{
BoneKnight rm = new BoneKnight();
rm.Team = this.Team;
rm.Combatant = this.Combatant;
rm.NoKillAwards = true;
if ( rm.Backpack == null )
{
Backpack pack = new Backpack();
pack.Movable = false;
rm.AddItem( pack );
}
for ( int i = 0; i < 2; i++ )
{
LootPack.FilthyRich.Generate( this, rm.Backpack, true, LootPack.<API key>( this ) );
LootPack.FilthyRich.Generate( this, rm.Backpack, false, LootPack.<API key>( this ) );
}
Effects.PlaySound(this, Map, GetDeathSound());
Effects.SendLocationEffect( Location, Map, 0x3709, 30, 10, 0x835, 0 );
rm.MoveToWorld( Location, Map );
Delete();
return false;
}
public override void Serialize( GenericWriter writer )
{
base.Serialize( writer );
writer.Write( (int) 0 ); // version
}
public override void Deserialize( GenericReader reader )
{
base.Deserialize( reader );
/*int version = */reader.ReadInt();
}
}
}
|
<?php
/**
* WordPress CRON API
*
* @package WordPress
*/
function <API key>( $timestamp, $hook, $args = array()) {
// don't schedule a duplicate if there's already an identical event due in the next 10 minutes
$next = wp_next_scheduled($hook, $args);
if ( $next && $next <= $timestamp + 600 )
return;
$crons = _get_cron_array();
$key = md5(serialize($args));
$crons[$timestamp][$hook][$key] = array( 'schedule' => false, 'args' => $args );
uksort( $crons, "strnatcasecmp" );
_set_cron_array( $crons );
}
/**
* Schedule a periodic event.
*
* Schedules a hook which will be executed by the WordPress actions core on a
* specific interval, specified by you. The action will trigger when someone
* visits your WordPress site, if the scheduled time has passed.
*
* @since 2.1.0
*
* @param int $timestamp Timestamp for when to run the event.
* @param string $recurrence How often the event should recur.
* @param callback $hook Function or method to call, when cron is run.
* @param array $args Optional. Arguments to pass to the hook function.
* @return bool|null False on failure, null when complete with scheduling event.
*/
function wp_schedule_event( $timestamp, $recurrence, $hook, $args = array()) {
$crons = _get_cron_array();
$schedules = wp_get_schedules();
$key = md5(serialize($args));
if ( !isset( $schedules[$recurrence] ) )
return false;
$crons[$timestamp][$hook][$key] = array( 'schedule' => $recurrence, 'args' => $args, 'interval' => $schedules[$recurrence]['interval'] );
uksort( $crons, "strnatcasecmp" );
_set_cron_array( $crons );
}
/**
* Reschedule a recurring event.
*
* @since 2.1.0
*
* @param int $timestamp Timestamp for when to run the event.
* @param string $recurrence How often the event should recur.
* @param callback $hook Function or method to call, when cron is run.
* @param array $args Optional. Arguments to pass to the hook function.
* @return bool|null False on failure. Null when event is rescheduled.
*/
function wp_reschedule_event( $timestamp, $recurrence, $hook, $args = array()) {
$crons = _get_cron_array();
$schedules = wp_get_schedules();
$key = md5(serialize($args));
$interval = 0;
// First we try to get it from the schedule
if ( 0 == $interval )
$interval = $schedules[$recurrence]['interval'];
// Now we try to get it from the saved interval in case the schedule disappears
if ( 0 == $interval )
$interval = $crons[$timestamp][$hook][$key]['interval'];
// Now we assume something is wrong and fail to schedule
if ( 0 == $interval )
return false;
while ( $timestamp < time() + 1 )
$timestamp += $interval;
wp_schedule_event( $timestamp, $recurrence, $hook, $args );
}
/**
* Unschedule a previously scheduled cron job.
*
* The $timestamp and $hook parameters are required, so that the event can be
* identified.
*
* @since 2.1.0
*
* @param int $timestamp Timestamp for when to run the event.
* @param callback $hook Function or method to call, when cron is run.
* @param array $args Optional. Arguments to pass to the hook function.
*/
function wp_unschedule_event( $timestamp, $hook, $args = array() ) {
$crons = _get_cron_array();
$key = md5(serialize($args));
unset( $crons[$timestamp][$hook][$key] );
if ( empty($crons[$timestamp][$hook]) )
unset( $crons[$timestamp][$hook] );
if ( empty($crons[$timestamp]) )
unset( $crons[$timestamp] );
_set_cron_array( $crons );
}
/**
* Unschedule all cron jobs attached to a specific hook.
*
* @since 2.1.0
*
* @param callback $hook Function or method to call, when cron is run.
* @param mixed $args,... Optional. Event arguments.
*/
function <API key>( $hook ) {
$args = array_slice( func_get_args(), 1 );
while ( $timestamp = wp_next_scheduled( $hook, $args ) )
wp_unschedule_event( $timestamp, $hook, $args );
}
/**
* Retrieve the next timestamp for a cron event.
*
* @since 2.1.0
*
* @param callback $hook Function or method to call, when cron is run.
* @param array $args Optional. Arguments to pass to the hook function.
* @return bool|int The UNIX timestamp of the next time the scheduled event will occur.
*/
function wp_next_scheduled( $hook, $args = array() ) {
$crons = _get_cron_array();
$key = md5(serialize($args));
if ( empty($crons) )
return false;
foreach ( $crons as $timestamp => $cron ) {
if ( isset( $cron[$hook][$key] ) )
return $timestamp;
}
return false;
}
/**
* Send request to run cron through HTTP request that doesn't halt page loading.
*
* @since 2.1.0
*
* @return null Cron could not be spawned, because it is not needed to run.
*/
function spawn_cron( $local_time ) {
/*
* do not even start the cron if local server timer has drifted
* such as due to power failure, or misconfiguration
*/
$timer_accurate = check_server_timer( $local_time );
if ( !$timer_accurate )
return;
//sanity check
$crons = _get_cron_array();
if ( !is_array($crons) )
return;
$keys = array_keys( $crons );
$timestamp = $keys[0];
if ( $timestamp > $local_time )
return;
$cron_url = get_option( 'siteurl' ) . '/wp-cron.php?check=' . wp_hash('187425');
/*
* multiple processes on multiple web servers can run this code concurrently
* try to make this as atomic as possible by setting doing_cron switch
*/
$flag = get_option('doing_cron');
// clean up potential invalid value resulted from various system chaos
if ( $flag != 0 ) {
if ( $flag > $local_time + 10*60 || $flag < $local_time - 10*60 ) {
update_option('doing_cron', 0);
$flag = 0;
}
}
//don't run if another process is currently running it
if ( $flag > $local_time )
return;
update_option( 'doing_cron', $local_time + 30 );
wp_remote_post($cron_url, array('timeout' => 0.01, 'blocking' => false));
}
/**
* Run scheduled callbacks or spawn cron for all scheduled events.
*
* @since 2.1.0
*
* @return null When doesn't need to run Cron.
*/
function wp_cron() {
// Prevent infinite loops caused by lack of wp-cron.php
if ( strpos($_SERVER['REQUEST_URI'], '/wp-cron.php') !== false )
return;
$crons = _get_cron_array();
if ( !is_array($crons) )
return;
$keys = array_keys( $crons );
if ( isset($keys[0]) && $keys[0] > time() )
return;
$local_time = time();
$schedules = wp_get_schedules();
foreach ( $crons as $timestamp => $cronhooks ) {
if ( $timestamp > $local_time ) break;
foreach ( (array) $cronhooks as $hook => $args ) {
if ( isset($schedules[$hook]['callback']) && !call_user_func( $schedules[$hook]['callback'] ) )
continue;
spawn_cron( $local_time );
break 2;
}
}
}
/**
* Retrieve supported and filtered Cron recurrences.
*
* The supported recurrences are 'hourly' and 'daily'. A plugin may add more by
* hooking into the 'cron_schedules' filter. The filter accepts an array of
* arrays. The outer array has a key that is the name of the schedule or for
* example 'weekly'. The value is an array with two keys, one is 'interval' and
* the other is 'display'.
*
* The 'interval' is a number in seconds of when the cron job should run. So for
* 'hourly', the time is 3600 or 60*60. For weekly, the value would be
* 60*60*24*7 or 604800. The value of 'interval' would then be 604800.
*
* The 'display' is the description. For the 'weekly' key, the 'display' would
* be <code>__('Once Weekly')</code>.
*
* For your plugin, you will be passed an array. you can easily add your
* schedule by doing the following.
* <code>
* // filter parameter variable name is 'array'
* $array['weekly'] = array(
* 'interval' => 604800,
* 'display' => __('Once Weekly')
* );
* </code>
*
* @since 2.1.0
*
* @return array
*/
function wp_get_schedules() {
$schedules = array(
'hourly' => array( 'interval' => 3600, 'display' => __('Once Hourly') ),
'twicedaily' => array( 'interval' => 43200, 'display' => __('Twice Daily') ),
'daily' => array( 'interval' => 86400, 'display' => __('Once Daily') ),
);
return array_merge( apply_filters( 'cron_schedules', array() ), $schedules );
}
/**
* Retrieve Cron schedule for hook with arguments.
*
* @since 2.1.0
*
* @param callback $hook Function or method to call, when cron is run.
* @param array $args Optional. Arguments to pass to the hook function.
* @return string|bool False, if no schedule. Schedule on success.
*/
function wp_get_schedule($hook, $args = array()) {
$crons = _get_cron_array();
$key = md5(serialize($args));
if ( empty($crons) )
return false;
foreach ( $crons as $timestamp => $cron ) {
if ( isset( $cron[$hook][$key] ) )
return $cron[$hook][$key]['schedule'];
}
return false;
}
// Private functions
/**
* Retrieve cron info array option.
*
* @since 2.1.0
* @access private
*
* @return array CRON info array.
*/
function _get_cron_array() {
$cron = get_option('cron');
if ( ! is_array($cron) )
return false;
if ( !isset($cron['version']) )
$cron = _upgrade_cron_array($cron);
unset($cron['version']);
return $cron;
}
/**
* Updates the CRON option with the new CRON array.
*
* @since 2.1.0
* @access private
*
* @param array $cron Cron info array from {@link _get_cron_array()}.
*/
function _set_cron_array($cron) {
$cron['version'] = 2;
update_option( 'cron', $cron );
}
/**
* Upgrade a Cron info array.
*
* This function upgrades the Cron info array to version 2.
*
* @since 2.1.0
* @access private
*
* @param array $cron Cron info array from {@link _get_cron_array()}.
* @return array An upgraded Cron info array.
*/
function _upgrade_cron_array($cron) {
if ( isset($cron['version']) && 2 == $cron['version'])
return $cron;
$new_cron = array();
foreach ( (array) $cron as $timestamp => $hooks) {
foreach ( (array) $hooks as $hook => $args ) {
$key = md5(serialize($args['args']));
$new_cron[$timestamp][$hook][$key] = $args;
}
}
$new_cron['version'] = 2;
update_option( 'cron', $new_cron );
return $new_cron;
}
// stub for checking server timer accuracy, using outside standard time sources
function check_server_timer( $local_time ) {
return true;
}
?>
|
#!/usr/bin/env python
## engine and compatible webserver.
## Contact mailto:jeremy@jeremyherbert.net
## This program is free software; you can redistribute it and/or
## as published by the Free Software Foundation; either version 2
## This program is distributed in the hope that it will be useful,
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
## along with this program; if not, write to the Free Software
## Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
## 02110-1301, USA.
import os, sys, ftplib, yaml, cherrypy, re, urllib2
from src.post_classes import *
from src import json
from src.constants import *
from src.support import *
from src.net import *
from src.server import *
post_types = ['Regular', 'Photo', 'Quote', 'Link', 'Conversation', 'Video', 'Audio', 'Conversation']
args_dict = {
'autoreload': 0, # Whether to add the meta refresh tag
'publish': False, # Whether to push the new theme data to tumblr
'data_source': DATA_LOCAL, # Whether to use local data in the theme
}
# take the arguments and place them in a mutable list
arguments = sys.argv
# if the script has been run with the interpreter prefix, get rid of it
if arguments[0] == 'python' or arguments[0] == 'ipython' \
or arguments[0] == 'python2.5':
arguments.pop(0)
# pop off the script name
arguments.pop(0)
# load the configuration file
config_path = 'data/config.yml'
if contains(arguments, '--config'):
if os.path.exists(next_arg(arguments, '--config')):
config_path = next_arg(arguments, '--config')
config = get_config(config_path)
# now we check if there are any data processing flags
if contains(arguments, '--pull-data'):
# call pull_data with the argument after the flag
pull_data( next_arg(arguments, '--pull-data') )
if contains(arguments, '--theme'):
if not os.path.exists("themes/" + next_arg(arguments, '--theme') + '.thtml'):
err_exit("The theme file %s.thtml does not exist in the themes\
directory." % next_arg(arguments, '--theme'))
config['defaults']['theme_name'] = next_arg(arguments, '--theme')
if contains(arguments, '--publish'):
if not has_keys(config['publishing_info'], \
( 'url', 'username', 'password' )):
err_exit('The configuration file is missing some critical publishing\
information. Please make sure you have specified your url, username and\
password.')
publish_theme(config['publishing_info']['url'],\
config['publishing_info']['username'],\
config['publishing_info']['password'],\
get_markup('themes/%s.thtml' % config['defaults']['theme_name']))
if contains(arguments, '--do-nothing'):
config['optimisations']['do_nothing'] = True
# start the server up
cherrypy.config.update('data/cherrypy.conf')
cherrypy.quickstart(TumblrServ(config), '/')
|
package pf::Switch::Motorola;
=head1 NAME
pf::Switch::Motorola
=head1 SYNOPSIS
The pf::Switch::Motorola module implements an object oriented interface to
manage Motorola RF Switches (Wireless Controllers)
=head1 STATUS
Developed and tested on RFS7000 running OS release 4.3.0.0-059R,
and RFS6000 running OS 5.2.0.0-069R.
=over
=item Supports
=over
=item Deauthentication with RADIUS Disconnect (RFC3576)
=item Deauthentication with SNMP
=item Roles-assignment through RADIUS
=back
=back
=head1 BUGS AND LIMITATIONS
=over
=item Firmware 4.x support
Deauthentication against firmware 4.x series is done using SNMP
=item Firmware 5.x support
Deauthentication against firmware 5.x series is done using RADIUS CoA.
=item SNMPv3
SNMPv3 support is untested.
=back
=cut
use strict;
use warnings;
use base ('pf::Switch');
use pf::accounting qw(<API key>);
use pf::constants;
use pf::config qw(
$MAC
$SSID
);
use pf::util;
=head1 SUBROUTINES
=over
=cut
# CAPABILITIES
# access technology supported
sub <API key> { return $TRUE; }
sub <API key> { return $TRUE; }
sub <API key> { return $TRUE; }
# inline capabilities
sub inlineCapabilities { return ($MAC,$SSID); }
=item getVersion
obtain image version information from switch
=cut
sub getVersion {
my ($self) = @_;
my $oid_sysDescr = '1.3.6.1.2.1.1.1.0';
my $logger = $self->logger;
if ( !$self->connectRead() ) {
return '';
}
$logger->trace("SNMP get_request for sysDescr: $oid_sysDescr");
my $result = $self->{_sessionRead}->get_request( -varbindlist => [$oid_sysDescr] );
my $sysDescr = ( $result->{$oid_sysDescr} || '' );
# sysDescr sample output:
# RFS7000 Wireless Switch, Version 4.3.0.0-059R MIB=01a
# all non-whitespace characters grouped after the string Version
if ( $sysDescr =~ / Version (\S+)/ ) {
return $1;
} else {
$logger->warn("couldn't extract exact version information, returning SNMP System Description instead");
return $sysDescr;
}
}
=item parseTrap
Parsing SNMP Traps - WIDS stuff only, other types are discarded
=cut
sub parseTrap {
my ( $self, $trapString ) = @_;
my $trapHashRef;
my $logger = $self->logger;
# Handle WIPS Trap
if ( $trapString =~ /BEGIN VARIABLEBINDINGS.*\.1\.3\.6\.1\.4\.1\.388\.50\.1\.2\.1\.4 = STRING: "Unsanctioned AP ([A-F0-9]{2}-[A-F0-9]{2}-[A-F0-9]{2}-[A-F0-9]{2}-[A-F0-9]{2}-[A-F0-9]{2})/){
$trapHashRef->{'trapType'} = 'wirelessIPS';
$trapHashRef->{'trapMac'} = clean_mac($1);
} else {
$logger->debug("trap currently not handled");
$trapHashRef->{'trapType'} = 'unknown';
}
return $trapHashRef;
}
=item de<API key>
De-authenticate a MAC address from wireless network (including 802.1x).
New implementation using RADIUS Disconnect-Request.
=cut
sub de<API key> {
my ( $self, $mac, $is_dot1x ) = @_;
my $logger = $self->logger;
if ( !$self->isProductionMode() ) {
$logger->info("not in production mode... we won't perform deauthentication");
return 1;
}
if ($self->getVersion() =~ /^5/) {
#Fetching the acct-session-id, mandatory for Motorola
my $acctsessionid = <API key>($mac);
$logger->debug("deauthenticate $mac using RADIUS Disconnect-Request deauth method");
return $self->radiusDisconnect( $mac, { 'Acct-Session-Id' => $acctsessionid } );
} else {
$logger->debug("deauthenticate $mac using SNMP deauth method");
return $self-><API key>($mac);
}
}
=item <API key>
deauthenticate a MAC address from wireless network (including 802.1x)
=cut
sub <API key> {
my ($self, $mac) = @_;
my $logger = $self->logger;
my $<API key> = '1.3.6.1.4.1.388.14.3.2.1.12.3.1.19'; # from WS-CC-RF-MIB
if ( !$self->isProductionMode() ) {
$logger->info("not in production mode ... we won't write to <API key>");
return 1;
}
# handles if deauth should be performed against controller or actual device. Returns sessionWrite hash key to use.
my $performDeauthOn = $self->getDe<API key>();
if ( !defined($performDeauthOn) ) {
return;
}
# append MAC to deauthenticate to oid to set
$<API key> .= '.' . mac2oid($mac);
$logger->info("deauthenticate mac $mac from controller: " . $self->{_ip});
$logger->trace("SNMP set_request for <API key>: $<API key>");
my $result = $self->{$performDeauthOn}->set_request(
-varbindlist => [ "$<API key>", Net::SNMP::INTEGER, $TRUE ]
);
if (defined($result)) {
$logger->debug("deauthenticatation successful");
return $TRUE;
} else {
$logger->warn("deauthenticatation failed with " . $self->{$performDeauthOn}->error());
return;
}
}
=item returnRoleAttribute
Motorola uses the following VSA for role assignment
=cut
sub returnRoleAttribute {
my ($self) = @_;
return 'Symbol-User-Group';
}
=item deauthTechniques
Return the reference to the deauth technique or the default deauth technique.
=cut
sub deauthTechniques {
my ($self, $method) = @_;
my $logger = $self->logger;
my $default = $SNMP::SNMP;
my %tech = (
$SNMP::SNMP => 'de<API key>,
);
if (!defined($method) || !defined($tech{$method})) {
$method = $default;
}
return $method,$tech{$method};
}
=back
=head1 AUTHOR
Inverse inc. <info@inverse.ca>
=head1 COPYRIGHT
Copyright (C) 2005-2017 Inverse inc.
=head1 LICENSE
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
USA.
=cut
1;
# vim: set shiftwidth=4:
# vim: set expandtab:
# vim: set backspace=indent,eol,start:
|
package io.github.mzmine.util;
import java.io.File;
import java.util.List;
import javax.annotation.Nonnull;
import com.google.common.io.Files;
/**
* File name utilities
*/
public class FileNameUtil {
public static @Nonnull String findCommonPrefix(@Nonnull List<File> fileNames) {
if (fileNames.size() < 2)
return "";
String firstName = fileNames.get(0).getName();
for (int prefixLen = 0; prefixLen < firstName.length(); prefixLen++) {
char c = firstName.charAt(prefixLen);
for (int i = 1; i < fileNames.size(); i++) {
String ithName = fileNames.get(i).getName();
if (prefixLen >= ithName.length() || ithName.charAt(prefixLen) != c) {
// Mismatch found
return ithName.substring(0, prefixLen);
}
}
}
return firstName;
}
public static @Nonnull String findCommonSuffix(@Nonnull List<File> fileNames) {
if (fileNames.isEmpty())
return "";
if (fileNames.size() == 1) {
// Return file extension
String ext = Files.getFileExtension(fileNames.get(0).getAbsolutePath());
return "." + ext;
}
String firstName = fileNames.get(0).getName();
for (int suffixLen = 0; suffixLen < firstName.length(); suffixLen++) {
char c = firstName.charAt(firstName.length() - 1 - suffixLen);
for (int i = 1; i < fileNames.size(); i++) {
String ithName = fileNames.get(i).getName();
if (suffixLen >= ithName.length()
|| ithName.charAt(ithName.length() - 1 - suffixLen) != c) {
// Mismatch found
return ithName.substring(ithName.length() - suffixLen);
}
}
}
return firstName;
}
}
|
#include <config.h>
#ifndef IO_H
#define IO_H
#include "utilities.h"
t_tree *Read_Tree(char **s_tree);
void R_rtree(char *s_tree_a,char *s_tree_d,t_node *a,t_tree *tree,int *n_int,int *n_ext);
void Read_Branch_Label(char *s_d,char *s_a,t_edge *b);
void Read_Branch_Length(char *s_d,char *s_a,t_tree *tree);
void Read_Node_Name(t_node *d,char *s_tree_d,t_tree *tree);
void <API key>(char **subtrees,int current_deg,int end_deg);
char **Sub_Trees(char *tree,int *degree);
int Next_Par(char *s,int pos);
void Print_Tree(FILE *fp,t_tree *tree);
char *Write_Tree(t_tree *tree,int custom);
void R_wtree(t_node *pere,t_node *fils,int *available,char **s_tree,t_tree *tree);
void R_wtree_Custom(t_node *pere,t_node *fils,int *available,char **s_tree,int *pos,t_tree *tree);
void <API key>(option *io);
void <API key>(option *io);
align **Get_Seq(option *io);
void Get_Nexus_Data(FILE *fp,option *io);
int Get_Token(FILE *fp,char *token);
align **Get_Seq_Phylip(option *io);
void <API key>(FILE *fp,int *n_otu,int *n_tax);
align **Read_Seq_Sequential(option *io);
align **<API key>(option *io);
int Read_One_Line_Seq(align ***data,int num_otu,FILE *in);
t_tree *Read_Tree_File(option *io);
char *<API key>(FILE *fp_input_tree);
t_tree *<API key>(FILE *fp_input_tree);
void Print_Site_Lk(t_tree *tree,FILE *fp);
void Print_Seq(FILE *fp, align **data, int n_otu);
void Print_CSeq(FILE *fp,int compressed,calign *cdata);
void Print_CSeq_Select(FILE *fp,int compressed,calign *cdata,t_tree *tree);
void Print_Dist(matrix *mat);
void Print_Node(t_node *a,t_node *d,t_tree *tree);
void Print_Model(t_mod *mod);
void Print_Mat(matrix *mat);
FILE *Openfile(char *filename,int mode);
void Print_Fp_Out(FILE *fp_out,time_t t_beg,time_t t_end,t_tree *tree,option *io,int n_data_set,int num_tree, int add_citation);
void Print_Fp_Out_Lines(FILE *fp_out,time_t t_beg,time_t t_end,t_tree *tree,option *io,int n_data_set);
void Print_Freq(t_tree *tree);
void Print_Settings(option *io);
void Print_Banner(FILE *fp);
void Print_Banner_Small(FILE *fp);
void <API key>(option *io,FILE *fp);
void Print_Lk(t_tree *tree,char *string);
void Print_Pars(t_tree *tree);
void Print_Lk_And_Pars(t_tree *tree);
void Read_Qmat(phydbl *daa,phydbl *pi,FILE *fp);
void Print_Qmat_AA(phydbl *daa,phydbl *pi);
void <API key>(int n,phydbl *mat);
void Print_Diversity(FILE *fp,t_tree *tree);
void Print_Diversity_Pre(t_node *a,t_node *d,t_edge *b,FILE *fp,t_tree *tree);
t_tree *Read_User_Tree(calign *cdata,t_mod *mod,option *io);
void Print_Time_Info(time_t t_beg,time_t t_end);
void PhyML_Printf(char *format,...);
void PhyML_Fprintf(FILE *fp,char *format,...);
void Read_Clade_Priors(char *file_name,t_tree *tree);
option *Get_Input(int argc,char **argv);
void <API key>(int final, FILE *fp, t_tree *root);
int Set_Whichmodel(int select);
void Print_Site(calign *cdata, int num, int n_otu, char *sep, int stepsize, FILE *fp);
option *PhyML_XML(char *xml_filename);
void Check_Taxa_Sets(t_tree *mixt_tree);
void <API key>(xml_node *instance, option *io, t_mod *mod);
void <API key>(xml_node *instance, option *io, t_mod *mod);
void <API key>(xml_node *instance, option *io, t_mod *mod);
void <API key>(xml_node *parent, t_mod *mod);
void Post_Process_Data(option *io);
int *Return_Int(int in);
void <API key>(t_tree* tree);
void <API key>(t_tree* tree);
void <API key>(t_tree* tree, t_edge* b, bool scientific);
void Print_Edge_PMats(t_tree* tree, t_edge* b);
void Print_Tip_Partials(t_tree* tree, t_node* d);
void Dump_Arr_D(phydbl* arr, int num);
void Dump_Arr_S(short int* arr, int num);
void Dump_Arr_I(int* arr, int num);
void <API key>(t_tree* tree);
void Print_Node_Brief(t_node *a, t_node *d, t_tree *tree, FILE *fp);
void Generic_Exit(const char *file, int line, const char *function);
#endif
|
/*
* <API key>.c
*
* Code generation for function '<API key>'
*
* C source code generated on: Fri Apr 25 23:35:45 2014
*
*/
/* Include files */
#include "rt_nonfinite.h"
#include "<API key>.h"
/* Type Definitions */
#ifndef <API key>
#define <API key>
struct emxArray__common
{
void *data;
int32_T *size;
int32_T allocatedSize;
int32_T numDimensions;
boolean_T canFreeData;
};
#endif /*<API key>*/
#ifndef <API key>
#define <API key>
typedef struct emxArray__common emxArray__common;
#endif /*<API key>*/
#ifndef <API key>
#define <API key>
struct emxArray_int32_T
{
int32_T *data;
int32_T *size;
int32_T allocatedSize;
int32_T numDimensions;
boolean_T canFreeData;
};
#endif /*<API key>*/
#ifndef <API key>
#define <API key>
typedef struct emxArray_int32_T emxArray_int32_T;
#endif /*<API key>*/
/* Function Declarations */
static void ConstantPad(const emxArray_real_T *a, const real_T padSize[2],
emxArray_real_T *b);
static void b_eml_li_find(const boolean_T x[12], int32_T y_data[12], int32_T
y_size[1]);
static void <API key>(emxArray_boolean_T *x, const emxArray_real_T
*idx);
static void b_emxInit_boolean_T(emxArray_boolean_T **pEmxArray, int32_T
numDimensions);
static void b_emxInit_real_T(emxArray_real_T **pEmxArray, int32_T numDimensions);
static real_T b_std(const real_T varargin_1[17]);
static void bsxfun(const real_T a[17], real_T b, real_T c[17]);
static void <API key>(emxArray_real_T *x, const emxArray_real_T *idx);
static real_T c_std(const real_T varargin_1[17]);
static int32_T div_s32(int32_T numerator, int32_T denominator);
static void eml_li_find(const emxArray_boolean_T *x, emxArray_int32_T *y);
static void eml_null_assignment(emxArray_boolean_T *x);
static void eml_sort(const real_T x[17], real_T y[17], int32_T idx[17]);
static void emxEnsureCapacity(emxArray__common *emxArray, int32_T oldNumel,
int32_T elementSize);
static void emxFree_boolean_T(emxArray_boolean_T **pEmxArray);
static void emxFree_int32_T(emxArray_int32_T **pEmxArray);
static void emxFree_real_T(emxArray_real_T **pEmxArray);
static void emxInit_boolean_T(emxArray_boolean_T **pEmxArray, int32_T
numDimensions);
static void emxInit_int32_T(emxArray_int32_T **pEmxArray, int32_T numDimensions);
static void emxInit_real_T(emxArray_real_T **pEmxArray, int32_T numDimensions);
static real_T <API key>(real_T S[17]);
static real_T <API key>(const real_T S[17]);
static void filter(const emxArray_real_T *x, real_T zi, emxArray_real_T *y);
static void filtfilt(const emxArray_real_T *x_in, emxArray_real_T *y_out);
static void histogramFeatures(const real_T ioiHist[17], real_T features[12]);
static void ioiHistogram(emxArray_boolean_T *onsets, const emxArray_real_T *T,
real_T ioiHist[17]);
static void onsetDetection(const emxArray_real_T *spec, emxArray_boolean_T
*onsets, emxArray_real_T *flux);
static void onsetFlux(const emxArray_real_T *S, emxArray_real_T *flux);
static void padarray(const emxArray_real_T *varargin_1, emxArray_real_T *b);
static void rdivide(const emxArray_real_T *x, real_T y, emxArray_real_T *z);
static real_T rt_powd_snf(real_T u0, real_T u1);
/* Function Definitions */
static void ConstantPad(const emxArray_real_T *a, const real_T padSize[2],
emxArray_real_T *b)
{
real_T sizeB[2];
int32_T cdiff;
uint32_T varargin_1[2];
int32_T ndbl;
emxArray_real_T *idxB;
emxArray_int32_T *r7;
emxArray_real_T *r8;
emxArray_real_T *r9;
int32_T k;
int32_T absb;
int32_T apnd;
int32_T i4;
emxArray_boolean_T *x;
real_T idxB1;
real_T idxB2;
int32_T b_sizeB[2];
int32_T outsize[2];
for (cdiff = 0; cdiff < 2; cdiff++) {
sizeB[cdiff] = 0.0;
}
for (cdiff = 0; cdiff < 2; cdiff++) {
varargin_1[cdiff] = (uint32_T)a->size[cdiff];
}
ndbl = (int32_T)varargin_1[0];
if ((int32_T)varargin_1[1] > (int32_T)varargin_1[0]) {
ndbl = (int32_T)varargin_1[1];
}
emxInit_real_T(&idxB, 2);
cdiff = idxB->size[0] * idxB->size[1];
idxB->size[0] = ndbl;
idxB->size[1] = 2;
emxEnsureCapacity((emxArray__common *)idxB, cdiff, (int32_T)sizeof(real_T));
ndbl <<= 1;
for (cdiff = 0; cdiff < ndbl; cdiff++) {
idxB->data[cdiff] = 0.0;
}
emxInit_int32_T(&r7, 1);
emxInit_real_T(&r8, 2);
emxInit_real_T(&r9, 2);
for (k = 0; k < 2; k++) {
sizeB[k] = (real_T)a->size[k] + 2.0 * padSize[k];
if (1 > a->size[k]) {
ndbl = 0;
} else {
ndbl = a->size[k];
}
cdiff = r7->size[0];
r7->size[0] = ndbl;
emxEnsureCapacity((emxArray__common *)r7, cdiff, (int32_T)sizeof(int32_T));
for (cdiff = 0; cdiff < ndbl; cdiff++) {
r7->data[cdiff] = cdiff;
}
if (a->size[k] < 1) {
absb = -1;
apnd = 0;
} else {
ndbl = (int32_T)floor(((real_T)a->size[k] - 1.0) + 0.5);
apnd = ndbl + 1;
cdiff = (ndbl - a->size[k]) + 1;
absb = a->size[k];
if (1 > absb) {
i4 = 1;
} else {
i4 = absb;
}
if (fabs(cdiff) < 4.<API key> * (real_T)i4) {
ndbl++;
apnd = a->size[k];
} else if (cdiff > 0) {
apnd = ndbl;
} else {
ndbl++;
}
absb = ndbl - 1;
}
cdiff = r8->size[0] * r8->size[1];
r8->size[0] = 1;
r8->size[1] = absb + 1;
emxEnsureCapacity((emxArray__common *)r8, cdiff, (int32_T)sizeof(real_T));
if (absb + 1 > 0) {
r8->data[0] = 1.0;
if (absb + 1 > 1) {
r8->data[absb] = apnd;
ndbl = absb / 2;
for (cdiff = 1; cdiff < ndbl; cdiff++) {
r8->data[cdiff] = 1.0 + (real_T)cdiff;
r8->data[absb - cdiff] = apnd - cdiff;
}
if (ndbl << 1 == absb) {
r8->data[ndbl] = (1.0 + (real_T)apnd) / 2.0;
} else {
r8->data[ndbl] = 1.0 + (real_T)ndbl;
r8->data[ndbl + 1] = apnd - ndbl;
}
}
}
cdiff = r9->size[0] * r9->size[1];
r9->size[0] = 1;
r9->size[1] = r8->size[1];
emxEnsureCapacity((emxArray__common *)r9, cdiff, (int32_T)sizeof(real_T));
ndbl = r8->size[1];
for (cdiff = 0; cdiff < ndbl; cdiff++) {
r9->data[r9->size[0] * cdiff] = r8->data[r8->size[0] * cdiff] + padSize[k];
}
ndbl = r7->size[0];
for (cdiff = 0; cdiff < ndbl; cdiff++) {
idxB->data[r7->data[cdiff] + idxB->size[0] * k] = r9->data[cdiff];
}
}
emxFree_real_T(&r9);
emxFree_real_T(&r8);
emxFree_int32_T(&r7);
b_emxInit_boolean_T(&x, 1);
ndbl = idxB->size[0];
cdiff = x->size[0];
x->size[0] = ndbl;
emxEnsureCapacity((emxArray__common *)x, cdiff, (int32_T)sizeof(boolean_T));
for (cdiff = 0; cdiff < ndbl; cdiff++) {
x->data[cdiff] = (idxB->data[cdiff] != 0.0);
}
if (x->size[0] == 0) {
idxB1 = 0.0;
} else {
idxB1 = x->data[0];
for (k = 2; k <= x->size[0]; k++) {
idxB1 += (real_T)x->data[k - 1];
}
}
ndbl = idxB->size[0];
cdiff = x->size[0];
x->size[0] = ndbl;
emxEnsureCapacity((emxArray__common *)x, cdiff, (int32_T)sizeof(boolean_T));
for (cdiff = 0; cdiff < ndbl; cdiff++) {
x->data[cdiff] = (idxB->data[cdiff + idxB->size[0]] != 0.0);
}
if (x->size[0] == 0) {
idxB2 = 0.0;
} else {
idxB2 = x->data[0];
for (k = 2; k <= x->size[0]; k++) {
idxB2 += (real_T)x->data[k - 1];
}
}
emxFree_boolean_T(&x);
b_sizeB[0] = (int32_T)sizeB[0];
b_sizeB[1] = (int32_T)sizeB[1];
for (cdiff = 0; cdiff < 2; cdiff++) {
outsize[cdiff] = b_sizeB[cdiff];
}
cdiff = b->size[0] * b->size[1];
b->size[0] = outsize[0];
emxEnsureCapacity((emxArray__common *)b, cdiff, (int32_T)sizeof(real_T));
cdiff = b->size[0] * b->size[1];
b->size[1] = outsize[1];
emxEnsureCapacity((emxArray__common *)b, cdiff, (int32_T)sizeof(real_T));
ndbl = outsize[0] * outsize[1];
for (cdiff = 0; cdiff < ndbl; cdiff++) {
b->data[cdiff] = 0.0;
}
for (ndbl = 0; ndbl < (int32_T)idxB1; ndbl++) {
for (cdiff = 0; cdiff < (int32_T)idxB2; cdiff++) {
b->data[((int32_T)idxB->data[(int32_T)(1.0 + (real_T)ndbl) - 1] + b->size
[0] * ((int32_T)idxB->data[((int32_T)(1.0 + (real_T)cdiff) +
idxB->size[0]) - 1] - 1)) - 1] = a->data[((int32_T)(1.0 +
(real_T)ndbl) + a->size[0] * ((int32_T)(1.0 + (real_T)cdiff) - 1)) - 1];
}
}
emxFree_real_T(&idxB);
}
static void b_eml_li_find(const boolean_T x[12], int32_T y_data[12], int32_T
y_size[1])
{
int32_T k;
int32_T i;
k = 0;
for (i = 0; i < 12; i++) {
if (x[i]) {
k++;
}
}
y_size[0] = k;
k = 0;
for (i = 0; i < 12; i++) {
if (x[i]) {
y_data[k] = i + 1;
k++;
}
}
}
static void <API key>(emxArray_boolean_T *x, const emxArray_real_T
*idx)
{
int32_T nxin;
int32_T k;
emxArray_int32_T *r13;
emxArray_boolean_T *b_x;
emxArray_boolean_T *c_x;
int32_T nxout;
int32_T i6;
int32_T k0;
emxArray_boolean_T *b;
nxin = x->size[0] * x->size[1];
if (idx->size[1] == 1) {
for (k = (int32_T)idx->data[0]; k < nxin; k++) {
x->data[k - 1] = x->data[k];
}
emxInit_int32_T(&r13, 1);
emxInit_boolean_T(&b_x, 2);
b_emxInit_boolean_T(&c_x, 1);
if ((x->size[0] != 1) && (x->size[1] == 1)) {
if (1 > nxin - 1) {
nxout = 0;
} else {
nxout = nxin - 1;
}
i6 = c_x->size[0];
c_x->size[0] = nxout;
emxEnsureCapacity((emxArray__common *)c_x, i6, (int32_T)sizeof(boolean_T));
for (i6 = 0; i6 < nxout; i6++) {
c_x->data[i6] = x->data[i6];
}
i6 = x->size[0] * x->size[1];
x->size[0] = nxout;
x->size[1] = 1;
emxEnsureCapacity((emxArray__common *)x, i6, (int32_T)sizeof(boolean_T));
i6 = 0;
while (i6 <= 0) {
for (i6 = 0; i6 < nxout; i6++) {
x->data[i6] = c_x->data[i6];
}
i6 = 1;
}
} else {
if (1 > nxin - 1) {
nxout = 0;
} else {
nxout = nxin - 1;
}
i6 = r13->size[0];
r13->size[0] = nxout;
emxEnsureCapacity((emxArray__common *)r13, i6, (int32_T)sizeof(int32_T));
for (i6 = 0; i6 < nxout; i6++) {
r13->data[i6] = 1 + i6;
}
nxout = r13->size[0];
i6 = b_x->size[0] * b_x->size[1];
b_x->size[0] = 1;
b_x->size[1] = nxout;
emxEnsureCapacity((emxArray__common *)b_x, i6, (int32_T)sizeof(boolean_T));
for (i6 = 0; i6 < nxout; i6++) {
k = 0;
while (k <= 0) {
b_x->data[b_x->size[0] * i6] = x->data[r13->data[i6] - 1];
k = 1;
}
}
i6 = x->size[0] * x->size[1];
x->size[0] = b_x->size[0];
x->size[1] = b_x->size[1];
emxEnsureCapacity((emxArray__common *)x, i6, (int32_T)sizeof(boolean_T));
nxout = b_x->size[1];
for (i6 = 0; i6 < nxout; i6++) {
k0 = b_x->size[0];
for (k = 0; k < k0; k++) {
x->data[k + x->size[0] * i6] = b_x->data[k + b_x->size[0] * i6];
}
}
}
emxFree_boolean_T(&c_x);
emxFree_boolean_T(&b_x);
emxFree_int32_T(&r13);
} else {
emxInit_boolean_T(&b, 2);
i6 = b->size[0] * b->size[1];
b->size[0] = 1;
b->size[1] = nxin;
emxEnsureCapacity((emxArray__common *)b, i6, (int32_T)sizeof(boolean_T));
for (i6 = 0; i6 < nxin; i6++) {
b->data[i6] = FALSE;
}
for (k = 1; k <= idx->size[1]; k++) {
b->data[(int32_T)idx->data[k - 1] - 1] = TRUE;
}
nxout = 0;
for (k = 1; k <= b->size[1]; k++) {
nxout += b->data[k - 1];
}
nxout = nxin - nxout;
k0 = -1;
for (k = 1; k <= nxin; k++) {
if ((k > b->size[1]) || (!b->data[k - 1])) {
k0++;
x->data[k0] = x->data[k - 1];
}
}
emxFree_boolean_T(&b);
emxInit_int32_T(&r13, 1);
emxInit_boolean_T(&b_x, 2);
b_emxInit_boolean_T(&c_x, 1);
if ((x->size[0] != 1) && (x->size[1] == 1)) {
if (1 > nxout) {
nxout = 0;
}
i6 = c_x->size[0];
c_x->size[0] = nxout;
emxEnsureCapacity((emxArray__common *)c_x, i6, (int32_T)sizeof(boolean_T));
for (i6 = 0; i6 < nxout; i6++) {
c_x->data[i6] = x->data[i6];
}
i6 = x->size[0] * x->size[1];
x->size[0] = nxout;
x->size[1] = 1;
emxEnsureCapacity((emxArray__common *)x, i6, (int32_T)sizeof(boolean_T));
i6 = 0;
while (i6 <= 0) {
for (i6 = 0; i6 < nxout; i6++) {
x->data[i6] = c_x->data[i6];
}
i6 = 1;
}
} else {
if (1 > nxout) {
nxout = 0;
}
i6 = r13->size[0];
r13->size[0] = nxout;
emxEnsureCapacity((emxArray__common *)r13, i6, (int32_T)sizeof(int32_T));
for (i6 = 0; i6 < nxout; i6++) {
r13->data[i6] = 1 + i6;
}
nxout = r13->size[0];
i6 = b_x->size[0] * b_x->size[1];
b_x->size[0] = 1;
b_x->size[1] = nxout;
emxEnsureCapacity((emxArray__common *)b_x, i6, (int32_T)sizeof(boolean_T));
for (i6 = 0; i6 < nxout; i6++) {
k = 0;
while (k <= 0) {
b_x->data[b_x->size[0] * i6] = x->data[r13->data[i6] - 1];
k = 1;
}
}
i6 = x->size[0] * x->size[1];
x->size[0] = b_x->size[0];
x->size[1] = b_x->size[1];
emxEnsureCapacity((emxArray__common *)x, i6, (int32_T)sizeof(boolean_T));
nxout = b_x->size[1];
for (i6 = 0; i6 < nxout; i6++) {
k0 = b_x->size[0];
for (k = 0; k < k0; k++) {
x->data[k + x->size[0] * i6] = b_x->data[k + b_x->size[0] * i6];
}
}
}
emxFree_boolean_T(&c_x);
emxFree_boolean_T(&b_x);
emxFree_int32_T(&r13);
}
}
static void b_emxInit_boolean_T(emxArray_boolean_T **pEmxArray, int32_T
numDimensions)
{
emxArray_boolean_T *emxArray;
int32_T i;
*pEmxArray = (emxArray_boolean_T *)malloc(sizeof(emxArray_boolean_T));
emxArray = *pEmxArray;
emxArray->data = (boolean_T *)NULL;
emxArray->numDimensions = numDimensions;
emxArray->size = (int32_T *)malloc((uint32_T)(sizeof(int32_T) * numDimensions));
emxArray->allocatedSize = 0;
emxArray->canFreeData = TRUE;
for (i = 0; i < numDimensions; i++) {
emxArray->size[i] = 0;
}
}
static void b_emxInit_real_T(emxArray_real_T **pEmxArray, int32_T numDimensions)
{
emxArray_real_T *emxArray;
int32_T i;
*pEmxArray = (emxArray_real_T *)malloc(sizeof(emxArray_real_T));
emxArray = *pEmxArray;
emxArray->data = (real_T *)NULL;
emxArray->numDimensions = numDimensions;
emxArray->size = (int32_T *)malloc((uint32_T)(sizeof(int32_T) * numDimensions));
emxArray->allocatedSize = 0;
emxArray->canFreeData = TRUE;
for (i = 0; i < numDimensions; i++) {
emxArray->size[i] = 0;
}
}
static real_T b_std(const real_T varargin_1[17])
{
real_T y;
int32_T ix;
real_T xbar;
int32_T k;
real_T r;
ix = 0;
xbar = varargin_1[0];
for (k = 0; k < 16; k++) {
ix++;
xbar += varargin_1[ix];
}
xbar /= 17.0;
ix = 0;
r = varargin_1[0] - xbar;
y = r * r;
for (k = 0; k < 16; k++) {
ix++;
r = varargin_1[ix] - xbar;
y += r * r;
}
y /= 16.0;
return sqrt(y);
}
static void bsxfun(const real_T a[17], real_T b, real_T c[17])
{
int32_T k;
for (k = 0; k < 17; k++) {
c[k] = a[k] - b;
}
}
static void <API key>(emxArray_real_T *x, const emxArray_real_T *idx)
{
int32_T nxin;
int32_T k;
emxArray_int32_T *r14;
emxArray_real_T *b_x;
emxArray_real_T *c_x;
int32_T nxout;
int32_T i7;
int32_T k0;
emxArray_boolean_T *b;
nxin = x->size[0] * x->size[1];
if (idx->size[1] == 1) {
for (k = (int32_T)idx->data[0]; k < nxin; k++) {
x->data[k - 1] = x->data[k];
}
emxInit_int32_T(&r14, 1);
emxInit_real_T(&b_x, 2);
b_emxInit_real_T(&c_x, 1);
if ((x->size[0] != 1) && (x->size[1] == 1)) {
if (1 > nxin - 1) {
nxout = 0;
} else {
nxout = nxin - 1;
}
i7 = c_x->size[0];
c_x->size[0] = nxout;
emxEnsureCapacity((emxArray__common *)c_x, i7, (int32_T)sizeof(real_T));
for (i7 = 0; i7 < nxout; i7++) {
c_x->data[i7] = x->data[i7];
}
i7 = x->size[0] * x->size[1];
x->size[0] = nxout;
x->size[1] = 1;
emxEnsureCapacity((emxArray__common *)x, i7, (int32_T)sizeof(real_T));
i7 = 0;
while (i7 <= 0) {
for (i7 = 0; i7 < nxout; i7++) {
x->data[i7] = c_x->data[i7];
}
i7 = 1;
}
} else {
if (1 > nxin - 1) {
nxout = 0;
} else {
nxout = nxin - 1;
}
i7 = r14->size[0];
r14->size[0] = nxout;
emxEnsureCapacity((emxArray__common *)r14, i7, (int32_T)sizeof(int32_T));
for (i7 = 0; i7 < nxout; i7++) {
r14->data[i7] = 1 + i7;
}
nxout = r14->size[0];
i7 = b_x->size[0] * b_x->size[1];
b_x->size[0] = 1;
b_x->size[1] = nxout;
emxEnsureCapacity((emxArray__common *)b_x, i7, (int32_T)sizeof(real_T));
for (i7 = 0; i7 < nxout; i7++) {
k = 0;
while (k <= 0) {
b_x->data[b_x->size[0] * i7] = x->data[r14->data[i7] - 1];
k = 1;
}
}
i7 = x->size[0] * x->size[1];
x->size[0] = b_x->size[0];
x->size[1] = b_x->size[1];
emxEnsureCapacity((emxArray__common *)x, i7, (int32_T)sizeof(real_T));
nxout = b_x->size[1];
for (i7 = 0; i7 < nxout; i7++) {
k0 = b_x->size[0];
for (k = 0; k < k0; k++) {
x->data[k + x->size[0] * i7] = b_x->data[k + b_x->size[0] * i7];
}
}
}
emxFree_real_T(&c_x);
emxFree_real_T(&b_x);
emxFree_int32_T(&r14);
} else {
emxInit_boolean_T(&b, 2);
i7 = b->size[0] * b->size[1];
b->size[0] = 1;
b->size[1] = nxin;
emxEnsureCapacity((emxArray__common *)b, i7, (int32_T)sizeof(boolean_T));
for (i7 = 0; i7 < nxin; i7++) {
b->data[i7] = FALSE;
}
for (k = 1; k <= idx->size[1]; k++) {
b->data[(int32_T)idx->data[k - 1] - 1] = TRUE;
}
nxout = 0;
for (k = 1; k <= b->size[1]; k++) {
nxout += b->data[k - 1];
}
nxout = nxin - nxout;
k0 = -1;
for (k = 1; k <= nxin; k++) {
if ((k > b->size[1]) || (!b->data[k - 1])) {
k0++;
x->data[k0] = x->data[k - 1];
}
}
emxFree_boolean_T(&b);
emxInit_int32_T(&r14, 1);
emxInit_real_T(&b_x, 2);
b_emxInit_real_T(&c_x, 1);
if ((x->size[0] != 1) && (x->size[1] == 1)) {
if (1 > nxout) {
nxout = 0;
}
i7 = c_x->size[0];
c_x->size[0] = nxout;
emxEnsureCapacity((emxArray__common *)c_x, i7, (int32_T)sizeof(real_T));
for (i7 = 0; i7 < nxout; i7++) {
c_x->data[i7] = x->data[i7];
}
i7 = x->size[0] * x->size[1];
x->size[0] = nxout;
x->size[1] = 1;
emxEnsureCapacity((emxArray__common *)x, i7, (int32_T)sizeof(real_T));
i7 = 0;
while (i7 <= 0) {
for (i7 = 0; i7 < nxout; i7++) {
x->data[i7] = c_x->data[i7];
}
i7 = 1;
}
} else {
if (1 > nxout) {
nxout = 0;
}
i7 = r14->size[0];
r14->size[0] = nxout;
emxEnsureCapacity((emxArray__common *)r14, i7, (int32_T)sizeof(int32_T));
for (i7 = 0; i7 < nxout; i7++) {
r14->data[i7] = 1 + i7;
}
nxout = r14->size[0];
i7 = b_x->size[0] * b_x->size[1];
b_x->size[0] = 1;
b_x->size[1] = nxout;
emxEnsureCapacity((emxArray__common *)b_x, i7, (int32_T)sizeof(real_T));
for (i7 = 0; i7 < nxout; i7++) {
k = 0;
while (k <= 0) {
b_x->data[b_x->size[0] * i7] = x->data[r14->data[i7] - 1];
k = 1;
}
}
i7 = x->size[0] * x->size[1];
x->size[0] = b_x->size[0];
x->size[1] = b_x->size[1];
emxEnsureCapacity((emxArray__common *)x, i7, (int32_T)sizeof(real_T));
nxout = b_x->size[1];
for (i7 = 0; i7 < nxout; i7++) {
k0 = b_x->size[0];
for (k = 0; k < k0; k++) {
x->data[k + x->size[0] * i7] = b_x->data[k + b_x->size[0] * i7];
}
}
}
emxFree_real_T(&c_x);
emxFree_real_T(&b_x);
emxFree_int32_T(&r14);
}
}
static real_T c_std(const real_T varargin_1[17])
{
real_T y;
int32_T ix;
real_T xbar;
int32_T k;
real_T r;
ix = 0;
xbar = varargin_1[0];
for (k = 0; k < 16; k++) {
ix++;
xbar += varargin_1[ix];
}
xbar /= 17.0;
ix = 0;
r = varargin_1[0] - xbar;
y = r * r;
for (k = 0; k < 16; k++) {
ix++;
r = varargin_1[ix] - xbar;
y += r * r;
}
y /= 17.0;
return sqrt(y);
}
static int32_T div_s32(int32_T numerator, int32_T denominator)
{
int32_T quotient;
uint32_T absNumerator;
uint32_T absDenominator;
int32_T <API key>;
if (denominator == 0) {
if (numerator >= 0) {
quotient = MAX_int32_T;
} else {
quotient = MIN_int32_T;
}
} else {
if (numerator >= 0) {
absNumerator = (uint32_T)numerator;
} else {
absNumerator = (uint32_T)-numerator;
}
if (denominator >= 0) {
absDenominator = (uint32_T)denominator;
} else {
absDenominator = (uint32_T)-denominator;
}
<API key> = ((numerator < 0) != (denominator < 0));
absNumerator /= absDenominator;
if ((uint32_T)<API key>) {
quotient = -(int32_T)absNumerator;
} else {
quotient = (int32_T)absNumerator;
}
}
return quotient;
}
static void eml_li_find(const emxArray_boolean_T *x, emxArray_int32_T *y)
{
int32_T n;
int32_T k;
int32_T i;
int32_T j;
n = x->size[0] * x->size[1];
k = 0;
for (i = 1; i <= n; i++) {
if (x->data[i - 1]) {
k++;
}
}
j = y->size[0];
y->size[0] = k;
emxEnsureCapacity((emxArray__common *)y, j, (int32_T)sizeof(int32_T));
j = 0;
for (i = 1; i <= n; i++) {
if (x->data[i - 1]) {
y->data[j] = i;
j++;
}
}
}
static void eml_null_assignment(emxArray_boolean_T *x)
{
emxArray_boolean_T *b;
int32_T nxin;
int32_T i5;
int32_T k;
int32_T nxout;
int32_T k0;
emxArray_int32_T *r12;
emxArray_boolean_T *b_x;
emxArray_boolean_T *c_x;
emxInit_boolean_T(&b, 2);
nxin = x->size[0] * x->size[1];
i5 = b->size[0] * b->size[1];
b->size[0] = 1;
b->size[1] = nxin;
emxEnsureCapacity((emxArray__common *)b, i5, (int32_T)sizeof(boolean_T));
for (i5 = 0; i5 < nxin; i5++) {
b->data[i5] = FALSE;
}
for (k = 0; k < 2; k++) {
b->data[k] = TRUE;
}
nxout = 0;
for (k = 1; k <= b->size[1]; k++) {
nxout += b->data[k - 1];
}
nxout = nxin - nxout;
k0 = -1;
for (k = 1; k <= nxin; k++) {
if ((k > b->size[1]) || (!b->data[k - 1])) {
k0++;
x->data[k0] = x->data[k - 1];
}
}
emxFree_boolean_T(&b);
emxInit_int32_T(&r12, 1);
emxInit_boolean_T(&b_x, 2);
b_emxInit_boolean_T(&c_x, 1);
if ((x->size[0] != 1) && (x->size[1] == 1)) {
if (1 > nxout) {
nxout = 0;
}
i5 = c_x->size[0];
c_x->size[0] = nxout;
emxEnsureCapacity((emxArray__common *)c_x, i5, (int32_T)sizeof(boolean_T));
for (i5 = 0; i5 < nxout; i5++) {
c_x->data[i5] = x->data[i5];
}
i5 = x->size[0] * x->size[1];
x->size[0] = nxout;
x->size[1] = 1;
emxEnsureCapacity((emxArray__common *)x, i5, (int32_T)sizeof(boolean_T));
i5 = 0;
while (i5 <= 0) {
for (i5 = 0; i5 < nxout; i5++) {
x->data[i5] = c_x->data[i5];
}
i5 = 1;
}
} else {
if (1 > nxout) {
nxout = 0;
}
i5 = r12->size[0];
r12->size[0] = nxout;
emxEnsureCapacity((emxArray__common *)r12, i5, (int32_T)sizeof(int32_T));
for (i5 = 0; i5 < nxout; i5++) {
r12->data[i5] = 1 + i5;
}
nxout = r12->size[0];
i5 = b_x->size[0] * b_x->size[1];
b_x->size[0] = 1;
b_x->size[1] = nxout;
emxEnsureCapacity((emxArray__common *)b_x, i5, (int32_T)sizeof(boolean_T));
for (i5 = 0; i5 < nxout; i5++) {
k = 0;
while (k <= 0) {
b_x->data[b_x->size[0] * i5] = x->data[r12->data[i5] - 1];
k = 1;
}
}
i5 = x->size[0] * x->size[1];
x->size[0] = b_x->size[0];
x->size[1] = b_x->size[1];
emxEnsureCapacity((emxArray__common *)x, i5, (int32_T)sizeof(boolean_T));
nxout = b_x->size[1];
for (i5 = 0; i5 < nxout; i5++) {
k0 = b_x->size[0];
for (k = 0; k < k0; k++) {
x->data[k + x->size[0] * i5] = b_x->data[k + b_x->size[0] * i5];
}
}
}
emxFree_boolean_T(&c_x);
emxFree_boolean_T(&b_x);
emxFree_int32_T(&r12);
}
static void eml_sort(const real_T x[17], real_T y[17], int32_T idx[17])
{
int32_T k;
boolean_T p;
int8_T idx0[17];
int32_T i;
int32_T i2;
int32_T j;
int32_T pEnd;
int32_T b_p;
int32_T q;
int32_T qEnd;
int32_T kEnd;
for (k = 0; k < 17; k++) {
idx[k] = k + 1;
}
for (k = 0; k < 15; k += 2) {
if ((x[k] <= x[k + 1]) || rtIsNaN(x[k + 1])) {
p = TRUE;
} else {
p = FALSE;
}
if (p) {
} else {
idx[k] = k + 2;
idx[k + 1] = k + 1;
}
}
for (i = 0; i < 17; i++) {
idx0[i] = 1;
}
i = 2;
while (i < 17) {
i2 = i << 1;
j = 1;
for (pEnd = 1 + i; pEnd < 18; pEnd = qEnd + i) {
b_p = j;
q = pEnd - 1;
qEnd = j + i2;
if (qEnd > 18) {
qEnd = 18;
}
k = 0;
kEnd = qEnd - j;
while (k + 1 <= kEnd) {
if ((x[idx[b_p - 1] - 1] <= x[idx[q] - 1]) || rtIsNaN(x[idx[q] - 1])) {
p = TRUE;
} else {
p = FALSE;
}
if (p) {
idx0[k] = (int8_T)idx[b_p - 1];
b_p++;
if (b_p == pEnd) {
while (q + 1 < qEnd) {
k++;
idx0[k] = (int8_T)idx[q];
q++;
}
}
} else {
idx0[k] = (int8_T)idx[q];
q++;
if (q + 1 == qEnd) {
while (b_p < pEnd) {
k++;
idx0[k] = (int8_T)idx[b_p - 1];
b_p++;
}
}
}
k++;
}
for (k = 0; k + 1 <= kEnd; k++) {
idx[(j + k) - 1] = idx0[k];
}
j = qEnd;
}
i = i2;
}
for (k = 0; k < 17; k++) {
y[k] = x[idx[k] - 1];
}
}
static void emxEnsureCapacity(emxArray__common *emxArray, int32_T oldNumel,
int32_T elementSize)
{
int32_T newNumel;
int32_T i;
void *newData;
newNumel = 1;
for (i = 0; i < emxArray->numDimensions; i++) {
newNumel *= emxArray->size[i];
}
if (newNumel > emxArray->allocatedSize) {
i = emxArray->allocatedSize;
if (i < 16) {
i = 16;
}
while (i < newNumel) {
i <<= 1;
}
newData = calloc((uint32_T)i, (uint32_T)elementSize);
if (emxArray->data != NULL) {
memcpy(newData, emxArray->data, (uint32_T)(elementSize * oldNumel));
if (emxArray->canFreeData) {
free(emxArray->data);
}
}
emxArray->data = newData;
emxArray->allocatedSize = i;
emxArray->canFreeData = TRUE;
}
}
static void emxFree_boolean_T(emxArray_boolean_T **pEmxArray)
{
if (*pEmxArray != (emxArray_boolean_T *)NULL) {
if ((*pEmxArray)->canFreeData) {
free((void *)(*pEmxArray)->data);
}
free((void *)(*pEmxArray)->size);
free((void *)*pEmxArray);
*pEmxArray = (emxArray_boolean_T *)NULL;
}
}
static void emxFree_int32_T(emxArray_int32_T **pEmxArray)
{
if (*pEmxArray != (emxArray_int32_T *)NULL) {
if ((*pEmxArray)->canFreeData) {
free((void *)(*pEmxArray)->data);
}
free((void *)(*pEmxArray)->size);
free((void *)*pEmxArray);
*pEmxArray = (emxArray_int32_T *)NULL;
}
}
static void emxFree_real_T(emxArray_real_T **pEmxArray)
{
if (*pEmxArray != (emxArray_real_T *)NULL) {
if ((*pEmxArray)->canFreeData) {
free((void *)(*pEmxArray)->data);
}
free((void *)(*pEmxArray)->size);
free((void *)*pEmxArray);
*pEmxArray = (emxArray_real_T *)NULL;
}
}
static void emxInit_boolean_T(emxArray_boolean_T **pEmxArray, int32_T
numDimensions)
{
emxArray_boolean_T *emxArray;
int32_T i;
*pEmxArray = (emxArray_boolean_T *)malloc(sizeof(emxArray_boolean_T));
emxArray = *pEmxArray;
emxArray->data = (boolean_T *)NULL;
emxArray->numDimensions = numDimensions;
emxArray->size = (int32_T *)malloc((uint32_T)(sizeof(int32_T) * numDimensions));
emxArray->allocatedSize = 0;
emxArray->canFreeData = TRUE;
for (i = 0; i < numDimensions; i++) {
emxArray->size[i] = 0;
}
}
static void emxInit_int32_T(emxArray_int32_T **pEmxArray, int32_T numDimensions)
{
emxArray_int32_T *emxArray;
int32_T i;
*pEmxArray = (emxArray_int32_T *)malloc(sizeof(emxArray_int32_T));
emxArray = *pEmxArray;
emxArray->data = (int32_T *)NULL;
emxArray->numDimensions = numDimensions;
emxArray->size = (int32_T *)malloc((uint32_T)(sizeof(int32_T) * numDimensions));
emxArray->allocatedSize = 0;
emxArray->canFreeData = TRUE;
for (i = 0; i < numDimensions; i++) {
emxArray->size[i] = 0;
}
}
static void emxInit_real_T(emxArray_real_T **pEmxArray, int32_T numDimensions)
{
emxArray_real_T *emxArray;
int32_T i;
*pEmxArray = (emxArray_real_T *)malloc(sizeof(emxArray_real_T));
emxArray = *pEmxArray;
emxArray->data = (real_T *)NULL;
emxArray->numDimensions = numDimensions;
emxArray->size = (int32_T *)malloc((uint32_T)(sizeof(int32_T) * numDimensions));
emxArray->allocatedSize = 0;
emxArray->canFreeData = TRUE;
for (i = 0; i < numDimensions; i++) {
emxArray->size[i] = 0;
}
}
static real_T <API key>(real_T S[17])
{
real_T y;
int32_T i;
real_T b_y;
/* <API key> Computes spectral centroid feature */
/* It is the mass center of the spectrum */
/* [r,c] = size(S); */
/* feature = sum(repmat((1:r)',1,c).* S)./sum(S); */
y = 0.0;
for (i = 0; i < 17; i++) {
b_y = S[i] * S[i];
y += (((real_T)i + 1.0) - 1.0) * b_y;
S[i] = b_y;
}
b_y = S[0];
for (i = 0; i < 16; i++) {
b_y += S[i + 1];
}
return y / b_y;
}
static real_T <API key>(const real_T S[17])
{
int32_T ixstart;
real_T mtmp;
int32_T ix;
boolean_T exitg1;
real_T y;
/* <API key> Computes spectral crest */
/* It is a rough measure of tonality */
ixstart = 1;
mtmp = S[0];
if (rtIsNaN(S[0])) {
ix = 2;
exitg1 = FALSE;
while ((exitg1 == FALSE) && (ix < 18)) {
ixstart = ix;
if (!rtIsNaN(S[ix - 1])) {
mtmp = S[ix - 1];
exitg1 = TRUE;
} else {
ix++;
}
}
}
if (ixstart < 17) {
while (ixstart + 1 < 18) {
if (S[ixstart] > mtmp) {
mtmp = S[ixstart];
}
ixstart++;
}
}
y = S[0];
for (ixstart = 0; ixstart < 16; ixstart++) {
y += S[ixstart + 1];
}
return mtmp / y;
}
static void filter(const emxArray_real_T *x, real_T zi, emxArray_real_T *y)
{
uint32_T unnamed_idx_0;
int32_T j;
real_T dbuffer[2];
int32_T k;
real_T b_dbuffer;
unnamed_idx_0 = (uint32_T)x->size[0];
j = y->size[0];
y->size[0] = (int32_T)unnamed_idx_0;
emxEnsureCapacity((emxArray__common *)y, j, (int32_T)sizeof(real_T));
dbuffer[1] = zi;
for (j = 0; j + 1 <= x->size[0]; j++) {
dbuffer[0] = dbuffer[1];
dbuffer[1] = 0.0;
for (k = 0; k < 2; k++) {
b_dbuffer = dbuffer[k] + x->data[j] * 0.33333333333333331;
dbuffer[k] = b_dbuffer;
}
y->data[j] = dbuffer[0];
}
}
static void filtfilt(const emxArray_real_T *x_in, emxArray_real_T *y_out)
{
emxArray_real_T *x;
int32_T i2;
int32_T loop_ub;
emxArray_real_T *y;
real_T xtmp;
real_T b_y;
int32_T md2;
emxArray_real_T *c_y;
int32_T m;
emxArray_real_T *d_y;
emxArray_int32_T *r6;
b_emxInit_real_T(&x, 1);
if (x_in->size[0] == 1) {
i2 = x->size[0];
x->size[0] = 1;
emxEnsureCapacity((emxArray__common *)x, i2, (int32_T)sizeof(real_T));
x->data[0] = x_in->data[0];
} else {
i2 = x->size[0];
x->size[0] = x_in->size[0];
emxEnsureCapacity((emxArray__common *)x, i2, (int32_T)sizeof(real_T));
loop_ub = x_in->size[0];
for (i2 = 0; i2 < loop_ub; i2++) {
x->data[i2] = x_in->data[i2];
}
}
if (x->size[0] == 0) {
i2 = y_out->size[0] * y_out->size[1];
y_out->size[0] = 0;
y_out->size[1] = 0;
emxEnsureCapacity((emxArray__common *)y_out, i2, (int32_T)sizeof(real_T));
} else {
b_emxInit_real_T(&y, 1);
xtmp = 2.0 * x->data[0];
b_y = 2.0 * x->data[x->size[0] - 1];
md2 = x->size[0] - 1;
i2 = y->size[0];
y->size[0] = 6 + x->size[0];
emxEnsureCapacity((emxArray__common *)y, i2, (int32_T)sizeof(real_T));
for (i2 = 0; i2 < 3; i2++) {
y->data[i2] = xtmp - x->data[3 - i2];
}
loop_ub = x->size[0];
for (i2 = 0; i2 < loop_ub; i2++) {
y->data[i2 + 3] = x->data[i2];
}
for (i2 = 0; i2 < 3; i2++) {
y->data[(i2 + x->size[0]) + 3] = b_y - x->data[(md2 - i2) - 1];
}
b_emxInit_real_T(&c_y, 1);
i2 = c_y->size[0];
c_y->size[0] = y->size[0];
emxEnsureCapacity((emxArray__common *)c_y, i2, (int32_T)sizeof(real_T));
loop_ub = y->size[0];
for (i2 = 0; i2 < loop_ub; i2++) {
c_y->data[i2] = y->data[i2];
}
xtmp = y->data[0];
filter(c_y, 0.33333333333333331 * xtmp, y);
m = y->size[0];
i2 = y->size[0];
md2 = i2 / 2;
loop_ub = 1;
emxFree_real_T(&c_y);
while (loop_ub <= md2) {
xtmp = y->data[loop_ub - 1];
y->data[loop_ub - 1] = y->data[m - loop_ub];
y->data[m - loop_ub] = xtmp;
loop_ub++;
}
b_emxInit_real_T(&d_y, 1);
i2 = d_y->size[0];
d_y->size[0] = y->size[0];
emxEnsureCapacity((emxArray__common *)d_y, i2, (int32_T)sizeof(real_T));
loop_ub = y->size[0];
for (i2 = 0; i2 < loop_ub; i2++) {
d_y->data[i2] = y->data[i2];
}
xtmp = y->data[0];
filter(d_y, 0.33333333333333331 * xtmp, y);
m = y->size[0];
i2 = y->size[0];
md2 = i2 / 2;
loop_ub = 1;
emxFree_real_T(&d_y);
while (loop_ub <= md2) {
xtmp = y->data[loop_ub - 1];
y->data[loop_ub - 1] = y->data[m - loop_ub];
y->data[m - loop_ub] = xtmp;
loop_ub++;
}
if (x_in->size[0] == 1) {
emxInit_int32_T(&r6, 1);
loop_ub = (int32_T)((real_T)x->size[0] + 3.0) - 4;
i2 = r6->size[0];
r6->size[0] = loop_ub + 1;
emxEnsureCapacity((emxArray__common *)r6, i2, (int32_T)sizeof(int32_T));
for (i2 = 0; i2 <= loop_ub; i2++) {
r6->data[i2] = 4 + i2;
}
i2 = y_out->size[0] * y_out->size[1];
y_out->size[0] = 1;
emxEnsureCapacity((emxArray__common *)y_out, i2, (int32_T)sizeof(real_T));
md2 = r6->size[0];
i2 = y_out->size[0] * y_out->size[1];
y_out->size[1] = md2;
emxEnsureCapacity((emxArray__common *)y_out, i2, (int32_T)sizeof(real_T));
loop_ub = r6->size[0];
for (i2 = 0; i2 < loop_ub; i2++) {
y_out->data[i2] = y->data[r6->data[i2] - 1];
}
emxFree_int32_T(&r6);
} else {
emxInit_int32_T(&r6, 1);
loop_ub = (int32_T)((real_T)x->size[0] + 3.0) - 3;
i2 = y_out->size[0] * y_out->size[1];
y_out->size[0] = loop_ub;
y_out->size[1] = 1;
emxEnsureCapacity((emxArray__common *)y_out, i2, (int32_T)sizeof(real_T));
md2 = (int32_T)((real_T)x->size[0] + 3.0) - 4;
i2 = r6->size[0];
r6->size[0] = md2 + 1;
emxEnsureCapacity((emxArray__common *)r6, i2, (int32_T)sizeof(int32_T));
for (i2 = 0; i2 <= md2; i2++) {
r6->data[i2] = 4 + i2;
}
for (i2 = 0; i2 < loop_ub; i2++) {
y_out->data[i2] = y->data[r6->data[i2] - 1];
}
emxFree_int32_T(&r6);
}
emxFree_real_T(&y);
}
emxFree_real_T(&x);
}
static void histogramFeatures(const real_T ioiHist[17], real_T features[12])
{
int32_T iidx[17];
real_T k[17];
int32_T ind[17];
boolean_T S[17];
int32_T cindx;
real_T xlast;
int32_T b_k;
real_T b_ioiHist[17];
real_T sigma;
real_T b_S[17];
real_T b[17];
int32_T ix;
boolean_T x;
int8_T S_size[2];
int8_T outsz[2];
int32_T loop_ub;
int32_T iindx_data[1];
int32_T b_ix;
int32_T indx_data[1];
/* UNTITLED Summary of this function goes here */
/* Detailed explanation goes here */
/* features(1) = mean(ioiHist); */
features[0] = b_std(ioiHist);
eml_sort(ioiHist, k, iidx);
features[1] = k[16] / k[15];
for (cindx = 0; cindx < 17; cindx++) {
ind[cindx] = iidx[cindx];
S[cindx] = (ioiHist[cindx] == 0.0);
}
features[2] = (real_T)ind[16] / (real_T)ind[15];
xlast = S[0];
for (b_k = 0; b_k < 16; b_k++) {
xlast += (real_T)S[b_k + 1];
}
features[3] = xlast / 17.0;
for (cindx = 0; cindx < 17; cindx++) {
b_ioiHist[cindx] = ioiHist[cindx];
/* <API key> Computes the Spectral Decrease */
/* A measure of steepness of spectral envelope over frequency */
k[cindx] = cindx;
}
features[4] = <API key>(b_ioiHist);
features[5] = <API key>(ioiHist);
k[0] = 1.0;
xlast = 0.0;
for (cindx = 0; cindx < 17; cindx++) {
/* compute slope */
xlast += 1.0 / k[cindx] * (ioiHist[cindx] - ioiHist[0]);
}
sigma = ioiHist[1];
for (b_k = 0; b_k < 15; b_k++) {
sigma += ioiHist[b_k + 2];
}
features[6] = xlast / sigma;
/* <API key> Computes the Spectral Kurtosis */
/* It is a measure of gaussianity of a spectrum */
sigma = c_std(ioiHist);
/* Subtracting means */
xlast = ioiHist[0];
for (b_k = 0; b_k < 16; b_k++) {
xlast += ioiHist[b_k + 1];
}
bsxfun(ioiHist, xlast / 17.0, b_S);
for (b_k = 0; b_k < 17; b_k++) {
k[b_k] = rt_powd_snf(b_S[b_k], 4.0) / (rt_powd_snf(sigma, 4.0) * 17.0);
}
sigma = k[0];
for (b_k = 0; b_k < 16; b_k++) {
sigma += k[b_k + 1];
}
features[7] = sigma;
/* <API key> Computes Spectral Rolloff */
/* Finds frequency bin where cumsum reaches 0.85 of magnitude */
/* compute rolloff */
xlast = ioiHist[0];
for (b_k = 0; b_k < 16; b_k++) {
xlast += ioiHist[b_k + 1];
}
sigma = 0.85 * xlast;
/* Find indices where cumulative sum is greater */
memcpy(&b[0], &ioiHist[0], 17U * sizeof(real_T));
ix = 0;
xlast = ioiHist[0];
for (b_k = 0; b_k < 16; b_k++) {
ix++;
xlast += b[ix];
b[ix] = xlast;
}
for (b_k = 0; b_k < 17; b_k++) {
S[b_k] = (b[b_k] >= sigma);
}
/* Find the maximum value */
xlast = S[0];
for (b_k = 0; b_k < 16; b_k++) {
xlast += (real_T)S[b_k + 1];
}
x = (xlast > 0.0);
b_k = 0;
if (x) {
b_k = 1;
}
S_size[0] = 17;
S_size[1] = (int8_T)b_k;
for (cindx = 0; cindx < 2; cindx++) {
outsz[cindx] = S_size[cindx];
}
loop_ub = outsz[1];
for (cindx = 0; cindx < loop_ub; cindx++) {
iindx_data[cindx] = 1;
}
ix = -16;
cindx = 1;
while (cindx <= b_k) {
ix += 17;
x = S[(ix - 1) % 17];
loop_ub = 1;
cindx = 1;
if (ix < ix + 16) {
for (b_ix = ix; b_ix + 1 <= ix + 16; b_ix++) {
cindx++;
if (S[b_ix % 17] > x) {
x = S[b_ix % 17];
loop_ub = cindx;
}
}
}
iindx_data[0] = loop_ub;
cindx = 2;
}
loop_ub = outsz[1];
for (cindx = 0; cindx < loop_ub; cindx++) {
indx_data[cindx] = iindx_data[cindx];
}
features[8] = indx_data[0];
/* <API key> Compute spectral skewness */
/* A measure of symmettricity of pdf */
sigma = c_std(ioiHist);
/* Subtracting means */
xlast = ioiHist[0];
for (b_k = 0; b_k < 16; b_k++) {
xlast += ioiHist[b_k + 1];
}
bsxfun(ioiHist, xlast / 17.0, b_S);
for (b_k = 0; b_k < 17; b_k++) {
k[b_k] = rt_powd_snf(b_S[b_k], 3.0) / (rt_powd_snf(sigma, 3.0) * 17.0);
}
sigma = k[0];
for (b_k = 0; b_k < 16; b_k++) {
sigma += k[b_k + 1];
}
features[9] = sigma;
/* <API key> Computes the spectral slope */
/* compute index vector */
/* compute slope */
xlast = ioiHist[0];
for (b_k = 0; b_k < 16; b_k++) {
xlast += ioiHist[b_k + 1];
}
bsxfun(ioiHist, xlast / 17.0, b_S);
xlast = 0.0;
sigma = 0.0;
for (b_k = 0; b_k < 17; b_k++) {
xlast += (-8.5 + (((real_T)b_k + 1.0) - 1.0)) * b_S[b_k];
sigma += (-8.5 + (((real_T)b_k + 1.0) - 1.0)) * (-8.5 + (((real_T)b_k + 1.0)
- 1.0));
b_ioiHist[b_k] = ioiHist[b_k];
k[b_k] = b_k;
b_S[b_k] = ioiHist[b_k] * ioiHist[b_k];
}
features[10] = xlast / sigma;
/* <API key> Computes spectral spread */
/* Concentration of energy around spectral centroid */
bsxfun(k, <API key>(b_ioiHist), b);
for (b_k = 0; b_k < 17; b_k++) {
k[b_k] = b[b_k] * b[b_k] * b_S[b_k];
}
xlast = k[0];
sigma = b_S[0];
for (b_k = 0; b_k < 16; b_k++) {
xlast += k[b_k + 1];
sigma += b_S[b_k + 1];
}
features[11] = sqrt(xlast / sigma);
}
static void ioiHistogram(emxArray_boolean_T *onsets, const emxArray_real_T *T,
real_T ioiHist[17])
{
emxArray_real_T *tOnset;
emxArray_int32_T *r10;
int32_T high_i;
int32_T ixLead;
emxArray_real_T *ioi;
emxArray_real_T *b_y1;
int32_T iyLead;
real_T work_data_idx_0;
real_T tmp1;
real_T tmp2;
int32_T sz[2];
real_T meanIOI_data[1];
int32_T meanIOI_size[2];
int32_T k;
emxArray_real_T *r11;
emxArray_real_T b_meanIOI_data;
int32_T d;
real_T stdIOI_data[1];
boolean_T goodInd_data[1];
real_T histEdges[17];
int32_T exitg1;
b_emxInit_real_T(&tOnset, 1);
emxInit_int32_T(&r10, 1);
/* UNTITLED2 Summary of this function goes here */
/* Detailed explanation goes here */
/* Setting the first one as true */
onsets->data[0] = TRUE;
/* onsetInd = onsets; */
eml_li_find(onsets, r10);
high_i = tOnset->size[0];
tOnset->size[0] = r10->size[0];
emxEnsureCapacity((emxArray__common *)tOnset, high_i, (int32_T)sizeof(real_T));
ixLead = r10->size[0];
for (high_i = 0; high_i < ixLead; high_i++) {
tOnset->data[high_i] = T->data[r10->data[high_i] - 1];
}
emxFree_int32_T(&r10);
emxInit_real_T(&ioi, 2);
if (tOnset->size[0] == 0) {
high_i = ioi->size[0] * ioi->size[1];
ioi->size[0] = 0;
ioi->size[1] = 1;
emxEnsureCapacity((emxArray__common *)ioi, high_i, (int32_T)sizeof(real_T));
} else {
ixLead = tOnset->size[0] - 1;
if (ixLead <= 1) {
} else {
ixLead = 1;
}
if (ixLead < 1) {
high_i = ioi->size[0] * ioi->size[1];
ioi->size[0] = 0;
ioi->size[1] = 0;
emxEnsureCapacity((emxArray__common *)ioi, high_i, (int32_T)sizeof(real_T));
} else {
b_emxInit_real_T(&b_y1, 1);
high_i = b_y1->size[0];
b_y1->size[0] = tOnset->size[0] - 1;
emxEnsureCapacity((emxArray__common *)b_y1, high_i, (int32_T)sizeof(real_T));
ixLead = 1;
iyLead = 0;
work_data_idx_0 = tOnset->data[0];
for (high_i = 2; high_i <= tOnset->size[0]; high_i++) {
tmp1 = tOnset->data[ixLead];
tmp2 = work_data_idx_0;
work_data_idx_0 = tmp1;
tmp1 -= tmp2;
ixLead++;
b_y1->data[iyLead] = tmp1;
iyLead++;
}
ixLead = b_y1->size[0];
high_i = ioi->size[0] * ioi->size[1];
ioi->size[0] = ixLead;
emxEnsureCapacity((emxArray__common *)ioi, high_i, (int32_T)sizeof(real_T));
high_i = ioi->size[0] * ioi->size[1];
ioi->size[1] = 1;
emxEnsureCapacity((emxArray__common *)ioi, high_i, (int32_T)sizeof(real_T));
ixLead = b_y1->size[0];
for (high_i = 0; high_i < ixLead; high_i++) {
ioi->data[high_i] = b_y1->data[high_i];
}
emxFree_real_T(&b_y1);
}
}
emxFree_real_T(&tOnset);
for (high_i = 0; high_i < 2; high_i++) {
sz[high_i] = ioi->size[high_i];
}
meanIOI_size[0] = 1;
meanIOI_size[1] = sz[1];
if ((ioi->size[0] == 0) || (ioi->size[1] == 0)) {
meanIOI_size[0] = 1;
meanIOI_size[1] = sz[1];
ixLead = sz[1];
for (high_i = 0; high_i < ixLead; high_i++) {
meanIOI_data[high_i] = 0.0;
}
} else {
iyLead = -1;
work_data_idx_0 = ioi->data[0];
for (k = 2; k <= ioi->size[0]; k++) {
iyLead++;
work_data_idx_0 += ioi->data[iyLead + 1];
}
meanIOI_data[0] = work_data_idx_0;
}
emxInit_real_T(&r11, 2);
b_meanIOI_data.data = (real_T *)&meanIOI_data;
b_meanIOI_data.size = (int32_T *)&meanIOI_size;
b_meanIOI_data.allocatedSize = 1;
b_meanIOI_data.numDimensions = 2;
b_meanIOI_data.canFreeData = FALSE;
rdivide(&b_meanIOI_data, ioi->size[0], r11);
meanIOI_size[0] = 1;
meanIOI_size[1] = r11->size[1];
ixLead = r11->size[0] * r11->size[1];
for (high_i = 0; high_i < ixLead; high_i++) {
meanIOI_data[high_i] = r11->data[high_i];
}
emxFree_real_T(&r11);
if (ioi->size[0] > 1) {
d = ioi->size[0] - 1;
} else {
d = ioi->size[0];
}
for (high_i = 0; high_i < 2; high_i++) {
sz[high_i] = ioi->size[high_i];
}
iyLead = 0;
ixLead = 1;
while (ixLead <= ioi->size[1]) {
if ((ioi->size[0] == 0) || (ioi->size[1] == 0)) {
work_data_idx_0 = rtNaN;
} else {
ixLead = iyLead;
tmp1 = ioi->data[iyLead];
for (k = 0; k <= ioi->size[0] - 2; k++) {
ixLead++;
tmp1 += ioi->data[ixLead];
}
tmp1 /= (real_T)ioi->size[0];
ixLead = iyLead;
tmp2 = ioi->data[iyLead] - tmp1;
work_data_idx_0 = tmp2 * tmp2;
for (k = 0; k <= ioi->size[0] - 2; k++) {
ixLead++;
tmp2 = ioi->data[ixLead] - tmp1;
work_data_idx_0 += tmp2 * tmp2;
}
work_data_idx_0 /= (real_T)d;
}
stdIOI_data[0] = work_data_idx_0;
iyLead += ioi->size[0];
ixLead = 2;
}
k = 0;
while (k <= sz[1] - 1) {
stdIOI_data[0] = sqrt(stdIOI_data[0]);
k = 1;
}
iyLead = ioi->size[1];
ixLead = ioi->size[0] * ioi->size[1];
for (high_i = 0; high_i < ixLead; high_i++) {
goodInd_data[high_i] = ((ioi->data[high_i] > meanIOI_data[high_i] - 2.0 *
stdIOI_data[high_i]) && (ioi->data[high_i] < meanIOI_data[high_i] + 2.0 *
stdIOI_data[high_i]));
}
k = 0;
ixLead = 1;
while (ixLead <= iyLead) {
if (goodInd_data[0]) {
k++;
}
ixLead = 2;
}
/* Avoiding code export bug */
/* ioi(ioi>upperThresh) = []; */
/* ioi(ioi<lowerThresh) = []; */
/* nBins = 16; */
for (high_i = 0; high_i < 17; high_i++) {
histEdges[high_i] = 0.125 * (real_T)high_i;
ioiHist[high_i] = 0.0;
}
histEdges[16] = rtInf;
high_i = 0;
do {
exitg1 = 0;
if (high_i < 16) {
if (histEdges[1 + high_i] < histEdges[high_i]) {
for (high_i = 0; high_i < 17; high_i++) {
ioiHist[high_i] = rtNaN;
}
exitg1 = 1;
} else {
high_i++;
}
} else {
ixLead = 0;
while (ixLead <= k - 1) {
ixLead = 0;
if (!rtIsNaN(ioi->data[0])) {
if ((ioi->data[0] >= 0.0) && (ioi->data[0] < rtInf)) {
ixLead = 1;
iyLead = 2;
high_i = 17;
while (high_i > iyLead) {
d = (ixLead + high_i) >> 1;
if (ioi->data[0] >= histEdges[d - 1]) {
ixLead = d;
iyLead = d + 1;
} else {
high_i = d;
}
}
}
if (ioi->data[0] == rtInf) {
ixLead = 17;
}
}
if (ixLead > 0) {
ioiHist[ixLead - 1]++;
}
ixLead = 1;
}
exitg1 = 1;
}
} while (exitg1 == 0);
emxFree_real_T(&ioi);
work_data_idx_0 = ioiHist[0];
for (k = 0; k < 16; k++) {
work_data_idx_0 += ioiHist[k + 1];
}
for (high_i = 0; high_i < 17; high_i++) {
ioiHist[high_i] /= work_data_idx_0;
}
}
static void onsetDetection(const emxArray_real_T *spec, emxArray_boolean_T
*onsets, emxArray_real_T *flux)
{
emxArray_real_T *b_flux;
int32_T ixstart;
real_T mtmp;
int32_T k0;
boolean_T exitg1;
int32_T i0;
emxArray_real_T *flux1;
int32_T varargin_1[2];
int32_T i;
boolean_T x[7];
int32_T k;
emxArray_real_T *r0;
int32_T nxin;
emxArray_real_T *r1;
emxArray_real_T *mask2;
emxArray_boolean_T *b;
emxArray_int32_T *r2;
emxArray_real_T *b_mask2;
emxArray_real_T *c_mask2;
emxArray_real_T *r3;
int32_T vstride;
int32_T npages;
int32_T dim;
int32_T j;
int32_T ia;
b_emxInit_real_T(&b_flux, 1);
/* UNTITLED2 Summary of this function goes here */
/* Detailed explanation goes here */
onsetFlux(spec, b_flux);
/* Normalizing */
ixstart = 1;
mtmp = b_flux->data[0];
if (b_flux->size[0] > 1) {
if (rtIsNaN(b_flux->data[0])) {
k0 = 2;
exitg1 = FALSE;
while ((exitg1 == FALSE) && (k0 <= b_flux->size[0])) {
ixstart = k0;
if (!rtIsNaN(b_flux->data[k0 - 1])) {
mtmp = b_flux->data[k0 - 1];
exitg1 = TRUE;
} else {
k0++;
}
}
}
if (ixstart < b_flux->size[0]) {
while (ixstart + 1 <= b_flux->size[0]) {
if (b_flux->data[ixstart] > mtmp) {
mtmp = b_flux->data[ixstart];
}
ixstart++;
}
}
}
i0 = b_flux->size[0];
emxEnsureCapacity((emxArray__common *)b_flux, i0, (int32_T)sizeof(real_T));
ixstart = b_flux->size[0];
for (i0 = 0; i0 < ixstart; i0++) {
b_flux->data[i0] /= mtmp;
}
emxInit_real_T(&flux1, 2);
/* Smoothing */
/* h=fdesign.lowpass('N,F3dB',12,0.15); */
/* d1 = design(h,'elliptic'); */
/* flux = filtfilt(d1.sosMatrix,d1.ScaleValues,flux); */
filtfilt(b_flux, flux);
/* h = 1/4*ones(4,1); */
/* flux = filter(h,1,flux); */
/* Peak picking */
/* w = 2; % Size of window to find local maxima */
padarray(flux, flux1);
emxFree_real_T(&b_flux);
for (i0 = 0; i0 < 2; i0++) {
varargin_1[i0] = flux1->size[i0];
}
i0 = onsets->size[0] * onsets->size[1];
onsets->size[0] = varargin_1[0];
emxEnsureCapacity((emxArray__common *)onsets, i0, (int32_T)sizeof(boolean_T));
i0 = onsets->size[0] * onsets->size[1];
onsets->size[1] = varargin_1[1];
emxEnsureCapacity((emxArray__common *)onsets, i0, (int32_T)sizeof(boolean_T));
ixstart = varargin_1[0] * varargin_1[1];
for (i0 = 0; i0 < ixstart; i0++) {
onsets->data[i0] = FALSE;
}
if ((0 == flux1->size[0]) || (0 == flux1->size[1])) {
ixstart = 0;
} else if (flux1->size[0] > flux1->size[1]) {
ixstart = flux1->size[0];
} else {
ixstart = flux1->size[1];
}
for (i = 3; i - 3 <= ixstart - 7; i++) {
mtmp = flux1->data[i];
for (i0 = 0; i0 < 7; i0++) {
x[i0] = (mtmp >= flux1->data[(i0 + i) - 3]);
}
mtmp = x[0];
for (k = 0; k < 6; k++) {
mtmp += (real_T)x[k + 1];
}
if (mtmp == 7.0) {
onsets->data[i] = TRUE;
}
}
b_emxInit_real_T(&r0, 1);
/* Remove m elements at the start and end */
eml_null_assignment(onsets);
mtmp = (real_T)(onsets->size[0] * onsets->size[1]) - 3.0;
i0 = onsets->size[0] * onsets->size[1];
nxin = r0->size[0];
r0->size[0] = (int32_T)((real_T)i0 - mtmp) + 1;
emxEnsureCapacity((emxArray__common *)r0, nxin, (int32_T)sizeof(real_T));
ixstart = (int32_T)((real_T)i0 - mtmp);
for (i0 = 0; i0 <= ixstart; i0++) {
r0->data[i0] = mtmp + (real_T)i0;
}
emxInit_real_T(&r1, 2);
i0 = r1->size[0] * r1->size[1];
r1->size[0] = 1;
emxEnsureCapacity((emxArray__common *)r1, i0, (int32_T)sizeof(real_T));
ixstart = r0->size[0];
i0 = r1->size[0] * r1->size[1];
r1->size[1] = ixstart;
emxEnsureCapacity((emxArray__common *)r1, i0, (int32_T)sizeof(real_T));
ixstart = r0->size[0];
for (i0 = 0; i0 < ixstart; i0++) {
r1->data[i0] = r0->data[i0];
}
emxFree_real_T(&r0);
<API key>(onsets, r1);
/* Perform second thresholding operation */
/* m = 1; % Multiplier so mean is calculated over a larger range before peak */
/* delta = 0.01; % Threshold above local mean */
padarray(flux, flux1);
for (i0 = 0; i0 < 2; i0++) {
varargin_1[i0] = flux1->size[i0];
}
emxInit_real_T(&mask2, 2);
i0 = mask2->size[0] * mask2->size[1];
mask2->size[0] = varargin_1[0];
emxEnsureCapacity((emxArray__common *)mask2, i0, (int32_T)sizeof(real_T));
i0 = mask2->size[0] * mask2->size[1];
mask2->size[1] = varargin_1[1];
emxEnsureCapacity((emxArray__common *)mask2, i0, (int32_T)sizeof(real_T));
ixstart = varargin_1[0] * varargin_1[1];
for (i0 = 0; i0 < ixstart; i0++) {
mask2->data[i0] = 0.0;
}
if ((0 == flux1->size[0]) || (0 == flux1->size[1])) {
ixstart = 0;
} else if (flux1->size[0] > flux1->size[1]) {
ixstart = flux1->size[0];
} else {
ixstart = flux1->size[1];
}
for (i = 3; i - 3 <= ixstart - 7; i++) {
/* flux = onsetDetection(denoisedSpec); */
mtmp = flux1->data[-3 + i];
for (k = 0; k < 6; k++) {
mtmp += flux1->data[(k + i) - 2];
}
if (flux1->data[i] >= mtmp / 7.0 + 0.01) {
mask2->data[i] = 1.0;
}
}
emxFree_real_T(&flux1);
emxInit_boolean_T(&b, 2);
/* Remove mw elements at the start and end */
nxin = mask2->size[0] * mask2->size[1];
i0 = b->size[0] * b->size[1];
b->size[0] = 1;
b->size[1] = nxin;
emxEnsureCapacity((emxArray__common *)b, i0, (int32_T)sizeof(boolean_T));
for (i0 = 0; i0 < nxin; i0++) {
b->data[i0] = FALSE;
}
for (k = 0; k < 2; k++) {
b->data[k] = TRUE;
}
ixstart = 0;
for (k = 1; k <= b->size[1]; k++) {
ixstart += b->data[k - 1];
}
ixstart = nxin - ixstart;
k0 = -1;
for (k = 1; k <= nxin; k++) {
if ((k > b->size[1]) || (!b->data[k - 1])) {
k0++;
mask2->data[k0] = mask2->data[k - 1];
}
}
emxInit_int32_T(&r2, 1);
emxInit_real_T(&b_mask2, 2);
b_emxInit_real_T(&c_mask2, 1);
if ((mask2->size[0] != 1) && (mask2->size[1] == 1)) {
if (1 > ixstart) {
ixstart = 0;
}
i0 = c_mask2->size[0];
c_mask2->size[0] = ixstart;
emxEnsureCapacity((emxArray__common *)c_mask2, i0, (int32_T)sizeof(real_T));
for (i0 = 0; i0 < ixstart; i0++) {
c_mask2->data[i0] = mask2->data[i0];
}
i0 = mask2->size[0] * mask2->size[1];
mask2->size[0] = ixstart;
mask2->size[1] = 1;
emxEnsureCapacity((emxArray__common *)mask2, i0, (int32_T)sizeof(real_T));
i0 = 0;
while (i0 <= 0) {
for (i0 = 0; i0 < ixstart; i0++) {
mask2->data[i0] = c_mask2->data[i0];
}
i0 = 1;
}
} else {
if (1 > ixstart) {
ixstart = 0;
}
i0 = r2->size[0];
r2->size[0] = ixstart;
emxEnsureCapacity((emxArray__common *)r2, i0, (int32_T)sizeof(int32_T));
for (i0 = 0; i0 < ixstart; i0++) {
r2->data[i0] = 1 + i0;
}
ixstart = r2->size[0];
i0 = b_mask2->size[0] * b_mask2->size[1];
b_mask2->size[0] = 1;
b_mask2->size[1] = ixstart;
emxEnsureCapacity((emxArray__common *)b_mask2, i0, (int32_T)sizeof(real_T));
for (i0 = 0; i0 < ixstart; i0++) {
nxin = 0;
while (nxin <= 0) {
b_mask2->data[b_mask2->size[0] * i0] = mask2->data[r2->data[i0] - 1];
nxin = 1;
}
}
i0 = mask2->size[0] * mask2->size[1];
mask2->size[0] = b_mask2->size[0];
mask2->size[1] = b_mask2->size[1];
emxEnsureCapacity((emxArray__common *)mask2, i0, (int32_T)sizeof(real_T));
ixstart = b_mask2->size[1];
for (i0 = 0; i0 < ixstart; i0++) {
k0 = b_mask2->size[0];
for (nxin = 0; nxin < k0; nxin++) {
mask2->data[nxin + mask2->size[0] * i0] = b_mask2->data[nxin +
b_mask2->size[0] * i0];
}
}
}
emxFree_real_T(&c_mask2);
emxFree_real_T(&b_mask2);
emxFree_int32_T(&r2);
b_emxInit_real_T(&r3, 1);
mtmp = (real_T)(mask2->size[0] * mask2->size[1]) - 3.0;
i0 = mask2->size[0] * mask2->size[1];
nxin = r3->size[0];
r3->size[0] = (int32_T)((real_T)i0 - mtmp) + 1;
emxEnsureCapacity((emxArray__common *)r3, nxin, (int32_T)sizeof(real_T));
ixstart = (int32_T)((real_T)i0 - mtmp);
for (i0 = 0; i0 <= ixstart; i0++) {
r3->data[i0] = mtmp + (real_T)i0;
}
i0 = r1->size[0] * r1->size[1];
r1->size[0] = 1;
emxEnsureCapacity((emxArray__common *)r1, i0, (int32_T)sizeof(real_T));
ixstart = r3->size[0];
i0 = r1->size[0] * r1->size[1];
r1->size[1] = ixstart;
emxEnsureCapacity((emxArray__common *)r1, i0, (int32_T)sizeof(real_T));
ixstart = r3->size[0];
for (i0 = 0; i0 < ixstart; i0++) {
r1->data[i0] = r3->data[i0];
}
emxFree_real_T(&r3);
<API key>(mask2, r1);
i0 = onsets->size[0] * onsets->size[1];
emxEnsureCapacity((emxArray__common *)onsets, i0, (int32_T)sizeof(boolean_T));
ixstart = onsets->size[0];
k0 = onsets->size[1];
ixstart *= k0;
emxFree_real_T(&r1);
for (i0 = 0; i0 < ixstart; i0++) {
onsets->data[i0] = (onsets->data[i0] && (mask2->data[i0] != 0.0));
}
emxFree_real_T(&mask2);
onsets->data[0] = FALSE;
if ((onsets->size[0] == 0) || (onsets->size[1] == 0) || ((onsets->size[0] == 1)
&& (onsets->size[1] == 1))) {
} else {
for (i0 = 0; i0 < 2; i0++) {
varargin_1[i0] = onsets->size[i0];
}
ixstart = varargin_1[0];
if (varargin_1[1] > varargin_1[0]) {
ixstart = varargin_1[1];
}
i0 = b->size[0] * b->size[1];
b->size[0] = 1;
b->size[1] = ixstart;
emxEnsureCapacity((emxArray__common *)b, i0, (int32_T)sizeof(boolean_T));
vstride = 1;
npages = onsets->size[0] * onsets->size[1];
for (dim = 0; dim < 2; dim++) {
i0 = onsets->size[dim];
npages = div_s32(npages, onsets->size[dim]);
if (onsets->size[dim] > 1) {
ixstart = (int32_T)fabs(-1.0 + (((real_T)dim + 1.0) - 1.0));
if (ixstart - div_s32(ixstart, onsets->size[dim]) * onsets->size[dim] >
0) {
ixstart = (onsets->size[dim] - 1) * vstride;
k0 = 0;
for (i = 1; i <= npages; i++) {
nxin = k0;
k0 += ixstart;
for (j = 1; j <= vstride; j++) {
nxin++;
k0++;
ia = nxin;
for (k = 1; k <= i0; k++) {
b->data[k - 1] = onsets->data[ia - 1];
ia += vstride;
}
ia = nxin - 1;
for (k = 2; k <= i0; k++) {
onsets->data[ia] = b->data[k - 1];
ia += vstride;
}
onsets->data[ia] = b->data[0];
}
}
}
}
vstride *= i0;
}
}
emxFree_boolean_T(&b);
/* Some post processing to remove sequences of onsets */
/* Changing to non vectorized versions for export */
if ((0 == onsets->size[0]) || (0 == onsets->size[1])) {
ixstart = 0;
} else if (onsets->size[0] > onsets->size[1]) {
ixstart = onsets->size[0];
} else {
ixstart = onsets->size[1];
}
for (i = 0; i <= ixstart - 3; i++) {
if ((onsets->data[i] == 1) && (onsets->data[i + 1] == 1)) {
if (onsets->data[i + 2] == 1) {
onsets->data[i + 2] = FALSE;
}
onsets->data[i + 1] = FALSE;
}
}
/* tripleInd = strfind(onsets',[1,1,1]); */
/* onsets(tripleInd+1) = 0; */
/* onsets(tripleInd+2) = 0; */
/* doubleInd = strfind(onsets',[1,1]); */
/* onsets(doubleInd+1) = 0; */
/* onsets(1) = 0; */
/* flux(1) = 0; */
/* onsets(end+1) = 0; */
/* flux(end+1) = 0; */
/* xmin = 1; */
/* xmax = length(flux); */
/* figure */
/* subplot(4,1,1) */
/* stem(mask1); */
/* axis([xmin xmax 0 1]); */
/* subplot(4,1,2) */
/* stem(mask2); */
/* axis([xmin xmax 0 1]); */
/* subplot(4,1,3) */
/* stem(mask1&mask2); */
/* axis([xmin xmax 0 1]); */
/* subplot(4,1,4); */
/* imagesc(denoisedSpec); */
/* axis([xmin xmax 0 512]); */
/* axis('xy'); */
/* colormap(hot); */
}
static void onsetFlux(const emxArray_real_T *S, emxArray_real_T *flux)
{
emxArray_real_T *b_S;
int32_T iyLead;
int32_T loop_ub;
int32_T ixLead;
int32_T iy;
emxArray_real_T *x;
int32_T d;
emxArray_real_T *b_y1;
uint32_T ySize[2];
int32_T ix;
real_T work;
real_T tmp2;
emxArray_real_T *r4;
emxArray_real_T *b_flux;
real_T y;
real_T r;
emxArray_real_T *c_flux;
emxArray_boolean_T *b_x;
emxArray_int32_T *r5;
b_emxInit_real_T(&b_S, 1);
/* ONSETFLUX Computes new spectral flux */
/* Detailed explanation goes here */
/* Just to be sure */
/* S = abs(S); */
iyLead = S->size[0];
loop_ub = S->size[0];
ixLead = S->size[1];
iy = b_S->size[0];
b_S->size[0] = loop_ub;
emxEnsureCapacity((emxArray__common *)b_S, iy, (int32_T)sizeof(real_T));
for (iy = 0; iy < loop_ub; iy++) {
b_S->data[iy] = S->data[iy + S->size[0] * (ixLead - 1)];
}
emxInit_real_T(&x, 2);
iy = x->size[0] * x->size[1];
x->size[0] = S->size[0];
x->size[1] = S->size[1] + 1;
emxEnsureCapacity((emxArray__common *)x, iy, (int32_T)sizeof(real_T));
loop_ub = S->size[1];
for (iy = 0; iy < loop_ub; iy++) {
d = S->size[0];
for (ixLead = 0; ixLead < d; ixLead++) {
x->data[ixLead + x->size[0] * iy] = S->data[ixLead + S->size[0] * iy];
}
}
iy = 0;
while (iy <= 0) {
for (iy = 0; iy < iyLead; iy++) {
x->data[iy + x->size[0] * S->size[1]] = b_S->data[iy];
}
iy = 1;
}
emxFree_real_T(&b_S);
emxInit_real_T(&b_y1, 2);
if (1 >= x->size[1]) {
for (iy = 0; iy < 2; iy++) {
ySize[iy] = (uint32_T)x->size[iy];
}
iy = b_y1->size[0] * b_y1->size[1];
b_y1->size[0] = (int32_T)ySize[0];
emxEnsureCapacity((emxArray__common *)b_y1, iy, (int32_T)sizeof(real_T));
iy = b_y1->size[0] * b_y1->size[1];
b_y1->size[1] = 0;
emxEnsureCapacity((emxArray__common *)b_y1, iy, (int32_T)sizeof(real_T));
} else {
for (iy = 0; iy < 2; iy++) {
ySize[iy] = (uint32_T)x->size[iy];
}
iy = b_y1->size[0] * b_y1->size[1];
b_y1->size[0] = (int32_T)ySize[0];
b_y1->size[1] = x->size[1] - 1;
emxEnsureCapacity((emxArray__common *)b_y1, iy, (int32_T)sizeof(real_T));
ix = 0;
iy = 1;
for (d = 1; d <= x->size[0]; d++) {
ixLead = ix + x->size[0];
iyLead = iy;
work = x->data[ix];
for (loop_ub = 2; loop_ub <= x->size[1]; loop_ub++) {
tmp2 = work;
work = x->data[ixLead];
tmp2 = x->data[ixLead] - tmp2;
ixLead += x->size[0];
b_y1->data[iyLead - 1] = tmp2;
iyLead += x->size[0];
}
ix++;
iy++;
}
}
emxFree_real_T(&x);
/* Half wave rectification */
for (iy = 0; iy < 2; iy++) {
ySize[iy] = (uint32_T)b_y1->size[iy];
}
emxInit_real_T(&r4, 2);
iy = r4->size[0] * r4->size[1];
r4->size[0] = (int32_T)ySize[0];
r4->size[1] = (int32_T)ySize[1];
emxEnsureCapacity((emxArray__common *)r4, iy, (int32_T)sizeof(real_T));
iy = b_y1->size[0] * b_y1->size[1];
for (loop_ub = 0; loop_ub < iy; loop_ub++) {
r4->data[(int32_T)(1.0 + (real_T)loop_ub) - 1] = fabs(b_y1->data[(int32_T)
(1.0 + (real_T)loop_ub) - 1]);
}
iy = b_y1->size[0] * b_y1->size[1];
emxEnsureCapacity((emxArray__common *)b_y1, iy, (int32_T)sizeof(real_T));
ixLead = b_y1->size[0];
d = b_y1->size[1];
iyLead = ixLead * d;
for (iy = 0; iy < iyLead; iy++) {
b_y1->data[iy] = (b_y1->data[iy] + r4->data[iy]) / 2.0;
}
emxFree_real_T(&r4);
/* Summed across all bins */
for (iy = 0; iy < 2; iy++) {
ySize[iy] = (uint32_T)b_y1->size[iy];
}
emxInit_real_T(&b_flux, 2);
iy = b_flux->size[0] * b_flux->size[1];
b_flux->size[0] = 1;
b_flux->size[1] = (int32_T)ySize[1];
emxEnsureCapacity((emxArray__common *)b_flux, iy, (int32_T)sizeof(real_T));
if ((b_y1->size[0] == 0) || (b_y1->size[1] == 0)) {
iy = b_flux->size[0] * b_flux->size[1];
b_flux->size[0] = 1;
emxEnsureCapacity((emxArray__common *)b_flux, iy, (int32_T)sizeof(real_T));
iy = b_flux->size[0] * b_flux->size[1];
b_flux->size[1] = (int32_T)ySize[1];
emxEnsureCapacity((emxArray__common *)b_flux, iy, (int32_T)sizeof(real_T));
iyLead = (int32_T)ySize[1];
for (iy = 0; iy < iyLead; iy++) {
b_flux->data[iy] = 0.0;
}
} else {
ix = -1;
iy = -1;
for (d = 1; d <= b_y1->size[1]; d++) {
ixLead = ix + 1;
ix++;
tmp2 = b_y1->data[ixLead];
for (loop_ub = 2; loop_ub <= b_y1->size[0]; loop_ub++) {
ix++;
tmp2 += b_y1->data[ix];
}
iy++;
b_flux->data[iy] = tmp2;
}
}
emxFree_real_T(&b_y1);
if (b_flux->size[1] == 0) {
tmp2 = 0.0;
} else {
tmp2 = b_flux->data[0];
for (loop_ub = 2; loop_ub <= b_flux->size[1]; loop_ub++) {
tmp2 += b_flux->data[loop_ub - 1];
}
}
tmp2 /= (real_T)b_flux->size[1];
if (b_flux->size[1] > 1) {
d = b_flux->size[1] - 1;
} else {
d = b_flux->size[1];
}
if (b_flux->size[1] == 0) {
y = rtNaN;
} else {
ix = 0;
work = b_flux->data[0];
for (loop_ub = 0; loop_ub <= b_flux->size[1] - 2; loop_ub++) {
ix++;
work += b_flux->data[ix];
}
work /= (real_T)b_flux->size[1];
ix = 0;
r = b_flux->data[0] - work;
y = r * r;
for (loop_ub = 0; loop_ub <= b_flux->size[1] - 2; loop_ub++) {
ix++;
r = b_flux->data[ix] - work;
y += r * r;
}
y /= (real_T)d;
}
emxInit_real_T(&c_flux, 2);
iy = c_flux->size[0] * c_flux->size[1];
c_flux->size[0] = 1;
c_flux->size[1] = b_flux->size[1];
emxEnsureCapacity((emxArray__common *)c_flux, iy, (int32_T)sizeof(real_T));
iyLead = b_flux->size[0] * b_flux->size[1];
for (iy = 0; iy < iyLead; iy++) {
c_flux->data[iy] = b_flux->data[iy] - tmp2;
}
rdivide(c_flux, y, b_flux);
iy = flux->size[0];
flux->size[0] = b_flux->size[1];
emxEnsureCapacity((emxArray__common *)flux, iy, (int32_T)sizeof(real_T));
iyLead = b_flux->size[1];
emxFree_real_T(&c_flux);
for (iy = 0; iy < iyLead; iy++) {
flux->data[iy] = b_flux->data[iy];
}
emxFree_real_T(&b_flux);
b_emxInit_boolean_T(&b_x, 1);
iy = b_x->size[0];
b_x->size[0] = flux->size[0];
emxEnsureCapacity((emxArray__common *)b_x, iy, (int32_T)sizeof(boolean_T));
iyLead = flux->size[0];
for (iy = 0; iy < iyLead; iy++) {
b_x->data[iy] = (flux->data[iy] < 0.0);
}
loop_ub = 0;
for (d = 1; d <= b_x->size[0]; d++) {
if (b_x->data[d - 1]) {
loop_ub++;
}
}
emxInit_int32_T(&r5, 1);
iy = r5->size[0];
r5->size[0] = loop_ub;
emxEnsureCapacity((emxArray__common *)r5, iy, (int32_T)sizeof(int32_T));
ixLead = 0;
for (d = 1; d <= b_x->size[0]; d++) {
if (b_x->data[d - 1]) {
r5->data[ixLead] = d;
ixLead++;
}
}
emxFree_boolean_T(&b_x);
iyLead = r5->size[0];
for (iy = 0; iy < iyLead; iy++) {
flux->data[r5->data[iy] - 1] = 0.0;
}
emxFree_int32_T(&r5);
}
static void padarray(const emxArray_real_T *varargin_1, emxArray_real_T *b)
{
real_T sizeB[2];
int32_T i3;
real_T b_sizeB;
int32_T c_sizeB[2];
int32_T outsize[2];
int32_T loop_ub;
for (i3 = 0; i3 < 2; i3++) {
sizeB[i3] = 0.0;
}
sizeB[0] = 3.0;
if ((varargin_1->size[0] == 0) || (varargin_1->size[1] == 0)) {
for (i3 = 0; i3 < 2; i3++) {
b_sizeB = (real_T)varargin_1->size[i3] + 2.0 * sizeB[i3];
sizeB[i3] = b_sizeB;
}
c_sizeB[0] = (int32_T)sizeB[0];
c_sizeB[1] = (int32_T)sizeB[1];
for (i3 = 0; i3 < 2; i3++) {
outsize[i3] = c_sizeB[i3];
}
i3 = b->size[0] * b->size[1];
b->size[0] = outsize[0];
emxEnsureCapacity((emxArray__common *)b, i3, (int32_T)sizeof(real_T));
i3 = b->size[0] * b->size[1];
b->size[1] = outsize[1];
emxEnsureCapacity((emxArray__common *)b, i3, (int32_T)sizeof(real_T));
loop_ub = outsize[0] * outsize[1];
for (i3 = 0; i3 < loop_ub; i3++) {
b->data[i3] = 0.0;
}
} else {
ConstantPad(varargin_1, sizeB, b);
}
}
static void rdivide(const emxArray_real_T *x, real_T y, emxArray_real_T *z)
{
int32_T i1;
int32_T loop_ub;
i1 = z->size[0] * z->size[1];
z->size[0] = 1;
z->size[1] = x->size[1];
emxEnsureCapacity((emxArray__common *)z, i1, (int32_T)sizeof(real_T));
loop_ub = x->size[0] * x->size[1];
for (i1 = 0; i1 < loop_ub; i1++) {
z->data[i1] = x->data[i1] / y;
}
}
static real_T rt_powd_snf(real_T u0, real_T u1)
{
real_T y;
real_T d0;
real_T d1;
if (rtIsNaN(u0) || rtIsNaN(u1)) {
y = rtNaN;
} else {
d0 = fabs(u0);
d1 = fabs(u1);
if (rtIsInf(u1)) {
if (d0 == 1.0) {
y = rtNaN;
} else if (d0 > 1.0) {
if (u1 > 0.0) {
y = rtInf;
} else {
y = 0.0;
}
} else if (u1 > 0.0) {
y = 0.0;
} else {
y = rtInf;
}
} else if (d1 == 0.0) {
y = 1.0;
} else if (d1 == 1.0) {
if (u1 > 0.0) {
y = u0;
} else {
y = 1.0 / u0;
}
} else if (u1 == 2.0) {
y = u0 * u0;
} else if ((u1 == 0.5) && (u0 >= 0.0)) {
y = sqrt(u0);
} else if ((u0 < 0.0) && (u1 > floor(u1))) {
y = rtNaN;
} else {
y = pow(u0, u1);
}
}
return y;
}
void <API key>(const emxArray_real_T *denoisedSpectrum, const
emxArray_real_T *T, real_T ioiFeatures[12], emxArray_boolean_T *onsets)
{
emxArray_real_T *unusedU0;
emxArray_boolean_T *b_onsets;
int32_T i;
int32_T loop_ub;
real_T ioiHist[17];
boolean_T bv0[12];
int32_T tmp_size[1];
int32_T tmp_data[12];
emxInit_real_T(&unusedU0, 2);
emxInit_boolean_T(&b_onsets, 2);
/* <API key> Computes onset features */
onsetDetection(denoisedSpectrum, onsets, unusedU0);
/* Collecting number of onsets per 2 second window */
/* onsetFeatures1 = onsetFeatures(onsets,T); */
/* Collect IOI histogram */
i = b_onsets->size[0] * b_onsets->size[1];
b_onsets->size[0] = onsets->size[0];
b_onsets->size[1] = onsets->size[1];
emxEnsureCapacity((emxArray__common *)b_onsets, i, (int32_T)sizeof(boolean_T));
loop_ub = onsets->size[0] * onsets->size[1];
emxFree_real_T(&unusedU0);
for (i = 0; i < loop_ub; i++) {
b_onsets->data[i] = onsets->data[i];
}
ioiHistogram(b_onsets, T, ioiHist);
histogramFeatures(ioiHist, ioiFeatures);
/* ioiFeatures = vertcat(ioiFeatures,onsetFeatures1); */
emxFree_boolean_T(&b_onsets);
for (i = 0; i < 12; i++) {
bv0[i] = rtIsNaN(ioiFeatures[i]);
}
b_eml_li_find(bv0, tmp_data, tmp_size);
loop_ub = tmp_size[0];
for (i = 0; i < loop_ub; i++) {
ioiFeatures[tmp_data[i] - 1] = 0.0;
}
for (i = 0; i < 12; i++) {
bv0[i] = rtIsInf(ioiFeatures[i]);
}
b_eml_li_find(bv0, tmp_data, tmp_size);
loop_ub = tmp_size[0];
for (i = 0; i < loop_ub; i++) {
ioiFeatures[tmp_data[i] - 1] = 0.0;
}
}
void <API key>(void)
{
rt_InitInfAndNaN(8U);
}
void <API key>(void)
{
/* (no terminate code required) */
}
emxArray_boolean_T *<API key>(int32_T numDimensions, int32_T *size)
{
emxArray_boolean_T *emx;
int32_T numEl;
int32_T i;
emxInit_boolean_T(&emx, numDimensions);
numEl = 1;
for (i = 0; i < numDimensions; i++) {
numEl *= size[i];
emx->size[i] = size[i];
}
emx->data = (boolean_T *)calloc((uint32_T)numEl, sizeof(boolean_T));
emx->numDimensions = numDimensions;
emx->allocatedSize = numEl;
return emx;
}
//emxArray_real_T *emxCreateND_real_T(int32_T numDimensions, int32_T *size)
// emxArray_real_T *emx;
// int32_T numEl;
// int32_T i;
// emxInit_real_T(&emx, numDimensions);
// numEl = 1;
// for (i = 0; i < numDimensions; i++) {
// numEl *= size[i];
// emx->size[i] = size[i];
// emx->data = (real_T *)calloc((uint32_T)numEl, sizeof(real_T));
// emx->numDimensions = numDimensions;
// emx->allocatedSize = numEl;
// return emx;
emxArray_boolean_T *<API key>(boolean_T *data, int32_T
numDimensions, int32_T *size)
{
emxArray_boolean_T *emx;
int32_T numEl;
int32_T i;
emxInit_boolean_T(&emx, numDimensions);
numEl = 1;
for (i = 0; i < numDimensions; i++) {
numEl *= size[i];
emx->size[i] = size[i];
}
emx->data = data;
emx->numDimensions = numDimensions;
emx->allocatedSize = numEl;
emx->canFreeData = FALSE;
return emx;
}
//emxArray_real_T *<API key>(real_T *data, int32_T numDimensions,
// int32_T *size)
// emxArray_real_T *emx;
// int32_T numEl;
// int32_T i;
// emxInit_real_T(&emx, numDimensions);
// numEl = 1;
// for (i = 0; i < numDimensions; i++) {
// numEl *= size[i];
// emx->size[i] = size[i];
// emx->data = data;
// emx->numDimensions = numDimensions;
// emx->allocatedSize = numEl;
// emx->canFreeData = FALSE;
// return emx;
emxArray_boolean_T *<API key>(boolean_T *data, int32_T rows,
int32_T cols)
{
emxArray_boolean_T *emx;
int32_T size[2];
int32_T numEl;
int32_T i;
size[0] = rows;
size[1] = cols;
emxInit_boolean_T(&emx, 2);
numEl = 1;
for (i = 0; i < 2; i++) {
numEl *= size[i];
emx->size[i] = size[i];
}
emx->data = data;
emx->numDimensions = 2;
emx->allocatedSize = numEl;
emx->canFreeData = FALSE;
return emx;
}
//emxArray_real_T *<API key>(real_T *data, int32_T rows, int32_T
// cols)
// emxArray_real_T *emx;
// int32_T size[2];
// int32_T numEl;
// int32_T i;
// size[0] = rows;
// size[1] = cols;
// emxInit_real_T(&emx, 2);
// numEl = 1;
// for (i = 0; i < 2; i++) {
// numEl *= size[i];
// emx->size[i] = size[i];
// emx->data = data;
// emx->numDimensions = 2;
// emx->allocatedSize = numEl;
// emx->canFreeData = FALSE;
// return emx;
emxArray_boolean_T *emxCreate_boolean_T(int32_T rows, int32_T cols)
{
emxArray_boolean_T *emx;
int32_T size[2];
int32_T numEl;
int32_T i;
size[0] = rows;
size[1] = cols;
emxInit_boolean_T(&emx, 2);
numEl = 1;
for (i = 0; i < 2; i++) {
numEl *= size[i];
emx->size[i] = size[i];
}
emx->data = (boolean_T *)calloc((uint32_T)numEl, sizeof(boolean_T));
emx->numDimensions = 2;
emx->allocatedSize = numEl;
return emx;
}
//emxArray_real_T *emxCreate_real_T(int32_T rows, int32_T cols)
// emxArray_real_T *emx;
// int32_T size[2];
// int32_T numEl;
// int32_T i;
// size[0] = rows;
// size[1] = cols;
// emxInit_real_T(&emx, 2);
// numEl = 1;
// for (i = 0; i < 2; i++) {
// numEl *= size[i];
// emx->size[i] = size[i];
// emx->data = (real_T *)calloc((uint32_T)numEl, sizeof(real_T));
// emx->numDimensions = 2;
// emx->allocatedSize = numEl;
// return emx;
void <API key>(emxArray_boolean_T *emxArray)
{
emxFree_boolean_T(&emxArray);
}
//void <API key>(emxArray_real_T *emxArray)
// emxFree_real_T(&emxArray);
/* End of code generation (<API key>.c) */
|
.tundra .dijitDialogRtl .<API key> {
right: auto;
left: 5px;
}
|
<?php locate_template( array( 'mobile/header-mobile.php' ), true, false ); ?>
<?php if ( have_posts() ) { ?>
<?php while ( have_posts() ) {
the_post(); ?>
<div <?php post_class( 'tbm-post tbm-padded' ) ?> id="post-<?php the_ID(); ?>">
<h2><?php the_title(); ?></h2>
<?php the_content(); ?>
<?php wp_link_pages('before=<div class="tbm-pc-navi">' . __('Pages', 'fastfood') . ':&after=</div>'); ?>
</div>
<?php comments_template('/mobile/comments-mobile.php'); ?>
<?php
$tbm_args = array(
'post_type' => 'page',
'post_parent' => $post->ID,
'order' => 'ASC',
'orderby' => 'menu_order',
'numberposts' => 0
);
$tbm_sub_pages = get_posts( $tbm_args ); // retrieve the child pages
if (!empty($tbm_sub_pages)) { ?>
<?php echo <API key>( 'before' ) . __( 'Child pages', 'fastfood' ) . <API key>( 'after' ); ?>
<ul class="tbm-group">
<?php
foreach ( $tbm_sub_pages as $tbm_children ) {
echo '<li class="outset"><a href="' . get_permalink( $tbm_children ) . '" title="' . esc_attr( strip_tags( get_the_title( $tbm_children ) ) ) . '">' . get_the_title( $tbm_children ) . '</a></li>';
}
?>
</ul>
<?php } ?>
<?php $tbm_the_parent_page = $post->post_parent; // retrieve the parent page
if ( $tbm_the_parent_page ) {?>
<?php echo <API key>( 'before' ) . __( 'Parent page', 'fastfood' ) . <API key>( 'after' ); ?>
<ul class="tbm-group">
<li class="outset"><a href="<?php echo get_permalink( $tbm_the_parent_page ); ?>" title="<?php echo esc_attr( strip_tags( get_the_title( $tbm_the_parent_page ) ) ); ?>"><?php echo get_the_title( $tbm_the_parent_page ); ?></a></li>
</ul>
<?php } ?>
<?php } ?>
<?php } else { ?>
<p class="tbm-padded"><?php _e( 'Sorry, no posts matched your criteria.', 'fastfood' );?></p>
<?php } ?>
<?php locate_template( array( 'mobile/footer-mobile.php' ), true, false ); ?>
|
<?php
// The name of this module
define("_MI_MEDIAWIKI_NAME", "MediaWiki");
// A brief description of this module
define("_MI_MEDIAWIKI_DESC", "MediaWiki For XOOPS Community");
// Configs
define("_MI_MEDIAWIKI_STYLE", "Interface style");
define("<API key>", "Xoops style, MediaWiki style, or user selectable");
define("<API key>", "MediaWiki Sidebar");
define("<API key>", "MediaWiki Recent changes");
define("<API key>", "Most revisions");
define("<API key>", "Hot contents");
?>
|
#include <cpu/itp/itp0.h>
#include <ctx/ctx.h>
#include <vid/vid.h>
unsigned short itp0_gate(const unsigned short nnn, struct cp8_ctx *cp8) {
unsigned short next = 2;
switch (nnn) {
case 0x00e0:
// INFO(Rafael): CLS
cp8_vidcls();
break;
case 0x00ee:
// INFO(Rafael): RET
cp8->pc = cp8_pop(cp8);
break;
default:
// INFO(Rafael): SYS addr is a pretty old stuff and should be ignored.
break;
}
return (cp8->pc + next);
}
|
package nl.pelagic.musicTree.flac2mp3.cli;
import java.io.BufferedReader;
import java.io.File;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintStream;
import java.nio.file.Files;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.logging.Level;
import java.util.logging.Logger;
import nl.pelagic.audio.conversion.flac2mp3.api.<API key>;
import nl.pelagic.audio.conversion.flac2mp3.api.FlacToMp3;
import nl.pelagic.audio.musicTree.configuration.api.<API key>;
import nl.pelagic.audio.musicTree.configuration.api.MusicTreeConstants;
import nl.pelagic.audio.musicTree.syncer.api.Syncer;
import nl.pelagic.audio.musicTree.util.MusicTreeHelpers;
import nl.pelagic.musicTree.flac2mp3.cli.i18n.Messages;
import nl.pelagic.shell.script.listener.api.ShellScriptListener;
import nl.pelagic.shutdownhook.api.<API key>;
import nl.pelagic.util.file.FileUtils;
import org.kohsuke.args4j.CmdLineException;
import org.kohsuke.args4j.CmdLineParser;
import org.osgi.framework.BundleContext;
import org.osgi.service.component.annotations.Activate;
import org.osgi.service.component.annotations.Component;
import org.osgi.service.component.annotations.Deactivate;
import org.osgi.service.component.annotations.Reference;
/**
* The main program that synchronises a flac tree into a mp3 tree or just
* converts one or more flac files in mp3 files, based on a music tree
* configuration
*/
@Component(property = {
"main.thread=true" /* Signal the launcher that this is the main thread */
})
public class Main implements Runnable, <API key> {
/** the application logger name */
static private final String <API key> = "nl.pelagic"; //$NON-NLS-1$
/** the application logger level to allow */
static private final Level <API key> = Level.SEVERE;
/** the jaudiotagger library logger name */
static private final String <API key> = "org.jaudiotagger"; //$NON-NLS-1$
/** the jaudiotagger library logger level to allow */
static private final Level <API key> = Level.SEVERE;
/** the program name */
static final String PROGRAM_NAME = "flac2mp3"; //$NON-NLS-1$
/** the application logger */
private final Logger applicationLogger;
/** the jaudiotagger library logger */
private final Logger jaudiotaggerLogger;
/** the list of extension to use in the flac tree */
private final HashSet<String> extensionsList = new HashSet<>();
/** the filenames for covers to use in the flac tree */
private final HashSet<String> coversList = new HashSet<>();
/*
* Construction
*/
/**
* Default constructor
*/
public Main() {
super();
/**
* <pre>
* 1=timestamp
* 2=level
* 3=logger
* 4=class method
* 5=message
* 6=stack trace, preceded by a newline (if exception is present)
* </pre>
*/
System.setProperty("java.util.logging.SimpleFormatter.format", "[%1$tF %1$tT] %4$10s %2$s : %5$s%6$s%n"); //$NON-NLS-1$ //$NON-NLS-2$
applicationLogger = Logger.getLogger(<API key>);
applicationLogger.setLevel(<API key>);
jaudiotaggerLogger = Logger.getLogger(<API key>);
jaudiotaggerLogger.setLevel(<API key>);
extensionsList.add(MusicTreeConstants.FLACEXTENSION);
coversList.add(MusicTreeConstants.COVER);
}
/*
* Consumed Services
*/
/** the shell script listener (optional) */
private ShellScriptListener shellScriptListener = null;
/**
* @param shellScriptListener the shellScriptListener to set
*/
@Reference
void <API key>(ShellScriptListener shellScriptListener) {
this.shellScriptListener = shellScriptListener;
}
/** the flac2Mp3 service */
private FlacToMp3 flacToMp3 = null;
/**
* @param flacToMp3 the flacToMp3 to set
*/
@Reference
void setFlacToMp3(FlacToMp3 flacToMp3) {
this.flacToMp3 = flacToMp3;
}
/** the syncer service */
private Syncer syncer = null;
/**
* @param syncer the syncer to set
*/
@Reference
void setSyncer(Syncer syncer) {
this.syncer = syncer;
}
/*
* Command line arguments
*/
/** the launcher arguments property name */
static final String LAUNCHER_ARGUMENTS = "launcher.arguments"; //$NON-NLS-1$
/** the command line arguments */
private String[] args = null;
/**
* The bnd launcher provides access to the command line arguments via the
* Launcher object. This object is also registered under Object.
*
* @param done unused
* @param parameters the launcher parameters, which includes the command line
* arguments
*/
@Reference
void setDone(@SuppressWarnings("unused") Object done, Map<String, Object> parameters) {
args = (String[]) parameters.get(LAUNCHER_ARGUMENTS);
}
/*
* Bundle
*/
/** The setting name for the stayAlive property */
public static final String SETTING_STAYALIVE = "stayAlive"; //$NON-NLS-1$
/** true when the application should NOT automatically exit when done */
private boolean stayAlive = false;
/**
* Bundle activator
*
* @param bundleContext the bundle context
*/
@Activate
void activate(BundleContext bundleContext) {
String ex = bundleContext.getProperty(PROGRAM_NAME + "." + SETTING_STAYALIVE); //$NON-NLS-1$
if (ex != null) {
stayAlive = Boolean.parseBoolean(ex);
}
}
/**
* Bundle deactivator
*/
@Deactivate
void deactivate() {
/* nothing to do */
}
/*
* Helpers
*/
/**
* Read a filelist file into a list of entries to convert
*
* @param out the stream to print the error messages to
* @param fileList the filelist file
* @param entriesToConvert a list of files to convert, to which the files read
* from the filelist file must be added
* @return true when successful
*/
static boolean readFileList(PrintStream out, File fileList, List<String> entriesToConvert) {
assert (out != null);
assert (fileList != null);
assert (entriesToConvert != null);
if (!fileList.isFile()) {
out.printf(Messages.getString("Main.8"), fileList.getPath()); //$NON-NLS-1$
return false;
}
try (BufferedReader reader =
new BufferedReader(new InputStreamReader(Files.newInputStream(fileList.toPath()), "UTF-8"))) { //$NON-NLS-1$
String line = null;
while ((line = reader.readLine()) != null) {
/* skip empty lines */
if (line.trim().isEmpty()) {
continue;
}
entriesToConvert.add(line);
}
}
catch (IOException e) {
/* can't be covered in a test */
out.printf(Messages.getString("Main.11"), fileList, e.getLocalizedMessage()); //$NON-NLS-1$
return false;
}
return true;
}
/**
* Validate the entry to convert to filter out non-existing directories and
* files. An entry to convert must exist and be below the flac base directory.
*
* @param out the stream to print the error messages to
* @param <API key> the music tree configuration
* @param entryToConvert the entry to convert
* @return true when validation is successful
*/
static boolean <API key>(PrintStream out, <API key> <API key>,
File entryToConvert) {
assert (out != null);
assert (<API key> != null);
assert (entryToConvert != null);
/* check that the entry exists */
if (!entryToConvert.exists()) {
out.printf(Messages.getString("Main.5"), entryToConvert.getPath()); //$NON-NLS-1$
return false;
}
/*
* check that entry is below the flac base directory so that it doesn't
* escape the base directory by doing a ../../..
*/
if (!FileUtils.<API key>(<API key>.getFlacBaseDir(), entryToConvert, true)) {
out.printf(Messages.getString("Main.6"), //$NON-NLS-1$
entryToConvert.getPath(), <API key>.getFlacBaseDir().getPath());
return false;
}
return true;
}
/**
* Convert a flac file into an mp3 file.
*
* @param err the stream to print to
* @param <API key> the conversion configuration. When null then
* the default configuration is used.
* @param <API key> the music tree configuration
* @param simulate true to simulate conversion
* @param fileToConvert the flac file to convert
*
* @return true when successful
*/
boolean convertFile(PrintStream err, <API key> <API key>,
<API key> <API key>, boolean simulate, File fileToConvert) {
assert (err != null);
assert (<API key> != null);
assert (<API key> != null);
assert (fileToConvert != null);
assert (fileToConvert.isFile());
File mp3File = MusicTreeHelpers.flacFileToMp3File(<API key>, fileToConvert);
if (mp3File == null) {
err.printf(Messages.getString("Main.12"), fileToConvert.getPath(), //$NON-NLS-1$
<API key>.getMp3BaseDir().getPath());
return false;
}
boolean doConversion = !mp3File.exists() || (fileToConvert.lastModified() > mp3File.lastModified());
if (!doConversion) {
return true;
}
boolean converted = false;
try {
converted = flacToMp3.convert(<API key>, fileToConvert, mp3File, simulate);
if (!converted) {
err.printf(Messages.getString("Main.1"), fileToConvert.getPath()); //$NON-NLS-1$
}
}
catch (IOException e) {
converted = false;
err.printf(Messages.getString("Main.2"), fileToConvert.getPath(), e.getLocalizedMessage()); //$NON-NLS-1$
}
return converted;
}
/**
* Stay alive, if needed (which is when the component has a SETTING_STAYALIVE
* property set to true).
*
* @param err the stream to print a 'staying alive' message to
*/
void stayAlive(PrintStream err) {
if (!stayAlive) {
return;
}
err.printf(Messages.getString("Main.7")); //$NON-NLS-1$
try {
Thread.sleep(Long.MAX_VALUE);
}
catch (<API key> e) {
/* swallow */
}
}
/*
* <API key>
*/
/** true when we have to stop */
private AtomicBoolean stop = new AtomicBoolean(false);
@Override
public void shutdownHook() {
stop.set(true);
}
/*
* Main
*/
/**
* Run the main program
*
* @param err the stream to print errors to
* @return true when successful
*/
boolean doMain(PrintStream err) {
if (args == null) {
/*
* the launcher didn't set our command line options so set empty arguments
* (use defaults)
*/
args = new String[0];
}
/*
* Parse the command line
*/
CommandLineOptions commandLineOptions = new CommandLineOptions();
CmdLineParser parser = new CmdLineParser(commandLineOptions);
try {
parser.parseArgument(args);
}
catch (CmdLineException e) {
err.printf(Messages.getString("Main.4"), e.getLocalizedMessage()); //$NON-NLS-1$
commandLineOptions.setErrorReported(true);
}
/*
* Process command-line options
*/
/* print usage when so requested and exit */
if (commandLineOptions.isHelp() || commandLineOptions.isErrorReported()) {
try {
/* can't be covered by a test */
int cols = Integer.parseInt(System.getenv("COLUMNS")); //$NON-NLS-1$
if (cols > 80) {
parser.getProperties().withUsageWidth(cols);
}
}
catch (<API key> e) {
/* swallow, can't be covered by a test */
}
CommandLineOptions.usage(err, PROGRAM_NAME, parser);
return false;
}
/*
* Setup verbose modes in the shell script listener
*/
shellScriptListener.setVerbose(commandLineOptions.isVerbose(), commandLineOptions.isExtraVerbose(),
commandLineOptions.isQuiet());
/*
* Setup & validate the music tree configuration
*/
<API key> <API key> =
new <API key>(commandLineOptions.getFlacBaseDir(), commandLineOptions.getMp3BaseDir());
List<String> errors = <API key>.validate(true);
if (errors != null) {
for (String error : errors) {
err.println(error);
}
return false;
}
/*
* Setup & validate the flac2mp3 configuration
*/
<API key> <API key> = new <API key>();
<API key>.setFlacExecutable(commandLineOptions.getFlacExecutable().getPath());
<API key>.setLameExecutable(commandLineOptions.getLameExecutable().getPath());
<API key>.setFlacOptions(commandLineOptions.getFlacOptions());
<API key>.setLameOptions(commandLineOptions.getLameOptions());
<API key>.setUseId3V1Tags(commandLineOptions.isUseID3v1());
<API key>.setUseId3V24Tags(commandLineOptions.isUseID3v24());
<API key>.setForceConversion(commandLineOptions.isForceConversion());
<API key>.setRunFlacLame(!commandLineOptions.<API key>());
<API key>.setCopyTag(!commandLineOptions.isDoNotCopyTag());
<API key>.setCopyTimestamp(!commandLineOptions.<API key>());
errors = <API key>.validate();
if (errors != null) {
/* can't be covered by a test */
for (String error : errors) {
err.println(error);
}
return false;
}
/*
* Setup the entries to convert: first get them from the command-line (if
* specified) and then add those in the file list (if set)
*/
List<String> entriesToConvert = commandLineOptions.getEntriesToConvert();
File fileList = commandLineOptions.getFileList();
if (fileList != null) {
readFileList(err, fileList, entriesToConvert);
}
if (entriesToConvert.isEmpty()) {
/*
* no entries to convert, so default to the flac base directory: sync the
* whole tree
*/
entriesToConvert.add(<API key>.getFlacBaseDir().getAbsolutePath());
}
/*
* Run
*/
boolean result = true;
for (String entryToConvert : entriesToConvert) {
if (stop.get()) {
break;
}
File entryToConvertFile = new File(entryToConvert);
boolean validationResult = <API key>(err, <API key>, entryToConvertFile);
if (validationResult) {
if (entryToConvertFile.isDirectory()) {
result = result && syncer.syncFlac2Mp3(<API key>, <API key>, entryToConvertFile,
extensionsList, coversList, commandLineOptions.isSimulate());
} else if (entryToConvertFile.isFile()) {
result = result && convertFile(err, <API key>, <API key>,
commandLineOptions.isSimulate(), entryToConvertFile);
} else {
/* can't be covered by a test */
err.printf(Messages.getString("Main.3"), entryToConvert); //$NON-NLS-1$
}
} else {
result = false;
}
}
return result;
}
/*
* Since we're registered as a Runnable with the main.thread property we get
* called when the system is fully initialised.
*/
@Override
public void run() {
boolean success = doMain(System.err);
stayAlive(System.err);
if (!success) {
/* can't be covered by a test */
System.exit(1);
}
}
}
|
--D
function c30539496.initial_effect(c)
--special summon
local e1=Effect.CreateEffect(c)
e1:SetDescription(aux.Stringid(30539496,0))
e1:SetCategory(CATEGORY_DESTROY+<API key>)
e1:SetType(<API key>)
e1:SetRange(LOCATION_HAND)
e1:SetCountLimit(1,30539496)
e1:SetTarget(c30539496.sptg)
e1:SetOperation(c30539496.spop)
c:RegisterEffect(e1)
--special summon
local e2=Effect.CreateEffect(c)
e2:SetDescription(aux.Stringid(30539496,1))
e2:SetCategory(<API key>)
e2:SetType(EFFECT_TYPE_SINGLE+<API key>)
e2:SetProperty(EFFECT_FLAG_DELAY)
e2:SetCode(EVENT_DESTROYED)
e2:SetCountLimit(1,30539497)
e2:SetCondition(c30539496.spcon2)
e2:SetTarget(c30539496.sptg2)
e2:SetOperation(c30539496.spop2)
c:RegisterEffect(e2)
end
function c30539496.desfilter(c)
return c:IsType(TYPE_MONSTER) and ((c:IsLocation(LOCATION_MZONE) and c:IsFaceup()) or c:IsLocation(LOCATION_HAND))
end
function c30539496.locfilter(c,tp)
return c:IsLocation(LOCATION_MZONE) and c:IsControler(tp)
end
function c30539496.sptg(e,tp,eg,ep,ev,re,r,rp,chk)
local c=e:GetHandler()
local ft=Duel.GetLocationCount(tp,LOCATION_MZONE)
local loc=LOCATION_MZONE+LOCATION_HAND
if ft<0 then loc=LOCATION_MZONE end
local loc2=0
if Duel.<API key>(tp,88581108) then loc2=LOCATION_MZONE end
local g=Duel.GetMatchingGroup(c30539496.desfilter,tp,loc,loc2,c)
if chk==0 then return c:<API key>(e,0,tp,false,false)
and g:GetCount()>=2 and g:IsExists(Card.IsAttribute,1,nil,ATTRIBUTE_EARTH)
and (ft>0 or g:IsExists(c30539496.locfilter,-ft+1,nil,tp)) end
Duel.SetOperationInfo(0,CATEGORY_DESTROY,nil,2,tp,loc)
Duel.SetOperationInfo(0,<API key>,c,1,0,0)
end
function c30539496.spop(e,tp,eg,ep,ev,re,r,rp)
local c=e:GetHandler()
local ft=Duel.GetLocationCount(tp,LOCATION_MZONE)
local loc=LOCATION_MZONE+LOCATION_HAND
if ft<0 then loc=LOCATION_MZONE end
local loc2=0
if Duel.<API key>(tp,88581108) then loc2=LOCATION_MZONE end
local g=Duel.GetMatchingGroup(c30539496.desfilter,tp,loc,loc2,c)
if g:GetCount()<2 or not g:IsExists(Card.IsAttribute,1,nil,ATTRIBUTE_EARTH) then return end
local g1=nil local g2=nil
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_DESTROY)
if ft<1 then
g1=g:FilterSelect(tp,c30539496.locfilter,1,1,nil,tp)
else
g1=g:Select(tp,1,1,nil)
end
g:RemoveCard(g1:GetFirst())
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_DESTROY)
if g1:GetFirst():IsAttribute(ATTRIBUTE_EARTH) then
g2=g:Select(tp,1,1,nil)
else
g2=g:FilterSelect(tp,Card.IsAttribute,1,1,nil,ATTRIBUTE_EARTH)
end
g1:Merge(g2)
local rm=g1:IsExists(Card.IsAttribute,2,nil,ATTRIBUTE_EARTH)
if Duel.Destroy(g1,REASON_EFFECT)==2 then
if not c:IsRelateToEffect(e) then return end
if Duel.SpecialSummon(c,0,tp,tp,false,false,POS_FACEUP)==0 then
return
end
local rg=Duel.GetMatchingGroup(Card.IsAbleToRemove,tp,0,LOCATION_EXTRA,nil)
if rm and rg:GetCount()>0 and Duel.SelectYesNo(tp,aux.Stringid(30539496,2)) then
Duel.ConfirmCards(tp,rg)
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_REMOVE)
local tg=rg:SelectSubGroup(tp,aux.dncheck,false,1,3)
Duel.Remove(tg,POS_FACEUP,REASON_EFFECT)
Duel.ShuffleExtra(1-tp)
end
end
end
function c30539496.spcon2(e,tp,eg,ep,ev,re,r,rp)
return e:GetHandler():IsReason(REASON_EFFECT)
end
function c30539496.thfilter(c,e,tp)
return not c:IsAttribute(ATTRIBUTE_EARTH) and c:IsRace(RACE_WYRM) and c:<API key>(e,0,tp,false,false)
end
function c30539496.sptg2(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return Duel.GetLocationCount(tp,LOCATION_MZONE)>0
and Duel.<API key>(c30539496.thfilter,tp,LOCATION_GRAVE,0,1,nil,e,tp) end
Duel.SetOperationInfo(0,<API key>,nil,1,tp,LOCATION_GRAVE)
end
function c30539496.spop2(e,tp,eg,ep,ev,re,r,rp)
if Duel.GetLocationCount(tp,LOCATION_MZONE)<=0 then return end
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_SPSUMMON)
local g=Duel.SelectMatchingCard(tp,c30539496.thfilter,tp,LOCATION_GRAVE,0,1,1,nil,e,tp)
if g:GetCount()>0 then
Duel.SpecialSummon(g,0,tp,tp,false,false,POS_FACEUP)
end
end
|
/**
* \file <API key>.h
* \brief Definition of the thelib::<API key> class.
*/
#ifndef <API key>
#define <API key>
// ITK
#include <<API key>.h>
// namespace
namespace thelib
{
/**
* \brief Mask an input image (input 0) using a mask image (input 1) (parrallel).
* \ingroup TheLib
*/
template< class T >
class <API key> : public itk::ImageToImageFilter<T,T>
{
public:
//! Standard class typedefs.
typedef <API key> Self;
typedef itk::ImageToImageFilter<T,T> Superclass;
typedef itk::SmartPointer<Self> Pointer;
typedef itk::SmartPointer<const Self> ConstPointer;
//! Method for creation through the object factory.
itkNewMacro(Self);
//! Run-time type information (and related methods).
itkTypeMacro(<API key>, ImageToImageFilter);
//! Set the invert flag.
itkSetMacro(InvertMask, bool);
//! Get the invert flag.
itkGetConstMacro(InvertMask, bool);
/**
* Print information about this class.
* \param os The stream to output to.
* \param indent The indent to apply to the output.
*/
void PrintSelf(std::ostream& os, itk::Indent indent) const;
protected:
//! Constructor: protect from instantiation.
<API key>();
//! Destructor: protect from instantiation.
~<API key>();
/**
* Main method.
* \param <API key> Image region to apply the filter to.
* \param threadId The thread identifier.
*/
void <API key>(
const typename itk::ImageSource<T>::<API key>& <API key>,
itk::ThreadIdType threadId);
private:
//! Copy constructor: purposely not implemented.
<API key>( const Self& filter);
//! Assignement operator: purposely not implemented.
void operator=( const Self& filter);
//! Flag to invert the mask or not
bool m_InvertMask;
}; // class <API key>
} // namespace thelib
#endif //<API key>
|
<?php
class fseLink
{
protected $userKey = "INSERT_USER_KEY"; //User Key
protected $groupKey = "INSERT_GROUP_KEY"; //Group Key
protected $groupId = "INSERT_GROUP_ID"; //Group ID
/* --Define initial arrays-- */
public $memberArray = array();
public $groupArray = array();
public $aircraftArray = array();
/* --Initializer-- */
public function startFSELink()
{
/* --Sets up groupArray-- */
/* --Structure: Flights, Time, Distance, Profit-- */
$this->groupArray = array(
0,
0,
0,
number_format(0.00, 2));
/* --Loads Aircraft feed and sets up aircraftArray-- */
/* --Structure: Registration, Make/Model, Flights, Time, Distance, Profit-- */
$ac = simplexml_load_file("http:
foreach ($ac->Aircraft as $aircraft) {
array_push($this->aircraftArray, array(
"$aircraft->Registration",
"$aircraft->MakeModel",
0,
0,
0,
number_format(0.00, 2)));
}
/* --Loads Group Member feed and sets up memberArray-- */
/* --Structure: Pilot Name, Group Status, Flights, Time, Distance, Profit-- */
$mem = simplexml_load_file("http:
foreach ($mem->Member as $Member) {
array_push($this->memberArray, array(
"$Member->Name",
"$Member->Status",
0,
0,
0,
number_format(0.00, 2))); //name, status, flights, time, distance, profit
}
/* --Populate arrays and return for use-- */
$this->populateArrays($this->memberArray, $this->groupArray, $this->
aircraftArray);
return $this->memberArray;
return $this->groupArray;
return $this->aircraftArray;
}
/* --Populate Arrays-- */
private function populateArrays(&$memberArray, &$groupArray, &$aircraftArray)
{
/* --Loads Flight Log feed(LIMIT 500) and starts populating-- */
$logs = simplexml_load_file("http:
foreach ($logs->FlightLog as $log) {
$ft = explode(":", $log->FlightTime); //Split time for use
/* --Populate memberArray-- */
for ($x = 0; $x < count($memberArray); $x++) {
if (strcmp($memberArray[$x][0], $log->Pilot) == 0) {
$memberArray[$x][2] = $memberArray[$x][2] + 1; //Increment flight counter
$memberArray[$x][3] = $memberArray[$x][3] + $ft[1] + ($ft[0] * 60); //Add Flight time(in minutes)
$memberArray[$x][4] = $memberArray[$x][4] + $log->Distance; //Add Distance
$memberArray[$x][5] = $memberArray[$x][5] + floatval($log->PilotFee); //Add Pilot's Pay
}
}
/* --Populates groupArray-- */
$groupArray[1] = $groupArray[1] + $ft[1] + ($ft[0] * 60); //Add Flight time(in minutes)
$groupArray[2] = $groupArray[2] + $log->Distance; //Add Distance
$groupArray[3] = $groupArray[3] + floatval($log->Income) - floatval($log->
PilotFee) - floatval($log->CrewCost) - floatval($log->BookingFee) - floatval($log->
FuelCost) - floatval($log->GCF) - floatval($log->RentalCost); //Calculate Profit
/* --Populates aircraftArray-- */
for ($x = 0; $x < count($aircraftArray); $x++) {
if (strcmp($aircraftArray[$x][0], $log->Aircraft) == 0) {
$aircraftArray[$x][2] = $aircraftArray[$x][2] + 1; //Increment flight counter
$aircraftArray[$x][3] = $aircraftArray[$x][3] + $ft[1] + ($ft[0] * 60); //Add Flight time(in minutes)
$aircraftArray[$x][4] = $aircraftArray[$x][4] + $log->Distance; //Add Distance
$aircraftArray[$x][5] = $aircraftArray[$x][5] + floatval($log->Income) -
floatval($log->CrewCost) - floatval($log->BookingFee) - floatval($log->FuelCost) -
floatval($log->GCF); //Calculate Profit
}
}
$groupArray[0] = count($logs->FlightLog); //Increment flight counter
}
/* --Returns populated arrays-- */
return $aircraftArray;
return $memberArray;
return $groupArray;
}
/* --Display sortable Pilot stats table-- */
public function displayPilotStats()
{
echo "<table id=\"memberTable\" class=\"tablesorter\"><thead><tr><th>Pilot</th><th>Status</th><th>Total Flights</th><th>Total Time</th><th>Total Distance</th><th>Total Profit</th></tr></thead><tbody>";
for ($x = 0; $x < count($this->memberArray); $x++) {
echo "<tr><td>" . $this->memberArray[$x][0] . "</td><td>" . ucfirst($this->
memberArray[$x][1]) . "</td><td>" . $this->memberArray[$x][2] . "</td><td>" . $this->
formatTime($this->memberArray[$x][3]) . "</td><td>" . $this->memberArray[$x][4] .
"nm</td><td>$" . number_format($this->memberArray[$x][5], 2) . "</td></tr>";
}
echo "</tbody></table>";
}
/* --Display sortable Pilot stats table-- */
public function displayGroupStats()
{
echo "<table id=\"groupTable\" class=\"tablesorter\"><thead><tr><th>Total Flights</th><th>Total Time</th><th>Total Distance</th><th>Total Profit</th></tr></thead><tbody>";
echo "<tr><td>" . $this->groupArray[0] . "</td><td>" . $this->formatTime($this->
groupArray[1]) . "</td><td>" . $this->groupArray[2] . "nm</td><td>$" .
number_format($this->groupArray[3], 2) . "</td></tr> ";
echo "</tbody></table>";
}
/* --Display sortable Pilot stats table-- */
public function <API key>()
{
echo "<table id=\"aircraftTable\" class=\"tablesorter\"><thead><tr><th>Aircraft Registration</th><th>Make/Model</th><th>Total Flights</th><th>Total Time</th><th>Total Distance</th><th>Total Profit</th></tr></thead><tbody>";
for ($x = 0; $x < count($this->aircraftArray); $x++) {
echo "<tr><td>" . $this->aircraftArray[$x][0] . "</td><td>" . $this->
aircraftArray[$x][1] . "</td><td>" . $this->aircraftArray[$x][2] . "</td><td>" .
$this->formatTime($this->aircraftArray[$x][3]) . "</td><td>" . $this->
aircraftArray[$x][4] . "nm</td><td>$" . number_format($this->aircraftArray[$x][5],
2) . "</td></tr>";
}
echo "</tbody></table> ";
}
/* --Formats time-- */
public function formatTime($minutes)
{
$hours = floor($minutes / 60);
$min = $minutes - ($hours * 60);
$formattedTime = $hours . ":" . $min;
return $formattedTime;
}
}
?>
|
<?php
/**
* Root directory of Drupal installation.
*/
define('DRUPAL_ROOT', getcwd());
require_once DRUPAL_ROOT . '/includes/bootstrap.inc';
drupal_bootstrap(<API key>);
<API key>();
|
#include <linux/types.h>
#include <linux/kernel.h>
#include <linux/export.h>
#include <linux/pci.h>
#include <linux/init.h>
#include <linux/delay.h>
#include <linux/acpi.h>
#include <linux/kallsyms.h>
#include <linux/dmi.h>
#include <linux/pci-aspm.h>
#include <linux/ioport.h>
#include <linux/sched.h>
#include <linux/ktime.h>
#include <linux/mm.h>
#include <asm/dma.h> /* <API key> */
#include "pci.h"
/*
* Decoding should be disabled for a PCI device during BAR sizing to avoid
* conflict. But doing so may cause problems on host bridge and perhaps other
* key system devices. For devices that need to have mmio decoding always-on,
* we need to set the dev->mmio_always_on bit.
*/
static void <API key>(struct pci_dev *dev)
{
dev->mmio_always_on = 1;
}
<API key>(PCI_ANY_ID, PCI_ANY_ID,
<API key>, 8, <API key>);
/* The Mellanox Tavor device gives false positive parity errors
* Mark this device with a <API key>, to allow
* PCI scanning code to "skip" this now blacklisted device.
*/
static void <API key>(struct pci_dev *dev)
{
dev-><API key> = 1; /* This device gives false positives */
}
<API key>(<API key>, <API key>, <API key>);
<API key>(<API key>, <API key>, <API key>);
/* Deal with broken BIOSes that neglect to enable passive release,
which can cause problems in combination with the 82441FX/PPro MTRRs */
static void <API key>(struct pci_dev *dev)
{
struct pci_dev *d = NULL;
unsigned char dlc;
/* We have to make sure a particular bit is set in the PIIX3
ISA bridge, so we have to go out and find it. */
while ((d = pci_get_device(PCI_VENDOR_ID_INTEL, <API key>, d))) {
<API key>(d, 0x82, &dlc);
if (!(dlc & 1<<1)) {
dev_info(&d->dev, "PIIX3: Enabling Passive Release\n");
dlc |= 1<<1;
<API key>(d, 0x82, dlc);
}
}
}
<API key>(PCI_VENDOR_ID_INTEL, <API key>, <API key>);
<API key>(PCI_VENDOR_ID_INTEL, <API key>, <API key>);
/* The VIA VP2/VP3/MVP3 seem to have some 'features'. There may be a workaround
but VIA don't answer queries. If you happen to have good contacts at VIA
ask them for me please -- Alan
This appears to be BIOS not version dependent. So presumably there is a
chipset level fix */
static void quirk_isa_dma_hangs(struct pci_dev *dev)
{
if (!<API key>) {
<API key> = 1;
dev_info(&dev->dev, "Activating ISA DMA hang workarounds\n");
}
}
/*
* Its not totally clear which chipsets are the problematic ones
* We know 82C586 and 82C596 variants are affected.
*/
<API key>(PCI_VENDOR_ID_VIA, <API key>, quirk_isa_dma_hangs);
<API key>(PCI_VENDOR_ID_VIA, <API key>, quirk_isa_dma_hangs);
<API key>(PCI_VENDOR_ID_INTEL, <API key>, quirk_isa_dma_hangs);
<API key>(PCI_VENDOR_ID_AL, <API key>, quirk_isa_dma_hangs);
<API key>(PCI_VENDOR_ID_NEC, <API key>, quirk_isa_dma_hangs);
<API key>(PCI_VENDOR_ID_NEC, <API key>, quirk_isa_dma_hangs);
<API key>(PCI_VENDOR_ID_NEC, <API key>, quirk_isa_dma_hangs);
/*
* Intel NM10 "TigerPoint" LPC PM1a_STS.BM_STS must be clear
* for some HT machines to use C4 w/o hanging.
*/
static void <API key>(struct pci_dev *dev)
{
u32 pmbase;
u16 pm1a;
<API key>(dev, 0x40, &pmbase);
pmbase = pmbase & 0xff80;
pm1a = inw(pmbase);
if (pm1a & 0x10) {
dev_info(&dev->dev, FW_BUG "TigerPoint LPC.BM_STS cleared\n");
outw(0x10, pmbase);
}
}
<API key>(PCI_VENDOR_ID_INTEL, <API key>, <API key>);
/*
* Chipsets where PCI->PCI transfers vanish or hang
*/
static void quirk_nopcipci(struct pci_dev *dev)
{
if ((pci_pci_problems & PCIPCI_FAIL) == 0) {
dev_info(&dev->dev, "Disabling direct PCI/PCI transfers\n");
pci_pci_problems |= PCIPCI_FAIL;
}
}
<API key>(PCI_VENDOR_ID_SI, <API key>, quirk_nopcipci);
<API key>(PCI_VENDOR_ID_SI, <API key>, quirk_nopcipci);
static void quirk_nopciamd(struct pci_dev *dev)
{
u8 rev;
<API key>(dev, 0x08, &rev);
if (rev == 0x13) {
/* Erratum 24 */
dev_info(&dev->dev, "Chipset erratum: Disabling direct PCI/AGP transfers\n");
pci_pci_problems |= PCIAGP_FAIL;
}
}
<API key>(PCI_VENDOR_ID_AMD, <API key>, quirk_nopciamd);
/*
* Triton requires workarounds to be used by the drivers
*/
static void quirk_triton(struct pci_dev *dev)
{
if ((pci_pci_problems&PCIPCI_TRITON) == 0) {
dev_info(&dev->dev, "Limiting direct PCI/PCI transfers\n");
pci_pci_problems |= PCIPCI_TRITON;
}
}
<API key>(PCI_VENDOR_ID_INTEL, <API key>, quirk_triton);
<API key>(PCI_VENDOR_ID_INTEL, <API key>, quirk_triton);
<API key>(PCI_VENDOR_ID_INTEL, <API key>, quirk_triton);
<API key>(PCI_VENDOR_ID_INTEL, <API key>, quirk_triton);
static void quirk_vialatency(struct pci_dev *dev)
{
struct pci_dev *p;
u8 busarb;
/* Ok we have a potential problem chipset here. Now see if we have
a buggy southbridge */
p = pci_get_device(PCI_VENDOR_ID_VIA, <API key>, NULL);
if (p != NULL) {
/* 0x40 - 0x4f == 686B, 0x10 - 0x2f == 686A; thanks Dan Hollis */
/* Check for buggy part revisions */
if (p->revision < 0x40 || p->revision > 0x42)
goto exit;
} else {
p = pci_get_device(PCI_VENDOR_ID_VIA, <API key>, NULL);
if (p == NULL) /* No problem parts */
goto exit;
/* Check for buggy part revisions */
if (p->revision < 0x10 || p->revision > 0x12)
goto exit;
}
/*
* Ok we have the problem. Now set the PCI master grant to
* occur every master grant. The apparent bug is that under high
* PCI load (quite common in Linux of course) you can get data
* loss when the CPU is held off the bus for 3 bus master requests
* This happens to include the IDE controllers....
*
* VIA only apply this fix when an SB Live! is present but under
* both Linux and Windows this isn't enough, and we have seen
* corruption without SB Live! but with things like 3 UDMA IDE
* controllers. So we ignore that bit of the VIA recommendation..
*/
<API key>(dev, 0x76, &busarb);
/* Set bit 4 and bi 5 of byte 76 to 0x01
"Master priority rotation on every PCI master grant */
busarb &= ~(1<<5);
busarb |= (1<<4);
<API key>(dev, 0x76, busarb);
dev_info(&dev->dev, "Applying VIA southbridge workaround\n");
exit:
pci_dev_put(p);
}
<API key>(PCI_VENDOR_ID_VIA, <API key>, quirk_vialatency);
<API key>(PCI_VENDOR_ID_VIA, <API key>, quirk_vialatency);
<API key>(PCI_VENDOR_ID_VIA, <API key>, quirk_vialatency);
/* Must restore this on a resume from RAM */
<API key>(PCI_VENDOR_ID_VIA, <API key>, quirk_vialatency);
<API key>(PCI_VENDOR_ID_VIA, <API key>, quirk_vialatency);
<API key>(PCI_VENDOR_ID_VIA, <API key>, quirk_vialatency);
/*
* VIA Apollo VP3 needs ETBF on BT848/878
*/
static void quirk_viaetbf(struct pci_dev *dev)
{
if ((pci_pci_problems&PCIPCI_VIAETBF) == 0) {
dev_info(&dev->dev, "Limiting direct PCI/PCI transfers\n");
pci_pci_problems |= PCIPCI_VIAETBF;
}
}
<API key>(PCI_VENDOR_ID_VIA, <API key>, quirk_viaetbf);
static void quirk_vsfx(struct pci_dev *dev)
{
if ((pci_pci_problems&PCIPCI_VSFX) == 0) {
dev_info(&dev->dev, "Limiting direct PCI/PCI transfers\n");
pci_pci_problems |= PCIPCI_VSFX;
}
}
<API key>(PCI_VENDOR_ID_VIA, <API key>, quirk_vsfx);
/*
* Ali Magik requires workarounds to be used by the drivers
* that DMA to AGP space. Latency must be set to 0xA and triton
* workaround applied too
* [Info kindly provided by ALi]
*/
static void quirk_alimagik(struct pci_dev *dev)
{
if ((pci_pci_problems&PCIPCI_ALIMAGIK) == 0) {
dev_info(&dev->dev, "Limiting direct PCI/PCI transfers\n");
pci_pci_problems |= PCIPCI_ALIMAGIK|PCIPCI_TRITON;
}
}
<API key>(PCI_VENDOR_ID_AL, <API key>, quirk_alimagik);
<API key>(PCI_VENDOR_ID_AL, <API key>, quirk_alimagik);
/*
* Natoma has some interesting boundary conditions with Zoran stuff
* at least
*/
static void quirk_natoma(struct pci_dev *dev)
{
if ((pci_pci_problems&PCIPCI_NATOMA) == 0) {
dev_info(&dev->dev, "Limiting direct PCI/PCI transfers\n");
pci_pci_problems |= PCIPCI_NATOMA;
}
}
<API key>(PCI_VENDOR_ID_INTEL, <API key>, quirk_natoma);
<API key>(PCI_VENDOR_ID_INTEL, <API key>, quirk_natoma);
<API key>(PCI_VENDOR_ID_INTEL, <API key>, quirk_natoma);
<API key>(PCI_VENDOR_ID_INTEL, <API key>, quirk_natoma);
<API key>(PCI_VENDOR_ID_INTEL, <API key>, quirk_natoma);
<API key>(PCI_VENDOR_ID_INTEL, <API key>, quirk_natoma);
/*
* This chip can cause PCI parity errors if config register 0xA0 is read
* while DMAs are occurring.
*/
static void quirk_citrine(struct pci_dev *dev)
{
dev->cfg_size = 0xA0;
}
<API key>(PCI_VENDOR_ID_IBM, <API key>, quirk_citrine);
/*
* This chip can cause bus lockups if config addresses above 0x600
* are read or written.
*/
static void quirk_nfp6000(struct pci_dev *dev)
{
dev->cfg_size = 0x600;
}
<API key>(<API key>, <API key>, quirk_nfp6000);
<API key>(<API key>, <API key>, quirk_nfp6000);
<API key>(<API key>, <API key>, quirk_nfp6000);
/* On IBM Crocodile ipr SAS adapters, expand BAR to system page size */
static void <API key>(struct pci_dev *dev)
{
int i;
for (i = 0; i < <API key>; i++) {
struct resource *r = &dev->resource[i];
if (r->flags & IORESOURCE_MEM && resource_size(r) < PAGE_SIZE) {
r->end = PAGE_SIZE - 1;
r->start = 0;
r->flags |= IORESOURCE_UNSET;
dev_info(&dev->dev, "expanded BAR %d to page size: %pR\n",
i, r);
}
}
}
<API key>(PCI_VENDOR_ID_IBM, 0x034a, <API key>);
/*
* S3 868 and 968 chips report region size equal to 32M, but they decode 64M.
* If it's needed, re-allocate the region.
*/
static void quirk_s3_64M(struct pci_dev *dev)
{
struct resource *r = &dev->resource[0];
if ((r->start & 0x3ffffff) || r->end != r->start + 0x3ffffff) {
r->flags |= IORESOURCE_UNSET;
r->start = 0;
r->end = 0x3ffffff;
}
}
<API key>(PCI_VENDOR_ID_S3, <API key>, quirk_s3_64M);
<API key>(PCI_VENDOR_ID_S3, <API key>, quirk_s3_64M);
static void quirk_io(struct pci_dev *dev, int pos, unsigned size,
const char *name)
{
u32 region;
struct pci_bus_region bus_region;
struct resource *res = dev->resource + pos;
<API key>(dev, PCI_BASE_ADDRESS_0 + (pos << 2), ®ion);
if (!region)
return;
res->name = pci_name(dev);
res->flags = region & ~<API key>;
res->flags |=
(IORESOURCE_IO | <API key> | <API key>);
region &= ~(size - 1);
/* Convert from PCI bus to resource space */
bus_region.start = region;
bus_region.end = region + size - 1;
<API key>(dev->bus, res, &bus_region);
dev_info(&dev->dev, FW_BUG "%s quirk: reg 0x%x: %pR\n",
name, PCI_BASE_ADDRESS_0 + (pos << 2), res);
}
static void quirk_cs5536_vsa(struct pci_dev *dev)
{
static char *name = "CS5536 ISA bridge";
if (pci_resource_len(dev, 0) != 8) {
quirk_io(dev, 0, 8, name); /* SMB */
quirk_io(dev, 1, 256, name); /* GPIO */
quirk_io(dev, 2, 64, name); /* MFGPT */
dev_info(&dev->dev, "%s bug detected (incorrect header); workaround applied\n",
name);
}
}
<API key>(PCI_VENDOR_ID_AMD, <API key>, quirk_cs5536_vsa);
static void quirk_io_region(struct pci_dev *dev, int port,
unsigned size, int nr, const char *name)
{
u16 region;
struct pci_bus_region bus_region;
struct resource *res = dev->resource + nr;
<API key>(dev, port, ®ion);
region &= ~(size - 1);
if (!region)
return;
res->name = pci_name(dev);
res->flags = IORESOURCE_IO;
/* Convert from PCI bus to resource space */
bus_region.start = region;
bus_region.end = region + size - 1;
<API key>(dev->bus, res, &bus_region);
if (!pci_claim_resource(dev, nr))
dev_info(&dev->dev, "quirk: %pR claimed by %s\n", res, name);
}
/*
* ATI Northbridge setups MCE the processor if you even
* read somewhere between 0x3b0->0x3bb or read 0x3d3
*/
static void <API key>(struct pci_dev *dev)
{
dev_info(&dev->dev, "ATI Northbridge, reserving I/O ports 0x3b0 to 0x3bb\n");
/* Mae rhaid i ni beidio ag edrych ar y lleoliadiau I/O hyn */
request_region(0x3b0, 0x0C, "RadeonIGP");
request_region(0x3d3, 0x01, "RadeonIGP");
}
<API key>(PCI_VENDOR_ID_ATI, <API key>, <API key>);
/*
* In the AMD NL platform, this device ([1022:7912]) has a class code of
* <API key> (0x0c0330), which means the xhci driver will
* claim it.
* But the dwc3 driver is a more specific driver for this device, and we'd
* prefer to use it instead of xhci. To prevent xhci from claiming the
* device, change the class code to 0x0c03fe, which the PCI r3.0 spec
* defines as "USB device (not host controller)". The dwc3 driver can then
* claim it based on its Vendor and Device ID.
*/
static void quirk_amd_nl_class(struct pci_dev *pdev)
{
u32 class = pdev->class;
/* Use "USB Device (not host controller)" class */
pdev->class = <API key>;
dev_info(&pdev->dev, "PCI class overridden (%#08x -> %#08x) so dwc3 driver can claim this instead of xhci\n",
class, pdev->class);
}
<API key>(PCI_VENDOR_ID_AMD, <API key>,
quirk_amd_nl_class);
/*
* Let's make the southbridge information explicit instead
* of having to worry about people probing the ACPI areas,
* for example.. (Yes, it happens, and if you read the wrong
* ACPI register it will put the machine to sleep with no
* way of waking it up again. Bummer).
*
* ALI M7101: Two IO regions pointed to by words at
* 0xE0 (64 bytes of ACPI registers)
* 0xE2 (32 bytes of SMB registers)
*/
static void quirk_ali7101_acpi(struct pci_dev *dev)
{
quirk_io_region(dev, 0xE0, 64, <API key>, "ali7101 ACPI");
quirk_io_region(dev, 0xE2, 32, <API key>+1, "ali7101 SMB");
}
<API key>(PCI_VENDOR_ID_AL, <API key>, quirk_ali7101_acpi);
static void piix4_io_quirk(struct pci_dev *dev, const char *name, unsigned int port, unsigned int enable)
{
u32 devres;
u32 mask, size, base;
<API key>(dev, port, &devres);
if ((devres & enable) != enable)
return;
mask = (devres >> 16) & 15;
base = devres & 0xffff;
size = 16;
for (;;) {
unsigned bit = size >> 1;
if ((bit & mask) == bit)
break;
size = bit;
}
/*
* For now we only print it out. Eventually we'll want to
* reserve it (at least if it's in the 0x1000+ range), but
* let's get enough confirmation reports first.
*/
base &= -size;
dev_info(&dev->dev, "%s PIO at %04x-%04x\n", name, base,
base + size - 1);
}
static void piix4_mem_quirk(struct pci_dev *dev, const char *name, unsigned int port, unsigned int enable)
{
u32 devres;
u32 mask, size, base;
<API key>(dev, port, &devres);
if ((devres & enable) != enable)
return;
base = devres & 0xffff0000;
mask = (devres & 0x3f) << 16;
size = 128 << 16;
for (;;) {
unsigned bit = size >> 1;
if ((bit & mask) == bit)
break;
size = bit;
}
/*
* For now we only print it out. Eventually we'll want to
* reserve it, but let's get enough confirmation reports first.
*/
base &= -size;
dev_info(&dev->dev, "%s MMIO at %04x-%04x\n", name, base,
base + size - 1);
}
/*
* PIIX4 ACPI: Two IO regions pointed to by longwords at
* 0x40 (64 bytes of ACPI registers)
* 0x90 (16 bytes of SMB registers)
* and a few strange programmable PIIX4 device resources.
*/
static void quirk_piix4_acpi(struct pci_dev *dev)
{
u32 res_a;
quirk_io_region(dev, 0x40, 64, <API key>, "PIIX4 ACPI");
quirk_io_region(dev, 0x90, 16, <API key>+1, "PIIX4 SMB");
/* Device resource A has enables for some of the other ones */
<API key>(dev, 0x5c, &res_a);
piix4_io_quirk(dev, "PIIX4 devres B", 0x60, 3 << 21);
piix4_io_quirk(dev, "PIIX4 devres C", 0x64, 3 << 21);
/* Device resource D is just bitfields for static resources */
/* Device 12 enabled? */
if (res_a & (1 << 29)) {
piix4_io_quirk(dev, "PIIX4 devres E", 0x68, 1 << 20);
piix4_mem_quirk(dev, "PIIX4 devres F", 0x6c, 1 << 7);
}
/* Device 13 enabled? */
if (res_a & (1 << 30)) {
piix4_io_quirk(dev, "PIIX4 devres G", 0x70, 1 << 20);
piix4_mem_quirk(dev, "PIIX4 devres H", 0x74, 1 << 7);
}
piix4_io_quirk(dev, "PIIX4 devres I", 0x78, 1 << 20);
piix4_io_quirk(dev, "PIIX4 devres J", 0x7c, 1 << 20);
}
<API key>(PCI_VENDOR_ID_INTEL, <API key>, quirk_piix4_acpi);
<API key>(PCI_VENDOR_ID_INTEL, <API key>, quirk_piix4_acpi);
#define ICH_PMBASE 0x40
#define ICH_ACPI_CNTL 0x44
#define ICH4_ACPI_EN 0x10
#define ICH6_ACPI_EN 0x80
#define ICH4_GPIOBASE 0x58
#define ICH4_GPIO_CNTL 0x5c
#define ICH4_GPIO_EN 0x10
#define ICH6_GPIOBASE 0x48
#define ICH6_GPIO_CNTL 0x4c
#define ICH6_GPIO_EN 0x10
/*
* ICH4, ICH4-M, ICH5, ICH5-M ACPI: Three IO regions pointed to by longwords at
* 0x40 (128 bytes of ACPI, GPIO & TCO registers)
* 0x58 (64 bytes of GPIO I/O space)
*/
static void quirk_ich4_lpc_acpi(struct pci_dev *dev)
{
u8 enable;
/*
* The check for PCIBIOS_MIN_IO is to ensure we won't create a conflict
* with low legacy (and fixed) ports. We don't know the decoding
* priority and can't tell whether the legacy device or the one created
* here is really at that address. This happens on boards with broken
* BIOSes.
*/
<API key>(dev, ICH_ACPI_CNTL, &enable);
if (enable & ICH4_ACPI_EN)
quirk_io_region(dev, ICH_PMBASE, 128, <API key>,
"ICH4 ACPI/GPIO/TCO");
<API key>(dev, ICH4_GPIO_CNTL, &enable);
if (enable & ICH4_GPIO_EN)
quirk_io_region(dev, ICH4_GPIOBASE, 64, <API key>+1,
"ICH4 GPIO");
}
<API key>(PCI_VENDOR_ID_INTEL, <API key>, quirk_ich4_lpc_acpi);
<API key>(PCI_VENDOR_ID_INTEL, <API key>, quirk_ich4_lpc_acpi);
<API key>(PCI_VENDOR_ID_INTEL, <API key>, quirk_ich4_lpc_acpi);
<API key>(PCI_VENDOR_ID_INTEL, <API key>, quirk_ich4_lpc_acpi);
<API key>(PCI_VENDOR_ID_INTEL, <API key>, quirk_ich4_lpc_acpi);
<API key>(PCI_VENDOR_ID_INTEL, <API key>, quirk_ich4_lpc_acpi);
<API key>(PCI_VENDOR_ID_INTEL, <API key>, quirk_ich4_lpc_acpi);
<API key>(PCI_VENDOR_ID_INTEL, <API key>, quirk_ich4_lpc_acpi);
<API key>(PCI_VENDOR_ID_INTEL, <API key>, quirk_ich4_lpc_acpi);
<API key>(PCI_VENDOR_ID_INTEL, <API key>, quirk_ich4_lpc_acpi);
static void ich6_lpc_acpi_gpio(struct pci_dev *dev)
{
u8 enable;
<API key>(dev, ICH_ACPI_CNTL, &enable);
if (enable & ICH6_ACPI_EN)
quirk_io_region(dev, ICH_PMBASE, 128, <API key>,
"ICH6 ACPI/GPIO/TCO");
<API key>(dev, ICH6_GPIO_CNTL, &enable);
if (enable & ICH6_GPIO_EN)
quirk_io_region(dev, ICH6_GPIOBASE, 64, <API key>+1,
"ICH6 GPIO");
}
static void <API key>(struct pci_dev *dev, unsigned reg, const char *name, int dynsize)
{
u32 val;
u32 size, base;
<API key>(dev, reg, &val);
/* Enabled? */
if (!(val & 1))
return;
base = val & 0xfffc;
if (dynsize) {
/*
* This is not correct. It is 16, 32 or 64 bytes depending on
* register D31:F0:ADh bits 5:4.
*
* But this gets us at least _part_ of it.
*/
size = 16;
} else {
size = 128;
}
base &= ~(size-1);
/* Just print it out for now. We should reserve it after more debugging */
dev_info(&dev->dev, "%s PIO at %04x-%04x\n", name, base, base+size-1);
}
static void quirk_ich6_lpc(struct pci_dev *dev)
{
/* Shared ACPI/GPIO decode with all ICH6+ */
ich6_lpc_acpi_gpio(dev);
/* ICH6-specific generic IO decode */
<API key>(dev, 0x84, "LPC Generic IO decode 1", 0);
<API key>(dev, 0x88, "LPC Generic IO decode 2", 1);
}
<API key>(PCI_VENDOR_ID_INTEL, <API key>, quirk_ich6_lpc);
<API key>(PCI_VENDOR_ID_INTEL, <API key>, quirk_ich6_lpc);
static void <API key>(struct pci_dev *dev, unsigned reg, const char *name)
{
u32 val;
u32 mask, base;
<API key>(dev, reg, &val);
/* Enabled? */
if (!(val & 1))
return;
/*
* IO base in bits 15:2, mask in bits 23:18, both
* are dword-based
*/
base = val & 0xfffc;
mask = (val >> 16) & 0xfc;
mask |= 3;
/* Just print it out for now. We should reserve it after more debugging */
dev_info(&dev->dev, "%s PIO at %04x (mask %04x)\n", name, base, mask);
}
/* ICH7-10 has the same common LPC generic IO decode registers */
static void quirk_ich7_lpc(struct pci_dev *dev)
{
/* We share the common ACPI/GPIO decode with ICH6 */
ich6_lpc_acpi_gpio(dev);
/* And have 4 ICH7+ generic decodes */
<API key>(dev, 0x84, "ICH7 LPC Generic IO decode 1");
<API key>(dev, 0x88, "ICH7 LPC Generic IO decode 2");
<API key>(dev, 0x8c, "ICH7 LPC Generic IO decode 3");
<API key>(dev, 0x90, "ICH7 LPC Generic IO decode 4");
}
<API key>(PCI_VENDOR_ID_INTEL, <API key>, quirk_ich7_lpc);
<API key>(PCI_VENDOR_ID_INTEL, <API key>, quirk_ich7_lpc);
<API key>(PCI_VENDOR_ID_INTEL, <API key>, quirk_ich7_lpc);
<API key>(PCI_VENDOR_ID_INTEL, <API key>, quirk_ich7_lpc);
<API key>(PCI_VENDOR_ID_INTEL, <API key>, quirk_ich7_lpc);
<API key>(PCI_VENDOR_ID_INTEL, <API key>, quirk_ich7_lpc);
<API key>(PCI_VENDOR_ID_INTEL, <API key>, quirk_ich7_lpc);
<API key>(PCI_VENDOR_ID_INTEL, <API key>, quirk_ich7_lpc);
<API key>(PCI_VENDOR_ID_INTEL, <API key>, quirk_ich7_lpc);
<API key>(PCI_VENDOR_ID_INTEL, <API key>, quirk_ich7_lpc);
<API key>(PCI_VENDOR_ID_INTEL, <API key>, quirk_ich7_lpc);
<API key>(PCI_VENDOR_ID_INTEL, <API key>, quirk_ich7_lpc);
<API key>(PCI_VENDOR_ID_INTEL, <API key>, quirk_ich7_lpc);
/*
* VIA ACPI: One IO region pointed to by longword at
* 0x48 or 0x20 (256 bytes of ACPI registers)
*/
static void quirk_vt82c586_acpi(struct pci_dev *dev)
{
if (dev->revision & 0x10)
quirk_io_region(dev, 0x48, 256, <API key>,
"vt82c586 ACPI");
}
<API key>(PCI_VENDOR_ID_VIA, <API key>, quirk_vt82c586_acpi);
/*
* VIA VT82C686 ACPI: Three IO region pointed to by (long)words at
* 0x48 (256 bytes of ACPI registers)
* 0x70 (128 bytes of hardware monitoring register)
* 0x90 (16 bytes of SMB registers)
*/
static void quirk_vt82c686_acpi(struct pci_dev *dev)
{
quirk_vt82c586_acpi(dev);
quirk_io_region(dev, 0x70, 128, <API key>+1,
"vt82c686 HW-mon");
quirk_io_region(dev, 0x90, 16, <API key>+2, "vt82c686 SMB");
}
<API key>(PCI_VENDOR_ID_VIA, <API key>, quirk_vt82c686_acpi);
/*
* VIA VT8235 ISA Bridge: Two IO regions pointed to by words at
* 0x88 (128 bytes of power management registers)
* 0xd0 (16 bytes of SMB registers)
*/
static void quirk_vt8235_acpi(struct pci_dev *dev)
{
quirk_io_region(dev, 0x88, 128, <API key>, "vt8235 PM");
quirk_io_region(dev, 0xd0, 16, <API key>+1, "vt8235 SMB");
}
<API key>(PCI_VENDOR_ID_VIA, <API key>, quirk_vt8235_acpi);
/*
* TI XIO2000a PCIe-PCI Bridge erroneously reports it supports fast back-to-back:
* Disable fast back-to-back on the secondary bus segment
*/
static void quirk_xio2000a(struct pci_dev *dev)
{
struct pci_dev *pdev;
u16 command;
dev_warn(&dev->dev, "TI XIO2000a quirk detected; secondary bus fast back-to-back transfers disabled\n");
list_for_each_entry(pdev, &dev->subordinate->devices, bus_list) {
<API key>(pdev, PCI_COMMAND, &command);
if (command & <API key>)
<API key>(pdev, PCI_COMMAND, command & ~<API key>);
}
}
<API key>(PCI_VENDOR_ID_TI, <API key>,
quirk_xio2000a);
#ifdef CONFIG_X86_IO_APIC
#include <asm/io_apic.h>
/*
* VIA 686A/B: If an IO-APIC is active, we need to route all on-chip
* devices to the external APIC.
*
* TODO: When we have device-specific interrupt routers,
* this code will go away from quirks.
*/
static void quirk_via_ioapic(struct pci_dev *dev)
{
u8 tmp;
if (nr_ioapics < 1)
tmp = 0; /* nothing routed to external APIC */
else
tmp = 0x1f; /* all known bits (4-0) routed to external APIC */
dev_info(&dev->dev, "%sbling VIA external APIC routing\n",
tmp == 0 ? "Disa" : "Ena");
/* Offset 0x58: External APIC IRQ output control */
<API key>(dev, 0x58, tmp);
}
<API key>(PCI_VENDOR_ID_VIA, <API key>, quirk_via_ioapic);
<API key>(PCI_VENDOR_ID_VIA, <API key>, quirk_via_ioapic);
/*
* VIA 8237: Some BIOSes don't set the 'Bypass APIC De-Assert Message' Bit.
* This leads to doubled level interrupt rates.
* Set this bit to get rid of cycle wastage.
* Otherwise uncritical.
*/
static void <API key>(struct pci_dev *dev)
{
u8 misc_control2;
#define <API key> 8
<API key>(dev, 0x5B, &misc_control2);
if (!(misc_control2 & <API key>)) {
dev_info(&dev->dev, "Bypassing VIA 8237 APIC De-Assert Message\n");
<API key>(dev, 0x5B, misc_control2|<API key>);
}
}
<API key>(PCI_VENDOR_ID_VIA, <API key>, <API key>);
<API key>(PCI_VENDOR_ID_VIA, <API key>, <API key>);
/*
* The AMD io apic can hang the box when an apic irq is masked.
* We check all revs >= B0 (yet not in the pre production!) as the bug
* is currently marked NoFix
*
* We have multiple reports of hangs with this chipset that went away with
* noapic specified. For the moment we assume it's the erratum. We may be wrong
* of course. However the advice is demonstrably good even if so..
*/
static void quirk_amd_ioapic(struct pci_dev *dev)
{
if (dev->revision >= 0x02) {
dev_warn(&dev->dev, "I/O APIC: AMD Erratum #22 may be present. In the event of instability try\n");
dev_warn(&dev->dev, " : booting with the \"noapic\" option\n");
}
}
<API key>(PCI_VENDOR_ID_AMD, <API key>, quirk_amd_ioapic);
#endif /* CONFIG_X86_IO_APIC */
#if defined(CONFIG_ARM64) && defined(CONFIG_PCI_ATS)
static void <API key>(struct pci_dev *dev)
{
/* Fix for improper SRIOV configuration on Cavium cn88xx RNM device */
if (dev->subsystem_device == 0xa118)
dev->sriov->link = dev->devfn;
}
<API key>(<API key>, 0xa018, <API key>);
#endif
/*
* Some settings of MMRBC can lead to data corruption so block changes.
* See AMD 8131 HyperTransport PCI-X Tunnel Revision Guide
*/
static void <API key>(struct pci_dev *dev)
{
if (dev->subordinate && dev->revision <= 0x12) {
dev_info(&dev->dev, "AMD8131 rev %x detected; disabling PCI-X MMRBC\n",
dev->revision);
dev->subordinate->bus_flags |= <API key>;
}
}
<API key>(PCI_VENDOR_ID_AMD, <API key>, <API key>);
/*
* FIXME: it is questionable that quirk_via_acpi
* is needed. It shows up as an ISA bridge, and does not
* support the PCI_INTERRUPT_LINE register at all. Therefore
* it seems like setting the pci_dev's 'irq' to the
* value of the ACPI SCI interrupt is only done for convenience.
* -jgarzik
*/
static void quirk_via_acpi(struct pci_dev *d)
{
/*
* VIA ACPI device: SCI IRQ line in PCI config byte 0x42
*/
u8 irq;
<API key>(d, 0x42, &irq);
irq &= 0xf;
if (irq && (irq != 2))
d->irq = irq;
}
<API key>(PCI_VENDOR_ID_VIA, <API key>, quirk_via_acpi);
<API key>(PCI_VENDOR_ID_VIA, <API key>, quirk_via_acpi);
/*
* VIA bridges which have VLink
*/
static int via_vlink_dev_lo = -1, via_vlink_dev_hi = 18;
static void quirk_via_bridge(struct pci_dev *dev)
{
/* See what bridge we have and find the device ranges */
switch (dev->device) {
case <API key>:
/* The VT82C686 is special, it attaches to PCI and can have
any device number. All its subdevices are functions of
that single device. */
via_vlink_dev_lo = PCI_SLOT(dev->devfn);
via_vlink_dev_hi = PCI_SLOT(dev->devfn);
break;
case <API key>:
case <API key>:
via_vlink_dev_lo = 15;
break;
case <API key>:
via_vlink_dev_lo = 16;
break;
case <API key>:
case <API key>:
case <API key>:
case <API key>:
via_vlink_dev_lo = 17;
break;
}
}
<API key>(PCI_VENDOR_ID_VIA, <API key>, quirk_via_bridge);
<API key>(PCI_VENDOR_ID_VIA, <API key>, quirk_via_bridge);
<API key>(PCI_VENDOR_ID_VIA, <API key>, quirk_via_bridge);
<API key>(PCI_VENDOR_ID_VIA, <API key>, quirk_via_bridge);
<API key>(PCI_VENDOR_ID_VIA, <API key>, quirk_via_bridge);
<API key>(PCI_VENDOR_ID_VIA, <API key>, quirk_via_bridge);
<API key>(PCI_VENDOR_ID_VIA, <API key>, quirk_via_bridge);
<API key>(PCI_VENDOR_ID_VIA, <API key>, quirk_via_bridge);
/**
* quirk_via_vlink - VIA VLink IRQ number update
* @dev: PCI device
*
* If the device we are dealing with is on a PIC IRQ we need to
* ensure that the IRQ line register which usually is not relevant
* for PCI cards, is actually written so that interrupts get sent
* to the right place.
* We only do this on systems where a VIA south bridge was detected,
* and only for VIA devices on the motherboard (see quirk_via_bridge
* above).
*/
static void quirk_via_vlink(struct pci_dev *dev)
{
u8 irq, new_irq;
/* Check if we have VLink at all */
if (via_vlink_dev_lo == -1)
return;
new_irq = dev->irq;
/* Don't quirk interrupts outside the legacy IRQ range */
if (!new_irq || new_irq > 15)
return;
/* Internal device ? */
if (dev->bus->number != 0 || PCI_SLOT(dev->devfn) > via_vlink_dev_hi ||
PCI_SLOT(dev->devfn) < via_vlink_dev_lo)
return;
/* This is an internal VLink device on a PIC interrupt. The BIOS
ought to have set this but may not have, so we redo it */
<API key>(dev, PCI_INTERRUPT_LINE, &irq);
if (new_irq != irq) {
dev_info(&dev->dev, "VIA VLink IRQ fixup, from %d to %d\n",
irq, new_irq);
udelay(15); /* unknown if delay really needed */
<API key>(dev, PCI_INTERRUPT_LINE, new_irq);
}
}
<API key>(PCI_VENDOR_ID_VIA, PCI_ANY_ID, quirk_via_vlink);
/*
* VIA VT82C598 has its device ID settable and many BIOSes
* set it to the ID of VT82C597 for backward compatibility.
* We need to switch it off to be able to recognize the real
* type of the chip.
*/
static void quirk_vt82c598_id(struct pci_dev *dev)
{
<API key>(dev, 0xfc, 0);
<API key>(dev, PCI_DEVICE_ID, &dev->device);
}
<API key>(PCI_VENDOR_ID_VIA, <API key>, quirk_vt82c598_id);
/*
* CardBus controllers have a legacy base address that enables them
* to respond as i82365 pcmcia controllers. We don't want them to
* do this even if the Linux CardBus driver is not loaded, because
* the Linux i82365 driver does not (and should not) handle CardBus.
*/
static void <API key>(struct pci_dev *dev)
{
<API key>(dev, <API key>, 0);
}
<API key>(PCI_ANY_ID, PCI_ANY_ID,
<API key>, 8, <API key>);
<API key>(PCI_ANY_ID, PCI_ANY_ID,
<API key>, 8, <API key>);
/*
* Following the PCI ordering rules is optional on the AMD762. I'm not
* sure what the designers were smoking but let's not inhale...
*
* To be fair to AMD, it follows the spec by default, its BIOS people
* who turn it off!
*/
static void quirk_amd_ordering(struct pci_dev *dev)
{
u32 pcic;
<API key>(dev, 0x4C, &pcic);
if ((pcic & 6) != 6) {
pcic |= 6;
dev_warn(&dev->dev, "BIOS failed to enable PCI standards compliance; fixing this error\n");
<API key>(dev, 0x4C, pcic);
<API key>(dev, 0x84, &pcic);
pcic |= (1 << 23); /* Required in this mode */
<API key>(dev, 0x84, pcic);
}
}
<API key>(PCI_VENDOR_ID_AMD, <API key>, quirk_amd_ordering);
<API key>(PCI_VENDOR_ID_AMD, <API key>, quirk_amd_ordering);
/*
* DreamWorks provided workaround for Dunord I-3000 problem
*
* This card decodes and responds to addresses not apparently
* assigned to it. We force a larger allocation to ensure that
* nothing gets put too close to it.
*/
static void quirk_dunord(struct pci_dev *dev)
{
struct resource *r = &dev->resource[1];
r->flags |= IORESOURCE_UNSET;
r->start = 0;
r->end = 0xffffff;
}
<API key>(<API key>, <API key>, quirk_dunord);
/*
* i82380FB mobile docking controller: its PCI-to-PCI bridge
* is subtractive decoding (transparent), and does indicate this
* in the ProgIf. Unfortunately, the ProgIf value is wrong - 0x80
* instead of 0x01.
*/
static void <API key>(struct pci_dev *dev)
{
dev->transparent = 1;
}
<API key>(PCI_VENDOR_ID_INTEL, <API key>, <API key>);
<API key>(<API key>, 0x605, <API key>);
static void <API key>(struct pci_dev *dev)
{
u8 reg;
<API key>(dev, 0x41, ®);
if (reg & 2) {
reg &= ~2;
dev_info(&dev->dev, "Fixup for MediaGX/Geode Slave Disconnect Boundary (0x41=0x%02x)\n",
reg);
<API key>(dev, 0x41, reg);
}
}
<API key>(PCI_VENDOR_ID_CYRIX, <API key>, <API key>);
<API key>(PCI_VENDOR_ID_CYRIX, <API key>, <API key>);
/*
* Ensure C0 rev restreaming is off. This is normally done by
* the BIOS but in the odd case it is not the results are corruption
* hence the presence of a Linux check
*/
static void quirk_disable_pxb(struct pci_dev *pdev)
{
u16 config;
if (pdev->revision != 0x04) /* Only C0 requires this */
return;
<API key>(pdev, 0x40, &config);
if (config & (1<<6)) {
config &= ~(1<<6);
<API key>(pdev, 0x40, config);
dev_info(&pdev->dev, "C0 revision 450NX. Disabling PCI restreaming\n");
}
}
<API key>(PCI_VENDOR_ID_INTEL, <API key>, quirk_disable_pxb);
<API key>(PCI_VENDOR_ID_INTEL, <API key>, quirk_disable_pxb);
static void quirk_amd_ide_mode(struct pci_dev *pdev)
{
/* set SBX00/Hudson-2 SATA in IDE mode to AHCI mode */
u8 tmp;
<API key>(pdev, PCI_CLASS_DEVICE, &tmp);
if (tmp == 0x01) {
<API key>(pdev, 0x40, &tmp);
<API key>(pdev, 0x40, tmp|1);
<API key>(pdev, 0x9, 1);
<API key>(pdev, 0xa, 6);
<API key>(pdev, 0x40, tmp);
pdev->class = <API key>;
dev_info(&pdev->dev, "set SATA to AHCI mode\n");
}
}
<API key>(PCI_VENDOR_ID_ATI, <API key>, quirk_amd_ide_mode);
<API key>(PCI_VENDOR_ID_ATI, <API key>, quirk_amd_ide_mode);
<API key>(PCI_VENDOR_ID_ATI, <API key>, quirk_amd_ide_mode);
<API key>(PCI_VENDOR_ID_ATI, <API key>, quirk_amd_ide_mode);
<API key>(PCI_VENDOR_ID_AMD, <API key>, quirk_amd_ide_mode);
<API key>(PCI_VENDOR_ID_AMD, <API key>, quirk_amd_ide_mode);
<API key>(PCI_VENDOR_ID_AMD, 0x7900, quirk_amd_ide_mode);
<API key>(PCI_VENDOR_ID_AMD, 0x7900, quirk_amd_ide_mode);
/*
* Serverworks CSB5 IDE does not fully support native mode
*/
static void quirk_svwks_csb5ide(struct pci_dev *pdev)
{
u8 prog;
<API key>(pdev, PCI_CLASS_PROG, &prog);
if (prog & 5) {
prog &= ~5;
pdev->class &= ~5;
<API key>(pdev, PCI_CLASS_PROG, prog);
/* PCI layer will sort out resources */
}
}
<API key>(<API key>, <API key>, quirk_svwks_csb5ide);
/*
* Intel 82801CAM ICH3-M datasheet says IDE modes must be the same
*/
static void quirk_ide_samemode(struct pci_dev *pdev)
{
u8 prog;
<API key>(pdev, PCI_CLASS_PROG, &prog);
if (((prog & 1) && !(prog & 4)) || ((prog & 4) && !(prog & 1))) {
dev_info(&pdev->dev, "IDE mode mismatch; forcing legacy mode\n");
prog &= ~5;
pdev->class &= ~5;
<API key>(pdev, PCI_CLASS_PROG, prog);
}
}
<API key>(PCI_VENDOR_ID_INTEL, <API key>, quirk_ide_samemode);
/*
* Some ATA devices break if put into D3
*/
static void quirk_no_ata_d3(struct pci_dev *pdev)
{
pdev->dev_flags |= PCI_DEV_FLAGS_NO_D3;
}
/* Quirk the legacy ATA devices only. The AHCI ones are ok */
<API key>(<API key>, PCI_ANY_ID,
<API key>, 8, quirk_no_ata_d3);
<API key>(PCI_VENDOR_ID_ATI, PCI_ANY_ID,
<API key>, 8, quirk_no_ata_d3);
/* ALi loses some register settings that we cannot then restore */
<API key>(PCI_VENDOR_ID_AL, PCI_ANY_ID,
<API key>, 8, quirk_no_ata_d3);
/* VIA comes back fine but we need to keep it alive or ACPI GTM failures
occur when mode detecting */
<API key>(PCI_VENDOR_ID_VIA, PCI_ANY_ID,
<API key>, 8, quirk_no_ata_d3);
/* This was originally an Alpha specific thing, but it really fits here.
* The i82375 PCI/EISA bridge appears as non-classified. Fix that.
*/
static void quirk_eisa_bridge(struct pci_dev *dev)
{
dev->class = <API key> << 8;
}
<API key>(PCI_VENDOR_ID_INTEL, <API key>, quirk_eisa_bridge);
/*
* On ASUS P4B boards, the SMBus PCI Device within the ICH2/4 southbridge
* is not activated. The myth is that Asus said that they do not want the
* users to be irritated by just another PCI Device in the Win98 device
* manager. (see the file prog/hotplug/README.p4b in the lm_sensors
* package 2.7.0 for details)
*
* The SMBus PCI Device can be activated by setting a bit in the ICH LPC
* bridge. Unfortunately, this device has no subvendor/subdevice ID. So it
* becomes necessary to do this tweak in two steps -- the chosen trigger
* is either the Host bridge (preferred) or on-board VGA controller.
*
* Note that we used to unhide the SMBus that way on Toshiba laptops
* (Satellite A40 and Tecra M2) but then found that the thermal management
* was done by SMM code, which could cause unsynchronized concurrent
* accesses to the SMBus registers, with potentially bad effects. Thus you
* should be very careful when adding new entries: if SMM is accessing the
* Intel SMBus, this is a very good reason to leave it hidden.
*
* Likewise, many recent laptops use ACPI for thermal management. If the
* ACPI DSDT code accesses the SMBus, then Linux should not access it
* natively, and keeping the SMBus hidden is the right thing to do. If you
* are about to add an entry in the table below, please first disassemble
* the DSDT and double-check that there is no code accessing the SMBus.
*/
static int asus_hides_smbus;
static void <API key>(struct pci_dev *dev)
{
if (unlikely(dev->subsystem_vendor == <API key>)) {
if (dev->device == <API key>)
switch (dev->subsystem_device) {
case 0x8025: /* P4B-LX */
case 0x8070: /* P4B */
case 0x8088: /* P4B533 */
case 0x1626: /* L3C notebook */
asus_hides_smbus = 1;
}
else if (dev->device == <API key>)
switch (dev->subsystem_device) {
case 0x80b1: /* P4GE-V */
case 0x80b2: /* P4PE */
case 0x8093: /* P4B533-V */
asus_hides_smbus = 1;
}
else if (dev->device == <API key>)
switch (dev->subsystem_device) {
case 0x8030: /* P4T533 */
asus_hides_smbus = 1;
}
else if (dev->device == <API key>)
switch (dev->subsystem_device) {
case 0x8070: /* P4G8X Deluxe */
asus_hides_smbus = 1;
}
else if (dev->device == <API key>)
switch (dev->subsystem_device) {
case 0x80c9: /* PU-DLS */
asus_hides_smbus = 1;
}
else if (dev->device == <API key>)
switch (dev->subsystem_device) {
case 0x1751: /* M2N notebook */
case 0x1821: /* M5N notebook */
case 0x1897: /* A6L notebook */
asus_hides_smbus = 1;
}
else if (dev->device == <API key>)
switch (dev->subsystem_device) {
case 0x184b: /* W1N notebook */
case 0x186a: /* M6Ne notebook */
asus_hides_smbus = 1;
}
else if (dev->device == <API key>)
switch (dev->subsystem_device) {
case 0x80f2: /* P4P800-X */
asus_hides_smbus = 1;
}
else if (dev->device == <API key>)
switch (dev->subsystem_device) {
case 0x1882: /* M6V notebook */
case 0x1977: /* A6VA notebook */
asus_hides_smbus = 1;
}
} else if (unlikely(dev->subsystem_vendor == PCI_VENDOR_ID_HP)) {
if (dev->device == <API key>)
switch (dev->subsystem_device) {
case 0x088C: /* HP Compaq nc8000 */
case 0x0890: /* HP Compaq nc6000 */
asus_hides_smbus = 1;
}
else if (dev->device == <API key>)
switch (dev->subsystem_device) {
case 0x12bc: /* HP D330L */
case 0x12bd: /* HP D530 */
case 0x006a: /* HP Compaq nx9500 */
asus_hides_smbus = 1;
}
else if (dev->device == <API key>)
switch (dev->subsystem_device) {
case 0x12bf: /* HP xw4100 */
asus_hides_smbus = 1;
}
} else if (unlikely(dev->subsystem_vendor == <API key>)) {
if (dev->device == <API key>)
switch (dev->subsystem_device) {
case 0xC00C: /* Samsung P35 notebook */
asus_hides_smbus = 1;
}
} else if (unlikely(dev->subsystem_vendor == <API key>)) {
if (dev->device == <API key>)
switch (dev->subsystem_device) {
case 0x0058: /* Compaq Evo N620c */
asus_hides_smbus = 1;
}
else if (dev->device == <API key>)
switch (dev->subsystem_device) {
case 0xB16C: /* Compaq Deskpro EP 401963-001 (PCA# 010174) */
/* Motherboard doesn't have Host bridge
* subvendor/subdevice IDs, therefore checking
* its on-board VGA controller */
asus_hides_smbus = 1;
}
else if (dev->device == <API key>)
switch (dev->subsystem_device) {
case 0x00b8: /* Compaq Evo D510 CMT */
case 0x00b9: /* Compaq Evo D510 SFF */
case 0x00ba: /* Compaq Evo D510 USDT */
/* Motherboard doesn't have Host bridge
* subvendor/subdevice IDs and on-board VGA
* controller is disabled if an AGP card is
* inserted, therefore checking USB UHCI
* Controller #1 */
asus_hides_smbus = 1;
}
else if (dev->device == <API key>)
switch (dev->subsystem_device) {
case 0x001A: /* Compaq Deskpro EN SSF P667 815E */
/* Motherboard doesn't have host bridge
* subvendor/subdevice IDs, therefore checking
* its on-board VGA controller */
asus_hides_smbus = 1;
}
}
}
<API key>(PCI_VENDOR_ID_INTEL, <API key>, <API key>);
<API key>(PCI_VENDOR_ID_INTEL, <API key>, <API key>);
<API key>(PCI_VENDOR_ID_INTEL, <API key>, <API key>);
<API key>(PCI_VENDOR_ID_INTEL, <API key>, <API key>);
<API key>(PCI_VENDOR_ID_INTEL, <API key>, <API key>);
<API key>(PCI_VENDOR_ID_INTEL, <API key>, <API key>);
<API key>(PCI_VENDOR_ID_INTEL, <API key>, <API key>);
<API key>(PCI_VENDOR_ID_INTEL, <API key>, <API key>);
<API key>(PCI_VENDOR_ID_INTEL, <API key>, <API key>);
<API key>(PCI_VENDOR_ID_INTEL, <API key>, <API key>);
<API key>(PCI_VENDOR_ID_INTEL, <API key>, <API key>);
<API key>(PCI_VENDOR_ID_INTEL, <API key>, <API key>);
<API key>(PCI_VENDOR_ID_INTEL, <API key>, <API key>);
static void <API key>(struct pci_dev *dev)
{
u16 val;
if (likely(!asus_hides_smbus))
return;
<API key>(dev, 0xF2, &val);
if (val & 0x8) {
<API key>(dev, 0xF2, val & (~0x8));
<API key>(dev, 0xF2, &val);
if (val & 0x8)
dev_info(&dev->dev, "i801 SMBus device continues to play 'hide and seek'! 0x%x\n",
val);
else
dev_info(&dev->dev, "Enabled i801 SMBus device\n");
}
}
<API key>(PCI_VENDOR_ID_INTEL, <API key>, <API key>);
<API key>(PCI_VENDOR_ID_INTEL, <API key>, <API key>);
<API key>(PCI_VENDOR_ID_INTEL, <API key>, <API key>);
<API key>(PCI_VENDOR_ID_INTEL, <API key>, <API key>);
<API key>(PCI_VENDOR_ID_INTEL, <API key>, <API key>);
<API key>(PCI_VENDOR_ID_INTEL, <API key>, <API key>);
<API key>(PCI_VENDOR_ID_INTEL, <API key>, <API key>);
<API key>(PCI_VENDOR_ID_INTEL, <API key>, <API key>);
<API key>(PCI_VENDOR_ID_INTEL, <API key>, <API key>);
<API key>(PCI_VENDOR_ID_INTEL, <API key>, <API key>);
<API key>(PCI_VENDOR_ID_INTEL, <API key>, <API key>);
<API key>(PCI_VENDOR_ID_INTEL, <API key>, <API key>);
<API key>(PCI_VENDOR_ID_INTEL, <API key>, <API key>);
<API key>(PCI_VENDOR_ID_INTEL, <API key>, <API key>);
/* It appears we just have one such device. If not, we have a warning */
static void __iomem *asus_rcba_base;
static void <API key>(struct pci_dev *dev)
{
u32 rcba;
if (likely(!asus_hides_smbus))
return;
WARN_ON(asus_rcba_base);
<API key>(dev, 0xF0, &rcba);
/* use bits 31:14, 16 kB aligned */
asus_rcba_base = ioremap_nocache(rcba & 0xFFFFC000, 0x4000);
if (asus_rcba_base == NULL)
return;
}
static void <API key>(struct pci_dev *dev)
{
u32 val;
if (likely(!asus_hides_smbus || !asus_rcba_base))
return;
/* read the Function Disable register, dword mode only */
val = readl(asus_rcba_base + 0x3418);
writel(val & 0xFFFFFFF7, asus_rcba_base + 0x3418); /* enable the SMBus device */
}
static void <API key>(struct pci_dev *dev)
{
if (likely(!asus_hides_smbus || !asus_rcba_base))
return;
iounmap(asus_rcba_base);
asus_rcba_base = NULL;
dev_info(&dev->dev, "Enabled ICH6/i801 SMBus device\n");
}
static void <API key>(struct pci_dev *dev)
{
<API key>(dev);
<API key>(dev);
<API key>(dev);
}
<API key>(PCI_VENDOR_ID_INTEL, <API key>, <API key>);
<API key>(PCI_VENDOR_ID_INTEL, <API key>, <API key>);
<API key>(PCI_VENDOR_ID_INTEL, <API key>, <API key>);
<API key>(PCI_VENDOR_ID_INTEL, <API key>, <API key>);
/*
* SiS 96x south bridge: BIOS typically hides SMBus device...
*/
static void quirk_sis_96x_smbus(struct pci_dev *dev)
{
u8 val = 0;
<API key>(dev, 0x77, &val);
if (val & 0x10) {
dev_info(&dev->dev, "Enabling SiS 96x SMBus\n");
<API key>(dev, 0x77, val & ~0x10);
}
}
<API key>(PCI_VENDOR_ID_SI, <API key>, quirk_sis_96x_smbus);
<API key>(PCI_VENDOR_ID_SI, <API key>, quirk_sis_96x_smbus);
<API key>(PCI_VENDOR_ID_SI, <API key>, quirk_sis_96x_smbus);
<API key>(PCI_VENDOR_ID_SI, <API key>, quirk_sis_96x_smbus);
<API key>(PCI_VENDOR_ID_SI, <API key>, quirk_sis_96x_smbus);
<API key>(PCI_VENDOR_ID_SI, <API key>, quirk_sis_96x_smbus);
<API key>(PCI_VENDOR_ID_SI, <API key>, quirk_sis_96x_smbus);
<API key>(PCI_VENDOR_ID_SI, <API key>, quirk_sis_96x_smbus);
/*
* ... This is further complicated by the fact that some SiS96x south
* bridges pretend to be 85C503/5513 instead. In that case see if we
* spotted a compatible north bridge to make sure.
* (pci_find_device doesn't work yet)
*
* We can also enable the sis96x bit in the discovery register..
*/
#define SIS_DETECT_REGISTER 0x40
static void quirk_sis_503(struct pci_dev *dev)
{
u8 reg;
u16 devid;
<API key>(dev, SIS_DETECT_REGISTER, ®);
<API key>(dev, SIS_DETECT_REGISTER, reg | (1 << 6));
<API key>(dev, PCI_DEVICE_ID, &devid);
if (((devid & 0xfff0) != 0x0960) && (devid != 0x0018)) {
<API key>(dev, SIS_DETECT_REGISTER, reg);
return;
}
/*
* Ok, it now shows up as a 96x.. run the 96x quirk by
* hand in case it has already been processed.
* (depends on link order, which is apparently not guaranteed)
*/
dev->device = devid;
quirk_sis_96x_smbus(dev);
}
<API key>(PCI_VENDOR_ID_SI, <API key>, quirk_sis_503);
<API key>(PCI_VENDOR_ID_SI, <API key>, quirk_sis_503);
/*
* On ASUS A8V and A8V Deluxe boards, the onboard AC97 audio controller
* and MC97 modem controller are disabled when a second PCI soundcard is
* present. This patch, tweaking the VT8237 ISA bridge, enables them.
* -- bjd
*/
static void asus_hides_ac97_lpc(struct pci_dev *dev)
{
u8 val;
int asus_hides_ac97 = 0;
if (likely(dev->subsystem_vendor == <API key>)) {
if (dev->device == <API key>)
asus_hides_ac97 = 1;
}
if (!asus_hides_ac97)
return;
<API key>(dev, 0x50, &val);
if (val & 0xc0) {
<API key>(dev, 0x50, val & (~0xc0));
<API key>(dev, 0x50, &val);
if (val & 0xc0)
dev_info(&dev->dev, "Onboard AC97/MC97 devices continue to play 'hide and seek'! 0x%x\n",
val);
else
dev_info(&dev->dev, "Enabled onboard AC97/MC97 devices\n");
}
}
<API key>(PCI_VENDOR_ID_VIA, <API key>, asus_hides_ac97_lpc);
<API key>(PCI_VENDOR_ID_VIA, <API key>, asus_hides_ac97_lpc);
#if defined(CONFIG_ATA) || defined(CONFIG_ATA_MODULE)
/*
* If we are using libata we can drive this chip properly but must
* do this early on to make the additional device appear during
* the PCI scanning.
*/
static void quirk_jmicron_ata(struct pci_dev *pdev)
{
u32 conf1, conf5, class;
u8 hdr;
/* Only poke fn 0 */
if (PCI_FUNC(pdev->devfn))
return;
<API key>(pdev, 0x40, &conf1);
<API key>(pdev, 0x80, &conf5);
conf1 &= ~0x00CFF302; /* Clear bit 1, 8, 9, 12-19, 22, 23 */
conf5 &= ~(1 << 24); /* Clear bit 24 */
switch (pdev->device) {
case <API key>: /* SATA single port */
case <API key>: /* SATA dual ports */
case <API key>: /* SATA dual ports */
/* The controller should be in single function ahci mode */
conf1 |= 0x0002A100; /* Set 8, 13, 15, 17 */
break;
case <API key>:
case <API key>:
/* Redirect IDE second PATA port to the right spot */
conf5 |= (1 << 24);
/* Fall through */
case <API key>:
case <API key>:
case <API key>:
/* Enable dual function mode, AHCI on fn 0, IDE fn1 */
/* Set the class codes correctly and then direct IDE 0 */
conf1 |= 0x00C2A1B3; /* Set 0, 1, 4, 5, 7, 8, 13, 15, 17, 22, 23 */
break;
case <API key>:
/* The controller should be in single function IDE mode */
conf1 |= 0x00C00000; /* Set 22, 23 */
break;
}
<API key>(pdev, 0x40, conf1);
<API key>(pdev, 0x80, conf5);
/* Update pdev accordingly */
<API key>(pdev, PCI_HEADER_TYPE, &hdr);
pdev->hdr_type = hdr & 0x7f;
pdev->multifunction = !!(hdr & 0x80);
<API key>(pdev, PCI_CLASS_REVISION, &class);
pdev->class = class >> 8;
}
<API key>(<API key>, <API key>, quirk_jmicron_ata);
<API key>(<API key>, <API key>, quirk_jmicron_ata);
<API key>(<API key>, <API key>, quirk_jmicron_ata);
<API key>(<API key>, <API key>, quirk_jmicron_ata);
<API key>(<API key>, <API key>, quirk_jmicron_ata);
<API key>(<API key>, <API key>, quirk_jmicron_ata);
<API key>(<API key>, <API key>, quirk_jmicron_ata);
<API key>(<API key>, <API key>, quirk_jmicron_ata);
<API key>(<API key>, <API key>, quirk_jmicron_ata);
<API key>(<API key>, <API key>, quirk_jmicron_ata);
<API key>(<API key>, <API key>, quirk_jmicron_ata);
<API key>(<API key>, <API key>, quirk_jmicron_ata);
<API key>(<API key>, <API key>, quirk_jmicron_ata);
<API key>(<API key>, <API key>, quirk_jmicron_ata);
<API key>(<API key>, <API key>, quirk_jmicron_ata);
<API key>(<API key>, <API key>, quirk_jmicron_ata);
<API key>(<API key>, <API key>, quirk_jmicron_ata);
<API key>(<API key>, <API key>, quirk_jmicron_ata);
#endif
static void <API key>(struct pci_dev *dev)
{
if (dev->multifunction) {
<API key>(&dev->dev);
dev_info(&dev->dev, "async suspend disabled to avoid multi-function power-on ordering issue\n");
}
}
<API key>(<API key>, PCI_ANY_ID, <API key>, 8, <API key>);
<API key>(<API key>, PCI_ANY_ID, <API key>, 0, <API key>);
<API key>(<API key>, 0x2362, <API key>);
<API key>(<API key>, 0x236f, <API key>);
#ifdef CONFIG_X86_IO_APIC
static void quirk_alder_ioapic(struct pci_dev *pdev)
{
int i;
if ((pdev->class >> 8) != 0xff00)
return;
/* the first BAR is the location of the IO APIC...we must
* not touch this (and it's already covered by the fixmap), so
* forcibly insert it into the resource tree */
if (pci_resource_start(pdev, 0) && pci_resource_len(pdev, 0))
insert_resource(&iomem_resource, &pdev->resource[0]);
/* The next five BARs all seem to be rubbish, so just clean
* them out */
for (i = 1; i < 6; i++)
memset(&pdev->resource[i], 0, sizeof(pdev->resource[i]));
}
<API key>(PCI_VENDOR_ID_INTEL, <API key>, quirk_alder_ioapic);
#endif
static void quirk_pcie_mch(struct pci_dev *pdev)
{
pdev->no_msi = 1;
}
<API key>(PCI_VENDOR_ID_INTEL, <API key>, quirk_pcie_mch);
<API key>(PCI_VENDOR_ID_INTEL, <API key>, quirk_pcie_mch);
<API key>(PCI_VENDOR_ID_INTEL, <API key>, quirk_pcie_mch);
/*
* It's possible for the MSI to get corrupted if shpc and acpi
* are used together on certain PXH-based systems.
*/
static void quirk_pcie_pxh(struct pci_dev *dev)
{
dev->no_msi = 1;
dev_warn(&dev->dev, "PXH quirk detected; SHPC device MSI disabled\n");
}
<API key>(PCI_VENDOR_ID_INTEL, <API key>, quirk_pcie_pxh);
<API key>(PCI_VENDOR_ID_INTEL, <API key>, quirk_pcie_pxh);
<API key>(PCI_VENDOR_ID_INTEL, <API key>, quirk_pcie_pxh);
<API key>(PCI_VENDOR_ID_INTEL, <API key>, quirk_pcie_pxh);
<API key>(PCI_VENDOR_ID_INTEL, <API key>, quirk_pcie_pxh);
/*
* Some Intel PCI Express chipsets have trouble with downstream
* device power management.
*/
static void quirk_intel_pcie_pm(struct pci_dev *dev)
{
pci_pm_d3_delay = 120;
dev->no_d1d2 = 1;
}
<API key>(PCI_VENDOR_ID_INTEL, 0x25e2, quirk_intel_pcie_pm);
<API key>(PCI_VENDOR_ID_INTEL, 0x25e3, quirk_intel_pcie_pm);
<API key>(PCI_VENDOR_ID_INTEL, 0x25e4, quirk_intel_pcie_pm);
<API key>(PCI_VENDOR_ID_INTEL, 0x25e5, quirk_intel_pcie_pm);
<API key>(PCI_VENDOR_ID_INTEL, 0x25e6, quirk_intel_pcie_pm);
<API key>(PCI_VENDOR_ID_INTEL, 0x25e7, quirk_intel_pcie_pm);
<API key>(PCI_VENDOR_ID_INTEL, 0x25f7, quirk_intel_pcie_pm);
<API key>(PCI_VENDOR_ID_INTEL, 0x25f8, quirk_intel_pcie_pm);
<API key>(PCI_VENDOR_ID_INTEL, 0x25f9, quirk_intel_pcie_pm);
<API key>(PCI_VENDOR_ID_INTEL, 0x25fa, quirk_intel_pcie_pm);
<API key>(PCI_VENDOR_ID_INTEL, 0x2601, quirk_intel_pcie_pm);
<API key>(PCI_VENDOR_ID_INTEL, 0x2602, quirk_intel_pcie_pm);
<API key>(PCI_VENDOR_ID_INTEL, 0x2603, quirk_intel_pcie_pm);
<API key>(PCI_VENDOR_ID_INTEL, 0x2604, quirk_intel_pcie_pm);
<API key>(PCI_VENDOR_ID_INTEL, 0x2605, quirk_intel_pcie_pm);
<API key>(PCI_VENDOR_ID_INTEL, 0x2606, quirk_intel_pcie_pm);
<API key>(PCI_VENDOR_ID_INTEL, 0x2607, quirk_intel_pcie_pm);
<API key>(PCI_VENDOR_ID_INTEL, 0x2608, quirk_intel_pcie_pm);
<API key>(PCI_VENDOR_ID_INTEL, 0x2609, quirk_intel_pcie_pm);
<API key>(PCI_VENDOR_ID_INTEL, 0x260a, quirk_intel_pcie_pm);
<API key>(PCI_VENDOR_ID_INTEL, 0x260b, quirk_intel_pcie_pm);
#ifdef CONFIG_X86_IO_APIC
/*
* Boot interrupts on some chipsets cannot be turned off. For these chipsets,
* remap the original interrupt in the linux kernel to the boot interrupt, so
* that a PCI device's interrupt handler is installed on the boot interrupt
* line instead.
*/
static void <API key>(struct pci_dev *dev)
{
if (noioapicquirk || noioapicreroute)
return;
dev->irq_reroute_variant = <API key>;
dev_info(&dev->dev, "rerouting interrupts for [%04x:%04x]\n",
dev->vendor, dev->device);
}
<API key>(PCI_VENDOR_ID_INTEL, <API key>, <API key>);
<API key>(PCI_VENDOR_ID_INTEL, <API key>, <API key>);
<API key>(PCI_VENDOR_ID_INTEL, <API key>, <API key>);
<API key>(PCI_VENDOR_ID_INTEL, <API key>, <API key>);
<API key>(PCI_VENDOR_ID_INTEL, <API key>, <API key>);
<API key>(PCI_VENDOR_ID_INTEL, <API key>, <API key>);
<API key>(PCI_VENDOR_ID_INTEL, <API key>, <API key>);
<API key>(PCI_VENDOR_ID_INTEL, <API key>, <API key>);
<API key>(PCI_VENDOR_ID_INTEL, <API key>, <API key>);
<API key>(PCI_VENDOR_ID_INTEL, <API key>, <API key>);
<API key>(PCI_VENDOR_ID_INTEL, <API key>, <API key>);
<API key>(PCI_VENDOR_ID_INTEL, <API key>, <API key>);
<API key>(PCI_VENDOR_ID_INTEL, <API key>, <API key>);
<API key>(PCI_VENDOR_ID_INTEL, <API key>, <API key>);
<API key>(PCI_VENDOR_ID_INTEL, <API key>, <API key>);
<API key>(PCI_VENDOR_ID_INTEL, <API key>, <API key>);
/*
* On some chipsets we can disable the generation of legacy INTx boot
* interrupts.
*/
/*
* IO-APIC1 on 6300ESB generates boot interrupts, see intel order no
* 300641-004US, section 5.7.3.
*/
#define <API key> 0x40
#define <API key> (1<<14)
static void <API key>(struct pci_dev *dev)
{
u16 pci_config_word;
if (noioapicquirk)
return;
<API key>(dev, <API key>, &pci_config_word);
pci_config_word |= <API key>;
<API key>(dev, <API key>, pci_config_word);
dev_info(&dev->dev, "disabled boot interrupts on device [%04x:%04x]\n",
dev->vendor, dev->device);
}
<API key>(PCI_VENDOR_ID_INTEL, <API key>, <API key>);
<API key>(PCI_VENDOR_ID_INTEL, <API key>, <API key>);
/*
* disable boot interrupts on HT-1000
*/
#define <API key> 0x64
#define <API key> (1<<0)
#define BC_HT1000_MAP_IDX 0xC00
#define BC_HT1000_MAP_DATA 0xC01
static void <API key>(struct pci_dev *dev)
{
u32 pci_config_dword;
u8 irq;
if (noioapicquirk)
return;
<API key>(dev, <API key>, &pci_config_dword);
<API key>(dev, <API key>, pci_config_dword |
<API key>);
for (irq = 0x10; irq < 0x10 + 32; irq++) {
outb(irq, BC_HT1000_MAP_IDX);
outb(0x00, BC_HT1000_MAP_DATA);
}
<API key>(dev, <API key>, pci_config_dword);
dev_info(&dev->dev, "disabled boot interrupts on device [%04x:%04x]\n",
dev->vendor, dev->device);
}
<API key>(<API key>, <API key>, <API key>);
<API key>(<API key>, <API key>, <API key>);
/*
* disable boot interrupts on AMD and ATI chipsets
*/
/*
* NOIOAMODE needs to be disabled to disable "boot interrupts". For AMD 8131
* rev. A0 and B0, NOIOAMODE needs to be disabled anyway to fix IO-APIC mode
* (due to an erratum).
*/
#define AMD_813X_MISC 0x40
#define AMD_813X_NOIOAMODE (1<<0)
#define AMD_813X_REV_B1 0x12
#define AMD_813X_REV_B2 0x13
static void <API key>(struct pci_dev *dev)
{
u32 pci_config_dword;
if (noioapicquirk)
return;
if ((dev->revision == AMD_813X_REV_B1) ||
(dev->revision == AMD_813X_REV_B2))
return;
<API key>(dev, AMD_813X_MISC, &pci_config_dword);
pci_config_dword &= ~AMD_813X_NOIOAMODE;
<API key>(dev, AMD_813X_MISC, pci_config_dword);
dev_info(&dev->dev, "disabled boot interrupts on device [%04x:%04x]\n",
dev->vendor, dev->device);
}
<API key>(PCI_VENDOR_ID_AMD, <API key>, <API key>);
<API key>(PCI_VENDOR_ID_AMD, <API key>, <API key>);
<API key>(PCI_VENDOR_ID_AMD, <API key>, <API key>);
<API key>(PCI_VENDOR_ID_AMD, <API key>, <API key>);
#define <API key> 0x56
static void <API key>(struct pci_dev *dev)
{
u16 pci_config_word;
if (noioapicquirk)
return;
<API key>(dev, <API key>, &pci_config_word);
if (!pci_config_word) {
dev_info(&dev->dev, "boot interrupts on device [%04x:%04x] already disabled\n",
dev->vendor, dev->device);
return;
}
<API key>(dev, <API key>, 0);
dev_info(&dev->dev, "disabled boot interrupts on device [%04x:%04x]\n",
dev->vendor, dev->device);
}
<API key>(PCI_VENDOR_ID_AMD, <API key>, <API key>);
<API key>(PCI_VENDOR_ID_AMD, <API key>, <API key>);
#endif /* CONFIG_X86_IO_APIC */
/*
* Toshiba TC86C001 IDE controller reports the standard 8-byte BAR0 size
* but the PIO transfers won't work if BAR0 falls at the odd 8 bytes.
* Re-allocate the region if needed...
*/
static void quirk_tc86c001_ide(struct pci_dev *dev)
{
struct resource *r = &dev->resource[0];
if (r->start & 0x8) {
r->flags |= IORESOURCE_UNSET;
r->start = 0;
r->end = 0xf;
}
}
<API key>(<API key>,
<API key>,
quirk_tc86c001_ide);
/*
* PLX PCI 9050 PCI Target bridge controller has an errata that prevents the
* local configuration registers accessible via BAR0 (memory) or BAR1 (i/o)
* being read correctly if bit 7 of the base address is set.
* The BAR0 or BAR1 region may be disabled (size 0) or enabled (size 128).
* Re-allocate the regions to a 256-byte boundary if necessary.
*/
static void quirk_plx_pci9050(struct pci_dev *dev)
{
unsigned int bar;
/* Fixed in revision 2 (PCI 9052). */
if (dev->revision >= 2)
return;
for (bar = 0; bar <= 1; bar++)
if (pci_resource_len(dev, bar) == 0x80 &&
(pci_resource_start(dev, bar) & 0x80)) {
struct resource *r = &dev->resource[bar];
dev_info(&dev->dev, "Re-allocating PLX PCI 9050 BAR %u to length 256 to avoid bit 7 bug\n",
bar);
r->flags |= IORESOURCE_UNSET;
r->start = 0;
r->end = 0xff;
}
}
<API key>(PCI_VENDOR_ID_PLX, <API key>,
quirk_plx_pci9050);
/*
* The following Meilhaus (vendor ID 0x1402) device IDs (amongst others)
* may be using the PLX PCI 9050: 0x0630, 0x0940, 0x0950, 0x0960, 0x100b,
* 0x1400, 0x140a, 0x140b, 0x14e0, 0x14ea, 0x14eb, 0x1604, 0x1608, 0x160c,
* 0x168f, 0x2000, 0x2600, 0x3000, 0x810a, 0x810b.
*
* Currently, device IDs 0x2000 and 0x2600 are used by the Comedi "me_daq"
* driver.
*/
<API key>(0x1402, 0x2000, quirk_plx_pci9050);
<API key>(0x1402, 0x2600, quirk_plx_pci9050);
static void quirk_netmos(struct pci_dev *dev)
{
unsigned int num_parallel = (dev->subsystem_device & 0xf0) >> 4;
unsigned int num_serial = dev->subsystem_device & 0xf;
/*
* These Netmos parts are multiport serial devices with optional
* parallel ports. Even when parallel ports are present, they
* are identified as class SERIAL, which means the serial driver
* will claim them. To prevent this, mark them as class OTHER.
* These combo devices should be claimed by parport_serial.
*
* The subdevice ID is of the form 0x00PS, where <P> is the number
* of parallel ports and <S> is the number of serial ports.
*/
switch (dev->device) {
case <API key>:
/* Well, this rule doesn't hold for the following 9835 device */
if (dev->subsystem_vendor == PCI_VENDOR_ID_IBM &&
dev->subsystem_device == 0x0299)
return;
case <API key>:
case <API key>:
case <API key>:
case <API key>:
if (num_parallel) {
dev_info(&dev->dev, "Netmos %04x (%u parallel, %u serial); changing class SERIAL to OTHER (use parport_serial)\n",
dev->device, num_parallel, num_serial);
dev->class = (<API key> << 8) |
(dev->class & 0xff);
}
}
}
<API key>(<API key>, PCI_ANY_ID,
<API key>, 8, quirk_netmos);
/*
* Quirk non-zero PCI functions to route VPD access through function 0 for
* devices that share VPD resources between functions. The functions are
* expected to be identical devices.
*/
static void quirk_f0_vpd_link(struct pci_dev *dev)
{
struct pci_dev *f0;
if (!PCI_FUNC(dev->devfn))
return;
f0 = pci_get_slot(dev->bus, PCI_DEVFN(PCI_SLOT(dev->devfn), 0));
if (!f0)
return;
if (f0->vpd && dev->class == f0->class &&
dev->vendor == f0->vendor && dev->device == f0->device)
dev->dev_flags |= <API key>;
pci_dev_put(f0);
}
<API key>(PCI_VENDOR_ID_INTEL, PCI_ANY_ID,
<API key>, 8, quirk_f0_vpd_link);
static void <API key>(struct pci_dev *dev)
{
u16 command, pmcsr;
u8 __iomem *csr;
u8 cmd_hi;
switch (dev->device) {
/* PCI IDs taken from drivers/net/e100.c */
case 0x1029:
case 0x1030 ... 0x1034:
case 0x1038 ... 0x103E:
case 0x1050 ... 0x1057:
case 0x1059:
case 0x1064 ... 0x106B:
case 0x1091 ... 0x1095:
case 0x1209:
case 0x1229:
case 0x2449:
case 0x2459:
case 0x245D:
case 0x27DC:
break;
default:
return;
}
/*
* Some firmware hands off the e100 with interrupts enabled,
* which can cause a flood of interrupts if packets are
* received before the driver attaches to the device. So
* disable all e100 interrupts here. The driver will
* re-enable them when it's ready.
*/
<API key>(dev, PCI_COMMAND, &command);
if (!(command & PCI_COMMAND_MEMORY) || !pci_resource_start(dev, 0))
return;
/*
* Check that the device is in the D0 power state. If it's not,
* there is no point to look any further.
*/
if (dev->pm_cap) {
<API key>(dev, dev->pm_cap + PCI_PM_CTRL, &pmcsr);
if ((pmcsr & <API key>) != PCI_D0)
return;
}
/* Convert from PCI bus to resource space. */
csr = ioremap(pci_resource_start(dev, 0), 8);
if (!csr) {
dev_warn(&dev->dev, "Can't map e100 registers\n");
return;
}
cmd_hi = readb(csr + 3);
if (cmd_hi == 0) {
dev_warn(&dev->dev, "Firmware left e100 interrupts enabled; disabling\n");
writeb(1, csr + 3);
}
iounmap(csr);
}
<API key>(PCI_VENDOR_ID_INTEL, PCI_ANY_ID,
<API key>, 8, <API key>);
/*
* The 82575 and 82598 may experience data corruption issues when transitioning
* out of L0S. To prevent this we need to disable L0S on the pci-e link
*/
static void <API key>(struct pci_dev *dev)
{
dev_info(&dev->dev, "Disabling L0s\n");
<API key>(dev, PCIE_LINK_STATE_L0S);
}
<API key>(PCI_VENDOR_ID_INTEL, 0x10a7, <API key>);
<API key>(PCI_VENDOR_ID_INTEL, 0x10a9, <API key>);
<API key>(PCI_VENDOR_ID_INTEL, 0x10b6, <API key>);
<API key>(PCI_VENDOR_ID_INTEL, 0x10c6, <API key>);
<API key>(PCI_VENDOR_ID_INTEL, 0x10c7, <API key>);
<API key>(PCI_VENDOR_ID_INTEL, 0x10c8, <API key>);
<API key>(PCI_VENDOR_ID_INTEL, 0x10d6, <API key>);
<API key>(PCI_VENDOR_ID_INTEL, 0x10db, <API key>);
<API key>(PCI_VENDOR_ID_INTEL, 0x10dd, <API key>);
<API key>(PCI_VENDOR_ID_INTEL, 0x10e1, <API key>);
<API key>(PCI_VENDOR_ID_INTEL, 0x10ec, <API key>);
<API key>(PCI_VENDOR_ID_INTEL, 0x10f1, <API key>);
<API key>(PCI_VENDOR_ID_INTEL, 0x10f4, <API key>);
<API key>(PCI_VENDOR_ID_INTEL, 0x1508, <API key>);
static void fixup_rev1_53c810(struct pci_dev *dev)
{
u32 class = dev->class;
/*
* rev 1 ncr53c810 chips don't set the class at all which means
* they don't get their resources remapped. Fix that here.
*/
if (class)
return;
dev->class = <API key> << 8;
dev_info(&dev->dev, "NCR 53c810 rev 1 PCI class overridden (%#08x -> %#08x)\n",
class, dev->class);
}
<API key>(PCI_VENDOR_ID_NCR, <API key>, fixup_rev1_53c810);
/* Enable 1k I/O space granularity on the Intel P64H2 */
static void quirk_p64h2_1k_io(struct pci_dev *dev)
{
u16 en1k;
<API key>(dev, 0x40, &en1k);
if (en1k & 0x200) {
dev_info(&dev->dev, "Enable I/O Space to 1KB granularity\n");
dev->io_window_1k = 1;
}
}
<API key>(PCI_VENDOR_ID_INTEL, 0x1460, quirk_p64h2_1k_io);
/* Under some circumstances, AER is not linked with extended capabilities.
* Force it to be linked by setting the corresponding control bit in the
* config space.
*/
static void <API key>(struct pci_dev *dev)
{
uint8_t b;
if (<API key>(dev, 0xf41, &b) == 0) {
if (!(b & 0x20)) {
<API key>(dev, 0xf41, b | 0x20);
dev_info(&dev->dev, "Linking AER extended capability\n");
}
}
}
<API key>(<API key>, <API key>,
<API key>);
<API key>(<API key>, <API key>,
<API key>);
static void <API key>(struct pci_dev *dev)
{
/*
* Disable PCI Bus Parking and PCI Master read caching on CX700
* which causes unspecified timing errors with a VT6212L on the PCI
* bus leading to USB2.0 packet loss.
*
* This quirk is only enabled if a second (on the external PCI bus)
* VT6212L is found -- the CX700 core itself also contains a USB
* host controller with the same PCI ID as the VT6212L.
*/
/* Count VT6212L instances */
struct pci_dev *p = pci_get_device(PCI_VENDOR_ID_VIA,
<API key>, NULL);
uint8_t b;
/* p should contain the first (internal) VT6212L -- see if we have
an external one by searching again */
p = pci_get_device(PCI_VENDOR_ID_VIA, <API key>, p);
if (!p)
return;
pci_dev_put(p);
if (<API key>(dev, 0x76, &b) == 0) {
if (b & 0x40) {
/* Turn off PCI Bus Parking */
<API key>(dev, 0x76, b ^ 0x40);
dev_info(&dev->dev, "Disabling VIA CX700 PCI parking\n");
}
}
if (<API key>(dev, 0x72, &b) == 0) {
if (b != 0) {
/* Turn off PCI Master read caching */
<API key>(dev, 0x72, 0x0);
/* Set PCI Master Bus time-out to "1x16 PCLK" */
<API key>(dev, 0x75, 0x1);
/* Disable "Read FIFO Timer" */
<API key>(dev, 0x77, 0x0);
dev_info(&dev->dev, "Disabling VIA CX700 PCI caching\n");
}
}
}
<API key>(PCI_VENDOR_ID_VIA, 0x324e, <API key>);
/*
* If a device follows the VPD format spec, the PCI core will not read or
* write past the VPD End Tag. But some vendors do not follow the VPD
* format spec, so we can't tell how much data is safe to access. Devices
* may behave unpredictably if we access too much. Blacklist these devices
* so we don't touch VPD at all.
*/
static void quirk_blacklist_vpd(struct pci_dev *dev)
{
if (dev->vpd) {
dev->vpd->len = 0;
dev_warn(&dev->dev, FW_BUG "disabling VPD access (can't determine size of non-standard VPD format)\n");
}
}
<API key>(<API key>, 0x0060, quirk_blacklist_vpd);
<API key>(<API key>, 0x007c, quirk_blacklist_vpd);
<API key>(<API key>, 0x0413, quirk_blacklist_vpd);
<API key>(<API key>, 0x0078, quirk_blacklist_vpd);
<API key>(<API key>, 0x0079, quirk_blacklist_vpd);
<API key>(<API key>, 0x0073, quirk_blacklist_vpd);
<API key>(<API key>, 0x0071, quirk_blacklist_vpd);
<API key>(<API key>, 0x005b, quirk_blacklist_vpd);
<API key>(<API key>, 0x002f, quirk_blacklist_vpd);
<API key>(<API key>, 0x005d, quirk_blacklist_vpd);
<API key>(<API key>, 0x005f, quirk_blacklist_vpd);
<API key>(<API key>, PCI_ANY_ID,
quirk_blacklist_vpd);
static void <API key>(struct pci_dev *dev)
{
/*
* Only disable the VPD capability for 5706, 5706S, 5708,
* 5708S and 5709 rev. A
*/
if ((dev->device == <API key>) ||
(dev->device == <API key>) ||
(dev->device == <API key>) ||
(dev->device == <API key>) ||
((dev->device == <API key>) &&
(dev->revision & 0xf0) == 0x0)) {
if (dev->vpd)
dev->vpd->len = 0x80;
}
}
<API key>(<API key>,
<API key>,
<API key>);
<API key>(<API key>,
<API key>,
<API key>);
<API key>(<API key>,
<API key>,
<API key>);
<API key>(<API key>,
<API key>,
<API key>);
<API key>(<API key>,
<API key>,
<API key>);
<API key>(<API key>,
<API key>,
<API key>);
static void <API key>(struct pci_dev *dev)
{
u32 rev;
<API key>(dev, 0xf4, &rev);
/* Only CAP the MRRS if the device is a 5719 A0 */
if (rev == 0x05719000) {
int readrq = pcie_get_readrq(dev);
if (readrq > 2048)
pcie_set_readrq(dev, 2048);
}
}
<API key>(<API key>,
<API key>,
<API key>);
static void <API key>(struct pci_dev *dev)
{
u8 reg;
if (<API key>(dev, 0xF4, ®) == 0 && !(reg & 0x02)) {
dev_info(&dev->dev, "Enabling MCH 'Overflow' Device\n");
<API key>(dev, 0xF4, reg | 0x02);
}
}
<API key>(PCI_VENDOR_ID_INTEL, <API key>,
<API key>);
<API key>(PCI_VENDOR_ID_INTEL, <API key>,
<API key>);
#ifdef CONFIG_TILEPRO
/*
* The Tilera TILEmpower tilepro platform needs to set the link speed
* to 2.5GT(Giga-Transfers)/s (Gen 1). The default link speed
* setting is 5GT/s (Gen 2). 0x98 is the Link Control2 PCIe
* capability register of the PEX8624 PCIe switch. The switch
* supports link speed auto negotiation, but falsely sets
* the link speed to 5GT/s.
*/
static void quirk_tile_plx_gen1(struct pci_dev *dev)
{
if (tile_plx_gen1) {
<API key>(dev, 0x98, 0x1);
mdelay(50);
}
}
<API key>(PCI_VENDOR_ID_PLX, 0x8624, quirk_tile_plx_gen1);
#endif /* CONFIG_TILEPRO */
#ifdef CONFIG_PCI_MSI
/* Some chipsets do not support MSI. We cannot easily rely on setting
* <API key> in its bus flags because there are actually
* some other buses controlled by the chipset even if Linux is not
* aware of it. Instead of setting the flag on all buses in the
* machine, simply disable MSI globally.
*/
static void <API key>(struct pci_dev *dev)
{
pci_no_msi();
dev_warn(&dev->dev, "MSI quirk detected; MSI disabled\n");
}
<API key>(<API key>, <API key>, <API key>);
<API key>(PCI_VENDOR_ID_ATI, <API key>, <API key>);
<API key>(PCI_VENDOR_ID_ATI, <API key>, <API key>);
<API key>(PCI_VENDOR_ID_VIA, <API key>, <API key>);
<API key>(PCI_VENDOR_ID_VIA, <API key>, <API key>);
<API key>(PCI_VENDOR_ID_VIA, <API key>, <API key>);
<API key>(PCI_VENDOR_ID_VIA, <API key>, <API key>);
<API key>(PCI_VENDOR_ID_SI, 0x0761, <API key>);
/* Disable MSI on chipsets that are known to not support it */
static void quirk_disable_msi(struct pci_dev *dev)
{
if (dev->subordinate) {
dev_warn(&dev->dev, "MSI quirk detected; subordinate MSI disabled\n");
dev->subordinate->bus_flags |= <API key>;
}
}
<API key>(PCI_VENDOR_ID_AMD, <API key>, quirk_disable_msi);
<API key>(PCI_VENDOR_ID_VIA, 0xa238, quirk_disable_msi);
<API key>(PCI_VENDOR_ID_ATI, 0x5a3f, quirk_disable_msi);
/*
* The APC bridge device in AMD 780 family northbridges has some random
* OEM subsystem ID in its vendor ID register (erratum 18), so instead
* we use the possible vendor/device IDs of the host bridge for the
* declared quirk, and search for the APC bridge by slot number.
*/
static void <API key>(struct pci_dev *host_bridge)
{
struct pci_dev *apc_bridge;
apc_bridge = pci_get_slot(host_bridge->bus, PCI_DEVFN(1, 0));
if (apc_bridge) {
if (apc_bridge->device == 0x9602)
quirk_disable_msi(apc_bridge);
pci_dev_put(apc_bridge);
}
}
<API key>(PCI_VENDOR_ID_AMD, 0x9600, <API key>);
<API key>(PCI_VENDOR_ID_AMD, 0x9601, <API key>);
/* Go through the list of Hypertransport capabilities and
* return 1 if a HT MSI capability is found and enabled */
static int msi_ht_cap_enabled(struct pci_dev *dev)
{
int pos, ttl = PCI_FIND_CAP_TTL;
pos = <API key>(dev, <API key>);
while (pos && ttl
u8 flags;
if (<API key>(dev, pos + HT_MSI_FLAGS,
&flags) == 0) {
dev_info(&dev->dev, "Found %s HT MSI Mapping\n",
flags & HT_MSI_FLAGS_ENABLE ?
"enabled" : "disabled");
return (flags & HT_MSI_FLAGS_ENABLE) != 0;
}
pos = <API key>(dev, pos,
<API key>);
}
return 0;
}
/* Check the hypertransport MSI mapping to know whether MSI is enabled or not */
static void quirk_msi_ht_cap(struct pci_dev *dev)
{
if (dev->subordinate && !msi_ht_cap_enabled(dev)) {
dev_warn(&dev->dev, "MSI quirk detected; subordinate MSI disabled\n");
dev->subordinate->bus_flags |= <API key>;
}
}
<API key>(<API key>, <API key>,
quirk_msi_ht_cap);
/* The nVidia CK804 chipset may have 2 HT MSI mappings.
* MSI are supported if the MSI capability set in any of these mappings.
*/
static void <API key>(struct pci_dev *dev)
{
struct pci_dev *pdev;
if (!dev->subordinate)
return;
/* check HT MSI cap on this chipset and the root one.
* a single one having MSI is enough to be sure that MSI are supported.
*/
pdev = pci_get_slot(dev->bus, 0);
if (!pdev)
return;
if (!msi_ht_cap_enabled(dev) && !msi_ht_cap_enabled(pdev)) {
dev_warn(&dev->dev, "MSI quirk detected; subordinate MSI disabled\n");
dev->subordinate->bus_flags |= <API key>;
}
pci_dev_put(pdev);
}
<API key>(<API key>, <API key>,
<API key>);
/* Force enable MSI mapping capability on HT bridges */
static void <API key>(struct pci_dev *dev)
{
int pos, ttl = PCI_FIND_CAP_TTL;
pos = <API key>(dev, <API key>);
while (pos && ttl
u8 flags;
if (<API key>(dev, pos + HT_MSI_FLAGS,
&flags) == 0) {
dev_info(&dev->dev, "Enabling HT MSI Mapping\n");
<API key>(dev, pos + HT_MSI_FLAGS,
flags | HT_MSI_FLAGS_ENABLE);
}
pos = <API key>(dev, pos,
<API key>);
}
}
<API key>(<API key>,
<API key>,
<API key>);
<API key>(PCI_VENDOR_ID_AMD, <API key>,
<API key>);
/* The P5N32-SLI motherboards from Asus have a problem with msi
* for the MCP55 NIC. It is not yet determined whether the msi problem
* also affects other devices. As for now, turn off msi for this device.
*/
static void nvenet_msi_disable(struct pci_dev *dev)
{
const char *board_name = dmi_get_system_info(DMI_BOARD_NAME);
if (board_name &&
(strstr(board_name, "P5N32-SLI PREMIUM") ||
strstr(board_name, "P5N32-E SLI"))) {
dev_info(&dev->dev, "Disabling msi for MCP55 NIC on P5N32-SLI\n");
dev->no_msi = 1;
}
}
<API key>(<API key>,
<API key>,
nvenet_msi_disable);
/*
* Some versions of the MCP55 bridge from Nvidia have a legacy IRQ routing
* config register. This register controls the routing of legacy
* interrupts from devices that route through the MCP55. If this register
* is misprogrammed, interrupts are only sent to the BSP, unlike
* conventional systems where the IRQ is broadcast to all online CPUs. Not
* having this register set properly prevents kdump from booting up
* properly, so let's make sure that we have it set correctly.
* Note that this is an undocumented register.
*/
static void <API key>(struct pci_dev *dev)
{
u32 cfg;
if (!pci_find_capability(dev, PCI_CAP_ID_HT))
return;
<API key>(dev, 0x74, &cfg);
if (cfg & ((1 << 2) | (1 << 15))) {
printk(KERN_INFO "Rewriting irq routing register on MCP55\n");
cfg &= ~((1 << 2) | (1 << 15));
<API key>(dev, 0x74, cfg);
}
}
<API key>(<API key>,
<API key>,
<API key>);
<API key>(<API key>,
<API key>,
<API key>);
static int <API key>(struct pci_dev *dev)
{
int pos, ttl = PCI_FIND_CAP_TTL;
int found = 0;
/* check if there is HT MSI cap or enabled on this device */
pos = <API key>(dev, <API key>);
while (pos && ttl
u8 flags;
if (found < 1)
found = 1;
if (<API key>(dev, pos + HT_MSI_FLAGS,
&flags) == 0) {
if (flags & HT_MSI_FLAGS_ENABLE) {
if (found < 2) {
found = 2;
break;
}
}
}
pos = <API key>(dev, pos,
<API key>);
}
return found;
}
static int <API key>(struct pci_dev *host_bridge)
{
struct pci_dev *dev;
int pos;
int i, dev_no;
int found = 0;
dev_no = host_bridge->devfn >> 3;
for (i = dev_no + 1; i < 0x20; i++) {
dev = pci_get_slot(host_bridge->bus, PCI_DEVFN(i, 0));
if (!dev)
continue;
/* found next host bridge ?*/
pos = <API key>(dev, HT_CAPTYPE_SLAVE);
if (pos != 0) {
pci_dev_put(dev);
break;
}
if (<API key>(dev)) {
found = 1;
pci_dev_put(dev);
break;
}
pci_dev_put(dev);
}
return found;
}
#define <API key> 4 /* link control */
#define <API key> 8 /* link control to */
static int is_end_of_ht_chain(struct pci_dev *dev)
{
int pos, ctrl_off;
int end = 0;
u16 flags, ctrl;
pos = <API key>(dev, HT_CAPTYPE_SLAVE);
if (!pos)
goto out;
<API key>(dev, pos + PCI_CAP_FLAGS, &flags);
ctrl_off = ((flags >> 10) & 1) ?
<API key> : <API key>;
<API key>(dev, pos + ctrl_off, &ctrl);
if (ctrl & (1 << 6))
end = 1;
out:
return end;
}
static void <API key>(struct pci_dev *dev)
{
struct pci_dev *host_bridge;
int pos;
int i, dev_no;
int found = 0;
dev_no = dev->devfn >> 3;
for (i = dev_no; i >= 0; i
host_bridge = pci_get_slot(dev->bus, PCI_DEVFN(i, 0));
if (!host_bridge)
continue;
pos = <API key>(host_bridge, HT_CAPTYPE_SLAVE);
if (pos != 0) {
found = 1;
break;
}
pci_dev_put(host_bridge);
}
if (!found)
return;
/* don't enable end_device/host_bridge with leaf directly here */
if (host_bridge == dev && is_end_of_ht_chain(host_bridge) &&
<API key>(host_bridge))
goto out;
/* root did that ! */
if (msi_ht_cap_enabled(host_bridge))
goto out;
<API key>(dev);
out:
pci_dev_put(host_bridge);
}
static void <API key>(struct pci_dev *dev)
{
int pos, ttl = PCI_FIND_CAP_TTL;
pos = <API key>(dev, <API key>);
while (pos && ttl
u8 flags;
if (<API key>(dev, pos + HT_MSI_FLAGS,
&flags) == 0) {
dev_info(&dev->dev, "Disabling HT MSI Mapping\n");
<API key>(dev, pos + HT_MSI_FLAGS,
flags & ~HT_MSI_FLAGS_ENABLE);
}
pos = <API key>(dev, pos,
<API key>);
}
}
static void <API key>(struct pci_dev *dev, int all)
{
struct pci_dev *host_bridge;
int pos;
int found;
if (!pci_msi_enabled())
return;
/* check if there is HT MSI cap or enabled on this device */
found = <API key>(dev);
/* no HT MSI CAP */
if (found == 0)
return;
/*
* HT MSI mapping should be disabled on devices that are below
* a non-Hypertransport host bridge. Locate the host bridge...
*/
host_bridge = <API key>(0, PCI_DEVFN(0, 0));
if (host_bridge == NULL) {
dev_warn(&dev->dev, "nv_msi_ht_cap_quirk didn't locate host bridge\n");
return;
}
pos = <API key>(host_bridge, HT_CAPTYPE_SLAVE);
if (pos != 0) {
/* Host bridge is to HT */
if (found == 1) {
/* it is not enabled, try to enable it */
if (all)
<API key>(dev);
else
<API key>(dev);
}
goto out;
}
/* HT MSI is not enabled */
if (found == 1)
goto out;
/* Host bridge is not to HT, disable HT MSI mapping on this device */
<API key>(dev);
out:
pci_dev_put(host_bridge);
}
static void <API key>(struct pci_dev *dev)
{
return <API key>(dev, 1);
}
static void <API key>(struct pci_dev *dev)
{
return <API key>(dev, 0);
}
<API key>(<API key>, PCI_ANY_ID, <API key>);
<API key>(<API key>, PCI_ANY_ID, <API key>);
<API key>(PCI_VENDOR_ID_AL, PCI_ANY_ID, <API key>);
<API key>(PCI_VENDOR_ID_AL, PCI_ANY_ID, <API key>);
static void <API key>(struct pci_dev *dev)
{
dev->dev_flags |= <API key>;
}
static void <API key>(struct pci_dev *dev)
{
struct pci_dev *p;
/* SB700 MSI issue will be fixed at HW level from revision A21,
* we need check PCI REVISION ID of SMBus controller to get SB700
* revision.
*/
p = pci_get_device(PCI_VENDOR_ID_ATI, <API key>,
NULL);
if (!p)
return;
if ((p->revision < 0x3B) && (p->revision >= 0x30))
dev->dev_flags |= <API key>;
pci_dev_put(p);
}
static void <API key>(struct pci_dev *dev)
{
/* AR816X/AR817X/E210X MSI is fixed at HW level from revision 0x18 */
if (dev->revision < 0x18) {
dev_info(&dev->dev, "set <API key> flag\n");
dev->dev_flags |= <API key>;
}
}
<API key>(<API key>,
<API key>,
<API key>);
<API key>(<API key>,
<API key>,
<API key>);
<API key>(<API key>,
<API key>,
<API key>);
<API key>(<API key>,
<API key>,
<API key>);
<API key>(<API key>,
<API key>,
<API key>);
<API key>(<API key>,
<API key>,
<API key>);
<API key>(PCI_VENDOR_ID_ATI, 0x4390,
<API key>);
<API key>(PCI_VENDOR_ID_ATI, 0x4391,
<API key>);
<API key>(PCI_VENDOR_ID_ATI, 0x4392,
<API key>);
<API key>(PCI_VENDOR_ID_ATI, 0x4393,
<API key>);
<API key>(PCI_VENDOR_ID_ATI, 0x4394,
<API key>);
<API key>(PCI_VENDOR_ID_ATI, 0x4373,
<API key>);
<API key>(PCI_VENDOR_ID_ATI, 0x4374,
<API key>);
<API key>(PCI_VENDOR_ID_ATI, 0x4375,
<API key>);
<API key>(<API key>, 0x1062,
<API key>);
<API key>(<API key>, 0x1063,
<API key>);
<API key>(<API key>, 0x2060,
<API key>);
<API key>(<API key>, 0x2062,
<API key>);
<API key>(<API key>, 0x1073,
<API key>);
<API key>(<API key>, 0x1083,
<API key>);
<API key>(<API key>, 0x1090,
<API key>);
<API key>(<API key>, 0x1091,
<API key>);
<API key>(<API key>, 0x10a0,
<API key>);
<API key>(<API key>, 0x10a1,
<API key>);
<API key>(<API key>, 0xe091,
<API key>);
#endif /* CONFIG_PCI_MSI */
/* Allow manual resource allocation for PCI hotplug bridges
* via pci=hpmemsize=nnM and pci=hpiosize=nnM parameters. For
* some PCI-PCI hotplug bridges, like PLX 6254 (former HINT HB6),
* kernel fails to allocate resources when hotplug device is
* inserted and PCI bus is rescanned.
*/
static void <API key>(struct pci_dev *dev)
{
dev->is_hotplug_bridge = 1;
}
<API key>(PCI_VENDOR_ID_HINT, 0x0020, <API key>);
/*
* This is a quirk for the Ricoh MMC controller found as a part of
* some mulifunction chips.
* This is very similar and based on the ricoh_mmc driver written by
* Philip Langdale. Thank you for these magic sequences.
*
* These chips implement the four main memory card controllers (SD, MMC, MS, xD)
* and one or both of cardbus or firewire.
*
* It happens that they implement SD and MMC
* support as separate controllers (and PCI functions). The linux SDHCI
* driver supports MMC cards but the chip detects MMC cards in hardware
* and directs them to the MMC controller - so the SDHCI driver never sees
* them.
*
* To get around this, we must disable the useless MMC controller.
* At that point, the SDHCI controller will start seeing them
* It seems to be the case that the relevant PCI registers to deactivate the
* MMC controller live on PCI function 0, which might be the cardbus controller
* or the firewire controller, depending on the particular chip in question
*
* This has to be done early, because as soon as we disable the MMC controller
* other pci functions shift up one level, e.g. function #2 becomes function
* #1, and this will confuse the pci core.
*/
#ifdef <API key>
static void <API key>(struct pci_dev *dev)
{
/* disable via cardbus interface */
u8 write_enable;
u8 write_target;
u8 disable;
/* disable must be done via function #0 */
if (PCI_FUNC(dev->devfn))
return;
<API key>(dev, 0xB7, &disable);
if (disable & 0x02)
return;
<API key>(dev, 0x8E, &write_enable);
<API key>(dev, 0x8E, 0xAA);
<API key>(dev, 0x8D, &write_target);
<API key>(dev, 0x8D, 0xB7);
<API key>(dev, 0xB7, disable | 0x02);
<API key>(dev, 0x8E, write_enable);
<API key>(dev, 0x8D, write_target);
dev_notice(&dev->dev, "proprietary Ricoh MMC controller disabled (via cardbus function)\n");
dev_notice(&dev->dev, "MMC cards are now supported by standard SDHCI controller\n");
}
<API key>(PCI_VENDOR_ID_RICOH, <API key>, <API key>);
<API key>(PCI_VENDOR_ID_RICOH, <API key>, <API key>);
static void <API key>(struct pci_dev *dev)
{
/* disable via firewire interface */
u8 write_enable;
u8 disable;
/* disable must be done via function #0 */
if (PCI_FUNC(dev->devfn))
return;
/*
* RICOH 0xe822 and 0xe823 SD/MMC card readers fail to recognize
* certain types of SD/MMC cards. Lowering the SD base
* clock frequency from 200Mhz to 50Mhz fixes this issue.
*
* 0x150 - SD2.0 mode enable for changing base clock
* frequency to 50Mhz
* 0xe1 - Base clock frequency
* 0x32 - 50Mhz new clock frequency
* 0xf9 - Key register for 0x150
* 0xfc - key register for 0xe1
*/
if (dev->device == <API key> ||
dev->device == <API key>) {
<API key>(dev, 0xf9, 0xfc);
<API key>(dev, 0x150, 0x10);
<API key>(dev, 0xf9, 0x00);
<API key>(dev, 0xfc, 0x01);
<API key>(dev, 0xe1, 0x32);
<API key>(dev, 0xfc, 0x00);
dev_notice(&dev->dev, "MMC controller base frequency changed to 50Mhz.\n");
}
<API key>(dev, 0xCB, &disable);
if (disable & 0x02)
return;
<API key>(dev, 0xCA, &write_enable);
<API key>(dev, 0xCA, 0x57);
<API key>(dev, 0xCB, disable | 0x02);
<API key>(dev, 0xCA, write_enable);
dev_notice(&dev->dev, "proprietary Ricoh MMC controller disabled (via firewire function)\n");
dev_notice(&dev->dev, "MMC cards are now supported by standard SDHCI controller\n");
}
<API key>(PCI_VENDOR_ID_RICOH, <API key>, <API key>);
<API key>(PCI_VENDOR_ID_RICOH, <API key>, <API key>);
<API key>(PCI_VENDOR_ID_RICOH, <API key>, <API key>);
<API key>(PCI_VENDOR_ID_RICOH, <API key>, <API key>);
<API key>(PCI_VENDOR_ID_RICOH, <API key>, <API key>);
<API key>(PCI_VENDOR_ID_RICOH, <API key>, <API key>);
#endif /*<API key>*/
#ifdef CONFIG_DMAR_TABLE
#define VTUNCERRMSK_REG 0x1ac
#define VTD_MSK_SPEC_ERRORS (1 << 31)
/*
* This is a quirk for masking vt-d spec defined errors to platform error
* handling logic. With out this, platforms using Intel 7500, 5500 chipsets
* (and the derivative chipsets like X58 etc) seem to generate NMI/SMI (based
* on the RAS config settings of the platform) when a vt-d fault happens.
* The resulting SMI caused the system to hang.
*
* VT-d spec related errors are already handled by the VT-d OS code, so no
* need to report the same error through other channels.
*/
static void <API key>(struct pci_dev *dev)
{
u32 word;
<API key>(dev, VTUNCERRMSK_REG, &word);
<API key>(dev, VTUNCERRMSK_REG, word | VTD_MSK_SPEC_ERRORS);
}
<API key>(PCI_VENDOR_ID_INTEL, 0x342e, <API key>);
<API key>(PCI_VENDOR_ID_INTEL, 0x3c28, <API key>);
#endif
static void fixup_ti816x_class(struct pci_dev *dev)
{
u32 class = dev->class;
/* TI 816x devices do not have class code set when in PCIe boot mode */
dev->class = <API key> << 8;
dev_info(&dev->dev, "PCI class overridden (%#08x -> %#08x)\n",
class, dev->class);
}
<API key>(PCI_VENDOR_ID_TI, 0xb800,
<API key>, 8, fixup_ti816x_class);
/* Some PCIe devices do not work reliably with the claimed maximum
* payload size supported.
*/
static void fixup_mpss_256(struct pci_dev *dev)
{
dev->pcie_mpss = 1; /* 256 bytes */
}
<API key>(<API key>,
<API key>, fixup_mpss_256);
<API key>(<API key>,
<API key>, fixup_mpss_256);
<API key>(<API key>,
<API key>, fixup_mpss_256);
/* Intel 5000 and 5100 Memory controllers have an errata with read completion
* coalescing (which is enabled by default on some BIOSes) and MPS of 256B.
* Since there is no way of knowing what the PCIE MPS on each fabric will be
* until all of the devices are discovered and buses walked, read completion
* coalescing must be disabled. Unfortunately, it cannot be re-enabled because
* it is possible to hotplug a device with MPS of 256B.
*/
static void <API key>(struct pci_dev *dev)
{
int err;
u16 rcc;
if (pcie_bus_config == PCIE_BUS_TUNE_OFF ||
pcie_bus_config == PCIE_BUS_DEFAULT)
return;
/* Intel errata specifies bits to change but does not say what they are.
* Keeping them magical until such time as the registers and values can
* be explained.
*/
err = <API key>(dev, 0x48, &rcc);
if (err) {
dev_err(&dev->dev, "Error attempting to read the read completion coalescing register\n");
return;
}
if (!(rcc & (1 << 10)))
return;
rcc &= ~(1 << 10);
err = <API key>(dev, 0x48, rcc);
if (err) {
dev_err(&dev->dev, "Error attempting to write the read completion coalescing register\n");
return;
}
pr_info_once("Read completion coalescing disabled due to hardware errata relating to 256B MPS\n");
}
/* Intel 5000 series memory controllers and ports 2-7 */
<API key>(PCI_VENDOR_ID_INTEL, 0x25c0, <API key>);
<API key>(PCI_VENDOR_ID_INTEL, 0x25d0, <API key>);
<API key>(PCI_VENDOR_ID_INTEL, 0x25d4, <API key>);
<API key>(PCI_VENDOR_ID_INTEL, 0x25d8, <API key>);
<API key>(PCI_VENDOR_ID_INTEL, 0x25e2, <API key>);
<API key>(PCI_VENDOR_ID_INTEL, 0x25e3, <API key>);
<API key>(PCI_VENDOR_ID_INTEL, 0x25e4, <API key>);
<API key>(PCI_VENDOR_ID_INTEL, 0x25e5, <API key>);
<API key>(PCI_VENDOR_ID_INTEL, 0x25e6, <API key>);
<API key>(PCI_VENDOR_ID_INTEL, 0x25e7, <API key>);
<API key>(PCI_VENDOR_ID_INTEL, 0x25f7, <API key>);
<API key>(PCI_VENDOR_ID_INTEL, 0x25f8, <API key>);
<API key>(PCI_VENDOR_ID_INTEL, 0x25f9, <API key>);
<API key>(PCI_VENDOR_ID_INTEL, 0x25fa, <API key>);
/* Intel 5100 series memory controllers and ports 2-7 */
<API key>(PCI_VENDOR_ID_INTEL, 0x65c0, <API key>);
<API key>(PCI_VENDOR_ID_INTEL, 0x65e2, <API key>);
<API key>(PCI_VENDOR_ID_INTEL, 0x65e3, <API key>);
<API key>(PCI_VENDOR_ID_INTEL, 0x65e4, <API key>);
<API key>(PCI_VENDOR_ID_INTEL, 0x65e5, <API key>);
<API key>(PCI_VENDOR_ID_INTEL, 0x65e6, <API key>);
<API key>(PCI_VENDOR_ID_INTEL, 0x65e7, <API key>);
<API key>(PCI_VENDOR_ID_INTEL, 0x65f7, <API key>);
<API key>(PCI_VENDOR_ID_INTEL, 0x65f8, <API key>);
<API key>(PCI_VENDOR_ID_INTEL, 0x65f9, <API key>);
<API key>(PCI_VENDOR_ID_INTEL, 0x65fa, <API key>);
/*
* Ivytown NTB BAR sizes are misreported by the hardware due to an erratum. To
* work around this, query the size it should be configured to by the device and
* modify the resource end to correspond to this new size.
*/
static void quirk_intel_ntb(struct pci_dev *dev)
{
int rc;
u8 val;
rc = <API key>(dev, 0x00D0, &val);
if (rc)
return;
dev->resource[2].end = dev->resource[2].start + ((u64) 1 << val) - 1;
rc = <API key>(dev, 0x00D1, &val);
if (rc)
return;
dev->resource[4].end = dev->resource[4].start + ((u64) 1 << val) - 1;
}
<API key>(PCI_VENDOR_ID_INTEL, 0x0e08, quirk_intel_ntb);
<API key>(PCI_VENDOR_ID_INTEL, 0x0e0d, quirk_intel_ntb);
static ktime_t fixup_debug_start(struct pci_dev *dev,
void (*fn)(struct pci_dev *dev))
{
ktime_t calltime = 0;
dev_dbg(&dev->dev, "calling %pF\n", fn);
if (initcall_debug) {
pr_debug("calling %pF @ %i for %s\n",
fn, task_pid_nr(current), dev_name(&dev->dev));
calltime = ktime_get();
}
return calltime;
}
static void fixup_debug_report(struct pci_dev *dev, ktime_t calltime,
void (*fn)(struct pci_dev *dev))
{
ktime_t delta, rettime;
unsigned long long duration;
if (initcall_debug) {
rettime = ktime_get();
delta = ktime_sub(rettime, calltime);
duration = (unsigned long long) ktime_to_ns(delta) >> 10;
pr_debug("pci fixup %pF returned after %lld usecs for %s\n",
fn, duration, dev_name(&dev->dev));
}
}
/*
* Some BIOS implementations leave the Intel GPU interrupts enabled,
* even though no one is handling them (f.e. i915 driver is never loaded).
* Additionally the interrupt destination is not set up properly
* and the interrupt ends up -somewhere-.
*
* These spurious interrupts are "sticky" and the kernel disables
* the (shared) interrupt line after 100.000+ generated interrupts.
*
* Fix it by disabling the still enabled interrupts.
* This resolves crashes often seen on monitor unplug.
*/
#define I915_DEIER_REG 0x4400c
static void disable_igfx_irq(struct pci_dev *dev)
{
void __iomem *regs = pci_iomap(dev, 0, 0);
if (regs == NULL) {
dev_warn(&dev->dev, "igfx quirk: Can't iomap PCI device\n");
return;
}
/* Check if any interrupt line is still enabled */
if (readl(regs + I915_DEIER_REG) != 0) {
dev_warn(&dev->dev, "BIOS left Intel GPU interrupts enabled; disabling\n");
writel(0, regs + I915_DEIER_REG);
}
pci_iounmap(dev, regs);
}
<API key>(PCI_VENDOR_ID_INTEL, 0x0102, disable_igfx_irq);
<API key>(PCI_VENDOR_ID_INTEL, 0x010a, disable_igfx_irq);
<API key>(PCI_VENDOR_ID_INTEL, 0x0152, disable_igfx_irq);
/*
* PCI devices which are on Intel chips can skip the 10ms delay
* before entering D3 mode.
*/
static void <API key>(struct pci_dev *dev)
{
dev->d3_delay = 0;
}
<API key>(PCI_VENDOR_ID_INTEL, 0x0c00, <API key>);
<API key>(PCI_VENDOR_ID_INTEL, 0x0412, <API key>);
<API key>(PCI_VENDOR_ID_INTEL, 0x0c0c, <API key>);
<API key>(PCI_VENDOR_ID_INTEL, 0x8c31, <API key>);
<API key>(PCI_VENDOR_ID_INTEL, 0x8c3a, <API key>);
<API key>(PCI_VENDOR_ID_INTEL, 0x8c3d, <API key>);
<API key>(PCI_VENDOR_ID_INTEL, 0x8c2d, <API key>);
<API key>(PCI_VENDOR_ID_INTEL, 0x8c20, <API key>);
<API key>(PCI_VENDOR_ID_INTEL, 0x8c18, <API key>);
<API key>(PCI_VENDOR_ID_INTEL, 0x8c1c, <API key>);
<API key>(PCI_VENDOR_ID_INTEL, 0x8c26, <API key>);
<API key>(PCI_VENDOR_ID_INTEL, 0x8c4e, <API key>);
<API key>(PCI_VENDOR_ID_INTEL, 0x8c02, <API key>);
<API key>(PCI_VENDOR_ID_INTEL, 0x8c22, <API key>);
/* Intel Cherrytrail devices do not need 10ms d3_delay */
<API key>(PCI_VENDOR_ID_INTEL, 0x2280, <API key>);
<API key>(PCI_VENDOR_ID_INTEL, 0x22b0, <API key>);
<API key>(PCI_VENDOR_ID_INTEL, 0x22b8, <API key>);
<API key>(PCI_VENDOR_ID_INTEL, 0x22d8, <API key>);
<API key>(PCI_VENDOR_ID_INTEL, 0x22dc, <API key>);
<API key>(PCI_VENDOR_ID_INTEL, 0x22b5, <API key>);
<API key>(PCI_VENDOR_ID_INTEL, 0x22b7, <API key>);
<API key>(PCI_VENDOR_ID_INTEL, 0x2298, <API key>);
<API key>(PCI_VENDOR_ID_INTEL, 0x229c, <API key>);
/*
* Some devices may pass our check in <API key>() if
* <API key> works though they actually do not properly
* support this feature.
*/
static void <API key>(struct pci_dev *dev)
{
dev->broken_intx_masking = 1;
}
<API key>(<API key>, 0x0030,
<API key>);
<API key>(0x1814, 0x0601, /* Ralink RT2800 802.11n PCI */
<API key>);
/*
* Realtek RTL8169 PCI Gigabit Ethernet Controller (rev 10)
* Subsystem: Realtek RTL8169/8110 Family PCI Gigabit Ethernet NIC
*
* RTL8110SC - Fails under PCI device assignment using DisINTx masking.
*/
<API key>(<API key>, 0x8169,
<API key>);
/*
* Intel i40e (XL710/X710) 10/20/40GbE NICs all have broken INTx masking,
* DisINTx can be set but the interrupt status bit is non-functional.
*/
<API key>(PCI_VENDOR_ID_INTEL, 0x1572,
<API key>);
<API key>(PCI_VENDOR_ID_INTEL, 0x1574,
<API key>);
<API key>(PCI_VENDOR_ID_INTEL, 0x1580,
<API key>);
<API key>(PCI_VENDOR_ID_INTEL, 0x1581,
<API key>);
<API key>(PCI_VENDOR_ID_INTEL, 0x1583,
<API key>);
<API key>(PCI_VENDOR_ID_INTEL, 0x1584,
<API key>);
<API key>(PCI_VENDOR_ID_INTEL, 0x1585,
<API key>);
<API key>(PCI_VENDOR_ID_INTEL, 0x1586,
<API key>);
<API key>(PCI_VENDOR_ID_INTEL, 0x1587,
<API key>);
<API key>(PCI_VENDOR_ID_INTEL, 0x1588,
<API key>);
<API key>(PCI_VENDOR_ID_INTEL, 0x1589,
<API key>);
<API key>(PCI_VENDOR_ID_INTEL, 0x37d0,
<API key>);
<API key>(PCI_VENDOR_ID_INTEL, 0x37d1,
<API key>);
<API key>(PCI_VENDOR_ID_INTEL, 0x37d2,
<API key>);
static u16 <API key>[] = {
<API key>,
<API key>,
<API key>,
<API key>,
<API key>,
<API key>,
<API key>,
<API key>,
<API key>,
<API key>,
<API key>,
<API key>,
<API key>,
<API key>,
};
#define <API key> 99
#define <API key> 14
/*
* Check ConnectX-4/LX FW version to see if it supports legacy interrupts.
* If so, don't mark it as broken.
* FW minor > 99 means older FW version format and no INTx masking support.
* FW minor < 14 means new FW version format and no INTx masking support.
*/
static void <API key>(struct pci_dev *pdev)
{
__be32 __iomem *fw_ver;
u16 fw_major;
u16 fw_minor;
u16 fw_subminor;
u32 fw_maj_min;
u32 fw_sub_min;
int i;
for (i = 0; i < ARRAY_SIZE(<API key>); i++) {
if (pdev->device == <API key>[i]) {
pdev->broken_intx_masking = 1;
return;
}
}
/* Getting here means Connect-IB cards and up. Connect-IB has no INTx
* support so shouldn't be checked further
*/
if (pdev->device == <API key>)
return;
if (pdev->device != <API key> &&
pdev->device != <API key>)
return;
/* For ConnectX-4 and ConnectX-4LX, need to check FW support */
if (<API key>(pdev)) {
dev_warn(&pdev->dev, "Can't enable device memory\n");
return;
}
fw_ver = ioremap(pci_resource_start(pdev, 0), 4);
if (!fw_ver) {
dev_warn(&pdev->dev, "Can't map ConnectX-4 initialization segment\n");
goto out;
}
/* Reading from resource space should be 32b aligned */
fw_maj_min = ioread32be(fw_ver);
fw_sub_min = ioread32be(fw_ver + 1);
fw_major = fw_maj_min & 0xffff;
fw_minor = fw_maj_min >> 16;
fw_subminor = fw_sub_min & 0xffff;
if (fw_minor > <API key> ||
fw_minor < <API key>) {
dev_warn(&pdev->dev, "ConnectX-4: FW %u.%u.%u doesn't support INTx masking, disabling. Please upgrade FW to %d.14.1100 and up for INTx support\n",
fw_major, fw_minor, fw_subminor, pdev->device ==
<API key> ? 12 : 14);
pdev->broken_intx_masking = 1;
}
iounmap(fw_ver);
out:
pci_disable_device(pdev);
}
<API key>(<API key>, PCI_ANY_ID,
<API key>);
static void quirk_no_bus_reset(struct pci_dev *dev)
{
dev->dev_flags |= <API key>;
}
<API key>(<API key>, 0x0030, quirk_no_bus_reset);
<API key>(<API key>, 0x0032, quirk_no_bus_reset);
<API key>(<API key>, 0x003c, quirk_no_bus_reset);
<API key>(<API key>, 0x0033, quirk_no_bus_reset);
static void quirk_no_pm_reset(struct pci_dev *dev)
{
/*
* We can't do a bus reset on root bus devices, but an ineffective
* PM reset may be better than nothing.
*/
if (!pci_is_root_bus(dev->bus))
dev->dev_flags |= <API key>;
}
/*
* Some AMD/ATI GPUS (HD8570 - Oland) report that a D3hot->D0 transition
* causes a reset (i.e., they advertise NoSoftRst-). This transition seems
* to have no effect on the device: it retains the framebuffer contents and
* monitor sync. Advertising this support makes other layers, like VFIO,
* assume pci_reset_function() is viable for this device. Mark it as
* unavailable to skip it when testing reset methods.
*/
<API key>(PCI_VENDOR_ID_ATI, PCI_ANY_ID,
<API key>, 8, quirk_no_pm_reset);
/*
* Thunderbolt controllers with broken MSI hotplug signaling:
* Entire 1st generation (Light Ridge, Eagle Ridge, Light Peak) and part
* of the 2nd generation (Cactus Ridge 4C up to revision 1, Port Ridge).
*/
static void <API key>(struct pci_dev *pdev)
{
if (pdev->is_hotplug_bridge &&
(pdev->device != <API key> ||
pdev->revision <= 1))
pdev->no_msi = 1;
}
<API key>(PCI_VENDOR_ID_INTEL, <API key>,
<API key>);
<API key>(PCI_VENDOR_ID_INTEL, <API key>,
<API key>);
<API key>(PCI_VENDOR_ID_INTEL, <API key>,
<API key>);
<API key>(PCI_VENDOR_ID_INTEL, <API key>,
<API key>);
<API key>(PCI_VENDOR_ID_INTEL, <API key>,
<API key>);
static void <API key>(struct pci_dev *dev)
{
pci_set_vpd_size(dev, 8192);
}
<API key>(<API key>, 0x20, <API key>);
<API key>(<API key>, 0x21, <API key>);
<API key>(<API key>, 0x22, <API key>);
<API key>(<API key>, 0x23, <API key>);
<API key>(<API key>, 0x24, <API key>);
<API key>(<API key>, 0x25, <API key>);
<API key>(<API key>, 0x26, <API key>);
<API key>(<API key>, 0x30, <API key>);
<API key>(<API key>, 0x31, <API key>);
<API key>(<API key>, 0x32, <API key>);
<API key>(<API key>, 0x35, <API key>);
<API key>(<API key>, 0x36, <API key>);
<API key>(<API key>, 0x37, <API key>);
#ifdef CONFIG_ACPI
/*
* Apple: Shutdown Cactus Ridge Thunderbolt controller.
*
* On Apple hardware the Cactus Ridge Thunderbolt controller needs to be
* shutdown before suspend. Otherwise the native host interface (NHI) will not
* be present after resume if a device was plugged in before suspend.
*
* The thunderbolt controller consists of a pcie switch with downstream
* bridges leading to the NHI and to the tunnel pci bridges.
*
* This quirk cuts power to the whole chip. Therefore we have to apply it
* during suspend_noirq of the upstream bridge.
*
* Power is automagically restored before resume. No action is needed.
*/
static void <API key>(struct pci_dev *dev)
{
acpi_handle bridge, SXIO, SXFP, SXLV;
if (!dmi_match(DMI_BOARD_VENDOR, "Apple Inc."))
return;
if (pci_pcie_type(dev) != <API key>)
return;
bridge = ACPI_HANDLE(&dev->dev);
if (!bridge)
return;
/*
* SXIO and SXLV are present only on machines requiring this quirk.
* TB bridges in external devices might have the same device id as those
* on the host, but they will not have the associated ACPI methods. This
* implicitly checks that we are at the right bridge.
*/
if (ACPI_FAILURE(acpi_get_handle(bridge, "DSB0.NHI0.SXIO", &SXIO))
|| ACPI_FAILURE(acpi_get_handle(bridge, "DSB0.NHI0.SXFP", &SXFP))
|| ACPI_FAILURE(acpi_get_handle(bridge, "DSB0.NHI0.SXLV", &SXLV)))
return;
dev_info(&dev->dev, "quirk: cutting power to thunderbolt controller...\n");
/* magic sequence */
<API key>(SXIO, NULL, 1);
<API key>(SXFP, NULL, 0);
msleep(300);
<API key>(SXLV, NULL, 0);
<API key>(SXIO, NULL, 0);
<API key>(SXLV, NULL, 0);
}
<API key>(PCI_VENDOR_ID_INTEL,
<API key>,
<API key>);
/*
* Apple: Wait for the thunderbolt controller to reestablish pci tunnels.
*
* During suspend the thunderbolt controller is reset and all pci
* tunnels are lost. The NHI driver will try to reestablish all tunnels
* during resume. We have to manually wait for the NHI since there is
* no parent child relationship between the NHI and the tunneled
* bridges.
*/
static void <API key>(struct pci_dev *dev)
{
struct pci_dev *sibling = NULL;
struct pci_dev *nhi = NULL;
if (!dmi_match(DMI_BOARD_VENDOR, "Apple Inc."))
return;
if (pci_pcie_type(dev) != <API key>)
return;
/*
* Find the NHI and confirm that we are a bridge on the tb host
* controller and not on a tb endpoint.
*/
sibling = pci_get_slot(dev->bus, 0x0);
if (sibling == dev)
goto out; /* we are the downstream bridge to the NHI */
if (!sibling || !sibling->subordinate)
goto out;
nhi = pci_get_slot(sibling->subordinate, 0x0);
if (!nhi)
goto out;
if (nhi->vendor != PCI_VENDOR_ID_INTEL
|| (nhi->device != <API key> &&
nhi->device != <API key> &&
nhi->device != <API key> &&
nhi->device != <API key>)
|| nhi->class != <API key> << 8)
goto out;
dev_info(&dev->dev, "quirk: waiting for thunderbolt to reestablish PCI tunnels...\n");
<API key>(&dev->dev, &nhi->dev);
out:
pci_dev_put(nhi);
pci_dev_put(sibling);
}
<API key>(PCI_VENDOR_ID_INTEL,
<API key>,
<API key>);
<API key>(PCI_VENDOR_ID_INTEL,
<API key>,
<API key>);
<API key>(PCI_VENDOR_ID_INTEL,
<API key>,
<API key>);
<API key>(PCI_VENDOR_ID_INTEL,
<API key>,
<API key>);
#endif
static void pci_do_fixups(struct pci_dev *dev, struct pci_fixup *f,
struct pci_fixup *end)
{
ktime_t calltime;
for (; f < end; f++)
if ((f->class == (u32) (dev->class >> f->class_shift) ||
f->class == (u32) PCI_ANY_ID) &&
(f->vendor == dev->vendor ||
f->vendor == (u16) PCI_ANY_ID) &&
(f->device == dev->device ||
f->device == (u16) PCI_ANY_ID)) {
calltime = fixup_debug_start(dev, f->hook);
f->hook(dev);
fixup_debug_report(dev, calltime, f->hook);
}
}
extern struct pci_fixup <API key>[];
extern struct pci_fixup <API key>[];
extern struct pci_fixup <API key>[];
extern struct pci_fixup <API key>[];
extern struct pci_fixup <API key>[];
extern struct pci_fixup <API key>[];
extern struct pci_fixup <API key>[];
extern struct pci_fixup <API key>[];
extern struct pci_fixup <API key>[];
extern struct pci_fixup <API key>[];
extern struct pci_fixup <API key>[];
extern struct pci_fixup <API key>[];
extern struct pci_fixup <API key>[];
extern struct pci_fixup <API key>[];
extern struct pci_fixup <API key>[];
extern struct pci_fixup <API key>[];
static bool <API key>;
void pci_fixup_device(enum pci_fixup_pass pass, struct pci_dev *dev)
{
struct pci_fixup *start, *end;
switch (pass) {
case pci_fixup_early:
start = <API key>;
end = <API key>;
break;
case pci_fixup_header:
start = <API key>;
end = <API key>;
break;
case pci_fixup_final:
if (!<API key>)
return;
start = <API key>;
end = <API key>;
break;
case pci_fixup_enable:
start = <API key>;
end = <API key>;
break;
case pci_fixup_resume:
start = <API key>;
end = <API key>;
break;
case <API key>:
start = <API key>;
end = <API key>;
break;
case pci_fixup_suspend:
start = <API key>;
end = <API key>;
break;
case <API key>:
start = <API key>;
end = <API key>;
break;
default:
/* stupid compiler warning, you would think with an enum... */
return;
}
pci_do_fixups(dev, start, end);
}
EXPORT_SYMBOL(pci_fixup_device);
static int __init <API key>(void)
{
struct pci_dev *dev = NULL;
u8 cls = 0;
u8 tmp;
if (pci_cache_line_size)
printk(KERN_DEBUG "PCI: CLS %u bytes\n",
pci_cache_line_size << 2);
<API key> = true;
for_each_pci_dev(dev) {
pci_fixup_device(pci_fixup_final, dev);
/*
* If arch hasn't set it explicitly yet, use the CLS
* value shared by all PCI devices. If there's a
* mismatch, fall back to the default value.
*/
if (!pci_cache_line_size) {
<API key>(dev, PCI_CACHE_LINE_SIZE, &tmp);
if (!cls)
cls = tmp;
if (!tmp || cls == tmp)
continue;
printk(KERN_DEBUG "PCI: CLS mismatch (%u != %u), using %u bytes\n",
cls << 2, tmp << 2,
<API key> << 2);
pci_cache_line_size = <API key>;
}
}
if (!pci_cache_line_size) {
printk(KERN_DEBUG "PCI: CLS %u bytes, default %u\n",
cls << 2, <API key> << 2);
pci_cache_line_size = cls ? cls : <API key>;
}
return 0;
}
fs_initcall_sync(<API key>);
/*
* Following are device-specific reset methods which can be used to
* reset a single function if other methods (e.g. FLR, PM D0->D3) are
* not available.
*/
static int <API key>(struct pci_dev *dev, int probe)
{
if (probe)
return 0;
if (!<API key>(dev))
dev_err(&dev->dev, "transaction is not cleared; proceeding with reset anyway\n");
<API key>(dev, PCI_EXP_DEVCTL, <API key>);
msleep(100);
return 0;
}
#define SOUTH_CHICKEN2 0xc2004
#define PCH_PP_STATUS 0xc7200
#define PCH_PP_CONTROL 0xc7204
#define MSG_CTL 0x45010
#define NSDE_PWR_STATE 0xd0100
#define <API key> 10000 /* set timeout 10 seconds */
static int reset_ivb_igd(struct pci_dev *dev, int probe)
{
void __iomem *mmio_base;
unsigned long timeout;
u32 val;
if (probe)
return 0;
mmio_base = pci_iomap(dev, 0, 0);
if (!mmio_base)
return -ENOMEM;
iowrite32(0x00000002, mmio_base + MSG_CTL);
/*
* Clobbering SOUTH_CHICKEN2 register is fine only if the next
* driver loaded sets the right bits. However, this's a reset and
* the bits have been set by i915 previously, so we clobber
* SOUTH_CHICKEN2 register directly here.
*/
iowrite32(0x00000005, mmio_base + SOUTH_CHICKEN2);
val = ioread32(mmio_base + PCH_PP_CONTROL) & 0xfffffffe;
iowrite32(val, mmio_base + PCH_PP_CONTROL);
timeout = jiffies + msecs_to_jiffies(<API key>);
do {
val = ioread32(mmio_base + PCH_PP_STATUS);
if ((val & 0xb0000000) == 0)
goto reset_complete;
msleep(10);
} while (time_before(jiffies, timeout));
dev_warn(&dev->dev, "timeout during reset\n");
reset_complete:
iowrite32(0x00000002, mmio_base + NSDE_PWR_STATE);
pci_iounmap(dev, mmio_base);
return 0;
}
/*
* Device-specific reset method for Chelsio T4-based adapters.
*/
static int <API key>(struct pci_dev *dev, int probe)
{
u16 old_command;
u16 msix_flags;
/*
* If this isn't a Chelsio T4-based device, return -ENOTTY indicating
* that we have no device-specific reset method.
*/
if ((dev->device & 0xf000) != 0x4000)
return -ENOTTY;
/*
* If this is the "probe" phase, return 0 indicating that we can
* reset this device.
*/
if (probe)
return 0;
/*
* T4 can wedge if there are DMAs in flight within the chip and Bus
* Master has been disabled. We need to have it on till the Function
* Level Reset completes. (BUS_MASTER is disabled in
* pci_reset_function()).
*/
<API key>(dev, PCI_COMMAND, &old_command);
<API key>(dev, PCI_COMMAND,
old_command | PCI_COMMAND_MASTER);
/*
* Perform the actual device function reset, saving and restoring
* configuration information around the reset.
*/
pci_save_state(dev);
/*
* T4 also suffers a Head-Of-Line blocking problem if MSI-X interrupts
* are disabled when an MSI-X interrupt message needs to be delivered.
* So we briefly re-enable MSI-X interrupts for the duration of the
* FLR. The pci_restore_state() below will restore the original
* MSI-X state.
*/
<API key>(dev, dev->msix_cap+PCI_MSIX_FLAGS, &msix_flags);
if ((msix_flags & <API key>) == 0)
<API key>(dev, dev->msix_cap+PCI_MSIX_FLAGS,
msix_flags |
<API key> |
<API key>);
/*
* Start of pcie_flr() code sequence. This reset code is a copy of
* the guts of pcie_flr() because that's not an exported function.
*/
if (!<API key>(dev))
dev_err(&dev->dev, "transaction is not cleared; proceeding with reset anyway\n");
<API key>(dev, PCI_EXP_DEVCTL, <API key>);
msleep(100);
/*
* End of pcie_flr() code sequence.
*/
/*
* Restore the configuration information (BAR values, etc.) including
* the original PCI Configuration Space Command word, and return
* success.
*/
pci_restore_state(dev);
<API key>(dev, PCI_COMMAND, old_command);
return 0;
}
#define <API key> 0x10ed
#define <API key> 0x0156
#define <API key> 0x0166
static const struct <API key> <API key>[] = {
{ PCI_VENDOR_ID_INTEL, <API key>,
<API key> },
{ PCI_VENDOR_ID_INTEL, <API key>,
reset_ivb_igd },
{ PCI_VENDOR_ID_INTEL, <API key>,
reset_ivb_igd },
{ <API key>, PCI_ANY_ID,
<API key> },
{ 0 }
};
/*
* These device-specific reset methods are here rather than in a driver
* because when a host assigns a device to a guest VM, the host may need
* to reset the device but probably doesn't have a driver for it.
*/
int <API key>(struct pci_dev *dev, int probe)
{
const struct <API key> *i;
for (i = <API key>; i->reset; i++) {
if ((i->vendor == dev->vendor ||
i->vendor == (u16)PCI_ANY_ID) &&
(i->device == dev->device ||
i->device == (u16)PCI_ANY_ID))
return i->reset(dev, probe);
}
return -ENOTTY;
}
static void <API key>(struct pci_dev *dev)
{
if (PCI_FUNC(dev->devfn) != 0)
pci_add_dma_alias(dev, PCI_DEVFN(PCI_SLOT(dev->devfn), 0));
}
<API key>(PCI_VENDOR_ID_RICOH, 0xe832, <API key>);
<API key>(PCI_VENDOR_ID_RICOH, 0xe476, <API key>);
static void <API key>(struct pci_dev *dev)
{
if (PCI_FUNC(dev->devfn) != 1)
pci_add_dma_alias(dev, PCI_DEVFN(PCI_SLOT(dev->devfn), 1));
}
<API key>(<API key>, 0x9120,
<API key>);
<API key>(<API key>, 0x9123,
<API key>);
<API key>(<API key>, 0x9130,
<API key>);
<API key>(<API key>, 0x9172,
<API key>);
<API key>(<API key>, 0x917a,
<API key>);
<API key>(<API key>, 0x9182,
<API key>);
<API key>(<API key>, 0x91a0,
<API key>);
<API key>(<API key>, 0x9230,
<API key>);
<API key>(PCI_VENDOR_ID_TTI, 0x0642,
<API key>);
<API key>(<API key>,
<API key>,
<API key>);
<API key>(0x1c28, /* Lite-On */
0x0122, /* Plextor M6E (Marvell 88SS9183)*/
<API key>);
/*
* Some devices DMA with the wrong devfn, not just the wrong function.
* <API key>() uses this table to create fixed aliases, where
* the alias is "fixed" and independent of the device devfn.
*
* For example, the Adaptec 3405 is a PCIe card with an Intel 80333 I/O
* processor. To software, this appears as a PCIe-to-PCI/X bridge with a
* single device on the secondary bus. In reality, the single exposed
* device at 0e.0 is the Address Translation Unit (ATU) of the controller
* that provides a bridge to the internal bus of the I/O processor. The
* controller supports private devices, which can be hidden from PCI config
* space. In the case of the Adaptec 3405, a private device at 01.0
* appears to be the DMA engine, which therefore needs to become a DMA
* alias for the device.
*/
static const struct pci_device_id fixed_dma_alias_tbl[] = {
{ PCI_DEVICE_SUB(<API key>, 0x0285,
<API key>, 0x02bb), /* Adaptec 3405 */
.driver_data = PCI_DEVFN(1, 0) },
{ PCI_DEVICE_SUB(<API key>, 0x0285,
<API key>, 0x02bc), /* Adaptec 3805 */
.driver_data = PCI_DEVFN(1, 0) },
{ 0 }
};
static void <API key>(struct pci_dev *dev)
{
const struct pci_device_id *id;
id = pci_match_id(fixed_dma_alias_tbl, dev);
if (id)
pci_add_dma_alias(dev, id->driver_data);
}
<API key>(<API key>, 0x0285, <API key>);
/*
* A few PCIe-to-PCI bridges fail to expose a PCIe capability, resulting in
* using the wrong DMA alias for the device. Some of these devices can be
* used as either forward or reverse bridges, so we need to test whether the
* device is operating in the correct mode. We could probably apply this
* quirk to PCI_ANY_ID, but for now we'll just use known offenders. The test
* is for a non-root, non-PCIe bridge where the upstream device is PCIe and
* is not a PCIe-to-PCI bridge, then @pdev is actually a PCIe-to-PCI bridge.
*/
static void <API key>(struct pci_dev *pdev)
{
if (!pci_is_root_bus(pdev->bus) &&
pdev->hdr_type == <API key> &&
!pci_is_pcie(pdev) && pci_is_pcie(pdev->bus->self) &&
pci_pcie_type(pdev->bus->self) != <API key>)
pdev->dev_flags |= <API key>;
}
<API key>(<API key>, 0x1080,
<API key>);
<API key>(0x10e3, 0x8113, <API key>);
<API key>(0x1283, 0x8892, <API key>);
<API key>(0x8086, 0x244e, <API key>);
/*
* MIC x200 NTB forwards PCIe traffic using multiple alien RIDs. They have to
* be added as aliases to the DMA device in order to allow buffer access
* when IOMMU is enabled. Following devfns have to match RIT-LUT table
* programmed in the EEPROM.
*/
static void <API key>(struct pci_dev *pdev)
{
pci_add_dma_alias(pdev, PCI_DEVFN(0x10, 0x0));
pci_add_dma_alias(pdev, PCI_DEVFN(0x11, 0x0));
pci_add_dma_alias(pdev, PCI_DEVFN(0x12, 0x3));
}
<API key>(PCI_VENDOR_ID_INTEL, 0x2260, <API key>);
<API key>(PCI_VENDOR_ID_INTEL, 0x2264, <API key>);
/*
* Intersil/Techwell TW686[4589]-based video capture cards have an empty (zero)
* class code. Fix it.
*/
static void quirk_tw686x_class(struct pci_dev *pdev)
{
u32 class = pdev->class;
/* Use "Multimedia controller" class */
pdev->class = (<API key> << 8) | 0x01;
dev_info(&pdev->dev, "TW686x PCI class overridden (%#08x -> %#08x)\n",
class, pdev->class);
}
<API key>(0x1797, 0x6864, <API key>, 8,
quirk_tw686x_class);
<API key>(0x1797, 0x6865, <API key>, 8,
quirk_tw686x_class);
<API key>(0x1797, 0x6868, <API key>, 8,
quirk_tw686x_class);
<API key>(0x1797, 0x6869, <API key>, 8,
quirk_tw686x_class);
/*
* Per PCIe r3.0, sec 2.2.9, "Completion headers must supply the same
* values for the Attribute as were supplied in the header of the
* corresponding Request, except as explicitly allowed when IDO is used."
*
* If a non-compliant device generates a completion with a different
* attribute than the request, the receiver may accept it (which itself
* seems non-compliant based on sec 2.3.2), or it may handle it as a
* Malformed TLP or an Unexpected Completion, which will probably lead to a
* device access timeout.
*
* If the non-compliant device generates completions with zero attributes
* (instead of copying the attributes from the request), we can work around
* this by disabling the "Relaxed Ordering" and "No Snoop" attributes in
* upstream devices so they always generate requests with zero attributes.
*
* This affects other devices under the same Root Port, but since these
* attributes are performance hints, there should be no functional problem.
*
* Note that Configuration Space accesses are never supposed to have TLP
* Attributes, so we're safe waiting till after any Configuration Space
* accesses to do the Root Port fixup.
*/
static void <API key>(struct pci_dev *pdev)
{
struct pci_dev *root_port = <API key>(pdev);
if (!root_port) {
dev_warn(&pdev->dev, "PCIe Completion erratum may cause device errors\n");
return;
}
dev_info(&root_port->dev, "Disabling No Snoop/Relaxed Ordering Attributes to avoid PCIe Completion erratum in %s\n",
dev_name(&pdev->dev));
<API key>(root_port, PCI_EXP_DEVCTL,
<API key> |
<API key>, 0);
}
/*
* The Chelsio T5 chip fails to copy TLP Attributes from a Request to the
* Completion it generates.
*/
static void <API key>(struct pci_dev *pdev)
{
/*
* This mask/compare operation selects for Physical Function 4 on a
* T5. We only need to fix up the Root Port once for any of the
* PFs. PF[0..3] have PCI Device IDs of 0x50xx, but PF4 is uniquely
* 0x54xx so we use that one,
*/
if ((pdev->device & 0xff00) == 0x5400)
<API key>(pdev);
}
<API key>(<API key>, PCI_ANY_ID,
<API key>);
static int <API key>(struct pci_dev *dev, u16 acs_flags)
{
#ifdef CONFIG_ACPI
struct acpi_table_header *header = NULL;
acpi_status status;
/* Targeting multifunction devices on the SB (appears on root bus) */
if (!dev->multifunction || !pci_is_root_bus(dev->bus))
return -ENODEV;
/* The IVRS table describes the AMD IOMMU */
status = acpi_get_table("IVRS", 0, &header);
if (ACPI_FAILURE(status))
return -ENODEV;
/* Filter out flags not applicable to multifunction */
acs_flags &= (PCI_ACS_RR | PCI_ACS_CR | PCI_ACS_EC | PCI_ACS_DT);
return acs_flags & ~(PCI_ACS_RR | PCI_ACS_CR) ? 0 : 1;
#else
return -ENODEV;
#endif
}
static int <API key>(struct pci_dev *dev, u16 acs_flags)
{
/*
* Cavium devices matching this quirk do not perform peer-to-peer
* with other functions, allowing masking out these bits as if they
* were unimplemented in the ACS capability.
*/
acs_flags &= ~(PCI_ACS_SV | PCI_ACS_TB | PCI_ACS_RR |
PCI_ACS_CR | PCI_ACS_UF | PCI_ACS_DT);
return acs_flags ? 0 : 1;
}
/*
* Many Intel PCH root ports do provide ACS-like features to disable peer
* transactions and validate bus numbers in requests, but do not provide an
* actual PCIe ACS capability. This is the list of device IDs known to fall
* into that category as provided by Intel in Red Hat bugzilla 1037684.
*/
static const u16 <API key>[] = {
/* Ibexpeak PCH */
0x3b42, 0x3b43, 0x3b44, 0x3b45, 0x3b46, 0x3b47, 0x3b48, 0x3b49,
0x3b4a, 0x3b4b, 0x3b4c, 0x3b4d, 0x3b4e, 0x3b4f, 0x3b50, 0x3b51,
/* Cougarpoint PCH */
0x1c10, 0x1c11, 0x1c12, 0x1c13, 0x1c14, 0x1c15, 0x1c16, 0x1c17,
0x1c18, 0x1c19, 0x1c1a, 0x1c1b, 0x1c1c, 0x1c1d, 0x1c1e, 0x1c1f,
/* Pantherpoint PCH */
0x1e10, 0x1e11, 0x1e12, 0x1e13, 0x1e14, 0x1e15, 0x1e16, 0x1e17,
0x1e18, 0x1e19, 0x1e1a, 0x1e1b, 0x1e1c, 0x1e1d, 0x1e1e, 0x1e1f,
/* Lynxpoint-H PCH */
0x8c10, 0x8c11, 0x8c12, 0x8c13, 0x8c14, 0x8c15, 0x8c16, 0x8c17,
0x8c18, 0x8c19, 0x8c1a, 0x8c1b, 0x8c1c, 0x8c1d, 0x8c1e, 0x8c1f,
/* Lynxpoint-LP PCH */
0x9c10, 0x9c11, 0x9c12, 0x9c13, 0x9c14, 0x9c15, 0x9c16, 0x9c17,
0x9c18, 0x9c19, 0x9c1a, 0x9c1b,
/* Wildcat PCH */
0x9c90, 0x9c91, 0x9c92, 0x9c93, 0x9c94, 0x9c95, 0x9c96, 0x9c97,
0x9c98, 0x9c99, 0x9c9a, 0x9c9b,
/* Patsburg (X79) PCH */
0x1d10, 0x1d12, 0x1d14, 0x1d16, 0x1d18, 0x1d1a, 0x1d1c, 0x1d1e,
/* Wellsburg (X99) PCH */
0x8d10, 0x8d11, 0x8d12, 0x8d13, 0x8d14, 0x8d15, 0x8d16, 0x8d17,
0x8d18, 0x8d19, 0x8d1a, 0x8d1b, 0x8d1c, 0x8d1d, 0x8d1e,
/* Lynx Point (9 series) PCH */
0x8c90, 0x8c92, 0x8c94, 0x8c96, 0x8c98, 0x8c9a, 0x8c9c, 0x8c9e,
};
static bool <API key>(struct pci_dev *dev)
{
int i;
/* Filter out a few obvious non-matches first */
if (!pci_is_pcie(dev) || pci_pcie_type(dev) != <API key>)
return false;
for (i = 0; i < ARRAY_SIZE(<API key>); i++)
if (<API key>[i] == dev->device)
return true;
return false;
}
#define INTEL_PCH_ACS_FLAGS (PCI_ACS_RR | PCI_ACS_CR | PCI_ACS_UF | PCI_ACS_SV)
static int <API key>(struct pci_dev *dev, u16 acs_flags)
{
u16 flags = dev->dev_flags & <API key> ?
INTEL_PCH_ACS_FLAGS : 0;
if (!<API key>(dev))
return -ENOTTY;
return acs_flags & ~flags ? 0 : 1;
}
static bool <API key>(struct pci_dev *dev)
{
return pci_is_pcie(dev) &&
pci_pcie_type(dev) == <API key> &&
((dev->device & ~0xf) == 0xa110 ||
(dev->device >= 0xa167 && dev->device <= 0xa16a));
}
#define INTEL_SPT_ACS_CTRL (PCI_ACS_CAP + 4)
static int <API key>(struct pci_dev *dev, u16 acs_flags)
{
int pos;
u32 cap, ctrl;
if (!<API key>(dev))
return -ENOTTY;
pos = <API key>(dev, PCI_EXT_CAP_ID_ACS);
if (!pos)
return -ENOTTY;
/* see <API key>() */
<API key>(dev, pos + PCI_ACS_CAP, &cap);
acs_flags &= (cap | PCI_ACS_EC);
<API key>(dev, pos + INTEL_SPT_ACS_CTRL, &ctrl);
return acs_flags & ~ctrl ? 0 : 1;
}
static int <API key>(struct pci_dev *dev, u16 acs_flags)
{
/*
* SV, TB, and UF are not relevant to multifunction endpoints.
*
* Multifunction devices are only required to implement RR, CR, and DT
* in their ACS capability if they support peer-to-peer transactions.
* Devices matching this quirk have been verified by the vendor to not
* perform peer-to-peer with other functions, allowing us to mask out
* these bits as if they were unimplemented in the ACS capability.
*/
acs_flags &= ~(PCI_ACS_SV | PCI_ACS_TB | PCI_ACS_RR |
PCI_ACS_CR | PCI_ACS_UF | PCI_ACS_DT);
return acs_flags ? 0 : 1;
}
static const struct pci_dev_acs_enabled {
u16 vendor;
u16 device;
int (*acs_enabled)(struct pci_dev *dev, u16 acs_flags);
} pci_dev_acs_enabled[] = {
{ PCI_VENDOR_ID_ATI, 0x4385, <API key> },
{ PCI_VENDOR_ID_ATI, 0x439c, <API key> },
{ PCI_VENDOR_ID_ATI, 0x4383, <API key> },
{ PCI_VENDOR_ID_ATI, 0x439d, <API key> },
{ PCI_VENDOR_ID_ATI, 0x4384, <API key> },
{ PCI_VENDOR_ID_ATI, 0x4399, <API key> },
{ PCI_VENDOR_ID_AMD, 0x780f, <API key> },
{ PCI_VENDOR_ID_AMD, 0x7809, <API key> },
{ <API key>, 0x0903, <API key> },
{ <API key>, 0x0923, <API key> },
{ <API key>, 0x0A03, <API key> },
{ PCI_VENDOR_ID_INTEL, 0x10C6, <API key> },
{ PCI_VENDOR_ID_INTEL, 0x10DB, <API key> },
{ PCI_VENDOR_ID_INTEL, 0x10DD, <API key> },
{ PCI_VENDOR_ID_INTEL, 0x10E1, <API key> },
{ PCI_VENDOR_ID_INTEL, 0x10F1, <API key> },
{ PCI_VENDOR_ID_INTEL, 0x10F7, <API key> },
{ PCI_VENDOR_ID_INTEL, 0x10F8, <API key> },
{ PCI_VENDOR_ID_INTEL, 0x10F9, <API key> },
{ PCI_VENDOR_ID_INTEL, 0x10FA, <API key> },
{ PCI_VENDOR_ID_INTEL, 0x10FB, <API key> },
{ PCI_VENDOR_ID_INTEL, 0x10FC, <API key> },
{ PCI_VENDOR_ID_INTEL, 0x1507, <API key> },
{ PCI_VENDOR_ID_INTEL, 0x1514, <API key> },
{ PCI_VENDOR_ID_INTEL, 0x151C, <API key> },
{ PCI_VENDOR_ID_INTEL, 0x1529, <API key> },
{ PCI_VENDOR_ID_INTEL, 0x152A, <API key> },
{ PCI_VENDOR_ID_INTEL, 0x154D, <API key> },
{ PCI_VENDOR_ID_INTEL, 0x154F, <API key> },
{ PCI_VENDOR_ID_INTEL, 0x1551, <API key> },
{ PCI_VENDOR_ID_INTEL, 0x1558, <API key> },
/* 82580 */
{ PCI_VENDOR_ID_INTEL, 0x1509, <API key> },
{ PCI_VENDOR_ID_INTEL, 0x150E, <API key> },
{ PCI_VENDOR_ID_INTEL, 0x150F, <API key> },
{ PCI_VENDOR_ID_INTEL, 0x1510, <API key> },
{ PCI_VENDOR_ID_INTEL, 0x1511, <API key> },
{ PCI_VENDOR_ID_INTEL, 0x1516, <API key> },
{ PCI_VENDOR_ID_INTEL, 0x1527, <API key> },
/* 82576 */
{ PCI_VENDOR_ID_INTEL, 0x10C9, <API key> },
{ PCI_VENDOR_ID_INTEL, 0x10E6, <API key> },
{ PCI_VENDOR_ID_INTEL, 0x10E7, <API key> },
{ PCI_VENDOR_ID_INTEL, 0x10E8, <API key> },
{ PCI_VENDOR_ID_INTEL, 0x150A, <API key> },
{ PCI_VENDOR_ID_INTEL, 0x150D, <API key> },
{ PCI_VENDOR_ID_INTEL, 0x1518, <API key> },
{ PCI_VENDOR_ID_INTEL, 0x1526, <API key> },
/* 82575 */
{ PCI_VENDOR_ID_INTEL, 0x10A7, <API key> },
{ PCI_VENDOR_ID_INTEL, 0x10A9, <API key> },
{ PCI_VENDOR_ID_INTEL, 0x10D6, <API key> },
/* I350 */
{ PCI_VENDOR_ID_INTEL, 0x1521, <API key> },
{ PCI_VENDOR_ID_INTEL, 0x1522, <API key> },
{ PCI_VENDOR_ID_INTEL, 0x1523, <API key> },
{ PCI_VENDOR_ID_INTEL, 0x1524, <API key> },
/* 82571 (Quads omitted due to non-ACS switch) */
{ PCI_VENDOR_ID_INTEL, 0x105E, <API key> },
{ PCI_VENDOR_ID_INTEL, 0x105F, <API key> },
{ PCI_VENDOR_ID_INTEL, 0x1060, <API key> },
{ PCI_VENDOR_ID_INTEL, 0x10D9, <API key> },
/* I219 */
{ PCI_VENDOR_ID_INTEL, 0x15b7, <API key> },
{ PCI_VENDOR_ID_INTEL, 0x15b8, <API key> },
/* Intel PCH root ports */
{ PCI_VENDOR_ID_INTEL, PCI_ANY_ID, <API key> },
{ PCI_VENDOR_ID_INTEL, PCI_ANY_ID, <API key> },
{ 0x19a2, 0x710, <API key> }, /* Emulex BE3-R */
{ 0x10df, 0x720, <API key> }, /* Emulex Skyhawk-R */
/* Cavium ThunderX */
{ <API key>, PCI_ANY_ID, <API key> },
{ 0 }
};
int <API key>(struct pci_dev *dev, u16 acs_flags)
{
const struct pci_dev_acs_enabled *i;
int ret;
/*
* Allow devices that do not expose standard PCIe ACS capabilities
* or control to indicate their support here. Multi-function express
* devices which do not allow internal peer-to-peer between functions,
* but do not implement PCIe ACS may wish to return true here.
*/
for (i = pci_dev_acs_enabled; i->acs_enabled; i++) {
if ((i->vendor == dev->vendor ||
i->vendor == (u16)PCI_ANY_ID) &&
(i->device == dev->device ||
i->device == (u16)PCI_ANY_ID)) {
ret = i->acs_enabled(dev, acs_flags);
if (ret >= 0)
return ret;
}
}
return -ENOTTY;
}
/* Config space offset of Root Complex Base Address register */
#define INTEL_LPC_RCBA_REG 0xf0
/* 31:14 RCBA address */
#define INTEL_LPC_RCBA_MASK 0xffffc000
/* RCBA Enable */
#define <API key> (1 << 0)
/* Backbone Scratch Pad Register */
#define INTEL_BSPR_REG 0x1104
/* Backbone Peer Non-Posted Disable */
#define <API key> (1 << 8)
/* Backbone Peer Posted Disable */
#define INTEL_BSPR_REG_BPPD (1 << 9)
/* Upstream Peer Decode Configuration Register */
#define INTEL_UPDCR_REG 0x1114
/* 5:0 Peer Decode Enable bits */
#define <API key> 0x3f
static int <API key>(struct pci_dev *dev)
{
u32 rcba, bspr, updcr;
void __iomem *rcba_mem;
/*
* Read the RCBA register from the LPC (D31:F0). PCH root ports
* are D28:F* and therefore get probed before LPC, thus we can't
* use pci_get_slot/<API key> here.
*/
<API key>(dev->bus, PCI_DEVFN(31, 0),
INTEL_LPC_RCBA_REG, &rcba);
if (!(rcba & <API key>))
return -EINVAL;
rcba_mem = ioremap_nocache(rcba & INTEL_LPC_RCBA_MASK,
PAGE_ALIGN(INTEL_UPDCR_REG));
if (!rcba_mem)
return -ENOMEM;
/*
* The BSPR can disallow peer cycles, but it's set by soft strap and
* therefore read-only. If both posted and non-posted peer cycles are
* disallowed, we're ok. If either are allowed, then we need to use
* the UPDCR to disable peer decodes for each port. This provides the
* PCIe ACS equivalent of PCI_ACS_RR | PCI_ACS_CR | PCI_ACS_UF
*/
bspr = readl(rcba_mem + INTEL_BSPR_REG);
bspr &= <API key> | INTEL_BSPR_REG_BPPD;
if (bspr != (<API key> | INTEL_BSPR_REG_BPPD)) {
updcr = readl(rcba_mem + INTEL_UPDCR_REG);
if (updcr & <API key>) {
dev_info(&dev->dev, "Disabling UPDCR peer decodes\n");
updcr &= ~<API key>;
writel(updcr, rcba_mem + INTEL_UPDCR_REG);
}
}
iounmap(rcba_mem);
return 0;
}
/* Miscellaneous Port Configuration register */
#define INTEL_MPC_REG 0xd8
/* MPC: Invalid Receive Bus Number Check Enable */
#define <API key> (1 << 26)
static void <API key>(struct pci_dev *dev)
{
u32 mpc;
/*
* When enabled, the IRBNCE bit of the MPC register enables the
* equivalent of PCI ACS Source Validation (PCI_ACS_SV), which
* ensures that requester IDs fall within the bus number range
* of the bridge. Enable if not already.
*/
<API key>(dev, INTEL_MPC_REG, &mpc);
if (!(mpc & <API key>)) {
dev_info(&dev->dev, "Enabling MPC IRBNCE\n");
mpc |= <API key>;
<API key>(dev, INTEL_MPC_REG, mpc);
}
}
static int <API key>(struct pci_dev *dev)
{
if (!<API key>(dev))
return -ENOTTY;
if (<API key>(dev)) {
dev_warn(&dev->dev, "Failed to enable Intel PCH ACS quirk\n");
return 0;
}
<API key>(dev);
dev->dev_flags |= <API key>;
dev_info(&dev->dev, "Intel PCH root port ACS workaround enabled\n");
return 0;
}
static int <API key>(struct pci_dev *dev)
{
int pos;
u32 cap, ctrl;
if (!<API key>(dev))
return -ENOTTY;
pos = <API key>(dev, PCI_EXT_CAP_ID_ACS);
if (!pos)
return -ENOTTY;
<API key>(dev, pos + PCI_ACS_CAP, &cap);
<API key>(dev, pos + INTEL_SPT_ACS_CTRL, &ctrl);
ctrl |= (cap & PCI_ACS_SV);
ctrl |= (cap & PCI_ACS_RR);
ctrl |= (cap & PCI_ACS_CR);
ctrl |= (cap & PCI_ACS_UF);
<API key>(dev, pos + INTEL_SPT_ACS_CTRL, ctrl);
dev_info(&dev->dev, "Intel SPT PCH root port ACS workaround enabled\n");
return 0;
}
static const struct pci_dev_enable_acs {
u16 vendor;
u16 device;
int (*enable_acs)(struct pci_dev *dev);
} pci_dev_enable_acs[] = {
{ PCI_VENDOR_ID_INTEL, PCI_ANY_ID, <API key> },
{ PCI_VENDOR_ID_INTEL, PCI_ANY_ID, <API key> },
{ 0 }
};
int <API key>(struct pci_dev *dev)
{
const struct pci_dev_enable_acs *i;
int ret;
for (i = pci_dev_enable_acs; i->enable_acs; i++) {
if ((i->vendor == dev->vendor ||
i->vendor == (u16)PCI_ANY_ID) &&
(i->device == dev->device ||
i->device == (u16)PCI_ANY_ID)) {
ret = i->enable_acs(dev);
if (ret >= 0)
return ret;
}
}
return -ENOTTY;
}
/*
* The PCI capabilities list for Intel DH895xCC VFs (device id 0x0443) with
* QuickAssist Technology (QAT) is prematurely terminated in hardware. The
* Next Capability pointer in the MSI Capability Structure should point to
* the PCIe Capability Structure but is incorrectly hardwired as 0 terminating
* the list.
*/
static void <API key>(struct pci_dev *pdev)
{
int pos, i = 0;
u8 next_cap;
u16 reg16, *cap;
struct pci_cap_saved_state *state;
/* Bail if the hardware bug is fixed */
if (pdev->pcie_cap || pci_find_capability(pdev, PCI_CAP_ID_EXP))
return;
/* Bail if MSI Capability Structure is not found for some reason */
pos = pci_find_capability(pdev, PCI_CAP_ID_MSI);
if (!pos)
return;
/*
* Bail if Next Capability pointer in the MSI Capability Structure
* is not the expected incorrect 0x00.
*/
<API key>(pdev, pos + 1, &next_cap);
if (next_cap)
return;
/*
* PCIe Capability Structure is expected to be at 0x50 and should
* terminate the list (Next Capability pointer is 0x00). Verify
* Capability Id and Next Capability pointer is as expected.
* Open-code some of set_pcie_port_type() and <API key>()
* to correctly set kernel data structures which have already been
* set incorrectly due to the hardware bug.
*/
pos = 0x50;
<API key>(pdev, pos, ®16);
if (reg16 == (0x0000 | PCI_CAP_ID_EXP)) {
u32 status;
#ifndef PCI_EXP_SAVE_REGS
#define PCI_EXP_SAVE_REGS 7
#endif
int size = PCI_EXP_SAVE_REGS * sizeof(u16);
pdev->pcie_cap = pos;
<API key>(pdev, pos + PCI_EXP_FLAGS, ®16);
pdev->pcie_flags_reg = reg16;
<API key>(pdev, pos + PCI_EXP_DEVCAP, ®16);
pdev->pcie_mpss = reg16 & <API key>;
pdev->cfg_size = <API key>;
if (<API key>(pdev, PCI_CFG_SPACE_SIZE, &status) !=
PCIBIOS_SUCCESSFUL || (status == 0xffffffff))
pdev->cfg_size = PCI_CFG_SPACE_SIZE;
if (pci_find_saved_cap(pdev, PCI_CAP_ID_EXP))
return;
/*
* Save PCIE cap
*/
state = kzalloc(sizeof(*state) + size, GFP_KERNEL);
if (!state)
return;
state->cap.cap_nr = PCI_CAP_ID_EXP;
state->cap.cap_extended = 0;
state->cap.size = size;
cap = (u16 *)&state->cap.data[0];
<API key>(pdev, PCI_EXP_DEVCTL, &cap[i++]);
<API key>(pdev, PCI_EXP_LNKCTL, &cap[i++]);
<API key>(pdev, PCI_EXP_SLTCTL, &cap[i++]);
<API key>(pdev, PCI_EXP_RTCTL, &cap[i++]);
<API key>(pdev, PCI_EXP_DEVCTL2, &cap[i++]);
<API key>(pdev, PCI_EXP_LNKCTL2, &cap[i++]);
<API key>(pdev, PCI_EXP_SLTCTL2, &cap[i++]);
hlist_add_head(&state->next, &pdev->saved_cap_space);
}
}
<API key>(PCI_VENDOR_ID_INTEL, 0x443, <API key>);
/*
* VMD-enabled root ports will change the source ID for all messages
* to the VMD device. Rather than doing device matching with the source
* ID, the AER driver should traverse the child device tree, reading
* AER registers to find the faulting device.
*/
static void quirk_no_aersid(struct pci_dev *pdev)
{
/* VMD Domain */
if (pdev->bus->sysdata && pci_domain_nr(pdev->bus) >= 0x10000)
pdev->bus->bus_flags |= <API key>;
}
<API key>(PCI_VENDOR_ID_INTEL, 0x2030, quirk_no_aersid);
<API key>(PCI_VENDOR_ID_INTEL, 0x2031, quirk_no_aersid);
<API key>(PCI_VENDOR_ID_INTEL, 0x2032, quirk_no_aersid);
<API key>(PCI_VENDOR_ID_INTEL, 0x2033, quirk_no_aersid);
|
package ch.dritz.remedy2redmine;
import java.io.File;
import java.io.IOException;
import ch.dritz.common.Config;
import ch.dritz.remedy2redmine.modules.SyncModule;
/**
* Main class for Remedy2Redmine
* @author D.Ritz
*/
public class Main
{
private static void usage(String msg)
{
if (msg != null)
System.out.println("ERROR: " + msg);
System.out.println("Remedy2Redmine " + Version.getVersion());
System.out.println("Usage: Remedy2Redmine <config.properties> <command> [<command specific args>]");
System.out.println(" <command> : one of (sync)");
System.out.println(" <mode specific args> for each mode:");
System.out.println(" - sync: none");
System.out.println("OR: Remedy2Redmine -version");
System.exit(1);
}
/**
* main() entry point
* @param args
* @throws IOException
*/
public static void main(String[] args)
throws Exception
{
if (args.length == 1 && "-version".equals(args[0])) {
System.out.println("Remedy2Redmine " + Version.getVersion());
return;
}
if (args.length < 2)
usage("Not enough arguments");
File configFile = new File(args[0]);
String command = args[1];
Config config = new Config();
config.loadFromFile(configFile);
if ("sync".equals(command)) {
File syncConfig = new File(configFile.getParentFile(),
config.getString("sync.config", "sync.properties"));
config.loadFromFile(syncConfig);
SyncModule sync = new SyncModule(config);
try {
sync.start();
} finally {
sync.shutdown();
}
} else {
usage("Unknown command");
}
}
}
|
package com.gilecode.langlocker;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.ui.plugin.AbstractUIPlugin;
import org.osgi.framework.BundleContext;
/**
* The activator class controls the plug-in life cycle
*/
public class Activator extends AbstractUIPlugin {
// The plug-in ID
public static final String PLUGIN_ID = "com.gilecode.langlocker"; //$NON-NLS-1$
// The shared instance
private static Activator plugin;
/**
* The constructor
*/
public Activator() {
super();
}
/*
* (non-Javadoc)
*
* @see
* org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext
* )
*/
public void start(BundleContext context) throws Exception {
super.start(context);
plugin = this;
}
/*
* (non-Javadoc)
*
* @see
* org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext
* )
*/
public void stop(BundleContext context) throws Exception {
plugin = null;
super.stop(context);
}
/**
* Returns the shared instance
*
* @return the shared instance
*/
public static Activator getDefault() {
return plugin;
}
/**
* Returns an image descriptor for the image file at the given plug-in
* relative path
*
* @param path
* the path
* @return the image descriptor
*/
public static ImageDescriptor getImageDescriptor(String path) {
return <API key>(PLUGIN_ID, path);
}
}
|
'use strict';
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
var Mecab = require('mecab-async');
var mecab = new Mecab();
var MarkovChain = function () {
function MarkovChain(text) {
_classCallCheck(this, MarkovChain);
this.text = text;
this.result = null;
this.dictionary = {};
this.output = 'output';
}
_createClass(MarkovChain, [{
key: 'start',
value: function start(sentence, callback) {
this.parse(sentence, callback);
}
}, {
key: 'parse',
value: function parse(sentence, callback) {
var _this = this;
mecab.parse(this.text, function (err, result) {
_this.dictionary = _this.makeDic(result);
_this.makeSentence(_this.dictionary, sentence);
callback(_this.output);
});
}
}, {
key: 'makeDic',
value: function makeDic(items) {
var tmp = ['@'];
var dic = {};
for (var i in items) {
var t = items[i];
var word = t[0];
word = word.replace(/\s*/, '');
if (word == '' || word == 'EOS') continue;
tmp.push(word);
if (tmp.length < 3) continue;
if (tmp.length > 3) tmp.splice(0, 1);
this.setWord3(dic, tmp);
if (word == '') {
tmp = ['@'];
continue;
}
}
return dic;
}
}, {
key: 'setWord3',
value: function setWord3(p, s3) {
var w1 = s3[0];
var w2 = s3[1];
var w3 = s3[2];
if (p[w1] == undefined) p[w1] = {};
if (p[w1][w2] == undefined) p[w1][w2] = {};
if (p[w1][w2][w3] == undefined) p[w1][w2][w3] = 0;
p[w1][w2][w3]++;
}
}, {
key: 'makeSentence',
value: function makeSentence(dic, sentence) {
for (var i = 0; i < sentence; i++) {
var ret = [];
var top = dic['@'];
if (!top) continue;
var w1 = this.choiceWord(top);
var w2 = this.choiceWord(top[w1]);
ret.push(w1);
ret.push(w2);
for (;;) {
var w3 = this.choiceWord(dic[w1][w2]);
ret.push(w3);
if (w3 == '') break;
w1 = w2, w2 = w3;
}
this.output = ret.join('');
return this.output;
}
}
}, {
key: 'objKeys',
value: function objKeys(obj) {
var r = [];
for (var i in obj) {
r.push(i);
}
return r;
}
}, {
key: 'choiceWord',
value: function choiceWord(obj) {
var ks = this.objKeys(obj);
var i = this.rnd(ks.length);
return ks[i];
}
}, {
key: 'rnd',
value: function rnd(num) {
return Math.floor(Math.random() * num);
}
}]);
return MarkovChain;
}();
module.exports = MarkovChain;
|
{% include 'overall_header.html' %}
<h2>{{ lang('ABOUTUS') }}</h2>
<div class="panel aboutus">
<div class="inner">
<div class="content">
{{ ABOUTUS_OUTPUT }}
</div>
{% if TERMS_OF_USE or PRIVACY %}
{% if TERMS_OF_USE and PRIVACY %}
<h2>{{ lang('TERMS_USE') }} {{ lang('ABOUTUS_AND') }} {{ lang('PRIVACY') }}</h2>
<p>{{ lang('<API key>') }} <a href="{{ U_TERMS_USE }}">{{ lang('TERMS_USE') }}</a> {{ lang('ABOUTUS_AND') }} <a href="{{ U_PRIVACY }}">{{ lang('PRIVACY') }}</a></p>
{% elseif PRIVACY %}
<h2>{{ lang('PRIVACY') }}</h2>
<p>{{ lang('DESCRIPTION_PRIVACY') }} <a href="{{ U_PRIVACY }}">{{ lang('PRIVACY') }}</a></p>
{% elseif TERMS_OF_USE %}
<h2>{{ lang('TERMS_USE') }}</h2>
<p>{{ lang('<API key>') }} <a href="{{ U_TERMS_USE }}">{{ lang('TERMS_USE') }}</a></p>
{% endif %}
{% endif %}
</div>
</div>
{% include 'overall_footer.html' %}
|
#include<stdio.h>
int main()
{
int *p,i;
int a[10]={12,23,56,1,65,67,87,34,6,23};
p=a;
for(i=0;i<10;i++)
{
printf("%d ",(p+i));
}
return 0;
}
|
package org.iatoki.judgels.jerahmeel.user.item;
public final class UserItem {
private final String userJid;
private final String itemJid;
private final UserItemStatus status;
public UserItem(String userJid, String itemJid, UserItemStatus status) {
this.userJid = userJid;
this.itemJid = itemJid;
this.status = status;
}
public String getUserJid() {
return userJid;
}
public String getItemJid() {
return itemJid;
}
public UserItemStatus getStatus() {
return status;
}
}
|
We would like to propose a manuscript submission to the *Methods* section of Ecology Letters, discussing the use of Partially Observed Markov Decision Processes (POMDP) in ecological research questions. Markov Decision Process (MDP) methods have a long history in ecology, particularly in natural resource management such as fisheries or forestry, and in behavioral ecology (where they are commonly called SDP problems, referring to the stochastic dynamic programming method used to solve them.) POMDPs have seen limited application owing to the complexity of solving them and the lack of appropriate software to do so. Recent breakthroughs in the robotics & artificial intelligence community have made POMDPs for large problems tractable, opening the door to a wide array of ecological problems previously considered intractable in an optimal control framework.
Our proposed methods paper would present a high quality R package we have developed over several years which leverages a recently developed algorithm for solving POMDP problems. We would illustrate the use of the package on both a classic decision problem from fisheries and in extending a recent Ecology Letters paper of ecosystem services (Dee et al, 2017; which received ESA's Innovation in Sustainability Science award) to account for imperfect observations. We believe that these examples coupled with the user friendly R package would catalyze significant breakthroughs in this critical and timely area of conservation decision making.
Authors qualifications: Carl Boettiger, is a theoretical ecologist & assistant professor at UC Berkeley's department Environmental Science, Policy, and Management. Jeroen Ooms is a well-recognized professional software developer with rOpenSci; several of his packages are downloaded over 100,000 times each week. Milad Memarzadeh is a post-doc in Civil & Environmental engineering at UC Berkeley with a PhD from Carnegie Mellon in POMDP methods.
|
#include <linux/kernel.h>
#include <linux/slab.h>
#include <linux/mtd/mtd.h>
#include <linux/mtd/partitions.h>
#include <linux/bootmem.h>
/* error message prefix */
#define ERRP "mtd: "
/* debug macro */
#if 0
#define dbg(x) do { printk("DEBUG-CMDLINE-PART: "); printk x; } while(0)
#else
#define dbg(x)
#endif
/* special size referring to all the remaining space in a partition */
#define SIZE_REMAINING UINT_MAX
#define OFFSET_CONTINUOUS UINT_MAX
struct <API key> {
struct <API key> *next;
char *mtd_id;
int num_parts;
struct mtd_partition *parts;
};
/* mtdpart_setup() parses into here */
static struct <API key> *partitions;
/* the command line passed to mtdpart_setupd() */
static char *cmdline;
static int cmdline_parsed = 0;
/*
* Parse one partition definition for an MTD. Since there can be many
* comma separated partition definitions, this function calls itself
* recursively until no more partition definitions are found. Nice side
* effect: the memory to keep the mtd_partition structs and the names
* is allocated upon the last definition being found. At that point the
* syntax has been verified ok.
*/
static struct mtd_partition * newpart(char *s,
char **retptr,
int *num_parts,
int this_part,
unsigned char **extra_mem_ptr,
int extra_mem_size)
{
struct mtd_partition *parts;
unsigned long size;
unsigned long offset = OFFSET_CONTINUOUS;
char *name;
int name_len;
unsigned char *extra_mem;
char delim;
unsigned int mask_flags;
/* fetch the partition size */
if (*s == '-')
{ /* assign all remaining space to this partition */
size = SIZE_REMAINING;
s++;
}
else
{
size = memparse(s, &s);
if (size < PAGE_SIZE)
{
printk(KERN_ERR ERRP "partition size too small (%lx)\n", size);
return NULL;
}
}
/* fetch partition name and flags */
mask_flags = 0; /* this is going to be a regular partition */
delim = 0;
/* check for offset */
if (*s == '@')
{
s++;
offset = memparse(s, &s);
}
/* now look for name */
if (*s == '(')
{
delim = ')';
}
if (delim)
{
char *p;
name = ++s;
p = strchr(name, delim);
if (!p)
{
printk(KERN_ERR ERRP "no closing %c found in partition name\n", delim);
return NULL;
}
name_len = p - name;
s = p + 1;
}
else
{
name = NULL;
name_len = 13; /* Partition_000 */
}
/* record name length for memory allocation later */
extra_mem_size += name_len + 1;
/* test for options */
if (strncmp(s, "ro", 2) == 0)
{
mask_flags |= MTD_WRITEABLE;
s += 2;
}
/* if lk is found do NOT unlock the MTD partition*/
if (strncmp(s, "lk", 2) == 0)
{
mask_flags |= MTD_POWERUP_LOCK;
s += 2;
}
/* test if more partitions are following */
if (*s == ',')
{
if (size == SIZE_REMAINING)
{
printk(KERN_ERR ERRP "no partitions allowed after a fill-up partition\n");
return NULL;
}
/* more partitions follow, parse them */
parts = newpart(s + 1, &s, num_parts, this_part + 1,
&extra_mem, extra_mem_size);
if (!parts)
return NULL;
}
else
{ /* this is the last partition: allocate space for all */
int alloc_size;
*num_parts = this_part + 1;
alloc_size = *num_parts * sizeof(struct mtd_partition) +
extra_mem_size;
parts = kzalloc(alloc_size, GFP_KERNEL);
if (!parts)
{
printk(KERN_ERR ERRP "out of memory\n");
return NULL;
}
extra_mem = (unsigned char *)(parts + *num_parts);
}
/* enter this partition (offset will be calculated later if it is zero at this point) */
parts[this_part].size = size;
parts[this_part].offset = offset;
parts[this_part].mask_flags = mask_flags;
if (name)
{
strlcpy((char *)extra_mem, name, name_len + 1);
}
else
{
sprintf((char *)extra_mem, "Partition_%03d", this_part);
}
parts[this_part].name = (char *)extra_mem;
extra_mem += name_len + 1;
dbg(("partition %d: name <%s>, offset %llx, size %llx, mask flags %x\n",
this_part,
parts[this_part].name,
parts[this_part].offset,
parts[this_part].size,
parts[this_part].mask_flags));
/* return (updated) pointer to extra_mem memory */
if (extra_mem_ptr)
*extra_mem_ptr = extra_mem;
/* return (updated) pointer command line string */
*retptr = s;
/* return partition table */
return parts;
}
/*
* Parse the command line.
*/
static int mtdpart_setup_real(char *s)
{
cmdline_parsed = 1;
for( ; s != NULL; )
{
struct <API key> *this_mtd;
struct mtd_partition *parts;
int mtd_id_len;
int num_parts;
char *p, *mtd_id;
mtd_id = s;
/* fetch <mtd-id> */
if (!(p = strchr(s, ':')))
{
printk(KERN_ERR ERRP "no mtd-id\n");
return 0;
}
mtd_id_len = p - mtd_id;
dbg(("parsing <%s>\n", p+1));
/*
* parse one mtd. have it reserve memory for the
* struct <API key> and the mtd-id string.
*/
parts = newpart(p + 1, /* cmdline */
&s, /* out: updated cmdline ptr */
&num_parts, /* out: number of parts */
0, /* first partition */
(unsigned char**)&this_mtd, /* out: extra mem */
mtd_id_len + 1 + sizeof(*this_mtd) +
sizeof(void*)-1 /*alignment*/);
if(!parts)
{
/*
* An error occurred. We're either:
* a) out of memory, or
* b) in the middle of the partition spec
* Either way, this mtd is hosed and we're
* unlikely to succeed in parsing any more
*/
return 0;
}
/* align this_mtd */
this_mtd = (struct <API key> *)
ALIGN((unsigned long)this_mtd, sizeof(void*));
/* enter results */
this_mtd->parts = parts;
this_mtd->num_parts = num_parts;
this_mtd->mtd_id = (char*)(this_mtd + 1);
strlcpy(this_mtd->mtd_id, mtd_id, mtd_id_len + 1);
/* link into chain */
this_mtd->next = partitions;
partitions = this_mtd;
dbg(("mtdid=<%s> num_parts=<%d>\n",
this_mtd->mtd_id, this_mtd->num_parts));
/* EOS - we're done */
if (*s == 0)
break;
/* does another spec follow? */
if (*s != ';')
{
printk(KERN_ERR ERRP "bad character after partition (%c)\n", *s);
return 0;
}
s++;
}
return 1;
}
/*
* Main function to be called from the MTD mapping driver/device to
* obtain the partitioning information. At this point the command line
* arguments will actually be parsed and turned to struct mtd_partition
* information. It returns partitions for the requested mtd device, or
* the first one in the chain if a NULL mtd_id is passed in.
*/
static int <API key>(struct mtd_info *master,
struct mtd_partition **pparts,
unsigned long origin)
{
unsigned long offset;
int i;
struct <API key> *part;
const char *mtd_id = master->name;
/* parse command line */
if (!cmdline_parsed)
mtdpart_setup_real(cmdline);
for(part = partitions; part; part = part->next)
{
if ((!mtd_id) || (!strcmp(part->mtd_id, mtd_id)))
{
for(i = 0, offset = 0; i < part->num_parts; i++)
{
if (part->parts[i].offset == OFFSET_CONTINUOUS)
part->parts[i].offset = offset;
else
offset = part->parts[i].offset;
if (part->parts[i].size == SIZE_REMAINING)
part->parts[i].size = master->size - offset;
if (offset + part->parts[i].size > master->size)
{
printk(KERN_WARNING ERRP
"%s: partitioning exceeds flash size, truncating\n",
part->mtd_id);
part->parts[i].size = master->size - offset;
part->num_parts = i;
}
offset += part->parts[i].size;
}
*pparts = kmemdup(part->parts,
sizeof(*part->parts) * part->num_parts,
GFP_KERNEL);
if (!*pparts)
return -ENOMEM;
return part->num_parts;
}
}
return 0;
}
/*
* This is the handler for our kernel parameter, called from
* main.c::checksetup(). Note that we can not yet kmalloc() anything,
* so we only save the commandline for later processing.
*
* This function needs to be visible for bootloaders.
*/
static int mtdpart_setup(char *s)
{
cmdline = s;
return 1;
}
__setup("mtdparts=", mtdpart_setup);
static struct mtd_part_parser cmdline_parser = {
.owner = THIS_MODULE,
.parse_fn = <API key>,
.name = "cmdlinepart",
};
static int __init cmdline_parser_init(void)
{
return register_mtd_parser(&cmdline_parser);
}
module_init(cmdline_parser_init);
MODULE_LICENSE("GPL");
MODULE_AUTHOR("Marius Groeger <mag@sysgo.de>");
MODULE_DESCRIPTION("Command line configuration of MTD partitions");
|
package FusionInventory::Agent::SNMP::MibSupport::Brocade;
use strict;
use warnings;
use parent 'FusionInventory::Agent::SNMP::MibSupportTemplate';
use FusionInventory::Agent::Tools;
use FusionInventory::Agent::Tools::SNMP;
use constant brocade => '.1.3.6.1.4.1.1991' ;
use constant serial => brocade .'.1.1.1.1.2.0' ;
use constant fw_pri => brocade . '.1.1.2.1.11.0' ;
our $mibSupport = [
{
name => "brocade-switch",
sysobjectid => getRegexpOidMatch(brocade)
}
];
sub getSerial {
my ($self) = @_;
return $self->get(serial);
}
sub getFirmware {
my ($self) = @_;
return $self->get(fw_pri);
}
1;
__END__
=head1 NAME
Inventory module for Brocade Switches
=head1 DESCRIPTION
The module enhances Brocade Switches devices support.
|
#ifndef <API key>
#define <API key>
// $Source: /Users/acg/CVSROOT/systemc-2.3/src/sysc/packages/boost/mpl/bool.hpp,v $
// $Revision: 1.2 $
#include <sysc/packages/boost/mpl/bool_fwd.hpp>
#include <sysc/packages/boost/mpl/integral_c_tag.hpp>
#include <sysc/packages/boost/mpl/aux_/config/static_constant.hpp>
<API key>
template< bool C_ > struct bool_
{
<API key>(bool, value = C_);
typedef integral_c_tag tag;
typedef bool_ type;
typedef bool value_type;
operator bool() const { return this->value; }
};
#if !defined(<API key>)
template< bool C_ >
bool const bool_<C_>::value;
#endif
<API key>
#endif // <API key>
|
#ifndef <API key>
#define <API key>
/*! \file
\brief Declares CommandParameter classes and the CommandParamType enum.
*/
#include <string>
#include <stdint.h>
namespace TPProto{
enum CommandParamType{
cpT_Invalid = -1,
cpT_String = 0,
cpT_Integer = 1,
cpT_Max
};
class Buffer;
/*! \brief Baseclass for holding a parameter for a Command.
*/
class CommandParameter{
public:
CommandParameter();
CommandParameter(const CommandParameter &rhs);
virtual ~CommandParameter();
virtual void packBuffer(Buffer* buf) = 0;
virtual bool unpackBuffer(Buffer* buf) = 0;
virtual CommandParameter* clone() = 0;
virtual bool setValueFromString(const std::string &nval) = 0;
std::string getName();
std::string getDescription();
void setName(const std::string &nn);
void setDescription(const std::string &nd);
private:
std::string name;
std::string description;
};
/*! \brief Holds a string CommandParameter.
*/
class <API key> : public CommandParameter{
public:
<API key>();
<API key>(const <API key> &rhs);
~<API key>();
void packBuffer(Buffer* buf);
bool unpackBuffer(Buffer* buf);
CommandParameter* clone();
bool setValueFromString(const std::string &nval);
unsigned int getMaxLength();
std::string getString();
void setString(const std::string &nval);
private:
unsigned int maxlength;
std::string value;
};
/*! \brief A CommandParameter that holds an integer.
*/
class <API key> : public CommandParameter{
public:
<API key>();
<API key>(const <API key> &rhs);
~<API key>();
void packBuffer(Buffer* buf);
bool unpackBuffer(Buffer* buf);
CommandParameter* clone();
bool setValueFromString(const std::string &nval);
uint32_t getValue() const;
void setValue(uint32_t nval);
private:
uint32_t value;
};
}
#endif
|
/* ftruncate was formerly an XOPEN extension. We define _XOPEN_SOURCE here to
avoid warning if the implementation does not program ftruncate as a base
interface */
#define _XOPEN_SOURCE 600
#include <stdio.h>
#include <sys/mman.h>
#include <sys/stat.h>
#include <unistd.h>
#include <string.h>
#include <fcntl.h>
#include "posixtest.h"
#define BUF_SIZE 8
#define SHM_NAME "posixtest_14-2"
int main() {
int fd;
char str[BUF_SIZE] = "qwerty";
char *buf;
fd = shm_open(SHM_NAME, O_RDWR|O_CREAT, S_IRUSR|S_IWUSR);
if (fd == -1) {
perror("An error occurs when calling shm_open()");
return PTS_UNRESOLVED;
}
if (ftruncate(fd, BUF_SIZE) != 0) {
perror("An error occurs when calling ftruncate()");
return PTS_UNRESOLVED;
}
buf = mmap(NULL, BUF_SIZE, PROT_WRITE, MAP_SHARED, fd, 0);
if (buf == MAP_FAILED) {
perror("An error occurs when calling mmap()");
return PTS_UNRESOLVED;
}
strcpy(buf, str);
fd = shm_open(SHM_NAME, O_RDWR, S_IRUSR|S_IWUSR);
if (fd == -1) {
perror("An error occurs when calling shm_open()");
return PTS_UNRESOLVED;
}
buf = mmap(NULL, BUF_SIZE, PROT_READ, MAP_SHARED, fd, 0);
if (buf == MAP_FAILED) {
perror("An error occurs when calling mmap()");
return PTS_UNRESOLVED;
}
shm_unlink(SHM_NAME);
if (strcmp(buf, str) == 0) {
printf("Test PASSED\n");
return PTS_PASS;
}
printf("Test FAILED\n");
return PTS_FAIL;
}
|
#include "message-view.h"
#include "adium-theme-view.h"
#include "<API key>.h"
#include <KTp/message-processor.h>
#include <KDebug>
#include <KIconLoader>
#include <QLabel>
#include <QResizeEvent>
#include <KTp/Logger/log-manager.h>
#include <KTp/Logger/pending-logger-logs.h>
#include <TelepathyQt/Account>
MessageView::MessageView(QWidget *parent) :
AdiumThemeView(parent),
m_infoLabel(new QLabel(this))
{
loadSettings();
QFont font = m_infoLabel->font();
font.setBold(true);
m_infoLabel->setFont(font);
m_infoLabel->setAlignment(Qt::AlignCenter);
connect(this, SIGNAL(loadFinished(bool)), SLOT(processStoredEvents()));
}
void MessageView::loadLog(const Tp::AccountPtr &account, const KTp::LogEntity &entity,
const Tp::ContactPtr &contact, const QDate &date,
const QPair< QDate, QDate > &nearestDates)
{
if (account.isNull() || !entity.isValid()) {
//note contact can be null
showInfoMessage(i18n("Unknown or invalid contact"));
return;
}
m_infoLabel->hide();
m_account = account;
// FIXME: Workaround for a bug, probably in QGlib which causes that
// m_entity = m_entity results in invalid m_entity->m_class being null
if (m_entity != entity) {
m_entity = entity;
}
m_contact = m_contact.dynamicCast<Tp::Contact>(contact);
m_date = date;
m_prev = nearestDates.first;
m_next = nearestDates.second;
if (entity.entityType() == Tp::HandleTypeRoom) {
load(AdiumThemeView::GroupChat);
} else {
load(AdiumThemeView::SingleUserChat);
}
Tp::Avatar avatar = m_account->avatar();
if (!avatar.avatarData.isEmpty()) {
m_accountAvatar = QString(QLatin1String("data:%1;base64,%2")).
/* Wait with initialization for the first event so that we can know when the chat session started */
/* Can't highlight the text directly, we need to wait for the JavaScript in
* AdiumThemeView to include the log messages into DOM. */
QTimer::singleShot(100, this, SLOT(doHighlightText()));
}
void MessageView::onLinkClicked(const QUrl &link)
{
// Don't emit the signal directly, KWebView does not like when we reload the
// page from an event handler (and then chain up) and we can't guarantee
// that everyone will use QueuedConnection when connecting to
// <API key>() slot
if (link.fragment() == QLatin1String("x-nextConversation")) {
// Q_EMIT <API key>(m_next)
QMetaObject::invokeMethod(this, "<API key>", Qt::QueuedConnection,
Q_ARG(QDate, m_next));
return;
}
if (link.fragment() == QLatin1String("x-prevConversation")) {
// Q_EMIT <API key>(m_prev)
QMetaObject::invokeMethod(this, "<API key>", Qt::QueuedConnection,
Q_ARG(QDate, m_prev));
return;
}
AdiumThemeView::onLinkClicked(link);
}
void MessageView::loadSettings()
{
const KConfig config(QLatin1String("ktelepathyrc"));
const KConfigGroup group = config.group("LogViewer");
m_sortMode = static_cast<SortMode>(group.readEntry("SortMode", static_cast<int>(SortOldestTop)));
}
void MessageView::reloadTheme()
{
loadSettings();
loadLog(m_account, m_entity, m_contact, m_date, qMakePair(m_prev, m_next));
}
void MessageView::doHighlightText()
{
findText(QString());
if (!m_highlightedText.isEmpty()) {
findText(m_highlightedText, QWebPage::<API key> |
QWebPage::<API key>);
}
}
|
<!DOCTYPE HTML PUBLIC "-
<!--NewPage
<HTML>
<HEAD>
<!-- Generated by javadoc (build 1.6.0_17) on Mon Jan 11 20:36:42 NZDT 2010 -->
<TITLE>
weka.classifiers.functions Class Hierarchy
</TITLE>
<META NAME="date" CONTENT="2010-01-11">
<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="weka.classifiers.functions Class Hierarchy";
}
}
</SCRIPT>
<NOSCRIPT>
</NOSCRIPT>
</HEAD>
<BODY BGCOLOR="white" onload="windowTitle();">
<HR>
<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"> <FONT CLASS="NavBarFont1">Class</FONT> </TD>
<TD BGCOLOR="#FFFFFF" CLASS="NavBarCell1Rev"> <FONT CLASS="NavBarFont1Rev"><B>Tree</B></FONT> </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="
</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="../../../weka/classifiers/evaluation/package-tree.html"><B>PREV</B></A>
<A HREF="../../../weka/classifiers/functions/neural/package-tree.html"><B>NEXT</B></A></FONT></TD>
<TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">
<A HREF="../../../index.html?weka/classifiers/functions/package-tree.html" target="_top"><B>FRAMES</B></A>
<A HREF="package-tree.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>
<HR>
<CENTER>
<H2>
Hierarchy For Package weka.classifiers.functions
</H2>
</CENTER>
<DL>
<DT><B>Package Hierarchies:</B><DD><A HREF="../../../overview-tree.html">All Packages</A></DL>
<HR>
<H2>
Class Hierarchy
</H2>
<UL>
<LI TYPE="circle">java.lang.Object<UL>
<LI TYPE="circle">weka.classifiers.<A HREF="../../../weka/classifiers/Classifier.html" title="class in weka.classifiers"><B>Classifier</B></A> (implements weka.core.<A HREF="../../../weka/core/CapabilitiesHandler.html" title="interface in weka.core">CapabilitiesHandler</A>, java.lang.Cloneable, weka.core.<A HREF="../../../weka/core/OptionHandler.html" title="interface in weka.core">OptionHandler</A>, weka.core.<A HREF="../../../weka/core/RevisionHandler.html" title="interface in weka.core">RevisionHandler</A>, java.io.Serializable)
<UL>
<LI TYPE="circle">weka.classifiers.functions.<A HREF="../../../weka/classifiers/functions/GaussianProcesses.html" title="class in weka.classifiers.functions"><B>GaussianProcesses</B></A> (implements weka.classifiers.<A HREF="../../../weka/classifiers/IntervalEstimator.html" title="interface in weka.classifiers">IntervalEstimator</A>, weka.core.<A HREF="../../../weka/core/OptionHandler.html" title="interface in weka.core">OptionHandler</A>, weka.core.<A HREF="../../../weka/core/<API key>.html" title="interface in weka.core"><API key></A>)
<LI TYPE="circle">weka.classifiers.functions.<A HREF="../../../weka/classifiers/functions/IsotonicRegression.html" title="class in weka.classifiers.functions"><B>IsotonicRegression</B></A> (implements weka.core.<A HREF="../../../weka/core/<API key>.html" title="interface in weka.core"><API key></A>)
<LI TYPE="circle">weka.classifiers.functions.<A HREF="../../../weka/classifiers/functions/LeastMedSq.html" title="class in weka.classifiers.functions"><B>LeastMedSq</B></A> (implements weka.core.<A HREF="../../../weka/core/OptionHandler.html" title="interface in weka.core">OptionHandler</A>, weka.core.<A HREF="../../../weka/core/<API key>.html" title="interface in weka.core"><API key></A>)
<LI TYPE="circle">weka.classifiers.functions.<A HREF="../../../weka/classifiers/functions/LibLINEAR.html" title="class in weka.classifiers.functions"><B>LibLINEAR</B></A> (implements weka.core.<A HREF="../../../weka/core/<API key>.html" title="interface in weka.core"><API key></A>)
<LI TYPE="circle">weka.classifiers.functions.<A HREF="../../../weka/classifiers/functions/LibSVM.html" title="class in weka.classifiers.functions"><B>LibSVM</B></A> (implements weka.core.<A HREF="../../../weka/core/<API key>.html" title="interface in weka.core"><API key></A>)
<LI TYPE="circle">weka.classifiers.functions.<A HREF="../../../weka/classifiers/functions/LinearRegression.html" title="class in weka.classifiers.functions"><B>LinearRegression</B></A> (implements weka.core.<A HREF="../../../weka/core/OptionHandler.html" title="interface in weka.core">OptionHandler</A>, weka.core.<A HREF="../../../weka/core/<API key>.html" title="interface in weka.core"><API key></A>)
<LI TYPE="circle">weka.classifiers.functions.<A HREF="../../../weka/classifiers/functions/Logistic.html" title="class in weka.classifiers.functions"><B>Logistic</B></A> (implements weka.core.<A HREF="../../../weka/core/OptionHandler.html" title="interface in weka.core">OptionHandler</A>, weka.core.<A HREF="../../../weka/core/<API key>.html" title="interface in weka.core"><API key></A>, weka.core.<A HREF="../../../weka/core/<API key>.html" title="interface in weka.core"><API key></A>)
<LI TYPE="circle">weka.classifiers.functions.<A HREF="../../../weka/classifiers/functions/<API key>.html" title="class in weka.classifiers.functions"><B><API key></B></A> (implements weka.core.<A HREF="../../../weka/core/OptionHandler.html" title="interface in weka.core">OptionHandler</A>, weka.core.<A HREF="../../../weka/core/Randomizable.html" title="interface in weka.core">Randomizable</A>, weka.core.<A HREF="../../../weka/core/<API key>.html" title="interface in weka.core"><API key></A>)
<LI TYPE="circle">weka.classifiers.functions.<A HREF="../../../weka/classifiers/functions/PaceRegression.html" title="class in weka.classifiers.functions"><B>PaceRegression</B></A> (implements weka.core.<A HREF="../../../weka/core/OptionHandler.html" title="interface in weka.core">OptionHandler</A>, weka.core.<A HREF="../../../weka/core/<API key>.html" title="interface in weka.core"><API key></A>, weka.core.<A HREF="../../../weka/core/<API key>.html" title="interface in weka.core"><API key></A>)
<LI TYPE="circle">weka.classifiers.functions.<A HREF="../../../weka/classifiers/functions/PLSClassifier.html" title="class in weka.classifiers.functions"><B>PLSClassifier</B></A><LI TYPE="circle">weka.classifiers.functions.<A HREF="../../../weka/classifiers/functions/RBFNetwork.html" title="class in weka.classifiers.functions"><B>RBFNetwork</B></A> (implements weka.core.<A HREF="../../../weka/core/OptionHandler.html" title="interface in weka.core">OptionHandler</A>)
<LI TYPE="circle">weka.classifiers.functions.<A HREF="../../../weka/classifiers/functions/<API key>.html" title="class in weka.classifiers.functions"><B><API key></B></A> (implements weka.core.<A HREF="../../../weka/core/<API key>.html" title="interface in weka.core"><API key></A>)
<LI TYPE="circle">weka.classifiers.functions.<A HREF="../../../weka/classifiers/functions/SimpleLogistic.html" title="class in weka.classifiers.functions"><B>SimpleLogistic</B></A> (implements weka.core.<A HREF="../../../weka/core/<API key>.html" title="interface in weka.core"><API key></A>, weka.core.<A HREF="../../../weka/core/OptionHandler.html" title="interface in weka.core">OptionHandler</A>, weka.core.<A HREF="../../../weka/core/<API key>.html" title="interface in weka.core"><API key></A>, weka.core.<A HREF="../../../weka/core/<API key>.html" title="interface in weka.core"><API key></A>)
<LI TYPE="circle">weka.classifiers.functions.<A HREF="../../../weka/classifiers/functions/SMO.html" title="class in weka.classifiers.functions"><B>SMO</B></A> (implements weka.core.<A HREF="../../../weka/core/<API key>.html" title="interface in weka.core"><API key></A>, weka.core.<A HREF="../../../weka/core/<API key>.html" title="interface in weka.core"><API key></A>)
<LI TYPE="circle">weka.classifiers.functions.<A HREF="../../../weka/classifiers/functions/SMOreg.html" title="class in weka.classifiers.functions"><B>SMOreg</B></A> (implements weka.core.<A HREF="../../../weka/core/<API key>.html" title="interface in weka.core"><API key></A>, weka.core.<A HREF="../../../weka/core/<API key>.html" title="interface in weka.core"><API key></A>, weka.core.<A HREF="../../../weka/core/<API key>.html" title="interface in weka.core"><API key></A>)
<LI TYPE="circle">weka.classifiers.functions.<A HREF="../../../weka/classifiers/functions/VotedPerceptron.html" title="class in weka.classifiers.functions"><B>VotedPerceptron</B></A> (implements weka.core.<A HREF="../../../weka/core/OptionHandler.html" title="interface in weka.core">OptionHandler</A>, weka.core.<A HREF="../../../weka/core/<API key>.html" title="interface in weka.core"><API key></A>)
<LI TYPE="circle">weka.classifiers.functions.<A HREF="../../../weka/classifiers/functions/Winnow.html" title="class in weka.classifiers.functions"><B>Winnow</B></A> (implements weka.core.<A HREF="../../../weka/core/<API key>.html" title="interface in weka.core"><API key></A>, weka.classifiers.<A HREF="../../../weka/classifiers/<API key>.html" title="interface in weka.classifiers"><API key></A>)
</UL>
<LI TYPE="circle">weka.classifiers.functions.<A HREF="../../../weka/classifiers/functions/SMO.BinarySMO.html" title="class in weka.classifiers.functions"><B>SMO.BinarySMO</B></A> (implements java.io.Serializable)
</UL>
</UL>
<HR>
<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="<API key>"></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"> <FONT CLASS="NavBarFont1">Class</FONT> </TD>
<TD BGCOLOR="#FFFFFF" CLASS="NavBarCell1Rev"> <FONT CLASS="NavBarFont1Rev"><B>Tree</B></FONT> </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="
</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="../../../weka/classifiers/evaluation/package-tree.html"><B>PREV</B></A>
<A HREF="../../../weka/classifiers/functions/neural/package-tree.html"><B>NEXT</B></A></FONT></TD>
<TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">
<A HREF="../../../index.html?weka/classifiers/functions/package-tree.html" target="_top"><B>FRAMES</B></A>
<A HREF="package-tree.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>
<HR>
</BODY>
</HTML>
|
field_dict={'ROME-FIELD-01':[ 267.835895375 , -30.0608178195 , '17:51:20.6149','-30:03:38.9442' ],
'ROME-FIELD-02':[ 269.636745458 , -27.9782661111 , '17:58:32.8189','-27:58:41.758' ],
'ROME-FIELD-03':[ 268.000049542 , -28.8195573333 , '17:52:00.0119','-28:49:10.4064' ],
'ROME-FIELD-04':[ 268.180171708 , -29.27851275 , '17:52:43.2412','-29:16:42.6459' ],
'ROME-FIELD-05':[ 268.35435 , -30.2578356389 , '17:53:25.044','-30:15:28.2083' ],
'ROME-FIELD-06':[ 268.356124833 , -29.7729819283 , '17:53:25.47','-29:46:22.7349' ],
'ROME-FIELD-07':[ 268.529571333 , -28.6937071111 , '17:54:07.0971','-28:41:37.3456' ],
'ROME-FIELD-08':[ 268.709737083 , -29.1867251944 , '17:54:50.3369','-29:11:12.2107' ],
'ROME-FIELD-09':[ 268.881108542 , -29.7704673333 , '17:55:31.4661','-29:46:13.6824' ],
'ROME-FIELD-10':[ 269.048498333 , -28.6440675 , '17:56:11.6396','-28:38:38.643' ],
'ROME-FIELD-11':[ 269.23883225 , -29.2716684211 , '17:56:57.3197','-29:16:18.0063' ],
'ROME-FIELD-12':[ 269.39478875 , -30.0992361667 , '17:57:34.7493','-30:05:57.2502' ],
'ROME-FIELD-13':[ 269.563719375 , -28.4422328996 , '17:58:15.2927','-28:26:32.0384' ],
'ROME-FIELD-14':[ 269.758843 , -29.1796030365 , '17:59:02.1223','-29:10:46.5709' ],
'ROME-FIELD-15':[ 269.78359875 , -29.63940425 , '17:59:08.0637','-29:38:21.8553' ],
'ROME-FIELD-16':[ 270.074981708 , -28.5375585833 , '18:00:17.9956','-28:32:15.2109' ],
'ROME-FIELD-17':[ 270.81 , -28.0978333333 , '18:03:14.4','-28:05:52.2' ],
'ROME-FIELD-18':[ 270.290886667 , -27.9986032778 , '18:01:09.8128','-27:59:54.9718' ],
'ROME-FIELD-19':[ 270.312763708 , -29.0084241944 , '18:01:15.0633','-29:00:30.3271' ],
'ROME-FIELD-20':[ 270.83674125 , -28.8431573889 , '18:03:20.8179','-28:50:35.3666' ]}
|
<?php
include("config_mynonprofit.php");
include("connect.php");
//Start session
session_start();
//Array to store validation errors
$errmsg_arr = array();
//Validation error flag
$errflag = false;
//Sanitize the POST values
$fname = htmlentities($_POST['fname']);
$lname = htmlentities($_POST['lname']);
$email = htmlentities($_POST['email']);
$username = htmlentities($_POST['username']);
$member_type = htmlentities($_POST['member_type']);
$password = htmlentities($_POST['password']);
$cpassword = htmlentities($_POST['cpassword']);
$today = date('Y-m-d H:i:s');
$hash = md5($today);
//Input Validations
if ($fname == '') {
$errmsg_arr[] = 'First name missing';
$errflag = true;
}
if ($lname == '') {
$errmsg_arr[] = 'Last name missing';
$errflag = true;
}
if ($email == '') {
$errmsg_arr[] = 'Email missing';
$errflag = true;
}
if ($username == '') {
$errmsg_arr[] = 'Username missing';
$errflag = true;
}
if ($password == '') {
$errmsg_arr[] = 'Password missing';
$errflag = true;
}
if ($cpassword == '') {
$errmsg_arr[] = 'Confirm password missing';
$errflag = true;
}
if (strcmp($password, $cpassword) != 0) {
$errmsg_arr[] = 'Passwords do not match';
$errflag = true;
}
//Check for duplicate username
if ($username != '') {
$query = $db->prepare('SELECT * FROM members WHERE username=:username');
$query->execute(array('username' => $username));
if ($query->rowCount() > 0) {
$errmsg_arr[] = 'Username already in use';
$errflag = true;
}
}
//If there are input validations, redirect back to the registration form
if ($errflag) {
$_SESSION['ERRMSG_ARR'] = $errmsg_arr;
session_write_close();
header("location: registration.php");
exit();
}
$password2 = md5($password);
if ($member_type != 'General') {
$to = 'ruthwitte@gmail.com, bjwitte@gmail.com';
$subject = 'New member requesting membership type.';
$body = 'New member ' . $username . ' ' . $fname . ' ' . $lname . ' ' . $email . ' requesting membership type of ' . $member_type . '';
$headers = "From: mygp@growingplaces.cc\r\n" .
mail($to, $subject, $body, $headers);
}
//Create INSERT query
$query2 = $db->prepare('INSERT INTO members(firstname, lastname, email, username, password, date_registered, member_type, confirm_hash, auth_type) VALUES(:fname,:lname,:email,:username,:password,:today ,"General",:hash, 0)');
$result = $query2->execute(array('fname' => $fname, 'lname' => $lname, 'email' => $email, 'username' => $username, 'password' => $password2, 'today' => $today, 'hash' => $hash));
$member_id = $db->lastInsertId('member_id');
if (is_array($_POST['volunteertypes'])) {
$query4 = $db->prepare('INSERT INTO <API key> (volunteer_type_id, member_id) VALUES (:checked ,:member_id)');
foreach ($_POST['volunteertypes'] as $checked) {
$query4->execute(array('checked' => $checked, 'member_id' => $member_id));
}
}
//Check whether the query was successful or not
if ($result) {
$to = $email;
$subject = "" . $site_name . " Confirmation";
$message = "<html><head><title>" . $site_name . " Confirmation</title></head><body><p> Click the following link to confirm your registration information.</p><a href='http:
$headers = "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/html; charset=iso-8859-1\r\n";
$headers .= "From: mygp@growingplaces.cc\r\n";
$mailed = mail($to, $subject, $message, $headers);
header("location: register-success.php");
exit();
} else {
die("Query failed");
}
?>
|
<script type="text/javascript">
jQuery(document).ready(function() {
// type of media
jQuery('#type').change(function() {
switch (jQuery(this).val()) {
case '<?php echo MEDIA_TYPE_EMAIL; ?>':
jQuery('#smtp_server, #smtp_helo, #smtp_email').closest('li').removeClass('hidden');
jQuery('#exec_path, #gsm_modem, #jabber_username, #eztext_username, #eztext_limit, #passwd')
.closest('li')
.addClass('hidden');
jQuery('#eztext_link').addClass('hidden');
break;
case '<?php echo MEDIA_TYPE_EXEC; ?>':
jQuery('#exec_path').closest('li').removeClass('hidden');
jQuery('#smtp_server, #smtp_helo, #smtp_email, #gsm_modem, #jabber_username, #eztext_username, #eztext_limit, #passwd')
.closest('li')
.addClass('hidden');
jQuery('#eztext_link').addClass('hidden');
break;
case '<?php echo MEDIA_TYPE_SMS; ?>':
jQuery('#gsm_modem').closest('li').removeClass('hidden');
jQuery('#smtp_server, #smtp_helo, #smtp_email, #exec_path, #jabber_username, #eztext_username, #eztext_limit, #passwd')
.closest('li')
.addClass('hidden');
jQuery('#eztext_link').addClass('hidden');
break;
case '<?php echo MEDIA_TYPE_JABBER; ?>':
jQuery('#jabber_username, #passwd').closest('li').removeClass('hidden');
jQuery('#smtp_server, #smtp_helo, #smtp_email, #exec_path, #gsm_modem, #eztext_username, #eztext_limit')
.closest('li')
.addClass('hidden');
jQuery('#eztext_link').addClass('hidden');
break;
case '<?php echo <API key>; ?>':
jQuery('#eztext_username, #eztext_limit, #passwd').closest('li').removeClass('hidden');
jQuery('#eztext_link').removeClass('hidden');
jQuery('#smtp_server, #smtp_helo, #smtp_email, #exec_path, #gsm_modem, #jabber_username')
.closest('li')
.addClass('hidden');
break;
}
});
// clone button
jQuery('#clone').click(function() {
jQuery('#mediatypeid, #delete, #clone').remove();
jQuery('#update span').text(<?php echo CJs::encodeJson(_('Add')); ?>);
jQuery('#update').val('mediatype.create').attr({id: 'add'});
jQuery('#cancel').addClass('ui-corner-left');
jQuery('#description').focus();
});
// trim spaces on sumbit
jQuery('#mediaTypeForm').submit(function() {
jQuery('#description').val(jQuery.trim(jQuery('#description').val()));
jQuery('#smtp_server').val(jQuery.trim(jQuery('#smtp_server').val()));
jQuery('#smtp_helo').val(jQuery.trim(jQuery('#smtp_helo').val()));
jQuery('#smtp_email').val(jQuery.trim(jQuery('#smtp_email').val()));
jQuery('#exec_path').val(jQuery.trim(jQuery('#exec_path').val()));
jQuery('#gsm_modem').val(jQuery.trim(jQuery('#gsm_modem').val()));
jQuery('#jabber_username').val(jQuery.trim(jQuery('#jabber_username').val()));
jQuery('#eztext_username').val(jQuery.trim(jQuery('#eztext_username').val()));
});
// refresh field visibility on document load
jQuery('#type').trigger('change');
});
</script>
|
/*
* Loader. loads an a.out into the memory.
*/
/* The starting address for the text (code) section - 64K of code. */
#define I_ADDRESS 0x600000
/* The starting address for the data section - 64K of data. */
#define D_ADDRESS 0x800000
typedef unsigned short uint16_t;
typedef unsigned long uint32_t;
typedef struct {
uint16_t magic __PACKED__; /* Magic number. */
uint16_t version __PACKED__; /* Version number. */
uint32_t code_size __PACKED__; /* Text segment size. */
uint32_t data_size __PACKED__; /* Initialized data size. */
uint32_t bss_size __PACKED__; /* Uninitialized data size. */
uint32_t syms_size __PACKED__;
uint32_t entry __PACKED__;
uint32_t code_offset __PACKED__;
uint32_t data_offset __PACKED__;
} aout_head_t; /* 28 bytes */
/*
* Since the OS does not have File I/O code yet, we need an image
* pointer that points to the file I have not figured out a way to do
* that yet, one reason is that we have no file system in the OS yet.
*/
/*
* Entry is the entry point of the program.
*/
int load_aout(char *filename, unsigned char *image, unsigned *entry)
{
/*
* Load the a.out format file filename.
*
* Read the text segment from the file to I_ADDRESS.
*
* Read the data segment from the file to D_ADDRESS. Zero out the BSS segment.
*
* Create and map in a stack segment (usually separate from the data
* segment, since the data heap and stack grow separately.) Place
* arguments from the command line or calling program on the stack.
*
* Set registers appropriately and jump to the starting address.
*/
aout_head_t *aout;
/* Validate headers. */
aout = (aout_head_t *) image;
image += sizeof(aout_head_t); /* Move to the code section. */
/* Get entry point. */
(*entry) = aout->entry;
/* Load text to I_ADDRESS.
*
* Copy aout->code_size bytes of code starting at image +
* code_offset to I_ADDRESS. */
image += aout->code_size;
/* Load DATA to D_ADDRESS.
*
* Copy aout->data_size bytes of code starting at image +
* data_offset to D_ADDRESS. */
image += aout->data_size;
/* Set uninitialized data to 0. */
/* Copy bss_size bytes of 0 starting at D_ADDRESS + aout->data_size. */
}
|
<h2>Methods run, sorted chronologically</h2><h3>>> means before, << means after</h3><p/><br/><em>Default suite</em><p/><small><i>(Hover the method name to see the test class name)</i></small><p/>
<table border="1">
<tr><th>Time</th><th>Delta (ms)</th><th>Suite<br>configuration</th><th>Test<br>configuration</th><th>Class<br>configuration</th><th>Groups<br>configuration</th><th>Method<br>configuration</th><th>Test<br>method</th><th>Thread</th><th>Instances</th></tr>
<tr bgcolor="756c8c"> <td>15/10/03 22:12:02</td> <td>0</td> <td> </td><td title=">>InitializeWebDriver.setUp()[pri:0, instance:testcases.module.login.LoginTest@4b5bc191]">>>setUp</td>
<td> </td><td> </td><td> </td><td> </td> <td>main@63390789</td> <td></td> </tr>
<tr bgcolor="756c8c"> <td>15/10/03 22:14:00</td> <td>118087</td> <td> </td><td title="<<InitializeWebDriver.tearDown()[pri:0, instance:testcases.module.login.LoginTest@4b5bc191]"><<tearDown</td>
<td> </td><td> </td><td> </td><td> </td> <td>main@63390789</td> <td></td> </tr>
<tr bgcolor="e09bd6"> <td>15/10/03 22:13:25</td> <td>83119</td> <td> </td><td> </td><td> </td><td> </td><td> </td><td title="LoginTest.testcaseone()[pri:0, instance:testcases.module.login.LoginTest@4b5bc191]">testcaseone</td>
<td>main@63390789</td> <td></td> </tr>
</table>
|
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <sys/shm.h>
#include "../include/RootDir.h"
#include "../include/fatSupport.h"
#include "../include/Shared_Info.h"
#define <API key> 512
#define BLUE "\x1B[1;36m" // for listing directories as blue
#define RESET "\033[0m"
#define BOLD "\033[1m"
FILE* FILE_SYSTEM_ID;
int BYTES_PER_SECTOR;
char* NEW_DIR;
Shared_Info *CUR_DIR;
void usage();
char* readFile(char*, char*[]);
char* readFileNonRoot(char*);
void getSharedMem(int, key_t, char*, char*);
void createSharedMem(int, key_t, char*, char*);
char* readFAT12Table(char*);
int main(int argc, char *argv[])
{
int fd[2], nbytes;
int i = 0, j = 0;
char *buffer;
int shmid;
key_t key;
char *shm, *s, *pch, tmp[9], *tmp_cur;
CUR_DIR = malloc(sizeof(Shared_Info));
// Read shared memory from terminal
getSharedMem(shmid, key, shm, s);
char *trunk[CUR_DIR->FLC];
if (argc != 2) {
usage();
return 1;
}
NEW_DIR = malloc(sizeof(argv));
strcpy(NEW_DIR, argv[argc - 1]);
FILE_SYSTEM_ID = fopen(CUR_DIR->img, "r+");
if (FILE_SYSTEM_ID == NULL)
{
fprintf(stderr, "Could not open the floppy drive or image.\n");
exit(1);
}
// Set it to this only to read the boot sector
BYTES_PER_SECTOR = <API key>;
buffer = (char*) malloc(32 * sizeof(char));
if (strcmp(NEW_DIR, "..") != 0) {
tmp_cur = malloc(sizeof(CUR_DIR->path));
strcpy(tmp_cur, CUR_DIR->path);
i = 0;
pch = strtok(tmp_cur, " /");
while (pch != NULL) {
trunk[i] = pch;
pch = strtok(NULL, " /");
i++;
}
if (strcmp(CUR_DIR->path, "/") == 0)
buffer = readFile(buffer, trunk); // Read directory sectors into buffer
else
buffer = readFileNonRoot(buffer);
} else {
tmp_cur = malloc(sizeof(CUR_DIR->path));
strcpy(tmp_cur, CUR_DIR->path);
pch = strtok(tmp_cur, " /");
while (pch != NULL) {
strcpy(tmp, pch);
pch = strtok(NULL, " /");
}
strcpy(tmp_cur, CUR_DIR->path);
strcpy(CUR_DIR->path, "/");
pch = strtok(tmp_cur, " /");
while (strcmp(pch, tmp) != 0) {
strcat(CUR_DIR->path, pch);
strcat(CUR_DIR->path, "/");
pch = strtok(NULL, " /");
}
CUR_DIR->FLC = CUR_DIR->OLD_FLC;
}
// Free data
free(buffer);
buffer = NULL;
fclose(FILE_SYSTEM_ID);
// Push new shared data to terminal
createSharedMem(shmid, key, shm, s);
exit(EXIT_SUCCESS);
}
char* readFAT12Table(char* buffer) {
int i = 0;
// Read in FAT table to buffer
for (i = 1; i <= 9; i++) {
if (read_sector(i, (buffer + BYTES_PER_SECTOR * (i - 1))) == -1) {
fprintf(stderr, "Something has gone wrong -- could not read the sector\n");
}
}
return buffer;
}
void createSharedMem(int shmid, key_t key, char * shm, char * s) {
key = 5678;
int i = 0;
Shared_Info* tmp;
if ((shmid = shmget(key, sizeof(Shared_Info*), IPC_CREAT | 0666)) < 0) {
perror("shmget");
exit(1);
}
if ((tmp = shmat(shmid, NULL, 0)) == (Shared_Info*) -1) {
perror("shmat");
exit(1);
}
tmp = CUR_DIR;
tmp = NULL;
//s = shm;
// Write current path to shared memory
//for (i = 0; i < sizeof(CUR_DIR->path); i++)
// *s++ = CUR_DIR->path[i];
|
<?php
/**
* DO NOT CHANGE
*/
if (!defined('IN_PHPBB'))
{
exit;
}
if (empty($lang) || !is_array($lang))
{
$lang = array();
}
// DEVELOPERS PLEASE NOTE
// All language files should use UTF-8 as their encoding and the files must not contain a BOM.
// Placeholders can now contain order information, e.g. instead of
// 'Page %s of %s' you can (and should) write 'Page %1$s of %2$s', this allows
// translators to re-order the output of data while ensuring it remains correct
// You do not need this where single placeholders are used, e.g. 'Message %d' is fine
// equally where a string contains only two placeholders which are used to wrap text
// in a url you again do not need to specify an order e.g., 'Click %sHERE%s' is fine
// Some characters you may want to copy&paste:
$lang = array_merge($lang, array(
'SO_SELECT' => 'Κοινοποίηση στο',
'SHARE_TOPIC' => 'Κοινοποίηση αυτού του θέματος στο',
'SHARE_POST' => 'Κοινοποίηση αυτής της απάντησης στο',
// Share On viewtopic.php
'SHARE_ON_FACEBOOK' => 'Κοινοποίηση στο Facebook',
'SHARE_ON_TWITTER' => 'Κοινοποίηση στο Twitter',
'SHARE_ON_TUENTI' => 'Κοινοποίηση στο Tuenti',
'SHARE_ON_DIGG' => 'Κοινοποίηση στο Digg',
'SHARE_ON_REDDIT' => 'Κοινοποίηση στο Reddit',
'SHARE_ON_DELICIOUS' => 'Κοινοποίηση στο Delicious',
'SHARE_ON_VK' => 'Κοινοποίηση στο VK',
'SHARE_ON_TUMBLR' => 'Κοινοποίηση στο Tumblr',
'SHARE_ON_GOOGLE' => 'Κοινοποίηση στο Google+',
'SHARE_ON_WHATSAPP' => 'Κοινοποίηση στο Whatsapp',
'SHARE_ON_POCKET' => 'Κοινοποίηση στο Pocket',
));
|
<?xml version="1.0" encoding="US-ASCII"?> <!DOCTYPE html PUBLIC "-
<!-- Authors: <API key> --> <dt><a name="<API key>">[<API key>]</a></dt><dd><API key>. <API key>.</dd>
<!-- Authors: Ken Thompson --> <dt><a name="Thompson:1968">[Thompson, 1968]</a></dt><dd>Ken Thompson. Programming techniques: Regular expression search algorithm. <cite>Communications of the ACM</cite>, 11(6):419&
<!-- Authors: Alfred V Aho and John E Hopcroft and Jeffrey D Ullman --> <dt><a name="RedDragon">[Aho et al., 1974]</a></dt><dd>Alfred V. Aho, John E. Hopcroft, and Jeffrey D. Ullman. <cite>The Design and Analysis of Computer Algorithms</cite>. Addison-Wesley, Reading, MA, 1974.</dd>
<!-- Authors: Harold Abelson and Gerald Jay Sussman and Jullie Sussman --> <dt><a name="SICP">[Abelson et al., 1985]</a></dt><dd>Harold Abelson, Gerald Jay Sussman, and Jullie Sussman. <cite>Structure and Interpretation of Computer Programs</cite>. MIT Press, Cambridge, 1985.</dd>
<!-- Authors: Adele Goldberg and David Robson --> <dt><a name="Smalltalk">[Goldberg and Robson, 1989]</a></dt><dd>Adele Goldberg and David Robson. <cite>Smalltalk-80: The Language</cite>. Addison-Wesley, Reading, MA, 1989.</dd>
<!-- Authors: Diomidis Spinellis --> <dt><a name="Spinellis:1990">[Spinellis, 1990]</a></dt><dd><strong>Diomidis Spinellis</strong>. An implementation of the Haskell language. Master's thesis, Imperial College, London, UK, June 1990. (<a href="http:
<!-- Authors: Diomidis Spinellis --> <dt><a name="Spinellis:1993">[Spinellis, 1993]</a></dt><dd><strong>Diomidis Spinellis</strong>. <a href="http://www.dmst.aueb.gr/dds/pubs/jrnl/<API key>/html/exp.html">Implementing Haskell: Language implementation as a tool building exercise</a>. <cite>Structured Programming (Software Concepts and Tools)</cite>, 14:37–48, 1993.</dd>
<!-- Authors: Diomidis Spinellis --> <dt><a name="Spinellis:1994">[Spinellis, 1994]</a></dt><dd><strong>Diomidis Spinellis</strong>. <cite>Programming Paradigms as Object Classes: A Structuring Mechanism for Multiparadigm Programming</cite>. PhD thesis, Imperial College of Science, Technology and Medicine, London, UK, February 1994. (<a href="http:
<!-- Authors: Diomidis Spinellis --> <dt><a name="Spinellis:1996">[Spinellis, 1996]</a></dt><dd><strong>Diomidis Spinellis</strong>. <a href="http:
<!-- Authors: Stefanos Gritzalis and Diomidis Spinellis and Panagiotis Georgiadis --> <dt><a name="Gritzalis:1999">[Gritzalis et al., 1999]</a></dt><dd>Stefanos Gritzalis, <strong>Diomidis Spinellis</strong>, and Panagiotis Georgiadis. <a href="http://www.dmst.aueb.gr/dds/pubs/jrnl/<API key>/html/formal.htm">Security protocols over open networks and distributed systems: Formal methods for their analysis, design, and verification</a>. <cite>Computer Communications</cite>, 22(8):695&
<!-- Authors: Diomidis Spinellis --> <dt><a name="Spinellis:2000">[Spinellis, 2000]</a></dt><dd><strong>Diomidis Spinellis</strong>. <a href="http://www.dmst.aueb.gr/dds/pubs/conf/2000-Usenix-outwit/html/utool.html">Outwit: Unix tool-based programming meets the Windows world</a>. In Christopher Small, editor, <cite>USENIX 2000 Technical Conference Proceedings</cite>, pages 149–158, Berkeley, CA, June 2000. Usenix Association.</dd>
<!-- Authors: Albert Laszlo Barabasi and Monica Ferreira da Silva and F Paterno and Wladyslaw M Turski and Sten AAke Tarnlund and Ketil Bo and J Encarnaccao and <API key> <API key> and Pesster vCuezog --> <dt><a name="XXX00">[Barabási et al., 2000]</a></dt><dd>Albert-László Barabási, Mônica Ferreira da Silva, F. Paternò, Władysław M. Turski, Sten-Åke Tärnlund, Ketil Bø, J. Encarnação, Διομηδης Σπινελλης, and Pëßtêr Čĕżōġ. Cite this paper. <cite>¡Journal of Authors Against ASCII!</cite>, 45(281):69–77, 2000.</dd>
<!-- Authors: Elizabeth Zwicky and Simon Cooper and D Brent Chapman --> <dt><a name="Firewalls">[Zwicky et al., 2000]</a></dt><dd>Elizabeth Zwicky, Simon Cooper, and D. Brent Chapman. <cite>Building Internet Firewalls</cite>. O'Reilly and Associates, Sebastopol, CA, second edition, 2000.</dd>
<!-- Authors: Diomidis Spinellis --> <dt><a name="Spinellis:2003">[Spinellis, 2003]</a></dt><dd><strong>Diomidis Spinellis</strong>. <a href="http://www.dmst.aueb.gr/dds/pubs/jrnl/2003-CACM-URLcite/html/urlcite.html">The decay and failures of web references</a>. <cite>Communications of the ACM</cite>, 46(1):71&
<!-- Authors: Diomidis Spinellis --> <dt><a name="Spinellis:2003b">[Spinellis, 2003]</a></dt><dd><strong>Diomidis Spinellis</strong>. <a href="http://www.dmst.aueb.gr/dds/pubs/jrnl/2003-TSE-Refactor/html/Spi03r.html">Global analysis and transformations in preprocessed languages</a>. <cite>IEEE Transactions on Software Engineering</cite>, 29(11):1019&
<!-- Authors: Diomidis Spinellis --> <dt><a name="CodeReading">[Spinellis, 2003]</a></dt><dd><strong>Diomidis Spinellis</strong>. <a href="http:
<!-- Authors: Stephanos Androutsellis Theotokis and Diomidis Spinellis --> <dt><a name="Androutsellis:2004">[<API key> and Spinellis, 2004]</a></dt><dd>Stephanos <API key> and <strong>Diomidis Spinellis</strong>. <a href="http://www.dmst.aueb.gr/dds/pubs/jrnl/2004-ACMCS-p2p/html/AS04.html">A survey of peer-to-peer content distribution technologies</a>. <cite>ACM Computing Surveys</cite>, 36(4):335&
<!-- Authors: Diomidis Spinellis --> <dt><a name="Spi06i">[Spinellis, 2006]</a></dt><dd><strong>Diomidis Spinellis</strong>. Open source and professional advancement. <cite>IEEE Software</cite>, 23(5):70&
<!-- Authors: Firstć Lastž and Second Thirdäöü --> <dt><a name="<API key>">[Lastž and Thirdäöü, 2018]</a></dt><dd>Firstć Lastž and Second Thirdäöü. Just a title. In <cite>Pattern Recognition</cite>, 2018.</dd>
</dl>
<!-- END BIBLIOGRAPHY example --> </body></html>
|
# -*- coding: utf-8 -*-
from scrapy.spider import Spider
from scrapy.selector import Selector
from kgrants.items import KgrantsItem
from scrapy.http import Request
import time
class GrantsSpider(Spider):
name = "grants"
allowed_domains = ["www.knightfoundation.org"]
pages = 1
base_url = 'http:
start_url_str = 'http:
def __init__(self, pages=None, *args, **kwargs):
super(GrantsSpider, self).__init__(*args, **kwargs)
if pages is not None:
self.pages = pages
self.start_urls = [ self.start_url_str % str(page) for page in xrange(1,int(self.pages)+1)]
def parse(self, response):
hxs = Selector(response)
projects = hxs.xpath('//article')
for project in projects:
time.sleep(2)
project_url = self.base_url + ''.join(project.xpath('a/@href').extract())
grants = KgrantsItem()
grants['page'] = project_url
grants['project'] = ''.join(project.xpath('a/div/header/h1/text()').extract()).strip()
grants['description'] = ''.join(project.xpath('p/text()').extract()).strip()
yield Request(grants['page'],
callback = self.parse_project,
meta={'grants':grants})
def parse_project(self,response):
hxs = Selector(response)
grants = response.meta['grants']
details = hxs.xpath('//section[@id="grant_info"]')
fields = hxs.xpath('
values = hxs.xpath('
self.log('field: <%s>' % fields.extract())
for item in details:
grants['fiscal_agent'] = ''.join(item.xpath('header/h2/text()').extract()).strip()
count = 0
for field in fields:
normalized_field = ''.join(field.xpath('text()').extract()).strip().lower().replace(' ','_')
self.log('field: <%s>' % normalized_field)
try:
grants[normalized_field] = values.xpath('text()').extract()[count]
except:
if normalized_field == 'community':
grants[normalized_field] = values.xpath('a/text()').extract()[1]
elif normalized_field == 'focus_area':
grants[normalized_field] = values.xpath('a/text()').extract()[0]
count += 1
grants['<API key>'] = ''.join(
item.xpath('section[@id="grant_contact"]/ul/li[@class="email"]/a/@href').extract()).replace('mailto:','').strip()
grants['<API key>'] = ''.join(
item.xpath('section[@id="grant_contact"]/ul/li[@class="email"]/a/text()').extract()).strip()
grants['<API key>'] = ''.join(
item.xpath('section[@id="grant_contact"]/ul/li[@class="location"]/text()').extract()).strip()
grants['<API key>'] = ''.join(
item.xpath('section[@id="grant_contact"]/ul/li[@class="facebook"]/a/@href').extract()).strip()
grants['<API key>'] = item.xpath('section[@id="grant_contact"]/ul/li[@class="twitter"]/a/@href').extract()
grants['<API key>'] = item.xpath('section[@id="grant_contact"]/ul/li[@class="website"]/a/@href').extract()
if 'grant_period' in grants:
grant_period = grants['grant_period'].split(' to ')
grants['grant_period_start'] = grant_period[0]
grants['grant_period_end'] = grant_period[1]
yield grants
|
package co.innovate.rentavoz.services.almacen.impl;
import java.io.Serializable;
import java.util.Date;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import co.innovate.rentavoz.model.Tercero;
import co.innovate.rentavoz.model.almacen.Cuota;
import co.innovate.rentavoz.model.almacen.venta.Venta;
import co.innovate.rentavoz.repositories.GenericRepository;
import co.innovate.rentavoz.repositories.almacen.CuotaDao;
import co.innovate.rentavoz.services.almacen.CuotaService;
import co.innovate.rentavoz.services.impl.GenericServiceImpl;
/**
* @author <a href="mailto:elmerdiazlazo@gmail.com">Elmer Jose Diaz Lazo</a>
* @project rentavoz3
* @class CuotaServiceImpl
* @date 7/02/2014
*
*/
@Service("cuotaService")
public class CuotaServiceImpl extends GenericServiceImpl<Cuota, Integer> implements CuotaService,Serializable {
/**
* 7/02/2014
* @author <a href="mailto:elmerdiazlazo@gmail.com">Elmer Jose Diaz Lazo</a>
* serialVersionUID
*/
private static final long serialVersionUID = 1L;
@Autowired
private CuotaDao cuotaDao;
/* (non-Javadoc)
* @see co.innovate.rentavoz.services.impl.GenericServiceImpl#getDao()
*/
@Override
public GenericRepository<Cuota, Integer> getDao() {
return cuotaDao;
}
/* (non-Javadoc)
* @see co.innovate.rentavoz.services.almacen.CuotaService#<API key>(co.innovate.rentavoz.model.Tercero)
*/
@Override
public List<Cuota> <API key>(Tercero cliente) {
return cuotaDao.<API key>(cliente);
}
/* (non-Javadoc)
* @see co.innovate.rentavoz.services.almacen.CuotaService#<API key>(co.innovate.rentavoz.model.Tercero)
*/
@Override
public List<Cuota> <API key>(Tercero cobrador) {
return cuotaDao.<API key>(cobrador);
}
/* (non-Javadoc)
* @see co.innovate.rentavoz.services.almacen.CuotaService#findByVenta(co.innovate.rentavoz.model.almacen.venta.Venta)
*/
@Override
public List<Cuota> findByVenta(Venta venta) {
return cuotaDao.findByVenta(venta);
}
/* (non-Javadoc)
* @see co.innovate.rentavoz.services.almacen.CuotaService#findDeudoresMorosos(java.util.Date)
*/
@Override
public List<Tercero> findDeudoresMorosos(Date fechaCierre) {
return cuotaDao.findDeudoresMorosos(fechaCierre);
}
}
|
;(function() {
/** Used to access the Firebug Lite panel (set by `run`). */
var fbPanel;
/** Used as a safe reference for `undefined` in pre ES5 environments. */
var undefined;
/** Used as a reference to the global object. */
var root = typeof global == 'object' && global || this;
/** Method and object shortcuts. */
var phantom = root.phantom,
amd = root.define && define.amd,
argv = root.process && process.argv,
document = !phantom && root.document,
noop = function() {},
params = root.arguments,
system = root.system;
/** Add `console.log()` support for Narwhal, Rhino, and RingoJS. */
var console = root.console || (root.console = { 'log': root.print });
/** The file path of the Lo-Dash file to test. */
var filePath = (function() {
var min = 0,
result = [];
if (phantom) {
result = params = phantom.args;
} else if (system) {
min = 1;
result = params = system.args;
} else if (argv) {
min = 2;
result = params = argv;
} else if (params) {
result = params;
}
var last = result[result.length - 1];
result = (result.length > min && !/perf(?:\.js)?$/.test(last)) ? last : '../lodash.js';
if (!amd) {
try {
result = require('fs').realpathSync(result);
} catch(e) {}
try {
result = require.resolve(result);
} catch(e) {}
}
return result;
}());
/** Used to match path separators. */
var rePathSeparator = /[\/\\]/;
/** Used to detect primitive types. */
var rePrimitive = /^(?:boolean|number|string|undefined)$/;
/** Used to match RegExp special characters. */
var reSpecialChars = /[.*+?^=!:${}()|[\]\/\\]/g;
/** The `ui` object. */
var ui = root.ui || (root.ui = {
'buildPath': basename(filePath, '.js'),
'otherPath': 'underscore'
});
/** The Lo-Dash build basename. */
var buildName = root.buildName = basename(ui.buildPath, '.js');
/** The other library basename. */
var otherName = root.otherName = (function() {
var result = basename(ui.otherPath, '.js');
return result + (result == buildName ? ' (2)' : '');
}());
/** Used to score performance. */
var score = { 'a': [], 'b': [] };
/** Used to queue benchmark suites. */
var suites = [];
/** Used to resolve a value's internal [[Class]]. */
var toString = Object.prototype.toString;
/** Detect if in a browser environment. */
var isBrowser = isHostType(root, 'document') && isHostType(root, 'navigator');
/** Detect if in a Java environment. */
var isJava = !isBrowser && /Java/.test(toString.call(root.java));
/** Use a single "load" function. */
var load = (typeof require == 'function' && !amd)
? require
: (isJava && root.load) || noop;
/** Load Lo-Dash. */
var lodash = root.lodash || (root.lodash = (
lodash = load(filePath) || root._,
lodash = lodash._ || lodash,
(lodash.runInContext ? lodash.runInContext(root) : lodash),
lodash.noConflict()
));
/** Load Benchmark.js. */
var Benchmark = root.Benchmark || (root.Benchmark = (
Benchmark = load('../vendor/benchmark.js/benchmark.js') || root.Benchmark,
Benchmark = Benchmark.Benchmark || Benchmark,
Benchmark.runInContext(lodash.extend({}, root, { '_': lodash }))
));
/** Load Underscore. */
var _ = root._ || (root._ = (
_ = load('../vendor/underscore/underscore.js') || root._,
_._ || _
));
/**
* Gets the basename of the given `filePath`. If the file `extension` is passed,
* it will be removed from the basename.
*
* @private
* @param {string} path The file path to inspect.
* @param {string} extension The extension to remove.
* @returns {string} Returns the basename.
*/
function basename(filePath, extension) {
var result = (filePath || '').split(rePathSeparator).pop();
return (arguments.length < 2)
? result
: result.replace(RegExp(extension.replace(reSpecialChars, '\\$&') + '$'), '');
}
function getGeometricMean(array) {
return Math.pow(Math.E, lodash.reduce(array, function(sum, x) {
return sum + Math.log(x);
}, 0) / array.length) || 0;
}
/**
* Gets the Hz, i.e. operations per second, of `bench` adjusted for the
* margin of error.
*
* @private
* @param {Object} bench The benchmark object.
* @returns {number} Returns the adjusted Hz.
*/
function getHz(bench) {
var result = 1 / (bench.stats.mean + bench.stats.moe);
return isFinite(result) ? result : 0;
}
/**
* Host objects can return type values that are different from their actual
* data type. The objects we are concerned with usually return non-primitive
* types of "object", "function", or "unknown".
*
* @private
* @param {*} object The owner of the property.
* @param {string} property The property to check.
* @returns {boolean} Returns `true` if the property value is a non-primitive, else `false`.
*/
function isHostType(object, property) {
if (object == null) {
return false;
}
var type = typeof object[property];
return !rePrimitive.test(type) && (type != 'object' || !!object[property]);
}
/**
* Logs text to the console.
*
* @private
* @param {string} text The text to log.
*/
function log(text) {
console.log(text + '');
if (fbPanel) {
// Scroll the Firebug Lite panel down.
fbPanel.scrollTop = fbPanel.scrollHeight;
}
}
/**
* Runs all benchmark suites.
*
* @private (@public in the browser)
*/
function run() {
fbPanel = (fbPanel = root.document && document.getElementById('FirebugUI')) &&
(fbPanel = (fbPanel = fbPanel.contentWindow || fbPanel.contentDocument).document || fbPanel) &&
fbPanel.getElementById('fbPanel1');
log('\nSit back and relax, this may take a while.');
suites[0].run({ 'async': !isJava });
}
lodash.extend(Benchmark.Suite.options, {
'onStart': function() {
log('\n' + this.name + ':');
},
'onCycle': function(event) {
log(event.target);
},
'onComplete': function() {
for (var index = 0, length = this.length; index < length; index++) {
var bench = this[index];
if (bench.error) {
var errored = true;
}
}
if (errored) {
log('There was a problem, skipping...');
}
else {
var formatNumber = Benchmark.formatNumber,
fastest = this.filter('fastest'),
fastestHz = getHz(fastest[0]),
slowest = this.filter('slowest'),
slowestHz = getHz(slowest[0]),
aHz = getHz(this[0]),
bHz = getHz(this[1]);
if (fastest.length > 1) {
log('It\'s too close to call.');
aHz = bHz = slowestHz;
}
else {
var percent = ((fastestHz / slowestHz) - 1) * 100;
log(
fastest[0].name + ' is ' +
formatNumber(percent < 1 ? percent.toFixed(2) : Math.round(percent)) +
'% faster.'
);
}
// Add score adjusted for margin of error.
score.a.push(aHz);
score.b.push(bHz);
}
// Remove current suite from queue.
suites.shift();
if (suites.length) {
// Run next suite.
suites[0].run({ 'async': !isJava });
}
else {
var aMeanHz = getGeometricMean(score.a),
bMeanHz = getGeometricMean(score.b),
fastestMeanHz = Math.max(aMeanHz, bMeanHz),
slowestMeanHz = Math.min(aMeanHz, bMeanHz),
xFaster = fastestMeanHz / slowestMeanHz,
percentFaster = formatNumber(Math.round((xFaster - 1) * 100)),
message = 'is ' + percentFaster + '% ' + (xFaster == 1 ? '' : '(' + formatNumber(xFaster.toFixed(2)) + 'x) ') + 'faster than';
// Report results.
if (aMeanHz >= bMeanHz) {
log('\n' + buildName + ' ' + message + ' ' + otherName + '.');
} else {
log('\n' + otherName + ' ' + message + ' ' + buildName + '.');
}
}
}
});
lodash.extend(Benchmark.options, {
'async': true,
'setup': '\
var _ = global._,\
lodash = global.lodash,\
belt = this.name == buildName ? lodash : _;\
\
var date = new Date,\
limit = 20,\
regexp = /x/,\
object = {},\
objects = Array(limit),\
numbers = Array(limit),\
fourNumbers = [5, 25, 10, 30],\
nestedNumbers = [1, [2], [3, [[4]]]],\
nestedObjects = [{}, [{}], [{}, [[{}]]]],\
twoNumbers = [12, 23];\
\
for (var index = 0; index < limit; index++) {\
numbers[index] = index;\
object["key" + index] = index;\
objects[index] = { "num": index };\
}\
var strNumbers = numbers + "";\
\
if (typeof bind != "undefined") {\
var thisArg = { "name": "fred" };\
\
var func = function(greeting, punctuation) {\
return (greeting || "hi") + " " + this.name + (punctuation || ".");\
};\
\
var _boundNormal = _.bind(func, thisArg),\
_boundMultiple = _boundNormal,\
_boundPartial = _.bind(func, thisArg, "hi");\
\
var lodashBoundNormal = lodash.bind(func, thisArg),\
lodashBoundMultiple = lodashBoundNormal,\
lodashBoundPartial = lodash.bind(func, thisArg, "hi");\
\
for (index = 0; index < 10; index++) {\
_boundMultiple = _.bind(_boundMultiple, { "name": "fred" + index });\
lodashBoundMultiple = lodash.bind(lodashBoundMultiple, { "name": "fred" + index });\
}\
}\
if (typeof bindAll != "undefined") {\
var bindAllCount = -1,\
bindAllObjects = Array(this.count);\
\
var funcNames = belt.reject(belt.functions(belt).slice(0, 40), function(funcName) {\
return /^_/.test(funcName);\
});\
\
// Potentially expensive.\n\
for (index = 0; index < this.count; index++) {\
bindAllObjects[index] = belt.reduce(funcNames, function(object, funcName) {\
object[funcName] = belt[funcName];\
return object;\
}, {});\
}\
}\
if (typeof chaining != "undefined") {\
var even = function(v) { return v % 2 == 0; },\
square = function(v) { return v * v; };\
\
var largeArray = belt.range(10000),\
_chaining = _.chain ? _(largeArray).chain() : _(largeArray),\
lodashChaining = lodash(largeArray);\
}\
if (typeof compact != "undefined") {\
var uncompacted = numbers.slice();\
uncompacted[2] = false;\
uncompacted[6] = null;\
uncompacted[18] = "";\
}\
if (typeof compose != "undefined") {\
var compAddOne = function(n) { return n + 1; },\
compAddTwo = function(n) { return n + 2; },\
compAddThree = function(n) { return n + 3; };\
\
var _composed = _.compose(compAddThree, compAddTwo, compAddOne),\
lodashComposed = lodash.compose(compAddThree, compAddTwo, compAddOne);\
}\
if (typeof countBy != "undefined" || typeof omit != "undefined") {\
var wordToNumber = {\
"one": 1,\
"two": 2,\
"three": 3,\
"four": 4,\
"five": 5,\
"six": 6,\
"seven": 7,\
"eight": 8,\
"nine": 9,\
"ten": 10,\
"eleven": 11,\
"twelve": 12,\
"thirteen": 13,\
"fourteen": 14,\
"fifteen": 15,\
"sixteen": 16,\
"seventeen": 17,\
"eighteen": 18,\
"nineteen": 19,\
"twenty": 20,\
"twenty-one": 21,\
"twenty-two": 22,\
"twenty-three": 23,\
"twenty-four": 24,\
"twenty-five": 25,\
"twenty-six": 26,\
"twenty-seven": 27,\
"twenty-eight": 28,\
"twenty-nine": 29,\
"thirty": 30,\
"thirty-one": 31,\
"thirty-two": 32,\
"thirty-three": 33,\
"thirty-four": 34,\
"thirty-five": 35,\
"thirty-six": 36,\
"thirty-seven": 37,\
"thirty-eight": 38,\
"thirty-nine": 39,\
"forty": 40\
};\
\
var words = belt.keys(wordToNumber).slice(0, limit);\
}\
if (typeof flatten != "undefined") {\
var _flattenDeep = _.flatten([[1]])[0] !== 1,\
lodashFlattenDeep = lodash.flatten([[1]]) !== 1;\
}\
if (typeof isEqual != "undefined") {\
var objectOfPrimitives = {\
"boolean": true,\
"number": 1,\
"string": "a"\
};\
\
var objectOfObjects = {\
"boolean": new Boolean(true),\
"number": new Number(1),\
"string": new String("a")\
};\
\
var objectOfObjects2 = {\
"boolean": new Boolean(true),\
"number": new Number(1),\
"string": new String("A")\
};\
\
var object2 = {},\
object3 = {},\
objects2 = Array(limit),\
objects3 = Array(limit),\
numbers2 = Array(limit),\
numbers3 = Array(limit),\
nestedNumbers2 = [1, [2], [3, [[4]]]],\
nestedNumbers3 = [1, [2], [3, [[6]]]];\
\
for (index = 0; index < limit; index++) {\
object2["key" + index] = index;\
object3["key" + index] = index;\
objects2[index] = { "num": index };\
objects3[index] = { "num": index };\
numbers2[index] = index;\
numbers3[index] = index;\
}\
object3["key" + (limit - 1)] = -1;\
objects3[limit - 1].num = -1;\
numbers3[limit - 1] = -1;\
}\
if (typeof matches != "undefined") {\
var source = { "num": 9 };\
\
var _findWhere = _.findWhere || _.find,\
_match = (_.matches || _.createCallback || _.noop)(source);\
\
var lodashFindWhere = lodash.findWhere || lodash.find,\
lodashMatch = (lodash.matches || lodash.createCallback || lodash.noop)(source);\
}\
if (typeof multiArrays != "undefined") {\
var twentyValues = belt.shuffle(belt.range(20)),\
fortyValues = belt.shuffle(belt.range(40)),\
hundredSortedValues = belt.range(100),\
hundredValues = belt.shuffle(hundredSortedValues),\
hundredValues2 = belt.shuffle(hundredValues),\
hundredTwentyValues = belt.shuffle(belt.range(120)),\
<API key> = belt.shuffle(hundredTwentyValues),\
twoHundredValues = belt.shuffle(belt.range(200)),\
twoHundredValues2 = belt.shuffle(twoHundredValues);\
}\
if (typeof partial != "undefined") {\
var func = function(greeting, punctuation) {\
return greeting + " fred" + (punctuation || ".");\
};\
\
var _partial = _.partial(func, "hi"),\
lodashPartial = lodash.partial(func, "hi");\
}\
if (typeof template != "undefined") {\
var tplData = {\
"header1": "Header1",\
"header2": "Header2",\
"header3": "Header3",\
"header4": "Header4",\
"header5": "Header5",\
"header6": "Header6",\
"list": ["1", "2", "3", "4", "5", "6", "7", "8", "9", "10"]\
};\
\
var tpl =\
"<div>" +\
"<h1 class=\'header1\'><%= header1 %></h1>" +\
"<h2 class=\'header2\'><%= header2 %></h2>" +\
"<h3 class=\'header3\'><%= header3 %></h3>" +\
"<h4 class=\'header4\'><%= header4 %></h4>" +\
"<h5 class=\'header5\'><%= header5 %></h5>" +\
"<h6 class=\'header6\'><%= header6 %></h6>" +\
"<ul class=\'list\'>" +\
"<% for (var index = 0, length = list.length; index < length; index++) { %>" +\
"<li class=\'item\'><%= list[index] %></li>" +\
"<% } %>" +\
"</ul>" +\
"</div>";\
\
var tplVerbose =\
"<div>" +\
"<h1 class=\'header1\'><%= data.header1 %></h1>" +\
"<h2 class=\'header2\'><%= data.header2 %></h2>" +\
"<h3 class=\'header3\'><%= data.header3 %></h3>" +\
"<h4 class=\'header4\'><%= data.header4 %></h4>" +\
"<h5 class=\'header5\'><%= data.header5 %></h5>" +\
"<h6 class=\'header6\'><%= data.header6 %></h6>" +\
"<ul class=\'list\'>" +\
"<% for (var index = 0, length = data.list.length; index < length; index++) { %>" +\
"<li class=\'item\'><%= data.list[index] %></li>" +\
"<% } %>" +\
"</ul>" +\
"</div>";\
\
var settingsObject = { "variable": "data" };\
\
var _tpl = _.template(tpl),\
_tplVerbose = _.template(tplVerbose, null, settingsObject);\
\
var lodashTpl = lodash.template(tpl),\
lodashTplVerbose = lodash.template(tplVerbose, null, settingsObject);\
}\
if (typeof wrap != "undefined") {\
var add = function(a, b) {\
return a + b;\
};\
\
var average = function(func, a, b) {\
return (func(a, b) / 2).toFixed(2);\
};\
\
var _wrapped = _.wrap(add, average);\
lodashWrapped = lodash.wrap(add, average);\
}\
if (typeof zip != "undefined") {\
var unzipped = [["a", "b", "c"], [1, 2, 3], [true, false, true]];\
}'
});
suites.push(
Benchmark.Suite('`_(...).map(...).filter(...).take(...).value()`')
.add(buildName, {
'fn': 'lodashChaining.map(square).filter(even).take(100).value()',
'teardown': 'function chaining(){}'
})
.add(otherName, {
'fn': '_chaining.map(square).filter(even).take(100).value()',
'teardown': 'function chaining(){}'
})
);
suites.push(
Benchmark.Suite('`_.bind` (slow path)')
.add(buildName, {
'fn': 'lodash.bind(function() { return this.name; }, { "name": "fred" })',
'teardown': 'function bind(){}'
})
.add(otherName, {
'fn': '_.bind(function() { return this.name; }, { "name": "fred" })',
'teardown': 'function bind(){}'
})
);
suites.push(
Benchmark.Suite('bound call with arguments')
.add(buildName, {
'fn': 'lodashBoundNormal("hi", "!")',
'teardown': 'function bind(){}'
})
.add(otherName, {
'fn': '_boundNormal("hi", "!")',
'teardown': 'function bind(){}'
})
);
suites.push(
Benchmark.Suite('bound and partially applied call with arguments')
.add(buildName, {
'fn': 'lodashBoundPartial("!")',
'teardown': 'function bind(){}'
})
.add(otherName, {
'fn': '_boundPartial("!")',
'teardown': 'function bind(){}'
})
);
suites.push(
Benchmark.Suite('bound multiple times')
.add(buildName, {
'fn': 'lodashBoundMultiple()',
'teardown': 'function bind(){}'
})
.add(otherName, {
'fn': '_boundMultiple()',
'teardown': 'function bind(){}'
})
);
suites.push(
Benchmark.Suite('`_.bindAll` iterating arguments')
.add(buildName, {
'fn': 'lodash.bindAll.apply(lodash, [bindAllObjects[++bindAllCount]].concat(funcNames))',
'teardown': 'function bindAll(){}'
})
.add(otherName, {
'fn': '_.bindAll.apply(_, [bindAllObjects[++bindAllCount]].concat(funcNames))',
'teardown': 'function bindAll(){}'
})
);
suites.push(
Benchmark.Suite('`_.bindAll` iterating the `object`')
.add(buildName, {
'fn': 'lodash.bindAll(bindAllObjects[++bindAllCount])',
'teardown': 'function bindAll(){}'
})
.add(otherName, {
'fn': '_.bindAll(bindAllObjects[++bindAllCount])',
'teardown': 'function bindAll(){}'
})
);
suites.push(
Benchmark.Suite('`_.clone` with an array')
.add(buildName, '\
lodash.clone(numbers)'
)
.add(otherName, '\
_.clone(numbers)'
)
);
suites.push(
Benchmark.Suite('`_.clone` with an object')
.add(buildName, '\
lodash.clone(object)'
)
.add(otherName, '\
_.clone(object)'
)
);
suites.push(
Benchmark.Suite('`_.compact`')
.add(buildName, {
'fn': 'lodash.compact(uncompacted)',
'teardown': 'function compact(){}'
})
.add(otherName, {
'fn': '_.compact(uncompacted)',
'teardown': 'function compact(){}'
})
);
suites.push(
Benchmark.Suite('`_.compose`')
.add(buildName, {
'fn': 'lodash.compose(compAddThree, compAddTwo, compAddOne)',
'teardown': 'function compose(){}'
})
.add(otherName, {
'fn': '_.compose(compAddThree, compAddTwo, compAddOne)',
'teardown': 'function compose(){}'
})
);
suites.push(
Benchmark.Suite('composed call')
.add(buildName, {
'fn': 'lodashComposed(0)',
'teardown': 'function compose(){}'
})
.add(otherName, {
'fn': '_composed(0)',
'teardown': 'function compose(){}'
})
);
suites.push(
Benchmark.Suite('`_.countBy` with `callback` iterating an array')
.add(buildName, '\
lodash.countBy(numbers, function(num) { return num >> 1; })'
)
.add(otherName, '\
_.countBy(numbers, function(num) { return num >> 1; })'
)
);
suites.push(
Benchmark.Suite('`_.countBy` with `property` name iterating an array')
.add(buildName, {
'fn': 'lodash.countBy(words, "length")',
'teardown': 'function countBy(){}'
})
.add(otherName, {
'fn': '_.countBy(words, "length")',
'teardown': 'function countBy(){}'
})
);
suites.push(
Benchmark.Suite('`_.countBy` with `callback` iterating an object')
.add(buildName, {
'fn': 'lodash.countBy(wordToNumber, function(num) { return num >> 1; })',
'teardown': 'function countBy(){}'
})
.add(otherName, {
'fn': '_.countBy(wordToNumber, function(num) { return num >> 1; })',
'teardown': 'function countBy(){}'
})
);
suites.push(
Benchmark.Suite('`_.defaults`')
.add(buildName, '\
lodash.defaults({ "key2": 2, "key6": 6, "key18": 18 }, object)'
)
.add(otherName, '\
_.defaults({ "key2": 2, "key6": 6, "key18": 18 }, object)'
)
);
suites.push(
Benchmark.Suite('`_.difference`')
.add(buildName, '\
lodash.difference(numbers, twoNumbers, fourNumbers)'
)
.add(otherName, '\
_.difference(numbers, twoNumbers, fourNumbers)'
)
);
suites.push(
Benchmark.Suite('`_.difference` iterating 200 elements')
.add(buildName, {
'fn': 'lodash.difference(twoHundredValues, twoHundredValues2)',
'teardown': 'function multiArrays(){}'
})
.add(otherName, {
'fn': '_.difference(twoHundredValues, twoHundredValues2)',
'teardown': 'function multiArrays(){}'
})
);
suites.push(
Benchmark.Suite('`_.difference` iterating 20 and 40 elements')
.add(buildName, {
'fn': 'lodash.difference(twentyValues, fortyValues)',
'teardown': 'function multiArrays(){}'
})
.add(otherName, {
'fn': '_.difference(twentyValues, fortyValues)',
'teardown': 'function multiArrays(){}'
})
);
suites.push(
Benchmark.Suite('`_.each` iterating an array')
.add(buildName, '\
var result = [];\
lodash.each(numbers, function(num) {\
result.push(num * 2);\
})'
)
.add(otherName, '\
var result = [];\
_.each(numbers, function(num) {\
result.push(num * 2);\
})'
)
);
suites.push(
Benchmark.Suite('`_.each` iterating an array with `thisArg` (slow path)')
.add(buildName, '\
var result = [];\
lodash.each(numbers, function(num, index) {\
result.push(num + this["key" + index]);\
}, object)'
)
.add(otherName, '\
var result = [];\
_.each(numbers, function(num, index) {\
result.push(num + this["key" + index]);\
}, object)'
)
);
suites.push(
Benchmark.Suite('`_.each` iterating an object')
.add(buildName, '\
var result = [];\
lodash.each(object, function(num) {\
result.push(num * 2);\
})'
)
.add(otherName, '\
var result = [];\
_.each(object, function(num) {\
result.push(num * 2);\
})'
)
);
suites.push(
Benchmark.Suite('`_.every` iterating an array')
.add(buildName, '\
lodash.every(numbers, function(num) {\
return num < limit;\
})'
)
.add(otherName, '\
_.every(numbers, function(num) {\
return num < limit;\
})'
)
);
suites.push(
Benchmark.Suite('`_.every` iterating an object')
.add(buildName, '\
lodash.every(object, function(num) {\
return num < limit;\
})'
)
.add(otherName, '\
_.every(object, function(num) {\
return num < limit;\
})'
)
);
suites.push(
Benchmark.Suite('`_.extend`')
.add(buildName, '\
lodash.extend({}, object)'
)
.add(otherName, '\
_.extend({}, object)'
)
);
suites.push(
Benchmark.Suite('`_.filter` iterating an array')
.add(buildName, '\
lodash.filter(numbers, function(num) {\
return num % 2;\
})'
)
.add(otherName, '\
_.filter(numbers, function(num) {\
return num % 2;\
})'
)
);
suites.push(
Benchmark.Suite('`_.filter` iterating an array with `thisArg` (slow path)')
.add(buildName, '\
lodash.filter(numbers, function(num, index) {\
return this["key" + index] % 2;\
}, object)'
)
.add(otherName, '\
_.filter(numbers, function(num, index) {\
return this["key" + index] % 2;\
}, object)'
)
);
suites.push(
Benchmark.Suite('`_.filter` iterating an object')
.add(buildName, '\
lodash.filter(object, function(num) {\
return num % 2\
})'
)
.add(otherName, '\
_.filter(object, function(num) {\
return num % 2\
})'
)
);
suites.push(
Benchmark.Suite('`_.find` iterating an array')
.add(buildName, '\
lodash.find(numbers, function(num) {\
return num === (limit - 1);\
})'
)
.add(otherName, '\
_.find(numbers, function(num) {\
return num === (limit - 1);\
})'
)
);
suites.push(
Benchmark.Suite('`_.find` iterating an object')
.add(buildName, '\
lodash.find(object, function(value, key) {\
return /\D9$/.test(key);\
})'
)
.add(otherName, '\
_.find(object, function(value, key) {\
return /\D9$/.test(key);\
})'
)
);
// Avoid Underscore induced `OutOfMemoryError` in Rhino, Narwhal, and Ringo.
if (!isJava) {
suites.push(
Benchmark.Suite('`_.find` with `properties`')
.add(buildName, {
'fn': 'lodashFindWhere(objects, source)',
'teardown': 'function matches(){}'
})
.add(otherName, {
'fn': '_findWhere(objects, source)',
'teardown': 'function matches(){}'
})
);
}
suites.push(
Benchmark.Suite('`_.flatten`')
.add(buildName, {
'fn': 'lodash.flatten(nestedNumbers, !lodashFlattenDeep)',
'teardown': 'function flatten(){}'
})
.add(otherName, {
'fn': '_.flatten(nestedNumbers, !_flattenDeep)',
'teardown': 'function flatten(){}'
})
);
suites.push(
Benchmark.Suite('`_.flatten` nested arrays of numbers with `isDeep`')
.add(buildName, {
'fn': 'lodash.flatten(nestedNumbers, lodashFlattenDeep)',
'teardown': 'function flatten(){}'
})
.add(otherName, {
'fn': '_.flatten(nestedNumbers, _flattenDeep)',
'teardown': 'function flatten(){}'
})
);
suites.push(
Benchmark.Suite('`_.flatten` nest arrays of objects with `isDeep`')
.add(buildName, {
'fn': 'lodash.flatten(nestedObjects, lodashFlattenDeep)',
'teardown': 'function flatten(){}'
})
.add(otherName, {
'fn': '_.flatten(nestedObjects, _flattenDeep)',
'teardown': 'function flatten(){}'
})
);
suites.push(
Benchmark.Suite('`_.functions`')
.add(buildName, '\
lodash.functions(lodash)'
)
.add(otherName, '\
_.functions(lodash)'
)
);
suites.push(
Benchmark.Suite('`_.groupBy` with `callback` iterating an array')
.add(buildName, '\
lodash.groupBy(numbers, function(num) { return num >> 1; })'
)
.add(otherName, '\
_.groupBy(numbers, function(num) { return num >> 1; })'
)
);
suites.push(
Benchmark.Suite('`_.groupBy` with `property` name iterating an array')
.add(buildName, {
'fn': 'lodash.groupBy(words, "length")',
'teardown': 'function countBy(){}'
})
.add(otherName, {
'fn': '_.groupBy(words, "length")',
'teardown': 'function countBy(){}'
})
);
suites.push(
Benchmark.Suite('`_.groupBy` with `callback` iterating an object')
.add(buildName, {
'fn': 'lodash.groupBy(wordToNumber, function(num) { return num >> 1; })',
'teardown': 'function countBy(){}'
})
.add(otherName, {
'fn': '_.groupBy(wordToNumber, function(num) { return num >> 1; })',
'teardown': 'function countBy(){}'
})
);
suites.push(
Benchmark.Suite('`_.include` iterating an array')
.add(buildName, '\
lodash.include(numbers, limit - 1)'
)
.add(otherName, '\
_.include(numbers, limit - 1)'
)
);
suites.push(
Benchmark.Suite('`_.include` iterating an object')
.add(buildName, '\
lodash.include(object, limit - 1)'
)
.add(otherName, '\
_.include(object, limit - 1)'
)
);
if (lodash.include('ab', 'ab') && _.include('ab', 'ab')) {
suites.push(
Benchmark.Suite('`_.include` iterating a string')
.add(buildName, '\
lodash.include(strNumbers, "," + (limit - 1))'
)
.add(otherName, '\
_.include(strNumbers, "," + (limit - 1))'
)
);
}
suites.push(
Benchmark.Suite('`_.indexBy` with `callback` iterating an array')
.add(buildName, '\
lodash.indexBy(numbers, function(num) { return num >> 1; })'
)
.add(otherName, '\
_.indexBy(numbers, function(num) { return num >> 1; })'
)
);
suites.push(
Benchmark.Suite('`_.indexBy` with `property` name iterating an array')
.add(buildName, {
'fn': 'lodash.indexBy(words, "length")',
'teardown': 'function countBy(){}'
})
.add(otherName, {
'fn': '_.indexBy(words, "length")',
'teardown': 'function countBy(){}'
})
);
suites.push(
Benchmark.Suite('`_.indexBy` with `callback` iterating an object')
.add(buildName, {
'fn': 'lodash.indexBy(wordToNumber, function(num) { return num >> 1; })',
'teardown': 'function countBy(){}'
})
.add(otherName, {
'fn': '_.indexBy(wordToNumber, function(num) { return num >> 1; })',
'teardown': 'function countBy(){}'
})
);
suites.push(
Benchmark.Suite('`_.indexOf`')
.add(buildName, {
'fn': 'lodash.indexOf(hundredSortedValues, 99)',
'teardown': 'function multiArrays(){}'
})
.add(otherName, {
'fn': '_.indexOf(hundredSortedValues, 99)',
'teardown': 'function multiArrays(){}'
})
);
suites.push(
Benchmark.Suite('`_.indexOf` performing a binary search')
.add(buildName, {
'fn': 'lodash.indexOf(hundredSortedValues, 99, true)',
'teardown': 'function multiArrays(){}'
})
.add(otherName, {
'fn': '_.indexOf(hundredSortedValues, 99, true)',
'teardown': 'function multiArrays(){}'
})
);
suites.push(
Benchmark.Suite('`_.intersection`')
.add(buildName, '\
lodash.intersection(numbers, twoNumbers, fourNumbers)'
)
.add(otherName, '\
_.intersection(numbers, twoNumbers, fourNumbers)'
)
);
suites.push(
Benchmark.Suite('`_.intersection` iterating 120 elements')
.add(buildName, {
'fn': 'lodash.intersection(hundredTwentyValues, <API key>)',
'teardown': 'function multiArrays(){}'
})
.add(otherName, {
'fn': '_.intersection(hundredTwentyValues, <API key>)',
'teardown': 'function multiArrays(){}'
})
);
suites.push(
Benchmark.Suite('`_.invert`')
.add(buildName, '\
lodash.invert(object)'
)
.add(otherName, '\
_.invert(object)'
)
);
suites.push(
Benchmark.Suite('`_.invoke` iterating an array')
.add(buildName, '\
lodash.invoke(numbers, "toFixed")'
)
.add(otherName, '\
_.invoke(numbers, "toFixed")'
)
);
suites.push(
Benchmark.Suite('`_.invoke` with arguments iterating an array')
.add(buildName, '\
lodash.invoke(numbers, "toFixed", 1)'
)
.add(otherName, '\
_.invoke(numbers, "toFixed", 1)'
)
);
suites.push(
Benchmark.Suite('`_.invoke` with a function for `methodName` iterating an array')
.add(buildName, '\
lodash.invoke(numbers, Number.prototype.toFixed, 1)'
)
.add(otherName, '\
_.invoke(numbers, Number.prototype.toFixed, 1)'
)
);
suites.push(
Benchmark.Suite('`_.invoke` iterating an object')
.add(buildName, '\
lodash.invoke(object, "toFixed", 1)'
)
.add(otherName, '\
_.invoke(object, "toFixed", 1)'
)
);
suites.push(
Benchmark.Suite('`_.isEqual` comparing primitives')
.add(buildName, {
'fn': '\
lodash.isEqual(1, "1");\
lodash.isEqual(1, 1)',
'teardown': 'function isEqual(){}'
})
.add(otherName, {
'fn': '\
_.isEqual(1, "1");\
_.isEqual(1, 1);',
'teardown': 'function isEqual(){}'
})
);
suites.push(
Benchmark.Suite('`_.isEqual` comparing primitives and their object counterparts (edge case)')
.add(buildName, {
'fn': '\
lodash.isEqual(objectOfPrimitives, objectOfObjects);\
lodash.isEqual(objectOfPrimitives, objectOfObjects2)',
'teardown': 'function isEqual(){}'
})
.add(otherName, {
'fn': '\
_.isEqual(objectOfPrimitives, objectOfObjects);\
_.isEqual(objectOfPrimitives, objectOfObjects2)',
'teardown': 'function isEqual(){}'
})
);
suites.push(
Benchmark.Suite('`_.isEqual` comparing arrays')
.add(buildName, {
'fn': '\
lodash.isEqual(numbers, numbers2);\
lodash.isEqual(numbers2, numbers3)',
'teardown': 'function isEqual(){}'
})
.add(otherName, {
'fn': '\
_.isEqual(numbers, numbers2);\
_.isEqual(numbers2, numbers3)',
'teardown': 'function isEqual(){}'
})
);
suites.push(
Benchmark.Suite('`_.isEqual` comparing nested arrays')
.add(buildName, {
'fn': '\
lodash.isEqual(nestedNumbers, nestedNumbers2);\
lodash.isEqual(nestedNumbers2, nestedNumbers3)',
'teardown': 'function isEqual(){}'
})
.add(otherName, {
'fn': '\
_.isEqual(nestedNumbers, nestedNumbers2);\
_.isEqual(nestedNumbers2, nestedNumbers3)',
'teardown': 'function isEqual(){}'
})
);
suites.push(
Benchmark.Suite('`_.isEqual` comparing arrays of objects')
.add(buildName, {
'fn': '\
lodash.isEqual(objects, objects2);\
lodash.isEqual(objects2, objects3)',
'teardown': 'function isEqual(){}'
})
.add(otherName, {
'fn': '\
_.isEqual(objects, objects2);\
_.isEqual(objects2, objects3)',
'teardown': 'function isEqual(){}'
})
);
suites.push(
Benchmark.Suite('`_.isEqual` comparing objects')
.add(buildName, {
'fn': '\
lodash.isEqual(object, object2);\
lodash.isEqual(object2, object3)',
'teardown': 'function isEqual(){}'
})
.add(otherName, {
'fn': '\
_.isEqual(object, object2);\
_.isEqual(object2, object3)',
'teardown': 'function isEqual(){}'
})
);
suites.push(
Benchmark.Suite('`_.isArguments`, `_.isDate`, `_.isFunction`, `_.isNumber`, `_.isObject`, `_.isRegExp`')
.add(buildName, '\
lodash.isArguments(arguments);\
lodash.isArguments(object);\
lodash.isDate(date);\
lodash.isDate(object);\
lodash.isFunction(lodash);\
lodash.isFunction(object);\
lodash.isNumber(1);\
lodash.isNumber(object);\
lodash.isObject(object);\
lodash.isObject(1);\
lodash.isRegExp(regexp);\
lodash.isRegExp(object)'
)
.add(otherName, '\
_.isArguments(arguments);\
_.isArguments(object);\
_.isDate(date);\
_.isDate(object);\
_.isFunction(_);\
_.isFunction(object);\
_.isNumber(1);\
_.isNumber(object);\
_.isObject(object);\
_.isObject(1);\
_.isRegExp(regexp);\
_.isRegExp(object)'
)
);
suites.push(
Benchmark.Suite('`_.keys` (uses native `Object.keys` if available)')
.add(buildName, '\
lodash.keys(object)'
)
.add(otherName, '\
_.keys(object)'
)
);
suites.push(
Benchmark.Suite('`_.lastIndexOf`')
.add(buildName, {
'fn': 'lodash.lastIndexOf(hundredSortedValues, 0)',
'teardown': 'function multiArrays(){}'
})
.add(otherName, {
'fn': '_.lastIndexOf(hundredSortedValues, 0)',
'teardown': 'function multiArrays(){}'
})
);
suites.push(
Benchmark.Suite('`_.lastIndexOf` performing a binary search')
.add(buildName, {
'fn': 'lodash.lastIndexOf(hundredSortedValues, 0, true)',
'teardown': 'function multiArrays(){}'
})
.add(otherName, {
'fn': '_.lastIndexOf(hundredSortedValues, 0, true)',
'teardown': 'function multiArrays(){}'
})
);
suites.push(
Benchmark.Suite('`_.map` iterating an array')
.add(buildName, '\
lodash.map(objects, function(value) {\
return value.num;\
})'
)
.add(otherName, '\
_.map(objects, function(value) {\
return value.num;\
})'
)
);
suites.push(
Benchmark.Suite('`_.map` with `thisArg` iterating an array (slow path)')
.add(buildName, '\
lodash.map(objects, function(value, index) {\
return this["key" + index] + value.num;\
}, object)'
)
.add(otherName, '\
_.map(objects, function(value, index) {\
return this["key" + index] + value.num;\
}, object)'
)
);
suites.push(
Benchmark.Suite('`_.map` iterating an object')
.add(buildName, '\
lodash.map(object, function(value) {\
return value;\
})'
)
.add(otherName, '\
_.map(object, function(value) {\
return value;\
})'
)
);
suites.push(
Benchmark.Suite('`_.matches` predicate')
.add(buildName, {
'fn': 'lodash.filter(objects, lodashMatch)',
'teardown': 'function matches(){}'
})
.add(otherName, {
'fn': '_.filter(objects, _match)',
'teardown': 'function matches(){}'
})
);
suites.push(
Benchmark.Suite('`_.max`')
.add(buildName, '\
lodash.max(numbers)'
)
.add(otherName, '\
_.max(numbers)'
)
);
suites.push(
Benchmark.Suite('`_.min`')
.add(buildName, '\
lodash.min(numbers)'
)
.add(otherName, '\
_.min(numbers)'
)
);
suites.push(
Benchmark.Suite('`_.omit` iterating 20 properties, omitting 2 keys')
.add(buildName, '\
lodash.omit(object, "key6", "key13")'
)
.add(otherName, '\
_.omit(object, "key6", "key13")'
)
);
suites.push(
Benchmark.Suite('`_.omit` iterating 40 properties, omitting 20 keys')
.add(buildName, {
'fn': 'lodash.omit(wordToNumber, words)',
'teardown': 'function omit(){}'
})
.add(otherName, {
'fn': '_.omit(wordToNumber, words)',
'teardown': 'function omit(){}'
})
);
suites.push(
Benchmark.Suite('`_.pairs`')
.add(buildName, '\
lodash.pairs(object)'
)
.add(otherName, '\
_.pairs(object)'
)
);
suites.push(
Benchmark.Suite('`_.partial` (slow path)')
.add(buildName, {
'fn': 'lodash.partial(function(greeting) { return greeting + " " + this.name; }, "hi")',
'teardown': 'function partial(){}'
})
.add(otherName, {
'fn': '_.partial(function(greeting) { return greeting + " " + this.name; }, "hi")',
'teardown': 'function partial(){}'
})
);
suites.push(
Benchmark.Suite('partially applied call with arguments')
.add(buildName, {
'fn': 'lodashPartial("!")',
'teardown': 'function partial(){}'
})
.add(otherName, {
'fn': '_partial("!")',
'teardown': 'function partial(){}'
})
);
suites.push(
Benchmark.Suite('`_.partition` iterating an array')
.add(buildName, '\
lodash.partition(numbers, function(num) {\
return num % 2;\
})'
)
.add(otherName, '\
_.partition(numbers, function(num) {\
return num % 2;\
})'
)
);
suites.push(
Benchmark.Suite('`_.partition` iterating an array with `thisArg` (slow path)')
.add(buildName, '\
lodash.partition(numbers, function(num, index) {\
return this["key" + index] % 2;\
}, object)'
)
.add(otherName, '\
_.partition(numbers, function(num, index) {\
return this["key" + index] % 2;\
}, object)'
)
);
suites.push(
Benchmark.Suite('`_.partition` iterating an object')
.add(buildName, '\
lodash.partition(object, function(num) {\
return num % 2;\
})'
)
.add(otherName, '\
_.partition(object, function(num) {\
return num % 2;\
})'
)
);
suites.push(
Benchmark.Suite('`_.pick`')
.add(buildName, '\
lodash.pick(object, "key6", "key13")'
)
.add(otherName, '\
_.pick(object, "key6", "key13")'
)
);
suites.push(
Benchmark.Suite('`_.pluck`')
.add(buildName, '\
lodash.pluck(objects, "num")'
)
.add(otherName, '\
_.pluck(objects, "num")'
)
);
suites.push(
Benchmark.Suite('`_.reduce` iterating an array')
.add(buildName, '\
lodash.reduce(numbers, function(result, value, index) {\
result[index] = value;\
return result;\
}, {})'
)
.add(otherName, '\
_.reduce(numbers, function(result, value, index) {\
result[index] = value;\
return result;\
}, {})'
)
);
suites.push(
Benchmark.Suite('`_.reduce` iterating an object')
.add(buildName, '\
lodash.reduce(object, function(result, value, key) {\
result.push(key, value);\
return result;\
}, [])'
)
.add(otherName, '\
_.reduce(object, function(result, value, key) {\
result.push(key, value);\
return result;\
}, [])'
)
);
suites.push(
Benchmark.Suite('`_.reduceRight` iterating an array')
.add(buildName, '\
lodash.reduceRight(numbers, function(result, value, index) {\
result[index] = value;\
return result;\
}, {})'
)
.add(otherName, '\
_.reduceRight(numbers, function(result, value, index) {\
result[index] = value;\
return result;\
}, {})'
)
);
suites.push(
Benchmark.Suite('`_.reduceRight` iterating an object')
.add(buildName, '\
lodash.reduceRight(object, function(result, value, key) {\
result.push(key, value);\
return result;\
}, [])'
)
.add(otherName, '\
_.reduceRight(object, function(result, value, key) {\
result.push(key, value);\
return result;\
}, [])'
)
);
suites.push(
Benchmark.Suite('`_.reject` iterating an array')
.add(buildName, '\
lodash.reject(numbers, function(num) {\
return num % 2;\
})'
)
.add(otherName, '\
_.reject(numbers, function(num) {\
return num % 2;\
})'
)
);
suites.push(
Benchmark.Suite('`_.reject` iterating an array with `thisArg` (slow path)')
.add(buildName, '\
lodash.reject(numbers, function(num, index) {\
return this["key" + index] % 2;\
}, object)'
)
.add(otherName, '\
_.reject(numbers, function(num, index) {\
return this["key" + index] % 2;\
}, object)'
)
);
suites.push(
Benchmark.Suite('`_.reject` iterating an object')
.add(buildName, '\
lodash.reject(object, function(num) {\
return num % 2;\
})'
)
.add(otherName, '\
_.reject(object, function(num) {\
return num % 2;\
})'
)
);
suites.push(
Benchmark.Suite('`_.sample` with an `n`')
.add(buildName, '\
lodash.sample(numbers, limit / 2)'
)
.add(otherName, '\
_.sample(numbers, limit / 2)'
)
);
suites.push(
Benchmark.Suite('`_.shuffle`')
.add(buildName, '\
lodash.shuffle(numbers)'
)
.add(otherName, '\
_.shuffle(numbers)'
)
);
suites.push(
Benchmark.Suite('`_.size` with an object')
.add(buildName, '\
lodash.size(object)'
)
.add(otherName, '\
_.size(object)'
)
);
suites.push(
Benchmark.Suite('`_.some` iterating an array')
.add(buildName, '\
lodash.some(numbers, function(num) {\
return num == (limit - 1);\
})'
)
.add(otherName, '\
_.some(numbers, function(num) {\
return num == (limit - 1);\
})'
)
);
suites.push(
Benchmark.Suite('`_.some` with `thisArg` iterating an array (slow path)')
.add(buildName, '\
lodash.some(objects, function(value, index) {\
return this["key" + index] == (limit - 1);\
}, object)'
)
.add(otherName, '\
_.some(objects, function(value, index) {\
return this["key" + index] == (limit - 1);\
}, object)'
)
);
suites.push(
Benchmark.Suite('`_.some` iterating an object')
.add(buildName, '\
lodash.some(object, function(num) {\
return num == (limit - 1);\
})'
)
.add(otherName, '\
_.some(object, function(num) {\
return num == (limit - 1);\
})'
)
);
suites.push(
Benchmark.Suite('`_.sortBy` with `callback`')
.add(buildName, '\
lodash.sortBy(numbers, function(num) { return Math.sin(num); })'
)
.add(otherName, '\
_.sortBy(numbers, function(num) { return Math.sin(num); })'
)
);
suites.push(
Benchmark.Suite('`_.sortBy` with `callback` and `thisArg` (slow path)')
.add(buildName, '\
lodash.sortBy(numbers, function(num) { return this.sin(num); }, Math)'
)
.add(otherName, '\
_.sortBy(numbers, function(num) { return this.sin(num); }, Math)'
)
);
suites.push(
Benchmark.Suite('`_.sortBy` with `property` name')
.add(buildName, {
'fn': 'lodash.sortBy(words, "length")',
'teardown': 'function countBy(){}'
})
.add(otherName, {
'fn': '_.sortBy(words, "length")',
'teardown': 'function countBy(){}'
})
);
suites.push(
Benchmark.Suite('`_.sortedIndex` with `callback`')
.add(buildName, {
'fn': '\
lodash.sortedIndex(words, "twenty-five", function(value) {\
return wordToNumber[value];\
})',
'teardown': 'function countBy(){}'
})
.add(otherName, {
'fn': '\
_.sortedIndex(words, "twenty-five", function(value) {\
return wordToNumber[value];\
})',
'teardown': 'function countBy(){}'
})
);
suites.push(
Benchmark.Suite('`_.template` (slow path)')
.add(buildName, {
'fn': 'lodash.template(tpl)(tplData)',
'teardown': 'function template(){}'
})
.add(otherName, {
'fn': '_.template(tpl)(tplData)',
'teardown': 'function template(){}'
})
);
suites.push(
Benchmark.Suite('compiled template')
.add(buildName, {
'fn': 'lodashTpl(tplData)',
'teardown': 'function template(){}'
})
.add(otherName, {
'fn': '_tpl(tplData)',
'teardown': 'function template(){}'
})
);
suites.push(
Benchmark.Suite('compiled template without a with-statement')
.add(buildName, {
'fn': 'lodashTplVerbose(tplData)',
'teardown': 'function template(){}'
})
.add(otherName, {
'fn': '_tplVerbose(tplData)',
'teardown': 'function template(){}'
})
);
suites.push(
Benchmark.Suite('`_.times`')
.add(buildName, '\
var result = [];\
lodash.times(limit, function(n) { result.push(n); })'
)
.add(otherName, '\
var result = [];\
_.times(limit, function(n) { result.push(n); })'
)
);
suites.push(
Benchmark.Suite('`_.times` with `thisArg` (slow path)')
.add(buildName, '\
var result = [];\
lodash.times(limit, function(n) { result.push(this.sin(n)); }, Math)'
)
.add(otherName, '\
var result = [];\
_.times(limit, function(n) { result.push(this.sin(n)); }, Math)'
)
);
suites.push(
Benchmark.Suite('`_.toArray` with an array (edge case)')
.add(buildName, '\
lodash.toArray(numbers)'
)
.add(otherName, '\
_.toArray(numbers)'
)
);
suites.push(
Benchmark.Suite('`_.toArray` with an object')
.add(buildName, '\
lodash.toArray(object)'
)
.add(otherName, '\
_.toArray(object)'
)
);
suites.push(
Benchmark.Suite('`_.unescape` string without html entities')
.add(buildName, '\
lodash.unescape("`&`, `<`, `>`, `\\"`, and `\'`")'
)
.add(otherName, '\
_.unescape("`&`, `<`, `>`, `\\"`, and `\'`")'
)
);
suites.push(
Benchmark.Suite('`_.unescape` string with html entities')
.add(buildName, '\
lodash.unescape("`&`, `<`, `>`, `"`, and `&
)
.add(otherName, '\
_.unescape("`&`, `<`, `>`, `"`, and `&
)
);
suites.push(
Benchmark.Suite('`_.union`')
.add(buildName, '\
lodash.union(numbers, twoNumbers, fourNumbers)'
)
.add(otherName, '\
_.union(numbers, twoNumbers, fourNumbers)'
)
);
suites.push(
Benchmark.Suite('`_.union` iterating an array of 200 elements')
.add(buildName, {
'fn': 'lodash.union(hundredValues, hundredValues2)',
'teardown': 'function multiArrays(){}'
})
.add(otherName, {
'fn': '_.union(hundredValues, hundredValues2)',
'teardown': 'function multiArrays(){}'
})
);
suites.push(
Benchmark.Suite('`_.uniq`')
.add(buildName, '\
lodash.uniq(numbers.concat(twoNumbers, fourNumbers))'
)
.add(otherName, '\
_.uniq(numbers.concat(twoNumbers, fourNumbers))'
)
);
suites.push(
Benchmark.Suite('`_.uniq` with `callback`')
.add(buildName, '\
lodash.uniq(numbers.concat(twoNumbers, fourNumbers), function(num) {\
return num % 2;\
})'
)
.add(otherName, '\
_.uniq(numbers.concat(twoNumbers, fourNumbers), function(num) {\
return num % 2;\
})'
)
);
suites.push(
Benchmark.Suite('`_.uniq` iterating an array of 200 elements')
.add(buildName, {
'fn': 'lodash.uniq(twoHundredValues)',
'teardown': 'function multiArrays(){}'
})
.add(otherName, {
'fn': '_.uniq(twoHundredValues)',
'teardown': 'function multiArrays(){}'
})
);
suites.push(
Benchmark.Suite('`_.values`')
.add(buildName, '\
lodash.values(object)'
)
.add(otherName, '\
_.values(object)'
)
);
suites.push(
Benchmark.Suite('`_.where`')
.add(buildName, {
'fn': 'lodash.where(objects, source)',
'teardown': 'function matches(){}'
})
.add(otherName, {
'fn': '_.where(objects, source)',
'teardown': 'function matches(){}'
})
);
suites.push(
Benchmark.Suite('`_.without`')
.add(buildName, '\
lodash.without(numbers, 9, 12, 14, 15)'
)
.add(otherName, '\
_.without(numbers, 9, 12, 14, 15)'
)
);
suites.push(
Benchmark.Suite('`_.wrap` result called')
.add(buildName, {
'fn': 'lodashWrapped(2, 5)',
'teardown': 'function wrap(){}'
})
.add(otherName, {
'fn': '_wrapped(2, 5)',
'teardown': 'function wrap(){}'
})
);
suites.push(
Benchmark.Suite('`_.zip`')
.add(buildName, {
'fn': 'lodash.zip.apply(lodash, unzipped)',
'teardown': 'function zip(){}'
})
.add(otherName, {
'fn': '_.zip.apply(_, unzipped)',
'teardown': 'function zip(){}'
})
);
if (Benchmark.platform + '') {
log(Benchmark.platform);
}
// Expose `run` to be called later when executing in a browser.
if (document) {
root.run = run;
} else {
run();
}
}.call(this));
|
// <API key>.h
// Selfy
#import <UIKit/UIKit.h>
@interface <API key> : UIViewController
@end
|
Intermediate PHP & MySQL
=====================
  
> This course is designed for students with a fundamental understanding of programming.
> We will spend some time reviewing PHP basics, for students who are familiar with another language.
> We will then move on to commonly used linguistic constructs, talk about the web, learn Object Oriented principles,
apply some of the most commonly used design patterns, learn about the MySQL database server and learn Symfony.
> We will then spend the rest of the class working on a project, which will ultimately become a part of our portfolio.
Week 1 - [PHP Basics](syllabus/01 PHP Basics.md) [:<API key>:](syllabus/homework/01_count_types.md)
Week 2 - [Functions, Arrays & Strings](syllabus/02 Strings Functions Arrays.md) [:<API key>:](syllabus/homework/02_card_game.md)
Week 3 - [Web Programming](syllabus/03 Web Programming.md) [:<API key>:](syllabus/homework/<API key>.md)
Week 4 - [Object Oriented Programming](syllabus/04 Object Oriented Programming.md) [:<API key>:](syllabus/homework/04_OO_card_game.md)
Week 5 - [Design Patterns](syllabus/05 Design Patterns.md) [:<API key>:](syllabus/homework/05_simon_says.md)
Week 6 - [MySQL Fundamentals](syllabus/06 MySQL Fundamentals.md)
Week 7 - [Introduction to Symfony](syllabus/07 Introduction to Symfony.md)
Week 8 - [ACAShop - Capstone Project Kickoff](syllabus/08 ACAShop Capstone Project Kickoff.md)
Week 9 - In class coding and project completion
Week 10 - Continue in class coding for ACAShop, Student Q&A, the state of PHP and the job market.
# Required Software
Here are some applications you will need installed.
- [VirtualBox](https:
- [Vagrant](https:
- [ansible](http://docs.ansible.com/intro_installation.html) - Configure the VM
- [PHPStorm](https:
- [git](http://git-scm.com/) - Version control system
- [SourceTree](http:
# Developer Environment
# Virtual Machine
We have created a seperate repository that contains instructions on how to setup and configure your VM.
Clone [VirtualMachines](https://github.com/AustinCodingAcademy/VirtualMachines) and follow the instructions.
*Note: We will host workshops, prior to class, to help students setup their machines.*
# Book
[The Symfony Book](http://symfony.com/doc/current/book/index.html) - The Symfony bible, written and maintained by the core team
# Reference
- [Helpful Links](Links.md)
- [git Commands](GitCommands.md)
***
`Instructor`: [Samir Patel](http://samirpatel.me)
`Phone`: (512) 745-7846
`Email`: samir at austincodingacademy dot com
`Office Hours`: 30 minutes after class
|
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
namespace Git.Storage.Common
{
public enum EEquipmentStatus
{
<summary>
</summary>
[Description("")]
Unused = 1,
<summary>
</summary>
[Description("")]
IsUsing = 2,
<summary>
</summary>
[Description("")]
Repair = 3,
<summary>
</summary>
[Description("")]
Breakage = 4,
<summary>
</summary>
[Description("")]
Lost = 5,
}
}
|
@title Motion Detect
]]
a=6 -- columns to split picture into
b=6 -- rows to split picture into
c=1
d=300000 -- timeout (mSec)
e=200 -- comparison interval (msec) - less than 100 will slow down other CHDK functions
f=5 -- threshold (difference in cell to trigger detection)
g=1 -- draw grid (0=no, 1=yes)
h=0 -- not used in LUA - in uBasic is the variable that gets loaded with the number of cells with motion detected
i=0 -- region masking mode: 0=no regions, 1=include, 2=exclude
j=0 -- first column
k=0 -- first row
l=0 -- last column
m=0 -- last row
n=0 -- optional parameters (1=shoot immediate)
o=2 -- pixel step
p=0 -- triggering delay (msec)
zones = md_detect_motion( a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p)
if( zones > 0 ) then
shoot()
end
|
body {
background-image: url("http:
background-size: 800px
}
p {
color: #000000
}
img {
top:100%;
left:100%;
}
a:link {
color: blue;
}
a:hover {
text-decoration: none;
color: red;
}
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.