answer stringlengths 15 1.25M |
|---|
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Preferred width of mrow-like elements</title>
<link rel="help" href="https://w3c.github.io/mathml-core/#<API key>">
<link rel="help" href="https://w3c.github.io/mathml-core/#style-change-mstyle">
<link rel="help" href="https://w3c.github.io/mathml-core/#<API key>">
<link rel="help" href="https://w3c.github.io/mathml-core/#<API key>">
<link rel="help" href="https://w3c.github.io/mathml-core/#<API key>">
<link rel="help" href="https://w3c.github.io/mathml-core/#<API key>">
<meta name="assert" content="The preferred width of mrow-like elements is the sum of children's width, modulo extra spacing.">
<script src="/mathml/support/feature-detection.js"></script>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script type="text/javascript">
setup({ explicit_done: true });
window.addEventListener("load", runTests);
function runTests()
{
var epsilon = 1;
function <API key>(mrow) {
var first = mrow.firstElementChild.<API key>();
var last = mrow.lastElementChild.<API key>();
return last.right - first.left;
}
test(function() {
assert_true(<API key>.has_mspace());
Array.from(document.getElementById("mspace-tests").<API key>("shrink-wrap")).forEach((container) => {
var containerWidth = container.<API key>().width;
var mrow = container.<API key>("mrow-like")[0];
var mrowWidth = <API key>(mrow);
<API key>(containerWidth, mrowWidth, epsilon, mrow.tagName);
});
}, "Preferred width of mrow with mspace children");
test(function() {
assert_true(<API key>.<API key>());
Array.from(document.getElementById("tokens-tests").<API key>("shrink-wrap")).forEach((container) => {
var containerWidth = container.<API key>().width;
var mrow = container.<API key>("mrow-like")[0];
var mrowWidth = <API key>(mrow);
<API key>(containerWidth, mrowWidth, epsilon, mrow.tagName);
});
}, "Preferred width of mrow with mn and mo children");
done();
}
</script>
<style>
div.shrink-wrap {
background: yellow;
display: inline-block;
margin-top: 5px;
padding-top: 5px;
}
</style>
</head>
<body>
<div id="log"></div>
<div id="mspace-tests">
<div><div class="shrink-wrap">
<math><mrow class="mrow-like"><mspace width="30px" height="15px" style="background: blue"/><mspace width="20px" depth="30px" style="background: green"/><mspace width="15px" height="5px" depth="10px" style="background: black"/></mrow></math>
</div></div>
<div>
<div class="shrink-wrap">
<math><mstyle class="mrow-like"><mspace width="30px" height="15px" style="background: blue"/><mspace width="20px" depth="30px" style="background: green"/><mspace width="15px" height="5px" depth="10px" style="background: black"/></mstyle></math>
</div>
</div>
<div>
<div class="shrink-wrap">
<math><mphantom class="mrow-like"><mspace width="30px" height="15px" style="background: blue"/><mspace width="20px" depth="30px" style="background: green"/><mspace width="15px" height="5px" depth="10px" style="background: black"/></mphantom></math>
</div>
</div>
<div>
<div class="shrink-wrap">
<math class="mrow-like"><mspace width="30px" height="15px" style="background: blue"/><mspace width="20px" depth="30px" style="background: green"/><mspace width="15px" height="5px" depth="10px" style="background: black"/></math>
</div>
</div>
<div>
<div class="shrink-wrap">
<math><unknown class="mrow-like"><mspace width="30px" height="15px" style="background: blue"/><mspace width="20px" depth="30px" style="background: green"/><mspace width="15px" height="5px" depth="10px" style="background: black"/></unknown></math>
</div>
</div>
<div>
</div>
</div>
<div id="tokens-tests">
<div>
<div class="shrink-wrap">
<math><mrow class="mrow-like"><mtext>blah</mtext><mo lspace="30px" rspace="20px">|</mo><mn>2</mn></mrow></math>
</div>
</div>
<div>
<div class="shrink-wrap">
<math><mstyle class="mrow-like"><mtext>blah</mtext><mo lspace="30px" rspace="20px">|</mo><mn>2</mn></mstyle></math>
</div>
</div>
<div>
<div class="shrink-wrap">
<math><mphantom class="mrow-like"><mtext>blah</mtext><mo lspace="30px" rspace="20px">|</mo><mn>2</mn></mphantom></math>
</div>
</div>
<div>
<div class="shrink-wrap">
<math class="mrow-like"><mtext>blah</mtext><mo lspace="30px" rspace="20px">|</mo><mn>2</mn></math>
</div>
</div>
<div>
<div class="shrink-wrap">
<math><unknown class="mrow-like"><mtext>blah</mtext><mo lspace="30px" rspace="20px">|</mo><mn>2</mn></unknown></math>
</div>
</div>
</div>
</p>
</body>
</html> |
<?php
/**
* General exception container for the ConsoleTools component referring to option handling.
* This base container allows you to catch all exceptions which are related to
* errors produced by invalid user submitted options {@link ezcConsoleInput::process()}.
*
* @package ConsoleTools
* @version 1.6.1
*/
abstract class <API key> extends ezcConsoleException
{
}
?> |
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import models, migrations
import versatileimagefield.fields
import jsonfield.fields
from decimal import Decimal
import saleor.product.models.fields
import django.core.validators
import django_prices.models
import satchless.item
class Migration(migrations.Migration):
dependencies = [
]
operations = [
migrations.CreateModel(
name='<API key>',
fields=[
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
('display', models.CharField(max_length=100, verbose_name='display name')),
('color', models.CharField(blank=True, max_length=7, verbose_name='color', validators=[django.core.validators.RegexValidator('^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$')])),
('image', versatileimagefield.fields.VersatileImageField(upload_to='attributes', null=True, verbose_name='image', blank=True)),
],
),
migrations.CreateModel(
name='Category',
fields=[
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
('name', models.CharField(max_length=128, verbose_name='name')),
('slug', models.SlugField(verbose_name='slug')),
('description', models.TextField(verbose_name='description', blank=True)),
('hidden', models.BooleanField(default=False, verbose_name='hidden')),
('lft', models.<API key>(editable=False, db_index=True)),
('rght', models.<API key>(editable=False, db_index=True)),
('tree_id', models.<API key>(editable=False, db_index=True)),
('level', models.<API key>(editable=False, db_index=True)),
('parent', models.ForeignKey(related_name='children', verbose_name='parent', blank=True, to='product.Category', null=True)),
],
options={
'verbose_name_plural': 'categories',
},
),
migrations.CreateModel(
name='<API key>',
fields=[
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
('name', models.CharField(max_length=255)),
('discount', django_prices.models.PriceField(currency=b'USD', verbose_name='discount value', max_digits=12, decimal_places=2)),
],
),
migrations.CreateModel(
name='Product',
fields=[
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
('name', models.CharField(max_length=128, verbose_name='name')),
('description', models.TextField(verbose_name='description')),
('price', django_prices.models.PriceField(currency=b'USD', verbose_name='price', max_digits=12, decimal_places=2)),
('weight', saleor.product.models.fields.WeightField(unit=b'lb', verbose_name='weight', max_digits=6, decimal_places=2)),
('available_on', models.DateField(null=True, verbose_name='available on', blank=True)),
],
bases=(models.Model, satchless.item.ItemRange),
),
migrations.CreateModel(
name='ProductAttribute',
fields=[
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
('name', models.SlugField(unique=True, verbose_name='internal name')),
('display', models.CharField(max_length=100, verbose_name='display name')),
],
options={
'ordering': ['name'],
},
),
migrations.CreateModel(
name='ProductImage',
fields=[
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
('image', versatileimagefield.fields.VersatileImageField(upload_to='products')),
('ppoi', versatileimagefield.fields.PPOIField(default='0.5x0.5', max_length=20, editable=False)),
('alt', models.CharField(max_length=128, verbose_name='short description', blank=True)),
('order', models.<API key>(editable=False)),
('product', models.ForeignKey(related_name='images', to='product.Product')),
],
options={
'ordering': ['order'],
},
),
migrations.CreateModel(
name='ProductVariant',
fields=[
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
('sku', models.CharField(unique=True, max_length=32, verbose_name='SKU')),
('name', models.CharField(max_length=100, verbose_name='variant name', blank=True)),
('price_override', django_prices.models.PriceField(decimal_places=2, currency=b'USD', max_digits=12, blank=True, null=True, verbose_name='price override')),
('weight_override', saleor.product.models.fields.WeightField(decimal_places=2, max_digits=6, blank=True, null=True, verbose_name='weight override', unit=b'lb')),
('attributes', jsonfield.fields.JSONField(default={}, verbose_name='attributes')),
('product', models.ForeignKey(related_name='variants', to='product.Product')),
],
bases=(models.Model, satchless.item.Item),
),
migrations.CreateModel(
name='Stock',
fields=[
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
('location', models.CharField(max_length=100, verbose_name='location')),
('quantity', models.IntegerField(default=Decimal('1'), verbose_name='quantity', validators=[django.core.validators.MinValueValidator(0)])),
('cost_price', django_prices.models.PriceField(decimal_places=2, currency=b'USD', max_digits=12, blank=True, null=True, verbose_name='cost price')),
('variant', models.ForeignKey(related_name='stock', verbose_name='variant', to='product.ProductVariant')),
],
),
migrations.AddField(
model_name='product',
name='attributes',
field=models.ManyToManyField(related_name='products', null=True, to='product.ProductAttribute', blank=True),
),
migrations.AddField(
model_name='product',
name='categories',
field=models.ManyToManyField(related_name='products', verbose_name='categories', to='product.Category'),
),
migrations.AddField(
model_name='<API key>',
name='products',
field=models.ManyToManyField(to='product.Product', blank=True),
),
migrations.AddField(
model_name='<API key>',
name='attribute',
field=models.ForeignKey(related_name='values', to='product.ProductAttribute'),
),
migrations.AlterUniqueTogether(
name='stock',
unique_together=set([('variant', 'location')]),
),
] |
<?php
defined('C5_EXECUTE') or die("Access Denied.");
if ($action == null) {
// we can pass an action from the block, but in most instances we won't, we'll use the default
$action = $bt->getBlockAddAction($a);
global $c;
} ?>
<a name="_add<?php echo $bt->getBlockTypeID()?>"></a>
<script type="text/javascript">
<?php $ci = Loader::helper("concrete/urls"); ?>
<?php $url = $ci-><API key>($bt);
if ($url != '') { ?>
ccm_addHeaderItem("<?php echo $url?>", 'JAVASCRIPT');
<?php }
$identifier = strtoupper('BLOCK_CONTROLLER_' . $btHandle);
if (is_array($headerItems[$identifier])) {
foreach($headerItems[$identifier] as $item) {
if ($item instanceof CSSOutputObject) {
$type = 'CSS';
} else {
$type = 'JAVASCRIPT';
}
?>
ccm_addHeaderItem("<?php echo $item->file?>", '<?php echo $type?>');
<?php
}
}
?>
$(function() {
$('#ccm-block-form').each(function() {
ccm_setupBlockForm($(this), false, 'add');
});
});
</script>
<input type="hidden" name="<API key>" value="<?php echo Loader::helper('security')->sanitizeURL($_SERVER['REQUEST_URI']); ?>" />
<?php
$hih = Loader::helper("concrete/interface/help");
$blockTypes = $hih->getBlockTypes();
$cont = $bt->getController();
if (isset($blockTypes[$bt->getBlockTypeHandle()])) {
$help = $blockTypes[$bt->getBlockTypeHandle()];
} else {
if ($cont->getBlockTypeHelp()) {
$help = $cont->getBlockTypeHelp();
}
}
if (isset($help)) { ?>
<div class="dialog-help" id="<API key>"><?php
if (is_array($help)) {
print $help[0] . '<br><br><a href="' . $help[1] . '" class="btn small" target="_blank">' . t('Learn More') . '</a>';
} else {
print $help;
}
?></div>
<?php } ?>
<?php if ($cont-><API key>() != '') { ?>
<div class="<?php echo $cont-><API key>();?>">
<?php } ?>
<form method="post" action="<?php echo $action?>" id="ccm-block-form" enctype="multipart/form-data" class="validate form-horizontal">
<input type="hidden" name="<API key>" value="REGULAR" />
<?php foreach($this->controller-><API key>() as $key => $val) { ?>
<input type="hidden" name="ccm-string-<?php echo $key?>" value="<?php echo $val?>" />
<?php } ?>
<div id="ccm-block-fields"> |
function whoAmI(a, i) {
a.splice(i, 1);
a.c //+? concat, copyWithin
} |
#ifndef <API key>
#define <API key>
#if (defined _MSC_VER)
#pragma warning( disable : 4786 )
#endif
#include "ExifConf.h"
#include "ExifTypeDefs.h"
#include "ExifIO.h"
#define <API key> 128
// The idea was to use strcpy_s and strncpy_s for buffer safety reasons,
// but that introduced a whole new set of problems (bugs in compilers(VC8)).
// So here's an implementation that should work on all platforms
inline void openexif_strcpy_s(char *cpy, int max_size, const char *org)
{
if (cpy && org){
int i = 0;
for (i=0;(i<max_size)&&(*org != 0);cpy++,i++,org++) *cpy = *org;
*cpy = 0;
}
}
#define OPENEXIF_STRCPY_S openexif_strcpy_s
/*!
\author George Sotak <george.sotak@kodak.com>
\date Sun Jan 20 09:18:08 2002
\brief Base class for all Application Segment implementations
*/
class EXIF_DECL ExifAppSegment
{
public:
//! Destructor
virtual ~ExifAppSegment()
{ }
/*! Creates the Application Identification string
\param marker the app segment marker (e.g., 0xFFE1, 0xFFE2, etc.)
\param ident the app segment identifier (e.g., "EXIF")
\param id the output identification string
*/
static void createAppId(uint16 marker,const std::string& ident,
std::string& id ) ;
/*! Factory method for the instantiation of App Segment implementations
\param ident the app segment identifier in toolkit expected format
\param defaultToRaw return a raw app segment if no other is found.
\return a base class pointer to the instantiated
implementation if previously registered with factory,
otherwise NULL
Example:
\code
string id ;
ExifAppSegment::createAppId( 0xFFE1, "Exif", id ) ;
ExifAppSegement* appSeg = ExifAppSegment::create( id ) ;
\endcode
*/
static ExifAppSegment* create( const std::string& ident,
bool defaultToRaw = true );
static ExifAppSegment* create( uint16 marker, const std::string& id,
bool defaultToRaw = true );
//inline static int addEntry(string key, ExifAppSegment * appSeg)
//{ msFactory.addEntry(key,appSeg); return 0;};
virtual ExifAppSegment* clone( void ) const = 0 ;
// Is this a TIFF (IFD) Based AppSegment?
virtual bool isTiff()
{ return false; }
// Is this a RAW app segment?
virtual bool isRaw()
{ return false; }
virtual ExifStatus init( ExifIO* exifio, uint16 _length,
exifoff_t _exifHeaderOffset ) ;
/*! Get the length of this app Segment in bytes.
\return length of the app segment.
*/
uint16 getLength( void ) const
{ return mLength; }
/*! Get the app Segment Label.
\return The app segment label.
*/
const char* getAppIdent( void ) const
{ return mIdent; }
/*! Get the app Segment marker.
\return the app segment marker.
*/
uint16 getAppSegmentMarker( void ) const
{ return mMarker; }
//! Write out the App Segment to the file
virtual ExifStatus write( ExifIO* exifio ) = 0 ;
protected:
//static ExifAppSegFactoryT msFactory ;
exifoff_t mExifOffset ;
exifoff_t mOffsetToLength ;
uint16 mMarker;
uint16 mLength;
exif_uint32 mSavedExifioFlags ;
bool mSavedEndianState ;
exif_uint32 mMyExifioFlags ;
bool mMyEndianState ;
// We currently support an identifier up to 128 bytes.
// Is this enough?? Or do we need to be more flexible??
char mIdent[<API key>];
ExifAppSegment( uint16 _appMarker, uint16 _length, const char* _ident,
exifoff_t _exifOffset )
: mExifOffset(_exifOffset), mOffsetToLength(0),
mMarker(_appMarker), mLength(_length),
mSavedExifioFlags(0), mSavedEndianState(0), mMyExifioFlags(0),
mMyEndianState(0)
{
initIdent();
OPENEXIF_STRCPY_S(mIdent, <API key>, _ident) ;
}
ExifAppSegment( uint16 _appMarker, const char* _ident )
: mExifOffset(0), mOffsetToLength(0), mMarker(_appMarker),
mLength(0),mSavedExifioFlags(0), mSavedEndianState(0), mMyExifioFlags(0),
mMyEndianState(0)
{
initIdent();
OPENEXIF_STRCPY_S(mIdent, <API key>, _ident) ;
}
// Copy Constructor
ExifAppSegment( const ExifAppSegment& theSrc )
: mExifOffset(theSrc.mExifOffset),
mOffsetToLength(theSrc.mOffsetToLength),
mMarker(theSrc.mMarker), mLength(theSrc.mLength),
mSavedExifioFlags(theSrc.mSavedExifioFlags),
mSavedEndianState(theSrc.mSavedEndianState),
mMyExifioFlags(theSrc.mMyExifioFlags),
mMyEndianState(theSrc.mMyEndianState)
{
const char * tmpOrig= theSrc.mIdent;
char * tmpCopy = mIdent;
for(int i=0;
i < <API key>;
i++,tmpCopy++,tmpOrig++)
*tmpCopy = *tmpOrig;
}
void initIdent( void )
{
memset( static_cast<void*>(&mIdent[0]), 0, <API key>) ;
}
// Saves current ExifIO flags and set them to mMyExifioFlags
virtual void setMyExifioFlags( ExifIO* exifio ) ;
// Restores saved ExifIO flags
virtual void restoreExifioFlags( ExifIO* exifio ) ;
} ;
#endif //<API key> |
<div ng-controller="Umbraco.PrevalueEditors.<API key>" class="umb-editor umb-contentpicker">
<ul class="unstyled list-icons"
ng-model="renderModel">
<li ng-repeat="node in renderModel">
<a href="" class="hover-show pull-right"><i class="icon icon-delete red" ng-click="remove($index, $event)"></i></a>
<i class="icon {{node.icon}} hover-hide"></i>
<a href prevent-default ng-click="openContentPicker()" >{{node.name}}</a>
</li>
</ul>
<ul class="unstyled list-icons" ng-show="multipicker || renderModel.length === 0">
<li>
<i class="icon icon-add turquoise"></i>
<a href ng-click="openContentPicker()" prevent-default>
<localize key="general_add">Add</localize>
</a>
</li>
</ul>
<umb-overlay
ng-if="<API key>.show"
model="<API key>"
position="right"
view="<API key>.view">
</umb-overlay>
</div> |
#include <linux/init.h>
#include <linux/input-polldev.h>
#include <linux/ioport.h>
#include <linux/module.h>
#include <linux/platform_device.h>
#ifdef CONFIG_SGI_IP22
#include <asm/sgi/ioc.h>
static inline u8 button_status(void)
{
u8 status;
status = readb(&sgioc->panel) ^ 0xa0;
return ((status & 0x80) >> 6) | ((status & 0x20) >> 5);
}
#endif
#ifdef CONFIG_SGI_IP32
#include <asm/ip32/mace.h>
static inline u8 button_status(void)
{
u64 status;
status = readq(&mace->perif.audio.control);
writeq(status & ~(3U << 23), &mace->perif.audio.control);
return (status >> 23) & 3;
}
#endif
#define <API key> 30 /* msec */
#define <API key> 3
static const unsigned short sgi_map[] = {
KEY_VOLUMEDOWN,
KEY_VOLUMEUP
};
struct buttons_dev {
struct input_polled_dev *poll_dev;
unsigned short keymap[ARRAY_SIZE(sgi_map)];
int count[ARRAY_SIZE(sgi_map)];
};
static void handle_buttons(struct input_polled_dev *dev)
{
struct buttons_dev *bdev = dev->private;
struct input_dev *input = dev->input;
u8 status;
int i;
status = button_status();
for (i = 0; i < ARRAY_SIZE(bdev->keymap); i++) {
if (status & (1U << i)) {
if (++bdev->count[i] == <API key>) {
input_event(input, EV_MSC, MSC_SCAN, i);
input_report_key(input, bdev->keymap[i], 1);
input_sync(input);
}
} else {
if (bdev->count[i] >= <API key>) {
input_event(input, EV_MSC, MSC_SCAN, i);
input_report_key(input, bdev->keymap[i], 0);
input_sync(input);
}
bdev->count[i] = 0;
}
}
}
static int __devinit sgi_buttons_probe(struct platform_device *pdev)
{
struct buttons_dev *bdev;
struct input_polled_dev *poll_dev;
struct input_dev *input;
int error, i;
bdev = kzalloc(sizeof(struct buttons_dev), GFP_KERNEL);
poll_dev = <API key>();
if (!bdev || !poll_dev) {
error = -ENOMEM;
goto err_free_mem;
}
memcpy(bdev->keymap, sgi_map, sizeof(bdev->keymap));
poll_dev->private = bdev;
poll_dev->poll = handle_buttons;
poll_dev->poll_interval = <API key>;
input = poll_dev->input;
input->name = "SGI buttons";
input->phys = "sgi/input0";
input->id.bustype = BUS_HOST;
input->dev.parent = &pdev->dev;
input->keycode = bdev->keymap;
input->keycodemax = ARRAY_SIZE(bdev->keymap);
input->keycodesize = sizeof(unsigned short);
<API key>(input, EV_MSC, MSC_SCAN);
__set_bit(EV_KEY, input->evbit);
for (i = 0; i < ARRAY_SIZE(sgi_map); i++)
__set_bit(bdev->keymap[i], input->keybit);
__clear_bit(KEY_RESERVED, input->keybit);
bdev->poll_dev = poll_dev;
dev_set_drvdata(&pdev->dev, bdev);
error = <API key>(poll_dev);
if (error)
goto err_free_mem;
return 0;
err_free_mem:
<API key>(poll_dev);
kfree(bdev);
dev_set_drvdata(&pdev->dev, NULL);
return error;
}
static int __devexit sgi_buttons_remove(struct platform_device *pdev)
{
struct device *dev = &pdev->dev;
struct buttons_dev *bdev = dev_get_drvdata(dev);
<API key>(bdev->poll_dev);
<API key>(bdev->poll_dev);
kfree(bdev);
dev_set_drvdata(dev, NULL);
return 0;
}
static struct platform_driver sgi_buttons_driver = {
.probe = sgi_buttons_probe,
.remove = __devexit_p(sgi_buttons_remove),
.driver = {
.name = "sgibtns",
.owner = THIS_MODULE,
},
};
static int __init sgi_buttons_init(void)
{
return <API key>(&sgi_buttons_driver);
}
static void __exit sgi_buttons_exit(void)
{
<API key>(&sgi_buttons_driver);
}
module_init(sgi_buttons_init);
module_exit(sgi_buttons_exit); |
package autotest.tko;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.user.client.ui.Anchor;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.HorizontalPanel;
import com.google.gwt.user.client.ui.Panel;
import com.google.gwt.user.client.ui.VerticalPanel;
import com.google.gwt.user.client.ui.Widget;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
class WidgetList<T extends Widget> extends Composite implements ClickHandler {
public interface ListWidgetFactory<S extends Widget> {
public List<String> getWidgetTypes();
public S getNewWidget(String type);
}
private ListWidgetFactory<T> factory;
private List<T> widgets = new ArrayList<T>();
private Panel widgetPanel = new VerticalPanel();
private HorizontalPanel addLinksPanel = new HorizontalPanel();
public WidgetList(ListWidgetFactory<T> factory) {
this.factory = factory;
addLinksPanel.setSpacing(10);
for (String type : factory.getWidgetTypes()) {
Anchor addLink = new Anchor(type);
addLink.addClickHandler(this);
addLinksPanel.add(addLink);
}
Panel outerPanel = new VerticalPanel();
outerPanel.add(widgetPanel);
outerPanel.add(addLinksPanel);
initWidget(outerPanel);
}
public void addWidget(T widget) {
widgets.add(widget);
widgetPanel.add(widget);
}
public void deleteWidget(T widget) {
widgets.remove(widget);
widgetPanel.remove(widget);
}
public void onClick(ClickEvent event) {
assert (event.getSource() instanceof Anchor);
Anchor addLink = (Anchor) event.getSource();
T widget = factory.getNewWidget(addLink.getText());
addWidget(widget);
}
public List<T> getWidgets() {
return Collections.unmodifiableList(widgets);
}
public void clear() {
widgets.clear();
widgetPanel.clear();
}
} |
#ifndef QWT_PLOT_LAYOUT_H
#define QWT_PLOT_LAYOUT_H
#include "qwt_global.h"
#include "qwt_plot.h"
#include "qwt_axis_id.h"
/*!
\brief Layout engine for QwtPlot.
It is used by the QwtPlot widget to organize its internal widgets
or by QwtPlot::print() to render its content to a QPaintDevice like
a QPrinter, QPixmap/QImage or QSvgRenderer.
\sa QwtPlot::setPlotLayout()
*/
class QWT_EXPORT QwtPlotLayout
{
public:
/*!
Options to configure the plot layout engine
\sa update(), QwtPlotRenderer
*/
enum Option
{
//! Unused
AlignScales = 0x01,
/*!
Ignore the dimension of the scrollbars. There are no
scrollbars, when the plot is not rendered to widgets.
*/
IgnoreScrollbars = 0x02,
//! Ignore all frames.
IgnoreFrames = 0x04,
//! Ignore the legend.
IgnoreLegend = 0x08,
//! Ignore the title.
IgnoreTitle = 0x10,
//! Ignore the footer.
IgnoreFooter = 0x20
};
//! Layout options
typedef QFlags<Option> Options;
explicit QwtPlotLayout();
virtual ~QwtPlotLayout();
void setCanvasMargin( int margin, int axis = -1 );
int canvasMargin( int axis ) const;
void <API key>( bool );
void <API key>( int axisId, bool );
bool alignCanvasToScale( int axisId ) const;
void setSpacing( int );
int spacing() const;
void setLegendPosition( QwtPlot::LegendPosition pos, double ratio );
void setLegendPosition( QwtPlot::LegendPosition pos );
QwtPlot::LegendPosition legendPosition() const;
void setLegendRatio( double ratio );
double legendRatio() const;
virtual QSize minimumSizeHint( const QwtPlot * ) const;
void update( const QwtPlot *,
const QRectF &rect, Options options = 0x00 );
virtual void invalidate();
QRectF titleRect() const;
QRectF footerRect() const;
QRectF legendRect() const;
QRectF scaleRect( QwtAxisId axis ) const;
QRectF canvasRect() const;
protected:
virtual void activate( const QwtPlot *,
const QRectF &rect, Options options );
void setTitleRect( const QRectF & );
void setFooterRect( const QRectF & );
void setLegendRect( const QRectF & );
void setScaleRect( QwtAxisId axis, const QRectF & );
void setCanvasRect( const QRectF & );
private:
class PrivateData;
PrivateData *d_data;
};
<API key>( QwtPlotLayout::Options )
#endif |
#include <linux/module.h>
#include <linux/init.h>
#include <linux/sched.h>
#include <linux/time.h>
#include <linux/kernel.h>
#include <linux/mm.h>
#include <linux/string.h>
#include <linux/stat.h>
#include <linux/errno.h>
#include <linux/unistd.h>
#include <linux/sunrpc/clnt.h>
#include <linux/sunrpc/stats.h>
#include <linux/sunrpc/metrics.h>
#include <linux/nfs_fs.h>
#include <linux/nfs_mount.h>
#include <linux/nfs4_mount.h>
#include <linux/lockd/bind.h>
#include <linux/seq_file.h>
#include <linux/mount.h>
#include <linux/nfs_idmap.h>
#include <linux/vfs.h>
#include <linux/inet.h>
#include <linux/nfs_xdr.h>
#include <linux/slab.h>
#include <linux/compat.h>
#include <linux/freezer.h>
#include <linux/crc32.h>
#include <asm/system.h>
#include <asm/uaccess.h>
#include "nfs4_fs.h"
#include "callback.h"
#include "delegation.h"
#include "iostat.h"
#include "internal.h"
#include "fscache.h"
#include "dns_resolve.h"
#include "pnfs.h"
#define NFSDBG_FACILITY NFSDBG_VFS
#define <API key> 1
/* Default is to see 64-bit inode numbers */
static int enable_ino64 = <API key>;
static void <API key>(struct inode *);
static int nfs_update_inode(struct inode *, struct nfs_fattr *);
static struct kmem_cache * nfs_inode_cachep;
static inline unsigned long
nfs_fattr_to_ino_t(struct nfs_fattr *fattr)
{
return nfs_fileid_to_ino_t(fattr->fileid);
}
/**
* <API key> - helper for functions that are sleeping on bit locks
* @word: long word containing the bit lock
*/
int <API key>(void *word)
{
if (<API key>(current))
return -ERESTARTSYS;
freezable_schedule();
return 0;
}
EXPORT_SYMBOL_GPL(<API key>);
/**
* <API key> - returns the user-visible inode number
* @fileid: 64-bit fileid
*
* This function returns a 32-bit inode number if the boot parameter
* nfs.enable_ino64 is zero.
*/
u64 <API key>(u64 fileid)
{
#ifdef CONFIG_COMPAT
compat_ulong_t ino;
#else
unsigned long ino;
#endif
if (enable_ino64)
return fileid;
ino = fileid;
if (sizeof(ino) < sizeof(fileid))
ino ^= fileid >> (sizeof(fileid)-sizeof(ino)) * 8;
return ino;
}
void nfs_clear_inode(struct inode *inode)
{
/*
* The following should never happen...
*/
BUG_ON(nfs_have_writebacks(inode));
BUG_ON(!list_empty(&NFS_I(inode)->open_files));
nfs_zap_acl_cache(inode);
<API key>(inode);
<API key>(inode);
}
/**
* nfs_sync_mapping - helper to flush all mmapped dirty data to disk
*/
int nfs_sync_mapping(struct address_space *mapping)
{
int ret = 0;
if (mapping->nrpages != 0) {
unmap_mapping_range(mapping, 0, 0, 0);
ret = nfs_wb_all(mapping->host);
}
return ret;
}
/*
* Invalidate the local caches
*/
static void <API key>(struct inode *inode)
{
struct nfs_inode *nfsi = NFS_I(inode);
int mode = inode->i_mode;
nfs_inc_stats(inode, <API key>);
nfsi->attrtimeo = NFS_MINATTRTIMEO(inode);
nfsi->attrtimeo_timestamp = jiffies;
memset(NFS_COOKIEVERF(inode), 0, sizeof(NFS_COOKIEVERF(inode)));
if (S_ISREG(mode) || S_ISDIR(mode) || S_ISLNK(mode)) {
nfsi->cache_validity |= <API key>|<API key>|<API key>|NFS_INO_INVALID_ACL|<API key>;
<API key>(inode);
} else {
nfsi->cache_validity |= <API key>|<API key>|NFS_INO_INVALID_ACL|<API key>;
}
}
void nfs_zap_caches(struct inode *inode)
{
spin_lock(&inode->i_lock);
<API key>(inode);
spin_unlock(&inode->i_lock);
}
void nfs_zap_mapping(struct inode *inode, struct address_space *mapping)
{
if (mapping->nrpages != 0) {
spin_lock(&inode->i_lock);
NFS_I(inode)->cache_validity |= <API key>;
<API key>(inode);
spin_unlock(&inode->i_lock);
}
}
void nfs_zap_acl_cache(struct inode *inode)
{
void (*clear_acl_cache)(struct inode *);
clear_acl_cache = NFS_PROTO(inode)->clear_acl_cache;
if (clear_acl_cache != NULL)
clear_acl_cache(inode);
spin_lock(&inode->i_lock);
NFS_I(inode)->cache_validity &= ~NFS_INO_INVALID_ACL;
spin_unlock(&inode->i_lock);
}
void <API key>(struct inode *inode)
{
spin_lock(&inode->i_lock);
NFS_I(inode)->cache_validity |= <API key>;
spin_unlock(&inode->i_lock);
}
/*
* Invalidate, but do not unhash, the inode.
* NB: must be called with inode->i_lock held!
*/
static void <API key>(struct inode *inode)
{
set_bit(NFS_INO_STALE, &NFS_I(inode)->flags);
<API key>(inode);
}
struct nfs_find_desc {
struct nfs_fh *fh;
struct nfs_fattr *fattr;
};
/*
* In NFSv3 we can have 64bit inode numbers. In order to support
* this, and re-exported directories (also seen in NFSv2)
* we are forced to allow 2 different inodes to have the same
* i_ino.
*/
static int
nfs_find_actor(struct inode *inode, void *opaque)
{
struct nfs_find_desc *desc = (struct nfs_find_desc *)opaque;
struct nfs_fh *fh = desc->fh;
struct nfs_fattr *fattr = desc->fattr;
if (NFS_FILEID(inode) != fattr->fileid)
return 0;
if ((S_IFMT & inode->i_mode) != (S_IFMT & fattr->mode))
return 0;
if (nfs_compare_fh(NFS_FH(inode), fh))
return 0;
if (is_bad_inode(inode) || NFS_STALE(inode))
return 0;
return 1;
}
static int
nfs_init_locked(struct inode *inode, void *opaque)
{
struct nfs_find_desc *desc = (struct nfs_find_desc *)opaque;
struct nfs_fattr *fattr = desc->fattr;
set_nfs_fileid(inode, fattr->fileid);
nfs_copy_fh(NFS_FH(inode), desc->fh);
return 0;
}
/*
* This is our front-end to iget that looks up inodes by file handle
* instead of inode number.
*/
struct inode *
nfs_fhget(struct super_block *sb, struct nfs_fh *fh, struct nfs_fattr *fattr)
{
struct nfs_find_desc desc = {
.fh = fh,
.fattr = fattr
};
struct inode *inode = ERR_PTR(-ENOENT);
unsigned long hash;
<API key>(sb, fattr);
if (((fattr->valid & <API key>) == 0) &&
!<API key>(fattr))
goto out_no_inode;
if ((fattr->valid & NFS_ATTR_FATTR_TYPE) == 0)
goto out_no_inode;
hash = nfs_fattr_to_ino_t(fattr);
inode = iget5_locked(sb, hash, nfs_find_actor, nfs_init_locked, &desc);
if (inode == NULL) {
inode = ERR_PTR(-ENOMEM);
goto out_no_inode;
}
if (inode->i_state & I_NEW) {
struct nfs_inode *nfsi = NFS_I(inode);
unsigned long now = jiffies;
/* We set i_ino for the few things that still rely on it,
* such as stat(2) */
inode->i_ino = hash;
/* We can't support update_atime(), since the server will reset it */
inode->i_flags |= S_NOATIME|S_NOCMTIME;
inode->i_mode = fattr->mode;
if ((fattr->valid & NFS_ATTR_FATTR_MODE) == 0
&& nfs_server_capable(inode, NFS_CAP_MODE))
nfsi->cache_validity |= <API key>;
/* Why so? Because we want revalidate for devices/FIFOs, and
* that's precisely what we have in <API key>.
*/
inode->i_op = NFS_SB(sb)->nfs_client->rpc_ops->file_inode_ops;
if (S_ISREG(inode->i_mode)) {
inode->i_fop = NFS_SB(sb)->nfs_client->rpc_ops->file_ops;
inode->i_data.a_ops = &nfs_file_aops;
inode->i_data.backing_dev_info = &NFS_SB(sb)->backing_dev_info;
} else if (S_ISDIR(inode->i_mode)) {
inode->i_op = NFS_SB(sb)->nfs_client->rpc_ops->dir_inode_ops;
inode->i_fop = &nfs_dir_operations;
set_ext_aops(&inode->i_data, &nfs_dir_aops);
/* Deal with crossing mountpoints */
if (fattr->valid & <API key> ||
fattr->valid & <API key>) {
if (fattr->valid & <API key>)
inode->i_op = &<API key>;
else
inode->i_op = &<API key>;
inode->i_fop = NULL;
inode->i_flags |= S_AUTOMOUNT;
}
} else if (S_ISLNK(inode->i_mode))
inode->i_op = &<API key>;
else
init_special_inode(inode, inode->i_mode, fattr->rdev);
memset(&inode->i_atime, 0, sizeof(inode->i_atime));
memset(&inode->i_mtime, 0, sizeof(inode->i_mtime));
memset(&inode->i_ctime, 0, sizeof(inode->i_ctime));
nfsi->change_attr = 0;
inode->i_size = 0;
inode->i_nlink = 0;
inode->i_uid = -2;
inode->i_gid = -2;
inode->i_blocks = 0;
memset(nfsi->cookieverf, 0, sizeof(nfsi->cookieverf));
nfsi->read_cache_jiffies = fattr->time_start;
nfsi->attr_gencount = fattr->gencount;
if (fattr->valid & <API key>)
inode->i_atime = fattr->atime;
else if (nfs_server_capable(inode, NFS_CAP_ATIME))
nfsi->cache_validity |= <API key>;
if (fattr->valid & <API key>)
inode->i_mtime = fattr->mtime;
else if (nfs_server_capable(inode, NFS_CAP_MTIME))
nfsi->cache_validity |= <API key>;
if (fattr->valid & <API key>)
inode->i_ctime = fattr->ctime;
else if (nfs_server_capable(inode, NFS_CAP_CTIME))
nfsi->cache_validity |= <API key>;
if (fattr->valid & <API key>)
nfsi->change_attr = fattr->change_attr;
else if (nfs_server_capable(inode, NFS_CAP_CHANGE_ATTR))
nfsi->cache_validity |= <API key>;
if (fattr->valid & NFS_ATTR_FATTR_SIZE)
inode->i_size = nfs_size_to_loff_t(fattr->size);
else
nfsi->cache_validity |= <API key>
| <API key>;
if (fattr->valid & <API key>)
inode->i_nlink = fattr->nlink;
else if (nfs_server_capable(inode, NFS_CAP_NLINK))
nfsi->cache_validity |= <API key>;
if (fattr->valid & <API key>)
inode->i_uid = fattr->uid;
else if (nfs_server_capable(inode, NFS_CAP_OWNER))
nfsi->cache_validity |= <API key>;
if (fattr->valid & <API key>)
inode->i_gid = fattr->gid;
else if (nfs_server_capable(inode, NFS_CAP_OWNER_GROUP))
nfsi->cache_validity |= <API key>;
if (fattr->valid & <API key>)
inode->i_blocks = fattr->du.nfs2.blocks;
if (fattr->valid & <API key>) {
/*
* report the blocks in 512byte units
*/
inode->i_blocks = nfs_calc_block_size(fattr->du.nfs3.used);
}
nfsi->attrtimeo = NFS_MINATTRTIMEO(inode);
nfsi->attrtimeo_timestamp = now;
nfsi->access_cache = RB_ROOT;
<API key>(inode);
unlock_new_inode(inode);
} else
nfs_refresh_inode(inode, fattr);
dprintk("NFS: nfs_fhget(%s/%Ld fh_crc=0x%08x ct=%d)\n",
inode->i_sb->s_id,
(long long)NFS_FILEID(inode),
<API key>(fh),
atomic_read(&inode->i_count));
out:
return inode;
out_no_inode:
dprintk("nfs_fhget: iget failed with error %ld\n", PTR_ERR(inode));
goto out;
}
EXPORT_SYMBOL_GPL(nfs_fhget);
#define NFS_VALID_ATTRS (ATTR_MODE|ATTR_UID|ATTR_GID|ATTR_SIZE|ATTR_ATIME|ATTR_ATIME_SET|ATTR_MTIME|ATTR_MTIME_SET|ATTR_FILE|ATTR_OPEN)
int
nfs_setattr(struct dentry *dentry, struct iattr *attr)
{
struct inode *inode = dentry->d_inode;
struct nfs_fattr *fattr;
int error = -ENOMEM;
nfs_inc_stats(inode, NFSIOS_VFSSETATTR);
/* skip mode change if it's just for clearing setuid/setgid */
if (attr->ia_valid & (ATTR_KILL_SUID | ATTR_KILL_SGID))
attr->ia_valid &= ~ATTR_MODE;
if (attr->ia_valid & ATTR_SIZE) {
if (!S_ISREG(inode->i_mode) || attr->ia_size == i_size_read(inode))
attr->ia_valid &= ~ATTR_SIZE;
}
/* Optimization: if the end result is no change, don't RPC */
attr->ia_valid &= NFS_VALID_ATTRS;
if ((attr->ia_valid & ~(ATTR_FILE|ATTR_OPEN)) == 0)
return 0;
/* Write all dirty data */
if (S_ISREG(inode->i_mode))
nfs_wb_all(inode);
fattr = nfs_alloc_fattr();
if (fattr == NULL)
goto out;
/*
* Return any delegations if we're going to change ACLs
*/
if ((attr->ia_valid & (ATTR_MODE|ATTR_UID|ATTR_GID)) != 0)
<API key>(inode);
error = NFS_PROTO(inode)->setattr(dentry, fattr, attr);
if (error == 0)
nfs_refresh_inode(inode, fattr);
nfs_free_fattr(fattr);
out:
return error;
}
/**
* nfs_vmtruncate - unmap mappings "freed" by truncate() syscall
* @inode: inode of the file used
* @offset: file offset to start truncating
*
* This is a copy of the common vmtruncate, but with the locking
* corrected to take into account the fact that NFS requires
* inode->i_size to be updated under the inode->i_lock.
*/
static int nfs_vmtruncate(struct inode * inode, loff_t offset)
{
loff_t oldsize;
int err;
err = inode_newsize_ok(inode, offset);
if (err)
goto out;
spin_lock(&inode->i_lock);
oldsize = inode->i_size;
i_size_write(inode, offset);
spin_unlock(&inode->i_lock);
truncate_pagecache(inode, oldsize, offset);
out:
return err;
}
/**
* <API key> - Update inode metadata after a setattr call.
* @inode: pointer to struct inode
* @attr: pointer to struct iattr
*
* Note: we do this in the *proc.c in order to ensure that
* it works for things like exclusive creates too.
*/
void <API key>(struct inode *inode, struct iattr *attr)
{
if ((attr->ia_valid & (ATTR_MODE|ATTR_UID|ATTR_GID)) != 0) {
spin_lock(&inode->i_lock);
if ((attr->ia_valid & ATTR_MODE) != 0) {
int mode = attr->ia_mode & S_IALLUGO;
mode |= inode->i_mode & ~S_IALLUGO;
inode->i_mode = mode;
}
if ((attr->ia_valid & ATTR_UID) != 0)
inode->i_uid = attr->ia_uid;
if ((attr->ia_valid & ATTR_GID) != 0)
inode->i_gid = attr->ia_gid;
NFS_I(inode)->cache_validity |= <API key>|NFS_INO_INVALID_ACL;
spin_unlock(&inode->i_lock);
}
if ((attr->ia_valid & ATTR_SIZE) != 0) {
nfs_inc_stats(inode, NFSIOS_SETATTRTRUNC);
nfs_vmtruncate(inode, attr->ia_size);
}
}
int nfs_getattr(struct vfsmount *mnt, struct dentry *dentry, struct kstat *stat)
{
struct inode *inode = dentry->d_inode;
int need_atime = NFS_I(inode)->cache_validity & <API key>;
int err;
/* Flush out writes to the server in order to update c/mtime. */
if (S_ISREG(inode->i_mode)) {
err = <API key>(inode->i_mapping);
if (err)
goto out;
}
/*
* We may force a getattr if the user cares about atime.
*
* Note that we only have to check the vfsmount flags here:
* - NFS always sets S_NOATIME by so checking it would give a
* bogus result
* - NFS never sets MS_NOATIME or MS_NODIRATIME so there is
* no point in checking those.
*/
if ((mnt->mnt_flags & MNT_NOATIME) ||
((mnt->mnt_flags & MNT_NODIRATIME) && S_ISDIR(inode->i_mode)))
need_atime = 0;
if (need_atime)
err = <API key>(NFS_SERVER(inode), inode);
else
err = <API key>(NFS_SERVER(inode), inode);
if (!err) {
generic_fillattr(inode, stat);
stat->ino = <API key>(NFS_FILEID(inode));
}
out:
return err;
}
static void <API key>(struct nfs_lock_context *l_ctx)
{
atomic_set(&l_ctx->count, 1);
l_ctx->lockowner.l_owner = current->files;
l_ctx->lockowner.l_pid = current->tgid;
INIT_LIST_HEAD(&l_ctx->list);
nfs_iocounter_init(&l_ctx->io_count);
}
static struct nfs_lock_context *<API key>(struct nfs_open_context *ctx)
{
struct nfs_lock_context *head = &ctx->lock_context;
struct nfs_lock_context *pos = head;
do {
if (pos->lockowner.l_owner != current->files)
continue;
if (pos->lockowner.l_pid != current->tgid)
continue;
atomic_inc(&pos->count);
return pos;
} while ((pos = list_entry(pos->list.next, typeof(*pos), list)) != head);
return NULL;
}
struct nfs_lock_context *<API key>(struct nfs_open_context *ctx)
{
struct nfs_lock_context *res, *new = NULL;
struct inode *inode = ctx->dentry->d_inode;
spin_lock(&inode->i_lock);
res = <API key>(ctx);
if (res == NULL) {
spin_unlock(&inode->i_lock);
new = kmalloc(sizeof(*new), GFP_KERNEL);
if (new == NULL)
return ERR_PTR(-ENOMEM);
<API key>(new);
spin_lock(&inode->i_lock);
res = <API key>(ctx);
if (res == NULL) {
list_add_tail(&new->list, &ctx->lock_context.list);
new->open_context = ctx;
res = new;
new = NULL;
}
}
spin_unlock(&inode->i_lock);
kfree(new);
return res;
}
void <API key>(struct nfs_lock_context *l_ctx)
{
struct nfs_open_context *ctx = l_ctx->open_context;
struct inode *inode = ctx->dentry->d_inode;
if (!atomic_dec_and_lock(&l_ctx->count, &inode->i_lock))
return;
list_del(&l_ctx->list);
spin_unlock(&inode->i_lock);
kfree(l_ctx);
}
/**
* nfs_close_context - Common close_context() routine NFSv2/v3
* @ctx: pointer to context
* @is_sync: is this a synchronous close
*
* always ensure that the attributes are up to date if we're mounted
* with close-to-open semantics
*/
void nfs_close_context(struct nfs_open_context *ctx, int is_sync)
{
struct inode *inode;
struct nfs_server *server;
if (!(ctx->mode & FMODE_WRITE))
return;
if (!is_sync)
return;
inode = ctx->dentry->d_inode;
if (!list_empty(&NFS_I(inode)->open_files))
return;
server = NFS_SERVER(inode);
if (server->flags & NFS_MOUNT_NOCTO)
return;
<API key>(server, inode);
}
struct nfs_open_context *<API key>(struct dentry *dentry, struct rpc_cred *cred, fmode_t f_mode)
{
struct nfs_open_context *ctx;
ctx = kmalloc(sizeof(*ctx), GFP_KERNEL);
if (ctx != NULL) {
nfs_sb_active(dentry->d_sb);
ctx->dentry = dget(dentry);
ctx->cred = get_rpccred(cred);
ctx->state = NULL;
ctx->mode = f_mode;
ctx->flags = 0;
ctx->error = 0;
<API key>(&ctx->lock_context);
ctx->lock_context.open_context = ctx;
INIT_LIST_HEAD(&ctx->list);
}
return ctx;
}
struct nfs_open_context *<API key>(struct nfs_open_context *ctx)
{
if (ctx != NULL)
atomic_inc(&ctx->lock_context.count);
return ctx;
}
static void <API key>(struct nfs_open_context *ctx, int is_sync)
{
struct inode *inode = ctx->dentry->d_inode;
struct super_block *sb = ctx->dentry->d_sb;
if (!list_empty(&ctx->list)) {
if (!atomic_dec_and_lock(&ctx->lock_context.count, &inode->i_lock))
return;
list_del(&ctx->list);
spin_unlock(&inode->i_lock);
} else if (!atomic_dec_and_test(&ctx->lock_context.count))
return;
if (inode != NULL)
NFS_PROTO(inode)->close_context(ctx, is_sync);
if (ctx->cred != NULL)
put_rpccred(ctx->cred);
dput(ctx->dentry);
if (is_sync)
nfs_sb_deactive(sb);
else
<API key>(sb);
kfree(ctx);
}
void <API key>(struct nfs_open_context *ctx)
{
<API key>(ctx, 0);
}
static void <API key>(struct nfs_open_context *ctx)
{
<API key>(ctx, 1);
}
/*
* Ensure that mmap has a recent RPC credential for use when writing out
* shared pages
*/
void <API key>(struct file *filp, struct nfs_open_context *ctx)
{
struct inode *inode = filp->f_path.dentry->d_inode;
struct nfs_inode *nfsi = NFS_I(inode);
filp->private_data = <API key>(ctx);
spin_lock(&inode->i_lock);
list_add(&ctx->list, &nfsi->open_files);
spin_unlock(&inode->i_lock);
}
/*
* Given an inode, search for an open context with the desired characteristics
*/
struct nfs_open_context *<API key>(struct inode *inode, struct rpc_cred *cred, fmode_t mode)
{
struct nfs_inode *nfsi = NFS_I(inode);
struct nfs_open_context *pos, *ctx = NULL;
spin_lock(&inode->i_lock);
list_for_each_entry(pos, &nfsi->open_files, list) {
if (cred != NULL && pos->cred != cred)
continue;
if ((pos->mode & (FMODE_READ|FMODE_WRITE)) != mode)
continue;
ctx = <API key>(pos);
break;
}
spin_unlock(&inode->i_lock);
return ctx;
}
static void <API key>(struct file *filp)
{
struct inode *inode = filp->f_path.dentry->d_inode;
struct nfs_open_context *ctx = <API key>(filp);
if (ctx) {
filp->private_data = NULL;
spin_lock(&inode->i_lock);
list_move_tail(&ctx->list, &NFS_I(inode)->open_files);
spin_unlock(&inode->i_lock);
<API key>(ctx);
}
}
/*
* These allocate and release file read/write context information.
*/
int nfs_open(struct inode *inode, struct file *filp)
{
struct nfs_open_context *ctx;
struct rpc_cred *cred;
cred = rpc_lookup_cred();
if (IS_ERR(cred))
return PTR_ERR(cred);
ctx = <API key>(filp->f_path.dentry, cred, filp->f_mode);
put_rpccred(cred);
if (ctx == NULL)
return -ENOMEM;
<API key>(filp, ctx);
<API key>(ctx);
<API key>(inode, filp);
return 0;
}
int nfs_release(struct inode *inode, struct file *filp)
{
<API key>(filp);
return 0;
}
/*
* This function is called whenever some part of NFS notices that
* the cached attributes have to be refreshed.
*/
int
<API key>(struct nfs_server *server, struct inode *inode)
{
int status = -ESTALE;
struct nfs_fattr *fattr = NULL;
struct nfs_inode *nfsi = NFS_I(inode);
dfprintk(PAGECACHE, "NFS: revalidating (%s/%Ld)\n",
inode->i_sb->s_id, (long long)NFS_FILEID(inode));
if (is_bad_inode(inode))
goto out;
if (NFS_STALE(inode))
goto out;
status = -ENOMEM;
fattr = nfs_alloc_fattr();
if (fattr == NULL)
goto out;
nfs_inc_stats(inode, <API key>);
status = NFS_PROTO(inode)->getattr(server, NFS_FH(inode), fattr);
if (status != 0) {
dfprintk(PAGECACHE, "<API key>: (%s/%Ld) getattr failed, error=%d\n",
inode->i_sb->s_id,
(long long)NFS_FILEID(inode), status);
if (status == -ESTALE) {
nfs_zap_caches(inode);
if (!S_ISDIR(inode->i_mode))
set_bit(NFS_INO_STALE, &NFS_I(inode)->flags);
}
goto out;
}
status = nfs_refresh_inode(inode, fattr);
if (status) {
dfprintk(PAGECACHE, "<API key>: (%s/%Ld) refresh failed, error=%d\n",
inode->i_sb->s_id,
(long long)NFS_FILEID(inode), status);
goto out;
}
if (nfsi->cache_validity & NFS_INO_INVALID_ACL)
nfs_zap_acl_cache(inode);
dfprintk(PAGECACHE, "NFS: (%s/%Ld) revalidation complete\n",
inode->i_sb->s_id,
(long long)NFS_FILEID(inode));
out:
nfs_free_fattr(fattr);
return status;
}
int <API key>(struct inode *inode)
{
struct nfs_inode *nfsi = NFS_I(inode);
return !time_in_range_open(jiffies, nfsi->read_cache_jiffies, nfsi->read_cache_jiffies + nfsi->attrtimeo);
}
int <API key>(struct inode *inode)
{
if (<API key>(inode))
return 0;
return <API key>(inode);
}
/**
* <API key> - Revalidate the inode attributes
* @server - pointer to nfs_server struct
* @inode - pointer to inode struct
*
* Updates inode attribute information by retrieving the data from the server.
*/
int <API key>(struct nfs_server *server, struct inode *inode)
{
if (!(NFS_I(inode)->cache_validity & <API key>)
&& !<API key>(inode))
return NFS_STALE(inode) ? -ESTALE : 0;
return <API key>(server, inode);
}
static int <API key>(struct inode *inode, struct address_space *mapping)
{
struct nfs_inode *nfsi = NFS_I(inode);
int ret;
if (mapping->nrpages != 0) {
if (S_ISREG(inode->i_mode)) {
ret = nfs_sync_mapping(mapping);
if (ret < 0)
return ret;
}
ret = <API key>(mapping);
if (ret < 0)
return ret;
}
spin_lock(&inode->i_lock);
nfsi->cache_validity &= ~<API key>;
if (S_ISDIR(inode->i_mode))
memset(nfsi->cookieverf, 0, sizeof(nfsi->cookieverf));
spin_unlock(&inode->i_lock);
nfs_inc_stats(inode, <API key>);
<API key>(inode);
dfprintk(PAGECACHE, "NFS: (%s/%Ld) data cache invalidated\n",
inode->i_sb->s_id, (long long)NFS_FILEID(inode));
return 0;
}
static bool <API key>(struct inode *inode)
{
if (<API key>(inode))
return false;
return (NFS_I(inode)->cache_validity & <API key>)
|| <API key>(inode)
|| NFS_STALE(inode);
}
/**
* <API key> - Revalidate the pagecache
* @inode - pointer to host inode
* @mapping - pointer to mapping
*/
int <API key>(struct inode *inode, struct address_space *mapping)
{
struct nfs_inode *nfsi = NFS_I(inode);
int ret = 0;
if (<API key>(inode)) {
ret = <API key>(NFS_SERVER(inode), inode);
if (ret < 0)
goto out;
}
if (nfsi->cache_validity & <API key>)
ret = <API key>(inode, mapping);
out:
return ret;
}
static unsigned long <API key>(struct inode *inode, struct nfs_fattr *fattr)
{
struct nfs_inode *nfsi = NFS_I(inode);
unsigned long ret = 0;
if ((fattr->valid & <API key>)
&& (fattr->valid & <API key>)
&& nfsi->change_attr == fattr->pre_change_attr) {
nfsi->change_attr = fattr->change_attr;
if (S_ISDIR(inode->i_mode))
nfsi->cache_validity |= <API key>;
ret |= <API key>;
}
/* If we have atomic WCC data, we may update some attributes */
if ((fattr->valid & <API key>)
&& (fattr->valid & <API key>)
&& timespec_equal(&inode->i_ctime, &fattr->pre_ctime)) {
memcpy(&inode->i_ctime, &fattr->ctime, sizeof(inode->i_ctime));
ret |= <API key>;
}
if ((fattr->valid & <API key>)
&& (fattr->valid & <API key>)
&& timespec_equal(&inode->i_mtime, &fattr->pre_mtime)) {
memcpy(&inode->i_mtime, &fattr->mtime, sizeof(inode->i_mtime));
if (S_ISDIR(inode->i_mode))
nfsi->cache_validity |= <API key>;
ret |= <API key>;
}
if ((fattr->valid & <API key>)
&& (fattr->valid & NFS_ATTR_FATTR_SIZE)
&& i_size_read(inode) == nfs_size_to_loff_t(fattr->pre_size)
&& nfsi->npages == 0) {
i_size_write(inode, nfs_size_to_loff_t(fattr->size));
ret |= <API key>;
}
if (nfsi->cache_validity & <API key>)
<API key>(inode);
return ret;
}
/**
* <API key> - verify consistency of the inode attribute cache
* @inode - pointer to inode
* @fattr - updated attributes
*
* Verifies the attribute cache. If we have just changed the attributes,
* so that fattr carries weak cache consistency data, then it may
* also update the ctime/mtime/change_attribute.
*/
static int <API key>(struct inode *inode, struct nfs_fattr *fattr)
{
struct nfs_inode *nfsi = NFS_I(inode);
loff_t cur_size, new_isize;
unsigned long invalid = 0;
if (<API key>(inode))
return 0;
/* Has the inode gone and changed behind our back? */
if ((fattr->valid & <API key>) && nfsi->fileid != fattr->fileid)
return -EIO;
if ((fattr->valid & NFS_ATTR_FATTR_TYPE) && (inode->i_mode & S_IFMT) != (fattr->mode & S_IFMT))
return -EIO;
if ((fattr->valid & <API key>) != 0 &&
nfsi->change_attr != fattr->change_attr)
invalid |= <API key>|<API key>;
/* Verify a few of the more important attributes */
if ((fattr->valid & <API key>) && !timespec_equal(&inode->i_mtime, &fattr->mtime))
invalid |= <API key>;
if (fattr->valid & NFS_ATTR_FATTR_SIZE) {
cur_size = i_size_read(inode);
new_isize = nfs_size_to_loff_t(fattr->size);
if (cur_size != new_isize && nfsi->npages == 0)
invalid |= <API key>|<API key>;
}
if ((fattr->valid & NFS_ATTR_FATTR_MODE) && (inode->i_mode & S_IALLUGO) != (fattr->mode & S_IALLUGO))
invalid |= <API key> | <API key> | NFS_INO_INVALID_ACL;
if ((fattr->valid & <API key>) && inode->i_uid != fattr->uid)
invalid |= <API key> | <API key> | NFS_INO_INVALID_ACL;
if ((fattr->valid & <API key>) && inode->i_gid != fattr->gid)
invalid |= <API key> | <API key> | NFS_INO_INVALID_ACL;
/* Has the link count changed? */
if ((fattr->valid & <API key>) && inode->i_nlink != fattr->nlink)
invalid |= <API key>;
if ((fattr->valid & <API key>) && !timespec_equal(&inode->i_atime, &fattr->atime))
invalid |= <API key>;
if (invalid != 0)
nfsi->cache_validity |= invalid;
nfsi->read_cache_jiffies = fattr->time_start;
return 0;
}
static int <API key>(const struct inode *inode, const struct nfs_fattr *fattr)
{
if (!(fattr->valid & <API key>))
return 0;
return timespec_compare(&fattr->ctime, &inode->i_ctime) > 0;
}
static int <API key>(const struct inode *inode, const struct nfs_fattr *fattr)
{
if (!(fattr->valid & NFS_ATTR_FATTR_SIZE))
return 0;
return nfs_size_to_loff_t(fattr->size) > i_size_read(inode);
}
static atomic_long_t <API key>;
static unsigned long <API key>(void)
{
return atomic_long_read(&<API key>);
}
unsigned long <API key>(void)
{
return <API key>(&<API key>);
}
void nfs_fattr_init(struct nfs_fattr *fattr)
{
fattr->valid = 0;
fattr->time_start = jiffies;
fattr->gencount = <API key>();
fattr->owner_name = NULL;
fattr->group_name = NULL;
}
struct nfs_fattr *nfs_alloc_fattr(void)
{
struct nfs_fattr *fattr;
fattr = kmalloc(sizeof(*fattr), GFP_NOFS);
if (fattr != NULL)
nfs_fattr_init(fattr);
return fattr;
}
struct nfs_fh *nfs_alloc_fhandle(void)
{
struct nfs_fh *fh;
fh = kmalloc(sizeof(struct nfs_fh), GFP_NOFS);
if (fh != NULL)
fh->size = 0;
return fh;
}
#ifdef RPC_DEBUG
/*
* <API key> - calculate the crc32 hash for the filehandle
* in the same way that wireshark does
*
* @fh: file handle
*
* For debugging only.
*/
u32 <API key>(const struct nfs_fh *fh)
{
/* wireshark uses 32-bit AUTODIN crc and does a bitwise
* not on the result */
return ~crc32(0xFFFFFFFF, &fh->data[0], fh->size);
}
/*
* <API key> - display an NFS file handle on the console
*
* @fh: file handle to display
* @caption: display caption
*
* For debugging only.
*/
void <API key>(const struct nfs_fh *fh, const char *caption)
{
unsigned short i;
if (fh->size == 0 || fh == NULL) {
printk(KERN_DEFAULT "%s at %p is empty\n", caption, fh);
return;
}
printk(KERN_DEFAULT "%s at %p is %u bytes, crc: 0x%08x:\n",
caption, fh, fh->size, <API key>(fh));
for (i = 0; i < fh->size; i += 16) {
__be32 *pos = (__be32 *)&fh->data[i];
switch ((fh->size - i - 1) >> 2) {
case 0:
printk(KERN_DEFAULT " %08x\n",
be32_to_cpup(pos));
break;
case 1:
printk(KERN_DEFAULT " %08x %08x\n",
be32_to_cpup(pos), be32_to_cpup(pos + 1));
break;
case 2:
printk(KERN_DEFAULT " %08x %08x %08x\n",
be32_to_cpup(pos), be32_to_cpup(pos + 1),
be32_to_cpup(pos + 2));
break;
default:
printk(KERN_DEFAULT " %08x %08x %08x %08x\n",
be32_to_cpup(pos), be32_to_cpup(pos + 1),
be32_to_cpup(pos + 2), be32_to_cpup(pos + 3));
}
}
}
#endif
/**
* <API key> - check if the inode attributes need updating
* @inode - pointer to inode
* @fattr - attributes
*
* Attempt to divine whether or not an RPC call reply carrying stale
* attributes got scheduled after another call carrying updated ones.
*
* To do so, the function first assumes that a more recent ctime means
* that the attributes in fattr are newer, however it also attempt to
* catch the case where ctime either didn't change, or went backwards
* (if someone reset the clock on the server) by looking at whether
* or not this RPC call was started after the inode was last updated.
* Note also the check for wraparound of 'attr_gencount'
*
* The function returns 'true' if it thinks the attributes in 'fattr' are
* more recent than the ones cached in the inode.
*
*/
static int <API key>(const struct inode *inode, const struct nfs_fattr *fattr)
{
const struct nfs_inode *nfsi = NFS_I(inode);
return ((long)fattr->gencount - (long)nfsi->attr_gencount) > 0 ||
<API key>(inode, fattr) ||
<API key>(inode, fattr) ||
((long)nfsi->attr_gencount - (long)<API key>() > 0);
}
static int <API key>(struct inode *inode, struct nfs_fattr *fattr)
{
if (<API key>(inode, fattr))
return nfs_update_inode(inode, fattr);
return <API key>(inode, fattr);
}
/**
* nfs_refresh_inode - try to update the inode attribute cache
* @inode - pointer to inode
* @fattr - updated attributes
*
* Check that an RPC call that returned attributes has not overlapped with
* other recent updates of the inode metadata, then decide whether it is
* safe to do a full update of the inode attributes, or whether just to
* call <API key>.
*/
int nfs_refresh_inode(struct inode *inode, struct nfs_fattr *fattr)
{
int status;
if ((fattr->valid & NFS_ATTR_FATTR) == 0)
return 0;
spin_lock(&inode->i_lock);
status = <API key>(inode, fattr);
spin_unlock(&inode->i_lock);
return status;
}
static int <API key>(struct inode *inode, struct nfs_fattr *fattr)
{
struct nfs_inode *nfsi = NFS_I(inode);
nfsi->cache_validity |= <API key>|<API key>;
if (S_ISDIR(inode->i_mode)) {
nfsi->cache_validity |= <API key>;
<API key>(inode);
}
if ((fattr->valid & NFS_ATTR_FATTR) == 0)
return 0;
return <API key>(inode, fattr);
}
/**
* <API key> - try to update the inode attribute cache
* @inode - pointer to inode
* @fattr - updated attributes
*
* After an operation that has changed the inode metadata, mark the
* attribute cache as being invalid, then try to update it.
*
* NB: if the server didn't return any post op attributes, this
* function will force the retrieval of attributes before the next
* NFS request. Thus it should be used only for operations that
* are expected to change one or more attributes, to avoid
* unnecessary NFS requests and trips through nfs_update_inode().
*/
int <API key>(struct inode *inode, struct nfs_fattr *fattr)
{
int status;
spin_lock(&inode->i_lock);
status = <API key>(inode, fattr);
spin_unlock(&inode->i_lock);
return status;
}
/**
* <API key> - try to update the inode attribute cache
* @inode - pointer to inode
* @fattr - updated attributes
*
* After an operation that has changed the inode metadata, mark the
* attribute cache as being invalid, then try to update it. Fake up
* weak cache consistency data, if none exist.
*
* This function is mainly designed to be used by the ->write_done() functions.
*/
int <API key>(struct inode *inode, struct nfs_fattr *fattr)
{
int status;
spin_lock(&inode->i_lock);
/* Don't do a WCC update if these attributes are already stale */
if ((fattr->valid & NFS_ATTR_FATTR) == 0 ||
!<API key>(inode, fattr)) {
fattr->valid &= ~(<API key>
| <API key>
| <API key>
| <API key>);
goto out_noforce;
}
if ((fattr->valid & <API key>) != 0 &&
(fattr->valid & <API key>) == 0) {
fattr->pre_change_attr = NFS_I(inode)->change_attr;
fattr->valid |= <API key>;
}
if ((fattr->valid & <API key>) != 0 &&
(fattr->valid & <API key>) == 0) {
memcpy(&fattr->pre_ctime, &inode->i_ctime, sizeof(fattr->pre_ctime));
fattr->valid |= <API key>;
}
if ((fattr->valid & <API key>) != 0 &&
(fattr->valid & <API key>) == 0) {
memcpy(&fattr->pre_mtime, &inode->i_mtime, sizeof(fattr->pre_mtime));
fattr->valid |= <API key>;
}
if ((fattr->valid & NFS_ATTR_FATTR_SIZE) != 0 &&
(fattr->valid & <API key>) == 0) {
fattr->pre_size = i_size_read(inode);
fattr->valid |= <API key>;
}
out_noforce:
status = <API key>(inode, fattr);
spin_unlock(&inode->i_lock);
return status;
}
/*
* Many nfs protocol calls return the new file attributes after
* an operation. Here we update the inode to reflect the state
* of the server's inode.
*
* This is a bit tricky because we have to make sure all dirty pages
* have been sent off to the server before calling <API key>.
* To make sure no other process adds more write requests while we try
* our best to flush them, we make them sleep during the attribute refresh.
*
* A very similar scenario holds for the dir cache.
*/
static int nfs_update_inode(struct inode *inode, struct nfs_fattr *fattr)
{
struct nfs_server *server;
struct nfs_inode *nfsi = NFS_I(inode);
loff_t cur_isize, new_isize;
unsigned long invalid = 0;
unsigned long now = jiffies;
unsigned long save_cache_validity;
dfprintk(VFS, "NFS: %s(%s/%ld fh_crc=0x%08x ct=%d info=0x%x)\n",
__func__, inode->i_sb->s_id, inode->i_ino,
<API key>(NFS_FH(inode)),
atomic_read(&inode->i_count), fattr->valid);
if ((fattr->valid & <API key>) && nfsi->fileid != fattr->fileid)
goto out_fileid;
/*
* Make sure the inode's type hasn't changed.
*/
if ((fattr->valid & NFS_ATTR_FATTR_TYPE) && (inode->i_mode & S_IFMT) != (fattr->mode & S_IFMT))
goto out_changed;
server = NFS_SERVER(inode);
/* Update the fsid? */
if (S_ISDIR(inode->i_mode) && (fattr->valid & NFS_ATTR_FATTR_FSID) &&
!nfs_fsid_equal(&server->fsid, &fattr->fsid) &&
!IS_AUTOMOUNT(inode))
server->fsid = fattr->fsid;
/*
* Update the read time so we don't revalidate too often.
*/
nfsi->read_cache_jiffies = fattr->time_start;
save_cache_validity = nfsi->cache_validity;
nfsi->cache_validity &= ~(<API key>
| <API key>
| <API key>
| <API key>);
/* Do atomic weak cache consistency updates */
invalid |= <API key>(inode, fattr);
/* More cache consistency checks */
if (fattr->valid & <API key>) {
if (nfsi->change_attr != fattr->change_attr) {
dprintk("NFS: change_attr change on server for file %s/%ld\n",
inode->i_sb->s_id, inode->i_ino);
invalid |= <API key>
| <API key>
| <API key>
| NFS_INO_INVALID_ACL
| <API key>;
if (S_ISDIR(inode->i_mode))
<API key>(inode);
nfsi->change_attr = fattr->change_attr;
}
} else if (server->caps & NFS_CAP_CHANGE_ATTR)
invalid |= save_cache_validity;
if (fattr->valid & <API key>) {
memcpy(&inode->i_mtime, &fattr->mtime, sizeof(inode->i_mtime));
} else if (server->caps & NFS_CAP_MTIME)
invalid |= save_cache_validity & (<API key>
| <API key>);
if (fattr->valid & <API key>) {
memcpy(&inode->i_ctime, &fattr->ctime, sizeof(inode->i_ctime));
} else if (server->caps & NFS_CAP_CTIME)
invalid |= save_cache_validity & (<API key>
| <API key>);
/* Check if our cached file size is stale */
if (fattr->valid & NFS_ATTR_FATTR_SIZE) {
new_isize = nfs_size_to_loff_t(fattr->size);
cur_isize = i_size_read(inode);
if (new_isize != cur_isize) {
/* Do we perhaps have any outstanding writes, or has
* the file grown beyond our last write? */
if ((nfsi->npages == 0 && !test_bit(<API key>, &nfsi->flags)) ||
new_isize > cur_isize) {
i_size_write(inode, new_isize);
invalid |= <API key>|<API key>;
}
dprintk("NFS: isize change on server for file %s/%ld\n",
inode->i_sb->s_id, inode->i_ino);
}
} else
invalid |= save_cache_validity & (<API key>
| <API key>
| <API key>);
if (fattr->valid & <API key>)
memcpy(&inode->i_atime, &fattr->atime, sizeof(inode->i_atime));
else if (server->caps & NFS_CAP_ATIME)
invalid |= save_cache_validity & (<API key>
| <API key>);
if (fattr->valid & NFS_ATTR_FATTR_MODE) {
if ((inode->i_mode & S_IALLUGO) != (fattr->mode & S_IALLUGO)) {
invalid |= <API key>|<API key>|NFS_INO_INVALID_ACL;
inode->i_mode = fattr->mode;
}
} else if (server->caps & NFS_CAP_MODE)
invalid |= save_cache_validity & (<API key>
| <API key>
| NFS_INO_INVALID_ACL
| <API key>);
if (fattr->valid & <API key>) {
if (inode->i_uid != fattr->uid) {
invalid |= <API key>|<API key>|NFS_INO_INVALID_ACL;
inode->i_uid = fattr->uid;
}
} else if (server->caps & NFS_CAP_OWNER)
invalid |= save_cache_validity & (<API key>
| <API key>
| NFS_INO_INVALID_ACL
| <API key>);
if (fattr->valid & <API key>) {
if (inode->i_gid != fattr->gid) {
invalid |= <API key>|<API key>|NFS_INO_INVALID_ACL;
inode->i_gid = fattr->gid;
}
} else if (server->caps & NFS_CAP_OWNER_GROUP)
invalid |= save_cache_validity & (<API key>
| <API key>
| NFS_INO_INVALID_ACL
| <API key>);
if (fattr->valid & <API key>) {
if (inode->i_nlink != fattr->nlink) {
invalid |= <API key>;
if (S_ISDIR(inode->i_mode))
invalid |= <API key>;
inode->i_nlink = fattr->nlink;
}
} else if (server->caps & NFS_CAP_NLINK)
invalid |= save_cache_validity & (<API key>
| <API key>);
if (fattr->valid & <API key>) {
/*
* report the blocks in 512byte units
*/
inode->i_blocks = nfs_calc_block_size(fattr->du.nfs3.used);
}
if (fattr->valid & <API key>)
inode->i_blocks = fattr->du.nfs2.blocks;
/* Update attrtimeo value if we're out of the unstable period */
if (invalid & <API key>) {
nfs_inc_stats(inode, <API key>);
nfsi->attrtimeo = NFS_MINATTRTIMEO(inode);
nfsi->attrtimeo_timestamp = now;
nfsi->attr_gencount = <API key>();
} else {
if (!time_in_range_open(now, nfsi->attrtimeo_timestamp, nfsi->attrtimeo_timestamp + nfsi->attrtimeo)) {
if ((nfsi->attrtimeo <<= 1) > NFS_MAXATTRTIMEO(inode))
nfsi->attrtimeo = NFS_MAXATTRTIMEO(inode);
nfsi->attrtimeo_timestamp = now;
}
}
invalid &= ~<API key>;
/* Don't invalidate the data if we were to blame */
if (!(S_ISREG(inode->i_mode) || S_ISDIR(inode->i_mode)
|| S_ISLNK(inode->i_mode)))
invalid &= ~<API key>;
if (!nfs_have_delegation(inode, FMODE_READ) ||
(save_cache_validity & <API key>))
nfsi->cache_validity |= invalid;
if (invalid & <API key>)
<API key>(inode);
return 0;
out_changed:
/*
* Big trouble! The inode has become a different object.
*/
printk(KERN_DEBUG "NFS: %s: inode %ld mode changed, %07o to %07o\n",
__func__, inode->i_ino, inode->i_mode, fattr->mode);
out_err:
/*
* No need to worry about unhashing the dentry, as the
* lookup validation will know that the inode is bad.
* (But we fall through to invalidate the caches.)
*/
<API key>(inode);
return -ESTALE;
out_fileid:
printk(KERN_ERR "NFS: server %s error: fileid changed\n"
"fsid %s: expected fileid 0x%Lx, got 0x%Lx\n",
NFS_SERVER(inode)->nfs_client->cl_hostname, inode->i_sb->s_id,
(long long)nfsi->fileid, (long long)fattr->fileid);
goto out_err;
}
#ifdef CONFIG_NFS_V4
/*
* Clean out any remaining NFSv4 state that might be left over due
* to open() calls that passed nfs_atomic_lookup, but failed to call
* nfs_open().
*/
void nfs4_clear_inode(struct inode *inode)
{
pnfs_return_layout(inode);
pnfs_destroy_layout(NFS_I(inode));
/* If we are holding a delegation, return it! */
<API key>(inode);
/* First call standard NFS clear_inode() code */
nfs_clear_inode(inode);
}
#endif
struct inode *nfs_alloc_inode(struct super_block *sb)
{
struct nfs_inode *nfsi;
nfsi = (struct nfs_inode *)kmem_cache_alloc(nfs_inode_cachep, GFP_KERNEL);
if (!nfsi)
return NULL;
nfsi->flags = 0UL;
nfsi->cache_validity = 0UL;
#ifdef CONFIG_NFS_V3_ACL
nfsi->acl_access = ERR_PTR(-EAGAIN);
nfsi->acl_default = ERR_PTR(-EAGAIN);
#endif
#ifdef CONFIG_NFS_V4
nfsi->nfs4_acl = NULL;
#endif /* CONFIG_NFS_V4 */
return &nfsi->vfs_inode;
}
void nfs_destroy_inode(struct inode *inode)
{
kmem_cache_free(nfs_inode_cachep, NFS_I(inode));
}
static inline void nfs4_init_once(struct nfs_inode *nfsi)
{
#ifdef CONFIG_NFS_V4
INIT_LIST_HEAD(&nfsi->open_states);
nfsi->delegation = NULL;
nfsi->delegation_state = 0;
init_rwsem(&nfsi->rwsem);
nfsi->layout = NULL;
#endif
}
static void init_once(void *foo)
{
struct nfs_inode *nfsi = (struct nfs_inode *) foo;
inode_init_once(&nfsi->vfs_inode);
INIT_LIST_HEAD(&nfsi->open_files);
INIT_LIST_HEAD(&nfsi-><API key>);
INIT_LIST_HEAD(&nfsi-><API key>);
INIT_LIST_HEAD(&nfsi->commit_info.list);
nfsi->npages = 0;
nfsi->commit_info.ncommit = 0;
atomic_set(&nfsi->commit_info.rpcs_out, 0);
atomic_set(&nfsi->silly_count, 1);
INIT_HLIST_HEAD(&nfsi->silly_list);
init_waitqueue_head(&nfsi->waitqueue);
nfs4_init_once(nfsi);
}
static int __init nfs_init_inodecache(void)
{
nfs_inode_cachep = kmem_cache_create("nfs_inode_cache",
sizeof(struct nfs_inode),
0, (<API key>|
SLAB_MEM_SPREAD),
init_once);
if (nfs_inode_cachep == NULL)
return -ENOMEM;
return 0;
}
static void <API key>(void)
{
kmem_cache_destroy(nfs_inode_cachep);
}
struct workqueue_struct *nfsiod_workqueue;
/*
* start up the nfsiod workqueue
*/
static int nfsiod_start(void)
{
struct workqueue_struct *wq;
dprintk("RPC: creating workqueue nfsiod\n");
wq = <API key>("nfsiod");
if (wq == NULL)
return -ENOMEM;
nfsiod_workqueue = wq;
return 0;
}
/*
* Destroy the nfsiod workqueue
*/
static void nfsiod_stop(void)
{
struct workqueue_struct *wq;
wq = nfsiod_workqueue;
if (wq == NULL)
return;
nfsiod_workqueue = NULL;
destroy_workqueue(wq);
}
/*
* Initialize NFS
*/
static int __init init_nfs_fs(void)
{
int err;
err = nfs_idmap_init();
if (err < 0)
goto out9;
err = <API key>();
if (err < 0)
goto out8;
err = <API key>();
if (err < 0)
goto out7;
err = nfsiod_start();
if (err)
goto out6;
err = nfs_fs_proc_init();
if (err)
goto out5;
err = <API key>();
if (err)
goto out4;
err = nfs_init_inodecache();
if (err)
goto out3;
err = <API key>();
if (err)
goto out2;
err = <API key>();
if (err)
goto out1;
err = <API key>();
if (err)
goto out0;
#ifdef CONFIG_PROC_FS
rpc_proc_register(&nfs_rpcstat);
#endif
if ((err = register_nfs_fs()) != 0)
goto out;
return 0;
out:
#ifdef CONFIG_PROC_FS
rpc_proc_unregister("nfs");
#endif
<API key>();
out0:
<API key>();
out1:
<API key>();
out2:
<API key>();
out3:
<API key>();
out4:
nfs_fs_proc_exit();
out5:
nfsiod_stop();
out6:
<API key>();
out7:
<API key>();
out8:
nfs_idmap_quit();
out9:
return err;
}
static void __exit exit_nfs_fs(void)
{
<API key>();
<API key>();
<API key>();
<API key>();
<API key>();
<API key>();
<API key>();
nfs_idmap_quit();
#ifdef CONFIG_PROC_FS
rpc_proc_unregister("nfs");
#endif
<API key>();
unregister_nfs_fs();
nfs_fs_proc_exit();
nfsiod_stop();
}
/* Not quite true; I just maintain it */
MODULE_AUTHOR("Olaf Kirch <okir@monad.swb.de>");
MODULE_LICENSE("GPL");
module_param(enable_ino64, bool, 0644);
module_init(init_nfs_fs)
module_exit(exit_nfs_fs) |
# <API key>: GPL-2.0
dtb-$(CONFIG_ARCH_ALPINE) += \
alpine-db.dtb
dtb-$(CONFIG_MACH_ARTPEC6) += \
artpec6-devboard.dtb
dtb-$(CONFIG_MACH_ASM9260) += \
<API key>.dtb
# Keep at91 dtb files sorted alphabetically for each SoC
dtb-$(<API key>) += \
at91rm9200ek.dtb \
mpa1600.dtb
dtb-$(CONFIG_SOC_AT91SAM9) += \
animeo_ip.dtb \
at91-qil_a9260.dtb \
aks-cdu.dtb \
ethernut5.dtb \
evk-pro3.dtb \
tny_a9260.dtb \
usb_a9260.dtb \
at91sam9260ek.dtb \
at91sam9261ek.dtb \
at91sam9263ek.dtb \
at91-sam9_l9260.dtb \
tny_a9263.dtb \
usb_a9263.dtb \
at91-foxg20.dtb \
at91-kizbox.dtb \
at91sam9g20ek.dtb \
at91sam9g20ek_2mmc.dtb \
tny_a9g20.dtb \
usb_a9g20.dtb \
usb_a9g20_lpw.dtb \
at91sam9m10g45ek.dtb \
pm9g45.dtb \
at91sam9n12ek.dtb \
at91sam9rlek.dtb \
at91-ariag25.dtb \
at91-ariettag25.dtb \
<API key>.dtb \
at91-kizboxmini.dtb \
at91sam9g15ek.dtb \
at91sam9g25ek.dtb \
at91sam9g35ek.dtb \
at91sam9x25ek.dtb \
at91sam9x35ek.dtb
dtb-$(CONFIG_SOC_SAM_V7) += \
at91-kizbox2.dtb \
<API key>.dtb \
<API key>.dtb \
at91-sama5d2_ptc_ek.dtb \
<API key>.dtb \
<API key>.dtb \
at91-tse850-3.dtb \
sama5d31ek.dtb \
sama5d33ek.dtb \
sama5d34ek.dtb \
sama5d35ek.dtb \
sama5d36ek.dtb \
sama5d36ek_cmp.dtb \
<API key>.dtb \
<API key>.dtb \
at91-sama5d4ek.dtb \
at91-vinco.dtb
dtb-$(CONFIG_ARCH_ATLAS6) += \
atlas6-evb.dtb
dtb-$(CONFIG_ARCH_ATLAS7) += \
atlas7-evb.dtb
dtb-$(CONFIG_ARCH_AXXIA) += \
axm5516-amarillo.dtb
dtb-$(CONFIG_ARCH_BCM2835) += \
bcm2835-rpi-b.dtb \
bcm2835-rpi-a.dtb \
bcm2835-rpi-b-rev2.dtb \
bcm2835-rpi-b-plus.dtb \
bcm2835-rpi-a-plus.dtb \
bcm2836-rpi-2-b.dtb \
bcm2837-rpi-3-b.dtb \
bcm2835-rpi-zero.dtb \
bcm2835-rpi-zero-w.dtb
dtb-$(<API key>) += \
<API key>.dtb \
<API key>.dtb \
<API key>.dtb \
<API key>.dtb \
<API key>.dtb \
<API key>.dtb \
<API key>.dtb \
<API key>.dtb \
<API key>.dtb \
<API key>.dtb \
<API key>.dtb \
<API key>.dtb \
<API key>.dtb \
<API key>.dtb \
<API key>.dtb \
<API key>.dtb \
<API key>.dtb \
<API key>.dtb \
<API key>.dtb \
<API key>.dtb \
<API key>.dtb \
<API key>.dtb \
<API key>.dtb \
<API key>.dtb \
<API key>.dtb \
<API key>.dtb \
<API key>.dtb \
bcm94708.dtb \
bcm94709.dtb \
bcm953012er.dtb \
bcm953012hr.dtb \
bcm953012k.dtb
dtb-$(<API key>) += \
<API key>.dtb \
<API key>.dtb \
bcm47189-tenda-ac9.dtb \
bcm947189acdbmr.dtb
dtb-$(<API key>) += \
bcm963138dvt.dtb
dtb-$(<API key>) += \
bcm911360_entphn.dtb \
bcm911360k.dtb \
bcm958300k.dtb \
bcm958305k.dtb
dtb-$(CONFIG_ARCH_BCM_HR2) += \
<API key>.dtb
dtb-$(<API key>) += \
bcm28155-ap.dtb \
bcm21664-garnet.dtb \
bcm23550-sparrow.dtb
dtb-$(CONFIG_ARCH_BCM_NSP) += \
bcm958522er.dtb \
bcm958525er.dtb \
bcm958525xmc.dtb \
bcm958622hr.dtb \
bcm958623hr.dtb \
bcm958625hr.dtb \
bcm988312hr.dtb \
bcm958625k.dtb
dtb-$(CONFIG_ARCH_BERLIN) += \
<API key>.dtb \
<API key>.dtb \
<API key>.dtb
dtb-$(CONFIG_ARCH_BRCMSTB) += \
<API key>.dtb
dtb-$(<API key>) += \
ep7211-edb7211.dtb
dtb-$(CONFIG_ARCH_DAVINCI) += \
da850-lcdk.dtb \
da850-enbw-cmc.dtb \
da850-evm.dtb \
da850-lego-ev3.dtb
dtb-$(<API key>) += \
cx92755_equinox.dtb
dtb-$(CONFIG_ARCH_EFM32) += \
efm32gg-dk3750.dtb
dtb-$(CONFIG_ARCH_EXYNOS3) += \
<API key>.dtb \
exynos3250-monk.dtb \
exynos3250-rinato.dtb
dtb-$(CONFIG_ARCH_EXYNOS4) += \
exynos4210-origen.dtb \
exynos4210-smdkv310.dtb \
exynos4210-trats.dtb \
<API key>.dtb \
<API key>.dtb \
exynos4412-odroidu3.dtb \
exynos4412-odroidx.dtb \
exynos4412-odroidx2.dtb \
exynos4412-origen.dtb \
exynos4412-smdk4412.dtb \
exynos4412-tiny4412.dtb \
exynos4412-trats2.dtb
dtb-$(CONFIG_ARCH_EXYNOS5) += \
exynos5250-arndale.dtb \
exynos5250-smdk5250.dtb \
exynos5250-snow.dtb \
<API key>.dtb \
exynos5250-spring.dtb \
<API key>.dtb \
exynos5410-odroidxu.dtb \
exynos5410-smdk5410.dtb \
<API key>.dtb \
<API key>.dtb \
exynos5420-smdk5420.dtb \
<API key>.dtb \
<API key>.dtb \
<API key>.dtb \
<API key>.dtb \
exynos5440-sd5v1.dtb \
exynos5440-ssdk5440.dtb \
exynos5800-peach-pi.dtb
dtb-$(CONFIG_ARCH_GEMINI) += \
<API key>.dtb \
<API key>.dtb \
gemini-nas4220b.dtb \
gemini-rut1xx.dtb \
gemini-sq201.dtb \
gemini-wbd111.dtb \
gemini-wbd222.dtb
dtb-$(CONFIG_ARCH_HI3xxx) += \
hi3620-hi4511.dtb
dtb-$(<API key>) += \
highbank.dtb \
ecx-2000.dtb
dtb-$(CONFIG_ARCH_HIP01) += \
hip01-ca9x2.dtb
dtb-$(CONFIG_ARCH_HIP04) += \
hip04-d01.dtb
dtb-$(CONFIG_ARCH_HISI) += \
hi3519-demb.dtb
dtb-$(CONFIG_ARCH_HIX5HD2) += \
hisi-x5hd2-dkb.dtb
dtb-$(<API key>) += \
integratorap.dtb \
integratorcp.dtb
dtb-$(<API key>) += \
keystone-k2hk-evm.dtb \
keystone-k2l-evm.dtb \
keystone-k2e-evm.dtb \
keystone-k2g-evm.dtb \
keystone-k2g-ice.dtb
dtb-$(<API key>) += \
kirkwood-b3.dtb \
<API key>.dtb \
kirkwood-cloudbox.dtb \
kirkwood-d2net.dtb \
kirkwood-db-88f6281.dtb \
kirkwood-db-88f6282.dtb \
kirkwood-dir665.dtb \
kirkwood-dns320.dtb \
kirkwood-dns325.dtb \
kirkwood-dockstar.dtb \
kirkwood-dreamplug.dtb \
kirkwood-ds109.dtb \
kirkwood-ds110jv10.dtb \
kirkwood-ds111.dtb \
kirkwood-ds112.dtb \
kirkwood-ds209.dtb \
kirkwood-ds210.dtb \
kirkwood-ds212.dtb \
kirkwood-ds212j.dtb \
kirkwood-ds409.dtb \
kirkwood-ds409slim.dtb \
kirkwood-ds411.dtb \
kirkwood-ds411j.dtb \
kirkwood-ds411slim.dtb \
kirkwood-goflexnet.dtb \
<API key>.dtb \
kirkwood-ib62x0.dtb \
kirkwood-iconnect.dtb \
<API key>.dtb \
kirkwood-is2.dtb \
<API key>.dtb \
kirkwood-laplug.dtb \
<API key>.dtb \
<API key>.dtb \
<API key>.dtb \
<API key>.dtb \
<API key>.dtb \
<API key>.dtb \
kirkwood-lschlv2.dtb \
kirkwood-lsxhl.dtb \
kirkwood-mplcec4.dtb \
<API key>.dtb \
kirkwood-nas2big.dtb \
kirkwood-net2big.dtb \
kirkwood-net5big.dtb \
<API key>.dtb \
<API key>+_v2.dtb \
kirkwood-ns2.dtb \
kirkwood-ns2lite.dtb \
kirkwood-ns2max.dtb \
kirkwood-ns2mini.dtb \
kirkwood-nsa310.dtb \
kirkwood-nsa310a.dtb \
kirkwood-nsa320.dtb \
kirkwood-nsa325.dtb \
<API key>.dtb \
<API key>.dtb \
<API key>.dtb \
<API key>.dtb \
<API key>.dtb \
kirkwood-pogo_e02.dtb \
<API key>.dtb \
kirkwood-rd88f6192.dtb \
<API key>.dtb \
<API key>.dtb \
kirkwood-rs212.dtb \
kirkwood-rs409.dtb \
kirkwood-rs411.dtb \
kirkwood-sheevaplug.dtb \
<API key>.dtb \
kirkwood-t5325.dtb \
kirkwood-topkick.dtb \
kirkwood-ts219-6281.dtb \
kirkwood-ts219-6282.dtb \
kirkwood-ts419-6281.dtb \
kirkwood-ts419-6282.dtb
dtb-$(CONFIG_ARCH_LPC18XX) += \
lpc4337-ciaa.dtb \
lpc4350-hitex-eval.dtb \
<API key>.dtb
dtb-$(CONFIG_ARCH_LPC32XX) += \
lpc3250-ea3250.dtb \
lpc3250-phy3250.dtb
dtb-$(CONFIG_MACH_MESON6) += \
meson6-atv1200.dtb
dtb-$(CONFIG_MACH_MESON8) += \
meson8-minix-neo-x8.dtb
dtb-$(CONFIG_ARCH_MMP) += \
pxa168-aspenite.dtb \
pxa910-dkb.dtb \
mmp2-brownstone.dtb
dtb-$(CONFIG_MACH_MESON8B) += \
meson8b-mxq.dtb \
meson8b-odroidc1.dtb
dtb-$(CONFIG_ARCH_MPS2) += \
mps2-an385.dtb \
mps2-an399.dtb
dtb-$(CONFIG_ARCH_MOXART) += \
moxart-uc7112lx.dtb
dtb-$(CONFIG_SOC_IMX1) += \
imx1-ads.dtb \
imx1-apf9328.dtb
dtb-$(CONFIG_SOC_IMX25) += \
<API key>.dtb \
<API key>.dtb \
<API key>.dtb \
<API key>.dtb \
imx25-karo-tx25.dtb \
imx25-pdk.dtb
dtb-$(CONFIG_SOC_IMX27) += \
imx27-apf27.dtb \
imx27-apf27dev.dtb \
<API key>.dtb \
imx27-pdk.dtb \
<API key>.dtb \
<API key>.dtb
dtb-$(CONFIG_SOC_IMX31) += \
imx31-bug.dtb
dtb-$(CONFIG_SOC_IMX35) += \
<API key>.dtb \
imx35-pdk.dtb
dtb-$(CONFIG_SOC_IMX50) += \
imx50-evk.dtb
dtb-$(CONFIG_SOC_IMX51) += \
imx51-apf51.dtb \
imx51-apf51dev.dtb \
imx51-babbage.dtb \
<API key>.dtb \
<API key>.dtb \
imx51-ts4800.dtb \
imx51-zii-rdu1.dtb
dtb-$(CONFIG_SOC_IMX53) += \
imx53-ard.dtb \
imx53-cx9020.dtb \
imx53-m53evk.dtb \
imx53-mba53.dtb \
imx53-ppd.dtb \
imx53-qsb.dtb \
imx53-qsrb.dtb \
imx53-smd.dtb \
imx53-tx53-x03x.dtb \
imx53-tx53-x13x.dtb \
imx53-usbarmory.dtb \
imx53-voipac-bsb.dtb
dtb-$(CONFIG_SOC_IMX6Q) += \
imx6dl-apf6dev.dtb \
<API key>.dtb \
<API key>.dtb \
<API key>.dtb \
<API key>.dtb \
<API key>.dtb \
imx6dl-cubox-i.dtb \
<API key>.dtb \
<API key>.dtb \
<API key>.dtb \
imx6dl-gw51xx.dtb \
imx6dl-gw52xx.dtb \
imx6dl-gw53xx.dtb \
imx6dl-gw54xx.dtb \
imx6dl-gw551x.dtb \
imx6dl-gw552x.dtb \
imx6dl-gw553x.dtb \
imx6dl-gw560x.dtb \
imx6dl-gw5903.dtb \
imx6dl-gw5904.dtb \
imx6dl-hummingboard.dtb \
<API key>.dtb \
<API key>.dtb \
<API key>.dtb \
<API key>.dtb \
<API key>.dtb \
imx6dl-icore.dtb \
imx6dl-icore-rqs.dtb \
imx6dl-nit6xlite.dtb \
imx6dl-nitrogen6x.dtb \
<API key>.dtb \
imx6dl-rex-basic.dtb \
imx6dl-riotboard.dtb \
imx6dl-sabreauto.dtb \
imx6dl-sabrelite.dtb \
imx6dl-sabresd.dtb \
imx6dl-savageboard.dtb \
imx6dl-ts4900.dtb \
imx6dl-ts7970.dtb \
imx6dl-tx6dl-comtft.dtb \
imx6dl-tx6s-8034.dtb \
<API key>.dtb \
imx6dl-tx6s-8035.dtb \
<API key>.dtb \
imx6dl-tx6u-801x.dtb \
<API key>.dtb \
imx6dl-tx6u-8033.dtb \
<API key>.dtb \
imx6dl-tx6u-811x.dtb \
<API key>.dtb \
imx6dl-udoo.dtb \
imx6dl-wandboard.dtb \
<API key>.dtb \
<API key>.dtb \
imx6q-apalis-eval.dtb \
imx6q-apalis-ixora.dtb \
<API key>.1.dtb \
imx6q-apf6dev.dtb \
imx6q-arm2.dtb \
imx6q-b450v3.dtb \
imx6q-b650v3.dtb \
imx6q-b850v3.dtb \
imx6q-cm-fx6.dtb \
imx6q-cubox-i.dtb \
<API key>.dtb \
<API key>.dtb \
imx6q-dfi-fs700-m60.dtb \
<API key>.dtb \
imx6q-dmo-edmqmx6.dtb \
imx6q-evi.dtb \
imx6q-gk802.dtb \
imx6q-gw51xx.dtb \
imx6q-gw52xx.dtb \
imx6q-gw53xx.dtb \
imx6q-gw5400-a.dtb \
imx6q-gw54xx.dtb \
imx6q-gw551x.dtb \
imx6q-gw552x.dtb \
imx6q-gw553x.dtb \
imx6q-gw560x.dtb \
imx6q-gw5903.dtb \
imx6q-gw5904.dtb \
imx6q-h100.dtb \
imx6q-hummingboard.dtb \
<API key>.dtb \
<API key>.dtb \
imx6q-hummingboard2.dtb \
<API key>.dtb \
<API key>.dtb \
imx6q-icore.dtb \
imx6q-icore-ofcap10.dtb \
imx6q-icore-ofcap12.dtb \
imx6q-icore-rqs.dtb \
imx6q-marsboard.dtb \
imx6q-mccmon6.dtb \
imx6q-nitrogen6x.dtb \
imx6q-nitrogen6_max.dtb \
<API key>.dtb \
imx6q-novena.dtb \
imx6q-phytec-pbab01.dtb \
imx6q-pistachio.dtb \
imx6q-rex-pro.dtb \
imx6q-sabreauto.dtb \
imx6q-sabrelite.dtb \
imx6q-sabresd.dtb \
imx6q-savageboard.dtb \
imx6q-sbc6x.dtb \
imx6q-tbs2910.dtb \
imx6q-ts4900.dtb \
imx6q-ts7970.dtb \
imx6q-tx6q-1010.dtb \
<API key>.dtb \
imx6q-tx6q-1020.dtb \
<API key>.dtb \
imx6q-tx6q-1036.dtb \
imx6q-tx6q-1036-mb7.dtb \
imx6q-tx6q-10x0-mb7.dtb \
imx6q-tx6q-1110.dtb \
imx6q-tx6q-11x0-mb7.dtb \
imx6q-udoo.dtb \
imx6q-utilite-pro.dtb \
<API key>.dtb \
imx6q-wandboard.dtb \
<API key>.dtb \
<API key>.dtb \
imx6q-zii-rdu2.dtb \
<API key>.dtb \
<API key>.dtb \
imx6qp-sabreauto.dtb \
imx6qp-sabresd.dtb \
imx6qp-tx6qp-8037.dtb \
<API key>.dtb \
imx6qp-tx6qp-8137.dtb \
<API key>.dtb \
<API key>.dtb \
imx6qp-zii-rdu2.dtb
dtb-$(CONFIG_SOC_IMX6SL) += \
imx6sl-evk.dtb \
imx6sl-warp.dtb
dtb-$(CONFIG_SOC_IMX6SX) += \
imx6sx-nitrogen6sx.dtb \
imx6sx-sabreauto.dtb \
imx6sx-sdb-reva.dtb \
imx6sx-sdb-sai.dtb \
imx6sx-sdb.dtb \
<API key>.dtb \
<API key>.dtb \
<API key>.dtb \
<API key>.dtb
dtb-$(CONFIG_SOC_IMX6UL) += \
imx6ul-14x14-evk.dtb \
imx6ul-geam.dtb \
imx6ul-isiot-emmc.dtb \
imx6ul-isiot-nand.dtb \
imx6ul-liteboard.dtb \
imx6ul-opos6uldev.dtb \
imx6ul-pico-hobbit.dtb \
imx6ul-tx6ul-0010.dtb \
imx6ul-tx6ul-0011.dtb \
<API key>.dtb \
imx6ull-14x14-evk.dtb
dtb-$(CONFIG_SOC_IMX7D) += \
imx7d-cl-som-imx7.dtb \
<API key>.dtb \
<API key>.dtb \
imx7d-nitrogen7.dtb \
imx7d-pico-pi.dtb \
imx7d-sbc-imx7.dtb \
imx7d-sdb.dtb \
imx7d-sdb-sht11.dtb \
<API key>.dtb \
imx7s-warp.dtb
dtb-$(CONFIG_SOC_LS1021A) += \
<API key>.dtb \
ls1021a-qds.dtb \
ls1021a-twr.dtb
dtb-$(CONFIG_SOC_VF610) += \
<API key>.dtb \
<API key>.dtb \
vf610m4-colibri.dtb \
vf610-cosmic.dtb \
vf610m4-cosmic.dtb \
vf610-twr.dtb \
vf610-zii-dev-rev-b.dtb \
vf610-zii-dev-rev-c.dtb
dtb-$(CONFIG_ARCH_MXS) += \
imx23-evk.dtb \
imx23-olinuxino.dtb \
imx23-sansa.dtb \
imx23-stmp378x_devb.dtb \
imx23-xfi3.dtb \
imx28-apf28.dtb \
imx28-apf28dev.dtb \
imx28-apx4devkit.dtb \
imx28-cfa10036.dtb \
imx28-cfa10037.dtb \
imx28-cfa10049.dtb \
imx28-cfa10055.dtb \
imx28-cfa10056.dtb \
imx28-cfa10057.dtb \
imx28-cfa10058.dtb \
<API key>.dtb \
imx28-duckbill-2.dtb \
<API key>.dtb \
<API key>.dtb \
imx28-duckbill.dtb \
<API key>.dtb \
<API key>.dtb \
imx28-evk.dtb \
imx28-m28cu3.dtb \
imx28-m28evk.dtb \
imx28-sps1.dtb \
imx28-ts4600.dtb \
imx28-tx28.dtb
dtb-$(CONFIG_ARCH_NOMADIK) += \
ste-nomadik-s8815.dtb \
ste-nomadik-nhk15.dtb
dtb-$(CONFIG_ARCH_NSPIRE) += \
nspire-cx.dtb \
nspire-tp.dtb \
nspire-clp.dtb
dtb-$(CONFIG_ARCH_OMAP2) += \
omap2420-h4.dtb \
omap2420-n800.dtb \
omap2420-n810.dtb \
omap2420-n810-wimax.dtb \
omap2430-sdp.dtb
dtb-$(CONFIG_ARCH_OMAP3) += \
am3517-craneboard.dtb \
am3517-evm.dtb \
am3517_mt_ventoux.dtb \
<API key>.dtb \
<API key>.dtb \
omap3430-sdp.dtb \
omap3-beagle.dtb \
omap3-beagle-xm.dtb \
omap3-beagle-xm-ab.dtb \
omap3-cm-t3517.dtb \
omap3-cm-t3530.dtb \
omap3-cm-t3730.dtb \
omap3-devkit8000.dtb \
<API key>.dtb \
<API key>.dtb \
omap3-evm.dtb \
omap3-evm-37xx.dtb \
omap3-gta04a3.dtb \
omap3-gta04a4.dtb \
omap3-gta04a5.dtb \
omap3-ha.dtb \
omap3-ha-lcd.dtb \
omap3-igep0020.dtb \
<API key>.dtb \
omap3-igep0030.dtb \
<API key>.dtb \
omap3-ldp.dtb \
omap3-lilly-dbb056.dtb \
omap3-n900.dtb \
omap3-n9.dtb \
omap3-n950.dtb \
omap3-overo-alto35.dtb \
<API key>.dtb \
<API key>.dtb \
omap3-overo-palo35.dtb \
omap3-overo-palo43.dtb \
<API key>.dtb \
<API key>.dtb \
<API key>.dtb \
<API key>.dtb \
<API key>.dtb \
<API key>.dtb \
<API key>.dtb \
<API key>.dtb \
omap3-overo-summit.dtb \
omap3-overo-tobi.dtb \
omap3-overo-tobiduo.dtb \
<API key>.dtb \
omap3-pandora-1ghz.dtb \
omap3-sbc-t3517.dtb \
omap3-sbc-t3530.dtb \
omap3-sbc-t3730.dtb \
omap3-sniper.dtb \
omap3-thunder.dtb \
omap3-zoom3.dtb
dtb-$(CONFIG_SOC_TI81XX) += \
dm8148-evm.dtb \
dm8148-t410.dtb \
dm8168-evm.dtb \
dra62x-j5eco-evm.dtb
dtb-$(CONFIG_SOC_AM33XX) += \
<API key>.dtb \
<API key>.dtb \
<API key>.dtb \
am335x-base0033.dtb \
am335x-bone.dtb \
am335x-boneblack.dtb \
<API key>.dtb \
am335x-boneblue.dtb \
am335x-bonegreen.dtb \
<API key>.dtb \
am335x-chiliboard.dtb \
am335x-cm-t335.dtb \
am335x-evm.dtb \
am335x-evmsk.dtb \
am335x-icev2.dtb \
am335x-lxm.dtb \
<API key>.dtb \
am335x-nano.dtb \
am335x-pepper.dtb \
am335x-phycore-rdk.dtb \
am335x-shc.dtb \
am335x-sbc-t335.dtb \
am335x-sl50.dtb \
am335x-wega-rdk.dtb
dtb-$(CONFIG_ARCH_OMAP4) += \
omap4-droid4-xt894.dtb \
<API key>.dtb \
omap4-kc1.dtb \
omap4-panda.dtb \
omap4-panda-a4.dtb \
omap4-panda-es.dtb \
omap4-sdp.dtb \
omap4-sdp-es23plus.dtb \
omap4-var-dvk-om44.dtb \
omap4-var-stk-om44.dtb
dtb-$(CONFIG_SOC_AM43XX) += \
am43x-epos-evm.dtb \
am437x-cm-t43.dtb \
am437x-gp-evm.dtb \
am437x-idk-evm.dtb \
am437x-sbc-t43.dtb \
am437x-sk-evm.dtb
dtb-$(CONFIG_SOC_OMAP5) += \
omap5-cm-t54.dtb \
omap5-igep0050.dtb \
omap5-sbc-t54.dtb \
omap5-uevm.dtb
dtb-$(CONFIG_SOC_DRA7XX) += \
am57xx-beagle-x15.dtb \
<API key>.dtb \
<API key>.dtb \
am57xx-cl-som-am57x.dtb \
am57xx-sbc-am57x.dtb \
am572x-idk.dtb \
am571x-idk.dtb \
am574x-idk.dtb \
dra7-evm.dtb \
dra72-evm.dtb \
dra72-evm-revc.dtb \
dra71-evm.dtb \
dra76-evm.dtb
dtb-$(CONFIG_ARCH_ORION5X) += \
orion5x-kuroboxpro.dtb \
<API key>.dtb \
<API key>.dtb \
<API key>.dtb \
<API key>.dtb \
<API key>.dtb \
orion5x-lswsgl.dtb \
<API key>.dtb \
<API key>.dtb \
<API key>.dtb
dtb-$(CONFIG_ARCH_ACTIONS) += \
<API key>.dtb \
<API key>.dtb \
owl-s500-sparky.dtb
dtb-$(CONFIG_ARCH_PRIMA2) += \
prima2-evb.dtb
dtb-$(CONFIG_ARCH_OXNAS) += \
ox810se-wd-mbwe.dtb \
<API key>.dtb
dtb-$(CONFIG_ARCH_QCOM) += \
<API key>.dtb \
<API key>.dtb \
<API key>.dtb \
<API key>.dtb \
<API key>.dtb \
<API key>.dtb \
<API key>.dtb \
<API key>.dtb \
qcom-apq8084-mtp.dtb \
qcom-ipq4019-ap.dk01.1-c1.dtb \
qcom-ipq8064-ap148.dtb \
qcom-msm8660-surf.dtb \
qcom-msm8960-cdp.dtb \
<API key>.dtb \
<API key>.dtb \
<API key>.dtb \
<API key>.dtb \
<API key>.dtb
dtb-$(<API key>) += \
arm-realview-pb1176.dtb \
arm-realview-pb11mp.dtb \
arm-realview-eb.dtb \
<API key>.dtb \
<API key>.dtb \
<API key>.dtb \
<API key>.dtb \
<API key>.dtb \
<API key>.dtb \
<API key>.dtb \
arm-realview-pba8.dtb \
arm-realview-pbx-a9.dtb
dtb-$(CONFIG_ARCH_RENESAS) += \
emev2-kzm9d.dtb \
r7s72100-genmai.dtb \
r7s72100-gr-peach.dtb \
r7s72100-rskrza1.dtb \
r8a73a4-ape6evm.dtb \
<API key>.dtb \
r8a7743-iwg20d-q7.dtb \
<API key>.dtb \
r8a7743-sk-rzg1m.dtb \
<API key>.dtb \
<API key>.dtb \
r8a7745-sk-rzg1e.dtb \
r8a7778-bockw.dtb \
r8a7779-marzen.dtb \
r8a7790-lager.dtb \
r8a7791-koelsch.dtb \
r8a7791-porter.dtb \
r8a7792-blanche.dtb \
r8a7792-wheat.dtb \
r8a7793-gose.dtb \
r8a7794-alt.dtb \
r8a7794-silk.dtb \
sh73a0-kzm9g.dtb
dtb-$(<API key>) += \
rv1108-evb.dtb \
rk3036-evb.dtb \
rk3036-kylin.dtb \
rk3066a-bqcurie2.dtb \
rk3066a-marsboard.dtb \
rk3066a-mk808.dtb \
rk3066a-rayeager.dtb \
rk3188-px3-evb.dtb \
rk3188-radxarock.dtb \
rk3228-evb.dtb \
rk3229-evb.dtb \
rk3288-evb-act8846.dtb \
rk3288-evb-rk808.dtb \
rk3288-fennec.dtb \
rk3288-firefly-beta.dtb \
rk3288-firefly.dtb \
<API key>.dtb \
rk3288-miqi.dtb \
rk3288-phycore-rdk.dtb \
rk3288-popmetal.dtb \
rk3288-r89.dtb \
rk3288-rock2-square.dtb \
rk3288-tinker.dtb \
rk3288-veyron-brain.dtb \
rk3288-veyron-jaq.dtb \
rk3288-veyron-jerry.dtb \
<API key>.dtb \
<API key>.dtb \
rk3288-veyron-pinky.dtb \
<API key>.dtb \
rk3288-vyasa.dtb
dtb-$(CONFIG_ARCH_S3C24XX) += \
s3c2416-smdk2416.dtb
dtb-$(CONFIG_ARCH_S3C64XX) += \
s3c6410-mini6410.dtb \
s3c6410-smdk6410.dtb
dtb-$(CONFIG_ARCH_S5PV210) += \
s5pv210-aquila.dtb \
s5pv210-goni.dtb \
s5pv210-smdkc110.dtb \
s5pv210-smdkv210.dtb \
s5pv210-torbreck.dtb
dtb-$(CONFIG_ARCH_SOCFPGA) += \
<API key>.dtb \
<API key>.dtb \
<API key>.dtb \
<API key>.dtb \
<API key>.dtb \
<API key>.dtb \
<API key>.dtb \
<API key>.dtb \
<API key>.dtb \
<API key>.dtb \
<API key>.dtb \
socfpga_vt.dtb
dtb-$(<API key>) += \
spear1310-evb.dtb \
spear1340-evb.dtb
dtb-$(<API key>) += \
spear300-evb.dtb \
spear310-evb.dtb \
spear320-evb.dtb \
spear320-hmi.dtb
dtb-$(<API key>) += \
spear600-evb.dtb
dtb-$(CONFIG_ARCH_STI) += \
stih407-b2120.dtb \
stih410-b2120.dtb \
stih410-b2260.dtb \
stih418-b2199.dtb
dtb-$(CONFIG_ARCH_STM32)+= \
stm32f429-disco.dtb \
stm32f469-disco.dtb \
stm32f746-disco.dtb \
stm32f769-disco.dtb \
stm32429i-eval.dtb \
stm32746g-eval.dtb \
stm32h743i-eval.dtb \
stm32h743i-disco.dtb
dtb-$(CONFIG_MACH_SUN4I) += \
sun4i-a10-a1000.dtb \
<API key>.dtb \
<API key>.dtb \
<API key>.dtb \
<API key>.dtb \
sun4i-a10-gemei-g9.dtb \
sun4i-a10-hackberry.dtb \
<API key>.dtb \
sun4i-a10-inet1.dtb \
sun4i-a10-inet97fv2.dtb \
<API key>.dtb \
<API key>.dtb \
<API key>.dtb \
sun4i-a10-marsboard.dtb \
<API key>.dtb \
sun4i-a10-mk802.dtb \
sun4i-a10-mk802ii.dtb \
<API key>.dtb \
sun4i-a10-pcduino.dtb \
sun4i-a10-pcduino2.dtb \
<API key>.dtb
dtb-$(CONFIG_MACH_SUN5I) += \
<API key>.dtb \
<API key>.dtb \
sun5i-a10s-mk802.dtb \
<API key>.dtb \
<API key>.dtb \
sun5i-a10s-wobo-i5.dtb \
<API key>.dtb \
<API key>.dtb \
<API key>.dtb \
sun5i-a13-hsg-h702.dtb \
<API key>.dtb \
<API key>.dtb \
sun5i-a13-olinuxino.dtb \
<API key>.dtb \
sun5i-a13-q8-tablet.dtb \
sun5i-a13-utoo-p66.dtb \
sun5i-gr8-chip-pro.dtb \
sun5i-gr8-evb.dtb \
sun5i-r8-chip.dtb
dtb-$(CONFIG_MACH_SUN6I) += \
sun6i-a31-app4-evb1.dtb \
sun6i-a31-colombus.dtb \
<API key>.dtb \
sun6i-a31-i7.dtb \
sun6i-a31-m9.dtb \
<API key>.dtb \
<API key>.dtb \
sun6i-a31s-cs908.dtb \
<API key>.dtb \
sun6i-a31s-primo81.dtb \
sun6i-a31s-sina31s.dtb \
<API key>.dtb \
<API key>.dtb
dtb-$(CONFIG_MACH_SUN7I) += \
sun7i-a20-bananapi.dtb \
<API key>.dtb \
sun7i-a20-bananapro.dtb \
<API key>.dtb \
<API key>.dtb \
<API key>.dtb \
<API key>.dtb \
sun7i-a20-i12-tvbox.dtb \
<API key>.dtb \
sun7i-a20-lamobo-r1.dtb \
sun7i-a20-m3.dtb \
sun7i-a20-mk808c.dtb \
<API key>.dtb \
<API key>.dtb \
<API key>.dtb \
<API key>.dtb \
<API key>.dtb \
<API key>.dtb \
sun7i-a20-orangepi.dtb \
<API key>.dtb \
sun7i-a20-pcduino3.dtb \
<API key>.dtb \
<API key>.dtb \
<API key>.dtb
dtb-$(CONFIG_MACH_SUN8I) += \
sun8i-a23-evb.dtb \
sun8i-a23-gt90h-v4.dtb \
sun8i-a23-inet86dz.dtb \
<API key>.dtb \
<API key>.2.dtb \
<API key>.dtb \
<API key>.dtb \
sun8i-a23-q8-tablet.dtb \
sun8i-a33-et-q8-v1.6.dtb \
sun8i-a33-ga10h-v1.1.dtb \
<API key>.dtb \
<API key>.2.dtb \
sun8i-a33-olinuxino.dtb \
sun8i-a33-q8-tablet.dtb \
<API key>.dtb \
<API key>.dtb \
<API key>.dtb \
<API key>.dtb \
sun8i-a83t-tbs-a711.dtb \
<API key>.dtb \
<API key>.dtb \
<API key>.dtb \
sun8i-h3-beelink-x2.dtb \
<API key>.dtb \
sun8i-h3-nanopi-m1.dtb \
<API key>.dtb \
sun8i-h3-nanopi-neo.dtb \
<API key>.dtb \
sun8i-h3-orangepi-2.dtb \
<API key>.dtb \
<API key>.dtb \
<API key>.dtb \
<API key>.dtb \
<API key>.dtb \
<API key>.dtb \
<API key>.dtb \
sun8i-r16-parrot.dtb \
<API key>.dtb \
<API key>.dtb \
<API key>.dtb \
<API key>.dtb
dtb-$(CONFIG_MACH_SUN9I) += \
sun9i-a80-optimus.dtb \
<API key>.dtb
dtb-$(CONFIG_ARCH_TANGO) += \
tango4-vantage-1172.dtb
dtb-$(<API key>) += \
tegra20-harmony.dtb \
tegra20-iris-512.dtb \
tegra20-medcom-wide.dtb \
tegra20-paz00.dtb \
tegra20-plutux.dtb \
tegra20-seaboard.dtb \
tegra20-tec.dtb \
tegra20-trimslice.dtb \
tegra20-ventana.dtb
dtb-$(<API key>) += \
tegra30-apalis-eval.dtb \
tegra30-beaver.dtb \
tegra30-cardhu-a02.dtb \
tegra30-cardhu-a04.dtb \
<API key>.dtb
dtb-$(<API key>) += \
tegra114-dalmore.dtb \
tegra114-roth.dtb \
tegra114-tn7.dtb
dtb-$(<API key>) += \
<API key>.dtb \
tegra124-jetson-tk1.dtb \
tegra124-nyan-big.dtb \
tegra124-nyan-blaze.dtb \
tegra124-venice2.dtb
dtb-$(CONFIG_ARCH_U300) += \
ste-u300.dtb
dtb-$(CONFIG_ARCH_U8500) += \
ste-snowball.dtb \
<API key>.dtb \
ste-hrefprev60-tvk.dtb \
<API key>.dtb \
ste-hrefv60plus-tvk.dtb \
ste-ccu8540.dtb \
ste-ccu9540.dtb
dtb-$(<API key>) += \
uniphier-ld4-ref.dtb \
uniphier-ld6b-ref.dtb \
uniphier-pro4-ace.dtb \
uniphier-pro4-ref.dtb \
uniphier-pro4-sanji.dtb \
<API key>.dtb \
uniphier-pxs2-vodka.dtb \
uniphier-sld8-ref.dtb
dtb-$(<API key>) += \
versatile-ab.dtb \
versatile-pb.dtb
dtb-$(<API key>) += \
vexpress-v2p-ca5s.dtb \
vexpress-v2p-ca9.dtb \
<API key>.dtb \
<API key>.dtb
dtb-$(CONFIG_ARCH_VIRT) += \
xenvm-4.2.dtb
dtb-$(CONFIG_ARCH_VT8500) += \
vt8500-bv07.dtb \
wm8505-ref.dtb \
wm8650-mid.dtb \
wm8750-apc8750.dtb \
wm8850-w70v2.dtb
dtb-$(CONFIG_ARCH_ZYNQ) += \
zynq-microzed.dtb \
zynq-parallella.dtb \
zynq-zc702.dtb \
zynq-zc706.dtb \
zynq-zed.dtb \
zynq-zybo.dtb
dtb-$(<API key>) += \
armada-370-db.dtb \
<API key>.dtb \
armada-370-mirabox.dtb \
<API key>.dtb \
<API key>.dtb \
armada-370-rd.dtb \
<API key>.dtb \
<API key>.dtb \
<API key>.dtb \
<API key>.dtb \
<API key>.dtb
dtb-$(<API key>) += \
armada-375-db.dtb
dtb-$(<API key>) += \
armada-385-db-ap.dtb \
<API key>.dtb \
<API key>.dtb \
<API key>.dtb \
<API key>.dtb \
<API key>.dtb \
<API key>.dtb \
armada-388-clearfog.dtb \
<API key>.dtb \
<API key>.dtb \
armada-388-db.dtb \
armada-388-gp.dtb \
armada-388-rd.dtb
dtb-$(<API key>) += \
armada-398-db.dtb
dtb-$(<API key>) += \
armada-xp-axpwifiap.dtb \
armada-xp-db.dtb \
armada-xp-db-dxbc2.dtb \
<API key>.dtb \
armada-xp-gp.dtb \
<API key>.dtb \
<API key>.dtb \
armada-xp-matrix.dtb \
<API key>.dtb \
<API key>.dtb \
<API key>.dtb
dtb-$(CONFIG_MACH_DOVE) += \
dove-cubox.dtb \
dove-cubox-es.dtb \
dove-d2plug.dtb \
dove-d3plug.dtb \
dove-dove-db.dtb \
dove-sbc-a510.dtb
dtb-$(<API key>) += \
mt2701-evb.dtb \
mt6580-evbp1.dtb \
mt6589-aquaris5.dtb \
mt6592-evb.dtb \
mt7623n-rfb-nand.dtb \
<API key>.dtb \
mt8127-moose.dtb \
mt8135-evbp1.dtb
dtb-$(CONFIG_ARCH_ZX) += zx296702-ad1.dtb
dtb-$(CONFIG_ARCH_ASPEED) += \
aspeed-ast2500-evb.dtb \
<API key>.dtb \
<API key>.dtb \
<API key>.dtb \
<API key>.dtb \
<API key>.dtb |
#include <stdlib.h>
double
erand48 (xsubi)
unsigned short int xsubi[3];
{
double result;
(void) __erand48_r (xsubi, &__libc_drand48_data, &result);
return result;
} |
! { dg-do run }
! PR 34565 - internal writes with negative strides
! didn't work.
program main
implicit none
integer :: i
integer :: lo, up, st
character(len=2) :: c (5)
integer, dimension(5) :: n
c = (/ 'a', 'b', 'c', 'd', 'e' /)
write (unit=c(5:1:-2),fmt="(A)") '5','3', '1'
write (unit=c(2:4:2),fmt="(A)") '2', '4'
read (c(5:1:-1),fmt="(I2)") (n(i), i=5,1,-1)
if (any(n /= (/ (i,i=1,5) /))) STOP 1
end program main |
#ifndef _LIBSMB_CLIRAP_H
#define _LIBSMB_CLIRAP_H
struct cli_state;
/* The following definitions come from libsmb/clirap.c */
bool cli_api(struct cli_state *cli,
char *param, int prcnt, int mprcnt,
char *data, int drcnt, int mdrcnt,
char **rparam, unsigned int *rprcnt,
char **rdata, unsigned int *rdrcnt);
bool <API key>(struct cli_state *cli,char *user, char *workstation);
int cli_RNetShareEnum(struct cli_state *cli, void (*fn)(const char *, uint32, const char *, void *), void *state);
bool cli_NetServerEnum(struct cli_state *cli, char *workgroup, uint32 stype,
void (*fn)(const char *, uint32, const char *, void *),
void *state);
bool <API key>(struct cli_state *cli, const char *user, const char *new_password,
const char *old_password);
struct tevent_req *cli_qpathinfo1_send(TALLOC_CTX *mem_ctx,
struct event_context *ev,
struct cli_state *cli,
const char *fname);
NTSTATUS cli_qpathinfo1_recv(struct tevent_req *req,
time_t *change_time,
time_t *access_time,
time_t *write_time,
SMB_OFF_T *size,
uint16 *mode);
NTSTATUS cli_qpathinfo1(struct cli_state *cli,
const char *fname,
time_t *change_time,
time_t *access_time,
time_t *write_time,
SMB_OFF_T *size,
uint16 *mode);
NTSTATUS <API key>(struct cli_state *cli, const char *fname,
time_t create_time,
time_t access_time,
time_t write_time,
time_t change_time,
uint16 mode);
struct tevent_req *cli_qpathinfo2_send(TALLOC_CTX *mem_ctx,
struct event_context *ev,
struct cli_state *cli,
const char *fname);
NTSTATUS cli_qpathinfo2_recv(struct tevent_req *req,
struct timespec *create_time,
struct timespec *access_time,
struct timespec *write_time,
struct timespec *change_time,
SMB_OFF_T *size, uint16 *mode,
SMB_INO_T *ino);
NTSTATUS cli_qpathinfo2(struct cli_state *cli, const char *fname,
struct timespec *create_time,
struct timespec *access_time,
struct timespec *write_time,
struct timespec *change_time,
SMB_OFF_T *size, uint16 *mode,
SMB_INO_T *ino);
struct tevent_req *<API key>(TALLOC_CTX *mem_ctx,
struct tevent_context *ev,
struct cli_state *cli,
const char *fname);
NTSTATUS <API key>(struct tevent_req *req,
TALLOC_CTX *mem_ctx,
unsigned int *pnum_streams,
struct stream_struct **pstreams);
NTSTATUS <API key>(struct cli_state *cli, const char *fname,
TALLOC_CTX *mem_ctx,
unsigned int *pnum_streams,
struct stream_struct **pstreams);
NTSTATUS cli_qfilename(struct cli_state *cli, uint16_t fnum, char *name,
size_t namelen);
NTSTATUS cli_qfileinfo_basic(struct cli_state *cli, uint16_t fnum,
uint16 *mode, SMB_OFF_T *size,
struct timespec *create_time,
struct timespec *access_time,
struct timespec *write_time,
struct timespec *change_time,
SMB_INO_T *ino);
struct tevent_req *<API key>(TALLOC_CTX *mem_ctx,
struct event_context *ev,
struct cli_state *cli,
const char *fname);
NTSTATUS <API key>(struct tevent_req *req,
SMB_STRUCT_STAT *sbuf, uint32 *attributes);
NTSTATUS cli_qpathinfo_basic(struct cli_state *cli, const char *name,
SMB_STRUCT_STAT *sbuf, uint32 *attributes);
NTSTATUS <API key>(struct cli_state *cli, const char *fname, fstring alt_name);
struct tevent_req *cli_qpathinfo_send(TALLOC_CTX *mem_ctx,
struct tevent_context *ev,
struct cli_state *cli, const char *fname,
uint16_t level, uint32_t min_rdata,
uint32_t max_rdata);
NTSTATUS cli_qpathinfo_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx,
uint8_t **rdata, uint32_t *num_rdata);
NTSTATUS cli_qpathinfo(TALLOC_CTX *mem_ctx, struct cli_state *cli,
const char *fname, uint16_t level, uint32_t min_rdata,
uint32_t max_rdata,
uint8_t **rdata, uint32_t *num_rdata);
struct tevent_req *cli_qfileinfo_send(TALLOC_CTX *mem_ctx,
struct tevent_context *ev,
struct cli_state *cli, uint16_t fnum,
uint16_t level, uint32_t min_rdata,
uint32_t max_rdata);
NTSTATUS cli_qfileinfo_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx,
uint8_t **rdata, uint32_t *num_rdata);
NTSTATUS cli_qfileinfo(TALLOC_CTX *mem_ctx, struct cli_state *cli,
uint16_t fnum, uint16_t level, uint32_t min_rdata,
uint32_t max_rdata,
uint8_t **rdata, uint32_t *num_rdata);
struct tevent_req *cli_flush_send(TALLOC_CTX *mem_ctx,
struct event_context *ev,
struct cli_state *cli,
uint16_t fnum);
NTSTATUS cli_flush_recv(struct tevent_req *req);
NTSTATUS cli_flush(TALLOC_CTX *mem_ctx, struct cli_state *cli, uint16_t fnum);
struct tevent_req *<API key>(TALLOC_CTX *mem_ctx,
struct tevent_context *ev,
struct cli_state *cli,
uint16_t fnum,
bool get_names);
NTSTATUS <API key>(struct tevent_req *req, TALLOC_CTX *mem_ctx,
char ***pnames, int *pnum_names);
NTSTATUS <API key>(TALLOC_CTX *mem_ctx, struct cli_state *cli,
uint16_t fnum, bool get_names,
char ***pnames, int *pnum_names);
/* The following definitions come from libsmb/clirap2.c */
struct rap_group_info_1;
struct rap_user_info_1;
struct rap_share_info_2;
int cli_NetGroupDelete(struct cli_state *cli, const char *group_name);
int cli_NetGroupAdd(struct cli_state *cli, struct rap_group_info_1 *grinfo);
int cli_RNetGroupEnum(struct cli_state *cli, void (*fn)(const char *, const char *, void *), void *state);
int cli_RNetGroupEnum0(struct cli_state *cli,
void (*fn)(const char *, void *),
void *state);
int cli_NetGroupDelUser(struct cli_state * cli, const char *group_name, const char *user_name);
int cli_NetGroupAddUser(struct cli_state * cli, const char *group_name, const char *user_name);
int <API key>(struct cli_state * cli, const char *group_name, void (*fn)(const char *, void *), void *state );
int <API key>(struct cli_state * cli, const char *user_name, void (*fn)(const char *, void *), void *state );
int cli_NetUserDelete(struct cli_state *cli, const char * user_name );
int cli_NetUserAdd(struct cli_state *cli, struct rap_user_info_1 * userinfo );
int cli_RNetUserEnum(struct cli_state *cli, void (*fn)(const char *, const char *, const char *, const char *, void *), void *state);
int cli_RNetUserEnum0(struct cli_state *cli,
void (*fn)(const char *, void *),
void *state);
int cli_NetFileClose(struct cli_state *cli, uint32 file_id );
int cli_NetFileGetInfo(struct cli_state *cli, uint32 file_id, void (*fn)(const char *, const char *, uint16, uint16, uint32));
int cli_NetFileEnum(struct cli_state *cli, const char * user,
const char * base_path,
void (*fn)(const char *, const char *, uint16, uint16,
uint32));
int cli_NetShareAdd(struct cli_state *cli, struct rap_share_info_2 * sinfo );
int cli_NetShareDelete(struct cli_state *cli, const char * share_name );
bool cli_get_pdc_name(struct cli_state *cli, const char *workgroup, char **pdc_name);
bool <API key>(struct cli_state *cli);
bool cli_get_server_type(struct cli_state *cli, uint32 *pstype);
bool cli_get_server_name(TALLOC_CTX *mem_ctx, struct cli_state *cli,
char **servername);
bool <API key>(struct cli_state *cli, char *workgroup, uint32 stype);
bool <API key>(struct cli_state *cli, const char *user, const char *workstation);
int cli_NetPrintQEnum(struct cli_state *cli,
void (*qfn)(const char*,uint16,uint16,uint16,const char*,const char*,const char*,const char*,const char*,uint16,uint16),
void (*jfn)(uint16,const char*,const char*,const char*,const char*,uint16,uint16,const char*,unsigned int,unsigned int,const char*));
int <API key>(struct cli_state *cli, const char *printer,
void (*qfn)(const char*,uint16,uint16,uint16,const char*,const char*,const char*,const char*,const char*,uint16,uint16),
void (*jfn)(uint16,const char*,const char*,const char*,const char*,uint16,uint16,const char*,unsigned int,unsigned int,const char*));
int cli_RNetServiceEnum(struct cli_state *cli, void (*fn)(const char *, const char *, void *), void *state);
int cli_NetSessionEnum(struct cli_state *cli, void (*fn)(char *, char *, uint16, uint16, uint16, unsigned int, unsigned int, unsigned int, char *));
int <API key>(struct cli_state *cli, const char *workstation,
void (*fn)(const char *, const char *, uint16, uint16, uint16, unsigned int, unsigned int, unsigned int, const char *));
int cli_NetSessionDel(struct cli_state *cli, const char *workstation);
int <API key>(struct cli_state *cli, const char *qualifier,
void (*fn)(uint16_t conid, uint16_t contype,
uint16_t numopens, uint16_t numusers,
uint32_t contime, const char *username,
const char *netname));
#endif /* _LIBSMB_CLIRAP_H */ |
#ifndef <API key>
#define <API key>
#define XFS_BMAP_MAGIC 0x424d4150 /* 'BMAP' */
struct xfs_btree_cur;
struct xfs_btree_lblock;
struct xfs_mount;
struct xfs_inode;
/*
* Bmap root header, on-disk form only.
*/
typedef struct xfs_bmdr_block {
__be16 bb_level; /* 0 is a leaf */
__be16 bb_numrecs; /* current # of data records */
} xfs_bmdr_block_t;
/*
* Bmap btree record and extent descriptor.
* l0:63 is an extent flag (value 1 indicates non-normal).
* l0:9-62 are startoff.
* l0:0-8 and l1:21-63 are startblock.
* l1:0-20 are blockcount.
*/
#define <API key> 1
#define <API key> 54
#define <API key> 52
#define <API key> 21
#define BMBT_USE_64 1
typedef struct xfs_bmbt_rec_32
{
__uint32_t l0, l1, l2, l3;
} xfs_bmbt_rec_32_t;
typedef struct xfs_bmbt_rec_64
{
__be64 l0, l1;
} xfs_bmbt_rec_64_t;
typedef __uint64_t xfs_bmbt_rec_base_t; /* use this for casts */
typedef xfs_bmbt_rec_64_t xfs_bmbt_rec_t, xfs_bmdr_rec_t;
typedef struct xfs_bmbt_rec_host {
__uint64_t l0, l1;
} xfs_bmbt_rec_host_t;
/*
* Values and macros for delayed-allocation startblock fields.
*/
#define STARTBLOCKVALBITS 17
#define STARTBLOCKMASKBITS (15 + XFS_BIG_BLKNOS * 20)
#define DSTARTBLOCKMASKBITS (15 + 20)
#define STARTBLOCKMASK \
(((((xfs_fsblock_t)1) << STARTBLOCKMASKBITS) - 1) << STARTBLOCKVALBITS)
#define DSTARTBLOCKMASK \
(((((xfs_dfsbno_t)1) << DSTARTBLOCKMASKBITS) - 1) << STARTBLOCKVALBITS)
#define ISNULLSTARTBLOCK(x) isnullstartblock(x)
static inline int isnullstartblock(xfs_fsblock_t x)
{
return ((x) & STARTBLOCKMASK) == STARTBLOCKMASK;
}
#define ISNULLDSTARTBLOCK(x) isnulldstartblock(x)
static inline int isnulldstartblock(xfs_dfsbno_t x)
{
return ((x) & DSTARTBLOCKMASK) == DSTARTBLOCKMASK;
}
#define NULLSTARTBLOCK(k) nullstartblock(k)
static inline xfs_fsblock_t nullstartblock(int k)
{
ASSERT(k < (1 << STARTBLOCKVALBITS));
return STARTBLOCKMASK | (k);
}
#define STARTBLOCKVAL(x) startblockval(x)
static inline xfs_filblks_t startblockval(xfs_fsblock_t x)
{
return (xfs_filblks_t)((x) & ~STARTBLOCKMASK);
}
/*
* Possible extent formats.
*/
typedef enum {
XFS_EXTFMT_NOSTATE = 0,
XFS_EXTFMT_HASSTATE
} xfs_exntfmt_t;
/*
* Possible extent states.
*/
typedef enum {
XFS_EXT_NORM, XFS_EXT_UNWRITTEN,
<API key>, XFS_EXT_INVALID
} xfs_exntst_t;
/*
* Extent state and extent format macros.
*/
#define XFS_EXTFMT_INODE(x) \
(<API key>(&((x)->i_mount->m_sb)) ? \
XFS_EXTFMT_HASSTATE : XFS_EXTFMT_NOSTATE)
#define ISUNWRITTEN(x) ((x)->br_state == XFS_EXT_UNWRITTEN)
/*
* Incore version of above.
*/
typedef struct xfs_bmbt_irec
{
xfs_fileoff_t br_startoff; /* starting file offset */
xfs_fsblock_t br_startblock; /* starting block number */
xfs_filblks_t br_blockcount; /* number of blocks */
xfs_exntst_t br_state; /* extent state */
} xfs_bmbt_irec_t;
/*
* Key structure for non-leaf levels of the tree.
*/
typedef struct xfs_bmbt_key {
__be64 br_startoff; /* starting file offset */
} xfs_bmbt_key_t, xfs_bmdr_key_t;
/* btree pointer type */
typedef __be64 xfs_bmbt_ptr_t, xfs_bmdr_ptr_t;
/* btree block header type */
typedef struct xfs_btree_lblock xfs_bmbt_block_t;
#define <API key>(bp) ((xfs_bmbt_block_t *)XFS_BUF_PTR(bp))
#define <API key>(lev,cur) ((cur)->bc_private.b.forksize)
#define <API key>(lev,cur) \
((int)XFS_IFORK_PTR((cur)->bc_private.b.ip, \
(cur)->bc_private.b.whichfork)->if_broot_bytes)
#define <API key>(lev,cur) \
(((lev) == (cur)->bc_nlevels - 1 ? \
<API key>(<API key>(lev,cur), \
xfs_bmdr, (lev) == 0) : \
((cur)->bc_mp->m_bmap_dmxr[(lev) != 0])))
#define <API key>(lev,cur) \
(((lev) == (cur)->bc_nlevels - 1 ? \
<API key>(<API key>(lev,cur),\
xfs_bmbt, (lev) == 0) : \
((cur)->bc_mp->m_bmap_dmxr[(lev) != 0])))
#define <API key>(lev,cur) \
(((lev) == (cur)->bc_nlevels - 1 ? \
<API key>(<API key>(lev,cur),\
xfs_bmdr, (lev) == 0) : \
((cur)->bc_mp->m_bmap_dmnr[(lev) != 0])))
#define <API key>(lev,cur) \
(((lev) == (cur)->bc_nlevels - 1 ? \
<API key>(<API key>(lev,cur),\
xfs_bmbt, (lev) == 0) : \
((cur)->bc_mp->m_bmap_dmnr[(lev) != 0])))
#define XFS_BMAP_REC_DADDR(bb,i,cur) (XFS_BTREE_REC_ADDR(xfs_bmbt, bb, i))
#define XFS_BMAP_REC_IADDR(bb,i,cur) (XFS_BTREE_REC_ADDR(xfs_bmbt, bb, i))
#define XFS_BMAP_KEY_DADDR(bb,i,cur) \
(XFS_BTREE_KEY_ADDR(xfs_bmbt, bb, i))
#define XFS_BMAP_KEY_IADDR(bb,i,cur) \
(XFS_BTREE_KEY_ADDR(xfs_bmbt, bb, i))
#define XFS_BMAP_PTR_DADDR(bb,i,cur) \
(XFS_BTREE_PTR_ADDR(xfs_bmbt, bb, i, <API key>( \
be16_to_cpu((bb)->bb_level), cur)))
#define XFS_BMAP_PTR_IADDR(bb,i,cur) \
(XFS_BTREE_PTR_ADDR(xfs_bmbt, bb, i, <API key>( \
be16_to_cpu((bb)->bb_level), cur)))
/*
* These are to be used when we know the size of the block and
* we don't have a cursor.
*/
#define <API key>(bb,i,sz) \
(XFS_BTREE_REC_ADDR(xfs_bmbt,bb,i))
#define <API key>(bb,i,sz) \
(XFS_BTREE_KEY_ADDR(xfs_bmbt,bb,i))
#define <API key>(bb,i,sz) \
(XFS_BTREE_PTR_ADDR(xfs_bmbt,bb,i,<API key>(sz)))
#define <API key>(bb) be16_to_cpu((bb)->bb_numrecs)
#define <API key>(sz) <API key>(sz,xfs_bmbt,0)
#define <API key>(nrecs) \
(int)(sizeof(xfs_bmbt_block_t) + \
((nrecs) * (sizeof(xfs_bmbt_key_t) + sizeof(xfs_bmbt_ptr_t))))
#define <API key>(bb) \
(<API key>(be16_to_cpu((bb)->bb_numrecs)))
#define XFS_BMDR_SPACE_CALC(nrecs) \
(int)(sizeof(xfs_bmdr_block_t) + \
((nrecs) * (sizeof(xfs_bmbt_key_t) + sizeof(xfs_bmbt_ptr_t))))
/*
* Maximum number of bmap btree levels.
*/
#define XFS_BM_MAXLEVELS(mp,w) ((mp)->m_bm_maxlevels[(w)])
#define <API key>(mp,bb,level) \
(be32_to_cpu((bb)->bb_magic) == XFS_BMAP_MAGIC && \
be16_to_cpu((bb)->bb_level) == level && \
be16_to_cpu((bb)->bb_numrecs) > 0 && \
be16_to_cpu((bb)->bb_numrecs) <= (mp)->m_bmap_dmxr[(level) != 0])
#ifdef __KERNEL__
#if defined(XFS_BMBT_TRACE)
/*
* Trace buffer entry types.
*/
#define <API key> 1
#define <API key> 2
#define <API key> 3
#define <API key> 4
#define <API key> 5
#define <API key> 6
#define <API key> 7
#define XFS_BMBT_KTRACE_CUR 8
#define XFS_BMBT_TRACE_SIZE 4096 /* size of global trace buffer */
#define <API key> 32 /* size of per-inode trace buffer */
extern ktrace_t *xfs_bmbt_trace_buf;
#endif
/*
* Prototypes for xfs_bmap.c to call.
*/
extern void xfs_bmdr_to_bmbt(xfs_bmdr_block_t *, int, xfs_bmbt_block_t *, int);
extern int xfs_bmbt_decrement(struct xfs_btree_cur *, int, int *);
extern int xfs_bmbt_delete(struct xfs_btree_cur *, int *);
extern void xfs_bmbt_get_all(xfs_bmbt_rec_host_t *r, xfs_bmbt_irec_t *s);
extern xfs_bmbt_block_t *xfs_bmbt_get_block(struct xfs_btree_cur *cur,
int, struct xfs_buf **bpp);
extern xfs_filblks_t <API key>(xfs_bmbt_rec_host_t *r);
extern xfs_fsblock_t <API key>(xfs_bmbt_rec_host_t *r);
extern xfs_fileoff_t <API key>(xfs_bmbt_rec_host_t *r);
extern xfs_exntst_t xfs_bmbt_get_state(xfs_bmbt_rec_host_t *r);
extern void <API key>(xfs_bmbt_rec_t *r, xfs_bmbt_irec_t *s);
extern xfs_filblks_t <API key>(xfs_bmbt_rec_t *r);
extern xfs_fileoff_t <API key>(xfs_bmbt_rec_t *r);
extern int xfs_bmbt_increment(struct xfs_btree_cur *, int, int *);
extern int xfs_bmbt_insert(struct xfs_btree_cur *, int *);
extern void xfs_bmbt_log_block(struct xfs_btree_cur *, struct xfs_buf *, int);
extern void xfs_bmbt_log_recs(struct xfs_btree_cur *, struct xfs_buf *, int,
int);
extern int xfs_bmbt_lookup_eq(struct xfs_btree_cur *, xfs_fileoff_t,
xfs_fsblock_t, xfs_filblks_t, int *);
extern int xfs_bmbt_lookup_ge(struct xfs_btree_cur *, xfs_fileoff_t,
xfs_fsblock_t, xfs_filblks_t, int *);
/*
* Give the bmap btree a new root block. Copy the old broot contents
* down into a real block and make the broot point to it.
*/
extern int xfs_bmbt_newroot(struct xfs_btree_cur *cur, int *lflags, int *stat);
extern void xfs_bmbt_set_all(xfs_bmbt_rec_host_t *r, xfs_bmbt_irec_t *s);
extern void xfs_bmbt_set_allf(xfs_bmbt_rec_host_t *r, xfs_fileoff_t o,
xfs_fsblock_t b, xfs_filblks_t c, xfs_exntst_t v);
extern void <API key>(xfs_bmbt_rec_host_t *r, xfs_filblks_t v);
extern void <API key>(xfs_bmbt_rec_host_t *r, xfs_fsblock_t v);
extern void <API key>(xfs_bmbt_rec_host_t *r, xfs_fileoff_t v);
extern void xfs_bmbt_set_state(xfs_bmbt_rec_host_t *r, xfs_exntst_t v);
extern void <API key>(xfs_bmbt_rec_t *r, xfs_bmbt_irec_t *s);
extern void <API key>(xfs_bmbt_rec_t *r, xfs_fileoff_t o,
xfs_fsblock_t b, xfs_filblks_t c, xfs_exntst_t v);
extern void xfs_bmbt_to_bmdr(xfs_bmbt_block_t *, int, xfs_bmdr_block_t *, int);
extern int xfs_bmbt_update(struct xfs_btree_cur *, xfs_fileoff_t,
xfs_fsblock_t, xfs_filblks_t, xfs_exntst_t);
#endif /* __KERNEL__ */
#endif /* <API key> */ |
#include <gtest/gtest.h>
#include "Common/CommonFuncs.h"
TEST(CommonFuncs, ArraySizeMacro)
{
char test[4];
u32 test2[42];
EXPECT_EQ(4u, ArraySize(test));
EXPECT_EQ(42u, ArraySize(test2));
(void)test;
(void)test2;
}
TEST(CommonFuncs, RoundUpPow2Macro)
{
EXPECT_EQ(4, ROUND_UP_POW2(3));
EXPECT_EQ(4, ROUND_UP_POW2(4));
EXPECT_EQ(8, ROUND_UP_POW2(6));
EXPECT_EQ(0x40000000, ROUND_UP_POW2(0x23456789));
}
TEST(CommonFuncs, CrashMacro)
{
EXPECT_DEATH({ Crash(); }, "");
}
TEST(CommonFuncs, Swap)
{
EXPECT_EQ(0xf0, Common::swap8(0xf0));
EXPECT_EQ(0x1234, Common::swap16(0x3412));
EXPECT_EQ(0x12345678u, Common::swap32(0x78563412));
EXPECT_EQ(<API key>, Common::swap64(<API key>));
} |
// <API key>: GPL-2.0-or-later
#include <linux/module.h>
#include <linux/rtc.h>
#include <linux/slab.h>
#include <linux/platform_device.h>
#include <linux/bcd.h>
#include <linux/io.h>
#include <linux/err.h>
struct m48t35_rtc {
u8 pad[0x7ff8]; /* starts at 0x7ff8 */
#ifdef CONFIG_SGI_IP27
u8 hour;
u8 min;
u8 sec;
u8 control;
u8 year;
u8 month;
u8 date;
u8 day;
#else
u8 control;
u8 sec;
u8 min;
u8 hour;
u8 day;
u8 date;
u8 month;
u8 year;
#endif
};
#define M48T35_RTC_SET 0x80
#define M48T35_RTC_READ 0x40
struct m48t35_priv {
struct rtc_device *rtc;
struct m48t35_rtc __iomem *reg;
size_t size;
unsigned long baseaddr;
spinlock_t lock;
};
static int m48t35_read_time(struct device *dev, struct rtc_time *tm)
{
struct m48t35_priv *priv = dev_get_drvdata(dev);
u8 control;
/*
* Only the values that we read from the RTC are set. We leave
* tm_wday, tm_yday and tm_isdst untouched. Even though the
* RTC has RTC_DAY_OF_WEEK, we ignore it, as it is only updated
* by the RTC when initially set to a non-zero value.
*/
spin_lock_irq(&priv->lock);
control = readb(&priv->reg->control);
writeb(control | M48T35_RTC_READ, &priv->reg->control);
tm->tm_sec = readb(&priv->reg->sec);
tm->tm_min = readb(&priv->reg->min);
tm->tm_hour = readb(&priv->reg->hour);
tm->tm_mday = readb(&priv->reg->date);
tm->tm_mon = readb(&priv->reg->month);
tm->tm_year = readb(&priv->reg->year);
writeb(control, &priv->reg->control);
spin_unlock_irq(&priv->lock);
tm->tm_sec = bcd2bin(tm->tm_sec);
tm->tm_min = bcd2bin(tm->tm_min);
tm->tm_hour = bcd2bin(tm->tm_hour);
tm->tm_mday = bcd2bin(tm->tm_mday);
tm->tm_mon = bcd2bin(tm->tm_mon);
tm->tm_year = bcd2bin(tm->tm_year);
/*
* Account for differences between how the RTC uses the values
* and how they are defined in a struct rtc_time;
*/
tm->tm_year += 70;
if (tm->tm_year <= 69)
tm->tm_year += 100;
tm->tm_mon
return 0;
}
static int m48t35_set_time(struct device *dev, struct rtc_time *tm)
{
struct m48t35_priv *priv = dev_get_drvdata(dev);
unsigned char mon, day, hrs, min, sec;
unsigned int yrs;
u8 control;
yrs = tm->tm_year + 1900;
mon = tm->tm_mon + 1; /* tm_mon starts at zero */
day = tm->tm_mday;
hrs = tm->tm_hour;
min = tm->tm_min;
sec = tm->tm_sec;
if (yrs < 1970)
return -EINVAL;
yrs -= 1970;
if (yrs > 255) /* They are unsigned */
return -EINVAL;
if (yrs > 169)
return -EINVAL;
if (yrs >= 100)
yrs -= 100;
sec = bin2bcd(sec);
min = bin2bcd(min);
hrs = bin2bcd(hrs);
day = bin2bcd(day);
mon = bin2bcd(mon);
yrs = bin2bcd(yrs);
spin_lock_irq(&priv->lock);
control = readb(&priv->reg->control);
writeb(control | M48T35_RTC_SET, &priv->reg->control);
writeb(yrs, &priv->reg->year);
writeb(mon, &priv->reg->month);
writeb(day, &priv->reg->date);
writeb(hrs, &priv->reg->hour);
writeb(min, &priv->reg->min);
writeb(sec, &priv->reg->sec);
writeb(control, &priv->reg->control);
spin_unlock_irq(&priv->lock);
return 0;
}
static const struct rtc_class_ops m48t35_ops = {
.read_time = m48t35_read_time,
.set_time = m48t35_set_time,
};
static int m48t35_probe(struct platform_device *pdev)
{
struct resource *res;
struct m48t35_priv *priv;
res = <API key>(pdev, IORESOURCE_MEM, 0);
if (!res)
return -ENODEV;
priv = devm_kzalloc(&pdev->dev, sizeof(struct m48t35_priv), GFP_KERNEL);
if (!priv)
return -ENOMEM;
priv->size = resource_size(res);
/*
* kludge: remove the #ifndef after ioc3 resource
* conflicts are resolved
*/
#ifndef CONFIG_SGI_IP27
if (!<API key>(&pdev->dev, res->start, priv->size,
pdev->name))
return -EBUSY;
#endif
priv->baseaddr = res->start;
priv->reg = devm_ioremap(&pdev->dev, priv->baseaddr, priv->size);
if (!priv->reg)
return -ENOMEM;
spin_lock_init(&priv->lock);
<API key>(pdev, priv);
priv->rtc = <API key>(&pdev->dev, "m48t35",
&m48t35_ops, THIS_MODULE);
return PTR_ERR_OR_ZERO(priv->rtc);
}
static struct platform_driver <API key> = {
.driver = {
.name = "rtc-m48t35",
},
.probe = m48t35_probe,
};
<API key>(<API key>);
MODULE_AUTHOR("Thomas Bogendoerfer <tsbogend@alpha.franken.de>");
MODULE_DESCRIPTION("M48T35 RTC driver");
MODULE_LICENSE("GPL");
MODULE_ALIAS("platform:rtc-m48t35"); |
#include <_ansi.h>
#include <reent.h>
#include <stdio.h>
#include <unistd.h>
#include <stdarg.h>
int
_diprintf_r (struct _reent *ptr,
int fd,
const char *format, ...)
{
va_list ap;
int n;
va_start (ap, format);
n = _vdiprintf_r (ptr, fd, format, ap);
va_end (ap);
return n;
}
#ifndef _REENT_ONLY
int
diprintf (int fd,
const char *format, ...)
{
va_list ap;
int n;
va_start (ap, format);
n = _vdiprintf_r (_REENT, fd, format, ap);
va_end (ap);
return n;
}
#endif /* ! _REENT_ONLY */ |
unsigned char console_font_8x16[] = {
/* 0 0x00 '^@' */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
/* 1 0x01 '^A' */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x7e, /* 01111110 */
0x81, /* 10000001 */
0xa5, /* 10100101 */
0x81, /* 10000001 */
0x81, /* 10000001 */
0xbd, /* 10111101 */
0x99, /* 10011001 */
0x81, /* 10000001 */
0x81, /* 10000001 */
0x7e, /* 01111110 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
/* 2 0x02 '^B' */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x7e, /* 01111110 */
0xff, /* 11111111 */
0xdb, /* 11011011 */
0xff, /* 11111111 */
0xff, /* 11111111 */
0xc3, /* 11000011 */
0xe7, /* 11100111 */
0xff, /* 11111111 */
0xff, /* 11111111 */
0x7e, /* 01111110 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
/* 3 0x03 '^C' */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x6c, /* 01101100 */
0xfe, /* 11111110 */
0xfe, /* 11111110 */
0xfe, /* 11111110 */
0xfe, /* 11111110 */
0x7c, /* 01111100 */
0x38, /* 00111000 */
0x10, /* 00010000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
/* 4 0x04 '^D' */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x10, /* 00010000 */
0x38, /* 00111000 */
0x7c, /* 01111100 */
0xfe, /* 11111110 */
0x7c, /* 01111100 */
0x38, /* 00111000 */
0x10, /* 00010000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
/* 5 0x05 '^E' */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x18, /* 00011000 */
0x3c, /* 00111100 */
0x3c, /* 00111100 */
0xe7, /* 11100111 */
0xe7, /* 11100111 */
0xe7, /* 11100111 */
0x18, /* 00011000 */
0x18, /* 00011000 */
0x3c, /* 00111100 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
/* 6 0x06 '^F' */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x18, /* 00011000 */
0x3c, /* 00111100 */
0x7e, /* 01111110 */
0xff, /* 11111111 */
0xff, /* 11111111 */
0x7e, /* 01111110 */
0x18, /* 00011000 */
0x18, /* 00011000 */
0x3c, /* 00111100 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
/* 7 0x07 '^G' */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x18, /* 00011000 */
0x3c, /* 00111100 */
0x3c, /* 00111100 */
0x18, /* 00011000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
/* 8 0x08 '^H' */
0xff, /* 11111111 */
0xff, /* 11111111 */
0xff, /* 11111111 */
0xff, /* 11111111 */
0xff, /* 11111111 */
0xff, /* 11111111 */
0xe7, /* 11100111 */
0xc3, /* 11000011 */
0xc3, /* 11000011 */
0xe7, /* 11100111 */
0xff, /* 11111111 */
0xff, /* 11111111 */
0xff, /* 11111111 */
0xff, /* 11111111 */
0xff, /* 11111111 */
0xff, /* 11111111 */
/* 9 0x09 '^I' */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x3c, /* 00111100 */
0x66, /* 01100110 */
0x42, /* 01000010 */
0x42, /* 01000010 */
0x66, /* 01100110 */
0x3c, /* 00111100 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
/* 10 0x0a '^J' */
0xff, /* 11111111 */
0xff, /* 11111111 */
0xff, /* 11111111 */
0xff, /* 11111111 */
0xff, /* 11111111 */
0xc3, /* 11000011 */
0x99, /* 10011001 */
0xbd, /* 10111101 */
0xbd, /* 10111101 */
0x99, /* 10011001 */
0xc3, /* 11000011 */
0xff, /* 11111111 */
0xff, /* 11111111 */
0xff, /* 11111111 */
0xff, /* 11111111 */
0xff, /* 11111111 */
/* 11 0x0b '^K' */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x1e, /* 00011110 */
0x0e, /* 00001110 */
0x1a, /* 00011010 */
0x32, /* 00110010 */
0x78, /* 01111000 */
0xcc, /* 11001100 */
0xcc, /* 11001100 */
0xcc, /* 11001100 */
0xcc, /* 11001100 */
0x78, /* 01111000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
/* 12 0x0c '^L' */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x3c, /* 00111100 */
0x66, /* 01100110 */
0x66, /* 01100110 */
0x66, /* 01100110 */
0x66, /* 01100110 */
0x3c, /* 00111100 */
0x18, /* 00011000 */
0x7e, /* 01111110 */
0x18, /* 00011000 */
0x18, /* 00011000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
/* 13 0x0d '^M' */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x3f, /* 00111111 */
0x33, /* 00110011 */
0x3f, /* 00111111 */
0x30, /* 00110000 */
0x30, /* 00110000 */
0x30, /* 00110000 */
0x30, /* 00110000 */
0x70, /* 01110000 */
0xf0, /* 11110000 */
0xe0, /* 11100000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
/* 14 0x0e '^N' */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x7f, /* 01111111 */
0x63, /* 01100011 */
0x7f, /* 01111111 */
0x63, /* 01100011 */
0x63, /* 01100011 */
0x63, /* 01100011 */
0x63, /* 01100011 */
0x67, /* 01100111 */
0xe7, /* 11100111 */
0xe6, /* 11100110 */
0xc0, /* 11000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
/* 15 0x0f '^O' */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x18, /* 00011000 */
0x18, /* 00011000 */
0xdb, /* 11011011 */
0x3c, /* 00111100 */
0xe7, /* 11100111 */
0x3c, /* 00111100 */
0xdb, /* 11011011 */
0x18, /* 00011000 */
0x18, /* 00011000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
/* 16 0x10 '^P' */
0x00, /* 00000000 */
0x80, /* 10000000 */
0xc0, /* 11000000 */
0xe0, /* 11100000 */
0xf0, /* 11110000 */
0xf8, /* 11111000 */
0xfe, /* 11111110 */
0xf8, /* 11111000 */
0xf0, /* 11110000 */
0xe0, /* 11100000 */
0xc0, /* 11000000 */
0x80, /* 10000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
/* 17 0x11 '^Q' */
0x00, /* 00000000 */
0x02, /* 00000010 */
0x06, /* 00000110 */
0x0e, /* 00001110 */
0x1e, /* 00011110 */
0x3e, /* 00111110 */
0xfe, /* 11111110 */
0x3e, /* 00111110 */
0x1e, /* 00011110 */
0x0e, /* 00001110 */
0x06, /* 00000110 */
0x02, /* 00000010 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
/* 18 0x12 '^R' */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x18, /* 00011000 */
0x3c, /* 00111100 */
0x7e, /* 01111110 */
0x18, /* 00011000 */
0x18, /* 00011000 */
0x18, /* 00011000 */
0x7e, /* 01111110 */
0x3c, /* 00111100 */
0x18, /* 00011000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
/* 19 0x13 '^S' */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x66, /* 01100110 */
0x66, /* 01100110 */
0x66, /* 01100110 */
0x66, /* 01100110 */
0x66, /* 01100110 */
0x66, /* 01100110 */
0x66, /* 01100110 */
0x00, /* 00000000 */
0x66, /* 01100110 */
0x66, /* 01100110 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
/* 20 0x14 '^T' */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x7f, /* 01111111 */
0xdb, /* 11011011 */
0xdb, /* 11011011 */
0xdb, /* 11011011 */
0x7b, /* 01111011 */
0x1b, /* 00011011 */
0x1b, /* 00011011 */
0x1b, /* 00011011 */
0x1b, /* 00011011 */
0x1b, /* 00011011 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
/* 21 0x15 '^U' */
0x00, /* 00000000 */
0x7c, /* 01111100 */
0xc6, /* 11000110 */
0x60, /* 01100000 */
0x38, /* 00111000 */
0x6c, /* 01101100 */
0xc6, /* 11000110 */
0xc6, /* 11000110 */
0x6c, /* 01101100 */
0x38, /* 00111000 */
0x0c, /* 00001100 */
0xc6, /* 11000110 */
0x7c, /* 01111100 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
/* 22 0x16 '^V' */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0xfe, /* 11111110 */
0xfe, /* 11111110 */
0xfe, /* 11111110 */
0xfe, /* 11111110 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
/* 23 0x17 '^W' */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x18, /* 00011000 */
0x3c, /* 00111100 */
0x7e, /* 01111110 */
0x18, /* 00011000 */
0x18, /* 00011000 */
0x18, /* 00011000 */
0x7e, /* 01111110 */
0x3c, /* 00111100 */
0x18, /* 00011000 */
0x7e, /* 01111110 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
/* 24 0x18 '^X' */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x18, /* 00011000 */
0x3c, /* 00111100 */
0x7e, /* 01111110 */
0x18, /* 00011000 */
0x18, /* 00011000 */
0x18, /* 00011000 */
0x18, /* 00011000 */
0x18, /* 00011000 */
0x18, /* 00011000 */
0x18, /* 00011000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
/* 25 0x19 '^Y' */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x18, /* 00011000 */
0x18, /* 00011000 */
0x18, /* 00011000 */
0x18, /* 00011000 */
0x18, /* 00011000 */
0x18, /* 00011000 */
0x18, /* 00011000 */
0x7e, /* 01111110 */
0x3c, /* 00111100 */
0x18, /* 00011000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
/* 26 0x1a '^Z' */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x18, /* 00011000 */
0x0c, /* 00001100 */
0xfe, /* 11111110 */
0x0c, /* 00001100 */
0x18, /* 00011000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
/* 27 0x1b '^[' */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x30, /* 00110000 */
0x60, /* 01100000 */
0xfe, /* 11111110 */
0x60, /* 01100000 */
0x30, /* 00110000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
/* 28 0x1c '^\' */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0xc0, /* 11000000 */
0xc0, /* 11000000 */
0xc0, /* 11000000 */
0xfe, /* 11111110 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
/* 29 0x1d '^]' */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x28, /* 00101000 */
0x6c, /* 01101100 */
0xfe, /* 11111110 */
0x6c, /* 01101100 */
0x28, /* 00101000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
/* 30 0x1e '^^' */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x10, /* 00010000 */
0x38, /* 00111000 */
0x38, /* 00111000 */
0x7c, /* 01111100 */
0x7c, /* 01111100 */
0xfe, /* 11111110 */
0xfe, /* 11111110 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
/* 31 0x1f '^_' */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0xfe, /* 11111110 */
0xfe, /* 11111110 */
0x7c, /* 01111100 */
0x7c, /* 01111100 */
0x38, /* 00111000 */
0x38, /* 00111000 */
0x10, /* 00010000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
/* 32 0x20 ' ' */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
/* 33 0x21 '!' */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x18, /* 00011000 */
0x3c, /* 00111100 */
0x3c, /* 00111100 */
0x3c, /* 00111100 */
0x18, /* 00011000 */
0x18, /* 00011000 */
0x18, /* 00011000 */
0x00, /* 00000000 */
0x18, /* 00011000 */
0x18, /* 00011000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
/* 34 0x22 '"' */
0x00, /* 00000000 */
0x66, /* 01100110 */
0x66, /* 01100110 */
0x66, /* 01100110 */
0x24, /* 00100100 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
/* 35 0x23 '#' */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x6c, /* 01101100 */
0x6c, /* 01101100 */
0xfe, /* 11111110 */
0x6c, /* 01101100 */
0x6c, /* 01101100 */
0x6c, /* 01101100 */
0xfe, /* 11111110 */
0x6c, /* 01101100 */
0x6c, /* 01101100 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
/* 36 0x24 '$' */
0x18, /* 00011000 */
0x18, /* 00011000 */
0x7c, /* 01111100 */
0xc6, /* 11000110 */
0xc2, /* 11000010 */
0xc0, /* 11000000 */
0x7c, /* 01111100 */
0x06, /* 00000110 */
0x06, /* 00000110 */
0x86, /* 10000110 */
0xc6, /* 11000110 */
0x7c, /* 01111100 */
0x18, /* 00011000 */
0x18, /* 00011000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
/* 37 0x25 '%' */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0xc2, /* 11000010 */
0xc6, /* 11000110 */
0x0c, /* 00001100 */
0x18, /* 00011000 */
0x30, /* 00110000 */
0x60, /* 01100000 */
0xc6, /* 11000110 */
0x86, /* 10000110 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
/* 38 0x26 '&' */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x38, /* 00111000 */
0x6c, /* 01101100 */
0x6c, /* 01101100 */
0x38, /* 00111000 */
0x76, /* 01110110 */
0xdc, /* 11011100 */
0xcc, /* 11001100 */
0xcc, /* 11001100 */
0xcc, /* 11001100 */
0x76, /* 01110110 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */ |
// File: stedlgs.h
// Purpose: Preferences dialog
// Maintainer:
// Created: 2003-04-28
// Licence: wxWidgets licence
@file stedlgs.h
@brief Most of the dialogs for prefs, styles, langs, and others.
#ifndef _STEDLGS_H_
#define _STEDLGS_H_
#include <wx/filedlg.h>
class <API key> wxComboBox;
class <API key> wxSpinCtrl;
class <API key> wxSpinEvent;
class <API key> wxNotebook;
class <API key> wxNotebookEvent;
class <API key> wxListbook;
class <API key> wxImageList;
class <API key> wxListBox;
class <API key> wxStaticText;
class <API key> wxColourData;
class <API key> wxCheckBox;
class <API key> <API key>;
#ifndef <API key>
#define <API key> (<API key> | wxRESIZE_BORDER)
#endif
@class <API key>
@brief Data shared by multiple pages shown at once.
You should create this and send it to all the pages you create.
See how the <API key> handles it.
What pages to show in the <API key>.
enum STE_PrefPageTypes
{
<API key> = 0x0001, ///< View preferences.
<API key> = 0x0002, ///< Tabs and eol preferences.
<API key> = 0x0004, ///< Folding and wrapping preferences.
<API key> = 0x0008, ///< Printing preferences.
<API key> = 0x0010, ///< Loading and saving preferences.
<API key> = 0x0020, ///< Highlighting preferences.
<API key> = 0x0040, ///< Styles colouring.
<API key> = 0x0080, ///< Language selection.
<API key> = 0x00FF ///< Show all the preference pages.
};
Internal use ref data for the <API key> (always created)
class WXDLLIMPEXP_STEDIT <API key> : public wxObjectRefData
{
public:
<API key>() : m_languageId(0), m_editor(NULL), m_options(0) {}
wxSTEditorPrefs m_prefs;
wxSTEditorStyles m_styles;
wxSTEditorLangs m_langs;
int m_languageId;
wxSTEditor* m_editor;
int m_options;
};
class WXDLLIMPEXP_STEDIT <API key> : public wxObject
{
public:
<API key>();
<API key>(const <API key>& prefData) : wxObject()
{ Ref(prefData); }
<API key>(const wxSTEditorPrefs& prefs,
const wxSTEditorStyles& styles,
const wxSTEditorLangs& langs,
int m_languageId,
wxSTEditor* editor,
int options = <API key>);
wxSTEditorPrefs& GetPrefs() const;
wxSTEditorStyles& GetStyles() const;
wxSTEditorLangs& GetLangs() const;
The language selection for the "current" editor.
int GetLanguageId() const;
void SetLanguageId(int lang_id);
Get the "current" editor to update the languange selection for.
wxSTEditor* GetEditor() const;
void SetEditor(wxSTEditor* editor);
Get the options this was created with, enum STE_PrefPageTypes.
int GetOptions() const;
bool HasOption(int option) const { return (GetOptions() & option) != 0; }
void SetOptions(int options);
// operators
<API key>& operator = (const <API key>& other)
{
if ( (*this) != other )
Ref(other);
return *this;
}
bool operator == (const <API key>& other) const
{ return m_refData == other.m_refData; }
bool operator != (const <API key>& other) const
{ return m_refData != other.m_refData; }
};
@class <API key>
@brief Base class for prefs/styles/langs pages.
It has some generic functions that map from Ok, Apply, Reset buttons.
The data to be manipulated is GetPrefData(), the original is GetEditorPrefData().
When Apply is called, the GetPrefData() is pushed into the GetEditorPrefData().
class WXDLLIMPEXP_STEDIT <API key> : public wxPanel
{
public:
<API key>( const <API key>& editorPrefData,
const <API key>& prefData,
wxWindow *parent,
wxWindowID winid = wxID_ANY )
: wxPanel(parent, winid),
m_editorPrefData(editorPrefData),
m_prefData(prefData) {}
virtual ~<API key>() {}
virtual void GetControlValues() = 0; ///< Set pref values from GUI values.
virtual void SetControlValues() = 0; ///< Set GUI values from pref values.
virtual void Apply() = 0; ///< Apply values from GUI to prefs.
virtual void Reset() = 0; ///< Reset GUI values to pref defaults.
virtual bool IsModified() { return true; } ///< Is it currently modified.
Get the pref data that will be modified by the GUI.
<API key> GetPrefData() const { return m_prefData; }
Get the original pref data that was used to init with.
Typically when Apply is called, the GetPrefData() is pushed onto the
GetEditorPrefData() setting the values for the editor.
<API key> GetEditorPrefData() const { return m_editorPrefData; }
// implementation
void OnApply(wxCommandEvent& ) { Apply(); } // wxID_APPLY, wxID_OK
void OnReset(wxCommandEvent& ) { Reset(); } // wxID_RESET
protected:
<API key> m_editorPrefData;
<API key> m_prefData;
private:
<API key>(<API key>);
DECLARE_EVENT_TABLE();
};
@class <API key>
@brief Blank page that maps control types to enum STE_PrefType.
GetValue/SetValue is called on the control after determining type.
wxCheckBox = bool, wxSpinCtrl = int, wxComboBox/wxChoice/wxListBox = int
class WXDLLIMPEXP_STEDIT <API key> : public <API key>
{
public:
<API key>( const <API key>& editorPrefData,
const <API key>& prefData,
wxWindow *parent,
wxWindowID winid = wxID_ANY );
virtual ~<API key>() {}
virtual void GetControlValues();
virtual void SetControlValues();
virtual void Apply();
virtual void Reset();
virtual bool IsModified();
// implementation
wxArrayInt m_prefsToIds; // map GUI window IDs to enum STE_PrefType
private:
<API key>(<API key>);
DECLARE_EVENT_TABLE();
};
@class <API key>
@brief Adjust all the styles, including gui.
class WXDLLIMPEXP_STEDIT <API key> : public <API key>
{
public:
<API key>( const <API key>& editorPrefData,
const <API key>& prefData,
wxWindow *parent,
wxWindowID winid = wxID_ANY );
virtual ~<API key>();
virtual void GetControlValues();
virtual void SetControlValues();
virtual void Apply();
virtual void Reset();
virtual bool IsModified();
// implementation
void FillStyleEditor(wxSTEditor* editor);
void SetupEditor(wxSTEditor* editor);
void UpdateEditor(wxSTEditor* editor, wxArrayInt& lineArray);
void OnEvent(wxCommandEvent &event);
void OnSpinEvent(wxSpinEvent &event);
void OnPageChanged(wxNotebookEvent &event);
void OnMarginClick(wxStyledTextEvent &event);
wxArrayInt m_styleArray;
<API key> <API key>;
int m_style_max_len;
int m_current_style;
int m_last_language_ID;
wxColourData *m_colourData;
wxNotebook *m_styleNotebook;
wxSTEditor *m_colourEditor;
wxSTEditor *m_styleEditor;
wxSTEditor *m_helpEditor;
int <API key>;
int <API key>;
wxArrayInt m_colourLineArray;
wxArrayInt m_styleLineArray;
wxChoice *m_langChoice;
wxCheckBox *m_fontCheckBox;
wxButton *m_fontButton;
wxChoice *m_fontChoice;
wxCheckBox *m_fontSizeCheckBox;
wxSpinCtrl *m_fontSizeSpin;
wxCheckBox *m_attribCheckBox;
wxCheckBox *m_boldCheckBox;
wxCheckBox *m_italicsCheckBox;
wxCheckBox *m_underlineCheckBox;
wxCheckBox *m_eolFillCheckBox;
wxCheckBox *m_fontForeCheckBox;
wxButton *m_fontForeButton;
wxCheckBox *m_fontBackCheckBox;
wxButton *m_fontBackButton;
static wxString sm_helpString; // the text to show in the help editor
private:
void Init();
<API key>(<API key>);
DECLARE_EVENT_TABLE();
};
@class <API key>
@brief Show user languages.
class WXDLLIMPEXP_STEDIT <API key> : public <API key>
{
public:
<API key>( const <API key>& editorPrefData,
const <API key>& prefData,
wxWindow *parent,
wxWindowID winid = wxID_ANY );
virtual ~<API key>() {}
virtual void GetControlValues();
virtual void SetControlValues();
virtual void Apply();
virtual void Reset();
virtual bool IsModified();
// implementation
void OnChoice(wxCommandEvent &event);
void OnMarginClick(wxStyledTextEvent &event);
void SetStylesChoice();
void SetKeywordTextCtrl();
wxChoice* m_languageChoice;
wxTextCtrl* <API key>;
wxNotebook* m_notebook;
wxChoice* m_styleChoice;
wxSTEditor* m_styleEditor;
wxChoice* m_keywordsChoice;
wxTextCtrl* m_keywordsTextCtrl;
wxTextCtrl* <API key>;
wxSTEditor* m_helpEditor;
int <API key>;
int m_current_lang;
int m_current_style_n;
int m_keyword_n;
size_t <API key>;
wxArrayInt m_usedLangs;
static wxString sm_helpString; // the text to show in the help editor
private:
void Init();
<API key>(<API key>);
DECLARE_EVENT_TABLE();
};
@class <API key>
@brief A dialog to show notebook pages for the prefs, styles, langs.
They can be !IsOk() which will not make that page shown, but at least one must be valid.
If the parent is derived from a wxSTEditor then you can change the
language of the editor.
The Apply/Ok button updates all editors attached to the prefs/styles/langs.
class WXDLLIMPEXP_STEDIT <API key> : public wxDialog
{
public:
<API key>() : wxDialog() { Init(); }
<API key>( const <API key>& editorPrefData,
wxWindow *parent, wxWindowID win_id = wxID_ANY,
long style = <API key>,
const wxString& name = wxT("<API key>")) : wxDialog()
{
Init();
Create(editorPrefData, parent, win_id, style, name);
}
bool Create( const <API key>& editorPrefData,
wxWindow *parent, wxWindowID win_id = wxID_ANY,
long style = <API key>,
const wxString& name = wxT("<API key>"));
virtual ~<API key>();
Get the data that they set
<API key> GetPrefData() const { return m_prefData; }
Get the data originally sent in
<API key> GetEditorPrefData() const { return m_editorPrefData; }
// implementation
void OnApply(wxCommandEvent& event);
void OnCancel(wxCommandEvent& event);
void OnOk(wxCommandEvent& event);
void OnReset(wxCommandEvent& event);
void <API key>(wxNotebookEvent& event);
void OnUpdateUIApply(wxUpdateUIEvent& event);
private:
static int ms_currentpage;
wxListbook *m_noteBook;
wxImageList *m_imageList;
<API key> m_prefData; // local copy to modify
<API key> m_editorPrefData; // editor's original unmodified copy
<API key> m_rGuard_inapply;
private:
void Init();
DECLARE_EVENT_TABLE()
<API key>(<API key>)
};
@class <API key>
@brief Display info about editor session.
File name, size, modified time, language, # lines/chars/words/tabs, LF type.
class WXDLLIMPEXP_STEDIT <API key> : public wxDialog
{
public:
<API key>(wxSTEditor* editor);
bool Create(wxWindow* parent,
const wxString& title,
long style = <API key>);
virtual bool <API key>();
bool IsEditable() const { return m_editor->IsEditable(); }
private:
wxSTEditor* m_editor;
int m_encoding;
bool m_bom;
void <API key>(wxUpdateUIEvent&);
void OnUpdateBomCheckBox(wxUpdateUIEvent&);
DECLARE_EVENT_TABLE()
<API key>(<API key>);
};
@class <API key>
@brief Dialog to manage opened windows in notebook.
The user can activate, save, close notebook pages.
The dialog is shown modal and closes itself.
class WXDLLIMPEXP_STEDIT <API key> : public wxDialog
{
public:
<API key>(wxSTEditorNotebook *notebook,
const wxString& title,
long style = <API key>);
// implementation
void UpdateListBox();
void UpdateButtons();
void OnListBox(wxCommandEvent& event);
void OnButton(wxCommandEvent& event);
wxSTEditorNotebook* m_notebook;
wxListBox* m_listBox;
private:
DECLARE_EVENT_TABLE()
<API key>(<API key>);
};
@class <API key>
@brief Dialog to manage bookmarks.
The user can goto or delete bookmarks.
The dialog is shown modal and closes itself.
class WXDLLIMPEXP_STEDIT <API key> : public wxDialog
{
public:
<API key>(wxWindow *win,
const wxString& title = _("Bookmarks"),
long style = <API key>);
virtual ~<API key>();
// implementation
bool GetItemInfo(const wxTreeItemId& id, long& notebook_page, long& bookmark_line);
void UpdateTreeCtrl();
void UpdateButtons();
void OnTreeCtrl(wxTreeEvent& event);
void OnButton(wxCommandEvent& event);
wxSTEditorNotebook* m_notebook;
wxSTEditor* m_editor;
wxTreeCtrl* m_treeCtrl;
static wxPoint ms_dialogPosition;
static wxSize ms_dialogSize;
private:
DECLARE_EVENT_TABLE()
<API key>(<API key>);
};
@class <API key>
@brief Provides a UI for the wxSTEditor::InsertTextAtCol() function.
class WXDLLIMPEXP_STEDIT <API key>: public wxDialog
{
public:
Create the dialog and call ShowModal(), the editor will be updated
if the user clicks Ok and wxID_OK is returned from ShowModal().
<API key>(wxSTEditor* editor,
long style = <API key>);
virtual ~<API key>();
// implementation
Setup this dialog from the editor
bool InitFromEditor();
If the user pressed wxID_OK, call this to replace the
text in the editor with the settings in the dialog.
Make sure that the selection in the editor has NOT changed
since the call to InitFromEditor(editor).
bool InsertIntoEditor();
How to insert text into an editor.
enum STE_InsertText_Type
{
<API key>,
<API key>,
<API key>,
<API key>
};
Get the column to insert the text at.
int GetColumn() const { return m_column-1; }
Set the text to display to the user to be formatted.
void SetText(const wxString& text);
Get the text in the editor currently (as user left it).
wxString GetText();
Format the text that you sent in with SetText using values in the gui.
void FormatText();
void OnButton(wxCommandEvent& event);
void OnMenu(wxCommandEvent& event);
void OnRadioButton(wxCommandEvent& event);
void OnIdle(wxIdleEvent& event);
void OnText(wxCommandEvent& event);
void UpdateControls();
STE_InsertText_Type RadioIdToType( wxWindowID id ) const;
wxWindowID GetSelectedRadioId() const;
wxSTEditor* m_editor;
STE_TextPos m_editor_sel_start;
STE_TextPos m_editor_sel_end;
wxComboBox* m_prependCombo;
wxComboBox* m_appendCombo;
wxStaticText* m_prependText;
wxMenu* m_insertMenu;
wxSTEditor* m_testEditor;
STE_InsertText_Type m_insert_type;
int m_column;
wxString m_prependString;
wxString m_appendString;
wxTextPos <API key>;
wxTextPos m_append_insert_pos;
wxString m_initText;
bool m_created;
static int sm_radioID; // last set radio button Window ID
static int sm_spinValue; // last set column for spinctrl
static wxArrayString sm_prependValues; // last values to prepend/append
static wxArrayString sm_appendValues;
private:
void Init();
DECLARE_EVENT_TABLE()
<API key>(<API key>);
};
@class <API key>
@brief Insert text at specified column.
class WXDLLIMPEXP_STEDIT <API key> : public wxDialog
{
public:
<API key>() : wxDialog() { Init(); }
<API key>(wxWindow* parent,
long style = <API key>|wxMAXIMIZE_BOX) : wxDialog()
{
Init();
Create(parent, style);
}
bool Create(wxWindow* parent,
long style = <API key>|wxMAXIMIZE_BOX);
Set the text to display to the user to be formatted.
void SetText(const wxString& text);
Get the text in the editor currently (as user left it).
wxString GetText();
Format the text that you sent in with SetText() using values in the gui.
void FormatText();
wxSTEditor* GetTestEditor() { return m_testEditor; }
// implementation
void OnButton(wxCommandEvent& event);
void OnText(wxCommandEvent& event);
wxComboBox* m_splitBeforeCombo;
wxComboBox* m_splitAfterCombo;
wxComboBox* m_preserveCombo;
wxComboBox* m_ignoreCombo;
wxCheckBox* m_updateCheckBox;
wxSTEditor* m_testEditor;
wxString m_initText;
static wxArrayString sm_splitBeforeArray; // remember previous settings
static wxArrayString sm_splitAfterArray;
static wxArrayString sm_preserveArray;
static wxArrayString sm_ignoreArray;
private:
void Init();
DECLARE_EVENT_TABLE()
<API key>(<API key>);
};
@class <API key>
@brief A specialized wxFileDialog for the wxSTEditor.
#if (wxVERSION_NUMBER >= 2903)
//#define STE_FILEOPENEXTRA 1 // trac.wxwidgets.org/ticket/13611
#define STE_FILEOPENEXTRA 0
#else
#define STE_FILEOPENEXTRA 0
#endif
class WXDLLIMPEXP_STEDIT <API key> : public wxFileDialog
{
public:
<API key>(wxWindow* parent,
const wxString& message = <API key>,
const wxString& defaultDir = wxEmptyString,
const wxString& wildCard = <API key>,
long style = wxFD_OPEN | <API key>);
virtual int ShowModal();
static wxString m_encoding;
static bool m_file_bom; // wxFD_SAVE only
private:
DECLARE_CLASS(<API key>)
};
<API key>
@brief A specialized <API key> for the wxSTEditor that
understands wxOK|wxCANCEL|wxAPPLY.
WXDLLIMPEXP_STEDIT <API key>* <API key>(wxWindow* parent, long flags);
<API key>
@brief A specialized wxAboutBox for the wxSTEditor.
WXDLLIMPEXP_STEDIT void <API key>(wxWindow* parent);
#endif // _STEDLGS_H_ |
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <malloc.h>
#include <ogcsys.h>
#include <gccore.h>
#include <usb.h>
#include "hci.h"
#include "btmemb.h"
#include "physbusif.h"
#define STACKSIZE 32768
#define NUM_ACL_BUFS 30
#define NUM_CTRL_BUFS 45
#define ACL_BUF_SIZE 1800
#define CTRL_BUF_SIZE 660
#define ROUNDUP32(v) (((u32)(v)+0x1f)&~0x1f)
#define ROUNDDOWN32(v) (((u32)(v)-0x1f)&~0x1f)
struct usbtxbuf
{
u32 txsize;
void *rpData;
};
static u32 __ntd_ohci = 0;
static u32 __ntd_ohci_initflag = 0;
static u16 __ntd_vid = 0;
static u16 __ntd_pid = 0;
static u32 <API key> = 0;
static s32 __ntd_usb_fd = -1;
static u32 __wait4hci = 1;
static struct _usb_p __usbdev;
static struct memb_blks ctrlbufs;
static struct memb_blks aclbufs;
static u8 __ppc_btstack1[STACKSIZE] ATTRIBUTE_ALIGN(8);
static u8 __ppc_btstack2[STACKSIZE] ATTRIBUTE_ALIGN(8);
static s32 __issue_bulkread();
static s32 __issue_intrread();
extern u32 __IPC_ClntInit();
static s32 __usb_closeCB(s32 result,void *usrdata)
{
__usbdev.fd = -1;
return result;
}
static s32 __writectrlmsgCB(s32 result,void *usrdata)
{
if(usrdata!=NULL) btmemb_free(&ctrlbufs,usrdata);
return result;
}
static s32 __writebulkmsgCB(s32 result,void *usrdata)
{
if(usrdata!=NULL) btmemb_free(&aclbufs,usrdata);
return result;
}
static s32 __readbulkdataCB(s32 result,void *usrdata)
{
u8 *ptr;
u32 len;
struct pbuf *p,*q;
struct usbtxbuf *buf = (struct usbtxbuf*)usrdata;
if(__usbdev.openstate!=0x0002) return 0;
if(result>0) {
len = result;
p = btpbuf_alloc(PBUF_RAW,len,PBUF_POOL);
if(p!=NULL) {
ptr = buf->rpData;
for(q=p;q!=NULL && len>0;q=q->next) {
memcpy(q->payload,ptr,q->len);
ptr += q->len;
len -= q->len;
}
SYS_SwitchFiber((u32)p,0,0,0,(u32)hci_acldata_handler,(u32)(&__ppc_btstack2[STACKSIZE]));
btpbuf_free(p);
} else
ERROR("__readbulkdataCB: Could not allocate memory for pbuf.\n");
}
btmemb_free(&aclbufs,buf);
return __issue_bulkread();
}
static s32 __readintrdataCB(s32 result,void *usrdata)
{
u8 *ptr;
u32 len;
struct pbuf *p,*q;
struct usbtxbuf *buf = (struct usbtxbuf*)usrdata;
if(__usbdev.openstate!=0x0002) return 0;
if(result>0) {
len = result;
p = btpbuf_alloc(PBUF_RAW,len,PBUF_POOL);
if(p!=NULL) {
ptr = buf->rpData;
for(q=p;q!=NULL && len>0;q=q->next) {
memcpy(q->payload,ptr,q->len);
ptr += q->len;
len -= q->len;
}
SYS_SwitchFiber((u32)p,0,0,0,(u32)hci_event_handler,(u32)(&__ppc_btstack1[STACKSIZE]));
btpbuf_free(p);
} else
ERROR("__readintrdataCB: Could not allocate memory for pbuf.\n");
}
btmemb_free(&ctrlbufs,buf);
return __issue_intrread();
}
static s32 __issue_intrread()
{
s32 ret;
u32 len;
u8 *ptr;
struct usbtxbuf *buf;
if(__usbdev.openstate!=0x0002) return IPC_OK;
buf = (struct usbtxbuf*)btmemb_alloc(&ctrlbufs);
if(buf!=NULL) {
ptr = (u8*)((u32)buf + sizeof(struct usbtxbuf));
buf->rpData = (void*)ROUNDUP32(ptr);
len = (ctrlbufs.size - ((u32)buf->rpData - (u32)buf));
buf->txsize = ROUNDDOWN32(len);
ret = <API key>(__usbdev.fd,__usbdev.hci_evt,buf->txsize,buf->rpData,__readintrdataCB,buf);
} else
ret = IPC_ENOMEM;
return ret;
}
static s32 __issue_bulkread()
{
s32 ret;
u32 len;
u8 *ptr;
struct usbtxbuf *buf;
if(__usbdev.openstate!=0x0002) return IPC_OK;
buf = (struct usbtxbuf*)btmemb_alloc(&aclbufs);
if(buf!=NULL) {
ptr = (u8*)((u32)buf + sizeof(struct usbtxbuf));
buf->rpData = (void*)ROUNDUP32(ptr);
len = (aclbufs.size - ((u32)buf->rpData - (u32)buf));
buf->txsize = ROUNDDOWN32(len);
ret = USB_ReadBlkMsgAsync(__usbdev.fd,__usbdev.acl_in,buf->txsize,buf->rpData,__readbulkdataCB,buf);
} else
ret = IPC_ENOMEM;
return ret;
}
static s32 __initUsbIOBuffer(struct memb_blks *blk,u32 buf_size,u32 num_bufs)
{
u32 len;
u8 *ptr = NULL;
len = ((MEM_ALIGN_SIZE(buf_size)+sizeof(u32))*num_bufs);
ptr = (u8*)ROUNDDOWN32(((u32)SYS_GetArena2Hi() - len));
if((u32)ptr<(u32)SYS_GetArena2Lo()) return -4;
SYS_SetArena2Hi(ptr);
blk->size = buf_size;
blk->num = num_bufs;
blk->mem = ptr;
btmemb_init(blk);
return 0;
}
static s32 __getDeviceId(u16 vid,u16 pid)
{
s32 ret = 0;
if(__ntd_ohci_initflag==0x0001) {
if(__ntd_ohci==0x0000)
ret = USB_OpenDevice(USB_OH0_DEVICE_ID,vid,pid,&__usbdev.fd);
else if(__ntd_ohci==0x0001)
ret = USB_OpenDevice(USB_OH1_DEVICE_ID,vid,pid,&__usbdev.fd);
} else
ret = USB_OpenDevice(USB_OH1_DEVICE_ID,vid,pid,&__usbdev.fd);
//printf("__getDeviceId(%04x,%04x,%d)\n",vid,pid,__usbdev.fd);
if(ret==0) __ntd_usb_fd = __usbdev.fd;
return ret;
}
static s32 __usb_register(pbcallback cb)
{
s32 ret = 0;
memset(&__usbdev,0,sizeof(struct _usb_p));
__usbdev.openstate = 5;
ret = __IPC_ClntInit();
if(ret<0) return ret;
ret = USB_Initialize();
if(ret<0) return ret;
__usbdev.fd = -1;
__usbdev.unregcb = cb;
if(<API key>) {
__usbdev.vid = __ntd_vid;
__usbdev.pid = __ntd_pid;
} else {
__usbdev.vid = 0x057E;
__usbdev.pid = 0x0305;
}
ret = __getDeviceId(__usbdev.vid,__usbdev.pid);
if(ret<0) return ret;
__usbdev.acl_out = 0x02;
__usbdev.acl_in = 0x82;
__usbdev.hci_evt = 0x81;
__usbdev.hci_ctrl = 0x00;
__initUsbIOBuffer(&ctrlbufs,CTRL_BUF_SIZE,NUM_CTRL_BUFS);
__initUsbIOBuffer(&aclbufs,ACL_BUF_SIZE,NUM_ACL_BUFS);
__usbdev.openstate = 4;
__wait4hci = 1;
return ret;
}
static s32 __usb_open(pbcallback cb)
{
if(__usbdev.openstate!=0x0004) return -1;
__usbdev.closecb = cb;
__usbdev.openstate = 2;
__issue_intrread();
__issue_bulkread();
__wait4hci = 0;
return 0;
}
void __ntd_set_ohci(u8 hci)
{
if(hci==0x0000) {
__ntd_ohci = 0;
__ntd_ohci_initflag = 1;
} else if(hci==0x0001) {
__ntd_ohci = 1;
__ntd_ohci_initflag = 1;
}
}
void __ntd_set_pid_vid(u16 vid,u16 pid)
{
__ntd_vid = vid;
__ntd_pid = pid;
<API key> = 1;
}
void physbusif_init()
{
s32 ret;
ret = __usb_register(NULL);
if(ret<0) return;
__usb_open(NULL);
}
void physbusif_close()
{
if(__usbdev.openstate!=0x0002) return;
__usbdev.openstate = 4;
__wait4hci = 1;
}
void physbusif_shutdown()
{
if(__usbdev.openstate!=0x0004) return;
<API key>(&__usbdev.fd,__usb_closeCB,NULL);
}
void physbusif_reset_all()
{
return;
}
void physbusif_output(struct pbuf *p,u16_t len)
{
u32 pos;
u8 *ptr;
struct pbuf *q;
struct memb_blks *mblks;
struct usbtxbuf *blkbuf;
if(__usbdev.openstate!=0x0002) return;
if(((u8*)p->payload)[0]==<API key>) mblks = &ctrlbufs;
else if(((u8*)p->payload)[0]==HCI_ACL_DATA_PACKET) mblks = &aclbufs;
else return;
blkbuf = btmemb_alloc(mblks);
if(blkbuf!=NULL) {
blkbuf->txsize = --len;
blkbuf->rpData = (void*)ROUNDUP32(((u32)blkbuf+sizeof(struct usbtxbuf)));
ptr = blkbuf->rpData;
for(q=p,pos=1;q!=NULL && len>0;q=q->next,pos=0) {
memcpy(ptr,q->payload+pos,(q->len-pos));
ptr += (q->len-pos);
len -= (q->len-pos);
}
if(((u8*)p->payload)[0]==<API key>) {
<API key>(__usbdev.fd,0x20,0,0,0,blkbuf->txsize,blkbuf->rpData,__writectrlmsgCB,blkbuf);
} else if(((u8*)p->payload)[0]==HCI_ACL_DATA_PACKET) {
<API key>(__usbdev.fd,__usbdev.acl_out,blkbuf->txsize,blkbuf->rpData,__writebulkmsgCB,blkbuf);
}
}
} |
/* set of parsable strings -- ALL LOWER CASE */
static const char *set[] = {
"get ",
"post ",
"options ",
"host:",
"connection:",
"upgrade:",
"origin:",
"sec-websocket-draft:",
"\x0d\x0a",
"<API key>:",
"sec-websocket-key1:",
"sec-websocket-key2:",
"<API key>:",
"<API key>:",
"sec-websocket-nonce:",
"http/1.1 ",
"http2-settings:",
"accept:",
"<API key>:",
"if-modified-since:",
"if-none-match:",
"accept-encoding:",
"accept-language:",
"pragma:",
"cache-control:",
"authorization:",
"cookie:",
"content-length:",
"content-type:",
"date:",
"range:",
"referer:",
"sec-websocket-key:",
"<API key>:",
"<API key>:",
":authority:",
":method:",
":path:",
":scheme:",
":status:",
"accept-charset:",
"accept-ranges:",
"<API key>:",
"age:",
"allow:",
"content-disposition:",
"content-encoding:",
"content-language:",
"content-location:",
"content-range:",
"etag:",
"expect:",
"expires:",
"from:",
"if-match:",
"if-range:",
"if-unmodified-since:",
"last-modified:",
"link:",
"location:",
"max-forwards:",
"proxy-authenticate:",
"proxy-authorization:",
"refresh:",
"retry-after:",
"server:",
"set-cookie:",
"<API key>:",
"transfer-encoding:",
"user-agent:",
"vary:",
"via:",
"www-authenticate:",
"proxy ",
"patch",
"put",
"delete",
"", /* not matchable */
}; |
// The LLVM Compiler Infrastructure
// This file is distributed under the University of Illinois Open Source
// This file implements LoopPass and LPPassManager. All loop optimization
// and transformation passes are derived from LoopPass. LPPassManager is
// responsible for managing LoopPasses.
#include "llvm/Analysis/LoopPass.h"
#include "llvm/Analysis/LoopPassManager.h"
#include "llvm/IR/IRPrintingPasses.h"
#include "llvm/IR/LLVMContext.h"
#include "llvm/IR/OptBisect.h"
#include "llvm/IR/PassManager.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/Timer.h"
#include "llvm/Support/raw_ostream.h"
using namespace llvm;
#define DEBUG_TYPE "loop-pass-manager"
namespace {
PrintLoopPass - Print a Function corresponding to a Loop.
class <API key> : public LoopPass {
PrintLoopPass P;
public:
static char ID;
<API key>() : LoopPass(ID) {}
<API key>(raw_ostream &OS, const std::string &Banner)
: LoopPass(ID), P(OS, Banner) {}
void getAnalysisUsage(AnalysisUsage &AU) const override {
AU.setPreservesAll();
}
bool runOnLoop(Loop *L, LPPassManager &) override {
auto BBI = find_if(L->blocks().begin(), L->blocks().end(),
[](BasicBlock *BB) { return BB; });
if (BBI != L->blocks().end() &&
<API key>((*BBI)->getParent()->getName())) {
AnalysisManager<Loop> DummyLAM;
P.run(*L, DummyLAM);
}
return false;
}
};
char <API key>::ID = 0;
}
// LPPassManager
char LPPassManager::ID = 0;
LPPassManager::LPPassManager()
: FunctionPass(ID), PMDataManager() {
LI = nullptr;
CurrentLoop = nullptr;
}
// Inset loop into loop nest (LoopInfo) and loop queue (LQ).
Loop &LPPassManager::addLoop(Loop *ParentLoop) {
// Create a new loop. LI will take ownership.
Loop *L = new Loop();
// Insert into the loop nest and the loop queue.
if (!ParentLoop) {
// This is the top level loop.
LI->addTopLevelLoop(L);
LQ.push_front(L);
return *L;
}
ParentLoop->addChildLoop(L);
// Insert L into the loop queue after the parent loop.
for (auto I = LQ.begin(), E = LQ.end(); I != E; ++I) {
if (*I == L->getParentLoop()) {
// deque does not support insert after.
++I;
LQ.insert(I, 1, L);
break;
}
}
return *L;
}
<API key> - Invoke <API key> hook for
all loop passes.
void LPPassManager::<API key>(BasicBlock *From,
BasicBlock *To, Loop *L) {
for (unsigned Index = 0; Index < <API key>(); ++Index) {
LoopPass *LP = getContainedPass(Index);
LP-><API key>(From, To, L);
}
}
<API key> - Invoke deleteAnalysisValue hook for all passes.
void LPPassManager::<API key>(Value *V, Loop *L) {
if (BasicBlock *BB = dyn_cast<BasicBlock>(V)) {
for (Instruction &I : *BB) {
<API key>(&I, L);
}
}
for (unsigned Index = 0; Index < <API key>(); ++Index) {
LoopPass *LP = getContainedPass(Index);
LP->deleteAnalysisValue(V, L);
}
}
Invoke deleteAnalysisLoop hook for all passes.
void LPPassManager::<API key>(Loop *L) {
for (unsigned Index = 0; Index < <API key>(); ++Index) {
LoopPass *LP = getContainedPass(Index);
LP->deleteAnalysisLoop(L);
}
}
// Recurse through all subloops and all loops into LQ.
static void addLoopIntoQueue(Loop *L, std::deque<Loop *> &LQ) {
LQ.push_back(L);
for (Loop::reverse_iterator I = L->rbegin(), E = L->rend(); I != E; ++I)
addLoopIntoQueue(*I, LQ);
}
Pass Manager itself does not invalidate any analysis info.
void LPPassManager::getAnalysisUsage(AnalysisUsage &Info) const {
// LPPassManager needs LoopInfo. In the long term LoopInfo class will
// become part of LPPassManager.
Info.addRequired<LoopInfoWrapperPass>();
Info.setPreservesAll();
}
run - Execute all of the passes scheduled for execution. Keep track of
whether any of the passes modifies the function, and if so, return true.
bool LPPassManager::runOnFunction(Function &F) {
auto &LIWP = getAnalysis<LoopInfoWrapperPass>();
LI = &LIWP.getLoopInfo();
bool Changed = false;
// Collect inherited analysis from Module level pass manager.
<API key>(TPM->activeStack);
// Populate the loop queue in reverse program order. There is no clear need to
// process sibling loops in either forward or reverse order. There may be some
// advantage in deleting uses in a later loop before optimizing the
// definitions in an earlier loop. If we find a clear reason to process in
// forward order, then a forward variant of LoopPassManager should be created.
// Note that LoopInfo::iterator visits loops in reverse program
// order. Here, reverse_iterator gives us a forward order, and the LoopQueue
// reverses the order a third time by popping from the back.
for (LoopInfo::reverse_iterator I = LI->rbegin(), E = LI->rend(); I != E; ++I)
addLoopIntoQueue(*I, LQ);
if (LQ.empty()) // No loops, skip calling finalizers
return false;
// Initialization
for (std::deque<Loop *>::const_iterator I = LQ.begin(), E = LQ.end();
I != E; ++I) {
Loop *L = *I;
for (unsigned Index = 0; Index < <API key>(); ++Index) {
LoopPass *P = getContainedPass(Index);
Changed |= P->doInitialization(L, *this);
}
}
// Walk Loops
while (!LQ.empty()) {
bool LoopWasDeleted = false;
CurrentLoop = LQ.back();
// Run all passes on the current Loop.
for (unsigned Index = 0; Index < <API key>(); ++Index) {
LoopPass *P = getContainedPass(Index);
dumpPassInfo(P, EXECUTION_MSG, ON_LOOP_MSG,
CurrentLoop->getHeader()->getName());
dumpRequiredSet(P);
<API key>(P);
{
<API key> X(P, *CurrentLoop->getHeader());
TimeRegion PassTimer(getPassTimer(P));
Changed |= P->runOnLoop(CurrentLoop, *this);
}
LoopWasDeleted = CurrentLoop->isInvalid();
if (Changed)
dumpPassInfo(P, MODIFICATION_MSG, ON_LOOP_MSG,
LoopWasDeleted ? "<deleted>"
: CurrentLoop->getHeader()->getName());
dumpPreservedSet(P);
if (LoopWasDeleted) {
// Notify passes that the loop is being deleted.
<API key>(CurrentLoop);
} else {
// Manually check that this loop is still healthy. This is done
// instead of relying on LoopInfo::verifyLoop since LoopInfo
// is a function pass and it's really expensive to verify every
// loop in the function every time. That level of checking can be
// enabled with the -verify-loop-info option.
{
TimeRegion PassTimer(getPassTimer(&LIWP));
CurrentLoop->verifyLoop();
}
// Then call the regular verifyAnalysis functions.
<API key>(P);
F.getContext().yield();
}
<API key>(P);
<API key>(P);
removeDeadPasses(P, LoopWasDeleted ? "<deleted>"
: CurrentLoop->getHeader()->getName(),
ON_LOOP_MSG);
if (LoopWasDeleted)
// Do not run other passes on this loop.
break;
}
// If the loop was deleted, release all the loop passes. This frees up
// some memory, and avoids trouble with the pass manager trying to call
// verifyAnalysis on them.
if (LoopWasDeleted) {
for (unsigned Index = 0; Index < <API key>(); ++Index) {
Pass *P = getContainedPass(Index);
freePass(P, "<deleted>", ON_LOOP_MSG);
}
}
// Pop the loop from queue after running all passes.
LQ.pop_back();
}
// Finalization
for (unsigned Index = 0; Index < <API key>(); ++Index) {
LoopPass *P = getContainedPass(Index);
Changed |= P->doFinalization();
}
return Changed;
}
Print passes managed by this manager
void LPPassManager::dumpPassStructure(unsigned Offset) {
errs().indent(Offset*2) << "Loop Pass Manager\n";
for (unsigned Index = 0; Index < <API key>(); ++Index) {
Pass *P = getContainedPass(Index);
P->dumpPassStructure(Offset + 1);
dumpLastUses(P, Offset+1);
}
}
// LoopPass
Pass *LoopPass::createPrinterPass(raw_ostream &O,
const std::string &Banner) const {
return new <API key>(O, Banner);
}
// Check if this pass is suitable for the current LPPassManager, if
// available. This pass P is not suitable for a LPPassManager if P
// is not preserving higher level analysis info used by other
// LPPassManager passes. In such case, pop LPPassManager from the
// stack. This will force assignPassManager() to create new
// LPPassManger as expected.
void LoopPass::preparePassManager(PMStack &PMS) {
// Find LPPassManager
while (!PMS.empty() &&
PMS.top()->getPassManagerType() > PMT_LoopPassManager)
PMS.pop();
// If this pass is destroying high level information that is used
// by other passes that are managed by LPM then do not insert
// this pass in current LPM. Use new LPPassManager.
if (PMS.top()->getPassManagerType() == PMT_LoopPassManager &&
!PMS.top()-><API key>(this))
PMS.pop();
}
Assign pass manager to manage this pass.
void LoopPass::assignPassManager(PMStack &PMS,
PassManagerType PreferredType) {
// Find LPPassManager
while (!PMS.empty() &&
PMS.top()->getPassManagerType() > PMT_LoopPassManager)
PMS.pop();
LPPassManager *LPPM;
if (PMS.top()->getPassManagerType() == PMT_LoopPassManager)
LPPM = (LPPassManager*)PMS.top();
else {
// Create new Loop Pass Manager if it does not exist.
assert (!PMS.empty() && "Unable to create Loop Pass Manager");
PMDataManager *PMD = PMS.top();
// [1] Create new Loop Pass Manager
LPPM = new LPPassManager();
LPPM-><API key>(PMS);
// [2] Set up new manager's top level manager
PMTopLevelManager *TPM = PMD->getTopLevelManager();
TPM-><API key>(LPPM);
// [3] Assign manager to manage this new manager. This may create
// and push new managers into PMS
Pass *P = LPPM->getAsPass();
TPM->schedulePass(P);
// [4] Push new manager into PMS
PMS.push(LPPM);
}
LPPM->add(this);
}
bool LoopPass::skipLoop(const Loop *L) const {
const Function *F = L->getHeader()->getParent();
if (!F)
return false;
// Check the opt bisect limit.
LLVMContext &Context = F->getContext();
if (!Context.getOptBisect().shouldRunPass(this, *L))
return true;
// Check for the OptimizeNone attribute.
if (F->hasFnAttribute(Attribute::OptimizeNone)) {
// FIXME: Report this to dbgs() only once per function.
DEBUG(dbgs() << "Skipping pass '" << getPassName()
<< "' in function " << F->getName() << "\n");
// FIXME: Delete loop from pass manager's queue?
return true;
}
return false;
} |
/* -*- indent-tabs-mode: nil -*- */
#include "proto/serializer.h"
#include <gflags/gflags.h>
#include <glog/logging.h>
#include <math.h>
#include <string>
#include "proto/ct.pb.h"
using ct::DigitallySigned;
using ct::<API key>;
using ct::<API key>;
using ct::LogEntry;
using ct::<API key>;
using ct::MerkleTreeLeaf;
using ct::PrecertChainEntry;
using ct::<API key>;
using ct::<API key>;
using ct::SthExtension;
using ct::SctExtension;
using ct::Version_IsValid;
using ct::X509ChainEntry;
using google::protobuf::RepeatedPtrField;
using std::function;
using std::string;
const size_t Serializer::kMaxSignatureLength = (1 << 16) - 1;
const size_t Serializer::kMaxV2ExtensionType = (1 << 16) - 1;
const size_t Serializer::<API key> = (1 << 16) - 2;
const size_t Serializer::<API key> = (1 << 16) - 1;
const size_t Serializer::<API key> = (1 << 16) - 1;
const size_t Serializer::kMaxSCTListLength = (1 << 16) - 1;
const size_t Serializer::<API key> = 2;
const size_t Serializer::<API key> = 1;
const size_t Serializer::<API key> = 1;
const size_t Serializer::<API key> = 1;
const size_t Serializer::<API key> = 1;
const size_t Serializer::kKeyIDLengthInBytes = 32;
const size_t Serializer::<API key> = 1;
const size_t Serializer::<API key> = 32;
const size_t Serializer::<API key> = 8;
DEFINE_bool(<API key>, false,
"Allow tests to reconfigure the serializer multiple times.");
// TODO(pphaneuf): This is just to avoid causing diff churn while
// refactoring. Functions for internal use only should be put together
// in an anonymous namespace.
SerializeResult <API key>(const DigitallySigned& sig);
SerializeResult <API key>(
const <API key>& extension);
namespace {
function<string(const ct::LogEntry&)> leaf_data;
function<SerializeResult(const ct::<API key>& sct,
const ct::LogEntry& entry, std::string* result)>
<API key>;
function<SerializeResult(const ct::<API key>& sct,
const ct::LogEntry& entry, std::string* result)>
<API key>;
function<SerializeResult(uint64_t timestamp, int64_t tree_size,
const std::string& root_hash, std::string* result)>
<API key>;
function<SerializeResult(uint64_t timestamp, int64_t tree_size,
const std::string& root_hash,
const <API key>& sth_extension,
const std::string& log_id, std::string* result)>
<API key>;
function<DeserializeResult(TLSDeserializer* d, ct::MerkleTreeLeaf* leaf)>
<API key>;
} // namespace
std::ostream& operator<<(std::ostream& stream, const SerializeResult& r) {
switch (r) {
case SerializeResult::OK:
return stream << "OK";
case SerializeResult::INVALID_ENTRY_TYPE:
return stream << "INVALID_ENTRY_TYPE";
case SerializeResult::EMPTY_CERTIFICATE:
return stream << "EMPTY_CERTIFICATE";
case SerializeResult::<API key>:
return stream << "<API key>";
case SerializeResult::<API key>:
return stream << "<API key>";
case SerializeResult::<API key>:
return stream << "<API key>";
case SerializeResult::<API key>:
return stream << "<API key>";
case SerializeResult::SIGNATURE_TOO_LONG:
return stream << "SIGNATURE_TOO_LONG";
case SerializeResult::INVALID_HASH_LENGTH:
return stream << "INVALID_HASH_LENGTH";
case SerializeResult::<API key>:
return stream << "<API key>";
case SerializeResult::UNSUPPORTED_VERSION:
return stream << "UNSUPPORTED_VERSION";
case SerializeResult::EXTENSIONS_TOO_LONG:
return stream << "EXTENSIONS_TOO_LONG";
case SerializeResult::<API key>:
return stream << "<API key>";
case SerializeResult::EMPTY_LIST:
return stream << "EMPTY_LIST";
case SerializeResult::EMPTY_ELEM_IN_LIST:
return stream << "EMPTY_ELEM_IN_LIST";
case SerializeResult::LIST_ELEM_TOO_LONG:
return stream << "LIST_ELEM_TOO_LONG";
case SerializeResult::LIST_TOO_LONG:
return stream << "LIST_TOO_LONG";
case SerializeResult::<API key>:
return stream << "<API key>";
}
}
std::ostream& operator<<(std::ostream& stream, const DeserializeResult& r) {
switch (r) {
case DeserializeResult::OK:
return stream << "OK";
case DeserializeResult::INPUT_TOO_SHORT:
return stream << "INPUT_TOO_SHORT";
case DeserializeResult::<API key>:
return stream << "<API key>";
case DeserializeResult::<API key>:
return stream << "<API key>";
case DeserializeResult::INPUT_TOO_LONG:
return stream << "INPUT_TOO_LONG";
case DeserializeResult::UNSUPPORTED_VERSION:
return stream << "UNSUPPORTED_VERSION";
case DeserializeResult::<API key>:
return stream << "<API key>";
case DeserializeResult::EMPTY_LIST:
return stream << "EMPTY_LIST";
case DeserializeResult::EMPTY_ELEM_IN_LIST:
return stream << "EMPTY_ELEM_IN_LIST";
case DeserializeResult::UNKNOWN_LEAF_TYPE:
return stream << "UNKNOWN_LEAF_TYPE";
case DeserializeResult::<API key>:
return stream << "<API key>";
case DeserializeResult::EXTENSIONS_TOO_LONG:
return stream << "EXTENSIONS_TOO_LONG";
case DeserializeResult::<API key>:
return stream << "<API key>";
}
}
// Returns the number of bytes needed to store a value up to max_length.
size_t PrefixLength(size_t max_length) {
CHECK_GT(max_length, 0U);
return ceil(log2(max_length) / float(8));
}
// static
string Serializer::LeafData(const LogEntry& entry) {
CHECK(leaf_data);
return leaf_data(entry);
}
// static
SerializeResult Serializer::<API key>(
uint64_t timestamp, int64_t tree_size, const string& root_hash,
string* result) {
CHECK(result);
CHECK(<API key>);
return <API key>(timestamp, tree_size, root_hash, result);
}
static SerializeResult <API key>(uint64_t timestamp,
int64_t tree_size,
const string& root_hash,
string* result) {
CHECK_GE(tree_size, 0);
if (root_hash.size() != 32)
return SerializeResult::INVALID_HASH_LENGTH;
TLSSerializer serializer;
serializer.WriteUint(ct::V1, Serializer::<API key>);
serializer.WriteUint(ct::TREE_HEAD, Serializer::<API key>);
serializer.WriteUint(timestamp, Serializer::<API key>);
serializer.WriteUint(tree_size, 8);
serializer.WriteFixedBytes(root_hash);
result->assign(serializer.SerializedString());
return SerializeResult::OK;
}
// static
SerializeResult Serializer::<API key>(
uint64_t timestamp, int64_t tree_size, const string& root_hash,
const <API key>& sth_extension, const string& log_id,
string* result) {
CHECK(result);
CHECK(<API key>);
return <API key>(timestamp, tree_size, root_hash,
sth_extension, log_id, result);
}
static SerializeResult <API key>(
uint64_t timestamp, int64_t tree_size, const string& root_hash,
const RepeatedPtrField<SthExtension>& sth_extension, const string& log_id,
string* result) {
CHECK_GE(tree_size, 0);
if (root_hash.size() != 32) {
return SerializeResult::INVALID_HASH_LENGTH;
}
SerializeResult res = <API key>(sth_extension);
if (res != SerializeResult::OK) {
return res;
}
if (log_id.size() != Serializer::kKeyIDLengthInBytes) {
return SerializeResult::<API key>;
}
TLSSerializer serializer;
serializer.WriteUint(ct::V2, Serializer::<API key>);
serializer.WriteUint(ct::TREE_HEAD, Serializer::<API key>);
serializer.WriteFixedBytes(log_id);
serializer.WriteUint(timestamp, Serializer::<API key>);
serializer.WriteUint(tree_size, 8);
serializer.WriteFixedBytes(root_hash);
// V2 STH can have multiple extensions
serializer.WriteUint(sth_extension.size(), 2);
for (auto it = sth_extension.begin(); it != sth_extension.end(); ++it) {
serializer.WriteUint(it->sth_extension_type(), 2);
serializer.WriteVarBytes(it->sth_extension_data(),
Serializer::<API key>);
}
result->assign(serializer.SerializedString());
return SerializeResult::OK;
}
// static
SerializeResult Serializer::<API key>(
const ct::SignedTreeHead& sth, std::string* result) {
CHECK(result);
// TODO(alcutter): this should know whether it's V1 or V2 from the
// Configure()
switch (sth.version()) {
case ct::V1:
return <API key>(sth.timestamp(), sth.tree_size(),
sth.sha256_root_hash(), result);
case ct::V2:
return <API key>(sth.timestamp(), sth.tree_size(),
sth.sha256_root_hash(),
sth.sth_extension(),
sth.id().key_id(), result);
default:
break;
}
return SerializeResult::UNSUPPORTED_VERSION;
}
// static
SerializeResult Serializer::<API key>(
const ct::<API key>& sct, const ct::LogEntry& entry,
std::string* result) {
CHECK(result);
CHECK(<API key>);
return <API key>(sct, entry, result);
}
// static
SerializeResult Serializer::<API key>(
const <API key>& sct, const LogEntry& entry,
string* result) {
CHECK(result);
CHECK(<API key>);
return <API key>(sct, entry, result);
}
SerializeResult TLSSerializer::WriteSCTV1(
const <API key>& sct) {
CHECK(sct.version() == ct::V1);
SerializeResult res = <API key>(sct.extensions());
if (res != SerializeResult::OK) {
return res;
}
if (sct.id().key_id().size() != Serializer::kKeyIDLengthInBytes) {
return SerializeResult::<API key>;
}
WriteUint(sct.version(), Serializer::<API key>);
WriteFixedBytes(sct.id().key_id());
WriteUint(sct.timestamp(), Serializer::<API key>);
WriteVarBytes(sct.extensions(), Serializer::<API key>);
return <API key>(sct.signature());
}
SerializeResult TLSSerializer::WriteSCTV2(
const <API key>& sct) {
CHECK(sct.version() == ct::V2);
SerializeResult res = <API key>(sct.sct_extension());
if (res != SerializeResult::OK) {
return res;
}
if (sct.id().key_id().size() != Serializer::kKeyIDLengthInBytes) {
return SerializeResult::<API key>;
}
WriteUint(sct.version(), Serializer::<API key>);
WriteFixedBytes(sct.id().key_id());
WriteUint(sct.timestamp(), Serializer::<API key>);
// V2 SCT can have a number of extensions. They must be ordered by type
// but we already checked that above.
WriteSctExtension(sct.sct_extension());
return <API key>(sct.signature());
}
// static
SerializeResult Serializer::SerializeSCT(const <API key>& sct,
string* result) {
TLSSerializer serializer;
SerializeResult res = SerializeResult::UNSUPPORTED_VERSION;
switch (sct.version()) {
case ct::V1:
res = serializer.WriteSCTV1(sct);
break;
case ct::V2:
res = serializer.WriteSCTV2(sct);
break;
default:
res = SerializeResult::UNSUPPORTED_VERSION;
}
if (res != SerializeResult::OK) {
return res;
}
result->assign(serializer.SerializedString());
return SerializeResult::OK;
}
// static
SerializeResult Serializer::SerializeSCTList(
const <API key>& sct_list, string* result) {
if (sct_list.sct_list_size() == 0) {
return SerializeResult::EMPTY_LIST;
}
return SerializeList(sct_list.sct_list(),
Serializer::<API key>,
Serializer::kMaxSCTListLength, result);
}
// static
SerializeResult Serializer::<API key>(
const DigitallySigned& sig, string* result) {
TLSSerializer serializer;
SerializeResult res = serializer.<API key>(sig);
if (res != SerializeResult::OK) {
return res;
}
result->assign(serializer.SerializedString());
return SerializeResult::OK;
}
void TLSSerializer::WriteFixedBytes(const string& in) {
output_.append(in);
}
void TLSSerializer::WriteVarBytes(const string& in, size_t max_length) {
CHECK_LE(in.size(), max_length);
size_t prefix_length = PrefixLength(max_length);
WriteUint(in.size(), prefix_length);
WriteFixedBytes(in);
}
// This does not enforce extension ordering, which must be done separately.
void TLSSerializer::WriteSctExtension(
const RepeatedPtrField<SctExtension>& extension) {
WriteUint(extension.size(), 2);
for (auto it = extension.begin(); it != extension.end(); ++it) {
WriteUint(it->sct_extension_type(), 2);
WriteVarBytes(it->sct_extension_data(), Serializer::<API key>);
}
}
size_t <API key>(const repeated_string& in, size_t max_elem_length,
size_t max_total_length) {
size_t elem_prefix_length = PrefixLength(max_elem_length);
size_t total_length = 0;
for (int i = 0; i < in.size(); ++i) {
if (in.Get(i).size() > max_elem_length ||
max_total_length - total_length < elem_prefix_length ||
max_total_length - total_length - elem_prefix_length <
in.Get(i).size())
return 0;
total_length += elem_prefix_length + in.Get(i).size();
}
return total_length + PrefixLength(max_total_length);
}
// static
SerializeResult Serializer::SerializeList(const repeated_string& in,
size_t max_elem_length,
size_t max_total_length,
string* result) {
TLSSerializer serializer;
SerializeResult res =
serializer.WriteList(in, max_elem_length, max_total_length);
if (res != SerializeResult::OK)
return res;
result->assign(serializer.SerializedString());
return SerializeResult::OK;
}
SerializeResult TLSSerializer::WriteList(const repeated_string& in,
size_t max_elem_length,
size_t max_total_length) {
for (int i = 0; i < in.size(); ++i) {
if (in.Get(i).empty())
return SerializeResult::EMPTY_ELEM_IN_LIST;
if (in.Get(i).size() > max_elem_length)
return SerializeResult::LIST_ELEM_TOO_LONG;
}
size_t length = <API key>(in, max_elem_length, max_total_length);
if (length == 0)
return SerializeResult::LIST_TOO_LONG;
size_t prefix_length = PrefixLength(max_total_length);
CHECK_GE(length, prefix_length);
WriteUint(length - prefix_length, prefix_length);
for (int i = 0; i < in.size(); ++i)
WriteVarBytes(in.Get(i), max_elem_length);
return SerializeResult::OK;
}
SerializeResult TLSSerializer::<API key>(
const DigitallySigned& sig) {
SerializeResult res = <API key>(sig);
if (res != SerializeResult::OK)
return res;
WriteUint(sig.hash_algorithm(), Serializer::<API key>);
WriteUint(sig.sig_algorithm(), Serializer::<API key>);
WriteVarBytes(sig.signature(), Serializer::kMaxSignatureLength);
return SerializeResult::OK;
}
SerializeResult CheckKeyHashFormat(const string& key_hash) {
if (key_hash.size() != Serializer::<API key>)
return SerializeResult::INVALID_HASH_LENGTH;
return SerializeResult::OK;
}
SerializeResult <API key>(const DigitallySigned& sig) {
// This is just DCHECKED upon setting, so check again.
if (!<API key>(sig.hash_algorithm()))
return SerializeResult::<API key>;
if (!<API key>(sig.sig_algorithm()))
return SerializeResult::<API key>;
if (sig.signature().size() > Serializer::kMaxSignatureLength)
return SerializeResult::SIGNATURE_TOO_LONG;
return SerializeResult::OK;
}
SerializeResult <API key>(const string& extensions) {
if (extensions.size() > Serializer::<API key>)
return SerializeResult::EXTENSIONS_TOO_LONG;
return SerializeResult::OK;
}
// Checks the (v2) STH extensions are correct. The RFC defines that there can
// be up to 65534 of them and each one can contain up to 65535 bytes.
// They must be in ascending order of extension type.
SerializeResult <API key>(
const <API key>& extension) {
if (extension.size() > Serializer::<API key>) {
return SerializeResult::EXTENSIONS_TOO_LONG;
}
int32_t last_type_seen = 0;
for (auto it = extension.begin(); it != extension.end(); ++it) {
if (it->sth_extension_type() > Serializer::kMaxV2ExtensionType) {
return SerializeResult::INVALID_ENTRY_TYPE;
}
if (it->sth_extension_data().size() > Serializer::<API key>) {
return SerializeResult::EXTENSIONS_TOO_LONG;
}
if (it->sth_extension_type() < last_type_seen) {
// It's out of order - reject
return SerializeResult::<API key>;
}
last_type_seen = it->sth_extension_type();
}
return SerializeResult::OK;
}
// Checks the (v2) SCT extensions are correct. The RFC defines that there can
// be up to 65534 of them and each one can contain up to 65535 bytes. They
// must be in ascending order of extension type
SerializeResult <API key>(
const RepeatedPtrField<SctExtension>& extension) {
if (extension.size() > Serializer::<API key>) {
return SerializeResult::EXTENSIONS_TOO_LONG;
}
int32_t last_type_seen = 0;
for (auto it = extension.begin(); it != extension.end(); ++it) {
if (it->sct_extension_data().size() > Serializer::<API key>) {
return SerializeResult::EXTENSIONS_TOO_LONG;
}
if (it->sct_extension_type() > Serializer::kMaxV2ExtensionType) {
return SerializeResult::INVALID_ENTRY_TYPE;
}
if (it->sct_extension_type() < last_type_seen) {
// It's out of order - reject
return SerializeResult::<API key>;
}
last_type_seen = it->sct_extension_type();
}
return SerializeResult::OK;
}
const size_t TLSDeserializer::<API key> = 2;
const size_t TLSDeserializer::<API key> = 2;
TLSDeserializer::TLSDeserializer(const string& input)
: current_pos_(input.data()), bytes_remaining_(input.size()) {
}
DeserializeResult TLSDeserializer::ReadSCTV1(<API key>* sct) {
sct->set_version(ct::V1);
if (!ReadFixedBytes(Serializer::kKeyIDLengthInBytes,
sct->mutable_id()->mutable_key_id())) {
return DeserializeResult::INPUT_TOO_SHORT;
}
// V1 encoding.
uint64_t timestamp = 0;
if (!ReadUint(Serializer::<API key>, ×tamp)) {
return DeserializeResult::INPUT_TOO_SHORT;
}
sct->set_timestamp(timestamp);
string extensions;
if (!ReadVarBytes(Serializer::<API key>, &extensions)) {
// In theory, could also be an invalid length prefix, but not if
// length limits follow byte boundaries.
return DeserializeResult::INPUT_TOO_SHORT;
}
return ReadDigitallySigned(sct->mutable_signature());
}
DeserializeResult TLSDeserializer::ReadSCTV2(<API key>* sct) {
sct->set_version(ct::V2);
if (!ReadFixedBytes(Serializer::kKeyIDLengthInBytes,
sct->mutable_id()->mutable_key_id())) {
return DeserializeResult::INPUT_TOO_SHORT;
}
// V2 encoding.
uint64_t timestamp = 0;
if (!ReadUint(Serializer::<API key>, ×tamp)) {
return DeserializeResult::INPUT_TOO_SHORT;
}
sct->set_timestamp(timestamp);
// Extensions are handled differently for V2
const DeserializeResult res = ReadSctExtension(sct-><API key>());
if (res != DeserializeResult::OK) {
return res;
}
return ReadDigitallySigned(sct->mutable_signature());
}
DeserializeResult TLSDeserializer::ReadSCT(<API key>* sct) {
int version;
if (!ReadUint(Serializer::<API key>, &version)) {
return DeserializeResult::INPUT_TOO_SHORT;
}
if (!Version_IsValid(version) || (version != ct::V1 && version != ct::V2)) {
return DeserializeResult::UNSUPPORTED_VERSION;
}
switch (version) {
case ct::V1:
return ReadSCTV1(sct);
break;
case ct::V2:
return ReadSCTV2(sct);
break;
default:
return DeserializeResult::UNSUPPORTED_VERSION;
}
}
// static
DeserializeResult Deserializer::DeserializeSCT(
const string& in, <API key>* sct) {
TLSDeserializer deserializer(in);
DeserializeResult res = deserializer.ReadSCT(sct);
if (res != DeserializeResult::OK) {
return res;
}
if (!deserializer.ReachedEnd()) {
return DeserializeResult::INPUT_TOO_LONG;
}
return DeserializeResult::OK;
}
// static
DeserializeResult Deserializer::DeserializeSCTList(
const string& in, <API key>* sct_list) {
sct_list->clear_sct_list();
DeserializeResult res = DeserializeList(in, Serializer::kMaxSCTListLength,
Serializer::<API key>,
sct_list->mutable_sct_list());
if (res != DeserializeResult::OK)
return res;
if (sct_list->sct_list_size() == 0)
return DeserializeResult::EMPTY_LIST;
return DeserializeResult::OK;
}
// static
DeserializeResult Deserializer::<API key>(
const string& in, DigitallySigned* sig) {
TLSDeserializer deserializer(in);
DeserializeResult res = deserializer.ReadDigitallySigned(sig);
if (res != DeserializeResult::OK)
return res;
if (!deserializer.ReachedEnd())
return DeserializeResult::INPUT_TOO_LONG;
return DeserializeResult::OK;
}
bool TLSDeserializer::ReadFixedBytes(size_t bytes, string* result) {
if (bytes_remaining_ < bytes)
return false;
result->assign(current_pos_, bytes);
current_pos_ += bytes;
bytes_remaining_ -= bytes;
return true;
}
bool TLSDeserializer::ReadLengthPrefix(size_t max_length, size_t* result) {
size_t prefix_length = PrefixLength(max_length);
size_t length;
if (!ReadUint(prefix_length, &length) || length > max_length)
return false;
*result = length;
return true;
}
bool TLSDeserializer::ReadVarBytes(size_t max_length, string* result) {
size_t length;
if (!ReadLengthPrefix(max_length, &length))
return false;
return ReadFixedBytes(length, result);
}
// static
DeserializeResult Deserializer::DeserializeList(const string& in,
size_t max_total_length,
size_t max_elem_length,
repeated_string* out) {
TLSDeserializer deserializer(in);
DeserializeResult res =
deserializer.ReadList(max_total_length, max_elem_length, out);
if (res != DeserializeResult::OK)
return res;
if (!deserializer.ReachedEnd())
return DeserializeResult::INPUT_TOO_LONG;
return DeserializeResult::OK;
}
DeserializeResult TLSDeserializer::ReadList(size_t max_total_length,
size_t max_elem_length,
repeated_string* out) {
string serialized_list;
if (!ReadVarBytes(max_total_length, &serialized_list))
// TODO(ekasper): could also be a length that's too large, if
// length limits don't follow byte boundaries.
return DeserializeResult::INPUT_TOO_SHORT;
if (!ReachedEnd())
return DeserializeResult::INPUT_TOO_LONG;
TLSDeserializer list_reader(serialized_list);
while (!list_reader.ReachedEnd()) {
string elem;
if (!list_reader.ReadVarBytes(max_elem_length, &elem))
return DeserializeResult::<API key>;
if (elem.empty())
return DeserializeResult::EMPTY_ELEM_IN_LIST;
*(out->Add()) = elem;
}
return DeserializeResult::OK;
}
DeserializeResult TLSDeserializer::ReadSctExtension(
RepeatedPtrField<SctExtension>* extension) {
uint32_t ext_count;
if (!ReadUint(<API key>, &ext_count)) {
return DeserializeResult::INPUT_TOO_SHORT;
}
if (ext_count > Serializer::<API key>) {
return DeserializeResult::EXTENSIONS_TOO_LONG;
}
for (int ext = 0; ext < ext_count; ++ext) {
uint32_t ext_type;
if (!ReadUint(<API key>, &ext_type)) {
return DeserializeResult::INPUT_TOO_SHORT;
}
string ext_data;
if (!ReadVarBytes(Serializer::<API key>, &ext_data)) {
return DeserializeResult::INPUT_TOO_SHORT;
}
SctExtension* new_ext = extension->Add();
new_ext-><API key>(ext_type);
new_ext-><API key>(ext_data);
}
// This makes sure they're correctly ordered (See RFC section 5.3)
return <API key>(*extension) == SerializeResult::OK
? DeserializeResult::OK
: DeserializeResult::<API key>;
}
DeserializeResult TLSDeserializer::ReadDigitallySigned(DigitallySigned* sig) {
int hash_algo = -1, sig_algo = -1;
if (!ReadUint(Serializer::<API key>, &hash_algo))
return DeserializeResult::INPUT_TOO_SHORT;
if (!<API key>(hash_algo))
return DeserializeResult::<API key>;
if (!ReadUint(Serializer::<API key>, &sig_algo))
return DeserializeResult::INPUT_TOO_SHORT;
if (!<API key>(sig_algo))
return DeserializeResult::<API key>;
string sig_string;
if (!ReadVarBytes(Serializer::kMaxSignatureLength, &sig_string))
return DeserializeResult::INPUT_TOO_SHORT;
sig->set_hash_algorithm(
static_cast<DigitallySigned::HashAlgorithm>(hash_algo));
sig->set_sig_algorithm(
static_cast<DigitallySigned::SignatureAlgorithm>(sig_algo));
sig->set_signature(sig_string);
return DeserializeResult::OK;
}
DeserializeResult TLSDeserializer::ReadExtensions(
ct::TimestampedEntry* entry) {
string extensions;
if (!ReadVarBytes(Serializer::<API key>, &extensions)) {
return DeserializeResult::INPUT_TOO_SHORT;
}
CHECK_NOTNULL(entry)->set_extensions(extensions);
return DeserializeResult::OK;
}
DeserializeResult Deserializer::<API key>(
const std::string& in, ct::MerkleTreeLeaf* leaf) {
TLSDeserializer des(in);
DeserializeResult ret = <API key>(&des, leaf);
if (ret != DeserializeResult::OK) {
return ret;
}
if (!des.ReachedEnd()) {
return DeserializeResult::INPUT_TOO_LONG;
}
return DeserializeResult::OK;
}
// static
void Serializer::ConfigureV1(
const function<string(const ct::LogEntry&)>& leaf_data_func,
const function<SerializeResult(
const ct::<API key>& sct, const ct::LogEntry& entry,
std::string* result)>& <API key>,
const function<SerializeResult(
const ct::<API key>& sct, const ct::LogEntry& entry,
std::string* result)>& <API key>) {
CHECK(<API key> ||
(!leaf_data&& !<API key> &&
!<API key>))
<< "Serializer already configured";
leaf_data = leaf_data_func;
<API key> = <API key>;
<API key> = <API key>;
<API key> = ::<API key>;
}
// static
void Serializer::ConfigureV2(
const function<string(const ct::LogEntry&)>& leaf_data_func,
const function<SerializeResult(
const ct::<API key>& sct, const ct::LogEntry& entry,
std::string* result)>& <API key>,
const function<SerializeResult(
const ct::<API key>& sct, const ct::LogEntry& entry,
std::string* result)>& <API key>) {
CHECK(<API key> ||
(!leaf_data && !<API key> &&
!<API key>))
<< "Serializer already configured";
leaf_data = leaf_data_func;
<API key> = <API key>;
<API key> = <API key>;
<API key> = ::<API key>;
}
// static
void Deserializer::Configure(
const function<DeserializeResult(TLSDeserializer* d,
ct::MerkleTreeLeaf* leaf)>&
<API key>) {
CHECK(<API key> ||
!<API key>)
<< "Deserializer already configured";
<API key> = <API key>;
} |
// Purpose: Player for HL1.
// $NoKeywords: $
#ifndef DT_UTLVECTOR_SEND_H
#define DT_UTLVECTOR_SEND_H
#pragma once
#include "dt_send.h"
#include "dt_utlvector_common.h"
#define SENDINFO_UTLVECTOR( varName ) #varName, \
offsetof(currentSendDTClass, varName), \
sizeof(((currentSendDTClass*)0)->varName[0]), \
<API key>( ((currentSendDTClass*)0)->varName )
#define <API key>( varName, nMaxElements, dataTableName ) \
SendPropUtlVector( \
SENDINFO_UTLVECTOR( varName ), \
nMaxElements, \
SendPropDataTable( NULL, 0, &<API key>( dataTableName ) ) \
)
// Set it up to transmit a CUtlVector of basic types or of structures.
// pArrayProp doesn't need a name, offset, or size. You can pass 0 for all those.
// Example usage:
// <API key>( m_StructArray, 11, DT_TestStruct )
// SendPropUtlVector(
// SENDINFO_UTLVECTOR( m_FloatArray ),
// 16, // max elements
// SendPropFloat( NULL, 0, 0, 0, SPROP_NOSCALE )
SendProp SendPropUtlVector(
char *pVarName, // Use SENDINFO_UTLVECTOR to generate these first 4 parameters.
int offset,
int sizeofVar,
EnsureCapacityFn ensureFn,
int nMaxElements, // Max # of elements in the array. Keep this as low as possible.
SendProp pArrayProp, // Describe the data inside of each element in the array.
SendTableProxyFn varProxy=<API key> // This can be overridden to control who the array is sent to.
);
#endif // DT_UTLVECTOR_SEND_H |
// run-pass
#![allow(dead_code)]
#![allow(unused_assignments)]
// Issue #2263.
// pretty-expanded FIXME #23616
#![allow(unused_variables)]
// Should pass region checking.
fn ok(f: Box<dyn FnMut(&usize)>) {
// Here, g is a function that can accept a usize pointer with
// lifetime r, and f is a function that can accept a usize pointer
// with any lifetime. The assignment g = f should be OK (i.e.,
// f's type should be a subtype of g's type), because f can be
// used in any context that expects g's type. But this currently
// fails.
let mut g: Box<dyn for<'r> FnMut(&'r usize)> = Box::new(|x| { });
g = f;
}
// This version is the same as above, except that here, g's type is
// inferred.
fn ok_inferred(f: Box<dyn FnMut(&usize)>) {
let mut g: Box<dyn for<'r> FnMut(&'r usize)> = Box::new(|_| {});
g = f;
}
pub fn main() {
} |
// MainFrm.h : interface of the CMainFrame class
#if !defined(<API key>)
#define <API key>
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#include <gpac/tools.h>
#include <gpac/constants.h>
#include <gpac/modules/service.h>
#include <gpac/options.h>
#include "FileProps.h"
#include "Options.h"
#include "AddressBar.h"
#include "Sliders.h"
#include "Playlist.h"
class CChildView : public CWnd
{
// Construction
public:
CChildView();
// Attributes
public:
// Operations
public:
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CChildView)
protected:
virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
//}}AFX_VIRTUAL
// Implementation
public:
virtual ~CChildView();
// Generated message map functions
protected:
//{{AFX_MSG(CChildView)
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
class CMainFrame : public CFrameWnd
{
public:
CMainFrame();
protected:
DECLARE_DYNAMIC(CMainFrame)
// Attributes
public:
// Operations
public:
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CMainFrame)
public:
virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
virtual BOOL OnCmdMsg(UINT nID, int nCode, void* pExtra, AFX_CMDHANDLERINFO* pHandlerInfo);
virtual BOOL DestroyWindow();
protected:
virtual BOOL OnNotify(WPARAM wParam, LPARAM lParam, LRESULT* pResult);
//}}AFX_VIRTUAL
// Implementation
public:
virtual ~CMainFrame();
#ifdef _DEBUG
virtual void AssertValid() const;
virtual void Dump(CDumpContext& dc) const;
#endif
public:
CStatusBar m_wndStatusBar;
CToolBar m_wndToolBar;
Sliders m_Sliders;
AddressBar m_Address;
CFileProps *m_pProps;
COptions *m_pOpt;
Playlist *m_pPlayList;
CChildView *m_pWndView;
Bool m_bFullScreen;
u32 m_RestoreFS;
UINT_PTR m_timer_on;
CString console_message;
CString console_service;
GF_Err console_err;
u32 m_aspect_ratio;
RECT backup_wnd_rc;
Bool m_bFirstStreamQuery;
/*filter progress events to avoid killing importers with status bar text display...*/
s32 m_last_prog;
Bool m_show_rti;
Bool m_bStartupFile;
public:
void SetFullscreen();
void BuildViewList();
void BuildStreamList(Bool reset_ony);
void BuildChapterList(Bool reset_ony);
void SetProgTimer(Bool bOn);
void AddSubtitle(const char *fileName, Bool auto_play);
private:
void ForwardMessage();
HICON m_icoerror, m_icomessage;
s32 nb_viewpoints;
Bool m_bInitShow;
void SetNavigate(u32 mode);
void LookForSubtitles();
Double *m_chapters_start;
u32 m_num_chapters;
// Generated message map functions
protected:
//{{AFX_MSG(CMainFrame)
afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
afx_msg void OnSetFocus(CWnd *pOldWnd);
afx_msg void OnInitMenuPopup(CMenu* pPopupMenu, UINT nIndex, BOOL bSysMenu);
afx_msg BOOL OnCommand(WPARAM wParam, LPARAM lParam);
afx_msg void OnSize(UINT nType, int cx, int cy);
afx_msg void OnMove(int x, int y);
afx_msg LRESULT OnSetSize(WPARAM wParam, LPARAM lParam);
afx_msg LRESULT OnNavigate(WPARAM wParam, LPARAM lParam);
afx_msg LRESULT Open(WPARAM wParam, LPARAM lParam);
afx_msg LRESULT NewInstanceOpened(WPARAM wParam, LPARAM lParam);
afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
afx_msg void OnLButtonDblClk(UINT nFlags, CPoint point);
afx_msg void OnLButtonUp(UINT nFlags, CPoint point);
afx_msg void OnChar( UINT nChar, UINT nRepCnt, UINT nFlags );
afx_msg void OnSysKeyDown( UINT nChar, UINT nRepCnt, UINT nFlags );
afx_msg void OnSysKeyUp( UINT nChar, UINT nRepCnt, UINT nFlags );
afx_msg void OnKeyDown( UINT nChar, UINT nRepCnt, UINT nFlags );
afx_msg void OnKeyUp( UINT nChar, UINT nRepCnt, UINT nFlags );
afx_msg void OnDropFiles(HDROP hDropInfo);
afx_msg LRESULT OnConsoleMessage(WPARAM wParam, LPARAM lParam);
afx_msg void OnViewOriginal();
afx_msg void OnViewFullscreen();
afx_msg void OnArKeep();
afx_msg void OnArFill();
afx_msg void OnAr43();
afx_msg void OnAr169();
afx_msg void OnUpdateAr169(CCmdUI* pCmdUI);
afx_msg void OnUpdateAr43(CCmdUI* pCmdUI);
afx_msg void OnUpdateArFill(CCmdUI* pCmdUI);
afx_msg void OnUpdateArKeep(CCmdUI* pCmdUI);
afx_msg void OnNavigateNone();
afx_msg void OnNavigateWalk();
afx_msg void OnNavigateFly();
afx_msg void OnNavigateExam();
afx_msg void OnNavigateSlide();
afx_msg void OnNavigatePan();
afx_msg void OnNavigateOrbit();
afx_msg void OnNavigateGame();
afx_msg void OnNavigateVR();
afx_msg void OnNavigateReset();
afx_msg void OnShortcuts();
afx_msg void OnConfigure();
afx_msg void OnFileProp();
afx_msg void OnViewPlaylist();
afx_msg void OnUpdateFileProp(CCmdUI* pCmdUI);
afx_msg void OnUpdateNavigate(CCmdUI* pCmdUI);
afx_msg void OnCacheEnable();
afx_msg void OnUpdateCacheEnable(CCmdUI* pCmdUI);
afx_msg void OnCacheStop();
afx_msg void OnCacheAbort();
afx_msg void OnUpdateCacheStop(CCmdUI* pCmdUI);
afx_msg void OnCollideDisp();
afx_msg void OnUpdateCollideDisp(CCmdUI* pCmdUI);
afx_msg void OnCollideNone();
afx_msg void OnUpdateCollideNone(CCmdUI* pCmdUI);
afx_msg void OnCollideReg();
afx_msg void OnUpdateCollideReg(CCmdUI* pCmdUI);
afx_msg void OnHeadlight();
afx_msg void OnUpdateHeadlight(CCmdUI* pCmdUI);
afx_msg void OnGravity();
afx_msg void OnUpdateGravity(CCmdUI* pCmdUI);
afx_msg void OnNavInfo();
afx_msg void OnNavNext();
afx_msg void OnNavPrev();
afx_msg void OnUpdateNavNext(CCmdUI* pCmdUI);
afx_msg void OnUpdateNavPrev(CCmdUI* pCmdUI);
afx_msg void OnClearNav();
afx_msg void <API key>(CCmdUI* pCmdUI);
afx_msg void OnPlaylistLoop();
afx_msg void <API key>(CCmdUI* pCmdUI);
afx_msg void OnAddSubtitle();
afx_msg void OnFileExit();
afx_msg void OnViewCPU();
afx_msg void OnUpdateViewCPU(CCmdUI* pCmdUI);
afx_msg void OnFileCopy();
afx_msg void OnUpdateFileCopy(CCmdUI* pCmdUI);
afx_msg void OnFilePaste();
afx_msg void OnUpdateFilePaste(CCmdUI* pCmdUI);
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
#endif // !defined(<API key>) |
package org.objectweb.asm.tree;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import org.objectweb.asm.MethodVisitor;
import org.objectweb.asm.Opcodes;
/**
* A node that represents a stack map frame. These nodes are pseudo instruction
* nodes in order to be inserted in an instruction list. In fact these nodes
* must(*) be inserted <i>just before</i> any instruction node <b>i</b> that
* follows an unconditionnal branch instruction such as GOTO or THROW, that is
* the target of a jump instruction, or that starts an exception handler block.
* The stack map frame types must describe the values of the local variables and
* of the operand stack elements <i>just before</i> <b>i</b> is executed. <br>
* <br>
* (*) this is mandatory only for classes whose version is greater than or equal
* to {@link Opcodes#V1_6 V1_6}.
*
* @author Eric Bruneton
*/
public class FrameNode extends AbstractInsnNode {
/**
* The type of this frame. Must be {@link Opcodes#F_NEW} for expanded
* frames, or {@link Opcodes#F_FULL}, {@link Opcodes#F_APPEND},
* {@link Opcodes#F_CHOP}, {@link Opcodes#F_SAME} or
* {@link Opcodes#F_APPEND}, {@link Opcodes#F_SAME1} for compressed frames.
*/
public int type;
/**
* The types of the local variables of this stack map frame. Elements of
* this list can be Integer, String or LabelNode objects (for primitive,
* reference and uninitialized types respectively - see
* {@link MethodVisitor}).
*/
public List<Object> local;
/**
* The types of the operand stack elements of this stack map frame. Elements
* of this list can be Integer, String or LabelNode objects (for primitive,
* reference and uninitialized types respectively - see
* {@link MethodVisitor}).
*/
public List<Object> stack;
private FrameNode() {
super(-1);
}
/**
* Constructs a new {@link FrameNode}.
*
* @param type
* the type of this frame. Must be {@link Opcodes#F_NEW} for
* expanded frames, or {@link Opcodes#F_FULL},
* {@link Opcodes#F_APPEND}, {@link Opcodes#F_CHOP},
* {@link Opcodes#F_SAME} or {@link Opcodes#F_APPEND},
* {@link Opcodes#F_SAME1} for compressed frames.
* @param nLocal
* number of local variables of this stack map frame.
* @param local
* the types of the local variables of this stack map frame.
* Elements of this list can be Integer, String or LabelNode
* objects (for primitive, reference and uninitialized types
* respectively - see {@link MethodVisitor}).
* @param nStack
* number of operand stack elements of this stack map frame.
* @param stack
* the types of the operand stack elements of this stack map
* frame. Elements of this list can be Integer, String or
* LabelNode objects (for primitive, reference and uninitialized
* types respectively - see {@link MethodVisitor}).
*/
public FrameNode(final int type, final int nLocal, final Object[] local,
final int nStack, final Object[] stack) {
super(-1);
this.type = type;
switch (type) {
case Opcodes.F_NEW:
case Opcodes.F_FULL:
this.local = asList(nLocal, local);
this.stack = asList(nStack, stack);
break;
case Opcodes.F_APPEND:
this.local = asList(nLocal, local);
break;
case Opcodes.F_CHOP:
this.local = Arrays.asList(new Object[nLocal]);
break;
case Opcodes.F_SAME:
break;
case Opcodes.F_SAME1:
this.stack = asList(1, stack);
break;
}
}
@Override
public int getType() {
return FRAME;
}
/**
* Makes the given visitor visit this stack map frame.
*
* @param mv
* a method visitor.
*/
@Override
public void accept(final MethodVisitor mv) {
switch (type) {
case Opcodes.F_NEW:
case Opcodes.F_FULL:
mv.visitFrame(type, local.size(), asArray(local), stack.size(),
asArray(stack));
break;
case Opcodes.F_APPEND:
mv.visitFrame(type, local.size(), asArray(local), 0, null);
break;
case Opcodes.F_CHOP:
mv.visitFrame(type, local.size(), null, 0, null);
break;
case Opcodes.F_SAME:
mv.visitFrame(type, 0, null, 0, null);
break;
case Opcodes.F_SAME1:
mv.visitFrame(type, 0, null, 1, asArray(stack));
break;
}
}
@Override
public AbstractInsnNode clone(final Map<LabelNode, LabelNode> labels) {
FrameNode clone = new FrameNode();
clone.type = type;
if (local != null) {
clone.local = new ArrayList<Object>();
for (int i = 0; i < local.size(); ++i) {
Object l = local.get(i);
if (l instanceof LabelNode) {
l = labels.get(l);
}
clone.local.add(l);
}
}
if (stack != null) {
clone.stack = new ArrayList<Object>();
for (int i = 0; i < stack.size(); ++i) {
Object s = stack.get(i);
if (s instanceof LabelNode) {
s = labels.get(s);
}
clone.stack.add(s);
}
}
return clone;
}
private static List<Object> asList(final int n, final Object[] o) {
return Arrays.asList(o).subList(0, n);
}
private static Object[] asArray(final List<Object> l) {
Object[] objs = new Object[l.size()];
for (int i = 0; i < objs.length; ++i) {
Object o = l.get(i);
if (o instanceof LabelNode) {
o = ((LabelNode) o).getLabel();
}
objs[i] = o;
}
return objs;
}
} |
package factory
import (
"fmt"
"time"
kapi "k8s.io/kubernetes/pkg/api"
kclient "k8s.io/kubernetes/pkg/client"
"k8s.io/kubernetes/pkg/client/cache"
"k8s.io/kubernetes/pkg/fields"
"k8s.io/kubernetes/pkg/labels"
"k8s.io/kubernetes/pkg/runtime"
"k8s.io/kubernetes/pkg/util"
"k8s.io/kubernetes/pkg/watch"
osclient "github.com/openshift/origin/pkg/client"
oscache "github.com/openshift/origin/pkg/client/cache"
routeapi "github.com/openshift/origin/pkg/route/api"
"github.com/openshift/origin/pkg/router"
"github.com/openshift/origin/pkg/router/controller"
)
// <API key> initializes and manages the watches that drive a router
// controller. It supports optional scoping on Namespace, Labels, and Fields of routes.
// If Namespace is empty, it means "all namespaces".
type <API key> struct {
KClient kclient.EndpointsNamespacer
OSClient osclient.RoutesNamespacer
Namespaces controller.NamespaceLister
ResyncInterval time.Duration
Namespace string
Labels labels.Selector
Fields fields.Selector
}
// <API key> initializes a default router controller factory.
func <API key>(oc osclient.RoutesNamespacer, kc kclient.EndpointsNamespacer) *<API key> {
return &<API key>{
KClient: kc,
OSClient: oc,
ResyncInterval: 10 * time.Minute,
Namespace: kapi.NamespaceAll,
Labels: labels.Everything(),
Fields: fields.Everything(),
}
}
// Create begins listing and watching against the API server for the desired route and endpoint
// resources. It spawns child goroutines that cannot be terminated.
func (factory *<API key>) Create(plugin router.Plugin) *controller.RouterController {
routeEventQueue := oscache.NewEventQueue(cache.<API key>)
cache.NewReflector(&routeLW{
client: factory.OSClient,
namespace: factory.Namespace,
field: factory.Fields,
label: factory.Labels,
}, &routeapi.Route{}, routeEventQueue, factory.ResyncInterval).Run()
endpointsEventQueue := oscache.NewEventQueue(cache.<API key>)
cache.NewReflector(&endpointsLW{
client: factory.KClient,
namespace: factory.Namespace,
// we do not scope endpoints by labels or fields because the route labels != endpoints labels
}, &kapi.Endpoints{}, endpointsEventQueue, factory.ResyncInterval).Run()
return &controller.RouterController{
Plugin: plugin,
NextEndpoints: func() (watch.EventType, *kapi.Endpoints, error) {
eventType, obj, err := endpointsEventQueue.Pop()
if err != nil {
return watch.Error, nil, err
}
return eventType, obj.(*kapi.Endpoints), nil
},
NextRoute: func() (watch.EventType, *routeapi.Route, error) {
eventType, obj, err := routeEventQueue.Pop()
if err != nil {
return watch.Error, nil, err
}
return eventType, obj.(*routeapi.Route), nil
},
Namespaces: factory.Namespaces,
// check namespaces a bit more often than we resync events, so that we aren't always waiting
// the maximum interval for new items to come into the list
// TODO: trigger a reflector resync after every namespace sync?
<API key>: factory.ResyncInterval - 10*time.Second,
<API key>: 10 * time.Second,
NamespaceRetries: 5,
}
}
// CreateNotifier begins listing and watching against the API server for the desired route and endpoint
// resources. It spawns child goroutines that cannot be terminated. It is a more efficient store of a
// route system.
func (factory *<API key>) CreateNotifier(changed func()) RoutesByHost {
keyFn := cache.<API key>
routeStore := cache.NewIndexer(keyFn, cache.Indexers{"host": hostIndexFunc})
routeEventQueue := oscache.<API key>(keyFn, routeStore)
cache.NewReflector(&routeLW{
client: factory.OSClient,
namespace: factory.Namespace,
field: factory.Fields,
label: factory.Labels,
}, &routeapi.Route{}, routeEventQueue, factory.ResyncInterval).Run()
endpointStore := cache.NewStore(keyFn)
endpointsEventQueue := oscache.<API key>(keyFn, endpointStore)
cache.NewReflector(&endpointsLW{
client: factory.KClient,
namespace: factory.Namespace,
// we do not scope endpoints by labels or fields because the route labels != endpoints labels
}, &kapi.Endpoints{}, endpointsEventQueue, factory.ResyncInterval).Run()
go util.Until(func() {
for {
if _, _, err := routeEventQueue.Pop(); err != nil {
return
}
changed()
}
}, time.Second, util.NeverStop)
go util.Until(func() {
for {
if _, _, err := endpointsEventQueue.Pop(); err != nil {
return
}
changed()
}
}, time.Second, util.NeverStop)
return &routesByHost{
routes: routeStore,
endpoints: endpointStore,
}
}
type RoutesByHost interface {
Hosts() []string
Route(host string) (*routeapi.Route, bool)
Endpoints(namespace, name string) *kapi.Endpoints
}
type routesByHost struct {
routes cache.Indexer
endpoints cache.Store
}
func (r *routesByHost) Hosts() []string {
return r.routes.ListIndexFuncValues("host")
}
func (r *routesByHost) Route(host string) (*routeapi.Route, bool) {
arr, err := r.routes.ByIndex("host", host)
if err != nil || len(arr) == 0 {
return nil, false
}
return oldestRoute(arr), true
}
func (r *routesByHost) Endpoints(namespace, name string) *kapi.Endpoints {
obj, ok, err := r.endpoints.GetByKey(fmt.Sprintf("%s/%s", namespace, name))
if !ok || err != nil {
return &kapi.Endpoints{}
}
return obj.(*kapi.Endpoints)
}
func oldestRoute(routes []interface{}) *routeapi.Route {
var oldest *routeapi.Route
for i := range routes {
route := routes[i].(*routeapi.Route)
if oldest == nil || route.CreationTimestamp.Before(oldest.CreationTimestamp) {
oldest = route
}
}
return oldest
}
func hostIndexFunc(obj interface{}) ([]string, error) {
route := obj.(*routeapi.Route)
hosts := []string{
fmt.Sprintf("%s-%s%s", route.Name, route.Namespace, ".generated.local"),
}
if len(route.Spec.Host) > 0 {
hosts = append(hosts, route.Spec.Host)
}
return hosts, nil
}
// routeLW is a ListWatcher for routes that can be filtered to a label, field, or
// namespace.
type routeLW struct {
client osclient.RoutesNamespacer
label labels.Selector
field fields.Selector
namespace string
}
func (lw *routeLW) List() (runtime.Object, error) {
return lw.client.Routes(lw.namespace).List(lw.label, lw.field)
}
func (lw *routeLW) Watch(resourceVersion string) (watch.Interface, error) {
return lw.client.Routes(lw.namespace).Watch(lw.label, lw.field, resourceVersion)
}
// endpointsLW is a list watcher for routes.
type endpointsLW struct {
client kclient.EndpointsNamespacer
label labels.Selector
field fields.Selector
namespace string
}
func (lw *endpointsLW) List() (runtime.Object, error) {
return lw.client.Endpoints(lw.namespace).List(labels.Everything())
}
func (lw *endpointsLW) Watch(resourceVersion string) (watch.Interface, error) {
return lw.client.Endpoints(lw.namespace).Watch(lw.label, lw.field, resourceVersion)
} |
class <API key> < ActiveRecord::Migration[5.0]
def change
add_column :generic_objects, :properties, :jsonb, :default => {}
end
end |
import lombok.extern.java.Log;
@Log
class LoggerJul {
}
@Log
class LoggerJulWithImport {
}
@Log(topic="DifferentName")
class <API key> {
} |
{% extends "wagtailadmin/base.html" %}
{% load i18n %}
{% block titletag %}{% blocktrans with title=page.title%}Unpublish {{ title }}{% endblocktrans %}{% endblock %}
{% block bodyclass %}menu-explorer{% endblock %}
{% block content %}
{% trans "Unpublish" as unpublish_str %}
{% include "wagtailadmin/shared/header.html" with title=unpublish_str subtitle=page.title icon="doc-empty-inverse" %}
<div class="nice-padding">
<p>{% trans "Are you sure you want to unpublish this page?" %}</p>
<form action="{% url '<API key>' page.id %}" method="POST">
{% csrf_token %}
<input type="submit" value="{% trans 'Yes, unpublish it' %}">
</form>
</div>
{% endblock %} |
require File.expand_path('../spec_helper', __FILE__)
describe "Function with variadic arguments" do
[ 0, 127, -128, -1 ].each do |i|
it "call variadic with (:char (#{i})) argument" do
buf = FFI::Buffer.new :long_long
FFISpecs::LibTest.pack_varargs(buf, "c", :char, i)
buf.get_int64(0).should == i
end
end
[ 0, 0x7f, 0x80, 0xff ].each do |i|
it "call variadic with (:uchar (#{i})) argument" do
buf = FFI::Buffer.new :long_long
FFISpecs::LibTest.pack_varargs(buf, "C", :uchar, i)
buf.get_int64(0).should == i
end
end
[ 0, 1.234567, 9.87654321 ].each do |v|
it "call variadic with (:float (#{v})) argument" do
buf = FFI::Buffer.new :long_long
FFISpecs::LibTest.pack_varargs(buf, "f", :float, v.to_f)
buf.get_float64(0).should == v
end
end
[ 0, 1.234567, 9.87654321 ].each do |v|
it "call variadic with (:double (#{v})) argument" do
buf = FFI::Buffer.new :long_long
FFISpecs::LibTest.pack_varargs(buf, "f", :double, v.to_f)
buf.get_float64(0).should == v
end
end
def self.verify(p, off, v)
if v.kind_of?(Float)
p.get_float64(off).should == v
else
p.get_int64(off).should == v
end
end
FFISpecs::Varargs::PACK_VALUES.keys.each do |t1|
FFISpecs::Varargs::PACK_VALUES.keys.each do |t2|
FFISpecs::Varargs::PACK_VALUES.keys.each do |t3|
FFISpecs::Varargs::PACK_VALUES[t1].each do |v1|
FFISpecs::Varargs::PACK_VALUES[t2].each do |v2|
FFISpecs::Varargs::PACK_VALUES[t3].each do |v3|
fmt = "#{t1}#{t2}#{t3}"
params = [ FFISpecs::Varargs::TYPE_MAP[t1], v1, FFISpecs::Varargs::TYPE_MAP[t2], v2, FFISpecs::Varargs::TYPE_MAP[t3], v3 ]
it "call(#{fmt}, #{params.join(',')})" do
buf = FFI::Buffer.new :long_long, 3
FFISpecs::LibTest.pack_varargs(buf, fmt, *params)
verify(buf, 0, v1)
verify(buf, 8, v2)
verify(buf, 16, v3)
end
end
end
end
end
end
end
end |
from sphinx.domains.python import PyXRefRole
def setup(app):
"""
Any time a python class is referenced, make it a pretty link that doesn't
include the full package path. This makes the base classes much prettier.
"""
app.add_role_to_domain('py', 'class', truncate_class_role)
return {'parallel_read_safe': True}
def truncate_class_role(name, rawtext, text, lineno, inliner,
options={}, content=[]):
if '<' not in rawtext:
text = '{} <{}>'.format(text.split('.')[-1], text)
rawtext = ':{}:`{}`'.format(name, text)
# Return a python x-reference
py_xref = PyXRefRole()
return py_xref('py:class', rawtext, text, lineno,
inliner, options=options, content=content) |
// Type definitions for Jasmine-JQuery 1.5.8
<reference path="../jasmine/jasmine.d.ts"/>
<reference path="../jquery/jquery.d.ts"/>
declare function sandbox(attributes?: any): string;
declare function readFixtures(...uls: string[]): string;
declare function preloadFixtures(...uls: string[]) : void;
declare function loadFixtures(...uls: string[]): void;
declare function appendLoadFixtures(...uls: string[]): void;
declare function setFixtures(html: string): string;
declare function appendSetFixtures(html: string) : void;
declare function <API key>(...uls: string[]) : void;
declare function loadStyleFixtures(...uls: string[]) : void;
declare function <API key>(...uls: string[]) : void;
declare function setStyleFixtures(html: string) : void;
declare function <API key>(html: string) : void;
declare function loadJSONFixtures(...uls: string[]): jasmine.JSONFixtures;
declare function getJSONFixture(url: string): any;
declare function spyOnEvent(selector: string, eventName: string): jasmine.JQueryEventSpy;
declare module jasmine {
function spiedEventsKey(selector: JQuery, eventName: string): string;
function getFixtures(): Fixtures;
function getStyleFixtures(): StyleFixtures;
function getJSONFixtures(): JSONFixtures;
interface Fixtures {
fixturesPath: string;
containerId: string;
set(html: string): string;
appendSet(html: string): void;
preload(...uls: string[]): void;
load(...uls: string[]): void;
appendLoad(...uls: string[]): void;
read(...uls: string[]): string;
clearCache(): void;
cleanUp(): void;
sandbox(attributes?: any): string;
createContainer_(html: string) : string;
addToContainer_(html: string): void;
getFixtureHtml_(url: string): string;
<API key>(relativeUrl: string): void;
makeFixtureUrl_(relativeUrl: string): string;
proxyCallTo_(methodName: string, passedArguments: any): any;
}
interface StyleFixtures {
fixturesPath: string;
set(html: string): string;
appendSet(html: string): void;
preload(...uls: string[]) : void;
load(...uls: string[]) : void;
appendLoad(...uls: string[]) : void;
read_(...uls: string[]): string;
clearCache() : void;
cleanUp() : void;
createStyle_(html: string) : void;
getFixtureHtml_(url: string): string;
<API key>(relativeUrl: string) : void;
makeFixtureUrl_(relativeUrl: string): string;
proxyCallTo_(methodName: string, passedArguments: any): any;
}
interface JSONFixtures {
fixturesPath: string;
load(...uls: string[]): void;
read(...uls: string[]): string;
clearCache(): void;
getFixtureData_(url: string): any;
<API key>(relativeUrl: string): void;
proxyCallTo_(methodName: string, passedArguments: any): any;
}
interface Matchers {
/**
* Check if DOM element has class.
*
* @param className Name of the class to check.
*
* @example
* // returns true
* expect($('<div class="some-class"></div>')).toHaveClass("some-class")
*/
toHaveClass(className: string): boolean;
/**
* Check if DOM element has the given CSS properties.
*
* @param css Object containing the properties (and values) to check.
*
* @example
* // returns true
* expect($('<div style="display: none; margin: 10px;"></div>')).toHaveCss({display: "none", margin: "10px"})
*
* @example
* // returns true
* expect($('<div style="display: none; margin: 10px;"></div>')).toHaveCss({margin: "10px"})
*/
toHaveCss(css: any): boolean;
/**
* Checks if DOM element is visible.
* Elements are considered visible if they consume space in the document. Visible elements have a width or height that is greater than zero.
*/
toBeVisible(): boolean;
/**
* Check if DOM element is hidden.
* Elements can be hidden for several reasons:
* - They have a CSS display value of none ;
* - They are form elements with type equal to hidden.
* - Their width and height are explicitly set to 0.
* - An ancestor element is hidden, so the element is not shown on the page.
*/
toBeHidden(): boolean;
/**
* Only for tags that have checked attribute
*
* @example
* // returns true
* expect($('<option selected="selected"></option>')).toBeSelected()
*/
toBeSelected(): boolean;
/**
* Only for tags that have checked attribute
* @example
* // returns true
* expect($('<input type="checkbox" checked="checked"/>')).toBeChecked()
*/
toBeChecked(): boolean;
/**
* Checks for child DOM elements or text
*/
toBeEmpty(): boolean;
/**
* Checks if element exists in or out the DOM.
*/
toExist(): boolean;
/**
* Checks if array has the given length.
*
* @param length Expected length
*/
toHaveLength(length: number): boolean;
/**
* Check if DOM element contains an attribute and, optionally, if the value of the attribute is equal to the expected one.
*
* @param attributeName Name of the attribute to check
* @param <API key> Expected attribute value
*/
toHaveAttr(attributeName: string, <API key>? : any): boolean;
/**
* Check if DOM element contains a property and, optionally, if the value of the property is equal to the expected one.
*
* @param propertyName Property name to check
* @param <API key> Expected property value
*/
toHaveProp(propertyName: string, <API key>? : any): boolean;
/**
* Check if DOM element has the given Id
*
* @param Id Expected identifier
*/
toHaveId(id: string): boolean;
/**
* Check if DOM element has the specified HTML.
*
* @example
* // returns true
* expect($('<div><span></span></div>')).toHaveHtml('<span></span>')
*/
toHaveHtml(html: string): boolean;
/**
* Check if DOM element contains the specified HTML.
*
* @example
* // returns true
* expect($('<div><ul></ul><h1>header</h1></div>')).toContainHtml('<ul></ul>')
*/
toContainHtml(html: string): boolean;
/**
* Check if DOM element has the given Text.
* @param text Accepts a string or regular expression
*
* @example
* // returns true
* expect($('<div>some text</div>')).toHaveText('some text')
*/
toHaveText(text: string): boolean;
/**
* Check if DOM element contains the specified text.
*
* @example
* // returns true
* expect($('<div><ul></ul><h1>header</h1></div>')).toContainText('header')
*/
toContainText(text: string): boolean;
/**
* Check if DOM element has the given value.
* This can only be applied for element on with jQuery val() can be called.
*
* @example
* // returns true
* expect($('<input type="text" value="some text"/>')).toHaveValue('some text')
*/
toHaveValue(value : string): boolean;
/**
* Check if DOM element has the given data.
* This can only be applied for element on with jQuery data(key) can be called.
*
*/
toHaveData(key : string, expectedValue : string): boolean;
toBe(selector: JQuery): boolean;
/**
* Check if DOM element is matched by the given selector.
*
* @example
* // returns true
* expect($('<div><span class="some-class"></span></div>')).toContain('some-class')
*/
toContain(selector: JQuery): boolean;
/**
* Check if DOM element exists inside the given parent element.
*
* @example
* // returns true
* expect($('<div><span class="some-class"></span></div>')).toContainElement('span.some-class')
*/
toContainElement(selector: string): boolean;
/**
* Check to see if the set of matched elements matches the given selector
*
* @example
* expect($('<span></span>').addClass('js-something')).toBeMatchedBy('.js-something')
*
* @returns {Boolean} true if DOM contains the element
*/
toBeMatchedBy(selector: string): boolean;
/**
* Only for tags that have disabled attribute
* @example
* // returns true
* expect('<input type="submit" disabled="disabled"/>').toBeDisabled()
*/
toBeDisabled(): boolean;
/**
* Check if DOM element is focused
* @example
* // returns true
* expect($('<input type="text" />').focus()).toBeFocused()
*/
toBeFocused(): boolean;
/**
* Checks if DOM element handles event.
*
* @example
* // returns true
* expect($form).toHandle("submit")
*/
toHandle(eventName: string): boolean;
/**
* Assigns a callback to an event of the DOM element.
*
* @param eventName Name of the event to assign the callback to.
* @param eventHandler Callback function to be assigned.
*
* @example
* expect($form).toHandleWith("submit", yourSubmitCallback)
*/
toHandleWith(eventName: string, eventHandler : JQueryCallback): boolean;
/**
* Checks if event was triggered.
*/
toHaveBeenTriggered(): boolean;
/**
* Checks if the event has been triggered on selector.
* @param selector Selector that should have triggered the event.
*/
<API key>(selector: string): boolean;
/**
* Checks if the event has been triggered on selector.
* @param selector Selector that should have triggered the event.
* @param args Extra arguments to be passed to jQuery events functions.
*/
<API key>(selector: string, ...args: any[]): boolean;
/**
* Checks if event propagation has been prevented.
*/
toHaveBeenPrevented(): boolean;
/**
* Checks if event propagation has been prevented on element with selector.
*
* @param selector Selector that should have prevented the event.
*/
<API key>(selector: string): boolean;
/**
* Checks if event propagation has been stopped.
*
* @example
* // returns true
* var spyEvent = spyOnEvent('#some_element', 'click')
* $('#some_element').click(function (event){event.stopPropagation();})
* $('#some_element').click()
* expect(spyEvent).toHaveBeenStopped()
*/
toHaveBeenStopped(): boolean;
/**
* Checks if event propagation has been stopped by an element with the given selector.
* @param selector Selector of the element that should have stopped the event propagation.
*
* @example
* // returns true
* $('#some_element').click(function (event){event.stopPropagation();})
* $('#some_element').click()
* expect('click').toHaveBeenStoppedOn('#some_element')
*/
toHaveBeenStoppedOn(selector: string): boolean;
/**
* Checks to see if the matched element is attached to the DOM.
* @example
* expect($('#id-name')[0]).toBeInDOM()
*/
toBeInDOM(): boolean;
}
interface JQueryEventSpy {
selector: string;
eventName: string;
handler(eventObject: JQueryEventObject): any;
reset(): any;
}
interface JasmineJQuery {
<API key>(html: string): string;
elementToString(element: JQuery): string;
matchersClass: any;
events: JasmineJQueryEvents;
}
interface JasmineJQueryEvents {
spyOn(selector: string, eventName: string): JQueryEventSpy;
args(selector: string, eventName: string): any;
wasTriggered(selector: string, eventName: string): boolean;
wasTriggeredWith(selector: string, eventName: string, expectedArgs: any, env: jasmine.Env): boolean;
wasPrevented(selector: string, eventName: string): boolean;
wasStopped(selector: string, eventName: string): boolean;
cleanUp() : void;
}
var JQuery: JasmineJQuery;
} |
function identity(value) {
return value;
}
module.exports = identity; |
.moment-picker { position: relative; display: block; }
.moment-picker .<API key> { cursor: pointer; }
.moment-picker .<API key> { color: #404040; min-width: 15em; background: #fff; padding: 4px; border: 1px solid #f0f3f4; border-radius: 4px; position: absolute;
top: 100%; margin-top: 4px; margin-left: -.5em; box-shadow: 0 2px 4px rgba(0, 0, 0, .075); z-index: 5; }
.moment-picker .<API key>:before,
.moment-picker .<API key>:after { content: ''; display: block; width: 0; height: 0; border: 8px solid transparent; border-top: none; position: absolute;
top: -9px; left: 15px; }
.moment-picker .<API key>:before { border-bottom-color: #f0f3f4; border-width: 9px; }
.moment-picker .<API key>:after { border-bottom-color: #fff; margin-top: 1px; margin-left: 1px; }
.moment-picker table { border-collapse: collapse; border-spacing: 0; min-width: 100%; table-layout: fixed; }
/* picker on top */
.moment-picker.top .<API key> { top: auto; bottom: 100%; margin-top: auto; margin-bottom: 4px; }
.moment-picker.top .<API key>:before,
.moment-picker.top .<API key>:after { border: 8px solid transparent; border-bottom: none; top: auto; bottom: -9px; }
.moment-picker.top .<API key>:before { border-top-color: #f0f3f4; border-width: 9px; }
.moment-picker.top .<API key>:after { border-top-color: #fff; margin-top: auto; margin-bottom: 1px; }
/* picker on left */
.moment-picker.left .<API key> { right: 0; margin-left: auto; margin-right: -.5em; }
.moment-picker.left .<API key>:before,
.moment-picker.left .<API key>:after { left: auto; right: 15px; }
.moment-picker.left .<API key>:after { margin-left: auto; margin-right: 1px; }
/* all views */
.moment-picker th { font-weight: bold; }
.moment-picker th:first-child,
.moment-picker th:last-child { width: 2em; }
.moment-picker th,
.moment-picker td { padding: 0; text-align: center; min-width: 2em; height: 2em; text-shadow: 0 1px 0 rgba(255, 255, 255, .9); cursor: pointer; border-radius: 4px; }
.moment-picker td.today { background: #e4eef5; color: #404040; text-shadow: 0 1px 0 rgba(255, 255, 255, .9); }
.moment-picker th:hover,
.moment-picker td:hover { background: #fafbfb;
background-image: -<API key>(#f0f3f4, #fafbfb);
background-image: -moz-linear-gradient(#f0f3f4, #fafbfb);
background-image: -ms-linear-gradient(#f0f3f4, #fafbfb);
background-image: -o-linear-gradient(#f0f3f4, #fafbfb);
background-image: linear-gradient(#f0f3f4, #fafbfb); }
.moment-picker td.selected { color: #fff; text-shadow: 0 -1px 0 rgba(0, 0, 0, .3); border-color: #3ca0dd; background: #45b1e8;
background-image: -<API key>(#45b1e8, #3097de);
background-image: -moz-linear-gradient(#45b1e8, #3097de);
background-image: -ms-linear-gradient(#45b1e8, #3097de);
background-image: -o-linear-gradient(#45b1e8, #3097de);
background-image: linear-gradient(#45b1e8, #3097de); }
.moment-picker td.highlighted { background: rgba(0, 0, 0, .15)
background-image: -<API key>(transparent, rgba(0, 0, 0, .1));
background-image: -moz-radial-gradient(transparent, rgba(0, 0, 0, .1));
background-image: -ms-radial-gradient(transparent, rgba(0, 0, 0, .1));
background-image: -o-radial-gradient(transparent, rgba(0, 0, 0, .1));
background-image: radial-gradient(transparent, rgba(0, 0, 0, .1)); }
.moment-picker th.disabled,
.moment-picker th.disabled:hover,
.moment-picker td.disabled,
.moment-picker td.disabled:hover { color: #abbbc7; background: none; cursor: default; }
/* decade view - year view */
.moment-picker .decade-view td,
.moment-picker .year-view td { height: 3.4em; }
/* month view */
.moment-picker .month-view .<API key> th { background: none; cursor: default; }
.moment-picker .month-view td { width: 1.4285714286em; }
/* day view, hour view */
.moment-picker .day-view td,
.moment-picker .hour-view td { height: 2.3333333333em; }
/* minute view */
.moment-picker .minute-view td { height: 1.8em; } |
namespace Caliburn.Micro.WPF.Tests {
using System;
using System.Globalization;
using System.Linq;
using Xunit;
public class <API key> {
[Fact]
public void <API key>() {
var conductor = new Conductor<IScreen>.Collection.OneActive();
var conducted = new Screen();
conductor.Items.Add(conducted);
Assert.Contains(conducted, conductor.GetChildren());
}
[Fact]
public void <API key>() {
var conductor = new Conductor<IScreen>.Collection.OneActive();
var conducted = new Screen();
conductor.Items.Add(conducted);
Assert.Equal(conductor, conducted.Parent);
}
[Fact]
public void <API key>() {
var conductor = new Conductor<IScreen>.Collection.OneActive();
var originalConducted = new Screen();
conductor.Items.Add(originalConducted);
var newConducted = new Screen();
conductor.Items[0] = newConducted;
Assert.Equal(conductor, newConducted.Parent);
}
[Fact]
public void <API key>() {
var conductor = new Conductor<IScreen>.Collection.OneActive();
var conducted = new Screen();
conductor.Items.Add(conducted);
((IActivate)conductor).Activate();
conductor.ActivateItem(conducted);
Assert.True(conducted.IsActive);
Assert.Equal(conducted, conductor.ActiveItem);
}
[Fact]
public void <API key>() {
var conductor = new Conductor<IScreen>.Collection.OneActive();
var conducted = new StateScreen { IsClosable = true };
conductor.Items.Add(conducted);
((IActivate)conductor).Activate();
conductor.CanClose(Assert.True);
Assert.False(conducted.IsClosed);
}
[Fact(Skip = "Investigating close issue. http://caliburnmicro.codeplex.com/discussions/275824")]
public void <API key>() {
var conductor = new Conductor<IScreen>.Collection.OneActive { CloseStrategy = new <API key><IScreen>(true) };
var conducted = new StateScreen { IsClosable = true };
conductor.Items.Add(conducted);
((IActivate)conductor).Activate();
conductor.CanClose(Assert.True);
Assert.True(conducted.IsClosed);
}
[Fact(Skip = "ActiveItem currently set regardless of IsActive value. See http://caliburnmicro.codeplex.com/discussions/276375")]
public void <API key>() {
var conductor = new Conductor<IScreen>.Collection.OneActive();
var conducted = new Screen();
conductor.Items.Add(conducted);
conductor.ActivateItem(conducted);
Assert.False(conducted.IsActive);
Assert.NotEqual(conducted, conductor.ActiveItem);
}
[Fact]
public void <API key>() {
var conductor = new Conductor<IScreen>.Collection.OneActive();
var conducted = new Screen();
conductor.Items.Add(conducted);
conductor.Items.RemoveAt(0);
Assert.NotEqual(conductor, conducted.Parent);
}
[Fact(Skip = "This is not possible as we don't get the removed items in the event handler.")]
public void <API key>()
{
var conductor = new Conductor<IScreen>.Collection.OneActive();
var conducted = new Screen();
conductor.Items.Add(conducted);
conductor.Items.Clear();
Assert.NotEqual(conductor, conducted.Parent);
}
[Fact]
public void <API key>()
{
var conductor = new Conductor<IScreen>.Collection.OneActive();
var conducted = new Screen();
conductor.Items.Add(conducted);
var conducted2 = new Screen();
conductor.Items[0] = conducted2;
Assert.NotEqual(conductor, conducted.Parent);
Assert.Equal(conductor, conducted2.Parent);
}
[Fact(Skip = "Behavior currently allowed; under investigation. See http://caliburnmicro.codeplex.com/discussions/276373")]
public void <API key>() {
var conductor = new Conductor<IScreen>.Collection.OneActive();
Assert.Throws<<API key>>(() => conductor.Items.Add(conductor));
}
[Fact]
public void TryCloseStressTest()
{
var conductor = new Conductor<IScreen>.Collection.OneActive();
var conducted = Enumerable.Range(0, 10000)
.Select(i => new Screen {DisplayName = i.ToString(CultureInfo.InvariantCulture)});
conductor.Items.AddRange(conducted);
var defered1 = new DeferredCloseScreen {DisplayName = "d1", IsClosable = true};
var defered2 = new DeferredCloseScreen {DisplayName = "d2", IsClosable = true};
conductor.Items.Insert(0, defered1);
conductor.Items.Insert(500, defered2);
var finished = false;
conductor.CanClose(canClose => {
finished = true;
Assert.True(canClose);
});
Assert.False(finished);
defered1.TryClose();
defered2.TryClose();
Assert.True(finished);
}
class StateScreen : Screen {
public Boolean IsClosed { get; private set; }
public Boolean IsClosable { get; set; }
public override void CanClose(Action<bool> callback) {
callback(IsClosable);
}
protected override void OnDeactivate(bool close) {
base.OnDeactivate(close);
IsClosed = close;
}
}
class DeferredCloseScreen : StateScreen {
Action<bool> closeCallback;
public override void CanClose(Action<bool> callback) {
closeCallback = callback;
}
public override void TryClose(bool? dialogResult = null) {
if (closeCallback != null) {
closeCallback(IsClosable);
}
}
}
}
} |
#include "standardpch.h"
#include "icorjitinfo.h"
#include "<API key>.h"
#include "ieememorymanager.h"
#include "icorjitcompiler.h"
#include "spmiutil.h"
// Stuff on ICorStaticInfo
// ICorMethodInfo
// return flags (defined above, CORINFO_FLG_PUBLIC ...)
DWORD interceptor_ICJI::getMethodAttribs(<API key> ftn )
{
mcs->AddCall("getMethodAttribs");
return <API key>->getMethodAttribs(ftn);
}
// sets private JIT flags, which can be, retrieved using getAttrib.
void interceptor_ICJI::setMethodAttribs(<API key> ftn,
<API key> attribs )
{
mcs->AddCall("setMethodAttribs");
<API key>->setMethodAttribs(ftn, attribs);
}
// Given a method descriptor ftnHnd, extract signature information into sigInfo
// 'memberParent' is typically only set when verifying. It should be the
// result of calling getMemberParent.
void interceptor_ICJI::getMethodSig(<API key> ftn,
CORINFO_SIG_INFO* sig, /* OUT */
<API key> memberParent
)
{
mcs->AddCall("getMethodSig");
<API key>->getMethodSig(ftn, sig, memberParent);
}
// return information about a method private to the implementation
// returns false if method is not IL, or is otherwise unavailable.
// This method is used to fetch data needed to inline functions
bool interceptor_ICJI::getMethodInfo(<API key> ftn,
CORINFO_METHOD_INFO* info /* OUT */
)
{
mcs->AddCall("getMethodInfo");
return <API key>->getMethodInfo(ftn, info);
}
// Decides if you have any limitations for inlining. If everything's OK, it will return
// INLINE_PASS and will fill out pRestrictions with a mask of restrictions the caller of this
// function must respect. If caller passes pRestrictions = nullptr, if there are any restrictions
// INLINE_FAIL will be returned
// The callerHnd must be the immediate caller (i.e. when we have a chain of inlined calls)
// The inlined method need not be verified
CorInfoInline interceptor_ICJI::canInline(<API key> callerHnd,
<API key> calleeHnd,
DWORD* pRestrictions /* OUT */
)
{
mcs->AddCall("canInline");
return <API key>->canInline(callerHnd, calleeHnd, pRestrictions);
}
// Reports whether or not a method can be inlined, and why. canInline is responsible for reporting all
// inlining results when it returns INLINE_FAIL and INLINE_NEVER. All other results are reported by the
// JIT.
void interceptor_ICJI::<API key>(<API key> inlinerHnd,
<API key> inlineeHnd,
CorInfoInline inlineResult,
const char* reason)
{
mcs->AddCall("<API key>");
<API key>-><API key>(inlinerHnd, inlineeHnd, inlineResult, reason);
}
// Returns false if the call is across security boundaries thus we cannot tailcall
// The callerHnd must be the immediate caller (i.e. when we have a chain of inlined calls)
bool interceptor_ICJI::canTailCall(<API key> callerHnd,
<API key> declaredCalleeHnd,
<API key> exactCalleeHnd,
bool fIsTailPrefix
)
{
mcs->AddCall("canTailCall");
return <API key>->canTailCall(callerHnd, declaredCalleeHnd, exactCalleeHnd, fIsTailPrefix);
}
// Reports whether or not a method can be tail called, and why.
// canTailCall is responsible for reporting all results when it returns
// false. All other results are reported by the JIT.
void interceptor_ICJI::<API key>(<API key> callerHnd,
<API key> calleeHnd,
bool fIsTailPrefix,
CorInfoTailCall tailCallResult,
const char* reason)
{
mcs->AddCall("<API key>");
<API key>-><API key>(callerHnd, calleeHnd, fIsTailPrefix, tailCallResult, reason);
}
// get individual exception handler
void interceptor_ICJI::getEHinfo(<API key> ftn,
unsigned EHnumber,
CORINFO_EH_CLAUSE* clause /* OUT */
)
{
mcs->AddCall("getEHinfo");
<API key>->getEHinfo(ftn, EHnumber, clause);
}
// return class it belongs to
<API key> interceptor_ICJI::getMethodClass(<API key> method)
{
mcs->AddCall("getMethodClass");
return <API key>->getMethodClass(method);
}
// return module it belongs to
<API key> interceptor_ICJI::getMethodModule(<API key> method)
{
mcs->AddCall("getMethodModule");
return <API key>->getMethodModule(method);
}
// This function returns the offset of the specified method in the
// vtable of it's owning class or interface.
void interceptor_ICJI::<API key>(<API key> method,
unsigned* offsetOfIndirection, /* OUT */
unsigned* <API key>, /* OUT */
bool* isRelative /* OUT */
)
{
mcs->AddCall("<API key>");
<API key>-><API key>(method, offsetOfIndirection, <API key>, isRelative);
}
// Find the virtual method in implementingClass that overrides virtualMethod.
// Return null if devirtualization is not possible.
<API key> interceptor_ICJI::<API key>(<API key> virtualMethod,
<API key> implementingClass,
<API key> ownerType)
{
mcs->AddCall("<API key>");
return <API key>-><API key>(virtualMethod, implementingClass, ownerType);
}
// Get the unboxed entry point for a method, if possible.
<API key> interceptor_ICJI::getUnboxedEntry(<API key> ftn, bool* <API key>)
{
mcs->AddCall("getUnboxedEntry");
return <API key>->getUnboxedEntry(ftn, <API key>);
}
// Given T, return the type of the default EqualityComparer<T>.
// Returns null if the type can't be determined exactly.
<API key> interceptor_ICJI::<API key>(<API key> cls)
{
mcs->AddCall("<API key>");
return <API key>-><API key>(cls);
}
void interceptor_ICJI::<API key>(<API key>* pResolvedToken,
<API key>* pResult)
{
mcs->AddCall("<API key>");
<API key>-><API key>(pResolvedToken, pResult);
}
// If a method's attributes have (getMethodAttribs) <API key> set,
// getIntrinsicID() returns the intrinsic ID.
CorInfoIntrinsics interceptor_ICJI::getIntrinsicID(<API key> method, bool* pMustExpand /* OUT */
)
{
mcs->AddCall("getIntrinsicID");
return <API key>->getIntrinsicID(method, pMustExpand);
}
// Is the given type in System.Private.Corelib and marked with IntrinsicAttribute?
bool interceptor_ICJI::isIntrinsicType(<API key> classHnd)
{
mcs->AddCall("isIntrinsicType");
return <API key>->isIntrinsicType(classHnd);
}
// return the unmanaged calling convention for a PInvoke
<API key> interceptor_ICJI::<API key>(<API key> method)
{
mcs->AddCall("<API key>");
return <API key>-><API key>(method);
}
// return if any marshaling is required for PInvoke methods. Note that
// method == 0 => calli. The call site sig is only needed for the varargs or calli case
BOOL interceptor_ICJI::<API key>(<API key> method, CORINFO_SIG_INFO* callSiteSig)
{
mcs->AddCall("<API key>");
return <API key>-><API key>(method, callSiteSig);
}
// Check constraints on method type arguments (only).
// The parent class should be checked separately using <API key>(parent).
BOOL interceptor_ICJI::<API key>(<API key> parent, // the exact parent of the method
<API key> method)
{
mcs->AddCall("<API key>");
return <API key>-><API key>(parent, method);
}
// Given a delegate target class, a target method parent class, a target method,
// a delegate class, check if the method signature is compatible with the Invoke method of the delegate
// (under the typical instantiation of any free type variables in the memberref signatures).
BOOL interceptor_ICJI::<API key>(
<API key> objCls, /* type of the delegate target, if any */
<API key> methodParentCls, /* exact parent of the target method, if any */
<API key> method, /* (representative) target method, if any */
<API key> delegateCls, /* exact type of the delegate */
BOOL* pfIsOpenDelegate /* is the delegate open */
)
{
mcs->AddCall("<API key>");
return <API key>-><API key>(objCls, methodParentCls, method, delegateCls, pfIsOpenDelegate);
}
// Indicates if the method is an instance of the generic
// method that passes (or has passed) verification
<API key> interceptor_ICJI::<API key>(<API key> method /* IN
*/
)
{
mcs->AddCall("<API key>");
return <API key>-><API key>(method);
}
// Loads the constraints on a typical method definition, detecting cycles;
// for use in verification.
void interceptor_ICJI::<API key>(<API key> method,
BOOL* <API key>, /* OUT */
BOOL* <API key> /* OUT */
)
{
mcs->AddCall("<API key>");
<API key>-><API key>(method, <API key>,
<API key>);
}
// Returns enum whether the method does not require verification
// Also see ICorModuleInfo::canSkipVerification
<API key> interceptor_ICJI::<API key>(<API key> ftnHandle)
{
mcs->AddCall("<API key>");
return <API key>-><API key>(ftnHandle);
}
// load and restore the method
void interceptor_ICJI::<API key>(<API key> method)
{
mcs->AddCall("<API key>");
<API key>-><API key>(method);
}
<API key> interceptor_ICJI::<API key>(<API key> method)
{
mcs->AddCall("<API key>");
return <API key>-><API key>(method);
}
// Returns the global cookie for the /GS unsafe buffer checks
// The cookie might be a constant value (JIT), or a handle to memory location (Ngen)
void interceptor_ICJI::getGSCookie(GSCookie* pCookieVal, // OUT
GSCookie** ppCookieVal // OUT
)
{
mcs->AddCall("getGSCookie");
<API key>->getGSCookie(pCookieVal, ppCookieVal);
}
// ICorModuleInfo
// Resolve metadata token into runtime method handles.
void interceptor_ICJI::resolveToken(/* IN, OUT */ <API key>* pResolvedToken)
{
mcs->AddCall("resolveToken");
<API key>->resolveToken(pResolvedToken);
}
bool interceptor_ICJI::tryResolveToken(/* IN, OUT */ <API key>* pResolvedToken)
{
mcs->AddCall("tryResolveToken");
return <API key>->tryResolveToken(pResolvedToken);
}
// Signature information about the call sig
void interceptor_ICJI::findSig(<API key> module,
unsigned sigTOK,
<API key> context,
CORINFO_SIG_INFO* sig /* OUT */
)
{
mcs->AddCall("findSig");
<API key>->findSig(module, sigTOK, context, sig);
}
// for Varargs, the signature at the call site may differ from
// the signature at the definition. Thus we need a way of
// fetching the call site information
void interceptor_ICJI::findCallSiteSig(<API key> module,
unsigned methTOK,
<API key> context,
CORINFO_SIG_INFO* sig /* OUT */
)
{
mcs->AddCall("findCallSiteSig");
<API key>->findCallSiteSig(module, methTOK, context, sig);
}
<API key> interceptor_ICJI::<API key>(<API key>* pResolvedToken )
{
mcs->AddCall("<API key>");
return <API key>-><API key>(pResolvedToken);
}
// Returns true if the module does not require verification
// If <API key>=TRUE, the function only checks that the
// module does not currently require verification in the current AppDomain.
// This decision could change in the future, and so should not be cached.
// If it is cached, it should only be used as a hint.
// This is only used by ngen for calculating certain hints.
// Returns enum whether the module does not require verification
// Also see ICorMethodInfo::<API key>();
<API key> interceptor_ICJI::canSkipVerification(<API key> module
)
{
mcs->AddCall("canSkipVerification");
return <API key>->canSkipVerification(module);
}
// Checks if the given metadata token is valid
BOOL interceptor_ICJI::isValidToken(<API key> module,
unsigned metaTOK
)
{
mcs->AddCall("isValidToken");
return <API key>->isValidToken(module, metaTOK);
}
// Checks if the given metadata token is valid StringRef
BOOL interceptor_ICJI::isValidStringRef(<API key> module,
unsigned metaTOK
)
{
mcs->AddCall("isValidStringRef");
return <API key>->isValidStringRef(module, metaTOK);
}
BOOL interceptor_ICJI::<API key>(<API key> scope)
{
mcs->AddCall("<API key>");
return <API key>-><API key>(scope);
}
// ICorClassInfo
// If the value class 'cls' is isomorphic to a primitive type it will
// return that type, otherwise it will return <API key>
CorInfoType interceptor_ICJI::asCorInfoType(<API key> cls)
{
mcs->AddCall("asCorInfoType");
return <API key>->asCorInfoType(cls);
}
// for completeness
const char* interceptor_ICJI::getClassName(<API key> cls)
{
mcs->AddCall("getClassName");
return <API key>->getClassName(cls);
}
const char* interceptor_ICJI::<API key>(<API key> cls, const char** namespaceName)
{
mcs->AddCall("<API key>");
return <API key>-><API key>(cls, namespaceName);
}
<API key> interceptor_ICJI::<API key>(<API key> cls, unsigned index)
{
mcs->AddCall("<API key>");
return <API key>-><API key>(cls, index);
}
// Append a (possibly truncated) representation of the type cls to the preallocated buffer ppBuf of length pnBufLen
// If fNamespace=TRUE, include the namespace/enclosing classes
// If fFullInst=TRUE (regardless of fNamespace and fAssembly), include namespace and assembly for any type parameters
// If fAssembly=TRUE, suffix with a comma and the full assembly qualification
// return size of representation
int interceptor_ICJI::appendClassName(<API key>(*pnBufLen) WCHAR** ppBuf,
int* pnBufLen,
<API key> cls,
BOOL fNamespace,
BOOL fFullInst,
BOOL fAssembly)
{
mcs->AddCall("appendClassName");
return <API key>->appendClassName(ppBuf, pnBufLen, cls, fNamespace, fFullInst, fAssembly);
}
// Quick check whether the type is a value class. Returns the same value as getClassAttribs(cls) &
// <API key>, except faster.
BOOL interceptor_ICJI::isValueClass(<API key> cls)
{
mcs->AddCall("isValueClass");
return <API key>->isValueClass(cls);
}
// Decides how the JIT should do the optimization to inline the check for
// GetTypeFromHandle(handle) == obj.GetType() (for <API key>)
// GetTypeFromHandle(X) == GetTypeFromHandle(Y) (for <API key>)
<API key> interceptor_ICJI::canInlineTypeCheck(<API key> cls,
<API key> source)
{
mcs->AddCall("canInlineTypeCheck");
return <API key>->canInlineTypeCheck(cls, source);
}
// If this method returns true, JIT will do optimization to inline the check for
// GetTypeFromHandle(handle) == obj.GetType()
BOOL interceptor_ICJI::<API key>(<API key> cls)
{
mcs->AddCall("<API key>");
return <API key>-><API key>(cls);
}
// return flags (defined above, CORINFO_FLG_PUBLIC ...)
DWORD interceptor_ICJI::getClassAttribs(<API key> cls)
{
mcs->AddCall("getClassAttribs");
return <API key>->getClassAttribs(cls);
}
// Returns "TRUE" iff "cls" is a struct type such that return buffers used for returning a value
// of this type must be stack-allocated. This will generally be true only if the struct
// contains GC pointers, and does not exceed some size limit. Maintaining this as an invariant allows
// an optimization: the JIT may assume that return buffer pointers for return types for which this predicate
// returns TRUE are always stack allocated, and thus, that stores to the GC-pointer fields of such return
// buffers do not require GC write barriers.
BOOL interceptor_ICJI::<API key>(<API key> cls)
{
mcs->AddCall("<API key>");
return <API key>-><API key>(cls);
}
<API key> interceptor_ICJI::getClassModule(<API key> cls)
{
mcs->AddCall("getClassModule");
return <API key>->getClassModule(cls);
}
// Returns the assembly that contains the module "mod".
<API key> interceptor_ICJI::getModuleAssembly(<API key> mod)
{
mcs->AddCall("getModuleAssembly");
return <API key>->getModuleAssembly(mod);
}
// Returns the name of the assembly "assem".
const char* interceptor_ICJI::getAssemblyName(<API key> assem)
{
mcs->AddCall("getAssemblyName");
return <API key>->getAssemblyName(assem);
}
// Allocate and delete process-lifetime objects. Should only be
// referred to from static fields, lest a leak occur.
// Note that "LongLifetimeFree" does not execute destructors, if "obj"
// is an array of a struct type with a destructor.
void* interceptor_ICJI::LongLifetimeMalloc(size_t sz)
{
mcs->AddCall("LongLifetimeMalloc");
return <API key>->LongLifetimeMalloc(sz);
}
void interceptor_ICJI::LongLifetimeFree(void* obj)
{
mcs->AddCall("LongLifetimeFree");
<API key>->LongLifetimeFree(obj);
}
size_t interceptor_ICJI::<API key>(<API key> cls,
<API key>* pModule,
void** ppIndirection)
{
mcs->AddCall("<API key>");
return <API key>-><API key>(cls, pModule, ppIndirection);
}
// return the number of bytes needed by an instance of the class
unsigned interceptor_ICJI::getClassSize(<API key> cls)
{
mcs->AddCall("getClassSize");
return <API key>->getClassSize(cls);
}
// return the number of bytes needed by an instance of the class allocated on the heap
unsigned interceptor_ICJI::getHeapClassSize(<API key> cls)
{
mcs->AddCall("getHeapClassSize");
return <API key>->getHeapClassSize(cls);
}
BOOL interceptor_ICJI::canAllocateOnStack(<API key> cls)
{
mcs->AddCall("canAllocateOnStack");
return <API key>->canAllocateOnStack(cls);
}
unsigned interceptor_ICJI::<API key>(<API key> cls, BOOL fDoubleAlignHint)
{
mcs->AddCall("<API key>");
return <API key>-><API key>(cls, fDoubleAlignHint);
}
// This is only called for Value classes. It returns a boolean array
// in representing of 'cls' from a GC perspective. The class is
// assumed to be an array of machine words
// (of length // getClassSize(cls) / sizeof(void*)),
// 'gcPtrs' is a pointer to an array of BYTEs of this length.
// getClassGClayout fills in this array so that gcPtrs[i] is set
// to one of the CorInfoGCType values which is the GC type of
// the i-th machine word of an object of type 'cls'
// returns the number of GC pointers in the array
unsigned interceptor_ICJI::getClassGClayout(<API key> cls,
BYTE* gcPtrs /* OUT */
)
{
mcs->AddCall("getClassGClayout");
return <API key>->getClassGClayout(cls, gcPtrs);
}
// returns the number of instance fields in a class
unsigned interceptor_ICJI::<API key>(<API key> cls
)
{
mcs->AddCall("<API key>");
return <API key>-><API key>(cls);
}
<API key> interceptor_ICJI::getFieldInClass(<API key> clsHnd, INT num)
{
mcs->AddCall("getFieldInClass");
return <API key>->getFieldInClass(clsHnd, num);
}
BOOL interceptor_ICJI::checkMethodModifier(<API key> hMethod, LPCSTR modifier, BOOL fOptional)
{
mcs->AddCall("checkMethodModifier");
return <API key>->checkMethodModifier(hMethod, modifier, fOptional);
}
// returns the "NEW" helper optimized for "newCls."
CorInfoHelpFunc interceptor_ICJI::getNewHelper(<API key>* pResolvedToken,
<API key> callerHandle,
bool* pHasSideEffects)
{
mcs->AddCall("getNewHelper");
return <API key>->getNewHelper(pResolvedToken, callerHandle, pHasSideEffects);
}
// returns the newArr (1-Dim array) helper optimized for "arrayCls."
CorInfoHelpFunc interceptor_ICJI::getNewArrHelper(<API key> arrayCls)
{
mcs->AddCall("getNewArrHelper");
return <API key>->getNewArrHelper(arrayCls);
}
// returns the optimized "IsInstanceOf" or "ChkCast" helper
CorInfoHelpFunc interceptor_ICJI::getCastingHelper(<API key>* pResolvedToken, bool fThrowing)
{
mcs->AddCall("getCastingHelper");
return <API key>->getCastingHelper(pResolvedToken, fThrowing);
}
// returns helper to trigger static constructor
CorInfoHelpFunc interceptor_ICJI::<API key>(<API key> clsHnd)
{
mcs->AddCall("<API key>");
return <API key>-><API key>(clsHnd);
}
CorInfoHelpFunc interceptor_ICJI::<API key>(<API key> ftn)
{
mcs->AddCall("<API key>");
return <API key>-><API key>(ftn);
}
// This is not pretty. Boxing nullable<T> actually returns
// a boxed<T> not a boxed Nullable<T>. This call allows the verifier
// to call back to the EE on the 'box' instruction and get the transformed
// type to use for verification.
<API key> interceptor_ICJI::getTypeForBox(<API key> cls)
{
mcs->AddCall("getTypeForBox");
return <API key>->getTypeForBox(cls);
}
// returns the correct box helper for a particular class. Note
// that if this returns CORINFO_HELP_BOX, the JIT can assume
// 'standard' boxing (allocate object and copy), and optimize
CorInfoHelpFunc interceptor_ICJI::getBoxHelper(<API key> cls)
{
mcs->AddCall("getBoxHelper");
return <API key>->getBoxHelper(cls);
}
// returns the unbox helper. If 'helperCopies' points to a true
// value it means the JIT is requesting a helper that unboxes the
// value into a particular location and thus has the signature
// void unboxHelper(void* dest, <API key> cls, Object* obj)
// Otherwise (it is null or points at a FALSE value) it is requesting
// a helper that returns a pointer to the unboxed data
// void* unboxHelper(<API key> cls, Object* obj)
// The EE has the option of NOT returning the copy style helper
// (But must be able to always honor the non-copy style helper)
// The EE set 'helperCopies' on return to indicate what kind of
// helper has been created.
CorInfoHelpFunc interceptor_ICJI::getUnBoxHelper(<API key> cls)
{
mcs->AddCall("getUnBoxHelper");
return <API key>->getUnBoxHelper(cls);
}
bool interceptor_ICJI::getReadyToRunHelper(<API key>* pResolvedToken,
CORINFO_LOOKUP_KIND* pGenericLookupKind,
CorInfoHelpFunc id,
<API key>* pLookup)
{
mcs->AddCall("getReadyToRunHelper");
return <API key>->getReadyToRunHelper(pResolvedToken, pGenericLookupKind, id, pLookup);
}
void interceptor_ICJI::<API key>(<API key>* pTargetMethod,
<API key> delegateType,
CORINFO_LOOKUP* pLookup)
{
mcs->AddCall("<API key>");
<API key>-><API key>(pTargetMethod, delegateType, pLookup);
}
const char* interceptor_ICJI::getHelperName(CorInfoHelpFunc funcNum)
{
mcs->AddCall("getHelperName");
return <API key>->getHelperName(funcNum);
}
// This function tries to initialize the class (run the class constructor).
// this function returns whether the JIT must insert helper calls before
// accessing static field or method.
// See code:ICorClassInfo#ClassConstruction.
<API key> interceptor_ICJI::initClass(
<API key> field, // Non-nullptr - inquire about cctor trigger before static field access
// nullptr - inquire about cctor trigger in method prolog
<API key> method, // Method referencing the field or prolog
<API key> context, // Exact context of method
BOOL speculative // TRUE means don't actually run it
)
{
mcs->AddCall("initClass");
return <API key>->initClass(field, method, context, speculative);
}
// This used to be called "loadClass". This records the fact
// that the class must be loaded (including restored if necessary) before we execute the
// code that we are currently generating. When jitting code
// the function loads the class immediately. When zapping code
// the zapper will if necessary use the call to record the fact that we have
// to do a fixup/restore before running the method currently being generated.
// This is typically used to ensure value types are loaded before zapped
// code that manipulates them is executed, so that the GC can access information
// about those value types.
void interceptor_ICJI::<API key>(<API key> cls)
{
mcs->AddCall("<API key>");
<API key>-><API key>(cls);
}
// returns the class handle for the special builtin classes
<API key> interceptor_ICJI::getBuiltinClass(CorInfoClassId classId)
{
mcs->AddCall("getBuiltinClass");
return <API key>->getBuiltinClass(classId);
}
// "System.Int32" ==> CORINFO_TYPE_INT..
CorInfoType interceptor_ICJI::<API key>(<API key> cls)
{
mcs->AddCall("<API key>");
return <API key>-><API key>(cls);
}
// "System.Int32" ==> CORINFO_TYPE_INT..
// "System.UInt32" ==> CORINFO_TYPE_UINT..
CorInfoType interceptor_ICJI::<API key>(<API key> cls)
{
mcs->AddCall("<API key>");
return <API key>-><API key>(cls);
}
// TRUE if child is a subtype of parent
// if parent is an interface, then does child implement / extend parent
BOOL interceptor_ICJI::canCast(<API key> child, // subtype (extends parent)
<API key> parent // base type
)
{
mcs->AddCall("canCast");
return <API key>->canCast(child, parent);
}
// TRUE if cls1 and cls2 are considered equivalent types.
BOOL interceptor_ICJI::areTypesEquivalent(<API key> cls1, <API key> cls2)
{
mcs->AddCall("areTypesEquivalent");
return <API key>->areTypesEquivalent(cls1, cls2);
}
// See if a cast from fromClass to toClass will succeed, fail, or needs
// to be resolved at runtime.
TypeCompareState interceptor_ICJI::compareTypesForCast(<API key> fromClass, <API key> toClass)
{
mcs->AddCall("compareTypesForCast");
return <API key>->compareTypesForCast(fromClass, toClass);
}
// See if types represented by cls1 and cls2 compare equal, not
// equal, or the comparison needs to be resolved at runtime.
TypeCompareState interceptor_ICJI::<API key>(<API key> cls1, <API key> cls2)
{
mcs->AddCall("<API key>");
return <API key>-><API key>(cls1, cls2);
}
// returns is the intersection of cls1 and cls2.
<API key> interceptor_ICJI::mergeClasses(<API key> cls1, <API key> cls2)
{
mcs->AddCall("mergeClasses");
return <API key>->mergeClasses(cls1, cls2);
}
// Returns true if cls2 is known to be a more specific type than cls1.
BOOL interceptor_ICJI::isMoreSpecificType(<API key> cls1, <API key> cls2)
{
mcs->AddCall("isMoreSpecificType");
return <API key>->isMoreSpecificType(cls1, cls2);
}
// Given a class handle, returns the Parent type.
// For COMObjectType, it returns Class Handle of System.Object.
// Returns 0 if System.Object is passed in.
<API key> interceptor_ICJI::getParentType(<API key> cls)
{
mcs->AddCall("getParentType");
return <API key>->getParentType(cls);
}
// Returns the CorInfoType of the "child type". If the child type is
// not a primitive type, *clsRet will be set.
// Given an Array of Type Foo, returns Foo.
// Given BYREF Foo, returns Foo
CorInfoType interceptor_ICJI::getChildType(<API key> clsHnd, <API key>* clsRet)
{
mcs->AddCall("getChildType");
return <API key>->getChildType(clsHnd, clsRet);
}
// Check constraints on type arguments of this class and parent classes
BOOL interceptor_ICJI::<API key>(<API key> cls)
{
mcs->AddCall("<API key>");
return <API key>-><API key>(cls);
}
// Check if this is a single dimensional array type
BOOL interceptor_ICJI::isSDArray(<API key> cls)
{
mcs->AddCall("isSDArray");
return <API key>->isSDArray(cls);
}
// Get the numbmer of dimensions in an array
unsigned interceptor_ICJI::getArrayRank(<API key> cls)
{
mcs->AddCall("getArrayRank");
return <API key>->getArrayRank(cls);
}
// Get static field data for an array
void* interceptor_ICJI::<API key>(<API key> field, DWORD size)
{
mcs->AddCall("<API key>");
return <API key>-><API key>(field, size);
}
// Check Visibility rules.
<API key> interceptor_ICJI::canAccessClass(
<API key>* pResolvedToken,
<API key> callerHandle,
CORINFO_HELPER_DESC* pAccessHelper /* If canAccessMethod returns something other
than ALLOWED, then this is filled in. */
)
{
mcs->AddCall("canAccessClass");
return <API key>->canAccessClass(pResolvedToken, callerHandle, pAccessHelper);
}
// ICorFieldInfo
// this function is for debugging only. It returns the field name
// and if 'moduleName' is non-null, it sets it to something that will
// says which method (a class name, or a module name)
const char* interceptor_ICJI::getFieldName(<API key> ftn,
const char** moduleName /* OUT */
)
{
mcs->AddCall("getFieldName");
return <API key>->getFieldName(ftn, moduleName);
}
// return class it belongs to
<API key> interceptor_ICJI::getFieldClass(<API key> field)
{
mcs->AddCall("getFieldClass");
return <API key>->getFieldClass(field);
}
// Return the field's type, if it is <API key> 'structType' is set
// the field's value class (if 'structType' == 0, then don't bother
// the structure info).
// 'memberParent' is typically only set when verifying. It should be the
// result of calling getMemberParent.
CorInfoType interceptor_ICJI::getFieldType(<API key> field,
<API key>* structType,
<API key> memberParent
)
{
mcs->AddCall("getFieldType");
return <API key>->getFieldType(field, structType, memberParent);
}
// return the data member's instance offset
unsigned interceptor_ICJI::getFieldOffset(<API key> field)
{
mcs->AddCall("getFieldOffset");
return <API key>->getFieldOffset(field);
}
// TODO: jit64 should be switched to the same plan as the i386 jits - use
// getClassGClayout to figure out the need for writebarrier helper, and inline the copying.
// The interpretted value class copy is slow. Once this happens, <API key>
bool interceptor_ICJI::<API key>(<API key> field)
{
mcs->AddCall("<API key>");
return <API key>-><API key>(field);
}
void interceptor_ICJI::getFieldInfo(<API key>* pResolvedToken,
<API key> callerHandle,
<API key> flags,
CORINFO_FIELD_INFO* pResult)
{
mcs->AddCall("getFieldInfo");
<API key>->getFieldInfo(pResolvedToken, callerHandle, flags, pResult);
}
// Returns true iff "fldHnd" represents a static field.
bool interceptor_ICJI::isFieldStatic(<API key> fldHnd)
{
mcs->AddCall("isFieldStatic");
return <API key>->isFieldStatic(fldHnd);
}
// ICorDebugInfo
// Query the EE to find out where interesting break points
// in the code are. The native compiler will ensure that these places
// have a corresponding break point in native code.
// Note that unless <API key> is specified, this function will
// be used only as a hint and the native compiler should not change its
// code generation.
void interceptor_ICJI::getBoundaries(<API key> ftn, // [IN] method of interest
unsigned int* cILOffsets, // [OUT] size of pILOffsets
DWORD** pILOffsets, // [OUT] IL offsets of interest
// jit MUST free with freeArray!
ICorDebugInfo::BoundaryTypes* implictBoundaries // [OUT] tell jit, all boundries of
// this type
)
{
mcs->AddCall("getBoundaries");
<API key>->getBoundaries(ftn, cILOffsets, pILOffsets, implictBoundaries);
}
// Report back the mapping from IL to native code,
// this map should include all boundaries that 'getBoundaries'
// reported as interesting to the debugger.
// Note that debugger (and profiler) is assuming that all of the
// offsets form a contiguous block of memory, and that the
// OffsetMapping is sorted in order of increasing native offset.
void interceptor_ICJI::setBoundaries(<API key> ftn, // [IN] method of interest
ULONG32 cMap, // [IN] size of pMap
ICorDebugInfo::OffsetMapping* pMap // [IN] map including all points of interest.
// jit allocated with allocateArray, EE
// frees
)
{
mcs->AddCall("setBoundaries");
<API key>->setBoundaries(ftn, cMap, pMap);
}
// Query the EE to find out the scope of local varables.
// normally the JIT would trash variables after last use, but
// under debugging, the JIT needs to keep them live over their
// entire scope so that they can be inspected.
// Note that unless <API key> is specified, this function will
// be used only as a hint and the native compiler should not change its
// code generation.
void interceptor_ICJI::getVars(<API key> ftn, // [IN] method of interest
ULONG32* cVars, // [OUT] size of 'vars'
ICorDebugInfo::ILVarInfo** vars, // [OUT] scopes of variables of interest
// jit MUST free with freeArray!
bool* extendOthers // [OUT] it TRUE, then assume the scope
// of unmentioned vars is entire method
)
{
mcs->AddCall("getVars");
<API key>->getVars(ftn, cVars, vars, extendOthers);
}
// Report back to the EE the location of every variable.
// note that the JIT might split lifetimes into different
// locations etc.
void interceptor_ICJI::setVars(<API key> ftn, // [IN] method of interest
ULONG32 cVars, // [IN] size of 'vars'
ICorDebugInfo::NativeVarInfo* vars // [IN] map telling where local vars are stored at
// what points
// jit allocated with allocateArray, EE frees
)
{
mcs->AddCall("setVars");
<API key>->setVars(ftn, cVars, vars);
}
// Used to allocate memory that needs to handed to the EE.
// For eg, use this to allocated memory for reporting debug info,
// which will be handed to the EE by setVars() and setBoundaries()
void* interceptor_ICJI::allocateArray(ULONG cBytes)
{
mcs->AddCall("allocateArray");
return <API key>->allocateArray(cBytes);
}
// JitCompiler will free arrays passed by the EE using this
// For eg, The EE returns memory in getVars() and getBoundaries()
// to the JitCompiler, which the JitCompiler should release using
// freeArray()
void interceptor_ICJI::freeArray(void* array)
{
mcs->AddCall("freeArray");
<API key>->freeArray(array);
}
// ICorArgInfo
// advance the pointer to the argument list.
// a ptr of 0, is special and always means the first argument
<API key> interceptor_ICJI::getArgNext(<API key> args
)
{
mcs->AddCall("getArgNext");
return <API key>->getArgNext(args);
}
// Get the type of a particular argument
// CORINFO_TYPE_UNDEF is returned when there are no more arguments
// If the type returned is a primitive type (or an enum) *vcTypeRet set to nullptr
// otherwise it is set to the TypeHandle associted with the type
// Enumerations will always look their underlying type (probably should fix this)
// Otherwise vcTypeRet is the type as would be seen by the IL,
// The return value is the type that is used for calling convention purposes
// (Thus if the EE wants a value class to be passed like an int, then it will
// return CORINFO_TYPE_INT
CorInfoTypeWithMod interceptor_ICJI::getArgType(CORINFO_SIG_INFO* sig,
<API key> args,
<API key>* vcTypeRet /* OUT */
)
{
mcs->AddCall("getArgType");
return <API key>->getArgType(sig, args, vcTypeRet);
}
// If the Arg is a CORINFO_TYPE_CLASS fetch the class handle associated with it
<API key> interceptor_ICJI::getArgClass(CORINFO_SIG_INFO* sig,
<API key> args
)
{
mcs->AddCall("getArgClass");
return <API key>->getArgClass(sig, args);
}
// Returns type of HFA for valuetype
CorInfoType interceptor_ICJI::getHFAType(<API key> hClass)
{
mcs->AddCall("getHFAType");
return <API key>->getHFAType(hClass);
}
// Returns the HRESULT of the current exception
HRESULT interceptor_ICJI::GetErrorHRESULT(struct _EXCEPTION_POINTERS* pExceptionPointers)
{
mcs->AddCall("GetErrorHRESULT");
return <API key>->GetErrorHRESULT(pExceptionPointers);
}
// Fetches the message of the current exception
// Returns the size of the message (including terminating null). This can be
// greater than bufferLength if the buffer is insufficient.
ULONG interceptor_ICJI::GetErrorMessage(__inout_ecount(bufferLength) LPWSTR buffer, ULONG bufferLength)
{
mcs->AddCall("GetErrorMessage");
return <API key>->GetErrorMessage(buffer, bufferLength);
}
// returns <API key> if it is OK for the compile to handle the
// exception, abort some work (like the inlining) and continue compilation
// returns <API key> if exception must always be handled by the EE
// things like <API key> ...
// returns <API key> if exception is fixed up by the EE
int interceptor_ICJI::FilterException(struct _EXCEPTION_POINTERS* pExceptionPointers)
{
mcs->AddCall("FilterException");
return <API key>->FilterException(pExceptionPointers);
}
// Cleans up internal EE tracking when an exception is caught.
void interceptor_ICJI::HandleException(struct _EXCEPTION_POINTERS* pExceptionPointers)
{
mcs->AddCall("HandleException");
<API key>->HandleException(pExceptionPointers);
}
void interceptor_ICJI::<API key>(HRESULT result)
{
mcs->AddCall("<API key>");
<API key>-><API key>(result);
}
// Throws an exception defined by the given throw helper.
void interceptor_ICJI::<API key>(const CORINFO_HELPER_DESC* throwHelper)
{
mcs->AddCall("<API key>");
<API key>-><API key>(throwHelper);
}
// Return details about EE internal data structures
void interceptor_ICJI::getEEInfo(CORINFO_EE_INFO* pEEInfoOut)
{
mcs->AddCall("getEEInfo");
<API key>->getEEInfo(pEEInfoOut);
}
// Returns name of the JIT timer log
LPCWSTR interceptor_ICJI::<API key>()
{
mcs->AddCall("<API key>");
return <API key>-><API key>();
}
// Diagnostic methods
// this function is for debugging only. Returns method token.
// Returns mdMethodDefNil for dynamic methods.
mdMethodDef interceptor_ICJI::<API key>(<API key> hMethod)
{
mcs->AddCall("<API key>");
return <API key>-><API key>(hMethod);
}
// this function is for debugging only. It returns the method name
// and if 'moduleName' is non-null, it sets it to something that will
// says which method (a class name, or a module name)
const char* interceptor_ICJI::getMethodName(<API key> ftn,
const char** moduleName /* OUT */
)
{
mcs->AddCall("getMethodName");
return <API key>->getMethodName(ftn, moduleName);
}
const char* interceptor_ICJI::<API key>(<API key> ftn,
const char** className, /* OUT */
const char** namespaceName, /* OUT */
const char** enclosingClassName /* OUT */
)
{
mcs->AddCall("<API key>");
return <API key>-><API key>(ftn, className, namespaceName, enclosingClassName);
}
// this function is for debugging only. It returns a value that
// is will always be the same for a given method. It is used
// to implement the 'jitRange' functionality
unsigned interceptor_ICJI::getMethodHash(<API key> ftn
)
{
mcs->AddCall("getMethodHash");
return <API key>->getMethodHash(ftn);
}
// this function is for debugging only.
size_t interceptor_ICJI::findNameOfToken(<API key> module,
mdToken metaTOK,
__out_ecount(FQNameCapacity) char* szFQName, /* OUT */
size_t FQNameCapacity
)
{
mcs->AddCall("findNameOfToken");
return <API key>->findNameOfToken(module, metaTOK, szFQName, FQNameCapacity);
}
bool interceptor_ICJI::<API key>(
<API key> structHnd,
/* OUT */ <API key>* <API key>)
{
mcs->AddCall("<API key>");
return <API key>-><API key>(structHnd, <API key>);
}
// Stuff on ICorDynamicInfo
DWORD interceptor_ICJI::getThreadTLSIndex(void** ppIndirection)
{
mcs->AddCall("getThreadTLSIndex");
return <API key>->getThreadTLSIndex(ppIndirection);
}
const void* interceptor_ICJI::<API key>(void** ppIndirection)
{
mcs->AddCall("<API key>");
return <API key>-><API key>(ppIndirection);
}
LONG* interceptor_ICJI::<API key>(void** ppIndirection)
{
mcs->AddCall("<API key>");
return <API key>-><API key>(ppIndirection);
}
// return the native entry point to an EE helper (see CorInfoHelpFunc)
void* interceptor_ICJI::getHelperFtn(CorInfoHelpFunc ftnNum, void** ppIndirection)
{
mcs->AddCall("getHelperFtn");
return <API key>->getHelperFtn(ftnNum, ppIndirection);
}
// return a callable address of the function (native code). This function
// may return a different value (depending on whether the method has
// been JITed or not.
void interceptor_ICJI::<API key>(<API key> ftn,
<API key>* pResult, /* OUT */
<API key> accessFlags)
{
mcs->AddCall("<API key>");
<API key>-><API key>(ftn, pResult, accessFlags);
}
// return a directly callable address. This can be used similarly to the
// value returned by <API key>() except that it is
// guaranteed to be multi callable entrypoint.
void interceptor_ICJI::<API key>(<API key> ftn, <API key>* pResult)
{
mcs->AddCall("<API key>");
<API key>-><API key>(ftn, pResult);
}
// get the synchronization handle that is passed to monXstatic function
void* interceptor_ICJI::getMethodSync(<API key> ftn, void** ppIndirection)
{
mcs->AddCall("getMethodSync");
return <API key>->getMethodSync(ftn, ppIndirection);
}
// These entry points must be called if a handle is being embedded in
// the code to be passed to a JIT helper function. (as opposed to just
// being passed back into the ICorInfo interface.)
// get slow lazy string literal helper to use (CORINFO_HELP_STRCNS*).
// Returns CORINFO_HELP_UNDEF if lazy string literal helper cannot be used.
CorInfoHelpFunc interceptor_ICJI::<API key>(<API key> handle)
{
mcs->AddCall("<API key>");
return <API key>-><API key>(handle);
}
<API key> interceptor_ICJI::embedModuleHandle(<API key> handle, void** ppIndirection)
{
mcs->AddCall("embedModuleHandle");
return <API key>->embedModuleHandle(handle, ppIndirection);
}
<API key> interceptor_ICJI::embedClassHandle(<API key> handle, void** ppIndirection)
{
mcs->AddCall("embedClassHandle");
return <API key>->embedClassHandle(handle, ppIndirection);
}
<API key> interceptor_ICJI::embedMethodHandle(<API key> handle, void** ppIndirection)
{
mcs->AddCall("embedMethodHandle");
return <API key>->embedMethodHandle(handle, ppIndirection);
}
<API key> interceptor_ICJI::embedFieldHandle(<API key> handle, void** ppIndirection)
{
mcs->AddCall("embedFieldHandle");
return <API key>->embedFieldHandle(handle, ppIndirection);
}
// Given a module scope (module), a method handle (context) and
// a metadata token (metaTOK), fetch the handle
// (type, field or method) associated with the token.
// If this is not possible at compile-time (because the current method's
// code is shared and the token contains generic parameters)
// then indicate how the handle should be looked up at run-time.
void interceptor_ICJI::embedGenericHandle(<API key>* pResolvedToken,
BOOL fEmbedParent, // TRUE - embeds parent type handle of the field/method
// handle
<API key>* pResult)
{
mcs->AddCall("embedGenericHandle");
<API key>->embedGenericHandle(pResolvedToken, fEmbedParent, pResult);
}
// Return information used to locate the exact enclosing type of the current method.
// Used only to invoke .cctor method from code shared across generic instantiations
// !needsRuntimeLookup statically known (enclosing type of method itself)
// needsRuntimeLookup:
// <API key> use vtable pointer of 'this' param
// <API key> use vtable hidden param
// <API key> use enclosing type of method-desc hidden param
CORINFO_LOOKUP_KIND interceptor_ICJI::<API key>(<API key> context)
{
mcs->AddCall("<API key>");
return <API key>-><API key>(context);
}
// return the unmanaged target *if method has already been prelinked.*
void* interceptor_ICJI::<API key>(<API key> method, void** ppIndirection)
{
mcs->AddCall("<API key>");
return <API key>-><API key>(method, ppIndirection);
}
// return address of fixup area for late-bound PInvoke calls.
void* interceptor_ICJI::<API key>(<API key> method, void** ppIndirection)
{
mcs->AddCall("<API key>");
return <API key>-><API key>(method, ppIndirection);
}
// return address of fixup area for late-bound PInvoke calls.
void interceptor_ICJI::<API key>(<API key> method, <API key>* pLookup)
{
mcs->AddCall("<API key>");
<API key>-><API key>(method, pLookup);
}
// Generate a cookie based on the signature that would needs to be passed
// to <API key>
LPVOID interceptor_ICJI::<API key>(CORINFO_SIG_INFO* szMetaSig, void** ppIndirection)
{
mcs->AddCall("<API key>");
return <API key>-><API key>(szMetaSig, ppIndirection);
}
// returns true if a VM cookie can be generated for it (might be false due to cross-module
// inlining, in which case the inlining should be aborted)
bool interceptor_ICJI::<API key>(CORINFO_SIG_INFO* szMetaSig)
{
mcs->AddCall("<API key>");
return <API key>-><API key>(szMetaSig);
}
// Gets a handle that is checked to see if the current method is
// included in "JustMyCode"
<API key> interceptor_ICJI::getJustMyCodeHandle(<API key> method,
<API key>** ppIndirection)
{
mcs->AddCall("getJustMyCodeHandle");
return <API key>->getJustMyCodeHandle(method, ppIndirection);
}
// Gets a method handle that can be used to correlate profiling data.
// This is the IP of a native method, or the address of the descriptor struct
// for IL. Always guaranteed to be unique per process, and not to move. */
void interceptor_ICJI::GetProfilingHandle(BOOL* pbHookFunction, void** pProfilerHandle, BOOL* pbIndirectedHandles)
{
mcs->AddCall("GetProfilingHandle");
<API key>->GetProfilingHandle(pbHookFunction, pProfilerHandle, pbIndirectedHandles);
}
// Returns instructions on how to make the call. See code:CORINFO_CALL_INFO for possible return values.
void interceptor_ICJI::getCallInfo(
// Token info
<API key>* pResolvedToken,
// Generics info
<API key>* <API key>,
// Security info
<API key> callerHandle,
// Jit info
<API key> flags,
// out params
CORINFO_CALL_INFO* pResult)
{
mcs->AddCall("getCallInfo");
<API key>->getCallInfo(pResolvedToken, <API key>, callerHandle, flags, pResult);
}
BOOL interceptor_ICJI::canAccessFamily(<API key> hCaller, <API key> hInstanceType)
{
mcs->AddCall("canAccessFamily");
return <API key>->canAccessFamily(hCaller, hInstanceType);
}
// Returns TRUE if the Class Domain ID is the RID of the class (currently true for every class
// except reflection emitted classes and generics)
BOOL interceptor_ICJI::isRIDClassDomainID(<API key> cls)
{
mcs->AddCall("isRIDClassDomainID");
return <API key>->isRIDClassDomainID(cls);
}
// returns the class's domain ID for accessing shared statics
unsigned interceptor_ICJI::getClassDomainID(<API key> cls, void** ppIndirection)
{
mcs->AddCall("getClassDomainID");
return <API key>->getClassDomainID(cls, ppIndirection);
}
// return the data's address (for static fields only)
void* interceptor_ICJI::getFieldAddress(<API key> field, void** ppIndirection)
{
mcs->AddCall("getFieldAddress");
return <API key>->getFieldAddress(field, ppIndirection);
}
// return the class handle for the current value of a static field
<API key> interceptor_ICJI::<API key>(<API key> field, bool* pIsSpeculative)
{
mcs->AddCall("<API key>");
return <API key>-><API key>(field, pIsSpeculative);
}
// registers a vararg sig & returns a VM cookie for it (which can contain other stuff)
<API key> interceptor_ICJI::getVarArgsHandle(CORINFO_SIG_INFO* pSig, void** ppIndirection)
{
mcs->AddCall("getVarArgsHandle");
return <API key>->getVarArgsHandle(pSig, ppIndirection);
}
// returns true if a VM cookie can be generated for it (might be false due to cross-module
// inlining, in which case the inlining should be aborted)
bool interceptor_ICJI::canGetVarArgsHandle(CORINFO_SIG_INFO* pSig)
{
mcs->AddCall("canGetVarArgsHandle");
return <API key>->canGetVarArgsHandle(pSig);
}
// Allocate a string literal on the heap and return a handle to it
InfoAccessType interceptor_ICJI::<API key>(<API key> module, mdToken metaTok, void** ppValue)
{
mcs->AddCall("<API key>");
return <API key>-><API key>(module, metaTok, ppValue);
}
bool interceptor_ICJI::<API key>(<API key>* pResolvedToken, bool fMustConvert)
{
mcs->AddCall("<API key>");
return <API key>-><API key>(pResolvedToken, fMustConvert);
}
InfoAccessType interceptor_ICJI::emptyStringLiteral(void** ppValue)
{
mcs->AddCall("emptyStringLiteral");
return <API key>->emptyStringLiteral(ppValue);
}
// (static fields only) given that 'field' refers to thread local store,
// return the ID (TLS index), which is used to find the begining of the
// TLS data area for the particular DLL 'field' is associated with.
DWORD interceptor_ICJI::<API key>(<API key> field, void** ppIndirection)
{
mcs->AddCall("<API key>");
return <API key>-><API key>(field, ppIndirection);
}
// Sets another object to intercept calls to "self" and current method being compiled
void interceptor_ICJI::setOverride(ICorDynamicInfo* pOverride, <API key> currentMethod)
{
mcs->AddCall("setOverride");
<API key>->setOverride(pOverride, currentMethod);
}
// Adds an active dependency from the context method's module to the given module
// This is internal callback for the EE. JIT should not call it directly.
void interceptor_ICJI::addActiveDependency(<API key> moduleFrom, <API key> moduleTo)
{
mcs->AddCall("addActiveDependency");
<API key>->addActiveDependency(moduleFrom, moduleTo);
}
<API key> interceptor_ICJI::GetDelegateCtor(<API key> methHnd,
<API key> clsHnd,
<API key> targetMethodHnd,
DelegateCtorArgs* pCtorData)
{
mcs->AddCall("GetDelegateCtor");
return <API key>->GetDelegateCtor(methHnd, clsHnd, targetMethodHnd, pCtorData);
}
void interceptor_ICJI::<API key>(<API key> methHnd)
{
mcs->AddCall("<API key>");
<API key>-><API key>(methHnd);
}
// return a thunk that will copy the arguments for the given signature.
void* interceptor_ICJI::<API key>(CORINFO_SIG_INFO* pSig, <API key> flags)
{
mcs->AddCall("<API key>");
return <API key>-><API key>(pSig, flags);
}
// Stuff directly on ICorJitInfo
// Returns extended flags for a particular compilation instance.
DWORD interceptor_ICJI::getJitFlags(CORJIT_FLAGS* jitFlags, DWORD sizeInBytes)
{
mcs->AddCall("getJitFlags");
return <API key>->getJitFlags(jitFlags, sizeInBytes);
}
// Runs the given function with the given parameter under an error trap
// and returns true if the function completes successfully. We don't
// record the results of the call: when this call gets played back,
// its result will depend on whether or not `function` calls something
// that throws at playback time rather than at capture time.
bool interceptor_ICJI::runWithErrorTrap(void (*function)(void*), void* param)
{
mcs->AddCall("runWithErrorTrap");
return <API key>->runWithErrorTrap(function, param);
}
// return memory manager that the JIT can use to allocate a regular memory
IEEMemoryManager* interceptor_ICJI::getMemoryManager()
{
mcs->AddCall("getMemoryManager");
if (current_IEEMM->original_IEEMM == nullptr)
current_IEEMM->original_IEEMM = <API key>->getMemoryManager();
return current_IEEMM;
}
// get a block of memory for the code, readonly data, and read-write data
void interceptor_ICJI::allocMem(ULONG hotCodeSize,
ULONG coldCodeSize,
ULONG roDataSize,
ULONG xcptnsCount,
CorJitAllocMemFlag flag,
void** hotCodeBlock, /* OUT */
void** coldCodeBlock, /* OUT */
void** roDataBlock /* OUT */
)
{
mcs->AddCall("allocMem");
return <API key>->allocMem(hotCodeSize, coldCodeSize, roDataSize, xcptnsCount, flag, hotCodeBlock,
coldCodeBlock, roDataBlock);
}
// Reserve memory for the method/funclet's unwind information.
// Note that this must be called before allocMem. It should be
// called once for the main method, once for every funclet, and
// once for every block of cold code for which allocUnwindInfo
// will be called.
// This is necessary because jitted code must allocate all the
// memory needed for the unwindInfo at the allocMem call.
// For prejitted code we split up the unwinding information into
// separate sections .rdata and .pdata.
void interceptor_ICJI::reserveUnwindInfo(BOOL isFunclet,
BOOL isColdCode,
ULONG unwindSize
)
{
mcs->AddCall("reserveUnwindInfo");
<API key>->reserveUnwindInfo(isFunclet, isColdCode, unwindSize);
}
// Allocate and initialize the .rdata and .pdata for this method or
// funclet, and get the block of memory needed for the machine-specific
// unwind information (the info for crawling the stack frame).
// Note that allocMem must be called first.
// Parameters:
// pHotCode main method code buffer, always filled in
// pColdCode cold code buffer, only filled in if this is cold code,
// null otherwise
// startOffset start of code block, relative to appropriate code buffer
// (e.g. pColdCode if cold, pHotCode if hot).
// endOffset end of code block, relative to appropriate code buffer
// unwindSize size of unwind info pointed to by pUnwindBlock
// pUnwindBlock pointer to unwind info
// funcKind type of funclet (main method code, handler, filter)
void interceptor_ICJI::allocUnwindInfo(BYTE* pHotCode,
BYTE* pColdCode,
ULONG startOffset,
ULONG endOffset,
ULONG unwindSize,
BYTE* pUnwindBlock,
CorJitFuncKind funcKind
)
{
mcs->AddCall("allocUnwindInfo");
<API key>->allocUnwindInfo(pHotCode, pColdCode, startOffset, endOffset, unwindSize, pUnwindBlock,
funcKind);
}
// Get a block of memory needed for the code manager information,
// (the info for enumerating the GC pointers while crawling the
// stack frame).
// Note that allocMem must be called first
void* interceptor_ICJI::allocGCInfo(size_t size
)
{
mcs->AddCall("allocGCInfo");
return <API key>->allocGCInfo(size);
}
// only used on x64
void interceptor_ICJI::yieldExecution()
{
mcs->AddCall("yieldExecution");
<API key>->yieldExecution();
}
// Indicate how many exception handler blocks are to be returned.
// This is guaranteed to be called before any 'setEHinfo' call.
// Note that allocMem must be called before this method can be called.
void interceptor_ICJI::setEHcount(unsigned cEH
)
{
mcs->AddCall("setEHcount");
<API key>->setEHcount(cEH);
}
// Set the values for one particular exception handler block.
// Handler regions should be lexically contiguous.
// This is because FinallyIsUnwinding() uses lexicality to
// determine if a "finally" clause is executing.
void interceptor_ICJI::setEHinfo(unsigned EHnumber,
const CORINFO_EH_CLAUSE* clause
)
{
mcs->AddCall("setEHinfo");
<API key>->setEHinfo(EHnumber, clause);
}
// Level 1 -> fatalError, Level 2 -> Error, Level 3 -> Warning
// Level 4 means happens 10 times in a run, level 5 means 100, level 6 means 1000 ...
// returns non-zero if the logging succeeded
BOOL interceptor_ICJI::logMsg(unsigned level, const char* fmt, va_list args)
{
mcs->AddCall("logMsg");
return <API key>->logMsg(level, fmt, args);
}
// do an assert. will return true if the code should retry (DebugBreak)
// returns false, if the assert should be igored.
int interceptor_ICJI::doAssert(const char* szFile, int iLine, const char* szExpr)
{
mcs->AddCall("doAssert");
return <API key>->doAssert(szFile, iLine, szExpr);
}
void interceptor_ICJI::reportFatalError(CorJitResult result)
{
mcs->AddCall("reportFatalError");
<API key>->reportFatalError(result);
}
/*
struct BlockCounts // Also defined here: code:<API key>
{
UINT32 ILOffset;
UINT32 ExecutionCount;
};
*/
// allocate a basic block profile buffer where execution counts will be stored
// for jitted basic blocks.
HRESULT interceptor_ICJI::<API key>(UINT32 count, // The number of basic blocks that we have
BlockCounts** pBlockCounts)
{
mcs->AddCall("<API key>");
return <API key>-><API key>(count, pBlockCounts);
}
// get profile information to be used for optimizing the current method. The format
// of the buffer is the same as the format the JIT passes to <API key>.
HRESULT interceptor_ICJI::<API key>(<API key> ftnHnd,
UINT32 * pCount, // The number of basic blocks that we have
BlockCounts** pBlockCounts,
UINT32 * pNumRuns)
{
mcs->AddCall("<API key>");
return <API key>-><API key>(ftnHnd, pCount, pBlockCounts, pNumRuns);
}
// Associates a native call site, identified by its offset in the native code stream, with
// the signature information and method handle the JIT used to lay out the call site. If
// the call site has no signature information (e.g. a helper call) or has no method handle
// (e.g. a CALLI P/Invoke), then null should be passed instead.
void interceptor_ICJI::recordCallSite(ULONG instrOffset,
CORINFO_SIG_INFO* callSig,
<API key> methodHandle
)
{
mcs->AddCall("recordCallSite");
return <API key>->recordCallSite(instrOffset, callSig, methodHandle);
}
// A relocation is recorded if we are pre-jitting.
// A jump thunk may be inserted if we are jitting
void interceptor_ICJI::recordRelocation(void* location,
void* target,
WORD fRelocType,
WORD slotNum,
INT32 addlDelta
)
{
mcs->AddCall("recordRelocation");
<API key>->recordRelocation(location, target, fRelocType, slotNum, addlDelta);
}
WORD interceptor_ICJI::getRelocTypeHint(void* target)
{
mcs->AddCall("getRelocTypeHint");
return <API key>->getRelocTypeHint(target);
}
// A callback to identify the range of address known to point to
// compiler-generated native entry points that call back into
// MSIL.
void interceptor_ICJI::<API key>(void** pStart, /* OUT */
void** pEnd /* OUT */
)
{
mcs->AddCall("<API key>");
<API key>-><API key>(pStart, pEnd);
}
// For what machine does the VM expect the JIT to generate code? The VM
// returns one of the IMAGE_FILE_MACHINE_* values. Note that if the VM
// is cross-compiling (such as the case for crossgen), it will return a
// different value than if it was compiling for the host architecture.
DWORD interceptor_ICJI::<API key>()
{
mcs->AddCall("<API key>");
return <API key>-><API key>();
} |
/**
* Generated bundle index. Do not edit.
*/
export * from './gosquared';
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYW5ndWxhcnRpY3MyLWdvc3F1YXJlZC5qcyIsInNvdXJjZVJvb3QiOiJuZzovL2FuZ3VsYXJ0aWNzMi9nb3NxdWFyZWQvIiwic291cmNlcyI6WyJhbmd1bGFydGljczItZ29zcXVhcmVkLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBOztHQUVHO0FBRUgsY0FBYyxhQUFhLENBQUMiLCJzb3VyY2VzQ29udGVudCI6WyIvKipcbiAqIEdlbmVyYXRlZCBidW5kbGUgaW5kZXguIERvIG5vdCBlZGl0LlxuICovXG5cbmV4cG9ydCAqIGZyb20gJy4vZ29zcXVhcmVkJztcbiJdfQ== |
package net.semanticmetadata.lire.imageanalysis.mser;
public class MSERParameter {
// delta, in the code, it compares (size_{i}-size_{i-delta})/size_{i-delta}
int delta;
// prune the area which bigger/smaller than maxArea/minArea
double maxArea;
double minArea;
// prune the area have similar size to its children
double maxVariation;
// trace back to cut off mser with diversity < min_diversity
double minDiversity;
/* the next few params for MSER of color image */
// for color image, the evolution steps
int maxEvolution;
// the area threshold to cause re-initialize
double areaThreshold;
// ignore too small margin
double minMargin;
// the aperture size for edge blur
int edgeBlurSize;
/**
* Constructor with default values
*/
public MSERParameter() {
// original of paper: 3, 0.5, > 25 pixel, 1, 0.5
this.delta = 5;
this.minArea = 0.001;
this.maxArea = 0.5;
this.maxVariation = 1;
this.minDiversity = 0.75F;
// this.delta = 5;
// this.minArea = 0.001;
// this.maxArea = 0.5;
// this.maxVariation = 1;
// this.minDiversity = 0.75F;
/*
this.minArea = 60;
this.maxArea = 14400;
this.maxEvolution = 200;
this.areaThreshold = 1.01;
this.minMargin = 0.003;
this.edgeBlurSize = 5;
*/
}
public MSERParameter(int delta,
double minArea, double maxArea,
double maxVariation, double minDiversity,
int maxEvolution, double areaThreshold,
double minMargin, int edgeBlurSize) {
this.delta = delta;
this.minArea = minArea;
this.maxArea = maxArea;
this.maxVariation = maxVariation;
this.minDiversity = minDiversity;
/*
this.maxEvolution = maxEvolution;
this.areaThreshold = areaThreshold;
this.minMargin = minMargin;
this.edgeBlurSize = edgeBlurSize;
*/
}
} |
<?php
namespace Drupal\<API key>\ResourceType;
use Drupal\Core\Entity\EntityTypeInterface;
use Drupal\jsonapi\ResourceType\<API key>;
/**
* Provides a repository of JSON:API resource types with aliasable field names.
*/
class <API key> extends <API key> {
/**
* {@inheritdoc}
*/
protected function getFields(array $field_names, EntityTypeInterface $entity_type, $bundle) {
$fields = parent::getFields($field_names, $entity_type, $bundle);
foreach ($fields as $field_name => $field) {
if (strpos($field_name, 'field_test_alias_') === 0) {
$fields[$field_name] = $fields[$field_name]->withPublicName('field_test_alias');
}
}
return $fields;
}
} |
#pragma once
#include "../util/c99defs.h"
#ifdef __cplusplus
extern "C" {
#endif
/*
* Functions for converting to and from packed 444 YUV
*/
EXPORT void <API key>(const uint8_t *input, uint32_t in_linesize,
uint32_t start_y, uint32_t end_y,
uint8_t *output[],
const uint32_t out_linesize[]);
EXPORT void <API key>(const uint8_t *input, uint32_t in_linesize,
uint32_t start_y, uint32_t end_y,
uint8_t *output[],
const uint32_t out_linesize[]);
EXPORT void <API key>(const uint8_t *input, uint32_t in_linesize,
uint32_t start_y, uint32_t end_y,
uint8_t *output[],
const uint32_t out_linesize[]);
EXPORT void decompress_nv12(const uint8_t *const input[],
const uint32_t in_linesize[], uint32_t start_y,
uint32_t end_y, uint8_t *output,
uint32_t out_linesize);
EXPORT void decompress_420(const uint8_t *const input[],
const uint32_t in_linesize[], uint32_t start_y,
uint32_t end_y, uint8_t *output,
uint32_t out_linesize);
EXPORT void decompress_422(const uint8_t *input, uint32_t in_linesize,
uint32_t start_y, uint32_t end_y, uint8_t *output,
uint32_t out_linesize, bool leading_lum);
#ifdef __cplusplus
}
#endif |
<?php
/**
* This file is automatically @generated by {@link <API key>}.
* Please don't modify it directly.
*/
return array (
1646 => 'New York',
1646237 => 'New York, NY',
1646336 => 'New York, NY',
1646434 => 'New York, NY',
1646476 => 'New York, NY',
1646486 => 'New York, NY',
1646559 => 'New York, NY',
1646613 => 'New York, NY',
1646638 => 'New York, NY',
1646672 => 'New York, NY',
); |
/*
* debug print functions
*/
#include <linux/module.h>
#include <linux/vt_kern.h>
#include "aufs.h"
int aufs_debug;
MODULE_PARM_DESC(debug, "debug print");
module_param_named(debug, aufs_debug, int, S_IRUGO | S_IWUSR | S_IWGRP);
char *au_plevel = KERN_DEBUG;
#define dpri(fmt, ...) do { \
if ((au_plevel \
&& strcmp(au_plevel, KERN_DEBUG)) \
|| au_debug_test()) \
printk("%s" fmt, au_plevel, ##__VA_ARGS__); \
} while (0)
void au_dpri_whlist(struct au_nhash *whlist)
{
unsigned long ul, n;
struct hlist_head *head;
struct au_vdir_wh *tpos;
struct hlist_node *pos;
n = whlist->nh_num;
head = whlist->nh_head;
for (ul = 0; ul < n; ul++) {
<API key>(tpos, pos, head, wh_hash)
dpri("b%d, %.*s, %d\n",
tpos->wh_bindex,
tpos->wh_str.len, tpos->wh_str.name,
tpos->wh_str.len);
head++;
}
}
void au_dpri_vdir(struct au_vdir *vdir)
{
unsigned long ul;
union au_vdir_deblk_p p;
unsigned char *o;
if (!vdir || IS_ERR(vdir)) {
dpri("err %ld\n", PTR_ERR(vdir));
return;
}
dpri("deblk %u, nblk %lu, deblk %p, last{%lu, %p}, ver %lu\n",
vdir->vd_deblk_sz, vdir->vd_nblk, vdir->vd_deblk,
vdir->vd_last.ul, vdir->vd_last.p.deblk, vdir->vd_version);
for (ul = 0; ul < vdir->vd_nblk; ul++) {
p.deblk = vdir->vd_deblk[ul];
o = p.deblk;
dpri("[%lu]: %p\n", ul, o);
}
}
static int do_pri_inode(aufs_bindex_t bindex, struct inode *inode,
struct dentry *wh)
{
char *n = NULL;
int l = 0;
if (!inode || IS_ERR(inode)) {
dpri("i%d: err %ld\n", bindex, PTR_ERR(inode));
return -1;
}
/* the type of i_blocks depends upon CONFIG_LSF */
BUILD_BUG_ON(sizeof(inode->i_blocks) != sizeof(unsigned long)
&& sizeof(inode->i_blocks) != sizeof(u64));
if (wh) {
n = (void *)wh->d_name.name;
l = wh->d_name.len;
}
dpri("i%d: i%lu, %s, cnt %d, nl %u, 0%o, sz %llu, blk %llu,"
" ct %lld, np %lu, st 0x%lx, f 0x%x, v %llu, g %x%s%.*s\n",
bindex,
inode->i_ino, inode->i_sb ? au_sbtype(inode->i_sb) : "??",
atomic_read(&inode->i_count), inode->i_nlink, inode->i_mode,
i_size_read(inode), (unsigned long long)inode->i_blocks,
(long long)timespec_to_ns(&inode->i_ctime) & 0x0ffff,
inode->i_mapping ? inode->i_mapping->nrpages : 0,
inode->i_state, inode->i_flags, inode->i_version,
inode->i_generation,
l ? ", wh " : "", l, n);
return 0;
}
void au_dpri_inode(struct inode *inode)
{
struct au_iinfo *iinfo;
aufs_bindex_t bindex;
int err;
err = do_pri_inode(-1, inode, NULL);
if (err || !au_test_aufs(inode->i_sb))
return;
iinfo = au_ii(inode);
if (!iinfo)
return;
dpri("i-1: bstart %d, bend %d, gen %d\n",
iinfo->ii_bstart, iinfo->ii_bend, au_iigen(inode));
if (iinfo->ii_bstart < 0)
return;
for (bindex = iinfo->ii_bstart; bindex <= iinfo->ii_bend; bindex++)
do_pri_inode(bindex, iinfo->ii_hinode[0 + bindex].hi_inode,
iinfo->ii_hinode[0 + bindex].hi_whdentry);
}
void au_dpri_dalias(struct inode *inode)
{
struct dentry *d;
spin_lock(&dcache_lock);
list_for_each_entry(d, &inode->i_dentry, d_alias)
au_dpri_dentry(d);
spin_unlock(&dcache_lock);
}
static int do_pri_dentry(aufs_bindex_t bindex, struct dentry *dentry)
{
struct dentry *wh = NULL;
if (!dentry || IS_ERR(dentry)) {
dpri("d%d: err %ld\n", bindex, PTR_ERR(dentry));
return -1;
}
/* do not call dget_parent() here */
dpri("d%d: %.*s?/%.*s, %s, cnt %d, flags 0x%x\n",
bindex,
AuDLNPair(dentry->d_parent), AuDLNPair(dentry),
dentry->d_sb ? au_sbtype(dentry->d_sb) : "??",
atomic_read(&dentry->d_count), dentry->d_flags);
if (bindex >= 0 && dentry->d_inode && au_test_aufs(dentry->d_sb)) {
struct au_iinfo *iinfo = au_ii(dentry->d_inode);
if (iinfo)
wh = iinfo->ii_hinode[0 + bindex].hi_whdentry;
}
do_pri_inode(bindex, dentry->d_inode, wh);
return 0;
}
void au_dpri_dentry(struct dentry *dentry)
{
struct au_dinfo *dinfo;
aufs_bindex_t bindex;
int err;
struct au_hdentry *hdp;
err = do_pri_dentry(-1, dentry);
if (err || !au_test_aufs(dentry->d_sb))
return;
dinfo = au_di(dentry);
if (!dinfo)
return;
dpri("d-1: bstart %d, bend %d, bwh %d, bdiropq %d, gen %d\n",
dinfo->di_bstart, dinfo->di_bend,
dinfo->di_bwh, dinfo->di_bdiropq, au_digen(dentry));
if (dinfo->di_bstart < 0)
return;
hdp = dinfo->di_hdentry;
for (bindex = dinfo->di_bstart; bindex <= dinfo->di_bend; bindex++)
do_pri_dentry(bindex, hdp[0 + bindex].hd_dentry);
}
static int do_pri_file(aufs_bindex_t bindex, struct file *file)
{
char a[32];
if (!file || IS_ERR(file)) {
dpri("f%d: err %ld\n", bindex, PTR_ERR(file));
return -1;
}
a[0] = 0;
if (bindex < 0
&& file->f_dentry
&& au_test_aufs(file->f_dentry->d_sb)
&& au_fi(file))
snprintf(a, sizeof(a), ", gen %d, mmapped %d",
au_figen(file), !!au_fi(file)->fi_hvmop);
dpri("f%d: mode 0x%x, flags 0%o, cnt %ld, v %llu, pos %llu%s\n",
bindex, file->f_mode, file->f_flags, (long)file_count(file),
file->f_version, file->f_pos, a);
if (file->f_dentry)
do_pri_dentry(bindex, file->f_dentry);
return 0;
}
void au_dpri_file(struct file *file)
{
struct au_finfo *finfo;
struct au_fidir *fidir;
struct au_hfile *hfile;
aufs_bindex_t bindex;
int err;
err = do_pri_file(-1, file);
if (err || !file->f_dentry || !au_test_aufs(file->f_dentry->d_sb))
return;
finfo = au_fi(file);
if (!finfo)
return;
if (finfo->fi_btop < 0)
return;
fidir = finfo->fi_hdir;
if (!fidir)
do_pri_file(finfo->fi_btop, finfo->fi_htop.hf_file);
else
for (bindex = finfo->fi_btop;
bindex >= 0 && bindex <= fidir->fd_bbot;
bindex++) {
hfile = fidir->fd_hfile + bindex;
do_pri_file(bindex, hfile ? hfile->hf_file : NULL);
}
}
static int do_pri_br(aufs_bindex_t bindex, struct au_branch *br)
{
struct vfsmount *mnt;
struct super_block *sb;
if (!br || IS_ERR(br))
goto out;
mnt = br->br_mnt;
if (!mnt || IS_ERR(mnt))
goto out;
sb = mnt->mnt_sb;
if (!sb || IS_ERR(sb))
goto out;
dpri("s%d: {perm 0x%x, cnt %d, wbr %p}, "
"%s, dev 0x%02x%02x, flags 0x%lx, cnt %d, active %d, "
"xino %d\n",
bindex, br->br_perm, atomic_read(&br->br_count), br->br_wbr,
au_sbtype(sb), MAJOR(sb->s_dev), MINOR(sb->s_dev),
sb->s_flags, sb->s_count,
atomic_read(&sb->s_active), !!br->br_xino.xi_file);
return 0;
out:
dpri("s%d: err %ld\n", bindex, PTR_ERR(br));
return -1;
}
void au_dpri_sb(struct super_block *sb)
{
struct au_sbinfo *sbinfo;
aufs_bindex_t bindex;
int err;
/* to reuduce stack size */
struct {
struct vfsmount mnt;
struct au_branch fake;
} *a;
/* this function can be called from magic sysrq */
a = kzalloc(sizeof(*a), GFP_ATOMIC);
if (unlikely(!a)) {
dpri("no memory\n");
return;
}
a->mnt.mnt_sb = sb;
a->fake.br_perm = 0;
a->fake.br_mnt = &a->mnt;
a->fake.br_xino.xi_file = NULL;
atomic_set(&a->fake.br_count, 0);
smp_mb(); /* atomic_set */
err = do_pri_br(-1, &a->fake);
kfree(a);
dpri("dev 0x%x\n", sb->s_dev);
if (err || !au_test_aufs(sb))
return;
sbinfo = au_sbi(sb);
if (!sbinfo)
return;
dpri("nw %d, gen %u, kobj %d\n",
atomic_read(&sbinfo->si_nowait.nw_len), sbinfo->si_generation,
atomic_read(&sbinfo->si_kobj.kref.refcount));
for (bindex = 0; bindex <= sbinfo->si_bend; bindex++)
do_pri_br(bindex, sbinfo->si_branch[0 + bindex]);
}
void au_dbg_sleep_jiffy(int jiffy)
{
while (jiffy)
jiffy = <API key>(jiffy);
}
void au_dbg_iattr(struct iattr *ia)
{
#define AuBit(name) if (ia->ia_valid & ATTR_ ## name) \
dpri(#name "\n")
AuBit(MODE);
AuBit(UID);
AuBit(GID);
AuBit(SIZE);
AuBit(ATIME);
AuBit(MTIME);
AuBit(CTIME);
AuBit(ATIME_SET);
AuBit(MTIME_SET);
AuBit(FORCE);
AuBit(ATTR_FLAG);
AuBit(KILL_SUID);
AuBit(KILL_SGID);
AuBit(FILE);
AuBit(KILL_PRIV);
AuBit(OPEN);
AuBit(TIMES_SET);
#undef AuBit
dpri("ia_file %p\n", ia->ia_file);
}
void <API key>(struct dentry *dentry, const char *func, int line)
{
struct inode *h_inode, *inode = dentry->d_inode;
struct dentry *h_dentry;
aufs_bindex_t bindex, bend, bi;
if (!inode /* || au_di(dentry)->di_lsc == AuLsc_DI_TMP */)
return;
bend = au_dbend(dentry);
bi = au_ibend(inode);
if (bi < bend)
bend = bi;
bindex = au_dbstart(dentry);
bi = au_ibstart(inode);
if (bi > bindex)
bindex = bi;
for (; bindex <= bend; bindex++) {
h_dentry = au_h_dptr(dentry, bindex);
if (!h_dentry)
continue;
h_inode = au_h_iptr(inode, bindex);
if (unlikely(h_inode != h_dentry->d_inode)) {
int old = au_debug_test();
if (!old)
au_debug(1);
AuDbg("b%d, %s:%d\n", bindex, func, line);
AuDbgDentry(dentry);
AuDbgInode(inode);
if (!old)
au_debug(0);
BUG();
}
}
}
void <API key>(struct dentry *dentry, unsigned int sigen)
{
struct dentry *parent;
parent = dget_parent(dentry);
AuDebugOn(!S_ISDIR(dentry->d_inode->i_mode));
AuDebugOn(IS_ROOT(dentry));
AuDebugOn(au_digen_test(parent, sigen));
dput(parent);
}
void <API key>(struct dentry *dentry, unsigned int sigen)
{
struct dentry *parent;
struct inode *inode;
parent = dget_parent(dentry);
inode = dentry->d_inode;
AuDebugOn(inode && S_ISDIR(dentry->d_inode->i_mode));
AuDebugOn(au_digen_test(parent, sigen));
dput(parent);
}
void au_dbg_verify_gen(struct dentry *parent, unsigned int sigen)
{
int err, i, j;
struct au_dcsub_pages dpages;
struct au_dpage *dpage;
struct dentry **dentries;
err = au_dpages_init(&dpages, GFP_NOFS);
AuDebugOn(err);
err = <API key>(&dpages, parent, /*do_include*/1);
AuDebugOn(err);
for (i = dpages.ndpage - 1; !err && i >= 0; i
dpage = dpages.dpages + i;
dentries = dpage->dentries;
for (j = dpage->ndentry - 1; !err && j >= 0; j
AuDebugOn(au_digen_test(dentries[j], sigen));
}
au_dpages_free(&dpages);
}
void <API key>(void)
{
struct task_struct *tsk = current;
if ((tsk->flags & PF_KTHREAD)
&& !strncmp(tsk->comm, AUFS_WKQ_NAME "/", sizeof(AUFS_WKQ_NAME))) {
au_dbg_blocked();
BUG();
}
}
static void <API key>(void *args)
{
BUG_ON(current_fsuid());
BUG_ON(rlimit(RLIMIT_FSIZE) != RLIM_INFINITY);
}
void au_dbg_verify_wkq(void)
{
au_wkq_wait(<API key>, NULL);
}
void <API key>(struct au_sbinfo *sbinfo __maybe_unused)
{
#ifdef AuForceNoPlink
au_opt_clr(sbinfo->si_mntflags, PLINK);
#endif
#ifdef AuForceNoXino
au_opt_clr(sbinfo->si_mntflags, XINO);
#endif
#ifdef AuForceNoRefrof
au_opt_clr(sbinfo->si_mntflags, REFROF);
#endif
#ifdef AuForceHnotify
au_opt_set_udba(sbinfo->si_mntflags, UDBA_HNOTIFY);
#endif
#ifdef AuForceRd0
sbinfo->si_rdblk = 0;
sbinfo->si_rdhash = 0;
#endif
}
int __init au_debug_init(void)
{
aufs_bindex_t bindex;
struct au_vdir_destr destr;
bindex = -1;
AuDebugOn(bindex >= 0);
destr.len = -1;
AuDebugOn(destr.len < NAME_MAX);
#ifdef CONFIG_4KSTACKS
pr_warning("CONFIG_4KSTACKS is defined.\n");
#endif
#ifdef AuForceNoBrs
sysaufs_brs = 0;
#endif
return 0;
} |
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
#include <linux/if.h>
#include <linux/module.h>
#include <linux/err.h>
#include <linux/list.h>
#include <linux/slab.h>
#include <linux/nl80211.h>
#include <linux/debugfs.h>
#include <linux/notifier.h>
#include <linux/device.h>
#include <linux/etherdevice.h>
#include <linux/rtnetlink.h>
#include <linux/sched.h>
#include <net/genetlink.h>
#include <net/cfg80211.h>
#include "nl80211.h"
#include "core.h"
#include "sysfs.h"
#include "debugfs.h"
#include "wext-compat.h"
#include "ethtool.h"
/* name for sysfs, %d is appended */
#define PHY_NAME "phy"
MODULE_AUTHOR("Johannes Berg");
MODULE_LICENSE("GPL");
MODULE_DESCRIPTION("wireless configuration support");
/* RCU-protected (and cfg80211_mutex for writers) */
LIST_HEAD(cfg80211_rdev_list);
int <API key>;
DEFINE_MUTEX(cfg80211_mutex);
/* for debugfs */
static struct dentry *<API key>;
/* for the cleanup, scan and event works */
struct workqueue_struct *cfg80211_wq;
static bool <API key>;
module_param(<API key>, bool, 0644);
MODULE_PARM_DESC(<API key>,
"Disable 40MHz support in the 2.4GHz band");
/* requires cfg80211_mutex to be held! */
struct <API key> *<API key>(int wiphy_idx)
{
struct <API key> *result = NULL, *rdev;
if (!wiphy_idx_valid(wiphy_idx))
return NULL;
<API key>();
list_for_each_entry(rdev, &cfg80211_rdev_list, list) {
if (rdev->wiphy_idx == wiphy_idx) {
result = rdev;
break;
}
}
return result;
}
int get_wiphy_idx(struct wiphy *wiphy)
{
struct <API key> *rdev;
if (!wiphy)
return WIPHY_IDX_STALE;
rdev = wiphy_to_dev(wiphy);
return rdev->wiphy_idx;
}
/* requires cfg80211_rdev_mutex to be held! */
struct wiphy *wiphy_idx_to_wiphy(int wiphy_idx)
{
struct <API key> *rdev;
if (!wiphy_idx_valid(wiphy_idx))
return NULL;
<API key>();
rdev = <API key>(wiphy_idx);
if (!rdev)
return NULL;
return &rdev->wiphy;
}
/* requires cfg80211_mutex to be held! */
struct <API key> *
<API key>(struct genl_info *info)
{
int ifindex;
struct <API key> *bywiphyidx = NULL, *byifidx = NULL;
struct net_device *dev;
int err = -EINVAL;
<API key>();
if (info->attrs[NL80211_ATTR_WIPHY]) {
bywiphyidx = <API key>(
nla_get_u32(info->attrs[NL80211_ATTR_WIPHY]));
err = -ENODEV;
}
if (info->attrs[<API key>]) {
ifindex = nla_get_u32(info->attrs[<API key>]);
dev = dev_get_by_index(genl_info_net(info), ifindex);
if (dev) {
if (dev->ieee80211_ptr)
byifidx =
wiphy_to_dev(dev->ieee80211_ptr->wiphy);
dev_put(dev);
}
err = -ENODEV;
}
if (bywiphyidx && byifidx) {
if (bywiphyidx != byifidx)
return ERR_PTR(-EINVAL);
else
return bywiphyidx; /* == byifidx */
}
if (bywiphyidx)
return bywiphyidx;
if (byifidx)
return byifidx;
return ERR_PTR(err);
}
struct <API key> *
<API key>(struct genl_info *info)
{
struct <API key> *rdev;
mutex_lock(&cfg80211_mutex);
rdev = <API key>(info);
/* if it is not an error we grab the lock on
* it to assure it won't be going away while
* we operate on it */
if (!IS_ERR(rdev))
mutex_lock(&rdev->mtx);
mutex_unlock(&cfg80211_mutex);
return rdev;
}
struct <API key> *
<API key>(struct net *net, int ifindex)
{
struct <API key> *rdev = ERR_PTR(-ENODEV);
struct net_device *dev;
mutex_lock(&cfg80211_mutex);
dev = dev_get_by_index(net, ifindex);
if (!dev)
goto out;
if (dev->ieee80211_ptr) {
rdev = wiphy_to_dev(dev->ieee80211_ptr->wiphy);
mutex_lock(&rdev->mtx);
} else
rdev = ERR_PTR(-ENODEV);
dev_put(dev);
out:
mutex_unlock(&cfg80211_mutex);
return rdev;
}
/* requires cfg80211_mutex to be held */
int cfg80211_dev_rename(struct <API key> *rdev,
char *newname)
{
struct <API key> *rdev2;
int wiphy_idx, taken = -1, result, digits;
<API key>();
/* prohibit calling the thing phy%d when %d is not its number */
sscanf(newname, PHY_NAME "%d%n", &wiphy_idx, &taken);
if (taken == strlen(newname) && wiphy_idx != rdev->wiphy_idx) {
/* count number of places needed to print wiphy_idx */
digits = 1;
while (wiphy_idx /= 10)
digits++;
/*
* deny the name if it is phy<idx> where <idx> is printed
* without leading zeroes. taken == strlen(newname) here
*/
if (taken == strlen(PHY_NAME) + digits)
return -EINVAL;
}
/* Ignore nop renames */
if (strcmp(newname, dev_name(&rdev->wiphy.dev)) == 0)
return 0;
/* Ensure another device does not already have this name. */
list_for_each_entry(rdev2, &cfg80211_rdev_list, list)
if (strcmp(newname, dev_name(&rdev2->wiphy.dev)) == 0)
return -EINVAL;
result = device_rename(&rdev->wiphy.dev, newname);
if (result)
return result;
if (rdev->wiphy.debugfsdir &&
!debugfs_rename(rdev->wiphy.debugfsdir->d_parent,
rdev->wiphy.debugfsdir,
rdev->wiphy.debugfsdir->d_parent,
newname))
pr_err("failed to rename debugfs dir to %s!\n", newname);
<API key>(rdev);
return 0;
}
int <API key>(struct <API key> *rdev,
struct net *net)
{
struct wireless_dev *wdev;
int err = 0;
if (!(rdev->wiphy.flags & WIPHY_FLAG_NETNS_OK))
return -EOPNOTSUPP;
list_for_each_entry(wdev, &rdev->netdev_list, list) {
wdev->netdev->features &= ~NETIF_F_NETNS_LOCAL;
err = <API key>(wdev->netdev, net, "wlan%d");
if (err)
break;
wdev->netdev->features |= NETIF_F_NETNS_LOCAL;
}
if (err) {
/* failed -- clean up to old netns */
net = wiphy_net(&rdev->wiphy);
<API key>(wdev, &rdev->netdev_list,
list) {
wdev->netdev->features &= ~NETIF_F_NETNS_LOCAL;
err = <API key>(wdev->netdev, net,
"wlan%d");
WARN_ON(err);
wdev->netdev->features |= NETIF_F_NETNS_LOCAL;
}
return err;
}
wiphy_net_set(&rdev->wiphy, net);
err = device_rename(&rdev->wiphy.dev, dev_name(&rdev->wiphy.dev));
WARN_ON(err);
return 0;
}
static void <API key>(struct rfkill *rfkill, void *data)
{
struct <API key> *rdev = data;
rdev->ops->rfkill_poll(&rdev->wiphy);
}
static int <API key>(void *data, bool blocked)
{
struct <API key> *rdev = data;
struct wireless_dev *wdev;
if (!blocked)
return 0;
rtnl_lock();
mutex_lock(&rdev->devlist_mtx);
list_for_each_entry(wdev, &rdev->netdev_list, list)
dev_close(wdev->netdev);
mutex_unlock(&rdev->devlist_mtx);
rtnl_unlock();
return 0;
}
static void <API key>(struct work_struct *work)
{
struct <API key> *rdev;
rdev = container_of(work, struct <API key>, rfkill_sync);
<API key>(rdev, rfkill_blocked(rdev->rfkill));
}
static void cfg80211_event_work(struct work_struct *work)
{
struct <API key> *rdev;
rdev = container_of(work, struct <API key>,
event_work);
rtnl_lock();
cfg80211_lock_rdev(rdev);
<API key>(rdev);
<API key>(rdev);
rtnl_unlock();
}
/* exported functions */
struct wiphy *wiphy_new(const struct cfg80211_ops *ops, int sizeof_priv)
{
static int wiphy_counter;
struct <API key> *rdev;
int alloc_size;
WARN_ON(ops->add_key && (!ops->del_key || !ops->set_default_key));
WARN_ON(ops->auth && (!ops->assoc || !ops->deauth || !ops->disassoc));
WARN_ON(ops->connect && !ops->disconnect);
WARN_ON(ops->join_ibss && !ops->leave_ibss);
WARN_ON(ops->add_virtual_intf && !ops->del_virtual_intf);
WARN_ON(ops->add_station && !ops->del_station);
WARN_ON(ops->add_mpath && !ops->del_mpath);
WARN_ON(ops->join_mesh && !ops->leave_mesh);
alloc_size = sizeof(*rdev) + sizeof_priv;
rdev = kzalloc(alloc_size, GFP_KERNEL);
if (!rdev)
return NULL;
rdev->ops = ops;
mutex_lock(&cfg80211_mutex);
rdev->wiphy_idx = wiphy_counter++;
if (unlikely(!wiphy_idx_valid(rdev->wiphy_idx))) {
wiphy_counter
mutex_unlock(&cfg80211_mutex);
/* ugh, wrapped! */
kfree(rdev);
return NULL;
}
mutex_unlock(&cfg80211_mutex);
/* give it a proper name */
dev_set_name(&rdev->wiphy.dev, PHY_NAME "%d", rdev->wiphy_idx);
mutex_init(&rdev->mtx);
mutex_init(&rdev->devlist_mtx);
mutex_init(&rdev->sched_scan_mtx);
INIT_LIST_HEAD(&rdev->netdev_list);
spin_lock_init(&rdev->bss_lock);
INIT_LIST_HEAD(&rdev->bss_list);
INIT_WORK(&rdev->scan_done_wk, <API key>);
INIT_WORK(&rdev-><API key>, <API key>);
#ifdef <API key>
rdev->wiphy.wext = &<API key>;
#endif
device_initialize(&rdev->wiphy.dev);
rdev->wiphy.dev.class = &ieee80211_class;
rdev->wiphy.dev.platform_data = rdev;
#ifdef <API key>
rdev->wiphy.flags |= <API key>;
#endif
wiphy_net_set(&rdev->wiphy, &init_net);
rdev->rfkill_ops.set_block = <API key>;
rdev->rfkill = rfkill_alloc(dev_name(&rdev->wiphy.dev),
&rdev->wiphy.dev, RFKILL_TYPE_WLAN,
&rdev->rfkill_ops, rdev);
if (!rdev->rfkill) {
kfree(rdev);
return NULL;
}
INIT_WORK(&rdev->rfkill_sync, <API key>);
INIT_WORK(&rdev->conn_work, cfg80211_conn_work);
INIT_WORK(&rdev->event_work, cfg80211_event_work);
init_waitqueue_head(&rdev->dev_wait);
/*
* Initialize wiphy parameters to IEEE 802.11 MIB default values.
* Fragmentation and RTS threshold are disabled by default with the
* special -1 value.
*/
rdev->wiphy.retry_short = 7;
rdev->wiphy.retry_long = 4;
rdev->wiphy.frag_threshold = (u32) -1;
rdev->wiphy.rts_threshold = (u32) -1;
rdev->wiphy.coverage_class = 0;
return &rdev->wiphy;
}
EXPORT_SYMBOL(wiphy_new);
static int <API key>(struct wiphy *wiphy)
{
const struct <API key> *c;
int i, j;
/* If we have combinations enforce them */
if (wiphy-><API key>)
wiphy->flags |= <API key>;
for (i = 0; i < wiphy-><API key>; i++) {
u32 cnt = 0;
u16 all_iftypes = 0;
c = &wiphy->iface_combinations[i];
/* Combinations with just one interface aren't real */
if (WARN_ON(c->max_interfaces < 2))
return -EINVAL;
/* Need at least one channel */
if (WARN_ON(!c-><API key>))
return -EINVAL;
if (WARN_ON(!c->n_limits))
return -EINVAL;
for (j = 0; j < c->n_limits; j++) {
u16 types = c->limits[j].types;
/*
* interface types shouldn't overlap, this is
* used in <API key>()
*/
if (WARN_ON(types & all_iftypes))
return -EINVAL;
all_iftypes |= types;
if (WARN_ON(!c->limits[j].max))
return -EINVAL;
/* Shouldn't list software iftypes in combinations! */
if (WARN_ON(wiphy->software_iftypes & types))
return -EINVAL;
cnt += c->limits[j].max;
/*
* Don't advertise an unsupported type
* in a combination.
*/
if (WARN_ON((wiphy->interface_modes & types) != types))
return -EINVAL;
}
/* You can't even choose that many! */
if (WARN_ON(cnt < c->max_interfaces))
return -EINVAL;
}
return 0;
}
int wiphy_register(struct wiphy *wiphy)
{
struct <API key> *rdev = wiphy_to_dev(wiphy);
int res;
enum ieee80211_band band;
struct <API key> *sband;
bool have_band = false;
int i;
u16 ifmodes = wiphy->interface_modes;
if (WARN_ON(wiphy->ap_sme_capa &&
!(wiphy->flags & <API key>)))
return -EINVAL;
if (WARN_ON(wiphy->addresses && !wiphy->n_addresses))
return -EINVAL;
if (WARN_ON(wiphy->addresses &&
!is_zero_ether_addr(wiphy->perm_addr) &&
memcmp(wiphy->perm_addr, wiphy->addresses[0].addr,
ETH_ALEN)))
return -EINVAL;
if (wiphy->addresses)
memcpy(wiphy->perm_addr, wiphy->addresses[0].addr, ETH_ALEN);
/* sanity check ifmodes */
WARN_ON(!ifmodes);
ifmodes &= ((1 << NUM_NL80211_IFTYPES) - 1) & ~1;
if (WARN_ON(ifmodes != wiphy->interface_modes))
wiphy->interface_modes = ifmodes;
res = <API key>(wiphy);
if (res)
return res;
/* sanity check supported bands/channels */
for (band = 0; band < IEEE80211_NUM_BANDS; band++) {
sband = wiphy->bands[band];
if (!sband)
continue;
sband->band = band;
if (WARN_ON(!sband->n_channels || !sband->n_bitrates))
return -EINVAL;
/*
* Since <API key> is global, we can
* modify the sband's ht data even if the driver uses a
* global structure for that.
*/
if (<API key> &&
band == IEEE80211_BAND_2GHZ &&
sband->ht_cap.ht_supported) {
sband->ht_cap.cap &= ~<API key>;
sband->ht_cap.cap &= ~<API key>;
}
/*
* Since we use a u32 for rate bitmaps in
* <API key>, we cannot
* have more than 32 legacy rates.
*/
if (WARN_ON(sband->n_bitrates > 32))
return -EINVAL;
for (i = 0; i < sband->n_channels; i++) {
sband->channels[i].orig_flags =
sband->channels[i].flags;
sband->channels[i].orig_mag = INT_MAX;
sband->channels[i].orig_mpwr =
sband->channels[i].max_power;
sband->channels[i].band = band;
}
have_band = true;
}
if (!have_band) {
WARN_ON(1);
return -EINVAL;
}
if (rdev->wiphy.wowlan.n_patterns) {
if (WARN_ON(!rdev->wiphy.wowlan.pattern_min_len ||
rdev->wiphy.wowlan.pattern_min_len >
rdev->wiphy.wowlan.pattern_max_len))
return -EINVAL;
}
/* check and set up bitrates */
<API key>(wiphy);
mutex_lock(&cfg80211_mutex);
res = device_add(&rdev->wiphy.dev);
if (res) {
mutex_unlock(&cfg80211_mutex);
return res;
}
/* set up regulatory info */
<API key>(wiphy, <API key>);
list_add_rcu(&rdev->list, &cfg80211_rdev_list);
<API key>++;
/* add to debugfs */
rdev->wiphy.debugfsdir =
debugfs_create_dir(wiphy_name(&rdev->wiphy),
<API key>);
if (IS_ERR(rdev->wiphy.debugfsdir))
rdev->wiphy.debugfsdir = NULL;
if (wiphy->flags & <API key>) {
struct regulatory_request request;
request.wiphy_idx = get_wiphy_idx(wiphy);
request.initiator = <API key>;
request.alpha2[0] = '9';
request.alpha2[1] = '9';
<API key>(&request);
}
<API key>(rdev);
mutex_unlock(&cfg80211_mutex);
/*
* due to a locking dependency this has to be outside of the
* cfg80211_mutex lock
*/
res = rfkill_register(rdev->rfkill);
if (res)
goto out_rm_dev;
return 0;
out_rm_dev:
device_del(&rdev->wiphy.dev);
return res;
}
EXPORT_SYMBOL(wiphy_register);
void <API key>(struct wiphy *wiphy)
{
struct <API key> *rdev = wiphy_to_dev(wiphy);
if (!rdev->ops->rfkill_poll)
return;
rdev->rfkill_ops.poll = <API key>;
<API key>(rdev->rfkill);
}
EXPORT_SYMBOL(<API key>);
void <API key>(struct wiphy *wiphy)
{
struct <API key> *rdev = wiphy_to_dev(wiphy);
<API key>(rdev->rfkill);
}
EXPORT_SYMBOL(<API key>);
void wiphy_unregister(struct wiphy *wiphy)
{
struct <API key> *rdev = wiphy_to_dev(wiphy);
rfkill_unregister(rdev->rfkill);
/* protect the device list */
mutex_lock(&cfg80211_mutex);
wait_event(rdev->dev_wait, ({
int __count;
mutex_lock(&rdev->devlist_mtx);
__count = rdev->opencount;
mutex_unlock(&rdev->devlist_mtx);
__count == 0;}));
mutex_lock(&rdev->devlist_mtx);
BUG_ON(!list_empty(&rdev->netdev_list));
mutex_unlock(&rdev->devlist_mtx);
/*
* First remove the hardware from everywhere, this makes
* it impossible to find from userspace.
*/
<API key>(rdev->wiphy.debugfsdir);
list_del_rcu(&rdev->list);
synchronize_rcu();
/*
* Try to grab rdev->mtx. If a command is still in progress,
* hopefully the driver will refuse it since it's tearing
* down the device already. We wait for this command to complete
* before unlinking the item from the list.
* Note: as codified by the BUG_ON above we cannot get here if
* a virtual interface is still present. Hence, we can only get
* to lock contention here if userspace issues a command that
* identified the hardware by wiphy index.
*/
cfg80211_lock_rdev(rdev);
/* nothing */
<API key>(rdev);
/* If this device got a regulatory hint tell core its
* free to listen now to a new shiny device regulatory hint */
reg_device_remove(wiphy);
<API key>++;
device_del(&rdev->wiphy.dev);
mutex_unlock(&cfg80211_mutex);
flush_work(&rdev->scan_done_wk);
cancel_work_sync(&rdev->conn_work);
flush_work(&rdev->event_work);
}
EXPORT_SYMBOL(wiphy_unregister);
void cfg80211_dev_free(struct <API key> *rdev)
{
struct <API key> *scan, *tmp;
rfkill_destroy(rdev->rfkill);
mutex_destroy(&rdev->mtx);
mutex_destroy(&rdev->devlist_mtx);
mutex_destroy(&rdev->sched_scan_mtx);
<API key>(scan, tmp, &rdev->bss_list, list)
cfg80211_put_bss(&scan->pub);
<API key>(rdev);
kfree(rdev);
}
void wiphy_free(struct wiphy *wiphy)
{
put_device(&wiphy->dev);
}
EXPORT_SYMBOL(wiphy_free);
void <API key>(struct wiphy *wiphy, bool blocked)
{
struct <API key> *rdev = wiphy_to_dev(wiphy);
if (rfkill_set_hw_state(rdev->rfkill, blocked))
schedule_work(&rdev->rfkill_sync);
}
EXPORT_SYMBOL(<API key>);
static void wdev_cleanup_work(struct work_struct *work)
{
struct wireless_dev *wdev;
struct <API key> *rdev;
wdev = container_of(work, struct wireless_dev, cleanup_work);
rdev = wiphy_to_dev(wdev->wiphy);
cfg80211_lock_rdev(rdev);
if (WARN_ON(rdev->scan_req && rdev->scan_req->dev == wdev->netdev)) {
rdev->scan_req->aborted = true;
<API key>(rdev, true);
}
<API key>(rdev);
mutex_lock(&rdev->sched_scan_mtx);
if (WARN_ON(rdev->sched_scan_req &&
rdev->sched_scan_req->dev == wdev->netdev)) {
<API key>(rdev, false);
}
mutex_unlock(&rdev->sched_scan_mtx);
mutex_lock(&rdev->devlist_mtx);
rdev->opencount
mutex_unlock(&rdev->devlist_mtx);
wake_up(&rdev->dev_wait);
dev_put(wdev->netdev);
}
static struct device_type wiphy_type = {
.name = "wlan",
};
static int <API key>(struct notifier_block * nb,
unsigned long state,
void *ndev)
{
struct net_device *dev = ndev;
struct wireless_dev *wdev = dev->ieee80211_ptr;
struct <API key> *rdev;
int ret;
if (!wdev)
return NOTIFY_DONE;
rdev = wiphy_to_dev(wdev->wiphy);
WARN_ON(wdev->iftype == <API key>);
switch (state) {
case NETDEV_POST_INIT:
SET_NETDEV_DEVTYPE(dev, &wiphy_type);
break;
case NETDEV_REGISTER:
/*
* NB: cannot take rdev->mtx here because this may be
* called within code protected by it when interfaces
* are added with nl80211.
*/
mutex_init(&wdev->mtx);
INIT_WORK(&wdev->cleanup_work, wdev_cleanup_work);
INIT_LIST_HEAD(&wdev->event_list);
spin_lock_init(&wdev->event_lock);
INIT_LIST_HEAD(&wdev->mgmt_registrations);
spin_lock_init(&wdev-><API key>);
mutex_lock(&rdev->devlist_mtx);
list_add_rcu(&wdev->list, &rdev->netdev_list);
rdev->devlist_generation++;
/* can only change netns with wiphy */
dev->features |= NETIF_F_NETNS_LOCAL;
if (sysfs_create_link(&dev->dev.kobj, &rdev->wiphy.dev.kobj,
"phy80211")) {
pr_err("failed to add phy80211 symlink to netdev!\n");
}
wdev->netdev = dev;
wdev->sme_state = CFG80211_SME_IDLE;
mutex_unlock(&rdev->devlist_mtx);
#ifdef <API key>
wdev->wext.default_key = -1;
wdev->wext.default_mgmt_key = -1;
wdev->wext.connect.auth_type = <API key>;
#endif
if (wdev->wiphy->flags & <API key>)
wdev->ps = true;
else
wdev->ps = false;
/* allow mac80211 to determine the timeout */
wdev->ps_timeout = -1;
if (!dev->ethtool_ops)
dev->ethtool_ops = &<API key>;
if ((wdev->iftype == <API key> ||
wdev->iftype == <API key> ||
wdev->iftype == <API key>) && !wdev->use_4addr)
dev->priv_flags |= IFF_DONT_BRIDGE;
break;
case NETDEV_GOING_DOWN:
switch (wdev->iftype) {
case <API key>:
cfg80211_leave_ibss(rdev, dev, true);
break;
case <API key>:
case <API key>:
mutex_lock(&rdev->sched_scan_mtx);
<API key>(rdev, false);
mutex_unlock(&rdev->sched_scan_mtx);
wdev_lock(wdev);
#ifdef <API key>
kfree(wdev->wext.ie);
wdev->wext.ie = NULL;
wdev->wext.ie_len = 0;
wdev->wext.connect.auth_type = <API key>;
#endif
<API key>(rdev, dev,
<API key>, true);
cfg80211_mlme_down(rdev, dev);
wdev_unlock(wdev);
break;
case <API key>:
cfg80211_leave_mesh(rdev, dev);
break;
default:
break;
}
wdev->beacon_interval = 0;
break;
case NETDEV_DOWN:
dev_hold(dev);
queue_work(cfg80211_wq, &wdev->cleanup_work);
break;
case NETDEV_UP:
/*
* If we have a really quick DOWN/UP succession we may
* have this work still pending ... cancel it and see
* if it was pending, in which case we need to account
* for some of the work it would have done.
*/
if (cancel_work_sync(&wdev->cleanup_work)) {
mutex_lock(&rdev->devlist_mtx);
rdev->opencount
mutex_unlock(&rdev->devlist_mtx);
dev_put(dev);
}
cfg80211_lock_rdev(rdev);
mutex_lock(&rdev->devlist_mtx);
wdev_lock(wdev);
switch (wdev->iftype) {
#ifdef <API key>
case <API key>:
<API key>(rdev, wdev);
break;
case <API key>:
<API key>(rdev, wdev);
break;
#endif
#ifdef <API key>
case <API key>:
{
/* backward compat code... */
struct mesh_setup setup;
memcpy(&setup, &default_mesh_setup,
sizeof(setup));
/* back compat only needed for mesh_id */
setup.mesh_id = wdev->ssid;
setup.mesh_id_len = wdev->mesh_id_up_len;
if (wdev->mesh_id_up_len)
<API key>(rdev, dev,
&setup,
&default_mesh_config);
break;
}
#endif
default:
break;
}
wdev_unlock(wdev);
rdev->opencount++;
mutex_unlock(&rdev->devlist_mtx);
<API key>(rdev);
/*
* Configure power management to the driver here so that its
* correctly set also after interface type changes etc.
*/
if (wdev->iftype == <API key> &&
rdev->ops->set_power_mgmt)
if (rdev->ops->set_power_mgmt(wdev->wiphy, dev,
wdev->ps,
wdev->ps_timeout)) {
/* assume this means it's off */
wdev->ps = false;
}
break;
case NETDEV_UNREGISTER:
/*
* NB: cannot take rdev->mtx here because this may be
* called within code protected by it when interfaces
* are removed with nl80211.
*/
mutex_lock(&rdev->devlist_mtx);
/*
* It is possible to get NETDEV_UNREGISTER
* multiple times. To detect that, check
* that the interface is still on the list
* of registered interfaces, and only then
* remove and clean it up.
*/
if (!list_empty(&wdev->list)) {
sysfs_remove_link(&dev->dev.kobj, "phy80211");
list_del_rcu(&wdev->list);
rdev->devlist_generation++;
<API key>(wdev);
#ifdef <API key>
kfree(wdev->wext.keys);
#endif
}
mutex_unlock(&rdev->devlist_mtx);
/*
* synchronise (so that we won't find this netdev
* from other code any more) and then clear the list
* head so that the above code can safely check for
* !list_empty() to avoid double-cleanup.
*/
synchronize_rcu();
INIT_LIST_HEAD(&wdev->list);
/*
* Ensure that all events have been processed and
* freed.
*/
<API key>(wdev);
break;
case NETDEV_PRE_UP:
if (!(wdev->wiphy->interface_modes & BIT(wdev->iftype)))
return notifier_from_errno(-EOPNOTSUPP);
if (rfkill_blocked(rdev->rfkill))
return notifier_from_errno(-ERFKILL);
ret = <API key>(rdev, wdev->iftype);
if (ret)
return notifier_from_errno(ret);
break;
}
return NOTIFY_DONE;
}
static struct notifier_block <API key> = {
.notifier_call = <API key>,
};
static void __net_exit <API key>(struct net *net)
{
struct <API key> *rdev;
rtnl_lock();
mutex_lock(&cfg80211_mutex);
list_for_each_entry(rdev, &cfg80211_rdev_list, list) {
if (net_eq(wiphy_net(&rdev->wiphy), net))
WARN_ON(<API key>(rdev, &init_net));
}
mutex_unlock(&cfg80211_mutex);
rtnl_unlock();
}
static struct pernet_operations cfg80211_pernet_ops = {
.exit = <API key>,
};
static int __init cfg80211_init(void)
{
int err;
err = <API key>(&cfg80211_pernet_ops);
if (err)
goto out_fail_pernet;
err = wiphy_sysfs_init();
if (err)
goto out_fail_sysfs;
err = <API key>(&<API key>);
if (err)
goto out_fail_notifier;
err = nl80211_init();
if (err)
goto out_fail_nl80211;
<API key> = debugfs_create_dir("ieee80211", NULL);
err = regulatory_init();
if (err)
goto out_fail_reg;
cfg80211_wq = <API key>("cfg80211");
if (!cfg80211_wq)
goto out_fail_wq;
return 0;
out_fail_wq:
regulatory_exit();
out_fail_reg:
debugfs_remove(<API key>);
out_fail_nl80211:
<API key>(&<API key>);
out_fail_notifier:
wiphy_sysfs_exit();
out_fail_sysfs:
<API key>(&cfg80211_pernet_ops);
out_fail_pernet:
return err;
}
subsys_initcall(cfg80211_init);
static void __exit cfg80211_exit(void)
{
debugfs_remove(<API key>);
nl80211_exit();
<API key>(&<API key>);
wiphy_sysfs_exit();
regulatory_exit();
<API key>(&cfg80211_pernet_ops);
destroy_workqueue(cfg80211_wq);
}
module_exit(cfg80211_exit); |
// <API key>: GPL-2.0-or-later
#include "cache.h"
#include "cacheops.h"
#include "config.h"
#include "printf.h"
#define cache_op(op,addr) \
__asm__ __volatile__( \
" .set push \n" \
" .set noreorder \n" \
" .set mips3\n\t \n" \
" cache %0, %1 \n" \
" .set pop \n" \
: \
: "i" (op), "R" (*(unsigned char *)(addr)))
void flush_cache(unsigned long start_addr, unsigned long size)
{
unsigned long lsize = <API key>;
unsigned long addr = start_addr & ~(lsize - 1);
unsigned long aend = (start_addr + size + (lsize - 1)) & ~(lsize - 1);
printf("blasting from 0x%08x to 0x%08x (0x%08x - 0x%08x)\n", start_addr, size, addr, aend);
while (1) {
cache_op(Hit_Writeback_Inv_D, addr);
cache_op(Hit_Invalidate_I, addr);
if (addr == aend)
break;
addr += lsize;
}
} |
#define KMSG_COMPONENT "zpci"
#define pr_fmt(fmt) KMSG_COMPONENT ": " fmt
#include <linux/kernel.h>
#include <linux/slab.h>
#include <linux/err.h>
#include <linux/export.h>
#include <linux/delay.h>
#include <linux/irq.h>
#include <linux/kernel_stat.h>
#include <linux/seq_file.h>
#include <linux/pci.h>
#include <linux/msi.h>
#include <asm/isc.h>
#include <asm/airq.h>
#include <asm/facility.h>
#include <asm/pci_insn.h>
#include <asm/pci_clp.h>
#include <asm/pci_dma.h>
#define DEBUG /* enable pr_debug */
#define SIC_IRQ_MODE_ALL 0
#define SIC_IRQ_MODE_SINGLE 1
#define ZPCI_NR_DMA_SPACES 1
#define ZPCI_NR_DEVICES <API key>
/* list of all detected zpci devices */
static LIST_HEAD(zpci_list);
static DEFINE_SPINLOCK(zpci_list_lock);
static struct irq_chip zpci_irq_chip = {
.name = "zPCI",
.irq_unmask = unmask_msi_irq,
.irq_mask = mask_msi_irq,
};
static DECLARE_BITMAP(zpci_domain, ZPCI_NR_DEVICES);
static DEFINE_SPINLOCK(zpci_domain_lock);
static struct airq_iv *zpci_aisb_iv;
static struct airq_iv *zpci_aibv[ZPCI_NR_DEVICES];
/* Adapter interrupt definitions */
static void zpci_irq_handler(struct airq_struct *airq);
static struct airq_struct zpci_airq = {
.handler = zpci_irq_handler,
.isc = PCI_ISC,
};
/* I/O Map */
static DEFINE_SPINLOCK(zpci_iomap_lock);
static DECLARE_BITMAP(zpci_iomap, <API key>);
struct zpci_iomap_entry *zpci_iomap_start;
EXPORT_SYMBOL_GPL(zpci_iomap_start);
static struct kmem_cache *zdev_fmb_cache;
struct zpci_dev *get_zdev(struct pci_dev *pdev)
{
return (struct zpci_dev *) pdev->sysdata;
}
struct zpci_dev *get_zdev_by_fid(u32 fid)
{
struct zpci_dev *tmp, *zdev = NULL;
spin_lock(&zpci_list_lock);
list_for_each_entry(tmp, &zpci_list, entry) {
if (tmp->fid == fid) {
zdev = tmp;
break;
}
}
spin_unlock(&zpci_list_lock);
return zdev;
}
static struct zpci_dev *get_zdev_by_bus(struct pci_bus *bus)
{
return (bus && bus->sysdata) ? (struct zpci_dev *) bus->sysdata : NULL;
}
int pci_domain_nr(struct pci_bus *bus)
{
return ((struct zpci_dev *) bus->sysdata)->domain;
}
EXPORT_SYMBOL_GPL(pci_domain_nr);
int pci_proc_domain(struct pci_bus *bus)
{
return pci_domain_nr(bus);
}
EXPORT_SYMBOL_GPL(pci_proc_domain);
/* Modify PCI: Register adapter interruptions */
static int zpci_set_airq(struct zpci_dev *zdev)
{
u64 req = ZPCI_CREATE_REQ(zdev->fh, 0, ZPCI_MOD_FC_REG_INT);
struct zpci_fib fib = {0};
fib.isc = PCI_ISC;
fib.sum = 1; /* enable summary notifications */
fib.noi = airq_iv_end(zdev->aibv);
fib.aibv = (unsigned long) zdev->aibv->vector;
fib.aibvo = 0; /* each zdev has its own interrupt vector */
fib.aisb = (unsigned long) zpci_aisb_iv->vector + (zdev->aisb/64)*8;
fib.aisbo = zdev->aisb & 63;
return zpci_mod_fc(req, &fib);
}
struct mod_pci_args {
u64 base;
u64 limit;
u64 iota;
u64 fmb_addr;
};
static int mod_pci(struct zpci_dev *zdev, int fn, u8 dmaas, struct mod_pci_args *args)
{
u64 req = ZPCI_CREATE_REQ(zdev->fh, dmaas, fn);
struct zpci_fib fib = {0};
fib.pba = args->base;
fib.pal = args->limit;
fib.iota = args->iota;
fib.fmb_addr = args->fmb_addr;
return zpci_mod_fc(req, &fib);
}
/* Modify PCI: Register I/O address translation parameters */
int zpci_register_ioat(struct zpci_dev *zdev, u8 dmaas,
u64 base, u64 limit, u64 iota)
{
struct mod_pci_args args = { base, limit, iota, 0 };
WARN_ON_ONCE(iota & 0x3fff);
args.iota |= ZPCI_IOTA_RTTO_FLAG;
return mod_pci(zdev, <API key>, dmaas, &args);
}
/* Modify PCI: Unregister I/O address translation parameters */
int <API key>(struct zpci_dev *zdev, u8 dmaas)
{
struct mod_pci_args args = { 0, 0, 0, 0 };
return mod_pci(zdev, <API key>, dmaas, &args);
}
/* Modify PCI: Unregister adapter interruptions */
static int zpci_clear_airq(struct zpci_dev *zdev)
{
struct mod_pci_args args = { 0, 0, 0, 0 };
return mod_pci(zdev, <API key>, 0, &args);
}
/* Modify PCI: Set PCI function measurement parameters */
int <API key>(struct zpci_dev *zdev)
{
struct mod_pci_args args = { 0, 0, 0, 0 };
if (zdev->fmb)
return -EINVAL;
zdev->fmb = kmem_cache_zalloc(zdev_fmb_cache, GFP_KERNEL);
if (!zdev->fmb)
return -ENOMEM;
WARN_ON((u64) zdev->fmb & 0xf);
args.fmb_addr = virt_to_phys(zdev->fmb);
return mod_pci(zdev, <API key>, 0, &args);
}
/* Modify PCI: Disable PCI function measurement */
int <API key>(struct zpci_dev *zdev)
{
struct mod_pci_args args = { 0, 0, 0, 0 };
int rc;
if (!zdev->fmb)
return -EINVAL;
/* Function measurement is disabled if fmb address is zero */
rc = mod_pci(zdev, <API key>, 0, &args);
kmem_cache_free(zdev_fmb_cache, zdev->fmb);
zdev->fmb = NULL;
return rc;
}
#define ZPCI_PCIAS_CFGSPC 15
static int zpci_cfg_load(struct zpci_dev *zdev, int offset, u32 *val, u8 len)
{
u64 req = ZPCI_CREATE_REQ(zdev->fh, ZPCI_PCIAS_CFGSPC, len);
u64 data;
int rc;
rc = zpci_load(&data, req, offset);
if (!rc) {
data = data << ((8 - len) * 8);
data = le64_to_cpu(data);
*val = (u32) data;
} else
*val = 0xffffffff;
return rc;
}
static int zpci_cfg_store(struct zpci_dev *zdev, int offset, u32 val, u8 len)
{
u64 req = ZPCI_CREATE_REQ(zdev->fh, ZPCI_PCIAS_CFGSPC, len);
u64 data = val;
int rc;
data = cpu_to_le64(data);
data = data >> ((8 - len) * 8);
rc = zpci_store(data, req, offset);
return rc;
}
void pcibios_fixup_bus(struct pci_bus *bus)
{
}
resource_size_t <API key>(void *data, const struct resource *res,
resource_size_t size,
resource_size_t align)
{
return 0;
}
/* combine single writes by using store-block insn */
void __iowrite64_copy(void __iomem *to, const void *from, size_t count)
{
zpci_memcpy_toio(to, from, count);
}
/* Create a virtual mapping cookie for a PCI BAR */
void __iomem *pci_iomap(struct pci_dev *pdev, int bar, unsigned long max)
{
struct zpci_dev *zdev = get_zdev(pdev);
u64 addr;
int idx;
if ((bar & 7) != bar)
return NULL;
idx = zdev->bars[bar].map_idx;
spin_lock(&zpci_iomap_lock);
zpci_iomap_start[idx].fh = zdev->fh;
zpci_iomap_start[idx].bar = bar;
spin_unlock(&zpci_iomap_lock);
addr = <API key> | ((u64) idx << 48);
return (void __iomem *) addr;
}
EXPORT_SYMBOL_GPL(pci_iomap);
void pci_iounmap(struct pci_dev *pdev, void __iomem *addr)
{
unsigned int idx;
idx = (((__force u64) addr) & ~<API key>) >> 48;
spin_lock(&zpci_iomap_lock);
zpci_iomap_start[idx].fh = 0;
zpci_iomap_start[idx].bar = 0;
spin_unlock(&zpci_iomap_lock);
}
EXPORT_SYMBOL_GPL(pci_iounmap);
static int pci_read(struct pci_bus *bus, unsigned int devfn, int where,
int size, u32 *val)
{
struct zpci_dev *zdev = get_zdev_by_bus(bus);
int ret;
if (!zdev || devfn != ZPCI_DEVFN)
ret = -ENODEV;
else
ret = zpci_cfg_load(zdev, where, val, size);
return ret;
}
static int pci_write(struct pci_bus *bus, unsigned int devfn, int where,
int size, u32 val)
{
struct zpci_dev *zdev = get_zdev_by_bus(bus);
int ret;
if (!zdev || devfn != ZPCI_DEVFN)
ret = -ENODEV;
else
ret = zpci_cfg_store(zdev, where, val, size);
return ret;
}
static struct pci_ops pci_root_ops = {
.read = pci_read,
.write = pci_write,
};
static void zpci_irq_handler(struct airq_struct *airq)
{
unsigned long si, ai;
struct airq_iv *aibv;
int irqs_on = 0;
inc_irq_stat(IRQIO_PCI);
for (si = 0;;) {
/* Scan adapter summary indicator bit vector */
si = airq_iv_scan(zpci_aisb_iv, si, airq_iv_end(zpci_aisb_iv));
if (si == -1UL) {
if (irqs_on++)
/* End of second scan with interrupts on. */
break;
/* First scan complete, reenable interrupts. */
zpci_set_irq_ctrl(SIC_IRQ_MODE_SINGLE, NULL, PCI_ISC);
si = 0;
continue;
}
/* Scan the adapter interrupt vector for this device. */
aibv = zpci_aibv[si];
for (ai = 0;;) {
ai = airq_iv_scan(aibv, ai, airq_iv_end(aibv));
if (ai == -1UL)
break;
inc_irq_stat(IRQIO_MSI);
airq_iv_lock(aibv, ai);
generic_handle_irq(airq_iv_get_data(aibv, ai));
airq_iv_unlock(aibv, ai);
}
}
}
int arch_setup_msi_irqs(struct pci_dev *pdev, int nvec, int type)
{
struct zpci_dev *zdev = get_zdev(pdev);
unsigned int hwirq, msi_vecs;
unsigned long aisb;
struct msi_desc *msi;
struct msi_msg msg;
int rc, irq;
if (type == PCI_CAP_ID_MSI && nvec > 1)
return 1;
msi_vecs = min(nvec, ZPCI_MSI_VEC_MAX);
msi_vecs = min_t(unsigned int, msi_vecs, CONFIG_PCI_NR_MSI);
/* Allocate adapter summary indicator bit */
rc = -EIO;
aisb = airq_iv_alloc_bit(zpci_aisb_iv);
if (aisb == -1UL)
goto out;
zdev->aisb = aisb;
/* Create adapter interrupt vector */
rc = -ENOMEM;
zdev->aibv = airq_iv_create(msi_vecs, AIRQ_IV_DATA | AIRQ_IV_BITLOCK);
if (!zdev->aibv)
goto out_si;
/* Wire up shortcut pointer */
zpci_aibv[aisb] = zdev->aibv;
/* Request MSI interrupts */
hwirq = 0;
list_for_each_entry(msi, &pdev->msi_list, list) {
rc = -EIO;
irq = irq_alloc_desc(0); /* Alloc irq on node 0 */
if (irq < 0)
goto out_msi;
rc = irq_set_msi_desc(irq, msi);
if (rc)
goto out_msi;
<API key>(irq, &zpci_irq_chip,
handle_simple_irq);
msg.data = hwirq;
msg.address_lo = zdev->msi_addr & 0xffffffff;
msg.address_hi = zdev->msi_addr >> 32;
pci_write_msi_msg(irq, &msg);
airq_iv_set_data(zdev->aibv, hwirq, irq);
hwirq++;
}
/* Enable adapter interrupts */
rc = zpci_set_airq(zdev);
if (rc)
goto out_msi;
return (msi_vecs == nvec) ? 0 : msi_vecs;
out_msi:
list_for_each_entry(msi, &pdev->msi_list, list) {
if (hwirq
break;
irq_set_msi_desc(msi->irq, NULL);
irq_free_desc(msi->irq);
msi->msg.address_lo = 0;
msi->msg.address_hi = 0;
msi->msg.data = 0;
msi->irq = 0;
}
zpci_aibv[aisb] = NULL;
airq_iv_release(zdev->aibv);
out_si:
airq_iv_free_bit(zpci_aisb_iv, aisb);
out:
return rc;
}
void <API key>(struct pci_dev *pdev)
{
struct zpci_dev *zdev = get_zdev(pdev);
struct msi_desc *msi;
int rc;
/* Disable adapter interrupts */
rc = zpci_clear_airq(zdev);
if (rc)
return;
/* Release MSI interrupts */
list_for_each_entry(msi, &pdev->msi_list, list) {
if (msi->msi_attrib.is_msix)
<API key>(msi, 1);
else
<API key>(msi, 1, 1);
irq_set_msi_desc(msi->irq, NULL);
irq_free_desc(msi->irq);
msi->msg.address_lo = 0;
msi->msg.address_hi = 0;
msi->msg.data = 0;
msi->irq = 0;
}
zpci_aibv[zdev->aisb] = NULL;
airq_iv_release(zdev->aibv);
airq_iv_free_bit(zpci_aisb_iv, zdev->aisb);
}
static void zpci_map_resources(struct zpci_dev *zdev)
{
struct pci_dev *pdev = zdev->pdev;
resource_size_t len;
int i;
for (i = 0; i < PCI_BAR_COUNT; i++) {
len = pci_resource_len(pdev, i);
if (!len)
continue;
pdev->resource[i].start = (resource_size_t) pci_iomap(pdev, i, 0);
pdev->resource[i].end = pdev->resource[i].start + len - 1;
}
}
static void <API key>(struct zpci_dev *zdev)
{
struct pci_dev *pdev = zdev->pdev;
resource_size_t len;
int i;
for (i = 0; i < PCI_BAR_COUNT; i++) {
len = pci_resource_len(pdev, i);
if (!len)
continue;
pci_iounmap(pdev, (void *) pdev->resource[i].start);
}
}
static int __init zpci_irq_init(void)
{
int rc;
rc = <API key>(&zpci_airq);
if (rc)
goto out;
/* Set summary to 1 to be called every time for the ISC. */
*zpci_airq.lsi_ptr = 1;
rc = -ENOMEM;
zpci_aisb_iv = airq_iv_create(ZPCI_NR_DEVICES, AIRQ_IV_ALLOC);
if (!zpci_aisb_iv)
goto out_airq;
zpci_set_irq_ctrl(SIC_IRQ_MODE_SINGLE, NULL, PCI_ISC);
return 0;
out_airq:
<API key>(&zpci_airq);
out:
return rc;
}
static void zpci_irq_exit(void)
{
airq_iv_release(zpci_aisb_iv);
<API key>(&zpci_airq);
}
static int zpci_alloc_iomap(struct zpci_dev *zdev)
{
int entry;
spin_lock(&zpci_iomap_lock);
entry = find_first_zero_bit(zpci_iomap, <API key>);
if (entry == <API key>) {
spin_unlock(&zpci_iomap_lock);
return -ENOSPC;
}
set_bit(entry, zpci_iomap);
spin_unlock(&zpci_iomap_lock);
return entry;
}
static void zpci_free_iomap(struct zpci_dev *zdev, int entry)
{
spin_lock(&zpci_iomap_lock);
memset(&zpci_iomap_start[entry], 0, sizeof(struct zpci_iomap_entry));
clear_bit(entry, zpci_iomap);
spin_unlock(&zpci_iomap_lock);
}
static struct resource *__alloc_res(struct zpci_dev *zdev, unsigned long start,
unsigned long size, unsigned long flags)
{
struct resource *r;
r = kzalloc(sizeof(*r), GFP_KERNEL);
if (!r)
return NULL;
r->start = start;
r->end = r->start + size - 1;
r->flags = flags;
r->name = zdev->res_name;
if (request_resource(&iomem_resource, r)) {
kfree(r);
return NULL;
}
return r;
}
static int <API key>(struct zpci_dev *zdev,
struct list_head *resources)
{
unsigned long addr, size, flags;
struct resource *res;
int i, entry;
snprintf(zdev->res_name, sizeof(zdev->res_name),
"PCI Bus %04x:%02x", zdev->domain, ZPCI_BUS_NR);
for (i = 0; i < PCI_BAR_COUNT; i++) {
if (!zdev->bars[i].size)
continue;
entry = zpci_alloc_iomap(zdev);
if (entry < 0)
return entry;
zdev->bars[i].map_idx = entry;
/* only MMIO is supported */
flags = IORESOURCE_MEM;
if (zdev->bars[i].val & 8)
flags |= IORESOURCE_PREFETCH;
if (zdev->bars[i].val & 4)
flags |= IORESOURCE_MEM_64;
addr = <API key> + ((u64) entry << 48);
size = 1UL << zdev->bars[i].size;
res = __alloc_res(zdev, addr, size, flags);
if (!res) {
zpci_free_iomap(zdev, entry);
return -ENOMEM;
}
zdev->bars[i].res = res;
pci_add_resource(resources, res);
}
return 0;
}
static void <API key>(struct zpci_dev *zdev)
{
int i;
for (i = 0; i < PCI_BAR_COUNT; i++) {
if (!zdev->bars[i].size)
continue;
zpci_free_iomap(zdev, zdev->bars[i].map_idx);
release_resource(zdev->bars[i].res);
kfree(zdev->bars[i].res);
}
}
int pcibios_add_device(struct pci_dev *pdev)
{
struct zpci_dev *zdev = get_zdev(pdev);
struct resource *res;
int i;
zdev->pdev = pdev;
pdev->dev.groups = zpci_attr_groups;
zpci_map_resources(zdev);
for (i = 0; i < PCI_BAR_COUNT; i++) {
res = &pdev->resource[i];
if (res->parent || !res->flags)
continue;
pci_claim_resource(pdev, i);
}
return 0;
}
int <API key>(struct pci_dev *pdev, int mask)
{
struct zpci_dev *zdev = get_zdev(pdev);
zdev->pdev = pdev;
<API key>(zdev);
<API key>(zdev);
zpci_map_resources(zdev);
return <API key>(pdev, mask);
}
void <API key>(struct pci_dev *pdev)
{
struct zpci_dev *zdev = get_zdev(pdev);
<API key>(zdev);
<API key>(zdev);
<API key>(zdev);
zdev->pdev = NULL;
}
#ifdef <API key>
static int zpci_restore(struct device *dev)
{
struct zpci_dev *zdev = get_zdev(to_pci_dev(dev));
int ret = 0;
if (zdev->state != <API key>)
goto out;
ret = clp_enable_fh(zdev, ZPCI_NR_DMA_SPACES);
if (ret)
goto out;
zpci_map_resources(zdev);
zpci_register_ioat(zdev, 0, zdev->start_dma + PAGE_OFFSET,
zdev->start_dma + zdev->iommu_size - 1,
(u64) zdev->dma_table);
out:
return ret;
}
static int zpci_freeze(struct device *dev)
{
struct zpci_dev *zdev = get_zdev(to_pci_dev(dev));
if (zdev->state != <API key>)
return 0;
<API key>(zdev, 0);
return clp_disable_fh(zdev);
}
struct dev_pm_ops pcibios_pm_ops = {
.thaw_noirq = zpci_restore,
.freeze_noirq = zpci_freeze,
.restore_noirq = zpci_restore,
.poweroff_noirq = zpci_freeze,
};
#endif /* <API key> */
static int zpci_alloc_domain(struct zpci_dev *zdev)
{
spin_lock(&zpci_domain_lock);
zdev->domain = find_first_zero_bit(zpci_domain, ZPCI_NR_DEVICES);
if (zdev->domain == ZPCI_NR_DEVICES) {
spin_unlock(&zpci_domain_lock);
return -ENOSPC;
}
set_bit(zdev->domain, zpci_domain);
spin_unlock(&zpci_domain_lock);
return 0;
}
static void zpci_free_domain(struct zpci_dev *zdev)
{
spin_lock(&zpci_domain_lock);
clear_bit(zdev->domain, zpci_domain);
spin_unlock(&zpci_domain_lock);
}
void pcibios_remove_bus(struct pci_bus *bus)
{
struct zpci_dev *zdev = get_zdev_by_bus(bus);
zpci_exit_slot(zdev);
<API key>(zdev);
zpci_free_domain(zdev);
spin_lock(&zpci_list_lock);
list_del(&zdev->entry);
spin_unlock(&zpci_list_lock);
kfree(zdev);
}
static int zpci_scan_bus(struct zpci_dev *zdev)
{
LIST_HEAD(resources);
int ret;
ret = <API key>(zdev, &resources);
if (ret)
return ret;
zdev->bus = pci_scan_root_bus(NULL, ZPCI_BUS_NR, &pci_root_ops,
zdev, &resources);
if (!zdev->bus) {
<API key>(zdev);
return -EIO;
}
zdev->bus->max_bus_speed = zdev->max_bus_speed;
return 0;
}
int zpci_enable_device(struct zpci_dev *zdev)
{
int rc;
rc = clp_enable_fh(zdev, ZPCI_NR_DMA_SPACES);
if (rc)
goto out;
rc = <API key>(zdev);
if (rc)
goto out_dma;
zdev->state = <API key>;
return 0;
out_dma:
clp_disable_fh(zdev);
out:
return rc;
}
EXPORT_SYMBOL_GPL(zpci_enable_device);
int zpci_disable_device(struct zpci_dev *zdev)
{
<API key>(zdev);
return clp_disable_fh(zdev);
}
EXPORT_SYMBOL_GPL(zpci_disable_device);
int zpci_create_device(struct zpci_dev *zdev)
{
int rc;
rc = zpci_alloc_domain(zdev);
if (rc)
goto out;
if (zdev->state == <API key>) {
rc = zpci_enable_device(zdev);
if (rc)
goto out_free;
}
rc = zpci_scan_bus(zdev);
if (rc)
goto out_disable;
spin_lock(&zpci_list_lock);
list_add_tail(&zdev->entry, &zpci_list);
spin_unlock(&zpci_list_lock);
zpci_init_slot(zdev);
return 0;
out_disable:
if (zdev->state == <API key>)
zpci_disable_device(zdev);
out_free:
zpci_free_domain(zdev);
out:
return rc;
}
void zpci_stop_device(struct zpci_dev *zdev)
{
<API key>(zdev);
/*
* Note: SCLP disables fh via set-pci-fn so don't
* do that here.
*/
}
EXPORT_SYMBOL_GPL(zpci_stop_device);
static inline int barsize(u8 size)
{
return (size) ? (1 << size) >> 10 : 0;
}
static int zpci_mem_init(void)
{
zdev_fmb_cache = kmem_cache_create("PCI_FMB_cache", sizeof(struct zpci_fmb),
16, 0, NULL);
if (!zdev_fmb_cache)
goto error_zdev;
/* TODO: use realloc */
zpci_iomap_start = kzalloc(<API key> * sizeof(*zpci_iomap_start),
GFP_KERNEL);
if (!zpci_iomap_start)
goto error_iomap;
return 0;
error_iomap:
kmem_cache_destroy(zdev_fmb_cache);
error_zdev:
return -ENOMEM;
}
static void zpci_mem_exit(void)
{
kfree(zpci_iomap_start);
kmem_cache_destroy(zdev_fmb_cache);
}
static unsigned int s390_pci_probe = 1;
static unsigned int <API key>;
char * __init pcibios_setup(char *str)
{
if (!strcmp(str, "off")) {
s390_pci_probe = 0;
return NULL;
}
return str;
}
bool zpci_is_enabled(void)
{
return <API key>;
}
static int __init pci_base_init(void)
{
int rc;
if (!s390_pci_probe)
return 0;
if (!test_facility(2) || !test_facility(69)
|| !test_facility(71) || !test_facility(72))
return 0;
rc = zpci_debug_init();
if (rc)
goto out;
rc = zpci_mem_init();
if (rc)
goto out_mem;
rc = zpci_irq_init();
if (rc)
goto out_irq;
rc = zpci_dma_init();
if (rc)
goto out_dma;
rc = <API key>();
if (rc)
goto out_find;
<API key> = 1;
return 0;
out_find:
zpci_dma_exit();
out_dma:
zpci_irq_exit();
out_irq:
zpci_mem_exit();
out_mem:
zpci_debug_exit();
out:
return rc;
}
<API key>(pci_base_init);
void zpci_rescan(void)
{
if (zpci_is_enabled())
<API key>();
} |
#include "avformat.h"
#include "internal.h"
#include "subtitles.h"
#include "libavcodec/internal.h"
#include "libavutil/avstring.h"
#include "libavutil/bprint.h"
#include "libavutil/intreadwrite.h"
typedef struct {
<API key> q;
} SubViewerContext;
static int subviewer_probe(AVProbeData *p)
{
char c;
const unsigned char *ptr = p->buf;
if (AV_RB24(ptr) == 0xEFBBBF)
ptr += 3; /* skip UTF-8 BOM */
if (sscanf(ptr, "%*u:%*u:%*u.%*u,%*u:%*u:%*u.%*u%c", &c) == 1)
return <API key>;
if (!strncmp(ptr, "[INFORMATION]", 13))
return AVPROBE_SCORE_MAX/3;
return 0;
}
static int read_ts(const char *s, int64_t *start, int *duration)
{
int64_t end;
int hh1, mm1, ss1, ms1;
int hh2, mm2, ss2, ms2;
if (sscanf(s, "%u:%u:%u.%u,%u:%u:%u.%u",
&hh1, &mm1, &ss1, &ms1, &hh2, &mm2, &ss2, &ms2) == 8) {
end = (hh2*3600LL + mm2*60LL + ss2) * 100LL + ms2;
*start = (hh1*3600LL + mm1*60LL + ss1) * 100LL + ms1;
*duration = end - *start;
return 0;
}
return -1;
}
static int <API key>(AVFormatContext *s)
{
SubViewerContext *subviewer = s->priv_data;
AVStream *st = avformat_new_stream(s, NULL);
AVBPrint header;
int res = 0, new_event = 1;
int64_t pts_start = AV_NOPTS_VALUE;
int duration = -1;
AVPacket *sub = NULL;
if (!st)
return AVERROR(ENOMEM);
avpriv_set_pts_info(st, 64, 1, 100);
st->codec->codec_type = <API key>;
st->codec->codec_id = <API key>;
av_bprint_init(&header, 0, <API key>);
while (!avio_feof(s->pb)) {
char line[2048];
int64_t pos = 0;
int len = ff_get_line(s->pb, line, sizeof(line));
if (!len)
break;
line[strcspn(line, "\r\n")] = 0;
if (line[0] == '[' && strncmp(line, "[br]", 4)) {
/* ignore event style, XXX: add to side_data? */
if (strstr(line, "[COLF]") || strstr(line, "[SIZE]") ||
strstr(line, "[FONT]") || strstr(line, "[STYLE]"))
continue;
if (!st->codec->extradata) { // header not finalized yet
av_bprintf(&header, "%s\n", line);
if (!strncmp(line, "[END INFORMATION]", 17) || !strncmp(line, "[SUBTITLE]", 10)) {
/* end of header */
res = <API key>(st->codec, &header);
if (res < 0)
goto end;
} else if (strncmp(line, "[INFORMATION]", 13)) {
/* assume file metadata at this point */
int i, j = 0;
char key[32], value[128];
for (i = 1; i < sizeof(key) - 1 && line[i] && line[i] != ']'; i++)
key[i - 1] = av_tolower(line[i]);
key[i - 1] = 0;
if (line[i] == ']')
i++;
while (line[i] == ' ')
i++;
while (j < sizeof(value) - 1 && line[i] && line[i] != ']')
value[j++] = line[i++];
value[j] = 0;
av_dict_set(&s->metadata, key, value, 0);
}
}
} else if (read_ts(line, &pts_start, &duration) >= 0) {
new_event = 1;
pos = avio_tell(s->pb);
} else if (*line) {
if (!new_event) {
sub = <API key>(&subviewer->q, "\n", 1, 1);
if (!sub) {
res = AVERROR(ENOMEM);
goto end;
}
}
sub = <API key>(&subviewer->q, line, strlen(line), !new_event);
if (!sub) {
res = AVERROR(ENOMEM);
goto end;
}
if (new_event) {
sub->pos = pos;
sub->pts = pts_start;
sub->duration = duration;
}
new_event = 0;
}
}
<API key>(s, &subviewer->q);
end:
av_bprint_finalize(&header, NULL);
return res;
}
static int <API key>(AVFormatContext *s, AVPacket *pkt)
{
SubViewerContext *subviewer = s->priv_data;
return <API key>(&subviewer->q, pkt);
}
static int subviewer_read_seek(AVFormatContext *s, int stream_index,
int64_t min_ts, int64_t ts, int64_t max_ts, int flags)
{
SubViewerContext *subviewer = s->priv_data;
return <API key>(&subviewer->q, s, stream_index,
min_ts, ts, max_ts, flags);
}
static int <API key>(AVFormatContext *s)
{
SubViewerContext *subviewer = s->priv_data;
<API key>(&subviewer->q);
return 0;
}
AVInputFormat <API key> = {
.name = "subviewer",
.long_name = <API key>("SubViewer subtitle format"),
.priv_data_size = sizeof(SubViewerContext),
.read_probe = subviewer_probe,
.read_header = <API key>,
.read_packet = <API key>,
.read_seek2 = subviewer_read_seek,
.read_close = <API key>,
.extensions = "sub",
}; |
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('jquery'), require('./util.js')) :
typeof define === 'function' && define.amd ? define(['jquery', './util.js'], factory) :
(global = global || self, global.Alert = factory(global.jQuery, global.Util));
}(this, function ($, Util) { 'use strict';
$ = $ && $.hasOwnProperty('default') ? $['default'] : $;
Util = Util && Util.hasOwnProperty('default') ? Util['default'] : Util;
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);
}
}
function _createClass(Constructor, protoProps, staticProps) {
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
if (staticProps) _defineProperties(Constructor, staticProps);
return Constructor;
}
var NAME = 'alert';
var VERSION = '4.3.1';
var DATA_KEY = 'bs.alert';
var EVENT_KEY = "." + DATA_KEY;
var DATA_API_KEY = '.data-api';
var JQUERY_NO_CONFLICT = $.fn[NAME];
var Selector = {
DISMISS: '[data-dismiss="alert"]'
};
var Event = {
CLOSE: "close" + EVENT_KEY,
CLOSED: "closed" + EVENT_KEY,
CLICK_DATA_API: "click" + EVENT_KEY + DATA_API_KEY
};
var ClassName = {
ALERT: 'alert',
FADE: 'fade',
SHOW: 'show'
};
var Alert =
/*#__PURE__*/
function () {
function Alert(element) {
this._element = element;
} // Getters
var _proto = Alert.prototype;
// Public
_proto.close = function close(element) {
var rootElement = this._element;
if (element) {
rootElement = this._getRootElement(element);
}
var customEvent = this._triggerCloseEvent(rootElement);
if (customEvent.isDefaultPrevented()) {
return;
}
this._removeElement(rootElement);
};
_proto.dispose = function dispose() {
$.removeData(this._element, DATA_KEY);
this._element = null;
} // Private
;
_proto._getRootElement = function _getRootElement(element) {
var selector = Util.<API key>(element);
var parent = false;
if (selector) {
parent = document.querySelector(selector);
}
if (!parent) {
parent = $(element).closest("." + ClassName.ALERT)[0];
}
return parent;
};
_proto._triggerCloseEvent = function _triggerCloseEvent(element) {
var closeEvent = $.Event(Event.CLOSE);
$(element).trigger(closeEvent);
return closeEvent;
};
_proto._removeElement = function _removeElement(element) {
var _this = this;
$(element).removeClass(ClassName.SHOW);
if (!$(element).hasClass(ClassName.FADE)) {
this._destroyElement(element);
return;
}
var transitionDuration = Util.<API key>(element);
$(element).one(Util.TRANSITION_END, function (event) {
return _this._destroyElement(element, event);
}).<API key>(transitionDuration);
};
_proto._destroyElement = function _destroyElement(element) {
$(element).detach().trigger(Event.CLOSED).remove();
} // Static
;
Alert._jQueryInterface = function _jQueryInterface(config) {
return this.each(function () {
var $element = $(this);
var data = $element.data(DATA_KEY);
if (!data) {
data = new Alert(this);
$element.data(DATA_KEY, data);
}
if (config === 'close') {
data[config](this);
}
});
};
Alert._handleDismiss = function _handleDismiss(alertInstance) {
return function (event) {
if (event) {
event.preventDefault();
}
alertInstance.close(this);
};
};
_createClass(Alert, null, [{
key: "VERSION",
get: function get() {
return VERSION;
}
}]);
return Alert;
}();
$(document).on(Event.CLICK_DATA_API, Selector.DISMISS, Alert._handleDismiss(new Alert()));
$.fn[NAME] = Alert._jQueryInterface;
$.fn[NAME].Constructor = Alert;
$.fn[NAME].noConflict = function () {
$.fn[NAME] = JQUERY_NO_CONFLICT;
return Alert._jQueryInterface;
};
return Alert;
})); |
#include <stdlib.h>
#define pvPortMalloc(xSize) (malloc(xSize))
#define vPortFree(pv) (free(pv)) |
// @(#)root/graf:$Id$
#ifndef ROOT_TPaveText
#define ROOT_TPaveText
#include "TPave.h"
#include "TText.h"
class TLine;
class TPaveText : public TPave, public TAttText {
protected:
TString fLabel; ///< Label written at the top of the pavetext
Int_t fLongest; ///< Length of the longest line
Float_t fMargin; ///< Text margin
TList *fLines; ///< List of labels
public:
TPaveText();
TPaveText(Double_t x1, Double_t y1,Double_t x2 ,Double_t y2, Option_t *option="br");
TPaveText(const TPaveText &pavetext);
virtual ~TPaveText();
TPaveText& operator=(const TPaveText&);
virtual TBox *AddBox(Double_t x1, Double_t y1, Double_t x2, Double_t y2);
virtual TLine *AddLine(Double_t x1=0, Double_t y1=0, Double_t x2=0, Double_t y2=0);
virtual TText *AddText(Double_t x1, Double_t y1, const char *label);
virtual TText *AddText(const char *label);
virtual void Clear(Option_t *option=""); // *MENU*
virtual void DeleteText(); // *MENU*
virtual void Draw(Option_t *option="");
virtual void DrawFile(const char *filename, Option_t *option="");
virtual void EditText(); // *MENU*
const char *GetLabel() const {return fLabel.Data();}
virtual TText *GetLine(Int_t number) const;
virtual TText *GetLineWith(const char *text) const;
virtual TList *GetListOfLines() const {return fLines;}
Float_t GetMargin() const {return fMargin;}
virtual TObject *GetObject(Double_t &ymouse, Double_t &yobj) const;
virtual Int_t GetSize() const;
virtual void InsertLine(); // *MENU*
virtual void InsertText(const char *label); // *MENU*
virtual void Paint(Option_t *option="");
virtual void PaintPrimitives(Int_t mode);
virtual void Print(Option_t *option="") const;
virtual void ReadFile(const char *filename, Option_t *option="", Int_t nlines=50, Int_t fromline=0); // *MENU*
virtual void SaveLines(std::ostream &out, const char *name, Bool_t saved);
virtual void SavePrimitive(std::ostream &out, Option_t *option = "");
virtual void SetAllWith(const char *text, Option_t *option, Double_t value); // *MENU*
virtual void SetLabel(const char *label) {fLabel = label;} // *MENU*
virtual void SetMargin(Float_t margin=0.05) {fMargin=margin;} // *MENU*
virtual void UseCurrentStyle();
ClassDef(TPaveText,2) //PaveText. A Pave with several lines of text.
};
#endif |
// @(#)root/roostats:$Id$
#ifndef <API key>
#define <API key>
#ifndef <API key>
#include "RooStats/CombinedCalculator.h"
#endif
#include "RooStats/LikelihoodInterval.h"
namespace RooStats {
class LikelihoodInterval;
/**
<API key> is a concrete implementation of CombinedCalculator (the interface class for a tools which can produce both RooStats HypoTestResults and ConfIntervals).
The tool uses the profile likelihood ratio as a test statistic, and assumes that Wilks' theorem is valid. Wilks' theorem states that -2* log (profile likelihood ratio) is asymptotically distributed as a chi^2 distribution with N-dof, where N is the number of degrees of freedom. Thus, p-values can be constructed and the profile likelihood ratio can be used to construct a LikelihoodInterval. (In the future, this class could be extended to use toy Monte Carlo to calibrate the distribution of the test statistic).
Usage: It uses the interface of the CombinedCalculator, so that it can be configured by specifying:
* a model common model (eg. a family of specific models which includes both the null and alternate),
* a data set,
* a set of parameters of interest. The nuisance parameters will be all other parameters of the model
* a set of parameters of which specify the null hypothesis (including values and const/non-const status)
The interface allows one to pass the model, data, and parameters either directly or via a ModelConfig class. The alternate hypothesis leaves the parameter free to take any value other than those specified by the null hypotesis. There is therefore no need to specify the alternate parameters.
After configuring the calculator, one only needs to ask GetHypoTest() (which will return a HypoTestResult pointer) or GetInterval() (which will return an ConfInterval pointer).
This calculator can work with both one-dimensional intervals or multi-dimensional ones (contours)
Note that for hypothesis tests, it is oftern better to use the RooStats::<API key> class, which can compute in addition the expected p-value using an Asimov data set.
\ingroup Roostats
*/
class <API key> : public CombinedCalculator {
public:
Default constructor (needed for I/O)
<API key>();
Constructor from data, from a full model pdf describing both parameter of interest and nuisance parameters
and from the set specifying the parameter of interest (POI).
There is no need to specify the nuisance parameters since they are all other parameters of the model.
When using the calculator for performing an hypothesis test one needs to provide also a snapshot (a copy)
defining the null parameters and their value. There is no need to pass the alternate parameters. These
will be obtained by the value maximazing the likelihood function
<API key>(RooAbsData& data, RooAbsPdf& pdf, const RooArgSet& paramsOfInterest,
Double_t size = 0.05, const RooArgSet* nullParams = 0 );
Constructor from data and a model configuration
If the ModelConfig defines a prior pdf for any of the parameters those will be included as constrained terms in the
likelihood function
<API key>(RooAbsData& data, ModelConfig & model, Double_t size = 0.05);
virtual ~<API key>();
Return a likelihood interval. A global fit to the likelihood is performed and
the interval is constructed using the the profile likelihood ratio function of the POI
virtual LikelihoodInterval* GetInterval() const ;
Return the hypothesis test result obtained from the likelihood ratio of the
maximum likelihood value with the null parameters fixed to their values, with respect keeping all parameters
floating (global maximum likelihood value).
virtual HypoTestResult* GetHypoTest() const;
protected:
// clear internal fit result
void DoReset() const;
// perform a global fit
RooAbsReal * DoGlobalFit() const;
// minimize likelihood
static RooFitResult * DoMinimizeNLL(RooAbsReal * nll);
mutable RooFitResult * fFitResult; // internal result of gloabl fit
mutable bool fGlobalFitDone; // flag to control if a global fit has been done
ClassDef(<API key>,2) // A concrete implementation of CombinedCalculator that uses the ProfileLikelihood ratio.
};
}
#endif |
/* Based on Dreamweaver's 2col_leftNav.css */
/* HTML tag styles */
body{
font-family: "Trebuchet MS", Arial, sans-serif;
color: #333333;
line-height: 1.166;
margin: 0px;
padding: 0px;
}
a:link, a:visited, a:hover {
color: #3300CC;
text-decoration: none;
font-weight: bold;
}
a:visited {
color:#330066;
}
a:hover {
text-decoration:underline;
}
/* overrides decoration from previous rule for hovered links */
h1, h2, h3, h4, h5, h6 {
font-family: "Trebuchet MS", Arial, sans-serif;
margin: 0px;
padding: 0px;
color: #662200;
}
h1{
font-size: 140%;
}
h2{
margin-top:20px;
font-size: 120%;
border-top: 1px solid #eebb88;
}
h3, h4, h5, h6 {
color: #bb8855;
}
h3{
font-style:italic;
}
h4{
font-size: 100%;
text-indent: 20px;
}
h5{
font-size: 100%;
text-indent: 40px;
font-weight: normal;
}
ul{
list-style-type: square;
}
ul ul{
list-style-type: disc;
}
ul ul ul{
list-style-type: none;
}
label{
font-family: "Trebuchet MS",sans-serif;
color: #334d55;
}
/* Layout Divs */
#masthead{
margin: 0;
padding: 4px 0px;
background-color: #ffcc99;
border-bottom: 1px solid #eebb88;
width: 100%;
height: 100px;
}
#banner{
float: left;
margin: 0;
padding: 4px 10px;
background-color: #ffcc99;
vertical-align:middle;
width: 20%;
}
#navBar{
padding: 0px;
background-color: #ffcc99;
border-right: 1px solid #eebb88;
width: 20%;
}
#navBarExtension{
padding: 0px;
background-color: #ffcc99;
border-right: 1px solid #eebb88;
width: 20%;
height: 100%;
min-height: 100px;
float: left;
}
#content{
width: 75%;
left: 25%;
margin: 0;
padding: 8px 3% 0 8px;
float: right;
background-color:#ffffff;
}
/*Component Divs */
#siteName{
margin: 0px;
padding: 0px 0px 10px 10px;
font-family:Georgia, "Times New Roman", Times, serif;
font-weight:bold;
font-size: 36px;
vertical-align:middle;
background-color: #ffcc99;
color:#330033;
}
#packageName{
font-size:28px;
}
#version{
font-size:86%;
}
#mainTitle{
margin: 0px;
padding: 0px 0px 10px 10px;
font-family:Georgia, "Times New Roman", Times, serif;
font-size: 14px;
vertical-align:middle;
color:#320032;
background-color: #ffcc99;
float: left;
}
#subtitle{
color: #330033;
background-color: #ffcc99;
padding-right: 20px;
font-family:Georgia, "Times New Roman", Times, serif;
font-weight:bold;
font-size: 18px;
font-style:italic;
float: right;
height:80px;
vertical-align:-450%;
}
#pageName{
padding: 0px 0px 10px 10px;
}
#globalNav{
color: #eebb88;
padding: 0px 0px 0px 10px;
white-space: nowrap;
}
/* 'nowrap' prevents links from line-wrapping if there are too many to fit in one line
this will force a horizontal scrollbar if there isn't enough room for all links
remove rule or change value to 'normal' if you want the links to line-wrap */
#globalNav img{
display: block;
}
#globalNav a {
font-size: 90%;
padding: 0px 4px 0px 0px;
}
#siteInfo{
border: 1px solid #eebb88;
font-size: 75%;
color: #555555;
padding: 10px 10px 10px 10px;
margin-top: 0px;
margin-right: 10px;
width: 75%;
left: 25%;
float: right;
}
/* negative top margin pulls siteinfo up so its top border overlaps (and thus lines up with)
the bottom border of the navBar in cases where they "touch" */
#siteInfo img{
padding: 4px 4px 4px 0px;
vertical-align: middle;
}
#navBar ul a:link, #navBar ul a:visited {display: block;}
#navBar ul {list-style: none; margin: 0; padding: 0;}
#navBar a:link {color:#773300;}
#navBar a:visited {color:#bb6644;}
/* hack to fix IE/Win's broken rendering of block-level anchors in lists */
#navBar li {border-bottom: 1px solid #EEE;}
/* fix for browsers that don't need the hack */
html>body #navBar li {border-bottom: none;}
#subUL {list-style: none; margin; 0; padding-left: 6px; font-size: 75%; text-indent:8px;}
#extraTopMarginLI {padding-top: 12px}
#sectionLinks{
position: relative;
margin: 0px;
padding: 0px;
border-bottom: 1px solid #eebb88;
font-size: 90%;
}
#sectionLinks h3{
padding: 10px 0px 2px 10px;
}
#sectionLinks a:link{
padding: 2px 0px 2px 10px;
border-top: 1px solid #eebb88;
width: 100%;
voice-family: "\"}\"";
voice-family:inherit;
width: auto;
}
#sectionLinks a:visited{
border-top: 1px solid #eebb88;
padding: 2px 0px 2px 10px;
}
#sectionLinks a:hover{
border-top: 1px solid #eebb88;
background-color: #eebb88;
padding: 2px 0px 2px 10px;
}
#menu {
font-family:Georgia, "Times New Roman", Times, serif;
color: #000000;
font-weight:600;
} |
package org.elasticsearch.action.get;
import com.carrotsearch.hppc.IntArrayList;
import org.elasticsearch.action.<API key>;
import org.elasticsearch.action.support.single.shard.SingleShardRequest;
import org.elasticsearch.common.io.stream.StreamInput;
import org.elasticsearch.common.io.stream.StreamOutput;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
public class <API key> extends SingleShardRequest<<API key>> {
private int shardId;
private String preference;
private boolean realtime;
private boolean refresh;
IntArrayList locations;
List<MultiGetRequest.Item> items;
<API key>(StreamInput in) throws IOException {
super(in);
int size = in.readVInt();
locations = new IntArrayList(size);
items = new ArrayList<>(size);
for (int i = 0; i < size; i++) {
locations.add(in.readVInt());
items.add(new MultiGetRequest.Item(in));
}
preference = in.readOptionalString();
refresh = in.readBoolean();
realtime = in.readBoolean();
}
<API key>(MultiGetRequest multiGetRequest, String index, int shardId) {
super(index);
this.shardId = shardId;
locations = new IntArrayList();
items = new ArrayList<>();
preference = multiGetRequest.preference;
realtime = multiGetRequest.realtime;
refresh = multiGetRequest.refresh;
}
@Override
public <API key> validate() {
return super.<API key>();
}
public int shardId() {
return this.shardId;
}
/**
* Sets the preference to execute the search. Defaults to randomize across shards. Can be set to
* {@code _local} to prefer local shards or a custom value, which guarantees that the same order
* will be used across different requests.
*/
public <API key> preference(String preference) {
this.preference = preference;
return this;
}
public String preference() {
return this.preference;
}
public boolean realtime() {
return this.realtime;
}
public <API key> realtime(boolean realtime) {
this.realtime = realtime;
return this;
}
public boolean refresh() {
return this.refresh;
}
public <API key> refresh(boolean refresh) {
this.refresh = refresh;
return this;
}
void add(int location, MultiGetRequest.Item item) {
this.locations.add(location);
this.items.add(item);
}
@Override
public String[] indices() {
String[] indices = new String[items.size()];
for (int i = 0; i < indices.length; i++) {
indices[i] = items.get(i).index();
}
return indices;
}
@Override
public void writeTo(StreamOutput out) throws IOException {
super.writeTo(out);
out.writeVInt(locations.size());
for (int i = 0; i < locations.size(); i++) {
out.writeVInt(locations.get(i));
items.get(i).writeTo(out);
}
out.writeOptionalString(preference);
out.writeBoolean(refresh);
out.writeBoolean(realtime);
}
} |
/*
* $Id: jpc_dec.c,v 1.2 2008-05-26 09:40:52 vp153 Exp $
*/
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
#include "jasper/jas_types.h"
#include "jasper/jas_math.h"
#include "jasper/jas_tvp.h"
#include "jasper/jas_malloc.h"
#include "jasper/jas_debug.h"
#include "jpc_fix.h"
#include "jpc_dec.h"
#include "jpc_cs.h"
#include "jpc_mct.h"
#include "jpc_t2dec.h"
#include "jpc_t1dec.h"
#include "jpc_math.h"
#define JPC_MHSOC 0x0001
/* In the main header, expecting a SOC marker segment. */
#define JPC_MHSIZ 0x0002
/* In the main header, expecting a SIZ marker segment. */
#define JPC_MH 0x0004
/* In the main header, expecting "other" marker segments. */
#define JPC_TPHSOT 0x0008
/* In a tile-part header, expecting a SOT marker segment. */
#define JPC_TPH 0x0010
/* In a tile-part header, expecting "other" marker segments. */
#define JPC_MT 0x0020
/* In the main trailer. */
typedef struct {
uint_fast16_t id;
/* The marker segment type. */
int validstates;
/* The states in which this type of marker segment can be
validly encountered. */
int (*action)(jpc_dec_t *dec, jpc_ms_t *ms);
/* The action to take upon encountering this type of marker segment. */
} jpc_dec_mstabent_t;
/* COD/COC parameters have been specified. */
#define JPC_CSET 0x0001
/* QCD/QCC parameters have been specified. */
#define JPC_QSET 0x0002
/* COD/COC parameters set from a COC marker segment. */
#define JPC_COC 0x0004
/* QCD/QCC parameters set from a QCC marker segment. */
#define JPC_QCC 0x0008
static int jpc_dec_dump(jpc_dec_t *dec, FILE *out);
jpc_ppxstab_t *jpc_ppxstab_create(void);
void jpc_ppxstab_destroy(jpc_ppxstab_t *tab);
int jpc_ppxstab_grow(jpc_ppxstab_t *tab, int maxents);
int jpc_ppxstab_insert(jpc_ppxstab_t *tab, jpc_ppxstabent_t *ent);
jpc_streamlist_t *<API key>(jpc_ppxstab_t *tab);
int jpc_pptstabwrite(jas_stream_t *out, jpc_ppxstab_t *tab);
jpc_ppxstabent_t *<API key>(void);
void <API key>(jpc_ppxstabent_t *ent);
int <API key>(jpc_streamlist_t *streamlist);
jpc_streamlist_t *<API key>(void);
int <API key>(jpc_streamlist_t *streamlist, int streamno,
jas_stream_t *stream);
jas_stream_t *<API key>(jpc_streamlist_t *streamlist, int streamno);
void <API key>(jpc_streamlist_t *streamlist);
jas_stream_t *jpc_streamlist_get(jpc_streamlist_t *streamlist, int streamno);
static void <API key>(jpc_dec_cp_t *cp);
static jpc_dec_cp_t *jpc_dec_cp_create(uint_fast16_t numcomps);
static int jpc_dec_cp_isvalid(jpc_dec_cp_t *cp);
static jpc_dec_cp_t *jpc_dec_cp_copy(jpc_dec_cp_t *cp);
static int <API key>(jpc_dec_cp_t *cp, jpc_cod_t *cod);
static int <API key>(jpc_dec_cp_t *cp, jpc_coc_t *coc);
static int <API key>(jpc_dec_cp_t *cp, jpc_dec_ccp_t *ccp,
jpc_coxcp_t *compparms, int flags);
static int <API key>(jpc_dec_cp_t *cp, jpc_qcd_t *qcd);
static int <API key>(jpc_dec_cp_t *cp, jpc_qcc_t *qcc);
static int <API key>(jpc_dec_cp_t *cp, jpc_dec_ccp_t *ccp,
jpc_qcxcp_t *compparms, int flags);
static int <API key>(jpc_dec_cp_t *cp, jpc_rgn_t *rgn);
static int jpc_dec_cp_prepare(jpc_dec_cp_t *cp);
static void jpc_dec_cp_destroy(jpc_dec_cp_t *cp);
static int <API key>(jpc_dec_cp_t *cp, jpc_poc_t *poc, int reset);
static int <API key>(jpc_pi_t *pi, jpc_poc_t *poc);
static int jpc_dec_decode(jpc_dec_t *dec);
static jpc_dec_t *jpc_dec_create(<API key> *impopts, jas_stream_t *in);
static void jpc_dec_destroy(jpc_dec_t *dec);
static void jpc_dequantize(jas_matrix_t *x, jpc_fix_t absstepsize);
static void jpc_undo_roi(jas_matrix_t *x, int roishift, int bgshift, int numbps);
static jpc_fix_t jpc_calcabsstepsize(int stepsize, int numbits);
static int jpc_dec_tiledecode(jpc_dec_t *dec, jpc_dec_tile_t *tile);
static int jpc_dec_tileinit(jpc_dec_t *dec, jpc_dec_tile_t *tile);
static int jpc_dec_tilefini(jpc_dec_t *dec, jpc_dec_tile_t *tile);
static int jpc_dec_process_soc(jpc_dec_t *dec, jpc_ms_t *ms);
static int jpc_dec_process_sot(jpc_dec_t *dec, jpc_ms_t *ms);
static int jpc_dec_process_sod(jpc_dec_t *dec, jpc_ms_t *ms);
static int jpc_dec_process_eoc(jpc_dec_t *dec, jpc_ms_t *ms);
static int jpc_dec_process_siz(jpc_dec_t *dec, jpc_ms_t *ms);
static int jpc_dec_process_cod(jpc_dec_t *dec, jpc_ms_t *ms);
static int jpc_dec_process_coc(jpc_dec_t *dec, jpc_ms_t *ms);
static int jpc_dec_process_rgn(jpc_dec_t *dec, jpc_ms_t *ms);
static int jpc_dec_process_qcd(jpc_dec_t *dec, jpc_ms_t *ms);
static int jpc_dec_process_qcc(jpc_dec_t *dec, jpc_ms_t *ms);
static int jpc_dec_process_poc(jpc_dec_t *dec, jpc_ms_t *ms);
static int jpc_dec_process_ppm(jpc_dec_t *dec, jpc_ms_t *ms);
static int jpc_dec_process_ppt(jpc_dec_t *dec, jpc_ms_t *ms);
static int jpc_dec_process_com(jpc_dec_t *dec, jpc_ms_t *ms);
static int jpc_dec_process_unk(jpc_dec_t *dec, jpc_ms_t *ms);
static int jpc_dec_process_crg(jpc_dec_t *dec, jpc_ms_t *ms);
static int jpc_dec_parseopts(char *optstr, <API key> *opts);
static jpc_dec_mstabent_t *<API key>(uint_fast16_t id);
jpc_dec_mstabent_t jpc_dec_mstab[] = {
{JPC_MS_SOC, JPC_MHSOC, jpc_dec_process_soc},
{JPC_MS_SOT, JPC_MH | JPC_TPHSOT, jpc_dec_process_sot},
{JPC_MS_SOD, JPC_TPH, jpc_dec_process_sod},
{JPC_MS_EOC, JPC_TPHSOT, jpc_dec_process_eoc},
{JPC_MS_SIZ, JPC_MHSIZ, jpc_dec_process_siz},
{JPC_MS_COD, JPC_MH | JPC_TPH, jpc_dec_process_cod},
{JPC_MS_COC, JPC_MH | JPC_TPH, jpc_dec_process_coc},
{JPC_MS_RGN, JPC_MH | JPC_TPH, jpc_dec_process_rgn},
{JPC_MS_QCD, JPC_MH | JPC_TPH, jpc_dec_process_qcd},
{JPC_MS_QCC, JPC_MH | JPC_TPH, jpc_dec_process_qcc},
{JPC_MS_POC, JPC_MH | JPC_TPH, jpc_dec_process_poc},
{JPC_MS_TLM, JPC_MH, 0},
{JPC_MS_PLM, JPC_MH, 0},
{JPC_MS_PLT, JPC_TPH, 0},
{JPC_MS_PPM, JPC_MH, jpc_dec_process_ppm},
{JPC_MS_PPT, JPC_TPH, jpc_dec_process_ppt},
{JPC_MS_SOP, 0, 0},
{JPC_MS_CRG, JPC_MH, jpc_dec_process_crg},
{JPC_MS_COM, JPC_MH | JPC_TPH, jpc_dec_process_com},
{0, JPC_MH | JPC_TPH, jpc_dec_process_unk}
};
jas_image_t *jpc_decode(jas_stream_t *in, char *optstr)
{
<API key> opts;
jpc_dec_t *dec;
jas_image_t *image;
dec = 0;
if (jpc_dec_parseopts(optstr, &opts)) {
goto error;
}
jpc_initluts();
if (!(dec = jpc_dec_create(&opts, in))) {
goto error;
}
/* Do most of the work. */
if (jpc_dec_decode(dec)) {
goto error;
}
if (jas_image_numcmpts(dec->image) >= 3) {
jas_image_setclrspc(dec->image, JAS_CLRSPC_SRGB);
<API key>(dec->image, 0,
JAS_IMAGE_CT_COLOR(<API key>));
<API key>(dec->image, 1,
JAS_IMAGE_CT_COLOR(<API key>));
<API key>(dec->image, 2,
JAS_IMAGE_CT_COLOR(<API key>));
} else {
jas_image_setclrspc(dec->image, JAS_CLRSPC_SGRAY);
<API key>(dec->image, 0,
JAS_IMAGE_CT_COLOR(<API key>));
}
/* Save the return value. */
image = dec->image;
/* Stop the image from being discarded. */
dec->image = 0;
/* Destroy decoder. */
jpc_dec_destroy(dec);
return image;
error:
if (dec) {
jpc_dec_destroy(dec);
}
return 0;
}
typedef enum {
OPT_MAXLYRS,
OPT_MAXPKTS,
OPT_DEBUG
} optid_t;
jas_taginfo_t decopts[] = {
{OPT_MAXLYRS, "maxlyrs"},
{OPT_MAXPKTS, "maxpkts"},
{OPT_DEBUG, "debug"},
{-1, 0}
};
static int jpc_dec_parseopts(char *optstr, <API key> *opts)
{
jas_tvparser_t *tvp;
opts->debug = 0;
opts->maxlyrs = JPC_MAXLYRS;
opts->maxpkts = -1;
if (!(tvp = jas_tvparser_create(optstr ? optstr : ""))) {
return -1;
}
while (!jas_tvparser_next(tvp)) {
switch (jas_taginfo_nonull(jas_taginfos_lookup(decopts,
jas_tvparser_gettag(tvp)))->id) {
case OPT_MAXLYRS:
opts->maxlyrs = atoi(jas_tvparser_getval(tvp));
break;
case OPT_DEBUG:
opts->debug = atoi(jas_tvparser_getval(tvp));
break;
case OPT_MAXPKTS:
opts->maxpkts = atoi(jas_tvparser_getval(tvp));
break;
default:
jas_eprintf("warning: ignoring invalid option %s\n",
jas_tvparser_gettag(tvp));
break;
}
}
<API key>(tvp);
return 0;
}
static jpc_dec_mstabent_t *<API key>(uint_fast16_t id)
{
jpc_dec_mstabent_t *mstabent;
for (mstabent = jpc_dec_mstab; mstabent->id != 0; ++mstabent) {
if (mstabent->id == id) {
break;
}
}
return mstabent;
}
static int jpc_dec_decode(jpc_dec_t *dec)
{
jpc_ms_t *ms;
jpc_dec_mstabent_t *mstabent;
int ret;
jpc_cstate_t *cstate;
if (!(cstate = jpc_cstate_create())) {
return -1;
}
dec->cstate = cstate;
/* Initially, we should expect to encounter a SOC marker segment. */
dec->state = JPC_MHSOC;
for (;;) {
/* Get the next marker segment in the code stream. */
if (!(ms = jpc_getms(dec->in, cstate))) {
jas_eprintf("cannot get marker segment\n");
return -1;
}
mstabent = <API key>(ms->id);
assert(mstabent);
/* Ensure that this type of marker segment is permitted
at this point in the code stream. */
if (!(dec->state & mstabent->validstates)) {
jas_eprintf("unexpected marker segment type\n");
jpc_ms_destroy(ms);
return -1;
}
/* Process the marker segment. */
if (mstabent->action) {
ret = (*mstabent->action)(dec, ms);
} else {
/* No explicit action is required. */
ret = 0;
}
/* Destroy the marker segment. */
jpc_ms_destroy(ms);
if (ret < 0) {
return -1;
} else if (ret > 0) {
break;
}
}
return 0;
}
static int jpc_dec_process_crg(jpc_dec_t *dec, jpc_ms_t *ms)
{
int cmptno;
jpc_dec_cmpt_t *cmpt;
jpc_crg_t *crg;
crg = &ms->parms.crg;
for (cmptno = 0, cmpt = dec->cmpts; cmptno < dec->numcomps; ++cmptno,
++cmpt) {
/* Ignore the information in the CRG marker segment for now.
This information serves no useful purpose for decoding anyhow.
Some other parts of the code need to be changed if these lines
are uncommented.
cmpt->hsubstep = crg->comps[cmptno].hoff;
cmpt->vsubstep = crg->comps[cmptno].voff;
*/
}
return 0;
}
static int jpc_dec_process_soc(jpc_dec_t *dec, jpc_ms_t *ms)
{
/* Eliminate warnings about unused variables. */
ms = 0;
/* We should expect to encounter a SIZ marker segment next. */
dec->state = JPC_MHSIZ;
return 0;
}
static int jpc_dec_process_sot(jpc_dec_t *dec, jpc_ms_t *ms)
{
jpc_dec_tile_t *tile;
jpc_sot_t *sot = &ms->parms.sot;
<API key> *compinfos;
<API key> *compinfo;
jpc_dec_cmpt_t *cmpt;
int cmptno;
if (dec->state == JPC_MH) {
compinfos = jas_alloc2(dec->numcomps, sizeof(<API key>));
assert(compinfos);
for (cmptno = 0, cmpt = dec->cmpts, compinfo = compinfos;
cmptno < dec->numcomps; ++cmptno, ++cmpt, ++compinfo) {
compinfo->tlx = 0;
compinfo->tly = 0;
compinfo->prec = cmpt->prec;
compinfo->sgnd = cmpt->sgnd;
compinfo->width = cmpt->width;
compinfo->height = cmpt->height;
compinfo->hstep = cmpt->hstep;
compinfo->vstep = cmpt->vstep;
}
if (!(dec->image = jas_image_create(dec->numcomps, compinfos,
JAS_CLRSPC_UNKNOWN))) {
return -1;
}
jas_free(compinfos);
/* Is the packet header information stored in PPM marker segments in
the main header? */
if (dec->ppmstab) {
/* Convert the PPM marker segment data into a collection of streams
(one stream per tile-part). */
if (!(dec->pkthdrstreams = <API key>(dec->ppmstab))) {
abort();
}
jpc_ppxstab_destroy(dec->ppmstab);
dec->ppmstab = 0;
}
}
if (sot->len > 0) {
dec->curtileendoff = <API key>(dec->in) - ms->len -
4 + sot->len;
} else {
dec->curtileendoff = 0;
}
if (JAS_CAST(int, sot->tileno) > dec->numtiles) {
jas_eprintf("invalid tile number in SOT marker segment\n");
return -1;
}
/* Set the current tile. */
dec->curtile = &dec->tiles[sot->tileno];
tile = dec->curtile;
/* Ensure that this is the expected part number. */
if (sot->partno != tile->partno) {
return -1;
}
if (tile->numparts > 0 && sot->partno >= tile->numparts) {
return -1;
}
if (!tile->numparts && sot->numparts > 0) {
tile->numparts = sot->numparts;
}
tile->pptstab = 0;
switch (tile->state) {
case JPC_TILE_INIT:
/* This is the first tile-part for this tile. */
tile->state = JPC_TILE_ACTIVE;
assert(!tile->cp);
if (!(tile->cp = jpc_dec_cp_copy(dec->cp))) {
return -1;
}
<API key>(dec->cp);
break;
default:
if (sot->numparts == sot->partno - 1) {
tile->state = JPC_TILE_ACTIVELAST;
}
break;
}
/* Note: We do not increment the expected tile-part number until
all processing for this tile-part is complete. */
/* We should expect to encounter other tile-part header marker
segments next. */
dec->state = JPC_TPH;
return 0;
}
static int jpc_dec_process_sod(jpc_dec_t *dec, jpc_ms_t *ms)
{
jpc_dec_tile_t *tile;
int pos;
/* Eliminate compiler warnings about unused variables. */
ms = 0;
if (!(tile = dec->curtile)) {
return -1;
}
if (!tile->partno) {
if (!jpc_dec_cp_isvalid(tile->cp)) {
return -1;
}
jpc_dec_cp_prepare(tile->cp);
if (jpc_dec_tileinit(dec, tile)) {
return -1;
}
}
/* Are packet headers stored in the main header or tile-part header? */
if (dec->pkthdrstreams) {
/* Get the stream containing the packet header data for this
tile-part. */
if (!(tile->pkthdrstream = <API key>(dec->pkthdrstreams, 0))) {
return -1;
}
}
if (tile->pptstab) {
if (!tile->pkthdrstream) {
if (!(tile->pkthdrstream = jas_stream_memopen(0, 0))) {
return -1;
}
}
pos = jas_stream_tell(tile->pkthdrstream);
jas_stream_seek(tile->pkthdrstream, 0, SEEK_END);
if (jpc_pptstabwrite(tile->pkthdrstream, tile->pptstab)) {
return -1;
}
jas_stream_seek(tile->pkthdrstream, pos, SEEK_SET);
jpc_ppxstab_destroy(tile->pptstab);
tile->pptstab = 0;
}
if (jas_getdbglevel() >= 10) {
jpc_dec_dump(dec, stderr);
}
if (jpc_dec_decodepkts(dec, (tile->pkthdrstream) ? tile->pkthdrstream :
dec->in, dec->in)) {
jas_eprintf("jpc_dec_decodepkts failed\n");
return -1;
}
/* Gobble any unconsumed tile data. */
if (dec->curtileendoff > 0) {
long curoff;
uint_fast32_t n;
curoff = <API key>(dec->in);
if (curoff < dec->curtileendoff) {
n = dec->curtileendoff - curoff;
jas_eprintf("warning: ignoring trailing garbage (%lu bytes)\n",
(unsigned long) n);
while (n
if (jas_stream_getc(dec->in) == EOF) {
jas_eprintf("read error\n");
return -1;
}
}
} else if (curoff > dec->curtileendoff) {
jas_eprintf("warning: not enough tile data (%lu bytes)\n",
(unsigned long) curoff - dec->curtileendoff);
}
}
if (tile->numparts > 0 && tile->partno == tile->numparts - 1) {
if (jpc_dec_tiledecode(dec, tile)) {
return -1;
}
jpc_dec_tilefini(dec, tile);
}
dec->curtile = 0;
/* Increment the expected tile-part number. */
++tile->partno;
/* We should expect to encounter a SOT marker segment next. */
dec->state = JPC_TPHSOT;
return 0;
}
static int jpc_dec_tileinit(jpc_dec_t *dec, jpc_dec_tile_t *tile)
{
jpc_dec_tcomp_t *tcomp;
int compno;
int rlvlno;
jpc_dec_rlvl_t *rlvl;
jpc_dec_band_t *band;
jpc_dec_prc_t *prc;
int bndno;
jpc_tsfb_band_t *bnd;
int bandno;
jpc_dec_ccp_t *ccp;
int prccnt;
jpc_dec_cblk_t *cblk;
int cblkcnt;
uint_fast32_t tlprcxstart;
uint_fast32_t tlprcystart;
uint_fast32_t brprcxend;
uint_fast32_t brprcyend;
uint_fast32_t tlcbgxstart;
uint_fast32_t tlcbgystart;
uint_fast32_t brcbgxend;
uint_fast32_t brcbgyend;
uint_fast32_t cbgxstart;
uint_fast32_t cbgystart;
uint_fast32_t cbgxend;
uint_fast32_t cbgyend;
uint_fast32_t tlcblkxstart;
uint_fast32_t tlcblkystart;
uint_fast32_t brcblkxend;
uint_fast32_t brcblkyend;
uint_fast32_t cblkxstart;
uint_fast32_t cblkystart;
uint_fast32_t cblkxend;
uint_fast32_t cblkyend;
uint_fast32_t tmpxstart;
uint_fast32_t tmpystart;
uint_fast32_t tmpxend;
uint_fast32_t tmpyend;
jpc_dec_cp_t *cp;
jpc_tsfb_band_t bnds[64];
jpc_pchg_t *pchg;
int pchgno;
jpc_dec_cmpt_t *cmpt;
cp = tile->cp;
tile->realmode = 0;
if (cp->mctid == JPC_MCT_ICT) {
tile->realmode = 1;
}
for (compno = 0, tcomp = tile->tcomps, cmpt = dec->cmpts; compno <
dec->numcomps; ++compno, ++tcomp, ++cmpt) {
ccp = &tile->cp->ccps[compno];
if (ccp->qmfbid == JPC_COX_INS) {
tile->realmode = 1;
}
tcomp->numrlvls = ccp->numrlvls;
if (!(tcomp->rlvls = jas_alloc2(tcomp->numrlvls,
sizeof(jpc_dec_rlvl_t)))) {
return -1;
}
if (!(tcomp->data = jas_seq2d_create(JPC_CEILDIV(tile->xstart,
cmpt->hstep), JPC_CEILDIV(tile->ystart, cmpt->vstep),
JPC_CEILDIV(tile->xend, cmpt->hstep), JPC_CEILDIV(tile->yend,
cmpt->vstep)))) {
return -1;
}
if (!(tcomp->tsfb = jpc_cod_gettsfb(ccp->qmfbid,
tcomp->numrlvls - 1))) {
return -1;
}
{
jpc_tsfb_getbands(tcomp->tsfb, jas_seq2d_xstart(tcomp->data), jas_seq2d_ystart(tcomp->data), jas_seq2d_xend(tcomp->data), jas_seq2d_yend(tcomp->data), bnds);
}
for (rlvlno = 0, rlvl = tcomp->rlvls; rlvlno < tcomp->numrlvls;
++rlvlno, ++rlvl) {
rlvl->bands = 0;
rlvl->xstart = JPC_CEILDIVPOW2(tcomp->xstart,
tcomp->numrlvls - 1 - rlvlno);
rlvl->ystart = JPC_CEILDIVPOW2(tcomp->ystart,
tcomp->numrlvls - 1 - rlvlno);
rlvl->xend = JPC_CEILDIVPOW2(tcomp->xend,
tcomp->numrlvls - 1 - rlvlno);
rlvl->yend = JPC_CEILDIVPOW2(tcomp->yend,
tcomp->numrlvls - 1 - rlvlno);
rlvl->prcwidthexpn = ccp->prcwidthexpns[rlvlno];
rlvl->prcheightexpn = ccp->prcheightexpns[rlvlno];
tlprcxstart = JPC_FLOORDIVPOW2(rlvl->xstart,
rlvl->prcwidthexpn) << rlvl->prcwidthexpn;
tlprcystart = JPC_FLOORDIVPOW2(rlvl->ystart,
rlvl->prcheightexpn) << rlvl->prcheightexpn;
brprcxend = JPC_CEILDIVPOW2(rlvl->xend,
rlvl->prcwidthexpn) << rlvl->prcwidthexpn;
brprcyend = JPC_CEILDIVPOW2(rlvl->yend,
rlvl->prcheightexpn) << rlvl->prcheightexpn;
rlvl->numhprcs = (brprcxend - tlprcxstart) >>
rlvl->prcwidthexpn;
rlvl->numvprcs = (brprcyend - tlprcystart) >>
rlvl->prcheightexpn;
rlvl->numprcs = rlvl->numhprcs * rlvl->numvprcs;
if (rlvl->xstart >= rlvl->xend || rlvl->ystart >= rlvl->yend) {
rlvl->bands = 0;
rlvl->numprcs = 0;
rlvl->numhprcs = 0;
rlvl->numvprcs = 0;
continue;
}
if (!rlvlno) {
tlcbgxstart = tlprcxstart;
tlcbgystart = tlprcystart;
brcbgxend = brprcxend;
brcbgyend = brprcyend;
rlvl->cbgwidthexpn = rlvl->prcwidthexpn;
rlvl->cbgheightexpn = rlvl->prcheightexpn;
} else {
tlcbgxstart = JPC_CEILDIVPOW2(tlprcxstart, 1);
tlcbgystart = JPC_CEILDIVPOW2(tlprcystart, 1);
brcbgxend = JPC_CEILDIVPOW2(brprcxend, 1);
brcbgyend = JPC_CEILDIVPOW2(brprcyend, 1);
rlvl->cbgwidthexpn = rlvl->prcwidthexpn - 1;
rlvl->cbgheightexpn = rlvl->prcheightexpn - 1;
}
rlvl->cblkwidthexpn = JAS_MIN(ccp->cblkwidthexpn,
rlvl->cbgwidthexpn);
rlvl->cblkheightexpn = JAS_MIN(ccp->cblkheightexpn,
rlvl->cbgheightexpn);
rlvl->numbands = (!rlvlno) ? 1 : 3;
if (!(rlvl->bands = jas_alloc2(rlvl->numbands,
sizeof(jpc_dec_band_t)))) {
return -1;
}
for (bandno = 0, band = rlvl->bands;
bandno < rlvl->numbands; ++bandno, ++band) {
bndno = (!rlvlno) ? 0 : (3 * (rlvlno - 1) +
bandno + 1);
bnd = &bnds[bndno];
band->orient = bnd->orient;
band->stepsize = ccp->stepsizes[bndno];
band->analgain = JPC_NOMINALGAIN(ccp->qmfbid,
tcomp->numrlvls - 1, rlvlno, band->orient);
band->absstepsize = jpc_calcabsstepsize(band->stepsize,
cmpt->prec + band->analgain);
band->numbps = ccp->numguardbits +
JPC_QCX_GETEXPN(band->stepsize) - 1;
band->roishift = (ccp->roishift + band->numbps >= JPC_PREC) ?
(JPC_PREC - 1 - band->numbps) : ccp->roishift;
band->data = 0;
band->prcs = 0;
if (bnd->xstart == bnd->xend || bnd->ystart == bnd->yend) {
continue;
}
if (!(band->data = jas_seq2d_create(0, 0, 0, 0))) {
return -1;
}
jas_seq2d_bindsub(band->data, tcomp->data, bnd->locxstart, bnd->locystart, bnd->locxend, bnd->locyend);
jas_seq2d_setshift(band->data, bnd->xstart, bnd->ystart);
assert(rlvl->numprcs);
if (!(band->prcs = jas_alloc2(rlvl->numprcs, sizeof(jpc_dec_prc_t)))) {
return -1;
}
cbgxstart = tlcbgxstart;
cbgystart = tlcbgystart;
for (prccnt = rlvl->numprcs, prc = band->prcs;
prccnt > 0; --prccnt, ++prc) {
cbgxend = cbgxstart + (1 << rlvl->cbgwidthexpn);
cbgyend = cbgystart + (1 << rlvl->cbgheightexpn);
prc->xstart = JAS_MAX(cbgxstart, JAS_CAST(uint_fast32_t, jas_seq2d_xstart(band->data)));
prc->ystart = JAS_MAX(cbgystart, JAS_CAST(uint_fast32_t, jas_seq2d_ystart(band->data)));
prc->xend = JAS_MIN(cbgxend, JAS_CAST(uint_fast32_t, jas_seq2d_xend(band->data)));
prc->yend = JAS_MIN(cbgyend, JAS_CAST(uint_fast32_t, jas_seq2d_yend(band->data)));
if (prc->xend > prc->xstart && prc->yend > prc->ystart) {
tlcblkxstart = JPC_FLOORDIVPOW2(prc->xstart,
rlvl->cblkwidthexpn) << rlvl->cblkwidthexpn;
tlcblkystart = JPC_FLOORDIVPOW2(prc->ystart,
rlvl->cblkheightexpn) << rlvl->cblkheightexpn;
brcblkxend = JPC_CEILDIVPOW2(prc->xend,
rlvl->cblkwidthexpn) << rlvl->cblkwidthexpn;
brcblkyend = JPC_CEILDIVPOW2(prc->yend,
rlvl->cblkheightexpn) << rlvl->cblkheightexpn;
prc->numhcblks = (brcblkxend - tlcblkxstart) >>
rlvl->cblkwidthexpn;
prc->numvcblks = (brcblkyend - tlcblkystart) >>
rlvl->cblkheightexpn;
prc->numcblks = prc->numhcblks * prc->numvcblks;
assert(prc->numcblks > 0);
if (!(prc->incltagtree = jpc_tagtree_create(prc->numhcblks, prc->numvcblks))) {
return -1;
}
if (!(prc->numimsbstagtree = jpc_tagtree_create(prc->numhcblks, prc->numvcblks))) {
return -1;
}
if (!(prc->cblks = jas_alloc2(prc->numcblks, sizeof(jpc_dec_cblk_t)))) {
return -1;
}
cblkxstart = cbgxstart;
cblkystart = cbgystart;
for (cblkcnt = prc->numcblks, cblk = prc->cblks; cblkcnt > 0;) {
cblkxend = cblkxstart + (1 << rlvl->cblkwidthexpn);
cblkyend = cblkystart + (1 << rlvl->cblkheightexpn);
tmpxstart = JAS_MAX(cblkxstart, prc->xstart);
tmpystart = JAS_MAX(cblkystart, prc->ystart);
tmpxend = JAS_MIN(cblkxend, prc->xend);
tmpyend = JAS_MIN(cblkyend, prc->yend);
if (tmpxend > tmpxstart && tmpyend > tmpystart) {
cblk->firstpassno = -1;
cblk->mqdec = 0;
cblk->nulldec = 0;
cblk->flags = 0;
cblk->numpasses = 0;
cblk->segs.head = 0;
cblk->segs.tail = 0;
cblk->curseg = 0;
cblk->numimsbs = 0;
cblk->numlenbits = 3;
cblk->flags = 0;
if (!(cblk->data = jas_seq2d_create(0, 0, 0, 0))) {
return -1;
}
jas_seq2d_bindsub(cblk->data, band->data, tmpxstart, tmpystart, tmpxend, tmpyend);
++cblk;
--cblkcnt;
}
cblkxstart += 1 << rlvl->cblkwidthexpn;
if (cblkxstart >= cbgxend) {
cblkxstart = cbgxstart;
cblkystart += 1 << rlvl->cblkheightexpn;
}
}
} else {
prc->cblks = 0;
prc->incltagtree = 0;
prc->numimsbstagtree = 0;
}
cbgxstart += 1 << rlvl->cbgwidthexpn;
if (cbgxstart >= brcbgxend) {
cbgxstart = tlcbgxstart;
cbgystart += 1 << rlvl->cbgheightexpn;
}
}
}
}
}
if (!(tile->pi = jpc_dec_pi_create(dec, tile)))
{
return -1;
}
for (pchgno = 0; pchgno < <API key>(tile->cp->pchglist);
++pchgno) {
pchg = jpc_pchg_copy(jpc_pchglist_get(tile->cp->pchglist, pchgno));
assert(pchg);
jpc_pi_addpchg(tile->pi, pchg);
}
jpc_pi_init(tile->pi);
return 0;
}
static int jpc_dec_tilefini(jpc_dec_t *dec, jpc_dec_tile_t *tile)
{
jpc_dec_tcomp_t *tcomp;
int compno;
int bandno;
int rlvlno;
jpc_dec_band_t *band;
jpc_dec_rlvl_t *rlvl;
int prcno;
jpc_dec_prc_t *prc;
jpc_dec_seg_t *seg;
jpc_dec_cblk_t *cblk;
int cblkno;
if (tile->tcomps) {
for (compno = 0, tcomp = tile->tcomps; compno < dec->numcomps;
++compno, ++tcomp) {
for (rlvlno = 0, rlvl = tcomp->rlvls; rlvlno < tcomp->numrlvls;
++rlvlno, ++rlvl) {
if (!rlvl->bands) {
continue;
}
for (bandno = 0, band = rlvl->bands; bandno < rlvl->numbands; ++bandno, ++band) {
if (band->prcs) {
for (prcno = 0, prc = band->prcs; prcno <
rlvl->numprcs; ++prcno, ++prc) {
if (!prc->cblks) {
continue;
}
for (cblkno = 0, cblk = prc->cblks; cblkno < prc->numcblks; ++cblkno, ++cblk) {
while (cblk->segs.head) {
seg = cblk->segs.head;
jpc_seglist_remove(&cblk->segs, seg);
jpc_seg_destroy(seg);
}
jas_matrix_destroy(cblk->data);
if (cblk->mqdec) {
jpc_mqdec_destroy(cblk->mqdec);
}
if (cblk->nulldec) {
jpc_bitstream_close(cblk->nulldec);
}
if (cblk->flags) {
jas_matrix_destroy(cblk->flags);
}
}
if (prc->incltagtree) {
jpc_tagtree_destroy(prc->incltagtree);
}
if (prc->numimsbstagtree) {
jpc_tagtree_destroy(prc->numimsbstagtree);
}
if (prc->cblks) {
jas_free(prc->cblks);
}
}
}
if (band->data) {
jas_matrix_destroy(band->data);
}
if (band->prcs) {
jas_free(band->prcs);
}
}
if (rlvl->bands) {
jas_free(rlvl->bands);
}
}
if (tcomp->rlvls) {
jas_free(tcomp->rlvls);
}
if (tcomp->data) {
jas_matrix_destroy(tcomp->data);
}
if (tcomp->tsfb) {
jpc_tsfb_destroy(tcomp->tsfb);
}
}
}
if (tile->cp) {
jpc_dec_cp_destroy(tile->cp);
tile->cp = 0;
}
if (tile->tcomps) {
jas_free(tile->tcomps);
tile->tcomps = 0;
}
if (tile->pi) {
jpc_pi_destroy(tile->pi);
tile->pi = 0;
}
if (tile->pkthdrstream) {
jas_stream_close(tile->pkthdrstream);
tile->pkthdrstream = 0;
}
if (tile->pptstab) {
jpc_ppxstab_destroy(tile->pptstab);
tile->pptstab = 0;
}
tile->state = JPC_TILE_DONE;
return 0;
}
static int jpc_dec_tiledecode(jpc_dec_t *dec, jpc_dec_tile_t *tile)
{
int i;
int j;
jpc_dec_tcomp_t *tcomp;
jpc_dec_rlvl_t *rlvl;
jpc_dec_band_t *band;
int compno;
int rlvlno;
int bandno;
int adjust;
int v;
jpc_dec_ccp_t *ccp;
jpc_dec_cmpt_t *cmpt;
if (jpc_dec_decodecblks(dec, tile)) {
jas_eprintf("jpc_dec_decodecblks failed\n");
return -1;
}
/* Perform dequantization. */
for (compno = 0, tcomp = tile->tcomps; compno < dec->numcomps;
++compno, ++tcomp) {
ccp = &tile->cp->ccps[compno];
for (rlvlno = 0, rlvl = tcomp->rlvls; rlvlno < tcomp->numrlvls;
++rlvlno, ++rlvl) {
if (!rlvl->bands) {
continue;
}
for (bandno = 0, band = rlvl->bands;
bandno < rlvl->numbands; ++bandno, ++band) {
if (!band->data) {
continue;
}
jpc_undo_roi(band->data, band->roishift, ccp->roishift -
band->roishift, band->numbps);
if (tile->realmode) {
jas_matrix_asl(band->data, JPC_FIX_FRACBITS);
jpc_dequantize(band->data, band->absstepsize);
}
}
}
}
/* Apply an inverse wavelet transform if necessary. */
for (compno = 0, tcomp = tile->tcomps; compno < dec->numcomps;
++compno, ++tcomp) {
ccp = &tile->cp->ccps[compno];
jpc_tsfb_synthesize(tcomp->tsfb, tcomp->data);
}
/* Apply an inverse intercomponent transform if necessary. */
switch (tile->cp->mctid) {
case JPC_MCT_RCT:
assert(dec->numcomps == 3 || dec->numcomps == 4);
jpc_irct(tile->tcomps[0].data, tile->tcomps[1].data,
tile->tcomps[2].data);
break;
case JPC_MCT_ICT:
assert(dec->numcomps == 3 || dec->numcomps == 4);
jpc_iict(tile->tcomps[0].data, tile->tcomps[1].data,
tile->tcomps[2].data);
break;
}
/* Perform rounding and convert to integer values. */
if (tile->realmode) {
for (compno = 0, tcomp = tile->tcomps; compno < dec->numcomps;
++compno, ++tcomp) {
for (i = 0; i < jas_matrix_numrows(tcomp->data); ++i) {
for (j = 0; j < jas_matrix_numcols(tcomp->data); ++j) {
v = jas_matrix_get(tcomp->data, i, j);
v = jpc_fix_round(v);
jas_matrix_set(tcomp->data, i, j, jpc_fixtoint(v));
}
}
}
}
/* Perform level shift. */
for (compno = 0, tcomp = tile->tcomps, cmpt = dec->cmpts; compno <
dec->numcomps; ++compno, ++tcomp, ++cmpt) {
adjust = cmpt->sgnd ? 0 : (1 << (cmpt->prec - 1));
for (i = 0; i < jas_matrix_numrows(tcomp->data); ++i) {
for (j = 0; j < jas_matrix_numcols(tcomp->data); ++j) {
*jas_matrix_getref(tcomp->data, i, j) += adjust;
}
}
}
/* Perform clipping. */
for (compno = 0, tcomp = tile->tcomps, cmpt = dec->cmpts; compno <
dec->numcomps; ++compno, ++tcomp, ++cmpt) {
jpc_fix_t mn;
jpc_fix_t mx;
mn = cmpt->sgnd ? (-(1 << (cmpt->prec - 1))) : (0);
mx = cmpt->sgnd ? ((1 << (cmpt->prec - 1)) - 1) : ((1 <<
cmpt->prec) - 1);
jas_matrix_clip(tcomp->data, mn, mx);
}
/* XXX need to free tsfb struct */
/* Write the data for each component of the image. */
for (compno = 0, tcomp = tile->tcomps, cmpt = dec->cmpts; compno <
dec->numcomps; ++compno, ++tcomp, ++cmpt) {
if (jas_image_writecmpt(dec->image, compno, tcomp->xstart -
JPC_CEILDIV(dec->xstart, cmpt->hstep), tcomp->ystart -
JPC_CEILDIV(dec->ystart, cmpt->vstep), jas_matrix_numcols(
tcomp->data), jas_matrix_numrows(tcomp->data), tcomp->data)) {
jas_eprintf("write component failed\n");
return -4;
}
}
return 0;
}
static int jpc_dec_process_eoc(jpc_dec_t *dec, jpc_ms_t *ms)
{
int tileno;
jpc_dec_tile_t *tile;
/* Eliminate compiler warnings about unused variables. */
ms = 0;
for (tileno = 0, tile = dec->tiles; tileno < dec->numtiles; ++tileno,
++tile) {
if (tile->state == JPC_TILE_ACTIVE) {
if (jpc_dec_tiledecode(dec, tile)) {
return -1;
}
}
jpc_dec_tilefini(dec, tile);
}
/* We are done processing the code stream. */
dec->state = JPC_MT;
return 1;
}
static int jpc_dec_process_siz(jpc_dec_t *dec, jpc_ms_t *ms)
{
jpc_siz_t *siz = &ms->parms.siz;
int compno;
int tileno;
jpc_dec_tile_t *tile;
jpc_dec_tcomp_t *tcomp;
int htileno;
int vtileno;
jpc_dec_cmpt_t *cmpt;
dec->xstart = siz->xoff;
dec->ystart = siz->yoff;
dec->xend = siz->width;
dec->yend = siz->height;
dec->tilewidth = siz->tilewidth;
dec->tileheight = siz->tileheight;
dec->tilexoff = siz->tilexoff;
dec->tileyoff = siz->tileyoff;
dec->numcomps = siz->numcomps;
if (!(dec->cp = jpc_dec_cp_create(dec->numcomps))) {
return -1;
}
if (!(dec->cmpts = jas_alloc2(dec->numcomps, sizeof(jpc_dec_cmpt_t)))) {
return -1;
}
for (compno = 0, cmpt = dec->cmpts; compno < dec->numcomps; ++compno,
++cmpt) {
cmpt->prec = siz->comps[compno].prec;
cmpt->sgnd = siz->comps[compno].sgnd;
cmpt->hstep = siz->comps[compno].hsamp;
cmpt->vstep = siz->comps[compno].vsamp;
cmpt->width = JPC_CEILDIV(dec->xend, cmpt->hstep) -
JPC_CEILDIV(dec->xstart, cmpt->hstep);
cmpt->height = JPC_CEILDIV(dec->yend, cmpt->vstep) -
JPC_CEILDIV(dec->ystart, cmpt->vstep);
cmpt->hsubstep = 0;
cmpt->vsubstep = 0;
}
dec->image = 0;
dec->numhtiles = JPC_CEILDIV(dec->xend - dec->tilexoff, dec->tilewidth);
dec->numvtiles = JPC_CEILDIV(dec->yend - dec->tileyoff, dec->tileheight);
dec->numtiles = dec->numhtiles * dec->numvtiles;
if (!(dec->tiles = jas_alloc2(dec->numtiles, sizeof(jpc_dec_tile_t)))) {
return -1;
}
for (tileno = 0, tile = dec->tiles; tileno < dec->numtiles; ++tileno,
++tile) {
htileno = tileno % dec->numhtiles;
vtileno = tileno / dec->numhtiles;
tile->realmode = 0;
tile->state = JPC_TILE_INIT;
tile->xstart = JAS_MAX(dec->tilexoff + htileno * dec->tilewidth,
dec->xstart);
tile->ystart = JAS_MAX(dec->tileyoff + vtileno * dec->tileheight,
dec->ystart);
tile->xend = JAS_MIN(dec->tilexoff + (htileno + 1) *
dec->tilewidth, dec->xend);
tile->yend = JAS_MIN(dec->tileyoff + (vtileno + 1) *
dec->tileheight, dec->yend);
tile->numparts = 0;
tile->partno = 0;
tile->pkthdrstream = 0;
tile->pkthdrstreampos = 0;
tile->pptstab = 0;
tile->cp = 0;
if (!(tile->tcomps = jas_alloc2(dec->numcomps,
sizeof(jpc_dec_tcomp_t)))) {
return -1;
}
for (compno = 0, cmpt = dec->cmpts, tcomp = tile->tcomps;
compno < dec->numcomps; ++compno, ++cmpt, ++tcomp) {
tcomp->rlvls = 0;
tcomp->data = 0;
tcomp->xstart = JPC_CEILDIV(tile->xstart, cmpt->hstep);
tcomp->ystart = JPC_CEILDIV(tile->ystart, cmpt->vstep);
tcomp->xend = JPC_CEILDIV(tile->xend, cmpt->hstep);
tcomp->yend = JPC_CEILDIV(tile->yend, cmpt->vstep);
tcomp->tsfb = 0;
}
}
dec->pkthdrstreams = 0;
/* We should expect to encounter other main header marker segments
or an SOT marker segment next. */
dec->state = JPC_MH;
return 0;
}
static int jpc_dec_process_cod(jpc_dec_t *dec, jpc_ms_t *ms)
{
jpc_cod_t *cod = &ms->parms.cod;
jpc_dec_tile_t *tile;
switch (dec->state) {
case JPC_MH:
<API key>(dec->cp, cod);
break;
case JPC_TPH:
if (!(tile = dec->curtile)) {
return -1;
}
if (tile->partno != 0) {
return -1;
}
<API key>(tile->cp, cod);
break;
}
return 0;
}
static int jpc_dec_process_coc(jpc_dec_t *dec, jpc_ms_t *ms)
{
jpc_coc_t *coc = &ms->parms.coc;
jpc_dec_tile_t *tile;
if (JAS_CAST(int, coc->compno) > dec->numcomps) {
jas_eprintf("invalid component number in COC marker segment\n");
return -1;
}
switch (dec->state) {
case JPC_MH:
<API key>(dec->cp, coc);
break;
case JPC_TPH:
if (!(tile = dec->curtile)) {
return -1;
}
if (tile->partno > 0) {
return -1;
}
<API key>(tile->cp, coc);
break;
}
return 0;
}
static int jpc_dec_process_rgn(jpc_dec_t *dec, jpc_ms_t *ms)
{
jpc_rgn_t *rgn = &ms->parms.rgn;
jpc_dec_tile_t *tile;
if (JAS_CAST(int, rgn->compno) > dec->numcomps) {
jas_eprintf("invalid component number in RGN marker segment\n");
return -1;
}
switch (dec->state) {
case JPC_MH:
<API key>(dec->cp, rgn);
break;
case JPC_TPH:
if (!(tile = dec->curtile)) {
return -1;
}
if (tile->partno > 0) {
return -1;
}
<API key>(tile->cp, rgn);
break;
}
return 0;
}
static int jpc_dec_process_qcd(jpc_dec_t *dec, jpc_ms_t *ms)
{
jpc_qcd_t *qcd = &ms->parms.qcd;
jpc_dec_tile_t *tile;
switch (dec->state) {
case JPC_MH:
<API key>(dec->cp, qcd);
break;
case JPC_TPH:
if (!(tile = dec->curtile)) {
return -1;
}
if (tile->partno > 0) {
return -1;
}
<API key>(tile->cp, qcd);
break;
}
return 0;
}
static int jpc_dec_process_qcc(jpc_dec_t *dec, jpc_ms_t *ms)
{
jpc_qcc_t *qcc = &ms->parms.qcc;
jpc_dec_tile_t *tile;
if (JAS_CAST(int, qcc->compno) > dec->numcomps) {
jas_eprintf("invalid component number in QCC marker segment\n");
return -1;
}
switch (dec->state) {
case JPC_MH:
<API key>(dec->cp, qcc);
break;
case JPC_TPH:
if (!(tile = dec->curtile)) {
return -1;
}
if (tile->partno > 0) {
return -1;
}
<API key>(tile->cp, qcc);
break;
}
return 0;
}
static int jpc_dec_process_poc(jpc_dec_t *dec, jpc_ms_t *ms)
{
jpc_poc_t *poc = &ms->parms.poc;
jpc_dec_tile_t *tile;
switch (dec->state) {
case JPC_MH:
if (<API key>(dec->cp, poc, 1)) {
return -1;
}
break;
case JPC_TPH:
if (!(tile = dec->curtile)) {
return -1;
}
if (!tile->partno) {
if (<API key>(tile->cp, poc, (!tile->partno))) {
return -1;
}
} else {
<API key>(tile->pi, poc);
}
break;
}
return 0;
}
static int jpc_dec_process_ppm(jpc_dec_t *dec, jpc_ms_t *ms)
{
jpc_ppm_t *ppm = &ms->parms.ppm;
jpc_ppxstabent_t *ppmstabent;
if (!dec->ppmstab) {
if (!(dec->ppmstab = jpc_ppxstab_create())) {
return -1;
}
}
if (!(ppmstabent = <API key>())) {
return -1;
}
ppmstabent->ind = ppm->ind;
ppmstabent->data = ppm->data;
ppm->data = 0;
ppmstabent->len = ppm->len;
if (jpc_ppxstab_insert(dec->ppmstab, ppmstabent)) {
return -1;
}
return 0;
}
static int jpc_dec_process_ppt(jpc_dec_t *dec, jpc_ms_t *ms)
{
jpc_ppt_t *ppt = &ms->parms.ppt;
jpc_dec_tile_t *tile;
jpc_ppxstabent_t *pptstabent;
tile = dec->curtile;
if (!tile->pptstab) {
if (!(tile->pptstab = jpc_ppxstab_create())) {
return -1;
}
}
if (!(pptstabent = <API key>())) {
return -1;
}
pptstabent->ind = ppt->ind;
pptstabent->data = ppt->data;
ppt->data = 0;
pptstabent->len = ppt->len;
if (jpc_ppxstab_insert(tile->pptstab, pptstabent)) {
return -1;
}
return 0;
}
static int jpc_dec_process_com(jpc_dec_t *dec, jpc_ms_t *ms)
{
/* Eliminate compiler warnings about unused variables. */
dec = 0;
ms = 0;
return 0;
}
static int jpc_dec_process_unk(jpc_dec_t *dec, jpc_ms_t *ms)
{
/* Eliminate compiler warnings about unused variables. */
dec = 0;
jas_eprintf("warning: ignoring unknown marker segment\n");
jpc_ms_dump(ms, stderr);
return 0;
}
static jpc_dec_cp_t *jpc_dec_cp_create(uint_fast16_t numcomps)
{
jpc_dec_cp_t *cp;
jpc_dec_ccp_t *ccp;
int compno;
if (!(cp = jas_malloc(sizeof(jpc_dec_cp_t)))) {
return 0;
}
cp->flags = 0;
cp->numcomps = numcomps;
cp->prgord = 0;
cp->numlyrs = 0;
cp->mctid = 0;
cp->csty = 0;
if (!(cp->ccps = jas_alloc2(cp->numcomps, sizeof(jpc_dec_ccp_t)))) {
return 0;
}
if (!(cp->pchglist = jpc_pchglist_create())) {
jas_free(cp->ccps);
return 0;
}
for (compno = 0, ccp = cp->ccps; compno < cp->numcomps;
++compno, ++ccp) {
ccp->flags = 0;
ccp->numrlvls = 0;
ccp->cblkwidthexpn = 0;
ccp->cblkheightexpn = 0;
ccp->qmfbid = 0;
ccp->numstepsizes = 0;
ccp->numguardbits = 0;
ccp->roishift = 0;
ccp->cblkctx = 0;
}
return cp;
}
static jpc_dec_cp_t *jpc_dec_cp_copy(jpc_dec_cp_t *cp)
{
jpc_dec_cp_t *newcp;
jpc_dec_ccp_t *newccp;
jpc_dec_ccp_t *ccp;
int compno;
if (!(newcp = jpc_dec_cp_create(cp->numcomps))) {
return 0;
}
newcp->flags = cp->flags;
newcp->prgord = cp->prgord;
newcp->numlyrs = cp->numlyrs;
newcp->mctid = cp->mctid;
newcp->csty = cp->csty;
<API key>(newcp->pchglist);
newcp->pchglist = 0;
if (!(newcp->pchglist = jpc_pchglist_copy(cp->pchglist))) {
jas_free(newcp);
return 0;
}
for (compno = 0, newccp = newcp->ccps, ccp = cp->ccps;
compno < cp->numcomps;
++compno, ++newccp, ++ccp) {
*newccp = *ccp;
}
return newcp;
}
static void <API key>(jpc_dec_cp_t *cp)
{
int compno;
jpc_dec_ccp_t *ccp;
cp->flags &= (JPC_CSET | JPC_QSET);
for (compno = 0, ccp = cp->ccps; compno < cp->numcomps;
++compno, ++ccp) {
ccp->flags = 0;
}
}
static void jpc_dec_cp_destroy(jpc_dec_cp_t *cp)
{
if (cp->ccps) {
jas_free(cp->ccps);
}
if (cp->pchglist) {
<API key>(cp->pchglist);
}
jas_free(cp);
}
static int jpc_dec_cp_isvalid(jpc_dec_cp_t *cp)
{
uint_fast16_t compcnt;
jpc_dec_ccp_t *ccp;
if (!(cp->flags & JPC_CSET) || !(cp->flags & JPC_QSET)) {
return 0;
}
for (compcnt = cp->numcomps, ccp = cp->ccps; compcnt > 0; --compcnt,
++ccp) {
/* Is there enough step sizes for the number of bands? */
if ((ccp->qsty != JPC_QCX_SIQNT && JAS_CAST(int, ccp->numstepsizes) < 3 *
ccp->numrlvls - 2) || (ccp->qsty == JPC_QCX_SIQNT &&
ccp->numstepsizes != 1)) {
return 0;
}
}
return 1;
}
static void calcstepsizes(uint_fast16_t refstepsize, int numrlvls,
uint_fast16_t *stepsizes)
{
int bandno;
int numbands;
uint_fast16_t expn;
uint_fast16_t mant;
expn = JPC_QCX_GETEXPN(refstepsize);
mant = JPC_QCX_GETMANT(refstepsize);
numbands = 3 * numrlvls - 2;
for (bandno = 0; bandno < numbands; ++bandno) {
stepsizes[bandno] = JPC_QCX_MANT(mant) | JPC_QCX_EXPN(expn +
(numrlvls - 1) - (numrlvls - 1 - ((bandno > 0) ? ((bandno + 2) / 3) : (0))));
}
}
static int jpc_dec_cp_prepare(jpc_dec_cp_t *cp)
{
jpc_dec_ccp_t *ccp;
int compno;
int i;
for (compno = 0, ccp = cp->ccps; compno < cp->numcomps;
++compno, ++ccp) {
if (!(ccp->csty & JPC_COX_PRT)) {
for (i = 0; i < JPC_MAXRLVLS; ++i) {
ccp->prcwidthexpns[i] = 15;
ccp->prcheightexpns[i] = 15;
}
}
if (ccp->qsty == JPC_QCX_SIQNT) {
calcstepsizes(ccp->stepsizes[0], ccp->numrlvls, ccp->stepsizes);
}
}
return 0;
}
static int <API key>(jpc_dec_cp_t *cp, jpc_cod_t *cod)
{
jpc_dec_ccp_t *ccp;
int compno;
cp->flags |= JPC_CSET;
cp->prgord = cod->prg;
if (cod->mctrans) {
cp->mctid = (cod->compparms.qmfbid == JPC_COX_INS) ? (JPC_MCT_ICT) : (JPC_MCT_RCT);
} else {
cp->mctid = JPC_MCT_NONE;
}
cp->numlyrs = cod->numlyrs;
cp->csty = cod->csty & (JPC_COD_SOP | JPC_COD_EPH);
for (compno = 0, ccp = cp->ccps; compno < cp->numcomps;
++compno, ++ccp) {
<API key>(cp, ccp, &cod->compparms, 0);
}
cp->flags |= JPC_CSET;
return 0;
}
static int <API key>(jpc_dec_cp_t *cp, jpc_coc_t *coc)
{
<API key>(cp, &cp->ccps[coc->compno], &coc->compparms, JPC_COC);
return 0;
}
static int <API key>(jpc_dec_cp_t *cp, jpc_dec_ccp_t *ccp,
jpc_coxcp_t *compparms, int flags)
{
int rlvlno;
/* Eliminate compiler warnings about unused variables. */
cp = 0;
if ((flags & JPC_COC) || !(ccp->flags & JPC_COC)) {
ccp->numrlvls = compparms->numdlvls + 1;
ccp->cblkwidthexpn = <API key>(
compparms->cblkwidthval);
ccp->cblkheightexpn = <API key>(
compparms->cblkheightval);
ccp->qmfbid = compparms->qmfbid;
ccp->cblkctx = compparms->cblksty;
ccp->csty = compparms->csty & JPC_COX_PRT;
for (rlvlno = 0; rlvlno < compparms->numrlvls; ++rlvlno) {
ccp->prcwidthexpns[rlvlno] =
compparms->rlvls[rlvlno].parwidthval;
ccp->prcheightexpns[rlvlno] =
compparms->rlvls[rlvlno].parheightval;
}
ccp->flags |= flags | JPC_CSET;
}
return 0;
}
static int <API key>(jpc_dec_cp_t *cp, jpc_qcd_t *qcd)
{
int compno;
jpc_dec_ccp_t *ccp;
for (compno = 0, ccp = cp->ccps; compno < cp->numcomps;
++compno, ++ccp) {
<API key>(cp, ccp, &qcd->compparms, 0);
}
cp->flags |= JPC_QSET;
return 0;
}
static int <API key>(jpc_dec_cp_t *cp, jpc_qcc_t *qcc)
{
return <API key>(cp, &cp->ccps[qcc->compno], &qcc->compparms, JPC_QCC);
}
static int <API key>(jpc_dec_cp_t *cp, jpc_dec_ccp_t *ccp,
jpc_qcxcp_t *compparms, int flags)
{
int bandno;
/* Eliminate compiler warnings about unused variables. */
cp = 0;
if ((flags & JPC_QCC) || !(ccp->flags & JPC_QCC)) {
ccp->flags |= flags | JPC_QSET;
for (bandno = 0; bandno < compparms->numstepsizes; ++bandno) {
ccp->stepsizes[bandno] = compparms->stepsizes[bandno];
}
ccp->numstepsizes = compparms->numstepsizes;
ccp->numguardbits = compparms->numguard;
ccp->qsty = compparms->qntsty;
}
return 0;
}
static int <API key>(jpc_dec_cp_t *cp, jpc_rgn_t *rgn)
{
jpc_dec_ccp_t *ccp;
ccp = &cp->ccps[rgn->compno];
ccp->roishift = rgn->roishift;
return 0;
}
static int <API key>(jpc_pi_t *pi, jpc_poc_t *poc)
{
int pchgno;
jpc_pchg_t *pchg;
for (pchgno = 0; pchgno < poc->numpchgs; ++pchgno) {
if (!(pchg = jpc_pchg_copy(&poc->pchgs[pchgno]))) {
return -1;
}
if (jpc_pchglist_insert(pi->pchglist, -1, pchg)) {
return -1;
}
}
return 0;
}
static int <API key>(jpc_dec_cp_t *cp, jpc_poc_t *poc, int reset)
{
int pchgno;
jpc_pchg_t *pchg;
if (reset) {
while (<API key>(cp->pchglist) > 0) {
pchg = jpc_pchglist_remove(cp->pchglist, 0);
jpc_pchg_destroy(pchg);
}
}
for (pchgno = 0; pchgno < poc->numpchgs; ++pchgno) {
if (!(pchg = jpc_pchg_copy(&poc->pchgs[pchgno]))) {
return -1;
}
if (jpc_pchglist_insert(cp->pchglist, -1, pchg)) {
return -1;
}
}
return 0;
}
static jpc_fix_t jpc_calcabsstepsize(int stepsize, int numbits)
{
jpc_fix_t absstepsize;
int n;
absstepsize = jpc_inttofix(1);
n = JPC_FIX_FRACBITS - 11;
absstepsize |= (n >= 0) ? (JPC_QCX_GETMANT(stepsize) << n) :
(JPC_QCX_GETMANT(stepsize) >> (-n));
n = numbits - JPC_QCX_GETEXPN(stepsize);
absstepsize = (n >= 0) ? (absstepsize << n) : (absstepsize >> (-n));
return absstepsize;
}
static void jpc_dequantize(jas_matrix_t *x, jpc_fix_t absstepsize)
{
int i;
int j;
int t;
assert(absstepsize >= 0);
if (absstepsize == jpc_inttofix(1)) {
return;
}
for (i = 0; i < jas_matrix_numrows(x); ++i) {
for (j = 0; j < jas_matrix_numcols(x); ++j) {
t = jas_matrix_get(x, i, j);
if (t) {
t = jpc_fix_mul(t, absstepsize);
} else {
t = 0;
}
jas_matrix_set(x, i, j, t);
}
}
}
static void jpc_undo_roi(jas_matrix_t *x, int roishift, int bgshift, int numbps)
{
int i;
int j;
int thresh;
jpc_fix_t val;
jpc_fix_t mag;
bool warn;
uint_fast32_t mask;
if (roishift == 0 && bgshift == 0) {
return;
}
thresh = 1 << roishift;
warn = false;
for (i = 0; i < jas_matrix_numrows(x); ++i) {
for (j = 0; j < jas_matrix_numcols(x); ++j) {
val = jas_matrix_get(x, i, j);
mag = JAS_ABS(val);
if (mag >= thresh) {
/* We are dealing with ROI data. */
mag >>= roishift;
val = (val < 0) ? (-mag) : mag;
jas_matrix_set(x, i, j, val);
} else {
/* We are dealing with non-ROI (i.e., background) data. */
mag <<= bgshift;
mask = (1 << numbps) - 1;
/* Perform a basic sanity check on the sample value. */
/* Some implementations write garbage in the unused
most-significant bit planes introduced by ROI shifting.
Here we ensure that any such bits are masked off. */
if (mag & (~mask)) {
if (!warn) {
jas_eprintf("warning: possibly corrupt code stream\n");
warn = true;
}
mag &= mask;
}
val = (val < 0) ? (-mag) : mag;
jas_matrix_set(x, i, j, val);
}
}
}
}
static jpc_dec_t *jpc_dec_create(<API key> *impopts, jas_stream_t *in)
{
jpc_dec_t *dec;
if (!(dec = jas_malloc(sizeof(jpc_dec_t)))) {
return 0;
}
dec->image = 0;
dec->xstart = 0;
dec->ystart = 0;
dec->xend = 0;
dec->yend = 0;
dec->tilewidth = 0;
dec->tileheight = 0;
dec->tilexoff = 0;
dec->tileyoff = 0;
dec->numhtiles = 0;
dec->numvtiles = 0;
dec->numtiles = 0;
dec->tiles = 0;
dec->curtile = 0;
dec->numcomps = 0;
dec->in = in;
dec->cp = 0;
dec->maxlyrs = impopts->maxlyrs;
dec->maxpkts = impopts->maxpkts;
dec->numpkts = 0;
dec->ppmseqno = 0;
dec->state = 0;
dec->cmpts = 0;
dec->pkthdrstreams = 0;
dec->ppmstab = 0;
dec->curtileendoff = 0;
return dec;
}
static void jpc_dec_destroy(jpc_dec_t *dec)
{
if (dec->cstate) {
jpc_cstate_destroy(dec->cstate);
}
if (dec->pkthdrstreams) {
<API key>(dec->pkthdrstreams);
}
if (dec->image) {
jas_image_destroy(dec->image);
}
if (dec->cp) {
jpc_dec_cp_destroy(dec->cp);
}
if (dec->cmpts) {
jas_free(dec->cmpts);
}
if (dec->tiles) {
jas_free(dec->tiles);
}
jas_free(dec);
}
void jpc_seglist_insert(jpc_dec_seglist_t *list, jpc_dec_seg_t *ins, jpc_dec_seg_t *node)
{
jpc_dec_seg_t *prev;
jpc_dec_seg_t *next;
prev = ins;
node->prev = prev;
next = prev ? (prev->next) : 0;
node->prev = prev;
node->next = next;
if (prev) {
prev->next = node;
} else {
list->head = node;
}
if (next) {
next->prev = node;
} else {
list->tail = node;
}
}
void jpc_seglist_remove(jpc_dec_seglist_t *list, jpc_dec_seg_t *seg)
{
jpc_dec_seg_t *prev;
jpc_dec_seg_t *next;
prev = seg->prev;
next = seg->next;
if (prev) {
prev->next = next;
} else {
list->head = next;
}
if (next) {
next->prev = prev;
} else {
list->tail = prev;
}
seg->prev = 0;
seg->next = 0;
}
jpc_dec_seg_t *jpc_seg_alloc()
{
jpc_dec_seg_t *seg;
if (!(seg = jas_malloc(sizeof(jpc_dec_seg_t)))) {
return 0;
}
seg->prev = 0;
seg->next = 0;
seg->passno = -1;
seg->numpasses = 0;
seg->maxpasses = 0;
seg->type = JPC_SEG_INVALID;
seg->stream = 0;
seg->cnt = 0;
seg->complete = 0;
seg->lyrno = -1;
return seg;
}
void jpc_seg_destroy(jpc_dec_seg_t *seg)
{
if (seg->stream) {
jas_stream_close(seg->stream);
}
jas_free(seg);
}
static int jpc_dec_dump(jpc_dec_t *dec, FILE *out)
{
jpc_dec_tile_t *tile;
int tileno;
jpc_dec_tcomp_t *tcomp;
int compno;
jpc_dec_rlvl_t *rlvl;
int rlvlno;
jpc_dec_band_t *band;
int bandno;
jpc_dec_prc_t *prc;
int prcno;
jpc_dec_cblk_t *cblk;
int cblkno;
for (tileno = 0, tile = dec->tiles; tileno < dec->numtiles;
++tileno, ++tile) {
for (compno = 0, tcomp = tile->tcomps; compno < dec->numcomps;
++compno, ++tcomp) {
for (rlvlno = 0, rlvl = tcomp->rlvls; rlvlno <
tcomp->numrlvls; ++rlvlno, ++rlvl) {
fprintf(out, "RESOLUTION LEVEL %d\n", rlvlno);
fprintf(out, "xs =%d, ys = %d, xe = %d, ye = %d, w = %d, h = %d\n",
(int)rlvl->xstart, (int)rlvl->ystart, (int)rlvl->xend, (int)rlvl->yend, (int)(rlvl->xend -
rlvl->xstart), (int)(rlvl->yend - rlvl->ystart));
for (bandno = 0, band = rlvl->bands;
bandno < rlvl->numbands; ++bandno, ++band) {
fprintf(out, "BAND %d\n", bandno);
fprintf(out, "xs =%d, ys = %d, xe = %d, ye = %d, w = %d, h = %d\n",
(int)jas_seq2d_xstart(band->data), (int)jas_seq2d_ystart(band->data), (int)jas_seq2d_xend(band->data),
(int)jas_seq2d_yend(band->data), (int)(jas_seq2d_xend(band->data) - jas_seq2d_xstart(band->data)),
(int)(jas_seq2d_yend(band->data) - jas_seq2d_ystart(band->data)));
for (prcno = 0, prc = band->prcs;
prcno < rlvl->numprcs; ++prcno,
++prc) {
fprintf(out, "CODE BLOCK GROUP %d\n", prcno);
fprintf(out, "xs =%d, ys = %d, xe = %d, ye = %d, w = %d, h = %d\n",
(int)prc->xstart, (int)prc->ystart, (int)prc->xend, (int)prc->yend, (int)(prc->xend -
prc->xstart), (int)(prc->yend - prc->ystart));
for (cblkno = 0, cblk =
prc->cblks; cblkno <
prc->numcblks; ++cblkno,
++cblk) {
fprintf(out, "CODE BLOCK %d\n", cblkno);
fprintf(out, "xs =%d, ys = %d, xe = %d, ye = %d, w = %d, h = %d\n",
(int)jas_seq2d_xstart(cblk->data), (int)jas_seq2d_ystart(cblk->data), (int)jas_seq2d_xend(cblk->data),
(int)jas_seq2d_yend(cblk->data), (int)(jas_seq2d_xend(cblk->data) - jas_seq2d_xstart(cblk->data)),
(int)(jas_seq2d_yend(cblk->data) - jas_seq2d_ystart(cblk->data)));
}
}
}
}
}
}
return 0;
}
jpc_streamlist_t *<API key>()
{
jpc_streamlist_t *streamlist;
int i;
if (!(streamlist = jas_malloc(sizeof(jpc_streamlist_t)))) {
return 0;
}
streamlist->numstreams = 0;
streamlist->maxstreams = 100;
if (!(streamlist->streams = jas_alloc2(streamlist->maxstreams,
sizeof(jas_stream_t *)))) {
jas_free(streamlist);
return 0;
}
for (i = 0; i < streamlist->maxstreams; ++i) {
streamlist->streams[i] = 0;
}
return streamlist;
}
int <API key>(jpc_streamlist_t *streamlist, int streamno,
jas_stream_t *stream)
{
jas_stream_t **newstreams;
int newmaxstreams;
int i;
/* Grow the array of streams if necessary. */
if (streamlist->numstreams >= streamlist->maxstreams) {
newmaxstreams = streamlist->maxstreams + 1024;
if (!(newstreams = jas_realloc2(streamlist->streams,
(newmaxstreams + 1024), sizeof(jas_stream_t *)))) {
return -1;
}
for (i = streamlist->numstreams; i < streamlist->maxstreams; ++i) {
streamlist->streams[i] = 0;
}
streamlist->maxstreams = newmaxstreams;
streamlist->streams = newstreams;
}
if (streamno != streamlist->numstreams) {
/* Can only handle insertion at start of list. */
return -1;
}
streamlist->streams[streamno] = stream;
++streamlist->numstreams;
return 0;
}
jas_stream_t *<API key>(jpc_streamlist_t *streamlist, int streamno)
{
jas_stream_t *stream;
int i;
if (streamno >= streamlist->numstreams) {
abort();
}
stream = streamlist->streams[streamno];
for (i = streamno + 1; i < streamlist->numstreams; ++i) {
streamlist->streams[i - 1] = streamlist->streams[i];
}
--streamlist->numstreams;
return stream;
}
void <API key>(jpc_streamlist_t *streamlist)
{
int streamno;
if (streamlist->streams) {
for (streamno = 0; streamno < streamlist->numstreams;
++streamno) {
jas_stream_close(streamlist->streams[streamno]);
}
jas_free(streamlist->streams);
}
jas_free(streamlist);
}
jas_stream_t *jpc_streamlist_get(jpc_streamlist_t *streamlist, int streamno)
{
assert(streamno < streamlist->numstreams);
return streamlist->streams[streamno];
}
int <API key>(jpc_streamlist_t *streamlist)
{
return streamlist->numstreams;
}
jpc_ppxstab_t *jpc_ppxstab_create()
{
jpc_ppxstab_t *tab;
if (!(tab = jas_malloc(sizeof(jpc_ppxstab_t)))) {
return 0;
}
tab->numents = 0;
tab->maxents = 0;
tab->ents = 0;
return tab;
}
void jpc_ppxstab_destroy(jpc_ppxstab_t *tab)
{
int i;
for (i = 0; i < tab->numents; ++i) {
<API key>(tab->ents[i]);
}
if (tab->ents) {
jas_free(tab->ents);
}
jas_free(tab);
}
int jpc_ppxstab_grow(jpc_ppxstab_t *tab, int maxents)
{
jpc_ppxstabent_t **newents;
if (tab->maxents < maxents) {
newents = jas_realloc2(tab->ents, maxents, sizeof(jpc_ppxstabent_t *));
if (!newents) {
return -1;
}
tab->ents = newents;
tab->maxents = maxents;
}
return 0;
}
int jpc_ppxstab_insert(jpc_ppxstab_t *tab, jpc_ppxstabent_t *ent)
{
int inspt;
int i;
for (i = 0; i < tab->numents; ++i) {
if (tab->ents[i]->ind > ent->ind) {
break;
}
}
inspt = i;
if (tab->numents >= tab->maxents) {
if (jpc_ppxstab_grow(tab, tab->maxents + 128)) {
return -1;
}
}
for (i = tab->numents; i > inspt; --i) {
tab->ents[i] = tab->ents[i - 1];
}
tab->ents[i] = ent;
++tab->numents;
return 0;
}
jpc_streamlist_t *<API key>(jpc_ppxstab_t *tab)
{
jpc_streamlist_t *streams;
uchar *dataptr;
uint_fast32_t datacnt;
uint_fast32_t tpcnt;
jpc_ppxstabent_t *ent;
int entno;
jas_stream_t *stream;
int n;
if (!(streams = <API key>())) {
goto error;
}
if (!tab->numents) {
return streams;
}
entno = 0;
ent = tab->ents[entno];
dataptr = ent->data;
datacnt = ent->len;
for (;;) {
/* Get the length of the packet header data for the current
tile-part. */
if (datacnt < 4) {
goto error;
}
if (!(stream = jas_stream_memopen(0, 0))) {
goto error;
}
if (<API key>(streams, <API key>(streams),
stream)) {
goto error;
}
tpcnt = (dataptr[0] << 24) | (dataptr[1] << 16) | (dataptr[2] << 8)
| dataptr[3];
datacnt -= 4;
dataptr += 4;
/* Get the packet header data for the current tile-part. */
while (tpcnt) {
if (!datacnt) {
if (++entno >= tab->numents) {
goto error;
}
ent = tab->ents[entno];
dataptr = ent->data;
datacnt = ent->len;
}
n = JAS_MIN(tpcnt, datacnt);
if (jas_stream_write(stream, dataptr, n) != n) {
goto error;
}
tpcnt -= n;
dataptr += n;
datacnt -= n;
}
jas_stream_rewind(stream);
if (!datacnt) {
if (++entno >= tab->numents) {
break;
}
ent = tab->ents[entno];
dataptr = ent->data;
datacnt = ent->len;
}
}
return streams;
error:
<API key>(streams);
return 0;
}
int jpc_pptstabwrite(jas_stream_t *out, jpc_ppxstab_t *tab)
{
int i;
jpc_ppxstabent_t *ent;
for (i = 0; i < tab->numents; ++i) {
ent = tab->ents[i];
if (jas_stream_write(out, ent->data, ent->len) != JAS_CAST(int, ent->len)) {
return -1;
}
}
return 0;
}
jpc_ppxstabent_t *<API key>()
{
jpc_ppxstabent_t *ent;
if (!(ent = jas_malloc(sizeof(jpc_ppxstabent_t)))) {
return 0;
}
ent->data = 0;
ent->len = 0;
ent->ind = 0;
return ent;
}
void <API key>(jpc_ppxstabent_t *ent)
{
if (ent->data) {
jas_free(ent->data);
}
jas_free(ent);
} |
// "Invert 'if' condition" "true"
class A {
public void foo() {
//comment
if (1 != 2) {
System.out.println("false");
}
else {
System.out.println("true");
}
}
} |
package org.elasticsearch.xpack.core.security.authc;
import org.elasticsearch.<API key>;
import org.elasticsearch.common.util.concurrent.ThreadContext;
import org.elasticsearch.rest.RestRequest;
import org.elasticsearch.transport.TransportMessage;
/**
* A <API key> is responsible for the handling of a request that has failed authentication. This must
* consist of returning an exception and this exception can have headers to indicate authentication is required or another
* HTTP operation such as a redirect.
* <p>
* For example, when using Basic authentication, most clients wait to send credentials until they have been challenged
* for them. In this workflow a client makes a request, the server responds with a 401 status with the header
* <code>WWW-Authenticate: Basic realm=auth-realm</code>, and then the client will send credentials. The same scheme also
* applies for other methods of authentication, with changes to the value provided in the WWW-Authenticate header.
* <p>
* Additionally, some methods of authentication may require a different status code. When using an single sign on system,
* clients will often retrieve a token from a single sign on system that is presented to the server and verified. When a
* client does not provide such a token, then the server can choose to redirect the client to the single sign on system to
* retrieve a token. This can be accomplished in the <API key> by setting the
* {@link org.elasticsearch.rest.RestStatus#FOUND}
* with a <code>Location</code> header that contains the location to redirect the user to.
*/
public interface <API key> {
/**
* This method is called when there has been an authentication failure for the given REST request and authentication
* token.
*
* @param request The request that was being authenticated when the exception occurred
* @param token The token that was extracted from the request
* @param context The context of the request that failed authentication that could not be authenticated
* @return <API key> with the appropriate headers and message
*/
<API key> <API key>(RestRequest request, AuthenticationToken token, ThreadContext context);
/**
* This method is called when there has been an authentication failure for the given message and token
*
* @param message The transport message that could not be authenticated
* @param token The token that was extracted from the message
* @param action The name of the action that the message is trying to perform
* @param context The context of the request that failed authentication that could not be authenticated
* @return <API key> with the appropriate headers and message
*/
<API key> <API key>(
TransportMessage message,
AuthenticationToken token,
String action,
ThreadContext context
);
/**
* The method is called when an exception has occurred while processing the REST request. This could be an error that
* occurred while attempting to extract a token or while attempting to authenticate the request
*
* @param request The request that was being authenticated when the exception occurred
* @param e The exception that was thrown
* @param context The context of the request that failed authentication that could not be authenticated
* @return <API key> with the appropriate headers and message
*/
<API key> <API key>(RestRequest request, Exception e, ThreadContext context);
/**
* The method is called when an exception has occurred while processing the transport message. This could be an error that
* occurred while attempting to extract a token or while attempting to authenticate the request
*
* @param message The message that was being authenticated when the exception occurred
* @param action The name of the action that the message is trying to perform
* @param e The exception that was thrown
* @param context The context of the request that failed authentication that could not be authenticated
* @return <API key> with the appropriate headers and message
*/
<API key> <API key>(TransportMessage message, String action, Exception e, ThreadContext context);
/**
* This method is called when a REST request is received and no authentication token could be extracted AND anonymous
* access is disabled. If anonymous access is enabled, this method will not be called
*
* @param request The request that did not have a token
* @param context The context of the request that failed authentication that could not be authenticated
* @return <API key> with the appropriate headers and message
*/
<API key> missingToken(RestRequest request, ThreadContext context);
/**
* This method is called when a transport message is received and no authentication token could be extracted AND
* anonymous access is disabled. If anonymous access is enabled this method will not be called
*
* @param message The message that did not have a token
* @param action The name of the action that the message is trying to perform
* @param context The context of the request that failed authentication that could not be authenticated
* @return <API key> with the appropriate headers and message
*/
<API key> missingToken(TransportMessage message, String action, ThreadContext context);
/**
* This method is called when anonymous access is enabled, a request does not pass authorization with the anonymous
* user, AND the anonymous service is configured to throw an authentication exception instead of an authorization
* exception
*
* @param action the action that failed authorization for anonymous access
* @param context The context of the request that failed authentication that could not be authenticated
* @return <API key> with the appropriate headers and message
*/
<API key> <API key>(String action, ThreadContext context);
} |
// This source file is part of the Swift.org open source project
#include "XMLValidator.h"
#ifdef SWIFT_HAVE_LIBXML
// libxml headers use their own variant of documentation comments that Clang
// does not understand well.
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdocumentation"
#include <libxml/parser.h>
#include <libxml/relaxng.h>
#include <libxml/xmlerror.h>
#pragma clang diagnostic pop
using namespace swift;
struct XMLValidator::Implementation {
std::string SchemaFileName;
<API key> RNGParser;
xmlRelaxNGPtr Schema;
};
XMLValidator::XMLValidator() : Impl(new Implementation()) {}
XMLValidator::~XMLValidator() { delete Impl; }
void XMLValidator::setSchema(StringRef FileName) {
assert(Impl->SchemaFileName.empty());
Impl->SchemaFileName = FileName.str();
}
XMLValidator::Status XMLValidator::validate(const std::string &XML) {
if (Impl->SchemaFileName.empty())
return Status{ErrorCode::NoSchema, ""};
if (!Impl->RNGParser) {
Impl->RNGParser = <API key>(Impl->SchemaFileName.c_str());
Impl->Schema = xmlRelaxNGParse(Impl->RNGParser);
}
if (!Impl->RNGParser)
return Status{ErrorCode::InternalError, ""};
if (!Impl->Schema)
return Status{ErrorCode::BadSchema, ""};
xmlDocPtr Doc = xmlParseDoc(reinterpret_cast<const xmlChar *>(XML.data()));
if (!Doc)
return Status{ErrorCode::NotWellFormed, xmlGetLastError()->message};
<API key> ValidationCtxt = <API key>(Impl->Schema);
int ValidationStatus = <API key>(ValidationCtxt, Doc);
Status Result;
if (ValidationStatus == 0) {
Result = Status{ErrorCode::Valid, ""};
} else if (ValidationStatus > 0) {
Result = Status{ErrorCode::NotValid, xmlGetLastError()->message};
} else
Result = Status{ErrorCode::InternalError, ""};
<API key>(ValidationCtxt);
xmlFreeDoc(Doc);
return Result;
}
#else // !SWIFT_HAVE_LIBXML
using namespace swift;
struct XMLValidator::Implementation {};
XMLValidator::XMLValidator() : Impl(new Implementation()) {}
XMLValidator::~XMLValidator() { delete Impl; }
void XMLValidator::setSchema(StringRef FileName) {}
XMLValidator::Status XMLValidator::validate(const std::string &XML) {
return Status{ErrorCode::NotCompiledIn, ""};
}
#endif // SWIFT_HAVE_LIBXML |
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/core'), require('@angular/<API key>'), require('@angular/platform-browser'), require('@angular/compiler')) :
typeof define === 'function' && define.amd ? define(['exports', '@angular/core', '@angular/<API key>', '@angular/platform-browser', '@angular/compiler'], factory) :
(factory((global.ng = global.ng || {}, global.ng.upgrade = global.ng.upgrade || {}), global.ng.core, global.ng.<API key>, global.ng.platformBrowser, global.ng.compiler));
}(this, function (exports, _angular_core, <API key>, <API key>, _angular_compiler) {
'use strict';
var COMPONENT_SELECTOR = /^[\w|-]*$/;
var SKEWER_CASE = /-(\w)/g;
var directiveResolver = new _angular_compiler.DirectiveResolver();
function getComponentInfo(type) {
var resolvedMetadata = directiveResolver.resolve(type);
var selector = resolvedMetadata.selector;
if (!selector.match(COMPONENT_SELECTOR)) {
throw new Error('Only selectors matching element names are supported, got: ' + selector);
}
var selector = selector.replace(SKEWER_CASE, function (all, letter) { return letter.toUpperCase(); });
return {
type: type,
selector: selector,
inputs: parseFields(resolvedMetadata.inputs),
outputs: parseFields(resolvedMetadata.outputs)
};
}
function parseFields(names) {
var attrProps = [];
if (names) {
for (var i = 0; i < names.length; i++) {
var parts = names[i].split(':');
var prop = parts[0].trim();
var attr = (parts[1] || parts[0]).trim();
var capitalAttr = attr.charAt(0).toUpperCase() + attr.substr(1);
attrProps.push({
prop: prop,
attr: attr,
bracketAttr: "[" + attr + "]",
parenAttr: "(" + attr + ")",
bracketParenAttr: "[(" + attr + ")]",
onAttr: "on" + capitalAttr,
bindAttr: "bind" + capitalAttr,
bindonAttr: "bindon" + capitalAttr
});
}
}
return attrProps;
}
function onError(e) {
// TODO: (misko): We seem to not have a stack trace here!
console.log(e, e.stack);
throw e;
}
function controllerKey(name) {
return '$' + name + 'Controller';
}
var NG2_COMPILER = 'ng2.Compiler';
var NG2_INJECTOR = 'ng2.Injector';
var <API key> = 'ng2.<API key>';
var NG2_ZONE = 'ng2.NgZone';
var NG1_CONTROLLER = '$controller';
var NG1_SCOPE = '$scope';
var NG1_ROOT_SCOPE = '$rootScope';
var NG1_COMPILE = '$compile';
var NG1_HTTP_BACKEND = '$httpBackend';
var NG1_INJECTOR = '$injector';
var NG1_PARSE = '$parse';
var NG1_TEMPLATE_CACHE = '$templateCache';
var NG1_TESTABILITY = '$$testability';
var REQUIRE_INJECTOR = '^' + NG2_INJECTOR;
var INITIAL_VALUE = {
__UNINITIALIZED__: true
};
var <API key> = (function () {
function <API key>(id, info, element, attrs, scope, parentInjector, parse, componentFactory) {
this.id = id;
this.info = info;
this.element = element;
this.attrs = attrs;
this.scope = scope;
this.parentInjector = parentInjector;
this.parse = parse;
this.componentFactory = componentFactory;
this.component = null;
this.inputChangeCount = 0;
this.inputChanges = null;
this.componentRef = null;
this.changeDetector = null;
this.<API key> = null;
this.element[0].id = id;
this.componentScope = scope.$new();
this.childNodes = element.contents();
}
<API key>.prototype.bootstrapNg2 = function () {
var childInjector = _angular_core.ReflectiveInjector.resolveAndCreate([_angular_core.provide(NG1_SCOPE, { useValue: this.componentScope })], this.parentInjector);
this.<API key> = document.createComment('ng1 insertion point');
this.componentRef =
this.componentFactory.create(childInjector, [[this.<API key>]], '#' + this.id);
this.changeDetector = this.componentRef.changeDetectorRef;
this.component = this.componentRef.instance;
};
<API key>.prototype.setupInputs = function () {
var _this = this;
var attrs = this.attrs;
var inputs = this.info.inputs;
for (var i = 0; i < inputs.length; i++) {
var input = inputs[i];
var expr = null;
if (attrs.hasOwnProperty(input.attr)) {
var observeFn = (function (prop) {
var prevValue = INITIAL_VALUE;
return function (value) {
if (_this.inputChanges !== null) {
_this.inputChangeCount++;
_this.inputChanges[prop] =
new Ng1Change(value, prevValue === INITIAL_VALUE ? value : prevValue);
prevValue = value;
}
_this.component[prop] = value;
};
})(input.prop);
attrs.$observe(input.attr, observeFn);
}
else if (attrs.hasOwnProperty(input.bindAttr)) {
expr = attrs[input.bindAttr];
}
else if (attrs.hasOwnProperty(input.bracketAttr)) {
expr = attrs[input.bracketAttr];
}
else if (attrs.hasOwnProperty(input.bindonAttr)) {
expr = attrs[input.bindonAttr];
}
else if (attrs.hasOwnProperty(input.bracketParenAttr)) {
expr = attrs[input.bracketParenAttr];
}
if (expr != null) {
var watchFn = (function (prop) { return function (value, prevValue) {
if (_this.inputChanges != null) {
_this.inputChangeCount++;
_this.inputChanges[prop] = new Ng1Change(prevValue, value);
}
_this.component[prop] = value;
}; })(input.prop);
this.componentScope.$watch(expr, watchFn);
}
}
var prototype = this.info.type.prototype;
if (prototype && prototype.ngOnChanges) {
// Detect: OnChanges interface
this.inputChanges = {};
this.componentScope.$watch(function () { return _this.inputChangeCount; }, function () {
var inputChanges = _this.inputChanges;
_this.inputChanges = {};
_this.component.ngOnChanges(inputChanges);
});
}
this.componentScope.$watch(function () { return _this.changeDetector && _this.changeDetector.detectChanges(); });
};
<API key>.prototype.projectContent = function () {
var childNodes = this.childNodes;
var parent = this.<API key>.parentNode;
if (parent) {
for (var i = 0, ii = childNodes.length; i < ii; i++) {
parent.insertBefore(childNodes[i], this.<API key>);
}
}
};
<API key>.prototype.setupOutputs = function () {
var _this = this;
var attrs = this.attrs;
var outputs = this.info.outputs;
for (var j = 0; j < outputs.length; j++) {
var output = outputs[j];
var expr = null;
var assignExpr = false;
var bindonAttr = output.bindonAttr ? output.bindonAttr.substring(0, output.bindonAttr.length - 6) : null;
var bracketParenAttr = output.bracketParenAttr ?
"[(" + output.bracketParenAttr.substring(2, output.bracketParenAttr.length - 8) + ")]" :
null;
if (attrs.hasOwnProperty(output.onAttr)) {
expr = attrs[output.onAttr];
}
else if (attrs.hasOwnProperty(output.parenAttr)) {
expr = attrs[output.parenAttr];
}
else if (attrs.hasOwnProperty(bindonAttr)) {
expr = attrs[bindonAttr];
assignExpr = true;
}
else if (attrs.hasOwnProperty(bracketParenAttr)) {
expr = attrs[bracketParenAttr];
assignExpr = true;
}
if (expr != null && assignExpr != null) {
var getter = this.parse(expr);
var setter = getter.assign;
if (assignExpr && !setter) {
throw new Error("Expression '" + expr + "' is not assignable!");
}
var emitter = this.component[output.prop];
if (emitter) {
emitter.subscribe({
next: assignExpr ? (function (setter) { return function (value) { return setter(_this.scope, value); }; })(setter) :
(function (getter) { return function (value) { return getter(_this.scope, { $event: value }); }; })(getter)
});
}
else {
throw new Error("Missing emitter '" + output.prop + "' on component '" + this.info.selector + "'!");
}
}
}
};
<API key>.prototype.registerCleanup = function () {
var _this = this;
this.element.bind('$destroy', function () {
_this.componentScope.$destroy();
_this.componentRef.destroy();
});
};
return <API key>;
}());
var Ng1Change = (function () {
function Ng1Change(previousValue, currentValue) {
this.previousValue = previousValue;
this.currentValue = currentValue;
}
Ng1Change.prototype.isFirstChange = function () { return this.previousValue === this.currentValue; };
return Ng1Change;
}());
function noNg() {
throw new Error('AngularJS v1.x is not loaded!');
}
var angular = {
bootstrap: noNg,
module: noNg,
element: noNg,
version: noNg,
resumeBootstrap: noNg,
getTestability: noNg
};
try {
if (window.hasOwnProperty('angular')) {
angular = window.angular;
}
}
catch (e) {
}
var bootstrap = angular.bootstrap;
var module$1 = angular.module;
var element = angular.element;
var CAMEL_CASE = /([A-Z])/g;
var INITIAL_VALUE$1 = {
__UNINITIALIZED__: true
};
var NOT_SUPPORTED = 'NOT_SUPPORTED';
var <API key> = (function () {
function <API key>(name) {
this.name = name;
this.inputs = [];
this.inputsRename = [];
this.outputs = [];
this.outputsRename = [];
this.propertyOutputs = [];
this.checkProperties = [];
this.propertyMap = {};
this.linkFn = null;
this.directive = null;
this.$controller = null;
var selector = name.replace(CAMEL_CASE, function (all, next) { return '-' + next.toLowerCase(); });
var self = this;
this.type =
_angular_core.Directive({ selector: selector, inputs: this.inputsRename, outputs: this.outputsRename })
.Class({
constructor: [
new _angular_core.Inject(NG1_SCOPE),
_angular_core.ElementRef,
function (scope, elementRef) {
return new <API key>(self.linkFn, scope, self.directive, elementRef, self.$controller, self.inputs, self.outputs, self.propertyOutputs, self.checkProperties, self.propertyMap);
}
],
ngOnInit: function () { },
ngOnChanges: function () { },
ngDoCheck: function () { }
});
}
<API key>.prototype.extractDirective = function (injector) {
var directives = injector.get(this.name + 'Directive');
if (directives.length > 1) {
throw new Error('Only support single directive definition for: ' + this.name);
}
var directive = directives[0];
if (directive.replace)
this.notSupported('replace');
if (directive.terminal)
this.notSupported('terminal');
var link = directive.link;
if (typeof link == 'object') {
if (link.post)
this.notSupported('link.post');
}
return directive;
};
<API key>.prototype.notSupported = function (feature) {
throw new Error("Upgraded directive '" + this.name + "' does not support '" + feature + "'.");
};
<API key>.prototype.extractBindings = function () {
var btcIsObject = typeof this.directive.bindToController === 'object';
if (btcIsObject && Object.keys(this.directive.scope).length) {
throw new Error("Binding definitions on scope and controller at the same time are not supported.");
}
var context = (btcIsObject) ? this.directive.bindToController : this.directive.scope;
if (typeof context == 'object') {
for (var name in context) {
if (context.hasOwnProperty(name)) {
var localName = context[name];
var type = localName.charAt(0);
localName = localName.substr(1) || name;
var outputName = 'output_' + name;
var outputNameRename = outputName + ': ' + name;
var <API key> = outputName + ': ' + name + 'Change';
var inputName = 'input_' + name;
var inputNameRename = inputName + ': ' + name;
switch (type) {
case '=':
this.propertyOutputs.push(outputName);
this.checkProperties.push(localName);
this.outputs.push(outputName);
this.outputsRename.push(<API key>);
this.propertyMap[outputName] = localName;
// don't break; let it fall through to '@'
case '@':
// handle the '<' binding of angular 1.5 components
case '<':
this.inputs.push(inputName);
this.inputsRename.push(inputNameRename);
this.propertyMap[inputName] = localName;
break;
case '&':
this.outputs.push(outputName);
this.outputsRename.push(outputNameRename);
this.propertyMap[outputName] = localName;
break;
default:
var json = JSON.stringify(context);
throw new Error("Unexpected mapping '" + type + "' in '" + json + "' in '" + this.name + "' directive.");
}
}
}
}
};
<API key>.prototype.compileTemplate = function (compile, templateCache, httpBackend) {
var _this = this;
if (this.directive.template !== undefined) {
this.linkFn = compileHtml(this.directive.template);
}
else if (this.directive.templateUrl) {
var url = this.directive.templateUrl;
var html = templateCache.get(url);
if (html !== undefined) {
this.linkFn = compileHtml(html);
}
else {
return new Promise(function (resolve, err) {
httpBackend('GET', url, null, function (status, response) {
if (status == 200) {
resolve(_this.linkFn = compileHtml(templateCache.put(url, response)));
}
else {
err("GET " + url + " returned " + status + ": " + response);
}
});
});
}
}
else {
throw new Error("Directive '" + this.name + "' is not a component, it is missing template.");
}
return null;
function compileHtml(html) {
var div = document.createElement('div');
div.innerHTML = html;
return compile(div.childNodes);
}
};
<API key>.resolve = function (exportedComponents, injector) {
var promises = [];
var compile = injector.get(NG1_COMPILE);
var templateCache = injector.get(NG1_TEMPLATE_CACHE);
var httpBackend = injector.get(NG1_HTTP_BACKEND);
var $controller = injector.get(NG1_CONTROLLER);
for (var name in exportedComponents) {
if (exportedComponents.hasOwnProperty(name)) {
var exportedComponent = exportedComponents[name];
exportedComponent.directive = exportedComponent.extractDirective(injector);
exportedComponent.$controller = $controller;
exportedComponent.extractBindings();
var promise = exportedComponent.compileTemplate(compile, templateCache, httpBackend);
if (promise)
promises.push(promise);
}
}
return Promise.all(promises);
};
return <API key>;
}());
var <API key> = (function () {
function <API key>(linkFn, scope, directive, elementRef, $controller, inputs, outputs, propOuts, checkProperties, propertyMap) {
this.linkFn = linkFn;
this.directive = directive;
this.inputs = inputs;
this.outputs = outputs;
this.propOuts = propOuts;
this.checkProperties = checkProperties;
this.propertyMap = propertyMap;
this.destinationObj = null;
this.checkLastValues = [];
this.element = elementRef.nativeElement;
this.componentScope = scope.$new(!!directive.scope);
var $element = element(this.element);
var controllerType = directive.controller;
var controller = null;
if (controllerType) {
var locals = { $scope: this.componentScope, $element: $element };
controller = $controller(controllerType, locals, null, directive.controllerAs);
$element.data(controllerKey(directive.name), controller);
}
var link = directive.link;
if (typeof link == 'object')
link = link.pre;
if (link) {
var attrs = NOT_SUPPORTED;
var transcludeFn = NOT_SUPPORTED;
var linkController = this.resolveRequired($element, directive.require);
directive.link(this.componentScope, $element, attrs, linkController, transcludeFn);
}
this.destinationObj =
directive.bindToController && controller ? controller : this.componentScope;
for (var i = 0; i < inputs.length; i++) {
this[inputs[i]] = null;
}
for (var j = 0; j < outputs.length; j++) {
var emitter = this[outputs[j]] = new _angular_core.EventEmitter();
this.<API key>(outputs[j], (function (emitter) { return function (value) { return emitter.emit(value); }; })(emitter));
}
for (var k = 0; k < propOuts.length; k++) {
this[propOuts[k]] = new _angular_core.EventEmitter();
this.checkLastValues.push(INITIAL_VALUE$1);
}
}
<API key>.prototype.ngOnInit = function () {
var _this = this;
var childNodes = [];
var childNode;
while (childNode = this.element.firstChild) {
this.element.removeChild(childNode);
childNodes.push(childNode);
}
this.linkFn(this.componentScope, function (clonedElement, scope) {
for (var i = 0, ii = clonedElement.length; i < ii; i++) {
_this.element.appendChild(clonedElement[i]);
}
}, { <API key>: function (scope, cloneAttach) { cloneAttach(childNodes); } });
if (this.destinationObj.$onInit) {
this.destinationObj.$onInit();
}
};
<API key>.prototype.ngOnChanges = function (changes) {
for (var name in changes) {
if (changes.hasOwnProperty(name)) {
var change = changes[name];
this.<API key>(name, change.currentValue);
}
}
};
<API key>.prototype.ngDoCheck = function () {
var count = 0;
var destinationObj = this.destinationObj;
var lastValues = this.checkLastValues;
var checkProperties = this.checkProperties;
for (var i = 0; i < checkProperties.length; i++) {
var value = destinationObj[checkProperties[i]];
var last = lastValues[i];
if (value !== last) {
if (typeof value == 'number' && isNaN(value) && typeof last == 'number' && isNaN(last)) {
}
else {
var eventEmitter = this[this.propOuts[i]];
eventEmitter.emit(lastValues[i] = value);
}
}
}
return count;
};
<API key>.prototype.<API key> = function (name, value) {
this.destinationObj[this.propertyMap[name]] = value;
};
<API key>.prototype.resolveRequired = function ($element, require) {
if (!require) {
return undefined;
}
else if (typeof require == 'string') {
var name = require;
var isOptional = false;
var startParent = false;
var searchParents = false;
var ch;
if (name.charAt(0) == '?') {
isOptional = true;
name = name.substr(1);
}
if (name.charAt(0) == '^') {
searchParents = true;
name = name.substr(1);
}
if (name.charAt(0) == '^') {
startParent = true;
name = name.substr(1);
}
var key = controllerKey(name);
if (startParent)
$element = $element.parent();
var dep = searchParents ? $element.inheritedData(key) : $element.data(key);
if (!dep && !isOptional) {
throw new Error("Can not locate '" + require + "' in '" + this.directive.name + "'.");
}
return dep;
}
else if (require instanceof Array) {
var deps = [];
for (var i = 0; i < require.length; i++) {
deps.push(this.resolveRequired($element, require[i]));
}
return deps;
}
throw new Error("Directive '" + this.directive.name + "' require syntax unrecognized: " + this.directive.require);
};
return <API key>;
}());
var upgradeCount = 0;
var UpgradeAdapter = (function () {
function UpgradeAdapter() {
/* @internal */
this.idPrefix = "NG2_UPGRADE_" + upgradeCount++ + "_";
/* @internal */
this.upgradedComponents = [];
/* @internal */
this.<API key> = {};
/* @internal */
this.providers = [];
}
UpgradeAdapter.prototype.<API key> = function (type) {
this.upgradedComponents.push(type);
var info = getComponentInfo(type);
return <API key>(info, "" + this.idPrefix + info.selector + "_c");
};
UpgradeAdapter.prototype.upgradeNg1Component = function (name) {
if (this.<API key>.hasOwnProperty(name)) {
return this.<API key>[name].type;
}
else {
return (this.<API key>[name] = new <API key>(name)).type;
}
};
UpgradeAdapter.prototype.bootstrap = function (element$$, modules, config) {
var _this = this;
var upgrade = new UpgradeAdapterRef();
var ng1Injector = null;
var platformRef = <API key>.browserPlatform();
var applicationRef = _angular_core.ReflectiveInjector.resolveAndCreate([
<API key>.<API key>,
_angular_core.provide(NG1_INJECTOR, { useFactory: function () { return ng1Injector; } }),
_angular_core.provide(NG1_COMPILE, { useFactory: function () { return ng1Injector.get(NG1_COMPILE); } }),
this.providers
], platformRef.injector)
.get(_angular_core.ApplicationRef);
var injector = applicationRef.injector;
var ngZone = injector.get(_angular_core.NgZone);
var compiler = injector.get(_angular_core.ComponentResolver);
var delayApplyExps = [];
var original$applyFn;
var rootScopePrototype;
var rootScope;
var <API key> = {};
var ng1Module = module$1(this.idPrefix, modules);
var ng1BootstrapPromise = null;
var ng1compilePromise = null;
ng1Module.value(NG2_INJECTOR, injector)
.value(NG2_ZONE, ngZone)
.value(NG2_COMPILER, compiler)
.value(<API key>, <API key>)
.config([
'$provide',
function (provide) {
provide.decorator(NG1_ROOT_SCOPE, [
'$delegate',
function (rootScopeDelegate) {
rootScopePrototype = rootScopeDelegate.constructor.prototype;
if (rootScopePrototype.hasOwnProperty('$apply')) {
original$applyFn = rootScopePrototype.$apply;
rootScopePrototype.$apply = function (exp) { return delayApplyExps.push(exp); };
}
else {
throw new Error("Failed to find '$apply' on '$rootScope'!");
}
return rootScope = rootScopeDelegate;
}
]);
provide.decorator(NG1_TESTABILITY, [
'$delegate',
function (testabilityDelegate) {
var _this = this;
var ng2Testability = injector.get(_angular_core.Testability);
var origonalWhenStable = testabilityDelegate.whenStable;
var newWhenStable = function (callback) {
var whenStableContext = _this;
origonalWhenStable.call(_this, function () {
if (ng2Testability.isStable()) {
callback.apply(this, arguments);
}
else {
ng2Testability.whenStable(newWhenStable.bind(whenStableContext, callback));
}
});
};
testabilityDelegate.whenStable = newWhenStable;
return testabilityDelegate;
}
]);
}
]);
ng1compilePromise = new Promise(function (resolve, reject) {
ng1Module.run([
'$injector',
'$rootScope',
function (injector, rootScope) {
ng1Injector = injector;
ngZone.onMicrotaskEmpty.subscribe({ next: function (_) { return ngZone.runOutsideAngular(function () { return rootScope.$apply(); }); } });
<API key>.resolve(_this.<API key>, injector)
.then(resolve, reject);
}
]);
});
// Make sure resumeBootstrap() only exists if the current bootstrap is deferred
var windowAngular = window['angular'];
windowAngular.resumeBootstrap = undefined;
element(element$$).data(controllerKey(NG2_INJECTOR), injector);
ngZone.run(function () { bootstrap(element$$, [_this.idPrefix], config); });
ng1BootstrapPromise = new Promise(function (resolve, reject) {
if (windowAngular.resumeBootstrap) {
var <API key> = windowAngular.resumeBootstrap;
windowAngular.resumeBootstrap = function () {
windowAngular.resumeBootstrap = <API key>;
windowAngular.resumeBootstrap.apply(this, arguments);
resolve();
};
}
else {
resolve();
}
});
Promise.all([
this.<API key>(compiler, <API key>),
ng1BootstrapPromise,
ng1compilePromise
])
.then(function () {
ngZone.run(function () {
if (rootScopePrototype) {
rootScopePrototype.$apply = original$applyFn; // restore original $apply
while (delayApplyExps.length) {
rootScope.$apply(delayApplyExps.shift());
}
upgrade._bootstrapDone(applicationRef, ng1Injector);
rootScopePrototype = null;
}
});
}, onError);
return upgrade;
};
UpgradeAdapter.prototype.addProvider = function (provider) { this.providers.push(provider); };
UpgradeAdapter.prototype.upgradeNg1Provider = function (name, options) {
var token = options && options.asToken || name;
this.providers.push(_angular_core.provide(token, {
useFactory: function (ng1Injector) { return ng1Injector.get(name); },
deps: [NG1_INJECTOR]
}));
};
UpgradeAdapter.prototype.<API key> = function (token) {
var factory = function (injector) { return injector.get(token); };
factory.$inject = [NG2_INJECTOR];
return factory;
};
/* @internal */
UpgradeAdapter.prototype.<API key> = function (compiler, <API key>) {
var _this = this;
var promises = [];
var types = this.upgradedComponents;
for (var i = 0; i < types.length; i++) {
promises.push(compiler.resolveComponent(types[i]));
}
return Promise.all(promises).then(function (componentFactories) {
var types = _this.upgradedComponents;
for (var i = 0; i < componentFactories.length; i++) {
<API key>[getComponentInfo(types[i]).selector] = componentFactories[i];
}
return <API key>;
}, onError);
};
return UpgradeAdapter;
}());
function <API key>(info, idPrefix) {
directiveFactory.$inject = [<API key>, NG1_PARSE];
function directiveFactory(<API key>, parse) {
var componentFactory = <API key>[info.selector];
if (!componentFactory)
throw new Error('Expecting ComponentFactory for: ' + info.selector);
var idCount = 0;
return {
restrict: 'E',
require: REQUIRE_INJECTOR,
link: {
post: function (scope, element, attrs, parentInjector, transclude) {
var domElement = element[0];
var facade = new <API key>(idPrefix + (idCount++), info, element, attrs, scope, parentInjector, parse, componentFactory);
facade.setupInputs();
facade.bootstrapNg2();
facade.projectContent();
facade.setupOutputs();
facade.registerCleanup();
}
}
};
}
return directiveFactory;
}
/**
* Use `UgradeAdapterRef` to control a hybrid AngularJS v1 / Angular v2 application.
*/
var UpgradeAdapterRef = (function () {
function UpgradeAdapterRef() {
/* @internal */
this._readyFn = null;
this.ng1RootScope = null;
this.ng1Injector = null;
this.ng2ApplicationRef = null;
this.ng2Injector = null;
}
/* @internal */
UpgradeAdapterRef.prototype._bootstrapDone = function (applicationRef, ng1Injector) {
this.ng2ApplicationRef = applicationRef;
this.ng2Injector = applicationRef.injector;
this.ng1Injector = ng1Injector;
this.ng1RootScope = ng1Injector.get(NG1_ROOT_SCOPE);
this._readyFn && this._readyFn(this);
};
/**
* Register a callback function which is notified upon successful hybrid AngularJS v1 / Angular v2
* application has been bootstrapped.
*
* The `ready` callback function is invoked inside the Angular v2 zone, therefore it does not
* require a call to `$apply()`.
*/
UpgradeAdapterRef.prototype.ready = function (fn) { this._readyFn = fn; };
/**
* Dispose of running hybrid AngularJS v1 / Angular v2 application.
*/
UpgradeAdapterRef.prototype.dispose = function () {
this.ng1Injector.get(NG1_ROOT_SCOPE).$destroy();
this.ng2ApplicationRef.dispose();
};
return UpgradeAdapterRef;
}());
exports.UpgradeAdapter = UpgradeAdapter;
exports.UpgradeAdapterRef = UpgradeAdapterRef;
})); |
// run-pass
// aux-build:issue-31702-1.rs
// aux-build:issue-31702-2.rs
// this test is actually entirely in the linked library crates
extern crate issue_31702_1;
extern crate issue_31702_2;
fn main() {} |
#ifndef <API key>
#define <API key>
#include <ostream>
#include <string>
#include "arch/sparc/registers.hh"
#include "arch/sparc/types.hh"
#include "cpu/cpuevent.hh"
#include "sim/sim_object.hh"
class Checkpoint;
class EventManager;
struct SparcISAParams;
class ThreadContext;
namespace SparcISA
{
class ISA : public SimObject
{
private:
/* ASR Registers */
// uint64_t y; // Y (used in obsolete multiplication)
// uint8_t ccr; // Condition Code Register
uint8_t asi; // Address Space Identifier
uint64_t tick; // Hardware clock-tick counter
uint8_t fprs; // Floating-Point Register State
uint64_t gsr; // General Status Register
uint64_t softint;
uint64_t tick_cmpr; // Hardware tick compare registers
uint64_t stick; // Hardware clock-tick counter
uint64_t stick_cmpr; // Hardware tick compare registers
/* Privileged Registers */
uint64_t tpc[MaxTL]; // Trap Program Counter (value from
// previous trap level)
uint64_t tnpc[MaxTL]; // Trap Next Program Counter (value from
// previous trap level)
uint64_t tstate[MaxTL]; // Trap State
uint16_t tt[MaxTL]; // Trap Type (Type of trap which occured
// on the previous level)
uint64_t tba; // Trap Base Address
PSTATE pstate; // Process State Register
uint8_t tl; // Trap Level
uint8_t pil; // Process Interrupt Register
uint8_t cwp; // Current Window Pointer
// uint8_t cansave; // Savable windows
// uint8_t canrestore; // Restorable windows
// uint8_t cleanwin; // Clean windows
// uint8_t otherwin; // Other windows
// uint8_t wstate; // Window State
uint8_t gl; // Global level register
/** Hyperprivileged Registers */
HPSTATE hpstate; // Hyperprivileged State Register
uint64_t htstate[MaxTL];// Hyperprivileged Trap State Register
uint64_t hintp;
uint64_t htba; // Hyperprivileged Trap Base Address register
uint64_t hstick_cmpr; // Hardware tick compare registers
uint64_t strandStatusReg;// Per strand status register
/** Floating point misc registers. */
uint64_t fsr; // Floating-Point State Register
/** MMU Internal Registers */
uint16_t priContext;
uint16_t secContext;
uint16_t partId;
uint64_t lsuCtrlReg;
uint64_t scratchPad[8];
uint64_t cpu_mondo_head;
uint64_t cpu_mondo_tail;
uint64_t dev_mondo_head;
uint64_t dev_mondo_tail;
uint64_t res_error_head;
uint64_t res_error_tail;
uint64_t nres_error_head;
uint64_t nres_error_tail;
// These need to check the int_dis field and if 0 then
// set appropriate bit in softint and checkinterrutps on the cpu
void setFSReg(int miscReg, const MiscReg &val, ThreadContext *tc);
MiscReg readFSReg(int miscReg, ThreadContext * tc);
// Update interrupt state on softint or pil change
void checkSoftInt(ThreadContext *tc);
/** Process a tick compare event and generate an interrupt on the cpu if
* appropriate. */
void processTickCompare(ThreadContext *tc);
void processSTickCompare(ThreadContext *tc);
void <API key>(ThreadContext *tc);
typedef CpuEventWrapper<ISA,
&ISA::processTickCompare> TickCompareEvent;
TickCompareEvent *tickCompare;
typedef CpuEventWrapper<ISA,
&ISA::processSTickCompare> STickCompareEvent;
STickCompareEvent *sTickCompare;
typedef CpuEventWrapper<ISA,
&ISA::<API key>> HSTickCompareEvent;
HSTickCompareEvent *hSTickCompare;
static const int NumGlobalRegs = 8;
static const int NumWindowedRegs = 24;
static const int WindowOverlap = 8;
static const int TotalGlobals = (MaxGL + 1) * NumGlobalRegs;
static const int RegsPerWindow = NumWindowedRegs - WindowOverlap;
static const int TotalWindowed = NWindows * RegsPerWindow;
enum InstIntRegOffsets {
<API key> = 0,
CurrentWindowOffset = <API key> + NumGlobalRegs,
MicroIntOffset = CurrentWindowOffset + NumWindowedRegs,
NextGlobalsOffset = MicroIntOffset + NumMicroIntRegs,
NextWindowOffset = NextGlobalsOffset + NumGlobalRegs,
<API key> = NextWindowOffset + NumWindowedRegs,
<API key> = <API key> + NumGlobalRegs,
TotalInstIntRegs = <API key> + NumWindowedRegs
};
RegIndex intRegMap[TotalInstIntRegs];
void installWindow(int cwp, int offset);
void installGlobals(int gl, int offset);
void reloadRegMap();
public:
void clear();
void serialize(std::ostream & os);
void unserialize(Checkpoint *cp, const std::string & section);
void startup(ThreadContext *tc) {}
Explicitly import the otherwise hidden startup
using SimObject::startup;
protected:
bool isHyperPriv() { return hpstate.hpriv; }
bool isPriv() { return hpstate.hpriv || pstate.priv; }
bool isNonPriv() { return !isPriv(); }
public:
MiscReg readMiscRegNoEffect(int miscReg);
MiscReg readMiscReg(int miscReg, ThreadContext *tc);
void setMiscRegNoEffect(int miscReg, const MiscReg val);
void setMiscReg(int miscReg, const MiscReg val,
ThreadContext *tc);
int
flattenIntIndex(int reg) const
{
assert(reg < TotalInstIntRegs);
RegIndex flatIndex = intRegMap[reg];
assert(flatIndex < NumIntRegs);
return flatIndex;
}
int
flattenFloatIndex(int reg) const
{
return reg;
}
// dummy
int
flattenCCIndex(int reg) const
{
return reg;
}
int
flattenMiscIndex(int reg) const
{
return reg;
}
typedef SparcISAParams Params;
const Params *params() const;
ISA(Params *p);
};
}
#endif |
<!DOCTYPE HTML>
<title>CSS Test Reference (Transforms): Filter on an element in a preserve-3d scene</title>
<link rel="author" title="L. David Baron" href="https://dbaron.org/">
<link rel="author" title="Google" href="http:
<style>
svg.cover {
position: absolute;
z-index: 1;
top: 0;
left: 0;
width: 500px;
height: 570px;
}
</style>
<svg class="cover">
<polygon fill="black" stroke="blue" stroke-width="8"
points="266.429,351
301.1586,351
301.1586,551
266.429,551" />
</svg> |
<!doctype html>
<meta charset="utf-8">
<link rel="author" name="Delan Azabani" href="mailto:dazabani@igalia.com">
<script src="support/selections.js"></script>
<link rel="stylesheet" href="support/highlights.css">
<style>
main {
font-size: 7em;
margin: 0.5em;
}
main::selection {
background-color: transparent;
color: black;
}
</style>
<p>Test passes if the text below does not appear to be highlighted.
<main class="highlight_reftest">quick</main>
<script>selectNodeContents(document.querySelector("main"));</script> |
THREE.WebGLRenderTarget = function ( width, height, options ) {
this.uuid = THREE.Math.generateUUID();
this.width = width;
this.height = height;
options = options || {};
if ( options.minFilter === undefined ) options.minFilter = THREE.LinearFilter;
this.texture = new THREE.Texture( undefined, undefined, options.wrapS, options.wrapT, options.magFilter, options.minFilter, options.format, options.type, options.anisotropy );
this.depthBuffer = options.depthBuffer !== undefined ? options.depthBuffer : true;
this.stencilBuffer = options.stencilBuffer !== undefined ? options.stencilBuffer : true;
this.shareDepthFrom = options.shareDepthFrom !== undefined ? options.shareDepthFrom : null;
};
THREE.WebGLRenderTarget.prototype = {
constructor: THREE.WebGLRenderTarget,
get wrapS() {
console.warn( 'THREE.WebGLRenderTarget: .wrapS is now .texture.wrapS.' );
return this.texture.wrapS;
},
set wrapS( value ) {
console.warn( 'THREE.WebGLRenderTarget: .wrapS is now .texture.wrapS.' );
this.texture.wrapS = value;
},
get wrapT() {
console.warn( 'THREE.WebGLRenderTarget: .wrapT is now .texture.wrapT.' );
return this.texture.wrapT;
},
set wrapT( value ) {
console.warn( 'THREE.WebGLRenderTarget: .wrapT is now .texture.wrapT.' );
this.texture.wrapT = value;
},
get magFilter() {
console.warn( 'THREE.WebGLRenderTarget: .magFilter is now .texture.magFilter.' );
return this.texture.magFilter;
},
set magFilter( value ) {
console.warn( 'THREE.WebGLRenderTarget: .magFilter is now .texture.magFilter.' );
this.texture.magFilter = value;
},
get minFilter() {
console.warn( 'THREE.WebGLRenderTarget: .minFilter is now .texture.minFilter.' );
return this.texture.minFilter;
},
set minFilter( value ) {
console.warn( 'THREE.WebGLRenderTarget: .minFilter is now .texture.minFilter.' );
this.texture.minFilter = value;
},
get anisotropy() {
console.warn( 'THREE.WebGLRenderTarget: .anisotropy is now .texture.anisotropy.' );
return this.texture.anisotropy;
},
set anisotropy( value ) {
console.warn( 'THREE.WebGLRenderTarget: .anisotropy is now .texture.anisotropy.' );
this.texture.anisotropy = value;
},
get offset() {
console.warn( 'THREE.WebGLRenderTarget: .offset is now .texture.offset.' );
return this.texture.offset;
},
set offset( value ) {
console.warn( 'THREE.WebGLRenderTarget: .offset is now .texture.offset.' );
this.texture.offset = value;
},
get repeat() {
console.warn( 'THREE.WebGLRenderTarget: .repeat is now .texture.repeat.' );
return this.texture.repeat;
},
set repeat( value ) {
console.warn( 'THREE.WebGLRenderTarget: .repeat is now .texture.repeat.' );
this.texture.repeat = value;
},
get format() {
console.warn( 'THREE.WebGLRenderTarget: .format is now .texture.format.' );
return this.texture.format;
},
set format( value ) {
console.warn( 'THREE.WebGLRenderTarget: .format is now .texture.format.' );
this.texture.format = value;
},
get type() {
console.warn( 'THREE.WebGLRenderTarget: .type is now .texture.type.' );
return this.texture.type;
},
set type( value ) {
console.warn( 'THREE.WebGLRenderTarget: .type is now .texture.type.' );
this.texture.type = value;
},
get generateMipmaps() {
console.warn( 'THREE.WebGLRenderTarget: .generateMipmaps is now .texture.generateMipmaps.' );
return this.texture.generateMipmaps;
},
set generateMipmaps( value ) {
console.warn( 'THREE.WebGLRenderTarget: .generateMipmaps is now .texture.generateMipmaps.' );
this.texture.generateMipmaps = value;
},
setSize: function ( width, height ) {
if ( this.width !== width || this.height !== height ) {
this.width = width;
this.height = height;
this.dispose();
}
},
clone: function () {
return new this.constructor().copy( this );
},
copy: function ( source ) {
this.width = source.width;
this.height = source.height;
this.texture = source.texture.clone();
this.depthBuffer = source.depthBuffer;
this.stencilBuffer = source.stencilBuffer;
this.shareDepthFrom = source.shareDepthFrom;
return this;
},
dispose: function () {
this.dispatchEvent( { type: 'dispose' } );
}
};
THREE.EventDispatcher.prototype.apply( THREE.WebGLRenderTarget.prototype ); |
import Player from '@vimeo/player';
let player: Player ;
player = new Player('handstick', {
id: 19231868,
width: 640,
// Use default values for settings, to test typings
autopause: true,
autoplay: false,
background: false,
byline: true,
color: '#00adef',
loop: false,
muted: false,
playsinline: true,
portrait: true,
speed: false,
title: true,
transparent: true
});
const onPlay = (data: any) => {
// data is an object containing properties specific to that event
};
player.on('play', onPlay);
player.off('play', onPlay);
// Alternatively, `off` can be called with just the event name to remove all
// listeners.
player.off('play');
player.loadVideo(76979871).then((id) => {
// the video successfully loaded
}).catch((error) => {
switch (error.name) {
case 'TypeError':
// the id was not a number
break;
case 'PasswordError':
// the video is password-protected and the viewer needs to enter the
// password first
break;
case 'PrivacyError':
// the video is password-protected or private
break;
default:
// some other error occurred
break;
}
});
player.ready().then(() => {
// the player is ready
});
player.enableTextTrack('en').then((track) => {
console.log(track.label);
console.log(track.kind);
console.log(track.language);
// track.language = the iso code for the language
// track.kind = 'captions' or 'subtitles'
// track.label = the human-readable label
}).catch((error) => {
switch (error.name) {
case '<API key>':
// no track was available with the specified language
break;
case 'InvalidTrackError':
// no track was available with the specified language and kind
break;
default:
// some other error occurred
break;
}
});
player.disableTextTrack().then(() => {
// the track was disabled
}).catch((error) => {
// an error occurred
});
player.pause().then(() => {
// the video was paused
}).catch((error) => {
switch (error.name) {
case 'PasswordError':
// the video is password-protected and the viewer needs to enter the
// password first
break;
case 'PrivacyError':
// the video is private
break;
default:
// some other error occurred
break;
}
});
player.play().then(() => {
// the video was played
}).catch((error) => {
switch (error.name) {
case 'PasswordError':
// the video is password-protected and the viewer needs to enter the
// password first
break;
case 'PrivacyError':
// the video is private
break;
default:
// some other error occurred
break;
}
});
player.unload().then(() => {
// the video was unloaded
}).catch((error) => {
// an error occurred
});
player.getAutopause().then((autopause) => {
// autopause = whether autopause is turned on or off
}).catch((error) => {
switch (error.name) {
case 'UnsupportedError':
// Autopause is not supported with the current player or browser
break;
default:
// some other error occurred
break;
}
});
player.setAutopause(false).then((autopause) => {
// autopause was turned off
}).catch((error) => {
switch (error.name) {
case 'UnsupportedError':
// Autopause is not supported with the current player or browser
break;
default:
// some other error occurred
break;
}
});
player.getColor().then((color) => {
// color = the hex color of the player
}).catch((error) => {
// an error occurred
});
player.setColor('#00adef').then((color) => {
// color was successfully set
}).catch((error) => {
switch (error.name) {
case 'ContrastError':
// the color was set, but the contrast is outside of the acceptable
// range
break;
case 'TypeError':
// the string was not a valid hex or rgb color
break;
case 'EmbedSettingsError':
// the owner of the video has chosen to use a specific color
break;
default:
// some other error occurred
break;
}
});
player.addCuePoint(15, {
customKey: 'customValue'
}).then((id) => {
// cue point was added successfully
}).catch((error) => {
switch (error.name) {
case 'UnsupportedError':
// cue points are not supported with the current player or browser
break;
case 'RangeError':
break;
default:
// some other error occurred
break;
}
});
player.removeCuePoint('<API key>').then((id) => {
// cue point was removed successfully
}).catch((error) => {
switch (error.name) {
case 'UnsupportedError':
// cue points are not supported with the current player or browser
break;
case 'InvalidCuePoint':
break;
default:
// some other error occurred
break;
}
});
player.getCuePoints().then((cuePoints) => {
// cuePoints = an array of cue point objects
}).catch((error) => {
switch (error.name) {
case 'UnsupportedError':
// cue points are not supported with the current player or browser
break;
default:
// some other error occurred
break;
}
});
player.getCurrentTime().then((seconds) => {
// seconds = the current playback position
}).catch((error) => {
// an error occurred
});
player.setCurrentTime(30.456).then((seconds) => {
// seconds = the actual time that the player seeked to
}).catch((error) => {
switch (error.name) {
case 'RangeError':
break;
default:
// some other error occurred
break;
}
});
player.getDuration().then((duration) => {
// duration = the duration of the video in seconds
}).catch((error) => {
// an error occurred
});
player.getEnded().then((ended) => {
// ended = whether or not the video has ended
}).catch((error) => {
// an error occurred
});
player.getLoop().then((loop) => {
// loop = whether loop is turned on or not
}).catch((error) => {
// an error occurred
});
player.setLoop(true).then((loop) => {
// loop was turned on
}).catch((error) => {
// an error occurred
});
player.getPaused().then((paused) => {
// paused = whether or not the player is paused
}).catch((error) => {
// an error occurred
});
player.getPlaybackRate().then((playbackRate) => {
// playbackRate = a numeric value of the current playback rate
}).catch((error) => {
// an error occurred
});
player.setPlaybackRate(0.5).then((playbackRate) => {
// playback rate was set
}).catch((error) => {
switch (error.name) {
case 'RangeError':
// the playback rate was less than 0.5 or greater than 2
break;
default:
// some other error occurred
break;
}
});
player.getTextTracks().then((tracks) => {
// tracks = an array of track objects
tracks.forEach((track) => {
console.log(track.label);
console.log(track.kind);
console.log(track.language);
console.log(track.mode);
});
}).catch((error) => {
// an error occurred
error.name;
});
player.getVideoEmbedCode().then((embedCode) => {
// embedCode = <iframe> embed code
}).catch((error) => {
// an error occurred
});
player.getVideoId().then((id) => {
// id = the video id
}).catch((error) => {
// an error occurred
});
player.getVideoTitle().then((title) => {
// title = the title of the video
}).catch((error) => {
// an error occurred
});
player.getVideoWidth().then((width) => {
// width = the width of the video that is currently playing
}).catch((error) => {
// an error occurred
});
player.getVideoHeight().then((height) => {
// height = the height of the video that is currently playing
}).catch((error) => {
// an error occurred
});
Promise.all([player.getVideoWidth(), player.getVideoHeight()]).then((dimensions) => {
const width = dimensions[0];
const height = dimensions[1];
});
player.getVideoUrl().then((url) => {
// url = the vimeo.com url for the video
}).catch((error) => {
switch (error.name) {
case 'PrivacyError':
break;
default:
// some other error occurred
break;
}
});
player.getVolume().then((volume) => {
// volume = the volume level of the player
}).catch((error) => {
// an error occurred
});
player.setVolume(0.5).then((volume) => {
// volume was set
}).catch((error) => {
switch (error.name) {
case 'RangeError':
// the volume was less than 0 or greater than 1
break;
default:
// some other error occurred
break;
}
});
player.getSeeking().then((seeking) => {
// seeking = whether the player is seeking or not
}).catch((error) => {
// an error occurred
});
player.getBuffered().then((buffered) => {
// buffered = an array of the buffered video time ranges.
}).catch((error) => {
// an error occurred
});
player.getPlayed().then((played) => {
// played = array values of the played video time ranges.
}).catch((error) => {
// an error occurred
});
player.getSeekable().then((seekable) => {
// seekable = array values of the seekable video time ranges.
}).catch((error) => {
// an error occurred
});
// EVENTS
player.on('play', (data) => {
// data is an object containing properties specific to that event
console.log(data.duration); // 61.857
console.log(data.percent);
console.log(data.seconds);
});
player.on('pause', (data) => {
// data is an object containing properties specific to that event
console.log(data.duration); // 61.857
console.log(data.percent);
console.log(data.seconds);
});
player.on('ended', (data) => {
// data is an object containing properties specific to that event
console.log(data.duration); // 61.857
console.log(data.percent);
console.log(data.seconds); // 61.857
});
player.on('timeupdate', (data) => {
// data is an object containing properties specific to that event
console.log(data.duration); // 61.857
console.log(data.percent); // 0.049
console.log(data.seconds); // 3.034
});
player.on('progress', (data) => {
// data is an object containing properties specific to that event
console.log(data.duration); // 61.857
console.log(data.percent); // 0.502
console.log(data.seconds); // 31.052
});
player.on('seeked', (data) => {
// data is an object containing properties specific to that event
console.log(data.duration); // 61.857
console.log(data.percent); // 0.485
console.log(data.seconds);
});
player.on('texttrackchange', (data) => {
// data is an object containing properties specific to that event
console.log(data.kind);
console.log(data.label);
console.log(data.language);
});
player.on('cuechange', (data) => {
// data is an object containing properties specific to that event
console.log(data.cues); // Array of Cues
console.log(data.cues[0].html);
console.log(data.cues[0].text);
console.log(data.label);
console.log(data.kind);
console.log(data.language);
});
player.on('cuepoint', (data) => {
// data is an object containing properties specific to that event
console.log(data.time);
console.log(data.data);
console.log(data.data.customKey);
console.log(data.id);
});
player.on('volumechange', (data) => {
// data is an object containing properties specific to that event
console.log(data.volume);
});
player.on('playbackratechange', (data) => {
// data is an object containing properties specific to that event
console.log(data.playbackRate);
});
player.on('bufferstart', (data) => {
// no associated data with this event
});
player.on('bufferend', (data) => {
// no associated data with this event
});
player.on('seeking', (data) => {
// data is an object containing properties specific to that event
console.log(data.duration); // 61.857
console.log(data.percent); // 0.485
console.log(data.seconds);
});
player.on('error', (data) => {
// data is an object containing properties specific to that event
console.log(data.message);
console.log(data.method);
console.log(data.name);
});
player.on('loaded', (data) => {
// data is an object containing properties specific to that event
console.log(data.id);
}); |
#include "PhyExport.h"
#define PHYEXPORT_CLASS_ID Class_ID(0x3dc3c42e, 0x185dc5f2)
class PhyExport : public GUP {
public:
static HWND hParams;
// GUP Methods
DWORD Start ( );
void Stop ( );
DWORD Control ( DWORD parameter );
// Loading/Saving
IOResult Save(ISave *isave);
IOResult Load(ILoad *iload);
//Constructor/Destructor
PhyExport();
~PhyExport();
};
class PhyExportClassDesc:public ClassDesc2 {
public:
int IsPublic() { return 1; }
void * Create(BOOL loading = FALSE) { return new PhyExport(); }
const TCHAR * ClassName() { return GetString(IDS_CLASS_NAME); }
SClass_ID SuperClassID() { return GUP_CLASS_ID; }
Class_ID ClassID() { return PHYEXPORT_CLASS_ID; }
const TCHAR* Category() { return GetString(IDS_CATEGORY); }
const TCHAR* InternalName() { return _T("PhyExport"); } // returns fixed parsable name (scripter-visible name)
HINSTANCE HInstance() { return hInstance; } // returns owning module handle
};
static PhyExportClassDesc PhyExportDesc;
ClassDesc2* GetPhyExportDesc() { return &PhyExportDesc; }
PhyExport::PhyExport()
{
}
PhyExport::~PhyExport()
{
}
// Activate and Stay Resident
DWORD PhyExport::Start( ) {
// TODO: Do plugin initialization here
// TODO: Return if you want remain loaded or not
return GUPRESULT_KEEP;
}
void PhyExport::Stop( ) {
// TODO: Do plugin un-initialization here
}
DWORD PhyExport::Control( DWORD parameter ) {
return 0;
}
IOResult PhyExport::Save(ISave *isave)
{
return IO_OK;
}
IOResult PhyExport::Load(ILoad *iload)
{
return IO_OK;
} |
#include "atom/common/options_switches.h"
namespace atom {
namespace switches {
const char kTitle[] = "title";
const char kIcon[] = "icon";
const char kFrame[] = "frame";
const char kShow[] = "show";
const char kCenter[] = "center";
const char kX[] = "x";
const char kY[] = "y";
const char kWidth[] = "width";
const char kHeight[] = "height";
const char kMinWidth[] = "min-width";
const char kMinHeight[] = "min-height";
const char kMaxWidth[] = "max-width";
const char kMaxHeight[] = "max-height";
const char kResizable[] = "resizable";
const char kFullscreen[] = "fullscreen";
// Whether the window should show in taskbar.
const char kSkipTaskbar[] = "skip-taskbar";
// Start with the kiosk mode, see Opera's page for description:
const char kKiosk[] = "kiosk";
// Make windows stays on the top of all other windows.
const char kAlwaysOnTop[] = "always-on-top";
const char kNodeIntegration[] = "node-integration";
// Enable the NSView to accept first mouse event.
const char kAcceptFirstMouse[] = "accept-first-mouse";
// Whether window size should include window frame.
const char kUseContentSize[] = "use-content-size";
// The WebPreferences.
const char kWebPreferences[] = "web-preferences";
// The factor of which page should be zoomed.
const char kZoomFactor[] = "zoom-factor";
// The menu bar is hidden unless "Alt" is pressed.
const char kAutoHideMenuBar[] = "auto-hide-menu-bar";
// Enable window to be resized larger than screen.
const char <API key>[] = "<API key>";
// Forces to use dark theme on Linux.
const char kDarkTheme[] = "dark-theme";
// Enable DirectWrite on Windows.
const char kDirectWrite[] = "direct-write";
// Enable plugins.
const char kEnablePlugins[] = "enable-plugins";
// Ppapi Flash path.
const char kPpapiFlashPath[] = "ppapi-flash-path";
// Ppapi Flash version.
const char kPpapiFlashVersion[] = "ppapi-flash-version";
// Instancd ID of guest WebContents.
const char kGuestInstanceID[] = "guest-instance-id";
// Script that will be loaded by guest WebContents before other scripts.
const char kPreloadScript[] = "preload";
// Like --preload, but the passed argument is an URL.
const char kPreloadUrl[] = "preload-url";
// Whether the window should be transparent.
const char kTransparent[] = "transparent";
// Window type hint.
const char kType[] = "type";
// Disable auto-hiding cursor.
const char <API key>[] = "<API key>";
// Use the OS X's standard window instead of the textured window.
const char kStandardWindow[] = "standard-window";
// Path to client certificate.
const char kClientCertificate[] = "client-certificate";
// Web runtime features.
const char <API key>[] = "<API key>";
const char <API key>[] = "<API key>";
const char <API key>[] = "<API key>";
const char kOverlayScrollbars[] = "overlay-scrollbars";
const char <API key>[] = "<API key>";
const char kSharedWorker[] = "shared-worker";
// Set page visiblity to always visible.
const char kPageVisibility[] = "page-visibility";
// Disable HTTP cache.
const char kDisableHttpCache[] = "disable-http-cache";
// Register schemes to standard.
const char <API key>[] = "<API key>";
// The browser process app model ID
const char kAppUserModelId[] = "app-user-model-id";
} // namespace switches
} // namespace atom |
// <auto-generated>
// This code was generated by a tool.
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// Tool: <API key>.exe
// This tool is located in the Windows 10 SDK and the Windows 10 AllJoyn
// Visual Studio Extension in the Visual Studio Gallery.
// The generated code should be packaged in a Windows 10 C++/CX Runtime
// Component which can be consumed in any UWP-supported language using
// APIs that are available in Windows.Devices.AllJoyn.
// Using <API key> - Invoke the following command with a valid
// Introspection XML file and a writable output directory:
// <API key> -i <INPUT XML FILE> -o <OUTPUT DIRECTORY>
// </auto-generated>
#include "pch.h"
using namespace concurrency;
using namespace Microsoft::WRL;
using namespace Platform;
using namespace Windows::Foundation;
using namespace Windows::Devices::AllJoyn;
using namespace net::allplay::MCU;
std::map<alljoyn_busobject, WeakReference*> MCUProducer::SourceObjects;
std::map<<API key>, WeakReference*> MCUProducer::SourceInterfaces;
MCUProducer::MCUProducer(<API key>^ busAttachment)
: m_busAttachment(busAttachment),
m_sessionListener(nullptr),
m_busObject(nullptr),
m_sessionPort(0),
m_sessionId(0)
{
m_weak = new WeakReference(this);
ServiceObjectPath = ref new String(L"/Service");
m_signals = ref new MCUSignals();
<API key>.Value = 0;
}
MCUProducer::~MCUProducer()
{
UnregisterFromBus();
delete m_weak;
}
void MCUProducer::UnregisterFromBus()
{
if ((nullptr != m_busAttachment) && (0 != <API key>.Value))
{
m_busAttachment->StateChanged -= <API key>;
<API key>.Value = 0;
}
if ((nullptr != m_busAttachment) && (nullptr != SessionPortListener))
{
<API key>(AllJoynHelpers::<API key>(m_busAttachment), m_sessionPort);
<API key>(SessionPortListener);
SessionPortListener = nullptr;
}
if ((nullptr != m_busAttachment) && (nullptr != BusObject))
{
<API key>(AllJoynHelpers::<API key>(m_busAttachment), BusObject);
<API key>(BusObject);
BusObject = nullptr;
}
if (nullptr != SessionListener)
{
<API key>(SessionListener);
SessionListener = nullptr;
}
}
bool MCUProducer::<API key>(_In_ alljoyn_sessionport sessionPort, _In_ PCSTR joiner, _In_ const alljoyn_sessionopts opts)
{
<API key>(sessionPort); <API key>(joiner); <API key>(opts);
return true;
}
void MCUProducer::OnSessionJoined(_In_ alljoyn_sessionport sessionPort, _In_ alljoyn_sessionid id, _In_ PCSTR joiner)
{
<API key>(joiner);
// We initialize the Signals object after the session has been joined, because it needs
// the session id.
m_signals->Initialize(BusObject, id);
m_sessionPort = sessionPort;
m_sessionId = id;
<API key> callbacks =
{
AllJoynHelpers::SessionLostHandler<MCUProducer>,
AllJoynHelpers::<API key><MCUProducer>,
AllJoynHelpers::<API key><MCUProducer>
};
SessionListener = <API key>(&callbacks, m_weak);
<API key>(AllJoynHelpers::<API key>(m_busAttachment), id, SessionListener);
}
void MCUProducer::OnSessionLost(_In_ alljoyn_sessionid sessionId, _In_ <API key> reason)
{
if (sessionId == m_sessionId)
{
<API key>^ args = ref new <API key>(static_cast<<API key>>(reason));
SessionLost(this, args);
}
}
void MCUProducer::<API key>(_In_ alljoyn_sessionid sessionId, _In_ PCSTR uniqueName)
{
if (sessionId == m_sessionId)
{
auto args = ref new <API key>(AllJoynHelpers::<API key>(uniqueName));
SessionMemberAdded(this, args);
}
}
void MCUProducer::<API key>(_In_ alljoyn_sessionid sessionId, _In_ PCSTR uniqueName)
{
if (sessionId == m_sessionId)
{
auto args = ref new <API key>(AllJoynHelpers::<API key>(uniqueName));
<API key>(this, args);
}
}
void MCUProducer::<API key>(_In_ <API key>^ sender, _In_ <API key>^ args)
{
if (args->State == <API key>::Connected)
{
QStatus result = AllJoynHelpers::<API key><MCUProducer>(m_busAttachment, m_weak);
if (ER_OK != result)
{
StopInternal(result);
return;
}
}
else if (args->State == <API key>::Disconnected)
{
StopInternal(ER_BUS_STOPPING);
}
}
void MCUProducer::<API key>(_Inout_ alljoyn_busobject busObject, _In_ alljoyn_message message)
{
auto source = SourceObjects.find(busObject);
if (source == SourceObjects.end())
{
return;
}
MCUProducer^ producer = source->second->Resolve<MCUProducer>();
if (producer->Service != nullptr)
{
AllJoynMessageInfo^ callInfo = ref new AllJoynMessageInfo(AllJoynHelpers::<API key>(<API key>(message)));
<API key>^ result = create_task(producer->Service-><API key>(callInfo)).get();
create_task([](){}).then([=]
{
int32 status;
if (nullptr == result)
{
<API key>(busObject, message, ER_BUS_NO_LISTENER);
return;
}
status = result->Status;
if (AllJoynStatus::Ok != status)
{
<API key>(busObject, message, static_cast<QStatus>(status));
return;
}
size_t argCount = 0;
alljoyn_msgarg outputs = <API key>(argCount);
<API key>(busObject, message, outputs, argCount);
<API key>(outputs);
}, result->m_creationContext).wait();
}
}
void MCUProducer::<API key>(_Inout_ alljoyn_busobject busObject, _In_ alljoyn_message message)
{
auto source = SourceObjects.find(busObject);
if (source == SourceObjects.end())
{
return;
}
MCUProducer^ producer = source->second->Resolve<MCUProducer>();
if (producer->Service != nullptr)
{
AllJoynMessageInfo^ callInfo = ref new AllJoynMessageInfo(AllJoynHelpers::<API key>(<API key>(message)));
<API key>^ result = create_task(producer->Service-><API key>(callInfo)).get();
create_task([](){}).then([=]
{
int32 status;
if (nullptr == result)
{
<API key>(busObject, message, ER_BUS_NO_LISTENER);
return;
}
status = result->Status;
if (AllJoynStatus::Ok != status)
{
<API key>(busObject, message, static_cast<QStatus>(status));
return;
}
size_t argCount = 1;
alljoyn_msgarg outputs = <API key>(argCount);
status = <API key>::<API key>(<API key>(outputs, 0), "s", result->Url);
if (AllJoynStatus::Ok != status)
{
<API key>(busObject, message, static_cast<QStatus>(status));
<API key>(outputs);
return;
}
<API key>(busObject, message, outputs, argCount);
<API key>(outputs);
}, result->m_creationContext).wait();
}
}
void MCUProducer::CallPlayItemHandler(_Inout_ alljoyn_busobject busObject, _In_ alljoyn_message message)
{
auto source = SourceObjects.find(busObject);
if (source == SourceObjects.end())
{
return;
}
MCUProducer^ producer = source->second->Resolve<MCUProducer>();
if (producer->Service != nullptr)
{
AllJoynMessageInfo^ callInfo = ref new AllJoynMessageInfo(AllJoynHelpers::<API key>(<API key>(message)));
Platform::String^ inputArg0;
(void)<API key>::<API key>(<API key>(message, 0), "s", &inputArg0);
Platform::String^ inputArg1;
(void)<API key>::<API key>(<API key>(message, 1), "s", &inputArg1);
Platform::String^ inputArg2;
(void)<API key>::<API key>(<API key>(message, 2), "s", &inputArg2);
Platform::String^ inputArg3;
(void)<API key>::<API key>(<API key>(message, 3), "s", &inputArg3);
int64 inputArg4;
(void)<API key>::<API key>(<API key>(message, 4), "x", &inputArg4);
Platform::String^ inputArg5;
(void)<API key>::<API key>(<API key>(message, 5), "s", &inputArg5);
Platform::String^ inputArg6;
(void)<API key>::<API key>(<API key>(message, 6), "s", &inputArg6);
MCUPlayItemResult^ result = create_task(producer->Service->PlayItemAsync(callInfo, inputArg0, inputArg1, inputArg2, inputArg3, inputArg4, inputArg5, inputArg6)).get();
create_task([](){}).then([=]
{
int32 status;
if (nullptr == result)
{
<API key>(busObject, message, ER_BUS_NO_LISTENER);
return;
}
status = result->Status;
if (AllJoynStatus::Ok != status)
{
<API key>(busObject, message, static_cast<QStatus>(status));
return;
}
size_t argCount = 0;
alljoyn_msgarg outputs = <API key>(argCount);
<API key>(busObject, message, outputs, argCount);
<API key>(outputs);
}, result->m_creationContext).wait();
}
}
void MCUProducer::<API key>(_Inout_ alljoyn_busobject busObject, _In_ alljoyn_message message)
{
auto source = SourceObjects.find(busObject);
if (source == SourceObjects.end())
{
return;
}
MCUProducer^ producer = source->second->Resolve<MCUProducer>();
if (producer->Service != nullptr)
{
AllJoynMessageInfo^ callInfo = ref new AllJoynMessageInfo(AllJoynHelpers::<API key>(<API key>(message)));
Platform::String^ inputArg0;
(void)<API key>::<API key>(<API key>(message, 0), "s", &inputArg0);
bool inputArg1;
(void)<API key>::<API key>(<API key>(message, 1), "b", &inputArg1);
bool inputArg2;
(void)<API key>::<API key>(<API key>(message, 2), "b", &inputArg2);
<API key>^ result = create_task(producer->Service-><API key>(callInfo, inputArg0, inputArg1, inputArg2)).get();
create_task([](){}).then([=]
{
int32 status;
if (nullptr == result)
{
<API key>(busObject, message, ER_BUS_NO_LISTENER);
return;
}
status = result->Status;
if (AllJoynStatus::Ok != status)
{
<API key>(busObject, message, static_cast<QStatus>(status));
return;
}
size_t argCount = 0;
alljoyn_msgarg outputs = <API key>(argCount);
<API key>(busObject, message, outputs, argCount);
<API key>(outputs);
}, result->m_creationContext).wait();
}
}
void MCUProducer::<API key>(_Inout_ alljoyn_busobject busObject, _In_ alljoyn_message message)
{
auto source = SourceObjects.find(busObject);
if (source == SourceObjects.end())
{
return;
}
MCUProducer^ producer = source->second->Resolve<MCUProducer>();
if (producer->Service != nullptr)
{
AllJoynMessageInfo^ callInfo = ref new AllJoynMessageInfo(AllJoynHelpers::<API key>(<API key>(message)));
<API key>^ result = create_task(producer->Service-><API key>(callInfo)).get();
create_task([](){}).then([=]
{
int32 status;
if (nullptr == result)
{
<API key>(busObject, message, ER_BUS_NO_LISTENER);
return;
}
status = result->Status;
if (AllJoynStatus::Ok != status)
{
<API key>(busObject, message, static_cast<QStatus>(status));
return;
}
size_t argCount = 0;
alljoyn_msgarg outputs = <API key>(argCount);
<API key>(busObject, message, outputs, argCount);
<API key>(outputs);
}, result->m_creationContext).wait();
}
}
QStatus MCUProducer::AddMethodHandler(_In_ <API key> <API key>, _In_ PCSTR methodName, _In_ <API key> handler)
{
<API key> member;
if (!<API key>(<API key>, methodName, &member))
{
return <API key>;
}
return <API key>(
m_busObject,
member,
handler,
m_weak);
}
QStatus MCUProducer::AddSignalHandler(_In_ <API key> busAttachment, _In_ <API key> <API key>, _In_ PCSTR methodName, _In_ <API key> handler)
{
<API key> member;
if (!<API key>(<API key>, methodName, &member))
{
return <API key>;
}
return <API key>(busAttachment, handler, member, NULL);
}
QStatus MCUProducer::OnPropertyGet(_In_ PCSTR interfaceName, _In_ PCSTR propertyName, _Inout_ alljoyn_msgarg value)
{
<API key>(interfaceName);
if (0 == strcmp(propertyName, "Version"))
{
auto task = create_task(Service->GetVersionAsync(nullptr));
auto result = task.get();
return create_task([](){}).then([=]() -> QStatus
{
if (AllJoynStatus::Ok != result->Status)
{
return static_cast<QStatus>(result->Status);
}
return static_cast<QStatus>(<API key>::<API key>(value, "q", result->Version));
}, result->m_creationContext).get();
}
return <API key>;
}
QStatus MCUProducer::OnPropertySet(_In_ PCSTR interfaceName, _In_ PCSTR propertyName, _In_ alljoyn_msgarg value)
{
<API key>(interfaceName);
return <API key>;
}
void MCUProducer::Start()
{
if (nullptr == m_busAttachment)
{
StopInternal(ER_FAIL);
return;
}
QStatus result = AllJoynHelpers::CreateInterfaces(m_busAttachment, <API key>);
if (result != ER_OK)
{
StopInternal(result);
return;
}
result = AllJoynHelpers::CreateBusObject<MCUProducer>(m_weak);
if (result != ER_OK)
{
StopInternal(result);
return;
}
<API key> <API key> = <API key>(AllJoynHelpers::<API key>(m_busAttachment), "net.allplay.MCU");
if (<API key> == nullptr)
{
StopInternal(ER_FAIL);
return;
}
<API key>(BusObject, <API key>);
result = AddMethodHandler(
<API key>,
"AdvanceLoopMode",
[](alljoyn_busobject busObject, const <API key>* member, alljoyn_message message) { <API key>(member); <API key>(busObject, message); });
if (result != ER_OK)
{
StopInternal(result);
return;
}
result = AddMethodHandler(
<API key>,
"GetCurrentItemUrl",
[](alljoyn_busobject busObject, const <API key>* member, alljoyn_message message) { <API key>(member); <API key>(busObject, message); });
if (result != ER_OK)
{
StopInternal(result);
return;
}
result = AddMethodHandler(
<API key>,
"PlayItem",
[](alljoyn_busobject busObject, const <API key>* member, alljoyn_message message) { <API key>(member); CallPlayItemHandler(busObject, message); });
if (result != ER_OK)
{
StopInternal(result);
return;
}
result = AddMethodHandler(
<API key>,
"SetExternalSource",
[](alljoyn_busobject busObject, const <API key>* member, alljoyn_message message) { <API key>(member); <API key>(busObject, message); });
if (result != ER_OK)
{
StopInternal(result);
return;
}
result = AddMethodHandler(
<API key>,
"ToggleShuffleMode",
[](alljoyn_busobject busObject, const <API key>* member, alljoyn_message message) { <API key>(member); <API key>(busObject, message); });
if (result != ER_OK)
{
StopInternal(result);
return;
}
SourceObjects[m_busObject] = m_weak;
SourceInterfaces[<API key>] = m_weak;
unsigned int noneMechanismIndex = 0;
bool <API key> = m_busAttachment-><API key>>IndexOf(AllJoyn<API key>::None, &noneMechanismIndex);
QCC_BOOL interfaceIsSecure = <API key>(<API key>);
// If the current set of <API key> supports authentication,
// determine whether a secure BusObject is required.
if (AllJoynHelpers::CanSecure(m_busAttachment-><API key>))
{
// Register the BusObject as "secure" if the org.alljoyn.Bus.Secure XML annotation
// is specified, or if None is not present in <API key>.
if (!<API key> || interfaceIsSecure)
{
result = <API key>(AllJoynHelpers::<API key>(m_busAttachment), BusObject);
}
else
{
result = <API key>(AllJoynHelpers::<API key>(m_busAttachment), BusObject);
}
}
else
{
// If the current set of <API key> does not support authentication
// but the interface requires security, report an error.
if (interfaceIsSecure)
{
result = ER_BUS_NO_<API key>;
}
else
{
result = <API key>(AllJoynHelpers::<API key>(m_busAttachment), BusObject);
}
}
if (result != ER_OK)
{
StopInternal(result);
return;
}
<API key><API key>>StateChanged += ref new TypedEventHandler<<API key>^,<API key>^>(this, &MCUProducer::<API key>);
m_busAttachment->Connect();
}
void MCUProducer::Stop()
{
StopInternal(AllJoynStatus::Ok);
}
void MCUProducer::StopInternal(int32 status)
{
UnregisterFromBus();
Stopped(this, ref new <API key>(status));
}
int32 MCUProducer::<API key>(_In_ String^ uniqueName)
{
return <API key>(
AllJoynHelpers::<API key>(m_busAttachment),
m_sessionId,
AllJoynHelpers::<API key>(uniqueName).data());
}
PCSTR net::allplay::MCU::<API key> = "<interface name=\"net.allplay.MCU\">"
" <method name=\"AdvanceLoopMode\"></method>"
" <method name=\"GetCurrentItemUrl\">"
" <arg name=\"url\" type=\"s\" direction=\"out\" />"
" </method>"
" <method name=\"PlayItem\">"
" <arg name=\"url\" type=\"s\" direction=\"in\" />"
" <arg name=\"title\" type=\"s\" direction=\"in\" />"
" <arg name=\"artist\" type=\"s\" direction=\"in\" />"
" <arg name=\"thumbnailUrl\" type=\"s\" direction=\"in\" />"
" <arg name=\"duration\" type=\"x\" direction=\"in\" />"
" <arg name=\"album\" type=\"s\" direction=\"in\" />"
" <arg name=\"genre\" type=\"s\" direction=\"in\" />"
" </method>"
" <method name=\"SetExternalSource\">"
" <arg name=\"name\" type=\"s\" direction=\"in\" />"
" <arg name=\"interruptible\" type=\"b\" direction=\"in\" />"
" <arg name=\"volumeCtrlEnabled\" type=\"b\" direction=\"in\" />"
" </method>"
" <method name=\"ToggleShuffleMode\"></method>"
" <property name=\"Version\" type=\"q\" access=\"read\" />"
"</interface>"
; |
package com.sun.tools.internal.ws.wsdl.framework;
/**
* An interface implemented by entities which have an ID.
*
* @author WS Development Team
*/
public interface Identifiable extends Elemental {
public String getID();
} |
/* Function formal arguments do not accept reserved words.
*
* We interpret this also to mean that a function declaration/expression
* in non-strict code will respect strict mode restricted reserved words
* if the function body is strict. This matches with V8.
*/
var orig_eval = eval;
try {
// Keyword
eval("function foo(for) {};");
print('never here');
} catch (e) {
print(e.name);
}
try {
// FutureReservedWord
eval("function foo(class) {};");
print('never here');
} catch (e) {
print(e.name);
}
try {
// FutureReservedWord only recognized in strict mode
// -> should work
eval("function foo(implements) { print(implements) }; foo('success');");
} catch (e) {
print(e.name);
}
try {
// FutureReservedWord only recognized in strict mode,
// function declared in non-strict mode but function
// itself is strict
eval("function foo(implements) { 'use strict'; };");
print('never here');
} catch (e) {
print(e.name);
}
/* Function expressions */
try {
eval("(function foo(for) {})();");
print('never here');
} catch (e) {
print(e.name);
}
try {
eval("(function foo(class) {})();");
print('never here');
} catch (e) {
print(e.name);
}
try {
eval("(function foo(implements) { print(implements) })('success');");
} catch (e) {
print(e.name);
}
try {
eval("(function foo(implements) { 'use strict'; })();");
print('never here');
} catch (e) {
print(e.name);
}
/* Eval and arguments */
try {
eval("function foo(eval) { print(eval); }; foo('success');");
} catch (e) {
print(e.name);
}
try {
eval("function foo(eval) { 'use strict'; print(eval); }; foo('success');");
print('never here');
} catch (e) {
print(e.name);
}
try {
eval("function foo(arguments) { print(arguments); }; foo('success');");
} catch (e) {
print(e.name);
}
try {
eval("function foo(arguments) { 'use strict'; print(arguments); }; foo('success');");
print('never here');
} catch (e) {
print(e.name);
}
/* Eval and arguments, function expressions */
try {
eval("(function foo(eval) { print(eval); })('success');");
} catch (e) {
print(e.name);
}
try {
eval("(function foo(eval) { 'use strict'; print(eval); })('success');");
print('never here');
} catch (e) {
print(e.name);
}
try {
eval("(function foo(arguments) { print(arguments); })('success');");
} catch (e) {
print(e.name);
}
try {
eval("(function foo(arguments) { 'use strict'; print(arguments); })foo('success');");
print('never here');
} catch (e) {
print(e.name);
}
/* Duplicate argument names */
try {
// ok, binds to latter
eval("function foo(a,a) { print(a); }; foo(1,2);");
} catch (e) {
print(e.name);
}
try {
eval("function foo(a,a) { 'use strict'; print(a); }; foo(1,2);");
print('never here');
} catch (e) {
print(e.name);
}
/* Duplicate argument names, function expressions */
try {
// ok, binds to latter
eval("(function foo(a,a) { print(a); })(1,2);");
} catch (e) {
print(e.name);
}
try {
eval("(function foo(a,a) { 'use strict'; print(a); })(1,2);");
print('never here');
} catch (e) {
print(e.name);
} |
<?php
namespace Symfony\Bundle\FrameworkBundle\Tests\Command;
use Symfony\Bundle\FrameworkBundle\Command\<API key>;
use Symfony\Bundle\FrameworkBundle\Console\Application;
use Symfony\Bundle\FrameworkBundle\Tests\TestCase;
use Symfony\Component\Cache\PruneableInterface;
use Symfony\Component\Console\Tester\CommandTester;
use Symfony\Component\DependencyInjection\Argument\RewindableGenerator;
use Symfony\Component\HttpKernel\KernelInterface;
class <API key> extends TestCase
{
public function <API key>()
{
$tester = $this->getCommandTester($this->getKernel(), $this-><API key>());
$tester->execute(array());
}
public function <API key>()
{
$tester = $this->getCommandTester($this->getKernel(), $this-><API key>());
$tester->execute(array());
}
private function <API key>(): RewindableGenerator
{
return new RewindableGenerator(function () {
yield 'foo_pool' => $this-><API key>();
yield 'bar_pool' => $this-><API key>();
}, 2);
}
private function <API key>(): RewindableGenerator
{
return new RewindableGenerator(function () {
return new \ArrayIterator(array());
}, 0);
}
/**
* @return \<API key>|KernelInterface
*/
private function getKernel()
{
$container = $this
->getMockBuilder('Symfony\Component\DependencyInjection\ContainerInterface')
->getMock();
$kernel = $this
->getMockBuilder(KernelInterface::class)
->getMock();
$kernel
->expects($this->any())
->method('getContainer')
->willReturn($container);
$kernel
->expects($this->once())
->method('getBundles')
->willReturn(array());
return $kernel;
}
/**
* @return \<API key>|PruneableInterface
*/
private function <API key>()
{
$pruneable = $this
->getMockBuilder(PruneableInterface::class)
->getMock();
$pruneable
->expects($this->atLeastOnce())
->method('prune');
return $pruneable;
}
private function getCommandTester(KernelInterface $kernel, RewindableGenerator $generator): CommandTester
{
$application = new Application($kernel);
$application->add(new <API key>($generator));
return new CommandTester($application->find('cache:pool:prune'));
}
} |
<?php
namespace Drupal\bootstrap\Plugin\Setting\General\Forms;
use Drupal\bootstrap\Plugin\Setting\SettingBase;
/**
* The "<API key>" theme setting.
*
* @ingroup plugins_setting
*
* @BootstrapSetting(
* id = "<API key>",
* type = "checkbox",
* title = @Translation("Automatically remove error classes when values have been entered"),
* description = @Translation("If an element has a <code>.has-error</code> class attached to it, enabling this will automatically remove that class when a value is entered."),
* defaultValue = 1,
* groups = {
* "general" = @Translation("General"),
* "forms" = @Translation("Forms"),
* },
* )
*/
class <API key> extends SettingBase {
/**
* {@inheritdoc}
*/
public function drupalSettings() {
return TRUE;
}
} |
var TAG_LABEL = 1;
var <API key> = 1;
var TAG_ANIMATION1 = 1;
var TAG_BITMAP_ATLAS1 = 1;
var TAG_BITMAP_ATLAS2 = 2;
var TAG_BITMAP_ATLAS3 = 3;
var TAG_LABEL_SPRITE1 = 660;
var TAG_LABEL_SPRITE12 = 661;
var TAG_LABEL_SPRITE13 = 662;
var TAG_LABEL_SPRITE14 = 663;
var TAG_LABEL_SPRITE15 = 664;
var TAG_LABEL_SPRITE16 = 665;
var TAG_LABEL_SPRITE17 = 666;
var TAG_LABEL_SPRITE18 = 667;
var labelTestIdx = -1;
var LabelTestScene = TestScene.extend({
runThisTest:function (num) {
labelTestIdx = (num || num == 0) ? (num - 1) : -1;
this.addChild(nextLabelTest());
director.runScene(this);
}
});
var AtlasDemo = BaseTestLayer.extend({
title:function () {
return "No title";
},
subtitle:function () {
return "";
},
onRestartCallback:function (sender) {
var s = new LabelTestScene();
s.addChild(restartLabelTest());
director.runScene(s);
},
onNextCallback:function (sender) {
var s = new LabelTestScene();
s.addChild(nextLabelTest());
director.runScene(s);
},
onBackCallback:function (sender) {
var s = new LabelTestScene();
s.addChild(previousLabelTest());
director.runScene(s);
},
// automation
<API key>:function() {
return ( (arrayOfLabelTest.length-1) - labelTestIdx );
},
getTestNumber:function() {
return labelTestIdx;
}
});
// <API key>
var <API key> = AtlasDemo.extend({
time:null,
ctor:function () {
this._super();
this.time = 0;
var label1 = new cc.LabelAtlas("123 Test", s_resprefix + "fonts/<API key>.plist");
this.addChild(label1, 0, TAG_LABEL_SPRITE1);
label1.x = 10;
label1.y = 100;
label1.opacity = 200;
var label2 = new cc.LabelAtlas("0123456789", s_resprefix + "fonts/<API key>.plist");
this.addChild(label2, 0, TAG_LABEL_SPRITE12);
label2.x = 10;
label2.y = 200;
label2.opacity = 32;
this.schedule(this.step);
},
step:function (dt) {
this.time += dt;
var label1 = this.getChildByTag(TAG_LABEL_SPRITE1);
var string1 = this.time.toFixed(2) + " Test";
label1.setString(string1);
var label2 = this.getChildByTag(TAG_LABEL_SPRITE12);
var string2 = parseInt(this.time, 10).toString();
label2.setString(string2);
},
title:function () {
return "LabelAtlas Opacity";
},
subtitle:function () {
return "Updating label should be fast";
},
// Automation
getExpectedResult:function() {
// yellow, red, green, blue, yellow
var ret = [200,32];
return JSON.stringify(ret);
},
getCurrentResult:function() {
var ret = [];
var tags = [TAG_LABEL_SPRITE1, TAG_LABEL_SPRITE12];
for( var i in tags ) {
var t = tags[i];
ret.push( this.getChildByTag(t).opacity );
}
return JSON.stringify(ret);
}
});
// <API key>
var <API key> = AtlasDemo.extend({
time:null,
ctor:function () {
this._super();
var label1 = new cc.LabelAtlas("123 Test", s_resprefix + "fonts/<API key>.png", 48, 64, ' ');
this.addChild(label1, 0, TAG_LABEL_SPRITE1);
label1.x = 10;
label1.y = 100;
label1.opacity = 200;
var label2 = new cc.LabelAtlas("0123456789", s_resprefix + "fonts/<API key>.png", 48, 64, ' ');
this.addChild(label2, 0, TAG_LABEL_SPRITE12);
label2.x = 10;
label2.y = 200;
label2.color = cc.color(255, 0, 0);
var fade = cc.fadeOut(1.0);
var fade_in = fade.reverse();
var delay = cc.delayTime(0.25);
var seq = cc.sequence(fade, delay, fade_in, delay.clone());
var repeat = seq.repeatForever();
label2.runAction(repeat);
this.time = 0;
this.schedule(this.step);
},
step:function (dt) {
this.time += dt;
var string1 = this.time.toFixed(2) + " Test";
var label1 = this.getChildByTag(TAG_LABEL_SPRITE1);
label1.setString(string1);
var label2 = this.getChildByTag(TAG_LABEL_SPRITE12);
var string2 = parseInt(this.time, 10).toString();
label2.setString(string2);
},
title:function () {
return "LabelAtlas Opacity Color";
},
subtitle:function () {
return "Opacity + Color should work at the same time";
},
// Automation
testDuration:1,
getExpectedResult:function() {
// yellow, red, green, blue, yellow
var ret = [200,{"r":255,"g":255,"b":255},0,{"r":255,"g":0,"b":0}];
return JSON.stringify(ret);
},
getCurrentResult:function() {
var ret = [];
var tags = [TAG_LABEL_SPRITE1, TAG_LABEL_SPRITE12];
for( var i in tags ) {
var t = tags[i];
ret.push( this.getChildByTag(t).opacity );
ret.push( this.getChildByTag(t).color );
}
return JSON.stringify(ret);
}
});
// LabelAtlasHD
var LabelAtlasHD = AtlasDemo.extend({
ctor:function () {
this._super();
var s = director.getWinSize();
// cc.LabelBMFont
var label1 = new cc.LabelAtlas("TESTING RETINA DISPLAY", s_resprefix + "fonts/larabie-16.plist");
label1.anchorX = 0.5;
label1.anchorY = 0.5;
this.addChild(label1);
label1.x = s.width / 2;
label1.y = s.height / 2;
},
title:function () {
return "LabelAtlas with Retina Display";
},
subtitle:function () {
return "loading larabie-16 / larabie-16-hd";
},
// Automation
pixel: {"0": 255, "1": 255, "2": 255, "3": 255},
getExpectedResult:function() {
// var ret = [{"0":0,"1":0,"2":226,"3":255},{"0":47,"1":0,"2":0,"3":255},{"0":0,"1":47,"2":0,"3":255}];
var s = director.getWinSize();
var ret = {"center": "yes"};
return JSON.stringify(ret);
},
getCurrentResult:function() {
var s = director.getWinSize();
var ret2 = this.readPixels(s.width/2, s.height/2, 100, 100);
var ret = {"center": this.containsPixel(ret2, this.pixel) ? "yes" : "no"};
return JSON.stringify(ret);
}
});
// <API key>
var <API key> = AtlasDemo.extend({
time:0,
ctor:function () {
this._super();
var col = new cc.LayerColor(cc.color(128, 128, 128, 255));
this.addChild(col, -10);
var label1 = new cc.LabelBMFont("Test", s_resprefix + "fonts/bitmapFontTest2.fnt");
// testing anchors
label1.anchorX = 0;
label1.anchorY = 0;
this.addChild(label1, 0, TAG_BITMAP_ATLAS1);
var fade = cc.fadeOut(1.0);
var fade_in = fade.reverse();
var seq = cc.sequence(fade, cc.delayTime(0.25), fade_in);
var repeat = seq.repeatForever();
label1.runAction(repeat);
// VERY IMPORTANT
// color and opacity work OK because bitmapFontAltas2 loads a BMP image (not a PNG image)
// If you want to use both opacity and color, it is recommended to use NON premultiplied images like BMP images
// Of course, you can also tell XCode not to compress PNG images, but I think it doesn't work as expected
var label2 = new cc.LabelBMFont("Test", s_resprefix + "fonts/bitmapFontTest2.fnt");
// testing anchors
label2.anchorX = 0.5;
label2.anchorY = 0.5;
label2.color = cc.color.RED ;
this.addChild(label2, 0, TAG_BITMAP_ATLAS2);
label2.runAction(repeat.clone());
var label3 = new cc.LabelBMFont("Test", s_resprefix + "fonts/bitmapFontTest2.fnt");
// testing anchors
label3.anchorX = 1;
label3.anchorY = 1;
this.addChild(label3, 0, TAG_BITMAP_ATLAS3);
var s = director.getWinSize();
label1.x = 0;
label1.y = 0;
label2.x = s.width / 2;
label2.y = s.height / 2;
label3.x = s.width;
label3.y = s.height;
this.schedule(this.step);
},
step:function (dt) {
this.time += dt;
//var string;
var string = this.time.toFixed(2) + "Test j";
var label1 = this.getChildByTag(TAG_BITMAP_ATLAS1);
label1.setString(string);
var label2 = this.getChildByTag(TAG_BITMAP_ATLAS2);
label2.setString(string);
var label3 = this.getChildByTag(TAG_BITMAP_ATLAS3);
label3.setString(string);
},
title:function () {
return "cc.LabelBMFont";
},
subtitle:function () {
return "Testing alignment. Testing opacity + tint";
},
// Automation
testDuration:1.1,
getExpectedResult:function() {
// yellow, red, green, blue, yellow
var ret = [0,{"r":255,"g":255,"b":255},0,{"r":255,"g":0,"b":0}];
return JSON.stringify(ret);
},
getCurrentResult:function() {
var ret = [];
var tags = [TAG_BITMAP_ATLAS1, TAG_BITMAP_ATLAS2];
for( var i in tags ) {
var t = tags[i];
ret.push( this.getChildByTag(t).opacity );
ret.push( this.getChildByTag(t).color );
}
return JSON.stringify(ret);
}
});
// BMFontSubSpriteTest
var BMFontSubSpriteTest = AtlasDemo.extend({
time:null,
ctor:function () {
this._super();
this.time = 0;
var s = director.getWinSize();
var drawNode = new cc.DrawNode();
this.addChild(drawNode);
drawNode.setDrawColor(cc.color(255,0,0,128));
drawNode.drawSegment(cc.p(0, s.height / 2), cc.p(s.width, s.height / 2), 2);
drawNode.drawSegment(cc.p(s.width / 2, 0), cc.p(s.width / 2, s.height), 2);
// Upper Label
var label = new cc.LabelBMFont("Bitmap Font Atlas", s_resprefix + "fonts/bitmapFontTest.fnt");
this.labelObj = label;
this.addChild(label);
label.x = s.width / 2;
label.y = s.height / 2;
label.anchorX = 0.5;
label.anchorY = 0.5;
var BChar = label.getChildByTag(0);
var FChar = label.getChildByTag(7);
var AChar = label.getChildByTag(12);
if(autoTestEnabled) {
var jump = cc.jumpBy(0.5, cc.p(0,0), 60, 1);
var jump_4ever = cc.sequence(jump, cc.delayTime(0.25)).repeatForever();
var fade_out = cc.fadeOut(0.5);
var rotate = cc.rotateBy(0.5, 180);
var rot_4ever = cc.sequence(rotate, cc.delayTime(0.25), rotate.clone()).repeatForever();
var scale = cc.scaleBy(0.5, 1.5);
} else {
var jump = cc.jumpBy(4, cc.p(0,0), 60, 1);
var jump_4ever = jump.repeatForever();
var fade_out = cc.fadeOut(1);
var rotate = cc.rotateBy(2, 360);
var rot_4ever = rotate.repeatForever();
var scale = cc.scaleBy(2, 1.5);
}
var scale_back = scale.reverse();
var scale_seq = cc.sequence(scale, cc.delayTime(0.25), scale_back);
var scale_4ever = scale_seq.repeatForever();
var fade_in = cc.fadeIn(1);
var seq = cc.sequence(fade_out, cc.delayTime(0.25), fade_in);
var fade_4ever = seq.repeatForever();
BChar.runAction(rot_4ever);
BChar.runAction(scale_4ever);
FChar.runAction(jump_4ever);
AChar.runAction(fade_4ever);
// Bottom Label
var label2 = new cc.LabelBMFont("00.0", s_resprefix + "fonts/bitmapFontTest.fnt");
this.addChild(label2, 0, TAG_BITMAP_ATLAS2);
label2.x = s.width / 2.0;
label2.y = 80;
var lastChar = label2.getChildByTag(3);
lastChar.runAction(rot_4ever.clone());
this.schedule(this.step, 0.1);
},
step:function (dt) {
this.time += dt;
var string = this.time.toFixed(1);
string = (string < 10) ? "0" + string : string;
var label1 = this.getChildByTag(TAG_BITMAP_ATLAS2);
label1.setString(string);
},
title:function () {
return "cc.LabelBMFont BMFontSubSpriteTest";
},
subtitle:function () {
return "Using fonts as cc.Sprite objects. Some characters should rotate.";
},
// Automation
testDuration:0.6,
getExpectedResult:function() {
// yellow, red, green, blue, yellow
var ret = {"rotate": 180, "scale": 1.5, "opacity": 0};
return JSON.stringify(ret);
},
getCurrentResult:function() {
var s = this.labelObj.getChildByTag(0).scale;
var r = this.labelObj.getChildByTag(0).rotation;
var o = this.labelObj.getChildByTag(12).opacity;
var ret = {"rotate": r, "scale": s, "opacity": o};
return JSON.stringify(ret);
}
});
// BMFontPaddingTest
var BMFontPaddingTest = AtlasDemo.extend({
ctor:function () {
this._super();
var label = new cc.LabelBMFont("abcdefg", s_resprefix + "fonts/bitmapFontTest4.fnt");
this.addChild(label);
var s = director.getWinSize();
label.x = s.width / 2;
label.y = s.height / 2;
label.anchorX = 0.5;
label.anchorY = 0.5;
},
title:function () {
return "cc.LabelBMFont BMFontPaddingTest";
},
subtitle:function () {
return "Testing padding";
},
// Automation
pixel: {"0": 255, "1": 255, "2": 255, "3": 255},
getExpectedResult:function() {
// var ret = [{"0":0,"1":0,"2":226,"3":255},{"0":47,"1":0,"2":0,"3":255},{"0":0,"1":47,"2":0,"3":255}];
var s = director.getWinSize();
var ret = {"center": "yes"};
return JSON.stringify(ret);
},
getCurrentResult:function() {
var s = director.getWinSize();
var ret2 = this.readPixels(s.width/2, s.height/2, 100, 100);
var ret = {"center": this.containsPixel(ret2, this.pixel) ? "yes" : "no"};
return JSON.stringify(ret);
}
});
// BMFontOffsetTest
var BMFontOffsetTest = AtlasDemo.extend({
ctor:function () {
this._super();
var s = director.getWinSize();
var label = null;
label = new cc.LabelBMFont("FaFeFiFoFu", s_resprefix + "fonts/bitmapFontTest5.fnt");
this.addChild(label);
label.x = s.width / 2;
label.y = s.height / 2 + 50;
label.anchorX = 0.5;
label.anchorY = 0.5;
label = new cc.LabelBMFont("fafefifofu", s_resprefix + "fonts/bitmapFontTest5.fnt");
this.addChild(label);
label.x = s.width / 2;
label.y = s.height / 2;
label.anchorX = 0.5;
label.anchorY = 0.5;
label = new cc.LabelBMFont("aeiou", s_resprefix + "fonts/bitmapFontTest5.fnt");
this.addChild(label);
label.x = s.width / 2;
label.y = s.height / 2 - 50;
label.anchorX = 0.5;
label.anchorY = 0.5;
},
title:function () {
return "cc.LabelBMFont";
},
subtitle:function () {
return "Rendering should be OK. Testing offset";
},
// Automation
pixel: {"0":150,"1":150,"2":150,"3":255},
getExpectedResult:function() {
var ret = {"top": "yes", "center": "yes", "bottom": "yes"};
return JSON.stringify(ret);
},
getCurrentResult:function() {
var s = director.getWinSize();
var ret1 = this.readPixels(s.width/2, s.height/2-50, 50, 50);
var ret2 = this.readPixels(s.width/2, s.height/2, 50, 50);
var ret3 = this.readPixels(s.width/2, s.height/2+50, 50, 50);
var ret = {"top": this.containsPixel(ret1, this.pixel, true, 140) ? "yes" : "no",
"center": this.containsPixel(ret2, this.pixel, true, 140) ? "yes" : "no",
"bottom": this.containsPixel(ret3, this.pixel, true, 140) ? "yes" : "no"};
return JSON.stringify(ret);
}
});
// BMFontTintTest
var BMFontTintTest = AtlasDemo.extend({
ctor:function () {
this._super();
var s = director.getWinSize();
var label = null;
label = new cc.LabelBMFont("Blue", s_resprefix + "fonts/bitmapFontTest5.fnt");
label.color = cc.color(0, 0, 255);
this.addChild(label);
label.x = s.width / 2;
label.y = s.height / 4;
label.anchorX = 0.5;
label.anchorY = 0.5;
label = new cc.LabelBMFont("Red", s_resprefix + "fonts/bitmapFontTest5.fnt");
this.addChild(label);
label.x = s.width / 2;
label.y = 2 * s.height / 4;
label.anchorX = 0.5;
label.anchorY = 0.5;
label.color = cc.color(255, 0, 0);
label = new cc.LabelBMFont("G", s_resprefix + "fonts/bitmapFontTest5.fnt");
this.addChild(label);
label.x = s.width / 2;
label.y = 3 * s.height / 4;
label.anchorX = 0.5;
label.anchorY = 0.5;
label.color = cc.color(0, 255, 0);
label.setString("Green");
},
title:function () {
return "cc.LabelBMFont BMFontTintTest";
},
subtitle:function () {
return "Testing color";
},
// Automation
pixel1: {"0":0,"1":0,"2":255,"3":255},
pixel2: {"0":255,"1":0,"2":0,"3":255},
pixel3: {"0":0,"1":255,"2":0,"3":255},
getExpectedResult:function() {
var ret = {"left": "yes", "center": "yes", "right": "yes"};
return JSON.stringify(ret);
},
getCurrentResult:function() {
var s = director.getWinSize();
var ret1 = this.readPixels(s.width/2, s.height/4, 50, 50);
var ret2 = this.readPixels(s.width/2, 2 * s.height/4, 50, 50);
var ret3 = this.readPixels(s.width/2, 3 * s.height/4, 50, 50);
var ret = {"left": this.containsPixel(ret1, this.pixel1, true, 100) ? "yes" : "no",
"center": this.containsPixel(ret2, this.pixel2, true, 100) ? "yes" : "no",
"right": this.containsPixel(ret3, this.pixel3, true, 100) ? "yes" : "no"}
return JSON.stringify(ret);
}
});
// BMFontSpeedTest
var BMFontSpeedTest = AtlasDemo.extend({
ctor:function () {
this._super();
// Upper Label
for (var i = 0; i < 100; i++) {
var str = "-" + i + "-";
var label = new cc.LabelBMFont(str, s_resprefix + "fonts/bitmapFontTest.fnt");
this.addChild(label);
var s = director.getWinSize();
var p = cc.p(Math.random() * s.width, Math.random() * s.height);
label.setPosition(p);
label.anchorX = 0.5;
label.anchorY = 0.5;
}
},
title:function () {
return "cc.LabelBMFont";
},
subtitle:function () {
return "Creating several cc.LabelBMFont with the same .fnt file should be fast";
}
});
// BMFontMultiLineTest
var BMFontMultiLineTest = AtlasDemo.extend({
ctor:function () {
this._super();
// Left
var label1 = new cc.LabelBMFont("Multi line\nLeft", s_resprefix + "fonts/bitmapFontTest3.fnt");
label1.anchorX = 0;
label1.anchorY = 0;
this.addChild(label1, 0, TAG_BITMAP_ATLAS1);
cc.log("content size:" + label1.width + "," + label1.height);
// Center
var label2 = new cc.LabelBMFont("Multi line\nCenter", s_resprefix + "fonts/bitmapFontTest3.fnt");
label2.anchorX = 0.5;
label2.anchorY = 0.5;
this.addChild(label2, 0, TAG_BITMAP_ATLAS2);
cc.log("content size:" + label2.width + "," + label2.height);
// right
var label3 = new cc.LabelBMFont("Multi line\nRight\nThree lines Three", s_resprefix + "fonts/bitmapFontTest3.fnt");
label3.anchorX = 1;
label3.anchorY = 1;
this.addChild(label3, 0, TAG_BITMAP_ATLAS3);
cc.log("content size:" + label3.width + "," + label3.height);
var s = director.getWinSize();
label1.x = 0;
label1.y = 0;
label2.x = s.width / 2;
label2.y = s.height / 2;
label3.x = s.width;
label3.y = s.height;
},
title:function () {
return "cc.LabelBMFont BMFontMultiLineTest";
},
subtitle:function () {
return "Multiline + anchor point";
},
// Automation
pixel: {"0": 255, "1": 186, "2": 33, "3": 255},
getExpectedResult:function() {
// var ret = [{"0":0,"1":0,"2":226,"3":255},{"0":47,"1":0,"2":0,"3":255},{"0":0,"1":47,"2":0,"3":255}];
var s = director.getWinSize();
var ret = {"left": "yes", "center": "yes", "right": "yes"};
return JSON.stringify(ret);
},
getCurrentResult:function() {
var s = director.getWinSize();
var ret1 = this.readPixels(0, 0, 100, 100);
var ret2 = this.readPixels(s.width/2, s.height/2, 100, 100);
var ret3 = this.readPixels(s.width - 100, s.height - 100, 100, 100);
var ret = {"left": this.containsPixel(ret1, this.pixel) ? "yes" : "no",
"center": this.containsPixel(ret2, this.pixel) ? "yes" : "no",
"right": this.containsPixel(ret3, this.pixel) ? "yes" : "no"}
return JSON.stringify(ret);
}
});
// <API key>
var <API key> = AtlasDemo.extend({
ctor:function () {
this._super();
// Left
var label1 = new cc.LabelBMFont("Multi line\n\nAligned to the left", s_resprefix + "fonts/bitmapFontTest3.fnt");
label1.anchorX = 0;
label1.anchorY = 0;
label1.textAlign = cc.TEXT_ALIGNMENT_LEFT;
label1.boundingWidth = 400;
this.addChild(label1, 0, TAG_BITMAP_ATLAS1);
cc.log("content size:" + label1.width + "," + label1.height);
// Center
var label2 = new cc.LabelBMFont("Error\n\nSome error message", s_resprefix + "fonts/bitmapFontTest3.fnt");
label2.anchorX = 0.5;
label2.anchorY = 0.5;
label2.textAlign = cc.<API key>;
label2.boundingWidth = 290;
this.addChild(label2, 0, TAG_BITMAP_ATLAS2);
cc.log("content size:" + label2.width + "," + label2.height);
// right
var label3 = new cc.LabelBMFont("Multi line\n\nAligned to the right", s_resprefix + "fonts/bitmapFontTest3.fnt");
label3.anchorX = 1;
label3.anchorY = 1;
label3.textAlign = cc.<API key>;
label3.boundingWidth = 400;
this.addChild(label3, 0, TAG_BITMAP_ATLAS3);
cc.log("content size:" + label3.width + "," + label3.height);
var s = director.getWinSize();
label1.x = 0;
label1.y = 0;
label2.x = s.width / 2;
label2.y = s.height / 2;
label3.x = s.width;
label3.y = s.height;
},
title:function () {
return "cc.LabelBMFont <API key>";
},
subtitle:function () {
return "Multiline with 2 new lines. All characters should appear";
},
// Automation
pixel: {"0": 255, "1": 186, "2": 33, "3": 255},
getExpectedResult:function() {
// var ret = [{"0":0,"1":0,"2":226,"3":255},{"0":47,"1":0,"2":0,"3":255},{"0":0,"1":47,"2":0,"3":255}];
var s = director.getWinSize();
var ret = {"left": "yes", "center": "yes", "right": "yes"};
return JSON.stringify(ret);
},
getCurrentResult:function() {
var s = director.getWinSize();
var ret1 = this.readPixels(0, 0, 100, 100);
var ret2 = this.readPixels(s.width/2, s.height/2, 100, 100);
var ret3 = this.readPixels(s.width - 100, s.height - 100, 100, 100);
var ret = {"left": this.containsPixel(ret1, this.pixel) ? "yes" : "no",
"center": this.containsPixel(ret2, this.pixel) ? "yes" : "no",
"right": this.containsPixel(ret3, this.pixel) ? "yes" : "no"}
return JSON.stringify(ret);
}
});
// LabelsEmpty
var LabelsEmpty = AtlasDemo.extend({
setEmpty:null,
ctor:function () {
this._super();
// cc.LabelBMFont
var label1 = new cc.LabelBMFont("", s_resprefix + "fonts/bitmapFontTest3.fnt");
this.addChild(label1, 0, TAG_BITMAP_ATLAS1);
label1.x = winSize.width / 2;
label1.y = winSize.height - 100;
// cc.LabelTTF
var label2 = new cc.LabelTTF("", "Arial", 24);
this.addChild(label2, 0, TAG_BITMAP_ATLAS2);
label2.x = winSize.width / 2;
label2.y = winSize.height / 2;
// cc.LabelAtlas
var label3 = new cc.LabelAtlas("", s_resprefix + "fonts/<API key>.png", 48, 64, ' ');
this.addChild(label3, 0, TAG_BITMAP_ATLAS3);
label3.x = winSize.width / 2;
label3.y = 0 + 100;
this.schedule(this.onUpdateStrings, 1.0);
this.setEmpty = false;
},
onUpdateStrings:function (dt) {
var label1 = this.getChildByTag(TAG_BITMAP_ATLAS1);
var label2 = this.getChildByTag(TAG_BITMAP_ATLAS2);
var label3 = this.getChildByTag(TAG_BITMAP_ATLAS3);
if (!this.setEmpty) {
label1.setString("not empty");
label2.setString("not empty");
label3.setString("hi");
this.setEmpty = true;
}
else {
label1.setString("");
label2.setString("");
label3.setString("");
this.setEmpty = false;
}
},
title:function () {
return "Testing empty labels";
},
subtitle:function () {
return "3 empty labels: LabelAtlas, LabelTTF and LabelBMFont";
}
});
// BMFontHDTest
var BMFontHDTest = AtlasDemo.extend({
ctor:function () {
this._super();
var s = director.getWinSize();
// cc.LabelBMFont
var label1 = new cc.LabelBMFont("TESTING RETINA DISPLAY", s_resprefix + "fonts/konqa32.fnt");
this.addChild(label1);
label1.x = s.width / 2;
label1.y = s.height / 2;
},
title:function () {
return "Testing Retina Display BMFont";
},
subtitle:function () {
return "loading arista16 or arista16-hd";
},
// Automation
pixel: {"0": 255, "1": 255, "2": 255, "3": 255},
getExpectedResult:function() {
// var ret = [{"0":0,"1":0,"2":226,"3":255},{"0":47,"1":0,"2":0,"3":255},{"0":0,"1":47,"2":0,"3":255}];
var s = director.getWinSize();
var ret = {"center": "yes"};
return JSON.stringify(ret);
},
getCurrentResult:function() {
var s = director.getWinSize();
var ret2 = this.readPixels(s.width/2, s.height/2, 100, 100);
var ret = {"center": this.containsPixel(ret2, this.pixel) ? "yes" : "no"};
return JSON.stringify(ret);
}
});
// <API key>
var <API key> = AtlasDemo.extend({
ctor:function () {
this._super();
var s = director.getWinSize();
var layer = new cc.LayerColor(cc.color(128, 128, 128, 255));
this.addChild(layer, -10);
// cc.LabelBMFont
var label1 = new cc.LabelBMFont("Testing Glyph Designer", s_resprefix + "fonts/futura-48.fnt");
this.addChild(label1);
label1.x = s.width / 2;
label1.y = s.height / 2;
},
title:function () {
return "Testing Glyph Designer";
},
subtitle:function () {
return "You should see a font with shawdows and outline";
},
// Automation
pixel: {"0": 240, "1": 201, "2": 108, "3": 255},
getExpectedResult:function() {
// var ret = [{"0":0,"1":0,"2":226,"3":255},{"0":47,"1":0,"2":0,"3":255},{"0":0,"1":47,"2":0,"3":255}];
var s = director.getWinSize();
var ret = {"center": "yes"};
return JSON.stringify(ret);
},
getCurrentResult:function() {
var s = director.getWinSize();
var ret2 = this.readPixels(s.width/2, s.height/2, 100, 100);
var ret = {"center": this.containsPixel(ret2, this.pixel) ? "yes" : "no"};
return JSON.stringify(ret);
}
});
// LabelTTFTest
var <API key> = AtlasDemo.extend({
_labelShadow: null,
_labelStroke: null,
_labelStrokeShadow: null,
ctor: function () {
this._super();
this.updateLabels();
},
updateLabels: function () {
var blockSize = cc.size(400, 100);
var s = director.getWinSize();
// colors
var redColor = cc.color(255, 0, 0);
var yellowColor = cc.color(255, 255, 0);
var blueColor = cc.color(0, 0, 255);
// shadow offset
var shadowOffset = cc.p(12, -12);
// positioning stuff
var posX = s.width / 2 - (blockSize.width / 2);
var posY_5 = s.height / 7;
// font definition
var fontDefRedShadow = new cc.FontDefinition();
fontDefRedShadow.fontName = "Arial";
fontDefRedShadow.fontSize = 32;
fontDefRedShadow.textAlign = cc.<API key>;
fontDefRedShadow.verticalAlign = cc.<API key>;
fontDefRedShadow.fillStyle = redColor;
fontDefRedShadow.boundingWidth = blockSize.width;
fontDefRedShadow.boundingHeight = blockSize.height;
// shadow
fontDefRedShadow.shadowEnabled = true;
fontDefRedShadow.shadowOffsetX = shadowOffset.x;
fontDefRedShadow.shadowOffsetY = shadowOffset.y;
// create the label using the definition
this._labelShadow = new cc.LabelTTF("Shadow Only", fontDefRedShadow);
this._labelShadow.anchorX = 0;
this._labelShadow.anchorY = 0;
this._labelShadow.x = posX;
this._labelShadow.y = posY_5;
// font definition
var fontDefBlueStroke = new cc.FontDefinition();
fontDefBlueStroke.fontName = "Arial";
fontDefBlueStroke.fontSize = 32;
fontDefBlueStroke.textAlign = cc.<API key>;
fontDefBlueStroke.verticalAlign = cc.<API key>;
fontDefBlueStroke.fillStyle = blueColor;
fontDefBlueStroke.boundingWidth = blockSize.width;
fontDefBlueStroke.boundingHeight = blockSize.height;
// stroke
fontDefBlueStroke.strokeEnabled = true;
fontDefBlueStroke.strokeStyle = yellowColor;
this._labelStroke = new cc.LabelTTF("Stroke Only", fontDefBlueStroke);
this._labelStroke.anchorX = 0;
this._labelStroke.anchorY = 0;
this._labelStroke.x = posX;
this._labelStroke.y = posY_5 * 2;
// font definition
var <API key> = new cc.FontDefinition();
<API key>.fontName = "Arial";
<API key>.fontSize = 32;
<API key>.textAlign = cc.<API key>;
<API key>.verticalAlign = cc.<API key>;
<API key>.fillStyle = blueColor;
<API key>.boundingWidth = blockSize.width;
<API key>.boundingHeight = blockSize.height;
// stroke
<API key>.strokeEnabled = true;
<API key>.strokeStyle = redColor;
// shadow
<API key>.shadowEnabled = true;
<API key>.shadowOffsetX = -12;
<API key>.shadowOffsetY = 12; //shadowOffset;
this._labelStrokeShadow = new cc.LabelTTF("Stroke + Shadow\n New Line", <API key>);
this._labelStrokeShadow.anchorX = 0;
this._labelStrokeShadow.anchorY = 0;
this._labelStrokeShadow.x = posX;
this._labelStrokeShadow.y = posY_5 * 3;
// add all the labels
this.addChild(this._labelShadow);
this.addChild(this._labelStroke);
this.addChild(this._labelStrokeShadow);
},
title: function () {
return "Testing cc.LabelTTF + shadow and stroke";
},
subtitle: function () {
return "";
}
});
var LabelTTFTest = AtlasDemo.extend({
_label:null,
_horizAlign:null,
_vertAlign:null,
ctor:function () {
this._super();
var blockSize = cc.size(200, 160);
var s = director.getWinSize();
var colorLayer = new cc.LayerColor(cc.color(100, 100, 100, 255), blockSize.width, blockSize.height);
colorLayer.anchorX = 0;
colorLayer.anchorY = 0;
colorLayer.x = (s.width - blockSize.width) / 2;
colorLayer.y = (s.height - blockSize.height) / 2;
this.addChild(colorLayer);
cc.MenuItemFont.setFontSize(30);
var menu = new cc.Menu(
new cc.MenuItemFont("Left", this.setAlignmentLeft, this),
new cc.MenuItemFont("Center", this.setAlignmentCenter, this),
new cc.MenuItemFont("Right", this.setAlignmentRight, this));
menu.<API key>(4);
menu.x = 50;
menu.y = s.height / 2 - 20;
this.addChild(menu);
menu = new cc.Menu(
new cc.MenuItemFont("Top", this.setAlignmentTop, this),
new cc.MenuItemFont("Middle", this.setAlignmentMiddle, this),
new cc.MenuItemFont("Bottom", this.setAlignmentBottom, this));
menu.<API key>(4);
menu.x = s.width - 50;
menu.y = s.height / 2 - 20;
this.addChild(menu);
this._label = null;
this._horizAlign = cc.TEXT_ALIGNMENT_LEFT;
this._vertAlign = cc.<API key>;
this.updateAlignment();
},
updateAlignment:function () {
var blockSize = cc.size(200, 160);
var s = director.getWinSize();
if (this._label) {
this._label.removeFromParent();
}
this._label = new cc.LabelTTF(this.getCurrentAlignment(), "Arial", 32, blockSize, this._horizAlign, this._vertAlign);
this._label.anchorX = 0;
this._label.anchorY = 0;
this._label.x = (s.width - blockSize.width) / 2;
this._label.y = (s.height - blockSize.height) / 2;
this.addChild(this._label);
},
setAlignmentLeft:function (sender) {
this._horizAlign = cc.TEXT_ALIGNMENT_LEFT;
this.updateAlignment();
},
setAlignmentCenter:function (sender) {
this._horizAlign = cc.<API key>;
this.updateAlignment();
},
setAlignmentRight:function (sender) {
this._horizAlign = cc.<API key>;
this.updateAlignment();
},
setAlignmentTop:function (sender) {
this._vertAlign = cc.<API key>;
this.updateAlignment();
},
setAlignmentMiddle:function (sender) {
this._vertAlign = cc.<API key>;
this.updateAlignment();
},
setAlignmentBottom:function (sender) {
this._vertAlign = cc.<API key>;
this.updateAlignment();
},
getCurrentAlignment:function () {
var vertical = null;
var horizontal = null;
switch (this._vertAlign) {
case cc.<API key>:
vertical = "Top";
break;
case cc.<API key>:
vertical = "Middle";
break;
case cc.<API key>:
vertical = "Bottom";
break;
}
switch (this._horizAlign) {
case cc.TEXT_ALIGNMENT_LEFT:
horizontal = "Left";
break;
case cc.<API key>:
horizontal = "Center";
break;
case cc.<API key>:
horizontal = "Right";
break;
}
return "Alignment " + vertical + " " + horizontal;
},
title:function () {
return "Testing cc.LabelTTF";
},
subtitle:function () {
return "Select the buttons on the sides to change alignment";
}
});
var LabelTTFMultiline = AtlasDemo.extend({
ctor:function () {
this._super();
var s = director.getWinSize();
// cc.LabelBMFont
var center = new cc.LabelTTF("word wrap \"testing\" (bla0) bla1 'bla2' [bla3] (bla4) {bla5} {bla6} [bla7] (bla8) [bla9] 'bla0' \"bla1\"",
"Arial", 32, cc.size(s.width / 2, 200), cc.<API key>, cc.<API key>);
center.setDimensions(s.width / 2, 200);
center.x = s.width / 2;
center.y = 150;
this.addChild(center);
},
title:function () {
return "Testing cc.LabelTTF Word Wrap";
},
subtitle:function () {
return "Word wrap using cc.LabelTTF";
},
// Automation
pixel: {"0": 255, "1": 255, "2": 255, "3": 255},
getExpectedResult:function() {
// var ret = [{"0":0,"1":0,"2":226,"3":255},{"0":47,"1":0,"2":0,"3":255},{"0":0,"1":47,"2":0,"3":255}];
var s = director.getWinSize();
var ret = {"center": "yes"};
return JSON.stringify(ret);
},
getCurrentResult:function() {
var s = director.getWinSize();
var ret2 = this.readPixels(s.width/2, 125, 100, 100);
var ret = {"center": this.containsPixel(ret2, this.pixel) ? "yes" : "no"};
return JSON.stringify(ret);
}
});
var LabelTTFChinese = AtlasDemo.extend({
ctor:function () {
this._super();
var size = director.getWinSize();
var fontname = (cc.sys.os === cc.sys.OS_WP8 ) ? "fonts/arialuni.ttf" : (cc.sys.os == cc.sys.OS_WINRT) ? "DengXian" : "Microsoft Yahei";
var label = new cc.LabelTTF("", fontname, 30);
label.x = size.width / 2;
label.y = size.height / 3 * 2;
this.addChild(label);
// Test UTF8 string from native to jsval.
var label2 = new cc.LabelTTF("string from native:"+label.getString(), fontname, 30);
label2.x = size.width / 2;
label2.y = size.height / 3;
this.addChild(label2);
},
title:function () {
return "Testing cc.LabelTTF with Chinese character";
}
});
var BMFontChineseTest = AtlasDemo.extend({
ctor:function () {
this._super();
var size = director.getWinSize();
var label = new cc.LabelBMFont("", s_resprefix + "fonts/bitmapFontChinese.fnt");
label.x = size.width / 2;
label.y = size.height / 2;
this.addChild(label);
},
title:function () {
return "Testing cc.LabelBMFont with Chinese character";
},
// Automation
pixel: {"0": 255, "1": 0, "2": 142, "3": 255},
getExpectedResult:function() {
// var ret = [{"0":0,"1":0,"2":226,"3":255},{"0":47,"1":0,"2":0,"3":255},{"0":0,"1":47,"2":0,"3":255}];
var s = director.getWinSize();
var ret = {"center": "yes"};
return JSON.stringify(ret);
},
getCurrentResult:function() {
var s = director.getWinSize();
var ret2 = this.readPixels(s.width/2, s.height / 2, 100, 100);
var ret = {"center": this.containsPixel(ret2, this.pixel) ? "yes" : "no"};
return JSON.stringify(ret);
}
});
var <API key> = "Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.";
var chineseExampleText = "";
var <API key> = "bdgpybbdbdbdpgbddbdgpybdgpybdgpybdgbdgpy";
var mixAllLanguageText = "Buen díabdgpybbdbdBuen bddBuen pybdgpy";
var LineBreaksExample = "Lorem ipsum dolor\nsit amet\nconsectetur adipisicing elit\nblah\nblah";
var MixedExample = "ABC\nLorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt\nDEF";
var ArrowsMax = 0.95;
var ArrowsMin = 0.7;
var LeftAlign = 0;
var CenterAlign = 1;
var RightAlign = 2;
var LongSentences = 0;
var LineBreaks = 1;
var Mixed = 2;
var chineseText = 3;
var chineseMixEnglish = 4;
var mixAllLanguage = 5;
var <API key> = 40;
var <API key> = 80;
var <API key> = AtlasDemo.extend({
labelShouldRetain:null,
<API key>:null,
arrowsShouldRetain:null,
lastSentenceItem:null,
lastAlignmentItem:null,
lineBreakFlag:false,
ctor:function () {
this._super();
cc.eventManager.addListener({
event: cc.EventListener.TOUCH_ALL_AT_ONCE,
onTouchesBegan: this.onTouchesBegan.bind(this),
onTouchesMoved: this.onTouchesMoved.bind(this),
onTouchesEnded: this.onTouchesEnded.bind(this)
}, this);
if ('touches' in cc.sys.capabilities){
cc.eventManager.addListener({
event: cc.EventListener.TOUCH_ALL_AT_ONCE,
onTouchesBegan: this.onTouchesBegan.bind(this),
onTouchesMoved: this.onTouchesMoved.bind(this),
onTouchesEnded: this.onTouchesEnded.bind(this)
}, this);
} else if ('mouse' in cc.sys.capabilities)
cc.eventManager.addListener({
event: cc.EventListener.MOUSE,
onMouseDown: this.onMouseDown.bind(this),
onMouseMove: this.onMouseMove.bind(this),
onMouseUp: this.onMouseUp.bind(this)
}, this);
// ask director the the window size
var size = director.getWinSize();
// create and initialize a Label
this.labelShouldRetain = new cc.LabelBMFont(<API key>, s_resprefix + "fonts/markerFelt.fnt", size.width / 2, cc.<API key>, cc.p(0, 0));
this.<API key> = new cc.Sprite(s_resprefix + "Images/arrowsBar.png");
this.arrowsShouldRetain = new cc.Sprite(s_resprefix + "Images/arrows.png");
cc.MenuItemFont.setFontSize(20);
var longSentences = new cc.MenuItemFont("Long Flowing Sentences", this.onStringChanged, this);
var lineBreaks = new cc.MenuItemFont("Short Sentences With Intentional Line Breaks", this.onStringChanged, this);
var mixed = new cc.MenuItemFont("Long Sentences Mixed With Intentional Line Breaks", this.onStringChanged.bind(this)); // another way to pass 'this'
var changeChineseItem = new cc.MenuItemFont("change chinese", this.onStringChanged, this);
var mixEnglishItem = new cc.MenuItemFont("change chinesemixEnglish", this.onStringChanged, this);
var mixAllLanItem = new cc.MenuItemFont("change mixAllLan", this.onStringChanged, this);
var stringMenu = new cc.Menu(longSentences, lineBreaks, mixed, changeChineseItem,mixEnglishItem, mixAllLanItem);
stringMenu.<API key>();
var setLineBreakItem = new cc.MenuItemFont("<API key>", this.onLineBreakChanged, this);
var setScale = new cc.MenuItemFont("setScale", this.onScaleChange, this);
var lineBreakMenu = new cc.Menu(setLineBreakItem, setScale);
lineBreakMenu.x = 100;
lineBreakMenu.y = winSize.height / 2;
lineBreakMenu.<API key>();
longSentences.color = cc.color(255, 0, 0);
this.lastSentenceItem = longSentences;
longSentences.tag = LongSentences;
lineBreaks.tag = LineBreaks;
mixed.tag = Mixed;
changeChineseItem.tag = chineseText;
mixEnglishItem.tag = chineseMixEnglish;
mixAllLanItem.tag = mixAllLanguage;
cc.MenuItemFont.setFontSize(30);
var left = new cc.MenuItemFont("Left", this.onAlignmentChanged, this);
var center = new cc.MenuItemFont("Center", this.onAlignmentChanged, this);
var right = new cc.MenuItemFont("Right", this.onAlignmentChanged.bind(this)); // another way to pass 'this'
var alignmentMenu = new cc.Menu(left, center, right);
alignmentMenu.<API key>(<API key>);
center.color = cc.color(255, 0, 0);
this.lastAlignmentItem = center;
left.tag = LeftAlign;
center.tag = CenterAlign;
right.tag = RightAlign;
// position the label on the center of the screen
this.labelShouldRetain.x = size.width / 2;
this.labelShouldRetain.y = size.height / 2;
this.<API key>.visible = false;
var arrowsWidth = (ArrowsMax - ArrowsMin) * size.width;
this.<API key>.scaleX = arrowsWidth / this.<API key>.width;
this.<API key>.anchorX = 0;
this.<API key>.anchorY = 0.5;
this.<API key>.x = ArrowsMin * size.width;
this.<API key>.y = this.labelShouldRetain.y;
this.arrowsShouldRetain.x = this.<API key>.x;
this.arrowsShouldRetain.y = this.<API key>.y;
stringMenu.x = size.width / 2;
stringMenu.y = size.height - <API key>;
alignmentMenu.x = size.width / 2;
alignmentMenu.y = <API key> + 15;
this.addChild(this.labelShouldRetain);
this.addChild(this.<API key>);
this.addChild(this.arrowsShouldRetain);
this.addChild(stringMenu);
this.addChild(alignmentMenu);
this.addChild(lineBreakMenu);
},
__title: function(){
return 'The scroll bar';
},
title:function () {
return "";
},
subtitle:function () {
return "";
},
onScaleChange:function(sener){
if (this.labelShouldRetain.getScale() > 1)
{
this.labelShouldRetain.setScale(1.0);
}
else
{
this.labelShouldRetain.setScale(2.0);
}
},
onLineBreakChanged:function(sender){
this.lineBreakFlag = !this.lineBreakFlag;
this.labelShouldRetain.<API key>(this.lineBreakFlag);
},
onStringChanged:function (sender) {
this.lastSentenceItem.color = cc.color(255, 255, 255);
sender.color = cc.color(255, 0, 0);
this.lastSentenceItem = sender;
switch (sender.tag) {
case LongSentences:
this.labelShouldRetain.setString(<API key>);
this.labelShouldRetain.setFntFile(s_resprefix + "fonts/markerFelt.fnt");
break;
case LineBreaks:
this.labelShouldRetain.setString(LineBreaksExample);
this.labelShouldRetain.setFntFile(s_resprefix + "fonts/markerFelt.fnt");
break;
case Mixed:
this.labelShouldRetain.setString(MixedExample);
this.labelShouldRetain.setFntFile(s_resprefix + "fonts/markerFelt.fnt");
break;
case chineseText:
this.labelShouldRetain.setFntFile(s_resprefix + "fonts/arial-unicode-26.fnt");
this.labelShouldRetain.setString(chineseExampleText);
break;
case chineseMixEnglish:
this.labelShouldRetain.setFntFile(s_resprefix + "fonts/arial-unicode-26.fnt");
this.labelShouldRetain.setString(<API key>);
break;
case mixAllLanguage:
this.labelShouldRetain.setFntFile(s_resprefix + "fonts/arial-unicode-26.fnt");
this.labelShouldRetain.setString(mixAllLanguageText);
break;
default:
break;
}
this.snapArrowsToEdge();
},
onAlignmentChanged:function (sender) {
var item = sender;
this.lastAlignmentItem.color = cc.color(255, 255, 255);
item.color = cc.color(255, 0, 0);
this.lastAlignmentItem = item;
switch (item.tag) {
case LeftAlign:
this.labelShouldRetain.textAlign = cc.TEXT_ALIGNMENT_LEFT;
break;
case CenterAlign:
this.labelShouldRetain.textAlign = cc.<API key>;
break;
case RightAlign:
this.labelShouldRetain.textAlign = cc.<API key>;
break;
default:
break;
}
this.snapArrowsToEdge();
},
onTouchesBegan:function (touches) {
var touch = touches[0];
var location = touch.getLocation();
if (cc.rectContainsPoint(this.arrowsShouldRetain.getBoundingBox(), location)) {
this.<API key>.visible = true;
}
},
onTouchesEnded:function () {
this.<API key>.visible = false;
},
onTouchesMoved:function (touches) {
var touch = touches[0];
var location = touch.getLocation();
var winSize = director.getWinSize();
this.arrowsShouldRetain.x = Math.max(Math.min(location.x, ArrowsMax * winSize.width), ArrowsMin * winSize.width);
this.labelShouldRetain.boundingWidth = Math.abs(this.arrowsShouldRetain.getPosition().x - this.labelShouldRetain.getPosition().x) * 2;
},
onMouseDown:function (event) {
var location = event.getLocation();
if (cc.rectContainsPoint(this.arrowsShouldRetain.getBoundingBox(), location)) {
this.<API key>.visible = true;
}
},
onMouseMove:function (event) {
if(!event.getButton || event.getButton() != cc.EventMouse.BUTTON_LEFT)
return;
var location = event.getLocation();
var winSize = director.getWinSize();
this.arrowsShouldRetain.x = Math.max(Math.min(location.x, ArrowsMax * winSize.width), ArrowsMin * winSize.width);
this.labelShouldRetain.boundingWidth = Math.abs(this.arrowsShouldRetain.x - this.labelShouldRetain.x) * 2;
},
onMouseUp:function (event) {
//this.snapArrowsToEdge();
this.<API key>.visible = false;
},
snapArrowsToEdge:function () {
var winSize = director.getWinSize();
this.arrowsShouldRetain.x = ArrowsMin * winSize.width;
this.arrowsShouldRetain.y = this.<API key>.y;
}
});
LabelTTFA8Test
var LabelTTFA8Test = AtlasDemo.extend({
ctor:function () {
this._super();
var s = director.getWinSize();
var layer = new cc.LayerColor(cc.color(128, 128, 128, 255));
this.addChild(layer, -10);
// cc.LabelBMFont
var label1 = new cc.LabelTTF("Testing A8 Format", "Arial", 48);
this.addChild(label1);
label1.color = cc.color(255, 0, 0);
label1.x = s.width / 2;
label1.y = s.height / 2;
var fadeOut = cc.fadeOut(2);
var fadeIn = cc.fadeIn(2);
var seq = cc.sequence(fadeOut, fadeIn);
var forever = seq.repeatForever();
label1.runAction(forever);
},
title:function () {
return "Testing A8 Format";
},
subtitle:function () {
return "RED label, fading In and Out in the center of the screen";
}
});
BMFontOneAtlas
var BMFontOneAtlas = AtlasDemo.extend({
ctor:function () {
this._super();
var s = director.getWinSize();
var label1 = new cc.LabelBMFont("This is Helvetica", s_resprefix + "fonts/helvetica-32.fnt", cc.LabelAutomaticWidth, cc.TEXT_ALIGNMENT_LEFT, cc.p(0, 0));
this.addChild(label1);
label1.x = s.width / 2;
label1.y = s.height * 2 / 3;
var label2 = new cc.LabelBMFont("And this is Geneva", s_resprefix + "fonts/geneva-32.fnt", cc.LabelAutomaticWidth, cc.TEXT_ALIGNMENT_LEFT, cc.p(0, 128));
this.addChild(label2);
label2.x = s.width / 2;
label2.y = s.height / 3;
},
title:function () {
return "cc.LabelBMFont with one texture";
},
subtitle:function () {
return "Using 2 .fnt definitions that share the same texture atlas.";
}
});
BMFontUnicode
var BMFontUnicode = AtlasDemo.extend({
ctor:function () {
this._super();
var chinese = "";
var japanese = "";
var spanish = "Buen día";
var label1 = new cc.LabelBMFont(spanish, s_resprefix + "fonts/arial-unicode-26.fnt", 200, cc.TEXT_ALIGNMENT_LEFT);
this.addChild(label1);
label1.x = winSize.width / 2;
label1.y = winSize.height / 4;
var label2 = new cc.LabelBMFont(chinese, s_resprefix + "fonts/arial-unicode-26.fnt");
this.addChild(label2);
label2.x = winSize.width / 2;
label2.y = winSize.height / 2.2;
var label3 = new cc.LabelBMFont(japanese, s_resprefix + "fonts/arial-unicode-26.fnt");
this.addChild(label3);
label3.x = winSize.width / 2;
label3.y = winSize.height / 1.5;
},
title:function () {
return "cc.LabelBMFont with Unicode support";
},
subtitle:function () {
return "You should see 3 different labels: In Spanish, Chinese and Korean";
}
});
// BMFontInit
var BMFontInit = AtlasDemo.extend({
ctor:function () {
this._super();
var bmFont = new cc.LabelBMFont();
bmFont.setFntFile(s_resprefix + "fonts/helvetica-32.fnt");
bmFont.setString("It is working!");
this.addChild(bmFont);
bmFont.x = winSize.width / 2;
bmFont.y = winSize.height / 2;
},
title:function () {
return "cc.LabelBMFont init";
},
subtitle:function () {
return "Test for support of init method without parameters.";
}
});
// <API key>
var <API key> = AtlasDemo.extend({
ctor:function () {
this._super();
var font = new cc.LabelTTF();
font.font = "48px 'Courier New'";
//font.setFontName("Arial");
font.string = "It is working!";
this.addChild(font);
font.x = winSize.width / 2;
font.y = winSize.height / 2;
},
title:function () {
return "cc.LabelTTF init";
},
subtitle:function () {
return "Test for support of init method without parameters.";
}
});
var LabelTTFAlignment = AtlasDemo.extend({
ctor:function () {
this._super();
var s = director.getWinSize();
var ttf0 = new cc.LabelTTF("Alignment 0\nnew line", "Arial", 12, cc.size(256, 32), cc.TEXT_ALIGNMENT_LEFT);
ttf0.x = s.width / 2;
ttf0.y = (s.height / 6) * 2;
ttf0.anchorX = 0.5;
ttf0.anchorY = 0.5;
this.addChild(ttf0);
var ttf1 = new cc.LabelTTF("Alignment 1\nnew line", "Arial", 12, cc.size(256, 32), cc.<API key>);
ttf1.x = s.width / 2;
ttf1.y = (s.height / 6) * 3;
ttf1.anchorX = 0.5;
ttf1.anchorY = 0.5;
this.addChild(ttf1);
var ttf2 = new cc.LabelTTF("Alignment 2\nnew line", "Arial", 12, cc.size(256, 32), cc.<API key>);
ttf2.x = s.width / 2;
ttf2.y = (s.height / 6) * 4;
ttf2.anchorX = 0.5;
ttf2.anchorY = 0.5;
this.addChild(ttf2);
},
title:function () {
return "cc.LabelTTF alignment";
},
subtitle:function () {
return "Tests alignment values";
},
// Automation
getExpectedResult:function() {
// yellow, red, green, blue, yellow
var ret = [{"r":255,"g":255,"b":0},{"r":255,"g":0,"b":0},{"r":0,"g":255,"b":0},{"r":0,"g":0,"b":255},{"r":255,"g":255,"b":0}];
return JSON.stringify(ret);
},
getCurrentResult:function() {
var ret = [];
for( var i=0; i<5; i++) {
var ch = this.label.getChildByTag(i).getDisplayedColor();
ret.push(ch);
}
return JSON.stringify(ret);
}
});
var <API key> = AtlasDemo.extend({
ctor:function () {
this._super();
this.label = new cc.LabelBMFont("YRGB", s_resprefix + "fonts/konqa32.fnt");
this.addChild(this.label);
this.label.x = winSize.width / 2;
this.label.y = winSize.height / 2;
this.label.color = cc.color.YELLOW;
var letter = this.label.getChildByTag(1);
letter.color = cc.color.RED;
letter = this.label.getChildByTag(2);
letter.color = cc.color.GREEN;
letter = this.label.getChildByTag(3);
letter.color = cc.color.BLUE;
this.scheduleUpdate();
this.accum = 0;
},
update:function(dt){
this.accum += dt;
this.label.setString("YRGB " + parseInt(this.accum,10).toString() );
},
title:function () {
return "cc.LabelBMFont color parent / child";
},
subtitle:function () {
return "Yellow Red Green Blue and numbers in Yellow";
},
// Automation
getExpectedResult:function() {
// yellow, red, green, blue, yellow
var ret = [{"r":255,"g":255,"b":0},{"r":255,"g":0,"b":0},{"r":0,"g":255,"b":0},{"r":0,"g":0,"b":255},{"r":255,"g":255,"b":0}];
return JSON.stringify(ret);
},
getCurrentResult:function() {
var ret = [];
for( var i=0; i<5; i++) {
var ch = this.label.getChildByTag(i).getDisplayedColor();
ret.push(ch);
}
return JSON.stringify(ret);
}
});
var WrapAlgorithmTest = AtlasDemo.extend({
ctor: function(){
this._super();
var self = this;
var normalText = [
"",
"",
"",
"",
"Here is the English test",
"aaaaaaaaaaaaaaaaa",
"test test test aaa, tt",
"test test test aa, tt",
"",
""
];
normalText.forEach(function(text, i){
var LabelTTF = new cc.LabelTTF();
LabelTTF.setString(text);
LabelTTF.setPosition(30 + 150 * (i/4|0), 300 - (i%4) * 60);
LabelTTF.setAnchorPoint(0,1);
LabelTTF.boundingWidth = 120;
LabelTTF.boundingHeight = 0;
LabelTTF.enableStroke(cc.color(0, 0, 0, 1), 3.0);
if (cc.sys.os === cc.sys.OS_WP8)
LabelTTF.setFontName("fonts/arialuni.ttf");
else if(cc.sys.os === cc.sys.OS_WINRT)
LabelTTF.setFontName("DengXian");
self.addChild(LabelTTF);
});
//Extreme test
var extremeText = [
"",
"\n",
"\r\n",
"",
",",
"W",
"7"
];
extremeText.forEach(function(text, i){
var LabelTTF = new cc.LabelTTF();
LabelTTF.setString(text);
LabelTTF.setPosition(480 + i * 25, 300);
LabelTTF.setAnchorPoint(0,1);
LabelTTF.boundingWidth = 3;
LabelTTF.boundingHeight = 0;
LabelTTF.enableStroke(cc.color(0, 0, 0, 1), 3.0);
if (cc.sys.os === cc.sys.OS_WP8)
LabelTTF.setFontName("fonts/arialuni.ttf");
else if(cc.sys.os === cc.sys.OS_WINRT)
LabelTTF.setFontName("DengXian");
self.addChild(LabelTTF);
});
//Combinatorial testing
var combinatorialText = [
"English",
"",
"English"
];
combinatorialText.forEach(function(text, i){
var LabelTTF = new cc.LabelTTF();
LabelTTF.setString(text);
LabelTTF.setPosition(480 + 100 * (i/3|0), 240 - (i%3) * 60);
LabelTTF.setAnchorPoint(0,1);
LabelTTF.boundingWidth = 90;
LabelTTF.boundingHeight = 0;
LabelTTF.enableStroke(cc.color(0, 0, 0, 1), 3.0);
if (cc.sys.os === cc.sys.OS_WP8)
LabelTTF.setFontName("fonts/arialuni.ttf");
else if(cc.sys.os === cc.sys.OS_WINRT)
LabelTTF.setFontName("DengXian");
self.addChild(LabelTTF);
});
},
title: function(){
return "Wrap algorithm test";
},
subtitle: function(){
return "Wrap effect under various circumstances";
},
onEnter: function(){
this._super();
cc.SPRITE_DEBUG_DRAW = 1;
},
onExit: function(){
this._super();
cc.SPRITE_DEBUG_DRAW = 0;
}
});
// Flow control
var arrayOfLabelTest = [
<API key>,
<API key>,
LabelAtlasHD,
<API key>,
BMFontSubSpriteTest,
BMFontPaddingTest,
BMFontOffsetTest,
BMFontTintTest,
BMFontSpeedTest,
BMFontMultiLineTest,
<API key>,
<API key>,
BMFontOneAtlas,
BMFontUnicode,
BMFontInit,
<API key>,
BMFontHDTest,
<API key>,
BMFontChineseTest,
LabelTTFTest,
LabelTTFMultiline,
LabelTTFChinese,
LabelTTFA8Test,
<API key>,
LabelTTFAlignment,
LabelsEmpty,
<API key>
];
if (!cc.sys.isNative || cc.sys.isMobile) {
arrayOfLabelTest.push(WrapAlgorithmTest);
}
var nextLabelTest = function () {
labelTestIdx++;
labelTestIdx = labelTestIdx % arrayOfLabelTest.length;
if(window.sideIndexBar){
labelTestIdx = window.sideIndexBar.changeTest(labelTestIdx, 19);
}
return new arrayOfLabelTest[labelTestIdx]();
};
var previousLabelTest = function () {
labelTestIdx
if (labelTestIdx < 0)
labelTestIdx += arrayOfLabelTest.length;
if(window.sideIndexBar){
labelTestIdx = window.sideIndexBar.changeTest(labelTestIdx, 19);
}
return new arrayOfLabelTest[labelTestIdx]();
};
var restartLabelTest = function () {
return new arrayOfLabelTest[labelTestIdx]();
}; |
package com.sun.tools.internal.ws.processor.modeler;
/**
*
* @author WS Development Team
*/
public enum ModelerConstants {
FALSE_STR("false"),
ZERO_STR("0"),
NULL_STR("null"),
ARRAY_STR("Array"),
/*
* Java ClassNames
*/
/*
* Java ClassNames
*/
<API key>("java.io.IOException"),
BOOLEAN_CLASSNAME("boolean"),
<API key>("java.lang.Boolean"),
BYTE_CLASSNAME("byte"),
<API key>("byte[]"),
<API key>("java.lang.Byte"),
<API key>("java.lang.Byte[]"),
CLASS_CLASSNAME("java.lang.Class"),
CHAR_CLASSNAME("char"),
<API key>("java.lang.Character"),
DOUBLE_CLASSNAME("double"),
<API key>("java.lang.Double"),
FLOAT_CLASSNAME("float"),
<API key>("java.lang.Float"),
INT_CLASSNAME("int"),
<API key>("java.lang.Integer"),
LONG_CLASSNAME("long"),
<API key>("java.lang.Long"),
SHORT_CLASSNAME("short"),
<API key>("java.lang.Short"),
<API key>("java.math.BigDecimal"),
<API key>("java.math.BigInteger"),
CALENDAR_CLASSNAME("java.util.Calendar"),
DATE_CLASSNAME("java.util.Date"),
STRING_CLASSNAME("java.lang.String"),
<API key>("java.lang.String[]"),
QNAME_CLASSNAME("javax.xml.namespace.QName"),
VOID_CLASSNAME("void"),
OBJECT_CLASSNAME("java.lang.Object"),
<API key>("javax.xml.soap.SOAPElement"),
IMAGE_CLASSNAME("java.awt.Image"),
<API key>("javax.mail.internet.MimeMultipart"),
SOURCE_CLASSNAME("javax.xml.transform.Source"),
<API key>("javax.activation.DataHandler"),
URI_CLASSNAME("java.net.URI"),
// URI_CLASSNAME ("java.lang.String"),
// Collections
<API key>("java.util.Collection"),
LIST_CLASSNAME("java.util.List"),
SET_CLASSNAME("java.util.Set"),
VECTOR_CLASSNAME("java.util.Vector"),
STACK_CLASSNAME("java.util.Stack"),
<API key>("java.util.LinkedList"),
<API key>("java.util.ArrayList"),
HASH_SET_CLASSNAME("java.util.HashSet"),
TREE_SET_CLASSNAME("java.util.TreeSet"),
// Maps
MAP_CLASSNAME("java.util.Map"),
HASH_MAP_CLASSNAME("java.util.HashMap"),
TREE_MAP_CLASSNAME("java.util.TreeMap"),
HASHTABLE_CLASSNAME("java.util.Hashtable"),
<API key>("java.util.Properties"),
// <API key> ("java.util.WeakHashMap"),
<API key>("com.sun.xml.internal.ws.encoding.soap.JAXWSMapEntry");
private String value;
private ModelerConstants(String value) {
this.value = value;
}
public String getValue() {
return value;
}
} |
define(
({
createLinkTitle: "Propriedades da ligação",
insertImageTitle: "Propriedades da imagem",
url: "URL:",
text: "Descrição:",
target: "Destino:",
set: "Definir",
currentWindow: "Janela actual",
parentWindow: "Janela ascendente",
topWindow: "Janela superior",
newWindow: "Nova janela"
})
); |
#include "common/str.h"
#include "mohawk/riven.h"
namespace Mohawk {
// The Riven variable system is complex. The scripts of each stack give a number, but the number has to be matched
// to a variable name defined in NAME resource 4.
static const char *variableNames[] = {
// aspit
"aAtrusBook",
"aAtrusPage",
"aCathBook",
"aCathPage",
"aCathState",
"aDoIt",
"aDomeCombo",
"aGehn",
"aInventory",
"aOva",
"aPower",
"aRaw",
"aTemp",
"aTrap",
"aTrapBook",
"aUserVolume",
"aZip",
// bspit
"bBackLock",
"bBait",
"bBigBridge",
"bBirds",
"bBlrArm",
"bBlrDoor",
"bBlrGrt",
"bBlrSw",
"bBlrValve",
"bBlrWtr",
"bBook",
"bBrLever",
"bCaveDoor",
"bcombo",
"bCPipeGr",
"bCraterGg",
"bDome",
"bDrwr",
"bFans",
"bFMDoor",
"bIdVlv",
"bLab",
"bLabBackDr",
"bLabBook",
"bLabEye",
"bLabFrontDr",
"bLabPage",
"bLever",
"bFrontLock",
"bHeat",
"bMagCar",
"bPipDr",
"bPrs",
"bStove",
"bTrap",
"bValve",
"bVise",
"bYtram",
"bYtramTime",
"bYtrap",
"bYtrapped",
// gspit
"gBook",
"gCathTime",
"gCathState",
"gCombo",
"gDome",
"gEmagCar",
"gImageCurr",
"gimagemax",
"gImageRot",
"gLkBtns",
"gLkBridge",
"gLkElev",
"gLView",
"gLViewMPos",
"gLViewPos",
"gNmagRot",
"gNmagCar",
"gPinUp",
"gPinPos",
"gPinsMPos",
"gRView",
"gRViewMPos",
"gRViewPos",
"gScribe",
"gScribeTime",
"gSubElev",
"gSubDr",
"gUpMoov",
"gWhark",
"gWharkTime",
// jspit
"jWMagCar",
"jBeetle",
"jBeetlePool",
"jBook",
"jBridge1",
"jBridge2",
"jBridge3",
"jBridge4",
"jBridge5",
"jCCB",
"jCombo",
"jCrg",
"jDome",
"jDrain",
"jGallows",
"jGate",
"jGirl",
"jIconCorrectOrder",
"jIconOrder",
"jIcons",
"jLadder",
"jLeftPos",
"jPeek",
"jPlayBeetle",
"jPRebel",
"jPrisonDr",
"jPrisonSecDr",
"jrBook",
"jRightPos",
"jSouthPathDr",
"jSchoolDr",
"jSub",
"jSubDir",
"jSubHatch",
"jSubSw",
"jSunners",
"jSunnerTime",
"jThroneDr",
"jTunnelDr",
"jTunnelLamps",
"jVillagePeople",
"jWarning",
"jWharkPos",
"jWharkRam",
"jWMouth",
"jWMagCar",
"jYMagCar",
// ospit
"oambient",
"oButton",
"ocage",
"oDeskBook",
"oGehnPage",
"oMusicPlayer",
"oStandDrawer",
"oStove",
// pspit
"pBook",
"pCage",
"pCathCheck",
"pCathState",
"pCathTime",
"pCombo",
"pCorrectOrder",
"pdome",
"pElevCombo",
"pLeftPos",
"pRightPos",
"pTemp",
"pWharkPos",
// rspit
"rRebel",
"rRebelView",
"rRichard",
"rVillageTime",
// tspit
"tBars",
"tBeetle",
"tBlue",
"tBook",
"tBookValve",
"tCage",
"tCombo",
"tCorrectOrder",
"tCoverCombo",
"tDL",
"tDome",
"tDomeElev",
"tDomeElevBtn",
"tGateBrHandle",
"tGateBridge",
"tGateState",
"tGreen",
"tGRIDoor",
"tGRODoor",
"tGRMDoor",
"tGuard",
"tImageDoor",
"tMagCar",
"tOrange",
"tRed",
"tSecDoor",
"tSubBridge",
"tTeleCover",
"tTeleHandle",
"tTelePin",
"tTelescope",
"tTeleValve",
"tTemple",
"tTempleDoor",
"tTunnelDoor",
"tViewer",
"tViolet",
"tWaBrValve",
"tWaffle",
"tYellow",
// Miscellaneous
"elevbtn1",
"elevbtn2",
"elevbtn3",
"domeCheck",
"transitionsEnabled",
"transitionMode",
"waterEnabled",
"RivenAmbients",
"<API key>",
"DoingSetupScreens",
"all_book",
"playerHasBook",
"returnStackID",
"returnCardID",
"NewPos",
"theMarble",
"CurrentStackID",
"CurrentCardID"
};
uint32 &MohawkEngine_Riven::getStackVar(uint32 index) {
Common::String name = getName(VariableNames, index);
if (!_vars.contains(name))
error("Could not find variable '%s' (stack variable %d)", name.c_str(), index);
return _vars[name];
}
void MohawkEngine_Riven::initVars() {
// Most variables just start at 0, it's simpler to do this
for (uint32 i = 0; i < ARRAYSIZE(variableNames); i++)
_vars[variableNames[i]] = 0;
// Initialize the rest of the variables to their proper state
_vars["ttelescope"] = 5;
_vars["tgatestate"] = 1;
_vars["jbridge1"] = 1;
_vars["jbridge4"] = 1;
_vars["jgallows"] = 1;
_vars["jiconcorrectorder"] = 12068577;
_vars["bblrvalve"] = 1;
_vars["bblrwtr"] = 1;
_vars["bfans"] = 1;
_vars["bytrap"] = 2;
_vars["aatruspage"] = 1;
_vars["acathpage"] = 1;
_vars["bheat"] = 1;
_vars["waterenabled"] = 1;
_vars["ogehnpage"] = 1;
_vars["bblrsw"] = 1;
_vars["ocage"] = 1;
_vars["jbeetle"] = 1;
_vars["tdl"] = 1;
_vars["bmagcar"] = 1;
_vars["gnmagcar"] = 1;
_vars["omusicplayer"] = 1;
_vars["transitionmode"] = <API key>;
_vars["tdomeelev"] = 1;
// Randomize the telescope combination
uint32 &teleCombo = _vars["tcorrectorder"];
for (byte i = 0; i < 5; i++) {
teleCombo *= 10;
teleCombo += _rnd->getRandomNumberRng(1, 5); // 5 buttons
}
// Randomize the prison combination
uint32 &prisonCombo = _vars["pcorrectorder"];
for (byte i = 0; i < 5; i++) {
prisonCombo *= 10;
prisonCombo += _rnd->getRandomNumberRng(1, 3); // 3 buttons/sounds
}
// Randomize the dome combination -- each bit represents a slider position,
// the highest bit (1 << 24) represents 1, (1 << 23) represents 2, etc.
uint32 &domeCombo = _vars["adomecombo"];
for (byte bitsSet = 0; bitsSet < 5;) {
uint32 randomBit = 1 << (24 - _rnd->getRandomNumber(24));
// Don't overwrite a bit we already set, and throw out the bottom five bits being set
if (domeCombo & randomBit || (domeCombo | randomBit) == 31)
continue;
domeCombo |= randomBit;
bitsSet++;
}
}
} // End of namespace Mohawk |
#ifndef __CONFIG_PANDA_H
#define __CONFIG_PANDA_H
/*
* High Level Configuration Options
*/
#define CONFIG_PANDA /* working with Panda */
/* USB UHH support options */
#define CONFIG_CMD_USB
#define CONFIG_USB_HOST
#define CONFIG_USB_EHCI
#define <API key>
#define CONFIG_USB_STORAGE
#define <API key> 3
#define <API key> 1
#define <API key> 62
/* USB Networking options */
#define <API key>
#define <API key>
#define <API key>
#define CONFIG_CMD_PING
#define CONFIG_CMD_DHCP
#define CONFIG_USB_ULPI
#define <API key>
#include <configs/omap4_common.h>
#define CONFIG_CMD_NET
/* GPIO */
#define CONFIG_CMD_GPIO
/* ENV related config options */
#define <API key>
#define CONFIG_SYS_PROMPT "Panda
#endif /* __CONFIG_PANDA_H */ |
// <API key>: GPL-2.0-only
#define pr_fmt(fmt) "software IO TLB: " fmt
#include <linux/cache.h>
#include <linux/dma-direct.h>
#include <linux/dma-map-ops.h>
#include <linux/mm.h>
#include <linux/export.h>
#include <linux/spinlock.h>
#include <linux/string.h>
#include <linux/swiotlb.h>
#include <linux/pfn.h>
#include <linux/types.h>
#include <linux/ctype.h>
#include <linux/highmem.h>
#include <linux/gfp.h>
#include <linux/scatterlist.h>
#include <linux/mem_encrypt.h>
#include <linux/set_memory.h>
#ifdef CONFIG_DEBUG_FS
#include <linux/debugfs.h>
#endif
#include <asm/io.h>
#include <asm/dma.h>
#include <linux/init.h>
#include <linux/memblock.h>
#include <linux/iommu-helper.h>
#define CREATE_TRACE_POINTS
#include <trace/events/swiotlb.h>
#define SLABS_PER_PAGE (1 << (PAGE_SHIFT - IO_TLB_SHIFT))
/*
* Minimum IO TLB size to bother booting with. Systems with mainly
* 64bit capable cards will only lightly use the swiotlb. If we can't
* allocate a contiguous 1MB, we're probably in trouble anyway.
*/
#define IO_TLB_MIN_SLABS ((1<<20) >> IO_TLB_SHIFT)
enum swiotlb_force swiotlb_force;
/*
* Used to do a quick range check in <API key> and
* <API key>*, to see if the memory was in fact allocated by this
* API.
*/
phys_addr_t io_tlb_start, io_tlb_end;
/*
* The number of IO TLB blocks (in groups of 64) between io_tlb_start and
* io_tlb_end. This is command line adjustable via setup_io_tlb_npages.
*/
static unsigned long io_tlb_nslabs;
/*
* The number of used IO TLB block
*/
static unsigned long io_tlb_used;
/*
* This is a free list describing the number of free entries available from
* each index
*/
static unsigned int *io_tlb_list;
static unsigned int io_tlb_index;
/*
* Max segment that we can provide which (if pages are contingous) will
* not be bounced (unless SWIOTLB_FORCE is set).
*/
static unsigned int max_segment;
/*
* We need to save away the original address corresponding to a mapped entry
* for the sync operations.
*/
#define INVALID_PHYS_ADDR (~(phys_addr_t)0)
static phys_addr_t *io_tlb_orig_addr;
/*
* The mapped buffer's size should be validated during a sync operation.
*/
static size_t *io_tlb_orig_size;
/*
* Protect the above data structures in the map and unmap calls
*/
static DEFINE_SPINLOCK(io_tlb_lock);
static int late_alloc;
static int __init
setup_io_tlb_npages(char *str)
{
if (isdigit(*str)) {
io_tlb_nslabs = simple_strtoul(str, &str, 0);
/* avoid tail segment of size < IO_TLB_SEGSIZE */
io_tlb_nslabs = ALIGN(io_tlb_nslabs, IO_TLB_SEGSIZE);
}
if (*str == ',')
++str;
if (!strcmp(str, "force")) {
swiotlb_force = SWIOTLB_FORCE;
} else if (!strcmp(str, "noforce")) {
swiotlb_force = SWIOTLB_NO_FORCE;
io_tlb_nslabs = 1;
}
return 0;
}
early_param("swiotlb", setup_io_tlb_npages);
static bool no_iotlb_memory;
unsigned long swiotlb_nr_tbl(void)
{
return unlikely(no_iotlb_memory) ? 0 : io_tlb_nslabs;
}
EXPORT_SYMBOL_GPL(swiotlb_nr_tbl);
unsigned int swiotlb_max_segment(void)
{
return unlikely(no_iotlb_memory) ? 0 : max_segment;
}
EXPORT_SYMBOL_GPL(swiotlb_max_segment);
void <API key>(unsigned int val)
{
if (swiotlb_force == SWIOTLB_FORCE)
max_segment = 1;
else
max_segment = rounddown(val, PAGE_SIZE);
}
unsigned long <API key>(void)
{
unsigned long size;
size = io_tlb_nslabs << IO_TLB_SHIFT;
return size ? size : (IO_TLB_DEFAULT_SIZE);
}
void __init swiotlb_adjust_size(unsigned long new_size)
{
unsigned long size;
/*
* If swiotlb parameter has not been specified, give a chance to
* architectures such as those supporting memory encryption to
* adjust/expand SWIOTLB size for their use.
*/
if (!io_tlb_nslabs) {
size = ALIGN(new_size, IO_TLB_SIZE);
io_tlb_nslabs = size >> IO_TLB_SHIFT;
io_tlb_nslabs = ALIGN(io_tlb_nslabs, IO_TLB_SEGSIZE);
pr_info("SWIOTLB bounce buffer size adjusted to %luMB", size >> 20);
}
}
void swiotlb_print_info(void)
{
unsigned long bytes = io_tlb_nslabs << IO_TLB_SHIFT;
if (no_iotlb_memory) {
pr_warn("No low mem\n");
return;
}
pr_info("mapped [mem %pa-%pa] (%luMB)\n", &io_tlb_start, &io_tlb_end,
bytes >> 20);
}
static inline unsigned long io_tlb_offset(unsigned long val)
{
return val & (IO_TLB_SEGSIZE - 1);
}
static inline unsigned long nr_slots(u64 val)
{
return DIV_ROUND_UP(val, IO_TLB_SIZE);
}
/*
* Early SWIOTLB allocation may be too early to allow an architecture to
* perform the desired operations. This function allows the architecture to
* call SWIOTLB when the operations are possible. It needs to be called
* before the SWIOTLB memory is used.
*/
void __init <API key>(void)
{
void *vaddr;
unsigned long bytes;
if (no_iotlb_memory || late_alloc)
return;
vaddr = phys_to_virt(io_tlb_start);
bytes = PAGE_ALIGN(io_tlb_nslabs << IO_TLB_SHIFT);
<API key>((unsigned long)vaddr, bytes >> PAGE_SHIFT);
memset(vaddr, 0, bytes);
}
int __init <API key>(char *tlb, unsigned long nslabs, int verbose)
{
unsigned long i, bytes;
size_t alloc_size;
bytes = nslabs << IO_TLB_SHIFT;
io_tlb_nslabs = nslabs;
io_tlb_start = __pa(tlb);
io_tlb_end = io_tlb_start + bytes;
/*
* Allocate and initialize the free list array. This array is used
* to find contiguous free memory regions of size up to IO_TLB_SEGSIZE
* between io_tlb_start and io_tlb_end.
*/
alloc_size = PAGE_ALIGN(io_tlb_nslabs * sizeof(int));
io_tlb_list = memblock_alloc(alloc_size, PAGE_SIZE);
if (!io_tlb_list)
panic("%s: Failed to allocate %zu bytes align=0x%lx\n",
__func__, alloc_size, PAGE_SIZE);
alloc_size = PAGE_ALIGN(io_tlb_nslabs * sizeof(phys_addr_t));
io_tlb_orig_addr = memblock_alloc(alloc_size, PAGE_SIZE);
if (!io_tlb_orig_addr)
panic("%s: Failed to allocate %zu bytes align=0x%lx\n",
__func__, alloc_size, PAGE_SIZE);
alloc_size = PAGE_ALIGN(io_tlb_nslabs * sizeof(size_t));
io_tlb_orig_size = memblock_alloc(alloc_size, PAGE_SIZE);
if (!io_tlb_orig_size)
panic("%s: Failed to allocate %zu bytes align=0x%lx\n",
__func__, alloc_size, PAGE_SIZE);
for (i = 0; i < io_tlb_nslabs; i++) {
io_tlb_list[i] = IO_TLB_SEGSIZE - io_tlb_offset(i);
io_tlb_orig_addr[i] = INVALID_PHYS_ADDR;
io_tlb_orig_size[i] = 0;
}
io_tlb_index = 0;
no_iotlb_memory = false;
if (verbose)
swiotlb_print_info();
<API key>(io_tlb_nslabs << IO_TLB_SHIFT);
return 0;
}
/*
* Statically reserve bounce buffer space and initialize bounce buffer data
* structures for the software IO TLB used to implement the DMA API.
*/
void __init
swiotlb_init(int verbose)
{
size_t default_size = IO_TLB_DEFAULT_SIZE;
unsigned char *vstart;
unsigned long bytes;
if (!io_tlb_nslabs) {
io_tlb_nslabs = (default_size >> IO_TLB_SHIFT);
io_tlb_nslabs = ALIGN(io_tlb_nslabs, IO_TLB_SEGSIZE);
}
bytes = io_tlb_nslabs << IO_TLB_SHIFT;
/* Get IO TLB memory from the low pages */
vstart = memblock_alloc_low(PAGE_ALIGN(bytes), PAGE_SIZE);
if (vstart && !<API key>(vstart, io_tlb_nslabs, verbose))
return;
if (io_tlb_start) {
memblock_free_early(io_tlb_start,
PAGE_ALIGN(io_tlb_nslabs << IO_TLB_SHIFT));
io_tlb_start = 0;
}
pr_warn("Cannot allocate buffer");
no_iotlb_memory = true;
}
/*
* Systems with larger DMA zones (those that don't support ISA) can
* initialize the swiotlb later using the slab allocator if needed.
* This should be just like above, but with some error catching.
*/
int
<API key>(size_t default_size)
{
unsigned long bytes, req_nslabs = io_tlb_nslabs;
unsigned char *vstart = NULL;
unsigned int order;
int rc = 0;
if (!io_tlb_nslabs) {
io_tlb_nslabs = (default_size >> IO_TLB_SHIFT);
io_tlb_nslabs = ALIGN(io_tlb_nslabs, IO_TLB_SEGSIZE);
}
/*
* Get IO TLB memory from the low pages
*/
order = get_order(io_tlb_nslabs << IO_TLB_SHIFT);
io_tlb_nslabs = SLABS_PER_PAGE << order;
bytes = io_tlb_nslabs << IO_TLB_SHIFT;
while ((SLABS_PER_PAGE << order) > IO_TLB_MIN_SLABS) {
vstart = (void *)__get_free_pages(GFP_DMA | __GFP_NOWARN,
order);
if (vstart)
break;
order
}
if (!vstart) {
io_tlb_nslabs = req_nslabs;
return -ENOMEM;
}
if (order != get_order(bytes)) {
pr_warn("only able to allocate %ld MB\n",
(PAGE_SIZE << order) >> 20);
io_tlb_nslabs = SLABS_PER_PAGE << order;
}
rc = <API key>(vstart, io_tlb_nslabs);
if (rc)
free_pages((unsigned long)vstart, order);
return rc;
}
static void swiotlb_cleanup(void)
{
io_tlb_end = 0;
io_tlb_start = 0;
io_tlb_nslabs = 0;
max_segment = 0;
}
int
<API key>(char *tlb, unsigned long nslabs)
{
unsigned long i, bytes;
bytes = nslabs << IO_TLB_SHIFT;
io_tlb_nslabs = nslabs;
io_tlb_start = virt_to_phys(tlb);
io_tlb_end = io_tlb_start + bytes;
<API key>((unsigned long)tlb, bytes >> PAGE_SHIFT);
memset(tlb, 0, bytes);
/*
* Allocate and initialize the free list array. This array is used
* to find contiguous free memory regions of size up to IO_TLB_SEGSIZE
* between io_tlb_start and io_tlb_end.
*/
io_tlb_list = (unsigned int *)__get_free_pages(GFP_KERNEL,
get_order(io_tlb_nslabs * sizeof(int)));
if (!io_tlb_list)
goto cleanup3;
io_tlb_orig_addr = (phys_addr_t *)
__get_free_pages(GFP_KERNEL,
get_order(io_tlb_nslabs *
sizeof(phys_addr_t)));
if (!io_tlb_orig_addr)
goto cleanup4;
io_tlb_orig_size = (size_t *)
__get_free_pages(GFP_KERNEL,
get_order(io_tlb_nslabs *
sizeof(size_t)));
if (!io_tlb_orig_size)
goto cleanup5;
for (i = 0; i < io_tlb_nslabs; i++) {
io_tlb_list[i] = IO_TLB_SEGSIZE - io_tlb_offset(i);
io_tlb_orig_addr[i] = INVALID_PHYS_ADDR;
io_tlb_orig_size[i] = 0;
}
io_tlb_index = 0;
no_iotlb_memory = false;
swiotlb_print_info();
late_alloc = 1;
<API key>(io_tlb_nslabs << IO_TLB_SHIFT);
return 0;
cleanup5:
free_pages((unsigned long)io_tlb_orig_addr, get_order(io_tlb_nslabs *
sizeof(phys_addr_t)));
cleanup4:
free_pages((unsigned long)io_tlb_list, get_order(io_tlb_nslabs *
sizeof(int)));
io_tlb_list = NULL;
cleanup3:
swiotlb_cleanup();
return -ENOMEM;
}
void __init swiotlb_exit(void)
{
if (!io_tlb_orig_addr)
return;
if (late_alloc) {
free_pages((unsigned long)io_tlb_orig_size,
get_order(io_tlb_nslabs * sizeof(size_t)));
free_pages((unsigned long)io_tlb_orig_addr,
get_order(io_tlb_nslabs * sizeof(phys_addr_t)));
free_pages((unsigned long)io_tlb_list, get_order(io_tlb_nslabs *
sizeof(int)));
free_pages((unsigned long)phys_to_virt(io_tlb_start),
get_order(io_tlb_nslabs << IO_TLB_SHIFT));
} else {
memblock_free_late(__pa(io_tlb_orig_addr),
PAGE_ALIGN(io_tlb_nslabs * sizeof(phys_addr_t)));
memblock_free_late(__pa(io_tlb_orig_size),
PAGE_ALIGN(io_tlb_nslabs * sizeof(size_t)));
memblock_free_late(__pa(io_tlb_list),
PAGE_ALIGN(io_tlb_nslabs * sizeof(int)));
memblock_free_late(io_tlb_start,
PAGE_ALIGN(io_tlb_nslabs << IO_TLB_SHIFT));
}
swiotlb_cleanup();
}
/*
* Bounce: copy the swiotlb buffer from or back to the original dma location
*/
static void swiotlb_bounce(phys_addr_t orig_addr, phys_addr_t tlb_addr,
size_t size, enum dma_data_direction dir)
{
unsigned long pfn = PFN_DOWN(orig_addr);
unsigned char *vaddr = phys_to_virt(tlb_addr);
if (PageHighMem(pfn_to_page(pfn))) {
/* The buffer does not have a mapping. Map it in and copy */
unsigned int offset = orig_addr & ~PAGE_MASK;
char *buffer;
unsigned int sz = 0;
unsigned long flags;
while (size) {
sz = min_t(size_t, PAGE_SIZE - offset, size);
local_irq_save(flags);
buffer = kmap_atomic(pfn_to_page(pfn));
if (dir == DMA_TO_DEVICE)
memcpy(vaddr, buffer + offset, sz);
else
memcpy(buffer + offset, vaddr, sz);
kunmap_atomic(buffer);
local_irq_restore(flags);
size -= sz;
pfn++;
vaddr += sz;
offset = 0;
}
} else if (dir == DMA_TO_DEVICE) {
memcpy(vaddr, phys_to_virt(orig_addr), size);
} else {
memcpy(phys_to_virt(orig_addr), vaddr, size);
}
}
#define slot_addr(start, idx) ((start) + ((idx) << IO_TLB_SHIFT))
/*
* Return the offset into a iotlb slot required to keep the device happy.
*/
static unsigned int <API key>(struct device *dev, u64 addr)
{
return addr & <API key>(dev) & (IO_TLB_SIZE - 1);
}
/*
* Carefully handle integer overflow which can occur when boundary_mask == ~0UL.
*/
static inline unsigned long get_max_slots(unsigned long boundary_mask)
{
if (boundary_mask == ~0UL)
return 1UL << (BITS_PER_LONG - IO_TLB_SHIFT);
return nr_slots(boundary_mask + 1);
}
static unsigned int wrap_index(unsigned int index)
{
if (index >= io_tlb_nslabs)
return 0;
return index;
}
/*
* Find a suitable number of IO TLB entries size that will fit this request and
* allocate a buffer from that IO TLB pool.
*/
static int find_slots(struct device *dev, phys_addr_t orig_addr,
size_t alloc_size)
{
unsigned long boundary_mask = <API key>(dev);
dma_addr_t tbl_dma_addr =
<API key>(dev, io_tlb_start) & boundary_mask;
unsigned long max_slots = get_max_slots(boundary_mask);
unsigned int iotlb_align_mask =
<API key>(dev) & ~(IO_TLB_SIZE - 1);
unsigned int nslots = nr_slots(alloc_size), stride;
unsigned int index, wrap, count = 0, i;
unsigned long flags;
BUG_ON(!nslots);
/*
* For mappings with an alignment requirement don't bother looping to
* unaligned slots once we found an aligned one. For allocations of
* PAGE_SIZE or larger only look for page aligned allocations.
*/
stride = (iotlb_align_mask >> IO_TLB_SHIFT) + 1;
if (alloc_size >= PAGE_SIZE)
stride = max(stride, stride << (PAGE_SHIFT - IO_TLB_SHIFT));
spin_lock_irqsave(&io_tlb_lock, flags);
if (unlikely(nslots > io_tlb_nslabs - io_tlb_used))
goto not_found;
index = wrap = wrap_index(ALIGN(io_tlb_index, stride));
do {
if ((slot_addr(tbl_dma_addr, index) & iotlb_align_mask) !=
(orig_addr & iotlb_align_mask)) {
index = wrap_index(index + 1);
continue;
}
/*
* If we find a slot that indicates we have 'nslots' number of
* contiguous buffers, we allocate the buffers from that slot
* and mark the entries as '0' indicating unavailable.
*/
if (!<API key>(index, nslots,
nr_slots(tbl_dma_addr),
max_slots)) {
if (io_tlb_list[index] >= nslots)
goto found;
}
index = wrap_index(index + stride);
} while (index != wrap);
not_found:
<API key>(&io_tlb_lock, flags);
return -1;
found:
for (i = index; i < index + nslots; i++)
io_tlb_list[i] = 0;
for (i = index - 1;
io_tlb_offset(i) != IO_TLB_SEGSIZE - 1 &&
io_tlb_list[i]; i
io_tlb_list[i] = ++count;
/*
* Update the indices to avoid searching in the next round.
*/
if (index + nslots < io_tlb_nslabs)
io_tlb_index = index + nslots;
else
io_tlb_index = 0;
io_tlb_used += nslots;
<API key>(&io_tlb_lock, flags);
return index;
}
phys_addr_t <API key>(struct device *dev, phys_addr_t orig_addr,
size_t mapping_size, size_t alloc_size,
enum dma_data_direction dir, unsigned long attrs)
{
unsigned int offset = <API key>(dev, orig_addr);
unsigned int index, i;
phys_addr_t tlb_addr;
if (no_iotlb_memory)
panic("Can not allocate SWIOTLB buffer earlier and can't now provide you with the DMA bounce buffer");
if (mem_encrypt_active())
pr_warn_once("Memory encryption is active and system is using DMA bounce buffers\n");
if (mapping_size > alloc_size) {
dev_warn_once(dev, "Invalid sizes (mapping: %zd bytes, alloc: %zd bytes)",
mapping_size, alloc_size);
return (phys_addr_t)DMA_MAPPING_ERROR;
}
index = find_slots(dev, orig_addr, alloc_size + offset);
if (index == -1) {
if (!(attrs & DMA_ATTR_NO_WARN))
<API key>(dev,
"swiotlb buffer is full (sz: %zd bytes), total %lu (slots), used %lu (slots)\n",
alloc_size, io_tlb_nslabs, io_tlb_used);
return (phys_addr_t)DMA_MAPPING_ERROR;
}
/*
* Save away the mapping from the original address to the DMA address.
* This is needed when we sync the memory. Then we sync the buffer if
* needed.
*/
for (i = 0; i < nr_slots(alloc_size + offset); i++) {
io_tlb_orig_addr[index + i] = slot_addr(orig_addr, i);
io_tlb_orig_size[index+i] = alloc_size - (i << IO_TLB_SHIFT);
}
tlb_addr = slot_addr(io_tlb_start, index) + offset;
if (!(attrs & <API key>) &&
(dir == DMA_TO_DEVICE || dir == DMA_BIDIRECTIONAL))
swiotlb_bounce(orig_addr, tlb_addr, mapping_size, DMA_TO_DEVICE);
return tlb_addr;
}
static void <API key>(struct device *hwdev, size_t orig_size, size_t *size)
{
if (*size > orig_size) {
/* Warn and truncate mapping_size */
dev_WARN_ONCE(hwdev, 1,
"Attempt for buffer overflow. Original size: %zu. Mapping size: %zu.\n",
orig_size, *size);
*size = orig_size;
}
}
/*
* tlb_addr is the physical address of the bounce buffer to unmap.
*/
void <API key>(struct device *hwdev, phys_addr_t tlb_addr,
size_t mapping_size, size_t alloc_size,
enum dma_data_direction dir, unsigned long attrs)
{
unsigned long flags;
unsigned int offset = <API key>(hwdev, tlb_addr);
int i, count, nslots = nr_slots(alloc_size + offset);
int index = (tlb_addr - offset - io_tlb_start) >> IO_TLB_SHIFT;
phys_addr_t orig_addr = io_tlb_orig_addr[index];
<API key>(hwdev, io_tlb_orig_size[index], &mapping_size);
/*
* First, sync the memory before unmapping the entry
*/
if (orig_addr != INVALID_PHYS_ADDR &&
!(attrs & <API key>) &&
((dir == DMA_FROM_DEVICE) || (dir == DMA_BIDIRECTIONAL)))
swiotlb_bounce(orig_addr, tlb_addr, mapping_size, DMA_FROM_DEVICE);
/*
* Return the buffer to the free list by setting the corresponding
* entries to indicate the number of contiguous entries available.
* While returning the entries to the free list, we merge the entries
* with slots below and above the pool being returned.
*/
spin_lock_irqsave(&io_tlb_lock, flags);
if (index + nslots < ALIGN(index + 1, IO_TLB_SEGSIZE))
count = io_tlb_list[index + nslots];
else
count = 0;
/*
* Step 1: return the slots to the free list, merging the slots with
* superceeding slots
*/
for (i = index + nslots - 1; i >= index; i
io_tlb_list[i] = ++count;
io_tlb_orig_addr[i] = INVALID_PHYS_ADDR;
io_tlb_orig_size[i] = 0;
}
/*
* Step 2: merge the returned slots with the preceding slots, if
* available (non zero)
*/
for (i = index - 1;
io_tlb_offset(i) != IO_TLB_SEGSIZE - 1 && io_tlb_list[i];
i
io_tlb_list[i] = ++count;
io_tlb_used -= nslots;
<API key>(&io_tlb_lock, flags);
}
void <API key>(struct device *hwdev, phys_addr_t tlb_addr,
size_t size, enum dma_data_direction dir,
enum dma_sync_target target)
{
int index = (tlb_addr - io_tlb_start) >> IO_TLB_SHIFT;
size_t orig_size = io_tlb_orig_size[index];
phys_addr_t orig_addr = io_tlb_orig_addr[index];
if (orig_addr == INVALID_PHYS_ADDR)
return;
<API key>(hwdev, orig_size, &size);
switch (target) {
case SYNC_FOR_CPU:
if (likely(dir == DMA_FROM_DEVICE || dir == DMA_BIDIRECTIONAL))
swiotlb_bounce(orig_addr, tlb_addr,
size, DMA_FROM_DEVICE);
else
BUG_ON(dir != DMA_TO_DEVICE);
break;
case SYNC_FOR_DEVICE:
if (likely(dir == DMA_TO_DEVICE || dir == DMA_BIDIRECTIONAL))
swiotlb_bounce(orig_addr, tlb_addr,
size, DMA_TO_DEVICE);
else
BUG_ON(dir != DMA_FROM_DEVICE);
break;
default:
BUG();
}
}
/*
* Create a swiotlb mapping for the buffer at @paddr, and in case of DMAing
* to the device copy the data into it as well.
*/
dma_addr_t swiotlb_map(struct device *dev, phys_addr_t paddr, size_t size,
enum dma_data_direction dir, unsigned long attrs)
{
phys_addr_t swiotlb_addr;
dma_addr_t dma_addr;
<API key>(dev, phys_to_dma(dev, paddr), size,
swiotlb_force);
swiotlb_addr = <API key>(dev, paddr, size, size, dir,
attrs);
if (swiotlb_addr == (phys_addr_t)DMA_MAPPING_ERROR)
return DMA_MAPPING_ERROR;
/* Ensure that the address returned is DMA'ble */
dma_addr = <API key>(dev, swiotlb_addr);
if (unlikely(!dma_capable(dev, dma_addr, size, true))) {
<API key>(dev, swiotlb_addr, size, size, dir,
attrs | <API key>);
dev_WARN_ONCE(dev, 1,
"swiotlb addr %pad+%zu overflow (mask %llx, bus limit %llx).\n",
&dma_addr, size, *dev->dma_mask, dev->bus_dma_limit);
return DMA_MAPPING_ERROR;
}
if (!dev_is_dma_coherent(dev) && !(attrs & <API key>))
<API key>(swiotlb_addr, size, dir);
return dma_addr;
}
size_t <API key>(struct device *dev)
{
return ((size_t)IO_TLB_SIZE) * IO_TLB_SEGSIZE;
}
bool is_swiotlb_active(void)
{
/*
* When SWIOTLB is initialized, even if io_tlb_start points to physical
* address zero, io_tlb_end surely doesn't.
*/
return io_tlb_end != 0;
}
#ifdef CONFIG_DEBUG_FS
static int __init <API key>(void)
{
struct dentry *root;
root = debugfs_create_dir("swiotlb", NULL);
<API key>("io_tlb_nslabs", 0400, root, &io_tlb_nslabs);
<API key>("io_tlb_used", 0400, root, &io_tlb_used);
return 0;
}
late_initcall(<API key>);
#endif |
#include <pthread.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
static int global;
static void
ch (void *arg)
{
int val = (long int) arg;
printf ("ch (%d)\n", val);
global *= val;
global += val;
}
static void *
tf (void *a)
{
<API key> (ch, (void *) 1l);
<API key> (ch, (void *) 2l);
<API key> (ch, (void *) 3l);
pthread_exit ((void *) 1l);
pthread_cleanup_pop (1);
pthread_cleanup_pop (1);
pthread_cleanup_pop (1);
return NULL;
}
int
do_test (void)
{
pthread_t th;
if (pthread_create (&th, NULL, tf, NULL) != 0)
{
write (2, "create failed\n", 14);
_exit (1);
}
void *r;
int e;
if ((e = pthread_join (th, &r)) != 0)
{
printf ("join failed: %d\n", e);
_exit (1);
}
if (r != (void *) 1l)
{
puts ("thread not canceled");
exit (1);
}
if (global != 9)
{
printf ("global = %d, expected 9\n", global);
exit (1);
}
return 0;
}
#define TEST_FUNCTION do_test ()
#include "../test-skeleton.c" |
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/types.h>
#include <linux/fcntl.h>
#include <linux/random.h>
#include <linux/slab.h>
#include <linux/cache.h>
#include <linux/init.h>
#include <linux/time.h>
#include <net/icmp.h>
#include <net/tcp.h>
#include <net/ipv6.h>
#include <net/inet_common.h>
#include <net/<API key>.h>
#include <net/inet_hashtables.h>
#include <net/inet_timewait_sock.h>
#include <net/inet6_hashtables.h>
#include <net/netlink.h>
#include <linux/inet.h>
#include <linux/stddef.h>
#include <linux/inet_diag.h>
#include <linux/sock_diag.h>
static const struct inet_diag_handler **inet_diag_table;
struct inet_diag_entry {
const __be32 *saddr;
const __be32 *daddr;
u16 sport;
u16 dport;
u16 family;
u16 userlocks;
};
static DEFINE_MUTEX(<API key>);
static const struct inet_diag_handler *<API key>(int proto)
{
if (!inet_diag_table[proto])
request_module("net-pf-%d-proto-%d-type-%d-%d", PF_NETLINK,
NETLINK_SOCK_DIAG, AF_INET, proto);
mutex_lock(&<API key>);
if (!inet_diag_table[proto])
return ERR_PTR(-ENOENT);
return inet_diag_table[proto];
}
static void <API key>(const struct inet_diag_handler *handler)
{
mutex_unlock(&<API key>);
}
static void <API key>(struct inet_diag_msg *r, struct sock *sk)
{
r->idiag_family = sk->sk_family;
r->id.idiag_sport = htons(sk->sk_num);
r->id.idiag_dport = sk->sk_dport;
r->id.idiag_if = sk->sk_bound_dev_if;
<API key>(sk, r->id.idiag_cookie);
#if IS_ENABLED(CONFIG_IPV6)
if (sk->sk_family == AF_INET6) {
*(struct in6_addr *)r->id.idiag_src = sk->sk_v6_rcv_saddr;
*(struct in6_addr *)r->id.idiag_dst = sk->sk_v6_daddr;
} else
#endif
{
memset(&r->id.idiag_src, 0, sizeof(r->id.idiag_src));
memset(&r->id.idiag_dst, 0, sizeof(r->id.idiag_dst));
r->id.idiag_src[0] = sk->sk_rcv_saddr;
r->id.idiag_dst[0] = sk->sk_daddr;
}
}
static size_t inet_sk_attr_size(void)
{
return nla_total_size(sizeof(struct tcp_info))
+ nla_total_size(1) /* INET_DIAG_SHUTDOWN */
+ nla_total_size(1) /* INET_DIAG_TOS */
+ nla_total_size(1) /* INET_DIAG_TCLASS */
+ nla_total_size(sizeof(struct inet_diag_meminfo))
+ nla_total_size(sizeof(struct inet_diag_msg))
+ nla_total_size(SK_MEMINFO_VARS * sizeof(u32))
+ nla_total_size(TCP_CA_NAME_MAX)
+ nla_total_size(sizeof(struct tcpvegas_info))
+ 64;
}
int inet_sk_diag_fill(struct sock *sk, struct <API key> *icsk,
struct sk_buff *skb, const struct inet_diag_req_v2 *req,
struct user_namespace *user_ns,
u32 portid, u32 seq, u16 nlmsg_flags,
const struct nlmsghdr *unlh)
{
const struct inet_sock *inet = inet_sk(sk);
const struct tcp_congestion_ops *ca_ops;
const struct inet_diag_handler *handler;
int ext = req->idiag_ext;
struct inet_diag_msg *r;
struct nlmsghdr *nlh;
struct nlattr *attr;
void *info = NULL;
handler = inet_diag_table[req->sdiag_protocol];
BUG_ON(!handler);
nlh = nlmsg_put(skb, portid, seq, unlh->nlmsg_type, sizeof(*r),
nlmsg_flags);
if (!nlh)
return -EMSGSIZE;
r = nlmsg_data(nlh);
BUG_ON(!sk_fullsock(sk));
<API key>(r, sk);
r->idiag_state = sk->sk_state;
r->idiag_timer = 0;
r->idiag_retrans = 0;
if (nla_put_u8(skb, INET_DIAG_SHUTDOWN, sk->sk_shutdown))
goto errout;
/* IPv6 dual-stack sockets use inet->tos for IPv4 connections,
* hence this needs to be included regardless of socket family.
*/
if (ext & (1 << (INET_DIAG_TOS - 1)))
if (nla_put_u8(skb, INET_DIAG_TOS, inet->tos) < 0)
goto errout;
#if IS_ENABLED(CONFIG_IPV6)
if (r->idiag_family == AF_INET6) {
if (ext & (1 << (INET_DIAG_TCLASS - 1)))
if (nla_put_u8(skb, INET_DIAG_TCLASS,
inet6_sk(sk)->tclass) < 0)
goto errout;
if (ipv6_only_sock(sk) &&
nla_put_u8(skb, INET_DIAG_SKV6ONLY, 1))
goto errout;
}
#endif
r->idiag_uid = from_kuid_munged(user_ns, sock_i_uid(sk));
r->idiag_inode = sock_i_ino(sk);
if (ext & (1 << (INET_DIAG_MEMINFO - 1))) {
struct inet_diag_meminfo minfo = {
.idiag_rmem = sk_rmem_alloc_get(sk),
.idiag_wmem = sk->sk_wmem_queued,
.idiag_fmem = sk->sk_forward_alloc,
.idiag_tmem = sk_wmem_alloc_get(sk),
};
if (nla_put(skb, INET_DIAG_MEMINFO, sizeof(minfo), &minfo) < 0)
goto errout;
}
if (ext & (1 << (INET_DIAG_SKMEMINFO - 1)))
if (<API key>(sk, skb, INET_DIAG_SKMEMINFO))
goto errout;
if (!icsk) {
handler->idiag_get_info(sk, r, NULL);
goto out;
}
#define EXPIRES_IN_MS(tmo) DIV_ROUND_UP((tmo - jiffies) * 1000, HZ)
if (icsk->icsk_pending == ICSK_TIME_RETRANS ||
icsk->icsk_pending == <API key> ||
icsk->icsk_pending == <API key>) {
r->idiag_timer = 1;
r->idiag_retrans = icsk->icsk_retransmits;
r->idiag_expires = EXPIRES_IN_MS(icsk->icsk_timeout);
} else if (icsk->icsk_pending == ICSK_TIME_PROBE0) {
r->idiag_timer = 4;
r->idiag_retrans = icsk->icsk_probes_out;
r->idiag_expires = EXPIRES_IN_MS(icsk->icsk_timeout);
} else if (timer_pending(&sk->sk_timer)) {
r->idiag_timer = 2;
r->idiag_retrans = icsk->icsk_probes_out;
r->idiag_expires = EXPIRES_IN_MS(sk->sk_timer.expires);
} else {
r->idiag_timer = 0;
r->idiag_expires = 0;
}
#undef EXPIRES_IN_MS
if ((ext & (1 << (INET_DIAG_INFO - 1))) && handler->idiag_info_size) {
attr = nla_reserve(skb, INET_DIAG_INFO,
handler->idiag_info_size);
if (!attr)
goto errout;
info = nla_data(attr);
}
if (ext & (1 << (INET_DIAG_CONG - 1))) {
int err = 0;
rcu_read_lock();
ca_ops = READ_ONCE(icsk->icsk_ca_ops);
if (ca_ops)
err = nla_put_string(skb, INET_DIAG_CONG, ca_ops->name);
rcu_read_unlock();
if (err < 0)
goto errout;
}
handler->idiag_get_info(sk, r, info);
if (sk->sk_state < TCP_TIME_WAIT) {
union tcp_cc_info info;
size_t sz = 0;
int attr;
rcu_read_lock();
ca_ops = READ_ONCE(icsk->icsk_ca_ops);
if (ca_ops && ca_ops->get_info)
sz = ca_ops->get_info(sk, ext, &attr, &info);
rcu_read_unlock();
if (sz && nla_put(skb, attr, sz, &info) < 0)
goto errout;
}
out:
nlmsg_end(skb, nlh);
return 0;
errout:
nlmsg_cancel(skb, nlh);
return -EMSGSIZE;
}
EXPORT_SYMBOL_GPL(inet_sk_diag_fill);
static int inet_csk_diag_fill(struct sock *sk,
struct sk_buff *skb,
const struct inet_diag_req_v2 *req,
struct user_namespace *user_ns,
u32 portid, u32 seq, u16 nlmsg_flags,
const struct nlmsghdr *unlh)
{
return inet_sk_diag_fill(sk, inet_csk(sk), skb, req,
user_ns, portid, seq, nlmsg_flags, unlh);
}
static int inet_twsk_diag_fill(struct sock *sk,
struct sk_buff *skb,
u32 portid, u32 seq, u16 nlmsg_flags,
const struct nlmsghdr *unlh)
{
struct inet_timewait_sock *tw = inet_twsk(sk);
struct inet_diag_msg *r;
struct nlmsghdr *nlh;
long tmo;
nlh = nlmsg_put(skb, portid, seq, unlh->nlmsg_type, sizeof(*r),
nlmsg_flags);
if (!nlh)
return -EMSGSIZE;
r = nlmsg_data(nlh);
BUG_ON(tw->tw_state != TCP_TIME_WAIT);
tmo = tw->tw_timer.expires - jiffies;
if (tmo < 0)
tmo = 0;
<API key>(r, sk);
r->idiag_retrans = 0;
r->idiag_state = tw->tw_substate;
r->idiag_timer = 3;
r->idiag_expires = jiffies_to_msecs(tmo);
r->idiag_rqueue = 0;
r->idiag_wqueue = 0;
r->idiag_uid = 0;
r->idiag_inode = 0;
nlmsg_end(skb, nlh);
return 0;
}
static int inet_req_diag_fill(struct sock *sk, struct sk_buff *skb,
u32 portid, u32 seq, u16 nlmsg_flags,
const struct nlmsghdr *unlh)
{
struct inet_diag_msg *r;
struct nlmsghdr *nlh;
long tmo;
nlh = nlmsg_put(skb, portid, seq, unlh->nlmsg_type, sizeof(*r),
nlmsg_flags);
if (!nlh)
return -EMSGSIZE;
r = nlmsg_data(nlh);
<API key>(r, sk);
r->idiag_state = TCP_SYN_RECV;
r->idiag_timer = 1;
r->idiag_retrans = inet_reqsk(sk)->num_retrans;
BUILD_BUG_ON(offsetof(struct inet_request_sock, ir_cookie) !=
offsetof(struct sock, sk_cookie));
tmo = inet_reqsk(sk)->rsk_timer.expires - jiffies;
r->idiag_expires = (tmo >= 0) ? jiffies_to_msecs(tmo) : 0;
r->idiag_rqueue = 0;
r->idiag_wqueue = 0;
r->idiag_uid = 0;
r->idiag_inode = 0;
nlmsg_end(skb, nlh);
return 0;
}
static int sk_diag_fill(struct sock *sk, struct sk_buff *skb,
const struct inet_diag_req_v2 *r,
struct user_namespace *user_ns,
u32 portid, u32 seq, u16 nlmsg_flags,
const struct nlmsghdr *unlh)
{
if (sk->sk_state == TCP_TIME_WAIT)
return inet_twsk_diag_fill(sk, skb, portid, seq,
nlmsg_flags, unlh);
if (sk->sk_state == TCP_NEW_SYN_RECV)
return inet_req_diag_fill(sk, skb, portid, seq,
nlmsg_flags, unlh);
return inet_csk_diag_fill(sk, skb, r, user_ns, portid, seq,
nlmsg_flags, unlh);
}
int <API key>(struct inet_hashinfo *hashinfo,
struct sk_buff *in_skb,
const struct nlmsghdr *nlh,
const struct inet_diag_req_v2 *req)
{
struct net *net = sock_net(in_skb->sk);
struct sk_buff *rep;
struct sock *sk;
int err;
err = -EINVAL;
if (req->sdiag_family == AF_INET)
sk = inet_lookup(net, hashinfo, req->id.idiag_dst[0],
req->id.idiag_dport, req->id.idiag_src[0],
req->id.idiag_sport, req->id.idiag_if);
#if IS_ENABLED(CONFIG_IPV6)
else if (req->sdiag_family == AF_INET6)
sk = inet6_lookup(net, hashinfo,
(struct in6_addr *)req->id.idiag_dst,
req->id.idiag_dport,
(struct in6_addr *)req->id.idiag_src,
req->id.idiag_sport,
req->id.idiag_if);
#endif
else
goto out_nosk;
err = -ENOENT;
if (!sk)
goto out_nosk;
err = <API key>(sk, req->id.idiag_cookie);
if (err)
goto out;
rep = nlmsg_new(inet_sk_attr_size(), GFP_KERNEL);
if (!rep) {
err = -ENOMEM;
goto out;
}
err = sk_diag_fill(sk, rep, req,
sk_user_ns(NETLINK_CB(in_skb).sk),
NETLINK_CB(in_skb).portid,
nlh->nlmsg_seq, 0, nlh);
if (err < 0) {
WARN_ON(err == -EMSGSIZE);
nlmsg_free(rep);
goto out;
}
err = netlink_unicast(net->diag_nlsk, rep, NETLINK_CB(in_skb).portid,
MSG_DONTWAIT);
if (err > 0)
err = 0;
out:
if (sk)
sock_gen_put(sk);
out_nosk:
return err;
}
EXPORT_SYMBOL_GPL(<API key>);
static int inet_diag_get_exact(struct sk_buff *in_skb,
const struct nlmsghdr *nlh,
const struct inet_diag_req_v2 *req)
{
const struct inet_diag_handler *handler;
int err;
handler = <API key>(req->sdiag_protocol);
if (IS_ERR(handler))
err = PTR_ERR(handler);
else
err = handler->dump_one(in_skb, nlh, req);
<API key>(handler);
return err;
}
static int bitstring_match(const __be32 *a1, const __be32 *a2, int bits)
{
int words = bits >> 5;
bits &= 0x1f;
if (words) {
if (memcmp(a1, a2, words << 2))
return 0;
}
if (bits) {
__be32 w1, w2;
__be32 mask;
w1 = a1[words];
w2 = a2[words];
mask = htonl((0xffffffff) << (32 - bits));
if ((w1 ^ w2) & mask)
return 0;
}
return 1;
}
static int inet_diag_bc_run(const struct nlattr *_bc,
const struct inet_diag_entry *entry)
{
const void *bc = nla_data(_bc);
int len = nla_len(_bc);
while (len > 0) {
int yes = 1;
const struct inet_diag_bc_op *op = bc;
switch (op->code) {
case INET_DIAG_BC_NOP:
break;
case INET_DIAG_BC_JMP:
yes = 0;
break;
case INET_DIAG_BC_S_GE:
yes = entry->sport >= op[1].no;
break;
case INET_DIAG_BC_S_LE:
yes = entry->sport <= op[1].no;
break;
case INET_DIAG_BC_D_GE:
yes = entry->dport >= op[1].no;
break;
case INET_DIAG_BC_D_LE:
yes = entry->dport <= op[1].no;
break;
case INET_DIAG_BC_AUTO:
yes = !(entry->userlocks & SOCK_BINDPORT_LOCK);
break;
case INET_DIAG_BC_S_COND:
case INET_DIAG_BC_D_COND: {
const struct inet_diag_hostcond *cond;
const __be32 *addr;
cond = (const struct inet_diag_hostcond *)(op + 1);
if (cond->port != -1 &&
cond->port != (op->code == INET_DIAG_BC_S_COND ?
entry->sport : entry->dport)) {
yes = 0;
break;
}
if (op->code == INET_DIAG_BC_S_COND)
addr = entry->saddr;
else
addr = entry->daddr;
if (cond->family != AF_UNSPEC &&
cond->family != entry->family) {
if (entry->family == AF_INET6 &&
cond->family == AF_INET) {
if (addr[0] == 0 && addr[1] == 0 &&
addr[2] == htonl(0xffff) &&
bitstring_match(addr + 3,
cond->addr,
cond->prefix_len))
break;
}
yes = 0;
break;
}
if (cond->prefix_len == 0)
break;
if (bitstring_match(addr, cond->addr,
cond->prefix_len))
break;
yes = 0;
break;
}
}
if (yes) {
len -= op->yes;
bc += op->yes;
} else {
len -= op->no;
bc += op->no;
}
}
return len == 0;
}
/* This helper is available for all sockets (ESTABLISH, TIMEWAIT, SYN_RECV)
*/
static void entry_fill_addrs(struct inet_diag_entry *entry,
const struct sock *sk)
{
#if IS_ENABLED(CONFIG_IPV6)
if (sk->sk_family == AF_INET6) {
entry->saddr = sk->sk_v6_rcv_saddr.s6_addr32;
entry->daddr = sk->sk_v6_daddr.s6_addr32;
} else
#endif
{
entry->saddr = &sk->sk_rcv_saddr;
entry->daddr = &sk->sk_daddr;
}
}
int inet_diag_bc_sk(const struct nlattr *bc, struct sock *sk)
{
struct inet_sock *inet = inet_sk(sk);
struct inet_diag_entry entry;
if (!bc)
return 1;
entry.family = sk->sk_family;
entry_fill_addrs(&entry, sk);
entry.sport = inet->inet_num;
entry.dport = ntohs(inet->inet_dport);
entry.userlocks = sk_fullsock(sk) ? sk->sk_userlocks : 0;
return inet_diag_bc_run(bc, &entry);
}
EXPORT_SYMBOL_GPL(inet_diag_bc_sk);
static int valid_cc(const void *bc, int len, int cc)
{
while (len >= 0) {
const struct inet_diag_bc_op *op = bc;
if (cc > len)
return 0;
if (cc == len)
return 1;
if (op->yes < 4 || op->yes & 3)
return 0;
len -= op->yes;
bc += op->yes;
}
return 0;
}
/* Validate an inet_diag_hostcond. */
static bool valid_hostcond(const struct inet_diag_bc_op *op, int len,
int *min_len)
{
struct inet_diag_hostcond *cond;
int addr_len;
/* Check hostcond space. */
*min_len += sizeof(struct inet_diag_hostcond);
if (len < *min_len)
return false;
cond = (struct inet_diag_hostcond *)(op + 1);
/* Check address family and address length. */
switch (cond->family) {
case AF_UNSPEC:
addr_len = 0;
break;
case AF_INET:
addr_len = sizeof(struct in_addr);
break;
case AF_INET6:
addr_len = sizeof(struct in6_addr);
break;
default:
return false;
}
*min_len += addr_len;
if (len < *min_len)
return false;
/* Check prefix length (in bits) vs address length (in bytes). */
if (cond->prefix_len > 8 * addr_len)
return false;
return true;
}
/* Validate a port comparison operator. */
static bool <API key>(const struct inet_diag_bc_op *op,
int len, int *min_len)
{
/* Port comparisons put the port in a follow-on inet_diag_bc_op. */
*min_len += sizeof(struct inet_diag_bc_op);
if (len < *min_len)
return false;
return true;
}
static int inet_diag_bc_audit(const void *bytecode, int bytecode_len)
{
const void *bc = bytecode;
int len = bytecode_len;
while (len > 0) {
int min_len = sizeof(struct inet_diag_bc_op);
const struct inet_diag_bc_op *op = bc;
switch (op->code) {
case INET_DIAG_BC_S_COND:
case INET_DIAG_BC_D_COND:
if (!valid_hostcond(bc, len, &min_len))
return -EINVAL;
break;
case INET_DIAG_BC_S_GE:
case INET_DIAG_BC_S_LE:
case INET_DIAG_BC_D_GE:
case INET_DIAG_BC_D_LE:
if (!<API key>(bc, len, &min_len))
return -EINVAL;
break;
case INET_DIAG_BC_AUTO:
case INET_DIAG_BC_JMP:
case INET_DIAG_BC_NOP:
break;
default:
return -EINVAL;
}
if (op->code != INET_DIAG_BC_NOP) {
if (op->no < min_len || op->no > len + 4 || op->no & 3)
return -EINVAL;
if (op->no < len &&
!valid_cc(bytecode, bytecode_len, len - op->no))
return -EINVAL;
}
if (op->yes < min_len || op->yes > len + 4 || op->yes & 3)
return -EINVAL;
bc += op->yes;
len -= op->yes;
}
return len == 0 ? 0 : -EINVAL;
}
static int inet_csk_diag_dump(struct sock *sk,
struct sk_buff *skb,
struct netlink_callback *cb,
const struct inet_diag_req_v2 *r,
const struct nlattr *bc)
{
if (!inet_diag_bc_sk(bc, sk))
return 0;
return inet_csk_diag_fill(sk, skb, r,
sk_user_ns(NETLINK_CB(cb->skb).sk),
NETLINK_CB(cb->skb).portid,
cb->nlh->nlmsg_seq, NLM_F_MULTI, cb->nlh);
}
static void twsk_build_assert(void)
{
BUILD_BUG_ON(offsetof(struct inet_timewait_sock, tw_family) !=
offsetof(struct sock, sk_family));
BUILD_BUG_ON(offsetof(struct inet_timewait_sock, tw_num) !=
offsetof(struct inet_sock, inet_num));
BUILD_BUG_ON(offsetof(struct inet_timewait_sock, tw_dport) !=
offsetof(struct inet_sock, inet_dport));
BUILD_BUG_ON(offsetof(struct inet_timewait_sock, tw_rcv_saddr) !=
offsetof(struct inet_sock, inet_rcv_saddr));
BUILD_BUG_ON(offsetof(struct inet_timewait_sock, tw_daddr) !=
offsetof(struct inet_sock, inet_daddr));
#if IS_ENABLED(CONFIG_IPV6)
BUILD_BUG_ON(offsetof(struct inet_timewait_sock, tw_v6_rcv_saddr) !=
offsetof(struct sock, sk_v6_rcv_saddr));
BUILD_BUG_ON(offsetof(struct inet_timewait_sock, tw_v6_daddr) !=
offsetof(struct sock, sk_v6_daddr));
#endif
}
static int inet_diag_dump_reqs(struct sk_buff *skb, struct sock *sk,
struct netlink_callback *cb,
const struct inet_diag_req_v2 *r,
const struct nlattr *bc)
{
struct <API key> *icsk = inet_csk(sk);
struct inet_sock *inet = inet_sk(sk);
struct inet_diag_entry entry;
int j, s_j, reqnum, s_reqnum;
struct listen_sock *lopt;
int err = 0;
s_j = cb->args[3];
s_reqnum = cb->args[4];
if (s_j > 0)
s_j
entry.family = sk->sk_family;
spin_lock(&icsk->icsk_accept_queue.syn_wait_lock);
lopt = icsk->icsk_accept_queue.listen_opt;
if (!lopt || !listen_sock_qlen(lopt))
goto out;
if (bc) {
entry.sport = inet->inet_num;
entry.userlocks = sk->sk_userlocks;
}
for (j = s_j; j < lopt->nr_table_entries; j++) {
struct request_sock *req, *head = lopt->syn_table[j];
reqnum = 0;
for (req = head; req; reqnum++, req = req->dl_next) {
struct inet_request_sock *ireq = inet_rsk(req);
if (reqnum < s_reqnum)
continue;
if (r->id.idiag_dport != ireq->ir_rmt_port &&
r->id.idiag_dport)
continue;
if (bc) {
/* Note: entry.sport and entry.userlocks are already set */
entry_fill_addrs(&entry, req_to_sk(req));
entry.dport = ntohs(ireq->ir_rmt_port);
if (!inet_diag_bc_run(bc, &entry))
continue;
}
err = inet_req_diag_fill(req_to_sk(req), skb,
NETLINK_CB(cb->skb).portid,
cb->nlh->nlmsg_seq,
NLM_F_MULTI, cb->nlh);
if (err < 0) {
cb->args[3] = j + 1;
cb->args[4] = reqnum;
goto out;
}
}
s_reqnum = 0;
}
out:
spin_unlock(&icsk->icsk_accept_queue.syn_wait_lock);
return err;
}
void inet_diag_dump_icsk(struct inet_hashinfo *hashinfo, struct sk_buff *skb,
struct netlink_callback *cb,
const struct inet_diag_req_v2 *r, struct nlattr *bc)
{
struct net *net = sock_net(skb->sk);
int i, num, s_i, s_num;
s_i = cb->args[1];
s_num = num = cb->args[2];
if (cb->args[0] == 0) {
if (!(r->idiag_states & (TCPF_LISTEN | TCPF_SYN_RECV)))
goto skip_listen_ht;
for (i = s_i; i < INET_LHTABLE_SIZE; i++) {
struct <API key> *ilb;
struct hlist_nulls_node *node;
struct sock *sk;
num = 0;
ilb = &hashinfo->listening_hash[i];
spin_lock_bh(&ilb->lock);
sk_nulls_for_each(sk, node, &ilb->head) {
struct inet_sock *inet = inet_sk(sk);
if (!net_eq(sock_net(sk), net))
continue;
if (num < s_num) {
num++;
continue;
}
if (r->sdiag_family != AF_UNSPEC &&
sk->sk_family != r->sdiag_family)
goto next_listen;
if (r->id.idiag_sport != inet->inet_sport &&
r->id.idiag_sport)
goto next_listen;
if (!(r->idiag_states & TCPF_LISTEN) ||
r->id.idiag_dport ||
cb->args[3] > 0)
goto syn_recv;
if (inet_csk_diag_dump(sk, skb, cb, r, bc) < 0) {
spin_unlock_bh(&ilb->lock);
goto done;
}
syn_recv:
if (!(r->idiag_states & TCPF_SYN_RECV))
goto next_listen;
if (inet_diag_dump_reqs(skb, sk, cb, r, bc) < 0) {
spin_unlock_bh(&ilb->lock);
goto done;
}
next_listen:
cb->args[3] = 0;
cb->args[4] = 0;
++num;
}
spin_unlock_bh(&ilb->lock);
s_num = 0;
cb->args[3] = 0;
cb->args[4] = 0;
}
skip_listen_ht:
cb->args[0] = 1;
s_i = num = s_num = 0;
}
if (!(r->idiag_states & ~(TCPF_LISTEN | TCPF_SYN_RECV)))
goto out;
for (i = s_i; i <= hashinfo->ehash_mask; i++) {
struct inet_ehash_bucket *head = &hashinfo->ehash[i];
spinlock_t *lock = inet_ehash_lockp(hashinfo, i);
struct hlist_nulls_node *node;
struct sock *sk;
num = 0;
if (hlist_nulls_empty(&head->chain))
continue;
if (i > s_i)
s_num = 0;
spin_lock_bh(lock);
sk_nulls_for_each(sk, node, &head->chain) {
int state, res;
if (!net_eq(sock_net(sk), net))
continue;
if (num < s_num)
goto next_normal;
state = (sk->sk_state == TCP_TIME_WAIT) ?
inet_twsk(sk)->tw_substate : sk->sk_state;
if (!(r->idiag_states & (1 << state)))
goto next_normal;
if (r->sdiag_family != AF_UNSPEC &&
sk->sk_family != r->sdiag_family)
goto next_normal;
if (r->id.idiag_sport != htons(sk->sk_num) &&
r->id.idiag_sport)
goto next_normal;
if (r->id.idiag_dport != sk->sk_dport &&
r->id.idiag_dport)
goto next_normal;
twsk_build_assert();
if (!inet_diag_bc_sk(bc, sk))
goto next_normal;
res = sk_diag_fill(sk, skb, r,
sk_user_ns(NETLINK_CB(cb->skb).sk),
NETLINK_CB(cb->skb).portid,
cb->nlh->nlmsg_seq, NLM_F_MULTI,
cb->nlh);
if (res < 0) {
spin_unlock_bh(lock);
goto done;
}
next_normal:
++num;
}
spin_unlock_bh(lock);
}
done:
cb->args[1] = i;
cb->args[2] = num;
out:
;
}
EXPORT_SYMBOL_GPL(inet_diag_dump_icsk);
static int __inet_diag_dump(struct sk_buff *skb, struct netlink_callback *cb,
const struct inet_diag_req_v2 *r,
struct nlattr *bc)
{
const struct inet_diag_handler *handler;
int err = 0;
handler = <API key>(r->sdiag_protocol);
if (!IS_ERR(handler))
handler->dump(skb, cb, r, bc);
else
err = PTR_ERR(handler);
<API key>(handler);
return err ? : skb->len;
}
static int inet_diag_dump(struct sk_buff *skb, struct netlink_callback *cb)
{
int hdrlen = sizeof(struct inet_diag_req_v2);
struct nlattr *bc = NULL;
if (nlmsg_attrlen(cb->nlh, hdrlen))
bc = nlmsg_find_attr(cb->nlh, hdrlen, <API key>);
return __inet_diag_dump(skb, cb, nlmsg_data(cb->nlh), bc);
}
static int <API key>(int type)
{
switch (type) {
case TCPDIAG_GETSOCK:
return IPPROTO_TCP;
case DCCPDIAG_GETSOCK:
return IPPROTO_DCCP;
default:
return 0;
}
}
static int <API key>(struct sk_buff *skb,
struct netlink_callback *cb)
{
struct inet_diag_req *rc = nlmsg_data(cb->nlh);
int hdrlen = sizeof(struct inet_diag_req);
struct inet_diag_req_v2 req;
struct nlattr *bc = NULL;
req.sdiag_family = AF_UNSPEC; /* compatibility */
req.sdiag_protocol = <API key>(cb->nlh->nlmsg_type);
req.idiag_ext = rc->idiag_ext;
req.idiag_states = rc->idiag_states;
req.id = rc->id;
if (nlmsg_attrlen(cb->nlh, hdrlen))
bc = nlmsg_find_attr(cb->nlh, hdrlen, <API key>);
return __inet_diag_dump(skb, cb, &req, bc);
}
static int <API key>(struct sk_buff *in_skb,
const struct nlmsghdr *nlh)
{
struct inet_diag_req *rc = nlmsg_data(nlh);
struct inet_diag_req_v2 req;
req.sdiag_family = rc->idiag_family;
req.sdiag_protocol = <API key>(nlh->nlmsg_type);
req.idiag_ext = rc->idiag_ext;
req.idiag_states = rc->idiag_states;
req.id = rc->id;
return inet_diag_get_exact(in_skb, nlh, &req);
}
static int <API key>(struct sk_buff *skb, struct nlmsghdr *nlh)
{
int hdrlen = sizeof(struct inet_diag_req);
struct net *net = sock_net(skb->sk);
if (nlh->nlmsg_type >= <API key> ||
nlmsg_len(nlh) < hdrlen)
return -EINVAL;
if (nlh->nlmsg_flags & NLM_F_DUMP) {
if (nlmsg_attrlen(nlh, hdrlen)) {
struct nlattr *attr;
attr = nlmsg_find_attr(nlh, hdrlen,
<API key>);
if (!attr ||
nla_len(attr) < sizeof(struct inet_diag_bc_op) ||
inet_diag_bc_audit(nla_data(attr), nla_len(attr)))
return -EINVAL;
}
{
struct <API key> c = {
.dump = <API key>,
};
return netlink_dump_start(net->diag_nlsk, skb, nlh, &c);
}
}
return <API key>(skb, nlh);
}
static int <API key>(struct sk_buff *skb, struct nlmsghdr *h)
{
int hdrlen = sizeof(struct inet_diag_req_v2);
struct net *net = sock_net(skb->sk);
if (nlmsg_len(h) < hdrlen)
return -EINVAL;
if (h->nlmsg_flags & NLM_F_DUMP) {
if (nlmsg_attrlen(h, hdrlen)) {
struct nlattr *attr;
attr = nlmsg_find_attr(h, hdrlen,
<API key>);
if (!attr ||
nla_len(attr) < sizeof(struct inet_diag_bc_op) ||
inet_diag_bc_audit(nla_data(attr), nla_len(attr)))
return -EINVAL;
}
{
struct <API key> c = {
.dump = inet_diag_dump,
};
return netlink_dump_start(net->diag_nlsk, skb, h, &c);
}
}
return inet_diag_get_exact(skb, h, nlmsg_data(h));
}
static
int <API key>(struct sk_buff *skb, struct sock *sk)
{
const struct inet_diag_handler *handler;
struct nlmsghdr *nlh;
struct nlattr *attr;
struct inet_diag_msg *r;
void *info = NULL;
int err = 0;
nlh = nlmsg_put(skb, 0, 0, SOCK_DIAG_BY_FAMILY, sizeof(*r), 0);
if (!nlh)
return -ENOMEM;
r = nlmsg_data(nlh);
memset(r, 0, sizeof(*r));
<API key>(r, sk);
if (sk->sk_type == SOCK_DGRAM || sk->sk_type == SOCK_STREAM)
r->id.idiag_sport = inet_sk(sk)->inet_sport;
r->idiag_state = sk->sk_state;
if ((err = nla_put_u8(skb, INET_DIAG_PROTOCOL, sk->sk_protocol))) {
nlmsg_cancel(skb, nlh);
return err;
}
handler = <API key>(sk->sk_protocol);
if (IS_ERR(handler)) {
<API key>(handler);
nlmsg_cancel(skb, nlh);
return PTR_ERR(handler);
}
attr = handler->idiag_info_size
? nla_reserve(skb, INET_DIAG_INFO, handler->idiag_info_size)
: NULL;
if (attr)
info = nla_data(attr);
handler->idiag_get_info(sk, r, info);
<API key>(handler);
nlmsg_end(skb, nlh);
return 0;
}
static const struct sock_diag_handler inet_diag_handler = {
.family = AF_INET,
.dump = <API key>,
.get_info = <API key>,
};
static const struct sock_diag_handler inet6_diag_handler = {
.family = AF_INET6,
.dump = <API key>,
.get_info = <API key>,
};
int inet_diag_register(const struct inet_diag_handler *h)
{
const __u16 type = h->idiag_type;
int err = -EINVAL;
if (type >= IPPROTO_MAX)
goto out;
mutex_lock(&<API key>);
err = -EEXIST;
if (!inet_diag_table[type]) {
inet_diag_table[type] = h;
err = 0;
}
mutex_unlock(&<API key>);
out:
return err;
}
EXPORT_SYMBOL_GPL(inet_diag_register);
void <API key>(const struct inet_diag_handler *h)
{
const __u16 type = h->idiag_type;
if (type >= IPPROTO_MAX)
return;
mutex_lock(&<API key>);
inet_diag_table[type] = NULL;
mutex_unlock(&<API key>);
}
EXPORT_SYMBOL_GPL(<API key>);
static int __init inet_diag_init(void)
{
const int <API key> = (IPPROTO_MAX *
sizeof(struct inet_diag_handler *));
int err = -ENOMEM;
inet_diag_table = kzalloc(<API key>, GFP_KERNEL);
if (!inet_diag_table)
goto out;
err = sock_diag_register(&inet_diag_handler);
if (err)
goto out_free_nl;
err = sock_diag_register(&inet6_diag_handler);
if (err)
goto out_free_inet;
<API key>(<API key>);
out:
return err;
out_free_inet:
<API key>(&inet_diag_handler);
out_free_nl:
kfree(inet_diag_table);
goto out;
}
static void __exit inet_diag_exit(void)
{
<API key>(&inet6_diag_handler);
<API key>(&inet_diag_handler);
<API key>(<API key>);
kfree(inet_diag_table);
}
module_init(inet_diag_init);
module_exit(inet_diag_exit);
MODULE_LICENSE("GPL");
<API key>(PF_NETLINK, NETLINK_SOCK_DIAG, 2 /* AF_INET */);
<API key>(PF_NETLINK, NETLINK_SOCK_DIAG, 10 /* AF_INET6 */); |
// "liveMedia"
// RTP sink for JPEG video (RFC 2435)
// Implementation
#include "JPEGVideoRTPSink.hh"
#include "JPEGVideoSource.hh"
JPEGVideoRTPSink
::JPEGVideoRTPSink(UsageEnvironment& env, Groupsock* RTPgs)
: VideoRTPSink(env, RTPgs, 26, 90000, "JPEG") {
}
JPEGVideoRTPSink::~JPEGVideoRTPSink() {
}
JPEGVideoRTPSink*
JPEGVideoRTPSink::createNew(UsageEnvironment& env, Groupsock* RTPgs) {
return new JPEGVideoRTPSink(env, RTPgs);
}
Boolean JPEGVideoRTPSink::<API key>(MediaSource& source) {
return source.isJPEGVideoSource();
}
Boolean JPEGVideoRTPSink
::<API key>(unsigned char const* /*frameStart*/,
unsigned /*numBytesInFrame*/) const {
// A packet can contain only one frame
return False;
}
void JPEGVideoRTPSink
::<API key>(unsigned fragmentationOffset,
unsigned char* /*frameStart*/,
unsigned /*numBytesInFrame*/,
struct timeval <API key>,
unsigned numRemainingBytes) {
// Our source is known to be a JPEGVideoSource
JPEGVideoSource* source = (JPEGVideoSource*)fSource;
if (source == NULL) return; // sanity check
u_int8_t mainJPEGHeader[8]; // the special header
u_int8_t const type = source->type();
mainJPEGHeader[0] = 0; // Type-specific
mainJPEGHeader[1] = fragmentationOffset >> 16;
mainJPEGHeader[2] = fragmentationOffset >> 8;
mainJPEGHeader[3] = fragmentationOffset;
mainJPEGHeader[4] = type;
mainJPEGHeader[5] = source->qFactor();
mainJPEGHeader[6] = source->width();
mainJPEGHeader[7] = source->height();
<API key>(mainJPEGHeader, sizeof mainJPEGHeader);
unsigned <API key> = 0; // by default
if (type >= 64 && type <= 127) {
// There is also a Restart Marker Header:
<API key> = 4;
u_int16_t const restartInterval = source->restartInterval(); // should be non-zero
u_int8_t restartMarkerHeader[4];
restartMarkerHeader[0] = restartInterval>>8;
restartMarkerHeader[1] = restartInterval&0xFF;
restartMarkerHeader[2] = restartMarkerHeader[3] = 0xFF; // F=L=1; Restart Count = 0x3FFF
<API key>(restartMarkerHeader, <API key>,
sizeof mainJPEGHeader/* start position */);
}
if (fragmentationOffset == 0 && source->qFactor() >= 128) {
// There is also a Quantization Header:
u_int8_t precision;
u_int16_t length;
u_int8_t const* quantizationTables
= source->quantizationTables(precision, length);
unsigned const <API key> = 4 + length;
u_int8_t* quantizationHeader = new u_int8_t[<API key>];
quantizationHeader[0] = 0; // MBZ
quantizationHeader[1] = precision;
quantizationHeader[2] = length >> 8;
quantizationHeader[3] = length&0xFF;
if (quantizationTables != NULL) { // sanity check
for (u_int16_t i = 0; i < length; ++i) {
quantizationHeader[4+i] = quantizationTables[i];
}
}
<API key>(quantizationHeader, <API key>,
sizeof mainJPEGHeader + <API key>/* start position */);
delete[] quantizationHeader;
}
if (numRemainingBytes == 0) {
// This packet contains the last (or only) fragment of the frame.
// Set the RTP 'M' ('marker') bit:
setMarkerBit();
}
// Also set the RTP timestamp:
setTimestamp(<API key>);
}
unsigned JPEGVideoRTPSink::specialHeaderSize() const {
// Our source is known to be a JPEGVideoSource
JPEGVideoSource* source = (JPEGVideoSource*)fSource;
if (source == NULL) return 0; // sanity check
unsigned headerSize = 8; // by default
u_int8_t const type = source->type();
if (type >= 64 && type <= 127) {
// There is also a Restart Marker Header:
headerSize += 4;
}
if (<API key>() == 0 && source->qFactor() >= 128) {
// There is also a Quantization Header:
u_int8_t dummy;
u_int16_t <API key>;
(void)(source->quantizationTables(dummy, <API key>));
headerSize += 4 + <API key>;
}
return headerSize;
} |
// W A R N I N G
// This file is not part of the Qt API. It exists for the convenience
// of qapplication_*.cpp, qwidget*.cpp, qcolor_x11.cpp, qfiledialog.cpp
// and many other. This header file may change from version to version
// without notice, or even be removed.
// We mean it.
/*
Cocoa Application Categories
*/
#include "qmacdefines_mac.h"
#ifdef QT_MAC_USE_COCOA
#import <AppKit/AppKit.h>
<API key>(QApplicationPrivate)
@class QT_MANGLE_NAMESPACE(QCocoaMenuLoader);
@interface NSApplication (QT_MANGLE_NAMESPACE(<API key>))
- (void)QT_MANGLE_NAMESPACE(qt_setDockMenu):(NSMenu *)newMenu;
- (QApplicationPrivate *)QT_MANGLE_NAMESPACE(qt_qappPrivate);
- (QT_MANGLE_NAMESPACE(QCocoaMenuLoader) *)QT_MANGLE_NAMESPACE(qt_qcocoamenuLoader);
- (int)QT_MANGLE_NAMESPACE(<API key>):(NSFontPanel *)fontPanel;
- (void)QT_MANGLE_NAMESPACE(<API key>):(NSEvent *)event;
- (BOOL)QT_MANGLE_NAMESPACE(qt_filterEvent):(NSEvent *)event;
@end
@interface QT_MANGLE_NAMESPACE(QNSApplication) : NSApplication {
}
@end
QT_BEGIN_NAMESPACE
void <API key>();
void <API key>();
QT_END_NAMESPACE
#endif |
// <API key>: GPL-2.0
#define KMSG_COMPONENT "sclp_early"
#define pr_fmt(fmt) KMSG_COMPONENT ": " fmt
#include <linux/errno.h>
#include <asm/ctl_reg.h>
#include <asm/sclp.h>
#include <asm/ipl.h>
#include "sclp_sdias.h"
#include "sclp.h"
static struct sclp_ipl_info sclp_ipl_info;
struct sclp_info sclp;
EXPORT_SYMBOL(sclp);
static void __init <API key>(struct read_info_sccb *sccb)
{
struct sclp_core_entry *cpue;
u16 boot_cpu_address, cpu;
if (sclp_early_get_info(sccb))
return;
sclp.facilities = sccb->facilities;
sclp.has_sprp = !!(sccb->fac84 & 0x02);
sclp.has_core_type = !!(sccb->fac84 & 0x01);
sclp.has_gsls = !!(sccb->fac85 & 0x80);
sclp.has_64bscao = !!(sccb->fac116 & 0x80);
sclp.has_cmma = !!(sccb->fac116 & 0x40);
sclp.has_esca = !!(sccb->fac116 & 0x08);
sclp.has_pfmfi = !!(sccb->fac117 & 0x40);
sclp.has_ibs = !!(sccb->fac117 & 0x20);
sclp.has_gisaf = !!(sccb->fac118 & 0x08);
sclp.has_hvs = !!(sccb->fac119 & 0x80);
sclp.has_kss = !!(sccb->fac98 & 0x01);
sclp.has_sipl = !!(sccb->cbl & 0x02);
sclp.has_sipl_g2 = !!(sccb->cbl & 0x04);
if (sccb->fac85 & 0x02)
S390_lowcore.machine_flags |= MACHINE_FLAG_ESOP;
if (sccb->fac91 & 0x40)
S390_lowcore.machine_flags |= <API key>;
if (sccb->cpuoff > 134)
sclp.has_diag318 = !!(sccb->byte_134 & 0x80);
sclp.rnmax = sccb->rnmax ? sccb->rnmax : sccb->rnmax2;
sclp.rzm = sccb->rnsize ? sccb->rnsize : sccb->rnsize2;
sclp.rzm <<= 20;
sclp.ibc = sccb->ibc;
if (sccb->hamaxpow && sccb->hamaxpow < 64)
sclp.hamax = (1UL << sccb->hamaxpow) - 1;
else
sclp.hamax = U64_MAX;
if (!sccb->hcpua) {
if (MACHINE_IS_VM)
sclp.max_cores = 64;
else
sclp.max_cores = sccb->ncpurl;
} else {
sclp.max_cores = sccb->hcpua + 1;
}
boot_cpu_address = stap();
cpue = (void *)sccb + sccb->cpuoff;
for (cpu = 0; cpu < sccb->ncpurl; cpue++, cpu++) {
if (boot_cpu_address != cpue->core_id)
continue;
sclp.has_siif = cpue->siif;
sclp.has_sigpif = cpue->sigpif;
sclp.has_sief2 = cpue->sief2;
sclp.has_gpere = cpue->gpere;
sclp.has_ib = cpue->ib;
sclp.has_cei = cpue->cei;
sclp.has_skey = cpue->skey;
break;
}
/* Save IPL information */
sclp_ipl_info.is_valid = 1;
if (sccb->fac91 & 0x2)
sclp_ipl_info.has_dump = 1;
memcpy(&sclp_ipl_info.loadparm, &sccb->loadparm, LOADPARM_LEN);
if (sccb->hsa_size)
sclp.hsa_size = (sccb->hsa_size - 1) * PAGE_SIZE;
sclp.mtid = (sccb->fac42 & 0x80) ? (sccb->fac42 & 31) : 0;
sclp.mtid_cp = (sccb->fac42 & 0x80) ? (sccb->fac43 & 31) : 0;
sclp.mtid_prev = (sccb->fac42 & 0x80) ? (sccb->fac66 & 31) : 0;
sclp.hmfai = sccb->hmfai;
sclp.has_dirq = !!(sccb->cpudirq & 0x80);
}
/*
* This function will be called after <API key>(), which gets
* called from early.c code. The <API key>() function retrieves
* and saves the IPL information.
*/
void __init <API key>(struct sclp_ipl_info *info)
{
*info = sclp_ipl_info;
}
static struct sclp_core_info <API key> __initdata;
static int <API key> __initdata;
static void __init <API key>(struct read_cpu_info_sccb *sccb)
{
if (!SCLP_HAS_CPU_INFO)
return;
memset(sccb, 0, sizeof(*sccb));
sccb->header.length = sizeof(*sccb);
if (sclp_early_cmd(<API key>, sccb))
return;
if (sccb->header.response_code != 0x0010)
return;
sclp_fill_core_info(&<API key>, sccb);
<API key> = 1;
}
int __init <API key>(struct sclp_core_info *info)
{
if (!<API key>)
return -EIO;
*info = <API key>;
return 0;
}
static void __init <API key>(struct init_sccb *sccb)
{
if (sccb->header.response_code != 0x20)
return;
if (<API key>(sccb))
sclp.has_vt220 = 1;
if (<API key>(sccb))
sclp.has_linemode = 1;
}
void __init sclp_early_detect(void)
{
void *sccb = sclp_early_sccb;
<API key>(sccb);
<API key>(sccb);
/*
* Turn off SCLP event notifications. Also save remote masks in the
* sccb. These are sufficient to detect sclp console capabilities.
*/
<API key>(sccb, 0, 0);
<API key>(sccb);
} |
package de.schaeuffelhut.android.openvpn.service.api;
import android.content.<API key>;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageInfo;
import android.net.Uri;
import android.widget.Toast;
public class <API key>
{
static final ComponentName COMPONENT_NAME = new ComponentName(
"de.schaeuffelhut.android.openvpn",
"de.schaeuffelhut.android.openvpn.services.PluginRegistry"
);
private final Context context;
private final PackageInfo openVpnSettings;
public <API key>(Context context)
{
this.context = context;
openVpnSettings = <API key>();
// Log.d( "OpenVPNSettings", "openVpnSettings.versionCode: " + openVpnSettings.versionCode );
// Log.d( "OpenVPNSettings", "openVpnSettings.versionName: " + openVpnSettings.versionName );
}
public boolean <API key>()
{
return openVpnSettings != null && openVpnSettings.versionCode >= 37;
}
private PackageInfo <API key>()
{
for (PackageInfo p : context.getPackageManager().<API key>( 0 ))
if ("de.schaeuffelhut.android.openvpn".equals( p.packageName ))
return p;
return null;
}
public void <API key>()
{
try
{
tryToOpenMarket();
return;
}
catch (<API key> e)
{
}
try
{
tryToOpenBrowser();
return;
}
catch (<API key> e)
{
}
Toast.makeText( context, "Neither market nor the browser could be launched! Please get OpenVPN Settings from the internet: code.google.com/p/<API key>", Toast.LENGTH_LONG ).show();
}
private void tryToOpenMarket() throws <API key>
{
Intent intent = new Intent( Intent.ACTION_VIEW );
intent.setData( Uri.parse( "market://details?id=de.schaeuffelhut.android.openvpn" ) );
context.startActivity( intent );
}
private void tryToOpenBrowser() throws <API key>
{
Intent intent = new Intent( Intent.ACTION_VIEW );
intent.setData( Uri.parse( "https://code.google.com/p/<API key>/" ) );
context.startActivity( intent );
}
} |
#include "serialization.hpp"
#include "yaml-cpp/yaml.h"
#include <QDebug>
#include <QStringList>
#include <QKeySequence>
#include <boost/iostreams/concepts.hpp>
#include <boost/iostreams/stream.hpp>
#include <iostream>
namespace ScIDE { namespace Settings {
typedef QSettings::SettingsMap::const_iterator SettingsIterator;
struct IODeviceSource : boost::iostreams::source {
IODeviceSource ( QIODevice *dev ) : mDev(dev) {}
std::streamsize read(char* s, std::streamsize n)
{
// Read up to n characters from the input
// sequence into the buffer s, returning
// the number of characters read, or -1
// to indicate end-of-sequence.
qint64 ret = mDev->read(s, n);
if( ret == 0 ) ret = -1;
return ret;
}
QIODevice *mDev;
};
static QVariant parseTextFormat( const YAML::Node & node )
{
using namespace YAML;
if(node.Type() != NodeType::Map) {
qWarning("YAML parsing: a node tagged 'textFormat' has wrong type (not a map)");
return QVariant();
}
const Node *n;
std::string val;
QTextCharFormat fm;
n = node.FindValue("color");
if(n && n->Type() == NodeType::Scalar) {
n->GetScalar(val);
fm.setForeground(QColor(val.c_str()));
}
n = node.FindValue("background");
if(n && n->Type() == NodeType::Scalar) {
n->GetScalar(val);
QColor color(val.c_str());
if(color.isValid())
fm.setBackground(color);
}
n = node.FindValue("bold");
if(n && n->Type() == NodeType::Scalar) {
bool bold = n->to<bool>();
if(bold) fm.setFontWeight(QFont::Bold);
}
n = node.FindValue("italic");
if(n && n->Type() == NodeType::Scalar) {
bool italic = n->to<bool>();
fm.setFontItalic(italic);
}
n = node.FindValue("underline");
if(n && n->Type() == NodeType::Scalar) {
bool underline = n->to<bool>();
fm.setFontUnderline(underline);
}
return QVariant::fromValue<QTextCharFormat>(fm);
}
static QVariant parseScalar( const YAML::Node & node )
{
using namespace YAML;
switch (node.Type())
{
case NodeType::Scalar:
{
std::string val;
node >> val;
return QVariant( QString::fromUtf8(val.c_str()) );
}
case NodeType::Sequence:
{
QVariantList list;
YAML::Iterator it;
for(it = node.begin(); it != node.end(); ++it)
list.append( parseScalar( *it ) );
return QVariant::fromValue<QVariantList>( list );
}
case NodeType::Map:
{
QVariantMap map;
YAML::Iterator it;
for(it = node.begin(); it != node.end(); ++it)
{
std::string key;
it.first() >> key;
QVariant value = parseScalar( it.second() );
map.insert( QString(key.c_str()), value );
}
return QVariant::fromValue<QVariantMap>( map );
}
case NodeType::Null:
return QVariant();
default:
qWarning("YAML parsing: unsupported node type.");
return QVariant();
}
}
static void parseNode( const YAML::Node &node, const QString &parentKey, QSettings::SettingsMap &map )
{
using namespace YAML;
static const std::string textFormatTag("!textFormat");
static const std::string qVariantListTag("!QVariantList");
static const std::string qVariantMapTag("!QVariantMap");
Q_ASSERT(node.Type() == NodeType::Map);
YAML::Iterator it;
for(it = node.begin(); it != node.end(); ++it) {
std::string key;
it.first() >> key;
QString childKey( parentKey );
if (!childKey.isEmpty()) childKey += "/";
childKey += key.c_str();
const YAML::Node & childNode = it.second();
const std::string & childTag = childNode.Tag();
if (childTag == textFormatTag)
map.insert( childKey, parseTextFormat(childNode) );
else if (childTag == qVariantListTag || childTag == qVariantMapTag || childNode.Type() != NodeType::Map)
map.insert( childKey, parseScalar( childNode ) );
else if (childNode.Type() == NodeType::Map)
parseNode( childNode, childKey, map );
}
}
bool readSettings(QIODevice &device, QSettings::SettingsMap &map)
{
using namespace YAML;
try {
boost::iostreams::stream<IODeviceSource> in( &device );
Parser parser(in);
Node doc;
while(parser.GetNextDocument(doc)) {
if( doc.Type() != NodeType::Map ) continue;
QString key;
parseNode( doc, key, map );
}
return true;
}
catch (std::exception & e) {
qWarning() << "Exception when parsing YAML config file:" << e.what();
return false;
}
}
static void writeTextFormat( const QTextCharFormat &fm, YAML::Emitter &out )
{
out << YAML::LocalTag("textFormat");
out << YAML::BeginMap;
if (fm.hasProperty(QTextFormat::ForegroundBrush)) {
out << YAML::Key << "color";
out << YAML::Value << fm.foreground().color().name().toStdString();
}
if (fm.hasProperty(QTextFormat::BackgroundBrush)) {
out << YAML::Key << "background";
out << YAML::Value << fm.background().color().name().toStdString();
}
if (fm.hasProperty(QTextFormat::FontWeight)) {
out << YAML::Key << "bold";
out << YAML::Value << (fm.fontWeight() == QFont::Bold);
}
if (fm.hasProperty(QTextFormat::FontItalic)) {
out << YAML::Key << "italic";
out << YAML::Value << fm.fontItalic();
}
if (fm.hasProperty(QTextFormat::TextUnderlineStyle)) {
qDebug("saving underline");
out << YAML::Key << "underline";
out << YAML::Value << fm.fontUnderline();
}
out << YAML::EndMap;
}
static void writeValue( const QVariant &var, YAML::Emitter &out )
{
switch(var.type()) {
case QVariant::Invalid:
{
out << YAML::Null;
break;
}
case QVariant::KeySequence:
{
QKeySequence kseq = var.value<QKeySequence>();
out << kseq.toString( QKeySequence::PortableText ).toUtf8().constData();
break;
}
case QVariant::List:
{
out << YAML::LocalTag("QVariantList") << YAML::BeginSeq;
QVariantList list = var.value<QVariantList>();
foreach (const QVariant & var, list)
writeValue( var, out );
out << YAML::EndSeq;
break;
}
case QVariant::Map:
{
out << YAML::LocalTag("QVariantMap") << YAML::BeginMap;
QVariantMap map = var.value<QVariantMap>();
QVariantMap::iterator it;
for (it = map.begin(); it != map.end(); ++it)
{
out << YAML::Key << it.key().toStdString();
out << YAML::Value;
writeValue( it.value(), out );
}
out << YAML::EndMap;
break;
}
case QVariant::UserType:
{
int utype = var.userType();
if (utype == qMetaTypeId<QTextCharFormat>())
{
writeTextFormat( var.value<QTextCharFormat>(), out );
}
else
{
out << var.toString().toUtf8().constData();
}
break;
}
default:
{
out << var.toString().toUtf8().constData();
}
}
}
static void writeGroup( const QString &groupKey, YAML::Emitter &out,
SettingsIterator &it, const QSettings::SettingsMap &map )
{
out << YAML::BeginMap;
int groupKeyLen = groupKey.size();
while(it != map.end())
{
QString key( it.key() );
if (!key.startsWith(groupKey)) break;
int i_separ = key.indexOf("/", groupKeyLen);
if (i_separ != -1) {
// There is child nodes
key.truncate( i_separ + 1 );
QString yamlKey(key);
yamlKey.remove(0, groupKeyLen);
yamlKey.chop(1);
out << YAML::Key << yamlKey.toStdString();
out << YAML::Value;
writeGroup( key, out, it, map );
}
else
{
// There is no child nodes
key.remove(0, groupKeyLen);
out << YAML::Key << key.toStdString();
out << YAML::Value;
writeValue( it.value(), out );
++it;
}
}
out << YAML::EndMap;
}
bool writeSettings(QIODevice &device, const QSettings::SettingsMap &map)
{
try {
YAML::Emitter out;
SettingsIterator it = map.begin();
writeGroup( "", out, it, map );
device.write(out.c_str());
return true;
}
catch (std::exception & e) {
qWarning() << "Exception when writing YAML config file:" << e.what();
return false;
}
}
QSettings::Format serializationFormat() {
static QSettings::Format format =
QSettings::registerFormat( "yaml", readSettings, writeSettings );
if( format == QSettings::InvalidFormat )
qWarning("Could not register settings format");
return format;
}
void printSettings (const QSettings * settings)
{
using namespace std;
cout << "config filename: " << settings->fileName().toStdString() << endl;
QStringList keys = settings->allKeys();
cout << "num keys: " << keys.count() << endl;
Q_FOREACH( QString key, keys ) {
QVariant var = settings->value(key);
if (var.type() == QVariant::Invalid)
cout << key.toStdString() << ": <null>" << endl;
else if (var.type() == QVariant::String)
cout << key.toStdString() << ": " << var.toString().toStdString() << endl;
else
cout << key.toStdString() << ": <unknown value type>" << endl;
}
}
}} // namespace ScIDE::Settings |
/*jshint node:true */
module.exports = function ( grunt ) {
grunt.loadNpmTasks( 'grunt-contrib-copy' );
grunt.loadNpmTasks( '<API key>' );
grunt.loadNpmTasks( 'grunt-contrib-watch' );
grunt.loadNpmTasks( '<API key>' );
grunt.loadNpmTasks( 'grunt-jscs' );
grunt.loadNpmTasks( 'grunt-jsonlint' );
grunt.loadNpmTasks( 'grunt-karma' );
var wgServer = process.env.MW_SERVER,
wgScriptPath = process.env.MW_SCRIPT_PATH,
karmaProxy = {};
karmaProxy[wgScriptPath] = wgServer + wgScriptPath;
grunt.initConfig( {
pkg: grunt.file.readJSON( 'package.json' ),
jshint: {
options: {
jshintrc: true
},
all: [
'*.js',
'{includes,languages,resources,tests}*.js'
]
},
jscs: {
all: [
'<%= jshint.all %>',
// Auto-generated file with JSON (double quotes)
'!tests/qunit/data/mediawiki.jqueryMsg.data.js',
// Skip functions are stored as script files but wrapped in a function when
'{languages,maintenance,resources}*.json',
src: 'resources*', |
#ifndef <API key>
#define <API key>
#define TRUE 1
#define FALSE 0
#define <API key> 72
// BB HEADER fields
#define TS_GS_TRANSPORT 3
#define <API key> 0
#define <API key> 1
#define TS_GS_RESERVED 2
#define SIS_MIS_SINGLE 1
#define SIS_MIS_MULTIPLE 0
#define CCM 1
#define ACM 0
#define ISSYI_ACTIVE 1
#define ISSYI_NOT_ACTIVE 0
#define NPD_ACTIVE 1
#define NPD_NOT_ACTIVE 0
#define FRAME_SIZE_NORMAL 64800
#define FRAME_SIZE_SHORT 16200
// BCH Code
#define BCH_CODE_N8 0
#define BCH_CODE_N10 1
#define BCH_CODE_N12 2
#define BCH_CODE_S12 3
#define <API key> (FRAME_SIZE_NORMAL * 10)
#endif /* <API key> */ |
\file
\ingroup tutorial_eve
Demonstrates usage of REveBoxSet class.
\image html eve_boxset.png
\macro_code
\author Matevz Tadel
#include "TRandom.h"
#include <ROOT/REveElement.hxx>
#include <ROOT/REveScene.hxx>
#include <ROOT/REveManager.hxx>
#include <ROOT/REveBoxSet.hxx>
using namespace ROOT::Experimental;
REveBoxSet* boxset(Int_t num=100)
{
auto eveMng = REveManager::Create();
TRandom r(0);
auto pal = new REveRGBAPalette(0, 130);
auto q = new REveBoxSet("BoxSet");
q->SetPalette(pal);
q->Reset(REveBoxSet::kBT_FreeBox, kFALSE, 64);
#define RND_BOX(x) (Float_t)r.Uniform(-(x), (x))
Float_t verts[24];
for (Int_t i=0; i<num; ++i) {
Float_t x = RND_BOX(10);
Float_t y = RND_BOX(10);
Float_t z = RND_BOX(10);
Float_t a = r.Uniform(0.2, 0.5);
Float_t d = 0.05;
Float_t verts[24] = {
x - a + RND_BOX(d), y - a + RND_BOX(d), z - a + RND_BOX(d),
x - a + RND_BOX(d), y + a + RND_BOX(d), z - a + RND_BOX(d),
x + a + RND_BOX(d), y + a + RND_BOX(d), z - a + RND_BOX(d),
x + a + RND_BOX(d), y - a + RND_BOX(d), z - a + RND_BOX(d),
x - a + RND_BOX(d), y - a + RND_BOX(d), z + a + RND_BOX(d),
x - a + RND_BOX(d), y + a + RND_BOX(d), z + a + RND_BOX(d),
x + a + RND_BOX(d), y + a + RND_BOX(d), z + a + RND_BOX(d),
x + a + RND_BOX(d), y - a + RND_BOX(d), z + a + RND_BOX(d) };
q->AddBox(verts);
q->DigitValue(r.Uniform(0, 130));
}
q->RefitPlex();
#undef RND_BOX
// Uncomment these two lines to get internal highlight / selection.
q->SetPickable(1);
q->SetAlwaysSecSelect(1);
eveMng->GetEventScene()->AddElement(q);
eveMng->Show();
return q;
}
REveBoxSet* boxset_axisaligned(Float_t x=0, Float_t y=0, Float_t z=0,
Int_t num=100, Bool_t registerSet=kTRUE)
{
auto eveMng = REveManager::Create();
TRandom r(0);
auto pal = new REveRGBAPalette(0, 130);
auto frm = new REveFrameBox();
frm-><API key>(0, 0, 0, 12, 12, 12);
frm->SetFrameColor(kCyan);
frm->SetBackColorRGBA(120,120,120,20);
frm->SetDrawBack(kTRUE);
auto q = new REveBoxSet("BoxSet");
q->SetPalette(pal);
q->SetFrame(frm);
q->Reset(REveBoxSet::kBT_AABox, kFALSE, 64);
for (Int_t i=0; i<num; ++i) {
q->AddBox(r.Uniform(-10, 10), r.Uniform(-10, 10), r.Uniform(-10, 10),
r.Uniform(0.2, 1), r.Uniform(0.2, 1), r.Uniform(0.2, 1));
q->DigitValue(r.Uniform(0, 130));
}
q->RefitPlex();
REveTrans& t = q->RefMainTrans();
t.SetPos(x, y, z);
// Uncomment these two lines to get internal highlight / selection.
q->SetPickable(1);
q->SetAlwaysSecSelect(1);
if (registerSet)
{
eveMng->GetEventScene()->AddElement(q);
eveMng->Show();
}
return q;
}
REveBoxSet* boxset_colisval(Float_t x=0, Float_t y=0, Float_t z=0,
Int_t num=100, Bool_t registerSet=kTRUE)
{
auto eveMng = REveManager::Create();
TRandom r(0);
auto q = new REveBoxSet("BoxSet");
q->Reset(REveBoxSet::kBT_AABox, kTRUE, 64);
for (Int_t i=0; i<num; ++i) {
q->AddBox(r.Uniform(-10, 10), r.Uniform(-10, 10), r.Uniform(-10, 10),
r.Uniform(0.2, 1), r.Uniform(0.2, 1), r.Uniform(0.2, 1));
q->DigitColor(r.Uniform(20, 255), r.Uniform(20, 255),
r.Uniform(20, 255), r.Uniform(20, 255));
}
q->RefitPlex();
REveTrans& t = q->RefMainTrans();
t.SetPos(x, y, z);
if (registerSet)
{
eveMng->GetEventScene()->AddElement(q);
eveMng->Show();
}
return q;
}
REveBoxSet* boxset_single_color(Float_t x=0, Float_t y=0, Float_t z=0,
Int_t num=100, Bool_t registerSet=kTRUE)
{
auto eveMng = REveManager::Create();
TRandom r(0);
auto q = new REveBoxSet("BoxSet");
q->UseSingleColor();
q->SetMainColorPtr(new Color_t);
q->SetMainColor(kRed);
q->SetMainTransparency(50);
q->Reset(REveBoxSet::kBT_AABox, kFALSE, 64);
for (Int_t i=0; i<num; ++i) {
q->AddBox(r.Uniform(-10, 10), r.Uniform(-10, 10), r.Uniform(-10, 10),
r.Uniform(0.2, 1), r.Uniform(0.2, 1), r.Uniform(0.2, 1));
}
q->RefitPlex();
REveTrans& t = q->RefMainTrans();
t.SetPos(x, y, z);
if (registerSet) {
eveMng->GetEventScene()->AddElement(q);
eveMng->Show();
}
return q;
}
/*
REveBoxSet* boxset_hex(Float_t x=0, Float_t y=0, Float_t z=0,
Int_t num=100, Bool_t registerSet=kTRUE)
{
auto eveMng = REveManager::Create();
TRandom r(0);
auto q = new REveBoxSet("BoxSet");
q->Reset(REveBoxSet::kBT_Hex, kTRUE, 64);
for (Int_t i=0; i<num; ++i) {
q->AddHex(REveVector(r.Uniform(-10, 10), r.Uniform(-10, 10), r.Uniform(-10, 10)),
r.Uniform(0.2, 1), r.Uniform(0, 60), r.Uniform(0.2, 5));
q->DigitColor(r.Uniform(20, 255), r.Uniform(20, 255),
r.Uniform(20, 255), r.Uniform(20, 255));
}
q->RefitPlex();
q->SetPickable(true);
q->SetAlwaysSecSelect(true);
REveTrans& t = q->RefMainTrans();
t.SetPos(x, y, z);
if (registerSet)
{
eveMng->GetEventScene()->AddElement(q);
eveMng->Show();
}
return q;
}
*/ |
// The LLVM Compiler Infrastructure
// This file is distributed under the University of Illinois Open Source
#include "llvm/DebugInfo/PDB/PDBSymbol.h"
#include "llvm/DebugInfo/PDB/IPDBEnumChildren.h"
#include "llvm/DebugInfo/PDB/IPDBRawSymbol.h"
#include "llvm/DebugInfo/PDB/PDBSymbolAnnotation.h"
#include "llvm/DebugInfo/PDB/PDBSymbolBlock.h"
#include "llvm/DebugInfo/PDB/PDBSymbolCompiland.h"
#include "llvm/DebugInfo/PDB/<API key>.h"
#include "llvm/DebugInfo/PDB/<API key>.h"
#include "llvm/DebugInfo/PDB/PDBSymbolCustom.h"
#include "llvm/DebugInfo/PDB/PDBSymbolData.h"
#include "llvm/DebugInfo/PDB/PDBSymbolExe.h"
#include "llvm/DebugInfo/PDB/PDBSymbolFunc.h"
#include "llvm/DebugInfo/PDB/<API key>.h"
#include "llvm/DebugInfo/PDB/<API key>.h"
#include "llvm/DebugInfo/PDB/PDBSymbolLabel.h"
#include "llvm/DebugInfo/PDB/<API key>.h"
#include "llvm/DebugInfo/PDB/PDBSymbolThunk.h"
#include "llvm/DebugInfo/PDB/PDBSymbolTypeArray.h"
#include "llvm/DebugInfo/PDB/<API key>.h"
#include "llvm/DebugInfo/PDB/<API key>.h"
#include "llvm/DebugInfo/PDB/PDBSymbolTypeCustom.h"
#include "llvm/DebugInfo/PDB/<API key>.h"
#include "llvm/DebugInfo/PDB/PDBSymbolTypeEnum.h"
#include "llvm/DebugInfo/PDB/PDBSymbolTypeFriend.h"
#include "llvm/DebugInfo/PDB/<API key>.h"
#include "llvm/DebugInfo/PDB/<API key>.h"
#include "llvm/DebugInfo/PDB/<API key>.h"
#include "llvm/DebugInfo/PDB/<API key>.h"
#include "llvm/DebugInfo/PDB/<API key>.h"
#include "llvm/DebugInfo/PDB/PDBSymbolTypeUDT.h"
#include "llvm/DebugInfo/PDB/PDBSymbolTypeVTable.h"
#include "llvm/DebugInfo/PDB/<API key>.h"
#include "llvm/DebugInfo/PDB/PDBSymbolUnknown.h"
#include "llvm/DebugInfo/PDB/<API key>.h"
#include "llvm/DebugInfo/PDB/PDBSymDumper.h"
#include <memory>
#include <utility>
#include <memory>
#include <utility>
using namespace llvm;
using namespace llvm::pdb;
PDBSymbol::PDBSymbol(const IPDBSession &PDBSession,
std::unique_ptr<IPDBRawSymbol> Symbol)
: Session(PDBSession), RawSymbol(std::move(Symbol)) {}
PDBSymbol::~PDBSymbol() {}
#define FACTORY_SYMTAG_CASE(Tag, Type) \
case PDB_SymType::Tag: \
return std::unique_ptr<PDBSymbol>(new Type(PDBSession, std::move(Symbol)));
std::unique_ptr<PDBSymbol>
PDBSymbol::create(const IPDBSession &PDBSession,
std::unique_ptr<IPDBRawSymbol> Symbol) {
switch (Symbol->getSymTag()) {
FACTORY_SYMTAG_CASE(Exe, PDBSymbolExe)
FACTORY_SYMTAG_CASE(Compiland, PDBSymbolCompiland)
FACTORY_SYMTAG_CASE(CompilandDetails, <API key>)
FACTORY_SYMTAG_CASE(CompilandEnv, <API key>)
FACTORY_SYMTAG_CASE(Function, PDBSymbolFunc)
FACTORY_SYMTAG_CASE(Block, PDBSymbolBlock)
FACTORY_SYMTAG_CASE(Data, PDBSymbolData)
FACTORY_SYMTAG_CASE(Annotation, PDBSymbolAnnotation)
FACTORY_SYMTAG_CASE(Label, PDBSymbolLabel)
FACTORY_SYMTAG_CASE(PublicSymbol, <API key>)
FACTORY_SYMTAG_CASE(UDT, PDBSymbolTypeUDT)
FACTORY_SYMTAG_CASE(Enum, PDBSymbolTypeEnum)
FACTORY_SYMTAG_CASE(FunctionSig, <API key>)
FACTORY_SYMTAG_CASE(PointerType, <API key>)
FACTORY_SYMTAG_CASE(ArrayType, PDBSymbolTypeArray)
FACTORY_SYMTAG_CASE(BuiltinType, <API key>)
FACTORY_SYMTAG_CASE(Typedef, <API key>)
FACTORY_SYMTAG_CASE(BaseClass, <API key>)
FACTORY_SYMTAG_CASE(Friend, PDBSymbolTypeFriend)
FACTORY_SYMTAG_CASE(FunctionArg, <API key>)
FACTORY_SYMTAG_CASE(FuncDebugStart, <API key>)
FACTORY_SYMTAG_CASE(FuncDebugEnd, <API key>)
FACTORY_SYMTAG_CASE(UsingNamespace, <API key>)
FACTORY_SYMTAG_CASE(VTableShape, <API key>)
FACTORY_SYMTAG_CASE(VTable, PDBSymbolTypeVTable)
FACTORY_SYMTAG_CASE(Custom, PDBSymbolCustom)
FACTORY_SYMTAG_CASE(Thunk, PDBSymbolThunk)
FACTORY_SYMTAG_CASE(CustomType, PDBSymbolTypeCustom)
FACTORY_SYMTAG_CASE(ManagedType, <API key>)
FACTORY_SYMTAG_CASE(Dimension, <API key>)
default:
return std::unique_ptr<PDBSymbol>(
new PDBSymbolUnknown(PDBSession, std::move(Symbol)));
}
}
#define TRY_DUMP_TYPE(Type) \
if (const Type *DerivedThis = dyn_cast<Type>(this)) \
Dumper.dump(OS, Indent, *DerivedThis);
#define ELSE_TRY_DUMP_TYPE(Type, Dumper) else TRY_DUMP_TYPE(Type, Dumper)
void PDBSymbol::defaultDump(raw_ostream &OS, int Indent) const {
RawSymbol->dump(OS, Indent);
}
PDB_SymType PDBSymbol::getSymTag() const { return RawSymbol->getSymTag(); }
uint32_t PDBSymbol::getSymIndexId() const { return RawSymbol->getSymIndexId(); }
std::unique_ptr<IPDBEnumSymbols> PDBSymbol::findAllChildren() const {
return findAllChildren(PDB_SymType::None);
}
std::unique_ptr<IPDBEnumSymbols>
PDBSymbol::findAllChildren(PDB_SymType Type) const {
return RawSymbol->findChildren(Type);
}
std::unique_ptr<IPDBEnumSymbols>
PDBSymbol::findChildren(PDB_SymType Type, StringRef Name,
PDB_NameSearchFlags Flags) const {
return RawSymbol->findChildren(Type, Name, Flags);
}
std::unique_ptr<IPDBEnumSymbols>
PDBSymbol::findChildrenByRVA(PDB_SymType Type, StringRef Name,
PDB_NameSearchFlags Flags, uint32_t RVA) const {
return RawSymbol->findChildrenByRVA(Type, Name, Flags, RVA);
}
std::unique_ptr<IPDBEnumSymbols>
PDBSymbol::<API key>(uint32_t RVA) const {
return RawSymbol-><API key>(RVA);
}
std::unique_ptr<IPDBEnumSymbols>
PDBSymbol::getChildStats(TagStats &Stats) const {
std::unique_ptr<IPDBEnumSymbols> Result(findAllChildren());
Stats.clear();
while (auto Child = Result->getNext()) {
++Stats[Child->getSymTag()];
}
Result->reset();
return Result;
} |
// Use of this source code is governed by a BSD-style
// +build integration
package tests
import (
"context"
"fmt"
"math/rand"
"net/http"
"os"
"github.com/google/go-github/github"
"golang.org/x/oauth2"
)
var (
client *github.Client
// auth indicates whether tests are being run with an OAuth token.
// Tests can use this flag to skip certain tests when run without auth.
auth bool
)
func init() {
token := os.Getenv("GITHUB_AUTH_TOKEN")
if token == "" {
print("!!! No OAuth token. Some tests won't run. !!!\n\n")
client = github.NewClient(nil)
} else {
tc := oauth2.NewClient(context.Background(), oauth2.StaticTokenSource(
&oauth2.Token{AccessToken: token},
))
client = github.NewClient(tc)
auth = true
}
// Environment variables required for Authorization integration tests
vars := []string{<API key>, <API key>, envKeyClientID, envKeyClientSecret}
for _, v := range vars {
value := os.Getenv(v)
if value == "" {
print("!!! " + fmt.Sprintf(msgEnvMissing, v) + " !!!\n\n")
}
}
}
func checkAuth(name string) bool {
if !auth {
fmt.Printf("No auth - skipping portions of %v\n", name)
}
return auth
}
func <API key>(owner string, autoinit bool) (*github.Repository, error) {
// create random repo name that does not currently exist
var repoName string
for {
repoName = fmt.Sprintf("test-%d", rand.Int())
_, resp, err := client.Repositories.Get(owner, repoName)
if err != nil {
if resp.StatusCode == http.StatusNotFound {
// found a non-existent repo, perfect
break
}
return nil, err
}
}
// create the repository
repo, _, err := client.Repositories.Create("", &github.Repository{Name: github.String(repoName), AutoInit: github.Bool(autoinit)})
if err != nil {
return nil, err
}
return repo, nil
} |
// file at the top-level directory of this distribution and at
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#![feature(<API key>)]
struct Foo;
trait Bar { }
unsafe impl Bar for Foo { } //~ ERROR implementing the trait `Bar` is not unsafe [E0199]
fn main() {
} |
create table "employees" ("name" varchar(32), "department" varchar(32), "salary" decimal(5,2))
create table "departments" ("name" varchar(32), "country" varchar(32))
create table "customers" ("name" varchar(32), "country" varchar(32))
create table "products" ("name" varchar(32), "amount" integer, "price" decimal(22,4))
create table "orders" ("customer" varchar(32), "department" varchar(32), "product" varchar(32), "quantity" integer, "created" timestamp not null default '0000-00-00 00:00:00')
create table "logs" ("modified" timestamp, "message" varchar(32))
insert into "employees" ("name", "department", "salary") values('Smith', 'American Fruits', cast('10.500' as decimal(5,2)))
insert into "employees" ("name", "department", "salary") values('Jones', 'English Fruits', cast('6.300' as decimal(5,2)))
insert into "employees" ("name", "department", "salary") values('Müller', 'German Fruits', cast('8.020' as decimal(5,2)))
insert into "employees" ("name", "department", "salary") values('Meier', 'German Fruits', cast(NULL as decimal(5,2)))
insert into "employees" ("name", "department", "salary") values('Schulze', 'German Fruits', cast('6.001' as decimal(5,2)))
insert into "departments" ("name", "country") values('American Fruits', 'us')
insert into "departments" ("name", "country") values('English Fruits', 'en')
insert into "departments" ("name", "country") values('German Fruits', 'de')
insert into "customers" ("name", "country") values('John', 'us')
insert into "customers" ("name", "country") values('George', 'en')
insert into "customers" ("name", "country") values('Ringo', 'en')
insert into "customers" ("name", "country") values('Otto', 'de')
insert into "customers" ("name", "country") values('Liesel', 'de')
insert into "customers" ("name", "country") values(NULL, 'de')
insert into "customers" ("name", "country") values('Fritz', NULL)
insert into "products" ("name", "amount", "price") values('Apples', 2, 1.50)
insert into "products" ("name", "amount", "price") values('Bananas', 3, 2.7446785)
insert into "products" ("name", "amount", "price") values('Oranges', 5, cast(NULL as decimal(22,4)))
insert into "products" ("name", "amount", "price") values('Nothing', NULL, cast(NULL as decimal(22,4)))
insert into "orders" ("customer", "department", "product", "quantity", "created") values('Big', 'American Fruits', 'Apples', 1, current_timestamp)
insert into "orders" ("customer", "department", "product", "quantity", "created") values('Large', 'German Fruits', 'Bananas', 1, current_timestamp)
insert into "orders" ("customer", "department", "product", "quantity", "created") values('Huge', 'German Fruits', 'Oranges', 2, current_timestamp)
insert into "orders" ("customer", "department", "product", "quantity", "created") values('Good', 'German Fruits', 'Apples', 2, {ts '2012-06-01 15:52:25'})
insert into "orders" ("customer", "department", "product", "quantity", "created") values('Bad', 'English Fruits', 'Oranges', 3, {ts '2012-06-01 16:31:24'}) |
package com.alibaba.otter.canal.common.zookeeper.running;
import java.util.concurrent.Executors;
import java.util.concurrent.<API key>;
import java.util.concurrent.TimeUnit;
import org.I0Itec.zkclient.IZkDataListener;
import org.I0Itec.zkclient.exception.ZkException;
import org.I0Itec.zkclient.exception.<API key>;
import org.I0Itec.zkclient.exception.ZkNoNodeException;
import org.I0Itec.zkclient.exception.<API key>;
import org.apache.zookeeper.CreateMode;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.slf4j.MDC;
import com.alibaba.otter.canal.common.<API key>;
import com.alibaba.otter.canal.common.utils.BooleanMutex;
import com.alibaba.otter.canal.common.utils.JsonUtils;
import com.alibaba.otter.canal.common.zookeeper.ZkClientx;
import com.alibaba.otter.canal.common.zookeeper.ZookeeperPathUtils;
/**
* serverrunning
*
* @author jianghang 2012-11-22 02:59:42
* @version 1.0.0
*/
public class <API key> extends <API key> {
private static final Logger logger = LoggerFactory.getLogger(<API key>.class);
private ZkClientx zkClient;
private String destination;
private IZkDataListener dataListener;
private BooleanMutex mutex = new BooleanMutex(false);
private volatile boolean release = false;
private ServerRunningData serverData;
private volatile ServerRunningData activeData;
private <API key> delayExector = Executors.<API key>(1);
private int delayTime = 5;
private <API key> listener;
public <API key>(ServerRunningData serverData){
this();
this.serverData = serverData;
}
public <API key>(){
dataListener = new IZkDataListener() {
public void handleDataChange(String dataPath, Object data) throws Exception {
MDC.put("destination", destination);
ServerRunningData runningData = JsonUtils.unmarshalFromByte((byte[]) data, ServerRunningData.class);
if (!isMine(runningData.getAddress())) {
mutex.set(false);
}
if (!runningData.isActive() && isMine(runningData.getAddress())) { // active
release = true;
releaseRunning();// mainstem
}
activeData = (ServerRunningData) runningData;
}
public void handleDataDeleted(String dataPath) throws Exception {
MDC.put("destination", destination);
mutex.set(false);
if (!release && activeData != null && isMine(activeData.getAddress())) {
// activeactive
initRunning();
} else {
// delayTimezk
delayExector.schedule(new Runnable() {
public void run() {
initRunning();
}
}, delayTime, TimeUnit.SECONDS);
}
}
};
}
public void start() {
super.start();
processStart();
if (zkClient != null) {
// instancerunningstopstart
String path = ZookeeperPathUtils.<API key>(destination);
zkClient.<API key>(path, dataListener);
initRunning();
} else {
processActiveEnter();
}
}
public void release() {
if (zkClient != null) {
releaseRunning(); // release
} else {
processActiveExit();
}
}
public void stop() {
super.stop();
if (zkClient != null) {
String path = ZookeeperPathUtils.<API key>(destination);
zkClient.<API key>(path, dataListener);
releaseRunning(); // release
} else {
processActiveExit();
}
processStop();
}
private void initRunning() {
if (!isStart()) {
return;
}
String path = ZookeeperPathUtils.<API key>(destination);
byte[] bytes = JsonUtils.marshalToByte(serverData);
try {
mutex.set(false);
zkClient.create(path, bytes, CreateMode.EPHEMERAL);
activeData = serverData;
processActiveEnter();
mutex.set(true);
} catch (<API key> e) {
bytes = zkClient.readData(path, true);
if (bytes == null) {
initRunning();
} else {
activeData = JsonUtils.unmarshalFromByte(bytes, ServerRunningData.class);
}
} catch (ZkNoNodeException e) {
zkClient.createPersistent(ZookeeperPathUtils.getDestinationPath(destination), true);
initRunning();
}
}
/**
* activeactive
*
* @throws <API key>
*/
public void waitForActive() throws <API key> {
initRunning();
mutex.get();
}
public boolean check() {
String path = ZookeeperPathUtils.<API key>(destination);
try {
byte[] bytes = zkClient.readData(path);
ServerRunningData eventData = JsonUtils.unmarshalFromByte(bytes, ServerRunningData.class);
activeData = eventData;
// nid
boolean result = isMine(activeData.getAddress());
if (!result) {
logger.warn("canal is running in node[{}] , but not in node[{}]",
activeData.getCid(),
serverData.getCid());
}
return result;
} catch (ZkNoNodeException e) {
logger.warn("canal is not run any in node");
return false;
} catch (<API key> e) {
logger.warn("canal check is interrupt");
Thread.interrupted();// interrupt
return check();
} catch (ZkException e) {
logger.warn("canal check is failed");
return false;
}
}
private boolean releaseRunning() {
if (check()) {
String path = ZookeeperPathUtils.<API key>(destination);
zkClient.delete(path);
mutex.set(false);
processActiveExit();
return true;
}
return false;
}
private boolean isMine(String address) {
return address.equals(serverData.getAddress());
}
private void processStart() {
if (listener != null) {
try {
listener.processStart();
} catch (Exception e) {
logger.error("processStart failed", e);
}
}
}
private void processStop() {
if (listener != null) {
try {
listener.processStop();
} catch (Exception e) {
logger.error("processStop failed", e);
}
}
}
private void processActiveEnter() {
if (listener != null) {
try {
listener.processActiveEnter();
} catch (Exception e) {
logger.error("processActiveEnter failed", e);
}
}
}
private void processActiveExit() {
if (listener != null) {
try {
listener.processActiveExit();
} catch (Exception e) {
logger.error("processActiveExit failed", e);
}
}
}
public void setListener(<API key> listener) {
this.listener = listener;
}
public void setDelayTime(int delayTime) {
this.delayTime = delayTime;
}
public void setServerData(ServerRunningData serverData) {
this.serverData = serverData;
}
public void setDestination(String destination) {
this.destination = destination;
}
public void setZkClient(ZkClientx zkClient) {
this.zkClient = zkClient;
}
} |
<?php
return <API key>(require __DIR__.'/en.php', [
'meridiem' => ['utuko', 'kyiukonyi'],
'weekdays' => ['Jumapilyi', 'Jumatatuu', 'Jumanne', 'Jumatanu', 'Alhamisi', 'Ijumaa', 'Jumamosi'],
'weekdays_short' => ['Jpi', 'Jtt', 'Jnn', 'Jtn', 'Alh', 'Iju', 'Jmo'],
'weekdays_min' => ['Jpi', 'Jtt', 'Jnn', 'Jtn', 'Alh', 'Iju', 'Jmo'],
'months' => ['Januari', 'Februari', 'Machi', 'Aprilyi', 'Mei', 'Junyi', 'Julyai', 'Agusti', 'Septemba', 'Oktoba', 'Novemba', 'Desemba'],
'months_short' => ['Jan', 'Feb', 'Mac', 'Apr', 'Mei', 'Jun', 'Jul', 'Ago', 'Sep', 'Okt', 'Nov', 'Des'],
'first_day_of_week' => 1,
'formats' => [
'LT' => 'HH:mm',
'LTS' => 'HH:mm:ss',
'L' => 'DD/MM/YYYY',
'LL' => 'D MMM YYYY',
'LLL' => 'D MMMM YYYY HH:mm',
'LLLL' => 'dddd, D MMMM YYYY HH:mm',
],
]); |
#ifndef <API key>
#define <API key>
#include <stdint.h>
#include "base/callback_forward.h"
#include "base/compiler_specific.h"
#include "base/macros.h"
#include "base/memory/weak_ptr.h"
#include "content/public/browser/<API key>.h"
namespace content {
class DownloadManager;
class <API key> : public <API key> {
public:
<API key>();
~<API key>() override;
void SetDownloadManager(DownloadManager* manager);
void Shutdown() override;
bool <API key>(DownloadItem* download,
const <API key>& callback) override;
bool ShouldOpenDownload(DownloadItem* item,
const <API key>& callback) override;
void GetNextId(const DownloadIdCallback& callback) override;
// Inhibits prompting and sets the default download path.
void <API key>(
const base::FilePath& <API key>);
private:
friend class base::<API key><<API key>>;
typedef base::Callback<void(const base::FilePath&)>
<API key>;
static void GenerateFilename(const GURL& url,
const std::string& content_disposition,
const std::string& suggested_filename,
const std::string& mime_type,
const base::FilePath& suggested_directory,
const <API key>& callback);
void <API key>(uint32_t download_id,
const <API key>& callback,
const base::FilePath& suggested_path);
void ChooseDownloadPath(uint32_t download_id,
const <API key>& callback,
const base::FilePath& suggested_path);
DownloadManager* download_manager_;
base::FilePath <API key>;
bool suppress_prompting_;
base::WeakPtrFactory<<API key>> weak_ptr_factory_;
<API key>(<API key>);
};
} // namespace content
#endif // <API key> |
#include "gpu-compute/pool_manager.hh"
PoolManager::PoolManager(uint32_t minAlloc, uint32_t poolSize)
: _minAllocation(minAlloc), _poolSize(poolSize)
{
assert(poolSize > 0);
} |
<?php
namespace PhpOffice\PhpWord;
use PhpOffice\PhpWord\Exception\Exception;
/**
* IO Factory
*/
abstract class IOFactory
{
/**
* Create new writer
*
* @param PhpWord $phpWord
* @param string $name
* @return \PhpOffice\PhpWord\Writer\WriterInterface
* @throws \PhpOffice\PhpWord\Exception\Exception
*/
public static function createWriter(PhpWord $phpWord, $name = 'Word2007')
{
$class = 'PhpOffice\\PhpWord\\Writer\\' . $name;
if (class_exists($class) && self::isConcreteClass($class)) {
return new $class($phpWord);
} else {
throw new Exception("\"{$name}\" is not a valid writer.");
}
}
/**
* Create new reader
*
* @param string $name
* @return \PhpOffice\PhpWord\Reader\ReaderInterface
* @throws \PhpOffice\PhpWord\Exception\Exception
*/
public static function createReader($name = 'Word2007')
{
$class = 'PhpOffice\\PhpWord\\Reader\\' . $name;
if (class_exists($class) && self::isConcreteClass($class)) {
return new $class();
} else {
throw new Exception("\"{$name}\" is not a valid reader.");
}
}
/**
* Loads PhpWord from file
*
* @param string $filename The name of the file
* @param string $readerName
* @return PhpWord
*/
public static function load($filename, $readerName = 'Word2007')
{
$reader = self::createReader($readerName);
return $reader->load($filename);
}
/**
* Check if it's a concrete class (not abstract nor interface)
*
* @param string $class
* @return bool
*/
private static function isConcreteClass($class)
{
$reflection = new \ReflectionClass($class);
return !$reflection->isAbstract() && !$reflection->isInterface();
}
} |
// Use of this source code is governed by a BSD-style
package mytype
type MyType struct {
Map map[string]string
MapBytes map[string][]byte
MapPtr map[string]*string
MapSlice map[string][]string
MapMap map[string]map[string]int64
MapCustom map[string]Custom
MapCustomPtr map[string]*Custom
CustomMap map[Custom]string
MapExternal map[pkg.Custom]string
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.