code stringlengths 5 1.01M | repo_name stringlengths 5 84 | path stringlengths 4 311 | language stringclasses 30
values | license stringclasses 15
values | size int64 5 1.01M | input_ids listlengths 502 502 | token_type_ids listlengths 502 502 | attention_mask listlengths 502 502 | labels listlengths 502 502 |
|---|---|---|---|---|---|---|---|---|---|
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.hive.hcatalog.templeton;
/**
* ExecBean - The results of an exec call.
*/
public class ExecBean {
public String stdout;
public String stderr;
public int exitcode;
public ExecBean() {}
/**
* Create a new ExecBean.
*
* @param stdout standard output of the the program.
* @param stderr error output of the the program.
* @param exitcode exit code of the program.
*/
public ExecBean(String stdout, String stderr, int exitcode) {
this.stdout = stdout;
this.stderr = stderr;
this.exitcode = exitcode;
}
public String toString() {
return String.format("ExecBean(stdout=%s, stderr=%s, exitcode=%s)",
stdout, stderr, exitcode);
}
}
| vineetgarg02/hive | hcatalog/webhcat/svr/src/main/java/org/apache/hive/hcatalog/templeton/ExecBean.java | Java | apache-2.0 | 1,535 | [
30522,
1013,
1008,
1008,
7000,
2000,
1996,
15895,
4007,
3192,
1006,
2004,
2546,
1007,
2104,
2028,
1008,
2030,
2062,
12130,
6105,
10540,
1012,
2156,
1996,
5060,
5371,
1008,
5500,
2007,
2023,
2147,
2005,
3176,
2592,
1008,
4953,
9385,
6095,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
const express = require('express');
const libxmljs = require('libxmljs');
express().get('/some/path', function(req) {
// OK: libxml does not expand entities by default
libxmljs.parseXml(req.param("some-xml"));
});
| github/codeql | javascript/ql/test/query-tests/Security/CWE-611/libxml.js | JavaScript | mit | 219 | [
30522,
9530,
3367,
4671,
1027,
5478,
1006,
1005,
4671,
1005,
1007,
1025,
9530,
3367,
5622,
2497,
2595,
19968,
22578,
1027,
5478,
1006,
1005,
5622,
2497,
2595,
19968,
22578,
1005,
1007,
1025,
4671,
1006,
1007,
1012,
2131,
1006,
1005,
1013,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
/*
* Entagged Audio Tag library
* Copyright (c) 2003-2005 Raphaël Slinckx <raphael@slinckx.net>
* Copyright (c) 2004-2005 Christian Laireiter <liree@web.de>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
package org.jaudiotagger.audio.ogg.util;
import org.jaudiotagger.audio.exceptions.CannotReadException;
import org.jaudiotagger.audio.generic.GenericAudioHeader;
import org.jaudiotagger.logging.ErrorMessage;
import org.jaudiotagger.tag.id3.AbstractID3v2Tag;
import java.io.IOException;
import java.io.RandomAccessFile;
import java.util.logging.Logger;
import java.util.Arrays;
/**
* Read encoding info, only implemented for vorbis streams
*/
public class OggInfoReader
{
// Logger Object
public static Logger logger = Logger.getLogger("org.jaudiotagger.audio.ogg.atom");
public GenericAudioHeader read(RandomAccessFile raf) throws CannotReadException, IOException
{
long start = raf.getFilePointer();
GenericAudioHeader info = new GenericAudioHeader();
logger.fine("Started");
long oldPos;
//Check start of file does it have Ogg pattern
byte[] b = new byte[OggPageHeader.CAPTURE_PATTERN.length];
raf.read(b);
if (!(Arrays.equals(b, OggPageHeader.CAPTURE_PATTERN)))
{
raf.seek(0);
if(AbstractID3v2Tag.isId3Tag(raf))
{
raf.read(b);
if ((Arrays.equals(b, OggPageHeader.CAPTURE_PATTERN)))
{
start=raf.getFilePointer();
}
}
else
{
throw new CannotReadException(ErrorMessage.OGG_HEADER_CANNOT_BE_FOUND.getMsg(new String(b)));
}
}
//Now work backwards from file looking for the last ogg page, it reads the granule position for this last page
//which must be set.
//TODO should do buffering to cut down the number of file reads
raf.seek(start);
double pcmSamplesNumber = -1;
raf.seek(raf.length() - 2);
while (raf.getFilePointer() >= 4)
{
if (raf.read() == OggPageHeader.CAPTURE_PATTERN[3])
{
raf.seek(raf.getFilePointer() - OggPageHeader.FIELD_CAPTURE_PATTERN_LENGTH);
byte[] ogg = new byte[3];
raf.readFully(ogg);
if (ogg[0] == OggPageHeader.CAPTURE_PATTERN[0] && ogg[1] == OggPageHeader.CAPTURE_PATTERN[1] && ogg[2] == OggPageHeader.CAPTURE_PATTERN[2])
{
raf.seek(raf.getFilePointer() - 3);
oldPos = raf.getFilePointer();
raf.seek(raf.getFilePointer() + OggPageHeader.FIELD_PAGE_SEGMENTS_POS);
int pageSegments = raf.readByte() & 0xFF; //Unsigned
raf.seek(oldPos);
b = new byte[OggPageHeader.OGG_PAGE_HEADER_FIXED_LENGTH + pageSegments];
raf.readFully(b);
OggPageHeader pageHeader = new OggPageHeader(b);
raf.seek(0);
pcmSamplesNumber = pageHeader.getAbsoluteGranulePosition();
break;
}
}
raf.seek(raf.getFilePointer() - 2);
}
if (pcmSamplesNumber == -1)
{
//According to spec a value of -1 indicates no packet finished on this page, this should not occur
throw new CannotReadException(ErrorMessage.OGG_VORBIS_NO_SETUP_BLOCK.getMsg());
}
//1st page = Identification Header
OggPageHeader pageHeader = OggPageHeader.read(raf);
byte[] vorbisData = new byte[pageHeader.getPageLength()];
raf.read(vorbisData);
VorbisIdentificationHeader vorbisIdentificationHeader = new VorbisIdentificationHeader(vorbisData);
//Map to generic encodingInfo
info.setPreciseLength((float) (pcmSamplesNumber / vorbisIdentificationHeader.getSamplingRate()));
info.setChannelNumber(vorbisIdentificationHeader.getChannelNumber());
info.setSamplingRate(vorbisIdentificationHeader.getSamplingRate());
info.setEncodingType(vorbisIdentificationHeader.getEncodingType());
info.setExtraEncodingInfos("");
//According to Wikipedia Vorbis Page, Vorbis only works on 16bits 44khz
info.setBitsPerSample(16);
//TODO this calculation should be done within identification header
if (vorbisIdentificationHeader.getNominalBitrate() != 0 && vorbisIdentificationHeader.getMaxBitrate() == vorbisIdentificationHeader.getNominalBitrate() && vorbisIdentificationHeader.getMinBitrate() == vorbisIdentificationHeader.getNominalBitrate())
{
//CBR (in kbps)
info.setBitrate(vorbisIdentificationHeader.getNominalBitrate() / 1000);
info.setVariableBitRate(false);
}
else
if (vorbisIdentificationHeader.getNominalBitrate() != 0 && vorbisIdentificationHeader.getMaxBitrate() == 0 && vorbisIdentificationHeader.getMinBitrate() == 0)
{
//Average vbr (in kpbs)
info.setBitrate(vorbisIdentificationHeader.getNominalBitrate() / 1000);
info.setVariableBitRate(true);
}
else
{
//TODO need to remove comment from raf.getLength()
info.setBitrate(computeBitrate(info.getTrackLength(), raf.length()));
info.setVariableBitRate(true);
}
logger.fine("Finished");
return info;
}
private int computeBitrate(int length, long size)
{
//Protect against audio less than 0.5 seconds that can be rounded to zero causing Arithmetic Exception
if(length==0)
{
length=1;
}
return (int) ((size / 1000) * 8 / length);
}
}
| nhminus/jaudiotagger-androidpatch | src/org/jaudiotagger/audio/ogg/util/OggInfoReader.java | Java | lgpl-2.1 | 6,507 | [
30522,
1013,
1008,
1008,
4372,
15900,
5999,
5746,
6415,
3075,
1008,
9385,
1006,
1039,
1007,
2494,
1011,
2384,
12551,
22889,
2378,
3600,
2595,
1026,
12551,
1030,
22889,
2378,
3600,
2595,
1012,
5658,
1028,
1008,
9385,
1006,
1039,
1007,
2432,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
/***************************************************************************
qgscurveeditorwidget.cpp
------------------------
begin : February 2017
copyright : (C) 2017 by Nyall Dawson
email : nyall dot dawson at gmail dot com
***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#include "qgscurveeditorwidget.h"
#include "qgsvectorlayer.h"
#include <QPainter>
#include <QVBoxLayout>
#include <QMouseEvent>
#include <algorithm>
// QWT Charting widget
#include <qwt_global.h>
#include <qwt_plot_canvas.h>
#include <qwt_plot.h>
#include <qwt_plot_curve.h>
#include <qwt_plot_grid.h>
#include <qwt_plot_marker.h>
#include <qwt_plot_picker.h>
#include <qwt_picker_machine.h>
#include <qwt_plot_layout.h>
#include <qwt_symbol.h>
#include <qwt_legend.h>
#include <qwt_plot_renderer.h>
#include <qwt_plot_histogram.h>
QgsCurveEditorWidget::QgsCurveEditorWidget( QWidget *parent, const QgsCurveTransform &transform )
: QWidget( parent )
, mCurve( transform )
{
mPlot = new QwtPlot();
mPlot->setMinimumSize( QSize( 0, 100 ) );
mPlot->setAxisScale( QwtPlot::yLeft, 0, 1 );
mPlot->setAxisScale( QwtPlot::yRight, 0, 1 );
mPlot->setAxisScale( QwtPlot::xBottom, 0, 1 );
mPlot->setAxisScale( QwtPlot::xTop, 0, 1 );
QVBoxLayout *vlayout = new QVBoxLayout();
vlayout->addWidget( mPlot );
setLayout( vlayout );
// hide the ugly canvas frame
mPlot->setFrameStyle( QFrame::NoFrame );
QFrame *plotCanvasFrame = dynamic_cast<QFrame *>( mPlot->canvas() );
if ( plotCanvasFrame )
plotCanvasFrame->setFrameStyle( QFrame::NoFrame );
mPlot->enableAxis( QwtPlot::yLeft, false );
mPlot->enableAxis( QwtPlot::xBottom, false );
// add a grid
QwtPlotGrid *grid = new QwtPlotGrid();
QwtScaleDiv gridDiv( 0.0, 1.0, QList<double>(), QList<double>(), QList<double>() << 0.2 << 0.4 << 0.6 << 0.8 );
grid->setXDiv( gridDiv );
grid->setYDiv( gridDiv );
grid->setPen( QPen( QColor( 0, 0, 0, 50 ) ) );
grid->attach( mPlot );
mPlotCurve = new QwtPlotCurve();
mPlotCurve->setTitle( QStringLiteral( "Curve" ) );
mPlotCurve->setPen( QPen( QColor( 30, 30, 30 ), 0.0 ) ),
mPlotCurve->setRenderHint( QwtPlotItem::RenderAntialiased, true );
mPlotCurve->attach( mPlot );
mPlotFilter = new QgsCurveEditorPlotEventFilter( mPlot );
connect( mPlotFilter, &QgsCurveEditorPlotEventFilter::mousePress, this, &QgsCurveEditorWidget::plotMousePress );
connect( mPlotFilter, &QgsCurveEditorPlotEventFilter::mouseRelease, this, &QgsCurveEditorWidget::plotMouseRelease );
connect( mPlotFilter, &QgsCurveEditorPlotEventFilter::mouseMove, this, &QgsCurveEditorWidget::plotMouseMove );
mPlotCurve->setVisible( true );
updatePlot();
}
QgsCurveEditorWidget::~QgsCurveEditorWidget()
{
if ( mGatherer && mGatherer->isRunning() )
{
connect( mGatherer.get(), &QgsHistogramValuesGatherer::finished, mGatherer.get(), &QgsHistogramValuesGatherer::deleteLater );
mGatherer->stop();
( void )mGatherer.release();
}
}
void QgsCurveEditorWidget::setCurve( const QgsCurveTransform &curve )
{
mCurve = curve;
updatePlot();
emit changed();
}
void QgsCurveEditorWidget::setHistogramSource( const QgsVectorLayer *layer, const QString &expression )
{
if ( !mGatherer )
{
mGatherer.reset( new QgsHistogramValuesGatherer() );
connect( mGatherer.get(), &QgsHistogramValuesGatherer::calculatedHistogram, this, [ = ]
{
mHistogram.reset( new QgsHistogram( mGatherer->histogram() ) );
updateHistogram();
} );
}
bool changed = mGatherer->layer() != layer || mGatherer->expression() != expression;
if ( changed )
{
mGatherer->setExpression( expression );
mGatherer->setLayer( layer );
mGatherer->start();
if ( mGatherer->isRunning() )
{
//stop any currently running task
mGatherer->stop();
while ( mGatherer->isRunning() )
{
QCoreApplication::processEvents();
}
}
mGatherer->start();
}
else
{
updateHistogram();
}
}
void QgsCurveEditorWidget::setMinHistogramValueRange( double minValueRange )
{
mMinValueRange = minValueRange;
updateHistogram();
}
void QgsCurveEditorWidget::setMaxHistogramValueRange( double maxValueRange )
{
mMaxValueRange = maxValueRange;
updateHistogram();
}
void QgsCurveEditorWidget::keyPressEvent( QKeyEvent *event )
{
if ( event->key() == Qt::Key_Delete || event->key() == Qt::Key_Backspace )
{
QList< QgsPointXY > cp = mCurve.controlPoints();
if ( mCurrentPlotMarkerIndex > 0 && mCurrentPlotMarkerIndex < cp.count() - 1 )
{
cp.removeAt( mCurrentPlotMarkerIndex );
mCurve.setControlPoints( cp );
updatePlot();
emit changed();
}
}
}
void QgsCurveEditorWidget::plotMousePress( QPointF point )
{
mCurrentPlotMarkerIndex = findNearestControlPoint( point );
if ( mCurrentPlotMarkerIndex < 0 )
{
// add a new point
mCurve.addControlPoint( point.x(), point.y() );
mCurrentPlotMarkerIndex = findNearestControlPoint( point );
emit changed();
}
updatePlot();
}
int QgsCurveEditorWidget::findNearestControlPoint( QPointF point ) const
{
double minDist = 3.0 / mPlot->width();
int currentPlotMarkerIndex = -1;
QList< QgsPointXY > controlPoints = mCurve.controlPoints();
for ( int i = 0; i < controlPoints.count(); ++i )
{
QgsPointXY currentPoint = controlPoints.at( i );
double currentDist;
currentDist = std::pow( point.x() - currentPoint.x(), 2.0 ) + std::pow( point.y() - currentPoint.y(), 2.0 );
if ( currentDist < minDist )
{
minDist = currentDist;
currentPlotMarkerIndex = i;
}
}
return currentPlotMarkerIndex;
}
void QgsCurveEditorWidget::plotMouseRelease( QPointF )
{
}
void QgsCurveEditorWidget::plotMouseMove( QPointF point )
{
if ( mCurrentPlotMarkerIndex < 0 )
return;
QList< QgsPointXY > cp = mCurve.controlPoints();
bool removePoint = false;
if ( mCurrentPlotMarkerIndex == 0 )
{
point.setX( std::min( point.x(), cp.at( 1 ).x() - 0.01 ) );
}
else
{
removePoint = point.x() <= cp.at( mCurrentPlotMarkerIndex - 1 ).x();
}
if ( mCurrentPlotMarkerIndex == cp.count() - 1 )
{
point.setX( std::max( point.x(), cp.at( mCurrentPlotMarkerIndex - 1 ).x() + 0.01 ) );
removePoint = false;
}
else
{
removePoint = removePoint || point.x() >= cp.at( mCurrentPlotMarkerIndex + 1 ).x();
}
if ( removePoint )
{
cp.removeAt( mCurrentPlotMarkerIndex );
mCurrentPlotMarkerIndex = -1;
}
else
{
cp[ mCurrentPlotMarkerIndex ] = QgsPointXY( point.x(), point.y() );
}
mCurve.setControlPoints( cp );
updatePlot();
emit changed();
}
void QgsCurveEditorWidget::addPlotMarker( double x, double y, bool isSelected )
{
QColor borderColor( 0, 0, 0 );
QColor brushColor = isSelected ? borderColor : QColor( 255, 255, 255, 0 );
QwtPlotMarker *marker = new QwtPlotMarker();
marker->setSymbol( new QwtSymbol( QwtSymbol::Ellipse, QBrush( brushColor ), QPen( borderColor, isSelected ? 2 : 1 ), QSize( 8, 8 ) ) );
marker->setValue( x, y );
marker->attach( mPlot );
marker->setRenderHint( QwtPlotItem::RenderAntialiased, true );
mMarkers << marker;
}
void QgsCurveEditorWidget::updateHistogram()
{
if ( !mHistogram )
return;
//draw histogram
QBrush histoBrush( QColor( 0, 0, 0, 70 ) );
delete mPlotHistogram;
mPlotHistogram = createPlotHistogram( histoBrush );
QVector<QwtIntervalSample> dataHisto;
int bins = 40;
QList<double> edges = mHistogram->binEdges( bins );
QList<int> counts = mHistogram->counts( bins );
// scale counts to 0->1
double max = *std::max_element( counts.constBegin(), counts.constEnd() );
// scale bin edges to fit in 0->1 range
if ( !qgsDoubleNear( mMinValueRange, mMaxValueRange ) )
{
std::transform( edges.begin(), edges.end(), edges.begin(),
[this]( double d ) -> double { return ( d - mMinValueRange ) / ( mMaxValueRange - mMinValueRange ); } );
}
for ( int bin = 0; bin < bins; ++bin )
{
double binValue = counts.at( bin ) / max;
double upperEdge = edges.at( bin + 1 );
dataHisto << QwtIntervalSample( binValue, edges.at( bin ), upperEdge );
}
mPlotHistogram->setSamples( dataHisto );
mPlotHistogram->attach( mPlot );
mPlot->replot();
}
void QgsCurveEditorWidget::updatePlot()
{
// remove existing markers
Q_FOREACH ( QwtPlotMarker *marker, mMarkers )
{
marker->detach();
delete marker;
}
mMarkers.clear();
QPolygonF curvePoints;
QVector< double > x;
int i = 0;
Q_FOREACH ( const QgsPointXY &point, mCurve.controlPoints() )
{
x << point.x();
addPlotMarker( point.x(), point.y(), mCurrentPlotMarkerIndex == i );
i++;
}
//add extra intermediate points
for ( double p = 0; p <= 1.0; p += 0.01 )
{
x << p;
}
std::sort( x.begin(), x.end() );
QVector< double > y = mCurve.y( x );
for ( int j = 0; j < x.count(); ++j )
{
curvePoints << QPointF( x.at( j ), y.at( j ) );
}
mPlotCurve->setSamples( curvePoints );
mPlot->replot();
}
QwtPlotHistogram *QgsCurveEditorWidget::createPlotHistogram( const QBrush &brush, const QPen &pen ) const
{
QwtPlotHistogram *histogram = new QwtPlotHistogram( QString() );
histogram->setBrush( brush );
if ( pen != Qt::NoPen )
{
histogram->setPen( pen );
}
else if ( brush.color().lightness() > 200 )
{
QPen p;
p.setColor( brush.color().darker( 150 ) );
p.setWidth( 0 );
p.setCosmetic( true );
histogram->setPen( p );
}
else
{
histogram->setPen( QPen( Qt::NoPen ) );
}
return histogram;
}
/// @cond PRIVATE
QgsCurveEditorPlotEventFilter::QgsCurveEditorPlotEventFilter( QwtPlot *plot )
: QObject( plot )
, mPlot( plot )
{
mPlot->canvas()->installEventFilter( this );
}
bool QgsCurveEditorPlotEventFilter::eventFilter( QObject *object, QEvent *event )
{
if ( !mPlot->isEnabled() )
return QObject::eventFilter( object, event );
switch ( event->type() )
{
case QEvent::MouseButtonPress:
{
const QMouseEvent *mouseEvent = static_cast<QMouseEvent * >( event );
if ( mouseEvent->button() == Qt::LeftButton )
{
emit mousePress( mapPoint( mouseEvent->pos() ) );
}
break;
}
case QEvent::MouseMove:
{
const QMouseEvent *mouseEvent = static_cast<QMouseEvent * >( event );
if ( mouseEvent->buttons() & Qt::LeftButton )
{
// only emit when button pressed
emit mouseMove( mapPoint( mouseEvent->pos() ) );
}
break;
}
case QEvent::MouseButtonRelease:
{
const QMouseEvent *mouseEvent = static_cast<QMouseEvent * >( event );
if ( mouseEvent->button() == Qt::LeftButton )
{
emit mouseRelease( mapPoint( mouseEvent->pos() ) );
}
break;
}
default:
break;
}
return QObject::eventFilter( object, event );
}
QPointF QgsCurveEditorPlotEventFilter::mapPoint( QPointF point ) const
{
if ( !mPlot )
return QPointF();
return QPointF( mPlot->canvasMap( QwtPlot::xBottom ).invTransform( point.x() ),
mPlot->canvasMap( QwtPlot::yLeft ).invTransform( point.y() ) );
}
///@endcond
| geopython/QGIS | src/gui/qgscurveeditorwidget.cpp | C++ | gpl-2.0 | 11,754 | [
30522,
1013,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
100... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
/**
* NOTE: This copyright does *not* cover user programs that use HQ
* program services by normal system calls through the application
* program interfaces provided as part of the Hyperic Plug-in Development
* Kit or the Hyperic Client Development Kit - this is merely considered
* normal use of the program, and does *not* fall under the heading of
* "derived work".
*
* Copyright (C) [2009-2010], VMware, Inc.
* This file is part of HQ.
*
* HQ is free software; you can redistribute it and/or modify
* it under the terms version 2 of the GNU General Public License as
* published by the Free Software Foundation. This program is distributed
* in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
* even the implied warranty of MERCHANTABILITY or FITNESS FOR A
* PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
* USA.
*
*/
package org.hyperic.hq.bizapp.shared;
import java.util.List;
import java.util.Map;
import javax.security.auth.login.LoginException;
import org.hyperic.hq.appdef.shared.AppdefEntityID;
import org.hyperic.hq.appdef.shared.AppdefEntityNotFoundException;
import org.hyperic.hq.appdef.shared.AppdefEntityTypeID;
import org.hyperic.hq.auth.shared.SessionException;
import org.hyperic.hq.auth.shared.SessionNotFoundException;
import org.hyperic.hq.auth.shared.SessionTimeoutException;
import org.hyperic.hq.authz.server.session.AuthzSubject;
import org.hyperic.hq.authz.shared.PermissionException;
import org.hyperic.hq.common.ApplicationException;
import org.hyperic.hq.common.DuplicateObjectException;
import org.hyperic.hq.escalation.server.session.Escalatable;
import org.hyperic.hq.escalation.server.session.Escalation;
import org.hyperic.hq.escalation.server.session.EscalationAlertType;
import org.hyperic.hq.escalation.server.session.EscalationState;
import org.hyperic.hq.events.ActionConfigInterface;
import org.hyperic.hq.events.ActionCreateException;
import org.hyperic.hq.events.ActionExecuteException;
import org.hyperic.hq.events.AlertConditionCreateException;
import org.hyperic.hq.events.AlertDefinitionCreateException;
import org.hyperic.hq.events.AlertNotFoundException;
import org.hyperic.hq.events.MaintenanceEvent;
import org.hyperic.hq.events.TriggerCreateException;
import org.hyperic.hq.events.server.session.Action;
import org.hyperic.hq.events.server.session.Alert;
import org.hyperic.hq.events.shared.ActionValue;
import org.hyperic.hq.events.shared.AlertDefinitionValue;
import org.hyperic.util.ConfigPropertyException;
import org.hyperic.util.config.ConfigResponse;
import org.hyperic.util.config.ConfigSchema;
import org.hyperic.util.config.InvalidOptionException;
import org.hyperic.util.config.InvalidOptionValueException;
import org.hyperic.util.pager.PageControl;
import org.hyperic.util.pager.PageList;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import org.quartz.SchedulerException;
import org.springframework.transaction.annotation.Transactional;
/**
* Local interface for EventsBoss.
*/
public interface EventsBoss {
/**
* Get the number of alerts for the given array of AppdefEntityID's
*/
public int[] getAlertCount(int sessionID, org.hyperic.hq.appdef.shared.AppdefEntityID[] ids)
throws SessionNotFoundException, SessionTimeoutException, PermissionException;
/**
* Get the number of alerts for the given array of AppdefEntityID's, mapping AppdefEntityID to it's alerts count
*
*/
@Transactional(readOnly = true)
public Map<AppdefEntityID, Integer> getAlertCountMapped(int sessionID, AppdefEntityID[] ids)
throws SessionNotFoundException, SessionTimeoutException, PermissionException;
/**
* Create an alert definition
*/
public AlertDefinitionValue createAlertDefinition(int sessionID, AlertDefinitionValue adval)
throws org.hyperic.hq.events.AlertDefinitionCreateException, PermissionException,
InvalidOptionException, InvalidOptionValueException, SessionException;
/**
* Create an alert definition for a resource type
*/
public AlertDefinitionValue createResourceTypeAlertDefinition(int sessionID,
AppdefEntityTypeID aetid,
AlertDefinitionValue adval)
throws org.hyperic.hq.events.AlertDefinitionCreateException, PermissionException,
InvalidOptionException, InvalidOptionValueException, SessionNotFoundException,
SessionTimeoutException;
public Action createAction(int sessionID, Integer adid, String className, ConfigResponse config)
throws SessionNotFoundException, SessionTimeoutException, ActionCreateException,
PermissionException;
/**
* Activate/deactivate a collection of alert definitions
*/
public void activateAlertDefinitions(int sessionID, java.lang.Integer[] ids, boolean activate)
throws SessionNotFoundException, SessionTimeoutException, PermissionException;
/**
* Activate or deactivate alert definitions by AppdefEntityID.
*/
public void activateAlertDefinitions(int sessionID,
org.hyperic.hq.appdef.shared.AppdefEntityID[] eids,
boolean activate) throws SessionNotFoundException,
SessionTimeoutException, AppdefEntityNotFoundException, PermissionException;
/**
* Update just the basics
*/
public void updateAlertDefinitionBasic(int sessionID, Integer alertDefId, String name,
String desc, int priority, boolean activate)
throws SessionNotFoundException, SessionTimeoutException, PermissionException;
public void updateAlertDefinition(int sessionID, AlertDefinitionValue adval)
throws TriggerCreateException, InvalidOptionException, InvalidOptionValueException,
AlertConditionCreateException, ActionCreateException, SessionNotFoundException,
SessionTimeoutException;
/**
* Get actions for a given alert.
* @param alertId the alert id
*/
public List<ActionValue> getActionsForAlert(int sessionId, Integer alertId)
throws SessionNotFoundException, SessionTimeoutException;
/**
* Update an action
*/
public void updateAction(int sessionID, ActionValue aval) throws SessionNotFoundException,
SessionTimeoutException;
/**
* Delete a collection of alert definitions
*/
public void deleteAlertDefinitions(int sessionID, java.lang.Integer[] ids)
throws SessionNotFoundException, SessionTimeoutException, PermissionException;
/**
* Delete list of alerts
*/
public void deleteAlerts(int sessionID, java.lang.Integer[] ids)
throws SessionNotFoundException, SessionTimeoutException, PermissionException;
/**
* Delete all alerts for a list of alert definitions
*
*/
public int deleteAlertsForDefinitions(int sessionID, java.lang.Integer[] adids)
throws SessionNotFoundException, SessionTimeoutException, PermissionException;
/**
* Get an alert definition by ID
*/
public AlertDefinitionValue getAlertDefinition(int sessionID, Integer id)
throws SessionNotFoundException, SessionTimeoutException, PermissionException;
/**
* Find an alert by ID
*/
public Alert getAlert(int sessionID, Integer id) throws SessionNotFoundException,
SessionTimeoutException, AlertNotFoundException;
/**
* Get a list of all alert definitions
*/
public PageList<AlertDefinitionValue> findAllAlertDefinitions(int sessionID)
throws SessionNotFoundException, SessionTimeoutException, PermissionException;
/**
* Get a collection of alert definitions for a resource
*/
public PageList<AlertDefinitionValue> findAlertDefinitions(int sessionID, AppdefEntityID id,
PageControl pc)
throws SessionNotFoundException, SessionTimeoutException, PermissionException;
/**
* Get a collection of alert definitions for a resource or resource type
*/
public PageList<AlertDefinitionValue> findAlertDefinitions(int sessionID,
AppdefEntityTypeID id, PageControl pc)
throws SessionNotFoundException, SessionTimeoutException, PermissionException;
/**
* Find all alert definition names for a resource
* @return Map of AlertDefinition names and IDs
*/
public Map<String, Integer> findAlertDefinitionNames(int sessionID, AppdefEntityID id,
Integer parentId)
throws SessionNotFoundException, SessionTimeoutException, AppdefEntityNotFoundException,
PermissionException;
/**
* Find all alerts for an appdef resource
*/
public PageList<Alert> findAlerts(int sessionID, AppdefEntityID id, long begin, long end,
PageControl pc) throws SessionNotFoundException,
SessionTimeoutException, PermissionException;
/**
* Search alerts given a set of criteria
* @param username the username
* @param count the maximum number of alerts to return
* @param priority allowable values: 0 (all), 1, 2, or 3
* @param timeRange the amount of time from current time to include
* @param ids the IDs of resources to include or null for ALL
* @return a list of {@link Escalatable}s
*/
public List<Escalatable> findRecentAlerts(String username, int count, int priority,
long timeRange,
org.hyperic.hq.appdef.shared.AppdefEntityID[] ids)
throws LoginException, ApplicationException, ConfigPropertyException;
/**
* Search recent alerts given a set of criteria
* @param sessionID the session token
* @param count the maximum number of alerts to return
* @param priority allowable values: 0 (all), 1, 2, or 3
* @param timeRange the amount of time from current time to include
* @param ids the IDs of resources to include or null for ALL
* @return a list of {@link Escalatable}s
*/
public List<Escalatable> findRecentAlerts(int sessionID, int count, int priority,
long timeRange,
org.hyperic.hq.appdef.shared.AppdefEntityID[] ids)
throws SessionNotFoundException, SessionTimeoutException, PermissionException;
/**
* Get config schema info for an action class
*/
public ConfigSchema getActionConfigSchema(int sessionID, String actionClass)
throws SessionNotFoundException, SessionTimeoutException,
org.hyperic.util.config.EncodingException;
/**
* Get config schema info for a trigger class
*/
public ConfigSchema getRegisteredTriggerConfigSchema(int sessionID, String triggerClass)
throws SessionNotFoundException, SessionTimeoutException,
org.hyperic.util.config.EncodingException;
public void deleteEscalationByName(int sessionID, String name) throws SessionTimeoutException,
SessionNotFoundException, PermissionException, org.hyperic.hq.common.ApplicationException;
public void deleteEscalationById(int sessionID, Integer id) throws SessionTimeoutException,
SessionNotFoundException, PermissionException, org.hyperic.hq.common.ApplicationException;
/**
* remove escalation by id
*/
public void deleteEscalationById(int sessionID, java.lang.Integer[] ids)
throws SessionTimeoutException, SessionNotFoundException, PermissionException,
org.hyperic.hq.common.ApplicationException;
/**
* retrieve escalation name by alert definition id.
*/
public Integer getEscalationIdByAlertDefId(int sessionID, Integer id,
EscalationAlertType alertType)
throws SessionTimeoutException, SessionNotFoundException, PermissionException;
/**
* set escalation name by alert definition id.
*/
public void setEscalationByAlertDefId(int sessionID, Integer id, Integer escId,
EscalationAlertType alertType)
throws SessionTimeoutException, SessionNotFoundException, PermissionException;
/**
* unset escalation by alert definition id.
*/
public void unsetEscalationByAlertDefId(int sessionID, Integer id, EscalationAlertType alertType)
throws SessionTimeoutException, SessionNotFoundException, PermissionException;
/**
* retrieve escalation JSONObject by alert definition id.
*/
public JSONObject jsonEscalationByAlertDefId(int sessionID, Integer id,
EscalationAlertType alertType)
throws org.hyperic.hq.auth.shared.SessionException, PermissionException, JSONException;
/**
* retrieve escalation object by escalation id.
*/
public Escalation findEscalationById(int sessionID, Integer id) throws SessionTimeoutException,
SessionNotFoundException, PermissionException;
public void addAction(int sessionID, Escalation e, ActionConfigInterface cfg, long waitTime)
throws SessionTimeoutException, SessionNotFoundException, PermissionException;
public void removeAction(int sessionID, Integer escId, Integer actId)
throws SessionTimeoutException, SessionNotFoundException, PermissionException;
/**
* Retrieve a list of {@link EscalationState}s, representing the active
* escalations in the system.
*/
public List<EscalationState> getActiveEscalations(int sessionId, int maxEscalations)
throws org.hyperic.hq.auth.shared.SessionException;
/**
* Gets the escalatable associated with the specified state
*/
public Escalatable getEscalatable(int sessionId, EscalationState state)
throws org.hyperic.hq.auth.shared.SessionException;
/**
* retrieve all escalation policy names as a Array of JSONObject. Escalation
* json finders begin with json* to be consistent with DAO finder convention
*/
public JSONArray listAllEscalationName(int sessionID) throws JSONException,
SessionTimeoutException, SessionNotFoundException, PermissionException;
/**
* Create a new escalation. If alertDefId is non-null, the escalation will
* also be associated with the given alert definition.
*/
public Escalation createEscalation(int sessionID, String name, String desc, boolean allowPause,
long maxWaitTime, boolean notifyAll, boolean repeat,
EscalationAlertType alertType, Integer alertDefId)
throws SessionTimeoutException, SessionNotFoundException, PermissionException,
DuplicateObjectException;
/**
* Update basic escalation properties
*/
public void updateEscalation(int sessionID, Escalation escalation, String name, String desc,
long maxWait, boolean pausable, boolean notifyAll, boolean repeat)
throws SessionTimeoutException, SessionNotFoundException, PermissionException,
DuplicateObjectException;
public boolean acknowledgeAlert(int sessionID, EscalationAlertType alertType, Integer alertID,
long pauseWaitTime, String moreInfo)
throws SessionTimeoutException, SessionNotFoundException, PermissionException,
ActionExecuteException;
/**
* Fix a single alert. Method is "NotSupported" since all the alert fixes
* may take longer than the transaction timeout. No need for a transaction
* in this context.
*/
public void fixAlert(int sessionID, EscalationAlertType alertType, Integer alertID,
String moreInfo) throws SessionTimeoutException, SessionNotFoundException,
PermissionException, ActionExecuteException;
/**
* Fix a batch of alerts. Method is "NotSupported" since all the alert fixes
* may take longer than the transaction timeout. No need for a transaction
* in this context.
*/
public void fixAlert(int sessionID, EscalationAlertType alertType, Integer alertID,
String moreInfo, boolean fixAllPrevious) throws SessionTimeoutException,
SessionNotFoundException, PermissionException, ActionExecuteException;
/**
* Get the last fix if available
*/
public String getLastFix(int sessionID, Integer defId) throws SessionNotFoundException,
SessionTimeoutException, PermissionException;
/**
* Get a maintenance event by group id
*/
public MaintenanceEvent getMaintenanceEvent(int sessionId, Integer groupId)
throws SessionNotFoundException, SessionTimeoutException, PermissionException,
SchedulerException;
/**
* Schedule a maintenance event
*/
public MaintenanceEvent scheduleMaintenanceEvent(int sessionId, MaintenanceEvent event)
throws SessionNotFoundException, SessionTimeoutException, PermissionException,
SchedulerException;
/**
* Schedule a maintenance event
*/
public void unscheduleMaintenanceEvent(int sessionId, MaintenanceEvent event)
throws SessionNotFoundException, SessionTimeoutException, PermissionException,
SchedulerException;
}
| cc14514/hq6 | hq-server/src/main/java/org/hyperic/hq/bizapp/shared/EventsBoss.java | Java | unlicense | 17,838 | [
30522,
1013,
1008,
1008,
1008,
3602,
1024,
2023,
9385,
2515,
1008,
2025,
1008,
3104,
5310,
3454,
2008,
2224,
16260,
1008,
2565,
2578,
2011,
3671,
2291,
4455,
2083,
1996,
4646,
1008,
2565,
19706,
3024,
2004,
2112,
1997,
1996,
23760,
2594,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
require 'test/unit'
require 'rubygems'
#require 'flexmock/test_unit'
#require 'mocha'
$: << File.join(File.dirname(__FILE__), '..', 'lib')
RAILS_ROOT=File.join(File.dirname(__FILE__),'..','..')
require 'yacht_transfer'
class Test::Unit::TestCase
private
def picture_fixture(string)
# ::File.open(File.dirname(__FILE__) + "/fixtures/#{string}", "rb") { |f| f.read }
File.open(File.dirname(__FILE__) + "/fixtures/#{string}", "rb")
end
def fixture(string)
File.open(File.dirname(__FILE__) + "/fixtures/#{string}").read
end
def write_fixture(filename, data)
File.open(File.dirname(__FILE__) + "/fixtures/#{filename}", "w") << data
end
def sample_accommodation
{:title=>"sample_title",:content=>"sample_content" }
end
def sample_picture
# {:label=>"rsample picture", :src=>picture_fixture("rails.png")}
{:label=>"sample picture", :src=>picture_fixture("main_silhouette.jpg")}
# {:label=>"jsample picture", :src=>picture_fixture("jordan_logo.jpg")}
end
def sample_listing
{:price=>"1234", :yacht_name=>"sample_name",:yacht_specification_manufacturer=>"sample_manufacturer",
:yacht_specification_model=>"sample_model", :yacht_specification_year=>"9999",
:yacht_specification_length=>"1", :yacht_specification_number_of_engines => "1", :yacht_specification_fuel=>"blas",
:yacht_location=>"sample_location", :yacht_specification_material=>"dfs", :yacht_specification_designer=>"crealock",
:photos=>[sample_picture, sample_picture,sample_picture, sample_picture,sample_picture, sample_picture, sample_picture, sample_picture]
# :details=>[sample_accommodation, sample_accommodation],
}
end
#######################################################
#######################################################
def sample_engine
{:manufacturer=>"smaple_manufacturer", :model=>"sample_model",
:fuel=>"gas",:horsepower=>1000, :year=>1111,
:hours=>100
}
end
def sample_hull
{:configuration=>"sample_configuration", :material=>"wood",
:color=>"sample_color", :designer=>"sample_designer"
}
end
def sample_location
{:city=>"sample_city", :zip=>33315, :country=>"United States of America",
:state=>"FL", :region=>"sample_region"
}
end
def sample_price
{:value=>1234, :units=>"euros"}
end
def sample_speed
{:value=>12, :units=>"knots"}
end
def sample_distance
{:value=>200, :units=>"meters"}
end
alias sample_measurement sample_distance
def sample_weight
{:value=>20, :units=>"tons"}
end
def sample_tank
{:material=>"sample_material", :capacity=> { :value=>999, :units=>"liters"} }
end
def sample_yacht
{:name=>"sample_name",:manufacturer=>"sample_manufacturer",
:model=>"sample_model",
:new=>"sample_new", :type=>"sail", :year=>9998,
:length=>sample_measurement, :lwl=>sample_measurement, :loa=>sample_measurement,
:beam=>sample_measurement, :min_draft=>sample_measurement, :max_draft=>sample_measurement,
:bridge_clearance=>sample_measurement, :displacement=>sample_weight,
:ballast=>sample_weight,:cruise_speed=>sample_speed,:max_speed=>sample_speed,
:hull=>sample_hull,
:fuel_tank=>sample_tank, :water_tank=>sample_tank, :holding_tank=>sample_tank,
:location=>sample_location,
:accommodations=>[sample_accommodation, sample_accommodation],
:engines=>[sample_engine, sample_engine],
:pictures=>[sample_picture ,sample_picture,sample_picture]
}
end
def old_sample_listing
{ :price=>sample_price, :broker=>"Dad", :type=>"open",
:status=>"in_progress", :co_op=>true,
:contact_info=>"sample_contact_info"}
end
end
| jordanr/yacht_transfer | test/test_helper.rb | Ruby | mit | 3,673 | [
30522,
5478,
1005,
3231,
1013,
3131,
1005,
5478,
1005,
10090,
3351,
5244,
1005,
1001,
5478,
1005,
23951,
5302,
3600,
1013,
3231,
1035,
3131,
1005,
1001,
5478,
1005,
9587,
7507,
1005,
1002,
1024,
1026,
1026,
5371,
1012,
3693,
1006,
5371,
1... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
'use strict';
module.exports = function(config) {
config.set({
files: [
'tests/main.js',
{pattern: 'app/js/**/*.js', included: false},
{pattern: 'app/bower_components/**/*.js', included: false},
{pattern: 'tests/specs/**/*.js', included: false},
{pattern: 'tests/fixtures/**/*.js', included: false}
],
basePath: '../',
frameworks: ['jasmine', 'requirejs'],
reporters: ['progress'],
runnerPort: 9000,
singleRun: true,
browsers: ['PhantomJS', 'Chrome'],
logLevel: 'ERROR'
});
};
| spolnik/javascript-workspace | grunt/TodoApp/tests/karma.conf.js | JavaScript | apache-2.0 | 619 | [
30522,
1005,
2224,
9384,
1005,
1025,
11336,
1012,
14338,
1027,
3853,
1006,
9530,
8873,
2290,
1007,
1063,
9530,
8873,
2290,
1012,
2275,
1006,
1063,
6764,
1024,
1031,
1005,
5852,
1013,
2364,
1012,
1046,
2015,
1005,
1010,
1063,
5418,
1024,
1... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
<?php
/*
* This file is part of Rocketeer
*
* (c) Maxime Fabre <ehtnam6@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
*/
namespace Rocketeer\Services\History;
use Illuminate\Support\Collection;
/**
* Keeps a memory of everything that was outputed/ran
* and on which connections/stages.
*/
class History extends Collection
{
/**
* Get the history, flattened.
*
* @return string[]|string[][]
*/
public function getFlattenedHistory()
{
return $this->getFlattened('history');
}
/**
* Get the output, flattened.
*
* @return string[]|string[][]
*/
public function getFlattenedOutput()
{
return $this->getFlattened('output');
}
/**
* Reset the history/output.
*/
public function reset()
{
$this->items = [];
}
//////////////////////////////////////////////////////////////////////
////////////////////////////// HELPERS ///////////////////////////////
//////////////////////////////////////////////////////////////////////
/**
* Get a flattened list of a certain type.
*
* @param string $type
*
* @return string[]|string[][]
*/
protected function getFlattened($type)
{
$history = [];
foreach ($this->items as $class => $entries) {
$history = array_merge($history, $entries[$type]);
}
ksort($history);
return array_values($history);
}
}
| rocketeers/rocketeer | src/Rocketeer/Services/History/History.php | PHP | mit | 1,576 | [
30522,
1026,
1029,
25718,
1013,
1008,
1008,
2023,
5371,
2003,
2112,
1997,
7596,
11510,
1008,
1008,
1006,
1039,
1007,
20446,
2063,
6904,
13578,
1026,
15501,
2102,
13129,
2575,
1030,
20917,
4014,
1012,
4012,
1028,
1008,
1008,
2005,
1996,
2440... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
package com.github.uralmax;
import java.lang.annotation.Annotation;
import java.lang.reflect.Method;
import java.lang.reflect.Type;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import org.apache.commons.lang3.ArrayUtils;
import org.apache.maven.plugin.logging.Log;
import org.springframework.core.annotation.AnnotationUtils;
import org.springframework.http.MediaType;
import com.github.kongchen.swagger.docgen.GenerateException;
import com.github.kongchen.swagger.docgen.reader.AbstractReader;
import com.github.kongchen.swagger.docgen.reader.ClassSwaggerReader;
import com.github.kongchen.swagger.docgen.spring.SpringResource;
import com.googlecode.jsonrpc4j.JsonRpcMethod;
import com.googlecode.jsonrpc4j.JsonRpcParam;
import com.googlecode.jsonrpc4j.JsonRpcService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import io.swagger.annotations.ApiResponses;
import io.swagger.annotations.Authorization;
import io.swagger.annotations.AuthorizationScope;
import io.swagger.converter.ModelConverters;
import io.swagger.models.Model;
import io.swagger.models.ModelImpl;
import io.swagger.models.Operation;
import io.swagger.models.Path;
import io.swagger.models.RefModel;
import io.swagger.models.Response;
import io.swagger.models.SecurityRequirement;
import io.swagger.models.Swagger;
import io.swagger.models.Tag;
import io.swagger.models.parameters.BodyParameter;
import io.swagger.models.properties.ArrayProperty;
import io.swagger.models.properties.MapProperty;
import io.swagger.models.properties.Property;
import io.swagger.models.properties.RefProperty;
import io.swagger.models.properties.StringProperty;
/**
* Reader for json-rpc
*
* @author Rozhkov Maksim
*/
public class JsonRpcSwaggerApiReader extends AbstractReader implements ClassSwaggerReader {
public static final String SEPARATOR = "_";
private static final String JsonRPC_WRAPPER_NAME_FORMAT = "JsonRPC %s";
private static final String JsonRPC_PARAMS_NAME_FORMAT = "JsonRPC %s Params(%s)";
private String resourcePath;
private String modifiedResourcePath;
/**
* Content type is constant
*/
private String[] CONTENT_TYPE = ArrayUtils.toArray(MediaType.APPLICATION_JSON_VALUE);
public JsonRpcSwaggerApiReader(Swagger swagger, Log log) {
super(swagger, log);
}
public Swagger read(Set<Class<?>> classes) throws GenerateException {
Map<String, SpringResource> resourceMap = new HashMap<String, SpringResource>();
for (Class<?> aClass : classes) {
resourceMap = analyzeController(aClass, resourceMap, "");
}
if (swagger == null) {
swagger = new Swagger();
}
for (String str : resourceMap.keySet()) {
SpringResource resource = resourceMap.get(str);
read(resource);
}
return swagger;
}
/**
* Read resource and fill swagger info
*
* @param resource
* -resource
* @return swagger main object
*/
public Swagger read(SpringResource resource) {
List<Method> methods = resource.getMethods();
Map<String, Tag> tags = new HashMap<String, Tag>();
List<SecurityRequirement> resourceSecurities = new ArrayList<SecurityRequirement>();
Class<?> controller = resource.getControllerClass();
if (controller.isAnnotationPresent(Api.class)) {
Api api = AnnotationUtils.findAnnotation(controller, Api.class);
if (!canReadApi(false, api)) {
return swagger;
}
tags = updateTagsForApi(null, api);
resourceSecurities = getSecurityRequirements(api);
}
resourcePath = resource.getControllerMapping();
modifiedResourcePath = resourcePath.replace("/", SEPARATOR);
Map<String, List<Method>> apiMethodMap = collectApisByRequestMapping(methods);
for (String path : apiMethodMap.keySet()) {
for (Method method : apiMethodMap.get(path)) {
ApiOperation apiOperation =
AnnotationUtils.findAnnotation(method, ApiOperation.class);
if (apiOperation == null || apiOperation.hidden()) {
continue;
}
Map<String, String> regexMap = new HashMap<String, String>();
Operation operation = parseMethod(apiOperation, method);
updateOperationProtocols(apiOperation, operation);
updateTagsForOperation(operation, apiOperation);
updateOperation(CONTENT_TYPE, CONTENT_TYPE, tags, resourceSecurities, operation);
swagger.path(parseOperationPath(path, regexMap), new Path().post(operation));
}
}
return swagger;
}
/**
* Get real body param for json rpc
*
* @param allParams
* all find params
* @param apiOperation
* - swagger annotation fo operation
* @param methodName
* metho
* @return real body for request
*/
private BodyParameter getBobyParam(List<Property> allParams, ApiOperation apiOperation,
String methodName) {
String jsonRpcPath = modifiedResourcePath + SEPARATOR + methodName;
BodyParameter requestBody = null;
if (!allParams.isEmpty()) {
ModelImpl jsonRpcModel = new ModelImpl();
jsonRpcModel.setType("object");
Map<String, Property> properties = new HashMap<String, Property>();
if (allParams.size() > 0) {
jsonRpcModel.setDescription(apiOperation.value());
ModelImpl paramsWrapperModel = new ModelImpl();
paramsWrapperModel.setType(ModelImpl.OBJECT);
String paramNames = "";
for (Property paramProperty : allParams) {
paramNames = paramNames + " " + paramProperty.getName();
paramsWrapperModel.addProperty(paramProperty.getName(), paramProperty);
}
String wrapperOfParamsKey =
String.format(JsonRPC_PARAMS_NAME_FORMAT, jsonRpcPath, paramNames);
swagger.addDefinition(wrapperOfParamsKey, paramsWrapperModel);
properties.put("params", new RefProperty(wrapperOfParamsKey));
}
properties.put("jsonrpc",
new StringProperty()._enum("2.0").example("2.0").required(true));
properties.put("id", new StringProperty().example("101").required(true));
properties.put("method",
new StringProperty()._enum(methodName).example(methodName).required(true));
jsonRpcModel.setProperties(properties);
String key = String.format(JsonRPC_WRAPPER_NAME_FORMAT, jsonRpcPath);
swagger.addDefinition(key, jsonRpcModel);
requestBody = new BodyParameter();
requestBody.setRequired(true);
requestBody.setDescription(jsonRpcModel.getDescription());
requestBody.setName("body");
requestBody.setSchema(new RefModel(key));
}
return requestBody;
}
/**
* Response wrapper for list type
*
* @param type
* -type
* @param property
* - swagger property
* @return wrapped response
*/
private Property withResponseContainer(String type, Property property) {
if ("list".equalsIgnoreCase(type)) {
return new ArrayProperty(property);
}
if ("set".equalsIgnoreCase(type)) {
return new ArrayProperty(property).uniqueItems();
}
if ("map".equalsIgnoreCase(type)) {
return new MapProperty(property);
}
return property;
}
/**
* Get swagger operation from method
*
* @param apiOperation
* - swagger operation
* @param method
* method
* @return swagger Operation object
*/
private Operation parseMethod(ApiOperation apiOperation, Method method) {
Operation operation = new Operation();
Type responseClass = null;
String responseContainer = null;
String operationId =
method.getDeclaringClass().getSimpleName() + SEPARATOR + method.getName();
if (apiOperation.hidden()) {
return null;
}
if (!apiOperation.nickname().isEmpty()) {
operationId = apiOperation.nickname();
}
Map<String, Property> defaultResponseHeaders =
parseResponseHeaders(apiOperation.responseHeaders());
operation.summary(apiOperation.value()).description(apiOperation.notes());
Set<Map<String, Object>> customExtensions =
parseCustomExtensions(apiOperation.extensions());
for (Map<String, Object> extension : customExtensions) {
if (extension == null) {
continue;
}
for (Map.Entry<String, Object> map : extension.entrySet()) {
operation.setVendorExtension(
map.getKey().startsWith("x-") ? map.getKey() : "x-" + map.getKey(),
map.getValue());
}
}
if (!apiOperation.response().equals(Void.class)) {
responseClass = apiOperation.response();
}
if (!apiOperation.responseContainer().isEmpty()) {
responseContainer = apiOperation.responseContainer();
}
List<SecurityRequirement> securities = new ArrayList<SecurityRequirement>();
for (Authorization auth : apiOperation.authorizations()) {
if (!auth.value().isEmpty()) {
SecurityRequirement security = new SecurityRequirement(auth.value());
for (AuthorizationScope scope : auth.scopes()) {
if (!scope.scope().isEmpty()) {
security.addScope(scope.scope());
}
}
securities.add(security);
}
}
for (SecurityRequirement sec : securities) {
operation.security(sec);
}
if (responseClass == null) {
responseClass = method.getGenericReturnType();
}
if (responseClass != null && !responseClass.equals(Void.class)) {
if (isPrimitive(responseClass)) {
Property property = ModelConverters.getInstance().readAsProperty(responseClass);
if (property != null) {
Property responseProperty = withResponseContainer(responseContainer, property);
operation.response(apiOperation.code(), new Response().description("")
.schema(responseProperty).headers(defaultResponseHeaders));
}
} else if (!responseClass.equals(Void.class) && !responseClass.equals(void.class)) {
Map<String, Model> models = ModelConverters.getInstance().read(responseClass);
if (models.isEmpty()) {
Property pp = ModelConverters.getInstance().readAsProperty(responseClass);
operation.response(apiOperation.code(), new Response().description("")
.schema(pp).headers(defaultResponseHeaders));
}
for (String key : models.keySet()) {
Property responseProperty = withResponseContainer(responseContainer,
new RefProperty().asDefault(key));
operation.response(apiOperation.code(), new Response().description("")
.schema(responseProperty).headers(defaultResponseHeaders));
swagger.model(key, models.get(key));
}
}
Map<String, Model> models = ModelConverters.getInstance().readAll(responseClass);
for (Map.Entry<String, Model> entry : models.entrySet()) {
swagger.model(entry.getKey(), entry.getValue());
}
}
operation.operationId(operationId);
ApiResponses responseAnnotation =
AnnotationUtils.findAnnotation(method, ApiResponses.class);
if (responseAnnotation != null) {
updateApiResponse(operation, responseAnnotation);
}
Deprecated annotation = AnnotationUtils.findAnnotation(method, Deprecated.class);
if (annotation != null) {
operation.deprecated(true);
}
Class[] parameterTypes = method.getParameterTypes();
Type[] genericParameterTypes = method.getGenericParameterTypes();
Annotation[][] paramAnnotations = method.getParameterAnnotations();
List<Property> allParams = new ArrayList<Property>();
for (int i = 0; i < parameterTypes.length; i++) {
Type type = genericParameterTypes[i];
List<Annotation> annotations = Arrays.asList(paramAnnotations[i]);
if (!getTypesToSkip().contains(type)) {
final Property property = ModelConverters.getInstance().readAsProperty(type);
if (property != null) {
for (Map.Entry<String, Model> entry : ModelConverters.getInstance()
.readAll(type).entrySet()) {
swagger.addDefinition(entry.getKey(), entry.getValue());
}
}
if (property != null) {
String name = "unknow";
for (Annotation paramAnnotation : annotations) {
if (paramAnnotation instanceof JsonRpcParam) {
name = ((JsonRpcParam) paramAnnotation).value();
break;
} else if (paramAnnotation instanceof ApiParam) {
ApiParam apiParamAnnotation = ((ApiParam) paramAnnotation);
name = apiParamAnnotation.name();
if (name != null && name.length() > 0) {
break;
}
property.setDescription(apiParamAnnotation.value());
property.setExample(apiParamAnnotation.example());
}
}
property.setName(name);
allParams.add(property);
}
}
}
JsonRpcMethod jsonRpcMethod = AnnotationUtils.findAnnotation(method, JsonRpcMethod.class);
BodyParameter bobyParam = getBobyParam(allParams, apiOperation, jsonRpcMethod.value());
if (bobyParam != null) {
operation.parameter(bobyParam);
}
if (operation.getResponses() == null) {
operation.defaultResponse(new Response().description("Success"));
}
return operation;
}
/**
* Get map of url and methods
*
* @param methods
* analized methods
* @return map url-> Methods
*/
private Map<String, List<Method>> collectApisByRequestMapping(List<Method> methods) {
Map<String, List<Method>> apiMethodMap = new HashMap<String, List<Method>>();
for (Method method : methods) {
if (method.isAnnotationPresent(JsonRpcMethod.class)) {
JsonRpcMethod jsonRpcMethod =
AnnotationUtils.findAnnotation(method, JsonRpcMethod.class);
// It is necessary to modify as few methods able to live on the same url in swagger
String path = resourcePath + " " + jsonRpcMethod.value();
if (apiMethodMap.containsKey(path)) {
apiMethodMap.get(path).add(method);
} else {
List<Method> ms = new ArrayList<Method>();
ms.add(method);
apiMethodMap.put(path, ms);
}
}
}
return apiMethodMap;
}
/**
* Analyze controller and search resource
*
* @param controllerClazz
* class
* @param resourceMap
* map of result
* @param description
* description
* @return return result map
*/
private Map<String, SpringResource> analyzeController(Class<?> controllerClazz,
Map<String, SpringResource> resourceMap, String description) {
JsonRpcService serviceAnnotation =
AnnotationUtils.findAnnotation(controllerClazz, JsonRpcService.class);
if (serviceAnnotation != null) {
String requestUrl = serviceAnnotation.value();
for (Method method : controllerClazz.getMethods()) {
JsonRpcMethod jsonRpcMethod =
AnnotationUtils.findAnnotation(method, JsonRpcMethod.class);
if (jsonRpcMethod != null) {
// It is necessary to modify as few methods able to live on the same url in
// swagger
String resourceKey = controllerClazz.getCanonicalName() + requestUrl + ' '
+ jsonRpcMethod.value();
if (!resourceMap.containsKey(resourceKey)) {
SpringResource springResource = new SpringResource(controllerClazz,
requestUrl, resourceKey, description);
springResource.setControllerMapping(requestUrl);
resourceMap.put(resourceKey, springResource);
}
resourceMap.get(resourceKey).addMethod(method);
}
}
}
return resourceMap;
}
}
| uralmax/jsonrpc4j-swagger-maven-plugin-helper | src/main/java/com/github/uralmax/JsonRpcSwaggerApiReader.java | Java | apache-2.0 | 17,914 | [
30522,
7427,
4012,
1012,
21025,
2705,
12083,
1012,
24471,
2389,
17848,
1025,
12324,
9262,
1012,
11374,
1012,
5754,
17287,
3508,
1012,
5754,
17287,
3508,
1025,
12324,
9262,
1012,
11374,
1012,
8339,
1012,
4118,
1025,
12324,
9262,
1012,
11374,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
# UNO #
is ALL IN ONE BUSINESS PLATFORM
PHP-BASE software that aim to dynamicly change database schematic on demand to be able to keep up with world demand today.
### Features ###
* Dynamic Mysql database schematic
* SOFTWARE FOR BUSINESS ALL IN ONE.
* System Login
* Level of permission per jobs and tasks
### What is this repository for? ###
Make Business more efficient
### How do I get set up? ###
* Setup PHP7.1+
* MYSQL server 5.7
* "/sql/github_uno.sql" import to mysql
* URL to "localhost" or "127.0.0.1"
* Register User
* NOTE: Login to Mysql
* need to change value in TABLE authentication COLUMN employee_id to 1 (FROM 0)*
* Login with your username and password
* URL to "localhost/admin.php"
* Edit and insert all table and rows as you want.
### Contribution guidelines ###
* optimized the efficientcy of the platform
* make it better
### Who do I talk to? ###
* me
| seasiri/uno | README.md | Markdown | mit | 895 | [
30522,
1001,
27776,
1001,
2003,
2035,
1999,
2028,
2449,
4132,
25718,
1011,
2918,
4007,
2008,
6614,
2000,
8790,
2135,
2689,
7809,
8040,
28433,
4588,
2006,
5157,
2000,
2022,
2583,
2000,
2562,
2039,
2007,
2088,
5157,
2651,
1012,
1001,
1001,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>mathcomp-character: 8 m 4 s 🏆</title>
<link rel="shortcut icon" type="image/png" href="../../../../../favicon.png" />
<link href="../../../../../bootstrap.min.css" rel="stylesheet">
<link href="../../../../../bootstrap-custom.css" rel="stylesheet">
<link href="//maxcdn.bootstrapcdn.com/font-awesome/4.2.0/css/font-awesome.min.css" rel="stylesheet">
<script src="../../../../../moment.min.js"></script>
<!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
<!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
<![endif]-->
</head>
<body>
<div class="container">
<div class="navbar navbar-default" role="navigation">
<div class="container-fluid">
<div class="navbar-header">
<a class="navbar-brand" href="../../../../.."><i class="fa fa-lg fa-flag-checkered"></i> Coq bench</a>
</div>
<div id="navbar" class="collapse navbar-collapse">
<ul class="nav navbar-nav">
<li><a href="../..">clean / released</a></li>
<li class="active"><a href="">8.11.0 / mathcomp-character - 1.13.0</a></li>
</ul>
</div>
</div>
</div>
<div class="article">
<div class="row">
<div class="col-md-12">
<a href="../..">« Up</a>
<h1>
mathcomp-character
<small>
1.13.0
<span class="label label-success">8 m 4 s 🏆</span>
</small>
</h1>
<p>📅 <em><script>document.write(moment("2021-12-12 17:32:44 +0000", "YYYY-MM-DD HH:mm:ss Z").fromNow());</script> (2021-12-12 17:32:44 UTC)</em><p>
<h2>Context</h2>
<pre># Packages matching: installed
# Name # Installed # Synopsis
base-bigarray base
base-threads base
base-unix base
conf-findutils 1 Virtual package relying on findutils
coq 8.11.0 Formal proof management system
num 1.4 The legacy Num library for arbitrary-precision integer and rational arithmetic
ocaml 4.09.1 The OCaml compiler (virtual package)
ocaml-base-compiler 4.09.1 Official release 4.09.1
ocaml-config 1 OCaml Switch Configuration
ocamlfind 1.9.1 A library manager for OCaml
# opam file:
opam-version: "2.0"
maintainer: "Mathematical Components <mathcomp-dev@sympa.inria.fr>"
homepage: "https://math-comp.github.io/"
bug-reports: "https://github.com/math-comp/math-comp/issues"
dev-repo: "git+https://github.com/math-comp/math-comp.git"
license: "CECILL-B"
build: [ make "-C" "mathcomp/character" "-j" "%{jobs}%" "COQEXTRAFLAGS+=-native-compiler yes" {coq-native:installed & coq:version < "8.13~" } ]
install: [ make "-C" "mathcomp/character" "install" ]
depends: [ "coq-mathcomp-field" { = version } ]
tags: [ "keyword:algebra" "keyword:character" "keyword:small scale reflection" "keyword:mathematical components" "keyword:odd order theorem" "logpath:mathcomp.character" ]
authors: [ "Jeremy Avigad <>" "Andrea Asperti <>" "Stephane Le Roux <>" "Yves Bertot <>" "Laurence Rideau <>" "Enrico Tassi <>" "Ioana Pasca <>" "Georges Gonthier <>" "Sidi Ould Biha <>" "Cyril Cohen <>" "Francois Garillot <>" "Alexey Solovyev <>" "Russell O'Connor <>" "Laurent Théry <>" "Assia Mahboubi <>" ]
synopsis: "Mathematical Components Library on character theory"
description:"""
This library contains definitions and theorems about group
representations, characters and class functions.
"""
url {
src: "https://github.com/math-comp/math-comp/archive/mathcomp-1.13.0.tar.gz"
checksum: "sha256=4334e915736f96032e1d4d502e70537047220af1a1c7a6740f770e45601bdab0"
}
</pre>
<h2>Lint</h2>
<dl class="dl-horizontal">
<dt>Command</dt>
<dd><code>true</code></dd>
<dt>Return code</dt>
<dd>0</dd>
</dl>
<h2>Dry install 🏜️</h2>
<p>Dry install with the current Coq version:</p>
<dl class="dl-horizontal">
<dt>Command</dt>
<dd><code>opam install -y --show-action coq-mathcomp-character.1.13.0 coq.8.11.0</code></dd>
<dt>Return code</dt>
<dd>0</dd>
</dl>
<p>Dry install without Coq/switch base, to test if the problem was incompatibility with the current Coq/OCaml version:</p>
<dl class="dl-horizontal">
<dt>Command</dt>
<dd><code>true</code></dd>
<dt>Return code</dt>
<dd>0</dd>
</dl>
<h2>Install dependencies</h2>
<dl class="dl-horizontal">
<dt>Command</dt>
<dd><code>opam list; echo; ulimit -Sv 4000000; timeout 4h opam install -y --deps-only coq-mathcomp-character.1.13.0 coq.8.11.0</code></dd>
<dt>Return code</dt>
<dd>0</dd>
<dt>Duration</dt>
<dd>32 m 38 s</dd>
</dl>
<h2>Install 🚀</h2>
<dl class="dl-horizontal">
<dt>Command</dt>
<dd><code>opam list; echo; ulimit -Sv 16000000; timeout 4h opam install -y -v coq-mathcomp-character.1.13.0 coq.8.11.0</code></dd>
<dt>Return code</dt>
<dd>0</dd>
<dt>Duration</dt>
<dd>8 m 4 s</dd>
</dl>
<h2>Installation size</h2>
<p>Total: 14 M</p>
<ul>
<li>4 M <code>../ocaml-base-compiler.4.09.1/lib/coq/user-contrib/mathcomp/character/mxrepresentation.vo</code></li>
<li>2 M <code>../ocaml-base-compiler.4.09.1/lib/coq/user-contrib/mathcomp/character/mxrepresentation.glob</code></li>
<li>1 M <code>../ocaml-base-compiler.4.09.1/lib/coq/user-contrib/mathcomp/character/character.vo</code></li>
<li>1 M <code>../ocaml-base-compiler.4.09.1/lib/coq/user-contrib/mathcomp/character/classfun.vo</code></li>
<li>1 M <code>../ocaml-base-compiler.4.09.1/lib/coq/user-contrib/mathcomp/character/character.glob</code></li>
<li>841 K <code>../ocaml-base-compiler.4.09.1/lib/coq/user-contrib/mathcomp/character/classfun.glob</code></li>
<li>712 K <code>../ocaml-base-compiler.4.09.1/lib/coq/user-contrib/mathcomp/character/inertia.vo</code></li>
<li>684 K <code>../ocaml-base-compiler.4.09.1/lib/coq/user-contrib/mathcomp/character/inertia.glob</code></li>
<li>498 K <code>../ocaml-base-compiler.4.09.1/lib/coq/user-contrib/mathcomp/character/integral_char.vo</code></li>
<li>436 K <code>../ocaml-base-compiler.4.09.1/lib/coq/user-contrib/mathcomp/character/mxabelem.vo</code></li>
<li>414 K <code>../ocaml-base-compiler.4.09.1/lib/coq/user-contrib/mathcomp/character/vcharacter.vo</code></li>
<li>378 K <code>../ocaml-base-compiler.4.09.1/lib/coq/user-contrib/mathcomp/character/vcharacter.glob</code></li>
<li>342 K <code>../ocaml-base-compiler.4.09.1/lib/coq/user-contrib/mathcomp/character/mxabelem.glob</code></li>
<li>318 K <code>../ocaml-base-compiler.4.09.1/lib/coq/user-contrib/mathcomp/character/integral_char.glob</code></li>
<li>239 K <code>../ocaml-base-compiler.4.09.1/lib/coq/user-contrib/mathcomp/character/mxrepresentation.v</code></li>
<li>113 K <code>../ocaml-base-compiler.4.09.1/lib/coq/user-contrib/mathcomp/character/character.v</code></li>
<li>96 K <code>../ocaml-base-compiler.4.09.1/lib/coq/user-contrib/mathcomp/character/classfun.v</code></li>
<li>69 K <code>../ocaml-base-compiler.4.09.1/lib/coq/user-contrib/mathcomp/character/inertia.v</code></li>
<li>54 K <code>../ocaml-base-compiler.4.09.1/lib/coq/user-contrib/mathcomp/character/all_character.vo</code></li>
<li>43 K <code>../ocaml-base-compiler.4.09.1/lib/coq/user-contrib/mathcomp/character/mxabelem.v</code></li>
<li>38 K <code>../ocaml-base-compiler.4.09.1/lib/coq/user-contrib/mathcomp/character/vcharacter.v</code></li>
<li>35 K <code>../ocaml-base-compiler.4.09.1/lib/coq/user-contrib/mathcomp/character/integral_char.v</code></li>
<li>1 K <code>../ocaml-base-compiler.4.09.1/lib/coq/user-contrib/mathcomp/character/all_character.glob</code></li>
<li>1 K <code>../ocaml-base-compiler.4.09.1/lib/coq/user-contrib/mathcomp/character/all_character.v</code></li>
</ul>
<h2>Uninstall 🧹</h2>
<dl class="dl-horizontal">
<dt>Command</dt>
<dd><code>opam remove -y coq-mathcomp-character.1.13.0</code></dd>
<dt>Return code</dt>
<dd>0</dd>
<dt>Missing removes</dt>
<dd>
none
</dd>
<dt>Wrong removes</dt>
<dd>
none
</dd>
</dl>
</div>
</div>
</div>
<hr/>
<div class="footer">
<p class="text-center">
Sources are on <a href="https://github.com/coq-bench">GitHub</a> © Guillaume Claret 🐣
</p>
</div>
</div>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script src="../../../../../bootstrap.min.js"></script>
</body>
</html>
| coq-bench/coq-bench.github.io | clean/Linux-x86_64-4.09.1-2.0.6/released/8.11.0/mathcomp-character/1.13.0.html | HTML | mit | 10,384 | [
30522,
1026,
999,
9986,
13874,
16129,
1028,
1026,
16129,
11374,
1027,
1000,
4372,
1000,
1028,
1026,
2132,
1028,
1026,
18804,
25869,
13462,
1027,
1000,
21183,
2546,
1011,
1022,
1000,
1028,
30524,
1011,
4094,
1027,
1015,
1000,
1028,
1026,
251... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
////////////////////////////////////////////////////////////////////////////////////
////// Events
////////////////////////////////////////////////////////////////////////////////////
'use strict';
// DI
var db,
responseHandler;
/**
*
* @param req the HTTP requests, contains header and body parameters
* @param res the callback to which send HTTP response
* @param next facilitate restify function chaining
*/
exports.findAll = function (req, res, next) {
req.check('appid', '"appid": must be a valid identifier').notNull();
var errors = req.validationErrors(),
appid;
if (errors) {
responseHandler(res).error(400, errors);
return;
}
appid = req.params.appid;
db.findAllEvents({'application_id': appid}, responseHandler(res, next));
};
/**
*
* @param req the HTTP requests, contains header and body parameters
* @param res the callback to which send HTTP response
* @param next facilitate restify function chaining
*/
exports.findById = function (req, res, next) {
req.check('appid', '"appid": must be a valid identifier').notNull();
req.check('eventid', '"eventid": must be a valid identifier').notNull();
var errors = req.validationErrors(),
appid,
eventid;
if (errors) {
responseHandler(res).error(400, errors);
return;
}
appid = req.params.appid;
eventid = req.params.eventid;
db.findEventById({'application_id': appid, 'event_id': eventid}, responseHandler(res, next));
};
/**
*
* @param req the HTTP requests, contains header and body parameters
* @param res the callback to which send HTTP response
* @param next facilitate restify function chaining
*/
exports.create = function (req, res, next) {
req.check('appid', '"appid": must be a valid identifier').notNull();
req.check('type', '"type": must be a valid identifier').notNull();
req.check('user', '"user": must be a valid identifier').notNull();
req.check('issued', '"date": must be a valid date').isDate();
var errors = req.validationErrors(),
appid,
type,
user,
issued;
if (errors) {
responseHandler(res).error(400, errors);
return;
}
appid = req.params.appid;
type = req.params.type;
user = req.params.user;
issued = req.params.issued; // or "2013-02-26"; // TODO today or specified
db.createEvent(
{'application_id': appid, 'type': type, 'user': user, 'issued': issued},
responseHandler(res, next)
);
};
| Gitification/gitification-server | controllers/events.js | JavaScript | mit | 2,351 | [
30522,
1013,
1013,
1013,
1013,
1013,
1013,
1013,
1013,
1013,
1013,
1013,
1013,
1013,
1013,
1013,
1013,
1013,
1013,
1013,
1013,
1013,
1013,
1013,
1013,
1013,
1013,
1013,
1013,
1013,
1013,
1013,
1013,
1013,
1013,
1013,
1013,
1013,
1013,
101... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
package com.arekusu.datamover.model.jaxb;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType;
/**
* <p>Java class for anonymous complex type.
*
* <p>The following schema fragment specifies the expected content contained within this class.
*
* <pre>
* <complexType>
* <complexContent>
* <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
* <sequence>
* <element ref="{http://www.arekusu.com}DefinitionType"/>
* </sequence>
* <attribute name="version" type="{http://www.w3.org/2001/XMLSchema}string" />
* </restriction>
* </complexContent>
* </complexType>
* </pre>
*
*
*/
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "", propOrder = {
"definitionType"
})
@XmlRootElement(name = "ModelType", namespace = "http://www.arekusu.com")
public class ModelType {
@XmlElement(name = "DefinitionType", namespace = "http://www.arekusu.com", required = true)
protected DefinitionType definitionType;
@XmlAttribute(name = "version")
protected String version;
/**
* Gets the value of the definitionType property.
*
* @return
* possible object is
* {@link DefinitionType }
*
*/
public DefinitionType getDefinitionType() {
return definitionType;
}
/**
* Sets the value of the definitionType property.
*
* @param value
* allowed object is
* {@link DefinitionType }
*
*/
public void setDefinitionType(DefinitionType value) {
this.definitionType = value;
}
/**
* Gets the value of the version property.
*
* @return
* possible object is
* {@link String }
*
*/
public String getVersion() {
return version;
}
/**
* Sets the value of the version property.
*
* @param value
* allowed object is
* {@link String }
*
*/
public void setVersion(String value) {
this.version = value;
}
}
| Arrekusu/datamover | components/datamover-core/src/main/java/com/arekusu/datamover/model/jaxb/ModelType.java | Java | mit | 2,303 | [
30522,
7427,
4012,
1012,
2024,
22332,
2226,
1012,
2951,
5302,
6299,
1012,
2944,
1012,
13118,
2497,
1025,
12324,
9262,
2595,
1012,
20950,
1012,
14187,
1012,
5754,
17287,
3508,
1012,
20950,
6305,
9623,
21756,
5051,
1025,
12324,
9262,
2595,
10... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width" />
<link rel="shortcut icon" type="image/x-icon" href="../../../../../../../favicon.ico" />
<title>DataBuffer | Android Developers</title>
<!-- STYLESHEETS -->
<link rel="stylesheet"
href="http://fonts.googleapis.com/css?family=Roboto+Condensed">
<link rel="stylesheet" href="http://fonts.googleapis.com/css?family=Roboto:light,regular,medium,thin,italic,mediumitalic,bold"
title="roboto">
<link href="../../../../../../../assets/css/default.css?v=5" rel="stylesheet" type="text/css">
<!-- FULLSCREEN STYLESHEET -->
<link href="../../../../../../../assets/css/fullscreen.css" rel="stylesheet" class="fullscreen"
type="text/css">
<!-- JAVASCRIPT -->
<script src="http://www.google.com/jsapi" type="text/javascript"></script>
<script src="../../../../../../../assets/js/android_3p-bundle.js" type="text/javascript"></script>
<script type="text/javascript">
var toRoot = "../../../../../../../";
var metaTags = [];
var devsite = false;
</script>
<script src="../../../../../../../assets/js/docs.js?v=3" type="text/javascript"></script>
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-5831155-1', 'android.com');
ga('create', 'UA-49880327-2', 'android.com', {'name': 'universal'}); // New tracker);
ga('send', 'pageview');
ga('universal.send', 'pageview'); // Send page view for new tracker.
</script>
</head>
<body class="gc-documentation
develop reference" itemscope itemtype="http://schema.org/Article">
<div id="doc-api-level" class="" style="display:none"></div>
<a name="top"></a>
<a name="top"></a>
<!-- dialog to prompt lang pref change when loaded from hardcoded URL
<div id="langMessage" style="display:none">
<div>
<div class="lang en">
<p>You requested a page in English, would you like to proceed with this language setting?</p>
</div>
<div class="lang es">
<p>You requested a page in Spanish (Español), would you like to proceed with this language setting?</p>
</div>
<div class="lang ja">
<p>You requested a page in Japanese (日本語), would you like to proceed with this language setting?</p>
</div>
<div class="lang ko">
<p>You requested a page in Korean (한국어), would you like to proceed with this language setting?</p>
</div>
<div class="lang ru">
<p>You requested a page in Russian (Русский), would you like to proceed with this language setting?</p>
</div>
<div class="lang zh-cn">
<p>You requested a page in Simplified Chinese (简体中文), would you like to proceed with this language setting?</p>
</div>
<div class="lang zh-tw">
<p>You requested a page in Traditional Chinese (繁體中文), would you like to proceed with this language setting?</p>
</div>
<a href="#" class="button yes" onclick="return false;">
<span class="lang en">Yes</span>
<span class="lang es">Sí</span>
<span class="lang ja">Yes</span>
<span class="lang ko">Yes</span>
<span class="lang ru">Yes</span>
<span class="lang zh-cn">是的</span>
<span class="lang zh-tw">没有</span>
</a>
<a href="#" class="button" onclick="$('#langMessage').hide();return false;">
<span class="lang en">No</span>
<span class="lang es">No</span>
<span class="lang ja">No</span>
<span class="lang ko">No</span>
<span class="lang ru">No</span>
<span class="lang zh-cn">没有</span>
<span class="lang zh-tw">没有</span>
</a>
</div>
</div> -->
<!-- Header -->
<div id="header-wrapper">
<div id="header">
<div class="wrap" id="header-wrap">
<div class="col-3 logo">
<a href="../../../../../../../index.html">
<img src="../../../../../../../assets/images/dac_logo.png"
srcset="../../../../../../../assets/images/dac_logo@2x.png 2x"
width="123" height="25" alt="Android Developers" />
</a>
<div class="btn-quicknav" id="btn-quicknav">
<a href="#" class="arrow-inactive">Quicknav</a>
<a href="#" class="arrow-active">Quicknav</a>
</div>
</div>
<ul class="nav-x col-9">
<li class="design">
<a href="../../../../../../../design/index.html"
zh-tw-lang="設計"
zh-cn-lang="设计"
ru-lang="Проектирование"
ko-lang="디자인"
ja-lang="設計"
es-lang="Diseñar"
>Design</a></li>
<li class="develop"><a href="../../../../../../../develop/index.html"
zh-tw-lang="開發"
zh-cn-lang="开发"
ru-lang="Разработка"
ko-lang="개발"
ja-lang="開発"
es-lang="Desarrollar"
>Develop</a></li>
<li class="distribute last"><a href="../../../../../../../distribute/googleplay/index.html"
zh-tw-lang="發佈"
zh-cn-lang="分发"
ru-lang="Распространение"
ko-lang="배포"
ja-lang="配布"
es-lang="Distribuir"
>Distribute</a></li>
</ul>
<div class="menu-container">
<div class="moremenu">
<div id="more-btn"></div>
</div>
<div class="morehover" id="moremenu">
<div class="top"></div>
<div class="mid">
<div class="header">Links</div>
<ul>
<li><a href="https://play.google.com/apps/publish/" target="_googleplay">Google Play Developer Console</a></li>
<li><a href="http://android-developers.blogspot.com/">Android Developers Blog</a></li>
<li><a href="../../../../../../../about/index.html">About Android</a></li>
</ul>
<div class="header">Android Sites</div>
<ul>
<li><a href="http://www.android.com">Android.com</a></li>
<li class="active"><a>Android Developers</a></li>
<li><a href="http://source.android.com">Android Open Source Project</a></li>
</ul>
<br class="clearfix" />
</div><!-- end 'mid' -->
<div class="bottom"></div>
</div><!-- end 'moremenu' -->
<div class="search" id="search-container">
<div class="search-inner">
<div id="search-btn"></div>
<div class="left"></div>
<form onsubmit="return submit_search()">
<input id="search_autocomplete" type="text" value="" autocomplete="off" name="q"
onfocus="search_focus_changed(this, true)" onblur="search_focus_changed(this, false)"
onkeydown="return search_changed(event, true, '../../../../../../../')"
onkeyup="return search_changed(event, false, '../../../../../../../')" />
</form>
<div class="right"></div>
<a class="close hide">close</a>
<div class="left"></div>
<div class="right"></div>
</div><!-- end search-inner -->
</div><!-- end search-container -->
<div class="search_filtered_wrapper reference">
<div class="suggest-card reference no-display">
<ul class="search_filtered">
</ul>
</div>
</div>
<div class="search_filtered_wrapper docs">
<div class="suggest-card dummy no-display"> </div>
<div class="suggest-card develop no-display">
<ul class="search_filtered">
</ul>
<div class="child-card guides no-display">
</div>
<div class="child-card training no-display">
</div>
<div class="child-card samples no-display">
</div>
</div>
<div class="suggest-card design no-display">
<ul class="search_filtered">
</ul>
</div>
<div class="suggest-card distribute no-display">
<ul class="search_filtered">
</ul>
</div>
</div>
</div><!-- end menu-container (search and menu widget) -->
<!-- Expanded quicknav -->
<div id="quicknav" class="col-13">
<ul>
<li class="about">
<ul>
<li><a href="../../../../../../../about/index.html">About</a></li>
<li><a href="../../../../../../../wear/index.html">Wear</a></li>
<li><a href="../../../../../../../tv/index.html">TV</a></li>
<li><a href="../../../../../../../auto/index.html">Auto</a></li>
</ul>
</li>
<li class="design">
<ul>
<li><a href="../../../../../../../design/index.html">Get Started</a></li>
<li><a href="../../../../../../../design/devices.html">Devices</a></li>
<li><a href="../../../../../../../design/style/index.html">Style</a></li>
<li><a href="../../../../../../../design/patterns/index.html">Patterns</a></li>
<li><a href="../../../../../../../design/building-blocks/index.html">Building Blocks</a></li>
<li><a href="../../../../../../../design/downloads/index.html">Downloads</a></li>
<li><a href="../../../../../../../design/videos/index.html">Videos</a></li>
</ul>
</li>
<li class="develop">
<ul>
<li><a href="../../../../../../../training/index.html"
zh-tw-lang="訓練課程"
zh-cn-lang="培训"
ru-lang="Курсы"
ko-lang="교육"
ja-lang="トレーニング"
es-lang="Capacitación"
>Training</a></li>
<li><a href="../../../../../../../guide/index.html"
zh-tw-lang="API 指南"
zh-cn-lang="API 指南"
ru-lang="Руководства по API"
ko-lang="API 가이드"
ja-lang="API ガイド"
es-lang="Guías de la API"
>API Guides</a></li>
<li><a href="../../../../../../../reference/packages.html"
zh-tw-lang="參考資源"
zh-cn-lang="参考"
ru-lang="Справочник"
ko-lang="참조문서"
ja-lang="リファレンス"
es-lang="Referencia"
>Reference</a></li>
<li><a href="../../../../../../../sdk/index.html"
zh-tw-lang="相關工具"
zh-cn-lang="工具"
ru-lang="Инструменты"
ko-lang="도구"
ja-lang="ツール"
es-lang="Herramientas"
>Tools</a>
</li>
<li><a href="../../../../../../../google/index.html">Google Services</a>
</li>
</ul>
</li>
<li class="distribute last">
<ul>
<li><a href="../../../../../../../distribute/googleplay/index.html">Google Play</a></li>
<li><a href="../../../../../../../distribute/essentials/index.html">Essentials</a></li>
<li><a href="../../../../../../../distribute/users/index.html">Get Users</a></li>
<li><a href="../../../../../../../distribute/engage/index.html">Engage & Retain</a></li>
<li><a href="../../../../../../../distribute/monetize/index.html">Monetize</a></li>
<li><a href="../../../../../../../distribute/analyze/index.html">Analyze</a></li>
<li><a href="../../../../../../../distribute/tools/index.html">Tools & Reference</a></li>
<li><a href="../../../../../../../distribute/stories/index.html">Developer Stories</a></li>
</ul>
</li>
</ul>
</div><!-- /Expanded quicknav -->
</div><!-- end header-wrap.wrap -->
</div><!-- end header -->
<!-- Secondary x-nav -->
<div id="nav-x">
<div class="wrap" style="position:relative;z-index:1">
<ul class="nav-x col-9 develop" style="width:100%">
<li class="training"><a href="../../../../../../../training/index.html"
zh-tw-lang="訓練課程"
zh-cn-lang="培训"
ru-lang="Курсы"
ko-lang="교육"
ja-lang="トレーニング"
es-lang="Capacitación"
>Training</a></li>
<li class="guide"><a href="../../../../../../../guide/index.html"
zh-tw-lang="API 指南"
zh-cn-lang="API 指南"
ru-lang="Руководства по API"
ko-lang="API 가이드"
ja-lang="API ガイド"
es-lang="Guías de la API"
>API Guides</a></li>
<li class="reference"><a href="../../../../../../../reference/packages.html"
zh-tw-lang="參考資源"
zh-cn-lang="参考"
ru-lang="Справочник"
ko-lang="참조문서"
ja-lang="リファレンス"
es-lang="Referencia"
>Reference</a></li>
<li class="tools"><a href="../../../../../../../sdk/index.html"
zh-tw-lang="相關工具"
zh-cn-lang="工具"
ru-lang="Инструменты"
ko-lang="도구"
ja-lang="ツール"
es-lang="Herramientas"
>Tools</a></li>
<li class="google"><a href="../../../../../../../google/index.html"
>Google Services</a>
</li>
</ul>
</div>
</div>
<!-- /Sendondary x-nav DEVELOP -->
<div id="searchResults" class="wrap" style="display:none;">
<h2 id="searchTitle">Results</h2>
<div id="leftSearchControl" class="search-control">Loading...</div>
</div>
</div> <!--end header-wrapper -->
<div id="sticky-header">
<div>
<a class="logo" href="#top"></a>
<a class="top" href="#top"></a>
<ul class="breadcrumb">
<li class="current">DataBuffer</li>
</ul>
</div>
</div>
<div class="wrap clearfix" id="body-content">
<div class="col-4" id="side-nav" itemscope itemtype="http://schema.org/SiteNavigationElement">
<div id="devdoc-nav">
<div id="api-nav-header">
<div id="api-level-toggle">
<label for="apiLevelCheckbox" class="disabled"
title="Select your target API level to dim unavailable APIs">API level: </label>
<div class="select-wrapper">
<select id="apiLevelSelector">
<!-- option elements added by buildApiLevelSelector() -->
</select>
</div>
</div><!-- end toggle -->
<div id="api-nav-title">Android APIs</div>
</div><!-- end nav header -->
<script>
var SINCE_DATA = [ ];
buildApiLevelSelector();
</script>
<div id="swapper">
<div id="nav-panels">
<div id="resize-packages-nav">
<div id="packages-nav" class="scroll-pane">
<ul>
<li class="api apilevel-">
<a href="../../../../../../../reference/com/google/android/gms/package-summary.html">com.google.android.gms</a></li>
<li class="api apilevel-">
<a href="../../../../../../../reference/com/google/android/gms/actions/package-summary.html">com.google.android.gms.actions</a></li>
<li class="api apilevel-">
<a href="../../../../../../../reference/com/google/android/gms/ads/package-summary.html">com.google.android.gms.ads</a></li>
<li class="api apilevel-">
<a href="../../../../../../../reference/com/google/android/gms/ads/doubleclick/package-summary.html">com.google.android.gms.ads.doubleclick</a></li>
<li class="api apilevel-">
<a href="../../../../../../../reference/com/google/android/gms/ads/identifier/package-summary.html">com.google.android.gms.ads.identifier</a></li>
<li class="api apilevel-">
<a href="../../../../../../../reference/com/google/android/gms/ads/mediation/package-summary.html">com.google.android.gms.ads.mediation</a></li>
<li class="api apilevel-">
<a href="../../../../../../../reference/com/google/android/gms/ads/mediation/admob/package-summary.html">com.google.android.gms.ads.mediation.admob</a></li>
<li class="api apilevel-">
<a href="../../../../../../../reference/com/google/android/gms/ads/mediation/customevent/package-summary.html">com.google.android.gms.ads.mediation.customevent</a></li>
<li class="api apilevel-">
<a href="../../../../../../../reference/com/google/android/gms/ads/purchase/package-summary.html">com.google.android.gms.ads.purchase</a></li>
<li class="api apilevel-">
<a href="../../../../../../../reference/com/google/android/gms/ads/search/package-summary.html">com.google.android.gms.ads.search</a></li>
<li class="api apilevel-">
<a href="../../../../../../../reference/com/google/android/gms/analytics/package-summary.html">com.google.android.gms.analytics</a></li>
<li class="api apilevel-">
<a href="../../../../../../../reference/com/google/android/gms/analytics/ecommerce/package-summary.html">com.google.android.gms.analytics.ecommerce</a></li>
<li class="api apilevel-">
<a href="../../../../../../../reference/com/google/android/gms/appindexing/package-summary.html">com.google.android.gms.appindexing</a></li>
<li class="api apilevel-">
<a href="../../../../../../../reference/com/google/android/gms/appstate/package-summary.html">com.google.android.gms.appstate</a></li>
<li class="api apilevel-">
<a href="../../../../../../../reference/com/google/android/gms/auth/package-summary.html">com.google.android.gms.auth</a></li>
<li class="api apilevel-">
<a href="../../../../../../../reference/com/google/android/gms/cast/package-summary.html">com.google.android.gms.cast</a></li>
<li class="api apilevel-">
<a href="../../../../../../../reference/com/google/android/gms/common/package-summary.html">com.google.android.gms.common</a></li>
<li class="api apilevel-">
<a href="../../../../../../../reference/com/google/android/gms/common/annotation/package-summary.html">com.google.android.gms.common.annotation</a></li>
<li class="api apilevel-">
<a href="../../../../../../../reference/com/google/android/gms/common/api/package-summary.html">com.google.android.gms.common.api</a></li>
<li class="selected api apilevel-">
<a href="../../../../../../../reference/com/google/android/gms/common/data/package-summary.html">com.google.android.gms.common.data</a></li>
<li class="api apilevel-">
<a href="../../../../../../../reference/com/google/android/gms/common/images/package-summary.html">com.google.android.gms.common.images</a></li>
<li class="api apilevel-">
<a href="../../../../../../../reference/com/google/android/gms/drive/package-summary.html">com.google.android.gms.drive</a></li>
<li class="api apilevel-">
<a href="../../../../../../../reference/com/google/android/gms/drive/events/package-summary.html">com.google.android.gms.drive.events</a></li>
<li class="api apilevel-">
<a href="../../../../../../../reference/com/google/android/gms/drive/metadata/package-summary.html">com.google.android.gms.drive.metadata</a></li>
<li class="api apilevel-">
<a href="../../../../../../../reference/com/google/android/gms/drive/query/package-summary.html">com.google.android.gms.drive.query</a></li>
<li class="api apilevel-">
<a href="../../../../../../../reference/com/google/android/gms/drive/widget/package-summary.html">com.google.android.gms.drive.widget</a></li>
<li class="api apilevel-">
<a href="../../../../../../../reference/com/google/android/gms/fitness/package-summary.html">com.google.android.gms.fitness</a></li>
<li class="api apilevel-">
<a href="../../../../../../../reference/com/google/android/gms/fitness/data/package-summary.html">com.google.android.gms.fitness.data</a></li>
<li class="api apilevel-">
<a href="../../../../../../../reference/com/google/android/gms/fitness/request/package-summary.html">com.google.android.gms.fitness.request</a></li>
<li class="api apilevel-">
<a href="../../../../../../../reference/com/google/android/gms/fitness/result/package-summary.html">com.google.android.gms.fitness.result</a></li>
<li class="api apilevel-">
<a href="../../../../../../../reference/com/google/android/gms/fitness/service/package-summary.html">com.google.android.gms.fitness.service</a></li>
<li class="api apilevel-">
<a href="../../../../../../../reference/com/google/android/gms/games/package-summary.html">com.google.android.gms.games</a></li>
<li class="api apilevel-">
<a href="../../../../../../../reference/com/google/android/gms/games/achievement/package-summary.html">com.google.android.gms.games.achievement</a></li>
<li class="api apilevel-">
<a href="../../../../../../../reference/com/google/android/gms/games/event/package-summary.html">com.google.android.gms.games.event</a></li>
<li class="api apilevel-">
<a href="../../../../../../../reference/com/google/android/gms/games/leaderboard/package-summary.html">com.google.android.gms.games.leaderboard</a></li>
<li class="api apilevel-">
<a href="../../../../../../../reference/com/google/android/gms/games/multiplayer/package-summary.html">com.google.android.gms.games.multiplayer</a></li>
<li class="api apilevel-">
<a href="../../../../../../../reference/com/google/android/gms/games/multiplayer/realtime/package-summary.html">com.google.android.gms.games.multiplayer.realtime</a></li>
<li class="api apilevel-">
<a href="../../../../../../../reference/com/google/android/gms/games/multiplayer/turnbased/package-summary.html">com.google.android.gms.games.multiplayer.turnbased</a></li>
<li class="api apilevel-">
<a href="../../../../../../../reference/com/google/android/gms/games/quest/package-summary.html">com.google.android.gms.games.quest</a></li>
<li class="api apilevel-">
<a href="../../../../../../../reference/com/google/android/gms/games/request/package-summary.html">com.google.android.gms.games.request</a></li>
<li class="api apilevel-">
<a href="../../../../../../../reference/com/google/android/gms/games/snapshot/package-summary.html">com.google.android.gms.games.snapshot</a></li>
<li class="api apilevel-">
<a href="../../../../../../../reference/com/google/android/gms/gcm/package-summary.html">com.google.android.gms.gcm</a></li>
<li class="api apilevel-">
<a href="../../../../../../../reference/com/google/android/gms/identity/intents/package-summary.html">com.google.android.gms.identity.intents</a></li>
<li class="api apilevel-">
<a href="../../../../../../../reference/com/google/android/gms/identity/intents/model/package-summary.html">com.google.android.gms.identity.intents.model</a></li>
<li class="api apilevel-">
<a href="../../../../../../../reference/com/google/android/gms/location/package-summary.html">com.google.android.gms.location</a></li>
<li class="api apilevel-">
<a href="../../../../../../../reference/com/google/android/gms/location/places/package-summary.html">com.google.android.gms.location.places</a></li>
<li class="api apilevel-">
<a href="../../../../../../../reference/com/google/android/gms/location/places/ui/package-summary.html">com.google.android.gms.location.places.ui</a></li>
<li class="api apilevel-">
<a href="../../../../../../../reference/com/google/android/gms/maps/package-summary.html">com.google.android.gms.maps</a></li>
<li class="api apilevel-">
<a href="../../../../../../../reference/com/google/android/gms/maps/model/package-summary.html">com.google.android.gms.maps.model</a></li>
<li class="api apilevel-">
<a href="../../../../../../../reference/com/google/android/gms/nearby/package-summary.html">com.google.android.gms.nearby</a></li>
<li class="api apilevel-">
<a href="../../../../../../../reference/com/google/android/gms/nearby/connection/package-summary.html">com.google.android.gms.nearby.connection</a></li>
<li class="api apilevel-">
<a href="../../../../../../../reference/com/google/android/gms/panorama/package-summary.html">com.google.android.gms.panorama</a></li>
<li class="api apilevel-">
<a href="../../../../../../../reference/com/google/android/gms/plus/package-summary.html">com.google.android.gms.plus</a></li>
<li class="api apilevel-">
<a href="../../../../../../../reference/com/google/android/gms/plus/model/moments/package-summary.html">com.google.android.gms.plus.model.moments</a></li>
<li class="api apilevel-">
<a href="../../../../../../../reference/com/google/android/gms/plus/model/people/package-summary.html">com.google.android.gms.plus.model.people</a></li>
<li class="api apilevel-">
<a href="../../../../../../../reference/com/google/android/gms/safetynet/package-summary.html">com.google.android.gms.safetynet</a></li>
<li class="api apilevel-">
<a href="../../../../../../../reference/com/google/android/gms/security/package-summary.html">com.google.android.gms.security</a></li>
<li class="api apilevel-">
<a href="../../../../../../../reference/com/google/android/gms/tagmanager/package-summary.html">com.google.android.gms.tagmanager</a></li>
<li class="api apilevel-">
<a href="../../../../../../../reference/com/google/android/gms/wallet/package-summary.html">com.google.android.gms.wallet</a></li>
<li class="api apilevel-">
<a href="../../../../../../../reference/com/google/android/gms/wallet/fragment/package-summary.html">com.google.android.gms.wallet.fragment</a></li>
<li class="api apilevel-">
<a href="../../../../../../../reference/com/google/android/gms/wearable/package-summary.html">com.google.android.gms.wearable</a></li>
</ul><br/>
</div> <!-- end packages-nav -->
</div> <!-- end resize-packages -->
<div id="classes-nav" class="scroll-pane">
<ul>
<li><h2>Interfaces</h2>
<ul>
<li class="selected api apilevel-"><a href="../../../../../../../reference/com/google/android/gms/common/data/DataBuffer.html">DataBuffer</a></li>
<li class="api apilevel-"><a href="../../../../../../../reference/com/google/android/gms/common/data/DataBufferObserver.html">DataBufferObserver</a></li>
<li class="api apilevel-"><a href="../../../../../../../reference/com/google/android/gms/common/data/DataBufferObserver.Observable.html">DataBufferObserver.Observable</a></li>
<li class="api apilevel-"><a href="../../../../../../../reference/com/google/android/gms/common/data/Freezable.html">Freezable</a></li>
</ul>
</li>
<li><h2>Classes</h2>
<ul>
<li class="api apilevel-"><a href="../../../../../../../reference/com/google/android/gms/common/data/AbstractDataBuffer.html">AbstractDataBuffer</a></li>
<li class="api apilevel-"><a href="../../../../../../../reference/com/google/android/gms/common/data/DataBufferObserverSet.html">DataBufferObserverSet</a></li>
<li class="api apilevel-"><a href="../../../../../../../reference/com/google/android/gms/common/data/DataBufferUtils.html">DataBufferUtils</a></li>
<li class="api apilevel-"><a href="../../../../../../../reference/com/google/android/gms/common/data/FreezableUtils.html">FreezableUtils</a></li>
</ul>
</li>
</ul><br/>
</div><!-- end classes -->
</div><!-- end nav-panels -->
<div id="nav-tree" style="display:none" class="scroll-pane">
<div id="tree-list"></div>
</div><!-- end nav-tree -->
</div><!-- end swapper -->
<div id="nav-swap">
<a class="fullscreen">fullscreen</a>
<a href='#' onclick='swapNav();return false;'><span id='tree-link'>Use Tree Navigation</span><span id='panel-link' style='display:none'>Use Panel Navigation</span></a>
</div>
</div> <!-- end devdoc-nav -->
</div> <!-- end side-nav -->
<script type="text/javascript">
// init fullscreen based on user pref
var fullscreen = readCookie("fullscreen");
if (fullscreen != 0) {
if (fullscreen == "false") {
toggleFullscreen(false);
} else {
toggleFullscreen(true);
}
}
// init nav version for mobile
if (isMobile) {
swapNav(); // tree view should be used on mobile
$('#nav-swap').hide();
} else {
chooseDefaultNav();
if ($("#nav-tree").is(':visible')) {
init_default_navtree("../../../../../../../");
}
}
// scroll the selected page into view
$(document).ready(function() {
scrollIntoView("packages-nav");
scrollIntoView("classes-nav");
});
</script>
<div class="col-12" id="doc-col">
<div id="api-info-block">
<div class="sum-details-links">
Summary:
<a href="#pubmethods">Methods</a>
| <a href="#inhmethods">Inherited Methods</a>
| <a href="#" onclick="return toggleAllClassInherited()" id="toggleAllClassInherited">[Expand All]</a>
</div><!-- end sum-details-links -->
<div class="api-level">
</div>
</div><!-- end api-info-block -->
<!-- ======== START OF CLASS DATA ======== -->
<div id="jd-header">
public
interface
<h1 itemprop="name">DataBuffer</h1>
implements
<a href="http://developer.android.com/reference/java/lang/Iterable.html">Iterable</a><T>
<a href="../../../../../../../reference/com/google/android/gms/common/api/Releasable.html">Releasable</a>
</div><!-- end header -->
<div id="naMessage"></div>
<div id="jd-content" class="api apilevel-">
<table class="jd-inheritance-table">
<tr>
<td colspan="1" class="jd-inheritance-class-cell">com.google.android.gms.common.data.DataBuffer<T></td>
</tr>
</table>
<table class="jd-sumtable jd-sumtable-subclasses"><tr><td colspan="12" style="border:none;margin:0;padding:0;">
<a href="#" onclick="return toggleInherited(this, null)" id="subclasses-indirect" class="jd-expando-trigger closed"
><img id="subclasses-indirect-trigger"
src="../../../../../../../assets/images/triangle-closed.png"
class="jd-expando-trigger-img" /></a>Known Indirect Subclasses
<div id="subclasses-indirect">
<div id="subclasses-indirect-list"
class="jd-inheritedlinks"
>
<a href="../../../../../../../reference/com/google/android/gms/common/data/AbstractDataBuffer.html">AbstractDataBuffer</a><T>,
<a href="../../../../../../../reference/com/google/android/gms/games/achievement/AchievementBuffer.html">AchievementBuffer</a>,
<a href="../../../../../../../reference/com/google/android/gms/appstate/AppStateBuffer.html">AppStateBuffer</a>,
<a href="../../../../../../../reference/com/google/android/gms/location/places/AutocompletePredictionBuffer.html">AutocompletePredictionBuffer</a>,
<a href="../../../../../../../reference/com/google/android/gms/wearable/DataEventBuffer.html">DataEventBuffer</a>,
<a href="../../../../../../../reference/com/google/android/gms/wearable/DataItemBuffer.html">DataItemBuffer</a>,
and
<a href="#" onclick="return toggleInherited(document.getElementById('subclasses-indirect', null))">8 others.</a>
</div>
<div id="subclasses-indirect-summary"
style="display: none;"
>
<table class="jd-sumtable-expando">
<tr class="alt-color api apilevel-" >
<td class="jd-linkcol"><a href="../../../../../../../reference/com/google/android/gms/common/data/AbstractDataBuffer.html">AbstractDataBuffer</a><T></td>
<td class="jd-descrcol" width="100%">
Default implementation of DataBuffer.
</td>
</tr>
<tr class=" api apilevel-" >
<td class="jd-linkcol"><a href="../../../../../../../reference/com/google/android/gms/games/achievement/AchievementBuffer.html">AchievementBuffer</a></td>
<td class="jd-descrcol" width="100%">
Data structure providing access to a list of achievements.
</td>
</tr>
<tr class="alt-color api apilevel-" >
<td class="jd-linkcol"><a href="../../../../../../../reference/com/google/android/gms/appstate/AppStateBuffer.html">AppStateBuffer</a></td>
<td class="jd-descrcol" width="100%">
Data structure providing access to a list of app states.
</td>
</tr>
<tr class=" api apilevel-" >
<td class="jd-linkcol"><a href="../../../../../../../reference/com/google/android/gms/location/places/AutocompletePredictionBuffer.html">AutocompletePredictionBuffer</a></td>
<td class="jd-descrcol" width="100%">
A <code>DataBuffer</code> that represents a list of AutocompletePredictionEntitys.
</td>
</tr>
<tr class="alt-color api apilevel-" >
<td class="jd-linkcol"><a href="../../../../../../../reference/com/google/android/gms/wearable/DataEventBuffer.html">DataEventBuffer</a></td>
<td class="jd-descrcol" width="100%">
Data structure holding references to a set of events.
</td>
</tr>
<tr class=" api apilevel-" >
<td class="jd-linkcol"><a href="../../../../../../../reference/com/google/android/gms/wearable/DataItemBuffer.html">DataItemBuffer</a></td>
<td class="jd-descrcol" width="100%">
Data structure holding reference to a set of <code><a href="../../../../../../../reference/com/google/android/gms/wearable/DataItem.html">DataItem</a></code>s.
</td>
</tr>
<tr class="alt-color api apilevel-" >
<td class="jd-linkcol"><a href="../../../../../../../reference/com/google/android/gms/games/event/EventBuffer.html">EventBuffer</a></td>
<td class="jd-descrcol" width="100%">
Data structure providing access to a list of events.
</td>
</tr>
<tr class=" api apilevel-" >
<td class="jd-linkcol"><a href="../../../../../../../reference/com/google/android/gms/games/GameBuffer.html">GameBuffer</a></td>
<td class="jd-descrcol" width="100%">
Data structure providing access to a list of games.
</td>
</tr>
<tr class="alt-color api apilevel-" >
<td class="jd-linkcol"><a href="../../../../../../../reference/com/google/android/gms/games/request/GameRequestBuffer.html">GameRequestBuffer</a></td>
<td class="jd-descrcol" width="100%">
EntityBuffer implementation containing
Request details.
</td>
</tr>
<tr class=" api apilevel-" >
<td class="jd-linkcol"><a href="../../../../../../../reference/com/google/android/gms/games/multiplayer/InvitationBuffer.html">InvitationBuffer</a></td>
<td class="jd-descrcol" width="100%">
EntityBuffer implementation containing Invitation data.
</td>
</tr>
<tr class="alt-color api apilevel-" >
<td class="jd-linkcol"><a href="../../../../../../../reference/com/google/android/gms/games/leaderboard/LeaderboardBuffer.html">LeaderboardBuffer</a></td>
<td class="jd-descrcol" width="100%">
EntityBuffer containing Leaderboard data.
</td>
</tr>
<tr class=" api apilevel-" >
<td class="jd-linkcol"><a href="../../../../../../../reference/com/google/android/gms/games/leaderboard/LeaderboardScoreBuffer.html">LeaderboardScoreBuffer</a></td>
<td class="jd-descrcol" width="100%">
<code><a href="../../../../../../../reference/com/google/android/gms/common/data/AbstractDataBuffer.html">AbstractDataBuffer</a></code> containing LeaderboardScore data.
</td>
</tr>
<tr class="alt-color api apilevel-" >
<td class="jd-linkcol"><a href="../../../../../../../reference/com/google/android/gms/drive/MetadataBuffer.html">MetadataBuffer</a></td>
<td class="jd-descrcol" width="100%">
A data buffer that points to Metadata entries.
</td>
</tr>
<tr class=" api apilevel-" >
<td class="jd-linkcol"><a href="../../../../../../../reference/com/google/android/gms/games/quest/MilestoneBuffer.html">MilestoneBuffer</a></td>
<td class="jd-descrcol" width="100%">
<code><a href="../../../../../../../reference/com/google/android/gms/common/data/AbstractDataBuffer.html">AbstractDataBuffer</a></code> implementation containing quest
milestone data.
</td>
</tr>
<tr class="alt-color api apilevel-" >
<td class="jd-linkcol"><a href="../../../../../../../reference/com/google/android/gms/plus/model/moments/MomentBuffer.html">MomentBuffer</a></td>
<td class="jd-descrcol" width="100%">
Data structure providing access to a list of <code><a href="../../../../../../../reference/com/google/android/gms/plus/model/moments/Moment.html">Moment</a></code> objects.
</td>
</tr>
<tr class=" api apilevel-" >
<td class="jd-linkcol"><a href="../../../../../../../reference/com/google/android/gms/games/multiplayer/ParticipantBuffer.html">ParticipantBuffer</a></td>
<td class="jd-descrcol" width="100%">
<code><a href="../../../../../../../reference/com/google/android/gms/common/data/AbstractDataBuffer.html">AbstractDataBuffer</a></code> implementation containing match participant data.
</td>
</tr>
<tr class="alt-color api apilevel-" >
<td class="jd-linkcol"><a href="../../../../../../../reference/com/google/android/gms/plus/model/people/PersonBuffer.html">PersonBuffer</a></td>
<td class="jd-descrcol" width="100%">
Data structure providing access to a list of <code><a href="../../../../../../../reference/com/google/android/gms/plus/model/people/Person.html">Person</a></code> objects.
</td>
</tr>
<tr class=" api apilevel-" >
<td class="jd-linkcol"><a href="../../../../../../../reference/com/google/android/gms/location/places/PlaceBuffer.html">PlaceBuffer</a></td>
<td class="jd-descrcol" width="100%">
Data structure providing access to a list of <code><a href="../../../../../../../reference/com/google/android/gms/location/places/Place.html">Places</a></code>.
</td>
</tr>
<tr class="alt-color api apilevel-" >
<td class="jd-linkcol"><a href="../../../../../../../reference/com/google/android/gms/location/places/PlaceLikelihoodBuffer.html">PlaceLikelihoodBuffer</a></td>
<td class="jd-descrcol" width="100%">
A <code>DataBuffer</code> that represents a list of <code>PlaceLikelihood</code>s.
</td>
</tr>
<tr class=" api apilevel-" >
<td class="jd-linkcol"><a href="../../../../../../../reference/com/google/android/gms/games/PlayerBuffer.html">PlayerBuffer</a></td>
<td class="jd-descrcol" width="100%">
Data structure providing access to a list of players.
</td>
</tr>
<tr class="alt-color api apilevel-" >
<td class="jd-linkcol"><a href="../../../../../../../reference/com/google/android/gms/games/quest/QuestBuffer.html">QuestBuffer</a></td>
<td class="jd-descrcol" width="100%">
EntityBuffer implementation containing Quest details.
</td>
</tr>
<tr class=" api apilevel-" >
<td class="jd-linkcol"><a href="../../../../../../../reference/com/google/android/gms/games/snapshot/SnapshotMetadataBuffer.html">SnapshotMetadataBuffer</a></td>
<td class="jd-descrcol" width="100%">
Data structure providing access to a list of snapshots.
</td>
</tr>
<tr class="alt-color api apilevel-" >
<td class="jd-linkcol"><a href="../../../../../../../reference/com/google/android/gms/games/multiplayer/turnbased/TurnBasedMatchBuffer.html">TurnBasedMatchBuffer</a></td>
<td class="jd-descrcol" width="100%">
EntityBuffer implementation containing TurnBasedMatch details.
</td>
</tr>
</table>
</div>
</div>
</td></tr></table>
<div class="jd-descr">
<h2>Class Overview</h2>
<p itemprop="articleBody">Interface for a buffer of typed data.
</p>
</div><!-- jd-descr -->
<div class="jd-descr">
<h2>Summary</h2>
<!-- ========== METHOD SUMMARY =========== -->
<table id="pubmethods" class="jd-sumtable"><tr><th colspan="12">Public Methods</th></tr>
<tr class="alt-color api apilevel-" >
<td class="jd-typecol"><nobr>
abstract
void</nobr>
</td>
<td class="jd-linkcol" width="100%"><nobr>
<span class="sympad"><a href="../../../../../../../reference/com/google/android/gms/common/data/DataBuffer.html#close()">close</a></span>()</nobr>
<div class="jd-descrdiv">
<em>
This method is deprecated.
use <code><a href="../../../../../../../reference/com/google/android/gms/common/data/DataBuffer.html#release()">release()</a></code> instead
</em>
</div>
</td></tr>
<tr class=" api apilevel-" >
<td class="jd-typecol"><nobr>
abstract
T</nobr>
</td>
<td class="jd-linkcol" width="100%"><nobr>
<span class="sympad"><a href="../../../../../../../reference/com/google/android/gms/common/data/DataBuffer.html#get(int)">get</a></span>(int position)</nobr>
<div class="jd-descrdiv">
Returns an element on specified position.
</div>
</td></tr>
<tr class="alt-color api apilevel-" >
<td class="jd-typecol"><nobr>
abstract
int</nobr>
</td>
<td class="jd-linkcol" width="100%"><nobr>
<span class="sympad"><a href="../../../../../../../reference/com/google/android/gms/common/data/DataBuffer.html#getCount()">getCount</a></span>()</nobr>
</td></tr>
<tr class=" api apilevel-" >
<td class="jd-typecol"><nobr>
abstract
boolean</nobr>
</td>
<td class="jd-linkcol" width="100%"><nobr>
<span class="sympad"><a href="../../../../../../../reference/com/google/android/gms/common/data/DataBuffer.html#isClosed()">isClosed</a></span>()</nobr>
<div class="jd-descrdiv">
<em>
This method is deprecated.
<code><a href="../../../../../../../reference/com/google/android/gms/common/data/DataBuffer.html#release()">release()</a></code> is idempotent, and so is safe to call multiple times
</em>
</div>
</td></tr>
<tr class="alt-color api apilevel-" >
<td class="jd-typecol"><nobr>
abstract
<a href="http://developer.android.com/reference/java/util/Iterator.html">Iterator</a><T></nobr>
</td>
<td class="jd-linkcol" width="100%"><nobr>
<span class="sympad"><a href="../../../../../../../reference/com/google/android/gms/common/data/DataBuffer.html#iterator()">iterator</a></span>()</nobr>
</td></tr>
<tr class=" api apilevel-" >
<td class="jd-typecol"><nobr>
abstract
void</nobr>
</td>
<td class="jd-linkcol" width="100%"><nobr>
<span class="sympad"><a href="../../../../../../../reference/com/google/android/gms/common/data/DataBuffer.html#release()">release</a></span>()</nobr>
<div class="jd-descrdiv">
Releases resources used by the buffer.
</div>
</td></tr>
<tr class="alt-color api apilevel-" >
<td class="jd-typecol"><nobr>
abstract
<a href="http://developer.android.com/reference/java/util/Iterator.html">Iterator</a><T></nobr>
</td>
<td class="jd-linkcol" width="100%"><nobr>
<span class="sympad"><a href="../../../../../../../reference/com/google/android/gms/common/data/DataBuffer.html#singleRefIterator()">singleRefIterator</a></span>()</nobr>
<div class="jd-descrdiv">
In order to use this iterator it should be supported by particular <code>DataBuffer</code>.
</div>
</td></tr>
</table>
<!-- ========== METHOD SUMMARY =========== -->
<table id="inhmethods" class="jd-sumtable"><tr><th>
<a href="#" class="toggle-all" onclick="return toggleAllInherited(this, null)">[Expand]</a>
<div style="clear:left;">Inherited Methods</div></th></tr>
<tr class="api apilevel-" >
<td colspan="12">
<a href="#" onclick="return toggleInherited(this, null)" id="inherited-methods-java.lang.Iterable" class="jd-expando-trigger closed"
><img id="inherited-methods-java.lang.Iterable-trigger"
src="../../../../../../../assets/images/triangle-closed.png"
class="jd-expando-trigger-img" /></a>
From interface
<a href="http://developer.android.com/reference/java/lang/Iterable.html">java.lang.Iterable</a>
<div id="inherited-methods-java.lang.Iterable">
<div id="inherited-methods-java.lang.Iterable-list"
class="jd-inheritedlinks">
</div>
<div id="inherited-methods-java.lang.Iterable-summary" style="display: none;">
<table class="jd-sumtable-expando">
<tr class="alt-color api apilevel-" >
<td class="jd-typecol"><nobr>
abstract
<a href="http://developer.android.com/reference/java/util/Iterator.html">Iterator</a><T></nobr>
</td>
<td class="jd-linkcol" width="100%"><nobr>
<span class="sympad">iterator</span>()</nobr>
</td></tr>
</table>
</div>
</div>
</td></tr>
<tr class="api apilevel-" >
<td colspan="12">
<a href="#" onclick="return toggleInherited(this, null)" id="inherited-methods-com.google.android.gms.common.api.Releasable" class="jd-expando-trigger closed"
><img id="inherited-methods-com.google.android.gms.common.api.Releasable-trigger"
src="../../../../../../../assets/images/triangle-closed.png"
class="jd-expando-trigger-img" /></a>
From interface
<a href="../../../../../../../reference/com/google/android/gms/common/api/Releasable.html">com.google.android.gms.common.api.Releasable</a>
<div id="inherited-methods-com.google.android.gms.common.api.Releasable">
<div id="inherited-methods-com.google.android.gms.common.api.Releasable-list"
class="jd-inheritedlinks">
</div>
<div id="inherited-methods-com.google.android.gms.common.api.Releasable-summary" style="display: none;">
<table class="jd-sumtable-expando">
<tr class="alt-color api apilevel-" >
<td class="jd-typecol"><nobr>
abstract
void</nobr>
</td>
<td class="jd-linkcol" width="100%"><nobr>
<span class="sympad"><a href="../../../../../../../reference/com/google/android/gms/common/api/Releasable.html#release()">release</a></span>()</nobr>
</td></tr>
</table>
</div>
</div>
</td></tr>
</table>
</div><!-- jd-descr (summary) -->
<!-- Details -->
<!-- XML Attributes -->
<!-- Enum Values -->
<!-- Constants -->
<!-- Fields -->
<!-- Public ctors -->
<!-- ========= CONSTRUCTOR DETAIL ======== -->
<!-- Protected ctors -->
<!-- ========= METHOD DETAIL ======== -->
<!-- Public methdos -->
<h2>Public Methods</h2>
<A NAME="close()"></A>
<div class="jd-details api apilevel-">
<h4 class="jd-details-title">
<span class="normal">
public
abstract
void
</span>
<span class="sympad">close</span>
<span class="normal">()</span>
</h4>
<div class="api-level">
<div></div>
</div>
<div class="jd-details-descr">
<p>
<p class="caution"><strong>
This method is deprecated.</strong><br/>
use <code><a href="../../../../../../../reference/com/google/android/gms/common/data/DataBuffer.html#release()">release()</a></code> instead
</p>
<div class="jd-tagdata jd-tagdescr"><p></p></div>
</div>
</div>
<A NAME="get(int)"></A>
<div class="jd-details api apilevel-">
<h4 class="jd-details-title">
<span class="normal">
public
abstract
T
</span>
<span class="sympad">get</span>
<span class="normal">(int position)</span>
</h4>
<div class="api-level">
<div></div>
</div>
<div class="jd-details-descr">
<div class="jd-tagdata jd-tagdescr"><p>Returns an element on specified position.
</p></div>
</div>
</div>
<A NAME="getCount()"></A>
<div class="jd-details api apilevel-">
<h4 class="jd-details-title">
<span class="normal">
public
abstract
int
</span>
<span class="sympad">getCount</span>
<span class="normal">()</span>
</h4>
<div class="api-level">
<div></div>
</div>
<div class="jd-details-descr">
<div class="jd-tagdata jd-tagdescr"><p></p></div>
</div>
</div>
<A NAME="isClosed()"></A>
<div class="jd-details api apilevel-">
<h4 class="jd-details-title">
<span class="normal">
public
abstract
boolean
</span>
<span class="sympad">isClosed</span>
<span class="normal">()</span>
</h4>
<div class="api-level">
<div></div>
</div>
<div class="jd-details-descr">
<p>
<p class="caution"><strong>
This method is deprecated.</strong><br/>
<code><a href="../../../../../../../reference/com/google/android/gms/common/data/DataBuffer.html#release()">release()</a></code> is idempotent, and so is safe to call multiple times
</p>
<div class="jd-tagdata jd-tagdescr"><p></p></div>
</div>
</div>
<A NAME="iterator()"></A>
<div class="jd-details api apilevel-">
<h4 class="jd-details-title">
<span class="normal">
public
abstract
<a href="http://developer.android.com/reference/java/util/Iterator.html">Iterator</a><T>
</span>
<span class="sympad">iterator</span>
<span class="normal">()</span>
</h4>
<div class="api-level">
<div></div>
</div>
<div class="jd-details-descr">
<div class="jd-tagdata jd-tagdescr"><p></p></div>
</div>
</div>
<A NAME="release()"></A>
<div class="jd-details api apilevel-">
<h4 class="jd-details-title">
<span class="normal">
public
abstract
void
</span>
<span class="sympad">release</span>
<span class="normal">()</span>
</h4>
<div class="api-level">
<div></div>
</div>
<div class="jd-details-descr">
<div class="jd-tagdata jd-tagdescr"><p>Releases resources used by the buffer. This method is idempotent.
</p></div>
</div>
</div>
<A NAME="singleRefIterator()"></A>
<div class="jd-details api apilevel-">
<h4 class="jd-details-title">
<span class="normal">
public
abstract
<a href="http://developer.android.com/reference/java/util/Iterator.html">Iterator</a><T>
</span>
<span class="sympad">singleRefIterator</span>
<span class="normal">()</span>
</h4>
<div class="api-level">
<div></div>
</div>
<div class="jd-details-descr">
<div class="jd-tagdata jd-tagdescr"><p>In order to use this iterator it should be supported by particular <code>DataBuffer</code>.
Be careful: there will be single reference while iterating.
If you are not sure - DO NOT USE this iterator.
</p></div>
</div>
</div>
<!-- ========= METHOD DETAIL ======== -->
<!-- ========= END OF CLASS DATA ========= -->
<A NAME="navbar_top"></A>
<div id="footer" class="wrap" >
<div id="copyright">
Except as noted, this content is licensed under <a
href="http://www.apache.org/licenses/LICENSE-2.0">Apache 2.0</a>.
For details and restrictions, see the <a href="../../../../../../../license.html">
Content License</a>.
</div>
<div id="build_info">
Android GmsCore 1784785 r —
<script src="../../../../../../../timestamp.js" type="text/javascript"></script>
<script>document.write(BUILD_TIMESTAMP)</script>
</div>
<div id="footerlinks">
<p>
<a href="../../../../../../../about/index.html">About Android</a> |
<a href="../../../../../../../legal.html">Legal</a> |
<a href="../../../../../../../support.html">Support</a>
</p>
</div>
</div> <!-- end footer -->
</div> <!-- jd-content -->
</div><!-- end doc-content -->
</div> <!-- end body-content -->
</body>
</html>
| CMPUT301W15T05/TrackerExpress | google-play-services_lib/docs/reference/com/google/android/gms/common/data/DataBuffer.html | HTML | mit | 56,195 | [
30522,
1026,
999,
9986,
13874,
16129,
1028,
1026,
16129,
1028,
1026,
2132,
1028,
1026,
18804,
8299,
1011,
1041,
15549,
2615,
1027,
1000,
4180,
1011,
2828,
1000,
4180,
1027,
1000,
3793,
1013,
16129,
1025,
25869,
13462,
1027,
21183,
2546,
101... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
#import "MOBProjection.h"
@interface MOBProjectionEPSG102713 : MOBProjection
@end
| jkdubr/Proj4 | Pod/Classes/Projection/MOBProjectionEPSG102713.h | C | mit | 84 | [
30522,
1001,
12324,
1000,
11240,
21572,
20614,
3258,
1012,
1044,
1000,
1030,
8278,
11240,
21572,
20614,
3258,
13699,
28745,
10790,
22907,
17134,
1024,
11240,
21572,
20614,
3258,
30524,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
using System;
using System.Linq;
using System.Reflection;
using Microsoft.AspNetCore.Mvc.ApplicationModels;
namespace Ardalis.CoreFeatureFolders
{
public class FeatureConvention : IControllerModelConvention
{
public void Apply(ControllerModel controller)
{
var featureName = GetFeatureName(controller.ControllerType);
controller.Properties.Add("feature", featureName);
}
private string GetFeatureName(TypeInfo controllerType)
{
string[] tokens = controllerType.FullName.Split('.');
if (!tokens.Any(t => t == "Features")) return "";
string featureName = tokens
.SkipWhile(t => !t.Equals("features", StringComparison.CurrentCultureIgnoreCase))
.Skip(1)
.Take(1)
.FirstOrDefault();
return featureName;
}
}
} | ardalis/OrganizingAspNetCore | CoreFeatureFolders/FeatureConvention.cs | C# | mit | 903 | [
30522,
2478,
2291,
1025,
2478,
2291,
1012,
11409,
4160,
1025,
2478,
2291,
1012,
9185,
1025,
2478,
7513,
1012,
2004,
2361,
7159,
17345,
1012,
19842,
2278,
1012,
4646,
5302,
9247,
2015,
1025,
3415,
15327,
12098,
9305,
2483,
1012,
4563,
7959,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
<?php defined('SYSPATH') OR die('No direct access allowed.');
class Facebook {
protected static $table_prefix = '';
public static function install()
{
$db_config = Kohana::$config->load('database');
$default = $db_config->get('default');
self::$table_prefix = $default['table_prefix'];
self::_sql();
}
private static function _sql()
{
$db = Database::instance('default');
$create = "
CREATE TABLE IF NOT EXISTS `".self::$table_prefix."facebook_settings`
(
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
`key` varchar(100) NOT NULL DEFAULT '',
`value` varchar(255) DEFAULT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `uniq_key` (`key`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
";
$db->query(NULL, $create, true);
// Insert Default Settings Keys
// Use ORM to prevent issues with unique keys
// Facebook Application ID / API Key
$setting = ORM::factory('facebook_setting')
->where('key', '=', 'application_id')
->find();
$setting->key = 'application_id';
$setting->save();
// Facebook Application Secret
$setting = ORM::factory('facebook_setting')
->where('key', '=', 'application_secret')
->find();
$setting->key = 'application_secret';
$setting->save();
// Access token for offline access to Facebook
$setting = ORM::factory('facebook_setting')
->where('key', '=', 'access_token')
->find();
$setting->key = 'access_token';
$setting->save();
// Unique ID on Facebook of the user Authorizing the Facebook Application
$setting = ORM::factory('facebook_setting')
->where('key', '=', 'access_user_id')
->find();
$setting->key = 'access_user_id';
$setting->save();
// Name of the user Authorizing the Facebook Application
$setting = ORM::factory('facebook_setting')
->where('key', '=', 'access_name')
->find();
$setting->key = 'access_name';
$setting->save();
}
} | ushahidi/Sweeper | plugins/facebook/classes/facebook.php | PHP | gpl-3.0 | 1,901 | [
30522,
1026,
1029,
25718,
4225,
1006,
1005,
25353,
13102,
8988,
1005,
1007,
2030,
3280,
1006,
1005,
2053,
3622,
3229,
3039,
1012,
1005,
1007,
1025,
2465,
9130,
1063,
5123,
10763,
1002,
2795,
1035,
17576,
1027,
1005,
1005,
1025,
2270,
10763,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
using System.Collections.Generic;
namespace Quilt4.Service.Controllers.WebAPI.Web.DataTransfer
{
public class ProjectPageProjectResponse
{
public string ProjectKey { get; set; }
public string Name { get; set; }
public string DashboardColor { get; set; }
public string ClientToken { get; set; }
public IEnumerable<ProjectPageApplicationResponse> Applications { get; set; }
}
} | Quilt4/Quilt4.Service | Quilt4.Service/Controllers/WebAPI/Web/DataTransfer/ProjectPageProjectResponse.cs | C# | mit | 432 | [
30522,
2478,
2291,
1012,
6407,
1012,
12391,
1025,
3415,
15327,
27565,
2549,
1012,
2326,
1012,
21257,
1012,
4773,
9331,
2072,
1012,
4773,
1012,
2951,
6494,
3619,
7512,
1063,
2270,
2465,
2622,
13704,
21572,
20614,
6072,
26029,
3366,
1063,
227... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
<?php $captcha_word = 'UCCL'; ?> | CoordCulturaDigital-Minc/culturadigital.br | wp-content/plugins/si-captcha-for-wordpress/captcha-secureimage/captcha-temp/ZSENmm3VbOQ8PhXO.php | PHP | gpl-2.0 | 32 | [
30522,
1026,
1029,
25718,
1002,
14408,
7507,
1035,
2773,
1027,
1005,
15384,
20464,
1005,
1025,
1029,
1028,
102,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
require 'net/ssh'
class RemoteServerJob < ActiveJob::Base
queue_as :default
SCRIPTS_PATH = './ruby-bench-docker/scripts'
RUBY_TRUNK = "#{SCRIPTS_PATH}/ruby/trunk.sh"
RUBY_RELEASE = "#{SCRIPTS_PATH}/ruby/releases.sh"
RAILS_MASTER = "#{SCRIPTS_PATH}/rails/master.sh"
RAILS_RELEASE = "#{SCRIPTS_PATH}/rails/releases.sh"
SEQUEL_MASTER = "#{SCRIPTS_PATH}/sequel/master.sh"
SEQUEL_RELEASE = "#{SCRIPTS_PATH}/sequel/releases.sh"
BUNDLER_RELEASE = "#{SCRIPTS_PATH}/bundler/releases.sh"
PG_MASTER = "#{SCRIPTS_PATH}/pg/master.sh"
# Use keyword arguments once Rails 4.2.1 has been released.
def perform(initiator_key, benchmark_group, options = {})
Net::SSH.start(
secrets.bare_metal_server_ip,
secrets.bare_metal_server_user,
password: secrets.bare_metal_server_password
) do |ssh|
send(benchmark_group, ssh, initiator_key, options)
end
end
private
def ruby_trunk(ssh, commit_hash, options)
ruby = true
memory = true
optcarrot = true
liquid = true
patterns = options[:include_patterns]
ssh_exec!(
ssh,
"#{RUBY_TRUNK} #{ruby} #{memory} #{optcarrot} #{liquid} #{commit_hash} #{secrets.api_name} #{secrets.api_password} #{patterns}"
)
end
def ruby_releases(ssh, version, options)
ruby = true
memory = true
optcarrot = true
liquid = true
patterns = options[:include_patterns]
ssh_exec!(
ssh,
"#{RUBY_RELEASE} #{ruby} #{memory} #{optcarrot} #{liquid} #{version} #{secrets.api_name} #{secrets.api_password} #{patterns}"
)
end
def ruby_releases_discourse(ssh, ruby_version, options)
execute_ssh_commands(ssh,
[
'docker pull rubybench/ruby_releases_discourse',
'docker run --name discourse_redis -d redis:2.8.19',
'docker run --name discourse_postgres -d postgres:9.3.5',
"docker run --rm
--link discourse_postgres:postgres
--link discourse_redis:redis
-e \"RUBY_VERSION=#{ruby_version}\"
-e \"API_NAME=#{secrets.api_name}\"
-e \"API_PASSWORD=#{secrets.api_password}\"
rubybench/ruby_releases_discourse".squish,
'docker stop discourse_postgres discourse_redis',
'docker rm -v discourse_postgres discourse_redis'
]
)
end
def ruby_trunk_discourse(ssh, commit_hash, options)
execute_ssh_commands(ssh,
[
'docker pull rubybench/ruby_trunk_discourse',
'docker run --name discourse_redis -d redis:2.8.19',
'docker run --name discourse_postgres -d postgres:9.3.5',
"docker run --rm --link discourse_postgres:postgres
--link discourse_redis:redis -e \"RUBY_COMMIT_HASH=#{commit_hash}\"
-e \"API_NAME=#{secrets.api_name}\"
-e \"API_PASSWORD=#{secrets.api_password}\"
rubybench/ruby_trunk_discourse".squish,
'docker stop discourse_postgres discourse_redis',
'docker rm -v discourse_postgres discourse_redis'
]
)
end
def rails_releases(ssh, version, options)
prepared_statements = if version >= '4.2.5' then 1 else 0 end
patterns = options[:include_patterns]
ssh_exec!(ssh, "#{RAILS_RELEASE} #{version} #{secrets.api_name} #{secrets.api_password} #{prepared_statements} #{patterns}")
end
def rails_trunk(ssh, commit_hash, options)
patterns = options[:include_patterns]
ssh_exec!(ssh, "#{RAILS_MASTER} #{commit_hash} #{secrets.api_name} #{secrets.api_password} #{patterns}")
end
def sequel_releases(ssh, version, options)
patterns = options[:include_patterns]
ssh_exec!(ssh, "#{SEQUEL_RELEASE} #{version} #{secrets.api_name} #{secrets.api_password} #{patterns}")
end
def sequel_trunk(ssh, commit_hash, options)
patterns = options[:include_patterns]
ssh_exec!(ssh, "#{SEQUEL_MASTER} #{commit_hash} #{secrets.api_name} #{secrets.api_password} #{patterns}")
end
def bundler_releases(ssh, version, options)
patterns = options[:include_patterns]
ssh_exec!(ssh, "#{BUNDLER_RELEASE} #{version} #{secrets.api_name} #{secrets.api_password} #{patterns}")
end
def pg_master(ssh, commit_hash, options)
patterns = options[:include_patterns]
ssh_exec!(ssh, "#{PG_MASTER} #{commit_hash} #{secrets.api_name} #{secrets.api_password} #{patterns}")
end
def execute_ssh_commands(ssh, commands)
commands.each do |command|
ssh_exec!(ssh, command)
end
end
def ssh_exec!(ssh, command)
ssh.exec!("tsp #{command}") do |channel, stream, data|
puts data
end
end
def build_include_patterns(patterns)
"-e \"INCLUDE_PATTERNS=#{patterns}\""
end
def secrets
Rails.application.secrets
end
end
| bmarkons/ruby-bench-web | app/jobs/remote_server_job.rb | Ruby | mit | 4,685 | [
30522,
5478,
1005,
5658,
1013,
7020,
2232,
1005,
2465,
6556,
8043,
6299,
5558,
2497,
1026,
3161,
5558,
2497,
1024,
1024,
2918,
24240,
1035,
2004,
1024,
12398,
14546,
1035,
4130,
1027,
1005,
1012,
1013,
10090,
1011,
6847,
1011,
8946,
2121,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
---
layout: default
---
<section>
<div class="row">
{% include about_contents.html %}
<div class="col-sm-9">
{% if page.title %}
<h1>{{ page.title }}</h1>
{% endif %}
<article>
{{ content }}
</article>
</div>
</div>
</section>
| bbockelm/bbockelm.github.io | _layouts/about.html | HTML | apache-2.0 | 314 | [
30522,
1011,
1011,
1011,
9621,
1024,
12398,
1011,
1011,
1011,
1026,
2930,
1028,
1026,
4487,
2615,
2465,
1027,
1000,
5216,
1000,
1028,
1063,
1003,
2421,
2055,
1035,
8417,
1012,
16129,
1003,
1065,
1026,
4487,
2615,
2465,
1027,
1000,
8902,
1... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
package notes
import (
"fmt"
"math/rand"
"regexp"
"strings"
"time"
)
const (
DATEFORMATGETPARAM = "02/01/2006"
DATEHOURFORMATPRINT = "02/01/2006 Mon 15:04"
HOURFORMATPRINT = "15:04"
DATEFORMATPRINT = "02 Jan 2006"
DATEFORMATFORHTML = "Monday, 02 January 2006"
MAXWORDSRESUMEBODY = 20
)
var nullTime = time.Time{}
type Note struct {
Id int64
Title string
Body string
Stamps []time.Time
Source string
Status string
Deadline time.Time
Warning time.Duration
}
func NewNote() *Note {
n := new(Note)
n.Id = rand.Int63()
n.Stamps = make([]time.Time, 0)
n.Status = ""
n.Deadline = nullTime
n.Warning = time.Duration(0)
return n
}
func (n *Note) IsValid() bool {
return len(strings.TrimSpace(n.Title)) > 0
}
func (n *Note) IsTodo() bool {
return n.Status == "TODO"
}
func (n *Note) HasDeadline(date time.Time) bool {
if n.Deadline == nullTime {
return false
}
return n.Deadline == date
}
func (n *Note) IsWarningTime() bool {
if n.Warning == 0 || n.Deadline == nullTime {
return true
}
warnTime := time.Now().Add(n.Warning)
return warnTime.After(n.Deadline)
}
func (n *Note) GetResumeBody() string {
words := strings.Fields(n.Body)
if len(words) < MAXWORDSRESUMEBODY {
return strings.Join(words, " ")
} else {
return ""
}
}
func (n *Note) GetTextBody() string {
body := Org2HTML([]byte(n.Body), "")
return body
}
// Return if a note have a stamp which happens in this day
func (n *Note) InDay(date time.Time) bool {
for _, stamp := range n.Stamps {
md := time.Date(date.Year(), date.Month(), date.Day(), 0, 0, 1, 0, time.UTC)
diffMd := int(stamp.Sub(md).Hours())
if stamp == date || (diffMd < 24 && diffMd >= 0) {
return true
}
}
return false
}
// Return the string part with the hour for the timestamp that happens
// in this day
func (n *Note) GetStampHour(date time.Time) string {
stamp := n.GetStampForDay(date)
if stamp.Hour() == 0 && stamp.Minute() == 0 {
return ""
}
return stamp.Format(HOURFORMATPRINT)
}
// Return the string part with the date for the timestamp that happens
// in this day
func (n *Note) GetStampDate(date time.Time) string {
stamp := n.GetStampForDay(date)
return stamp.Format(DATEFORMATFORHTML)
}
// Get the stamp of the note for this day
func (n *Note) GetStampForDay(date time.Time) time.Time {
for _, stamp := range n.Stamps {
if datesInSameDay(stamp, date) {
return stamp
}
}
return time.Date(1982, time.August, 20, 20, 45, 0, 0, time.UTC)
}
func (n *Note) String() string {
s := fmt.Sprintf("\n* %s %s\n", n.Status, n.Title)
for i := range n.Stamps {
s += fmt.Sprintf("\t<%s>\n", n.Stamps[i].Format(ORGDATEHOURFORMAT))
}
s += n.Body + "\n"
return s
}
// DayNotes sort a group of notes for a particular day
type DayNotes struct {
Date time.Time
Notes []Note
}
func NewDayNotes(date time.Time) *DayNotes {
dn := new(DayNotes)
dn.Notes = make([]Note, 0)
dn.Date = date
return dn
}
func (dn *DayNotes) Add(note Note) {
if note.InDay(dn.Date) {
dn.Notes = append(dn.Notes, note)
}
}
func (dn *DayNotes) Len() int {
return len(dn.Notes)
}
func (dn *DayNotes) Less(i, j int) bool {
return dn.Notes[i].GetStampForDay(dn.Date).Before(dn.Notes[j].GetStampForDay(dn.Date))
}
func (dn *DayNotes) Swap(i, j int) {
dn.Notes[i], dn.Notes[j] = dn.Notes[j], dn.Notes[i]
}
func datesInSameDay(date1, date2 time.Time) bool {
var md time.Time
var diffMd int
if date1.Before(date2) {
md = time.Date(date1.Year(), date1.Month(), date1.Day(), 0, 0, 1, 0, time.UTC)
diffMd = int(date2.Sub(md).Hours())
} else {
md = time.Date(date2.Year(), date2.Month(), date2.Day(), 0, 0, 1, 0, time.UTC)
diffMd = int(date1.Sub(md).Hours())
}
if date1 == date2 || (diffMd < 24 && diffMd >= 0) {
return true
}
return false
}
type Bookmark struct {
Url string
Text string
Desc string
Tags []string
}
func NewBookmark(note Note) Bookmark {
b := new(Bookmark)
b.Tags = make([]string, 0)
re := regexp.MustCompile("\\[\\[.+\\]\\]")
links := re.FindAllString(note.Title, 1)
if len(links) > 0 {
fields := strings.Split(strings.Trim(links[0], "[]"), "][")
b.Url = fields[0]
b.Text = fields[1]
}
tagsRe := regexp.MustCompile(":[a-zA-Z0-9:]+:")
tagsFind := tagsRe.FindAllString(note.Title, -1)
if len(tagsFind) > 0 {
b.Tags = strings.Split(tagsFind[0], ":")
}
return *b
}
| sdemingo/worgenda | model/notes/note.go | GO | agpl-3.0 | 4,350 | [
30522,
7427,
3964,
12324,
1006,
1000,
4718,
2102,
1000,
1000,
8785,
1013,
14566,
1000,
1000,
19723,
10288,
2361,
1000,
1000,
7817,
1000,
1000,
2051,
1000,
1007,
9530,
3367,
1006,
3058,
14192,
4017,
18150,
28689,
2213,
1027,
1000,
6185,
1013... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
<?php
$L = array();
$L["DATA_TYPE"] = array(
"NAME" => "Straat en huisnummer",
"DESC" => "Generates random street addresses."
);
$L["ap_num"] = "Ap #";
$L["po_box"] = "PO Box";
$L["street_types"] = "St., St., straat, weg, Rd., Rd., Ave, Av., Avenue";
| nickmoorman/generatedata | plugins/dataTypes/StreetAddress/lang/nl.php | PHP | gpl-3.0 | 261 | [
30522,
1026,
1029,
25718,
1002,
1048,
1027,
9140,
1006,
1007,
1025,
1002,
1048,
1031,
1000,
2951,
1035,
2828,
1000,
1033,
1027,
9140,
1006,
1000,
2171,
1000,
1027,
1028,
1000,
2358,
2527,
4017,
4372,
17504,
2015,
19172,
5017,
1000,
1010,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
/***************************************************************************//**
* @file PinNames.h
*******************************************************************************
* @section License
* <b>(C) Copyright 2015 Silicon Labs, http://www.silabs.com</b>
*******************************************************************************
*
* Permission is granted to anyone to use this software for any purpose,
* including commercial applications, and to alter it and redistribute it
* freely, subject to the following restrictions:
*
* 1. The origin of this software must not be misrepresented; you must not
* claim that you wrote the original software.
* 2. Altered source versions must be plainly marked as such, and must not be
* misrepresented as being the original software.
* 3. This notice may not be removed or altered from any source distribution.
*
* DISCLAIMER OF WARRANTY/LIMITATION OF REMEDIES: Silicon Labs has no
* obligation to support this Software. Silicon Labs is providing the
* Software "AS IS", with no express or implied warranties of any kind,
* including, but not limited to, any implied warranties of merchantability
* or fitness for any particular purpose or warranties against infringement
* of any proprietary rights of a third party.
*
* Silicon Labs will not be liable for any consequential, incidental, or
* special damages, or any other relief, or for any claim by any third party,
* arising from your use of this Software.
*
******************************************************************************/
#ifndef MBED_PINNAMES_H
#define MBED_PINNAMES_H
#include "cmsis.h"
#include "em_gpio.h"
#ifdef __cplusplus
extern "C" {
#endif
typedef enum {
PIN_INPUT = 0,
PIN_OUTPUT = 1
} PinDirection;
typedef enum {
/* EFM32 Pin Names
* First 4 bits represent pin number, the remaining
* bits represent port number (A = 0, B = 1, ...)
*/
PA0 = 0 << 4, PA1, PA2, PA3, PA4, PA5, PA6, PA7, PA8, PA9, PA10, PA11, PA12, PA13, PA14, PA15,
PB0 = 1 << 4, PB1, PB2, PB3, PB4, PB5, PB6, PB7, PB8, PB9, PB10, PB11, PB12, PB13, PB14, PB15,
PC0 = 2 << 4, PC1, PC2, PC3, PC4, PC5, PC6, PC7, PC8, PC9, PC10, PC11, PC12, PC13, PC14, PC15,
PD0 = 3 << 4, PD1, PD2, PD3, PD4, PD5, PD6, PD7, PD8, PD9, PD10, PD11, PD12, PD13, PD14, PD15,
PE0 = 4 << 4, PE1, PE2, PE3, PE4, PE5, PE6, PE7, PE8, PE9, PE10, PE11, PE12, PE13, PE14, PE15,
PF0 = 5 << 4, PF1, PF2, PF3, PF4, PF5, PF6, PF7, PF8, PF9, PF10, PF11, PF12, PF13, PF14, PF15,
/* Starter Kit says LED0 and LED1, but mbed expects 1 and 2. This way using 1 and 2 or 0 and 1 will work. */
LED0 = PC10,
LED1 = PC11,
LED2 = LED0,
LED3 = LED0,
LED4 = LED1,
/* Push Buttons */
SW0 = PC8,
SW1 = PC9,
BTN0 = SW0,
BTN1 = SW1,
/* Serial */
SERIAL_TX = PD7,
SERIAL_RX = PD6,
USBTX = PD4,
USBRX = PD5,
EFM_BC_EN = PA9,
/* Not connected */
NC = (int) 0xFFFFFFFF
} PinName;
/* 0x10 represents setting the DOUT register (see efm32 modes in ref. manual) */
typedef enum {
/* EFM32 pin modes */
Disabled = gpioModeDisabled,
DisabledPullUp = gpioModeDisabled | 0x10,
Input = gpioModeInput,
InputFilter = gpioModeInput | 0x10,
InputPullDown = gpioModeInputPull,
InputPullUp = gpioModeInputPull | 0x10,
InputPullFilterDown = gpioModeInputPullFilter,
InputPullFilterUp = gpioModeInputPullFilter | 0x10,
PushPull = gpioModePushPull,
PushPullDrive = gpioModePushPullDrive,
WiredOr = gpioModeWiredOr,
WiredOrPullDown = gpioModeWiredOrPullDown,
WiredAnd = gpioModeWiredAnd,
WiredAndFilter = gpioModeWiredAndFilter,
WiredAndPullUp = gpioModeWiredAndPullUp,
WiredAndPullUpFilter = gpioModeWiredAndPullUpFilter,
WiredAndDrive = gpioModeWiredAndDrive,
WiredAndDriveFilter = gpioModeWiredAndDriveFilter,
WiredAndDrivePullUp = gpioModeWiredAndDrivePullUp,
WiredAndDrivePullUpFilter = gpioModeWiredAndDrivePullUpFilter,
/* mbed modes:
* PullUp, PullDown, PullNone, OpenDrain
*
* mbed default digital input mode:
* PullDefault
*
* mbed default digital output mode:
* PullNone
*/
PullUp = InputPullUp,
PullDown = InputPullDown,
OpenDrain = WiredAnd,
PullNone = PushPull,
PullDefault = PushPull
} PinMode;
#ifdef __cplusplus
}
#endif
#endif
| jferreir/mbed | libraries/mbed/targets/hal/TARGET_Silicon_Labs/TARGET_EFM32/TARGET_EFM32ZG_STK3200/PinNames.h | C | apache-2.0 | 4,523 | [
30522,
1013,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
100... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
#!/usr/bin/env bash
git config --global user.name "Liam Morley"
git config --global user.email "liam@carpeliam.com"
git config --global core.excludesfile ~/.gitignore
git config --global help.autocorrect 1
| carpeliam/dotfiles | git_config.sh | Shell | mit | 208 | [
30522,
1001,
999,
1013,
2149,
2099,
1013,
8026,
1013,
4372,
2615,
24234,
21025,
2102,
9530,
8873,
2290,
1011,
1011,
3795,
5310,
1012,
2171,
1000,
8230,
20653,
1000,
30524,
2890,
21025,
2102,
9530,
8873,
2290,
1011,
1011,
3795,
2393,
1012,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
/*
* Copyright (c) 2013 Juniper Networks, Inc. All rights reserved.
*/
#include "inter_vn_stats.h"
#include <oper/interface.h>
#include <oper/mirror_table.h>
using namespace std;
InterVnStatsCollector::VnStatsSet *InterVnStatsCollector::Find(string vn) {
VnStatsMap::iterator it = inter_vn_stats_.find(vn);
if (it != inter_vn_stats_.end()) {
return it->second;
}
return NULL;
}
void InterVnStatsCollector::PrintAll() {
VnStatsMap::iterator it = inter_vn_stats_.begin();
while(it != inter_vn_stats_.end()) {
PrintVn(it->first);
it++;
}
}
void InterVnStatsCollector::PrintVn(string vn) {
VnStatsSet *stats_set;
VnStats *stats;
LOG(DEBUG, "...........Stats for Vn " << vn);
VnStatsMap::iterator it = inter_vn_stats_.find(vn);
if (it != inter_vn_stats_.end()) {
stats_set = it->second;
/* Remove all the elements of map entry value which is a set */
VnStatsSet::iterator stats_it = stats_set->begin();
while(stats_it != stats_set->end()) {
stats = *stats_it;
stats_it++;
LOG(DEBUG, " Other-VN " << stats->dst_vn);
LOG(DEBUG, " in_pkts " << stats->in_pkts << " in_bytes " << stats->in_bytes);
LOG(DEBUG, " out_pkts " << stats->out_pkts << " out_bytes " << stats->out_bytes);
}
}
}
void InterVnStatsCollector::Remove(string vn) {
VnStatsSet *stats_set;
VnStats *stats;
VnStatsMap::iterator it = inter_vn_stats_.find(vn);
if (it != inter_vn_stats_.end()) {
stats_set = it->second;
/* Remove the entry from the inter_vn_stats_ map */
inter_vn_stats_.erase(it);
/* Remove all the elements of map entry value which is a set */
VnStatsSet::iterator stats_it = stats_set->begin();
VnStatsSet::iterator del_it;
while(stats_it != stats_set->end()) {
stats = *stats_it;
delete stats;
del_it = stats_it;
stats_it++;
stats_set->erase(del_it);
}
delete stats_set;
}
}
void InterVnStatsCollector::UpdateVnStats(FlowEntry *fe, uint64_t bytes,
uint64_t pkts) {
string src_vn = fe->data.source_vn, dst_vn = fe->data.dest_vn;
if (!fe->data.source_vn.length())
src_vn = *FlowHandler::UnknownVn();
if (!fe->data.dest_vn.length())
dst_vn = *FlowHandler::UnknownVn();
if (fe->local_flow) {
VnStatsUpdateInternal(src_vn, dst_vn, bytes, pkts, true);
VnStatsUpdateInternal(dst_vn, src_vn, bytes, pkts, false);
} else {
if (fe->data.ingress) {
VnStatsUpdateInternal(src_vn, dst_vn, bytes, pkts, true);
} else {
VnStatsUpdateInternal(dst_vn, src_vn, bytes, pkts, false);
}
}
//PrintAll();
}
void InterVnStatsCollector::VnStatsUpdateInternal(string src_vn, string dst_vn,
uint64_t bytes, uint64_t pkts,
bool outgoing) {
VnStatsSet *stats_set;
VnStats *stats;
VnStatsMap::iterator it = inter_vn_stats_.find(src_vn);
if (it == inter_vn_stats_.end()) {
stats = new VnStats(dst_vn, bytes, pkts, outgoing);
stats_set = new VnStatsSet;
stats_set->insert(stats);
inter_vn_stats_.insert(make_pair(src_vn, stats_set));
} else {
stats_set = it->second;
VnStats key(dst_vn, 0, 0, false);
VnStatsSet::iterator stats_it = stats_set->find(&key);
if (stats_it == stats_set->end()) {
stats = new VnStats(dst_vn, bytes, pkts, outgoing);
stats_set->insert(stats);
} else {
stats = *stats_it;
if (outgoing) {
stats->out_bytes += bytes;
stats->out_pkts += pkts;
} else {
stats->in_bytes += bytes;
stats->in_pkts += pkts;
}
}
}
}
| sysbot/contrail-controller | src/vnsw/agent/uve/inter_vn_stats.cc | C++ | apache-2.0 | 4,028 | [
30522,
1013,
1008,
1008,
9385,
1006,
1039,
1007,
2286,
29425,
6125,
1010,
4297,
1012,
2035,
2916,
9235,
1012,
1008,
1013,
1001,
2421,
1000,
6970,
1035,
1058,
2078,
1035,
26319,
1012,
1044,
1000,
1001,
2421,
1026,
6728,
2121,
1013,
8278,
1... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
package puzzledice;
import gui.PuzzleEditPanel;
import gui.WindowMain;
import java.awt.Dimension;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import javax.swing.BoxLayout;
import javax.swing.DefaultComboBoxModel;
import javax.swing.JComboBox;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.SwingUtilities;
import com.mxgraph.view.mxGraph;
public class ORBlock extends PuzzleBlock {
private PuzzleBlock _optionBlock1, _optionBlock2;
private static int nextIndex = 0;
public static void reset() {
nextIndex = 0;
}
private String _optionName1, _optionName2;
public void setOptionName1(String value) {
_optionName1 = value;
}
public void setOptionName2(String value) {
_optionName2 = value;
}
private JComboBox _optionSelect1, _optionSelect2;
public ORBlock()
{
_name = "OR-Block-" + ++nextIndex;
_type = "OR Block";
JPanel editPanel = new JPanel();
editPanel.setLayout(new BoxLayout(editPanel, BoxLayout.Y_AXIS));
JPanel optionPanel1 = new JPanel();
optionPanel1.setLayout(new BoxLayout(optionPanel1, BoxLayout.X_AXIS));
JLabel optionLabel1 = new JLabel("Option 1:");
optionPanel1.add(optionLabel1);
_optionSelect1 = new JComboBox();
_optionSelect1.setMaximumSize(new Dimension(Integer.MAX_VALUE, _optionSelect1.getPreferredSize().height));
optionPanel1.add(_optionSelect1);
editPanel.add(optionPanel1);
JPanel optionPanel2 = new JPanel();
optionPanel2.setLayout(new BoxLayout(optionPanel2, BoxLayout.X_AXIS));
JLabel optionLabel2 = new JLabel("Option 2:");
optionPanel2.add(optionLabel2);
_optionSelect2 = new JComboBox();
_optionSelect2.setMaximumSize(new Dimension(Integer.MAX_VALUE, _optionSelect2.getPreferredSize().height));
optionPanel2.add(_optionSelect2);
editPanel.add(optionPanel2);
_editUI = editPanel;
_optionSelect1.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
if(_optionBlock1 == _optionSelect1.getSelectedItem() || _optionBlock1 == null && _optionSelect1.getSelectedItem().equals("None"))
return;
mxGraph puzzleGraph = WindowMain.getPuzzleGraph();
// Before anything, check for a cycle
if (_optionSelect1.getSelectedItem() != null && !_optionSelect1.getSelectedItem().equals("None")) {
PuzzleBlock block = (PuzzleBlock)_optionSelect1.getSelectedItem();
if (block.canReachBlockBackwards(ORBlock.this)) {
SwingUtilities.invokeLater(new Runnable() {
public void run() {
JOptionPane.showMessageDialog(null, "Error: Cannot add cycle to puzzle graph.");
}
});
if (_optionBlock1 != null)
_optionSelect1.setSelectedItem(_optionBlock1);
else
_optionSelect1.setSelectedIndex(0);
return;
}
}
// First, see if we need to remove a previous edge
if (_optionBlock1 != null) {
puzzleGraph.getModel().beginUpdate();
try { puzzleGraph.removeCells(puzzleGraph.getEdgesBetween(_optionBlock1.getGraphCell(), _graphCell, false)); }
finally { puzzleGraph.getModel().endUpdate(); }
}
if (_optionSelect1.getSelectedItem() == null)
_optionSelect1.setSelectedIndex(0);
if (_optionSelect1.getSelectedItem().equals("None"))
_optionBlock1 = null;
else {
_optionBlock1 = (PuzzleBlock)_optionSelect1.getSelectedItem();
// Update the graph with a new edge
puzzleGraph.getModel().beginUpdate();
try { puzzleGraph.insertEdge(puzzleGraph.getDefaultParent(), null, null, _optionBlock1.getGraphCell(), _graphCell); }
finally { puzzleGraph.getModel().endUpdate(); }
}
// Need to update our other option list
_optionSelect2.setModel(new DefaultComboBoxModel(makeComboBoxList2()));
// Update our selected values
if (_optionBlock2 == null)
_optionSelect2.setSelectedIndex(0);
else
_optionSelect2.setSelectedItem(_optionBlock2);
PuzzleEditPanel.resetTextualDescription();
WindowMain.updatePuzzleGraph();
}
});
_optionSelect2.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
if(_optionBlock2 == _optionSelect2.getSelectedItem() || _optionBlock2 == null && _optionSelect2.getSelectedItem().equals("None"))
return;
mxGraph puzzleGraph = WindowMain.getPuzzleGraph();
// Before anything, check for a cycle
if (_optionSelect2.getSelectedItem() != null && !_optionSelect2.getSelectedItem().equals("None")) {
PuzzleBlock block = (PuzzleBlock)_optionSelect2.getSelectedItem();
if (block.canReachBlockBackwards(ORBlock.this)) {
SwingUtilities.invokeLater(new Runnable() {
public void run() {
JOptionPane.showMessageDialog(null, "Error: Cannot add cycle to puzzle graph.");
}
});
if (_optionBlock2 != null)
_optionSelect2.setSelectedItem(_optionBlock2);
else
_optionSelect2.setSelectedIndex(0);
return;
}
}
// First, see if we need to remove a previous edge
if (_optionBlock2 != null) {
puzzleGraph.getModel().beginUpdate();
try { puzzleGraph.removeCells(puzzleGraph.getEdgesBetween(_optionBlock2.getGraphCell(), _graphCell, false)); }
finally { puzzleGraph.getModel().endUpdate(); }
}
if (_optionSelect2.getSelectedItem() == null)
_optionSelect2.setSelectedIndex(0);
if (_optionSelect2.getSelectedItem().equals("None"))
_optionBlock2 = null;
else {
_optionBlock2 = (PuzzleBlock)_optionSelect2.getSelectedItem();
// Update the graph with a new edge
puzzleGraph.getModel().beginUpdate();
try { puzzleGraph.insertEdge(puzzleGraph.getDefaultParent(), null, null, _optionBlock2.getGraphCell(), _graphCell); }
finally { puzzleGraph.getModel().endUpdate(); }
}
// Need to update our other option list
_optionSelect1.setModel(new DefaultComboBoxModel(makeComboBoxList1()));
// Update our selected values
if (_optionBlock1 == null)
_optionSelect1.setSelectedIndex(0);
else
_optionSelect1.setSelectedItem(_optionBlock1);
PuzzleEditPanel.resetTextualDescription();
WindowMain.updatePuzzleGraph();
}
});
}
@Override
public void update() {
// Update the UI comboBoxes
_optionSelect1.setModel(new DefaultComboBoxModel(makeComboBoxList1()));
// Update the selected values
if (_optionBlock1 == null)
_optionSelect1.setSelectedIndex(0);
else
_optionSelect1.setSelectedItem(_optionBlock1);
_optionSelect2.setModel(new DefaultComboBoxModel(makeComboBoxList2()));
if (_optionBlock2 == null)
_optionSelect2.setSelectedIndex(0);
else
_optionSelect2.setSelectedItem(_optionBlock2);
}
private Object[] makeComboBoxList1()
{
List<Object> retVal = new ArrayList<Object>();
PuzzleBlock[] blockList = PuzzleEditPanel.getBlockList();
retVal.add("None");
for (PuzzleBlock p : blockList) {
if (!p.equals(_optionSelect2.getSelectedItem()) && !p.equals(this))
retVal.add(p);
}
return retVal.toArray();
}
private Object[] makeComboBoxList2()
{
List<Object> retVal = new ArrayList<Object>();
PuzzleBlock[] blockList = PuzzleEditPanel.getBlockList();
retVal.add("None");
for (PuzzleBlock p : blockList) {
if (!p.equals(_optionSelect1.getSelectedItem()) && !p.equals(this))
retVal.add(p);
}
return retVal.toArray();
}
@Override
public void maybeRemoveRef(PuzzleBlock block)
{
if (block.equals(_optionBlock1)) {
_optionBlock1 = null;
_optionSelect1.setSelectedIndex(0);
}
if (block.equals(_optionBlock2)) {
_optionBlock2 = null;
_optionSelect2.setSelectedIndex(0);
}
}
@Override
public String getTextualDescription()
{
String retVal = "";
if (_optionBlock1 != null)
retVal += _optionBlock1.getTextualDescription();
if (_optionBlock2 != null)
retVal += _optionBlock2.getTextualDescription();
String input1 = (_optionBlock1 == null) ? "SOMETHING" : _optionBlock1.getOutputTempName();
String input2 = (_optionBlock2 == null) ? "SOMETHING" : _optionBlock2.getOutputTempName();
_outputTempName = "(" + input1 + " or " + input2 + ")";
return retVal;
}
@Override
public void attachBlocksToName(Map<String, AreaBlock> areas, Map<String, PuzzleBlock> puzzles)
{
mxGraph puzzleGraph = WindowMain.getPuzzleGraph();
if (_optionName1 != null) {
_optionBlock1 = puzzles.get(_optionName1);
puzzleGraph.getModel().beginUpdate();
try { puzzleGraph.insertEdge(puzzleGraph.getDefaultParent(), null, null, _optionBlock1.getGraphCell(), _graphCell); }
finally { puzzleGraph.getModel().endUpdate(); }
}
if (_optionName2 != null) {
_optionBlock2 = puzzles.get(_optionName2);
puzzleGraph.getModel().beginUpdate();
try { puzzleGraph.insertEdge(puzzleGraph.getDefaultParent(), null, null, _optionBlock2.getGraphCell(), _graphCell); }
finally { puzzleGraph.getModel().endUpdate(); }
}
this.update();
}
@Override
public PuzzleBlock[] getPuzzleInputs()
{
if (_optionBlock1 != null && _optionBlock2 != null)
return new PuzzleBlock[] { _optionBlock1, _optionBlock2 } ;
else if (_optionBlock1 != null)
return new PuzzleBlock[] { _optionBlock1 };
else if (_optionBlock2 != null)
return new PuzzleBlock[] { _optionBlock2 };
return new PuzzleBlock[0];
}
@Override
public String toXML()
{
String xml = "<ORBlock name=\"" + _name + "\" ";
if (_optionBlock1 != null)
xml += "option1=\"" + _optionBlock1.getName() + "\" ";
if (_optionBlock2 != null)
xml += "option2=\"" + _optionBlock2.getName() + "\" ";
xml += "/>";
return xml;
}
}
| alect/Puzzledice | Tools/PuzzleMapEditor/src/puzzledice/ORBlock.java | Java | mit | 9,826 | [
30522,
7427,
14909,
6610,
1025,
12324,
26458,
1012,
11989,
2098,
4183,
9739,
2884,
1025,
12324,
26458,
1012,
3332,
24238,
1025,
12324,
9262,
1012,
22091,
2102,
1012,
9812,
1025,
12324,
9262,
1012,
22091,
2102,
1012,
2724,
1012,
2895,
18697,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
/* Copyright 2020 The TensorFlow Authors. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
==============================================================================*/
#ifndef TENSORFLOW_COMPILER_XLA_CLIENT_LIB_LU_DECOMPOSITION_H_
#define TENSORFLOW_COMPILER_XLA_CLIENT_LIB_LU_DECOMPOSITION_H_
#include "tensorflow/compiler/xla/client/xla_builder.h"
#include "tensorflow/compiler/xla/xla_data.pb.h"
namespace xla {
// Computes the LU decomposition with partial pivoting of a batch of matrices.
//
// Given a (batched) matrix a with shape [..., m, n], computes the matrix
// decomposition A = P @ L @ U where P is a permutation matrix, L is a
// lower-triangular matrix with unit diagonal entries, and U is an
// upper-triangular matrix.
//
// L and U are returned as a single matrix [..., m, n] containing both L and U
// packed in the same array. The unit diagonal of L is not represented
// explicitly.
//
// The permutation matrix P is returned in two forms, both as `pivots`, which is
// an s32[..., min(m, n)] array that describes a sequence of row-swaps in the
// style of LAPACK's xGETRF API, and `permutation`, which is a s32[..., m] array
// which gives the permutation to apply to the rows. We return both
// representations because they are each useful for different purposes; `pivots`
// is useful for computing the sign of a determinant, whereas `permutation` can
// be used via a Gather operation to permute the rows of a matrix.
//
// This method is only implemented on TPU at the moment.
// TODO(b/168208200): the implementation only supports F32 arrays. Handle the
// complex case.
struct LuDecompositionResult {
// The LU decomposition, with both L and U packed into an array with shape
// [..., m, n].
XlaOp lu;
// An array of shape s32[..., min(m, n)] containing the pivot rows.
XlaOp pivots;
// An array of shape s32[..., m], containing an another representation of the
// pivots as a permutation.
XlaOp permutation;
};
LuDecompositionResult LuDecomposition(XlaOp a);
} // namespace xla
#endif // TENSORFLOW_COMPILER_XLA_CLIENT_LIB_LU_DECOMPOSITION_H_
| karllessard/tensorflow | tensorflow/compiler/xla/client/lib/lu_decomposition.h | C | apache-2.0 | 2,599 | [
30522,
1013,
1008,
9385,
12609,
1996,
23435,
12314,
6048,
1012,
2035,
2916,
9235,
1012,
7000,
2104,
1996,
15895,
6105,
1010,
2544,
1016,
1012,
1014,
1006,
1996,
1000,
6105,
1000,
1007,
1025,
2017,
2089,
2025,
2224,
2023,
5371,
3272,
1999,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
using Liath.ViewRanger.RequestBuilders;
using NUnit.Framework;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Liath.ViewRanger.Tests.RequestBuilderTests.GetTrackRequestTests
{
[TestFixture]
public class ConstructorTests
{
[Test]
public void Ensure_does_not_throw_when_all_parameters_supplied()
{
Assert.DoesNotThrow(() => new GetTrackRequest(Guid.NewGuid().ToString(), Guid.NewGuid().ToString()));
}
[Test]
public void Ensure_throw_when_applicationKey_not_supplied()
{
var ex = Assert.Throws<ArgumentNullException>(() => new GetTrackRequest(null, Guid.NewGuid().ToString()));
Assert.AreEqual("applicationKey", ex.ParamName);
}
[Test]
public void Check_service_is_correct()
{
Assert.AreEqual("getBBPositions", new GetTrackRequest(Guid.NewGuid().ToString(), Guid.NewGuid().ToString()).Service);
}
[Test]
public void Ensure_throw_when_address_not_supplied()
{
var ex = Assert.Throws<ArgumentNullException>(() => new GetTrackRequest(Guid.NewGuid().ToString(), null));
Assert.AreEqual("baseAddress", ex.ParamName);
}
}
}
| ardliath/viewranger | Liath.ViewRanger.Tests/RequestBuilderTests/GetTrackRequestTests/ConstructorTests.cs | C# | mit | 1,318 | [
30522,
2478,
22393,
2705,
1012,
3193,
24388,
2121,
1012,
5227,
8569,
23891,
2869,
1025,
2478,
16634,
4183,
1012,
7705,
1025,
2478,
2291,
1025,
2478,
2291,
1012,
6407,
1012,
12391,
1025,
2478,
2291,
1012,
11409,
4160,
1025,
2478,
2291,
1012,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
#include "Animated.hpp"
// Par Copie
Animated::Animated(const Animated& Cpy) :
sf::Sprite(Cpy)
{
myCurrentFrame = Cpy.myCurrentFrame;
myTime = Cpy.myTime;
myElapsedTime = Cpy.myElapsedTime;
Paused = Cpy.Paused;
myAnim = Cpy.myAnim;
myLoop = Cpy.myLoop;
}
// Par défault
Animated::Animated(bool Play, bool Loop, float Time)
{
myAnim = NULL;
myCurrentFrame = 0;
myTime = Time;
myElapsedTime = Time;
Paused = !Play;
myLoop = Loop;
}
// Directement avec une Anim
Animated::Animated(Anim* NewAnim, bool Play, bool Loop, float Time)
{
myTime = Time;
myElapsedTime = Time;
Paused = !Play;
myLoop = Loop;
myAnim = NewAnim;
SetFrame(0);
}
// Destructeur
Animated::~Animated()
{
}
// Comme 'SetImage', sauf qu'on lui fournit l'Anim
void Animated::SetAnim(Anim* NewAnim)
{
myAnim = NewAnim;
SetFrame(0);
}
// Retourne un pointeur sur l'anim
Anim* Animated::GetAnim()
{
return myAnim;
}
// Passer à l'image numéro X
void Animated::SetFrame(int Frame)
{
if ( myAnim != NULL)
{
if (myAnim->Size() > 0)
{
if ((*myAnim)[Frame].Image != NULL)
SetImage(*((*myAnim)[Frame].Image));
SetSubRect((*myAnim)[Frame].Rect);
SetColor((*myAnim)[Frame].Color);
myCurrentFrame = Frame;
}
}
}
//Retourne La frame courante
int Animated::GetCurrentFrame()
{
return myCurrentFrame;
}
// Fixer le temps entre chaques Frame
void Animated::SetFrameTime(float Time)
{
myTime = Time;
}
// retourne le temps entre chaques Frame
float Animated::GetFrameTime()
{
return myTime;
}
// Jouer en boucle ?
void Animated::SetLoop(bool Loop)
{
myLoop = Loop;
}
// Jouer en boucle ?
bool Animated::IsLoop()
{
return myLoop;
}
// Met en pause la lecture
void Animated::Pause()
{
Paused = true;
}
// Relance la lecture
void Animated::Play()
{
Paused = false;
}
// Met en pause la lecture, et 'rembobine'
void Animated::Stop()
{
SetFrame(0);
myElapsedTime = myTime;
Paused = true;
}
// Est En pause ?
bool Animated::IsPaused()
{
return Paused;
}
int Animated::Size()
{
return (int)myAnim->Size();
}
// Est Stoppé ?
bool Animated::IsStoped()
{
return (Paused and (myCurrentFrame == 0) and (myElapsedTime == myTime));
}
// Fonction à appeler à chaque tours de boucle, prend le temps
// écoulé depuis le dernier appel à la fonction en paramètre
void Animated::anim(float ElapsedTime)
{
// Si il n'est pas en pause et que l'animation est valide
if (!Paused and myAnim != NULL)
{
// on retranche le temps écoulé a notre compteur
myElapsedTime -= ElapsedTime;
// Si Le temps entre chaque frame est atteint
if (myElapsedTime <= 0.f)
{
// On réinitialise notre compteur
myElapsedTime = myTime;
// On passe a la frame suivante
if (myCurrentFrame + 1 < myAnim->Size())
++myCurrentFrame;
else
{
// Ou on a la premiere
if (myLoop)
myCurrentFrame = 0;
else
{
// Si le mode Loop est désactivé, on stop l'animation
Stop();
}
}
// On change la frame
SetFrame(myCurrentFrame);
}
}
}
| Krozark/Dethroned-God | SFML-1.6/Game/Animated.cpp | C++ | bsd-2-clause | 3,427 | [
30522,
1001,
2421,
1000,
6579,
1012,
6522,
2361,
1000,
1013,
1013,
11968,
8872,
2666,
6579,
1024,
1024,
6579,
1006,
9530,
3367,
6579,
1004,
18133,
2100,
1007,
1024,
16420,
1024,
1024,
11867,
17625,
1006,
18133,
2100,
1007,
1063,
2026,
10841... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
/*
* window.c - the PuTTY(tel) main program, which runs a PuTTY terminal
* emulator and backend in a window.
*/
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <time.h>
#include <limits.h>
#include <assert.h>
#ifndef NO_MULTIMON
#define COMPILE_MULTIMON_STUBS
#endif
#define PUTTY_DO_GLOBALS /* actually _define_ globals */
#include "putty.h"
#include "terminal.h"
#include "storage.h"
#include "win_res.h"
#ifndef NO_MULTIMON
#include <multimon.h>
#endif
#include <imm.h>
#include <commctrl.h>
#include <richedit.h>
#include <mmsystem.h>
/* From MSDN: In the WM_SYSCOMMAND message, the four low-order bits of
* wParam are used by Windows, and should be masked off, so we shouldn't
* attempt to store information in them. Hence all these identifiers have
* the low 4 bits clear. Also, identifiers should < 0xF000. */
#define IDM_SHOWLOG 0x0010
#define IDM_NEWSESS 0x0020
#define IDM_DUPSESS 0x0030
#define IDM_RESTART 0x0040
#define IDM_RECONF 0x0050
#define IDM_CLRSB 0x0060
#define IDM_RESET 0x0070
#define IDM_HELP 0x0140
#define IDM_ABOUT 0x0150
#define IDM_SAVEDSESS 0x0160
#define IDM_COPYALL 0x0170
#define IDM_FULLSCREEN 0x0180
#define IDM_PASTE 0x0190
#define IDM_SPECIALSEP 0x0200
#define IDM_SPECIAL_MIN 0x0400
#define IDM_SPECIAL_MAX 0x0800
#define IDM_SAVED_MIN 0x1000
#define IDM_SAVED_MAX 0x5000
#define MENU_SAVED_STEP 16
/* Maximum number of sessions on saved-session submenu */
#define MENU_SAVED_MAX ((IDM_SAVED_MAX-IDM_SAVED_MIN) / MENU_SAVED_STEP)
#define WM_IGNORE_CLIP (WM_APP + 2)
#define WM_FULLSCR_ON_MAX (WM_APP + 3)
#define WM_AGENT_CALLBACK (WM_APP + 4)
#define WM_GOT_CLIPDATA (WM_APP + 6)
/* Needed for Chinese support and apparently not always defined. */
#ifndef VK_PROCESSKEY
#define VK_PROCESSKEY 0xE5
#endif
/* Mouse wheel support. */
#ifndef WM_MOUSEWHEEL
#define WM_MOUSEWHEEL 0x020A /* not defined in earlier SDKs */
#endif
#ifndef WHEEL_DELTA
#define WHEEL_DELTA 120
#endif
static Mouse_Button translate_button(Mouse_Button button);
static LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
static int TranslateKey(UINT message, WPARAM wParam, LPARAM lParam,
unsigned char *output);
static void conftopalette(void);
static void systopalette(void);
static void init_palette(void);
static void init_fonts(int, int);
static void another_font(int);
static void deinit_fonts(void);
static void set_input_locale(HKL);
static void update_savedsess_menu(void);
static void init_flashwindow(void);
static int is_full_screen(void);
static void make_full_screen(void);
static void clear_full_screen(void);
static void flip_full_screen(void);
static int process_clipdata(HGLOBAL clipdata, int unicode);
/* Window layout information */
static void reset_window(int);
static int extra_width, extra_height;
static int font_width, font_height, font_dualwidth, font_varpitch;
static int offset_width, offset_height;
static int was_zoomed = 0;
static int prev_rows, prev_cols;
static int pending_netevent = 0;
static WPARAM pend_netevent_wParam = 0;
static LPARAM pend_netevent_lParam = 0;
static void enact_pending_netevent(void);
static void flash_window(int mode);
static void sys_cursor_update(void);
static int get_fullscreen_rect(RECT * ss);
static int caret_x = -1, caret_y = -1;
static int kbd_codepage;
static void *ldisc;
static Backend *back;
static void *backhandle;
static struct unicode_data ucsdata;
static int must_close_session, session_closed;
static int reconfiguring = FALSE;
static const struct telnet_special *specials = NULL;
static HMENU specials_menu = NULL;
static int n_specials = 0;
static wchar_t *clipboard_contents;
static size_t clipboard_length;
#define TIMING_TIMER_ID 1234
static long timing_next_time;
static struct {
HMENU menu;
} popup_menus[2];
enum { SYSMENU, CTXMENU };
static HMENU savedsess_menu;
Conf *conf; /* exported to windlg.c */
static void conf_cache_data(void);
int cursor_type;
int vtmode;
static struct sesslist sesslist; /* for saved-session menu */
struct agent_callback {
void (*callback)(void *, void *, int);
void *callback_ctx;
void *data;
int len;
};
#define FONT_NORMAL 0
#define FONT_BOLD 1
#define FONT_UNDERLINE 2
#define FONT_BOLDUND 3
#define FONT_WIDE 0x04
#define FONT_HIGH 0x08
#define FONT_NARROW 0x10
#define FONT_OEM 0x20
#define FONT_OEMBOLD 0x21
#define FONT_OEMUND 0x22
#define FONT_OEMBOLDUND 0x23
#define FONT_MAXNO 0x40
#define FONT_SHIFT 5
static HFONT fonts[FONT_MAXNO];
static LOGFONT lfont;
static int fontflag[FONT_MAXNO];
static enum {
BOLD_NONE, BOLD_SHADOW, BOLD_FONT
} bold_font_mode;
static int bold_colours;
static enum {
UND_LINE, UND_FONT
} und_mode;
static int descent;
#ifndef NCFGCOLOURS
#ifdef PERSOPORT
#define NCFGCOLOURS 34
#else
#define NCFGCOLOURS 22
#endif
#endif
#define NEXTCOLOURS 240
#define NALLCOLOURS (NCFGCOLOURS + NEXTCOLOURS)
static COLORREF colours[NALLCOLOURS];
static HPALETTE pal;
static LPLOGPALETTE logpal;
static RGBTRIPLE defpal[NALLCOLOURS];
static HBITMAP caretbm;
#ifdef HYPERLINKPORT
#include "urlhack.h"
static int urlhack_cursor_is_hand = 0;
void urlhack_enable(void);
#endif
#ifdef PERSOPORT
#include <process.h>
#include <math.h>
#include "../../kitty.h"
#include "../../kitty_commun.h"
#include "../../kitty_crypt.h"
#include "../../kitty_launcher.h"
#include "../../kitty_registry.h"
#include "../../kitty_ssh.h"
#include "../../kitty_tools.h"
#include "../../kitty_win.h"
void SendStrToTerminal( const char * str, const int len ) {
char c ;
int i ;
if( len <= 0 ) return ;
term_seen_key_event(term);
for( i=0 ; i<len ; i++ ) {
c=(unsigned char)str[i] ;
if (ldisc)
lpage_send(ldisc, CP_ACP, &c, 1, 1);
}
}
// resize en convertissant en nombre de lignes et colonnes
void resize( int height, int width ) {
int w,h;
if( width!=-1 ) {
prev_rows = term->rows;
prev_cols = term->cols;
w = width / font_width ;
if (w < 1) w = 1;
h = height / font_height ;
if (h < 1) h = 1;
}
else {
h = prev_rows ;
w = prev_cols ;
}
term_size(term, h, w, conf_get_int(conf,CONF_savelines)) ;
reset_window(0);
w = (width-conf_get_int(conf,CONF_window_border)*2) / font_width ;
if (w < 1) w = 1;
h = (height-conf_get_int(conf,CONF_window_border)*2) / font_height ;
if (h < 1) h = 1;
conf_set_int(conf,CONF_height,h);
conf_set_int(conf,CONF_width,w);
}
//`colours'
int return_offset_height(void) { return offset_height ; }
int return_offset_width(void) { return offset_width ; }
int return_font_height(void) { return font_height ; }
int return_font_width(void) { return font_width ; }
COLORREF return_colours258(void) { return colours[258]; }
// prototypes de fonctions decrites dans winnet.c
struct netscheduler_tag* netscheduler_new(void) ;
void netscheduler_free(struct netscheduler_tag* netscheduler) ;
#endif
#if (defined IMAGEPORT) && (!defined FDJ)
#include "../../kitty_image.h"
#endif
#ifdef RECONNECTPORT
static time_t last_reconnect = 0;
#endif
static int dbltime, lasttime, lastact;
static Mouse_Button lastbtn;
/* this allows xterm-style mouse handling. */
static int send_raw_mouse = 0;
static int wheel_accumulator = 0;
static int busy_status = BUSY_NOT;
static char *window_name, *icon_name;
static int compose_state = 0;
static UINT wm_mousewheel = WM_MOUSEWHEEL;
#define IS_HIGH_VARSEL(wch1, wch2) \
((wch1) == 0xDB40 && ((wch2) >= 0xDD00 && (wch2) <= 0xDDEF))
#define IS_LOW_VARSEL(wch) \
(((wch) >= 0x180B && (wch) <= 0x180D) || /* MONGOLIAN FREE VARIATION SELECTOR */ \
((wch) >= 0xFE00 && (wch) <= 0xFE0F)) /* VARIATION SELECTOR 1-16 */
/* Dummy routine, only required in plink. */
void ldisc_update(void *frontend, int echo, int edit)
{
}
char *get_ttymode(void *frontend, const char *mode)
{
return term_get_ttymode(term, mode);
}
static void start_backend(void)
{
const char *error;
char msg[1024], *title;
char *realhost;
int i;
/*
* Select protocol. This is farmed out into a table in a
* separate file to enable an ssh-free variant.
*/
back = backend_from_proto(conf_get_int(conf, CONF_protocol));
if (back == NULL) {
char *str = dupprintf("%s Internal Error", appname);
MessageBox(NULL, "Unsupported protocol number found",
str, MB_OK | MB_ICONEXCLAMATION);
sfree(str);
cleanup_exit(1);
}
error = back->init(NULL, &backhandle, conf,
conf_get_str(conf, CONF_host),
conf_get_int(conf, CONF_port),
&realhost,
conf_get_int(conf, CONF_tcp_nodelay),
conf_get_int(conf, CONF_tcp_keepalives));
back->provide_logctx(backhandle, logctx);
if (error) {
char *str = dupprintf("%s Error", appname);
sprintf(msg, "Unable to open connection to\n"
"%.800s\n" "%s", conf_dest(conf), error);
MessageBox(NULL, msg, str, MB_ICONERROR | MB_OK);
sfree(str);
exit(0);
}
window_name = icon_name = NULL;
title = conf_get_str(conf, CONF_wintitle);
if (!*title) {
sprintf(msg, "%s - %s", realhost, appname);
title = msg;
}
sfree(realhost);
set_title(NULL, title);
set_icon(NULL, title);
/*
* Connect the terminal to the backend for resize purposes.
*/
term_provide_resize_fn(term, back->size, backhandle);
/*
* Set up a line discipline.
*/
ldisc = ldisc_create(conf, term, back, backhandle, NULL);
/*
* Destroy the Restart Session menu item. (This will return
* failure if it's already absent, as it will be the very first
* time we call this function. We ignore that, because as long
* as the menu item ends up not being there, we don't care
* whether it was us who removed it or not!)
*/
for (i = 0; i < lenof(popup_menus); i++) {
DeleteMenu(popup_menus[i].menu, IDM_RESTART, MF_BYCOMMAND);
}
must_close_session = FALSE;
session_closed = FALSE;
}
static void close_session(void)
{
char morestuff[100];
int i;
session_closed = TRUE;
sprintf(morestuff, "%.70s (inactive)", appname);
set_icon(NULL, morestuff);
set_title(NULL, morestuff);
if (ldisc) {
ldisc_free(ldisc);
ldisc = NULL;
}
if (back) {
back->free(backhandle);
backhandle = NULL;
back = NULL;
term_provide_resize_fn(term, NULL, NULL);
update_specials_menu(NULL);
}
/*
* Show the Restart Session menu item. Do a precautionary
* delete first to ensure we never end up with more than one.
*/
for (i = 0; i < lenof(popup_menus); i++) {
DeleteMenu(popup_menus[i].menu, IDM_RESTART, MF_BYCOMMAND);
InsertMenu(popup_menus[i].menu, IDM_DUPSESS, MF_BYCOMMAND | MF_ENABLED,
IDM_RESTART, "&Restart Session");
}
/*
* Unset the 'must_close_session' flag, or else we'll come
* straight back here the next time we go round the main message
* loop - which, worse still, will be immediately (without
* blocking) because we've just triggered a WM_SETTEXT by the
* window title change above.
*/
must_close_session = FALSE;
}
#ifdef CYGTERMPORT
/* Copy at most n characters from src to dst or until copying a '\0'
* character. A pointer to the terminal '\0' in dst is returned, or if no
* '\0' was written, dst+n is returned. */
static char *
stpcpy_max(char *dst, const char *src, size_t n)
{
while (n-- && (*dst = *src++))
dst++;
return dst;
}
#endif
int WINAPI WinMain(HINSTANCE inst, HINSTANCE prev, LPSTR cmdline, int show)
{
WNDCLASS wndclass;
MSG msg;
HRESULT hr;
int guess_width, guess_height;
#ifdef ZMODEMPORT
struct netscheduler_tag *netsc;
#endif
hinst = inst;
hwnd = NULL;
flags = FLAG_VERBOSE | FLAG_INTERACTIVE;
sk_init();
InitCommonControls();
/* Ensure a Maximize setting in Explorer doesn't maximise the
* config box. */
defuse_showwindow();
if (!init_winver())
{
char *str = dupprintf("%s Fatal Error", appname);
MessageBox(NULL, "Windows refuses to report a version",
str, MB_OK | MB_ICONEXCLAMATION);
sfree(str);
return 1;
}
/*
* If we're running a version of Windows that doesn't support
* WM_MOUSEWHEEL, find out what message number we should be
* using instead.
*/
if (osVersion.dwMajorVersion < 4 ||
(osVersion.dwMajorVersion == 4 &&
osVersion.dwPlatformId != VER_PLATFORM_WIN32_NT))
wm_mousewheel = RegisterWindowMessage("MSWHEEL_ROLLMSG");
init_help();
init_flashwindow();
conf = conf_new();
#ifdef HYPERLINKPORT
urlhack_init();
#endif
#ifdef PERSOPORT
// Initialisation specifique a KiTTY
SethInstIcons( hinst ) ;
InitWinMain();
#endif
/*
* Initialize COM.
*/
hr = CoInitialize(NULL);
if (hr != S_OK && hr != S_FALSE) {
char *str = dupprintf("%s Fatal Error", appname);
MessageBox(NULL, "Failed to initialize COM subsystem",
str, MB_OK | MB_ICONEXCLAMATION);
sfree(str);
return 1;
}
/*
* Process the command line.
*/
{
char *p;
int got_host = 0;
/* By default, we bring up the config dialog, rather than launching
* a session. This gets set to TRUE if something happens to change
* that (e.g., a hostname is specified on the command-line). */
int allow_launch = FALSE;
default_protocol = be_default_protocol;
/* Find the appropriate default port. */
{
Backend *b = backend_from_proto(default_protocol);
default_port = 0; /* illegal */
if (b)
default_port = b->default_port;
}
conf_set_int(conf, CONF_logtype, LGTYP_NONE);
do_defaults(NULL, conf);
#ifdef PERSOPORT
// On cree la session "Default Settings" si elle n'existe pas
{ char buffer[1024] ; GetSessionFolderName( "Default Settings", buffer ) ;
if( strlen( buffer ) == 0 ) { save_settings( "Default Settings", conf ) ; }
}
#endif
p = cmdline;
/*
* Process a couple of command-line options which are more
* easily dealt with before the line is broken up into words.
* These are the old-fashioned but convenient @sessionname and
* the internal-use-only &sharedmemoryhandle, neither of which
* are combined with anything else.
*/
while (*p && isspace(*p))
p++;
if (*p == '@') {
/*
* An initial @ means that the whole of the rest of the
* command line should be treated as the name of a saved
* session, with _no quoting or escaping_. This makes it a
* very convenient means of automated saved-session
* launching, via IDM_SAVEDSESS or Windows 7 jump lists.
*/
int i = strlen(p);
while (i > 1 && isspace(p[i - 1]))
i--;
p[i] = '\0';
#ifdef PERSOPORT
if( DirectoryBrowseFlag ) {
char * pfolder ;
if( (pfolder=strstr(p+1," -folder \"")) ) {
pfolder[0]='\0';
pfolder += 10 ;
pfolder[strlen(pfolder)-1]='\0';
SetSessPath( pfolder ) ;
SetInitCurrentFolder( pfolder ) ;
}
}
#endif
do_defaults(p + 1, conf);
if (!conf_launchable(conf) && !do_config()) {
cleanup_exit(0);
}
allow_launch = TRUE; /* allow it to be launched directly */
} else if (*p == '&') {
/*
* An initial & means we've been given a command line
* containing the hex value of a HANDLE for a file
* mapping object, which we must then interpret as a
* serialised Conf.
*/
HANDLE filemap;
void *cp;
unsigned cpsize;
if (sscanf(p + 1, "%p:%u", &filemap, &cpsize) == 2 &&
(cp = MapViewOfFile(filemap, FILE_MAP_READ,
0, 0, cpsize)) != NULL) {
conf_deserialise(conf, cp, cpsize);
UnmapViewOfFile(cp);
CloseHandle(filemap);
} else if (!do_config()) {
cleanup_exit(0);
}
allow_launch = TRUE;
} else {
/*
* Otherwise, break up the command line and deal with
* it sensibly.
*/
int argc, i;
char **argv;
split_into_argv(cmdline, &argc, &argv, NULL);
for (i = 0; i < argc; i++) {
char *p = argv[i];
int ret;
ret = cmdline_process_param(p, i+1<argc?argv[i+1]:NULL,
1, conf);
if (ret == -2) {
cmdline_error("option \"%s\" requires an argument", p);
} else if (ret == 2) {
i++; /* skip next argument */
} else if (ret == 1) {
continue; /* nothing further needs doing */
#ifdef PERSOPORT
} else if( !strcmp(p, "-pass") ) {
i++ ;
char bufpass[1024] ;
strcpy( bufpass, argv[i] );
MASKPASS( bufpass ) ;
conf_set_str( conf, CONF_password, bufpass ) ; //strcpy( cfg.password, argv[i] ) ;
memset( bufpass, 0, strlen(bufpass) ) ;
memset( argv[i], 0, strlen(argv[i]) ) ;
#ifdef CYGTERMPORT
} else if( !strcmp(p, "-cc") ) {
conf_set_str( conf, CONF_host, "cmd.exe /k" ) ; // strcpy( cfg.host, "cmd.exe /k" ) ;
conf_set_int( conf, CONF_port, 0 ) ; //cfg.port = 0 ;
conf_set_int( conf, CONF_protocol, PROT_CYGTERM ) ; // cfg.protocol = PROT_CYGTERM ;
got_host = 1 ;
#endif
} else if( !strcmp(p, "-auto_store_sshkey") ) {
SetAutoStoreSSHKeyFlag( 1 ) ;
} else if( !strcmp(p, "-cmd") ) {
i++ ;
conf_set_str( conf, CONF_autocommand, argv[i] ) ; //strcpy( cfg.autocommand, argv[i] ) ;
//cfg.remote_cmd_ptr=argv[i] ;
} else if( !strcmp(p, "-debug") ) {
debug_flag = 1 ;
} else if( !strcmp(p, "-fullscreen") ) {
conf_set_int( conf, CONF_fullscreen, 1 ) ; //cfg.fullscreen = 1 ;
} else if( !strcmp(p, "-initdelay") ) {
i++ ;
init_delay = (int)(1000*atof( argv[i] )) ;
} else if( !strcmp(p, "-log") ) {
i++ ;
conf_set_filename( conf, CONF_logfilename,filename_from_str(argv[i])) ; // cfg.logfilename = filename_from_str( argv[i] ) ;
conf_set_int( conf, CONF_logtype,1 ) ; // cfg.logtype = 1 ;
conf_set_int( conf, CONF_logxfovr,1 ) ; // cfg.logxfovr = 1 ;
conf_set_int( conf, CONF_logflush,1 ) ; // cfg.logflush = 1 ;
} else if( !strcmp(p, "-nofiles") ) {
SetNoKittyFileFlag( 1 ) ;
} else if( !strcmp(p, "-edit") ) {
} else if( !strcmp(p, "-folder") ) {
char *pfolder ;
pfolder=p+7;
pfolder[0]='\0';
pfolder += 1 ;
if( pfolder[0]=='\"' ) pfolder++;
if( pfolder[strlen(pfolder)-1]=='\"' ) pfolder[strlen(pfolder)-1]='\0';
if( DirectoryBrowseFlag ) SetSessPath( pfolder ) ;
SetInitCurrentFolder( pfolder ) ;
i++ ;
} else if( !strcmp(p, "-version") || !strcmp(p, "-about") ) {
showabout(hwnd) ; exit( 0 ) ;
} else if( !strcmp(p, "-noicon") ) {
SetIconeFlag( -1 ) ;
} else if( !strcmp(p, "-notrans") ) {
SetTransparencyFlag( 0 ) ;
conf_set_int(conf,CONF_transparencynumber, -1) ;
#ifdef ZMODEMPORT
} else if( !strcmp(p, "-zmodem") ) {
SetZModemFlag( 1 ) ;
} else if( !strcmp(p, "-nozmodem") ) {
SetZModemFlag( 0 ) ;
#endif
#ifdef HYPERLINKPORT
#ifndef NO_HYPERLINK
} else if( !strcmp(p, "-hyperlink") ) {
HyperlinkFlag = 1 ;
} else if( !strcmp(p, "-nohyperlink") ) {
HyperlinkFlag = 0 ;
} else if( !strcmp(p, "-hyperlinkfix") ) {
FixWrongRegex();
#endif
#endif
} else if( !strcmp(p, "-xpos") ) {
i++ ;
if( atoi(argv[i])>=0 ) {
conf_set_int( conf, CONF_xpos,atoi(argv[i])); // cfg.xpos=atoi(argv[i]) ;
if( conf_get_int( conf, CONF_ypos)/*cfg.ypos*/<0 ) conf_set_int( conf, CONF_ypos,0); //cfg.ypos=0 ;
conf_set_int( conf, CONF_save_windowpos, 1 ) ; // cfg.save_windowpos=1 ;
}
} else if( !strcmp(p, "-ypos") ) {
i++ ;
if( atoi(argv[i])>=0 ) {
conf_set_int( conf, CONF_ypos, atoi(argv[i])); // cfg.ypos=atoi(argv[i]) ;
if( conf_get_int( conf, CONF_xpos)/*cfg.xpos*/<0) conf_set_int( conf, CONF_xpos,0); //cfg.xpos=0 ;
conf_set_int( conf, CONF_save_windowpos,1); //cfg.save_windowpos=1 ;
}
#if (defined IMAGEPORT) && (!defined FDJ)
} else if( !strcmp(p, "-nobgimage") ) {
BackgroundImageFlag = 0 ;
} else if( !strcmp(p, "-bgimage") ) {
BackgroundImageFlag = 1 ;
#endif
} else if( !strcmp(p, "-putty") ) {
SetAutoStoreSSHKeyFlag( 0 ) ;
SetUserPassSSHNoSave( 0 ) ;
SetNoKittyFileFlag( 1 ) ;
HyperlinkFlag = 0 ;
SetIconeFlag( -1 ) ;
SethInstIcons( hinst ) ;
SetTransparencyFlag( 0 ) ;
conf_set_int(conf,CONF_transparencynumber, -1) ;
SetShortcutsFlag( 0 ) ;
SetMouseShortcutsFlag( 0 ) ;
SetSizeFlag( 0 ) ;
SetCapsLockFlag( 0 ) ;
SetWinHeight( -1 ) ;
SetConfigBoxHeight( 7 ) ;
#ifdef CYGTERMPORT
cygterm_set_flag( 0 ) ;
#endif
#if (defined IMAGEPORT) && (!defined FDJ)
BackgroundImageFlag = 0 ;
#endif
SetSessionFilterFlag( 0 ) ;
PuttyFlag = 1 ;
//SetWindowPos(GetForegroundWindow(), HWND_TOP, 0, 0, 0, 252, SWP_SHOWWINDOW|SWP_NOMOVE);
} else if( !strcmp(p, "-send-to-tray") ) {
SetAutoSendToTray( 1 ) ;
} else if( !strcmp(p, "-sshhandler") ) {
CreateSSHHandler() ; return 0 ;
} else if( !strcmp(p, "-fileassoc") ) {
CreateFileAssoc() ; return 0 ;
#ifndef FDJ
} else if( !strcmp(p, "-key") ) {
GenerePrivateKey( "private.key.ppk" ) ; return 0 ;
#endif
} else if( !strcmp(p, "-ed") ) {
return Notepad_WinMain(inst, prev, cmdline, show) ;
#ifdef LAUNCHERPORT
} else if( !strcmp(p, "-launcher") ) {
return Launcher_WinMain(inst, prev, cmdline, show) ;
#endif
} else if( !strcmp(p, "-convert-dir") ) {
return Convert2Dir( ConfigDirectory ) ;
} else if( !strcmp(p, "-convert-reg") ) {
return Convert2Reg( ConfigDirectory ) ;
} else if( !strcmp(p, "-title") ) {
i++ ;
conf_set_str( conf, CONF_wintitle, argv[i] ); //strcpy( cfg.wintitle, argv[i] ) ;
#ifndef FDJ
} else if( !strcmp(p, "-classname") ) {
i++ ;
if( strlen( argv[i] ) > 0 ) {
strcpy( KiTTYClassName, argv[i] ) ;
appname = KiTTYClassName ;
}
#endif
} else if( !strcmp(p, "-sendcmd") ) {
i++ ;
if( strlen(argv[i])>0 )
SendCommandAllWindows( hwnd, argv[i] ) ;
exit(0);
} else if( !strcmp(p, "-kload") ) {
i++ ;
if( strlen(argv[i])>0 ) {
load_open_settings_forced( argv[i], conf ) ;
got_host=1;
}
} else if( !strcmp(p, "-loadfile") ) {
i++ ;
if( strlen(argv[i])>0 ) {
load_open_settings_forced( argv[i], conf ) ;
got_host=1;
}
#endif
} else if (!strcmp(p, "-cleanup") ||
!strcmp(p, "-cleanup-during-uninstall")) {
/*
* `putty -cleanup'. Remove all registry
* entries associated with PuTTY, and also find
* and delete the random seed file.
*/
char *s1, *s2;
/* Are we being invoked from an uninstaller? */
if (!strcmp(p, "-cleanup-during-uninstall")) {
s1 = dupprintf("Remove saved sessions and random seed file?\n"
"\n"
"If you hit Yes, ALL Registry entries associated\n"
"with %s will be removed, as well as the\n"
"random seed file. THIS PROCESS WILL\n"
"DESTROY YOUR SAVED SESSIONS.\n"
"(This only affects the currently logged-in user.)\n"
"\n"
"If you hit No, uninstallation will proceed, but\n"
"saved sessions etc will be left on the machine.",
appname);
s2 = dupprintf("%s Uninstallation", appname);
} else {
s1 = dupprintf("This procedure will remove ALL Registry entries\n"
"associated with %s, and will also remove\n"
"the random seed file. (This only affects the\n"
"currently logged-in user.)\n"
"\n"
"THIS PROCESS WILL DESTROY YOUR SAVED SESSIONS.\n"
"Are you really sure you want to continue?",
appname);
s2 = dupprintf("%s Warning", appname);
}
if (message_box(s1, s2,
MB_YESNO | MB_ICONWARNING | MB_DEFBUTTON2,
HELPCTXID(option_cleanup)) == IDYES) {
cleanup_all();
}
sfree(s1);
sfree(s2);
exit(0);
} else if (!strcmp(p, "-pgpfp")) {
pgp_fingerprints();
exit(1);
#ifdef CYGTERMPORT
/* A single "-" argument is interpreted as a "host name" */
} else if (p[0] != '-' || p[1] == '\0') {
#else
} else if (*p != '-') {
#endif
char *q = p;
if (got_host) {
/*
* If we already have a host name, treat
* this argument as a port number. NB we
* have to treat this as a saved -P
* argument, so that it will be deferred
* until it's a good moment to run it.
*/
int ret = cmdline_process_param("-P", p, 1, conf);
assert(ret == 2);
} else if (!strncmp(q, "telnet:", 7)) {
/*
* If the hostname starts with "telnet:",
* set the protocol to Telnet and process
* the string as a Telnet URL.
*/
char c;
q += 7;
if (q[0] == '/' && q[1] == '/')
q += 2;
conf_set_int(conf, CONF_protocol, PROT_TELNET);
p = q;
while (*p && *p != ':' && *p != '/')
p++;
c = *p;
if (*p)
*p++ = '\0';
if (c == ':')
conf_set_int(conf, CONF_port, atoi(p));
else
conf_set_int(conf, CONF_port, -1);
conf_set_str(conf, CONF_host, q);
got_host = 1;
#ifdef PERSOPORT
} else if (!strncmp(q, "ssh:", 4)) {
/*
* If the hostname starts with "ssh:",
* set the protocol to SSH and process
* the string as a SSH URL
*/
char c;
q += 4;
if (q[0] == '/' && q[1] == '/')
q += 2;
conf_set_int( conf, CONF_protocol, PROT_SSH); //cfg.protocol = PROT_SSH;
p = q;
while (*p && *p != ':' && *p != '/')
p++;
c = *p;
if (*p)
*p++ = '\0';
if (c == ':')
conf_set_int( conf,CONF_port,atoi(p)); //cfg.port = atoi(p);
else if( (c == '/')&&(strlen(p)>0) ) {
conf_set_int( conf,CONF_port,-1); // cfg.port = -1;
char * buf;
buf=(char*)malloc(strlen(p)+10);
strcpy(buf,p);
if( p[0]=='#' ) {
decryptstring( p+1, MASTER_PASSWORD ) ;
conf_set_str( conf,CONF_autocommand, p+1);
/* strcpy( cfg.autocommand, p+1 ) ;
decryptstring( cfg.autocommand, MASTER_PASSWORD ) ; */
}
else
{
int i = decode64(p) ; p[i]='\0';
conf_set_str(conf,CONF_autocommand,p);
/* strcpy( cfg.autocommand, p ) ;
int i = decode64(cfg.autocommand) ; cfg.autocommand[i]='\0'; */
}
free(buf);
}
else
conf_set_int( conf,CONF_port,-1) ; //cfg.port = -1;
char * buf;
buf=(char*)malloc( strlen(q)+10 );
strncpy(buf,q,strlen(q)+1);
buf[strlen(q)+1] = '\0' ;
conf_set_str( conf, CONF_host, buf);
/* strncpy(cfg.host, q, sizeof(cfg.host) - 1);
cfg.host[sizeof(cfg.host) - 1] = '\0'; */
free(buf);
got_host = 1;
} else if (!strncmp(q, "putty:", 4)) {
int ret = 0;
q += 6;
if (q[0] == '/' && q[1] == '/') q += 2;
if (q[strlen(q) - 1] == '/') q[strlen(q) - 1] = '\0';
p = q;
ret = cmdline_process_param("-load", p, 1, conf);//ret = cmdline_process_param("-load", p, 1, &cfg);
assert(ret == 2);
#endif
#ifdef CYGTERMPORT
} else if ( conf_get_int(conf,CONF_protocol) /*cfg.protocol*/ == PROT_CYGTERM) {
/* Concatenate all the remaining arguments separating
* them with spaces to get the command line to execute.
*/
//char *p = conf_get_str(conf,CONF_cygcmd) /*cfg.cygcmd*/;
//char *const end = conf_get_str(conf,CONF_cygcmd)/*cfg.cygcmd*/ + strlen( conf_get_str(conf,CONF_cygcmd) );
//char *const end = conf_get_str(conf,CONF_cygcmd)/*cfg.cygcmd*/ + sizeof conf_get_str(conf,CONF_cygcmd)/*cfg.cygcmd*/;
char *p,*pst;
pst=(char*)malloc(1000);
p=pst;
strcpy( p, conf_get_str(conf,CONF_cygcmd) );
char *const end = p + 1000 ;
for (; i < argc && p < end; i++) {
p = stpcpy_max(p, argv[i], end - p - 1);
*p++ = ' ';
}
assert(p > pst/*conf_get_str(conf,CONF_cygcmd)*//*cfg.cygcmd*/ && p <= end);
*--p = '\0';
got_host = 1;
conf_set_str( conf, CONF_cygcmd, pst );
free(pst);
#endif
} else {
/*
* Otherwise, treat this argument as a host
* name.
*/
while (*p && !isspace(*p))
p++;
if (*p)
*p++ = '\0';
conf_set_str(conf, CONF_host, q);
got_host = 1;
}
} else {
cmdline_error("unknown option \"%s\"", p);
}
}
}
#ifdef PERSOPORT
// Creation du fichier kitty.ini par defaut si besoin
CreateDefaultIniFile() ;
#endif
cmdline_run_saved(conf);
if (loaded_session || got_host)
allow_launch = TRUE;
if ((!allow_launch || !conf_launchable(conf)) && !do_config()) {
cleanup_exit(0);
}
/*
* Muck about with the hostname in various ways.
*/
{
char *hostbuf = dupstr(conf_get_str(conf, CONF_host));
char *host = hostbuf;
char *p, *q;
/*
* Trim leading whitespace.
*/
host += strspn(host, " \t");
/*
* See if host is of the form user@host, and separate
* out the username if so.
*/
if (host[0] != '\0') {
char *atsign = strrchr(host, '@');
if (atsign) {
*atsign = '\0';
conf_set_str(conf, CONF_username, host);
host = atsign + 1;
}
}
/*
* Trim a colon suffix off the hostname if it's there. In
* order to protect IPv6 address literals against this
* treatment, we do not do this if there's _more_ than one
* colon.
*/
{
char *c = strchr(host, ':');
if (c) {
char *d = strchr(c+1, ':');
if (!d)
*c = '\0';
}
}
/*
* Remove any remaining whitespace.
*/
p = hostbuf;
q = host;
while (*q) {
if (*q != ' ' && *q != '\t')
*p++ = *q;
q++;
}
*p = '\0';
conf_set_str(conf, CONF_host, hostbuf);
sfree(hostbuf);
}
}
#ifdef PERSOPORT
int xpos_init=0, ypos_init=0 ;
if( (conf_get_int(conf,CONF_saveonexit)||conf_get_int(conf,CONF_save_windowpos))
&& (conf_get_int(conf,CONF_xpos)>=0) && (conf_get_int(conf,CONF_ypos)>=0) ) {
xpos_init=conf_get_int(conf,CONF_xpos) ; //if( xpos_init>(GetSystemMetrics(SM_CXSCREEN)-10) ) xpos_init = 10 ;
ypos_init=conf_get_int(conf,CONF_ypos) ; //if( ypos_init>(GetSystemMetrics(SM_CYSCREEN)-10) ) ypos_init = 10 ;
}
while( conf_get_int(conf,CONF_icone)/*cfg.icone*/ > GetNumberOfIcons() ) {
conf_set_int( conf, CONF_icone, conf_get_int( conf, CONF_icone) - GetNumberOfIcons() ) ;
}
if( conf_get_int(conf,CONF_icone)/*cfg.icone*/ == 0 ) {
if( GetIconeFlag() > 0 ) SetIconeNum( time( NULL ) % GetNumberOfIcons() ) ; else SetIconeNum( 0 ) ;
} else{
if( GetIconeFlag() > 0 ) SetIconeNum( conf_get_int(conf,CONF_icone) - 1 ) ; else SetIconeNum( 0 ) ;
}
#endif
if (!prev) {
wndclass.style = 0;
wndclass.lpfnWndProc = WndProc;
wndclass.cbClsExtra = 0;
wndclass.cbWndExtra = 0;
wndclass.hInstance = inst;
#ifdef PERSOPORT
if (conf_get_int(conf, CONF_ctrl_tab_switch))
wndclass.cbWndExtra += 8;
if( GetIconeFlag() > 0 )
wndclass.hIcon = LoadIcon( GethInstIcons(), MAKEINTRESOURCE(IDI_MAINICON_0 + GetIconeNum() ) );
else
wndclass.hIcon = LoadIcon(inst, MAKEINTRESOURCE(IDI_MAINICON));
#else
wndclass.hIcon = LoadIcon(inst, MAKEINTRESOURCE(IDI_MAINICON));
#endif
wndclass.hCursor = LoadCursor(NULL, IDC_IBEAM);
wndclass.hbrBackground = NULL;
wndclass.lpszMenuName = NULL;
#if (defined PERSOPORT) && (!defined FDJ)
wndclass.lpszClassName = KiTTYClassName ;
#else
wndclass.lpszClassName = appname;
#endif
RegisterClass(&wndclass);
}
#ifdef PERSOPORT
// Initialisation de la structure NOTIFYICONDATA
TrayIcone.cbSize = sizeof(TrayIcone); // On alloue la taille necessaire pour la structure
TrayIcone.uID = IDI_MAINICON_0 ; // On lui donne un ID
TrayIcone.uFlags = NIF_ICON | NIF_TIP | NIF_MESSAGE; // On lui indique les champs valables
// On lui dit qu'il devra "ecouter" son environement (clique de souris, etc)
TrayIcone.uCallbackMessage = MYWM_NOTIFYICON;
TrayIcone.hIcon = LoadIcon(NULL, NULL); // On ne load aucune icone pour le moment
//TrayIcone.szTip[1024] = "PuTTY That\'s all folks!\0" ; // Le tooltip par defaut, soit rien
strcpy( TrayIcone.szTip, "PuTTY That\'s all folks!\0") ; // Le tooltip par defaut, soit rien
TrayIcone.hWnd = hwnd ;
#endif
memset(&ucsdata, 0, sizeof(ucsdata));
conf_cache_data();
conftopalette();
/*
* Guess some defaults for the window size. This all gets
* updated later, so we don't really care too much. However, we
* do want the font width/height guesses to correspond to a
* large font rather than a small one...
*/
font_width = 10;
font_height = 20;
extra_width = 25;
extra_height = 28;
guess_width = extra_width + font_width * conf_get_int(conf, CONF_width);
guess_height = extra_height + font_height*conf_get_int(conf, CONF_height);
{
RECT r;
get_fullscreen_rect(&r);
if (guess_width > r.right - r.left)
guess_width = r.right - r.left;
if (guess_height > r.bottom - r.top)
guess_height = r.bottom - r.top;
}
#if (defined IMAGEPORT) && (!defined FDJ)
const char* winname = appname;
#endif
{
int winmode = WS_OVERLAPPEDWINDOW | WS_VSCROLL;
int exwinmode = 0;
if (!conf_get_int(conf, CONF_scrollbar))
winmode &= ~(WS_VSCROLL);
if (conf_get_int(conf, CONF_resize_action) == RESIZE_DISABLED)
winmode &= ~(WS_THICKFRAME | WS_MAXIMIZEBOX);
if (conf_get_int(conf, CONF_alwaysontop))
exwinmode |= WS_EX_TOPMOST;
#ifdef TUTTYPORT
if (!conf_get_int(conf, CONF_window_has_sysmenu))
winmode &= ~(WS_SYSMENU);
if (!conf_get_int(conf, CONF_window_minimizable))
winmode &= ~(WS_MINIMIZEBOX);
if (!conf_get_int(conf, CONF_window_maximizable))
winmode &= ~(WS_MAXIMIZEBOX);
#endif
if (conf_get_int(conf, CONF_sunken_edge))
exwinmode |= WS_EX_CLIENTEDGE;
#ifdef PERSOPORT
#if (defined IMAGEPORT) && (!defined FDJ)
// TODO: This is the beginning of some work to have windows with fancy
// no-client-edge borders. It's not ready yet.
if( BackgroundImageFlag && (!PuttyFlag) )
if(0)
{
winmode = WS_POPUP;
exwinmode = 0;
winname = NULL;
// TODO: This is proof-of-concept. For this to really work, we'll
// have to do some additional mods, like creating our own title/move
// window to glue to the top, and some kind of drag-resizing window
// to glue to the bottom-right. Otherwise there'll be no way to move
// or resize the window, which will get old extremely quickly. Finally,
// this won't work as written anyway, b/c when you call SetWindowText
// anywhere Win32 forces a window border to appear anyway. So, we'll
// want to create a new function, set_window_text, that checks whether
// to really call SetWindowText or to set the window text in whatever
// other location is necessary for our custom window text display for
// when we're handling our own border here.
}
hwnd = CreateWindowEx(exwinmode|WS_EX_ACCEPTFILES, appname, winname,
winmode, CW_USEDEFAULT, CW_USEDEFAULT,
guess_width, guess_height,
NULL, NULL, inst, NULL);
if( BackgroundImageFlag ) init_dc_blend();
#else
hwnd = CreateWindowEx(exwinmode|WS_EX_ACCEPTFILES, appname, appname,
winmode, CW_USEDEFAULT, CW_USEDEFAULT,
guess_width, guess_height,
NULL, NULL, inst, NULL);
#endif
#else
hwnd = CreateWindowEx(exwinmode, appname, appname,
winmode, CW_USEDEFAULT, CW_USEDEFAULT,
guess_width, guess_height,
NULL, NULL, inst, NULL);
#endif
}
/*
* Initialise the fonts, simultaneously correcting the guesses
* for font_{width,height}.
*/
init_fonts(0,0);
/*
* Initialise the terminal. (We have to do this _after_
* creating the window, since the terminal is the first thing
* which will call schedule_timer(), which will in turn call
* timer_change_notify() which will expect hwnd to exist.)
*/
term = term_init(conf, &ucsdata, NULL);
logctx = log_init(NULL, conf);
term_provide_logctx(term, logctx);
term_size(term, conf_get_int(conf, CONF_height),
conf_get_int(conf, CONF_width),
conf_get_int(conf, CONF_savelines));
/*
* Correct the guesses for extra_{width,height}.
*/
{
RECT cr, wr;
GetWindowRect(hwnd, &wr);
GetClientRect(hwnd, &cr);
offset_width = offset_height = conf_get_int(conf, CONF_window_border);
extra_width = wr.right - wr.left - cr.right + cr.left + offset_width*2;
extra_height = wr.bottom - wr.top - cr.bottom + cr.top +offset_height*2;
}
/*
* Resize the window, now we know what size we _really_ want it
* to be.
*/
guess_width = extra_width + font_width * term->cols;
guess_height = extra_height + font_height * term->rows;
SetWindowPos(hwnd, NULL, 0, 0, guess_width, guess_height,
SWP_NOMOVE | SWP_NOREDRAW | SWP_NOZORDER);
#ifdef PERSOPORT
if( !PuttyFlag )
if( (conf_get_int(conf,CONF_saveonexit)/*cfg.saveonexit*/||conf_get_int(conf,CONF_save_windowpos)/*cfg.save_windowpos*/)
&& (xpos_init>=0) && (ypos_init>=0) ) {
MoveWindow(hwnd, xpos_init, ypos_init, guess_width, guess_height, TRUE );
}
#endif
/*
* Set up a caret bitmap, with no content.
*/
{
char *bits;
int size = (font_width + 15) / 16 * 2 * font_height;
bits = snewn(size, char);
memset(bits, 0, size);
caretbm = CreateBitmap(font_width, font_height, 1, 1, bits);
sfree(bits);
}
CreateCaret(hwnd, caretbm, font_width, font_height);
/*
* Initialise the scroll bar.
*/
{
SCROLLINFO si;
si.cbSize = sizeof(si);
si.fMask = SIF_ALL | SIF_DISABLENOSCROLL;
si.nMin = 0;
si.nMax = term->rows - 1;
si.nPage = term->rows;
si.nPos = 0;
SetScrollInfo(hwnd, SB_VERT, &si, FALSE);
}
/*
* Prepare the mouse handler.
*/
lastact = MA_NOTHING;
lastbtn = MBT_NOTHING;
dbltime = GetDoubleClickTime();
/*
* Set up the session-control options on the system menu.
*/
{
HMENU m;
int j;
char *str;
popup_menus[SYSMENU].menu = GetSystemMenu(hwnd, FALSE);
#ifdef TUTTYPORT
EnableMenuItem(popup_menus[SYSMENU].menu, SC_CLOSE, conf_get_int(conf,CONF_window_closable) ? MF_ENABLED : MF_GRAYED);
#endif
popup_menus[CTXMENU].menu = CreatePopupMenu();
AppendMenu(popup_menus[CTXMENU].menu, MF_ENABLED, IDM_PASTE, "&Paste");
savedsess_menu = CreateMenu();
get_sesslist(&sesslist, TRUE);
update_savedsess_menu();
for (j = 0; j < lenof(popup_menus); j++) {
m = popup_menus[j].menu;
AppendMenu(m, MF_SEPARATOR, 0, 0);
#ifdef PERSOPORT
if( !PuttyFlag ) InitSpecialMenu( m, conf_get_str(conf,CONF_folder)/*cfg.folder*/, conf_get_str(conf,CONF_sessionname)/*cfg.sessionname*/ ) ;
#endif
AppendMenu(m, MF_ENABLED, IDM_SHOWLOG, "&Event Log");
AppendMenu(m, MF_SEPARATOR, 0, 0);
AppendMenu(m, MF_ENABLED, IDM_NEWSESS, "Ne&w Session...");
AppendMenu(m, MF_ENABLED, IDM_DUPSESS, "&Duplicate Session");
AppendMenu(m, MF_POPUP | MF_ENABLED, (UINT) savedsess_menu,
"Sa&ved Sessions");
AppendMenu(m, MF_ENABLED, IDM_RECONF, "Chan&ge Settings...");
AppendMenu(m, MF_SEPARATOR, 0, 0);
AppendMenu(m, MF_ENABLED, IDM_COPYALL, "C&opy All to Clipboard");
AppendMenu(m, MF_ENABLED, IDM_CLRSB, "C&lear Scrollback");
AppendMenu(m, MF_ENABLED, IDM_RESET, "Rese&t Terminal");
AppendMenu(m, MF_SEPARATOR, 0, 0);
AppendMenu(m, (conf_get_int(conf, CONF_resize_action)
== RESIZE_DISABLED) ? MF_GRAYED : MF_ENABLED,
IDM_FULLSCREEN, "&Full Screen");
#ifdef PERSOPORT
if( !PuttyFlag ) {
AppendMenu(m, MF_ENABLED, IDM_PRINT, "Print clip&board");
AppendMenu(m, MF_ENABLED, IDM_TOTRAY, "Send to tra&y");
if( conf_get_int(conf,CONF_alwaysontop)/*cfg.alwaysontop*/ )
AppendMenu(m, MF_ENABLED|MF_CHECKED, IDM_VISIBLE, "Always visi&ble");
else
AppendMenu(m, MF_ENABLED, IDM_VISIBLE, "Always visi&ble");
AppendMenu(m, MF_ENABLED, IDM_PROTECT, "Prote&ct");
AppendMenu(m, MF_ENABLED, IDM_WINROL, "Roll-u&p");
AppendMenu(m, MF_ENABLED, IDM_SCRIPTFILE, "Send scr&ipt file" ) ;
if( PSCPPath!=NULL ) AppendMenu(m, MF_ENABLED, IDM_PSCP, "Send wit&h pscp");
else AppendMenu(m, MF_DISABLED|MF_GRAYED, IDM_PSCP, "Send wit&h pscp");
if( WinSCPPath!=NULL ) AppendMenu(m, MF_ENABLED, IDM_WINSCP, "&Start WinSCP");
else AppendMenu(m, MF_DISABLED|MF_GRAYED, IDM_WINSCP, "&Start WinSCP");
AppendMenu(m, MF_ENABLED, IDM_SHOWPORTFWD, "Po&rt forwarding");
AppendMenu(m, MF_SEPARATOR, 0, 0);
AppendMenu(m, MF_ENABLED, IDM_EXPORTSETTINGS, "Export ¤t settings" ) ;
}
#endif
#ifdef ZMODEMPORT
if( (!PuttyFlag) && GetZModemFlag() ) {
AppendMenu(m, MF_SEPARATOR, 0, 0);
AppendMenu(m, term->xyz_transfering?MF_GRAYED:MF_ENABLED, IDM_XYZSTART, "&Zmodem Receive");
AppendMenu(m, term->xyz_transfering?MF_GRAYED:MF_ENABLED, IDM_XYZUPLOAD, "Zmodem &Upload");
AppendMenu(m, !term->xyz_transfering?MF_GRAYED:MF_ENABLED, IDM_XYZABORT, "Zmodem &Abort");
}
#endif
AppendMenu(m, MF_SEPARATOR, 0, 0);
if (has_help())
AppendMenu(m, MF_ENABLED, IDM_HELP, "&Help");
str = dupprintf("&About %s", appname);
AppendMenu(m, MF_ENABLED, IDM_ABOUT, str);
sfree(str);
}
}
#ifdef PERSOPORT
// SETTINGS specifique a la session
if( !PuttyFlag ) {
// Lancement automatique dans le Tray
if( conf_get_int(conf,CONF_sendtotray)/*cfg.sendtotray*/ ) SetAutoSendToTray( 1 ) ;
// Charge le fichier de script d'initialisation si il existe
ScriptFileContent = NULL ;
ReadInitScript( NULL ) ;
// Lancement du serveur de chat
static char reg_buffer[256];
if( ReadParameter( INIT_SECTION, "chat", reg_buffer ) )
{
int chat_flag = atoi( reg_buffer ) ;
if ( chat_flag > 0 ) {
if( chat_flag != 1 ) PORT = chat_flag ; _beginthread( routine_server, 0, NULL ) ;
//if( chat_flag == 1 ) chat_flag = 1987 ; server_run_routine( chat_flag, 2 ) ;
}
}
// Parametrage specifique a la session
if( GetSessionField( conf_get_str(conf,CONF_sessionname)/*cfg.sessionname*/, conf_get_str(conf,CONF_folder)/*cfg.folder*/, "InitDelay", reg_buffer ) ) {
if( init_delay != (int)(1000*atof( reg_buffer ) ) ) {
init_delay = (int)(1000*atof( reg_buffer ) ) ;
conf_set_int(conf,CONF_initdelay,init_delay)/*cfg.initdelay = atof( reg_buffer )*/ ;
}
}
if( GetSessionField( conf_get_str(conf,CONF_sessionname)/*cfg.sessionname*/, conf_get_str(conf,CONF_folder)/*cfg.folder*/, "BCDelay", reg_buffer ) ) {
if( between_char_delay != atof( reg_buffer ) ) {
between_char_delay = atof( reg_buffer ) ;
conf_set_int(conf,CONF_bcdelay, atof( reg_buffer ) ); //cfg.bcdelay = atof( reg_buffer ) ;
}
}
#ifndef NO_TRANSPARENCY
if( GetTransparencyFlag() && conf_get_int(conf,CONF_transparencynumber)/*cfg.transparencynumber*/ != -1 ) {
if( conf_get_int(conf,CONF_transparencynumber)/*cfg.transparencynumber*/ > 0 ) {
SetTransparency( hwnd, 255-conf_get_int(conf,CONF_transparencynumber)/*cfg.transparencynumber*/ ) ;
}
}
#endif
// Lancement du timer auto-command pour les connexions non SSH
if(conf_get_int(conf,CONF_protocol)/*cfg.protocol*/ != PROT_SSH) backend_connected = 1 ;
SetTimer(hwnd, TIMER_INIT, init_delay, NULL) ;
if( IniFileFlag == SAVEMODE_REG ) {
sprintf( reg_buffer, "%s@%s:%d (prot=%d) name=%s", conf_get_str(conf,CONF_username)/*cfg.username*/, conf_get_str(conf,CONF_host)/*cfg.host*/, conf_get_int(conf,CONF_port)/*cfg.port*/, conf_get_int(conf,CONF_protocol)/*cfg.protocol*/, conf_get_str(conf,CONF_sessionname)/*cfg.sessionname*/) ;
cryptstring( reg_buffer, MASTER_PASSWORD ) ;
WriteParameter( INIT_SECTION, "KiLastSe", reg_buffer ) ;
}
// Lancement des timer (changement image de fond, rafraichissement)
#if (defined IMAGEPORT) && (!defined FDJ)
if( (!BackgroundImageFlag) || PuttyFlag ) conf_set_int(conf,CONF_bg_type,0); //cfg.bg_type = 0 ;
if( conf_get_int(conf,CONF_bg_type)/*cfg.bg_type*/!=0 ) {
if(conf_get_int(conf,CONF_bg_slideshow)/*cfg.bg_slideshow*/>0)
SetTimer(hwnd, TIMER_SLIDEBG, (int)(conf_get_int(conf,CONF_bg_slideshow)/*cfg.bg_slideshow*/*1000), NULL) ;
else
if(ImageSlideDelay>0)
SetTimer(hwnd, TIMER_SLIDEBG, (int)(ImageSlideDelay*1000), NULL) ;
}
// Lancement du rafraichissement toutes les 10 secondes (pour l'image de fond, pour pallier bug d'affichage)
if( ReadParameter( INIT_SECTION, "redraw", reg_buffer ) ) {
if( stricmp( reg_buffer, "NO" ) ) SetTimer(hwnd, TIMER_REDRAW, (int)(10*1000), NULL) ;
}
else SetTimer(hwnd, TIMER_REDRAW, (int)(10*1000), NULL) ;
#endif
} // fin de if( !PuttyFlag )
#ifdef HYPERLINKPORT
else {
conf_set_int(conf,CONF_url_underline,URLHACK_UNDERLINE_NEVER);//cfg.url_underline = URLHACK_UNDERLINE_NEVER ;
}
#endif
#endif
#ifdef PORTKNOCKINGPORT
ManagePortKnocking(conf_get_str(conf,CONF_host),conf_get_str(conf,CONF_portknockingoptions));
#endif
start_backend();
#ifdef HYPERLINKPORT
/*
* HACK: PuttyTray / Nutty
* Hyperlink stuff: Set the regular expression
*/
if( !PuttyFlag && HyperlinkFlag ) {
if( strlen( conf_get_str(conf,CONF_url_regex))==0 ) { conf_set_str(conf,CONF_url_regex,"@°@°@NO REGEX--") ; }
if( strlen( conf_get_str(term->conf,CONF_url_regex))==0 ) { conf_set_str(term->conf,CONF_url_regex,"@°@°@NO REGEX--") ; }
if( conf_get_int(term->conf,CONF_url_defregex) != 0 ) {
urlhack_set_regular_expression(URLHACK_REGEX_CLASSIC, conf_get_str(term->conf,CONF_url_regex) ) ;
} else {
urlhack_set_regular_expression(URLHACK_REGEX_CUSTOM, conf_get_str(term->conf, CONF_url_regex) ) ;
}
}
#endif
/*
* Set up the initial input locale.
*/
set_input_locale(GetKeyboardLayout(0));
/*
* Finally show the window!
*/
ShowWindow(hwnd, show);
SetForegroundWindow(hwnd);
/*
* Set the palette up.
*/
pal = NULL;
logpal = NULL;
init_palette();
term_set_focus(term, GetForegroundWindow() == hwnd);
UpdateWindow(hwnd);
#ifdef ZMODEMPORT
netsc = netscheduler_new();
#endif
while (1) {
HANDLE *handles;
int nhandles, n;
handles = handle_get_events(&nhandles);
n = MsgWaitForMultipleObjects(nhandles, handles, FALSE, INFINITE,
QS_ALLINPUT);
if ((unsigned)(n - WAIT_OBJECT_0) < (unsigned)nhandles) {
handle_got_event(handles[n - WAIT_OBJECT_0]);
sfree(handles);
if (must_close_session)
#ifdef PERSOPORT
{ close_session(); must_close_session = FALSE; }
#else
close_session();
#endif
#ifdef ZMODEMPORT
if( GetZModemFlag() ) continue;
#endif
} else
sfree(handles);
while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) {
if (msg.message == WM_QUIT)
goto finished; /* two-level break */
if (!(IsWindow(logbox) && IsDialogMessage(logbox, &msg)))
DispatchMessage(&msg);
/* Send the paste buffer if there's anything to send */
term_paste(term);
#ifdef ZMODEMPORT
if( GetZModemFlag() && xyz_Process(back, backhandle, term))
continue;
#endif
/* If there's nothing new in the queue then we can do everything
* we've delayed, reading the socket, writing, and repainting
* the window.
*/
if (must_close_session)
#ifdef PERSOPORT
{ close_session(); must_close_session = FALSE; }
#else
close_session();
#endif
}
/* The messages seem unreliable; especially if we're being tricky */
term_set_focus(term, GetForegroundWindow() == hwnd);
if (pending_netevent)
enact_pending_netevent();
net_pending_errors();
}
finished:
#ifdef ZMODEMPORT
netscheduler_free(netsc);
#endif
cleanup_exit(msg.wParam); /* this doesn't return... */
return msg.wParam; /* ... but optimiser doesn't know */
}
/*
* Clean up and exit.
*/
void cleanup_exit(int code)
{
/*
* Clean up.
*/
#ifdef PERSOPORT
chdir( InitialDirectory ) ;
if( conf_get_int(conf,CONF_saveonexit)/*cfg.saveonexit*/ ) { SaveWindowCoord( conf/*cfg*/ ) ; }
if( IniFileFlag == SAVEMODE_REG ) { // Mode de sauvegarde registry
//SaveRegistryKey() ;
#ifndef FDJ
if( RegTestKey( HKEY_CURRENT_USER, "Software\\SimonTatham\\PuTTY" ) )
RepliqueToPuTTY( PUTTY_REG_POS ) ; // Sauvegarde la conf dans Putty (uniquement si elle existe)
#endif
}
else if( IniFileFlag == SAVEMODE_FILE ) { // Mode de sauvegarde fichier
int nb ;
nb = WindowsCount( MainHwnd ) ;
if( nb == 1 ) { // c'est la derniere instance de kitty on vide la cle de registre
HWND hdlg = InfoBox( hinst, NULL ) ;
InfoBoxSetText( hdlg, "Cleaning registry" ) ;
RegDelTree( HKEY_CURRENT_USER, TEXT(PUTTY_REG_POS) ) ;
if( RegTestKey( HKEY_CURRENT_USER, TEXT(PUTTY_REG_POS_SAVE) ) ) {
InfoBoxSetText( hdlg, "Restoring backup registry" ) ;
RegRenameTree( NULL, HKEY_CURRENT_USER, TEXT(PUTTY_REG_POS_SAVE), TEXT(PUTTY_REG_POS) ) ;
}
else DelRegistryKey() ;
InfoBoxClose( hdlg ) ;
}
}
/*
Embryon de mecanisme de retour a la config box en sortant d'une session.
Le probleme est que ca retourne a la config box aussi en sortant ... de la config box si une session est chargee ...
*/
if( !PuttyFlag && GetConfigBoxNoExitFlag() )
if( backend_connected && strlen(conf_get_str(conf,CONF_sessionname))>0 ) {
char buffer[4096]="",shortname[1024]="" ; ;
if( GetModuleFileName( NULL, (LPTSTR)buffer, 1023 ) )
if( GetShortPathName( buffer, shortname, 1023 ) ) {
STARTUPINFO si ;
PROCESS_INFORMATION pi ;
ZeroMemory( &si, sizeof(si) );
si.cb = sizeof(si);
ZeroMemory( &pi, sizeof(pi) );
if( !CreateProcess(NULL, shortname, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi) ) ;
}
}
#endif
#ifdef HYPERLINKPORT
urlhack_cleanup();
#endif
deinit_fonts();
sfree(logpal);
if (pal)
DeleteObject(pal);
sk_cleanup();
if (conf_get_int(conf, CONF_protocol) == PROT_SSH) {
random_save_seed();
#ifdef MSCRYPTOAPI
crypto_wrapup();
#endif
}
shutdown_help();
/* Clean up COM. */
CoUninitialize();
exit(code);
}
/*
* Set up, or shut down, an AsyncSelect. Called from winnet.c.
*/
char *do_select(SOCKET skt, int startup)
{
int msg, events;
if (startup) {
msg = WM_NETEVENT;
events = (FD_CONNECT | FD_READ | FD_WRITE |
FD_OOB | FD_CLOSE | FD_ACCEPT);
} else {
msg = events = 0;
}
if (!hwnd)
return "do_select(): internal error (hwnd==NULL)";
if (p_WSAAsyncSelect(skt, hwnd, msg, events) == SOCKET_ERROR) {
switch (p_WSAGetLastError()) {
case WSAENETDOWN:
return "Network is down";
default:
return "WSAAsyncSelect(): unknown error";
}
}
return NULL;
}
/*
* Refresh the saved-session submenu from `sesslist'.
*/
static void update_savedsess_menu(void)
{
int i;
while (DeleteMenu(savedsess_menu, 0, MF_BYPOSITION)) ;
/* skip sesslist.sessions[0] == Default Settings */
for (i = 1;
i < ((sesslist.nsessions <= MENU_SAVED_MAX+1) ? sesslist.nsessions
: MENU_SAVED_MAX+1);
i++)
AppendMenu(savedsess_menu, MF_ENABLED,
IDM_SAVED_MIN + (i-1)*MENU_SAVED_STEP,
sesslist.sessions[i]);
if (sesslist.nsessions <= 1)
AppendMenu(savedsess_menu, MF_GRAYED, IDM_SAVED_MIN, "(No sessions)");
}
/*
* Update the Special Commands submenu.
*/
void update_specials_menu(void *frontend)
{
HMENU new_menu;
int i, j;
if (back)
specials = back->get_specials(backhandle);
else
specials = NULL;
if (specials) {
/* We can't use Windows to provide a stack for submenus, so
* here's a lame "stack" that will do for now. */
HMENU saved_menu = NULL;
int nesting = 1;
new_menu = CreatePopupMenu();
for (i = 0; nesting > 0; i++) {
assert(IDM_SPECIAL_MIN + 0x10 * i < IDM_SPECIAL_MAX);
switch (specials[i].code) {
case TS_SEP:
AppendMenu(new_menu, MF_SEPARATOR, 0, 0);
break;
case TS_SUBMENU:
assert(nesting < 2);
nesting++;
saved_menu = new_menu; /* XXX lame stacking */
new_menu = CreatePopupMenu();
AppendMenu(saved_menu, MF_POPUP | MF_ENABLED,
(UINT) new_menu, specials[i].name);
break;
case TS_EXITMENU:
nesting--;
if (nesting) {
new_menu = saved_menu; /* XXX lame stacking */
saved_menu = NULL;
}
break;
default:
AppendMenu(new_menu, MF_ENABLED, IDM_SPECIAL_MIN + 0x10 * i,
specials[i].name);
break;
}
}
/* Squirrel the highest special. */
n_specials = i - 1;
} else {
new_menu = NULL;
n_specials = 0;
}
for (j = 0; j < lenof(popup_menus); j++) {
if (specials_menu) {
/* XXX does this free up all submenus? */
DeleteMenu(popup_menus[j].menu, (UINT)specials_menu, MF_BYCOMMAND);
DeleteMenu(popup_menus[j].menu, IDM_SPECIALSEP, MF_BYCOMMAND);
}
if (new_menu) {
InsertMenu(popup_menus[j].menu, IDM_SHOWLOG,
MF_BYCOMMAND | MF_POPUP | MF_ENABLED,
(UINT) new_menu, "S&pecial Command");
InsertMenu(popup_menus[j].menu, IDM_SHOWLOG,
MF_BYCOMMAND | MF_SEPARATOR, IDM_SPECIALSEP, 0);
}
}
specials_menu = new_menu;
}
static void update_mouse_pointer(void)
{
LPTSTR curstype;
int force_visible = FALSE;
static int forced_visible = FALSE;
switch (busy_status) {
case BUSY_NOT:
if (send_raw_mouse)
curstype = IDC_ARROW;
else
curstype = IDC_IBEAM;
break;
case BUSY_WAITING:
curstype = IDC_APPSTARTING; /* this may be an abuse */
force_visible = TRUE;
break;
case BUSY_CPU:
curstype = IDC_WAIT;
force_visible = TRUE;
break;
default:
assert(0);
}
{
HCURSOR cursor = LoadCursor(NULL, curstype);
SetClassLongPtr(hwnd, GCLP_HCURSOR, (LONG_PTR)cursor);
SetCursor(cursor); /* force redraw of cursor at current posn */
}
if (force_visible != forced_visible) {
/* We want some cursor shapes to be visible always.
* Along with show_mouseptr(), this manages the ShowCursor()
* counter such that if we switch back to a non-force_visible
* cursor, the previous visibility state is restored. */
ShowCursor(force_visible);
forced_visible = force_visible;
}
}
void set_busy_status(void *frontend, int status)
{
busy_status = status;
update_mouse_pointer();
}
/*
* set or clear the "raw mouse message" mode
*/
void set_raw_mouse_mode(void *frontend, int activate)
{
activate = activate && !conf_get_int(conf, CONF_no_mouse_rep);
send_raw_mouse = activate;
update_mouse_pointer();
}
/*
* Print a message box and close the connection.
*/
void connection_fatal(void *frontend, char *fmt, ...)
{
va_list ap;
char *stuff, morestuff[100];
#ifdef RECONNECTPORT
if ( conf_get_int(conf,CONF_failure_reconnect)/*cfg.failure_reconnect*/) {
time_t tnow = time(NULL);
close_session();
if(last_reconnect && (tnow - last_reconnect) < GetReconnectDelay() ) {
Sleep(1000);
}
last_reconnect = tnow;
logevent(NULL, "Lost connection, reconnecting...");
term_pwron(term, FALSE);
backend_connected = 0 ;
start_backend();
SetTimer(hwnd, TIMER_INIT, init_delay, NULL) ;
} else {
va_start(ap, fmt);
stuff = dupvprintf(fmt, ap);
va_end(ap);
sprintf(morestuff, "%.70s Fatal Error", appname);
MessageBox(hwnd, stuff, morestuff, MB_ICONERROR | MB_OK);
sfree(stuff);
if ( conf_get_int(conf,CONF_close_on_exit)/*cfg.close_on_exit*/ == FORCE_ON)
PostQuitMessage(1);
else {
must_close_session = TRUE;
}
}
#else
va_start(ap, fmt);
stuff = dupvprintf(fmt, ap);
va_end(ap);
sprintf(morestuff, "%.70s Fatal Error", appname);
MessageBox(hwnd, stuff, morestuff, MB_ICONERROR | MB_OK);
sfree(stuff);
if (conf_get_int(conf, CONF_close_on_exit) == FORCE_ON)
PostQuitMessage(1);
else {
must_close_session = TRUE;
}
#endif
}
/*
* Report an error at the command-line parsing stage.
*/
void cmdline_error(char *fmt, ...)
{
va_list ap;
char *stuff, morestuff[100];
va_start(ap, fmt);
stuff = dupvprintf(fmt, ap);
va_end(ap);
sprintf(morestuff, "%.70s Command Line Error", appname);
MessageBox(hwnd, stuff, morestuff, MB_ICONERROR | MB_OK);
sfree(stuff);
exit(1);
}
/*
* Actually do the job requested by a WM_NETEVENT
*/
static void enact_pending_netevent(void)
{
static int reentering = 0;
extern int select_result(WPARAM, LPARAM);
if (reentering)
return; /* don't unpend the pending */
pending_netevent = FALSE;
reentering = 1;
select_result(pend_netevent_wParam, pend_netevent_lParam);
reentering = 0;
}
/*
* Copy the colour palette from the configuration data into defpal.
* This is non-trivial because the colour indices are different.
*/
static void conftopalette(void)
{
int i;
static const int ww[] = {
256, 257, 258, 259, 260, 261,
0, 8, 1, 9, 2, 10, 3, 11,
#ifdef TUTTYPORT
4, 12, 5, 13, 6, 14, 7, 15,
262, 263, 264, 265, 266, 267,
268, 269, 270, 271, 272, 273
};
for (i = 0; i < NCFGCOLOURS; i++) {
#else
4, 12, 5, 13, 6, 14, 7, 15
};
for (i = 0; i < 22; i++) {
#endif
int w = ww[i];
defpal[w].rgbtRed = conf_get_int_int(conf, CONF_colours, i*3+0);
defpal[w].rgbtGreen = conf_get_int_int(conf, CONF_colours, i*3+1);
defpal[w].rgbtBlue = conf_get_int_int(conf, CONF_colours, i*3+2);
}
for (i = 0; i < NEXTCOLOURS; i++) {
if (i < 216) {
int r = i / 36, g = (i / 6) % 6, b = i % 6;
defpal[i+16].rgbtRed = r ? r * 40 + 55 : 0;
defpal[i+16].rgbtGreen = g ? g * 40 + 55 : 0;
defpal[i+16].rgbtBlue = b ? b * 40 + 55 : 0;
} else {
int shade = i - 216;
shade = shade * 10 + 8;
defpal[i+16].rgbtRed = defpal[i+16].rgbtGreen =
defpal[i+16].rgbtBlue = shade;
}
}
/* Override with system colours if appropriate */
if (conf_get_int(conf, CONF_system_colour))
systopalette();
}
/*
* Override bit of defpal with colours from the system.
* (NB that this takes a copy the system colours at the time this is called,
* so subsequent colour scheme changes don't take effect. To fix that we'd
* probably want to be using GetSysColorBrush() and the like.)
*/
static void systopalette(void)
{
int i;
static const struct { int nIndex; int norm; int bold; } or[] =
{
{ COLOR_WINDOWTEXT, 256, 257 }, /* Default Foreground */
{ COLOR_WINDOW, 258, 259 }, /* Default Background */
{ COLOR_HIGHLIGHTTEXT, 260, 260 }, /* Cursor Text */
{ COLOR_HIGHLIGHT, 261, 261 }, /* Cursor Colour */
};
for (i = 0; i < (sizeof(or)/sizeof(or[0])); i++) {
COLORREF colour = GetSysColor(or[i].nIndex);
defpal[or[i].norm].rgbtRed =
defpal[or[i].bold].rgbtRed = GetRValue(colour);
defpal[or[i].norm].rgbtGreen =
defpal[or[i].bold].rgbtGreen = GetGValue(colour);
defpal[or[i].norm].rgbtBlue =
defpal[or[i].bold].rgbtBlue = GetBValue(colour);
}
}
/*
* Set up the colour palette.
*/
static void init_palette(void)
{
int i;
HDC hdc = GetDC(hwnd);
if (hdc) {
if (conf_get_int(conf, CONF_try_palette) &&
GetDeviceCaps(hdc, RASTERCAPS) & RC_PALETTE) {
/*
* This is a genuine case where we must use smalloc
* because the snew macros can't cope.
*/
logpal = smalloc(sizeof(*logpal)
- sizeof(logpal->palPalEntry)
+ NALLCOLOURS * sizeof(PALETTEENTRY));
logpal->palVersion = 0x300;
logpal->palNumEntries = NALLCOLOURS;
for (i = 0; i < NALLCOLOURS; i++) {
logpal->palPalEntry[i].peRed = defpal[i].rgbtRed;
logpal->palPalEntry[i].peGreen = defpal[i].rgbtGreen;
logpal->palPalEntry[i].peBlue = defpal[i].rgbtBlue;
logpal->palPalEntry[i].peFlags = PC_NOCOLLAPSE;
}
pal = CreatePalette(logpal);
if (pal) {
SelectPalette(hdc, pal, FALSE);
RealizePalette(hdc);
SelectPalette(hdc, GetStockObject(DEFAULT_PALETTE), FALSE);
}
}
ReleaseDC(hwnd, hdc);
}
if (pal)
for (i = 0; i < NALLCOLOURS; i++)
colours[i] = PALETTERGB(defpal[i].rgbtRed,
defpal[i].rgbtGreen,
defpal[i].rgbtBlue);
else
for (i = 0; i < NALLCOLOURS; i++)
colours[i] = RGB(defpal[i].rgbtRed,
defpal[i].rgbtGreen, defpal[i].rgbtBlue);
}
/*
* This is a wrapper to ExtTextOut() to force Windows to display
* the precise glyphs we give it. Otherwise it would do its own
* bidi and Arabic shaping, and we would end up uncertain which
* characters it had put where.
*/
static void exact_textout(HDC hdc, int x, int y, CONST RECT *lprc,
unsigned short *lpString, UINT cbCount,
CONST INT *lpDx, int opaque)
{
#ifdef __LCC__
/*
* The LCC include files apparently don't supply the
* GCP_RESULTSW type, but we can make do with GCP_RESULTS
* proper: the differences aren't important to us (the only
* variable-width string parameter is one we don't use anyway).
*/
GCP_RESULTS gcpr;
#else
GCP_RESULTSW gcpr;
#endif
char *buffer = snewn(cbCount*2+2, char);
char *classbuffer = snewn(cbCount, char);
memset(&gcpr, 0, sizeof(gcpr));
memset(buffer, 0, cbCount*2+2);
memset(classbuffer, GCPCLASS_NEUTRAL, cbCount);
gcpr.lStructSize = sizeof(gcpr);
gcpr.lpGlyphs = (void *)buffer;
gcpr.lpClass = (void *)classbuffer;
gcpr.nGlyphs = cbCount;
GetCharacterPlacementW(hdc, lpString, cbCount, 0, &gcpr,
FLI_MASK | GCP_CLASSIN | GCP_DIACRITIC);
ExtTextOut(hdc, x, y,
ETO_GLYPH_INDEX | ETO_CLIPPED | (opaque ? ETO_OPAQUE : 0),
lprc, buffer, cbCount, lpDx);
}
/*
* The exact_textout() wrapper, unfortunately, destroys the useful
* Windows `font linking' behaviour: automatic handling of Unicode
* code points not supported in this font by falling back to a font
* which does contain them. Therefore, we adopt a multi-layered
* approach: for any potentially-bidi text, we use exact_textout(),
* and for everything else we use a simple ExtTextOut as we did
* before exact_textout() was introduced.
*/
static void general_textout(HDC hdc, int x, int y, CONST RECT *lprc,
unsigned short *lpString, UINT cbCount,
CONST INT *lpDx, int opaque)
{
int i, j, xp, xn;
int bkmode = 0, got_bkmode = FALSE;
xp = xn = x;
for (i = 0; i < (int)cbCount ;) {
int rtl = is_rtl(lpString[i]);
xn += lpDx[i];
for (j = i+1; j < (int)cbCount; j++) {
if (rtl != is_rtl(lpString[j]))
break;
xn += lpDx[j];
}
/*
* Now [i,j) indicates a maximal substring of lpString
* which should be displayed using the same textout
* function.
*/
if (rtl) {
exact_textout(hdc, xp, y, lprc, lpString+i, j-i,
font_varpitch ? NULL : lpDx+i, opaque);
} else {
ExtTextOutW(hdc, xp, y, ETO_CLIPPED | (opaque ? ETO_OPAQUE : 0),
lprc, lpString+i, j-i,
font_varpitch ? NULL : lpDx+i);
}
i = j;
xp = xn;
bkmode = GetBkMode(hdc);
got_bkmode = TRUE;
SetBkMode(hdc, TRANSPARENT);
opaque = FALSE;
}
if (got_bkmode)
SetBkMode(hdc, bkmode);
}
static int get_font_width(HDC hdc, const TEXTMETRIC *tm)
{
int ret;
/* Note that the TMPF_FIXED_PITCH bit is defined upside down :-( */
if (!(tm->tmPitchAndFamily & TMPF_FIXED_PITCH)) {
ret = tm->tmAveCharWidth;
} else {
#define FIRST '0'
#define LAST '9'
ABCFLOAT widths[LAST-FIRST + 1];
int j;
font_varpitch = TRUE;
font_dualwidth = TRUE;
if (GetCharABCWidthsFloat(hdc, FIRST, LAST, widths)) {
ret = 0;
for (j = 0; j < lenof(widths); j++) {
int width = (int)(0.5 + widths[j].abcfA +
widths[j].abcfB + widths[j].abcfC);
if (ret < width)
ret = width;
}
} else {
ret = tm->tmMaxCharWidth;
}
#undef FIRST
#undef LAST
}
return ret;
}
/*
* Initialise all the fonts we will need initially. There may be as many as
* three or as few as one. The other (potentially) twenty-one fonts are done
* if/when they are needed.
*
* We also:
*
* - check the font width and height, correcting our guesses if
* necessary.
*
* - verify that the bold font is the same width as the ordinary
* one, and engage shadow bolding if not.
*
* - verify that the underlined font is the same width as the
* ordinary one (manual underlining by means of line drawing can
* be done in a pinch).
*/
static void init_fonts(int pick_width, int pick_height)
{
TEXTMETRIC tm;
CPINFO cpinfo;
FontSpec *font;
int fontsize[3];
int i;
int quality;
HDC hdc;
int fw_dontcare, fw_bold;
for (i = 0; i < FONT_MAXNO; i++)
fonts[i] = NULL;
bold_font_mode = conf_get_int(conf, CONF_bold_style) & 1 ?
BOLD_FONT : BOLD_NONE;
bold_colours = conf_get_int(conf, CONF_bold_style) & 2 ? TRUE : FALSE;
und_mode = UND_FONT;
font = conf_get_fontspec(conf, CONF_font);
if (font->isbold) {
fw_dontcare = FW_BOLD;
fw_bold = FW_HEAVY;
} else {
fw_dontcare = FW_DONTCARE;
fw_bold = FW_BOLD;
}
hdc = GetDC(hwnd);
if (pick_height)
font_height = pick_height;
else {
font_height = font->height;
if (font_height > 0) {
font_height =
-MulDiv(font_height, GetDeviceCaps(hdc, LOGPIXELSY), 72);
}
}
font_width = pick_width;
quality = conf_get_int(conf, CONF_font_quality);
#define f(i,c,w,u) \
fonts[i] = CreateFont (font_height, font_width, 0, 0, w, FALSE, u, FALSE, \
c, OUT_DEFAULT_PRECIS, \
CLIP_DEFAULT_PRECIS, FONT_QUALITY(quality), \
FIXED_PITCH | FF_DONTCARE, font->name)
f(FONT_NORMAL, font->charset, fw_dontcare, FALSE);
if (bold_font_mode == BOLD_FONT) {
f(FONT_BOLD, font->charset, fw_bold, FALSE);
}
SelectObject(hdc, fonts[FONT_NORMAL]);
GetTextMetrics(hdc, &tm);
GetObject(fonts[FONT_NORMAL], sizeof(LOGFONT), &lfont);
/* Note that the TMPF_FIXED_PITCH bit is defined upside down :-( */
if (!(tm.tmPitchAndFamily & TMPF_FIXED_PITCH)) {
font_varpitch = FALSE;
font_dualwidth = (tm.tmAveCharWidth != tm.tmMaxCharWidth);
} else {
font_varpitch = TRUE;
font_dualwidth = TRUE;
}
if (pick_width == 0 || pick_height == 0) {
font_height = tm.tmHeight;
font_width = get_font_width(hdc, &tm);
}
#ifdef RDB_DEBUG_PATCH
debug(23, "Primary font H=%d, AW=%d, MW=%d",
tm.tmHeight, tm.tmAveCharWidth, tm.tmMaxCharWidth);
#endif
{
CHARSETINFO info;
DWORD cset = tm.tmCharSet;
memset(&info, 0xFF, sizeof(info));
/* !!! Yes the next line is right */
if (cset == OEM_CHARSET)
ucsdata.font_codepage = GetOEMCP();
else
if (TranslateCharsetInfo ((DWORD *) cset, &info, TCI_SRCCHARSET))
ucsdata.font_codepage = info.ciACP;
else
ucsdata.font_codepage = -1;
GetCPInfo(ucsdata.font_codepage, &cpinfo);
ucsdata.dbcs_screenfont = (cpinfo.MaxCharSize > 1);
}
f(FONT_UNDERLINE, font->charset, fw_dontcare, TRUE);
/*
* Some fonts, e.g. 9-pt Courier, draw their underlines
* outside their character cell. We successfully prevent
* screen corruption by clipping the text output, but then
* we lose the underline completely. Here we try to work
* out whether this is such a font, and if it is, we set a
* flag that causes underlines to be drawn by hand.
*
* Having tried other more sophisticated approaches (such
* as examining the TEXTMETRIC structure or requesting the
* height of a string), I think we'll do this the brute
* force way: we create a small bitmap, draw an underlined
* space on it, and test to see whether any pixels are
* foreground-coloured. (Since we expect the underline to
* go all the way across the character cell, we only search
* down a single column of the bitmap, half way across.)
*/
{
HDC und_dc;
HBITMAP und_bm, und_oldbm;
int i, gotit;
COLORREF c;
und_dc = CreateCompatibleDC(hdc);
und_bm = CreateCompatibleBitmap(hdc, font_width, font_height);
und_oldbm = SelectObject(und_dc, und_bm);
SelectObject(und_dc, fonts[FONT_UNDERLINE]);
SetTextAlign(und_dc, TA_TOP | TA_LEFT | TA_NOUPDATECP);
SetTextColor(und_dc, RGB(255, 255, 255));
SetBkColor(und_dc, RGB(0, 0, 0));
SetBkMode(und_dc, OPAQUE);
ExtTextOut(und_dc, 0, 0, ETO_OPAQUE, NULL, " ", 1, NULL);
gotit = FALSE;
for (i = 0; i < font_height; i++) {
c = GetPixel(und_dc, font_width / 2, i);
if (c != RGB(0, 0, 0))
gotit = TRUE;
}
SelectObject(und_dc, und_oldbm);
DeleteObject(und_bm);
DeleteDC(und_dc);
if (!gotit) {
und_mode = UND_LINE;
DeleteObject(fonts[FONT_UNDERLINE]);
fonts[FONT_UNDERLINE] = 0;
}
}
#undef f
descent = tm.tmAscent + 1;
if (descent >= font_height)
descent = font_height - 1;
for (i = 0; i < 3; i++) {
if (fonts[i]) {
if (SelectObject(hdc, fonts[i]) && GetTextMetrics(hdc, &tm))
fontsize[i] = get_font_width(hdc, &tm) + 256 * tm.tmHeight;
else
fontsize[i] = -i;
} else
fontsize[i] = -i;
}
ReleaseDC(hwnd, hdc);
if (fontsize[FONT_UNDERLINE] != fontsize[FONT_NORMAL]) {
und_mode = UND_LINE;
DeleteObject(fonts[FONT_UNDERLINE]);
fonts[FONT_UNDERLINE] = 0;
}
if (bold_font_mode == BOLD_FONT &&
fontsize[FONT_BOLD] != fontsize[FONT_NORMAL]) {
bold_font_mode = BOLD_SHADOW;
DeleteObject(fonts[FONT_BOLD]);
fonts[FONT_BOLD] = 0;
}
fontflag[0] = fontflag[1] = fontflag[2] = 1;
init_ucs(conf, &ucsdata);
}
static void another_font(int fontno)
{
int basefont;
int fw_dontcare, fw_bold, quality;
int c, u, w, x;
char *s;
FontSpec *font;
if (fontno < 0 || fontno >= FONT_MAXNO || fontflag[fontno])
return;
basefont = (fontno & ~(FONT_BOLDUND));
if (basefont != fontno && !fontflag[basefont])
another_font(basefont);
font = conf_get_fontspec(conf, CONF_font);
if (font->isbold) {
fw_dontcare = FW_BOLD;
fw_bold = FW_HEAVY;
} else {
fw_dontcare = FW_DONTCARE;
fw_bold = FW_BOLD;
}
c = font->charset;
w = fw_dontcare;
u = FALSE;
s = font->name;
x = font_width;
if (fontno & FONT_WIDE)
x *= 2;
if (fontno & FONT_NARROW)
x = (x+1)/2;
if (fontno & FONT_OEM)
c = OEM_CHARSET;
if (fontno & FONT_BOLD)
w = fw_bold;
if (fontno & FONT_UNDERLINE)
u = TRUE;
quality = conf_get_int(conf, CONF_font_quality);
fonts[fontno] =
CreateFont(font_height * (1 + !!(fontno & FONT_HIGH)), x, 0, 0, w,
FALSE, u, FALSE, c, OUT_DEFAULT_PRECIS,
CLIP_DEFAULT_PRECIS, FONT_QUALITY(quality),
DEFAULT_PITCH | FF_DONTCARE, s);
fontflag[fontno] = 1;
}
static void deinit_fonts(void)
{
int i;
for (i = 0; i < FONT_MAXNO; i++) {
if (fonts[i])
DeleteObject(fonts[i]);
fonts[i] = 0;
fontflag[i] = 0;
}
}
void request_resize(void *frontend, int w, int h)
{
int width, height;
/* If the window is maximized supress resizing attempts */
if (IsZoomed(hwnd)) {
if (conf_get_int(conf, CONF_resize_action) == RESIZE_TERM)
return;
}
if (conf_get_int(conf, CONF_resize_action) == RESIZE_DISABLED) return;
if (h == term->rows && w == term->cols) return;
/* Sanity checks ... */
{
static int first_time = 1;
static RECT ss;
switch (first_time) {
case 1:
/* Get the size of the screen */
if (get_fullscreen_rect(&ss))
/* first_time = 0 */ ;
else {
first_time = 2;
break;
}
case 0:
/* Make sure the values are sane */
width = (ss.right - ss.left - extra_width) / 4;
height = (ss.bottom - ss.top - extra_height) / 6;
if (w > width || h > height)
return;
if (w < 15)
w = 15;
if (h < 1)
h = 1;
}
}
term_size(term, h, w, conf_get_int(conf, CONF_savelines));
if (conf_get_int(conf, CONF_resize_action) != RESIZE_FONT &&
!IsZoomed(hwnd)) {
width = extra_width + font_width * w;
height = extra_height + font_height * h;
SetWindowPos(hwnd, NULL, 0, 0, width, height,
SWP_NOACTIVATE | SWP_NOCOPYBITS |
SWP_NOMOVE | SWP_NOZORDER);
} else
reset_window(0);
InvalidateRect(hwnd, NULL, TRUE);
}
static void reset_window(int reinit) {
/*
* This function decides how to resize or redraw when the
* user changes something.
*
* This function doesn't like to change the terminal size but if the
* font size is locked that may be it's only soluion.
*/
int win_width, win_height, resize_action, window_border;
RECT cr, wr;
#ifdef RDB_DEBUG_PATCH
debug((27, "reset_window()"));
#endif
/* Current window sizes ... */
GetWindowRect(hwnd, &wr);
GetClientRect(hwnd, &cr);
win_width = cr.right - cr.left;
win_height = cr.bottom - cr.top;
resize_action = conf_get_int(conf, CONF_resize_action);
window_border = conf_get_int(conf, CONF_window_border);
if (resize_action == RESIZE_DISABLED)
reinit = 2;
/* Are we being forced to reload the fonts ? */
if (reinit>1) {
#ifdef RDB_DEBUG_PATCH
debug((27, "reset_window() -- Forced deinit"));
#endif
deinit_fonts();
init_fonts(0,0);
}
/* Oh, looks like we're minimised */
if (win_width == 0 || win_height == 0)
return;
/* Is the window out of position ? */
if ( !reinit &&
(offset_width != (win_width-font_width*term->cols)/2 ||
offset_height != (win_height-font_height*term->rows)/2) ){
offset_width = (win_width-font_width*term->cols)/2;
offset_height = (win_height-font_height*term->rows)/2;
InvalidateRect(hwnd, NULL, TRUE);
#ifdef RDB_DEBUG_PATCH
debug((27, "reset_window() -> Reposition terminal"));
#endif
}
if (IsZoomed(hwnd)) {
/* We're fullscreen, this means we must not change the size of
* the window so it's the font size or the terminal itself.
*/
extra_width = wr.right - wr.left - cr.right + cr.left;
extra_height = wr.bottom - wr.top - cr.bottom + cr.top;
if (resize_action != RESIZE_TERM) {
if (font_width != win_width/term->cols ||
font_height != win_height/term->rows) {
deinit_fonts();
init_fonts(win_width/term->cols, win_height/term->rows);
offset_width = (win_width-font_width*term->cols)/2;
offset_height = (win_height-font_height*term->rows)/2;
InvalidateRect(hwnd, NULL, TRUE);
#ifdef RDB_DEBUG_PATCH
debug((25, "reset_window() -> Z font resize to (%d, %d)",
font_width, font_height));
#endif
}
} else {
if (font_width * term->cols != win_width ||
font_height * term->rows != win_height) {
/* Our only choice at this point is to change the
* size of the terminal; Oh well.
*/
term_size(term, win_height/font_height, win_width/font_width,
conf_get_int(conf, CONF_savelines));
offset_width = (win_width-font_width*term->cols)/2;
offset_height = (win_height-font_height*term->rows)/2;
InvalidateRect(hwnd, NULL, TRUE);
#ifdef RDB_DEBUG_PATCH
debug((27, "reset_window() -> Zoomed term_size"));
#endif
}
}
return;
}
/* Hmm, a force re-init means we should ignore the current window
* so we resize to the default font size.
*/
if (reinit>0) {
#ifdef RDB_DEBUG_PATCH
debug((27, "reset_window() -> Forced re-init"));
#endif
offset_width = offset_height = window_border;
extra_width = wr.right - wr.left - cr.right + cr.left + offset_width*2;
extra_height = wr.bottom - wr.top - cr.bottom + cr.top +offset_height*2;
if (win_width != font_width*term->cols + offset_width*2 ||
win_height != font_height*term->rows + offset_height*2) {
/* If this is too large windows will resize it to the maximum
* allowed window size, we will then be back in here and resize
* the font or terminal to fit.
*/
SetWindowPos(hwnd, NULL, 0, 0,
font_width*term->cols + extra_width,
font_height*term->rows + extra_height,
SWP_NOMOVE | SWP_NOZORDER);
}
InvalidateRect(hwnd, NULL, TRUE);
return;
}
/* Okay the user doesn't want us to change the font so we try the
* window. But that may be too big for the screen which forces us
* to change the terminal.
*/
if ((resize_action == RESIZE_TERM && reinit<=0) ||
(resize_action == RESIZE_EITHER && reinit<0) ||
reinit>0) {
offset_width = offset_height = window_border;
extra_width = wr.right - wr.left - cr.right + cr.left + offset_width*2;
extra_height = wr.bottom - wr.top - cr.bottom + cr.top +offset_height*2;
if (win_width != font_width*term->cols + offset_width*2 ||
win_height != font_height*term->rows + offset_height*2) {
static RECT ss;
int width, height;
get_fullscreen_rect(&ss);
width = (ss.right - ss.left - extra_width) / font_width;
height = (ss.bottom - ss.top - extra_height) / font_height;
/* Grrr too big */
if ( term->rows > height || term->cols > width ) {
if (resize_action == RESIZE_EITHER) {
/* Make the font the biggest we can */
if (term->cols > width)
font_width = (ss.right - ss.left - extra_width)
/ term->cols;
if (term->rows > height)
font_height = (ss.bottom - ss.top - extra_height)
/ term->rows;
deinit_fonts();
init_fonts(font_width, font_height);
width = (ss.right - ss.left - extra_width) / font_width;
height = (ss.bottom - ss.top - extra_height) / font_height;
} else {
if ( height > term->rows ) height = term->rows;
if ( width > term->cols ) width = term->cols;
term_size(term, height, width,
conf_get_int(conf, CONF_savelines));
#ifdef RDB_DEBUG_PATCH
debug((27, "reset_window() -> term resize to (%d,%d)",
height, width));
#endif
}
}
SetWindowPos(hwnd, NULL, 0, 0,
font_width*term->cols + extra_width,
font_height*term->rows + extra_height,
SWP_NOMOVE | SWP_NOZORDER);
InvalidateRect(hwnd, NULL, TRUE);
#ifdef RDB_DEBUG_PATCH
debug((27, "reset_window() -> window resize to (%d,%d)",
font_width*term->cols + extra_width,
font_height*term->rows + extra_height));
#endif
}
return;
}
/* We're allowed to or must change the font but do we want to ? */
if (font_width != (win_width-window_border*2)/term->cols ||
font_height != (win_height-window_border*2)/term->rows) {
deinit_fonts();
init_fonts((win_width-window_border*2)/term->cols,
(win_height-window_border*2)/term->rows);
offset_width = (win_width-font_width*term->cols)/2;
offset_height = (win_height-font_height*term->rows)/2;
extra_width = wr.right - wr.left - cr.right + cr.left +offset_width*2;
extra_height = wr.bottom - wr.top - cr.bottom + cr.top+offset_height*2;
InvalidateRect(hwnd, NULL, TRUE);
#ifdef RDB_DEBUG_PATCH
debug((25, "reset_window() -> font resize to (%d,%d)",
font_width, font_height));
#endif
}
}
static void set_input_locale(HKL kl)
{
char lbuf[20];
GetLocaleInfo(LOWORD(kl), LOCALE_IDEFAULTANSICODEPAGE,
lbuf, sizeof(lbuf));
kbd_codepage = atoi(lbuf);
}
static void click(Mouse_Button b, int x, int y, int shift, int ctrl, int alt)
{
int thistime = GetMessageTime();
if (send_raw_mouse &&
!(shift && conf_get_int(conf, CONF_mouse_override))) {
lastbtn = MBT_NOTHING;
term_mouse(term, b, translate_button(b), MA_CLICK,
x, y, shift, ctrl, alt);
return;
}
if (lastbtn == b && thistime - lasttime < dbltime) {
lastact = (lastact == MA_CLICK ? MA_2CLK :
lastact == MA_2CLK ? MA_3CLK :
lastact == MA_3CLK ? MA_CLICK : MA_NOTHING);
} else {
lastbtn = b;
lastact = MA_CLICK;
}
if (lastact != MA_NOTHING)
term_mouse(term, b, translate_button(b), lastact,
x, y, shift, ctrl, alt);
lasttime = thistime;
}
/*
* Translate a raw mouse button designation (LEFT, MIDDLE, RIGHT)
* into a cooked one (SELECT, EXTEND, PASTE).
*/
static Mouse_Button translate_button(Mouse_Button button)
{
if (button == MBT_LEFT)
return MBT_SELECT;
if (button == MBT_MIDDLE)
return conf_get_int(conf, CONF_mouse_is_xterm) == 1 ?
MBT_PASTE : MBT_EXTEND;
if (button == MBT_RIGHT)
return conf_get_int(conf, CONF_mouse_is_xterm) == 1 ?
MBT_EXTEND : MBT_PASTE;
return 0; /* shouldn't happen */
}
static void show_mouseptr(int show)
{
/* NB that the counter in ShowCursor() is also frobbed by
* update_mouse_pointer() */
static int cursor_visible = 1;
if (!conf_get_int(conf, CONF_hide_mouseptr))
show = 1; /* override if this feature disabled */
if (cursor_visible && !show)
ShowCursor(FALSE);
else if (!cursor_visible && show)
ShowCursor(TRUE);
cursor_visible = show;
}
static int is_alt_pressed(void)
{
BYTE keystate[256];
int r = GetKeyboardState(keystate);
if (!r)
return FALSE;
if (keystate[VK_MENU] & 0x80)
return TRUE;
if (keystate[VK_RMENU] & 0x80)
return TRUE;
return FALSE;
}
#if (!defined IMAGEPORT) || (defined FDJ)
static int resizing ;
#endif
#ifdef PERSOPORT
struct ctrl_tab_info {
int direction;
HWND self;
DWORD self_hi_date_time;
DWORD self_lo_date_time;
HWND next;
DWORD next_hi_date_time;
DWORD next_lo_date_time;
int next_self;
};
static BOOL CALLBACK CtrlTabWindowProc(HWND hwnd, LPARAM lParam) {
struct ctrl_tab_info* info = (struct ctrl_tab_info*) lParam;
char lpszClassName[256];
#if (defined PERSOPORT) && (!defined FDJ)
strcpy(lpszClassName,KiTTYClassName) ;
#else
strcpy(lpszClassName,appname) ;
#endif
char class_name[16];
int wndExtra;
if (info->self != hwnd && (wndExtra = GetClassLong(hwnd, GCL_CBWNDEXTRA)) >= 8 && GetClassName(hwnd, class_name, sizeof class_name) >= 5 && memcmp(class_name, lpszClassName, 5) == 0) {
DWORD hwnd_hi_date_time = GetWindowLong(hwnd, wndExtra - 8);
DWORD hwnd_lo_date_time = GetWindowLong(hwnd, wndExtra - 4);
int hwnd_self, hwnd_next;
hwnd_self = hwnd_hi_date_time - info->self_hi_date_time;
if (hwnd_self == 0)
hwnd_self = hwnd_lo_date_time - info->self_lo_date_time;
hwnd_self *= info->direction;
hwnd_next = hwnd_hi_date_time - info->next_hi_date_time;
if (hwnd_next == 0)
hwnd_next = hwnd_lo_date_time - info->next_lo_date_time;
hwnd_next *= info->direction;
if( ((hwnd_self > 0) && (hwnd_next < 0)) || (((hwnd_self > 0) || (hwnd_next < 0)) && (info->next_self <= 0)) ) {
info->next = hwnd;
info->next_hi_date_time = hwnd_hi_date_time;
info->next_lo_date_time = hwnd_lo_date_time;
info->next_self = hwnd_self;
}
}
return TRUE;
}
#endif
void notify_remote_exit(void *fe)
{
int exitcode, close_on_exit;
if (!session_closed &&
(exitcode = back->exitcode(backhandle)) >= 0) {
close_on_exit = conf_get_int(conf, CONF_close_on_exit);
/* Abnormal exits will already have set session_closed and taken
* appropriate action. */
if (close_on_exit == FORCE_ON ||
(close_on_exit == AUTO && exitcode != INT_MAX)) {
PostQuitMessage(0);
} else {
must_close_session = TRUE;
session_closed = TRUE;
/* exitcode == INT_MAX indicates that the connection was closed
* by a fatal error, so an error box will be coming our way and
* we should not generate this informational one. */
if (exitcode != INT_MAX)
MessageBox(hwnd, "Connection closed by remote host",
appname, MB_OK | MB_ICONINFORMATION);
}
}
}
void timer_change_notify(unsigned long next)
{
unsigned long now = GETTICKCOUNT();
long ticks;
if (now - next < INT_MAX)
ticks = 0;
else
ticks = next - now;
KillTimer(hwnd, TIMING_TIMER_ID);
SetTimer(hwnd, TIMING_TIMER_ID, ticks, NULL);
timing_next_time = next;
}
static void conf_cache_data(void)
{
/* Cache some items from conf to speed lookups in very hot code */
cursor_type = conf_get_int(conf, CONF_cursor_type);
vtmode = conf_get_int(conf, CONF_vtmode);
}
static LRESULT CALLBACK WndProc(HWND hwnd, UINT message,
WPARAM wParam, LPARAM lParam)
{
HDC hdc;
static int ignore_clip = FALSE;
static int need_backend_resize = FALSE;
static int fullscr_on_max = FALSE;
static int processed_resize = FALSE;
static UINT last_mousemove = 0;
int resize_action;
#ifdef HYPERLINKPORT
/*
* HACK: PuttyTray / Nutty
*/
POINT cursor_pt;
#endif
switch (message) {
case WM_TIMER:
if ((UINT_PTR)wParam == TIMING_TIMER_ID) {
unsigned long next;
KillTimer(hwnd, TIMING_TIMER_ID);
if (run_timers(timing_next_time, &next)) {
timer_change_notify(next);
} else {
}
}
#ifdef PERSOPORT
else if((UINT_PTR)wParam == TIMER_INIT) { // Initialisation
char buffer[4096] = "" ;
if( (conf_get_int(conf,CONF_protocol)/*cfg.protocol*/ == PROT_SSH) && (!backend_connected) ) break ; // On sort si en SSH on n'est pas connecte
// Lancement d'une (ou plusieurs separees par \\n) commande(s) automatique(s) a l'initialisation
KillTimer( hwnd, TIMER_INIT ) ;
if( conf_get_int(conf,CONF_protocol) == PROT_TELNET ) {
if( strlen( conf_get_str(conf,CONF_username) ) > 0 ) {
if( strlen( conf_get_str(conf,CONF_password) ) > 0 ) {
char bufpass[256]; strcpy(bufpass,conf_get_str(conf,CONF_password)) ;
MASKPASS(bufpass); strcat(buffer,bufpass); memset(bufpass,0,strlen(bufpass));
strcat( buffer, "\\n" ) ;
}
}
if( strlen( conf_get_str(conf,CONF_autocommand)/*cfg.autocommand*/ ) > 0 ) {
strcat( buffer, "\\n\\p" ) ;
strcat( buffer, conf_get_str(conf,CONF_autocommand)/*cfg.autocommand*/ ) ;
strcat( buffer, "\\n" ) ;
}
if( strlen(buffer) > 0 ) {
conf_set_str( conf, CONF_autocommand, buffer ); //strcpy( cfg.autocommand, buffer ) ;
}
}
// Envoi automatiquement dans le systeme tray si besoin
if( GetAutoSendToTray() ) ManageToTray( hwnd ) ;
// Maximize automatic
if( conf_get_int(conf,CONF_maximize) /*cfg.maximize*/ ) { PostMessage( hwnd, WM_SYSCOMMAND, SC_MAXIMIZE, (LPARAM)NULL ) ; }
// Fullscreen automatic
if( conf_get_int(conf,CONF_fullscreen) /*cfg.fullscreen*/ ) { PostMessage( hwnd, WM_COMMAND, IDM_FULLSCREEN, (LPARAM)NULL ) ; }
// Affichage d'une note de la session s'il y en a une
if( GetSessionField( conf_get_str( conf, CONF_sessionname)/*cfg.sessionname*/, conf_get_str( conf, CONF_folder)/*cfg.folder*/, "Notes", buffer ) )
{ if( strlen( buffer ) > 0 ) MessageBox( hwnd, buffer, "Notes", MB_OK ) ; }
RenewPassword( conf/*&cfg*/ ) ;
if( strlen( conf_get_str(conf,CONF_autocommand)/*cfg.autocommand*/ ) > 0 ) {
SetTimer(hwnd, TIMER_AUTOCOMMAND, autocommand_delay, NULL) ;
}
if( conf_get_int(conf,CONF_logtimerotation)/*cfg.logtimerotation*/ > 0 ) {
SetTimer(hwnd, TIMER_LOGROTATION, (int)( conf_get_int(conf,CONF_logtimerotation)/*cfg.logtimerotation*/*1000), NULL) ;
logevent(NULL, "Start log rotation" );
}
RefreshBackground( hwnd ) ;
}
else if((UINT_PTR)wParam == TIMER_AUTOCOMMAND) { // Autocommand au demarrage
KillTimer( hwnd, TIMER_AUTOCOMMAND ) ;
if( AutoCommand == NULL ) {
ValidateRect( hwnd, NULL ) ;
AutoCommand = (char*) malloc( strlen(conf_get_str(conf,CONF_autocommand))+10 ) ;
strcpy( AutoCommand, conf_get_str(conf,CONF_autocommand) ) ;
//char bufauto[8192]="";
//GetSessionField( conf_get_str(conf,CONF_sessionname)/*cfg.sessionname*/, conf_get_str(conf,CONF_folder)/*cfg.folder*/, "Autocommand", bufauto/*cfg.autocommand*/ ) ;
//conf_set_str( conf,CONF_autocommand, bufauto);
//AutoCommand = conf_get_str(conf,CONF_autocommand)/*cfg.autocommand */; // Probleme ou pas ?
//logevent(NULL, AutoCommand );
}
char buffer[8192] = "" ;
int i = 0 ;
while( AutoCommand[i] != '\0' ) {
if( AutoCommand[i]=='\n' ) { i++ ; break ; }
else if( (AutoCommand[i] == '\\') && (AutoCommand[i+1] == 'n') ) { i += 2 ; break ; }
else if( (AutoCommand[i] == '\\') && (AutoCommand[i+1] == 'p') ) {
strcat( buffer, "\\p" ) ;
i += 2 ;
break ;
}
else if( (AutoCommand[i] == '\\') && (AutoCommand[i+1] == 's') ) {
strcat( buffer, "\\s" ) ;
i += 2 ;
buffer[i] = AutoCommand[i] ; buffer[i+1] = '\0' ; i++ ;
buffer[i] = AutoCommand[i] ; buffer[i+1] = '\0' ; i++ ;
break ;
}
else { buffer[i] = AutoCommand[i] ; buffer[i+1] = '\0' ; i++ ; }
}
//if( AutoCommand[i] != '\0' ) { AutoCommand += i ; }
del( AutoCommand, 1, i ) ; //AutoCommand += i ;
if( strlen( buffer ) > 0 ) { SendAutoCommand( hwnd, buffer ) ; }
if( AutoCommand[0] == '\0' ) {
free( AutoCommand ) ; AutoCommand = NULL ;
InvalidateRect( hwnd, NULL, TRUE ) ;
//char bufauto[8192]="";
//GetSessionField( conf_get_str(conf,CONF_sessionname)/*cfg.sessionname*/, conf_get_str(conf,CONF_folder)/*cfg.folder*/, "Autocommand", bufauto/*cfg.autocommand*/ ) ;
//conf_set_str( conf,CONF_autocommand,bufauto);
}
else { SetTimer(hwnd, TIMER_AUTOCOMMAND, autocommand_delay, NULL) ; }
}
else if((UINT_PTR)wParam == TIMER_AUTOPASTE) { // AutoPaste
char buffer[4096] = "" ;
int i = 0, j ;
KillTimer( hwnd, TIMER_AUTOPASTE ) ;
if( PasteCommand == NULL ) { ValidateRect( hwnd, NULL ) ; }
else if( strlen( PasteCommand ) == 0 ) { free( PasteCommand ) ; PasteCommand = NULL ; }
else {
while( PasteCommand[0] != '\0' ) {
buffer[i] = PasteCommand[0] ; buffer[i+1] = '\0' ;
j = 0 ; do { PasteCommand[j] = PasteCommand[j+1] ; j++ ; } while( PasteCommand[j] != '\0' ) ;
if( buffer[i] == '\n' ) { buffer[i] = '\0' ; break ; }
i++ ;
}
if( strlen( buffer ) > 0 ) {
SendAutoCommand( hwnd, buffer ) ;
SetTimer(hwnd, TIMER_AUTOPASTE, autocommand_delay, NULL) ;
}
}
}
#if (defined IMAGEPORT) && (!defined FDJ)
else if( BackgroundImageFlag && ((UINT_PTR)wParam == TIMER_SLIDEBG) ) { // Changement automatique de l'image de fond
NextBgImage( hwnd ) ;
InvalidateRect( hwnd, NULL, TRUE ) ;
}
#endif
else if((UINT_PTR)wParam == TIMER_REDRAW) { // rafraichissement automatique (bug d'affichage)
//RefreshBackground( hwnd ) ; // On inhibe cette fonction a cause du probleme de fuite memoire due a l'image de fond !!!
InvalidateRect( hwnd, NULL, TRUE ) ; // On remplace par
// Envoi de l'anti-idle
AntiIdleCount += 1 ;
if( AntiIdleCount >= AntiIdleCountMax ) {
AntiIdleCount = 0 ;
if(strlen( conf_get_str(conf,CONF_antiidle) ) > 0) SendAutoCommand( hwnd, conf_get_str(conf,CONF_antiidle) ) ;
else if( strlen( AntiIdleStr ) > 0 ) SendAutoCommand( hwnd, AntiIdleStr ) ;
}
}
else if((UINT_PTR)wParam == TIMER_BLINKTRAYICON) { // Clignotement de l'icone dans le systeme tray sur reception d'un signal BELL (print '\007' pour simuler)
static int BlinkingState = 0 ;
static HICON hBlinkingIcon = NULL ;
if( GetVisibleFlag()!=VISIBLE_TRAY )
{ KillTimer( hwnd, TIMER_BLINKTRAYICON ) ; TrayIcone.hIcon = hBlinkingIcon ; BlinkingState = 0 ; break ; }
if( BlinkingState==0 ) {
hBlinkingIcon = TrayIcone.hIcon ;
TrayIcone.hIcon = LoadIcon(NULL, NULL) ;
Shell_NotifyIcon(NIM_MODIFY, &TrayIcone) ;
BlinkingState = 1 ;
}
else {
if( hBlinkingIcon ) {
TrayIcone.hIcon = hBlinkingIcon ;
Shell_NotifyIcon(NIM_MODIFY, &TrayIcone) ;
BlinkingState = 0 ;
}
}
}
else if((UINT_PTR)wParam == TIMER_LOGROTATION) { // log rotation
timestamp_change_filename() ;
}
#endif
return 0;
case WM_CREATE:
#ifdef PERSOPORT
{
// Initialiation
MainHwnd = hwnd ;
if( GetIconeFlag() != -1 )
SetNewIcon( hwnd, conf_get_filename(conf,CONF_iconefile)->path, conf_get_int(conf,CONF_icone), SI_INIT ) ;
// Gestion de la transparence
if( GetTransparencyFlag() && conf_get_int(conf,CONF_transparencynumber) >= 0 ) {
SetWindowLongPtr(hwnd, GWL_EXSTYLE, GetWindowLong(hwnd, GWL_EXSTYLE) | WS_EX_LAYERED ) ;
//SetLayeredWindowAttributes(hwnd, 0, TransparencyNumber, LWA_ALPHA) ;
SetTransparency( hwnd, 255-conf_get_int(conf,CONF_transparencynumber) ) ;
}
#if (defined IMAGEPORT) && (!defined FDJ)
if( GetIconeFlag() == -1 ) conf_set_int( conf, CONF_bg_type, 0 ) ; //cfg.bg_type = 0 ;
if( !BackgroundImageFlag ) conf_set_int( conf, CONF_bg_type,0 ); //cfg.bg_type = 0 ;
#endif
if( !PuttyFlag )
if( conf_get_int( conf,CONF_saveonexit) /*cfg.saveonexit*/ && conf_get_int( conf,CONF_windowstate)/*cfg.windowstate*/ )
PostMessage( hwnd, WM_SYSCOMMAND, SC_MAXIMIZE, (LPARAM)NULL );
if (conf_get_int(conf, CONF_ctrl_tab_switch)) {
int wndExtra = GetClassLong(hwnd, GCL_CBWNDEXTRA);
FILETIME filetime;
GetSystemTimeAsFileTime(&filetime);
SetWindowLong(hwnd, wndExtra - 8, filetime.dwHighDateTime);
SetWindowLong(hwnd, wndExtra - 4, filetime.dwLowDateTime);
}
}
#endif
break;
case WM_CLOSE:
{
#ifdef PERSOPORT
if( GetProtectFlag() ) {
MessageBox(hwnd,
"You are not allowed to close a protected window",
"Exit warning", MB_ICONERROR | MB_OK ) ;
return 0 ;
}
char *str;
show_mouseptr(1);
str = dupprintf("%s Exit Confirmation", appname);
if ( !conf_get_int(conf,CONF_warn_on_close)/*cfg.warn_on_close*/ || session_closed ||
MessageBox(hwnd,
"Are you sure you want to close this session?",
str, MB_ICONWARNING | MB_OKCANCEL | MB_DEFBUTTON1)
== IDOK) {
if( strlen( conf_get_str(conf,CONF_autocommandout)/*cfg.autocommandout*/ ) > 0 ) { //Envoie d'une command automatique en sortant
SendAutoCommand( hwnd, conf_get_str(conf,CONF_autocommandout)/*cfg.autocommandout*/ ) ;
conf_set_str(conf,CONF_autocommandout,"" );//strcpy( cfg.autocommandout, "" );
}
DestroyWindow(hwnd);
}
sfree(str);
#else
char *str;
show_mouseptr(1);
str = dupprintf("%s Exit Confirmation", appname);
if (session_closed || !conf_get_int(conf, CONF_warn_on_close) ||
MessageBox(hwnd,
"Are you sure you want to close this session?",
str, MB_ICONWARNING | MB_OKCANCEL | MB_DEFBUTTON1)
== IDOK)
DestroyWindow(hwnd);
sfree(str);
#endif
}
return 0;
case WM_DESTROY:
show_mouseptr(1);
PostQuitMessage(0);
return 0;
case WM_INITMENUPOPUP:
if ((HMENU)wParam == savedsess_menu) {
/* About to pop up Saved Sessions sub-menu.
* Refresh the session list. */
get_sesslist(&sesslist, FALSE); /* free */
get_sesslist(&sesslist, TRUE);
update_savedsess_menu();
return 0;
}
break;
case WM_COMMAND:
case WM_SYSCOMMAND:
#ifdef PERSOPORT
if( strlen( conf_get_str(conf,CONF_folder)/*cfg.folder*/ )>0 ) SetInitCurrentFolder( conf_get_str(conf,CONF_folder)/*cfg.folder*/ );
if( (wParam>=IDM_USERCMD)&&(wParam<(IDM_USERCMD+NB_MENU_MAX)) ) {
ManageSpecialCommand( hwnd, wParam-IDM_USERCMD ) ;
break ;
}
#endif
switch (wParam & ~0xF) { /* low 4 bits reserved to Windows */
case IDM_SHOWLOG:
showeventlog(hwnd);
break;
case IDM_NEWSESS:
case IDM_DUPSESS:
case IDM_SAVEDSESS:
{
char b[2048];
#ifdef PERSOPORT
char c[180], *cl;
#else
char c[30], *cl;
#endif
int freecl = FALSE;
BOOL inherit_handles;
STARTUPINFO si;
PROCESS_INFORMATION pi;
HANDLE filemap = NULL;
if (wParam == IDM_DUPSESS) {
/*
* Allocate a file-mapping memory chunk for the
* config structure.
*/
SECURITY_ATTRIBUTES sa;
void *p;
int size;
size = conf_serialised_size(conf);
sa.nLength = sizeof(sa);
sa.lpSecurityDescriptor = NULL;
sa.bInheritHandle = TRUE;
filemap = CreateFileMapping(INVALID_HANDLE_VALUE,
&sa,
PAGE_READWRITE,
0, size, NULL);
if (filemap && filemap != INVALID_HANDLE_VALUE) {
p = MapViewOfFile(filemap, FILE_MAP_WRITE, 0, 0, size);
if (p) {
conf_serialise(conf, p);
UnmapViewOfFile(p);
}
}
inherit_handles = TRUE;
sprintf(c, "putty &%p:%u", filemap, (unsigned)size);
cl = c;
} else if (wParam == IDM_SAVEDSESS) {
unsigned int sessno = ((lParam - IDM_SAVED_MIN)
/ MENU_SAVED_STEP) + 1;
if (sessno < (unsigned)sesslist.nsessions) {
char *session = sesslist.sessions[sessno];
cl = dupprintf("putty @%s", session);
#ifdef PERSOPORT
GetSessionFolderName( conf_get_str(conf,CONF_sessionname)/*cfg.sessionname*/, conf_get_str(conf,CONF_folder)/*cfg.folder*/ ) ;
if( DirectoryBrowseFlag ) if( strcmp(conf_get_str(conf,CONF_folder)/*cfg.folder*/, "")&&strcmp(conf_get_str(conf,CONF_folder)/*cfg.folder*/,"Default") )
{ strcat( cl, " -folder \"" ) ; strcat( cl, conf_get_str(conf,CONF_folder)/*cfg.folder*/ ) ; strcat( cl, "\"" ) ; }
#endif
inherit_handles = FALSE;
freecl = TRUE;
} else
break;
#ifdef PERSOPORT
} else /* IDM_NEWSESS */ {
if( strcmp(conf_get_str(conf,CONF_folder)/*cfg.folder*/, "")&&strcmp(conf_get_str(conf,CONF_folder)/*cfg.folder*/,"Default") )
sprintf(c, "putty -folder \"%s\"", conf_get_str(conf,CONF_folder)/*cfg.folder*/ ) ;
else c[0]='\0' ;
cl = c ;
#else
} else /* IDM_NEWSESS */ {
cl = NULL;
#endif
inherit_handles = FALSE;
}
GetModuleFileName(NULL, b, sizeof(b) - 1);
si.cb = sizeof(si);
si.lpReserved = NULL;
si.lpDesktop = NULL;
si.lpTitle = NULL;
si.dwFlags = 0;
si.cbReserved2 = 0;
si.lpReserved2 = NULL;
CreateProcess(b, cl, NULL, NULL, inherit_handles,
NORMAL_PRIORITY_CLASS, NULL, NULL, &si, &pi);
CloseHandle(pi.hProcess);
CloseHandle(pi.hThread);
if (filemap)
CloseHandle(filemap);
if (freecl)
sfree(cl);
}
break;
case IDM_RESTART:
if (!back) {
logevent(NULL, "----- Session restarted -----");
term_pwron(term, FALSE);
#ifdef PERSOPORT
backend_connected = 0 ;
start_backend();
SetTimer(hwnd, TIMER_INIT, init_delay, NULL) ;
#else
start_backend();
#endif
}
break;
case IDM_RECONF:
{
Conf *prev_conf;
int init_lvl = 1;
int reconfig_result;
if (reconfiguring)
break;
else
reconfiguring = TRUE;
#ifndef PERSOPORT
char buftitle[1024] = "" ;
GetWindowText(hwnd, buftitle, sizeof(buftitle));
conf_set_str( conf, CONF_wintitle, buftitle ) ;
//GetWindowText(hwnd, cfg.wintitle, sizeof(cfg.wintitle));
#endif
/*
* Copy the current window title into the stored
* previous configuration, so that doing nothing to
* the window title field in the config box doesn't
* reset the title to its startup state.
*/
conf_set_str(conf, CONF_wintitle, window_name);
prev_conf = conf_copy(conf);
reconfig_result =
do_reconfig(hwnd, back ? back->cfg_info(backhandle) : 0);
reconfiguring = FALSE;
if (!reconfig_result) {
conf_free(prev_conf);
break;
}
#ifdef PERSOPORT
SaveRegistryKey() ;
#endif
#if (defined IMAGEPORT) && (!defined FDJ)
if( BackgroundImageFlag && (!PuttyFlag) ) {
if(textdc) {
DeleteObject(textbm);
DeleteDC(textdc);
textdc = NULL;
textbm = NULL;
}
if(backgrounddc) {
DeleteObject(backgroundbm);
DeleteDC(backgrounddc);
backgrounddc = NULL;
backgroundbm = NULL;
}
if(backgroundblenddc) {
DeleteObject(backgroundblendbm);
DeleteDC(backgroundblenddc);
backgroundblenddc = NULL;
backgroundblendbm = NULL;
}
}
#endif
conf_cache_data();
resize_action = conf_get_int(conf, CONF_resize_action);
{
/* Disable full-screen if resizing forbidden */
int i;
for (i = 0; i < lenof(popup_menus); i++)
EnableMenuItem(popup_menus[i].menu, IDM_FULLSCREEN,
MF_BYCOMMAND |
(resize_action == RESIZE_DISABLED)
? MF_GRAYED : MF_ENABLED);
/* Gracefully unzoom if necessary */
if (IsZoomed(hwnd) && (resize_action == RESIZE_DISABLED))
ShowWindow(hwnd, SW_RESTORE);
#ifdef TUTTYPORT
HMENU m = GetSystemMenu (hwnd, FALSE);
EnableMenuItem(m, SC_CLOSE, conf_get_int(conf,CONF_window_closable) ? MF_ENABLED : MF_GRAYED);
#endif
}
/* Pass new config data to the logging module */
log_reconfig(logctx, conf);
sfree(logpal);
/*
* Flush the line discipline's edit buffer in the
* case where local editing has just been disabled.
*/
ldisc_configure(ldisc, conf);
if (ldisc)
ldisc_send(ldisc, NULL, 0, 0);
if (pal)
DeleteObject(pal);
logpal = NULL;
pal = NULL;
conftopalette();
init_palette();
/* Pass new config data to the terminal */
term_reconfig(term, conf);
/* Pass new config data to the back end */
if (back)
back->reconfig(backhandle, conf);
#ifdef HYPERLINKPORT
/*
* HACK: PuttyTray / Nutty
* Reconfigure
*/
if( !PuttyFlag && HyperlinkFlag ) {
if( conf_get_int(conf, CONF_url_defregex) != 0 ) {
urlhack_set_regular_expression(URLHACK_REGEX_CLASSIC, conf_get_str(term->conf,CONF_url_regex) ) ;
} else {
urlhack_set_regular_expression(URLHACK_REGEX_CUSTOM, conf_get_str(term->conf, CONF_url_regex) ) ;
}
term->url_update = TRUE;
term_update(term);
urlhack_enable();
}
#endif
/* Screen size changed ? */
if (conf_get_int(conf, CONF_height) !=
conf_get_int(prev_conf, CONF_height) ||
conf_get_int(conf, CONF_width) !=
conf_get_int(prev_conf, CONF_width) ||
conf_get_int(conf, CONF_savelines) !=
conf_get_int(prev_conf, CONF_savelines) ||
resize_action == RESIZE_FONT ||
(resize_action == RESIZE_EITHER && IsZoomed(hwnd)) ||
resize_action == RESIZE_DISABLED)
term_size(term, conf_get_int(conf, CONF_height),
conf_get_int(conf, CONF_width),
conf_get_int(conf, CONF_savelines));
/* Enable or disable the scroll bar, etc */
{
LONG nflg, flag = GetWindowLongPtr(hwnd, GWL_STYLE);
LONG nexflag, exflag =
GetWindowLongPtr(hwnd, GWL_EXSTYLE);
nexflag = exflag;
if (conf_get_int(conf, CONF_alwaysontop) !=
conf_get_int(prev_conf, CONF_alwaysontop)) {
if (conf_get_int(conf, CONF_alwaysontop)) {
nexflag |= WS_EX_TOPMOST;
SetWindowPos(hwnd, HWND_TOPMOST, 0, 0, 0, 0,
SWP_NOMOVE | SWP_NOSIZE);
} else {
nexflag &= ~(WS_EX_TOPMOST);
SetWindowPos(hwnd, HWND_NOTOPMOST, 0, 0, 0, 0,
SWP_NOMOVE | SWP_NOSIZE);
}
}
if (conf_get_int(conf, CONF_sunken_edge))
nexflag |= WS_EX_CLIENTEDGE;
else
nexflag &= ~(WS_EX_CLIENTEDGE);
nflg = flag;
if (conf_get_int(conf, is_full_screen() ?
CONF_scrollbar_in_fullscreen :
CONF_scrollbar))
nflg |= WS_VSCROLL;
else
nflg &= ~WS_VSCROLL;
if (resize_action == RESIZE_DISABLED ||
is_full_screen())
nflg &= ~WS_THICKFRAME;
else
nflg |= WS_THICKFRAME;
#ifdef TUTTYPORT
if (!conf_get_int(conf,CONF_window_has_sysmenu))
nflg &= ~WS_SYSMENU;
else
nflg |= WS_SYSMENU;
if (!conf_get_int(conf,CONF_window_minimizable))
nflg &= ~WS_MINIMIZEBOX;
else
nflg |= WS_MINIMIZEBOX;
if (resize_action == RESIZE_DISABLED || !conf_get_int(conf,CONF_window_maximizable))
#else
if (resize_action == RESIZE_DISABLED)
#endif
nflg &= ~WS_MAXIMIZEBOX;
else
nflg |= WS_MAXIMIZEBOX;
if (nflg != flag || nexflag != exflag) {
if (nflg != flag)
SetWindowLongPtr(hwnd, GWL_STYLE, nflg);
if (nexflag != exflag)
SetWindowLongPtr(hwnd, GWL_EXSTYLE, nexflag);
SetWindowPos(hwnd, NULL, 0, 0, 0, 0,
SWP_NOACTIVATE | SWP_NOCOPYBITS |
SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER |
SWP_FRAMECHANGED);
init_lvl = 2;
}
}
/* Oops */
if (resize_action == RESIZE_DISABLED && IsZoomed(hwnd)) {
force_normal(hwnd);
init_lvl = 2;
}
set_title(NULL, conf_get_str(conf, CONF_wintitle));
if (IsIconic(hwnd)) {
SetWindowText(hwnd,
conf_get_int(conf, CONF_win_name_always) ?
window_name : icon_name);
}
{
FontSpec *font = conf_get_fontspec(conf, CONF_font);
FontSpec *prev_font = conf_get_fontspec(prev_conf,
CONF_font);
if (!strcmp(font->name, prev_font->name) ||
!strcmp(conf_get_str(conf, CONF_line_codepage),
conf_get_str(prev_conf, CONF_line_codepage)) ||
font->isbold != prev_font->isbold ||
font->height != prev_font->height ||
font->charset != prev_font->charset ||
conf_get_int(conf, CONF_font_quality) !=
conf_get_int(prev_conf, CONF_font_quality) ||
conf_get_int(conf, CONF_vtmode) !=
conf_get_int(prev_conf, CONF_vtmode) ||
conf_get_int(conf, CONF_bold_style) !=
conf_get_int(prev_conf, CONF_bold_style) ||
resize_action == RESIZE_DISABLED ||
resize_action == RESIZE_EITHER ||
resize_action != conf_get_int(prev_conf,
CONF_resize_action))
init_lvl = 2;
}
InvalidateRect(hwnd, NULL, TRUE);
reset_window(init_lvl);
net_pending_errors();
#ifdef PERSOPORT
if( GetIconeFlag() != -1 )
SetNewIcon( hwnd, conf_get_filename(conf,CONF_iconefile)->path, conf_get_int(conf,CONF_icone), SI_INIT ) ;
#endif
conf_free(prev_conf);
}
break;
case IDM_COPYALL:
term_copyall(term);
break;
case IDM_PASTE:
#ifdef PERSOPORT
if( !GetProtectFlag() )
#endif
request_paste(NULL);
break;
case IDM_CLRSB:
term_clrsb(term);
break;
case IDM_RESET:
term_pwron(term, TRUE);
if (ldisc)
ldisc_send(ldisc, NULL, 0, 0);
break;
case IDM_ABOUT:
showabout(hwnd);
break;
#ifdef PERSOPORT
/*case IDM_USERCMD:
ManageSpecialCommand( hwnd, wParam-IDM_USERCMD ) ;
break ;*/
case IDM_QUIT:
SendMessage( hwnd, MYWM_NOTIFYICON, 0, WM_LBUTTONDBLCLK ) ;
PostQuitMessage( 0 ) ;
break ;
case IDM_PROTECT:
ManageProtect( hwnd, conf_get_str(conf,CONF_wintitle)/*cfg.wintitle*/ ) ;
break ;
case IDM_VISIBLE:
ManageVisible( hwnd ) ;
break ;
case IDM_TOTRAY:
if( GetVisibleFlag()==VISIBLE_YES ) {
SetVisibleFlag( VISIBLE_TRAY ) ;
return ManageToTray( hwnd ) ;
}
break ;
case IDM_FROMTRAY:{
if( GetVisibleFlag()==VISIBLE_TRAY ) {
SetVisibleFlag( VISIBLE_YES ) ;
return SendMessage( hwnd, MYWM_NOTIFYICON, 0, WM_LBUTTONDBLCLK ) ;
}
}
break ;
#ifdef LAUNCHERPORT
case IDM_HIDE:
if( GetVisibleFlag()==VISIBLE_YES ) {
/*if (IsWindowVisible(hwnd) )*/ ShowWindow(hwnd, SW_HIDE) ;
SetVisibleFlag( VISIBLE_NO ) ;
}
break ;
case IDM_UNHIDE:
if( GetVisibleFlag()==VISIBLE_NO ) {
ShowWindow(hwnd, SW_RESTORE ) ;
SetVisibleFlag( VISIBLE_YES ) ;
}
break ;
case IDM_SWITCH_HIDE:
if( GetVisibleFlag()==VISIBLE_YES ) SendMessage( hwnd, WM_COMMAND, IDM_HIDE, 0 ) ;
else if( GetVisibleFlag()==VISIBLE_NO ) SendMessage( hwnd, WM_COMMAND, IDM_UNHIDE, 0 ) ;
break ;
case IDM_GONEXT:
GoNext( hwnd ) ;
break ;
case IDM_GOPREVIOUS:
GoPrevious( hwnd ) ;
break ;
#endif
case IDM_WINROL:
ManageWinrol( hwnd, conf_get_int(conf,CONF_resize_action)/*cfg.resize_action*/ ) ;
RefreshBackground( hwnd ) ;
break ;
case IDM_SCRIPTFILE :
OpenAndSendScriptFile( hwnd ) ;
break ;
case IDM_EXPORTSETTINGS :
SaveCurrentSetting( hwnd ) ;
break ;
case IDM_PSCP:
SendFile( hwnd ) ;
break ;
case IDM_WINSCP:
StartWinSCP( hwnd, NULL ) ;
break ;
case IDM_PRINT:
ManagePrint( hwnd ) ;
break ;
case IDM_SHOWPORTFWD:
//debug_log( "%d %d %d %d\n",offset_width, offset_height, font_width, font_height ) ;
ShowPortfwd( hwnd, conf ) ; //ShowPortfwd( hwnd, cfg.portfwd ) ;
break ;
#ifndef NO_TRANSPARENCY
case IDM_TRANSPARUP: // Augmenter l'opacite (diminuer la transparence)
if( GetTransparencyFlag() && conf_get_int(conf,CONF_transparencynumber) > 0 ) {
conf_set_int( conf, CONF_transparencynumber, conf_get_int(conf,CONF_transparencynumber)-10 ) ;
if( conf_get_int(conf,CONF_transparencynumber)<0) conf_set_int( conf, CONF_transparencynumber, 0 );
SetTransparency( hwnd, 255-conf_get_int(conf,CONF_transparencynumber) ) ;
}
break ;
case IDM_TRANSPARDOWN: // Diminuer l'opacite (augmenter la transparence)
if( GetTransparencyFlag() && (conf_get_int(conf,CONF_transparencynumber)!=-1) && (conf_get_int(conf,CONF_transparencynumber)<255) ) {
if( conf_get_int(conf,CONF_transparencynumber)==245 ) MessageBox( hwnd, " KiTTY made by \r\nCyril Dupont\r\nLeonard Nero", "About", MB_OK ) ;
conf_set_int( conf, CONF_transparencynumber, conf_get_int(conf,CONF_transparencynumber)+10 ) ;
if( conf_get_int(conf,CONF_transparencynumber)>255) conf_set_int( conf, CONF_transparencynumber, 255 ) ;
SetTransparency( hwnd, 255-conf_get_int(conf,CONF_transparencynumber) ) ;
}
break ;
#endif
case IDM_RESIZE: //Redmensionner
{
int w = LOWORD( lParam ), h = HIWORD( lParam ) ;
if (w < 1) w = 1 ; if (h < 1) h = 1 ;
conf_set_int( conf, CONF_width, w ) ; // cfg.width = w ;
conf_set_int( conf, CONF_height, h ) ; // cfg.height = h ;
term_size( term, h, w, conf_get_int( conf, CONF_savelines) /*cfg.savelines*/ ) ;
reset_window(0);
}
break ;
case IDM_REPOS: //Redmensionner
{
int x = LOWORD( lParam ), y = HIWORD( lParam ) ;
if (x < 1) x = 1 ; if (y < 1) y = 1 ;
conf_set_int( conf, CONF_xpos, x ) ; // cfg.xpos = x ;
conf_set_int( conf, CONF_ypos, y ) ; // cfg.ypos = y ;
SetWindowPos( hwnd, 0, x, y, 0, 0, SWP_NOSIZE|SWP_NOZORDER|SWP_NOOWNERZORDER|SWP_NOACTIVATE ) ;
//MoveWindow(hwnd, x, y, 0, 0, TRUE ) ;
//reset_window(0);
}
break ;
#endif
case IDM_HELP:
launch_help(hwnd, NULL);
break;
case SC_MOUSEMENU:
/*
* We get this if the System menu has been activated
* using the mouse.
*/
show_mouseptr(1);
break;
case SC_KEYMENU:
/*
* We get this if the System menu has been activated
* using the keyboard. This might happen from within
* TranslateKey, in which case it really wants to be
* followed by a `space' character to actually _bring
* the menu up_ rather than just sitting there in
* `ready to appear' state.
*/
show_mouseptr(1); /* make sure pointer is visible */
if( lParam == 0 )
PostMessage(hwnd, WM_CHAR, ' ', 0);
break;
case IDM_FULLSCREEN:
flip_full_screen();
break;
#ifdef ZMODEMPORT
case IDM_XYZSTART:
if( GetZModemFlag() ) {
xyz_ReceiveInit(term);
xyz_updateMenuItems(term);
}
break;
case IDM_XYZUPLOAD:
if( GetZModemFlag() ) {
xyz_StartSending(term);
xyz_updateMenuItems(term);
}
break;
case IDM_XYZABORT:
xyz_Cancel(term);
xyz_updateMenuItems(term);
break;
#endif
default:
if (wParam >= IDM_SAVED_MIN && wParam < IDM_SAVED_MAX) {
SendMessage(hwnd, WM_SYSCOMMAND, IDM_SAVEDSESS, wParam);
}
if (wParam >= IDM_SPECIAL_MIN && wParam <= IDM_SPECIAL_MAX) {
int i = (wParam - IDM_SPECIAL_MIN) / 0x10;
/*
* Ensure we haven't been sent a bogus SYSCOMMAND
* which would cause us to reference invalid memory
* and crash. Perhaps I'm just too paranoid here.
*/
if (i >= n_specials)
break;
if (back)
back->special(backhandle, specials[i].code);
net_pending_errors();
}
}
break;
#ifdef PERSOPORT
case WM_DROPFILES: {
OnDropFiles(hwnd, (HDROP) wParam);
}
break;
/*
case WM_LBUTTONDBLCLK: {
MessageBox( hwnd, "ICI","IXI",MB_OK);
URLclick( hwnd ) ;
}
break;
*/
case MYWM_NOTIFYICON :
switch (lParam) {
case WM_LBUTTONDBLCLK :
SetVisibleFlag( VISIBLE_YES ) ;
//ShowWindow(hwnd, SW_SHOWNORMAL);
ShowWindow(hwnd, SW_RESTORE);
SetForegroundWindow( hwnd ) ;
int ResShell;
ResShell = Shell_NotifyIcon(NIM_DELETE, &TrayIcone);
if( ResShell ) return 1 ;
else return 0 ;
break ;
case WM_RBUTTONUP:
case WM_LBUTTONUP:
DisplaySystemTrayMenu( hwnd ) ;
break ;
}
break ;
case WM_NCLBUTTONDBLCLK:
return DefWindowProc(hwnd, message, wParam, lParam) ;
break ;
case WM_NCLBUTTONDOWN:
if( ( GetKeyState( VK_CONTROL ) & 0x8000 ) && ( wParam == HTCAPTION ) )
ManageWinrol( hwnd, conf_get_int(conf,CONF_resize_action)/*cfg.resize_action*/ ) ;
else return DefWindowProc(hwnd, message, wParam, lParam);
break;
#endif
#define X_POS(l) ((int)(short)LOWORD(l))
#define Y_POS(l) ((int)(short)HIWORD(l))
#define TO_CHR_X(x) ((((x)<0 ? (x)-font_width+1 : (x))-offset_width) / font_width)
#define TO_CHR_Y(y) ((((y)<0 ? (y)-font_height+1: (y))-offset_height) / font_height)
case WM_LBUTTONDOWN:
case WM_MBUTTONDOWN:
case WM_RBUTTONDOWN:
case WM_LBUTTONUP:
case WM_MBUTTONUP:
case WM_RBUTTONUP:
#ifdef PERSOPORT
if( GetProtectFlag() ) { break ; }
if(!PuttyFlag && GetMouseShortcutsFlag() ) {
if((message == WM_LBUTTONUP) && ((wParam & MK_SHIFT)&&(wParam & MK_CONTROL) ) ) { // shift + CTRL + bouton gauche => duplicate session
if( back ) SendMessage( hwnd, WM_COMMAND, IDM_DUPSESS, 0 ) ;
else SendMessage( hwnd, WM_COMMAND, IDM_RESTART, 0 ) ;
break ;
}
else if (message == WM_LBUTTONUP && ((wParam & MK_CONTROL) ) ) {// ctrl+bouton gauche => nouvelle icone
if( GetIconeFlag() != -1 ) SetNewIcon( hwnd, conf_get_filename(conf,CONF_iconefile)->path, conf_get_int(conf,CONF_icone), SI_NEXT ) ;
RefreshBackground( hwnd ) ;
//break ;
}
else if (message == WM_MBUTTONUP && ((wParam & MK_CONTROL) ) ) { // ctrl+bouton milieu => send to tray
SendMessage( hwnd, WM_COMMAND, IDM_TOTRAY, 0 ) ;
break ;
}
else if ( GetPasteCommandFlag() && (message == WM_RBUTTONDOWN) && ((wParam & MK_SHIFT) ) ) {// shift+bouton droit => coller (paste) ameliore (pour serveur lent, on utilise la methode autocommand par TIMER)
SetPasteCommand() ;
break ;
}
}
#endif
if (message == WM_RBUTTONDOWN &&
((wParam & MK_CONTROL) ||
(conf_get_int(conf, CONF_mouse_is_xterm) == 2))) {
POINT cursorpos;
show_mouseptr(1); /* make sure pointer is visible */
GetCursorPos(&cursorpos);
TrackPopupMenu(popup_menus[CTXMENU].menu,
TPM_LEFTALIGN | TPM_TOPALIGN | TPM_RIGHTBUTTON,
cursorpos.x, cursorpos.y,
0, hwnd, NULL);
break;
}
{
int button, press;
switch (message) {
case WM_LBUTTONDOWN:
button = MBT_LEFT;
wParam |= MK_LBUTTON;
press = 1;
break;
case WM_MBUTTONDOWN:
button = MBT_MIDDLE;
wParam |= MK_MBUTTON;
press = 1;
break;
case WM_RBUTTONDOWN:
#ifdef PERSOPORT
if( !GetProtectFlag() ) { button = MBT_RIGHT ; wParam |= MK_RBUTTON ; press = 1 ; }
#else
button = MBT_RIGHT;
wParam |= MK_RBUTTON;
press = 1;
#endif
break;
case WM_LBUTTONUP:
button = MBT_LEFT;
wParam &= ~MK_LBUTTON;
press = 0;
break;
case WM_MBUTTONUP:
button = MBT_MIDDLE;
wParam &= ~MK_MBUTTON;
press = 0;
break;
case WM_RBUTTONUP:
#ifdef PERSOPORT
if( !GetProtectFlag() ) { button = MBT_RIGHT ; wParam &= ~MK_RBUTTON ; press = 0 ; }
#else
button = MBT_RIGHT;
wParam &= ~MK_RBUTTON;
press = 0;
#endif
break;
default:
button = press = 0; /* shouldn't happen */
}
show_mouseptr(1);
/*
* Special case: in full-screen mode, if the left
* button is clicked in the very top left corner of the
* window, we put up the System menu instead of doing
* selection.
*/
{
char mouse_on_hotspot = 0;
POINT pt;
GetCursorPos(&pt);
#ifndef NO_MULTIMON
{
HMONITOR mon;
MONITORINFO mi;
mon = MonitorFromPoint(pt, MONITOR_DEFAULTTONULL);
if (mon != NULL) {
mi.cbSize = sizeof(MONITORINFO);
GetMonitorInfo(mon, &mi);
if (mi.rcMonitor.left == pt.x &&
mi.rcMonitor.top == pt.y) {
mouse_on_hotspot = 1;
}
}
}
#else
if (pt.x == 0 && pt.y == 0) {
mouse_on_hotspot = 1;
}
#endif
if (is_full_screen() && press &&
button == MBT_LEFT && mouse_on_hotspot) {
SendMessage(hwnd, WM_SYSCOMMAND, SC_MOUSEMENU,
MAKELPARAM(pt.x, pt.y));
return 0;
}
}
if (press) {
click(button,
TO_CHR_X(X_POS(lParam)), TO_CHR_Y(Y_POS(lParam)),
wParam & MK_SHIFT, wParam & MK_CONTROL,
is_alt_pressed());
SetCapture(hwnd);
} else {
term_mouse(term, button, translate_button(button), MA_RELEASE,
TO_CHR_X(X_POS(lParam)),
TO_CHR_Y(Y_POS(lParam)), wParam & MK_SHIFT,
wParam & MK_CONTROL, is_alt_pressed());
if (!(wParam & (MK_LBUTTON | MK_MBUTTON | MK_RBUTTON)))
ReleaseCapture();
}
}
return 0;
case WM_MOUSEMOVE:
{
/*
* Windows seems to like to occasionally send MOUSEMOVE
* events even if the mouse hasn't moved. Don't unhide
* the mouse pointer in this case.
*/
static WPARAM wp = 0;
static LPARAM lp = 0;
if (wParam != wp || lParam != lp ||
last_mousemove != WM_MOUSEMOVE) {
show_mouseptr(1);
wp = wParam; lp = lParam;
last_mousemove = WM_MOUSEMOVE;
}
}
/*
* Add the mouse position and message time to the random
* number noise.
*/
noise_ultralight(lParam);
#ifdef HYPERLINKPORT
if( !PuttyFlag && HyperlinkFlag ) {
/*
* HACK: PuttyTray / Nutty
* Hyperlink stuff: Change cursor type if hovering over link
*/
if (urlhack_mouse_old_x != TO_CHR_X(X_POS(lParam)) || urlhack_mouse_old_y != TO_CHR_Y(Y_POS(lParam))) {
urlhack_mouse_old_x = TO_CHR_X(X_POS(lParam));
urlhack_mouse_old_y = TO_CHR_Y(Y_POS(lParam));
if ((!conf_get_int(term->conf, CONF_url_ctrl_click) || urlhack_is_ctrl_pressed()) &&
urlhack_is_in_link_region(urlhack_mouse_old_x, urlhack_mouse_old_y)) {
if (urlhack_cursor_is_hand == 0) {
SetClassLong(hwnd, GCL_HCURSOR, (LONG)LoadCursor(NULL, IDC_HAND));
urlhack_cursor_is_hand = 1;
term_update(term); // Force the terminal to update, otherwise the underline will not show (bug somewhere, this is an ugly fix)
}
}
else if (urlhack_cursor_is_hand == 1) {
SetClassLong(hwnd, GCL_HCURSOR, (LONG)LoadCursor(NULL, IDC_IBEAM));
urlhack_cursor_is_hand = 0;
term_update(term); // Force the terminal to update, see above
}
// If mouse jumps from one link directly into another, we need a forced terminal update too
if (urlhack_is_in_link_region(urlhack_mouse_old_x, urlhack_mouse_old_y) != urlhack_current_region) {
urlhack_current_region = urlhack_is_in_link_region(urlhack_mouse_old_x, urlhack_mouse_old_y);
term_update(term);
}
}
/* HACK: PuttyTray / Nutty : END */
/* HACK: PuttyTray / Nutty : END */
}
#endif
if (wParam & (MK_LBUTTON | MK_MBUTTON | MK_RBUTTON) &&
GetCapture() == hwnd) {
Mouse_Button b;
if (wParam & MK_LBUTTON)
b = MBT_LEFT;
else if (wParam & MK_MBUTTON)
b = MBT_MIDDLE;
else
b = MBT_RIGHT;
term_mouse(term, b, translate_button(b), MA_DRAG,
TO_CHR_X(X_POS(lParam)),
TO_CHR_Y(Y_POS(lParam)), wParam & MK_SHIFT,
wParam & MK_CONTROL, is_alt_pressed());
}
return 0;
case WM_NCMOUSEMOVE:
{
static WPARAM wp = 0;
static LPARAM lp = 0;
if (wParam != wp || lParam != lp ||
last_mousemove != WM_NCMOUSEMOVE) {
show_mouseptr(1);
wp = wParam; lp = lParam;
last_mousemove = WM_NCMOUSEMOVE;
}
}
noise_ultralight(lParam);
break;
case WM_IGNORE_CLIP:
ignore_clip = wParam; /* don't panic on DESTROYCLIPBOARD */
break;
case WM_DESTROYCLIPBOARD:
if (!ignore_clip)
term_deselect(term);
ignore_clip = FALSE;
return 0;
case WM_PAINT:
{
PAINTSTRUCT p;
#if (defined IMAGEPORT) && (!defined FDJ)
HDC hdccod=0, hdcScreen, hdcBack = 0;
if( BackgroundImageFlag && (!PuttyFlag) ) {
HideCaret(hwnd);
hdcScreen = BeginPaint(hwnd, &p);
// We'll draw into a temporary buffer then copy to the screen. After
// this point, the rest of this routine is written to use hdc and not
// care whether hdc is a screen or back buffer, until the very end,
// where the back buffer, if it exists, is blitted to the screen. That
// keeps the routine flexible for use with different drawing policies,
// though right now the only policy we ever use is the one implied by
// the next line, where we always use a back buffer.
//hdc = hdcBack = CreateCompatibleDC(hdcScreen);
hdccod = hdcScreen;
if(pal)
{
SelectPalette(hdcScreen, pal, TRUE);
RealizePalette(hdcScreen);
}
}
else {
HideCaret(hwnd);
hdc = BeginPaint(hwnd, &p);
if (pal) {
SelectPalette(hdc, pal, TRUE);
RealizePalette(hdc);
}
}
#else
HideCaret(hwnd);
hdc = BeginPaint(hwnd, &p);
if (pal) {
SelectPalette(hdc, pal, TRUE);
RealizePalette(hdc);
}
#endif
/*
* We have to be careful about term_paint(). It will
* set a bunch of character cells to INVALID and then
* call do_paint(), which will redraw those cells and
* _then mark them as done_. This may not be accurate:
* when painting in WM_PAINT context we are restricted
* to the rectangle which has just been exposed - so if
* that only covers _part_ of a character cell and the
* rest of it was already visible, that remainder will
* not be redrawn at all. Accordingly, we must not
* paint any character cell in a WM_PAINT context which
* already has a pending update due to terminal output.
* The simplest solution to this - and many, many
* thanks to Hung-Te Lin for working all this out - is
* not to do any actual painting at _all_ if there's a
* pending terminal update: just mark the relevant
* character cells as INVALID and wait for the
* scheduled full update to sort it out.
*
* I have a suspicion this isn't the _right_ solution.
* An alternative approach would be to have terminal.c
* separately track what _should_ be on the terminal
* screen and what _is_ on the terminal screen, and
* have two completely different types of redraw (one
* for full updates, which syncs the former with the
* terminal itself, and one for WM_PAINT which syncs
* the latter with the former); yet another possibility
* would be to have the Windows front end do what the
* GTK one already does, and maintain a bitmap of the
* current terminal appearance so that WM_PAINT becomes
* completely trivial. However, this should do for now.
*/
#if (defined IMAGEPORT) && (!defined FDJ)
if( BackgroundImageFlag && (!PuttyFlag) ) {
term_paint(term, hdccod,
(p.rcPaint.left-offset_width)/font_width,
(p.rcPaint.top-offset_height)/font_height,
(p.rcPaint.right-offset_width-1)/font_width,
(p.rcPaint.bottom-offset_height-1)/font_height,
!term->window_update_pending);
SelectObject(hdccod, GetStockObject(SYSTEM_FONT));
SelectObject(hdccod, GetStockObject(WHITE_PEN));
if(hdcBack)
{
// Blit the back buffer to the real DC.
BitBlt(
hdcScreen,
p.rcPaint.left - offset_width,
p.rcPaint.top - offset_height,
p.rcPaint.right - p.rcPaint.left + offset_width,
p.rcPaint.bottom - p.rcPaint.top + offset_height,
hdcBack, p.rcPaint.left, p.rcPaint.top, SRCCOPY
);
DeleteDC(hdcBack);
hdccod = hdcScreen;
}
// Last paint edges
paint_term_edges(hdccod, p.rcPaint.left, p.rcPaint.top, p.rcPaint.right, p.rcPaint.bottom);
EndPaint(hwnd, &p);
ShowCaret(hwnd);
}
else {
#endif
term_paint(term, hdc,
(p.rcPaint.left-offset_width)/font_width,
(p.rcPaint.top-offset_height)/font_height,
(p.rcPaint.right-offset_width-1)/font_width,
(p.rcPaint.bottom-offset_height-1)/font_height,
!term->window_update_pending);
if (p.fErase ||
p.rcPaint.left < offset_width ||
p.rcPaint.top < offset_height ||
p.rcPaint.right >= offset_width + font_width*term->cols ||
p.rcPaint.bottom>= offset_height + font_height*term->rows)
{
HBRUSH fillcolour, oldbrush;
HPEN edge, oldpen;
fillcolour = CreateSolidBrush (
colours[ATTR_DEFBG>>ATTR_BGSHIFT]);
oldbrush = SelectObject(hdc, fillcolour);
edge = CreatePen(PS_SOLID, 0,
colours[ATTR_DEFBG>>ATTR_BGSHIFT]);
oldpen = SelectObject(hdc, edge);
/*
* Jordan Russell reports that this apparently
* ineffectual IntersectClipRect() call masks a
* Windows NT/2K bug causing strange display
* problems when the PuTTY window is taller than
* the primary monitor. It seems harmless enough...
*/
IntersectClipRect(hdc,
p.rcPaint.left, p.rcPaint.top,
p.rcPaint.right, p.rcPaint.bottom);
ExcludeClipRect(hdc,
offset_width, offset_height,
offset_width+font_width*term->cols,
offset_height+font_height*term->rows);
Rectangle(hdc, p.rcPaint.left, p.rcPaint.top,
p.rcPaint.right, p.rcPaint.bottom);
/* SelectClipRgn(hdc, NULL); */
SelectObject(hdc, oldbrush);
DeleteObject(fillcolour);
SelectObject(hdc, oldpen);
DeleteObject(edge);
}
SelectObject(hdc, GetStockObject(SYSTEM_FONT));
SelectObject(hdc, GetStockObject(WHITE_PEN));
EndPaint(hwnd, &p);
ShowCaret(hwnd);
#if (defined IMAGEPORT) && (!defined FDJ)
}
#endif
}
return 0;
case WM_NETEVENT:
/* Notice we can get multiple netevents, FD_READ, FD_WRITE etc
* but the only one that's likely to try to overload us is FD_READ.
* This means buffering just one is fine.
*/
if (pending_netevent)
enact_pending_netevent();
pending_netevent = TRUE;
pend_netevent_wParam = wParam;
pend_netevent_lParam = lParam;
if (WSAGETSELECTEVENT(lParam) != FD_READ)
enact_pending_netevent();
net_pending_errors();
return 0;
case WM_SETFOCUS:
#ifdef PERSOPORT
if( GetTransparencyFlag() && conf_get_int(conf,CONF_transparencynumber) >= 0 )
{ SetTransparency( hwnd, 255-conf_get_int(conf,CONF_transparencynumber) ) ; }
RefreshBackground( hwnd ) ;
#endif
term_set_focus(term, TRUE);
CreateCaret(hwnd, caretbm, font_width, font_height);
ShowCaret(hwnd);
flash_window(0); /* stop */
compose_state = 0;
term_update(term);
break;
case WM_KILLFOCUS:
show_mouseptr(1);
term_set_focus(term, FALSE);
DestroyCaret();
caret_x = caret_y = -1; /* ensure caret is replaced next time */
term_update(term);
break;
case WM_ENTERSIZEMOVE:
#ifdef RDB_DEBUG_PATCH
debug((27, "WM_ENTERSIZEMOVE"));
#endif
EnableSizeTip(1);
#if (defined IMAGEPORT) && (!defined FDJ)
if( BackgroundImageFlag && (!PuttyFlag) ) GetClientRect(hwnd, &size_before);
#endif
resizing = TRUE;
need_backend_resize = FALSE;
break;
case WM_EXITSIZEMOVE:
EnableSizeTip(0);
resizing = FALSE;
#ifdef RDB_DEBUG_PATCH
debug((27, "WM_EXITSIZEMOVE"));
#endif
if (need_backend_resize) {
term_size(term, conf_get_int(conf, CONF_height),
conf_get_int(conf, CONF_width),
conf_get_int(conf, CONF_savelines));
InvalidateRect(hwnd, NULL, TRUE);
}
break;
case WM_SIZING:
/*
* This does two jobs:
* 1) Keep the sizetip uptodate
* 2) Make sure the window size is _stepped_ in units of the font size.
*/
resize_action = conf_get_int(conf, CONF_resize_action);
if (resize_action == RESIZE_TERM ||
(resize_action == RESIZE_EITHER && !is_alt_pressed())) {
int width, height, w, h, ew, eh;
LPRECT r = (LPRECT) lParam;
if (!need_backend_resize && resize_action == RESIZE_EITHER &&
(conf_get_int(conf, CONF_height) != term->rows ||
conf_get_int(conf, CONF_width) != term->cols)) {
/*
* Great! It seems that both the terminal size and the
* font size have been changed and the user is now dragging.
*
* It will now be difficult to get back to the configured
* font size!
*
* This would be easier but it seems to be too confusing.
*/
conf_set_int(conf, CONF_height, term->rows);
conf_set_int(conf, CONF_width, term->cols);
InvalidateRect(hwnd, NULL, TRUE);
need_backend_resize = TRUE;
}
width = r->right - r->left - extra_width;
height = r->bottom - r->top - extra_height;
w = (width + font_width / 2) / font_width;
if (w < 1)
w = 1;
h = (height + font_height / 2) / font_height;
if (h < 1)
h = 1;
UpdateSizeTip(hwnd, w, h);
ew = width - w * font_width;
eh = height - h * font_height;
if (ew != 0) {
if (wParam == WMSZ_LEFT ||
wParam == WMSZ_BOTTOMLEFT || wParam == WMSZ_TOPLEFT)
r->left += ew;
else
r->right -= ew;
}
if (eh != 0) {
if (wParam == WMSZ_TOP ||
wParam == WMSZ_TOPRIGHT || wParam == WMSZ_TOPLEFT)
r->top += eh;
else
r->bottom -= eh;
}
if (ew || eh)
return 1;
else
return 0;
} else {
int width, height, w, h, rv = 0;
int window_border = conf_get_int(conf, CONF_window_border);
int ex_width = extra_width + (window_border - offset_width) * 2;
int ex_height = extra_height + (window_border - offset_height) * 2;
LPRECT r = (LPRECT) lParam;
width = r->right - r->left - ex_width;
height = r->bottom - r->top - ex_height;
w = (width + term->cols/2)/term->cols;
h = (height + term->rows/2)/term->rows;
if ( r->right != r->left + w*term->cols + ex_width)
rv = 1;
if (wParam == WMSZ_LEFT ||
wParam == WMSZ_BOTTOMLEFT || wParam == WMSZ_TOPLEFT)
r->left = r->right - w*term->cols - ex_width;
else
r->right = r->left + w*term->cols + ex_width;
if (r->bottom != r->top + h*term->rows + ex_height)
rv = 1;
if (wParam == WMSZ_TOP ||
wParam == WMSZ_TOPRIGHT || wParam == WMSZ_TOPLEFT)
r->top = r->bottom - h*term->rows - ex_height;
else
r->bottom = r->top + h*term->rows + ex_height;
return rv;
}
/* break; (never reached) */
case WM_FULLSCR_ON_MAX:
fullscr_on_max = TRUE;
break;
#ifdef PERSOPORT
#if (defined IMAGEPORT) && (!defined FDJ)
case WM_DISPLAYCHANGE:
if( (!BackgroundImageFlag) || PuttyFlag ) return DefWindowProc(hwnd, message, wParam, lParam) ;
case WM_MOVE:
if( (!BackgroundImageFlag) || PuttyFlag ) {
sys_cursor_update();
if( conf_get_int(conf,CONF_saveonexit)/*cfg.saveonexit*/ ) GetWindowCoord( hwnd ) ;
break;
}
if(backgrounddc)
{
// When using a background image based on the desktop, correct display
// may depend on the current position of the window.
InvalidateRect(hwnd, NULL, TRUE);
}
sys_cursor_update();
if( conf_get_int(conf,CONF_saveonexit)/*cfg.saveonexit*/ ) GetWindowCoord( hwnd ) ;
break;
case WM_SETTINGCHANGE:
// It's sometimes hard to tell what setting changed, but our decisions
// regarding background drawing depends on some system settings, so force
// it to be redone.
if(textdc)
{
DeleteObject(textbm);
DeleteDC(textdc);
textdc = NULL;
textbm = NULL;
}
if(backgrounddc)
{
DeleteObject(backgroundbm);
DeleteDC(backgrounddc);
backgrounddc = NULL;
backgroundbm = NULL;
}
if(backgroundblenddc)
{
DeleteObject(backgroundblendbm);
DeleteDC(backgroundblenddc);
backgroundblenddc = NULL;
backgroundblendbm = NULL;
}
if(textdc || backgrounddc || backgroundblenddc)
{
InvalidateRect(hwnd, NULL, TRUE);
}
break;
#else
case WM_MOVE:
sys_cursor_update();
if( conf_get_int(conf,CONF_saveonexit)/*cfg.saveonexit*/ ) GetWindowCoord( hwnd ) ;
break;
#endif
#else
case WM_MOVE:
sys_cursor_update();
break;
#endif
case WM_SIZE:
resize_action = conf_get_int(conf, CONF_resize_action);
#ifdef RDB_DEBUG_PATCH
debug((27, "WM_SIZE %s (%d,%d)",
(wParam == SIZE_MINIMIZED) ? "SIZE_MINIMIZED":
(wParam == SIZE_MAXIMIZED) ? "SIZE_MAXIMIZED":
(wParam == SIZE_RESTORED && resizing) ? "to":
(wParam == SIZE_RESTORED) ? "SIZE_RESTORED":
"...",
LOWORD(lParam), HIWORD(lParam)));
#endif
#ifdef PERSOPORT
if (wParam == SIZE_MINIMIZED) {
if( GetKeyState( VK_CONTROL ) & 0x8000 ) {
SendMessage( hwnd, WM_COMMAND, IDM_TOTRAY, 0 ) ; return 0 ;
}
else
SetWindowText(hwnd, conf_get_int(conf,CONF_win_name_always) ? window_name : icon_name);
}
#else
if (wParam == SIZE_MINIMIZED)
SetWindowText(hwnd,
conf_get_int(conf, CONF_win_name_always) ?
window_name : icon_name);
#endif
if (wParam == SIZE_RESTORED || wParam == SIZE_MAXIMIZED)
SetWindowText(hwnd, window_name);
if (wParam == SIZE_RESTORED) {
processed_resize = FALSE;
clear_full_screen();
if (processed_resize) {
/*
* Inhibit normal processing of this WM_SIZE; a
* secondary one was triggered just now by
* clear_full_screen which contained the correct
* client area size.
*/
return 0;
}
}
if (wParam == SIZE_MAXIMIZED && fullscr_on_max) {
fullscr_on_max = FALSE;
processed_resize = FALSE;
make_full_screen();
if (processed_resize) {
/*
* Inhibit normal processing of this WM_SIZE; a
* secondary one was triggered just now by
* make_full_screen which contained the correct client
* area size.
*/
return 0;
}
}
processed_resize = TRUE;
if (resize_action == RESIZE_DISABLED) {
/* A resize, well it better be a minimize. */
reset_window(-1);
} else {
int width, height, w, h;
int window_border = conf_get_int(conf, CONF_window_border);
width = LOWORD(lParam);
height = HIWORD(lParam);
if (wParam == SIZE_MAXIMIZED && !was_zoomed) {
was_zoomed = 1;
prev_rows = term->rows;
prev_cols = term->cols;
if (resize_action == RESIZE_TERM) {
w = width / font_width;
if (w < 1) w = 1;
h = height / font_height;
if (h < 1) h = 1;
if (resizing) {
/*
* As below, if we're in the middle of an
* interactive resize we don't call
* back->size. In Windows 7, this case can
* arise in maximisation as well via the Aero
* snap UI.
*/
need_backend_resize = TRUE;
conf_set_int(conf, CONF_height, h);
conf_set_int(conf, CONF_width, w);
} else {
term_size(term, h, w,
conf_get_int(conf, CONF_savelines));
}
}
reset_window(0);
} else if (wParam == SIZE_RESTORED && was_zoomed) {
was_zoomed = 0;
if (resize_action == RESIZE_TERM) {
w = (width-window_border*2) / font_width;
if (w < 1) w = 1;
h = (height-window_border*2) / font_height;
if (h < 1) h = 1;
term_size(term, h, w, conf_get_int(conf, CONF_savelines));
reset_window(2);
} else if (resize_action != RESIZE_FONT)
reset_window(2);
else
reset_window(0);
} else if (wParam == SIZE_MINIMIZED) {
/* do nothing */
} else if (resize_action == RESIZE_TERM ||
(resize_action == RESIZE_EITHER &&
!is_alt_pressed())) {
w = (width-window_border*2) / font_width;
if (w < 1) w = 1;
h = (height-window_border*2) / font_height;
if (h < 1) h = 1;
if (resizing) {
#ifdef PERSOPORT
SetWinHeight( -1 ) ;
#endif
/*
* Don't call back->size in mid-resize. (To
* prevent massive numbers of resize events
* getting sent down the connection during an NT
* opaque drag.)
*/
need_backend_resize = TRUE;
conf_set_int(conf, CONF_height, h);
conf_set_int(conf, CONF_width, w);
} else {
term_size(term, h, w, conf_get_int(conf, CONF_savelines));
}
} else {
reset_window(0);
}
}
#ifdef PERSOPORT
if( GetTitleBarFlag() ) set_title( NULL, conf_get_str(conf,CONF_wintitle) ) ; // Pour refaire la barre de titre si option SizeFlag
if( conf_get_int(conf,CONF_saveonexit) ) GetWindowCoord( hwnd ) ;
#endif
#if (defined IMAGEPORT) && (!defined FDJ)
if( BackgroundImageFlag && (conf_get_int(conf,CONF_bg_image_abs_fixed)/*cfg.bg_image_abs_fixed*/==1) && (conf_get_int(conf,CONF_bg_type)/*cfg.bg_type*/!=0) ) RefreshBackground( hwnd ) ;
#endif
sys_cursor_update();
return 0;
case WM_VSCROLL:
switch (LOWORD(wParam)) {
case SB_BOTTOM:
term_scroll(term, -1, 0);
break;
case SB_TOP:
term_scroll(term, +1, 0);
break;
case SB_LINEDOWN:
term_scroll(term, 0, +1);
break;
case SB_LINEUP:
term_scroll(term, 0, -1);
break;
case SB_PAGEDOWN:
term_scroll(term, 0, +term->rows / 2);
break;
case SB_PAGEUP:
term_scroll(term, 0, -term->rows / 2);
break;
case SB_THUMBPOSITION:
case SB_THUMBTRACK:
/*
* Use GetScrollInfo instead of HIWORD(wParam) to get
* 32-bit scroll position.
*/
{
SCROLLINFO si;
si.cbSize = sizeof(si);
si.fMask = SIF_TRACKPOS;
if (GetScrollInfo(hwnd, SB_VERT, &si) == 0)
si.nTrackPos = HIWORD(wParam);
term_scroll(term, 1, si.nTrackPos);
}
break;
}
break;
case WM_PALETTECHANGED:
if ((HWND) wParam != hwnd && pal != NULL) {
HDC hdc = get_ctx(NULL);
if (hdc) {
if (RealizePalette(hdc) > 0)
UpdateColors(hdc);
free_ctx(hdc);
}
}
break;
case WM_QUERYNEWPALETTE:
if (pal != NULL) {
HDC hdc = get_ctx(NULL);
if (hdc) {
if (RealizePalette(hdc) > 0)
UpdateColors(hdc);
free_ctx(hdc);
return TRUE;
}
}
return FALSE;
#ifdef HYPERLINKPORT
/*
* HACK: PuttyTray / Nutty
* Hyperlink stuff: Change cursor if we are in ctrl+click link mode
*
* WARNING: Spans over multiple CASEs
*/
case WM_KEYDOWN:
if( PuttyFlag || !HyperlinkFlag ) goto KEY_END;
if(wParam == VK_CONTROL && conf_get_int(term->conf,CONF_url_ctrl_click)/*term->cfg.url_ctrl_click*/) {
GetCursorPos(&cursor_pt);
ScreenToClient(hwnd, &cursor_pt);
if (urlhack_is_in_link_region(TO_CHR_X(cursor_pt.x), TO_CHR_Y(cursor_pt.y))) {
SetCursor(LoadCursor(NULL, IDC_HAND));
term_update(term);
}
goto KEY_END;
}
case WM_KEYUP:
if( PuttyFlag || !HyperlinkFlag ) goto KEY_END;
if (wParam == VK_CONTROL && conf_get_int(term->conf,CONF_url_ctrl_click)/*term->cfg.url_ctrl_click*/) {
SetCursor(LoadCursor(NULL, IDC_IBEAM));
term_update(term);
goto KEY_END;
}
KEY_END:
case WM_SYSKEYDOWN:
#ifdef PERSOPORT
if( (wParam == VK_TAB) && (GetKeyState(VK_CONTROL) < 0) && (GetKeyState(VK_MENU) >= 0) && (GetKeyState(VK_SHIFT) >= 0) && conf_get_int(conf, CONF_ctrl_tab_switch)) {
struct ctrl_tab_info info = {
GetKeyState(VK_SHIFT) < 0 ? 1 : -1,
hwnd,
};
info.next_hi_date_time = info.self_hi_date_time = GetWindowLong(hwnd, 0);
info.next_lo_date_time = info.self_lo_date_time = GetWindowLong(hwnd, 4);
EnumWindows(CtrlTabWindowProc, (LPARAM) &info);
if (info.next != NULL)
SetForegroundWindow(info.next);
return 0;
}
#endif
case WM_SYSKEYUP:
/* HACK: PuttyTray / Nutty : END */
#else
case WM_KEYDOWN:
case WM_SYSKEYDOWN:
case WM_KEYUP:
case WM_SYSKEYUP:
#endif
#ifdef PERSOPORT
AntiIdleCount = 0 ;
/* Permet de sauvegarder tous les caracteres tapes au clavier pour les avoir dans le /savedump */
#ifdef SAVEDUMPPORT
if( debug_flag ) addkeypressed( message, wParam, lParam, GetKeyState(VK_SHIFT)&0x8000, GetKeyState(VK_CONTROL)&0x8000, (GetKeyState(VK_MENU)&0x8000)||(GetKeyState(VK_LMENU)&0x8000),GetKeyState(VK_RMENU)&0x8000, (GetKeyState(VK_RWIN)&0x8000)||(GetKeyState(VK_LWIN)&0x8000 ) );
#endif
if((wParam==VK_TAB)&&(message==WM_KEYDOWN)&&(GetKeyState(VK_CONTROL)&0x8000)&&(GetKeyState(VK_SHIFT)&0x8000))
{ SetShortcutsFlag( abs(GetShortcutsFlag()-1) ) ; return 0 ; }
if( GetShortcutsFlag() ) { if ( (message==WM_KEYDOWN)||(message==WM_SYSKEYDOWN) ) {
if( ManageShortcuts( hwnd, wParam
, GetKeyState(VK_SHIFT)&0x8000
, GetKeyState(VK_CONTROL)&0x8000
, (GetKeyState(VK_MENU)&0x8000)||(GetKeyState(VK_LMENU)&0x8000)
, GetKeyState(VK_RMENU)&0x8000
//, is_alt_pressed()
, (GetKeyState(VK_RWIN)&0x8000)||(GetKeyState(VK_LWIN)&0x8000)
) )
return 0 ;
} } // fin if( GetShortcutsFlag() )
else { if( GetProtectFlag() == 1 ) return 0 ; }
// Majuscule uniquement
if( GetCapsLockFlag() ) {
if( ( wParam>='A' ) && ( wParam <= 'Z' )
&& !(GetKeyState( VK_CAPITAL ) & 0x0001)
&& !(GetKeyState( VK_SHIFT ) & 0x8000) ) {
keybd_event( VK_CAPITAL, 0x45, KEYEVENTF_EXTENDEDKEY | 0, 0 ) ;
keybd_event( VK_CAPITAL, 0x45, KEYEVENTF_EXTENDEDKEY | KEYEVENTF_KEYUP, 0) ;
SendMessage(hwnd, WM_CHAR, wParam, 0) ;
return 0 ;
}
}
#endif
/*
* Add the scan code and keypress timing to the random
* number noise.
*/
noise_ultralight(lParam);
/*
* We don't do TranslateMessage since it disassociates the
* resulting CHAR message from the KEYDOWN that sparked it,
* which we occasionally don't want. Instead, we process
* KEYDOWN, and call the Win32 translator functions so that
* we get the translations under _our_ control.
*/
{
unsigned char buf[20];
int len;
if (wParam == VK_PROCESSKEY) { /* IME PROCESS key */
if (message == WM_KEYDOWN) {
MSG m;
m.hwnd = hwnd;
m.message = WM_KEYDOWN;
m.wParam = wParam;
m.lParam = lParam & 0xdfff;
TranslateMessage(&m);
} else break; /* pass to Windows for default processing */
} else {
len = TranslateKey(message, wParam, lParam, buf);
if (len == -1)
return DefWindowProc(hwnd, message, wParam, lParam);
if (len != 0) {
/*
* Interrupt an ongoing paste. I'm not sure
* this is sensible, but for the moment it's
* preferable to having to faff about buffering
* things.
*/
term_nopaste(term);
/*
* We need not bother about stdin backlogs
* here, because in GUI PuTTY we can't do
* anything about it anyway; there's no means
* of asking Windows to hold off on KEYDOWN
* messages. We _have_ to buffer everything
* we're sent.
*/
term_seen_key_event(term);
if (ldisc)
ldisc_send(ldisc, buf, len, 1);
show_mouseptr(0);
}
}
}
#ifdef KEYMAPPINGPORT
if( PuttyFlag ) net_pending_errors();
#else
net_pending_errors();
#endif
return 0;
case WM_INPUTLANGCHANGE:
/* wParam == Font number */
/* lParam == Locale */
set_input_locale((HKL)lParam);
sys_cursor_update();
break;
case WM_IME_STARTCOMPOSITION:
{
HIMC hImc = ImmGetContext(hwnd);
ImmSetCompositionFont(hImc, &lfont);
ImmReleaseContext(hwnd, hImc);
}
break;
case WM_IME_COMPOSITION:
{
HIMC hIMC;
int n;
char *buff;
if(osVersion.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS ||
osVersion.dwPlatformId == VER_PLATFORM_WIN32s) break; /* no Unicode */
if ((lParam & GCS_RESULTSTR) == 0) /* Composition unfinished. */
break; /* fall back to DefWindowProc */
hIMC = ImmGetContext(hwnd);
n = ImmGetCompositionStringW(hIMC, GCS_RESULTSTR, NULL, 0);
if (n > 0) {
int i;
buff = snewn(n, char);
ImmGetCompositionStringW(hIMC, GCS_RESULTSTR, buff, n);
/*
* Jaeyoun Chung reports that Korean character
* input doesn't work correctly if we do a single
* luni_send() covering the whole of buff. So
* instead we luni_send the characters one by one.
*/
term_seen_key_event(term);
/* don't divide SURROGATE PAIR */
if (ldisc) {
for (i = 0; i < n; i += 2) {
WCHAR hs = *(unsigned short *)(buff+i);
if (IS_HIGH_SURROGATE(hs) && i+2 < n) {
WCHAR ls = *(unsigned short *)(buff+i+2);
if (IS_LOW_SURROGATE(ls)) {
luni_send(ldisc, (unsigned short *)(buff+i), 2, 1);
i += 2;
continue;
}
}
luni_send(ldisc, (unsigned short *)(buff+i), 1, 1);
}
}
free(buff);
}
ImmReleaseContext(hwnd, hIMC);
return 1;
}
case WM_IME_CHAR:
if (wParam & 0xFF00) {
unsigned char buf[2];
buf[1] = wParam;
buf[0] = wParam >> 8;
term_seen_key_event(term);
if (ldisc)
lpage_send(ldisc, kbd_codepage, buf, 2, 1);
} else {
char c = (unsigned char) wParam;
term_seen_key_event(term);
if (ldisc)
lpage_send(ldisc, kbd_codepage, &c, 1, 1);
}
return (0);
case WM_CHAR:
case WM_SYSCHAR:
/*
* Nevertheless, we are prepared to deal with WM_CHAR
* messages, should they crop up. So if someone wants to
* post the things to us as part of a macro manoeuvre,
* we're ready to cope.
*/
{
char c = (unsigned char)wParam;
term_seen_key_event(term);
if (ldisc)
lpage_send(ldisc, CP_ACP, &c, 1, 1);
}
return 0;
case WM_SYSCOLORCHANGE:
if (conf_get_int(conf, CONF_system_colour)) {
/* Refresh palette from system colours. */
/* XXX actually this zaps the entire palette. */
systopalette();
init_palette();
/* Force a repaint of the terminal window. */
term_invalidate(term);
}
break;
case WM_AGENT_CALLBACK:
{
struct agent_callback *c = (struct agent_callback *)lParam;
c->callback(c->callback_ctx, c->data, c->len);
sfree(c);
}
return 0;
case WM_GOT_CLIPDATA:
if (process_clipdata((HGLOBAL)lParam, wParam))
term_do_paste(term);
return 0;
#ifdef RECONNECTPORT
case WM_POWERBROADCAST:
if(conf_get_int(conf,CONF_wakeup_reconnect)/*cfg.wakeup_reconnect*/) {
switch(wParam) {
case PBT_APMRESUMESUSPEND:
case PBT_APMRESUMEAUTOMATIC:
case PBT_APMRESUMECRITICAL:
case PBT_APMQUERYSUSPENDFAILED:
if(session_closed && !back) {
time_t tnow = time(NULL);
if(last_reconnect && (tnow - last_reconnect) < GetReconnectDelay() ) {
Sleep(1000);
}
last_reconnect = tnow;
logevent(NULL, "Woken up from suspend, reconnecting...");
term_pwron(term, FALSE);
backend_connected = 0 ;
start_backend();
SetTimer(hwnd, TIMER_INIT, init_delay, NULL) ;
}
break;
case PBT_APMSUSPEND:
if(!session_closed && back) {
logevent(NULL, "Suspend detected, disconnecting cleanly...");
close_session();
}
break;
}
}
break;
#endif
default:
if (message == wm_mousewheel || message == WM_MOUSEWHEEL) {
int shift_pressed=0, control_pressed=0;
if (message == WM_MOUSEWHEEL) {
wheel_accumulator += (short)HIWORD(wParam);
shift_pressed=LOWORD(wParam) & MK_SHIFT;
control_pressed=LOWORD(wParam) & MK_CONTROL;
} else {
BYTE keys[256];
wheel_accumulator += (int)wParam;
if (GetKeyboardState(keys)!=0) {
shift_pressed=keys[VK_SHIFT]&0x80;
control_pressed=keys[VK_CONTROL]&0x80;
}
}
/* process events when the threshold is reached */
while (abs(wheel_accumulator) >= WHEEL_DELTA) {
int b;
/* reduce amount for next time */
if (wheel_accumulator > 0) {
b = MBT_WHEEL_UP;
wheel_accumulator -= WHEEL_DELTA;
} else if (wheel_accumulator < 0) {
b = MBT_WHEEL_DOWN;
wheel_accumulator += WHEEL_DELTA;
} else
break;
if (send_raw_mouse &&
!(conf_get_int(conf, CONF_mouse_override) &&
shift_pressed)) {
/* Mouse wheel position is in screen coordinates for
* some reason */
POINT p;
p.x = X_POS(lParam); p.y = Y_POS(lParam);
if (ScreenToClient(hwnd, &p)) {
/* send a mouse-down followed by a mouse up */
term_mouse(term, b, translate_button(b),
MA_CLICK,
TO_CHR_X(p.x),
TO_CHR_Y(p.y), shift_pressed,
control_pressed, is_alt_pressed());
#ifndef PUTTYXPORT
// HACK (@unphased: I am removing the "button release" when triggered by mouse wheel to better replicate iTerm2's behavior)
term_mouse(term, b, translate_button(b),
MA_RELEASE, TO_CHR_X(p.x),
TO_CHR_Y(p.y), shift_pressed,
control_pressed, is_alt_pressed());
#endif
} /* else: not sure when this can fail */
} else {
/* trigger a scroll */
term_scroll(term, 0,
b == MBT_WHEEL_UP ?
-term->rows / 2 : term->rows / 2);
}
}
return 0;
}
}
/*
* Any messages we don't process completely above are passed through to
* DefWindowProc() for default processing.
*/
return DefWindowProc(hwnd, message, wParam, lParam);
}
/*
* Move the system caret. (We maintain one, even though it's
* invisible, for the benefit of blind people: apparently some
* helper software tracks the system caret, so we should arrange to
* have one.)
*/
void sys_cursor(void *frontend, int x, int y)
{
int cx, cy;
if (!term->has_focus) return;
/*
* Avoid gratuitously re-updating the cursor position and IMM
* window if there's no actual change required.
*/
cx = x * font_width + offset_width;
cy = y * font_height + offset_height;
if (cx == caret_x && cy == caret_y)
return;
caret_x = cx;
caret_y = cy;
sys_cursor_update();
}
static void sys_cursor_update(void)
{
COMPOSITIONFORM cf;
HIMC hIMC;
if (!term->has_focus) return;
if (caret_x < 0 || caret_y < 0)
return;
SetCaretPos(caret_x, caret_y);
/* IMM calls on Win98 and beyond only */
if(osVersion.dwPlatformId == VER_PLATFORM_WIN32s) return; /* 3.11 */
if(osVersion.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS &&
osVersion.dwMinorVersion == 0) return; /* 95 */
/* we should have the IMM functions */
hIMC = ImmGetContext(hwnd);
cf.dwStyle = CFS_POINT;
cf.ptCurrentPos.x = caret_x;
cf.ptCurrentPos.y = caret_y;
ImmSetCompositionWindow(hIMC, &cf);
ImmReleaseContext(hwnd, hIMC);
}
/*
* Draw a line of text in the window, at given character
* coordinates, in given attributes.
*
* We are allowed to fiddle with the contents of `text'.
*/
void do_text_internal(Context ctx, int x, int y, wchar_t *text, int len,
unsigned long attr, int lattr)
{
COLORREF fg, bg, t;
int nfg, nbg, nfont;
HDC hdc = ctx;
RECT line_box;
int force_manual_underline = 0;
int fnt_width, char_width;
int text_adjust = 0;
int xoffset = 0;
int maxlen, remaining, opaque;
int is_cursor = FALSE;
static int *lpDx = NULL;
static int lpDx_len = 0;
int *lpDx_maybe;
int len2; /* for SURROGATE PAIR */
#if (defined IMAGEPORT) && (!defined FDJ)
int transBg = backgrounddc ? 1 : 0;
UINT etoFlagOpaque = transBg ? 0 : ETO_OPAQUE;
#endif
lattr &= LATTR_MODE;
char_width = fnt_width = font_width * (1 + (lattr != LATTR_NORM));
if (attr & ATTR_WIDE)
char_width *= 2;
/* Only want the left half of double width lines */
if (lattr != LATTR_NORM && x*2 >= term->cols)
return;
x *= fnt_width;
y *= font_height;
x += offset_width;
y += offset_height;
if ((attr & TATTR_ACTCURS) && (cursor_type == 0 || term->big_cursor)) {
attr &= ~(ATTR_REVERSE|ATTR_BLINK|ATTR_COLOURS);
/* cursor fg and bg */
attr |= (260 << ATTR_FGSHIFT) | (261 << ATTR_BGSHIFT);
is_cursor = TRUE;
}
#ifdef TUTTYPORT
if (!conf_get_int(conf,CONF_sel_colour) && (attr & ATTR_SELECTED)) {
attr &= ~ATTR_SELECTED;
attr |= ATTR_REVERSE;
};
#endif
nfont = 0;
if (vtmode == VT_POORMAN && lattr != LATTR_NORM) {
/* Assume a poorman font is borken in other ways too. */
lattr = LATTR_WIDE;
} else
switch (lattr) {
case LATTR_NORM:
break;
case LATTR_WIDE:
nfont |= FONT_WIDE;
break;
default:
nfont |= FONT_WIDE + FONT_HIGH;
break;
}
if (attr & ATTR_NARROW)
nfont |= FONT_NARROW;
#ifdef USES_VTLINE_HACK
/* Special hack for the VT100 linedraw glyphs. */
if (text[0] >= 0x23BA && text[0] <= 0x23BD) {
switch ((unsigned char) (text[0])) {
case 0xBA:
text_adjust = -2 * font_height / 5;
break;
case 0xBB:
text_adjust = -1 * font_height / 5;
break;
case 0xBC:
text_adjust = font_height / 5;
break;
case 0xBD:
text_adjust = 2 * font_height / 5;
break;
}
if (lattr == LATTR_TOP || lattr == LATTR_BOT)
text_adjust *= 2;
text[0] = ucsdata.unitab_xterm['q'];
if (attr & ATTR_UNDER) {
attr &= ~ATTR_UNDER;
force_manual_underline = 1;
}
}
#endif
/* Anything left as an original character set is unprintable. */
if (DIRECT_CHAR(text[0]) &&
(len < 2 || !IS_SURROGATE_PAIR(text[0], text[1]))) {
int i;
for (i = 0; i < len; i++)
text[i] = 0xFFFD;
}
/* OEM CP */
if ((text[0] & CSET_MASK) == CSET_OEMCP)
nfont |= FONT_OEM;
nfg = ((attr & ATTR_FGMASK) >> ATTR_FGSHIFT);
nbg = ((attr & ATTR_BGMASK) >> ATTR_BGSHIFT);
if (bold_font_mode == BOLD_FONT && (attr & ATTR_BOLD))
nfont |= FONT_BOLD;
if (und_mode == UND_FONT && (attr & ATTR_UNDER))
nfont |= FONT_UNDERLINE;
another_font(nfont);
if (!fonts[nfont]) {
if (nfont & FONT_UNDERLINE)
force_manual_underline = 1;
/* Don't do the same for manual bold, it could be bad news. */
nfont &= ~(FONT_BOLD | FONT_UNDERLINE);
}
another_font(nfont);
if (!fonts[nfont])
nfont = FONT_NORMAL;
if (attr & ATTR_REVERSE) {
t = nfg;
nfg = nbg;
nbg = t;
}
if (bold_colours && (attr & ATTR_BOLD) && !is_cursor) {
if (nfg < 16) nfg |= 8;
else if (nfg >= 256) nfg |= 1;
}
if (bold_colours && (attr & ATTR_BLINK)) {
if (nbg < 16) nbg |= 8;
else if (nbg >= 256) nbg |= 1;
}
#ifdef TUTTYPORT
/*
* quick & dirty hack: underlined text has colour preference over bold & normal
* another one: selected text have absolute preference over all other attributes
*/
if (attr & ATTR_SELECTED) {
nfg = 272;
nbg = 273;
} else {
if (conf_get_int(conf,CONF_under_colour) && (nfont & FONT_UNDERLINE)) {
if (nfg < 7)
nfg += 264;
else if (nfg > 7 && nfg < 16)
nfg += 256;
else
switch (nfg) {
case 256:
nfg = 262;
break;
case 257:
nfg = 262;
break;
case 258:
nfg = 263;
break;
case 259:
nfg = 263;
};
if (nbg < 7)
nbg += 264;
else if (nbg > 7 && nbg < 16)
nbg += 256;
else
switch (nbg) {
case 256:
nbg = 262;
break;
case 257:
nbg = 262;
break;
case 258:
nbg = 263;
break;
case 259:
nbg = 263;
};
};
};
#endif
fg = colours[nfg];
bg = colours[nbg];
#if (defined IMAGEPORT) && (!defined FDJ)
if( BackgroundImageFlag && (!PuttyFlag) ) {
line_box.left = x;
line_box.top = y;
line_box.right = x + char_width * len;
line_box.bottom = y + font_height;
if(textdc)
{
int x = line_box.left;
int y = line_box.top;
int width = line_box.right - line_box.left;
int height = line_box.bottom - line_box.top;
POINT bgloc = { x, y };
COLORREF backgroundcolor = colours[258]; // Default Background
if(!bBgRelToTerm)
ClientToScreen(hwnd, &bgloc);
if(bg == backgroundcolor)
{
// Use fast screen fill for default background.
BitBlt(textdc, x, y, width, height, backgroundblenddc, bgloc.x, bgloc.y, SRCCOPY);
}
else
{
BitBlt(textdc, x, y, width, height, backgrounddc, bgloc.x, bgloc.y, SRCCOPY);
color_blend(textdc, x, y, width, height, bg, conf_get_int(conf,CONF_bg_opacity)/*cfg.bg_opacity*/);
}
hdc = textdc;
}
SelectObject(hdc, fonts[nfont]);
SetTextColor(hdc, fg);
SetBkColor(hdc, bg);
if (transBg || attr & TATTR_COMBINING)
SetBkMode(hdc, TRANSPARENT);
else
SetBkMode(hdc, OPAQUE);
}
else {
SelectObject(hdc, fonts[nfont]);
SetTextColor(hdc, fg);
SetBkColor(hdc, bg);
if (attr & TATTR_COMBINING)
SetBkMode(hdc, TRANSPARENT);
else
SetBkMode(hdc, OPAQUE);
line_box.left = x;
line_box.top = y;
line_box.right = x + char_width * len;
line_box.bottom = y + font_height;
}
#else
SelectObject(hdc, fonts[nfont]);
SetTextColor(hdc, fg);
SetBkColor(hdc, bg);
if (attr & TATTR_COMBINING)
SetBkMode(hdc, TRANSPARENT);
else
SetBkMode(hdc, OPAQUE);
line_box.left = x;
line_box.top = y;
line_box.right = x + char_width * len;
line_box.bottom = y + font_height;
#endif
/* adjust line_box.right for SURROGATE PAIR & VARIATION SELECTOR */
{
int i;
int rc_width = 0;
for (i = 0; i < len ; i++) {
if (i+1 < len && IS_HIGH_VARSEL(text[i], text[i+1])) {
i++;
} else if (i+1 < len && IS_SURROGATE_PAIR(text[i], text[i+1])) {
rc_width += char_width;
i++;
} else if (IS_LOW_VARSEL(text[i])) {
/* do nothing */
} else {
rc_width += char_width;
}
}
line_box.right = line_box.left + rc_width;
}
/* Only want the left half of double width lines */
if (line_box.right > font_width*term->cols+offset_width)
line_box.right = font_width*term->cols+offset_width;
if (font_varpitch) {
/*
* If we're using a variable-pitch font, we unconditionally
* draw the glyphs one at a time and centre them in their
* character cells (which means in particular that we must
* disable the lpDx mechanism). This gives slightly odd but
* generally reasonable results.
*/
xoffset = char_width / 2;
SetTextAlign(hdc, TA_TOP | TA_CENTER | TA_NOUPDATECP);
lpDx_maybe = NULL;
maxlen = 1;
} else {
/*
* In a fixed-pitch font, we draw the whole string in one go
* in the normal way.
*/
xoffset = 0;
SetTextAlign(hdc, TA_TOP | TA_LEFT | TA_NOUPDATECP);
lpDx_maybe = lpDx;
maxlen = len;
}
opaque = TRUE; /* start by erasing the rectangle */
for (remaining = len; remaining > 0;
text += len, remaining -= len, x += char_width * len2) {
len = (maxlen < remaining ? maxlen : remaining);
/* don't divide SURROGATE PAIR and VARIATION SELECTOR */
len2 = len;
if (maxlen == 1) {
if (remaining >= 1 && IS_SURROGATE_PAIR(text[0], text[1]))
len++;
if (remaining-len >= 1 && IS_LOW_VARSEL(text[len]))
len++;
else if (remaining-len >= 2 &&
IS_HIGH_VARSEL(text[len], text[len+1]))
len += 2;
}
if (len > lpDx_len) {
lpDx_len = len * 9 / 8 + 16;
lpDx = sresize(lpDx, lpDx_len, int);
if (lpDx_maybe) lpDx_maybe = lpDx;
}
{
int i;
/* only last char has dx width in SURROGATE PAIR and
* VARIATION sequence */
for (i = 0; i < len; i++) {
lpDx[i] = char_width;
if (i+1 < len && IS_HIGH_VARSEL(text[i], text[i+1])) {
if (i > 0) lpDx[i-1] = 0;
lpDx[i] = 0;
i++;
lpDx[i] = char_width;
} else if (i+1 < len && IS_SURROGATE_PAIR(text[i],text[i+1])) {
lpDx[i] = 0;
i++;
lpDx[i] = char_width;
} else if (IS_LOW_VARSEL(text[i])) {
if (i > 0) lpDx[i-1] = 0;
lpDx[i] = char_width;
}
}
}
/* We're using a private area for direct to font. (512 chars.) */
if (ucsdata.dbcs_screenfont && (text[0] & CSET_MASK) == CSET_ACP) {
/* Ho Hum, dbcs fonts are a PITA! */
/* To display on W9x I have to convert to UCS */
static wchar_t *uni_buf = 0;
static int uni_len = 0;
int nlen, mptr;
if (len > uni_len) {
sfree(uni_buf);
uni_len = len;
uni_buf = snewn(uni_len, wchar_t);
}
for(nlen = mptr = 0; mptr<len; mptr++) {
uni_buf[nlen] = 0xFFFD;
if (IsDBCSLeadByteEx(ucsdata.font_codepage,
(BYTE) text[mptr])) {
char dbcstext[2];
dbcstext[0] = text[mptr] & 0xFF;
dbcstext[1] = text[mptr+1] & 0xFF;
lpDx[nlen] += char_width;
MultiByteToWideChar(ucsdata.font_codepage, MB_USEGLYPHCHARS,
dbcstext, 2, uni_buf+nlen, 1);
mptr++;
}
else
{
char dbcstext[1];
dbcstext[0] = text[mptr] & 0xFF;
MultiByteToWideChar(ucsdata.font_codepage, MB_USEGLYPHCHARS,
dbcstext, 1, uni_buf+nlen, 1);
}
nlen++;
}
if (nlen <= 0)
return; /* Eeek! */
#if (defined IMAGEPORT) && (!defined FDJ)
if( BackgroundImageFlag && (!PuttyFlag) )
// ExtTextOutW(hdc, x,
// y - font_height * (lattr == LATTR_BOT) + text_adjust,
// ETO_CLIPPED | etoFlagOpaque, &line_box, uni_buf, nlen, lpDx);
ExtTextOutW(hdc, x + xoffset,
y - font_height * (lattr == LATTR_BOT) + text_adjust,
ETO_CLIPPED | etoFlagOpaque, &line_box, uni_buf, nlen, lpDx_maybe);
else
#endif
ExtTextOutW(hdc, x + xoffset,
y - font_height * (lattr == LATTR_BOT) + text_adjust,
ETO_CLIPPED | (opaque ? ETO_OPAQUE : 0),
&line_box, uni_buf, nlen,
lpDx_maybe);
if (bold_font_mode == BOLD_SHADOW && (attr & ATTR_BOLD)) {
SetBkMode(hdc, TRANSPARENT);
ExtTextOutW(hdc, x + xoffset - 1,
y - font_height * (lattr ==
LATTR_BOT) + text_adjust,
ETO_CLIPPED, &line_box, uni_buf, nlen, lpDx_maybe);
}
lpDx[0] = -1;
} else if (DIRECT_FONT(text[0])) {
static char *directbuf = NULL;
static int directlen = 0;
int i;
if (len > directlen) {
directlen = len;
directbuf = sresize(directbuf, directlen, char);
}
for (i = 0; i < len; i++)
directbuf[i] = text[i] & 0xFF;
#if (defined IMAGEPORT) && (!defined FDJ)
if( BackgroundImageFlag && (!PuttyFlag) )
// ExtTextOut(hdc, x,
// y - font_height * (lattr == LATTR_BOT) + text_adjust,
// ETO_CLIPPED | etoFlagOpaque, &line_box, directbuf, len, lpDx);
ExtTextOut(hdc, x + xoffset,
y - font_height * (lattr == LATTR_BOT) + text_adjust,
ETO_CLIPPED | etoFlagOpaque, &line_box, directbuf, len, lpDx_maybe);
else
#endif
ExtTextOut(hdc, x + xoffset,
y - font_height * (lattr == LATTR_BOT) + text_adjust,
ETO_CLIPPED | (opaque ? ETO_OPAQUE : 0),
&line_box, directbuf, len, lpDx_maybe);
if (bold_font_mode == BOLD_SHADOW && (attr & ATTR_BOLD)) {
SetBkMode(hdc, TRANSPARENT);
/* GRR: This draws the character outside its box and
* can leave 'droppings' even with the clip box! I
* suppose I could loop it one character at a time ...
* yuk.
*
* Or ... I could do a test print with "W", and use +1
* or -1 for this shift depending on if the leftmost
* column is blank...
*/
ExtTextOut(hdc, x + xoffset - 1,
y - font_height * (lattr ==
LATTR_BOT) + text_adjust,
ETO_CLIPPED, &line_box, directbuf, len, lpDx_maybe);
}
} else {
/* And 'normal' unicode characters */
static WCHAR *wbuf = NULL;
static int wlen = 0;
int i;
if (wlen < len) {
sfree(wbuf);
wlen = len;
wbuf = snewn(wlen, WCHAR);
}
for (i = 0; i < len; i++)
wbuf[i] = text[i];
#if (defined IMAGEPORT) && (!defined FDJ)
/* print Glyphs as they are, without Windows' Shaping*/
if( BackgroundImageFlag && (!PuttyFlag) )
// exact_textout(hdc, x, y - font_height * (lattr == LATTR_BOT) + text_adjust,
// &line_box, wbuf, len, lpDx, !(attr & TATTR_COMBINING) &&!transBg);
exact_textout(hdc, x + xoffset, y - font_height * (lattr == LATTR_BOT) + text_adjust,
&line_box, wbuf, len, lpDx, !(attr & TATTR_COMBINING) &&!transBg);
else
#endif
/* print Glyphs as they are, without Windows' Shaping*/
general_textout(hdc, x + xoffset,
y - font_height * (lattr==LATTR_BOT) + text_adjust,
&line_box, wbuf, len, lpDx,
opaque && !(attr & TATTR_COMBINING));
/* And the shadow bold hack. */
if (bold_font_mode == BOLD_SHADOW && (attr & ATTR_BOLD)) {
SetBkMode(hdc, TRANSPARENT);
ExtTextOutW(hdc, x + xoffset - 1,
y - font_height * (lattr ==
LATTR_BOT) + text_adjust,
ETO_CLIPPED, &line_box, wbuf, len, lpDx_maybe);
}
}
/*
* If we're looping round again, stop erasing the background
* rectangle.
*/
SetBkMode(hdc, TRANSPARENT);
opaque = FALSE;
}
if (lattr != LATTR_TOP && (force_manual_underline ||
(und_mode == UND_LINE
&& (attr & ATTR_UNDER)))) {
HPEN oldpen;
int dec = descent;
if (lattr == LATTR_BOT)
dec = dec * 2 - font_height;
oldpen = SelectObject(hdc, CreatePen(PS_SOLID, 0, fg));
MoveToEx(hdc, line_box.left, line_box.top + dec, NULL);
LineTo(hdc, line_box.right, line_box.top + dec);
oldpen = SelectObject(hdc, oldpen);
DeleteObject(oldpen);
}
#if (defined IMAGEPORT) && (!defined FDJ)
if( BackgroundImageFlag && (!PuttyFlag) )
if(textdc)
{
int x = line_box.left;
int y = line_box.top;
int width = line_box.right - line_box.left;
int height = line_box.bottom - line_box.top;
// Copy the result to the working DC.
BitBlt(ctx, x, y, width, height, hdc, x, y, SRCCOPY);
}
#endif
}
/*
* Wrapper that handles combining characters.
*/
void do_text(Context ctx, int x, int y, wchar_t *text, int len,
unsigned long attr, int lattr)
{
if (attr & TATTR_COMBINING) {
unsigned long a = 0;
int len0 = 1;
/* don't divide SURROGATE PAIR and VARIATION SELECTOR */
if (len >= 2 && IS_SURROGATE_PAIR(text[0], text[1]))
len0 = 2;
if (len-len0 >= 1 && IS_LOW_VARSEL(text[len0])) {
attr &= ~TATTR_COMBINING;
do_text_internal(ctx, x, y, text, len0+1, attr, lattr);
text += len0+1;
len -= len0+1;
a = TATTR_COMBINING;
} else if (len-len0 >= 2 && IS_HIGH_VARSEL(text[len0], text[len0+1])) {
attr &= ~TATTR_COMBINING;
do_text_internal(ctx, x, y, text, len0+2, attr, lattr);
text += len0+2;
len -= len0+2;
a = TATTR_COMBINING;
} else {
attr &= ~TATTR_COMBINING;
}
while (len--) {
if (len >= 1 && IS_SURROGATE_PAIR(text[0], text[1])) {
do_text_internal(ctx, x, y, text, 2, attr | a, lattr);
len--;
text++;
} else {
do_text_internal(ctx, x, y, text, 1, attr | a, lattr);
}
text++;
a = TATTR_COMBINING;
}
} else
do_text_internal(ctx, x, y, text, len, attr, lattr);
}
void do_cursor(Context ctx, int x, int y, wchar_t *text, int len,
unsigned long attr, int lattr)
{
int fnt_width;
int char_width;
HDC hdc = ctx;
int ctype = cursor_type;
lattr &= LATTR_MODE;
if ((attr & TATTR_ACTCURS) && (ctype == 0 || term->big_cursor)) {
if (*text != UCSWIDE) {
do_text(ctx, x, y, text, len, attr, lattr);
return;
}
ctype = 2;
attr |= TATTR_RIGHTCURS;
}
fnt_width = char_width = font_width * (1 + (lattr != LATTR_NORM));
if (attr & ATTR_WIDE)
char_width *= 2;
x *= fnt_width;
y *= font_height;
x += offset_width;
y += offset_height;
if ((attr & TATTR_PASCURS) && (ctype == 0 || term->big_cursor)) {
POINT pts[5];
HPEN oldpen;
pts[0].x = pts[1].x = pts[4].x = x;
pts[2].x = pts[3].x = x + char_width - 1;
pts[0].y = pts[3].y = pts[4].y = y;
pts[1].y = pts[2].y = y + font_height - 1;
oldpen = SelectObject(hdc, CreatePen(PS_SOLID, 0, colours[261]));
Polyline(hdc, pts, 5);
oldpen = SelectObject(hdc, oldpen);
DeleteObject(oldpen);
} else if ((attr & (TATTR_ACTCURS | TATTR_PASCURS)) && ctype != 0) {
int startx, starty, dx, dy, length, i;
if (ctype == 1) {
startx = x;
starty = y + descent;
dx = 1;
dy = 0;
length = char_width;
} else {
int xadjust = 0;
if (attr & TATTR_RIGHTCURS)
xadjust = char_width - 1;
startx = x + xadjust;
starty = y;
dx = 0;
dy = 1;
length = font_height;
}
if (attr & TATTR_ACTCURS) {
HPEN oldpen;
oldpen =
SelectObject(hdc, CreatePen(PS_SOLID, 0, colours[261]));
MoveToEx(hdc, startx, starty, NULL);
LineTo(hdc, startx + dx * length, starty + dy * length);
oldpen = SelectObject(hdc, oldpen);
DeleteObject(oldpen);
} else {
for (i = 0; i < length; i++) {
if (i % 2 == 0) {
SetPixel(hdc, startx, starty, colours[261]);
}
startx += dx;
starty += dy;
}
}
}
}
/* This function gets the actual width of a character in the normal font.
*/
int char_width(Context ctx, int uc) {
HDC hdc = ctx;
int ibuf = 0;
/* If the font max is the same as the font ave width then this
* function is a no-op.
*/
if (!font_dualwidth) return 1;
switch (uc & CSET_MASK) {
case CSET_ASCII:
uc = ucsdata.unitab_line[uc & 0xFF];
break;
case CSET_LINEDRW:
uc = ucsdata.unitab_xterm[uc & 0xFF];
break;
case CSET_SCOACS:
uc = ucsdata.unitab_scoacs[uc & 0xFF];
break;
}
if (DIRECT_FONT(uc)) {
if (ucsdata.dbcs_screenfont) return 1;
/* Speedup, I know of no font where ascii is the wrong width */
if ((uc&~CSET_MASK) >= ' ' && (uc&~CSET_MASK)<= '~')
return 1;
if ( (uc & CSET_MASK) == CSET_ACP ) {
SelectObject(hdc, fonts[FONT_NORMAL]);
} else if ( (uc & CSET_MASK) == CSET_OEMCP ) {
another_font(FONT_OEM);
if (!fonts[FONT_OEM]) return 0;
SelectObject(hdc, fonts[FONT_OEM]);
} else
return 0;
if ( GetCharWidth32(hdc, uc&~CSET_MASK, uc&~CSET_MASK, &ibuf) != 1 &&
GetCharWidth(hdc, uc&~CSET_MASK, uc&~CSET_MASK, &ibuf) != 1)
return 0;
} else {
/* Speedup, I know of no font where ascii is the wrong width */
if (uc >= ' ' && uc <= '~') return 1;
SelectObject(hdc, fonts[FONT_NORMAL]);
if ( GetCharWidth32W(hdc, uc, uc, &ibuf) == 1 )
/* Okay that one worked */ ;
else if ( GetCharWidthW(hdc, uc, uc, &ibuf) == 1 )
/* This should work on 9x too, but it's "less accurate" */ ;
else
return 0;
}
ibuf += font_width / 2 -1;
ibuf /= font_width;
return ibuf;
}
/*
* Translate a WM_(SYS)?KEY(UP|DOWN) message into a string of ASCII
* codes. Returns number of bytes used, zero to drop the message,
* -1 to forward the message to Windows, or another negative number
* to indicate a NUL-terminated "special" string.
*/
static int TranslateKey(UINT message, WPARAM wParam, LPARAM lParam,
unsigned char *output)
{
BYTE keystate[256];
int scan, left_alt = 0, key_down, shift_state;
int r, i, code;
unsigned char *p = output;
static int alt_sum = 0;
int funky_type = conf_get_int(conf, CONF_funky_type);
int no_applic_k = conf_get_int(conf, CONF_no_applic_k);
int ctrlaltkeys = conf_get_int(conf, CONF_ctrlaltkeys);
int nethack_keypad = conf_get_int(conf, CONF_nethack_keypad);
HKL kbd_layout = GetKeyboardLayout(0);
static wchar_t keys_unicode[3];
static int compose_char = 0;
static WPARAM compose_keycode = 0;
r = GetKeyboardState(keystate);
if (!r)
memset(keystate, 0, sizeof(keystate));
else {
#if 0
#define SHOW_TOASCII_RESULT
{ /* Tell us all about key events */
static BYTE oldstate[256];
static int first = 1;
static int scan;
int ch;
if (first)
memcpy(oldstate, keystate, sizeof(oldstate));
first = 0;
if ((HIWORD(lParam) & (KF_UP | KF_REPEAT)) == KF_REPEAT) {
debug(("+"));
} else if ((HIWORD(lParam) & KF_UP)
&& scan == (HIWORD(lParam) & 0xFF)) {
debug((". U"));
} else {
debug((".\n"));
if (wParam >= VK_F1 && wParam <= VK_F20)
debug(("K_F%d", wParam + 1 - VK_F1));
else
switch (wParam) {
case VK_SHIFT:
debug(("SHIFT"));
break;
case VK_CONTROL:
debug(("CTRL"));
break;
case VK_MENU:
debug(("ALT"));
break;
default:
debug(("VK_%02x", wParam));
}
if (message == WM_SYSKEYDOWN || message == WM_SYSKEYUP)
debug(("*"));
debug((", S%02x", scan = (HIWORD(lParam) & 0xFF)));
ch = MapVirtualKeyEx(wParam, 2, kbd_layout);
if (ch >= ' ' && ch <= '~')
debug((", '%c'", ch));
else if (ch)
debug((", $%02x", ch));
if (keys_unicode[0])
debug((", KB0=%04x", keys_unicode[0]));
if (keys_unicode[1])
debug((", KB1=%04x", keys_unicode[1]));
if (keys_unicode[2])
debug((", KB2=%04x", keys_unicode[2]));
if ((keystate[VK_SHIFT] & 0x80) != 0)
debug((", S"));
if ((keystate[VK_CONTROL] & 0x80) != 0)
debug((", C"));
if ((HIWORD(lParam) & KF_EXTENDED))
debug((", E"));
if ((HIWORD(lParam) & KF_UP))
debug((", U"));
}
if ((HIWORD(lParam) & (KF_UP | KF_REPEAT)) == KF_REPEAT);
else if ((HIWORD(lParam) & KF_UP))
oldstate[wParam & 0xFF] ^= 0x80;
else
oldstate[wParam & 0xFF] ^= 0x81;
for (ch = 0; ch < 256; ch++)
if (oldstate[ch] != keystate[ch])
debug((", M%02x=%02x", ch, keystate[ch]));
memcpy(oldstate, keystate, sizeof(oldstate));
}
#endif
if (wParam == VK_MENU && (HIWORD(lParam) & KF_EXTENDED)) {
keystate[VK_RMENU] = keystate[VK_MENU];
}
/* Nastyness with NUMLock - Shift-NUMLock is left alone though */
if ((funky_type == FUNKY_VT400 ||
(funky_type <= FUNKY_LINUX && term->app_keypad_keys &&
!no_applic_k))
&& wParam == VK_NUMLOCK && !(keystate[VK_SHIFT] & 0x80)) {
wParam = VK_EXECUTE;
/* UnToggle NUMLock */
if ((HIWORD(lParam) & (KF_UP | KF_REPEAT)) == 0)
keystate[VK_NUMLOCK] ^= 1;
}
/* And write back the 'adjusted' state */
SetKeyboardState(keystate);
}
/* Disable Auto repeat if required */
if (term->repeat_off &&
(HIWORD(lParam) & (KF_UP | KF_REPEAT)) == KF_REPEAT)
return 0;
if ((HIWORD(lParam) & KF_ALTDOWN) && (keystate[VK_RMENU] & 0x80) == 0)
left_alt = 1;
key_down = ((HIWORD(lParam) & KF_UP) == 0);
/* Make sure Ctrl-ALT is not the same as AltGr for ToAscii unless told. */
if (left_alt && (keystate[VK_CONTROL] & 0x80)) {
if (ctrlaltkeys)
keystate[VK_MENU] = 0;
else {
keystate[VK_RMENU] = 0x80;
left_alt = 0;
}
}
scan = (HIWORD(lParam) & (KF_UP | KF_EXTENDED | 0xFF));
shift_state = ((keystate[VK_SHIFT] & 0x80) != 0)
+ ((keystate[VK_CONTROL] & 0x80) != 0) * 2;
/* Note if AltGr was pressed and if it was used as a compose key */
if (!compose_state) {
compose_keycode = 0x100;
if (conf_get_int(conf, CONF_compose_key)) {
if (wParam == VK_MENU && (HIWORD(lParam) & KF_EXTENDED))
compose_keycode = wParam;
}
if (wParam == VK_APPS)
compose_keycode = wParam;
}
if (wParam == compose_keycode) {
if (compose_state == 0
&& (HIWORD(lParam) & (KF_UP | KF_REPEAT)) == 0) compose_state =
1;
else if (compose_state == 1 && (HIWORD(lParam) & KF_UP))
compose_state = 2;
else
compose_state = 0;
} else if (compose_state == 1 && wParam != VK_CONTROL)
compose_state = 0;
if (compose_state > 1 && left_alt)
compose_state = 0;
/* Sanitize the number pad if not using a PC NumPad */
if (left_alt || (term->app_keypad_keys && !no_applic_k
&& funky_type != FUNKY_XTERM)
|| funky_type == FUNKY_VT400 || nethack_keypad || compose_state) {
if ((HIWORD(lParam) & KF_EXTENDED) == 0) {
int nParam = 0;
switch (wParam) {
case VK_INSERT:
nParam = VK_NUMPAD0;
break;
case VK_END:
nParam = VK_NUMPAD1;
break;
case VK_DOWN:
nParam = VK_NUMPAD2;
break;
case VK_NEXT:
nParam = VK_NUMPAD3;
break;
case VK_LEFT:
nParam = VK_NUMPAD4;
break;
case VK_CLEAR:
nParam = VK_NUMPAD5;
break;
case VK_RIGHT:
nParam = VK_NUMPAD6;
break;
case VK_HOME:
nParam = VK_NUMPAD7;
break;
case VK_UP:
nParam = VK_NUMPAD8;
break;
case VK_PRIOR:
nParam = VK_NUMPAD9;
break;
case VK_DELETE:
nParam = VK_DECIMAL;
break;
}
if (nParam) {
if (keystate[VK_NUMLOCK] & 1)
shift_state |= 1;
wParam = nParam;
}
}
}
/* If a key is pressed and AltGr is not active */
if (key_down && (keystate[VK_RMENU] & 0x80) == 0 && !compose_state) {
/* Okay, prepare for most alts then ... */
#ifdef KEYMAPPINGPORT
if( !PuttyFlag ) {
if (left_alt && shift_state != 1 && !(wParam == VK_UP || wParam == VK_DOWN || wParam == VK_RIGHT || wParam == VK_LEFT))
*p++ = '\033';
}
else
#endif
if (left_alt)
*p++ = '\033';
/* Lets see if it's a pattern we know all about ... */
if (wParam == VK_PRIOR && shift_state == 1) {
SendMessage(hwnd, WM_VSCROLL, SB_PAGEUP, 0);
return 0;
}
if (wParam == VK_PRIOR && shift_state == 2) {
SendMessage(hwnd, WM_VSCROLL, SB_LINEUP, 0);
return 0;
}
if (wParam == VK_NEXT && shift_state == 1) {
SendMessage(hwnd, WM_VSCROLL, SB_PAGEDOWN, 0);
return 0;
}
if (wParam == VK_NEXT && shift_state == 2) {
SendMessage(hwnd, WM_VSCROLL, SB_LINEDOWN, 0);
return 0;
}
if ((wParam == VK_PRIOR || wParam == VK_NEXT) && shift_state == 3) {
term_scroll_to_selection(term, (wParam == VK_PRIOR ? 0 : 1));
return 0;
}
if (wParam == VK_INSERT && shift_state == 1) {
request_paste(NULL);
return 0;
}
if (left_alt && wParam == VK_F4 && conf_get_int(conf, CONF_alt_f4)) {
return -1;
}
if (left_alt && wParam == VK_SPACE && conf_get_int(conf,
CONF_alt_space)) {
SendMessage(hwnd, WM_SYSCOMMAND, SC_KEYMENU, 0);
return -1;
}
if (left_alt && wParam == VK_RETURN &&
conf_get_int(conf, CONF_fullscreenonaltenter) &&
(conf_get_int(conf, CONF_resize_action) != RESIZE_DISABLED)) {
if ((HIWORD(lParam) & (KF_UP | KF_REPEAT)) != KF_REPEAT)
flip_full_screen();
return -1;
}
/* Control-Numlock for app-keypad mode switch */
if (wParam == VK_PAUSE && shift_state == 2) {
term->app_keypad_keys ^= 1;
return 0;
}
/* Nethack keypad */
if (nethack_keypad && !left_alt) {
switch (wParam) {
case VK_NUMPAD1:
*p++ = "bB\002\002"[shift_state & 3];
return p - output;
case VK_NUMPAD2:
*p++ = "jJ\012\012"[shift_state & 3];
return p - output;
case VK_NUMPAD3:
*p++ = "nN\016\016"[shift_state & 3];
return p - output;
case VK_NUMPAD4:
*p++ = "hH\010\010"[shift_state & 3];
return p - output;
case VK_NUMPAD5:
*p++ = shift_state ? '.' : '.';
return p - output;
case VK_NUMPAD6:
*p++ = "lL\014\014"[shift_state & 3];
return p - output;
case VK_NUMPAD7:
*p++ = "yY\031\031"[shift_state & 3];
return p - output;
case VK_NUMPAD8:
*p++ = "kK\013\013"[shift_state & 3];
return p - output;
case VK_NUMPAD9:
*p++ = "uU\025\025"[shift_state & 3];
return p - output;
}
}
/* Application Keypad */
if (!left_alt) {
int xkey = 0;
if (funky_type == FUNKY_VT400 ||
(funky_type <= FUNKY_LINUX &&
term->app_keypad_keys && !no_applic_k)) switch (wParam) {
case VK_EXECUTE:
xkey = 'P';
break;
case VK_DIVIDE:
xkey = 'Q';
break;
case VK_MULTIPLY:
xkey = 'R';
break;
case VK_SUBTRACT:
xkey = 'S';
break;
}
if (term->app_keypad_keys && !no_applic_k)
switch (wParam) {
case VK_NUMPAD0:
xkey = 'p';
break;
case VK_NUMPAD1:
xkey = 'q';
break;
case VK_NUMPAD2:
xkey = 'r';
break;
case VK_NUMPAD3:
xkey = 's';
break;
case VK_NUMPAD4:
xkey = 't';
break;
case VK_NUMPAD5:
xkey = 'u';
break;
case VK_NUMPAD6:
xkey = 'v';
break;
case VK_NUMPAD7:
xkey = 'w';
break;
case VK_NUMPAD8:
xkey = 'x';
break;
case VK_NUMPAD9:
xkey = 'y';
break;
case VK_DECIMAL:
xkey = 'n';
break;
case VK_ADD:
if (funky_type == FUNKY_XTERM) {
if (shift_state)
xkey = 'l';
else
xkey = 'k';
} else if (shift_state)
xkey = 'm';
else
xkey = 'l';
break;
case VK_DIVIDE:
if (funky_type == FUNKY_XTERM)
xkey = 'o';
break;
case VK_MULTIPLY:
if (funky_type == FUNKY_XTERM)
xkey = 'j';
break;
case VK_SUBTRACT:
if (funky_type == FUNKY_XTERM)
xkey = 'm';
break;
case VK_RETURN:
if (HIWORD(lParam) & KF_EXTENDED)
xkey = 'M';
break;
}
if (xkey) {
if (term->vt52_mode) {
if (xkey >= 'P' && xkey <= 'S')
p += sprintf((char *) p, "\x1B%c", xkey);
else
p += sprintf((char *) p, "\x1B?%c", xkey);
} else
p += sprintf((char *) p, "\x1BO%c", xkey);
return p - output;
}
}
if (wParam == VK_BACK && shift_state == 0) { /* Backspace */
*p++ = (conf_get_int(conf, CONF_bksp_is_delete) ? 0x7F : 0x08);
*p++ = 0;
return -2;
}
#ifdef CYGTERMPORT
if (wParam == VK_BACK && shift_state != 0) { /* Shift-Backspace, Ctrl-Backspace */
#else
if (wParam == VK_BACK && shift_state == 1) { /* Shift Backspace */
#endif
/* We do the opposite of what is configured */
*p++ = (conf_get_int(conf, CONF_bksp_is_delete) ? 0x08 : 0x7F);
*p++ = 0;
return -2;
}
#ifdef KEYMAPPINGPORT
if( !PuttyFlag ) {
if (wParam == VK_TAB && shift_state == 2) { /* Ctrl-Tab */
p += sprintf((char *) p, "\x1B[27;5;9~");
return p - output;
}
if (wParam == VK_TAB && shift_state == 3) { /* Ctrl-Shift-Tab */
p += sprintf((char *) p, "\x1B[27;6;9~");
return p - output;
}
if (wParam == VK_UP && shift_state == 3) { /* Ctrl-Shift-Up */
p += sprintf((char *) p, "\x1B[1;6A");
return p - output;
}
if (wParam == VK_DOWN && shift_state == 3) { /* Ctrl-Shift-Down */
p += sprintf((char *) p, "\x1B[1;6B");
return p - output;
}
if (wParam == VK_RIGHT && shift_state == 3) { /* Ctrl-Shift-Right */
p += sprintf((char *) p, "\x1B[1;6C");
return p - output;
}
if (wParam == VK_LEFT && shift_state == 3) { /* Ctrl-Shift-Left */
p += sprintf((char *) p, "\x1B[1;6D");
return p - output;
}
}
#endif
if (wParam == VK_TAB && shift_state == 1) { /* Shift tab */
#ifdef CYGTERMPORT
p = output; /* don't also pass escape */
#endif
*p++ = 0x1B;
*p++ = '[';
*p++ = 'Z';
return p - output;
}
if (wParam == VK_SPACE && shift_state == 2) { /* Ctrl-Space */
*p++ = 0;
return p - output;
}
if (wParam == VK_SPACE && shift_state == 3) { /* Ctrl-Shift-Space */
#ifdef CYGTERMPORT
p = output; /* don't also pass escape */
*p++ = 160; /* Latin1 NBSP */
return p - output;
}
if (wParam == '/' && shift_state == 2) { /* Ctrl-/ sends ^_ */
*p++ = 037;
#else
*p++ = 160;
#endif
return p - output;
}
if (wParam == VK_CANCEL && shift_state == 2) { /* Ctrl-Break */
if (back)
back->special(backhandle, TS_BRK);
return 0;
}
if (wParam == VK_PAUSE) { /* Break/Pause */
*p++ = 26;
*p++ = 0;
return -2;
}
/* Control-2 to Control-8 are special */
if (shift_state == 2 && wParam >= '2' && wParam <= '8') {
*p++ = "\000\033\034\035\036\037\177"[wParam - '2'];
return p - output;
}
if (shift_state == 2 && (wParam == 0xBD || wParam == 0xBF)) {
*p++ = 0x1F;
return p - output;
}
if (shift_state == 2 && (wParam == 0xDF || wParam == 0xDC)) {
*p++ = 0x1C;
return p - output;
}
if (shift_state == 3 && wParam == 0xDE) {
*p++ = 0x1E; /* Ctrl-~ == Ctrl-^ in xterm at least */
return p - output;
}
#ifdef CYGTERMPORT
if (wParam == VK_RETURN && shift_state != 0) { /* Shift-Return, Ctrl-Return */
/* send LINEFEED */
*p++ = 012;
return p - output;
}
#endif
if (shift_state == 0 && wParam == VK_RETURN && term->cr_lf_return) {
*p++ = '\r';
*p++ = '\n';
return p - output;
}
/*
* Next, all the keys that do tilde codes. (ESC '[' nn '~',
* for integer decimal nn.)
*
* We also deal with the weird ones here. Linux VCs replace F1
* to F5 by ESC [ [ A to ESC [ [ E. rxvt doesn't do _that_, but
* does replace Home and End (1~ and 4~) by ESC [ H and ESC O w
* respectively.
*/
code = 0;
switch (wParam) {
case VK_F1:
code = (keystate[VK_SHIFT] & 0x80 ? 23 : 11);
break;
case VK_F2:
code = (keystate[VK_SHIFT] & 0x80 ? 24 : 12);
break;
case VK_F3:
code = (keystate[VK_SHIFT] & 0x80 ? 25 : 13);
break;
case VK_F4:
code = (keystate[VK_SHIFT] & 0x80 ? 26 : 14);
break;
case VK_F5:
code = (keystate[VK_SHIFT] & 0x80 ? 28 : 15);
break;
case VK_F6:
code = (keystate[VK_SHIFT] & 0x80 ? 29 : 17);
break;
case VK_F7:
code = (keystate[VK_SHIFT] & 0x80 ? 31 : 18);
break;
case VK_F8:
code = (keystate[VK_SHIFT] & 0x80 ? 32 : 19);
break;
case VK_F9:
code = (keystate[VK_SHIFT] & 0x80 ? 33 : 20);
break;
case VK_F10:
code = (keystate[VK_SHIFT] & 0x80 ? 34 : 21);
break;
case VK_F11:
code = 23;
break;
case VK_F12:
code = 24;
break;
case VK_F13:
code = 25;
break;
case VK_F14:
code = 26;
break;
case VK_F15:
code = 28;
break;
case VK_F16:
code = 29;
break;
case VK_F17:
code = 31;
break;
case VK_F18:
code = 32;
break;
case VK_F19:
code = 33;
break;
case VK_F20:
code = 34;
break;
}
if ((shift_state&2) == 0) switch (wParam) {
case VK_HOME:
code = 1;
break;
case VK_INSERT:
code = 2;
break;
case VK_DELETE:
code = 3;
break;
case VK_END:
code = 4;
break;
case VK_PRIOR:
code = 5;
break;
case VK_NEXT:
code = 6;
break;
}
/* Reorder edit keys to physical order */
if (funky_type == FUNKY_VT400 && code <= 6)
code = "\0\2\1\4\5\3\6"[code];
if (term->vt52_mode && code > 0 && code <= 6) {
p += sprintf((char *) p, "\x1B%c", " HLMEIG"[code]);
return p - output;
}
if (funky_type == FUNKY_SCO && code >= 11 && code <= 34) {
/* SCO function keys */
char codes[] = "MNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz@[\\]^_`{";
int index = 0;
switch (wParam) {
case VK_F1: index = 0; break;
case VK_F2: index = 1; break;
case VK_F3: index = 2; break;
case VK_F4: index = 3; break;
case VK_F5: index = 4; break;
case VK_F6: index = 5; break;
case VK_F7: index = 6; break;
case VK_F8: index = 7; break;
case VK_F9: index = 8; break;
case VK_F10: index = 9; break;
case VK_F11: index = 10; break;
case VK_F12: index = 11; break;
}
if (keystate[VK_SHIFT] & 0x80) index += 12;
if (keystate[VK_CONTROL] & 0x80) index += 24;
p += sprintf((char *) p, "\x1B[%c", codes[index]);
return p - output;
}
if (funky_type == FUNKY_SCO && /* SCO small keypad */
code >= 1 && code <= 6) {
char codes[] = "HL.FIG";
if (code == 3) {
*p++ = '\x7F';
} else {
p += sprintf((char *) p, "\x1B[%c", codes[code-1]);
}
return p - output;
}
if ((term->vt52_mode || funky_type == FUNKY_VT100P) && code >= 11 && code <= 24) {
int offt = 0;
if (code > 15)
offt++;
if (code > 21)
offt++;
if (term->vt52_mode)
p += sprintf((char *) p, "\x1B%c", code + 'P' - 11 - offt);
else
p +=
sprintf((char *) p, "\x1BO%c", code + 'P' - 11 - offt);
return p - output;
}
if (funky_type == FUNKY_LINUX && code >= 11 && code <= 15) {
p += sprintf((char *) p, "\x1B[[%c", code + 'A' - 11);
return p - output;
}
if (funky_type == FUNKY_XTERM && code >= 11 && code <= 14) {
if (term->vt52_mode)
p += sprintf((char *) p, "\x1B%c", code + 'P' - 11);
else
p += sprintf((char *) p, "\x1BO%c", code + 'P' - 11);
return p - output;
}
if ((code == 1 || code == 4) &&
conf_get_int(conf, CONF_rxvt_homeend)) {
p += sprintf((char *) p, code == 1 ? "\x1B[H" : "\x1BOw");
return p - output;
}
if (code) {
p += sprintf((char *) p, "\x1B[%d~", code);
return p - output;
}
/*
* Now the remaining keys (arrows and Keypad 5. Keypad 5 for
* some reason seems to send VK_CLEAR to Windows...).
*/
{
char xkey = 0;
switch (wParam) {
case VK_UP:
xkey = 'A';
break;
case VK_DOWN:
xkey = 'B';
break;
case VK_RIGHT:
xkey = 'C';
break;
case VK_LEFT:
xkey = 'D';
break;
case VK_CLEAR:
xkey = 'G';
break;
}
if (xkey) {
#ifdef KEYMAPPINGPORT
p += format_arrow_key(p, term, xkey, shift_state, left_alt);
#else
p += format_arrow_key(p, term, xkey, shift_state);
#endif
return p - output;
}
}
/*
* Finally, deal with Return ourselves. (Win95 seems to
* foul it up when Alt is pressed, for some reason.)
*/
if (wParam == VK_RETURN) { /* Return */
*p++ = 0x0D;
*p++ = 0;
return -2;
}
if (left_alt && wParam >= VK_NUMPAD0 && wParam <= VK_NUMPAD9)
alt_sum = alt_sum * 10 + wParam - VK_NUMPAD0;
else
alt_sum = 0;
}
/* Okay we've done everything interesting; let windows deal with
* the boring stuff */
{
BOOL capsOn=0;
/* helg: clear CAPS LOCK state if caps lock switches to cyrillic */
if(keystate[VK_CAPITAL] != 0 &&
conf_get_int(conf, CONF_xlat_capslockcyr)) {
capsOn= !left_alt;
keystate[VK_CAPITAL] = 0;
}
/* XXX how do we know what the max size of the keys array should
* be is? There's indication on MS' website of an Inquire/InquireEx
* functioning returning a KBINFO structure which tells us. */
if (osVersion.dwPlatformId == VER_PLATFORM_WIN32_NT) {
r = ToUnicodeEx(wParam, scan, keystate, keys_unicode,
lenof(keys_unicode), 0, kbd_layout);
} else {
/* XXX 'keys' parameter is declared in MSDN documentation as
* 'LPWORD lpChar'.
* The experience of a French user indicates that on
* Win98, WORD[] should be passed in, but on Win2K, it should
* be BYTE[]. German WinXP and my Win2K with "US International"
* driver corroborate this.
* Experimentally I've conditionalised the behaviour on the
* Win9x/NT split, but I suspect it's worse than that.
* See wishlist item `win-dead-keys' for more horrible detail
* and speculations. */
int i;
static WORD keys[3];
static BYTE keysb[3];
r = ToAsciiEx(wParam, scan, keystate, keys, 0, kbd_layout);
if (r > 0) {
for (i = 0; i < r; i++) {
keysb[i] = (BYTE)keys[i];
}
MultiByteToWideChar(CP_ACP, 0, (LPCSTR)keysb, r,
keys_unicode, lenof(keys_unicode));
}
}
#ifdef SHOW_TOASCII_RESULT
if (r == 1 && !key_down) {
if (alt_sum) {
if (in_utf(term) || ucsdata.dbcs_screenfont)
debug((", (U+%04x)", alt_sum));
else
debug((", LCH(%d)", alt_sum));
} else {
debug((", ACH(%d)", keys_unicode[0]));
}
} else if (r > 0) {
int r1;
debug((", ASC("));
for (r1 = 0; r1 < r; r1++) {
debug(("%s%d", r1 ? "," : "", keys_unicode[r1]));
}
debug((")"));
}
#endif
if (r > 0) {
WCHAR keybuf;
/*
* Interrupt an ongoing paste. I'm not sure this is
* sensible, but for the moment it's preferable to
* having to faff about buffering things.
*/
term_nopaste(term);
p = output;
for (i = 0; i < r; i++) {
wchar_t wch = keys_unicode[i];
if (compose_state == 2 && wch >= ' ' && wch < 0x80) {
compose_char = wch;
compose_state++;
continue;
}
if (compose_state == 3 && wch >= ' ' && wch < 0x80) {
int nc;
compose_state = 0;
if ((nc = check_compose(compose_char, wch)) == -1) {
MessageBeep(MB_ICONHAND);
return 0;
}
keybuf = nc;
term_seen_key_event(term);
if (ldisc)
luni_send(ldisc, &keybuf, 1, 1);
continue;
}
compose_state = 0;
if (!key_down) {
if (alt_sum) {
if (in_utf(term) || ucsdata.dbcs_screenfont) {
keybuf = alt_sum;
term_seen_key_event(term);
if (ldisc)
luni_send(ldisc, &keybuf, 1, 1);
} else {
char ch = (char) alt_sum;
/*
* We need not bother about stdin
* backlogs here, because in GUI PuTTY
* we can't do anything about it
* anyway; there's no means of asking
* Windows to hold off on KEYDOWN
* messages. We _have_ to buffer
* everything we're sent.
*/
term_seen_key_event(term);
if (ldisc)
ldisc_send(ldisc, &ch, 1, 1);
}
alt_sum = 0;
} else {
term_seen_key_event(term);
if (ldisc)
luni_send(ldisc, &wch, 1, 1);
}
} else {
if(capsOn && wch < 0x80) {
WCHAR cbuf[2];
cbuf[0] = 27;
cbuf[1] = xlat_uskbd2cyrllic(wch);
term_seen_key_event(term);
if (ldisc)
luni_send(ldisc, cbuf+!left_alt, 1+!!left_alt, 1);
} else {
WCHAR cbuf[2];
cbuf[0] = '\033';
#ifdef CYGTERMPORT
cbuf[1] = wch | ((left_alt & conf_get_int(conf,CONF_alt_metabit)/*cfg.alt_metabit*/) << 7);
#else
cbuf[1] = wch;
#endif
term_seen_key_event(term);
if (ldisc)
#ifdef CYGTERMPORT
luni_send(ldisc,
cbuf + !(left_alt & !conf_get_int(conf,CONF_alt_metabit)/*cfg.alt_metabit*/),
1 + !!(left_alt & !conf_get_int(conf,CONF_alt_metabit)/*cfg.alt_metabit*/),
1);
#else
luni_send(ldisc, cbuf +!left_alt, 1+!!left_alt, 1);
#endif
}
}
show_mouseptr(0);
}
/* This is so the ALT-Numpad and dead keys work correctly. */
keys_unicode[0] = 0;
return p - output;
}
/* If we're definitly not building up an ALT-54321 then clear it */
if (!left_alt)
keys_unicode[0] = 0;
/* If we will be using alt_sum fix the 256s */
else if (keys_unicode[0] && (in_utf(term) || ucsdata.dbcs_screenfont))
keys_unicode[0] = 10;
}
/*
* ALT alone may or may not want to bring up the System menu.
* If it's not meant to, we return 0 on presses or releases of
* ALT, to show that we've swallowed the keystroke. Otherwise
* we return -1, which means Windows will give the keystroke
* its default handling (i.e. bring up the System menu).
*/
if (wParam == VK_MENU && !conf_get_int(conf, CONF_alt_only))
return 0;
return -1;
}
#ifdef PERSOPORT
void set_title_internal(void *frontend, char *title) {
sfree(window_name);
window_name = snewn(1 + strlen(title), char);
strcpy(window_name, title);
if (conf_get_int(conf, CONF_win_name_always) || !IsIconic(hwnd))
SetWindowText(hwnd, title);
}
/* Creer un titre de fenetre a partir d'un schema donne
%%f: le folder auquel apprtient le session
%%h: le hostname
%%i: le pid du process
%%p: le port
%%P: le protocole
%%s: nom de la session (vide sinon)
%%u: le user
Ex: %%P://%%u@%%h:%%p
Ex: %%f / %%s
*/
void make_title( char * res, char * fmt, char * title ) {
int p;
char b[256] ;
int port ;
sprintf( res, fmt, title ) ;
while( (p=poss( "%%s", res)) > 0 ) { del(res,p,3); if(strlen(conf_get_str(conf,CONF_sessionname)/*cfg.sessionname*/)>0) insert(res,conf_get_str(conf,CONF_sessionname)/*cfg.sessionname*/,p); }
while( (p=poss( "%%h", res)) > 0 ) { del(res,p,3); insert(res,conf_get_str(conf,CONF_host)/*cfg.host*/,p); }
while( (p=poss( "%%u", res)) > 0 ) { del(res,p,3); insert(res,conf_get_str(conf,CONF_username)/*cfg.username*/,p); }
while( (p=poss( "%%f", res)) > 0 ) { del(res,p,3); if(strlen(conf_get_str(conf,CONF_folder)/*cfg.folder*/)>0) insert(res,conf_get_str(conf,CONF_folder)/*cfg.folder*/,p); }
port = conf_get_int(conf,CONF_port)/*cfg.port*/ ;
switch(conf_get_int(conf,CONF_protocol)/*cfg.protocol*/) {
case PROT_RAW: strcpy(b,"raw"); break;
case PROT_TELNET: strcpy(b,"telnet"); if(port==-1) port=23 ; break;
case PROT_RLOGIN: strcpy(b,"rlogin"); break;
case PROT_SSH: strcpy(b,"ssh"); if(port==-1) port=22 ; break;
#ifdef CYGTERMPORT
case PROT_CYGTERM: strcpy(b,"cyg"); break;
#endif
case PROT_SERIAL: strcpy(b,"serial"); break;
}
while( (p=poss( "%%P", res)) > 0 ) { del(res,p,3); insert(res,b,p); }
sprintf(b,"%d", port ) ;
while( (p=poss( "%%p", res)) > 0 ) { del(res,p,3); insert(res,b,p); }
sprintf(b,"%ld", GetCurrentProcessId() ) ;
while( (p=poss( "%%i", res)) > 0 ) { del(res,p,3); insert(res,b,p); }
}
void set_title(void *frontend, char *title) {
char *buffer, fmt[256]="%s" ;
if( (title[0]=='_')&&(title[1]=='_') ) { // Mode commande a distance
if( ManageLocalCmd( MainHwnd, title+2 ) ) return ;
}
if( !GetTitleBarFlag() ) { set_title_internal( frontend, title ) ; return ; }
if( strstr(title, " (PROTECTED)")==(title+strlen(title)-12) )
{ title[strlen(title)-12]='\0' ; }
#if (defined IMAGEPORT) && (!defined FDJ)
buffer = (char*) malloc( strlen( title ) + strlen( conf_get_str(conf,CONF_host)/*cfg.host*/ ) + strlen( conf_get_filename(conf,CONF_bg_image_filename)/*cfg.bg_image_filename.*/->path ) + 40 ) ;
if( BackgroundImageFlag && GetImageViewerFlag() && (!PuttyFlag) ) {sprintf( buffer, "%s", conf_get_filename(conf,CONF_bg_image_filename)/*cfg.bg_image_filename.*/->path ) ; }
else
#else
buffer = (char*) malloc( strlen( title ) + strlen( conf_get_str(conf,CONF_host)/*cfg.host*/ ) + 40 ) ;
#endif
if( GetSizeFlag() && (!IsZoomed( MainHwnd )) ) {
if( strlen( title ) > 0 ) {
if( title[strlen(title)-1] == ']' ) make_title( buffer, "%s", title ) ;
else {
sprintf( fmt, "%%s [%dx%d]", conf_get_int(conf,CONF_height)/*cfg.height*/, conf_get_int(conf,CONF_width)/*cfg.width*/ ) ;
make_title( buffer, fmt, title ) ;
}
}
else sprintf( buffer, "%s [%dx%d] - %s", conf_get_str(conf,CONF_host)/*cfg.host*/, conf_get_int(conf,CONF_height)/*cfg.height*/, conf_get_int(conf,CONF_width)/*cfg.width*/, appname ) ;
}
else {
if( strlen( title ) > 0 ) make_title( buffer, "%s", title ) ;
else sprintf( buffer, "%s - %s", conf_get_str(conf,CONF_host)/*cfg.host*/, appname ) ;
}
if( GetProtectFlag() ) if( strstr(buffer, " (PROTECTED)")==NULL ) strcat( buffer, " (PROTECTED)" ) ;
set_title_internal( frontend, buffer ) ;
free(buffer);
}
void set_icon(void *frontend, char *title2)
{
char title[1024]="",buf[512]=""; ;
int i=0;
do { buf[i]=title2[i]; i++ ; }
while ( (i<511)&&(title2[i]!='\0') ) ;
buf[i+1]='\0';
make_title( title, "%s", buf ) ;
sfree(icon_name);
icon_name = snewn(1 + strlen(title), char);
strcpy(icon_name, title);
if (!conf_get_int(conf,CONF_win_name_always)/*cfg.win_name_always*/ && IsIconic(hwnd))
SetWindowText(hwnd, title);
}
#else
void set_title(void *frontend, char *title)
{
sfree(window_name);
window_name = snewn(1 + strlen(title), char);
strcpy(window_name, title);
if (conf_get_int(conf, CONF_win_name_always) || !IsIconic(hwnd))
SetWindowText(hwnd, title);
}
void set_icon(void *frontend, char *title)
{
sfree(icon_name);
icon_name = snewn(1 + strlen(title), char);
strcpy(icon_name, title);
if (!conf_get_int(conf, CONF_win_name_always) && IsIconic(hwnd))
SetWindowText(hwnd, title);
}
#endif
void set_sbar(void *frontend, int total, int start, int page)
{
SCROLLINFO si;
if (!conf_get_int(conf, is_full_screen() ?
CONF_scrollbar_in_fullscreen : CONF_scrollbar))
return;
si.cbSize = sizeof(si);
si.fMask = SIF_ALL | SIF_DISABLENOSCROLL;
si.nMin = 0;
si.nMax = total - 1;
si.nPage = page;
si.nPos = start;
if (hwnd)
SetScrollInfo(hwnd, SB_VERT, &si, TRUE);
}
Context get_ctx(void *frontend)
{
HDC hdc;
if (hwnd) {
hdc = GetDC(hwnd);
if (hdc && pal)
SelectPalette(hdc, pal, FALSE);
return hdc;
} else
return NULL;
}
void free_ctx(Context ctx)
{
SelectPalette(ctx, GetStockObject(DEFAULT_PALETTE), FALSE);
ReleaseDC(hwnd, ctx);
}
static void real_palette_set(int n, int r, int g, int b)
{
if (pal) {
logpal->palPalEntry[n].peRed = r;
logpal->palPalEntry[n].peGreen = g;
logpal->palPalEntry[n].peBlue = b;
logpal->palPalEntry[n].peFlags = PC_NOCOLLAPSE;
colours[n] = PALETTERGB(r, g, b);
SetPaletteEntries(pal, 0, NALLCOLOURS, logpal->palPalEntry);
} else
colours[n] = RGB(r, g, b);
}
void palette_set(void *frontend, int n, int r, int g, int b)
{
if (n >= 16)
n += 256 - 16;
if (n >= NALLCOLOURS)
return;
real_palette_set(n, r, g, b);
if (pal) {
HDC hdc = get_ctx(frontend);
UnrealizeObject(pal);
RealizePalette(hdc);
free_ctx(hdc);
} else {
if (n == (ATTR_DEFBG>>ATTR_BGSHIFT))
/* If Default Background changes, we need to ensure any
* space between the text area and the window border is
* redrawn. */
InvalidateRect(hwnd, NULL, TRUE);
}
}
void palette_reset(void *frontend)
{
int i;
/* And this */
for (i = 0; i < NALLCOLOURS; i++) {
if (pal) {
logpal->palPalEntry[i].peRed = defpal[i].rgbtRed;
logpal->palPalEntry[i].peGreen = defpal[i].rgbtGreen;
logpal->palPalEntry[i].peBlue = defpal[i].rgbtBlue;
logpal->palPalEntry[i].peFlags = 0;
colours[i] = PALETTERGB(defpal[i].rgbtRed,
defpal[i].rgbtGreen,
defpal[i].rgbtBlue);
} else
colours[i] = RGB(defpal[i].rgbtRed,
defpal[i].rgbtGreen, defpal[i].rgbtBlue);
}
if (pal) {
HDC hdc;
SetPaletteEntries(pal, 0, NALLCOLOURS, logpal->palPalEntry);
hdc = get_ctx(frontend);
RealizePalette(hdc);
free_ctx(hdc);
} else {
/* Default Background may have changed. Ensure any space between
* text area and window border is redrawn. */
InvalidateRect(hwnd, NULL, TRUE);
}
}
void write_aclip(void *frontend, char *data, int len, int must_deselect)
{
HGLOBAL clipdata;
void *lock;
clipdata = GlobalAlloc(GMEM_DDESHARE | GMEM_MOVEABLE, len + 1);
if (!clipdata)
return;
lock = GlobalLock(clipdata);
if (!lock)
return;
memcpy(lock, data, len);
((unsigned char *) lock)[len] = 0;
GlobalUnlock(clipdata);
if (!must_deselect)
SendMessage(hwnd, WM_IGNORE_CLIP, TRUE, 0);
if (OpenClipboard(hwnd)) {
EmptyClipboard();
SetClipboardData(CF_TEXT, clipdata);
CloseClipboard();
} else
GlobalFree(clipdata);
if (!must_deselect)
SendMessage(hwnd, WM_IGNORE_CLIP, FALSE, 0);
}
#ifdef URLPORT
static void detect_and_launch_url(char * urldata) {
char * pc;
int len;
int urlbegin;
int hostend;
int i;
URLclick( MainHwnd ) ; return ;
urlbegin = 0;
len = strlen(urldata);
pc = urldata;
// "ftp://" is shortest detected begining of URL
if(len<=6)
return;
// skip whitespaces at the begining
while(len > 6 && isspace(*pc)) {
len--;
pc++;
}
// detect urls
if(!strncmp(pc, "ftp://", 6))
urlbegin = 6;
else if(!strncmp(pc, "http://", 7))
urlbegin = 7;
else if(!strncmp(pc, "https://", 8))
urlbegin = 8;
else
return;
// skip whitespaces at the end
while(len > urlbegin && isspace(pc[len-1])) {
len--;
pc[len]=0;
}
if(len <= urlbegin)
return;
// find first '/' or end
for(hostend = urlbegin; pc[hostend] && pc[hostend] != '/'; hostend++);
// check for spaces in hostname
for(i = urlbegin; i < hostend; i++)
if(isspace(pc[i]))
return;
ShellExecute(hwnd, NULL, pc, NULL, NULL, SW_SHOWDEFAULT);
}
#endif
/*
* Note: unlike write_aclip() this will not append a nul.
*/
void write_clip(void *frontend, wchar_t * data, int *attr, int len, int must_deselect)
{
HGLOBAL clipdata, clipdata2, clipdata3;
int len2;
void *lock, *lock2, *lock3;
#ifdef URLPORT
char * urldata;
#endif
len2 = WideCharToMultiByte(CP_ACP, 0, data, len, 0, 0, NULL, NULL);
clipdata = GlobalAlloc(GMEM_DDESHARE | GMEM_MOVEABLE,
len * sizeof(wchar_t));
clipdata2 = GlobalAlloc(GMEM_DDESHARE | GMEM_MOVEABLE, len2);
if (!clipdata || !clipdata2) {
if (clipdata)
GlobalFree(clipdata);
if (clipdata2)
GlobalFree(clipdata2);
return;
}
if (!(lock = GlobalLock(clipdata))) {
GlobalFree(clipdata);
GlobalFree(clipdata2);
return;
}
if (!(lock2 = GlobalLock(clipdata2))) {
GlobalUnlock(clipdata);
GlobalFree(clipdata);
GlobalFree(clipdata2);
return;
}
memcpy(lock, data, len * sizeof(wchar_t));
WideCharToMultiByte(CP_ACP, 0, data, len, lock2, len2, NULL, NULL);
#ifdef URLPORT
if(conf_get_int(conf,CONF_copy_clipbd_url_reg)/*cfg.copy_clipbd_url_reg*/)
urldata = strdup((char*)lock2);
else
urldata = 0;
#endif
if (conf_get_int(conf, CONF_rtf_paste)) {
wchar_t unitab[256];
char *rtf = NULL;
unsigned char *tdata = (unsigned char *)lock2;
wchar_t *udata = (wchar_t *)lock;
int rtflen = 0, uindex = 0, tindex = 0;
int rtfsize = 0;
int multilen, blen, alen, totallen, i;
char before[16], after[4];
int fgcolour, lastfgcolour = 0;
int bgcolour, lastbgcolour = 0;
int attrBold, lastAttrBold = 0;
int attrUnder, lastAttrUnder = 0;
int palette[NALLCOLOURS];
int numcolours;
FontSpec *font = conf_get_fontspec(conf, CONF_font);
get_unitab(CP_ACP, unitab, 0);
rtfsize = 100 + strlen(font->name);
rtf = snewn(rtfsize, char);
rtflen = sprintf(rtf, "{\\rtf1\\ansi\\deff0{\\fonttbl\\f0\\fmodern %s;}\\f0\\fs%d",
font->name, font->height*2);
/*
* Add colour palette
* {\colortbl ;\red255\green0\blue0;\red0\green0\blue128;}
*/
/*
* First - Determine all colours in use
* o Foregound and background colours share the same palette
*/
if (attr) {
memset(palette, 0, sizeof(palette));
for (i = 0; i < (len-1); i++) {
fgcolour = ((attr[i] & ATTR_FGMASK) >> ATTR_FGSHIFT);
bgcolour = ((attr[i] & ATTR_BGMASK) >> ATTR_BGSHIFT);
if (attr[i] & ATTR_REVERSE) {
int tmpcolour = fgcolour; /* Swap foreground and background */
fgcolour = bgcolour;
bgcolour = tmpcolour;
}
if (bold_colours && (attr[i] & ATTR_BOLD)) {
if (fgcolour < 8) /* ANSI colours */
fgcolour += 8;
else if (fgcolour >= 256) /* Default colours */
fgcolour ++;
}
if (attr[i] & ATTR_BLINK) {
if (bgcolour < 8) /* ANSI colours */
bgcolour += 8;
else if (bgcolour >= 256) /* Default colours */
bgcolour ++;
}
palette[fgcolour]++;
palette[bgcolour]++;
}
/*
* Next - Create a reduced palette
*/
numcolours = 0;
for (i = 0; i < NALLCOLOURS; i++) {
if (palette[i] != 0)
palette[i] = ++numcolours;
}
/*
* Finally - Write the colour table
*/
rtf = sresize(rtf, rtfsize + (numcolours * 25), char);
strcat(rtf, "{\\colortbl ;");
rtflen = strlen(rtf);
for (i = 0; i < NALLCOLOURS; i++) {
if (palette[i] != 0) {
rtflen += sprintf(&rtf[rtflen], "\\red%d\\green%d\\blue%d;", defpal[i].rgbtRed, defpal[i].rgbtGreen, defpal[i].rgbtBlue);
}
}
strcpy(&rtf[rtflen], "}");
rtflen ++;
}
/*
* We want to construct a piece of RTF that specifies the
* same Unicode text. To do this we will read back in
* parallel from the Unicode data in `udata' and the
* non-Unicode data in `tdata'. For each character in
* `tdata' which becomes the right thing in `udata' when
* looked up in `unitab', we just copy straight over from
* tdata. For each one that doesn't, we must WCToMB it
* individually and produce a \u escape sequence.
*
* It would probably be more robust to just bite the bullet
* and WCToMB each individual Unicode character one by one,
* then MBToWC each one back to see if it was an accurate
* translation; but that strikes me as a horrifying number
* of Windows API calls so I want to see if this faster way
* will work. If it screws up badly we can always revert to
* the simple and slow way.
*/
while (tindex < len2 && uindex < len &&
tdata[tindex] && udata[uindex]) {
if (tindex + 1 < len2 &&
tdata[tindex] == '\r' &&
tdata[tindex+1] == '\n') {
tindex++;
uindex++;
}
/*
* Set text attributes
*/
if (attr) {
if (rtfsize < rtflen + 64) {
rtfsize = rtflen + 512;
rtf = sresize(rtf, rtfsize, char);
}
/*
* Determine foreground and background colours
*/
fgcolour = ((attr[tindex] & ATTR_FGMASK) >> ATTR_FGSHIFT);
bgcolour = ((attr[tindex] & ATTR_BGMASK) >> ATTR_BGSHIFT);
if (attr[tindex] & ATTR_REVERSE) {
int tmpcolour = fgcolour; /* Swap foreground and background */
fgcolour = bgcolour;
bgcolour = tmpcolour;
}
if (bold_colours && (attr[tindex] & ATTR_BOLD)) {
if (fgcolour < 8) /* ANSI colours */
fgcolour += 8;
else if (fgcolour >= 256) /* Default colours */
fgcolour ++;
}
if (attr[tindex] & ATTR_BLINK) {
if (bgcolour < 8) /* ANSI colours */
bgcolour += 8;
else if (bgcolour >= 256) /* Default colours */
bgcolour ++;
}
/*
* Collect other attributes
*/
if (bold_font_mode != BOLD_NONE)
attrBold = attr[tindex] & ATTR_BOLD;
else
attrBold = 0;
attrUnder = attr[tindex] & ATTR_UNDER;
/*
* Reverse video
* o If video isn't reversed, ignore colour attributes for default foregound
* or background.
* o Special case where bolded text is displayed using the default foregound
* and background colours - force to bolded RTF.
*/
if (!(attr[tindex] & ATTR_REVERSE)) {
if (bgcolour >= 256) /* Default color */
bgcolour = -1; /* No coloring */
if (fgcolour >= 256) { /* Default colour */
if (bold_colours && (fgcolour & 1) && bgcolour == -1)
attrBold = ATTR_BOLD; /* Emphasize text with bold attribute */
fgcolour = -1; /* No coloring */
}
}
/*
* Write RTF text attributes
*/
if (lastfgcolour != fgcolour) {
lastfgcolour = fgcolour;
rtflen += sprintf(&rtf[rtflen], "\\cf%d ", (fgcolour >= 0) ? palette[fgcolour] : 0);
}
if (lastbgcolour != bgcolour) {
lastbgcolour = bgcolour;
rtflen += sprintf(&rtf[rtflen], "\\highlight%d ", (bgcolour >= 0) ? palette[bgcolour] : 0);
}
if (lastAttrBold != attrBold) {
lastAttrBold = attrBold;
rtflen += sprintf(&rtf[rtflen], "%s", attrBold ? "\\b " : "\\b0 ");
}
if (lastAttrUnder != attrUnder) {
lastAttrUnder = attrUnder;
rtflen += sprintf(&rtf[rtflen], "%s", attrUnder ? "\\ul " : "\\ulnone ");
}
}
if (unitab[tdata[tindex]] == udata[uindex]) {
multilen = 1;
before[0] = '\0';
after[0] = '\0';
blen = alen = 0;
} else {
multilen = WideCharToMultiByte(CP_ACP, 0, unitab+uindex, 1,
NULL, 0, NULL, NULL);
if (multilen != 1) {
blen = sprintf(before, "{\\uc%d\\u%d", multilen,
udata[uindex]);
alen = 1; strcpy(after, "}");
} else {
blen = sprintf(before, "\\u%d", udata[uindex]);
alen = 0; after[0] = '\0';
}
}
assert(tindex + multilen <= len2);
totallen = blen + alen;
for (i = 0; i < multilen; i++) {
if (tdata[tindex+i] == '\\' ||
tdata[tindex+i] == '{' ||
tdata[tindex+i] == '}')
totallen += 2;
else if (tdata[tindex+i] == 0x0D || tdata[tindex+i] == 0x0A)
totallen += 6; /* \par\r\n */
else if (tdata[tindex+i] > 0x7E || tdata[tindex+i] < 0x20)
totallen += 4;
else
totallen++;
}
if (rtfsize < rtflen + totallen + 3) {
rtfsize = rtflen + totallen + 512;
rtf = sresize(rtf, rtfsize, char);
}
strcpy(rtf + rtflen, before); rtflen += blen;
for (i = 0; i < multilen; i++) {
if (tdata[tindex+i] == '\\' ||
tdata[tindex+i] == '{' ||
tdata[tindex+i] == '}') {
rtf[rtflen++] = '\\';
rtf[rtflen++] = tdata[tindex+i];
} else if (tdata[tindex+i] == 0x0D || tdata[tindex+i] == 0x0A) {
rtflen += sprintf(rtf+rtflen, "\\par\r\n");
} else if (tdata[tindex+i] > 0x7E || tdata[tindex+i] < 0x20) {
rtflen += sprintf(rtf+rtflen, "\\'%02x", tdata[tindex+i]);
} else {
rtf[rtflen++] = tdata[tindex+i];
}
}
strcpy(rtf + rtflen, after); rtflen += alen;
tindex += multilen;
uindex++;
}
rtf[rtflen++] = '}'; /* Terminate RTF stream */
rtf[rtflen++] = '\0';
rtf[rtflen++] = '\0';
clipdata3 = GlobalAlloc(GMEM_DDESHARE | GMEM_MOVEABLE, rtflen);
if (clipdata3 && (lock3 = GlobalLock(clipdata3)) != NULL) {
memcpy(lock3, rtf, rtflen);
GlobalUnlock(clipdata3);
}
sfree(rtf);
} else
clipdata3 = NULL;
GlobalUnlock(clipdata);
GlobalUnlock(clipdata2);
if (!must_deselect)
SendMessage(hwnd, WM_IGNORE_CLIP, TRUE, 0);
if (OpenClipboard(hwnd)) {
EmptyClipboard();
SetClipboardData(CF_UNICODETEXT, clipdata);
SetClipboardData(CF_TEXT, clipdata2);
if (clipdata3)
SetClipboardData(RegisterClipboardFormat(CF_RTF), clipdata3);
CloseClipboard();
} else {
GlobalFree(clipdata);
GlobalFree(clipdata2);
}
#ifdef URLPORT
if( !PuttyFlag && conf_get_int(fonc,CONF_copy_clipbd_url_reg)/*cfg.copy_clipbd_url_reg*/ && urldata) {
detect_and_launch_url(urldata);
free(urldata);
}
#endif
if (!must_deselect)
SendMessage(hwnd, WM_IGNORE_CLIP, FALSE, 0);
}
static DWORD WINAPI clipboard_read_threadfunc(void *param)
{
HWND hwnd = (HWND)param;
HGLOBAL clipdata;
if (OpenClipboard(NULL)) {
if ((clipdata = GetClipboardData(CF_UNICODETEXT))) {
SendMessage(hwnd, WM_GOT_CLIPDATA, (WPARAM)1, (LPARAM)clipdata);
} else if ((clipdata = GetClipboardData(CF_TEXT))) {
SendMessage(hwnd, WM_GOT_CLIPDATA, (WPARAM)0, (LPARAM)clipdata);
}
CloseClipboard();
}
return 0;
}
static int process_clipdata(HGLOBAL clipdata, int unicode)
{
sfree(clipboard_contents);
clipboard_contents = NULL;
clipboard_length = 0;
if (unicode) {
wchar_t *p = GlobalLock(clipdata);
wchar_t *p2;
if (p) {
/* Unwilling to rely on Windows having wcslen() */
for (p2 = p; *p2; p2++);
clipboard_length = p2 - p;
clipboard_contents = snewn(clipboard_length + 1, wchar_t);
memcpy(clipboard_contents, p, clipboard_length * sizeof(wchar_t));
clipboard_contents[clipboard_length] = L'\0';
return TRUE;
}
} else {
char *s = GlobalLock(clipdata);
int i;
if (s) {
i = MultiByteToWideChar(CP_ACP, 0, s, strlen(s) + 1, 0, 0);
clipboard_contents = snewn(i, wchar_t);
MultiByteToWideChar(CP_ACP, 0, s, strlen(s) + 1,
clipboard_contents, i);
clipboard_length = i - 1;
clipboard_contents[clipboard_length] = L'\0';
return TRUE;
}
}
return FALSE;
}
void request_paste(void *frontend)
{
/*
* I always thought pasting was synchronous in Windows; the
* clipboard access functions certainly _look_ synchronous,
* unlike the X ones. But in fact it seems that in some
* situations the contents of the clipboard might not be
* immediately available, and the clipboard-reading functions
* may block. This leads to trouble if the application
* delivering the clipboard data has to get hold of it by -
* for example - talking over a network connection which is
* forwarded through this very PuTTY.
*
* Hence, we spawn a subthread to read the clipboard, and do
* our paste when it's finished. The thread will send a
* message back to our main window when it terminates, and
* that tells us it's OK to paste.
*/
DWORD in_threadid; /* required for Win9x */
CreateThread(NULL, 0, clipboard_read_threadfunc,
hwnd, 0, &in_threadid);
}
void get_clip(void *frontend, wchar_t **p, int *len)
{
if (p) {
*p = clipboard_contents;
*len = clipboard_length;
}
}
#if 0
/*
* Move `lines' lines from position `from' to position `to' in the
* window.
*/
void optimised_move(void *frontend, int to, int from, int lines)
{
RECT r;
int min, max;
min = (to < from ? to : from);
max = to + from - min;
r.left = offset_width;
r.right = offset_width + term->cols * font_width;
r.top = offset_height + min * font_height;
r.bottom = offset_height + (max + lines) * font_height;
ScrollWindow(hwnd, 0, (to - from) * font_height, &r, &r);
}
#endif
/*
* Print a message box and perform a fatal exit.
*/
void fatalbox(char *fmt, ...)
{
va_list ap;
char *stuff, morestuff[100];
va_start(ap, fmt);
stuff = dupvprintf(fmt, ap);
va_end(ap);
sprintf(morestuff, "%.70s Fatal Error", appname);
MessageBox(hwnd, stuff, morestuff, MB_ICONERROR | MB_OK);
sfree(stuff);
cleanup_exit(1);
}
/*
* Print a modal (Really Bad) message box and perform a fatal exit.
*/
void modalfatalbox(char *fmt, ...)
{
va_list ap;
char *stuff, morestuff[100];
va_start(ap, fmt);
stuff = dupvprintf(fmt, ap);
va_end(ap);
sprintf(morestuff, "%.70s Fatal Error", appname);
MessageBox(hwnd, stuff, morestuff,
MB_SYSTEMMODAL | MB_ICONERROR | MB_OK);
sfree(stuff);
cleanup_exit(1);
}
/*
* Print a message box and don't close the connection.
*/
void nonfatal(char *fmt, ...)
{
va_list ap;
char *stuff, morestuff[100];
va_start(ap, fmt);
stuff = dupvprintf(fmt, ap);
va_end(ap);
sprintf(morestuff, "%.70s Error", appname);
MessageBox(hwnd, stuff, morestuff, MB_ICONERROR | MB_OK);
sfree(stuff);
}
DECL_WINDOWS_FUNCTION(static, BOOL, FlashWindowEx, (PFLASHWINFO));
static void init_flashwindow(void)
{
HMODULE user32_module = load_system32_dll("user32.dll");
GET_WINDOWS_FUNCTION(user32_module, FlashWindowEx);
}
static BOOL flash_window_ex(DWORD dwFlags, UINT uCount, DWORD dwTimeout)
{
if (p_FlashWindowEx) {
FLASHWINFO fi;
fi.cbSize = sizeof(fi);
fi.hwnd = hwnd;
fi.dwFlags = dwFlags;
fi.uCount = uCount;
fi.dwTimeout = dwTimeout;
return (*p_FlashWindowEx)(&fi);
}
else
return FALSE; /* shrug */
}
static void flash_window(int mode);
static long next_flash;
static int flashing = 0;
/*
* Timer for platforms where we must maintain window flashing manually
* (e.g., Win95).
*/
static void flash_window_timer(void *ctx, unsigned long now)
{
if (flashing && now == next_flash) {
flash_window(1);
}
}
/*
* Manage window caption / taskbar flashing, if enabled.
* 0 = stop, 1 = maintain, 2 = start
*/
static void flash_window(int mode)
{
int beep_ind = conf_get_int(conf, CONF_beep_ind);
if ((mode == 0) || (beep_ind == B_IND_DISABLED)) {
/* stop */
if (flashing) {
flashing = 0;
if (p_FlashWindowEx)
flash_window_ex(FLASHW_STOP, 0, 0);
else
FlashWindow(hwnd, FALSE);
}
} else if (mode == 2) {
/* start */
if (!flashing) {
flashing = 1;
if (p_FlashWindowEx) {
/* For so-called "steady" mode, we use uCount=2, which
* seems to be the traditional number of flashes used
* by user notifications (e.g., by Explorer).
* uCount=0 appears to enable continuous flashing, per
* "flashing" mode, although I haven't seen this
* documented. */
flash_window_ex(FLASHW_ALL | FLASHW_TIMER,
(beep_ind == B_IND_FLASH ? 0 : 2),
0 /* system cursor blink rate */);
/* No need to schedule timer */
} else {
FlashWindow(hwnd, TRUE);
next_flash = schedule_timer(450, flash_window_timer, hwnd);
}
}
} else if ((mode == 1) && (beep_ind == B_IND_FLASH)) {
/* maintain */
if (flashing && !p_FlashWindowEx) {
FlashWindow(hwnd, TRUE); /* toggle */
next_flash = schedule_timer(450, flash_window_timer, hwnd);
}
}
}
/*
* Beep.
*/
void do_beep(void *frontend, int mode)
{
if (mode == BELL_DEFAULT) {
/*
* For MessageBeep style bells, we want to be careful of
* timing, because they don't have the nice property of
* PlaySound bells that each one cancels the previous
* active one. So we limit the rate to one per 50ms or so.
*/
static long lastbeep = 0;
long beepdiff;
beepdiff = GetTickCount() - lastbeep;
if (beepdiff >= 0 && beepdiff < 50)
return;
MessageBeep(MB_OK);
/*
* The above MessageBeep call takes time, so we record the
* time _after_ it finishes rather than before it starts.
*/
lastbeep = GetTickCount();
} else if (mode == BELL_WAVEFILE) {
Filename *bell_wavefile = conf_get_filename(conf, CONF_bell_wavefile);
if (!PlaySound(bell_wavefile->path, NULL,
SND_ASYNC | SND_FILENAME)) {
char buf[sizeof(bell_wavefile->path) + 80];
char otherbuf[100];
sprintf(buf, "Unable to play sound file\n%s\n"
"Using default sound instead", bell_wavefile->path);
sprintf(otherbuf, "%.70s Sound Error", appname);
MessageBox(hwnd, buf, otherbuf,
MB_OK | MB_ICONEXCLAMATION);
conf_set_int(conf, CONF_beep, BELL_DEFAULT);
}
} else if (mode == BELL_PCSPEAKER) {
static long lastbeep = 0;
long beepdiff;
beepdiff = GetTickCount() - lastbeep;
if (beepdiff >= 0 && beepdiff < 50)
return;
/*
* We must beep in different ways depending on whether this
* is a 95-series or NT-series OS.
*/
if(osVersion.dwPlatformId == VER_PLATFORM_WIN32_NT)
Beep(800, 100);
else
MessageBeep(-1);
lastbeep = GetTickCount();
}
/* Otherwise, either visual bell or disabled; do nothing here */
if (!term->has_focus) {
#ifdef PERSOPORT
if( GetVisibleFlag()!=VISIBLE_TRAY ) {
if(conf_get_int(conf,CONF_foreground_on_bell)/*cfg.foreground_on_bell*/ ) { // Tester avec sleep 4 ; echo -e '\a'
if( IsIconic(hwnd) ) SwitchToThisWindow( hwnd, TRUE ) ;
else SetForegroundWindow( MainHwnd ) ;
}
else {
//if( IsIconic(hwnd) && (mode == BELL_VISUAL) )
if( mode == BELL_VISUAL ) {
if( IsIconic(hwnd) )
FlashWindow(hwnd, TRUE) ;
else
flash_window(2) ;
}
else { if( conf_get_int(conf,CONF_beep_ind)==B_IND_FLASH ) flash_window(2) ; }
}
} else if( GetVisibleFlag()==VISIBLE_TRAY ) {
if( conf_get_int(conf,CONF_foreground_on_bell)/*cfg.foreground_on_bell*/ ) { SendMessage( MainHwnd, WM_COMMAND, IDM_FROMTRAY, 0 ); }
else if(mode == BELL_VISUAL) SetTimer(hwnd, TIMER_BLINKTRAYICON, (int)500, NULL) ;
//SendMessage( MainHwnd, WM_COMMAND, IDM_FROMTRAY, 0 );
//flash_window(2); /* start */
//ShowWindow( MainHwnd, SW_MINIMIZE);
} else
#endif
flash_window(2); /* start */
}
}
/*
* Minimise or restore the window in response to a server-side
* request.
*/
void set_iconic(void *frontend, int iconic)
{
if (IsIconic(hwnd)) {
if (!iconic)
ShowWindow(hwnd, SW_RESTORE);
} else {
if (iconic)
ShowWindow(hwnd, SW_MINIMIZE);
}
}
/*
* Move the window in response to a server-side request.
*/
void move_window(void *frontend, int x, int y)
{
int resize_action = conf_get_int(conf, CONF_resize_action);
if (resize_action == RESIZE_DISABLED ||
resize_action == RESIZE_FONT ||
IsZoomed(hwnd))
return;
SetWindowPos(hwnd, NULL, x, y, 0, 0, SWP_NOSIZE | SWP_NOZORDER);
}
/*
* Move the window to the top or bottom of the z-order in response
* to a server-side request.
*/
void set_zorder(void *frontend, int top)
{
if (conf_get_int(conf, CONF_alwaysontop))
return; /* ignore */
SetWindowPos(hwnd, top ? HWND_TOP : HWND_BOTTOM, 0, 0, 0, 0,
SWP_NOMOVE | SWP_NOSIZE);
}
/*
* Refresh the window in response to a server-side request.
*/
void refresh_window(void *frontend)
{
InvalidateRect(hwnd, NULL, TRUE);
}
/*
* Maximise or restore the window in response to a server-side
* request.
*/
void set_zoomed(void *frontend, int zoomed)
{
if (IsZoomed(hwnd)) {
if (!zoomed)
ShowWindow(hwnd, SW_RESTORE);
} else {
if (zoomed)
ShowWindow(hwnd, SW_MAXIMIZE);
}
}
/*
* Report whether the window is iconic, for terminal reports.
*/
int is_iconic(void *frontend)
{
return IsIconic(hwnd);
}
/*
* Report the window's position, for terminal reports.
*/
void get_window_pos(void *frontend, int *x, int *y)
{
RECT r;
GetWindowRect(hwnd, &r);
*x = r.left;
*y = r.top;
}
/*
* Report the window's pixel size, for terminal reports.
*/
void get_window_pixels(void *frontend, int *x, int *y)
{
RECT r;
GetWindowRect(hwnd, &r);
*x = r.right - r.left;
*y = r.bottom - r.top;
}
/*
* Return the window or icon title.
*/
char *get_window_title(void *frontend, int icon)
{
return icon ? icon_name : window_name;
}
/*
* See if we're in full-screen mode.
*/
static int is_full_screen()
{
if (!IsZoomed(hwnd))
return FALSE;
if (GetWindowLongPtr(hwnd, GWL_STYLE) & WS_CAPTION)
return FALSE;
return TRUE;
}
/* Get the rect/size of a full screen window using the nearest available
* monitor in multimon systems; default to something sensible if only
* one monitor is present. */
static int get_fullscreen_rect(RECT * ss)
{
#if defined(MONITOR_DEFAULTTONEAREST) && !defined(NO_MULTIMON)
HMONITOR mon;
MONITORINFO mi;
mon = MonitorFromWindow(hwnd, MONITOR_DEFAULTTONEAREST);
mi.cbSize = sizeof(mi);
GetMonitorInfo(mon, &mi);
/* structure copy */
*ss = mi.rcMonitor;
return TRUE;
#else
/* could also use code like this:
ss->left = ss->top = 0;
ss->right = GetSystemMetrics(SM_CXSCREEN);
ss->bottom = GetSystemMetrics(SM_CYSCREEN);
*/
return GetClientRect(GetDesktopWindow(), ss);
#endif
}
/*
* Go full-screen. This should only be called when we are already
* maximised.
*/
static void make_full_screen()
{
DWORD style;
RECT ss;
assert(IsZoomed(hwnd));
if (is_full_screen())
return;
/* Remove the window furniture. */
style = GetWindowLongPtr(hwnd, GWL_STYLE);
style &= ~(WS_CAPTION | WS_BORDER | WS_THICKFRAME);
if (conf_get_int(conf, CONF_scrollbar_in_fullscreen))
style |= WS_VSCROLL;
else
style &= ~WS_VSCROLL;
SetWindowLongPtr(hwnd, GWL_STYLE, style);
/* Resize ourselves to exactly cover the nearest monitor. */
get_fullscreen_rect(&ss);
SetWindowPos(hwnd, HWND_TOP, ss.left, ss.top,
ss.right - ss.left,
ss.bottom - ss.top,
SWP_FRAMECHANGED);
/* We may have changed size as a result */
reset_window(0);
/* Tick the menu item in the System and context menus. */
{
int i;
for (i = 0; i < lenof(popup_menus); i++)
CheckMenuItem(popup_menus[i].menu, IDM_FULLSCREEN, MF_CHECKED);
}
}
/*
* Clear the full-screen attributes.
*/
static void clear_full_screen()
{
DWORD oldstyle, style;
/* Reinstate the window furniture. */
style = oldstyle = GetWindowLongPtr(hwnd, GWL_STYLE);
style |= WS_CAPTION | WS_BORDER;
if (conf_get_int(conf, CONF_resize_action) == RESIZE_DISABLED)
style &= ~WS_THICKFRAME;
else
style |= WS_THICKFRAME;
if (conf_get_int(conf, CONF_scrollbar))
style |= WS_VSCROLL;
else
style &= ~WS_VSCROLL;
if (style != oldstyle) {
SetWindowLongPtr(hwnd, GWL_STYLE, style);
SetWindowPos(hwnd, NULL, 0, 0, 0, 0,
SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER |
SWP_FRAMECHANGED);
}
/* Untick the menu item in the System and context menus. */
{
int i;
for (i = 0; i < lenof(popup_menus); i++)
CheckMenuItem(popup_menus[i].menu, IDM_FULLSCREEN, MF_UNCHECKED);
}
}
/*
* Toggle full-screen mode.
*/
static void flip_full_screen()
{
if (is_full_screen()) {
ShowWindow(hwnd, SW_RESTORE);
} else if (IsZoomed(hwnd)) {
make_full_screen();
} else {
SendMessage(hwnd, WM_FULLSCR_ON_MAX, 0, 0);
ShowWindow(hwnd, SW_MAXIMIZE);
}
#if (defined IMAGEPORT) && (!defined FDJ)
if( BackgroundImageFlag&&(!PuttyFlag)&&(conf_get_int(conf,CONF_bg_image_abs_fixed)/*cfg.bg_image_abs_fixed*/==1)&&(conf_get_int(conf,CONF_bg_type)/*cfg.bg_type*/!=0) ) RefreshBackground( hwnd ) ;
#endif
}
void frontend_keypress(void *handle)
{
/*
* Keypress termination in non-Close-On-Exit mode is not
* currently supported in PuTTY proper, because the window
* always has a perfectly good Close button anyway. So we do
* nothing here.
*/
return;
}
int from_backend(void *frontend, int is_stderr, const char *data, int len)
{
#ifdef PERSOPORT
int res = term_data(term, is_stderr, data, len) ;
if( (!PuttyFlag) && (ScriptFileContent!=NULL) ) ManageInitScript( data, len ) ;
return res ;
#else
return term_data(term, is_stderr, data, len);
#endif
}
int from_backend_untrusted(void *frontend, const char *data, int len)
{
return term_data_untrusted(term, data, len);
}
int from_backend_eof(void *frontend)
{
return TRUE; /* do respond to incoming EOF with outgoing */
}
int get_userpass_input(prompts_t *p, unsigned char *in, int inlen)
{
int ret;
ret = cmdline_get_passwd_input(p, in, inlen);
if (ret == -1)
ret = term_get_userpass_input(term, p, in, inlen);
return ret;
}
void agent_schedule_callback(void (*callback)(void *, void *, int),
void *callback_ctx, void *data, int len)
{
struct agent_callback *c = snew(struct agent_callback);
c->callback = callback;
c->callback_ctx = callback_ctx;
c->data = data;
c->len = len;
PostMessage(hwnd, WM_AGENT_CALLBACK, 0, (LPARAM)c);
}
#include "../../kitty_light.c"
| ralish/kitty | 0.63_My_PuTTY/WINDOWS/WINDOW.C | C++ | mit | 238,518 | [
30522,
1013,
1008,
1008,
3332,
1012,
1039,
1011,
1996,
2404,
3723,
1006,
10093,
1007,
2364,
2565,
1010,
2029,
3216,
1037,
2404,
3723,
5536,
1008,
7861,
20350,
1998,
2067,
10497,
1999,
1037,
3332,
1012,
1008,
1013,
1001,
2421,
1026,
2358,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
/**
* FreeRDP: A Remote Desktop Protocol Implementation
* Digital Sound Processing - FFMPEG backend
*
* Copyright 2018 Armin Novak <armin.novak@thincast.com>
* Copyright 2018 Thincast Technologies GmbH
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <freerdp/log.h>
#include <libavcodec/avcodec.h>
#include <libavutil/avutil.h>
#include <libavutil/opt.h>
#include <libavresample/avresample.h>
#include "dsp.h"
#include "dsp_ffmpeg.h"
#define TAG FREERDP_TAG("dsp.ffmpeg")
struct _FREERDP_DSP_CONTEXT
{
AUDIO_FORMAT format;
BOOL isOpen;
BOOL encoder;
UINT32 bufferedSamples;
enum AVCodecID id;
AVCodec* codec;
AVCodecContext* context;
AVFrame* frame;
AVFrame* resampled;
AVFrame* buffered;
AVPacket* packet;
AVAudioResampleContext* rcontext;
};
static BOOL ffmpeg_codec_is_filtered(enum AVCodecID id, BOOL encoder)
{
if (!encoder)
return FALSE;
switch (id)
{
#if !defined(WITH_DSP_EXPERIMENTAL)
case AV_CODEC_ID_MP3:
case AV_CODEC_ID_GSM_MS:
case AV_CODEC_ID_AAC:
return TRUE;
#endif
case AV_CODEC_ID_NONE:
return TRUE;
default:
return FALSE;
}
}
static enum AVCodecID ffmpeg_get_avcodec(const AUDIO_FORMAT* format)
{
const char* id;
if (!format)
return AV_CODEC_ID_NONE;
id = rdpsnd_get_audio_tag_string(format->wFormatTag);
switch (format->wFormatTag)
{
case WAVE_FORMAT_UNKNOWN:
return AV_CODEC_ID_NONE;
case WAVE_FORMAT_PCM:
switch (format->wBitsPerSample)
{
case 16:
return AV_CODEC_ID_PCM_U16LE;
case 8:
return AV_CODEC_ID_PCM_U8;
default:
return AV_CODEC_ID_NONE;
}
case WAVE_FORMAT_DVI_ADPCM:
return AV_CODEC_ID_ADPCM_MS;
case WAVE_FORMAT_ADPCM:
return AV_CODEC_ID_ADPCM_MS;
case WAVE_FORMAT_ALAW:
return AV_CODEC_ID_PCM_ALAW;
case WAVE_FORMAT_MULAW:
return AV_CODEC_ID_PCM_MULAW;
case WAVE_FORMAT_GSM610:
return AV_CODEC_ID_GSM_MS;
case WAVE_FORMAT_AAC_MS:
return AV_CODEC_ID_AAC;
default:
return AV_CODEC_ID_NONE;
}
}
static int ffmpeg_sample_format(const AUDIO_FORMAT* format)
{
switch (format->wFormatTag)
{
case WAVE_FORMAT_PCM:
switch (format->wBitsPerSample)
{
case 8:
return AV_SAMPLE_FMT_U8;
case 16:
return AV_SAMPLE_FMT_S16;
default:
return FALSE;
}
case WAVE_FORMAT_DVI_ADPCM:
case WAVE_FORMAT_ADPCM:
return AV_SAMPLE_FMT_S16P;
case WAVE_FORMAT_MPEGLAYER3:
case WAVE_FORMAT_AAC_MS:
return AV_SAMPLE_FMT_FLTP;
case WAVE_FORMAT_GSM610:
return AV_SAMPLE_FMT_S16P;
case WAVE_FORMAT_ALAW:
return AV_SAMPLE_FMT_S16;
default:
return FALSE;
}
}
static void ffmpeg_close_context(FREERDP_DSP_CONTEXT* context)
{
if (context)
{
if (context->context)
avcodec_free_context(&context->context);
if (context->frame)
av_frame_free(&context->frame);
if (context->resampled)
av_frame_free(&context->resampled);
if (context->buffered)
av_frame_free(&context->buffered);
if (context->packet)
av_packet_free(&context->packet);
if (context->rcontext)
avresample_free(&context->rcontext);
context->id = AV_CODEC_ID_NONE;
context->codec = NULL;
context->isOpen = FALSE;
context->context = NULL;
context->frame = NULL;
context->resampled = NULL;
context->packet = NULL;
context->rcontext = NULL;
}
}
static BOOL ffmpeg_open_context(FREERDP_DSP_CONTEXT* context)
{
int ret;
int layout;
const AUDIO_FORMAT* format;
if (!context || context->isOpen)
return FALSE;
format = &context->format;
if (!format)
return FALSE;
layout = av_get_default_channel_layout(format->nChannels);
context->id = ffmpeg_get_avcodec(format);
if (ffmpeg_codec_is_filtered(context->id, context->encoder))
goto fail;
if (context->encoder)
context->codec = avcodec_find_encoder(context->id);
else
context->codec = avcodec_find_decoder(context->id);
if (!context->codec)
goto fail;
context->context = avcodec_alloc_context3(context->codec);
if (!context->context)
goto fail;
switch (context->id)
{
/* We need support for multichannel and sample rates != 8000 */
case AV_CODEC_ID_GSM_MS:
context->context->strict_std_compliance = FF_COMPLIANCE_UNOFFICIAL;
break;
default:
break;
}
context->context->channels = format->nChannels;
context->context->channel_layout = layout;
context->context->sample_rate = format->nSamplesPerSec;
context->context->block_align = format->nBlockAlign;
context->context->bit_rate = format->nAvgBytesPerSec * 8;
context->context->sample_fmt = ffmpeg_sample_format(format);
context->context->time_base = av_make_q(1, context->context->sample_rate);
if ((ret = avcodec_open2(context->context, context->codec, NULL)) < 0)
{
const char* err = av_err2str(ret);
WLog_ERR(TAG, "Error avcodec_open2 %s [%d]", err, ret);
goto fail;
}
context->packet = av_packet_alloc();
if (!context->packet)
goto fail;
context->frame = av_frame_alloc();
if (!context->frame)
goto fail;
context->resampled = av_frame_alloc();
if (!context->resampled)
goto fail;
context->buffered = av_frame_alloc();
if (!context->buffered)
goto fail;
context->rcontext = avresample_alloc_context();
if (!context->rcontext)
goto fail;
context->frame->channel_layout = layout;
context->frame->channels = format->nChannels;
context->frame->sample_rate = format->nSamplesPerSec;
context->frame->format = AV_SAMPLE_FMT_S16;
if (context->encoder)
{
context->resampled->format = context->context->sample_fmt;
context->resampled->sample_rate = context->context->sample_rate;
}
else
{
context->resampled->format = AV_SAMPLE_FMT_S16;
context->resampled->sample_rate = format->nSamplesPerSec;
}
context->resampled->channel_layout = layout;
context->resampled->channels = format->nChannels;
if (context->context->frame_size > 0)
{
context->buffered->channel_layout = context->resampled->channel_layout;
context->buffered->channels = context->resampled->channels;
context->buffered->format = context->resampled->format;
context->buffered->nb_samples = context->context->frame_size;
if ((ret = av_frame_get_buffer(context->buffered, 1)) < 0)
goto fail;
}
context->isOpen = TRUE;
return TRUE;
fail:
ffmpeg_close_context(context);
return FALSE;
}
static BOOL ffmpeg_resample_frame(AVAudioResampleContext* context,
AVFrame* in, AVFrame* out)
{
int ret;
if (!avresample_is_open(context))
{
if ((ret = avresample_config(context, out, in)) < 0)
{
const char* err = av_err2str(ret);
WLog_ERR(TAG, "Error during resampling %s [%d]", err, ret);
return FALSE;
}
if ((ret = (avresample_open(context))) < 0)
{
const char* err = av_err2str(ret);
WLog_ERR(TAG, "Error during resampling %s [%d]", err, ret);
return FALSE;
}
}
if ((ret = avresample_convert_frame(context, out, in)) < 0)
{
const char* err = av_err2str(ret);
WLog_ERR(TAG, "Error during resampling %s [%d]", err, ret);
return FALSE;
}
return TRUE;
}
static BOOL ffmpeg_encode_frame(AVCodecContext* context, AVFrame* in,
AVPacket* packet, wStream* out)
{
int ret;
/* send the packet with the compressed data to the encoder */
ret = avcodec_send_frame(context, in);
if (ret < 0)
{
const char* err = av_err2str(ret);
WLog_ERR(TAG, "Error submitting the packet to the encoder %s [%d]",
err, ret);
return FALSE;
}
/* read all the output frames (in general there may be any number of them */
while (ret >= 0)
{
ret = avcodec_receive_packet(context, packet);
if (ret == AVERROR(EAGAIN) || ret == AVERROR_EOF)
return TRUE;
else if (ret < 0)
{
const char* err = av_err2str(ret);
WLog_ERR(TAG, "Error during encoding %s [%d]", err, ret);
return FALSE;
}
if (!Stream_EnsureRemainingCapacity(out, packet->size))
return FALSE;
Stream_Write(out, packet->data, packet->size);
av_packet_unref(packet);
}
return TRUE;
}
static BOOL ffmpeg_fill_frame(AVFrame* frame, const AUDIO_FORMAT* inputFormat,
const BYTE* data, size_t size)
{
int ret, bpp;
frame->channels = inputFormat->nChannels;
frame->sample_rate = inputFormat->nSamplesPerSec;
frame->format = ffmpeg_sample_format(inputFormat);
frame->channel_layout = av_get_default_channel_layout(frame->channels);
bpp = av_get_bytes_per_sample(frame->format);
frame->nb_samples = size / inputFormat->nChannels / bpp;
if ((ret = avcodec_fill_audio_frame(frame, frame->channels,
frame->format,
data, size, 1)) < 0)
{
const char* err = av_err2str(ret);
WLog_ERR(TAG, "Error during audio frame fill %s [%d]", err, ret);
return FALSE;
}
return TRUE;
}
static BOOL ffmpeg_decode(AVCodecContext* dec_ctx, AVPacket* pkt,
AVFrame* frame,
AVAudioResampleContext* resampleContext,
AVFrame* resampled, wStream* out)
{
int ret;
/* send the packet with the compressed data to the decoder */
ret = avcodec_send_packet(dec_ctx, pkt);
if (ret < 0)
{
const char* err = av_err2str(ret);
WLog_ERR(TAG, "Error submitting the packet to the decoder %s [%d]",
err, ret);
return FALSE;
}
/* read all the output frames (in general there may be any number of them */
while (ret >= 0)
{
ret = avcodec_receive_frame(dec_ctx, frame);
if (ret == AVERROR(EAGAIN) || ret == AVERROR_EOF)
return TRUE;
else if (ret < 0)
{
const char* err = av_err2str(ret);
WLog_ERR(TAG, "Error during decoding %s [%d]", err, ret);
return FALSE;
}
if (!avresample_is_open(resampleContext))
{
if ((ret = avresample_config(resampleContext, resampled, frame)) < 0)
{
const char* err = av_err2str(ret);
WLog_ERR(TAG, "Error during resampling %s [%d]", err, ret);
return FALSE;
}
if ((ret = (avresample_open(resampleContext))) < 0)
{
const char* err = av_err2str(ret);
WLog_ERR(TAG, "Error during resampling %s [%d]", err, ret);
return FALSE;
}
}
if ((ret = avresample_convert_frame(resampleContext, resampled, frame)) < 0)
{
const char* err = av_err2str(ret);
WLog_ERR(TAG, "Error during resampling %s [%d]", err, ret);
return FALSE;
}
{
const size_t data_size = resampled->channels * resampled->nb_samples * 2;
Stream_EnsureRemainingCapacity(out, data_size);
Stream_Write(out, resampled->data[0], data_size);
}
}
return TRUE;
}
BOOL freerdp_dsp_ffmpeg_supports_format(const AUDIO_FORMAT* format, BOOL encode)
{
enum AVCodecID id = ffmpeg_get_avcodec(format);
if (ffmpeg_codec_is_filtered(id, encode))
return FALSE;
if (encode)
return avcodec_find_encoder(id) != NULL;
else
return avcodec_find_decoder(id) != NULL;
}
FREERDP_DSP_CONTEXT* freerdp_dsp_ffmpeg_context_new(BOOL encode)
{
FREERDP_DSP_CONTEXT* context;
avcodec_register_all();
context = calloc(1, sizeof(FREERDP_DSP_CONTEXT));
if (!context)
return NULL;
context->encoder = encode;
return context;
}
void freerdp_dsp_ffmpeg_context_free(FREERDP_DSP_CONTEXT* context)
{
if (context)
{
ffmpeg_close_context(context);
free(context);
}
}
BOOL freerdp_dsp_ffmpeg_context_reset(FREERDP_DSP_CONTEXT* context,
const AUDIO_FORMAT* targetFormat)
{
if (!context || !targetFormat)
return FALSE;
ffmpeg_close_context(context);
context->format = *targetFormat;
return ffmpeg_open_context(context);
}
BOOL freerdp_dsp_ffmpeg_encode(FREERDP_DSP_CONTEXT* context, const AUDIO_FORMAT* format,
const BYTE* data, size_t length, wStream* out)
{
int rc;
int samples, rest;
if (!context || !format || !data || !out || !context->encoder)
return FALSE;
if (!context || !data || !out)
return FALSE;
/* Create input frame */
if (!ffmpeg_fill_frame(context->frame, format, data, length))
return FALSE;
/* Resample to desired format. */
if (!ffmpeg_resample_frame(context->rcontext,
context->frame,
context->resampled))
return FALSE;
if (context->context->frame_size <= 0)
{
return ffmpeg_encode_frame(context->context, context->resampled,
context->packet, out);
}
else
{
rest = samples = context->resampled->nb_samples;
do
{
if (samples + context->bufferedSamples > context->context->frame_size)
samples = context->context->frame_size - context->bufferedSamples;
rc = av_samples_copy(context->buffered->extended_data, context->resampled->extended_data,
context->bufferedSamples, 0, samples,
context->context->channels, context->context->sample_fmt);
rest -= samples;
context->bufferedSamples += samples;
if (context->context->frame_size <= context->bufferedSamples)
{
/* Encode in desired format. */
if (!ffmpeg_encode_frame(context->context, context->buffered,
context->packet, out))
return FALSE;
context->bufferedSamples = 0;
}
}
while (rest > 0);
return TRUE;
}
}
BOOL freerdp_dsp_ffmpeg_decode(FREERDP_DSP_CONTEXT* context, const AUDIO_FORMAT* srcFormat,
const BYTE* data, size_t length, wStream* out)
{
if (!context || !srcFormat || !data || !out || context->encoder)
return FALSE;
av_init_packet(context->packet);
context->packet->data = data;
context->packet->size = length;
return ffmpeg_decode(context->context, context->packet, context->frame,
context->rcontext, context->resampled, out);
}
| rjcorrig/FreeRDP | libfreerdp/codec/dsp_ffmpeg.c | C | apache-2.0 | 14,139 | [
30522,
1013,
1008,
1008,
1008,
2489,
4103,
2361,
1024,
1037,
6556,
15363,
8778,
7375,
1008,
3617,
2614,
6364,
1011,
21461,
8737,
13910,
2067,
10497,
1008,
1008,
9385,
2760,
2849,
2378,
19580,
1026,
2849,
2378,
1012,
19580,
1030,
4857,
10526... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
/*
* The Kuali Financial System, a comprehensive financial management system for higher education.
*
* Copyright 2005-2014 The Kuali Foundation
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.kuali.kfs.module.cg.service.impl;
import java.util.ArrayList;
import java.util.List;
import org.kuali.kfs.module.cg.CGPropertyConstants;
import org.kuali.kfs.module.cg.service.ContractsAndGrantsBillingService;
/**
* Service with methods related to the Contracts & Grants Billing (CGB) enhancement.
*/
public class ContractsAndGrantsBillingServiceImpl implements ContractsAndGrantsBillingService {
@Override
public List<String> getAgencyContractsGrantsBillingSectionIds() {
List<String> contractsGrantsSectionIds = new ArrayList<String>();
contractsGrantsSectionIds.add(CGPropertyConstants.SectionId.AGENCY_ADDRESS_SECTION_ID);
contractsGrantsSectionIds.add(CGPropertyConstants.SectionId.AGENCY_ADDRESSES_SECTION_ID);
contractsGrantsSectionIds.add(CGPropertyConstants.SectionId.AGENCY_COLLECTIONS_MAINTENANCE_SECTION_ID);
contractsGrantsSectionIds.add(CGPropertyConstants.SectionId.AGENCY_CONTRACTS_AND_GRANTS_SECTION_ID);
contractsGrantsSectionIds.add(CGPropertyConstants.SectionId.AGENCY_CUSTOMER_SECTION_ID);
return contractsGrantsSectionIds;
}
@Override
public List<String> getAwardContractsGrantsBillingSectionIds() {
List<String> contractsGrantsSectionIds = new ArrayList<String>();
contractsGrantsSectionIds.add(CGPropertyConstants.SectionId.AWARD_FUND_MANAGERS_SECTION_ID);
contractsGrantsSectionIds.add(CGPropertyConstants.SectionId.AWARD_INVOICING_SECTION_ID);
contractsGrantsSectionIds.add(CGPropertyConstants.SectionId.AWARD_MILESTONE_SCHEDULE_SECTION_ID);
contractsGrantsSectionIds.add(CGPropertyConstants.SectionId.AWARD_PREDETERMINED_BILLING_SCHEDULE_SECTION_ID);
return contractsGrantsSectionIds;
}
}
| bhutchinson/kfs | kfs-cg/src/main/java/org/kuali/kfs/module/cg/service/impl/ContractsAndGrantsBillingServiceImpl.java | Java | agpl-3.0 | 2,589 | [
30522,
1013,
1008,
1008,
1996,
13970,
11475,
3361,
2291,
1010,
1037,
7721,
3361,
2968,
2291,
2005,
3020,
2495,
1012,
1008,
1008,
9385,
2384,
1011,
2297,
1996,
13970,
11475,
3192,
1008,
1008,
2023,
2565,
2003,
2489,
4007,
1024,
2017,
2064,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('vega'), require('vega-lite')) :
typeof define === 'function' && define.amd ? define(['vega', 'vega-lite'], factory) :
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.vegaEmbed = factory(global.vega, global.vegaLite));
})(this, (function (vegaImport, vegaLiteImport) { 'use strict';
function _interopNamespace(e) {
if (e && e.__esModule) return e;
var n = Object.create(null);
if (e) {
Object.keys(e).forEach(function (k) {
if (k !== 'default') {
var d = Object.getOwnPropertyDescriptor(e, k);
Object.defineProperty(n, k, d.get ? d : {
enumerable: true,
get: function () { return e[k]; }
});
}
});
}
n["default"] = e;
return Object.freeze(n);
}
var vegaImport__namespace = /*#__PURE__*/_interopNamespace(vegaImport);
var vegaLiteImport__namespace = /*#__PURE__*/_interopNamespace(vegaLiteImport);
/*!
* https://github.com/Starcounter-Jack/JSON-Patch
* (c) 2017 Joachim Wester
* MIT license
*/
var __extends = undefined && undefined.__extends || function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf || {
__proto__: []
} instanceof Array && function (d, b) {
d.__proto__ = b;
} || function (d, b) {
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
};
return extendStatics(d, b);
};
return function (d, b) {
extendStatics(d, b);
function __() {
this.constructor = d;
}
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
}();
var _hasOwnProperty = Object.prototype.hasOwnProperty;
function hasOwnProperty(obj, key) {
return _hasOwnProperty.call(obj, key);
}
function _objectKeys(obj) {
if (Array.isArray(obj)) {
var keys = new Array(obj.length);
for (var k = 0; k < keys.length; k++) {
keys[k] = "" + k;
}
return keys;
}
if (Object.keys) {
return Object.keys(obj);
}
var keys = [];
for (var i in obj) {
if (hasOwnProperty(obj, i)) {
keys.push(i);
}
}
return keys;
}
/**
* Deeply clone the object.
* https://jsperf.com/deep-copy-vs-json-stringify-json-parse/25 (recursiveDeepCopy)
* @param {any} obj value to clone
* @return {any} cloned obj
*/
function _deepClone(obj) {
switch (typeof obj) {
case "object":
return JSON.parse(JSON.stringify(obj));
//Faster than ES5 clone - http://jsperf.com/deep-cloning-of-objects/5
case "undefined":
return null;
//this is how JSON.stringify behaves for array items
default:
return obj;
//no need to clone primitives
}
} //3x faster than cached /^\d+$/.test(str)
function isInteger(str) {
var i = 0;
var len = str.length;
var charCode;
while (i < len) {
charCode = str.charCodeAt(i);
if (charCode >= 48 && charCode <= 57) {
i++;
continue;
}
return false;
}
return true;
}
/**
* Escapes a json pointer path
* @param path The raw pointer
* @return the Escaped path
*/
function escapePathComponent(path) {
if (path.indexOf('/') === -1 && path.indexOf('~') === -1) return path;
return path.replace(/~/g, '~0').replace(/\//g, '~1');
}
/**
* Unescapes a json pointer path
* @param path The escaped pointer
* @return The unescaped path
*/
function unescapePathComponent(path) {
return path.replace(/~1/g, '/').replace(/~0/g, '~');
}
/**
* Recursively checks whether an object has any undefined values inside.
*/
function hasUndefined(obj) {
if (obj === undefined) {
return true;
}
if (obj) {
if (Array.isArray(obj)) {
for (var i = 0, len = obj.length; i < len; i++) {
if (hasUndefined(obj[i])) {
return true;
}
}
} else if (typeof obj === "object") {
var objKeys = _objectKeys(obj);
var objKeysLength = objKeys.length;
for (var i = 0; i < objKeysLength; i++) {
if (hasUndefined(obj[objKeys[i]])) {
return true;
}
}
}
}
return false;
}
function patchErrorMessageFormatter(message, args) {
var messageParts = [message];
for (var key in args) {
var value = typeof args[key] === 'object' ? JSON.stringify(args[key], null, 2) : args[key]; // pretty print
if (typeof value !== 'undefined') {
messageParts.push(key + ": " + value);
}
}
return messageParts.join('\n');
}
var PatchError = function (_super) {
__extends(PatchError, _super);
function PatchError(message, name, index, operation, tree) {
var _newTarget = this.constructor;
var _this = _super.call(this, patchErrorMessageFormatter(message, {
name: name,
index: index,
operation: operation,
tree: tree
})) || this;
_this.name = name;
_this.index = index;
_this.operation = operation;
_this.tree = tree;
Object.setPrototypeOf(_this, _newTarget.prototype); // restore prototype chain, see https://stackoverflow.com/a/48342359
_this.message = patchErrorMessageFormatter(message, {
name: name,
index: index,
operation: operation,
tree: tree
});
return _this;
}
return PatchError;
}(Error);
var JsonPatchError = PatchError;
var deepClone = _deepClone;
/* We use a Javascript hash to store each
function. Each hash entry (property) uses
the operation identifiers specified in rfc6902.
In this way, we can map each patch operation
to its dedicated function in efficient way.
*/
/* The operations applicable to an object */
var objOps = {
add: function (obj, key, document) {
obj[key] = this.value;
return {
newDocument: document
};
},
remove: function (obj, key, document) {
var removed = obj[key];
delete obj[key];
return {
newDocument: document,
removed: removed
};
},
replace: function (obj, key, document) {
var removed = obj[key];
obj[key] = this.value;
return {
newDocument: document,
removed: removed
};
},
move: function (obj, key, document) {
/* in case move target overwrites an existing value,
return the removed value, this can be taxing performance-wise,
and is potentially unneeded */
var removed = getValueByPointer(document, this.path);
if (removed) {
removed = _deepClone(removed);
}
var originalValue = applyOperation(document, {
op: "remove",
path: this.from
}).removed;
applyOperation(document, {
op: "add",
path: this.path,
value: originalValue
});
return {
newDocument: document,
removed: removed
};
},
copy: function (obj, key, document) {
var valueToCopy = getValueByPointer(document, this.from); // enforce copy by value so further operations don't affect source (see issue #177)
applyOperation(document, {
op: "add",
path: this.path,
value: _deepClone(valueToCopy)
});
return {
newDocument: document
};
},
test: function (obj, key, document) {
return {
newDocument: document,
test: _areEquals(obj[key], this.value)
};
},
_get: function (obj, key, document) {
this.value = obj[key];
return {
newDocument: document
};
}
};
/* The operations applicable to an array. Many are the same as for the object */
var arrOps = {
add: function (arr, i, document) {
if (isInteger(i)) {
arr.splice(i, 0, this.value);
} else {
// array props
arr[i] = this.value;
} // this may be needed when using '-' in an array
return {
newDocument: document,
index: i
};
},
remove: function (arr, i, document) {
var removedList = arr.splice(i, 1);
return {
newDocument: document,
removed: removedList[0]
};
},
replace: function (arr, i, document) {
var removed = arr[i];
arr[i] = this.value;
return {
newDocument: document,
removed: removed
};
},
move: objOps.move,
copy: objOps.copy,
test: objOps.test,
_get: objOps._get
};
/**
* Retrieves a value from a JSON document by a JSON pointer.
* Returns the value.
*
* @param document The document to get the value from
* @param pointer an escaped JSON pointer
* @return The retrieved value
*/
function getValueByPointer(document, pointer) {
if (pointer == '') {
return document;
}
var getOriginalDestination = {
op: "_get",
path: pointer
};
applyOperation(document, getOriginalDestination);
return getOriginalDestination.value;
}
/**
* Apply a single JSON Patch Operation on a JSON document.
* Returns the {newDocument, result} of the operation.
* It modifies the `document` and `operation` objects - it gets the values by reference.
* If you would like to avoid touching your values, clone them:
* `jsonpatch.applyOperation(document, jsonpatch._deepClone(operation))`.
*
* @param document The document to patch
* @param operation The operation to apply
* @param validateOperation `false` is without validation, `true` to use default jsonpatch's validation, or you can pass a `validateOperation` callback to be used for validation.
* @param mutateDocument Whether to mutate the original document or clone it before applying
* @param banPrototypeModifications Whether to ban modifications to `__proto__`, defaults to `true`.
* @return `{newDocument, result}` after the operation
*/
function applyOperation(document, operation, validateOperation, mutateDocument, banPrototypeModifications, index) {
if (validateOperation === void 0) {
validateOperation = false;
}
if (mutateDocument === void 0) {
mutateDocument = true;
}
if (banPrototypeModifications === void 0) {
banPrototypeModifications = true;
}
if (index === void 0) {
index = 0;
}
if (validateOperation) {
if (typeof validateOperation == 'function') {
validateOperation(operation, 0, document, operation.path);
} else {
validator(operation, 0);
}
}
/* ROOT OPERATIONS */
if (operation.path === "") {
var returnValue = {
newDocument: document
};
if (operation.op === 'add') {
returnValue.newDocument = operation.value;
return returnValue;
} else if (operation.op === 'replace') {
returnValue.newDocument = operation.value;
returnValue.removed = document; //document we removed
return returnValue;
} else if (operation.op === 'move' || operation.op === 'copy') {
// it's a move or copy to root
returnValue.newDocument = getValueByPointer(document, operation.from); // get the value by json-pointer in `from` field
if (operation.op === 'move') {
// report removed item
returnValue.removed = document;
}
return returnValue;
} else if (operation.op === 'test') {
returnValue.test = _areEquals(document, operation.value);
if (returnValue.test === false) {
throw new JsonPatchError("Test operation failed", 'TEST_OPERATION_FAILED', index, operation, document);
}
returnValue.newDocument = document;
return returnValue;
} else if (operation.op === 'remove') {
// a remove on root
returnValue.removed = document;
returnValue.newDocument = null;
return returnValue;
} else if (operation.op === '_get') {
operation.value = document;
return returnValue;
} else {
/* bad operation */
if (validateOperation) {
throw new JsonPatchError('Operation `op` property is not one of operations defined in RFC-6902', 'OPERATION_OP_INVALID', index, operation, document);
} else {
return returnValue;
}
}
}
/* END ROOT OPERATIONS */
else {
if (!mutateDocument) {
document = _deepClone(document);
}
var path = operation.path || "";
var keys = path.split('/');
var obj = document;
var t = 1; //skip empty element - http://jsperf.com/to-shift-or-not-to-shift
var len = keys.length;
var existingPathFragment = undefined;
var key = void 0;
var validateFunction = void 0;
if (typeof validateOperation == 'function') {
validateFunction = validateOperation;
} else {
validateFunction = validator;
}
while (true) {
key = keys[t];
if (key && key.indexOf('~') != -1) {
key = unescapePathComponent(key);
}
if (banPrototypeModifications && key == '__proto__') {
throw new TypeError('JSON-Patch: modifying `__proto__` prop is banned for security reasons, if this was on purpose, please set `banPrototypeModifications` flag false and pass it to this function. More info in fast-json-patch README');
}
if (validateOperation) {
if (existingPathFragment === undefined) {
if (obj[key] === undefined) {
existingPathFragment = keys.slice(0, t).join('/');
} else if (t == len - 1) {
existingPathFragment = operation.path;
}
if (existingPathFragment !== undefined) {
validateFunction(operation, 0, document, existingPathFragment);
}
}
}
t++;
if (Array.isArray(obj)) {
if (key === '-') {
key = obj.length;
} else {
if (validateOperation && !isInteger(key)) {
throw new JsonPatchError("Expected an unsigned base-10 integer value, making the new referenced value the array element with the zero-based index", "OPERATION_PATH_ILLEGAL_ARRAY_INDEX", index, operation, document);
} // only parse key when it's an integer for `arr.prop` to work
else if (isInteger(key)) {
key = ~~key;
}
}
if (t >= len) {
if (validateOperation && operation.op === "add" && key > obj.length) {
throw new JsonPatchError("The specified index MUST NOT be greater than the number of elements in the array", "OPERATION_VALUE_OUT_OF_BOUNDS", index, operation, document);
}
var returnValue = arrOps[operation.op].call(operation, obj, key, document); // Apply patch
if (returnValue.test === false) {
throw new JsonPatchError("Test operation failed", 'TEST_OPERATION_FAILED', index, operation, document);
}
return returnValue;
}
} else {
if (t >= len) {
var returnValue = objOps[operation.op].call(operation, obj, key, document); // Apply patch
if (returnValue.test === false) {
throw new JsonPatchError("Test operation failed", 'TEST_OPERATION_FAILED', index, operation, document);
}
return returnValue;
}
}
obj = obj[key]; // If we have more keys in the path, but the next value isn't a non-null object,
// throw an OPERATION_PATH_UNRESOLVABLE error instead of iterating again.
if (validateOperation && t < len && (!obj || typeof obj !== "object")) {
throw new JsonPatchError('Cannot perform operation at the desired path', 'OPERATION_PATH_UNRESOLVABLE', index, operation, document);
}
}
}
}
/**
* Apply a full JSON Patch array on a JSON document.
* Returns the {newDocument, result} of the patch.
* It modifies the `document` object and `patch` - it gets the values by reference.
* If you would like to avoid touching your values, clone them:
* `jsonpatch.applyPatch(document, jsonpatch._deepClone(patch))`.
*
* @param document The document to patch
* @param patch The patch to apply
* @param validateOperation `false` is without validation, `true` to use default jsonpatch's validation, or you can pass a `validateOperation` callback to be used for validation.
* @param mutateDocument Whether to mutate the original document or clone it before applying
* @param banPrototypeModifications Whether to ban modifications to `__proto__`, defaults to `true`.
* @return An array of `{newDocument, result}` after the patch
*/
function applyPatch(document, patch, validateOperation, mutateDocument, banPrototypeModifications) {
if (mutateDocument === void 0) {
mutateDocument = true;
}
if (banPrototypeModifications === void 0) {
banPrototypeModifications = true;
}
if (validateOperation) {
if (!Array.isArray(patch)) {
throw new JsonPatchError('Patch sequence must be an array', 'SEQUENCE_NOT_AN_ARRAY');
}
}
if (!mutateDocument) {
document = _deepClone(document);
}
var results = new Array(patch.length);
for (var i = 0, length_1 = patch.length; i < length_1; i++) {
// we don't need to pass mutateDocument argument because if it was true, we already deep cloned the object, we'll just pass `true`
results[i] = applyOperation(document, patch[i], validateOperation, true, banPrototypeModifications, i);
document = results[i].newDocument; // in case root was replaced
}
results.newDocument = document;
return results;
}
/**
* Apply a single JSON Patch Operation on a JSON document.
* Returns the updated document.
* Suitable as a reducer.
*
* @param document The document to patch
* @param operation The operation to apply
* @return The updated document
*/
function applyReducer(document, operation, index) {
var operationResult = applyOperation(document, operation);
if (operationResult.test === false) {
// failed test
throw new JsonPatchError("Test operation failed", 'TEST_OPERATION_FAILED', index, operation, document);
}
return operationResult.newDocument;
}
/**
* Validates a single operation. Called from `jsonpatch.validate`. Throws `JsonPatchError` in case of an error.
* @param {object} operation - operation object (patch)
* @param {number} index - index of operation in the sequence
* @param {object} [document] - object where the operation is supposed to be applied
* @param {string} [existingPathFragment] - comes along with `document`
*/
function validator(operation, index, document, existingPathFragment) {
if (typeof operation !== 'object' || operation === null || Array.isArray(operation)) {
throw new JsonPatchError('Operation is not an object', 'OPERATION_NOT_AN_OBJECT', index, operation, document);
} else if (!objOps[operation.op]) {
throw new JsonPatchError('Operation `op` property is not one of operations defined in RFC-6902', 'OPERATION_OP_INVALID', index, operation, document);
} else if (typeof operation.path !== 'string') {
throw new JsonPatchError('Operation `path` property is not a string', 'OPERATION_PATH_INVALID', index, operation, document);
} else if (operation.path.indexOf('/') !== 0 && operation.path.length > 0) {
// paths that aren't empty string should start with "/"
throw new JsonPatchError('Operation `path` property must start with "/"', 'OPERATION_PATH_INVALID', index, operation, document);
} else if ((operation.op === 'move' || operation.op === 'copy') && typeof operation.from !== 'string') {
throw new JsonPatchError('Operation `from` property is not present (applicable in `move` and `copy` operations)', 'OPERATION_FROM_REQUIRED', index, operation, document);
} else if ((operation.op === 'add' || operation.op === 'replace' || operation.op === 'test') && operation.value === undefined) {
throw new JsonPatchError('Operation `value` property is not present (applicable in `add`, `replace` and `test` operations)', 'OPERATION_VALUE_REQUIRED', index, operation, document);
} else if ((operation.op === 'add' || operation.op === 'replace' || operation.op === 'test') && hasUndefined(operation.value)) {
throw new JsonPatchError('Operation `value` property is not present (applicable in `add`, `replace` and `test` operations)', 'OPERATION_VALUE_CANNOT_CONTAIN_UNDEFINED', index, operation, document);
} else if (document) {
if (operation.op == "add") {
var pathLen = operation.path.split("/").length;
var existingPathLen = existingPathFragment.split("/").length;
if (pathLen !== existingPathLen + 1 && pathLen !== existingPathLen) {
throw new JsonPatchError('Cannot perform an `add` operation at the desired path', 'OPERATION_PATH_CANNOT_ADD', index, operation, document);
}
} else if (operation.op === 'replace' || operation.op === 'remove' || operation.op === '_get') {
if (operation.path !== existingPathFragment) {
throw new JsonPatchError('Cannot perform the operation at a path that does not exist', 'OPERATION_PATH_UNRESOLVABLE', index, operation, document);
}
} else if (operation.op === 'move' || operation.op === 'copy') {
var existingValue = {
op: "_get",
path: operation.from,
value: undefined
};
var error = validate([existingValue], document);
if (error && error.name === 'OPERATION_PATH_UNRESOLVABLE') {
throw new JsonPatchError('Cannot perform the operation from a path that does not exist', 'OPERATION_FROM_UNRESOLVABLE', index, operation, document);
}
}
}
}
/**
* Validates a sequence of operations. If `document` parameter is provided, the sequence is additionally validated against the object document.
* If error is encountered, returns a JsonPatchError object
* @param sequence
* @param document
* @returns {JsonPatchError|undefined}
*/
function validate(sequence, document, externalValidator) {
try {
if (!Array.isArray(sequence)) {
throw new JsonPatchError('Patch sequence must be an array', 'SEQUENCE_NOT_AN_ARRAY');
}
if (document) {
//clone document and sequence so that we can safely try applying operations
applyPatch(_deepClone(document), _deepClone(sequence), externalValidator || true);
} else {
externalValidator = externalValidator || validator;
for (var i = 0; i < sequence.length; i++) {
externalValidator(sequence[i], i, document, undefined);
}
}
} catch (e) {
if (e instanceof JsonPatchError) {
return e;
} else {
throw e;
}
}
} // based on https://github.com/epoberezkin/fast-deep-equal
// MIT License
// Copyright (c) 2017 Evgeny Poberezkin
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
function _areEquals(a, b) {
if (a === b) return true;
if (a && b && typeof a == 'object' && typeof b == 'object') {
var arrA = Array.isArray(a),
arrB = Array.isArray(b),
i,
length,
key;
if (arrA && arrB) {
length = a.length;
if (length != b.length) return false;
for (i = length; i-- !== 0;) if (!_areEquals(a[i], b[i])) return false;
return true;
}
if (arrA != arrB) return false;
var keys = Object.keys(a);
length = keys.length;
if (length !== Object.keys(b).length) return false;
for (i = length; i-- !== 0;) if (!b.hasOwnProperty(keys[i])) return false;
for (i = length; i-- !== 0;) {
key = keys[i];
if (!_areEquals(a[key], b[key])) return false;
}
return true;
}
return a !== a && b !== b;
}
var core = /*#__PURE__*/Object.freeze({
__proto__: null,
JsonPatchError: JsonPatchError,
deepClone: deepClone,
getValueByPointer: getValueByPointer,
applyOperation: applyOperation,
applyPatch: applyPatch,
applyReducer: applyReducer,
validator: validator,
validate: validate,
_areEquals: _areEquals
});
/*!
* https://github.com/Starcounter-Jack/JSON-Patch
* (c) 2017 Joachim Wester
* MIT license
*/
var beforeDict = new WeakMap();
var Mirror = function () {
function Mirror(obj) {
this.observers = new Map();
this.obj = obj;
}
return Mirror;
}();
var ObserverInfo = function () {
function ObserverInfo(callback, observer) {
this.callback = callback;
this.observer = observer;
}
return ObserverInfo;
}();
function getMirror(obj) {
return beforeDict.get(obj);
}
function getObserverFromMirror(mirror, callback) {
return mirror.observers.get(callback);
}
function removeObserverFromMirror(mirror, observer) {
mirror.observers.delete(observer.callback);
}
/**
* Detach an observer from an object
*/
function unobserve(root, observer) {
observer.unobserve();
}
/**
* Observes changes made to an object, which can then be retrieved using generate
*/
function observe(obj, callback) {
var patches = [];
var observer;
var mirror = getMirror(obj);
if (!mirror) {
mirror = new Mirror(obj);
beforeDict.set(obj, mirror);
} else {
var observerInfo = getObserverFromMirror(mirror, callback);
observer = observerInfo && observerInfo.observer;
}
if (observer) {
return observer;
}
observer = {};
mirror.value = _deepClone(obj);
if (callback) {
observer.callback = callback;
observer.next = null;
var dirtyCheck = function () {
generate(observer);
};
var fastCheck = function () {
clearTimeout(observer.next);
observer.next = setTimeout(dirtyCheck);
};
if (typeof window !== 'undefined') {
//not Node
window.addEventListener('mouseup', fastCheck);
window.addEventListener('keyup', fastCheck);
window.addEventListener('mousedown', fastCheck);
window.addEventListener('keydown', fastCheck);
window.addEventListener('change', fastCheck);
}
}
observer.patches = patches;
observer.object = obj;
observer.unobserve = function () {
generate(observer);
clearTimeout(observer.next);
removeObserverFromMirror(mirror, observer);
if (typeof window !== 'undefined') {
window.removeEventListener('mouseup', fastCheck);
window.removeEventListener('keyup', fastCheck);
window.removeEventListener('mousedown', fastCheck);
window.removeEventListener('keydown', fastCheck);
window.removeEventListener('change', fastCheck);
}
};
mirror.observers.set(callback, new ObserverInfo(callback, observer));
return observer;
}
/**
* Generate an array of patches from an observer
*/
function generate(observer, invertible) {
if (invertible === void 0) {
invertible = false;
}
var mirror = beforeDict.get(observer.object);
_generate(mirror.value, observer.object, observer.patches, "", invertible);
if (observer.patches.length) {
applyPatch(mirror.value, observer.patches);
}
var temp = observer.patches;
if (temp.length > 0) {
observer.patches = [];
if (observer.callback) {
observer.callback(temp);
}
}
return temp;
} // Dirty check if obj is different from mirror, generate patches and update mirror
function _generate(mirror, obj, patches, path, invertible) {
if (obj === mirror) {
return;
}
if (typeof obj.toJSON === "function") {
obj = obj.toJSON();
}
var newKeys = _objectKeys(obj);
var oldKeys = _objectKeys(mirror);
var deleted = false; //if ever "move" operation is implemented here, make sure this test runs OK: "should not generate the same patch twice (move)"
for (var t = oldKeys.length - 1; t >= 0; t--) {
var key = oldKeys[t];
var oldVal = mirror[key];
if (hasOwnProperty(obj, key) && !(obj[key] === undefined && oldVal !== undefined && Array.isArray(obj) === false)) {
var newVal = obj[key];
if (typeof oldVal == "object" && oldVal != null && typeof newVal == "object" && newVal != null && Array.isArray(oldVal) === Array.isArray(newVal)) {
_generate(oldVal, newVal, patches, path + "/" + escapePathComponent(key), invertible);
} else {
if (oldVal !== newVal) {
if (invertible) {
patches.push({
op: "test",
path: path + "/" + escapePathComponent(key),
value: _deepClone(oldVal)
});
}
patches.push({
op: "replace",
path: path + "/" + escapePathComponent(key),
value: _deepClone(newVal)
});
}
}
} else if (Array.isArray(mirror) === Array.isArray(obj)) {
if (invertible) {
patches.push({
op: "test",
path: path + "/" + escapePathComponent(key),
value: _deepClone(oldVal)
});
}
patches.push({
op: "remove",
path: path + "/" + escapePathComponent(key)
});
deleted = true; // property has been deleted
} else {
if (invertible) {
patches.push({
op: "test",
path: path,
value: mirror
});
}
patches.push({
op: "replace",
path: path,
value: obj
});
}
}
if (!deleted && newKeys.length == oldKeys.length) {
return;
}
for (var t = 0; t < newKeys.length; t++) {
var key = newKeys[t];
if (!hasOwnProperty(mirror, key) && obj[key] !== undefined) {
patches.push({
op: "add",
path: path + "/" + escapePathComponent(key),
value: _deepClone(obj[key])
});
}
}
}
/**
* Create an array of patches from the differences in two objects
*/
function compare$b(tree1, tree2, invertible) {
if (invertible === void 0) {
invertible = false;
}
var patches = [];
_generate(tree1, tree2, patches, '', invertible);
return patches;
}
var duplex = /*#__PURE__*/Object.freeze({
__proto__: null,
unobserve: unobserve,
observe: observe,
generate: generate,
compare: compare$b
});
Object.assign({}, core, duplex, {
JsonPatchError: PatchError,
deepClone: _deepClone,
escapePathComponent,
unescapePathComponent
});
// working on the output of `JSON.stringify` we know that only valid strings
// are present (unless the user supplied a weird `options.indent` but in
// that case we don’t care since the output would be invalid anyway).
var stringOrChar = /("(?:[^\\"]|\\.)*")|[:,]/g;
var jsonStringifyPrettyCompact = function stringify(passedObj, options) {
var indent, maxLength, replacer;
options = options || {};
indent = JSON.stringify([1], undefined, options.indent === undefined ? 2 : options.indent).slice(2, -3);
maxLength = indent === "" ? Infinity : options.maxLength === undefined ? 80 : options.maxLength;
replacer = options.replacer;
return function _stringify(obj, currentIndent, reserved) {
// prettier-ignore
var end, index, items, key, keyPart, keys, length, nextIndent, prettified, start, string, value;
if (obj && typeof obj.toJSON === "function") {
obj = obj.toJSON();
}
string = JSON.stringify(obj, replacer);
if (string === undefined) {
return string;
}
length = maxLength - currentIndent.length - reserved;
if (string.length <= length) {
prettified = string.replace(stringOrChar, function (match, stringLiteral) {
return stringLiteral || match + " ";
});
if (prettified.length <= length) {
return prettified;
}
}
if (replacer != null) {
obj = JSON.parse(string);
replacer = undefined;
}
if (typeof obj === "object" && obj !== null) {
nextIndent = currentIndent + indent;
items = [];
index = 0;
if (Array.isArray(obj)) {
start = "[";
end = "]";
length = obj.length;
for (; index < length; index++) {
items.push(_stringify(obj[index], nextIndent, index === length - 1 ? 0 : 1) || "null");
}
} else {
start = "{";
end = "}";
keys = Object.keys(obj);
length = keys.length;
for (; index < length; index++) {
key = keys[index];
keyPart = JSON.stringify(key) + ": ";
value = _stringify(obj[key], nextIndent, keyPart.length + (index === length - 1 ? 0 : 1));
if (value !== undefined) {
items.push(keyPart + value);
}
}
}
if (items.length > 0) {
return [start, indent + items.join(",\n" + nextIndent), end].join("\n" + currentIndent);
}
}
return string;
}(passedObj, "", 0);
};
var re$5 = {exports: {}};
// Not necessarily the package version of this code.
const SEMVER_SPEC_VERSION = '2.0.0';
const MAX_LENGTH$2 = 256;
const MAX_SAFE_INTEGER$1 = Number.MAX_SAFE_INTEGER ||
/* istanbul ignore next */
9007199254740991; // Max safe segment length for coercion.
const MAX_SAFE_COMPONENT_LENGTH = 16;
var constants = {
SEMVER_SPEC_VERSION,
MAX_LENGTH: MAX_LENGTH$2,
MAX_SAFE_INTEGER: MAX_SAFE_INTEGER$1,
MAX_SAFE_COMPONENT_LENGTH
};
const debug$3 = typeof process === 'object' && process.env && process.env.NODE_DEBUG && /\bsemver\b/i.test(process.env.NODE_DEBUG) ? (...args) => console.error('SEMVER', ...args) : () => {};
var debug_1 = debug$3;
(function (module, exports) {
const {
MAX_SAFE_COMPONENT_LENGTH
} = constants;
const debug = debug_1;
exports = module.exports = {}; // The actual regexps go on exports.re
const re = exports.re = [];
const src = exports.src = [];
const t = exports.t = {};
let R = 0;
const createToken = (name, value, isGlobal) => {
const index = R++;
debug(index, value);
t[name] = index;
src[index] = value;
re[index] = new RegExp(value, isGlobal ? 'g' : undefined);
}; // The following Regular Expressions can be used for tokenizing,
// validating, and parsing SemVer version strings.
// ## Numeric Identifier
// A single `0`, or a non-zero digit followed by zero or more digits.
createToken('NUMERICIDENTIFIER', '0|[1-9]\\d*');
createToken('NUMERICIDENTIFIERLOOSE', '[0-9]+'); // ## Non-numeric Identifier
// Zero or more digits, followed by a letter or hyphen, and then zero or
// more letters, digits, or hyphens.
createToken('NONNUMERICIDENTIFIER', '\\d*[a-zA-Z-][a-zA-Z0-9-]*'); // ## Main Version
// Three dot-separated numeric identifiers.
createToken('MAINVERSION', `(${src[t.NUMERICIDENTIFIER]})\\.` + `(${src[t.NUMERICIDENTIFIER]})\\.` + `(${src[t.NUMERICIDENTIFIER]})`);
createToken('MAINVERSIONLOOSE', `(${src[t.NUMERICIDENTIFIERLOOSE]})\\.` + `(${src[t.NUMERICIDENTIFIERLOOSE]})\\.` + `(${src[t.NUMERICIDENTIFIERLOOSE]})`); // ## Pre-release Version Identifier
// A numeric identifier, or a non-numeric identifier.
createToken('PRERELEASEIDENTIFIER', `(?:${src[t.NUMERICIDENTIFIER]}|${src[t.NONNUMERICIDENTIFIER]})`);
createToken('PRERELEASEIDENTIFIERLOOSE', `(?:${src[t.NUMERICIDENTIFIERLOOSE]}|${src[t.NONNUMERICIDENTIFIER]})`); // ## Pre-release Version
// Hyphen, followed by one or more dot-separated pre-release version
// identifiers.
createToken('PRERELEASE', `(?:-(${src[t.PRERELEASEIDENTIFIER]}(?:\\.${src[t.PRERELEASEIDENTIFIER]})*))`);
createToken('PRERELEASELOOSE', `(?:-?(${src[t.PRERELEASEIDENTIFIERLOOSE]}(?:\\.${src[t.PRERELEASEIDENTIFIERLOOSE]})*))`); // ## Build Metadata Identifier
// Any combination of digits, letters, or hyphens.
createToken('BUILDIDENTIFIER', '[0-9A-Za-z-]+'); // ## Build Metadata
// Plus sign, followed by one or more period-separated build metadata
// identifiers.
createToken('BUILD', `(?:\\+(${src[t.BUILDIDENTIFIER]}(?:\\.${src[t.BUILDIDENTIFIER]})*))`); // ## Full Version String
// A main version, followed optionally by a pre-release version and
// build metadata.
// Note that the only major, minor, patch, and pre-release sections of
// the version string are capturing groups. The build metadata is not a
// capturing group, because it should not ever be used in version
// comparison.
createToken('FULLPLAIN', `v?${src[t.MAINVERSION]}${src[t.PRERELEASE]}?${src[t.BUILD]}?`);
createToken('FULL', `^${src[t.FULLPLAIN]}$`); // like full, but allows v1.2.3 and =1.2.3, which people do sometimes.
// also, 1.0.0alpha1 (prerelease without the hyphen) which is pretty
// common in the npm registry.
createToken('LOOSEPLAIN', `[v=\\s]*${src[t.MAINVERSIONLOOSE]}${src[t.PRERELEASELOOSE]}?${src[t.BUILD]}?`);
createToken('LOOSE', `^${src[t.LOOSEPLAIN]}$`);
createToken('GTLT', '((?:<|>)?=?)'); // Something like "2.*" or "1.2.x".
// Note that "x.x" is a valid xRange identifer, meaning "any version"
// Only the first item is strictly required.
createToken('XRANGEIDENTIFIERLOOSE', `${src[t.NUMERICIDENTIFIERLOOSE]}|x|X|\\*`);
createToken('XRANGEIDENTIFIER', `${src[t.NUMERICIDENTIFIER]}|x|X|\\*`);
createToken('XRANGEPLAIN', `[v=\\s]*(${src[t.XRANGEIDENTIFIER]})` + `(?:\\.(${src[t.XRANGEIDENTIFIER]})` + `(?:\\.(${src[t.XRANGEIDENTIFIER]})` + `(?:${src[t.PRERELEASE]})?${src[t.BUILD]}?` + `)?)?`);
createToken('XRANGEPLAINLOOSE', `[v=\\s]*(${src[t.XRANGEIDENTIFIERLOOSE]})` + `(?:\\.(${src[t.XRANGEIDENTIFIERLOOSE]})` + `(?:\\.(${src[t.XRANGEIDENTIFIERLOOSE]})` + `(?:${src[t.PRERELEASELOOSE]})?${src[t.BUILD]}?` + `)?)?`);
createToken('XRANGE', `^${src[t.GTLT]}\\s*${src[t.XRANGEPLAIN]}$`);
createToken('XRANGELOOSE', `^${src[t.GTLT]}\\s*${src[t.XRANGEPLAINLOOSE]}$`); // Coercion.
// Extract anything that could conceivably be a part of a valid semver
createToken('COERCE', `${'(^|[^\\d])' + '(\\d{1,'}${MAX_SAFE_COMPONENT_LENGTH}})` + `(?:\\.(\\d{1,${MAX_SAFE_COMPONENT_LENGTH}}))?` + `(?:\\.(\\d{1,${MAX_SAFE_COMPONENT_LENGTH}}))?` + `(?:$|[^\\d])`);
createToken('COERCERTL', src[t.COERCE], true); // Tilde ranges.
// Meaning is "reasonably at or greater than"
createToken('LONETILDE', '(?:~>?)');
createToken('TILDETRIM', `(\\s*)${src[t.LONETILDE]}\\s+`, true);
exports.tildeTrimReplace = '$1~';
createToken('TILDE', `^${src[t.LONETILDE]}${src[t.XRANGEPLAIN]}$`);
createToken('TILDELOOSE', `^${src[t.LONETILDE]}${src[t.XRANGEPLAINLOOSE]}$`); // Caret ranges.
// Meaning is "at least and backwards compatible with"
createToken('LONECARET', '(?:\\^)');
createToken('CARETTRIM', `(\\s*)${src[t.LONECARET]}\\s+`, true);
exports.caretTrimReplace = '$1^';
createToken('CARET', `^${src[t.LONECARET]}${src[t.XRANGEPLAIN]}$`);
createToken('CARETLOOSE', `^${src[t.LONECARET]}${src[t.XRANGEPLAINLOOSE]}$`); // A simple gt/lt/eq thing, or just "" to indicate "any version"
createToken('COMPARATORLOOSE', `^${src[t.GTLT]}\\s*(${src[t.LOOSEPLAIN]})$|^$`);
createToken('COMPARATOR', `^${src[t.GTLT]}\\s*(${src[t.FULLPLAIN]})$|^$`); // An expression to strip any whitespace between the gtlt and the thing
// it modifies, so that `> 1.2.3` ==> `>1.2.3`
createToken('COMPARATORTRIM', `(\\s*)${src[t.GTLT]}\\s*(${src[t.LOOSEPLAIN]}|${src[t.XRANGEPLAIN]})`, true);
exports.comparatorTrimReplace = '$1$2$3'; // Something like `1.2.3 - 1.2.4`
// Note that these all use the loose form, because they'll be
// checked against either the strict or loose comparator form
// later.
createToken('HYPHENRANGE', `^\\s*(${src[t.XRANGEPLAIN]})` + `\\s+-\\s+` + `(${src[t.XRANGEPLAIN]})` + `\\s*$`);
createToken('HYPHENRANGELOOSE', `^\\s*(${src[t.XRANGEPLAINLOOSE]})` + `\\s+-\\s+` + `(${src[t.XRANGEPLAINLOOSE]})` + `\\s*$`); // Star ranges basically just allow anything at all.
createToken('STAR', '(<|>)?=?\\s*\\*'); // >=0.0.0 is like a star
createToken('GTE0', '^\\s*>=\\s*0\.0\.0\\s*$');
createToken('GTE0PRE', '^\\s*>=\\s*0\.0\.0-0\\s*$');
})(re$5, re$5.exports);
// obj with keys in a consistent order.
const opts = ['includePrerelease', 'loose', 'rtl'];
const parseOptions$4 = options => !options ? {} : typeof options !== 'object' ? {
loose: true
} : opts.filter(k => options[k]).reduce((options, k) => {
options[k] = true;
return options;
}, {});
var parseOptions_1 = parseOptions$4;
const numeric = /^[0-9]+$/;
const compareIdentifiers$1 = (a, b) => {
const anum = numeric.test(a);
const bnum = numeric.test(b);
if (anum && bnum) {
a = +a;
b = +b;
}
return a === b ? 0 : anum && !bnum ? -1 : bnum && !anum ? 1 : a < b ? -1 : 1;
};
const rcompareIdentifiers = (a, b) => compareIdentifiers$1(b, a);
var identifiers = {
compareIdentifiers: compareIdentifiers$1,
rcompareIdentifiers
};
const debug$2 = debug_1;
const {
MAX_LENGTH: MAX_LENGTH$1,
MAX_SAFE_INTEGER
} = constants;
const {
re: re$4,
t: t$4
} = re$5.exports;
const parseOptions$3 = parseOptions_1;
const {
compareIdentifiers
} = identifiers;
class SemVer$e {
constructor(version, options) {
options = parseOptions$3(options);
if (version instanceof SemVer$e) {
if (version.loose === !!options.loose && version.includePrerelease === !!options.includePrerelease) {
return version;
} else {
version = version.version;
}
} else if (typeof version !== 'string') {
throw new TypeError(`Invalid Version: ${version}`);
}
if (version.length > MAX_LENGTH$1) {
throw new TypeError(`version is longer than ${MAX_LENGTH$1} characters`);
}
debug$2('SemVer', version, options);
this.options = options;
this.loose = !!options.loose; // this isn't actually relevant for versions, but keep it so that we
// don't run into trouble passing this.options around.
this.includePrerelease = !!options.includePrerelease;
const m = version.trim().match(options.loose ? re$4[t$4.LOOSE] : re$4[t$4.FULL]);
if (!m) {
throw new TypeError(`Invalid Version: ${version}`);
}
this.raw = version; // these are actually numbers
this.major = +m[1];
this.minor = +m[2];
this.patch = +m[3];
if (this.major > MAX_SAFE_INTEGER || this.major < 0) {
throw new TypeError('Invalid major version');
}
if (this.minor > MAX_SAFE_INTEGER || this.minor < 0) {
throw new TypeError('Invalid minor version');
}
if (this.patch > MAX_SAFE_INTEGER || this.patch < 0) {
throw new TypeError('Invalid patch version');
} // numberify any prerelease numeric ids
if (!m[4]) {
this.prerelease = [];
} else {
this.prerelease = m[4].split('.').map(id => {
if (/^[0-9]+$/.test(id)) {
const num = +id;
if (num >= 0 && num < MAX_SAFE_INTEGER) {
return num;
}
}
return id;
});
}
this.build = m[5] ? m[5].split('.') : [];
this.format();
}
format() {
this.version = `${this.major}.${this.minor}.${this.patch}`;
if (this.prerelease.length) {
this.version += `-${this.prerelease.join('.')}`;
}
return this.version;
}
toString() {
return this.version;
}
compare(other) {
debug$2('SemVer.compare', this.version, this.options, other);
if (!(other instanceof SemVer$e)) {
if (typeof other === 'string' && other === this.version) {
return 0;
}
other = new SemVer$e(other, this.options);
}
if (other.version === this.version) {
return 0;
}
return this.compareMain(other) || this.comparePre(other);
}
compareMain(other) {
if (!(other instanceof SemVer$e)) {
other = new SemVer$e(other, this.options);
}
return compareIdentifiers(this.major, other.major) || compareIdentifiers(this.minor, other.minor) || compareIdentifiers(this.patch, other.patch);
}
comparePre(other) {
if (!(other instanceof SemVer$e)) {
other = new SemVer$e(other, this.options);
} // NOT having a prerelease is > having one
if (this.prerelease.length && !other.prerelease.length) {
return -1;
} else if (!this.prerelease.length && other.prerelease.length) {
return 1;
} else if (!this.prerelease.length && !other.prerelease.length) {
return 0;
}
let i = 0;
do {
const a = this.prerelease[i];
const b = other.prerelease[i];
debug$2('prerelease compare', i, a, b);
if (a === undefined && b === undefined) {
return 0;
} else if (b === undefined) {
return 1;
} else if (a === undefined) {
return -1;
} else if (a === b) {
continue;
} else {
return compareIdentifiers(a, b);
}
} while (++i);
}
compareBuild(other) {
if (!(other instanceof SemVer$e)) {
other = new SemVer$e(other, this.options);
}
let i = 0;
do {
const a = this.build[i];
const b = other.build[i];
debug$2('prerelease compare', i, a, b);
if (a === undefined && b === undefined) {
return 0;
} else if (b === undefined) {
return 1;
} else if (a === undefined) {
return -1;
} else if (a === b) {
continue;
} else {
return compareIdentifiers(a, b);
}
} while (++i);
} // preminor will bump the version up to the next minor release, and immediately
// down to pre-release. premajor and prepatch work the same way.
inc(release, identifier) {
switch (release) {
case 'premajor':
this.prerelease.length = 0;
this.patch = 0;
this.minor = 0;
this.major++;
this.inc('pre', identifier);
break;
case 'preminor':
this.prerelease.length = 0;
this.patch = 0;
this.minor++;
this.inc('pre', identifier);
break;
case 'prepatch':
// If this is already a prerelease, it will bump to the next version
// drop any prereleases that might already exist, since they are not
// relevant at this point.
this.prerelease.length = 0;
this.inc('patch', identifier);
this.inc('pre', identifier);
break;
// If the input is a non-prerelease version, this acts the same as
// prepatch.
case 'prerelease':
if (this.prerelease.length === 0) {
this.inc('patch', identifier);
}
this.inc('pre', identifier);
break;
case 'major':
// If this is a pre-major version, bump up to the same major version.
// Otherwise increment major.
// 1.0.0-5 bumps to 1.0.0
// 1.1.0 bumps to 2.0.0
if (this.minor !== 0 || this.patch !== 0 || this.prerelease.length === 0) {
this.major++;
}
this.minor = 0;
this.patch = 0;
this.prerelease = [];
break;
case 'minor':
// If this is a pre-minor version, bump up to the same minor version.
// Otherwise increment minor.
// 1.2.0-5 bumps to 1.2.0
// 1.2.1 bumps to 1.3.0
if (this.patch !== 0 || this.prerelease.length === 0) {
this.minor++;
}
this.patch = 0;
this.prerelease = [];
break;
case 'patch':
// If this is not a pre-release version, it will increment the patch.
// If it is a pre-release it will bump up to the same patch version.
// 1.2.0-5 patches to 1.2.0
// 1.2.0 patches to 1.2.1
if (this.prerelease.length === 0) {
this.patch++;
}
this.prerelease = [];
break;
// This probably shouldn't be used publicly.
// 1.0.0 'pre' would become 1.0.0-0 which is the wrong direction.
case 'pre':
if (this.prerelease.length === 0) {
this.prerelease = [0];
} else {
let i = this.prerelease.length;
while (--i >= 0) {
if (typeof this.prerelease[i] === 'number') {
this.prerelease[i]++;
i = -2;
}
}
if (i === -1) {
// didn't increment anything
this.prerelease.push(0);
}
}
if (identifier) {
// 1.2.0-beta.1 bumps to 1.2.0-beta.2,
// 1.2.0-beta.fooblz or 1.2.0-beta bumps to 1.2.0-beta.0
if (this.prerelease[0] === identifier) {
if (isNaN(this.prerelease[1])) {
this.prerelease = [identifier, 0];
}
} else {
this.prerelease = [identifier, 0];
}
}
break;
default:
throw new Error(`invalid increment argument: ${release}`);
}
this.format();
this.raw = this.version;
return this;
}
}
var semver$1 = SemVer$e;
const {
MAX_LENGTH
} = constants;
const {
re: re$3,
t: t$3
} = re$5.exports;
const SemVer$d = semver$1;
const parseOptions$2 = parseOptions_1;
const parse$5 = (version, options) => {
options = parseOptions$2(options);
if (version instanceof SemVer$d) {
return version;
}
if (typeof version !== 'string') {
return null;
}
if (version.length > MAX_LENGTH) {
return null;
}
const r = options.loose ? re$3[t$3.LOOSE] : re$3[t$3.FULL];
if (!r.test(version)) {
return null;
}
try {
return new SemVer$d(version, options);
} catch (er) {
return null;
}
};
var parse_1 = parse$5;
const parse$4 = parse_1;
const valid$1 = (version, options) => {
const v = parse$4(version, options);
return v ? v.version : null;
};
var valid_1 = valid$1;
const parse$3 = parse_1;
const clean = (version, options) => {
const s = parse$3(version.trim().replace(/^[=v]+/, ''), options);
return s ? s.version : null;
};
var clean_1 = clean;
const SemVer$c = semver$1;
const inc = (version, release, options, identifier) => {
if (typeof options === 'string') {
identifier = options;
options = undefined;
}
try {
return new SemVer$c(version, options).inc(release, identifier).version;
} catch (er) {
return null;
}
};
var inc_1 = inc;
const SemVer$b = semver$1;
const compare$a = (a, b, loose) => new SemVer$b(a, loose).compare(new SemVer$b(b, loose));
var compare_1 = compare$a;
const compare$9 = compare_1;
const eq$2 = (a, b, loose) => compare$9(a, b, loose) === 0;
var eq_1 = eq$2;
const parse$2 = parse_1;
const eq$1 = eq_1;
const diff = (version1, version2) => {
if (eq$1(version1, version2)) {
return null;
} else {
const v1 = parse$2(version1);
const v2 = parse$2(version2);
const hasPre = v1.prerelease.length || v2.prerelease.length;
const prefix = hasPre ? 'pre' : '';
const defaultResult = hasPre ? 'prerelease' : '';
for (const key in v1) {
if (key === 'major' || key === 'minor' || key === 'patch') {
if (v1[key] !== v2[key]) {
return prefix + key;
}
}
}
return defaultResult; // may be undefined
}
};
var diff_1 = diff;
const SemVer$a = semver$1;
const major = (a, loose) => new SemVer$a(a, loose).major;
var major_1 = major;
const SemVer$9 = semver$1;
const minor = (a, loose) => new SemVer$9(a, loose).minor;
var minor_1 = minor;
const SemVer$8 = semver$1;
const patch = (a, loose) => new SemVer$8(a, loose).patch;
var patch_1 = patch;
const parse$1 = parse_1;
const prerelease = (version, options) => {
const parsed = parse$1(version, options);
return parsed && parsed.prerelease.length ? parsed.prerelease : null;
};
var prerelease_1 = prerelease;
const compare$8 = compare_1;
const rcompare = (a, b, loose) => compare$8(b, a, loose);
var rcompare_1 = rcompare;
const compare$7 = compare_1;
const compareLoose = (a, b) => compare$7(a, b, true);
var compareLoose_1 = compareLoose;
const SemVer$7 = semver$1;
const compareBuild$2 = (a, b, loose) => {
const versionA = new SemVer$7(a, loose);
const versionB = new SemVer$7(b, loose);
return versionA.compare(versionB) || versionA.compareBuild(versionB);
};
var compareBuild_1 = compareBuild$2;
const compareBuild$1 = compareBuild_1;
const sort = (list, loose) => list.sort((a, b) => compareBuild$1(a, b, loose));
var sort_1 = sort;
const compareBuild = compareBuild_1;
const rsort = (list, loose) => list.sort((a, b) => compareBuild(b, a, loose));
var rsort_1 = rsort;
const compare$6 = compare_1;
const gt$3 = (a, b, loose) => compare$6(a, b, loose) > 0;
var gt_1 = gt$3;
const compare$5 = compare_1;
const lt$2 = (a, b, loose) => compare$5(a, b, loose) < 0;
var lt_1 = lt$2;
const compare$4 = compare_1;
const neq$1 = (a, b, loose) => compare$4(a, b, loose) !== 0;
var neq_1 = neq$1;
const compare$3 = compare_1;
const gte$2 = (a, b, loose) => compare$3(a, b, loose) >= 0;
var gte_1 = gte$2;
const compare$2 = compare_1;
const lte$2 = (a, b, loose) => compare$2(a, b, loose) <= 0;
var lte_1 = lte$2;
const eq = eq_1;
const neq = neq_1;
const gt$2 = gt_1;
const gte$1 = gte_1;
const lt$1 = lt_1;
const lte$1 = lte_1;
const cmp$1 = (a, op, b, loose) => {
switch (op) {
case '===':
if (typeof a === 'object') a = a.version;
if (typeof b === 'object') b = b.version;
return a === b;
case '!==':
if (typeof a === 'object') a = a.version;
if (typeof b === 'object') b = b.version;
return a !== b;
case '':
case '=':
case '==':
return eq(a, b, loose);
case '!=':
return neq(a, b, loose);
case '>':
return gt$2(a, b, loose);
case '>=':
return gte$1(a, b, loose);
case '<':
return lt$1(a, b, loose);
case '<=':
return lte$1(a, b, loose);
default:
throw new TypeError(`Invalid operator: ${op}`);
}
};
var cmp_1 = cmp$1;
const SemVer$6 = semver$1;
const parse = parse_1;
const {
re: re$2,
t: t$2
} = re$5.exports;
const coerce = (version, options) => {
if (version instanceof SemVer$6) {
return version;
}
if (typeof version === 'number') {
version = String(version);
}
if (typeof version !== 'string') {
return null;
}
options = options || {};
let match = null;
if (!options.rtl) {
match = version.match(re$2[t$2.COERCE]);
} else {
// Find the right-most coercible string that does not share
// a terminus with a more left-ward coercible string.
// Eg, '1.2.3.4' wants to coerce '2.3.4', not '3.4' or '4'
//
// Walk through the string checking with a /g regexp
// Manually set the index so as to pick up overlapping matches.
// Stop when we get a match that ends at the string end, since no
// coercible string can be more right-ward without the same terminus.
let next;
while ((next = re$2[t$2.COERCERTL].exec(version)) && (!match || match.index + match[0].length !== version.length)) {
if (!match || next.index + next[0].length !== match.index + match[0].length) {
match = next;
}
re$2[t$2.COERCERTL].lastIndex = next.index + next[1].length + next[2].length;
} // leave it in a clean state
re$2[t$2.COERCERTL].lastIndex = -1;
}
if (match === null) return null;
return parse(`${match[2]}.${match[3] || '0'}.${match[4] || '0'}`, options);
};
var coerce_1 = coerce;
var yallist = Yallist$1;
Yallist$1.Node = Node;
Yallist$1.create = Yallist$1;
function Yallist$1(list) {
var self = this;
if (!(self instanceof Yallist$1)) {
self = new Yallist$1();
}
self.tail = null;
self.head = null;
self.length = 0;
if (list && typeof list.forEach === 'function') {
list.forEach(function (item) {
self.push(item);
});
} else if (arguments.length > 0) {
for (var i = 0, l = arguments.length; i < l; i++) {
self.push(arguments[i]);
}
}
return self;
}
Yallist$1.prototype.removeNode = function (node) {
if (node.list !== this) {
throw new Error('removing node which does not belong to this list');
}
var next = node.next;
var prev = node.prev;
if (next) {
next.prev = prev;
}
if (prev) {
prev.next = next;
}
if (node === this.head) {
this.head = next;
}
if (node === this.tail) {
this.tail = prev;
}
node.list.length--;
node.next = null;
node.prev = null;
node.list = null;
return next;
};
Yallist$1.prototype.unshiftNode = function (node) {
if (node === this.head) {
return;
}
if (node.list) {
node.list.removeNode(node);
}
var head = this.head;
node.list = this;
node.next = head;
if (head) {
head.prev = node;
}
this.head = node;
if (!this.tail) {
this.tail = node;
}
this.length++;
};
Yallist$1.prototype.pushNode = function (node) {
if (node === this.tail) {
return;
}
if (node.list) {
node.list.removeNode(node);
}
var tail = this.tail;
node.list = this;
node.prev = tail;
if (tail) {
tail.next = node;
}
this.tail = node;
if (!this.head) {
this.head = node;
}
this.length++;
};
Yallist$1.prototype.push = function () {
for (var i = 0, l = arguments.length; i < l; i++) {
push(this, arguments[i]);
}
return this.length;
};
Yallist$1.prototype.unshift = function () {
for (var i = 0, l = arguments.length; i < l; i++) {
unshift(this, arguments[i]);
}
return this.length;
};
Yallist$1.prototype.pop = function () {
if (!this.tail) {
return undefined;
}
var res = this.tail.value;
this.tail = this.tail.prev;
if (this.tail) {
this.tail.next = null;
} else {
this.head = null;
}
this.length--;
return res;
};
Yallist$1.prototype.shift = function () {
if (!this.head) {
return undefined;
}
var res = this.head.value;
this.head = this.head.next;
if (this.head) {
this.head.prev = null;
} else {
this.tail = null;
}
this.length--;
return res;
};
Yallist$1.prototype.forEach = function (fn, thisp) {
thisp = thisp || this;
for (var walker = this.head, i = 0; walker !== null; i++) {
fn.call(thisp, walker.value, i, this);
walker = walker.next;
}
};
Yallist$1.prototype.forEachReverse = function (fn, thisp) {
thisp = thisp || this;
for (var walker = this.tail, i = this.length - 1; walker !== null; i--) {
fn.call(thisp, walker.value, i, this);
walker = walker.prev;
}
};
Yallist$1.prototype.get = function (n) {
for (var i = 0, walker = this.head; walker !== null && i < n; i++) {
// abort out of the list early if we hit a cycle
walker = walker.next;
}
if (i === n && walker !== null) {
return walker.value;
}
};
Yallist$1.prototype.getReverse = function (n) {
for (var i = 0, walker = this.tail; walker !== null && i < n; i++) {
// abort out of the list early if we hit a cycle
walker = walker.prev;
}
if (i === n && walker !== null) {
return walker.value;
}
};
Yallist$1.prototype.map = function (fn, thisp) {
thisp = thisp || this;
var res = new Yallist$1();
for (var walker = this.head; walker !== null;) {
res.push(fn.call(thisp, walker.value, this));
walker = walker.next;
}
return res;
};
Yallist$1.prototype.mapReverse = function (fn, thisp) {
thisp = thisp || this;
var res = new Yallist$1();
for (var walker = this.tail; walker !== null;) {
res.push(fn.call(thisp, walker.value, this));
walker = walker.prev;
}
return res;
};
Yallist$1.prototype.reduce = function (fn, initial) {
var acc;
var walker = this.head;
if (arguments.length > 1) {
acc = initial;
} else if (this.head) {
walker = this.head.next;
acc = this.head.value;
} else {
throw new TypeError('Reduce of empty list with no initial value');
}
for (var i = 0; walker !== null; i++) {
acc = fn(acc, walker.value, i);
walker = walker.next;
}
return acc;
};
Yallist$1.prototype.reduceReverse = function (fn, initial) {
var acc;
var walker = this.tail;
if (arguments.length > 1) {
acc = initial;
} else if (this.tail) {
walker = this.tail.prev;
acc = this.tail.value;
} else {
throw new TypeError('Reduce of empty list with no initial value');
}
for (var i = this.length - 1; walker !== null; i--) {
acc = fn(acc, walker.value, i);
walker = walker.prev;
}
return acc;
};
Yallist$1.prototype.toArray = function () {
var arr = new Array(this.length);
for (var i = 0, walker = this.head; walker !== null; i++) {
arr[i] = walker.value;
walker = walker.next;
}
return arr;
};
Yallist$1.prototype.toArrayReverse = function () {
var arr = new Array(this.length);
for (var i = 0, walker = this.tail; walker !== null; i++) {
arr[i] = walker.value;
walker = walker.prev;
}
return arr;
};
Yallist$1.prototype.slice = function (from, to) {
to = to || this.length;
if (to < 0) {
to += this.length;
}
from = from || 0;
if (from < 0) {
from += this.length;
}
var ret = new Yallist$1();
if (to < from || to < 0) {
return ret;
}
if (from < 0) {
from = 0;
}
if (to > this.length) {
to = this.length;
}
for (var i = 0, walker = this.head; walker !== null && i < from; i++) {
walker = walker.next;
}
for (; walker !== null && i < to; i++, walker = walker.next) {
ret.push(walker.value);
}
return ret;
};
Yallist$1.prototype.sliceReverse = function (from, to) {
to = to || this.length;
if (to < 0) {
to += this.length;
}
from = from || 0;
if (from < 0) {
from += this.length;
}
var ret = new Yallist$1();
if (to < from || to < 0) {
return ret;
}
if (from < 0) {
from = 0;
}
if (to > this.length) {
to = this.length;
}
for (var i = this.length, walker = this.tail; walker !== null && i > to; i--) {
walker = walker.prev;
}
for (; walker !== null && i > from; i--, walker = walker.prev) {
ret.push(walker.value);
}
return ret;
};
Yallist$1.prototype.splice = function (start, deleteCount, ...nodes) {
if (start > this.length) {
start = this.length - 1;
}
if (start < 0) {
start = this.length + start;
}
for (var i = 0, walker = this.head; walker !== null && i < start; i++) {
walker = walker.next;
}
var ret = [];
for (var i = 0; walker && i < deleteCount; i++) {
ret.push(walker.value);
walker = this.removeNode(walker);
}
if (walker === null) {
walker = this.tail;
}
if (walker !== this.head && walker !== this.tail) {
walker = walker.prev;
}
for (var i = 0; i < nodes.length; i++) {
walker = insert(this, walker, nodes[i]);
}
return ret;
};
Yallist$1.prototype.reverse = function () {
var head = this.head;
var tail = this.tail;
for (var walker = head; walker !== null; walker = walker.prev) {
var p = walker.prev;
walker.prev = walker.next;
walker.next = p;
}
this.head = tail;
this.tail = head;
return this;
};
function insert(self, node, value) {
var inserted = node === self.head ? new Node(value, null, node, self) : new Node(value, node, node.next, self);
if (inserted.next === null) {
self.tail = inserted;
}
if (inserted.prev === null) {
self.head = inserted;
}
self.length++;
return inserted;
}
function push(self, item) {
self.tail = new Node(item, self.tail, null, self);
if (!self.head) {
self.head = self.tail;
}
self.length++;
}
function unshift(self, item) {
self.head = new Node(item, null, self.head, self);
if (!self.tail) {
self.tail = self.head;
}
self.length++;
}
function Node(value, prev, next, list) {
if (!(this instanceof Node)) {
return new Node(value, prev, next, list);
}
this.list = list;
this.value = value;
if (prev) {
prev.next = this;
this.prev = prev;
} else {
this.prev = null;
}
if (next) {
next.prev = this;
this.next = next;
} else {
this.next = null;
}
}
try {
// add if support for Symbol.iterator is present
require('./iterator.js')(Yallist$1);
} catch (er) {}
const Yallist = yallist;
const MAX = Symbol('max');
const LENGTH = Symbol('length');
const LENGTH_CALCULATOR = Symbol('lengthCalculator');
const ALLOW_STALE = Symbol('allowStale');
const MAX_AGE = Symbol('maxAge');
const DISPOSE = Symbol('dispose');
const NO_DISPOSE_ON_SET = Symbol('noDisposeOnSet');
const LRU_LIST = Symbol('lruList');
const CACHE = Symbol('cache');
const UPDATE_AGE_ON_GET = Symbol('updateAgeOnGet');
const naiveLength = () => 1; // lruList is a yallist where the head is the youngest
// item, and the tail is the oldest. the list contains the Hit
// objects as the entries.
// Each Hit object has a reference to its Yallist.Node. This
// never changes.
//
// cache is a Map (or PseudoMap) that matches the keys to
// the Yallist.Node object.
class LRUCache {
constructor(options) {
if (typeof options === 'number') options = {
max: options
};
if (!options) options = {};
if (options.max && (typeof options.max !== 'number' || options.max < 0)) throw new TypeError('max must be a non-negative number'); // Kind of weird to have a default max of Infinity, but oh well.
this[MAX] = options.max || Infinity;
const lc = options.length || naiveLength;
this[LENGTH_CALCULATOR] = typeof lc !== 'function' ? naiveLength : lc;
this[ALLOW_STALE] = options.stale || false;
if (options.maxAge && typeof options.maxAge !== 'number') throw new TypeError('maxAge must be a number');
this[MAX_AGE] = options.maxAge || 0;
this[DISPOSE] = options.dispose;
this[NO_DISPOSE_ON_SET] = options.noDisposeOnSet || false;
this[UPDATE_AGE_ON_GET] = options.updateAgeOnGet || false;
this.reset();
} // resize the cache when the max changes.
set max(mL) {
if (typeof mL !== 'number' || mL < 0) throw new TypeError('max must be a non-negative number');
this[MAX] = mL || Infinity;
trim(this);
}
get max() {
return this[MAX];
}
set allowStale(allowStale) {
this[ALLOW_STALE] = !!allowStale;
}
get allowStale() {
return this[ALLOW_STALE];
}
set maxAge(mA) {
if (typeof mA !== 'number') throw new TypeError('maxAge must be a non-negative number');
this[MAX_AGE] = mA;
trim(this);
}
get maxAge() {
return this[MAX_AGE];
} // resize the cache when the lengthCalculator changes.
set lengthCalculator(lC) {
if (typeof lC !== 'function') lC = naiveLength;
if (lC !== this[LENGTH_CALCULATOR]) {
this[LENGTH_CALCULATOR] = lC;
this[LENGTH] = 0;
this[LRU_LIST].forEach(hit => {
hit.length = this[LENGTH_CALCULATOR](hit.value, hit.key);
this[LENGTH] += hit.length;
});
}
trim(this);
}
get lengthCalculator() {
return this[LENGTH_CALCULATOR];
}
get length() {
return this[LENGTH];
}
get itemCount() {
return this[LRU_LIST].length;
}
rforEach(fn, thisp) {
thisp = thisp || this;
for (let walker = this[LRU_LIST].tail; walker !== null;) {
const prev = walker.prev;
forEachStep(this, fn, walker, thisp);
walker = prev;
}
}
forEach(fn, thisp) {
thisp = thisp || this;
for (let walker = this[LRU_LIST].head; walker !== null;) {
const next = walker.next;
forEachStep(this, fn, walker, thisp);
walker = next;
}
}
keys() {
return this[LRU_LIST].toArray().map(k => k.key);
}
values() {
return this[LRU_LIST].toArray().map(k => k.value);
}
reset() {
if (this[DISPOSE] && this[LRU_LIST] && this[LRU_LIST].length) {
this[LRU_LIST].forEach(hit => this[DISPOSE](hit.key, hit.value));
}
this[CACHE] = new Map(); // hash of items by key
this[LRU_LIST] = new Yallist(); // list of items in order of use recency
this[LENGTH] = 0; // length of items in the list
}
dump() {
return this[LRU_LIST].map(hit => isStale(this, hit) ? false : {
k: hit.key,
v: hit.value,
e: hit.now + (hit.maxAge || 0)
}).toArray().filter(h => h);
}
dumpLru() {
return this[LRU_LIST];
}
set(key, value, maxAge) {
maxAge = maxAge || this[MAX_AGE];
if (maxAge && typeof maxAge !== 'number') throw new TypeError('maxAge must be a number');
const now = maxAge ? Date.now() : 0;
const len = this[LENGTH_CALCULATOR](value, key);
if (this[CACHE].has(key)) {
if (len > this[MAX]) {
del(this, this[CACHE].get(key));
return false;
}
const node = this[CACHE].get(key);
const item = node.value; // dispose of the old one before overwriting
// split out into 2 ifs for better coverage tracking
if (this[DISPOSE]) {
if (!this[NO_DISPOSE_ON_SET]) this[DISPOSE](key, item.value);
}
item.now = now;
item.maxAge = maxAge;
item.value = value;
this[LENGTH] += len - item.length;
item.length = len;
this.get(key);
trim(this);
return true;
}
const hit = new Entry(key, value, len, now, maxAge); // oversized objects fall out of cache automatically.
if (hit.length > this[MAX]) {
if (this[DISPOSE]) this[DISPOSE](key, value);
return false;
}
this[LENGTH] += hit.length;
this[LRU_LIST].unshift(hit);
this[CACHE].set(key, this[LRU_LIST].head);
trim(this);
return true;
}
has(key) {
if (!this[CACHE].has(key)) return false;
const hit = this[CACHE].get(key).value;
return !isStale(this, hit);
}
get(key) {
return get(this, key, true);
}
peek(key) {
return get(this, key, false);
}
pop() {
const node = this[LRU_LIST].tail;
if (!node) return null;
del(this, node);
return node.value;
}
del(key) {
del(this, this[CACHE].get(key));
}
load(arr) {
// reset the cache
this.reset();
const now = Date.now(); // A previous serialized cache has the most recent items first
for (let l = arr.length - 1; l >= 0; l--) {
const hit = arr[l];
const expiresAt = hit.e || 0;
if (expiresAt === 0) // the item was created without expiration in a non aged cache
this.set(hit.k, hit.v);else {
const maxAge = expiresAt - now; // dont add already expired items
if (maxAge > 0) {
this.set(hit.k, hit.v, maxAge);
}
}
}
}
prune() {
this[CACHE].forEach((value, key) => get(this, key, false));
}
}
const get = (self, key, doUse) => {
const node = self[CACHE].get(key);
if (node) {
const hit = node.value;
if (isStale(self, hit)) {
del(self, node);
if (!self[ALLOW_STALE]) return undefined;
} else {
if (doUse) {
if (self[UPDATE_AGE_ON_GET]) node.value.now = Date.now();
self[LRU_LIST].unshiftNode(node);
}
}
return hit.value;
}
};
const isStale = (self, hit) => {
if (!hit || !hit.maxAge && !self[MAX_AGE]) return false;
const diff = Date.now() - hit.now;
return hit.maxAge ? diff > hit.maxAge : self[MAX_AGE] && diff > self[MAX_AGE];
};
const trim = self => {
if (self[LENGTH] > self[MAX]) {
for (let walker = self[LRU_LIST].tail; self[LENGTH] > self[MAX] && walker !== null;) {
// We know that we're about to delete this one, and also
// what the next least recently used key will be, so just
// go ahead and set it now.
const prev = walker.prev;
del(self, walker);
walker = prev;
}
}
};
const del = (self, node) => {
if (node) {
const hit = node.value;
if (self[DISPOSE]) self[DISPOSE](hit.key, hit.value);
self[LENGTH] -= hit.length;
self[CACHE].delete(hit.key);
self[LRU_LIST].removeNode(node);
}
};
class Entry {
constructor(key, value, length, now, maxAge) {
this.key = key;
this.value = value;
this.length = length;
this.now = now;
this.maxAge = maxAge || 0;
}
}
const forEachStep = (self, fn, node, thisp) => {
let hit = node.value;
if (isStale(self, hit)) {
del(self, node);
if (!self[ALLOW_STALE]) hit = undefined;
}
if (hit) fn.call(thisp, hit.value, hit.key, self);
};
var lruCache = LRUCache;
class Range$a {
constructor(range, options) {
options = parseOptions$1(options);
if (range instanceof Range$a) {
if (range.loose === !!options.loose && range.includePrerelease === !!options.includePrerelease) {
return range;
} else {
return new Range$a(range.raw, options);
}
}
if (range instanceof Comparator$3) {
// just put it in the set and return
this.raw = range.value;
this.set = [[range]];
this.format();
return this;
}
this.options = options;
this.loose = !!options.loose;
this.includePrerelease = !!options.includePrerelease; // First, split based on boolean or ||
this.raw = range;
this.set = range.split(/\s*\|\|\s*/) // map the range to a 2d array of comparators
.map(range => this.parseRange(range.trim())) // throw out any comparator lists that are empty
// this generally means that it was not a valid range, which is allowed
// in loose mode, but will still throw if the WHOLE range is invalid.
.filter(c => c.length);
if (!this.set.length) {
throw new TypeError(`Invalid SemVer Range: ${range}`);
} // if we have any that are not the null set, throw out null sets.
if (this.set.length > 1) {
// keep the first one, in case they're all null sets
const first = this.set[0];
this.set = this.set.filter(c => !isNullSet(c[0]));
if (this.set.length === 0) this.set = [first];else if (this.set.length > 1) {
// if we have any that are *, then the range is just *
for (const c of this.set) {
if (c.length === 1 && isAny(c[0])) {
this.set = [c];
break;
}
}
}
}
this.format();
}
format() {
this.range = this.set.map(comps => {
return comps.join(' ').trim();
}).join('||').trim();
return this.range;
}
toString() {
return this.range;
}
parseRange(range) {
range = range.trim(); // memoize range parsing for performance.
// this is a very hot path, and fully deterministic.
const memoOpts = Object.keys(this.options).join(',');
const memoKey = `parseRange:${memoOpts}:${range}`;
const cached = cache.get(memoKey);
if (cached) return cached;
const loose = this.options.loose; // `1.2.3 - 1.2.4` => `>=1.2.3 <=1.2.4`
const hr = loose ? re$1[t$1.HYPHENRANGELOOSE] : re$1[t$1.HYPHENRANGE];
range = range.replace(hr, hyphenReplace(this.options.includePrerelease));
debug$1('hyphen replace', range); // `> 1.2.3 < 1.2.5` => `>1.2.3 <1.2.5`
range = range.replace(re$1[t$1.COMPARATORTRIM], comparatorTrimReplace);
debug$1('comparator trim', range, re$1[t$1.COMPARATORTRIM]); // `~ 1.2.3` => `~1.2.3`
range = range.replace(re$1[t$1.TILDETRIM], tildeTrimReplace); // `^ 1.2.3` => `^1.2.3`
range = range.replace(re$1[t$1.CARETTRIM], caretTrimReplace); // normalize spaces
range = range.split(/\s+/).join(' '); // At this point, the range is completely trimmed and
// ready to be split into comparators.
const compRe = loose ? re$1[t$1.COMPARATORLOOSE] : re$1[t$1.COMPARATOR];
const rangeList = range.split(' ').map(comp => parseComparator(comp, this.options)).join(' ').split(/\s+/) // >=0.0.0 is equivalent to *
.map(comp => replaceGTE0(comp, this.options)) // in loose mode, throw out any that are not valid comparators
.filter(this.options.loose ? comp => !!comp.match(compRe) : () => true).map(comp => new Comparator$3(comp, this.options)); // if any comparators are the null set, then replace with JUST null set
// if more than one comparator, remove any * comparators
// also, don't include the same comparator more than once
rangeList.length;
const rangeMap = new Map();
for (const comp of rangeList) {
if (isNullSet(comp)) return [comp];
rangeMap.set(comp.value, comp);
}
if (rangeMap.size > 1 && rangeMap.has('')) rangeMap.delete('');
const result = [...rangeMap.values()];
cache.set(memoKey, result);
return result;
}
intersects(range, options) {
if (!(range instanceof Range$a)) {
throw new TypeError('a Range is required');
}
return this.set.some(thisComparators => {
return isSatisfiable(thisComparators, options) && range.set.some(rangeComparators => {
return isSatisfiable(rangeComparators, options) && thisComparators.every(thisComparator => {
return rangeComparators.every(rangeComparator => {
return thisComparator.intersects(rangeComparator, options);
});
});
});
});
} // if ANY of the sets match ALL of its comparators, then pass
test(version) {
if (!version) {
return false;
}
if (typeof version === 'string') {
try {
version = new SemVer$5(version, this.options);
} catch (er) {
return false;
}
}
for (let i = 0; i < this.set.length; i++) {
if (testSet(this.set[i], version, this.options)) {
return true;
}
}
return false;
}
}
var range = Range$a;
const LRU = lruCache;
const cache = new LRU({
max: 1000
});
const parseOptions$1 = parseOptions_1;
const Comparator$3 = comparator;
const debug$1 = debug_1;
const SemVer$5 = semver$1;
const {
re: re$1,
t: t$1,
comparatorTrimReplace,
tildeTrimReplace,
caretTrimReplace
} = re$5.exports;
const isNullSet = c => c.value === '<0.0.0-0';
const isAny = c => c.value === ''; // take a set of comparators and determine whether there
// exists a version which can satisfy it
const isSatisfiable = (comparators, options) => {
let result = true;
const remainingComparators = comparators.slice();
let testComparator = remainingComparators.pop();
while (result && remainingComparators.length) {
result = remainingComparators.every(otherComparator => {
return testComparator.intersects(otherComparator, options);
});
testComparator = remainingComparators.pop();
}
return result;
}; // comprised of xranges, tildes, stars, and gtlt's at this point.
// already replaced the hyphen ranges
// turn into a set of JUST comparators.
const parseComparator = (comp, options) => {
debug$1('comp', comp, options);
comp = replaceCarets(comp, options);
debug$1('caret', comp);
comp = replaceTildes(comp, options);
debug$1('tildes', comp);
comp = replaceXRanges(comp, options);
debug$1('xrange', comp);
comp = replaceStars(comp, options);
debug$1('stars', comp);
return comp;
};
const isX = id => !id || id.toLowerCase() === 'x' || id === '*'; // ~, ~> --> * (any, kinda silly)
// ~2, ~2.x, ~2.x.x, ~>2, ~>2.x ~>2.x.x --> >=2.0.0 <3.0.0-0
// ~2.0, ~2.0.x, ~>2.0, ~>2.0.x --> >=2.0.0 <2.1.0-0
// ~1.2, ~1.2.x, ~>1.2, ~>1.2.x --> >=1.2.0 <1.3.0-0
// ~1.2.3, ~>1.2.3 --> >=1.2.3 <1.3.0-0
// ~1.2.0, ~>1.2.0 --> >=1.2.0 <1.3.0-0
const replaceTildes = (comp, options) => comp.trim().split(/\s+/).map(comp => {
return replaceTilde(comp, options);
}).join(' ');
const replaceTilde = (comp, options) => {
const r = options.loose ? re$1[t$1.TILDELOOSE] : re$1[t$1.TILDE];
return comp.replace(r, (_, M, m, p, pr) => {
debug$1('tilde', comp, _, M, m, p, pr);
let ret;
if (isX(M)) {
ret = '';
} else if (isX(m)) {
ret = `>=${M}.0.0 <${+M + 1}.0.0-0`;
} else if (isX(p)) {
// ~1.2 == >=1.2.0 <1.3.0-0
ret = `>=${M}.${m}.0 <${M}.${+m + 1}.0-0`;
} else if (pr) {
debug$1('replaceTilde pr', pr);
ret = `>=${M}.${m}.${p}-${pr} <${M}.${+m + 1}.0-0`;
} else {
// ~1.2.3 == >=1.2.3 <1.3.0-0
ret = `>=${M}.${m}.${p} <${M}.${+m + 1}.0-0`;
}
debug$1('tilde return', ret);
return ret;
});
}; // ^ --> * (any, kinda silly)
// ^2, ^2.x, ^2.x.x --> >=2.0.0 <3.0.0-0
// ^2.0, ^2.0.x --> >=2.0.0 <3.0.0-0
// ^1.2, ^1.2.x --> >=1.2.0 <2.0.0-0
// ^1.2.3 --> >=1.2.3 <2.0.0-0
// ^1.2.0 --> >=1.2.0 <2.0.0-0
const replaceCarets = (comp, options) => comp.trim().split(/\s+/).map(comp => {
return replaceCaret(comp, options);
}).join(' ');
const replaceCaret = (comp, options) => {
debug$1('caret', comp, options);
const r = options.loose ? re$1[t$1.CARETLOOSE] : re$1[t$1.CARET];
const z = options.includePrerelease ? '-0' : '';
return comp.replace(r, (_, M, m, p, pr) => {
debug$1('caret', comp, _, M, m, p, pr);
let ret;
if (isX(M)) {
ret = '';
} else if (isX(m)) {
ret = `>=${M}.0.0${z} <${+M + 1}.0.0-0`;
} else if (isX(p)) {
if (M === '0') {
ret = `>=${M}.${m}.0${z} <${M}.${+m + 1}.0-0`;
} else {
ret = `>=${M}.${m}.0${z} <${+M + 1}.0.0-0`;
}
} else if (pr) {
debug$1('replaceCaret pr', pr);
if (M === '0') {
if (m === '0') {
ret = `>=${M}.${m}.${p}-${pr} <${M}.${m}.${+p + 1}-0`;
} else {
ret = `>=${M}.${m}.${p}-${pr} <${M}.${+m + 1}.0-0`;
}
} else {
ret = `>=${M}.${m}.${p}-${pr} <${+M + 1}.0.0-0`;
}
} else {
debug$1('no pr');
if (M === '0') {
if (m === '0') {
ret = `>=${M}.${m}.${p}${z} <${M}.${m}.${+p + 1}-0`;
} else {
ret = `>=${M}.${m}.${p}${z} <${M}.${+m + 1}.0-0`;
}
} else {
ret = `>=${M}.${m}.${p} <${+M + 1}.0.0-0`;
}
}
debug$1('caret return', ret);
return ret;
});
};
const replaceXRanges = (comp, options) => {
debug$1('replaceXRanges', comp, options);
return comp.split(/\s+/).map(comp => {
return replaceXRange(comp, options);
}).join(' ');
};
const replaceXRange = (comp, options) => {
comp = comp.trim();
const r = options.loose ? re$1[t$1.XRANGELOOSE] : re$1[t$1.XRANGE];
return comp.replace(r, (ret, gtlt, M, m, p, pr) => {
debug$1('xRange', comp, ret, gtlt, M, m, p, pr);
const xM = isX(M);
const xm = xM || isX(m);
const xp = xm || isX(p);
const anyX = xp;
if (gtlt === '=' && anyX) {
gtlt = '';
} // if we're including prereleases in the match, then we need
// to fix this to -0, the lowest possible prerelease value
pr = options.includePrerelease ? '-0' : '';
if (xM) {
if (gtlt === '>' || gtlt === '<') {
// nothing is allowed
ret = '<0.0.0-0';
} else {
// nothing is forbidden
ret = '*';
}
} else if (gtlt && anyX) {
// we know patch is an x, because we have any x at all.
// replace X with 0
if (xm) {
m = 0;
}
p = 0;
if (gtlt === '>') {
// >1 => >=2.0.0
// >1.2 => >=1.3.0
gtlt = '>=';
if (xm) {
M = +M + 1;
m = 0;
p = 0;
} else {
m = +m + 1;
p = 0;
}
} else if (gtlt === '<=') {
// <=0.7.x is actually <0.8.0, since any 0.7.x should
// pass. Similarly, <=7.x is actually <8.0.0, etc.
gtlt = '<';
if (xm) {
M = +M + 1;
} else {
m = +m + 1;
}
}
if (gtlt === '<') pr = '-0';
ret = `${gtlt + M}.${m}.${p}${pr}`;
} else if (xm) {
ret = `>=${M}.0.0${pr} <${+M + 1}.0.0-0`;
} else if (xp) {
ret = `>=${M}.${m}.0${pr} <${M}.${+m + 1}.0-0`;
}
debug$1('xRange return', ret);
return ret;
});
}; // Because * is AND-ed with everything else in the comparator,
// and '' means "any version", just remove the *s entirely.
const replaceStars = (comp, options) => {
debug$1('replaceStars', comp, options); // Looseness is ignored here. star is always as loose as it gets!
return comp.trim().replace(re$1[t$1.STAR], '');
};
const replaceGTE0 = (comp, options) => {
debug$1('replaceGTE0', comp, options);
return comp.trim().replace(re$1[options.includePrerelease ? t$1.GTE0PRE : t$1.GTE0], '');
}; // This function is passed to string.replace(re[t.HYPHENRANGE])
// M, m, patch, prerelease, build
// 1.2 - 3.4.5 => >=1.2.0 <=3.4.5
// 1.2.3 - 3.4 => >=1.2.0 <3.5.0-0 Any 3.4.x will do
// 1.2 - 3.4 => >=1.2.0 <3.5.0-0
const hyphenReplace = incPr => ($0, from, fM, fm, fp, fpr, fb, to, tM, tm, tp, tpr, tb) => {
if (isX(fM)) {
from = '';
} else if (isX(fm)) {
from = `>=${fM}.0.0${incPr ? '-0' : ''}`;
} else if (isX(fp)) {
from = `>=${fM}.${fm}.0${incPr ? '-0' : ''}`;
} else if (fpr) {
from = `>=${from}`;
} else {
from = `>=${from}${incPr ? '-0' : ''}`;
}
if (isX(tM)) {
to = '';
} else if (isX(tm)) {
to = `<${+tM + 1}.0.0-0`;
} else if (isX(tp)) {
to = `<${tM}.${+tm + 1}.0-0`;
} else if (tpr) {
to = `<=${tM}.${tm}.${tp}-${tpr}`;
} else if (incPr) {
to = `<${tM}.${tm}.${+tp + 1}-0`;
} else {
to = `<=${to}`;
}
return `${from} ${to}`.trim();
};
const testSet = (set, version, options) => {
for (let i = 0; i < set.length; i++) {
if (!set[i].test(version)) {
return false;
}
}
if (version.prerelease.length && !options.includePrerelease) {
// Find the set of versions that are allowed to have prereleases
// For example, ^1.2.3-pr.1 desugars to >=1.2.3-pr.1 <2.0.0
// That should allow `1.2.3-pr.2` to pass.
// However, `1.2.4-alpha.notready` should NOT be allowed,
// even though it's within the range set by the comparators.
for (let i = 0; i < set.length; i++) {
debug$1(set[i].semver);
if (set[i].semver === Comparator$3.ANY) {
continue;
}
if (set[i].semver.prerelease.length > 0) {
const allowed = set[i].semver;
if (allowed.major === version.major && allowed.minor === version.minor && allowed.patch === version.patch) {
return true;
}
}
} // Version has a -pre, but it's not one of the ones we like.
return false;
}
return true;
};
const ANY$2 = Symbol('SemVer ANY'); // hoisted class for cyclic dependency
class Comparator$2 {
static get ANY() {
return ANY$2;
}
constructor(comp, options) {
options = parseOptions(options);
if (comp instanceof Comparator$2) {
if (comp.loose === !!options.loose) {
return comp;
} else {
comp = comp.value;
}
}
debug('comparator', comp, options);
this.options = options;
this.loose = !!options.loose;
this.parse(comp);
if (this.semver === ANY$2) {
this.value = '';
} else {
this.value = this.operator + this.semver.version;
}
debug('comp', this);
}
parse(comp) {
const r = this.options.loose ? re[t.COMPARATORLOOSE] : re[t.COMPARATOR];
const m = comp.match(r);
if (!m) {
throw new TypeError(`Invalid comparator: ${comp}`);
}
this.operator = m[1] !== undefined ? m[1] : '';
if (this.operator === '=') {
this.operator = '';
} // if it literally is just '>' or '' then allow anything.
if (!m[2]) {
this.semver = ANY$2;
} else {
this.semver = new SemVer$4(m[2], this.options.loose);
}
}
toString() {
return this.value;
}
test(version) {
debug('Comparator.test', version, this.options.loose);
if (this.semver === ANY$2 || version === ANY$2) {
return true;
}
if (typeof version === 'string') {
try {
version = new SemVer$4(version, this.options);
} catch (er) {
return false;
}
}
return cmp(version, this.operator, this.semver, this.options);
}
intersects(comp, options) {
if (!(comp instanceof Comparator$2)) {
throw new TypeError('a Comparator is required');
}
if (!options || typeof options !== 'object') {
options = {
loose: !!options,
includePrerelease: false
};
}
if (this.operator === '') {
if (this.value === '') {
return true;
}
return new Range$9(comp.value, options).test(this.value);
} else if (comp.operator === '') {
if (comp.value === '') {
return true;
}
return new Range$9(this.value, options).test(comp.semver);
}
const sameDirectionIncreasing = (this.operator === '>=' || this.operator === '>') && (comp.operator === '>=' || comp.operator === '>');
const sameDirectionDecreasing = (this.operator === '<=' || this.operator === '<') && (comp.operator === '<=' || comp.operator === '<');
const sameSemVer = this.semver.version === comp.semver.version;
const differentDirectionsInclusive = (this.operator === '>=' || this.operator === '<=') && (comp.operator === '>=' || comp.operator === '<=');
const oppositeDirectionsLessThan = cmp(this.semver, '<', comp.semver, options) && (this.operator === '>=' || this.operator === '>') && (comp.operator === '<=' || comp.operator === '<');
const oppositeDirectionsGreaterThan = cmp(this.semver, '>', comp.semver, options) && (this.operator === '<=' || this.operator === '<') && (comp.operator === '>=' || comp.operator === '>');
return sameDirectionIncreasing || sameDirectionDecreasing || sameSemVer && differentDirectionsInclusive || oppositeDirectionsLessThan || oppositeDirectionsGreaterThan;
}
}
var comparator = Comparator$2;
const parseOptions = parseOptions_1;
const {
re,
t
} = re$5.exports;
const cmp = cmp_1;
const debug = debug_1;
const SemVer$4 = semver$1;
const Range$9 = range;
const Range$8 = range;
const satisfies$3 = (version, range, options) => {
try {
range = new Range$8(range, options);
} catch (er) {
return false;
}
return range.test(version);
};
var satisfies_1 = satisfies$3;
const Range$7 = range; // Mostly just for testing and legacy API reasons
const toComparators = (range, options) => new Range$7(range, options).set.map(comp => comp.map(c => c.value).join(' ').trim().split(' '));
var toComparators_1 = toComparators;
const SemVer$3 = semver$1;
const Range$6 = range;
const maxSatisfying = (versions, range, options) => {
let max = null;
let maxSV = null;
let rangeObj = null;
try {
rangeObj = new Range$6(range, options);
} catch (er) {
return null;
}
versions.forEach(v => {
if (rangeObj.test(v)) {
// satisfies(v, range, options)
if (!max || maxSV.compare(v) === -1) {
// compare(max, v, true)
max = v;
maxSV = new SemVer$3(max, options);
}
}
});
return max;
};
var maxSatisfying_1 = maxSatisfying;
const SemVer$2 = semver$1;
const Range$5 = range;
const minSatisfying = (versions, range, options) => {
let min = null;
let minSV = null;
let rangeObj = null;
try {
rangeObj = new Range$5(range, options);
} catch (er) {
return null;
}
versions.forEach(v => {
if (rangeObj.test(v)) {
// satisfies(v, range, options)
if (!min || minSV.compare(v) === 1) {
// compare(min, v, true)
min = v;
minSV = new SemVer$2(min, options);
}
}
});
return min;
};
var minSatisfying_1 = minSatisfying;
const SemVer$1 = semver$1;
const Range$4 = range;
const gt$1 = gt_1;
const minVersion = (range, loose) => {
range = new Range$4(range, loose);
let minver = new SemVer$1('0.0.0');
if (range.test(minver)) {
return minver;
}
minver = new SemVer$1('0.0.0-0');
if (range.test(minver)) {
return minver;
}
minver = null;
for (let i = 0; i < range.set.length; ++i) {
const comparators = range.set[i];
let setMin = null;
comparators.forEach(comparator => {
// Clone to avoid manipulating the comparator's semver object.
const compver = new SemVer$1(comparator.semver.version);
switch (comparator.operator) {
case '>':
if (compver.prerelease.length === 0) {
compver.patch++;
} else {
compver.prerelease.push(0);
}
compver.raw = compver.format();
/* fallthrough */
case '':
case '>=':
if (!setMin || gt$1(compver, setMin)) {
setMin = compver;
}
break;
case '<':
case '<=':
/* Ignore maximum versions */
break;
/* istanbul ignore next */
default:
throw new Error(`Unexpected operation: ${comparator.operator}`);
}
});
if (setMin && (!minver || gt$1(minver, setMin))) minver = setMin;
}
if (minver && range.test(minver)) {
return minver;
}
return null;
};
var minVersion_1 = minVersion;
const Range$3 = range;
const validRange = (range, options) => {
try {
// Return '*' instead of '' so that truthiness works.
// This will throw if it's invalid anyway
return new Range$3(range, options).range || '*';
} catch (er) {
return null;
}
};
var valid = validRange;
const SemVer = semver$1;
const Comparator$1 = comparator;
const {
ANY: ANY$1
} = Comparator$1;
const Range$2 = range;
const satisfies$2 = satisfies_1;
const gt = gt_1;
const lt = lt_1;
const lte = lte_1;
const gte = gte_1;
const outside$2 = (version, range, hilo, options) => {
version = new SemVer(version, options);
range = new Range$2(range, options);
let gtfn, ltefn, ltfn, comp, ecomp;
switch (hilo) {
case '>':
gtfn = gt;
ltefn = lte;
ltfn = lt;
comp = '>';
ecomp = '>=';
break;
case '<':
gtfn = lt;
ltefn = gte;
ltfn = gt;
comp = '<';
ecomp = '<=';
break;
default:
throw new TypeError('Must provide a hilo val of "<" or ">"');
} // If it satisfies the range it is not outside
if (satisfies$2(version, range, options)) {
return false;
} // From now on, variable terms are as if we're in "gtr" mode.
// but note that everything is flipped for the "ltr" function.
for (let i = 0; i < range.set.length; ++i) {
const comparators = range.set[i];
let high = null;
let low = null;
comparators.forEach(comparator => {
if (comparator.semver === ANY$1) {
comparator = new Comparator$1('>=0.0.0');
}
high = high || comparator;
low = low || comparator;
if (gtfn(comparator.semver, high.semver, options)) {
high = comparator;
} else if (ltfn(comparator.semver, low.semver, options)) {
low = comparator;
}
}); // If the edge version comparator has a operator then our version
// isn't outside it
if (high.operator === comp || high.operator === ecomp) {
return false;
} // If the lowest version comparator has an operator and our version
// is less than it then it isn't higher than the range
if ((!low.operator || low.operator === comp) && ltefn(version, low.semver)) {
return false;
} else if (low.operator === ecomp && ltfn(version, low.semver)) {
return false;
}
}
return true;
};
var outside_1 = outside$2;
const outside$1 = outside_1;
const gtr = (version, range, options) => outside$1(version, range, '>', options);
var gtr_1 = gtr;
const outside = outside_1; // Determine if version is less than all the versions possible in the range
const ltr = (version, range, options) => outside(version, range, '<', options);
var ltr_1 = ltr;
const Range$1 = range;
const intersects = (r1, r2, options) => {
r1 = new Range$1(r1, options);
r2 = new Range$1(r2, options);
return r1.intersects(r2);
};
var intersects_1 = intersects;
// that includes the same versions that the original range does
// If the original range is shorter than the simplified one, return that.
const satisfies$1 = satisfies_1;
const compare$1 = compare_1;
var simplify = (versions, range, options) => {
const set = [];
let min = null;
let prev = null;
const v = versions.sort((a, b) => compare$1(a, b, options));
for (const version of v) {
const included = satisfies$1(version, range, options);
if (included) {
prev = version;
if (!min) min = version;
} else {
if (prev) {
set.push([min, prev]);
}
prev = null;
min = null;
}
}
if (min) set.push([min, null]);
const ranges = [];
for (const [min, max] of set) {
if (min === max) ranges.push(min);else if (!max && min === v[0]) ranges.push('*');else if (!max) ranges.push(`>=${min}`);else if (min === v[0]) ranges.push(`<=${max}`);else ranges.push(`${min} - ${max}`);
}
const simplified = ranges.join(' || ');
const original = typeof range.raw === 'string' ? range.raw : String(range);
return simplified.length < original.length ? simplified : range;
};
const Range = range;
const Comparator = comparator;
const {
ANY
} = Comparator;
const satisfies = satisfies_1;
const compare = compare_1; // Complex range `r1 || r2 || ...` is a subset of `R1 || R2 || ...` iff:
// - Every simple range `r1, r2, ...` is a null set, OR
// - Every simple range `r1, r2, ...` which is not a null set is a subset of
// some `R1, R2, ...`
//
// Simple range `c1 c2 ...` is a subset of simple range `C1 C2 ...` iff:
// - If c is only the ANY comparator
// - If C is only the ANY comparator, return true
// - Else if in prerelease mode, return false
// - else replace c with `[>=0.0.0]`
// - If C is only the ANY comparator
// - if in prerelease mode, return true
// - else replace C with `[>=0.0.0]`
// - Let EQ be the set of = comparators in c
// - If EQ is more than one, return true (null set)
// - Let GT be the highest > or >= comparator in c
// - Let LT be the lowest < or <= comparator in c
// - If GT and LT, and GT.semver > LT.semver, return true (null set)
// - If any C is a = range, and GT or LT are set, return false
// - If EQ
// - If GT, and EQ does not satisfy GT, return true (null set)
// - If LT, and EQ does not satisfy LT, return true (null set)
// - If EQ satisfies every C, return true
// - Else return false
// - If GT
// - If GT.semver is lower than any > or >= comp in C, return false
// - If GT is >=, and GT.semver does not satisfy every C, return false
// - If GT.semver has a prerelease, and not in prerelease mode
// - If no C has a prerelease and the GT.semver tuple, return false
// - If LT
// - If LT.semver is greater than any < or <= comp in C, return false
// - If LT is <=, and LT.semver does not satisfy every C, return false
// - If GT.semver has a prerelease, and not in prerelease mode
// - If no C has a prerelease and the LT.semver tuple, return false
// - Else return true
const subset = (sub, dom, options = {}) => {
if (sub === dom) return true;
sub = new Range(sub, options);
dom = new Range(dom, options);
let sawNonNull = false;
OUTER: for (const simpleSub of sub.set) {
for (const simpleDom of dom.set) {
const isSub = simpleSubset(simpleSub, simpleDom, options);
sawNonNull = sawNonNull || isSub !== null;
if (isSub) continue OUTER;
} // the null set is a subset of everything, but null simple ranges in
// a complex range should be ignored. so if we saw a non-null range,
// then we know this isn't a subset, but if EVERY simple range was null,
// then it is a subset.
if (sawNonNull) return false;
}
return true;
};
const simpleSubset = (sub, dom, options) => {
if (sub === dom) return true;
if (sub.length === 1 && sub[0].semver === ANY) {
if (dom.length === 1 && dom[0].semver === ANY) return true;else if (options.includePrerelease) sub = [new Comparator('>=0.0.0-0')];else sub = [new Comparator('>=0.0.0')];
}
if (dom.length === 1 && dom[0].semver === ANY) {
if (options.includePrerelease) return true;else dom = [new Comparator('>=0.0.0')];
}
const eqSet = new Set();
let gt, lt;
for (const c of sub) {
if (c.operator === '>' || c.operator === '>=') gt = higherGT(gt, c, options);else if (c.operator === '<' || c.operator === '<=') lt = lowerLT(lt, c, options);else eqSet.add(c.semver);
}
if (eqSet.size > 1) return null;
let gtltComp;
if (gt && lt) {
gtltComp = compare(gt.semver, lt.semver, options);
if (gtltComp > 0) return null;else if (gtltComp === 0 && (gt.operator !== '>=' || lt.operator !== '<=')) return null;
} // will iterate one or zero times
for (const eq of eqSet) {
if (gt && !satisfies(eq, String(gt), options)) return null;
if (lt && !satisfies(eq, String(lt), options)) return null;
for (const c of dom) {
if (!satisfies(eq, String(c), options)) return false;
}
return true;
}
let higher, lower;
let hasDomLT, hasDomGT; // if the subset has a prerelease, we need a comparator in the superset
// with the same tuple and a prerelease, or it's not a subset
let needDomLTPre = lt && !options.includePrerelease && lt.semver.prerelease.length ? lt.semver : false;
let needDomGTPre = gt && !options.includePrerelease && gt.semver.prerelease.length ? gt.semver : false; // exception: <1.2.3-0 is the same as <1.2.3
if (needDomLTPre && needDomLTPre.prerelease.length === 1 && lt.operator === '<' && needDomLTPre.prerelease[0] === 0) {
needDomLTPre = false;
}
for (const c of dom) {
hasDomGT = hasDomGT || c.operator === '>' || c.operator === '>=';
hasDomLT = hasDomLT || c.operator === '<' || c.operator === '<=';
if (gt) {
if (needDomGTPre) {
if (c.semver.prerelease && c.semver.prerelease.length && c.semver.major === needDomGTPre.major && c.semver.minor === needDomGTPre.minor && c.semver.patch === needDomGTPre.patch) {
needDomGTPre = false;
}
}
if (c.operator === '>' || c.operator === '>=') {
higher = higherGT(gt, c, options);
if (higher === c && higher !== gt) return false;
} else if (gt.operator === '>=' && !satisfies(gt.semver, String(c), options)) return false;
}
if (lt) {
if (needDomLTPre) {
if (c.semver.prerelease && c.semver.prerelease.length && c.semver.major === needDomLTPre.major && c.semver.minor === needDomLTPre.minor && c.semver.patch === needDomLTPre.patch) {
needDomLTPre = false;
}
}
if (c.operator === '<' || c.operator === '<=') {
lower = lowerLT(lt, c, options);
if (lower === c && lower !== lt) return false;
} else if (lt.operator === '<=' && !satisfies(lt.semver, String(c), options)) return false;
}
if (!c.operator && (lt || gt) && gtltComp !== 0) return false;
} // if there was a < or >, and nothing in the dom, then must be false
// UNLESS it was limited by another range in the other direction.
// Eg, >1.0.0 <1.0.1 is still a subset of <2.0.0
if (gt && hasDomLT && !lt && gtltComp !== 0) return false;
if (lt && hasDomGT && !gt && gtltComp !== 0) return false; // we needed a prerelease range in a specific tuple, but didn't get one
// then this isn't a subset. eg >=1.2.3-pre is not a subset of >=1.0.0,
// because it includes prereleases in the 1.2.3 tuple
if (needDomGTPre || needDomLTPre) return false;
return true;
}; // >=1.2.3 is lower than >1.2.3
const higherGT = (a, b, options) => {
if (!a) return b;
const comp = compare(a.semver, b.semver, options);
return comp > 0 ? a : comp < 0 ? b : b.operator === '>' && a.operator === '>=' ? b : a;
}; // <=1.2.3 is higher than <1.2.3
const lowerLT = (a, b, options) => {
if (!a) return b;
const comp = compare(a.semver, b.semver, options);
return comp < 0 ? a : comp > 0 ? b : b.operator === '<' && a.operator === '<=' ? b : a;
};
var subset_1 = subset;
const internalRe = re$5.exports;
var semver = {
re: internalRe.re,
src: internalRe.src,
tokens: internalRe.t,
SEMVER_SPEC_VERSION: constants.SEMVER_SPEC_VERSION,
SemVer: semver$1,
compareIdentifiers: identifiers.compareIdentifiers,
rcompareIdentifiers: identifiers.rcompareIdentifiers,
parse: parse_1,
valid: valid_1,
clean: clean_1,
inc: inc_1,
diff: diff_1,
major: major_1,
minor: minor_1,
patch: patch_1,
prerelease: prerelease_1,
compare: compare_1,
rcompare: rcompare_1,
compareLoose: compareLoose_1,
compareBuild: compareBuild_1,
sort: sort_1,
rsort: rsort_1,
gt: gt_1,
lt: lt_1,
eq: eq_1,
neq: neq_1,
gte: gte_1,
lte: lte_1,
cmp: cmp_1,
coerce: coerce_1,
Comparator: comparator,
Range: range,
satisfies: satisfies_1,
toComparators: toComparators_1,
maxSatisfying: maxSatisfying_1,
minSatisfying: minSatisfying_1,
minVersion: minVersion_1,
validRange: valid,
outside: outside_1,
gtr: gtr_1,
ltr: ltr_1,
intersects: intersects_1,
simplifyRange: simplify,
subset: subset_1
};
function adjustSpatial(item, encode, swap) {
let t;
if (encode.x2) {
if (encode.x) {
if (swap && item.x > item.x2) {
t = item.x;
item.x = item.x2;
item.x2 = t;
}
item.width = item.x2 - item.x;
} else {
item.x = item.x2 - (item.width || 0);
}
}
if (encode.xc) {
item.x = item.xc - (item.width || 0) / 2;
}
if (encode.y2) {
if (encode.y) {
if (swap && item.y > item.y2) {
t = item.y;
item.y = item.y2;
item.y2 = t;
}
item.height = item.y2 - item.y;
} else {
item.y = item.y2 - (item.height || 0);
}
}
if (encode.yc) {
item.y = item.yc - (item.height || 0) / 2;
}
}
var Constants = {
NaN: NaN,
E: Math.E,
LN2: Math.LN2,
LN10: Math.LN10,
LOG2E: Math.LOG2E,
LOG10E: Math.LOG10E,
PI: Math.PI,
SQRT1_2: Math.SQRT1_2,
SQRT2: Math.SQRT2,
MIN_VALUE: Number.MIN_VALUE,
MAX_VALUE: Number.MAX_VALUE
};
var Ops = {
'*': (a, b) => a * b,
'+': (a, b) => a + b,
'-': (a, b) => a - b,
'/': (a, b) => a / b,
'%': (a, b) => a % b,
'>': (a, b) => a > b,
'<': (a, b) => a < b,
'<=': (a, b) => a <= b,
'>=': (a, b) => a >= b,
'==': (a, b) => a == b,
'!=': (a, b) => a != b,
'===': (a, b) => a === b,
'!==': (a, b) => a !== b,
'&': (a, b) => a & b,
'|': (a, b) => a | b,
'^': (a, b) => a ^ b,
'<<': (a, b) => a << b,
'>>': (a, b) => a >> b,
'>>>': (a, b) => a >>> b
};
var Unary = {
'+': a => +a,
'-': a => -a,
'~': a => ~a,
'!': a => !a
};
const slice = Array.prototype.slice;
const apply = (m, args, cast) => {
const obj = cast ? cast(args[0]) : args[0];
return obj[m].apply(obj, slice.call(args, 1));
};
const datetime = (y, m, d, H, M, S, ms) => new Date(y, m || 0, d != null ? d : 1, H || 0, M || 0, S || 0, ms || 0);
var Functions = {
// math functions
isNaN: Number.isNaN,
isFinite: Number.isFinite,
abs: Math.abs,
acos: Math.acos,
asin: Math.asin,
atan: Math.atan,
atan2: Math.atan2,
ceil: Math.ceil,
cos: Math.cos,
exp: Math.exp,
floor: Math.floor,
log: Math.log,
max: Math.max,
min: Math.min,
pow: Math.pow,
random: Math.random,
round: Math.round,
sin: Math.sin,
sqrt: Math.sqrt,
tan: Math.tan,
clamp: (a, b, c) => Math.max(b, Math.min(c, a)),
// date functions
now: Date.now,
utc: Date.UTC,
datetime: datetime,
date: d => new Date(d).getDate(),
day: d => new Date(d).getDay(),
year: d => new Date(d).getFullYear(),
month: d => new Date(d).getMonth(),
hours: d => new Date(d).getHours(),
minutes: d => new Date(d).getMinutes(),
seconds: d => new Date(d).getSeconds(),
milliseconds: d => new Date(d).getMilliseconds(),
time: d => new Date(d).getTime(),
timezoneoffset: d => new Date(d).getTimezoneOffset(),
utcdate: d => new Date(d).getUTCDate(),
utcday: d => new Date(d).getUTCDay(),
utcyear: d => new Date(d).getUTCFullYear(),
utcmonth: d => new Date(d).getUTCMonth(),
utchours: d => new Date(d).getUTCHours(),
utcminutes: d => new Date(d).getUTCMinutes(),
utcseconds: d => new Date(d).getUTCSeconds(),
utcmilliseconds: d => new Date(d).getUTCMilliseconds(),
// sequence functions
length: x => x.length,
join: function () {
return apply('join', arguments);
},
indexof: function () {
return apply('indexOf', arguments);
},
lastindexof: function () {
return apply('lastIndexOf', arguments);
},
slice: function () {
return apply('slice', arguments);
},
reverse: x => x.slice().reverse(),
// string functions
parseFloat: parseFloat,
parseInt: parseInt,
upper: x => String(x).toUpperCase(),
lower: x => String(x).toLowerCase(),
substring: function () {
return apply('substring', arguments, String);
},
split: function () {
return apply('split', arguments, String);
},
replace: function () {
return apply('replace', arguments, String);
},
trim: x => String(x).trim(),
// regexp functions
regexp: RegExp,
test: (r, t) => RegExp(r).test(t)
};
const EventFunctions = ['view', 'item', 'group', 'xy', 'x', 'y'];
const Visitors = {
Literal: ($, n) => n.value,
Identifier: ($, n) => {
const id = n.name;
return $.memberDepth > 0 ? id : id === 'datum' ? $.datum : id === 'event' ? $.event : id === 'item' ? $.item : Constants[id] || $.params['$' + id];
},
MemberExpression: ($, n) => {
const d = !n.computed,
o = $(n.object);
if (d) $.memberDepth += 1;
const p = $(n.property);
if (d) $.memberDepth -= 1;
return o[p];
},
CallExpression: ($, n) => {
const args = n.arguments;
let name = n.callee.name; // handle special internal functions used by encoders
// re-route to corresponding standard function
if (name.startsWith('_')) {
name = name.slice(1);
} // special case "if" due to conditional evaluation of branches
return name === 'if' ? $(args[0]) ? $(args[1]) : $(args[2]) : ($.fn[name] || Functions[name]).apply($.fn, args.map($));
},
ArrayExpression: ($, n) => n.elements.map($),
BinaryExpression: ($, n) => Ops[n.operator]($(n.left), $(n.right)),
UnaryExpression: ($, n) => Unary[n.operator]($(n.argument)),
ConditionalExpression: ($, n) => $(n.test) ? $(n.consequent) : $(n.alternate),
LogicalExpression: ($, n) => n.operator === '&&' ? $(n.left) && $(n.right) : $(n.left) || $(n.right),
ObjectExpression: ($, n) => n.properties.reduce((o, p) => {
$.memberDepth += 1;
const k = $(p.key);
$.memberDepth -= 1;
o[k] = $(p.value);
return o;
}, {})
};
function interpret(ast, fn, params, datum, event, item) {
const $ = n => Visitors[n.type]($, n);
$.memberDepth = 0;
$.fn = Object.create(fn);
$.params = params;
$.datum = datum;
$.event = event;
$.item = item; // route event functions to annotated vega event context
EventFunctions.forEach(f => $.fn[f] = (...args) => event.vega[f](...args));
return $(ast);
}
var expression = {
/**
* Parse an expression used to update an operator value.
*/
operator(ctx, expr) {
const ast = expr.ast,
fn = ctx.functions;
return _ => interpret(ast, fn, _);
},
/**
* Parse an expression provided as an operator parameter value.
*/
parameter(ctx, expr) {
const ast = expr.ast,
fn = ctx.functions;
return (datum, _) => interpret(ast, fn, _, datum);
},
/**
* Parse an expression applied to an event stream.
*/
event(ctx, expr) {
const ast = expr.ast,
fn = ctx.functions;
return event => interpret(ast, fn, undefined, undefined, event);
},
/**
* Parse an expression used to handle an event-driven operator update.
*/
handler(ctx, expr) {
const ast = expr.ast,
fn = ctx.functions;
return (_, event) => {
const datum = event.item && event.item.datum;
return interpret(ast, fn, _, datum, event);
};
},
/**
* Parse an expression that performs visual encoding.
*/
encode(ctx, encode) {
const {
marktype,
channels
} = encode,
fn = ctx.functions,
swap = marktype === 'group' || marktype === 'image' || marktype === 'rect';
return (item, _) => {
const datum = item.datum;
let m = 0,
v;
for (const name in channels) {
v = interpret(channels[name].ast, fn, _, datum, undefined, item);
if (item[name] !== v) {
item[name] = v;
m = 1;
}
}
if (marktype !== 'rule') {
adjustSpatial(item, channels, swap);
}
return m;
};
}
};
function e(e) {
const [n, r] = /schema\/([\w-]+)\/([\w\.\-]+)\.json$/g.exec(e).slice(1, 3);
return {
library: n,
version: r
};
}
var name$1 = "vega-themes";
var version$2 = "2.10.0";
var description$1 = "Themes for stylized Vega and Vega-Lite visualizations.";
var keywords$1 = ["vega", "vega-lite", "themes", "style"];
var license$1 = "BSD-3-Clause";
var author$1 = {
name: "UW Interactive Data Lab",
url: "https://idl.cs.washington.edu"
};
var contributors$1 = [{
name: "Emily Gu",
url: "https://github.com/emilygu"
}, {
name: "Arvind Satyanarayan",
url: "http://arvindsatya.com"
}, {
name: "Jeffrey Heer",
url: "https://idl.cs.washington.edu"
}, {
name: "Dominik Moritz",
url: "https://www.domoritz.de"
}];
var main$1 = "build/vega-themes.js";
var module$1 = "build/vega-themes.module.js";
var unpkg$1 = "build/vega-themes.min.js";
var jsdelivr$1 = "build/vega-themes.min.js";
var types$1 = "build/vega-themes.module.d.ts";
var repository$1 = {
type: "git",
url: "https://github.com/vega/vega-themes.git"
};
var files$1 = ["src", "build"];
var scripts$1 = {
prebuild: "yarn clean",
build: "rollup -c",
clean: "rimraf build && rimraf examples/build",
"copy:data": "rsync -r node_modules/vega-datasets/data/* examples/data",
"copy:build": "rsync -r build/* examples/build",
"deploy:gh": "yarn build && mkdir -p examples/build && rsync -r build/* examples/build && gh-pages -d examples",
prepublishOnly: "yarn clean && yarn build",
preversion: "yarn lint",
serve: "browser-sync start -s -f build examples --serveStatic examples",
start: "yarn build && concurrently --kill-others -n Server,Rollup 'yarn serve' 'rollup -c -w'",
prepare: "beemo create-config",
eslintbase: "beemo eslint .",
format: "yarn eslintbase --fix",
lint: "yarn eslintbase"
};
var devDependencies$1 = {
"@rollup/plugin-json": "^4.1.0",
"@rollup/plugin-node-resolve": "^11.2.0",
"@wessberg/rollup-plugin-ts": "^1.3.8",
"browser-sync": "^2.26.14",
concurrently: "^6.0.0",
"gh-pages": "^3.1.0",
rollup: "^2.39.1",
"rollup-plugin-bundle-size": "^1.0.3",
"rollup-plugin-terser": "^7.0.2",
typescript: "^4.2.2",
vega: "^5.19.1",
"vega-lite": "^5.0.0",
"vega-lite-dev-config": "^0.16.1"
};
var peerDependencies$1 = {
vega: "*",
"vega-lite": "*"
};
var pkg$1 = {
name: name$1,
version: version$2,
description: description$1,
keywords: keywords$1,
license: license$1,
author: author$1,
contributors: contributors$1,
main: main$1,
module: module$1,
unpkg: unpkg$1,
jsdelivr: jsdelivr$1,
types: types$1,
repository: repository$1,
files: files$1,
scripts: scripts$1,
devDependencies: devDependencies$1,
peerDependencies: peerDependencies$1
};
const lightColor = '#fff';
const medColor = '#888';
const darkTheme = {
background: '#333',
title: {
color: lightColor,
subtitleColor: lightColor
},
style: {
'guide-label': {
fill: lightColor
},
'guide-title': {
fill: lightColor
}
},
axis: {
domainColor: lightColor,
gridColor: medColor,
tickColor: lightColor
}
};
const markColor = '#4572a7';
const excelTheme = {
background: '#fff',
arc: {
fill: markColor
},
area: {
fill: markColor
},
line: {
stroke: markColor,
strokeWidth: 2
},
path: {
stroke: markColor
},
rect: {
fill: markColor
},
shape: {
stroke: markColor
},
symbol: {
fill: markColor,
strokeWidth: 1.5,
size: 50
},
axis: {
bandPosition: 0.5,
grid: true,
gridColor: '#000000',
gridOpacity: 1,
gridWidth: 0.5,
labelPadding: 10,
tickSize: 5,
tickWidth: 0.5
},
axisBand: {
grid: false,
tickExtra: true
},
legend: {
labelBaseline: 'middle',
labelFontSize: 11,
symbolSize: 50,
symbolType: 'square'
},
range: {
category: ['#4572a7', '#aa4643', '#8aa453', '#71598e', '#4598ae', '#d98445', '#94aace', '#d09393', '#b9cc98', '#a99cbc']
}
};
const markColor$1 = '#30a2da';
const axisColor = '#cbcbcb';
const guideLabelColor = '#999';
const guideTitleColor = '#333';
const backgroundColor = '#f0f0f0';
const blackTitle = '#333';
const fiveThirtyEightTheme = {
arc: {
fill: markColor$1
},
area: {
fill: markColor$1
},
axis: {
domainColor: axisColor,
grid: true,
gridColor: axisColor,
gridWidth: 1,
labelColor: guideLabelColor,
labelFontSize: 10,
titleColor: guideTitleColor,
tickColor: axisColor,
tickSize: 10,
titleFontSize: 14,
titlePadding: 10,
labelPadding: 4
},
axisBand: {
grid: false
},
background: backgroundColor,
group: {
fill: backgroundColor
},
legend: {
labelColor: blackTitle,
labelFontSize: 11,
padding: 1,
symbolSize: 30,
symbolType: 'square',
titleColor: blackTitle,
titleFontSize: 14,
titlePadding: 10
},
line: {
stroke: markColor$1,
strokeWidth: 2
},
path: {
stroke: markColor$1,
strokeWidth: 0.5
},
rect: {
fill: markColor$1
},
range: {
category: ['#30a2da', '#fc4f30', '#e5ae38', '#6d904f', '#8b8b8b', '#b96db8', '#ff9e27', '#56cc60', '#52d2ca', '#52689e', '#545454', '#9fe4f8'],
diverging: ['#cc0020', '#e77866', '#f6e7e1', '#d6e8ed', '#91bfd9', '#1d78b5'],
heatmap: ['#d6e8ed', '#cee0e5', '#91bfd9', '#549cc6', '#1d78b5']
},
point: {
filled: true,
shape: 'circle'
},
shape: {
stroke: markColor$1
},
bar: {
binSpacing: 2,
fill: markColor$1,
stroke: null
},
title: {
anchor: 'start',
fontSize: 24,
fontWeight: 600,
offset: 20
}
};
const markColor$2 = '#000';
const ggplot2Theme = {
group: {
fill: '#e5e5e5'
},
arc: {
fill: markColor$2
},
area: {
fill: markColor$2
},
line: {
stroke: markColor$2
},
path: {
stroke: markColor$2
},
rect: {
fill: markColor$2
},
shape: {
stroke: markColor$2
},
symbol: {
fill: markColor$2,
size: 40
},
axis: {
domain: false,
grid: true,
gridColor: '#FFFFFF',
gridOpacity: 1,
labelColor: '#7F7F7F',
labelPadding: 4,
tickColor: '#7F7F7F',
tickSize: 5.67,
titleFontSize: 16,
titleFontWeight: 'normal'
},
legend: {
labelBaseline: 'middle',
labelFontSize: 11,
symbolSize: 40
},
range: {
category: ['#000000', '#7F7F7F', '#1A1A1A', '#999999', '#333333', '#B0B0B0', '#4D4D4D', '#C9C9C9', '#666666', '#DCDCDC']
}
};
const headlineFontSize = 22;
const headlineFontWeight = 'normal';
const labelFont = 'Benton Gothic, sans-serif';
const labelFontSize = 11.5;
const labelFontWeight = 'normal';
const markColor$3 = '#82c6df'; // const markHighlight = '#006d8f';
// const markDemocrat = '#5789b8';
// const markRepublican = '#d94f54';
const titleFont = 'Benton Gothic Bold, sans-serif';
const titleFontWeight = 'normal';
const titleFontSize = 13;
const colorSchemes = {
'category-6': ['#ec8431', '#829eb1', '#c89d29', '#3580b1', '#adc839', '#ab7fb4'],
'fire-7': ['#fbf2c7', '#f9e39c', '#f8d36e', '#f4bb6a', '#e68a4f', '#d15a40', '#ab4232'],
'fireandice-6': ['#e68a4f', '#f4bb6a', '#f9e39c', '#dadfe2', '#a6b7c6', '#849eae'],
'ice-7': ['#edefee', '#dadfe2', '#c4ccd2', '#a6b7c6', '#849eae', '#607785', '#47525d']
};
const latimesTheme = {
background: '#ffffff',
title: {
anchor: 'start',
color: '#000000',
font: titleFont,
fontSize: headlineFontSize,
fontWeight: headlineFontWeight
},
arc: {
fill: markColor$3
},
area: {
fill: markColor$3
},
line: {
stroke: markColor$3,
strokeWidth: 2
},
path: {
stroke: markColor$3
},
rect: {
fill: markColor$3
},
shape: {
stroke: markColor$3
},
symbol: {
fill: markColor$3,
size: 30
},
axis: {
labelFont,
labelFontSize,
labelFontWeight,
titleFont,
titleFontSize,
titleFontWeight
},
axisX: {
labelAngle: 0,
labelPadding: 4,
tickSize: 3
},
axisY: {
labelBaseline: 'middle',
maxExtent: 45,
minExtent: 45,
tickSize: 2,
titleAlign: 'left',
titleAngle: 0,
titleX: -45,
titleY: -11
},
legend: {
labelFont,
labelFontSize,
symbolType: 'square',
titleFont,
titleFontSize,
titleFontWeight
},
range: {
category: colorSchemes['category-6'],
diverging: colorSchemes['fireandice-6'],
heatmap: colorSchemes['fire-7'],
ordinal: colorSchemes['fire-7'],
ramp: colorSchemes['fire-7']
}
};
const markColor$4 = '#ab5787';
const axisColor$1 = '#979797';
const quartzTheme = {
background: '#f9f9f9',
arc: {
fill: markColor$4
},
area: {
fill: markColor$4
},
line: {
stroke: markColor$4
},
path: {
stroke: markColor$4
},
rect: {
fill: markColor$4
},
shape: {
stroke: markColor$4
},
symbol: {
fill: markColor$4,
size: 30
},
axis: {
domainColor: axisColor$1,
domainWidth: 0.5,
gridWidth: 0.2,
labelColor: axisColor$1,
tickColor: axisColor$1,
tickWidth: 0.2,
titleColor: axisColor$1
},
axisBand: {
grid: false
},
axisX: {
grid: true,
tickSize: 10
},
axisY: {
domain: false,
grid: true,
tickSize: 0
},
legend: {
labelFontSize: 11,
padding: 1,
symbolSize: 30,
symbolType: 'square'
},
range: {
category: ['#ab5787', '#51b2e5', '#703c5c', '#168dd9', '#d190b6', '#00609f', '#d365ba', '#154866', '#666666', '#c4c4c4']
}
};
const markColor$5 = '#3e5c69';
const voxTheme = {
background: '#fff',
arc: {
fill: markColor$5
},
area: {
fill: markColor$5
},
line: {
stroke: markColor$5
},
path: {
stroke: markColor$5
},
rect: {
fill: markColor$5
},
shape: {
stroke: markColor$5
},
symbol: {
fill: markColor$5
},
axis: {
domainWidth: 0.5,
grid: true,
labelPadding: 2,
tickSize: 5,
tickWidth: 0.5,
titleFontWeight: 'normal'
},
axisBand: {
grid: false
},
axisX: {
gridWidth: 0.2
},
axisY: {
gridDash: [3],
gridWidth: 0.4
},
legend: {
labelFontSize: 11,
padding: 1,
symbolType: 'square'
},
range: {
category: ['#3e5c69', '#6793a6', '#182429', '#0570b0', '#3690c0', '#74a9cf', '#a6bddb', '#e2ddf2']
}
};
const markColor$6 = '#1696d2';
const axisColor$2 = '#000000';
const backgroundColor$1 = '#FFFFFF';
const font = 'Lato';
const labelFont$1 = 'Lato';
const sourceFont = 'Lato';
const gridColor = '#DEDDDD';
const titleFontSize$1 = 18;
const colorSchemes$1 = {
'main-colors': ['#1696d2', '#d2d2d2', '#000000', '#fdbf11', '#ec008b', '#55b748', '#5c5859', '#db2b27'],
'shades-blue': ['#CFE8F3', '#A2D4EC', '#73BFE2', '#46ABDB', '#1696D2', '#12719E', '#0A4C6A', '#062635'],
'shades-gray': ['#F5F5F5', '#ECECEC', '#E3E3E3', '#DCDBDB', '#D2D2D2', '#9D9D9D', '#696969', '#353535'],
'shades-yellow': ['#FFF2CF', '#FCE39E', '#FDD870', '#FCCB41', '#FDBF11', '#E88E2D', '#CA5800', '#843215'],
'shades-magenta': ['#F5CBDF', '#EB99C2', '#E46AA7', '#E54096', '#EC008B', '#AF1F6B', '#761548', '#351123'],
'shades-green': ['#DCEDD9', '#BCDEB4', '#98CF90', '#78C26D', '#55B748', '#408941', '#2C5C2D', '#1A2E19'],
'shades-black': ['#D5D5D4', '#ADABAC', '#848081', '#5C5859', '#332D2F', '#262223', '#1A1717', '#0E0C0D'],
'shades-red': ['#F8D5D4', '#F1AAA9', '#E9807D', '#E25552', '#DB2B27', '#A4201D', '#6E1614', '#370B0A'],
'one-group': ['#1696d2', '#000000'],
'two-groups-cat-1': ['#1696d2', '#000000'],
'two-groups-cat-2': ['#1696d2', '#fdbf11'],
'two-groups-cat-3': ['#1696d2', '#db2b27'],
'two-groups-seq': ['#a2d4ec', '#1696d2'],
'three-groups-cat': ['#1696d2', '#fdbf11', '#000000'],
'three-groups-seq': ['#a2d4ec', '#1696d2', '#0a4c6a'],
'four-groups-cat-1': ['#000000', '#d2d2d2', '#fdbf11', '#1696d2'],
'four-groups-cat-2': ['#1696d2', '#ec0008b', '#fdbf11', '#5c5859'],
'four-groups-seq': ['#cfe8f3', '#73bf42', '#1696d2', '#0a4c6a'],
'five-groups-cat-1': ['#1696d2', '#fdbf11', '#d2d2d2', '#ec008b', '#000000'],
'five-groups-cat-2': ['#1696d2', '#0a4c6a', '#d2d2d2', '#fdbf11', '#332d2f'],
'five-groups-seq': ['#cfe8f3', '#73bf42', '#1696d2', '#0a4c6a', '#000000'],
'six-groups-cat-1': ['#1696d2', '#ec008b', '#fdbf11', '#000000', '#d2d2d2', '#55b748'],
'six-groups-cat-2': ['#1696d2', '#d2d2d2', '#ec008b', '#fdbf11', '#332d2f', '#0a4c6a'],
'six-groups-seq': ['#cfe8f3', '#a2d4ec', '#73bfe2', '#46abdb', '#1696d2', '#12719e'],
'diverging-colors': ['#ca5800', '#fdbf11', '#fdd870', '#fff2cf', '#cfe8f3', '#73bfe2', '#1696d2', '#0a4c6a']
};
const urbanInstituteTheme = {
background: backgroundColor$1,
title: {
anchor: 'start',
fontSize: titleFontSize$1,
font: font
},
axisX: {
domain: true,
domainColor: axisColor$2,
domainWidth: 1,
grid: false,
labelFontSize: 12,
labelFont: labelFont$1,
labelAngle: 0,
tickColor: axisColor$2,
tickSize: 5,
titleFontSize: 12,
titlePadding: 10,
titleFont: font
},
axisY: {
domain: false,
domainWidth: 1,
grid: true,
gridColor: gridColor,
gridWidth: 1,
labelFontSize: 12,
labelFont: labelFont$1,
labelPadding: 8,
ticks: false,
titleFontSize: 12,
titlePadding: 10,
titleFont: font,
titleAngle: 0,
titleY: -10,
titleX: 18
},
legend: {
labelFontSize: 12,
labelFont: labelFont$1,
symbolSize: 100,
titleFontSize: 12,
titlePadding: 10,
titleFont: font,
orient: 'right',
offset: 10
},
view: {
stroke: 'transparent'
},
range: {
category: colorSchemes$1['six-groups-cat-1'],
diverging: colorSchemes$1['diverging-colors'],
heatmap: colorSchemes$1['diverging-colors'],
ordinal: colorSchemes$1['six-groups-seq'],
ramp: colorSchemes$1['shades-blue']
},
area: {
fill: markColor$6
},
rect: {
fill: markColor$6
},
line: {
color: markColor$6,
stroke: markColor$6,
strokeWidth: 5
},
trail: {
color: markColor$6,
stroke: markColor$6,
strokeWidth: 0,
size: 1
},
path: {
stroke: markColor$6,
strokeWidth: 0.5
},
point: {
filled: true
},
text: {
font: sourceFont,
color: markColor$6,
fontSize: 11,
align: 'center',
fontWeight: 400,
size: 11
},
style: {
bar: {
fill: markColor$6,
stroke: null
}
},
arc: {
fill: markColor$6
},
shape: {
stroke: markColor$6
},
symbol: {
fill: markColor$6,
size: 30
}
};
/**
* Copyright 2020 Google LLC.
*
* Use of this source code is governed by a BSD-style
* license that can be found in the LICENSE file or at
* https://developers.google.com/open-source/licenses/bsd
*/
const markColor$7 = '#3366CC';
const gridColor$1 = '#ccc';
const defaultFont = 'Arial, sans-serif';
const googlechartsTheme = {
arc: {
fill: markColor$7
},
area: {
fill: markColor$7
},
path: {
stroke: markColor$7
},
rect: {
fill: markColor$7
},
shape: {
stroke: markColor$7
},
symbol: {
stroke: markColor$7
},
circle: {
fill: markColor$7
},
background: '#fff',
padding: {
top: 10,
right: 10,
bottom: 10,
left: 10
},
style: {
'guide-label': {
font: defaultFont,
fontSize: 12
},
'guide-title': {
font: defaultFont,
fontSize: 12
},
'group-title': {
font: defaultFont,
fontSize: 12
}
},
title: {
font: defaultFont,
fontSize: 14,
fontWeight: 'bold',
dy: -3,
anchor: 'start'
},
axis: {
gridColor: gridColor$1,
tickColor: gridColor$1,
domain: false,
grid: true
},
range: {
category: ['#4285F4', '#DB4437', '#F4B400', '#0F9D58', '#AB47BC', '#00ACC1', '#FF7043', '#9E9D24', '#5C6BC0', '#F06292', '#00796B', '#C2185B'],
heatmap: ['#c6dafc', '#5e97f6', '#2a56c6']
}
};
const version$1$1 = pkg$1.version;
var themes = /*#__PURE__*/Object.freeze({
__proto__: null,
dark: darkTheme,
excel: excelTheme,
fivethirtyeight: fiveThirtyEightTheme,
ggplot2: ggplot2Theme,
googlecharts: googlechartsTheme,
latimes: latimesTheme,
quartz: quartzTheme,
urbaninstitute: urbanInstituteTheme,
version: version$1$1,
vox: voxTheme
});
function accessor(fn, fields, name) {
fn.fields = fields || [];
fn.fname = name;
return fn;
}
function getter(path) {
return path.length === 1 ? get1(path[0]) : getN(path);
}
const get1 = field => function (obj) {
return obj[field];
};
const getN = path => {
const len = path.length;
return function (obj) {
for (let i = 0; i < len; ++i) {
obj = obj[path[i]];
}
return obj;
};
};
function error(message) {
throw Error(message);
}
function splitAccessPath(p) {
const path = [],
n = p.length;
let q = null,
b = 0,
s = '',
i,
j,
c;
p = p + '';
function push() {
path.push(s + p.substring(i, j));
s = '';
i = j + 1;
}
for (i = j = 0; j < n; ++j) {
c = p[j];
if (c === '\\') {
s += p.substring(i, j);
s += p.substring(++j, ++j);
i = j;
} else if (c === q) {
push();
q = null;
b = -1;
} else if (q) {
continue;
} else if (i === b && c === '"') {
i = j + 1;
q = c;
} else if (i === b && c === "'") {
i = j + 1;
q = c;
} else if (c === '.' && !b) {
if (j > i) {
push();
} else {
i = j + 1;
}
} else if (c === '[') {
if (j > i) push();
b = i = j + 1;
} else if (c === ']') {
if (!b) error('Access path missing open bracket: ' + p);
if (b > 0) push();
b = 0;
i = j + 1;
}
}
if (b) error('Access path missing closing bracket: ' + p);
if (q) error('Access path missing closing quote: ' + p);
if (j > i) {
j++;
push();
}
return path;
}
function field(field, name, opt) {
const path = splitAccessPath(field);
field = path.length === 1 ? path[0] : field;
return accessor((opt && opt.get || getter)(path), [field], name || field);
}
field('id');
accessor(_ => _, [], 'identity');
accessor(() => 0, [], 'zero');
accessor(() => 1, [], 'one');
accessor(() => true, [], 'true');
accessor(() => false, [], 'false');
var isArray = Array.isArray;
function isObject(_) {
return _ === Object(_);
}
function isString(_) {
return typeof _ === 'string';
}
/*! *****************************************************************************
Copyright (c) Microsoft Corporation.
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
***************************************************************************** */
function __rest(s, e) {
var t = {};
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]];
}
return t;
}
/**
* Format the value to be shown in the tooltip.
*
* @param value The value to show in the tooltip.
* @param valueToHtml Function to convert a single cell value to an HTML string
*/
function formatValue(value, valueToHtml, maxDepth) {
if (isArray(value)) {
return `[${value.map(v => valueToHtml(isString(v) ? v : stringify(v, maxDepth))).join(', ')}]`;
}
if (isObject(value)) {
let content = '';
const _a = value,
{
title,
image
} = _a,
rest = __rest(_a, ["title", "image"]);
if (title) {
content += `<h2>${valueToHtml(title)}</h2>`;
}
if (image) {
content += `<img src="${valueToHtml(image)}">`;
}
const keys = Object.keys(rest);
if (keys.length > 0) {
content += '<table>';
for (const key of keys) {
let val = rest[key]; // ignore undefined properties
if (val === undefined) {
continue;
}
if (isObject(val)) {
val = stringify(val, maxDepth);
}
content += `<tr><td class="key">${valueToHtml(key)}:</td><td class="value">${valueToHtml(val)}</td></tr>`;
}
content += `</table>`;
}
return content || '{}'; // show empty object if there are no properties
}
return valueToHtml(value);
}
function replacer(maxDepth) {
const stack = [];
return function (key, value) {
if (typeof value !== 'object' || value === null) {
return value;
}
const pos = stack.indexOf(this) + 1;
stack.length = pos;
if (stack.length > maxDepth) {
return '[Object]';
}
if (stack.indexOf(value) >= 0) {
return '[Circular]';
}
stack.push(value);
return value;
};
}
/**
* Stringify any JS object to valid JSON
*/
function stringify(obj, maxDepth) {
return JSON.stringify(obj, replacer(maxDepth));
} // generated with build-style.sh
var defaultStyle = `#vg-tooltip-element {
visibility: hidden;
padding: 8px;
position: fixed;
z-index: 1000;
font-family: sans-serif;
font-size: 11px;
border-radius: 3px;
box-shadow: 2px 2px 4px rgba(0, 0, 0, 0.1);
/* The default theme is the light theme. */
background-color: rgba(255, 255, 255, 0.95);
border: 1px solid #d9d9d9;
color: black; }
#vg-tooltip-element.visible {
visibility: visible; }
#vg-tooltip-element h2 {
margin-top: 0;
margin-bottom: 10px;
font-size: 13px; }
#vg-tooltip-element img {
max-width: 200px;
max-height: 200px; }
#vg-tooltip-element table {
border-spacing: 0; }
#vg-tooltip-element table tr {
border: none; }
#vg-tooltip-element table tr td {
overflow: hidden;
text-overflow: ellipsis;
padding-top: 2px;
padding-bottom: 2px; }
#vg-tooltip-element table tr td.key {
color: #808080;
max-width: 150px;
text-align: right;
padding-right: 4px; }
#vg-tooltip-element table tr td.value {
display: block;
max-width: 300px;
max-height: 7em;
text-align: left; }
#vg-tooltip-element.dark-theme {
background-color: rgba(32, 32, 32, 0.9);
border: 1px solid #f5f5f5;
color: white; }
#vg-tooltip-element.dark-theme td.key {
color: #bfbfbf; }
`;
const EL_ID = 'vg-tooltip-element';
const DEFAULT_OPTIONS = {
/**
* X offset.
*/
offsetX: 10,
/**
* Y offset.
*/
offsetY: 10,
/**
* ID of the tooltip element.
*/
id: EL_ID,
/**
* ID of the tooltip CSS style.
*/
styleId: 'vega-tooltip-style',
/**
* The name of the theme. You can use the CSS class called [THEME]-theme to style the tooltips.
*
* There are two predefined themes: "light" (default) and "dark".
*/
theme: 'light',
/**
* Do not use the default styles provided by Vega Tooltip. If you enable this option, you need to use your own styles. It is not necessary to disable the default style when using a custom theme.
*/
disableDefaultStyle: false,
/**
* HTML sanitizer function that removes dangerous HTML to prevent XSS.
*
* This should be a function from string to string. You may replace it with a formatter such as a markdown formatter.
*/
sanitize: escapeHTML,
/**
* The maximum recursion depth when printing objects in the tooltip.
*/
maxDepth: 2,
/**
* A function to customize the rendered HTML of the tooltip.
* @param value A value string, or object of value strings keyed by field
* @param sanitize The `sanitize` function from `options.sanitize`
* @returns {string} The returned string will become the `innerHTML` of the tooltip element
*/
formatTooltip: formatValue
};
/**
* Escape special HTML characters.
*
* @param value A value to convert to string and HTML-escape.
*/
function escapeHTML(value) {
return String(value).replace(/&/g, '&').replace(/</g, '<');
}
function createDefaultStyle(id) {
// Just in case this id comes from a user, ensure these is no security issues
if (!/^[A-Za-z]+[-:.\w]*$/.test(id)) {
throw new Error('Invalid HTML ID');
}
return defaultStyle.toString().replace(EL_ID, id);
}
/**
* Position the tooltip
*
* @param event The mouse event.
* @param tooltipBox
* @param offsetX Horizontal offset.
* @param offsetY Vertical offset.
*/
function calculatePosition(event, tooltipBox, offsetX, offsetY) {
let x = event.clientX + offsetX;
if (x + tooltipBox.width > window.innerWidth) {
x = +event.clientX - offsetX - tooltipBox.width;
}
let y = event.clientY + offsetY;
if (y + tooltipBox.height > window.innerHeight) {
y = +event.clientY - offsetY - tooltipBox.height;
}
return {
x,
y
};
}
/**
* The tooltip handler class.
*/
class Handler {
/**
* Create the tooltip handler and initialize the element and style.
*
* @param options Tooltip Options
*/
constructor(options) {
this.options = Object.assign(Object.assign({}, DEFAULT_OPTIONS), options);
const elementId = this.options.id;
this.el = null; // bind this to call
this.call = this.tooltipHandler.bind(this); // prepend a default stylesheet for tooltips to the head
if (!this.options.disableDefaultStyle && !document.getElementById(this.options.styleId)) {
const style = document.createElement('style');
style.setAttribute('id', this.options.styleId);
style.innerHTML = createDefaultStyle(elementId);
const head = document.head;
if (head.childNodes.length > 0) {
head.insertBefore(style, head.childNodes[0]);
} else {
head.appendChild(style);
}
}
}
/**
* The tooltip handler function.
*/
tooltipHandler(handler, event, item, value) {
// console.log(handler, event, item, value);
var _a; // append a div element that we use as a tooltip unless it already exists
this.el = document.getElementById(this.options.id);
if (!this.el) {
this.el = document.createElement('div');
this.el.setAttribute('id', this.options.id);
this.el.classList.add('vg-tooltip');
document.body.appendChild(this.el);
}
const tooltipContainer = (_a = document.fullscreenElement) !== null && _a !== void 0 ? _a : document.body;
tooltipContainer.appendChild(this.el); // hide tooltip for null, undefined, or empty string values
if (value == null || value === '') {
this.el.classList.remove('visible', `${this.options.theme}-theme`);
return;
} // set the tooltip content
this.el.innerHTML = this.options.formatTooltip(value, this.options.sanitize, this.options.maxDepth); // make the tooltip visible
this.el.classList.add('visible', `${this.options.theme}-theme`);
const {
x,
y
} = calculatePosition(event, this.el.getBoundingClientRect(), this.options.offsetX, this.options.offsetY);
this.el.setAttribute('style', `top: ${y}px; left: ${x}px`);
}
}
/**
* Open editor url in a new window, and pass a message.
*/
function post (window, url, data) {
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
const editor = window.open(url);
const wait = 10000;
const step = 250;
const {
origin
} = new URL(url); // eslint-disable-next-line no-bitwise
let count = ~~(wait / step);
function listen(evt) {
if (evt.source === editor) {
count = 0;
window.removeEventListener('message', listen, false);
}
}
window.addEventListener('message', listen, false); // send message
// periodically resend until ack received or timeout
function send() {
if (count <= 0) {
return;
}
editor.postMessage(data, origin);
setTimeout(send, step);
count -= 1;
}
setTimeout(send, step);
}
// generated with build-style.sh
var embedStyle = `.vega-embed {
position: relative;
display: inline-block;
box-sizing: border-box; }
.vega-embed.has-actions {
padding-right: 38px; }
.vega-embed details:not([open]) > :not(summary) {
display: none !important; }
.vega-embed summary {
list-style: none;
position: absolute;
top: 0;
right: 0;
padding: 6px;
z-index: 1000;
background: white;
box-shadow: 1px 1px 3px rgba(0, 0, 0, 0.1);
color: #1b1e23;
border: 1px solid #aaa;
border-radius: 999px;
opacity: 0.2;
transition: opacity 0.4s ease-in;
outline: none;
cursor: pointer;
line-height: 0px; }
.vega-embed summary::-webkit-details-marker {
display: none; }
.vega-embed summary:active {
box-shadow: #aaa 0px 0px 0px 1px inset; }
.vega-embed summary svg {
width: 14px;
height: 14px; }
.vega-embed details[open] summary {
opacity: 0.7; }
.vega-embed:hover summary,
.vega-embed:focus summary {
opacity: 1 !important;
transition: opacity 0.2s ease; }
.vega-embed .vega-actions {
position: absolute;
z-index: 1001;
top: 35px;
right: -9px;
display: flex;
flex-direction: column;
padding-bottom: 8px;
padding-top: 8px;
border-radius: 4px;
box-shadow: 0 2px 8px 0 rgba(0, 0, 0, 0.2);
border: 1px solid #d9d9d9;
background: white;
animation-duration: 0.15s;
animation-name: scale-in;
animation-timing-function: cubic-bezier(0.2, 0, 0.13, 1.5);
text-align: left; }
.vega-embed .vega-actions a {
padding: 8px 16px;
font-family: sans-serif;
font-size: 14px;
font-weight: 600;
white-space: nowrap;
color: #434a56;
text-decoration: none; }
.vega-embed .vega-actions a:hover {
background-color: #f7f7f9;
color: black; }
.vega-embed .vega-actions::before, .vega-embed .vega-actions::after {
content: "";
display: inline-block;
position: absolute; }
.vega-embed .vega-actions::before {
left: auto;
right: 14px;
top: -16px;
border: 8px solid #0000;
border-bottom-color: #d9d9d9; }
.vega-embed .vega-actions::after {
left: auto;
right: 15px;
top: -14px;
border: 7px solid #0000;
border-bottom-color: #fff; }
.vega-embed .chart-wrapper.fit-x {
width: 100%; }
.vega-embed .chart-wrapper.fit-y {
height: 100%; }
.vega-embed-wrapper {
max-width: 100%;
overflow: auto;
padding-right: 14px; }
@keyframes scale-in {
from {
opacity: 0;
transform: scale(0.6); }
to {
opacity: 1;
transform: scale(1); } }
`;
if (!String.prototype.startsWith) {
// eslint-disable-next-line no-extend-native,func-names
String.prototype.startsWith = function (search, pos) {
return this.substr(!pos || pos < 0 ? 0 : +pos, search.length) === search;
};
}
function isURL(s) {
return s.startsWith('http://') || s.startsWith('https://') || s.startsWith('//');
}
function mergeDeep(dest, ...src) {
for (const s of src) {
deepMerge_(dest, s);
}
return dest;
}
function deepMerge_(dest, src) {
for (const property of Object.keys(src)) {
vegaImport.writeConfig(dest, property, src[property], true);
}
}
var name = "vega-embed";
var version$1 = "6.20.0-next.0";
var description = "Publish Vega visualizations as embedded web components.";
var keywords = ["vega", "data", "visualization", "component", "embed"];
var repository = {
type: "git",
url: "http://github.com/vega/vega-embed.git"
};
var author = {
name: "UW Interactive Data Lab",
url: "http://idl.cs.washington.edu"
};
var contributors = [{
name: "Dominik Moritz",
url: "https://www.domoritz.de"
}];
var bugs = {
url: "https://github.com/vega/vega-embed/issues"
};
var homepage = "https://github.com/vega/vega-embed#readme";
var license = "BSD-3-Clause";
var main = "build/vega-embed.js";
var module = "build/vega-embed.module.js";
var unpkg = "build/vega-embed.min.js";
var jsdelivr = "build/vega-embed.min.js";
var types = "build/vega-embed.module.d.ts";
var files = ["src", "build", "build-es5"];
var devDependencies = {
"@auto-it/conventional-commits": "^10.32.0",
"@auto-it/first-time-contributor": "^10.32.0",
"@rollup/plugin-commonjs": "21.0.1",
"@rollup/plugin-json": "^4.1.0",
"@rollup/plugin-node-resolve": "^13.0.4",
"@types/semver": "^7.3.8",
"@wessberg/rollup-plugin-ts": "^1.3.14",
auto: "^10.32.0",
"browser-sync": "^2.27.5",
concurrently: "^6.2.1",
"del-cli": "^4.0.1",
"jest-canvas-mock": "^2.3.1",
"node-sass": "^6.0.1",
"rollup-plugin-bundle-size": "^1.0.3",
"rollup-plugin-terser": "^7.0.2",
rollup: "2.58.1",
typescript: "^4.4.3",
"vega-lite-dev-config": "^0.18.0",
"vega-lite": "^5.0.0",
vega: "^5.19.1"
};
var peerDependencies = {
vega: "^5.20.2",
"vega-lite": "*"
};
var dependencies = {
"fast-json-patch": "^3.1.0",
"json-stringify-pretty-compact": "^3.0.0",
semver: "^7.3.5",
tslib: "^2.3.1",
"vega-interpreter": "^1.0.4",
"vega-schema-url-parser": "^2.2.0",
"vega-themes": "^2.10.0",
"vega-tooltip": "^0.27.0"
};
var scripts = {
prebuild: "yarn clean && yarn build:style",
build: "rollup -c",
"build:style": "./build-style.sh",
clean: "del-cli build build-es5 src/style.ts",
prepublishOnly: "yarn clean && yarn build",
preversion: "yarn lint && yarn test",
serve: "browser-sync start --directory -s -f build *.html",
start: "yarn build && concurrently --kill-others -n Server,Rollup 'yarn serve' 'rollup -c -w'",
pretest: "yarn build:style",
test: "beemo jest --stdio stream",
"test:inspect": "node --inspect-brk ./node_modules/.bin/jest --runInBand",
prepare: "beemo create-config",
prettierbase: "beemo prettier '*.{css,scss,html}'",
eslintbase: "beemo eslint .",
format: "yarn eslintbase --fix && yarn prettierbase --write",
lint: "yarn eslintbase && yarn prettierbase --check",
release: "auto shipit"
};
var pkg = {
name: name,
version: version$1,
description: description,
keywords: keywords,
repository: repository,
author: author,
contributors: contributors,
bugs: bugs,
homepage: homepage,
license: license,
main: main,
module: module,
unpkg: unpkg,
jsdelivr: jsdelivr,
types: types,
files: files,
devDependencies: devDependencies,
peerDependencies: peerDependencies,
dependencies: dependencies,
scripts: scripts
};
var _w$vl;
const version = pkg.version;
const vega = vegaImport__namespace;
let vegaLite = vegaLiteImport__namespace; // For backwards compatibility with Vega-Lite before v4.
const w = typeof window !== 'undefined' ? window : undefined;
if (vegaLite === undefined && w !== null && w !== void 0 && (_w$vl = w['vl']) !== null && _w$vl !== void 0 && _w$vl.compile) {
vegaLite = w['vl'];
}
const DEFAULT_ACTIONS = {
export: {
svg: true,
png: true
},
source: true,
compiled: true,
editor: true
};
const I18N = {
CLICK_TO_VIEW_ACTIONS: 'Click to view actions',
COMPILED_ACTION: 'View Compiled Vega',
EDITOR_ACTION: 'Open in Vega Editor',
PNG_ACTION: 'Save as PNG',
SOURCE_ACTION: 'View Source',
SVG_ACTION: 'Save as SVG'
};
const NAMES = {
vega: 'Vega',
'vega-lite': 'Vega-Lite'
};
const VERSION = {
vega: vega.version,
'vega-lite': vegaLite ? vegaLite.version : 'not available'
};
const PREPROCESSOR = {
vega: vgSpec => vgSpec,
'vega-lite': (vlSpec, config) => vegaLite.compile(vlSpec, {
config: config
}).spec
};
const SVG_CIRCLES = `
<svg viewBox="0 0 16 16" fill="currentColor" stroke="none" stroke-width="1" stroke-linecap="round" stroke-linejoin="round">
<circle r="2" cy="8" cx="2"></circle>
<circle r="2" cy="8" cx="8"></circle>
<circle r="2" cy="8" cx="14"></circle>
</svg>`;
const CHART_WRAPPER_CLASS = 'chart-wrapper';
function isTooltipHandler(h) {
return typeof h === 'function';
}
function viewSource(source, sourceHeader, sourceFooter, mode) {
const header = `<html><head>${sourceHeader}</head><body><pre><code class="json">`;
const footer = `</code></pre>${sourceFooter}</body></html>`; // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
const win = window.open('');
win.document.write(header + source + footer);
win.document.title = `${NAMES[mode]} JSON Source`;
}
/**
* Try to guess the type of spec.
*
* @param spec Vega or Vega-Lite spec.
*/
function guessMode(spec, providedMode) {
// Decide mode
if (spec.$schema) {
const parsed = e(spec.$schema);
if (providedMode && providedMode !== parsed.library) {
var _NAMES$providedMode;
console.warn(`The given visualization spec is written in ${NAMES[parsed.library]}, but mode argument sets ${(_NAMES$providedMode = NAMES[providedMode]) !== null && _NAMES$providedMode !== void 0 ? _NAMES$providedMode : providedMode}.`);
}
const mode = parsed.library;
if (!semver.satisfies(VERSION[mode], `^${parsed.version.slice(1)}`)) {
console.warn(`The input spec uses ${NAMES[mode]} ${parsed.version}, but the current version of ${NAMES[mode]} is v${VERSION[mode]}.`);
}
return mode;
} // try to guess from the provided spec
if ('mark' in spec || 'encoding' in spec || 'layer' in spec || 'hconcat' in spec || 'vconcat' in spec || 'facet' in spec || 'repeat' in spec) {
return 'vega-lite';
}
if ('marks' in spec || 'signals' in spec || 'scales' in spec || 'axes' in spec) {
return 'vega';
}
return providedMode !== null && providedMode !== void 0 ? providedMode : 'vega';
}
function isLoader(o) {
return !!(o && 'load' in o);
}
function createLoader(opts) {
return isLoader(opts) ? opts : vega.loader(opts);
}
function embedOptionsFromUsermeta(parsedSpec) {
var _ref;
return (_ref = parsedSpec.usermeta && parsedSpec.usermeta['embedOptions']) !== null && _ref !== void 0 ? _ref : {};
}
/**
* Embed a Vega visualization component in a web page. This function returns a promise.
*
* @param el DOM element in which to place component (DOM node or CSS selector).
* @param spec String : A URL string from which to load the Vega specification.
* Object : The Vega/Vega-Lite specification as a parsed JSON object.
* @param opts A JavaScript object containing options for embedding.
*/
async function embed(el, spec, opts = {}) {
var _parsedOpts$config, _usermetaOpts$config;
let parsedSpec;
let loader;
if (vegaImport.isString(spec)) {
loader = createLoader(opts.loader);
parsedSpec = JSON.parse(await loader.load(spec));
} else {
parsedSpec = spec;
}
const usermetaLoader = embedOptionsFromUsermeta(parsedSpec).loader; // either create the loader for the first time or create a new loader if the spec has new loader options
if (!loader || usermetaLoader) {
var _opts$loader;
loader = createLoader((_opts$loader = opts.loader) !== null && _opts$loader !== void 0 ? _opts$loader : usermetaLoader);
}
const usermetaOpts = await loadOpts(embedOptionsFromUsermeta(parsedSpec), loader);
const parsedOpts = await loadOpts(opts, loader);
const mergedOpts = { ...mergeDeep(parsedOpts, usermetaOpts),
config: vegaImport.mergeConfig((_parsedOpts$config = parsedOpts.config) !== null && _parsedOpts$config !== void 0 ? _parsedOpts$config : {}, (_usermetaOpts$config = usermetaOpts.config) !== null && _usermetaOpts$config !== void 0 ? _usermetaOpts$config : {})
};
return await _embed(el, parsedSpec, mergedOpts, loader);
}
async function loadOpts(opt, loader) {
var _opt$config;
const config = vegaImport.isString(opt.config) ? JSON.parse(await loader.load(opt.config)) : (_opt$config = opt.config) !== null && _opt$config !== void 0 ? _opt$config : {};
const patch = vegaImport.isString(opt.patch) ? JSON.parse(await loader.load(opt.patch)) : opt.patch;
return { ...opt,
...(patch ? {
patch
} : {}),
...(config ? {
config
} : {})
};
}
function getRoot(el) {
const possibleRoot = el.getRootNode ? el.getRootNode() : document;
if (possibleRoot instanceof ShadowRoot) {
return {
root: possibleRoot,
rootContainer: possibleRoot
};
} else {
var _document$head;
return {
root: document,
rootContainer: (_document$head = document.head) !== null && _document$head !== void 0 ? _document$head : document.body
};
}
}
async function _embed(el, spec, opts = {}, loader) {
var _opts$config, _opts$actions, _opts$renderer, _opts$logLevel, _opts$downloadFileNam, _ref2, _vega$expressionInter;
const config = opts.theme ? vegaImport.mergeConfig(themes[opts.theme], (_opts$config = opts.config) !== null && _opts$config !== void 0 ? _opts$config : {}) : opts.config;
const actions = vegaImport.isBoolean(opts.actions) ? opts.actions : mergeDeep({}, DEFAULT_ACTIONS, (_opts$actions = opts.actions) !== null && _opts$actions !== void 0 ? _opts$actions : {});
const i18n = { ...I18N,
...opts.i18n
};
const renderer = (_opts$renderer = opts.renderer) !== null && _opts$renderer !== void 0 ? _opts$renderer : 'canvas';
const logLevel = (_opts$logLevel = opts.logLevel) !== null && _opts$logLevel !== void 0 ? _opts$logLevel : vega.Warn;
const downloadFileName = (_opts$downloadFileNam = opts.downloadFileName) !== null && _opts$downloadFileNam !== void 0 ? _opts$downloadFileNam : 'visualization';
const element = typeof el === 'string' ? document.querySelector(el) : el;
if (!element) {
throw new Error(`${el} does not exist`);
}
if (opts.defaultStyle !== false) {
// Add a default stylesheet to the head of the document.
const ID = 'vega-embed-style';
const {
root,
rootContainer
} = getRoot(element);
if (!root.getElementById(ID)) {
const style = document.createElement('style');
style.id = ID;
style.innerText = opts.defaultStyle === undefined || opts.defaultStyle === true ? (embedStyle ).toString() : opts.defaultStyle;
rootContainer.appendChild(style);
}
}
const mode = guessMode(spec, opts.mode);
let vgSpec = PREPROCESSOR[mode](spec, config);
if (mode === 'vega-lite') {
if (vgSpec.$schema) {
const parsed = e(vgSpec.$schema);
if (!semver.satisfies(VERSION.vega, `^${parsed.version.slice(1)}`)) {
console.warn(`The compiled spec uses Vega ${parsed.version}, but current version is v${VERSION.vega}.`);
}
}
}
element.classList.add('vega-embed');
if (actions) {
element.classList.add('has-actions');
}
element.innerHTML = ''; // clear container
let container = element;
if (actions) {
const chartWrapper = document.createElement('div');
chartWrapper.classList.add(CHART_WRAPPER_CLASS);
element.appendChild(chartWrapper);
container = chartWrapper;
}
const patch = opts.patch;
if (patch) {
if (patch instanceof Function) {
vgSpec = patch(vgSpec);
} else {
vgSpec = applyPatch(vgSpec, patch, true, false).newDocument;
}
} // Set locale. Note that this is a global setting.
if (opts.formatLocale) {
vega.formatLocale(opts.formatLocale);
}
if (opts.timeFormatLocale) {
vega.timeFormatLocale(opts.timeFormatLocale);
}
const {
ast
} = opts; // Do not apply the config to Vega when we have already applied it to Vega-Lite.
// This call may throw an Error if parsing fails.
const runtime = vega.parse(vgSpec, mode === 'vega-lite' ? {} : config, {
ast
});
const view = new (opts.viewClass || vega.View)(runtime, {
loader,
logLevel,
renderer,
...(ast ? {
expr: (_ref2 = (_vega$expressionInter = vega.expressionInterpreter) !== null && _vega$expressionInter !== void 0 ? _vega$expressionInter : opts.expr) !== null && _ref2 !== void 0 ? _ref2 : expression
} : {})
});
view.addSignalListener('autosize', (_, autosize) => {
const {
type
} = autosize;
if (type == 'fit-x') {
container.classList.add('fit-x');
container.classList.remove('fit-y');
} else if (type == 'fit-y') {
container.classList.remove('fit-x');
container.classList.add('fit-y');
} else if (type == 'fit') {
container.classList.add('fit-x', 'fit-y');
} else {
container.classList.remove('fit-x', 'fit-y');
}
});
if (opts.tooltip !== false) {
let handler;
if (isTooltipHandler(opts.tooltip)) {
handler = opts.tooltip;
} else {
// user provided boolean true or tooltip options
handler = new Handler(opts.tooltip === true ? {} : opts.tooltip).call;
}
view.tooltip(handler);
}
let {
hover
} = opts;
if (hover === undefined) {
hover = mode === 'vega';
}
if (hover) {
const {
hoverSet,
updateSet
} = typeof hover === 'boolean' ? {} : hover;
view.hover(hoverSet, updateSet);
}
if (opts) {
if (opts.width != null) {
view.width(opts.width);
}
if (opts.height != null) {
view.height(opts.height);
}
if (opts.padding != null) {
view.padding(opts.padding);
}
}
await view.initialize(container, opts.bind).runAsync();
let documentClickHandler;
if (actions !== false) {
let wrapper = element;
if (opts.defaultStyle !== false) {
const details = document.createElement('details');
details.title = i18n.CLICK_TO_VIEW_ACTIONS;
element.append(details);
wrapper = details;
const summary = document.createElement('summary');
summary.innerHTML = SVG_CIRCLES;
details.append(summary);
documentClickHandler = ev => {
if (!details.contains(ev.target)) {
details.removeAttribute('open');
}
};
document.addEventListener('click', documentClickHandler);
}
const ctrl = document.createElement('div');
wrapper.append(ctrl);
ctrl.classList.add('vega-actions'); // add 'Export' action
if (actions === true || actions.export !== false) {
for (const ext of ['svg', 'png']) {
if (actions === true || actions.export === true || actions.export[ext]) {
const i18nExportAction = i18n[`${ext.toUpperCase()}_ACTION`];
const exportLink = document.createElement('a');
exportLink.text = i18nExportAction;
exportLink.href = '#';
exportLink.target = '_blank';
exportLink.download = `${downloadFileName}.${ext}`; // add link on mousedown so that it's correct when the click happens
exportLink.addEventListener('mousedown', async function (e) {
e.preventDefault();
const url = await view.toImageURL(ext, opts.scaleFactor);
this.href = url;
});
ctrl.append(exportLink);
}
}
} // add 'View Source' action
if (actions === true || actions.source !== false) {
const viewSourceLink = document.createElement('a');
viewSourceLink.text = i18n.SOURCE_ACTION;
viewSourceLink.href = '#';
viewSourceLink.addEventListener('click', function (e) {
var _opts$sourceHeader, _opts$sourceFooter;
viewSource(jsonStringifyPrettyCompact(spec), (_opts$sourceHeader = opts.sourceHeader) !== null && _opts$sourceHeader !== void 0 ? _opts$sourceHeader : '', (_opts$sourceFooter = opts.sourceFooter) !== null && _opts$sourceFooter !== void 0 ? _opts$sourceFooter : '', mode);
e.preventDefault();
});
ctrl.append(viewSourceLink);
} // add 'View Compiled' action
if (mode === 'vega-lite' && (actions === true || actions.compiled !== false)) {
const compileLink = document.createElement('a');
compileLink.text = i18n.COMPILED_ACTION;
compileLink.href = '#';
compileLink.addEventListener('click', function (e) {
var _opts$sourceHeader2, _opts$sourceFooter2;
viewSource(jsonStringifyPrettyCompact(vgSpec), (_opts$sourceHeader2 = opts.sourceHeader) !== null && _opts$sourceHeader2 !== void 0 ? _opts$sourceHeader2 : '', (_opts$sourceFooter2 = opts.sourceFooter) !== null && _opts$sourceFooter2 !== void 0 ? _opts$sourceFooter2 : '', 'vega');
e.preventDefault();
});
ctrl.append(compileLink);
} // add 'Open in Vega Editor' action
if (actions === true || actions.editor !== false) {
var _opts$editorUrl;
const editorUrl = (_opts$editorUrl = opts.editorUrl) !== null && _opts$editorUrl !== void 0 ? _opts$editorUrl : 'https://vega.github.io/editor/';
const editorLink = document.createElement('a');
editorLink.text = i18n.EDITOR_ACTION;
editorLink.href = '#';
editorLink.addEventListener('click', function (e) {
post(window, editorUrl, {
config: config,
mode,
renderer,
spec: jsonStringifyPrettyCompact(spec)
});
e.preventDefault();
});
ctrl.append(editorLink);
}
}
function finalize() {
if (documentClickHandler) {
document.removeEventListener('click', documentClickHandler);
}
view.finalize();
}
return {
view,
spec,
vgSpec,
finalize
};
}
/**
* Create a promise to an HTML Div element with an embedded Vega-Lite or Vega visualization.
* The element has a value property with the view. By default all actions except for the editor action are disabled.
*
* The main use case is in [Observable](https://observablehq.com/).
*/
async function container (spec, opt = {}) {
var _opt$actions;
const wrapper = document.createElement('div');
wrapper.classList.add('vega-embed-wrapper');
const div = document.createElement('div');
wrapper.appendChild(div);
const actions = opt.actions === true || opt.actions === false ? opt.actions : {
export: true,
source: false,
compiled: true,
editor: true,
...((_opt$actions = opt.actions) !== null && _opt$actions !== void 0 ? _opt$actions : {})
};
const result = await embed(div, spec, {
actions,
...(opt !== null && opt !== void 0 ? opt : {})
});
wrapper.value = result.view;
return wrapper;
}
/**
* Returns true if the object is an HTML element.
*/
function isElement(obj) {
return obj instanceof HTMLElement;
}
const wrapper = (...args) => {
if (args.length > 1 && (vegaImport.isString(args[0]) && !isURL(args[0]) || isElement(args[0]) || args.length === 3)) {
return embed(args[0], args[1], args[2]);
}
return container(args[0], args[1]);
};
wrapper.vegaLite = vegaLite;
wrapper.vl = vegaLite; // backwards compatibility
wrapper.container = container;
wrapper.embed = embed;
wrapper.vega = vega;
wrapper.default = embed;
wrapper.version = version;
return wrapper;
}));
//# sourceMappingURL=vega-embed.js.map
| cdnjs/cdnjs | ajax/libs/vega-embed/6.20.0-next.0/vega-embed.js | JavaScript | mit | 182,412 | [
30522,
1006,
3853,
1006,
3795,
1010,
4713,
1007,
1063,
2828,
11253,
14338,
1027,
1027,
1027,
1005,
4874,
1005,
1004,
1004,
2828,
11253,
11336,
999,
1027,
1027,
1005,
6151,
28344,
1005,
1029,
11336,
1012,
14338,
1027,
4713,
1006,
5478,
1006,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Routing\Generator;
use Symfony\Component\Routing\RouteCollection;
use Symfony\Component\Routing\RequestContext;
use Symfony\Component\Routing\Exception\InvalidParameterException;
use Symfony\Component\Routing\Exception\RouteNotFoundException;
use Symfony\Component\Routing\Exception\MissingMandatoryParametersException;
use Psr\Log\LoggerInterface;
/**
* UrlGenerator can generate a URL or a path for any route in the RouteCollection
* based on the passed parameters.
*
* @author Fabien Potencier <fabien@symfony.com>
* @author Tobias Schultze <http://tobion.de>
*/
class UrlGenerator implements UrlGeneratorInterface, ConfigurableRequirementsInterface
{
protected $routes;
protected $context;
/**
* @var bool|null
*/
protected $strictRequirements = true;
protected $logger;
/**
* This array defines the characters (besides alphanumeric ones) that will not be percent-encoded in the path segment of the generated URL.
*
* PHP's rawurlencode() encodes all chars except "a-zA-Z0-9-._~" according to RFC 3986. But we want to allow some chars
* to be used in their literal form (reasons below). Other chars inside the path must of course be encoded, e.g.
* "?" and "#" (would be interpreted wrongly as query and fragment identifier),
* "'" and """ (are used as delimiters in HTML).
*/
protected $decodedChars = array(
// the slash can be used to designate a hierarchical structure and we want allow using it with this meaning
// some webservers don't allow the slash in encoded form in the path for security reasons anyway
// see http://stackoverflow.com/questions/4069002/http-400-if-2f-part-of-get-url-in-jboss
'%2F' => '/',
// the following chars are general delimiters in the URI specification but have only special meaning in the authority component
// so they can safely be used in the path in unencoded form
'%40' => '@',
'%3A' => ':',
// these chars are only sub-delimiters that have no predefined meaning and can therefore be used literally
// so URI producing applications can use these chars to delimit subcomponents in a path segment without being encoded for better readability
'%3B' => ';',
'%2C' => ',',
'%3D' => '=',
'%2B' => '+',
'%21' => '!',
'%2A' => '*',
'%7C' => '|',
);
public function __construct(RouteCollection $routes, RequestContext $context, LoggerInterface $logger = null)
{
$this->routes = $routes;
$this->context = $context;
$this->logger = $logger;
}
/**
* {@inheritdoc}
*/
public function setContext(RequestContext $context)
{
$this->context = $context;
}
/**
* {@inheritdoc}
*/
public function getContext()
{
return $this->context;
}
/**
* {@inheritdoc}
*/
public function setStrictRequirements($enabled)
{
$this->strictRequirements = null === $enabled ? null : (bool) $enabled;
}
/**
* {@inheritdoc}
*/
public function isStrictRequirements()
{
return $this->strictRequirements;
}
/**
* {@inheritdoc}
*/
public function generate($name, $parameters = array(), $referenceType = self::ABSOLUTE_PATH)
{
if (null === $route = $this->routes->get($name)) {
throw new RouteNotFoundException(sprintf('Unable to generate a URL for the named route "%s" as such route does not exist.', $name));
}
// the Route has a cache of its own and is not recompiled as long as it does not get modified
$compiledRoute = $route->compile();
return $this->doGenerate($compiledRoute->getVariables(), $route->getDefaults(), $route->getRequirements(), $compiledRoute->getTokens(), $parameters, $name, $referenceType, $compiledRoute->getHostTokens(), $route->getSchemes());
}
/**
* @throws MissingMandatoryParametersException When some parameters are missing that are mandatory for the route
* @throws InvalidParameterException When a parameter value for a placeholder is not correct because
* it does not match the requirement
*/
protected function doGenerate($variables, $defaults, $requirements, $tokens, $parameters, $name, $referenceType, $hostTokens, array $requiredSchemes = array())
{
if (is_bool($referenceType) || is_string($referenceType)) {
@trigger_error('The hardcoded value you are using for the $referenceType argument of the '.__CLASS__.'::generate method is deprecated since version 2.8 and will not be supported anymore in 3.0. Use the constants defined in the UrlGeneratorInterface instead.', E_USER_DEPRECATED);
if (true === $referenceType) {
$referenceType = self::ABSOLUTE_URL;
} elseif (false === $referenceType) {
$referenceType = self::ABSOLUTE_PATH;
} elseif ('relative' === $referenceType) {
$referenceType = self::RELATIVE_PATH;
} elseif ('network' === $referenceType) {
$referenceType = self::NETWORK_PATH;
}
}
$variables = array_flip($variables);
$mergedParams = array_replace($defaults, $this->context->getParameters(), $parameters);
// all params must be given
if ($diff = array_diff_key($variables, $mergedParams)) {
throw new MissingMandatoryParametersException(sprintf('Some mandatory parameters are missing ("%s") to generate a URL for route "%s".', implode('", "', array_keys($diff)), $name));
}
$url = '';
$optional = true;
foreach ($tokens as $token) {
if ('variable' === $token[0]) {
if (!$optional || !array_key_exists($token[3], $defaults) || null !== $mergedParams[$token[3]] && (string) $mergedParams[$token[3]] !== (string) $defaults[$token[3]]) {
// check requirement
if (null !== $this->strictRequirements && !preg_match('#^'.$token[2].'$#', $mergedParams[$token[3]])) {
$message = sprintf('Parameter "%s" for route "%s" must match "%s" ("%s" given) to generate a corresponding URL.', $token[3], $name, $token[2], $mergedParams[$token[3]]);
if ($this->strictRequirements) {
throw new InvalidParameterException($message);
}
if ($this->logger) {
$this->logger->error($message);
}
return;
}
$url = $token[1].$mergedParams[$token[3]].$url;
$optional = false;
}
} else {
// static text
$url = $token[1].$url;
$optional = false;
}
}
if ('' === $url) {
$url = '/';
}
// the contexts base URL is already encoded (see Symfony\Component\HttpFoundation\Request)
$url = strtr(rawurlencode($url), $this->decodedChars);
// the path segments "." and ".." are interpreted as relative reference when resolving a URI; see http://tools.ietf.org/html/rfc3986#section-3.3
// so we need to encode them as they are not used for this purpose here
// otherwise we would generate a URI that, when followed by a user agent (e.g. browser), does not match this route
$url = strtr($url, array('/../' => '/%2E%2E/', '/./' => '/%2E/'));
if ('/..' === substr($url, -3)) {
$url = substr($url, 0, -2).'%2E%2E';
} elseif ('/.' === substr($url, -2)) {
$url = substr($url, 0, -1).'%2E';
}
$schemeAuthority = '';
if ($host = $this->context->getHost()) {
$scheme = $this->context->getScheme();
if ($requiredSchemes) {
if (!in_array($scheme, $requiredSchemes, true)) {
$referenceType = self::ABSOLUTE_URL;
$scheme = current($requiredSchemes);
}
} elseif (isset($requirements['_scheme']) && ($req = strtolower($requirements['_scheme'])) && $scheme !== $req) {
// We do this for BC; to be removed if _scheme is not supported anymore
$referenceType = self::ABSOLUTE_URL;
$scheme = $req;
}
if ($hostTokens) {
$routeHost = '';
foreach ($hostTokens as $token) {
if ('variable' === $token[0]) {
if (null !== $this->strictRequirements && !preg_match('#^'.$token[2].'$#i', $mergedParams[$token[3]])) {
$message = sprintf('Parameter "%s" for route "%s" must match "%s" ("%s" given) to generate a corresponding URL.', $token[3], $name, $token[2], $mergedParams[$token[3]]);
if ($this->strictRequirements) {
throw new InvalidParameterException($message);
}
if ($this->logger) {
$this->logger->error($message);
}
return;
}
$routeHost = $token[1].$mergedParams[$token[3]].$routeHost;
} else {
$routeHost = $token[1].$routeHost;
}
}
if ($routeHost !== $host) {
$host = $routeHost;
if (self::ABSOLUTE_URL !== $referenceType) {
$referenceType = self::NETWORK_PATH;
}
}
}
if (self::ABSOLUTE_URL === $referenceType || self::NETWORK_PATH === $referenceType) {
$port = '';
if ('http' === $scheme && 80 != $this->context->getHttpPort()) {
$port = ':'.$this->context->getHttpPort();
} elseif ('https' === $scheme && 443 != $this->context->getHttpsPort()) {
$port = ':'.$this->context->getHttpsPort();
}
$schemeAuthority = self::NETWORK_PATH === $referenceType ? '//' : "$scheme://";
$schemeAuthority .= $host.$port;
}
}
if (self::RELATIVE_PATH === $referenceType) {
$url = self::getRelativePath($this->context->getPathInfo(), $url);
} else {
$url = $schemeAuthority.$this->context->getBaseUrl().$url;
}
// add a query string if needed
$extra = array_udiff_assoc(array_diff_key($parameters, $variables), $defaults, function ($a, $b) {
return $a == $b ? 0 : 1;
});
if ($extra && $query = http_build_query($extra, '', '&')) {
// "/" and "?" can be left decoded for better user experience, see
// http://tools.ietf.org/html/rfc3986#section-3.4
$url .= '?'.strtr($query, array('%2F' => '/'));
}
return $url;
}
/**
* Returns the target path as relative reference from the base path.
*
* Only the URIs path component (no schema, host etc.) is relevant and must be given, starting with a slash.
* Both paths must be absolute and not contain relative parts.
* Relative URLs from one resource to another are useful when generating self-contained downloadable document archives.
* Furthermore, they can be used to reduce the link size in documents.
*
* Example target paths, given a base path of "/a/b/c/d":
* - "/a/b/c/d" -> ""
* - "/a/b/c/" -> "./"
* - "/a/b/" -> "../"
* - "/a/b/c/other" -> "other"
* - "/a/x/y" -> "../../x/y"
*
* @param string $basePath The base path
* @param string $targetPath The target path
*
* @return string The relative target path
*/
public static function getRelativePath($basePath, $targetPath)
{
if ($basePath === $targetPath) {
return '';
}
$sourceDirs = explode('/', isset($basePath[0]) && '/' === $basePath[0] ? substr($basePath, 1) : $basePath);
$targetDirs = explode('/', isset($targetPath[0]) && '/' === $targetPath[0] ? substr($targetPath, 1) : $targetPath);
array_pop($sourceDirs);
$targetFile = array_pop($targetDirs);
foreach ($sourceDirs as $i => $dir) {
if (isset($targetDirs[$i]) && $dir === $targetDirs[$i]) {
unset($sourceDirs[$i], $targetDirs[$i]);
} else {
break;
}
}
$targetDirs[] = $targetFile;
$path = str_repeat('../', count($sourceDirs)).implode('/', $targetDirs);
// A reference to the same base directory or an empty subdirectory must be prefixed with "./".
// This also applies to a segment with a colon character (e.g., "file:colon") that cannot be used
// as the first segment of a relative-path reference, as it would be mistaken for a scheme name
// (see http://tools.ietf.org/html/rfc3986#section-4.2).
return '' === $path || '/' === $path[0]
|| false !== ($colonPos = strpos($path, ':')) && ($colonPos < ($slashPos = strpos($path, '/')) || false === $slashPos)
? "./$path" : $path;
}
}
| BaderLab/openPIP | vendor/symfony/symfony/src/Symfony/Component/Routing/Generator/UrlGenerator.php | PHP | mit | 13,796 | [
30522,
1026,
1029,
25718,
1013,
1008,
1008,
2023,
5371,
2003,
2112,
1997,
1996,
25353,
2213,
14876,
4890,
7427,
1012,
1008,
1008,
1006,
1039,
1007,
6904,
11283,
2078,
8962,
2368,
19562,
1026,
6904,
11283,
2078,
1030,
25353,
2213,
14876,
489... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
/* pcapio.h
* Declarations of our own routins for writing libpcap files.
*
* $Id$
*
* Wireshark - Network traffic analyzer
* By Gerald Combs <gerald@wireshark.org>
* Copyright 1998 Gerald Combs
*
* Derived from code in the Wiretap Library
* Copyright (c) 1998 by Gilbert Ramirez <gram@alumni.rice.edu>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
/** Returns a FILE * to write to on success, NULL on failure */
extern FILE *
libpcap_fdopen(int fd, int *err);
/** Write the file header to a dump file.
Returns TRUE on success, FALSE on failure.
Sets "*err" to an error code, or 0 for a short write, on failure*/
extern gboolean
libpcap_write_file_header(FILE *fp, int linktype, int snaplen, gboolean ts_nsecs, long *bytes_written, int *err);
/** Write a record for a packet to a dump file.
Returns TRUE on success, FALSE on failure. */
extern gboolean
libpcap_write_packet(FILE *fp, const struct pcap_pkthdr *phdr, const u_char *pd,
long *bytes_written, int *err);
/** Write a section header block (SHB)
*
*/
extern gboolean
libpcap_write_session_header_block(FILE *fp, /**< File pointer */
const char *comment, /**< Comment on the section, Optinon 1 opt_comment
* A UTF-8 string containing a comment that is associated to the current block.
*/
const char *hw, /**< HW, Optinon 2 shb_hardware
* An UTF-8 string containing the description of the hardware used to create this section.
*/
const char *os, /**< Operating system name, Optinon 3 shb_os
* An UTF-8 string containing the name of the operating system used to create this section.
*/
const char *appname, /**< Application name, Optinon 4 shb_userappl
* An UTF-8 string containing the name of the application used to create this section.
*/
guint64 section_length,
long *bytes_written,
int *err);
extern gboolean
libpcap_write_interface_description_block(FILE *fp,
const char *comment, /* OPT_COMMENT 1 */
const char *name, /* IDB_NAME 2 */
const char *descr, /* IDB_DESCRIPTION 3 */
const char *filter, /* IDB_FILTER 11 */
const char *os, /* IDB_OS 12 */
int link_type,
int snap_len,
long *bytes_written,
guint64 if_speed, /* IDB_IF_SPEED 8 */
guint8 tsresol, /* IDB_TSRESOL 9 */
int *err);
extern gboolean
libpcap_write_interface_statistics_block(FILE *fp,
guint32 interface_id,
pcap_t *pd,
long *bytes_written,
const char *comment, /* OPT_COMMENT 1 */
guint64 isb_starttime, /* ISB_STARTTIME 2 */
guint64 isb_endtime, /* ISB_ENDTIME 3 */
int *err);
extern gboolean
libpcap_write_enhanced_packet_block(FILE *fp,
const struct pcap_pkthdr *phdr,
guint32 interface_id,
guint ts_mul,
const u_char *pd,
long *bytes_written,
int *err);
extern gboolean
libpcap_dump_flush(FILE *pd, int *err);
extern gboolean
libpcap_dump_close(FILE *pd, int *err);
| giuliano108/wireshark-rtpmon | pcapio.h | C | gpl-2.0 | 5,236 | [
30522,
1013,
1008,
7473,
9331,
3695,
1012,
1044,
1008,
8170,
2015,
1997,
2256,
2219,
20996,
21823,
3619,
2005,
3015,
5622,
2497,
15042,
9331,
6764,
1012,
1008,
1008,
1002,
8909,
1002,
1008,
1008,
14666,
8167,
2243,
1011,
2897,
4026,
17908,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
#!/usr/bin/env python
#
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
from setuptools import setup
DESC = """Installer for Apache Bloodhound
Adds the bloodhound_setup cli command.
"""
versions = [
(0, 8, 0),
(0, 9, 0),
]
latest = '.'.join(str(x) for x in versions[-1])
setup(
name="bloodhound_installer",
version=latest,
description=DESC.split('\n', 1)[0],
author="Apache Bloodhound",
license="Apache License v2",
url="https://bloodhound.apache.org/",
requires=['trac', 'BloodhoundMultiProduct'],
packages=['bhsetup'],
entry_points="""
[console_scripts]
bloodhound_setup = bhsetup.bloodhound_setup:run
""",
long_description=DESC,
)
| apache/bloodhound | installer/setup.py | Python | apache-2.0 | 1,462 | [
30522,
1001,
999,
1013,
2149,
2099,
1013,
8026,
1013,
4372,
2615,
18750,
1001,
1001,
7000,
2000,
1996,
15895,
4007,
3192,
1006,
2004,
2546,
1007,
2104,
2028,
1001,
2030,
2062,
12130,
6105,
10540,
1012,
2156,
1996,
5060,
5371,
1001,
5500,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
/* TEMPLATE GENERATED TESTCASE FILE
Filename: CWE124_Buffer_Underwrite__wchar_t_alloca_loop_73a.cpp
Label Definition File: CWE124_Buffer_Underwrite.stack.label.xml
Template File: sources-sink-73a.tmpl.cpp
*/
/*
* @description
* CWE: 124 Buffer Underwrite
* BadSource: Set data pointer to before the allocated memory buffer
* GoodSource: Set data pointer to the allocated memory buffer
* Sinks: loop
* BadSink : Copy string to data using a loop
* Flow Variant: 73 Data flow: data passed in a list from one function to another in different source files
*
* */
#include "std_testcase.h"
#include <list>
#include <wchar.h>
using namespace std;
namespace CWE124_Buffer_Underwrite__wchar_t_alloca_loop_73
{
#ifndef OMITBAD
/* bad function declaration */
void badSink(list<wchar_t *> dataList);
void bad()
{
wchar_t * data;
list<wchar_t *> dataList;
wchar_t * dataBuffer = (wchar_t *)ALLOCA(100*sizeof(wchar_t));
wmemset(dataBuffer, L'A', 100-1);
dataBuffer[100-1] = L'\0';
/* FLAW: Set data pointer to before the allocated memory buffer */
data = dataBuffer - 8;
/* Put data in a list */
dataList.push_back(data);
dataList.push_back(data);
dataList.push_back(data);
badSink(dataList);
}
#endif /* OMITBAD */
#ifndef OMITGOOD
/* good function declarations */
/* goodG2B uses the GoodSource with the BadSink */
void goodG2BSink(list<wchar_t *> dataList);
static void goodG2B()
{
wchar_t * data;
list<wchar_t *> dataList;
wchar_t * dataBuffer = (wchar_t *)ALLOCA(100*sizeof(wchar_t));
wmemset(dataBuffer, L'A', 100-1);
dataBuffer[100-1] = L'\0';
/* FIX: Set data pointer to the allocated memory buffer */
data = dataBuffer;
/* Put data in a list */
dataList.push_back(data);
dataList.push_back(data);
dataList.push_back(data);
goodG2BSink(dataList);
}
void good()
{
goodG2B();
}
#endif /* OMITGOOD */
} /* close namespace */
/* Below is the main(). It is only used when building this testcase on
* its own for testing or for building a binary to use in testing binary
* analysis tools. It is not used when compiling all the testcases as one
* application, which is how source code analysis tools are tested.
*/
#ifdef INCLUDEMAIN
using namespace CWE124_Buffer_Underwrite__wchar_t_alloca_loop_73; /* so that we can use good and bad easily */
int main(int argc, char * argv[])
{
/* seed randomness */
srand( (unsigned)time(NULL) );
#ifndef OMITGOOD
printLine("Calling good()...");
good();
printLine("Finished good()");
#endif /* OMITGOOD */
#ifndef OMITBAD
printLine("Calling bad()...");
bad();
printLine("Finished bad()");
#endif /* OMITBAD */
return 0;
}
#endif
| JianpingZeng/xcc | xcc/test/juliet/testcases/CWE124_Buffer_Underwrite/s03/CWE124_Buffer_Underwrite__wchar_t_alloca_loop_73a.cpp | C++ | bsd-3-clause | 2,835 | [
30522,
1013,
1008,
23561,
7013,
3231,
18382,
5371,
5371,
18442,
1024,
19296,
2063,
12521,
2549,
1035,
17698,
1035,
2104,
26373,
1035,
1035,
15868,
8167,
1035,
1056,
1035,
2035,
24755,
1035,
7077,
1035,
6421,
2050,
1012,
18133,
2361,
3830,
6... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
--久遠の魔術師ミラ
function c33225925.initial_effect(c)
--confirm
local e1=Effect.CreateEffect(c)
e1:SetDescription(aux.Stringid(33225925,0))
e1:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_TRIGGER_F)
e1:SetProperty(EFFECT_FLAG_CARD_TARGET)
e1:SetCode(EVENT_SUMMON_SUCCESS)
e1:SetTarget(c33225925.target)
e1:SetOperation(c33225925.operation)
c:RegisterEffect(e1)
end
function c33225925.target(e,tp,eg,ep,ev,re,r,rp,chk,chkc)
if chkc then return chkc:IsControler(1-tp) and chkc:IsOnField() and chkc:IsFacedown() end
if chk==0 then return true end
Duel.Hint(HINT_SELECTMSG,tp,aux.Stringid(33225925,1))
local g=Duel.SelectTarget(tp,Card.IsFacedown,tp,0,LOCATION_ONFIELD,1,1,nil)
Duel.SetChainLimit(c33225925.chainlimit)
end
function c33225925.chainlimit(e,rp,tp)
return tp==rp or not e:IsHasType(EFFECT_TYPE_ACTIVATE)
end
function c33225925.operation(e,tp,eg,ep,ev,re,r,rp)
local tc=Duel.GetFirstTarget()
if tc and tc:IsRelateToEffect(e) and tc:IsFacedown() then
Duel.ConfirmCards(tp,tc)
end
end
| DailyShana/ygopro-scripts | c33225925.lua | Lua | gpl-2.0 | 1,015 | [
30522,
1011,
1011,
1748,
100,
1671,
100,
100,
100,
1724,
30257,
3853,
1039,
22394,
19317,
28154,
17788,
1012,
3988,
1035,
3466,
1006,
1039,
1007,
1011,
1011,
12210,
2334,
1041,
2487,
1027,
3466,
1012,
3443,
12879,
25969,
1006,
1039,
1007,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
/*
* An implementation of the Acorn Econet and AUN protocols.
* Philip Blundell <philb@gnu.org>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version
* 2 of the License, or (at your option) any later version.
*
*/
#include <linux/config.h>
#include <linux/module.h>
#include <linux/types.h>
#include <linux/kernel.h>
#include <linux/sched.h>
#include <linux/string.h>
#include <linux/mm.h>
#include <linux/socket.h>
#include <linux/sockios.h>
#include <linux/in.h>
#include <linux/errno.h>
#include <linux/interrupt.h>
#include <linux/if_ether.h>
#include <linux/netdevice.h>
#include <linux/inetdevice.h>
#include <linux/route.h>
#include <linux/inet.h>
#include <linux/etherdevice.h>
#include <linux/if_arp.h>
#include <linux/wireless.h>
#include <linux/skbuff.h>
#include <net/sock.h>
#include <net/inet_common.h>
#include <linux/stat.h>
#include <linux/init.h>
#include <linux/if_ec.h>
#include <net/udp.h>
#include <net/ip.h>
#include <linux/spinlock.h>
#include <linux/rcupdate.h>
#include <asm/uaccess.h>
#include <asm/system.h>
#include <asm/bitops.h>
static struct proto_ops econet_ops;
static struct hlist_head econet_sklist;
static rwlock_t econet_lock = RW_LOCK_UNLOCKED;
/* Since there are only 256 possible network numbers (or fewer, depends
how you count) it makes sense to use a simple lookup table. */
static struct net_device *net2dev_map[256];
#define EC_PORT_IP 0xd2
#ifdef CONFIG_ECONET_AUNUDP
static spinlock_t aun_queue_lock;
static struct socket *udpsock;
#define AUN_PORT 0x8000
struct aunhdr
{
unsigned char code; /* AUN magic protocol byte */
unsigned char port;
unsigned char cb;
unsigned char pad;
unsigned long handle;
};
static unsigned long aun_seq;
/* Queue of packets waiting to be transmitted. */
static struct sk_buff_head aun_queue;
static struct timer_list ab_cleanup_timer;
#endif /* CONFIG_ECONET_AUNUDP */
/* Per-packet information */
struct ec_cb
{
struct sockaddr_ec sec;
unsigned long cookie; /* Supplied by user. */
#ifdef CONFIG_ECONET_AUNUDP
int done;
unsigned long seq; /* Sequencing */
unsigned long timeout; /* Timeout */
unsigned long start; /* jiffies */
#endif
#ifdef CONFIG_ECONET_NATIVE
void (*sent)(struct sk_buff *, int result);
#endif
};
static void econet_remove_socket(struct hlist_head *list, struct sock *sk)
{
write_lock_bh(&econet_lock);
sk_del_node_init(sk);
write_unlock_bh(&econet_lock);
}
static void econet_insert_socket(struct hlist_head *list, struct sock *sk)
{
write_lock_bh(&econet_lock);
sk_add_node(sk, list);
write_unlock_bh(&econet_lock);
}
/*
* Pull a packet from our receive queue and hand it to the user.
* If necessary we block.
*/
static int econet_recvmsg(struct kiocb *iocb, struct socket *sock,
struct msghdr *msg, size_t len, int flags)
{
struct sock *sk = sock->sk;
struct sk_buff *skb;
size_t copied;
int err;
msg->msg_namelen = sizeof(struct sockaddr_ec);
/*
* Call the generic datagram receiver. This handles all sorts
* of horrible races and re-entrancy so we can forget about it
* in the protocol layers.
*
* Now it will return ENETDOWN, if device have just gone down,
* but then it will block.
*/
skb=skb_recv_datagram(sk,flags,flags&MSG_DONTWAIT,&err);
/*
* An error occurred so return it. Because skb_recv_datagram()
* handles the blocking we don't see and worry about blocking
* retries.
*/
if(skb==NULL)
goto out;
/*
* You lose any data beyond the buffer you gave. If it worries a
* user program they can ask the device for its MTU anyway.
*/
copied = skb->len;
if (copied > len)
{
copied=len;
msg->msg_flags|=MSG_TRUNC;
}
/* We can't use skb_copy_datagram here */
err = memcpy_toiovec(msg->msg_iov, skb->data, copied);
if (err)
goto out_free;
sk->sk_stamp = skb->stamp;
if (msg->msg_name)
memcpy(msg->msg_name, skb->cb, msg->msg_namelen);
/*
* Free or return the buffer as appropriate. Again this
* hides all the races and re-entrancy issues from us.
*/
err = copied;
out_free:
skb_free_datagram(sk, skb);
out:
return err;
}
/*
* Bind an Econet socket.
*/
static int econet_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len)
{
struct sockaddr_ec *sec = (struct sockaddr_ec *)uaddr;
struct sock *sk=sock->sk;
struct econet_opt *eo = ec_sk(sk);
/*
* Check legality
*/
if (addr_len < sizeof(struct sockaddr_ec) ||
sec->sec_family != AF_ECONET)
return -EINVAL;
eo->cb = sec->cb;
eo->port = sec->port;
eo->station = sec->addr.station;
eo->net = sec->addr.net;
return 0;
}
#if defined(CONFIG_ECONET_AUNUDP) || defined(CONFIG_ECONET_NATIVE)
/*
* Queue a transmit result for the user to be told about.
*/
static void tx_result(struct sock *sk, unsigned long cookie, int result)
{
struct sk_buff *skb = alloc_skb(0, GFP_ATOMIC);
struct ec_cb *eb;
struct sockaddr_ec *sec;
if (skb == NULL)
{
printk(KERN_DEBUG "ec: memory squeeze, transmit result dropped.\n");
return;
}
eb = (struct ec_cb *)&skb->cb;
sec = (struct sockaddr_ec *)&eb->sec;
memset(sec, 0, sizeof(struct sockaddr_ec));
sec->cookie = cookie;
sec->type = ECTYPE_TRANSMIT_STATUS | result;
sec->sec_family = AF_ECONET;
if (sock_queue_rcv_skb(sk, skb) < 0)
kfree_skb(skb);
}
#endif
#ifdef CONFIG_ECONET_NATIVE
/*
* Called by the Econet hardware driver when a packet transmit
* has completed. Tell the user.
*/
static void ec_tx_done(struct sk_buff *skb, int result)
{
struct ec_cb *eb = (struct ec_cb *)&skb->cb;
tx_result(skb->sk, eb->cookie, result);
}
#endif
/*
* Send a packet. We have to work out which device it's going out on
* and hence whether to use real Econet or the UDP emulation.
*/
static int econet_sendmsg(struct kiocb *iocb, struct socket *sock,
struct msghdr *msg, size_t len)
{
struct sock *sk = sock->sk;
struct sockaddr_ec *saddr=(struct sockaddr_ec *)msg->msg_name;
struct net_device *dev;
struct ec_addr addr;
int err;
unsigned char port, cb;
#if defined(CONFIG_ECONET_AUNUDP) || defined(CONFIG_ECONET_NATIVE)
struct sk_buff *skb;
struct ec_cb *eb;
#endif
#ifdef CONFIG_ECONET_AUNUDP
struct msghdr udpmsg;
struct iovec iov[msg->msg_iovlen+1];
struct aunhdr ah;
struct sockaddr_in udpdest;
__kernel_size_t size;
int i;
mm_segment_t oldfs;
#endif
/*
* Check the flags.
*/
if (msg->msg_flags & ~(MSG_DONTWAIT|MSG_CMSG_COMPAT))
return -EINVAL;
/*
* Get and verify the address.
*/
if (saddr == NULL) {
struct econet_opt *eo = ec_sk(sk);
addr.station = eo->station;
addr.net = eo->net;
port = eo->port;
cb = eo->cb;
} else {
if (msg->msg_namelen < sizeof(struct sockaddr_ec))
return -EINVAL;
addr.station = saddr->addr.station;
addr.net = saddr->addr.net;
port = saddr->port;
cb = saddr->cb;
}
/* Look for a device with the right network number. */
dev = net2dev_map[addr.net];
/* If not directly reachable, use some default */
if (dev == NULL)
{
dev = net2dev_map[0];
/* No interfaces at all? */
if (dev == NULL)
return -ENETDOWN;
}
if (len + 15 > dev->mtu)
return -EMSGSIZE;
if (dev->type == ARPHRD_ECONET)
{
/* Real hardware Econet. We're not worthy etc. */
#ifdef CONFIG_ECONET_NATIVE
unsigned short proto = 0;
dev_hold(dev);
skb = sock_alloc_send_skb(sk, len+LL_RESERVED_SPACE(dev),
msg->msg_flags & MSG_DONTWAIT, &err);
if (skb==NULL)
goto out_unlock;
skb_reserve(skb, LL_RESERVED_SPACE(dev));
skb->nh.raw = skb->data;
eb = (struct ec_cb *)&skb->cb;
/* BUG: saddr may be NULL */
eb->cookie = saddr->cookie;
eb->sec = *saddr;
eb->sent = ec_tx_done;
if (dev->hard_header) {
int res;
struct ec_framehdr *fh;
err = -EINVAL;
res = dev->hard_header(skb, dev, ntohs(proto),
&addr, NULL, len);
/* Poke in our control byte and
port number. Hack, hack. */
fh = (struct ec_framehdr *)(skb->data);
fh->cb = cb;
fh->port = port;
if (sock->type != SOCK_DGRAM) {
skb->tail = skb->data;
skb->len = 0;
} else if (res < 0)
goto out_free;
}
/* Copy the data. Returns -EFAULT on error */
err = memcpy_fromiovec(skb_put(skb,len), msg->msg_iov, len);
skb->protocol = proto;
skb->dev = dev;
skb->priority = sk->sk_priority;
if (err)
goto out_free;
err = -ENETDOWN;
if (!(dev->flags & IFF_UP))
goto out_free;
/*
* Now send it
*/
dev_queue_xmit(skb);
dev_put(dev);
return(len);
out_free:
kfree_skb(skb);
out_unlock:
if (dev)
dev_put(dev);
#else
err = -EPROTOTYPE;
#endif
return err;
}
#ifdef CONFIG_ECONET_AUNUDP
/* AUN virtual Econet. */
if (udpsock == NULL)
return -ENETDOWN; /* No socket - can't send */
/* Make up a UDP datagram and hand it off to some higher intellect. */
memset(&udpdest, 0, sizeof(udpdest));
udpdest.sin_family = AF_INET;
udpdest.sin_port = htons(AUN_PORT);
/* At the moment we use the stupid Acorn scheme of Econet address
y.x maps to IP a.b.c.x. This should be replaced with something
more flexible and more aware of subnet masks. */
{
struct in_device *idev;
unsigned long network = 0;
rcu_read_lock();
idev = __in_dev_get(dev);
if (idev) {
if (idev->ifa_list)
network = ntohl(idev->ifa_list->ifa_address) &
0xffffff00; /* !!! */
}
rcu_read_unlock();
udpdest.sin_addr.s_addr = htonl(network | addr.station);
}
ah.port = port;
ah.cb = cb & 0x7f;
ah.code = 2; /* magic */
ah.pad = 0;
/* tack our header on the front of the iovec */
size = sizeof(struct aunhdr);
/*
* XXX: that is b0rken. We can't mix userland and kernel pointers
* in iovec, since on a lot of platforms copy_from_user() will
* *not* work with the kernel and userland ones at the same time,
* regardless of what we do with set_fs(). And we are talking about
* econet-over-ethernet here, so "it's only ARM anyway" doesn't
* apply. Any suggestions on fixing that code? -- AV
*/
iov[0].iov_base = (void *)&ah;
iov[0].iov_len = size;
for (i = 0; i < msg->msg_iovlen; i++) {
void __user *base = msg->msg_iov[i].iov_base;
size_t len = msg->msg_iov[i].iov_len;
/* Check it now since we switch to KERNEL_DS later. */
if ((err = verify_area(VERIFY_READ, base, len)) < 0)
return err;
iov[i+1].iov_base = base;
iov[i+1].iov_len = len;
size += len;
}
/* Get a skbuff (no data, just holds our cb information) */
if ((skb = sock_alloc_send_skb(sk, 0,
msg->msg_flags & MSG_DONTWAIT, &err)) == NULL)
return err;
eb = (struct ec_cb *)&skb->cb;
eb->cookie = saddr->cookie;
eb->timeout = (5*HZ);
eb->start = jiffies;
ah.handle = aun_seq;
eb->seq = (aun_seq++);
eb->sec = *saddr;
skb_queue_tail(&aun_queue, skb);
udpmsg.msg_name = (void *)&udpdest;
udpmsg.msg_namelen = sizeof(udpdest);
udpmsg.msg_iov = &iov[0];
udpmsg.msg_iovlen = msg->msg_iovlen + 1;
udpmsg.msg_control = NULL;
udpmsg.msg_controllen = 0;
udpmsg.msg_flags=0;
oldfs = get_fs(); set_fs(KERNEL_DS); /* More privs :-) */
err = sock_sendmsg(udpsock, &udpmsg, size);
set_fs(oldfs);
#else
err = -EPROTOTYPE;
#endif
return err;
}
/*
* Look up the address of a socket.
*/
static int econet_getname(struct socket *sock, struct sockaddr *uaddr,
int *uaddr_len, int peer)
{
struct sock *sk = sock->sk;
struct econet_opt *eo = ec_sk(sk);
struct sockaddr_ec *sec = (struct sockaddr_ec *)uaddr;
if (peer)
return -EOPNOTSUPP;
sec->sec_family = AF_ECONET;
sec->port = eo->port;
sec->addr.station = eo->station;
sec->addr.net = eo->net;
*uaddr_len = sizeof(*sec);
return 0;
}
static void econet_destroy_timer(unsigned long data)
{
struct sock *sk=(struct sock *)data;
if (!atomic_read(&sk->sk_wmem_alloc) &&
!atomic_read(&sk->sk_rmem_alloc)) {
sk_free(sk);
return;
}
sk->sk_timer.expires = jiffies + 10 * HZ;
add_timer(&sk->sk_timer);
printk(KERN_DEBUG "econet socket destroy delayed\n");
}
/*
* Close an econet socket.
*/
static int econet_release(struct socket *sock)
{
struct sock *sk = sock->sk;
if (!sk)
return 0;
econet_remove_socket(&econet_sklist, sk);
/*
* Now the socket is dead. No more input will appear.
*/
sk->sk_state_change(sk); /* It is useless. Just for sanity. */
sock->sk = NULL;
sk->sk_socket = NULL;
sock_set_flag(sk, SOCK_DEAD);
/* Purge queues */
skb_queue_purge(&sk->sk_receive_queue);
if (atomic_read(&sk->sk_rmem_alloc) ||
atomic_read(&sk->sk_wmem_alloc)) {
sk->sk_timer.data = (unsigned long)sk;
sk->sk_timer.expires = jiffies + HZ;
sk->sk_timer.function = econet_destroy_timer;
add_timer(&sk->sk_timer);
return 0;
}
sk_free(sk);
return 0;
}
/*
* Create an Econet socket
*/
static int econet_create(struct socket *sock, int protocol)
{
struct sock *sk;
struct econet_opt *eo;
int err;
/* Econet only provides datagram services. */
if (sock->type != SOCK_DGRAM)
return -ESOCKTNOSUPPORT;
sock->state = SS_UNCONNECTED;
err = -ENOBUFS;
sk = sk_alloc(PF_ECONET, GFP_KERNEL, 1, NULL);
if (sk == NULL)
goto out;
sk->sk_reuse = 1;
sock->ops = &econet_ops;
sock_init_data(sock,sk);
sk_set_owner(sk, THIS_MODULE);
eo = sk->sk_protinfo = kmalloc(sizeof(*eo), GFP_KERNEL);
if (!eo)
goto out_free;
memset(eo, 0, sizeof(*eo));
sk->sk_zapped = 0;
sk->sk_family = PF_ECONET;
eo->num = protocol;
econet_insert_socket(&econet_sklist, sk);
return(0);
out_free:
sk_free(sk);
out:
return err;
}
/*
* Handle Econet specific ioctls
*/
static int ec_dev_ioctl(struct socket *sock, unsigned int cmd, void __user *arg)
{
struct ifreq ifr;
struct ec_device *edev;
struct net_device *dev;
struct sockaddr_ec *sec;
/*
* Fetch the caller's info block into kernel space
*/
if (copy_from_user(&ifr, arg, sizeof(struct ifreq)))
return -EFAULT;
if ((dev = dev_get_by_name(ifr.ifr_name)) == NULL)
return -ENODEV;
sec = (struct sockaddr_ec *)&ifr.ifr_addr;
switch (cmd)
{
case SIOCSIFADDR:
edev = dev->ec_ptr;
if (edev == NULL)
{
/* Magic up a new one. */
edev = kmalloc(sizeof(struct ec_device), GFP_KERNEL);
if (edev == NULL) {
printk("af_ec: memory squeeze.\n");
dev_put(dev);
return -ENOMEM;
}
memset(edev, 0, sizeof(struct ec_device));
dev->ec_ptr = edev;
}
else
net2dev_map[edev->net] = NULL;
edev->station = sec->addr.station;
edev->net = sec->addr.net;
net2dev_map[sec->addr.net] = dev;
if (!net2dev_map[0])
net2dev_map[0] = dev;
dev_put(dev);
return 0;
case SIOCGIFADDR:
edev = dev->ec_ptr;
if (edev == NULL)
{
dev_put(dev);
return -ENODEV;
}
memset(sec, 0, sizeof(struct sockaddr_ec));
sec->addr.station = edev->station;
sec->addr.net = edev->net;
sec->sec_family = AF_ECONET;
dev_put(dev);
if (copy_to_user(arg, &ifr, sizeof(struct ifreq)))
return -EFAULT;
return 0;
}
dev_put(dev);
return -EINVAL;
}
/*
* Handle generic ioctls
*/
static int econet_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg)
{
struct sock *sk = sock->sk;
void __user *argp = (void __user *)arg;
switch(cmd) {
case SIOCGSTAMP:
return sock_get_timestamp(sk, argp);
case SIOCSIFADDR:
case SIOCGIFADDR:
return ec_dev_ioctl(sock, cmd, argp);
break;
default:
return dev_ioctl(cmd, argp);
}
/*NOTREACHED*/
return 0;
}
static struct net_proto_family econet_family_ops = {
.family = PF_ECONET,
.create = econet_create,
.owner = THIS_MODULE,
};
static struct proto_ops SOCKOPS_WRAPPED(econet_ops) = {
.family = PF_ECONET,
.owner = THIS_MODULE,
.release = econet_release,
.bind = econet_bind,
.connect = sock_no_connect,
.socketpair = sock_no_socketpair,
.accept = sock_no_accept,
.getname = econet_getname,
.poll = datagram_poll,
.ioctl = econet_ioctl,
.listen = sock_no_listen,
.shutdown = sock_no_shutdown,
.setsockopt = sock_no_setsockopt,
.getsockopt = sock_no_getsockopt,
.sendmsg = econet_sendmsg,
.recvmsg = econet_recvmsg,
.mmap = sock_no_mmap,
.sendpage = sock_no_sendpage,
};
#include <linux/smp_lock.h>
SOCKOPS_WRAP(econet, PF_ECONET);
#if defined(CONFIG_ECONET_AUNUDP) || defined(CONFIG_ECONET_NATIVE)
/*
* Find the listening socket, if any, for the given data.
*/
static struct sock *ec_listening_socket(unsigned char port, unsigned char
station, unsigned char net)
{
struct sock *sk;
struct hlist_node *node;
sk_for_each(sk, node, &econet_sklist) {
struct econet_opt *opt = ec_sk(sk);
if ((opt->port == port || opt->port == 0) &&
(opt->station == station || opt->station == 0) &&
(opt->net == net || opt->net == 0))
goto found;
}
sk = NULL;
found:
return sk;
}
/*
* Queue a received packet for a socket.
*/
static int ec_queue_packet(struct sock *sk, struct sk_buff *skb,
unsigned char stn, unsigned char net,
unsigned char cb, unsigned char port)
{
struct ec_cb *eb = (struct ec_cb *)&skb->cb;
struct sockaddr_ec *sec = (struct sockaddr_ec *)&eb->sec;
memset(sec, 0, sizeof(struct sockaddr_ec));
sec->sec_family = AF_ECONET;
sec->type = ECTYPE_PACKET_RECEIVED;
sec->port = port;
sec->cb = cb;
sec->addr.net = net;
sec->addr.station = stn;
return sock_queue_rcv_skb(sk, skb);
}
#endif
#ifdef CONFIG_ECONET_AUNUDP
/*
* Send an AUN protocol response.
*/
static void aun_send_response(__u32 addr, unsigned long seq, int code, int cb)
{
struct sockaddr_in sin = {
.sin_family = AF_INET,
.sin_port = htons(AUN_PORT),
.sin_addr = {.s_addr = addr}
};
struct aunhdr ah = {.code = code, .cb = cb, .handle = seq};
struct kvec iov = {.iov_base = (void *)&ah, .iov_len = sizeof(ah)};
struct msghdr udpmsg;
udpmsg.msg_name = (void *)&sin;
udpmsg.msg_namelen = sizeof(sin);
udpmsg.msg_control = NULL;
udpmsg.msg_controllen = 0;
udpmsg.msg_flags=0;
kernel_sendmsg(udpsock, &udpmsg, &iov, 1, sizeof(ah));
}
/*
* Handle incoming AUN packets. Work out if anybody wants them,
* and send positive or negative acknowledgements as appropriate.
*/
static void aun_incoming(struct sk_buff *skb, struct aunhdr *ah, size_t len)
{
struct iphdr *ip = skb->nh.iph;
unsigned char stn = ntohl(ip->saddr) & 0xff;
struct sock *sk;
struct sk_buff *newskb;
struct ec_device *edev = skb->dev->ec_ptr;
if (! edev)
goto bad;
if ((sk = ec_listening_socket(ah->port, stn, edev->net)) == NULL)
goto bad; /* Nobody wants it */
newskb = alloc_skb((len - sizeof(struct aunhdr) + 15) & ~15,
GFP_ATOMIC);
if (newskb == NULL)
{
printk(KERN_DEBUG "AUN: memory squeeze, dropping packet.\n");
/* Send nack and hope sender tries again */
goto bad;
}
memcpy(skb_put(newskb, len - sizeof(struct aunhdr)), (void *)(ah+1),
len - sizeof(struct aunhdr));
if (ec_queue_packet(sk, newskb, stn, edev->net, ah->cb, ah->port))
{
/* Socket is bankrupt. */
kfree_skb(newskb);
goto bad;
}
aun_send_response(ip->saddr, ah->handle, 3, 0);
return;
bad:
aun_send_response(ip->saddr, ah->handle, 4, 0);
}
/*
* Handle incoming AUN transmit acknowledgements. If the sequence
* number matches something in our backlog then kill it and tell
* the user. If the remote took too long to reply then we may have
* dropped the packet already.
*/
static void aun_tx_ack(unsigned long seq, int result)
{
struct sk_buff *skb;
unsigned long flags;
struct ec_cb *eb;
spin_lock_irqsave(&aun_queue_lock, flags);
skb = skb_peek(&aun_queue);
while (skb && skb != (struct sk_buff *)&aun_queue)
{
struct sk_buff *newskb = skb->next;
eb = (struct ec_cb *)&skb->cb;
if (eb->seq == seq)
goto foundit;
skb = newskb;
}
spin_unlock_irqrestore(&aun_queue_lock, flags);
printk(KERN_DEBUG "AUN: unknown sequence %ld\n", seq);
return;
foundit:
tx_result(skb->sk, eb->cookie, result);
skb_unlink(skb);
spin_unlock_irqrestore(&aun_queue_lock, flags);
kfree_skb(skb);
}
/*
* Deal with received AUN frames - sort out what type of thing it is
* and hand it to the right function.
*/
static void aun_data_available(struct sock *sk, int slen)
{
int err;
struct sk_buff *skb;
unsigned char *data;
struct aunhdr *ah;
struct iphdr *ip;
size_t len;
while ((skb = skb_recv_datagram(sk, 0, 1, &err)) == NULL) {
if (err == -EAGAIN) {
printk(KERN_ERR "AUN: no data available?!");
return;
}
printk(KERN_DEBUG "AUN: recvfrom() error %d\n", -err);
}
data = skb->h.raw + sizeof(struct udphdr);
ah = (struct aunhdr *)data;
len = skb->len - sizeof(struct udphdr);
ip = skb->nh.iph;
switch (ah->code)
{
case 2:
aun_incoming(skb, ah, len);
break;
case 3:
aun_tx_ack(ah->handle, ECTYPE_TRANSMIT_OK);
break;
case 4:
aun_tx_ack(ah->handle, ECTYPE_TRANSMIT_NOT_LISTENING);
break;
#if 0
/* This isn't quite right yet. */
case 5:
aun_send_response(ip->saddr, ah->handle, 6, ah->cb);
break;
#endif
default:
printk(KERN_DEBUG "unknown AUN packet (type %d)\n", data[0]);
}
skb_free_datagram(sk, skb);
}
/*
* Called by the timer to manage the AUN transmit queue. If a packet
* was sent to a dead or nonexistent host then we will never get an
* acknowledgement back. After a few seconds we need to spot this and
* drop the packet.
*/
static void ab_cleanup(unsigned long h)
{
struct sk_buff *skb;
unsigned long flags;
spin_lock_irqsave(&aun_queue_lock, flags);
skb = skb_peek(&aun_queue);
while (skb && skb != (struct sk_buff *)&aun_queue)
{
struct sk_buff *newskb = skb->next;
struct ec_cb *eb = (struct ec_cb *)&skb->cb;
if ((jiffies - eb->start) > eb->timeout)
{
tx_result(skb->sk, eb->cookie,
ECTYPE_TRANSMIT_NOT_PRESENT);
skb_unlink(skb);
kfree_skb(skb);
}
skb = newskb;
}
spin_unlock_irqrestore(&aun_queue_lock, flags);
mod_timer(&ab_cleanup_timer, jiffies + (HZ*2));
}
static int __init aun_udp_initialise(void)
{
int error;
struct sockaddr_in sin;
skb_queue_head_init(&aun_queue);
spin_lock_init(&aun_queue_lock);
init_timer(&ab_cleanup_timer);
ab_cleanup_timer.expires = jiffies + (HZ*2);
ab_cleanup_timer.function = ab_cleanup;
add_timer(&ab_cleanup_timer);
memset(&sin, 0, sizeof(sin));
sin.sin_port = htons(AUN_PORT);
/* We can count ourselves lucky Acorn machines are too dim to
speak IPv6. :-) */
if ((error = sock_create_kern(PF_INET, SOCK_DGRAM, 0, &udpsock)) < 0)
{
printk("AUN: socket error %d\n", -error);
return error;
}
udpsock->sk->sk_reuse = 1;
udpsock->sk->sk_allocation = GFP_ATOMIC; /* we're going to call it
from interrupts */
error = udpsock->ops->bind(udpsock, (struct sockaddr *)&sin,
sizeof(sin));
if (error < 0)
{
printk("AUN: bind error %d\n", -error);
goto release;
}
udpsock->sk->sk_data_ready = aun_data_available;
return 0;
release:
sock_release(udpsock);
udpsock = NULL;
return error;
}
#endif
#ifdef CONFIG_ECONET_NATIVE
/*
* Receive an Econet frame from a device.
*/
static int econet_rcv(struct sk_buff *skb, struct net_device *dev, struct packet_type *pt)
{
struct ec_framehdr *hdr;
struct sock *sk;
struct ec_device *edev = dev->ec_ptr;
if (skb->pkt_type == PACKET_OTHERHOST)
goto drop;
if (!edev)
goto drop;
if ((skb = skb_share_check(skb, GFP_ATOMIC)) == NULL)
return NET_RX_DROP;
if (!pskb_may_pull(skb, sizeof(struct ec_framehdr)))
goto drop;
hdr = (struct ec_framehdr *) skb->data;
/* First check for encapsulated IP */
if (hdr->port == EC_PORT_IP) {
skb->protocol = htons(ETH_P_IP);
skb_pull(skb, sizeof(struct ec_framehdr));
netif_rx(skb);
return 0;
}
sk = ec_listening_socket(hdr->port, hdr->src_stn, hdr->src_net);
if (!sk)
goto drop;
if (ec_queue_packet(sk, skb, edev->net, hdr->src_stn, hdr->cb,
hdr->port))
goto drop;
return 0;
drop:
kfree_skb(skb);
return NET_RX_DROP;
}
static struct packet_type econet_packet_type = {
.type = __constant_htons(ETH_P_ECONET),
.func = econet_rcv,
};
static void econet_hw_initialise(void)
{
dev_add_pack(&econet_packet_type);
}
#endif
static int econet_notifier(struct notifier_block *this, unsigned long msg, void *data)
{
struct net_device *dev = (struct net_device *)data;
struct ec_device *edev;
switch (msg) {
case NETDEV_UNREGISTER:
/* A device has gone down - kill any data we hold for it. */
edev = dev->ec_ptr;
if (edev)
{
if (net2dev_map[0] == dev)
net2dev_map[0] = NULL;
net2dev_map[edev->net] = NULL;
kfree(edev);
dev->ec_ptr = NULL;
}
break;
}
return NOTIFY_DONE;
}
static struct notifier_block econet_netdev_notifier = {
.notifier_call =econet_notifier,
};
static void __exit econet_proto_exit(void)
{
#ifdef CONFIG_ECONET_AUNUDP
del_timer(&ab_cleanup_timer);
if (udpsock)
sock_release(udpsock);
#endif
unregister_netdevice_notifier(&econet_netdev_notifier);
sock_unregister(econet_family_ops.family);
}
static int __init econet_proto_init(void)
{
sock_register(&econet_family_ops);
#ifdef CONFIG_ECONET_AUNUDP
spin_lock_init(&aun_queue_lock);
aun_udp_initialise();
#endif
#ifdef CONFIG_ECONET_NATIVE
econet_hw_initialise();
#endif
register_netdevice_notifier(&econet_netdev_notifier);
return 0;
}
module_init(econet_proto_init);
module_exit(econet_proto_exit);
MODULE_LICENSE("GPL");
MODULE_ALIAS_NETPROTO(PF_ECONET);
| dduval/kernel-rhel4 | net/econet/af_econet.c | C | gpl-2.0 | 25,180 | [
30522,
1013,
1008,
1008,
2019,
7375,
1997,
1996,
9353,
9691,
17338,
7159,
1998,
8740,
2078,
16744,
1012,
1008,
5170,
14154,
13629,
3363,
1026,
6316,
2497,
1030,
27004,
1012,
8917,
1028,
1008,
1008,
2023,
2565,
2003,
2489,
4007,
1025,
2017,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 1.0 Transitional//EN">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<META http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet" href="../includes/main.css" type="text/css">
<link rel="shortcut icon" href="../favicon.ico" type="image/x-icon">
<title>Apache CloudStack | The Power Behind Your Cloud</title>
</head>
<body>
<div id="insidetopbg">
<div id="inside_wrapper">
<div class="uppermenu_panel">
<div class="uppermenu_box"></div>
</div>
<div id="main_master">
<div id="inside_header">
<div class="header_top">
<a class="cloud_logo" href="http://cloudstack.org"></a>
<div class="mainemenu_panel"></div>
</div>
</div>
<div id="main_content">
<div class="inside_apileftpanel">
<div class="inside_contentpanel" style="width:930px;">
<div class="api_titlebox">
<div class="api_titlebox_left">
<span>
Apache CloudStack v4.4.1 Domain Admin API Reference
</span>
<p></p>
<h1>listEgressFirewallRules</h1>
<p>Lists all egress firewall rules for network id.</p>
</div>
<div class="api_titlebox_right">
<a class="api_backbutton" href="../TOC_Domain_Admin.html"></a>
</div>
</div>
<div class="api_tablepanel">
<h2>Request parameters</h2>
<table class="apitable">
<tr class="hed">
<td style="width:200px;"><strong>Parameter Name</strong></td><td style="width:500px;">Description</td><td style="width:180px;">Required</td>
</tr>
<tr>
<td style="width:200px;"><i>account</i></td><td style="width:500px;"><i>list resources by account. Must be used with the domainId parameter.</i></td><td style="width:180px;"><i>false</i></td>
</tr>
<tr>
<td style="width:200px;"><i>domainid</i></td><td style="width:500px;"><i>list only resources belonging to the domain specified</i></td><td style="width:180px;"><i>false</i></td>
</tr>
<tr>
<td style="width:200px;"><i>fordisplay</i></td><td style="width:500px;"><i>list resources by display flag; only ROOT admin is eligible to pass this parameter</i></td><td style="width:180px;"><i>false</i></td>
</tr>
<tr>
<td style="width:200px;"><i>id</i></td><td style="width:500px;"><i>Lists rule with the specified ID.</i></td><td style="width:180px;"><i>false</i></td>
</tr>
<tr>
<td style="width:200px;"><i>id</i></td><td style="width:500px;"><i>Lists rule with the specified ID.</i></td><td style="width:180px;"><i>false</i></td>
</tr>
<tr>
<td style="width:200px;"><i>ipaddressid</i></td><td style="width:500px;"><i>the id of IP address of the firwall services</i></td><td style="width:180px;"><i>false</i></td>
</tr>
<tr>
<td style="width:200px;"><i>isrecursive</i></td><td style="width:500px;"><i>defaults to false, but if true, lists all resources from the parent specified by the domainId till leaves.</i></td><td style="width:180px;"><i>false</i></td>
</tr>
<tr>
<td style="width:200px;"><i>keyword</i></td><td style="width:500px;"><i>List by keyword</i></td><td style="width:180px;"><i>false</i></td>
</tr>
<tr>
<td style="width:200px;"><i>listall</i></td><td style="width:500px;"><i>If set to false, list only resources belonging to the command's caller; if set to true - list resources that the caller is authorized to see. Default value is false</i></td><td style="width:180px;"><i>false</i></td>
</tr>
<tr>
<td style="width:200px;"><i>networkid</i></td><td style="width:500px;"><i>the id network network for the egress firwall services</i></td><td style="width:180px;"><i>false</i></td>
</tr>
<tr>
<td style="width:200px;"><i>networkid</i></td><td style="width:500px;"><i>list firewall rules for ceratin network</i></td><td style="width:180px;"><i>false</i></td>
</tr>
<tr>
<td style="width:200px;"><i>page</i></td><td style="width:500px;"><i></i></td><td style="width:180px;"><i>false</i></td>
</tr>
<tr>
<td style="width:200px;"><i>pagesize</i></td><td style="width:500px;"><i></i></td><td style="width:180px;"><i>false</i></td>
</tr>
<tr>
<td style="width:200px;"><i>projectid</i></td><td style="width:500px;"><i>list objects by project</i></td><td style="width:180px;"><i>false</i></td>
</tr>
<tr>
<td style="width:200px;"><i>tags</i></td><td style="width:500px;"><i>List resources by tags (key/value pairs)</i></td><td style="width:180px;"><i>false</i></td>
</tr>
</table>
</div>
<div class="api_tablepanel">
<h2>Response Tags</h2>
<table class="apitable">
<tr class="hed">
<td style="width:200px;"><strong>Response Name</strong></td><td style="width:500px;">Description</td>
</tr>
<tr>
<td style="width:200px;"><strong>id</strong></td><td style="width:500px;">the ID of the firewall rule</td>
</tr>
<tr>
<td style="width:200px;"><strong>cidrlist</strong></td><td style="width:500px;">the cidr list to forward traffic from</td>
</tr>
<tr>
<td style="width:200px;"><strong>endport</strong></td><td style="width:500px;">the ending port of firewall rule's port range</td>
</tr>
<tr>
<td style="width:200px;"><strong>fordisplay</strong></td><td style="width:500px;">is rule for display to the regular user</td>
</tr>
<tr>
<td style="width:200px;"><strong>icmpcode</strong></td><td style="width:500px;">error code for this icmp message</td>
</tr>
<tr>
<td style="width:200px;"><strong>icmptype</strong></td><td style="width:500px;">type of the icmp message being sent</td>
</tr>
<tr>
<td style="width:200px;"><strong>ipaddress</strong></td><td style="width:500px;">the public ip address for the firewall rule</td>
</tr>
<tr>
<td style="width:200px;"><strong>ipaddressid</strong></td><td style="width:500px;">the public ip address id for the firewall rule</td>
</tr>
<tr>
<td style="width:200px;"><strong>networkid</strong></td><td style="width:500px;">the network id of the firewall rule</td>
</tr>
<tr>
<td style="width:200px;"><strong>protocol</strong></td><td style="width:500px;">the protocol of the firewall rule</td>
</tr>
<tr>
<td style="width:200px;"><strong>startport</strong></td><td style="width:500px;">the starting port of firewall rule's port range</td>
</tr>
<tr>
<td style="width:200px;"><strong>state</strong></td><td style="width:500px;">the state of the rule</td>
</tr>
<tr>
<td style="width:200px;"><strong>tags(*)</strong></td><td style="width:500px;">the list of resource tags associated with the rule</td>
<tr>
<td style="width:180px; padding-left:25px;"><strong>account</strong></td><td style="width:500px;">the account associated with the tag</td>
</tr>
<tr>
<td style="width:180px; padding-left:25px;"><strong>customer</strong></td><td style="width:500px;">customer associated with the tag</td>
</tr>
<tr>
<td style="width:180px; padding-left:25px;"><strong>domain</strong></td><td style="width:500px;">the domain associated with the tag</td>
</tr>
<tr>
<td style="width:180px; padding-left:25px;"><strong>domainid</strong></td><td style="width:500px;">the ID of the domain associated with the tag</td>
</tr>
<tr>
<td style="width:180px; padding-left:25px;"><strong>key</strong></td><td style="width:500px;">tag key name</td>
</tr>
<tr>
<td style="width:180px; padding-left:25px;"><strong>project</strong></td><td style="width:500px;">the project name where tag belongs to</td>
</tr>
<tr>
<td style="width:180px; padding-left:25px;"><strong>projectid</strong></td><td style="width:500px;">the project id the tag belongs to</td>
</tr>
<tr>
<td style="width:180px; padding-left:25px;"><strong>resourceid</strong></td><td style="width:500px;">id of the resource</td>
</tr>
<tr>
<td style="width:180px; padding-left:25px;"><strong>resourcetype</strong></td><td style="width:500px;">resource type</td>
</tr>
<tr>
<td style="width:180px; padding-left:25px;"><strong>value</strong></td><td style="width:500px;">tag value</td>
</tr>
</tr>
</table>
</div>
</div>
</div>
</div>
</div>
<div id="footer">
<div id="footer_mainmaster">
<p>Copyright © 2014 The Apache Software Foundation, Licensed under the
<a href="http://www.apache.org/licenses/LICENSE-2.0">Apache License, Version 2.0.</a>
<br>
Apache, CloudStack, Apache CloudStack, the Apache CloudStack logo, the CloudMonkey logo and the Apache feather logo are trademarks of The Apache Software Foundation.</p>
</div>
</div>
</div>
</div>
</body>
</html>
| resmo/cloudstack-www | source/api/apidocs-4.4/domain_admin/listEgressFirewallRules.html | HTML | apache-2.0 | 8,157 | [
30522,
1026,
999,
9986,
13874,
16129,
2270,
1000,
1011,
1013,
1013,
1059,
2509,
2278,
1013,
1013,
26718,
2094,
16129,
1015,
1012,
1014,
17459,
1013,
1013,
4372,
1000,
1028,
1026,
16129,
20950,
3619,
1027,
1000,
8299,
1024,
1013,
1013,
7479,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
fork of https://code.google.com/p/anntools/
| rane-hs/anntools-py3x | README.md | Markdown | lgpl-2.1 | 44 | [
30522,
9292,
1997,
16770,
1024,
1013,
1013,
3642,
1012,
8224,
1012,
4012,
1013,
1052,
1013,
5754,
3406,
27896,
1013,
102,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
<!DOCTYPE>
<html>
<head>
<title>cytoscape-panzoom.js demo</title>
<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1, maximum-scale=1">
<link href="cytoscape.js-panzoom.css" rel="stylesheet" type="text/css" />
<link href="font-awesome-4.0.3/css/font-awesome.css" rel="stylesheet" type="text/css" />
<script src="http://code.jquery.com/jquery-2.0.3.min.js"></script>
<script src="http://cytoscape.github.io/cytoscape.js/api/cytoscape.js-latest/cytoscape.min.js"></script>
<!-- for testing with local version of cytoscape.js -->
<!-- <script src="../cytoscape.js/build/cytoscape.js"></script> -->
<script src="cytoscape-panzoom.js"></script>
<style>
body {
font-family: helvetica;
font-size: 14px;
}
#cy {
width: 100%;
height: 100%;
position: absolute;
left: 0;
top: 0;
z-index: 999;
}
h1 {
opacity: 0.5;
font-size: 1em;
}
</style>
<script>
$(function(){
var cy = window.cy = cytoscape({
container: document.getElementById('cy'),
ready: function(){
},
style: [
{
selector: 'node',
css: {
'content': 'data(name)'
}
},
{
selector: 'edge',
css: {
'target-arrow-shape': 'triangle'
}
}
],
elements: {
nodes: [
{ data: { id: 'j', name: 'Jerry' } },
{ data: { id: 'e', name: 'Elaine' } },
{ data: { id: 'k', name: 'Kramer' } },
{ data: { id: 'g', name: 'George' } }
],
edges: [
{ data: { source: 'j', target: 'e' } },
{ data: { source: 'j', target: 'k' } },
{ data: { source: 'j', target: 'g' } },
{ data: { source: 'e', target: 'j' } },
{ data: { source: 'e', target: 'k' } },
{ data: { source: 'k', target: 'j' } },
{ data: { source: 'k', target: 'e' } },
{ data: { source: 'k', target: 'g' } },
{ data: { source: 'g', target: 'j' } }
]
},
});
cy.panzoom({
// options here...
});
});
</script>
</head>
<body>
<h1>cytoscape-panzoom demo</h1>
<div id="cy"></div>
</body>
</html>
| rye-sift/dreal3 | tools/multimodel_vis/lib/cytoscape.js-panzoom-master/demo.html | HTML | gpl-3.0 | 2,178 | [
30522,
1026,
999,
9986,
13874,
1028,
1026,
16129,
1028,
1026,
2132,
1028,
1026,
2516,
1028,
22330,
13122,
19464,
1011,
30524,
5310,
1011,
26743,
3468,
1027,
2053,
1010,
3988,
1011,
4094,
1027,
1015,
1010,
4555,
1011,
4094,
1027,
1015,
1000,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "media/base/message_loop_factory.h"
namespace media {
MessageLoopFactory::~MessageLoopFactory() {}
} // namespace media
| Crystalnix/house-of-life-chromium | media/base/message_loop_factory.cc | C++ | bsd-3-clause | 303 | [
30522,
1013,
1013,
9385,
1006,
1039,
1007,
2249,
1996,
10381,
21716,
5007,
6048,
1012,
2035,
2916,
9235,
1012,
1013,
1013,
2224,
1997,
2023,
3120,
3642,
30524,
1013,
2918,
1013,
4471,
1035,
7077,
1035,
4713,
1012,
1044,
1000,
3415,
15327,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
<link rel="stylesheet" href="${basePath}/resources/common/libs/fileinput/css/fileinput.min.css">
<script src="${basePath}/resources/common/libs/fileinput/js/fileinput.js"></script>
<script src="${basePath}/resources/common/libs/fileinput/js/locales/zh.js"></script>
<style >
input{
width:100%;
text-align: left;
font-size: 15px;
height:25px
}
span{
font-size: 13px;
font-weight: 600
}
.rqd{
border-radius:10px;
height:50px;
width:50px;
border:1px solid #ccc;
display: inline-block;
margin:10px;
text-align: center;
}
.rqspan{
font-size:25px;
line-height:50px;
}
</style>
<section class="content" id="projectaddstep2">
<section class="content-header">
<h1>
安全施工日志日期选择
</h1>
<ol class="breadcrumb">
<li><a href="${basePath}"><i class="fa fa-dashboard"></i> 首页</a></li>
<li><a href="#">施工日志</a></li>
<li class="active">安全施工日志日期选择</li>
</ol>
</section>
<section class="content">
<div class="row" style="max-height:100%;overflow-y:auto;">
<div class="col-xs-12">
<div class="box">
<form style="width:100%" id="RqForm" name="RqForm" class="form-horizontal">
<div class="box-body">
<div class="col-md-6">
<div class="form-group">
<label class="col-sm-5 control-label">姓名</label>
<div class="col-sm-6">
<input type="text" id="username" name="username" readonly="readonly"/>
<input type="hidden" id="userid" name="ryid">
</div>
</div>
<div class="form-group">
<label class="col-sm-5 control-label">年月选择</label>
<div class="col-sm-6">
<input id="rzdate"name="rzdate" style="width:100%;text-align: left;" class="date-picker" data-flag="datepicker" data-format="yyyy-mm-dd" />
</div>
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<label class="col-sm-3 control-label">项目</label>
<div class="col-sm-6">
<select id="xmid" class="select2 " name="xmid" style="width:100%">
<option selected="selected" value="">选择一个项目</option>
</select>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label"></label>
<div class="col-sm-6">
<button type="submit" class="btn btn-primary" data-btn-type="save" id="getRq">确定月份</button>
<span style="display: inline-block;width:60px;background:#ADFF2F;height:50px;line-height: 50px">有日志</span>
<span style="display: inline-block;width:60px;background:#FF4040;height:50px;line-height: 50px">无日志</span>
<span style="display: inline-block;width:60px;background:#ccc;height:50px;line-height: 50px">日期未到</span>
</div>
</div>
</div>
<div class="col-md-12">
<div class="col-sm-3">
</div>
<div class="col-sm-6" id="rqdiv">
</div>
<div class="col-sm-3">
</div>
</div>
</div>
<!-- <div class="modal-body" style="max-height:100%;overflow-y:auto;">
<span>姓名:<input id="username"name="username" style="width:8%;text-align: left;" readonly="readonly"/>
<input id="userid" name="ryid" style="display: none"/>
</span>
<span>项目:
<select id="xmid" class="select2 " name="xmid" style="width:10%">
<option selected="selected" value="">选择一个项目</option>
</select>
</span>
<span>年月选择:<input id="rzdate"name="rzdate" style="width:8%;text-align: left;" class="date-picker" data-flag="datepicker" data-format="yyyy-mm-dd" /></span>
<button type="submit" class="btn btn-primary" data-btn-type="save" id="getRq">确定月份</button>
<span style="display: inline-block;width:60px;background:#ADFF2F;height:50px;line-height: 50px">有日志</span>
<span style="display: inline-block;width:60px;background:#FF4040;height:50px;line-height: 50px">无日志</span>
<span style="display: inline-block;width:60px;background:#ccc;height:50px;line-height: 50px">日期未到</span>
</div>
<div class="modal-body">
<div style="padding-left: 15%;padding-right: 15%;" id="rqdiv">
</div>
</div> -->
</form>
</div>
</div>
</div>
</section>
<script>
var dateMonthConfig = {
language: "zh-CN", //语言
todayHighlight: true, //是否今日高亮
format: 'yyyy-mm', //点击月份后显示在input中的格式
autoclose: true, //是否开启自动关闭
startView: 'months', //开始视图层,为月视图层
maxViewMode:'years', //最大视图层,为年视图层
minViewMode:'months' //最小视图层,为月视图层
//startDate:moment().subtract(11,'month').toDate(), //控制可选的最早月份,为前12个月(含当前月)
//endDate:moment().toDate() //控制可选的最晚月份,为当前月
};
$('#rzdate').datepicker(dateMonthConfig);
var xms = '${xm?default(0)}',xm=0;
if(xms != 0){
xm = JSON.parse(xms);
}
var ryxm = '${ry?default(0)}';
var ryid = '${ryid?default(0)}';
$("#username").val(ryxm);
$("#userid").val(ryid);
var form =null;
$(function() {
//初始化时间框
var date=new Date;
var year=date.getFullYear();
var month=date.getMonth()+1;
month =(month<10 ? "0"+month:month);
$("#rzdate").val(year+"-"+month);
//初始化控件
form=$("#RqForm").form();
//数据校验
$("#RqForm").bootstrapValidator({
message : '请输入有效值',
feedbackIcons : {
valid : 'glyphicon glyphicon-ok',
invalid : 'glyphicon glyphicon-remove',
validating : 'glyphicon glyphicon-refresh'
},
submitHandler : function() {
if(!$("#rzdate").val()){
modals.info("请选择年月");
return ;
}
if(!$("#xmid option:selected").val()){
modals.info("请选择项目");
return ;
}
tcsj();
}
});
form.initComponent();
if(xm != 0){
for (var i = 0, len = xm.length; i < len; i++) {
var u = xm[i];
$('#xmid').append("<option value='" + u.value + "'>" + u.data + "</option>");
}
$(".select2").select2();
}
});
function tcsj(){
$("#rqdiv").empty();
//获取当前月日志
var params = form.getFormSimpleData();
ajaxPost(basePath+'/safediary/getRq', params, function(data) {
if(data.success){
var result = data.data;
for(var i=0;i<result.length;i++){
s1 = new Date(result[i].rq.replace(/-/g, "/"));
s2 = new Date();
var divs ="";
if(result[i].ishave=="1"&&s1<=s2){
divs += '<div class="rqd" style="background-color:#ADFF2F;" onclick="addRz(\''+result[i].rq+'\',\''+result[i].rzid+'\')">';
}else if(s1<=s2){
divs += '<div class="rqd" style="background-color:#FF4040;" onclick="addRz(\''+result[i].rq+'\')">';
}else if(s1>s2){
divs += '<div class="rqd" style="background-color:#ccc;" onclick="addRz(\''+result[i].rq+'\')">';
}
divs+="<span class='rqspan' >"+result[i].ts+"</span>";
divs+='</div>';
$("#rqdiv").append(divs);
}
}
});
}
function addRz(rq,rzid){
if(!$("#xmid option:selected").val()){
modals.info("请选择项目");
return ;
}
s1 = new Date(rq.replace(/-/g, "/"));
s2 = new Date();
if(s1>s2){
modals.info("选择日期未到,不能编写日志!");
return ;
}
var days = s2.getTime() - s1.getTime();
var time = parseInt(days / (1000 * 60 * 60 * 24));
if(parseFloat(time)>parseFloat(2)&&!rzid){
modals.info("选择日期已超两日期限,不能编写日志!");
return ;
}
var url = basePath+"/safediary/addindex?xmid="+$("#xmid option:selected").val()+"&rq="+rq+"&ryid="+ryid;
if(rzid){
url += "&rzid="+rzid;
if(parseFloat(time)>parseFloat(2)){
url += "&lx=look";
}
}
modals.openWin({
winId:"rz",
title:'日志',
width:$(document).width()*0.8 + 'px',
url:url,
hideFunc:function(){
tcsj();
}
});
}
function resetForm(){
form.clearForm();
$("#contract-form").data('bootstrapValidator').resetForm();
}
</script>
| Squama/Master | AdminEAP-web/src/main/webapp/WEB-INF/views/safetyManage/newDiary/grlist.html | HTML | mit | 9,607 | [
30522,
1026,
4957,
2128,
2140,
1027,
1000,
6782,
21030,
2102,
1000,
17850,
12879,
1027,
1000,
1002,
1063,
2918,
15069,
1065,
1013,
4219,
1013,
2691,
1013,
5622,
5910,
1013,
5371,
2378,
18780,
1013,
20116,
2015,
1013,
5371,
2378,
18780,
1012... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
# Rspec Thinking Sphinx matchers
[](https://travis-ci.org/Govinda-Fichtner/rspec-thinking-sphinx-matchers)
Test your Thinking Sphinx 3 index defintions with the custom rspec matchers of this gem.
If you are still using Thinking Sphinx 2 have a look at https://github.com/fuzzyalej/thinking-sphinx-rspec-matchers
I would appreciate feedback very much, in the form of comments, code and/or beer! :-)
# Installation
To install the matchers you only have to add the gem to your test group in `Gemfile`:
group :test do
gem 'rspec-thinking-sphinx-matchers'
end
And then execute:
$ bundle
# Use
describe "fields" do
it { should index :name, :from => :client, :as => :client_name }
it { should index :content }
end
describe "attributes" do
it { should have_attribute :user_id, :as => :users }
end
Field options
:from
:as
:facet
:sortable
Attribute Field options
:from
:as
:facet
# Testing
If you are feeling brave and want to test the gem, simply issue a `bundle exec rspec`. Contributions and enhancements and mostly welcomed!
# References
[1] https://github.com/fuzzyalej/thinking-sphinx-rspec-matchers
[2] http://openmonkey.com/2009/07/19/thinking-sphinx-rspec-matchers/
[3] https://gist.github.com/21755
# Credits
Thanks to Pal Allan from http://freelancing-gods.com/ for creating Thinking Sphinx!
Thanks to Alejandro Andrés for the rspec matchers for ThinkingSphinx v2.
## Contributing
1. Fork it
2. Create your feature branch (`git checkout -b my-new-feature`)
3. Commit your changes (`git commit -am 'Add some feature'`)
4. Push to the branch (`git push origin my-new-feature`)
5. Create new Pull Request
| Govinda-Fichtner/rspec-thinking-sphinx-matchers | README.md | Markdown | mit | 1,855 | [
30522,
1001,
12667,
5051,
2278,
3241,
27311,
2674,
2545,
1031,
999,
1031,
3857,
3570,
1033,
1006,
16770,
1024,
1013,
1013,
10001,
1011,
25022,
1012,
8917,
1013,
18079,
23938,
1011,
10882,
10143,
3678,
1013,
12667,
5051,
2278,
1011,
3241,
10... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
#ifndef _CURVE25519_DONNA_H_
#define _CURVE25519_DONNA_H_
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
typedef uint8_t u8;
int curve25519_donna(u8 *, const u8 *, const u8 *);
#ifdef __cplusplus
}
#endif // __cplusplus
#endif // _CURVE25519_DONNA_H_
| fellownet/micasa | src/plugins/HomeKit/curve25519/curve25519-donna.h | C | mit | 266 | [
30522,
1001,
2065,
13629,
2546,
1035,
7774,
17788,
22203,
2683,
1035,
10972,
1035,
1044,
1035,
1001,
9375,
1035,
7774,
17788,
22203,
2683,
1035,
10972,
1035,
1044,
1035,
1001,
2065,
3207,
2546,
1035,
1035,
18133,
7393,
24759,
2271,
4654,
16... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
xdescribe('uiMask', function () {
var inputHtml = "<input ui-mask=\"'(9)9'\" ng-model='x'>";
var $compile, $rootScope, element;
beforeEach(module('ui.directives'));
beforeEach(inject(function (_$rootScope_, _$compile_) {
$rootScope = _$rootScope_;
$compile = _$compile_;
}));
describe('ui changes on model changes', function () {
it('should update ui valid model value', function () {
$rootScope.x = undefined;
element = $compile(inputHtml)($rootScope);
$rootScope.$digest();
expect(element.val()).toBe('');
$rootScope.$apply(function () {
$rootScope.x = 12;
});
expect(element.val()).toBe('(1)2');
});
it('should wipe out ui on invalid model value', function () {
$rootScope.x = 12;
element = $compile(inputHtml)($rootScope);
$rootScope.$digest();
expect(element.val()).toBe('(1)2');
$rootScope.$apply(function () {
$rootScope.x = 1;
});
expect(element.val()).toBe('');
});
});
describe('model binding on ui change', function () {
//TODO: was having har time writing those tests, will open a separate issue for those
});
describe('should fail', function() {
it('errors on missing quotes', function() {
$rootScope.x = 42;
var errorInputHtml = "<input ui-mask=\"(9)9\" ng-model='x'>";
element = $compile(errorInputHtml)($rootScope);
expect($rootScope.$digest).toThrow('The Mask widget is not correctly set up');
});
});
}); | inergex/meetups | 2014Q2/bower_components/angular-ui/modules/directives/mask/test/maskSpec.js | JavaScript | mit | 1,508 | [
30522,
1060,
6155,
26775,
20755,
1006,
1005,
21318,
9335,
2243,
1005,
1010,
3853,
1006,
1007,
1063,
13075,
7953,
11039,
19968,
1027,
1000,
1026,
7953,
21318,
1011,
7308,
1027,
1032,
1000,
1005,
1006,
1023,
1007,
1023,
1005,
1032,
1000,
1283... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
<!DOCTYPE html>
<HTML><head><TITLE>Manpage of FSYNC</TITLE>
<meta charset="utf-8">
<link rel="stylesheet" href="/css/main.css" type="text/css">
</head>
<body>
<header class="site-header">
<div class="wrap"> <div class="site-title"><a href="/manpages/index.html">linux manpages</a></div>
<div class="site-description">{"type":"documentation"}</div>
</div>
</header>
<div class="page-content"><div class="wrap">
<H1>FSYNC</H1>
Section: Linux Programmer's Manual (2)<BR>Updated: 2008-11-07<BR><A HREF="#index">Index</A>
<A HREF="/manpages/index.html">Return to Main Contents</A><HR>
<A NAME="lbAB"> </A>
<H2>NAME</H2>
fsync, fdatasync - synchronize a file's in-core state with storage device
<A NAME="lbAC"> </A>
<H2>SYNOPSIS</H2>
<B>#include <<A HREF="file:/usr/include/unistd.h">unistd.h</A>></B>
<P>
<B>int fsync(int </B><I>fd</I><B>);</B>
<P>
<B>int fdatasync(int </B><I>fd</I><B>);</B>
<P>
Feature Test Macro Requirements for glibc (see
<B><A HREF="/manpages/index.html?7+feature_test_macros">feature_test_macros</A></B>(7)):
<P>
<B>fsync</B>():
_BSD_SOURCE || _XOPEN_SOURCE
<BR>
<BR> || /* since glibc 2.8: */ _POSIX_C_SOURCE >= 200112L
<BR>
<B>fdatasync</B>():
_POSIX_C_SOURCE >= 199309L || _XOPEN_SOURCE >= 500
<A NAME="lbAD"> </A>
<H2>DESCRIPTION</H2>
<B>fsync</B>()
transfers ("flushes") all modified in-core data of
(i.e., modified buffer cache pages for) the
file referred to by the file descriptor
<I>fd</I>
to the disk device (or other permanent storage device)
where that file resides.
The call blocks until the device reports that the transfer has completed.
It also flushes metadata information associated with the file (see
<B><A HREF="/manpages/index.html?2+stat">stat</A></B>(2)).
<P>
Calling
<B>fsync</B>()
does not necessarily ensure
that the entry in the directory containing the file has also reached disk.
For that an explicit
<B>fsync</B>()
on a file descriptor for the directory is also needed.
<P>
<B>fdatasync</B>()
is similar to
<B>fsync</B>(),
but does not flush modified metadata unless that metadata
is needed in order to allow a subsequent data retrieval to be
correctly handled.
For example, changes to
<I>st_atime</I>
or
<I>st_mtime</I>
(respectively, time of last access and
time of last modification; see
<B><A HREF="/manpages/index.html?2+stat">stat</A></B>(2))
do not require flushing because they are not necessary for
a subsequent data read to be handled correctly.
On the other hand, a change to the file size
(<I>st_size</I>,
as made by say
<B><A HREF="/manpages/index.html?2+ftruncate">ftruncate</A></B>(2)),
would require a metadata flush.
<P>
The aim of
<B>fdatasync</B>()
is to reduce disk activity for applications that do not
require all metadata to be synchronized with the disk.
<A NAME="lbAE"> </A>
<H2>RETURN VALUE</H2>
On success, these system calls return zero.
On error, -1 is returned, and
<I>errno</I>
is set appropriately.
<A NAME="lbAF"> </A>
<H2>ERRORS</H2>
<DL COMPACT>
<DT><B>EBADF</B>
<DD>
<I>fd</I>
is not a valid file descriptor open for writing.
<DT><B>EIO</B>
<DD>
An error occurred during synchronization.
<DT><B>EROFS</B>, <B>EINVAL</B>
<DD>
<I>fd</I>
is bound to a special file which does not support synchronization.
</DL>
<A NAME="lbAG"> </A>
<H2>CONFORMING TO</H2>
4.3BSD, POSIX.1-2001.
<A NAME="lbAH"> </A>
<H2>AVAILABILITY</H2>
On POSIX systems on which
<B>fdatasync</B>()
is available,
<B>_POSIX_SYNCHRONIZED_IO</B>
is defined in
<I><<A HREF="file:/usr/include/unistd.h">unistd.h</A>></I>
to a value greater than 0.
(See also
<B><A HREF="/manpages/index.html?3+sysconf">sysconf</A></B>(3).)
<A NAME="lbAI"> </A>
<H2>NOTES</H2>
Applications that access databases or log files often write a tiny
data fragment (e.g., one line in a log file) and then call
<B>fsync</B>()
immediately in order to ensure that the written data is physically
stored on the harddisk.
Unfortunately,
<B>fsync</B>()
will always initiate two write operations: one for the newly written
data and another one in order to update the modification time stored
in the inode.
If the modification time is not a part of the transaction
concept
<B>fdatasync</B>()
can be used to avoid unnecessary inode disk write operations.
<P>
If the underlying hard disk has write caching enabled, then
the data may not really be on permanent storage when
<B>fsync</B>()
/
<B>fdatasync</B>()
return.
<P>
When an ext2 file system is mounted with the
<I>sync</I>
option, directory entries are also implicitly synced by
<B>fsync</B>().
<P>
On kernels before 2.4,
<B>fsync</B>()
on big files can be inefficient.
An alternative might be to use the
<B>O_SYNC</B>
flag to
<B><A HREF="/manpages/index.html?2+open">open</A></B>(2).
<P>
In Linux 2.2 and earlier,
<B>fdatasync</B>()
is equivalent to
<B>fsync</B>(),
and so has no performance advantage.
<A NAME="lbAJ"> </A>
<H2>SEE ALSO</H2>
<B><A HREF="/manpages/index.html?2+bdflush">bdflush</A></B>(2),
<B><A HREF="/manpages/index.html?2+open">open</A></B>(2),
<B><A HREF="/manpages/index.html?2+sync">sync</A></B>(2),
<B><A HREF="/manpages/index.html?2+sync_file_range">sync_file_range</A></B>(2),
<B><A HREF="/manpages/index.html?8+hdparm">hdparm</A></B>(8),
<B><A HREF="/manpages/index.html?8+mount">mount</A></B>(8),
<B><A HREF="/manpages/index.html?8+sync">sync</A></B>(8),
<B><A HREF="/manpages/index.html?8+update">update</A></B>(8)
<A NAME="lbAK"> </A>
<H2>COLOPHON</H2>
This page is part of release 3.22 of the Linux
<I>man-pages</I>
project.
A description of the project,
and information about reporting bugs,
can be found at
<A HREF="http://www.kernel.org/doc/man-pages/.">http://www.kernel.org/doc/man-pages/.</A>
<P>
<HR>
<A NAME="index"> </A><H2>Index</H2>
<DL>
<DT><A HREF="#lbAB">NAME</A><DD>
<DT><A HREF="#lbAC">SYNOPSIS</A><DD>
<DT><A HREF="#lbAD">DESCRIPTION</A><DD>
<DT><A HREF="#lbAE">RETURN VALUE</A><DD>
<DT><A HREF="#lbAF">ERRORS</A><DD>
<DT><A HREF="#lbAG">CONFORMING TO</A><DD>
<DT><A HREF="#lbAH">AVAILABILITY</A><DD>
<DT><A HREF="#lbAI">NOTES</A><DD>
<DT><A HREF="#lbAJ">SEE ALSO</A><DD>
<DT><A HREF="#lbAK">COLOPHON</A><DD>
</DL>
<HR>
This document was created by
<A HREF="/manpages/index.html">man2html</A>,
using the manual pages.<BR>
Time: 05:33:03 GMT, December 24, 2015
</div></div>
</body>
</HTML>
| yuweijun/yuweijun.github.io | manpages/man2/fsync.2.html | HTML | mit | 6,480 | [
30522,
1026,
999,
9986,
13874,
16129,
1028,
1026,
16129,
1028,
1026,
2132,
1028,
1026,
2516,
1028,
2158,
13704,
1997,
1042,
6508,
12273,
1026,
1013,
2516,
1028,
1026,
18804,
25869,
13462,
1027,
1000,
21183,
2546,
1011,
1022,
1000,
1028,
102... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
package com.socialthingy.plusf.z80.operations;
import com.socialthingy.plusf.z80.Clock;
import com.socialthingy.plusf.z80.ContentionModel;
import com.socialthingy.plusf.z80.Processor;
import com.socialthingy.plusf.z80.Register;
public class OpAddAIndexed8Reg extends ArithmeticOperation {
private final Register register;
private final String toString;
public OpAddAIndexed8Reg(final Processor processor, final Register register, final boolean useCarryFlag) {
super(processor, useCarryFlag);
this.register = register;
if (useCarryFlag) {
this.toString = "adc a, " + register.name();
} else {
this.toString = "add a, " + register.name();
}
}
@Override
public void execute(ContentionModel contentionModel, int initialPcValue, int irValue) {
contentionModel.applyContention(initialPcValue, 4);
contentionModel.applyContention(initialPcValue + 1, 4);
add(register.get());
}
@Override
public String toString() {
return toString;
}
} | alangibson27/plus-f | plus-f/src/main/java/com/socialthingy/plusf/z80/operations/OpAddAIndexed8Reg.java | Java | mit | 1,070 | [
30522,
7427,
4012,
1012,
2591,
20744,
2100,
1012,
4606,
2546,
1012,
1062,
17914,
1012,
3136,
1025,
12324,
4012,
1012,
2591,
20744,
2100,
1012,
4606,
2546,
1012,
1062,
17914,
1012,
5119,
1025,
12324,
4012,
1012,
2591,
20744,
2100,
1012,
4606... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
import { ComponentRef, DebugElement } from '@angular/core';
import { ComponentFixture } from '@angular/core/testing';
export function doClassesMatch(resultClasses: DOMTokenList, expectedClasses: string[]): boolean {
let classesMatch = true;
let currentClass: string = null;
for (let i = 0; i < expectedClasses.length; i++) {
currentClass = expectedClasses[i];
classesMatch = resultClasses.contains(currentClass);
if (!classesMatch) {
break;
}
}
return classesMatch;
}
| testing-angular-applications/contacts-app-starter | website/src/app/contacts/testing/do-classes-match.ts | TypeScript | mit | 504 | [
30522,
12324,
1063,
6922,
2890,
2546,
1010,
2139,
8569,
12439,
13665,
1065,
2013,
1005,
1030,
16108,
1013,
4563,
1005,
1025,
12324,
1063,
6922,
8873,
18413,
5397,
1065,
2013,
1005,
1030,
16108,
1013,
4563,
1013,
5604,
1005,
1025,
9167,
3853... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js" type="text/javascript" charset="utf-8"></script>
<script src="specimen_files/easytabs.js" type="text/javascript" charset="utf-8"></script>
<link rel="stylesheet" href="specimen_files/specimen_stylesheet.css" type="text/css" charset="utf-8" />
<link rel="stylesheet" href="stylesheet.css" type="text/css" charset="utf-8" />
<style type="text/css">
body{
font-family: 'ralewaythin';
}
</style>
<title>Raleway Thin Specimen</title>
<script type="text/javascript" charset="utf-8">
$(document).ready(function() {
$('#container').easyTabs({defaultContent:1});
});
</script>
</head>
<body>
<div id="container">
<div id="header">
Raleway Thin </div>
<ul class="tabs">
<li><a href="#specimen">Specimen</a></li>
<li><a href="#layout">Sample Layout</a></li>
<li><a href="#glyphs">Glyphs & Languages</a></li>
<li><a href="#installing">Installing Webfonts</a></li>
</ul>
<div id="main_content">
<div id="specimen">
<div class="section">
<div class="grid12 firstcol">
<div class="huge">AaBb</div>
</div>
</div>
<div class="section">
<div class="glyph_range">A​B​C​D​E​F​G​H​I​J​K​L​M​N​O​P​Q​R​S​T​U​V​W​X​Y​Z​a​b​c​d​e​f​g​h​i​j​k​l​m​n​o​p​q​r​s​t​u​v​w​x​y​z​1​2​3​4​5​6​7​8​9​0​&​.​,​?​!​@​(​)​#​$​%​*​+​-​=​:​;</div>
</div>
<div class="section">
<div class="grid12 firstcol">
<table class="sample_table">
<tr><td>10</td><td class="size10">abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ</td></tr>
<tr><td>11</td><td class="size11">abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ</td></tr>
<tr><td>12</td><td class="size12">abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ</td></tr>
<tr><td>13</td><td class="size13">abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ</td></tr>
<tr><td>14</td><td class="size14">abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ</td></tr>
<tr><td>16</td><td class="size16">abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ</td></tr>
<tr><td>18</td><td class="size18">abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ</td></tr>
<tr><td>20</td><td class="size20">abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ</td></tr>
<tr><td>24</td><td class="size24">abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ</td></tr>
<tr><td>30</td><td class="size30">abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ</td></tr>
<tr><td>36</td><td class="size36">abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ</td></tr>
<tr><td>48</td><td class="size48">abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ</td></tr>
<tr><td>60</td><td class="size60">abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ</td></tr>
<tr><td>72</td><td class="size72">abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ</td></tr>
<tr><td>90</td><td class="size90">abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ</td></tr>
</table>
</div>
</div>
<div class="section" id="bodycomparison">
<div id="xheight">
<div class="fontbody">◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼body</div><div class="arialbody">body</div><div class="verdanabody">body</div><div class="georgiabody">body</div></div>
<div class="fontbody" style="z-index:1">
body<span>Raleway Thin</span>
</div>
<div class="arialbody" style="z-index:1">
body<span>Arial</span>
</div>
<div class="verdanabody" style="z-index:1">
body<span>Verdana</span>
</div>
<div class="georgiabody" style="z-index:1">
body<span>Georgia</span>
</div>
</div>
<div class="section psample psample_row1" id="">
<div class="grid2 firstcol">
<p class="size10"><span>10.</span>Aenean lacinia bibendum nulla sed consectetur. Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit amet risus. Nullam id dolor id nibh ultricies vehicula ut id elit. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Nulla vitae elit libero, a pharetra augue.</p>
</div>
<div class="grid3">
<p class="size11"><span>11.</span>Aenean lacinia bibendum nulla sed consectetur. Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit amet risus. Nullam id dolor id nibh ultricies vehicula ut id elit. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Nulla vitae elit libero, a pharetra augue.</p>
</div>
<div class="grid3">
<p class="size12"><span>12.</span>Aenean lacinia bibendum nulla sed consectetur. Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit amet risus. Nullam id dolor id nibh ultricies vehicula ut id elit. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Nulla vitae elit libero, a pharetra augue.</p>
</div>
<div class="grid4">
<p class="size13"><span>13.</span>Aenean lacinia bibendum nulla sed consectetur. Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit amet risus. Nullam id dolor id nibh ultricies vehicula ut id elit. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Nulla vitae elit libero, a pharetra augue.</p>
</div>
<div class="white_blend"></div>
</div>
<div class="section psample psample_row2" id="">
<div class="grid3 firstcol">
<p class="size14"><span>14.</span>Aenean lacinia bibendum nulla sed consectetur. Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit amet risus. Nullam id dolor id nibh ultricies vehicula ut id elit. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Nulla vitae elit libero, a pharetra augue.</p>
</div>
<div class="grid4">
<p class="size16"><span>16.</span>Aenean lacinia bibendum nulla sed consectetur. Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit amet risus. Nullam id dolor id nibh ultricies vehicula ut id elit. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Nulla vitae elit libero, a pharetra augue.</p>
</div>
<div class="grid5">
<p class="size18"><span>18.</span>Aenean lacinia bibendum nulla sed consectetur. Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit amet risus. Nullam id dolor id nibh ultricies vehicula ut id elit. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Nulla vitae elit libero, a pharetra augue.</p>
</div>
<div class="white_blend"></div>
</div>
<div class="section psample psample_row3" id="">
<div class="grid5 firstcol">
<p class="size20"><span>20.</span>Aenean lacinia bibendum nulla sed consectetur. Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit amet risus. Nullam id dolor id nibh ultricies vehicula ut id elit. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Nulla vitae elit libero, a pharetra augue.</p>
</div>
<div class="grid7">
<p class="size24"><span>24.</span>Aenean lacinia bibendum nulla sed consectetur. Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit amet risus. Nullam id dolor id nibh ultricies vehicula ut id elit. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Nulla vitae elit libero, a pharetra augue.</p>
</div>
<div class="white_blend"></div>
</div>
<div class="section psample psample_row4" id="">
<div class="grid12 firstcol">
<p class="size30"><span>30.</span>Aenean lacinia bibendum nulla sed consectetur. Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit amet risus. Nullam id dolor id nibh ultricies vehicula ut id elit. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Nulla vitae elit libero, a pharetra augue.</p>
</div>
<div class="white_blend"></div>
</div>
<div class="section psample psample_row1 fullreverse">
<div class="grid2 firstcol">
<p class="size10"><span>10.</span>Aenean lacinia bibendum nulla sed consectetur. Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit amet risus. Nullam id dolor id nibh ultricies vehicula ut id elit. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Nulla vitae elit libero, a pharetra augue.</p>
</div>
<div class="grid3">
<p class="size11"><span>11.</span>Aenean lacinia bibendum nulla sed consectetur. Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit amet risus. Nullam id dolor id nibh ultricies vehicula ut id elit. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Nulla vitae elit libero, a pharetra augue.</p>
</div>
<div class="grid3">
<p class="size12"><span>12.</span>Aenean lacinia bibendum nulla sed consectetur. Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit amet risus. Nullam id dolor id nibh ultricies vehicula ut id elit. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Nulla vitae elit libero, a pharetra augue.</p>
</div>
<div class="grid4">
<p class="size13"><span>13.</span>Aenean lacinia bibendum nulla sed consectetur. Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit amet risus. Nullam id dolor id nibh ultricies vehicula ut id elit. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Nulla vitae elit libero, a pharetra augue.</p>
</div>
<div class="black_blend"></div>
</div>
<div class="section psample psample_row2 fullreverse">
<div class="grid3 firstcol">
<p class="size14"><span>14.</span>Aenean lacinia bibendum nulla sed consectetur. Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit amet risus. Nullam id dolor id nibh ultricies vehicula ut id elit. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Nulla vitae elit libero, a pharetra augue.</p>
</div>
<div class="grid4">
<p class="size16"><span>16.</span>Aenean lacinia bibendum nulla sed consectetur. Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit amet risus. Nullam id dolor id nibh ultricies vehicula ut id elit. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Nulla vitae elit libero, a pharetra augue.</p>
</div>
<div class="grid5">
<p class="size18"><span>18.</span>Aenean lacinia bibendum nulla sed consectetur. Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit amet risus. Nullam id dolor id nibh ultricies vehicula ut id elit. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Nulla vitae elit libero, a pharetra augue.</p>
</div>
<div class="black_blend"></div>
</div>
<div class="section psample fullreverse psample_row3" id="">
<div class="grid5 firstcol">
<p class="size20"><span>20.</span>Aenean lacinia bibendum nulla sed consectetur. Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit amet risus. Nullam id dolor id nibh ultricies vehicula ut id elit. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Nulla vitae elit libero, a pharetra augue.</p>
</div>
<div class="grid7">
<p class="size24"><span>24.</span>Aenean lacinia bibendum nulla sed consectetur. Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit amet risus. Nullam id dolor id nibh ultricies vehicula ut id elit. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Nulla vitae elit libero, a pharetra augue.</p>
</div>
<div class="black_blend"></div>
</div>
<div class="section psample fullreverse psample_row4" id="" style="border-bottom: 20px #000 solid;">
<div class="grid12 firstcol">
<p class="size30"><span>30.</span>Aenean lacinia bibendum nulla sed consectetur. Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit amet risus. Nullam id dolor id nibh ultricies vehicula ut id elit. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Nulla vitae elit libero, a pharetra augue.</p>
</div>
<div class="black_blend"></div>
</div>
</div>
<div id="layout">
<div class="section">
<div class="grid12 firstcol">
<h1>Lorem Ipsum Dolor</h1>
<h2>Etiam porta sem malesuada magna mollis euismod</h2>
<p class="byline">By <a href="#link">Aenean Lacinia</a></p>
</div>
</div>
<div class="section">
<div class="grid8 firstcol">
<p class="large">Donec sed odio dui. Morbi leo risus, porta ac consectetur ac, vestibulum at eros. Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit amet risus. </p>
<h3>Pellentesque ornare sem</h3>
<p>Maecenas sed diam eget risus varius blandit sit amet non magna. Maecenas faucibus mollis interdum. Donec ullamcorper nulla non metus auctor fringilla. Nullam id dolor id nibh ultricies vehicula ut id elit. Nullam id dolor id nibh ultricies vehicula ut id elit. </p>
<p>Aenean eu leo quam. Pellentesque ornare sem lacinia quam venenatis vestibulum. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. </p>
<p>Nulla vitae elit libero, a pharetra augue. Praesent commodo cursus magna, vel scelerisque nisl consectetur et. Aenean lacinia bibendum nulla sed consectetur. </p>
<p>Nullam quis risus eget urna mollis ornare vel eu leo. Nullam quis risus eget urna mollis ornare vel eu leo. Maecenas sed diam eget risus varius blandit sit amet non magna. Donec ullamcorper nulla non metus auctor fringilla. </p>
<h3>Cras mattis consectetur</h3>
<p>Aenean eu leo quam. Pellentesque ornare sem lacinia quam venenatis vestibulum. Aenean lacinia bibendum nulla sed consectetur. Integer posuere erat a ante venenatis dapibus posuere velit aliquet. Cras mattis consectetur purus sit amet fermentum. </p>
<p>Nullam id dolor id nibh ultricies vehicula ut id elit. Nullam quis risus eget urna mollis ornare vel eu leo. Cras mattis consectetur purus sit amet fermentum.</p>
</div>
<div class="grid4 sidebar">
<div class="box reverse">
<p class="last">Nullam quis risus eget urna mollis ornare vel eu leo. Donec ullamcorper nulla non metus auctor fringilla. Cras mattis consectetur purus sit amet fermentum. Sed posuere consectetur est at lobortis. Lorem ipsum dolor sit amet, consectetur adipiscing elit. </p>
</div>
<p class="caption">Maecenas sed diam eget risus varius.</p>
<p>Vestibulum id ligula porta felis euismod semper. Integer posuere erat a ante venenatis dapibus posuere velit aliquet. Vestibulum id ligula porta felis euismod semper. Sed posuere consectetur est at lobortis. Maecenas sed diam eget risus varius blandit sit amet non magna. Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit amet risus. </p>
<p>Duis mollis, est non commodo luctus, nisi erat porttitor ligula, eget lacinia odio sem nec elit. Aenean lacinia bibendum nulla sed consectetur. Vivamus sagittis lacus vel augue laoreet rutrum faucibus dolor auctor. Aenean lacinia bibendum nulla sed consectetur. Nullam quis risus eget urna mollis ornare vel eu leo. </p>
<p>Praesent commodo cursus magna, vel scelerisque nisl consectetur et. Donec ullamcorper nulla non metus auctor fringilla. Maecenas faucibus mollis interdum. Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit amet risus. </p>
</div>
</div>
</div>
<div id="glyphs">
<div class="section">
<div class="grid12 firstcol">
<h1>Language Support</h1>
<p>The subset of Raleway Thin in this kit supports the following languages:<br />
Albanian, Basque, Breton, Chamorro, Danish, Dutch, English, Faroese, Finnish, French, Frisian, Galician, German, Icelandic, Italian, Malagasy, Norwegian, Portuguese, Spanish, Swedish </p>
<h1>Glyph Chart</h1>
<p>The subset of Raleway Thin in this kit includes all the glyphs listed below. Unicode entities are included above each glyph to help you insert individual characters into your layout.</p>
<div id="glyph_chart">
<div><p>&#13;</p> </div>
<div><p>&#32;</p> </div>
<div><p>&#33;</p>!</div>
<div><p>&#34;</p>"</div>
<div><p>&#35;</p>#</div>
<div><p>&#36;</p>$</div>
<div><p>&#37;</p>%</div>
<div><p>&#38;</p>&</div>
<div><p>&#39;</p>'</div>
<div><p>&#40;</p>(</div>
<div><p>&#41;</p>)</div>
<div><p>&#42;</p>*</div>
<div><p>&#43;</p>+</div>
<div><p>&#44;</p>,</div>
<div><p>&#45;</p>-</div>
<div><p>&#46;</p>.</div>
<div><p>&#47;</p>/</div>
<div><p>&#48;</p>0</div>
<div><p>&#49;</p>1</div>
<div><p>&#50;</p>2</div>
<div><p>&#51;</p>3</div>
<div><p>&#52;</p>4</div>
<div><p>&#53;</p>5</div>
<div><p>&#54;</p>6</div>
<div><p>&#55;</p>7</div>
<div><p>&#56;</p>8</div>
<div><p>&#57;</p>9</div>
<div><p>&#58;</p>:</div>
<div><p>&#59;</p>;</div>
<div><p>&#60;</p><</div>
<div><p>&#61;</p>=</div>
<div><p>&#62;</p>></div>
<div><p>&#63;</p>?</div>
<div><p>&#64;</p>@</div>
<div><p>&#65;</p>A</div>
<div><p>&#66;</p>B</div>
<div><p>&#67;</p>C</div>
<div><p>&#68;</p>D</div>
<div><p>&#69;</p>E</div>
<div><p>&#70;</p>F</div>
<div><p>&#71;</p>G</div>
<div><p>&#72;</p>H</div>
<div><p>&#73;</p>I</div>
<div><p>&#74;</p>J</div>
<div><p>&#75;</p>K</div>
<div><p>&#76;</p>L</div>
<div><p>&#77;</p>M</div>
<div><p>&#78;</p>N</div>
<div><p>&#79;</p>O</div>
<div><p>&#80;</p>P</div>
<div><p>&#81;</p>Q</div>
<div><p>&#82;</p>R</div>
<div><p>&#83;</p>S</div>
<div><p>&#84;</p>T</div>
<div><p>&#85;</p>U</div>
<div><p>&#86;</p>V</div>
<div><p>&#87;</p>W</div>
<div><p>&#88;</p>X</div>
<div><p>&#89;</p>Y</div>
<div><p>&#90;</p>Z</div>
<div><p>&#91;</p>[</div>
<div><p>&#92;</p>\</div>
<div><p>&#93;</p>]</div>
<div><p>&#94;</p>^</div>
<div><p>&#95;</p>_</div>
<div><p>&#96;</p>`</div>
<div><p>&#97;</p>a</div>
<div><p>&#98;</p>b</div>
<div><p>&#99;</p>c</div>
<div><p>&#100;</p>d</div>
<div><p>&#101;</p>e</div>
<div><p>&#102;</p>f</div>
<div><p>&#103;</p>g</div>
<div><p>&#104;</p>h</div>
<div><p>&#105;</p>i</div>
<div><p>&#106;</p>j</div>
<div><p>&#107;</p>k</div>
<div><p>&#108;</p>l</div>
<div><p>&#109;</p>m</div>
<div><p>&#110;</p>n</div>
<div><p>&#111;</p>o</div>
<div><p>&#112;</p>p</div>
<div><p>&#113;</p>q</div>
<div><p>&#114;</p>r</div>
<div><p>&#115;</p>s</div>
<div><p>&#116;</p>t</div>
<div><p>&#117;</p>u</div>
<div><p>&#118;</p>v</div>
<div><p>&#119;</p>w</div>
<div><p>&#120;</p>x</div>
<div><p>&#121;</p>y</div>
<div><p>&#122;</p>z</div>
<div><p>&#123;</p>{</div>
<div><p>&#124;</p>|</div>
<div><p>&#125;</p>}</div>
<div><p>&#126;</p>~</div>
<div><p>&#160;</p> </div>
<div><p>&#161;</p>¡</div>
<div><p>&#162;</p>¢</div>
<div><p>&#163;</p>£</div>
<div><p>&#165;</p>¥</div>
<div><p>&#166;</p>¦</div>
<div><p>&#167;</p>§</div>
<div><p>&#168;</p>¨</div>
<div><p>&#169;</p>©</div>
<div><p>&#170;</p>ª</div>
<div><p>&#171;</p>«</div>
<div><p>&#172;</p>¬</div>
<div><p>&#173;</p>­</div>
<div><p>&#174;</p>®</div>
<div><p>&#175;</p>¯</div>
<div><p>&#176;</p>°</div>
<div><p>&#177;</p>±</div>
<div><p>&#178;</p>²</div>
<div><p>&#179;</p>³</div>
<div><p>&#180;</p>´</div>
<div><p>&#181;</p>µ</div>
<div><p>&#182;</p>¶</div>
<div><p>&#183;</p>·</div>
<div><p>&#184;</p>¸</div>
<div><p>&#185;</p>¹</div>
<div><p>&#186;</p>º</div>
<div><p>&#187;</p>»</div>
<div><p>&#188;</p>¼</div>
<div><p>&#189;</p>½</div>
<div><p>&#190;</p>¾</div>
<div><p>&#191;</p>¿</div>
<div><p>&#192;</p>À</div>
<div><p>&#193;</p>Á</div>
<div><p>&#194;</p>Â</div>
<div><p>&#195;</p>Ã</div>
<div><p>&#196;</p>Ä</div>
<div><p>&#197;</p>Å</div>
<div><p>&#198;</p>Æ</div>
<div><p>&#199;</p>Ç</div>
<div><p>&#200;</p>È</div>
<div><p>&#201;</p>É</div>
<div><p>&#202;</p>Ê</div>
<div><p>&#203;</p>Ë</div>
<div><p>&#204;</p>Ì</div>
<div><p>&#205;</p>Í</div>
<div><p>&#206;</p>Î</div>
<div><p>&#207;</p>Ï</div>
<div><p>&#208;</p>Ð</div>
<div><p>&#209;</p>Ñ</div>
<div><p>&#210;</p>Ò</div>
<div><p>&#211;</p>Ó</div>
<div><p>&#212;</p>Ô</div>
<div><p>&#213;</p>Õ</div>
<div><p>&#214;</p>Ö</div>
<div><p>&#215;</p>×</div>
<div><p>&#216;</p>Ø</div>
<div><p>&#217;</p>Ù</div>
<div><p>&#218;</p>Ú</div>
<div><p>&#219;</p>Û</div>
<div><p>&#220;</p>Ü</div>
<div><p>&#221;</p>Ý</div>
<div><p>&#222;</p>Þ</div>
<div><p>&#223;</p>ß</div>
<div><p>&#224;</p>à</div>
<div><p>&#225;</p>á</div>
<div><p>&#226;</p>â</div>
<div><p>&#227;</p>ã</div>
<div><p>&#228;</p>ä</div>
<div><p>&#229;</p>å</div>
<div><p>&#230;</p>æ</div>
<div><p>&#231;</p>ç</div>
<div><p>&#232;</p>è</div>
<div><p>&#233;</p>é</div>
<div><p>&#234;</p>ê</div>
<div><p>&#235;</p>ë</div>
<div><p>&#236;</p>ì</div>
<div><p>&#237;</p>í</div>
<div><p>&#238;</p>î</div>
<div><p>&#239;</p>ï</div>
<div><p>&#240;</p>ð</div>
<div><p>&#241;</p>ñ</div>
<div><p>&#242;</p>ò</div>
<div><p>&#243;</p>ó</div>
<div><p>&#244;</p>ô</div>
<div><p>&#245;</p>õ</div>
<div><p>&#246;</p>ö</div>
<div><p>&#247;</p>÷</div>
<div><p>&#248;</p>ø</div>
<div><p>&#249;</p>ù</div>
<div><p>&#250;</p>ú</div>
<div><p>&#251;</p>û</div>
<div><p>&#252;</p>ü</div>
<div><p>&#253;</p>ý</div>
<div><p>&#254;</p>þ</div>
<div><p>&#255;</p>ÿ</div>
<div><p>&#338;</p>Œ</div>
<div><p>&#339;</p>œ</div>
<div><p>&#376;</p>Ÿ</div>
<div><p>&#710;</p>ˆ</div>
<div><p>&#732;</p>˜</div>
<div><p>&#8192;</p> </div>
<div><p>&#8193;</p> </div>
<div><p>&#8194;</p> </div>
<div><p>&#8195;</p> </div>
<div><p>&#8196;</p> </div>
<div><p>&#8197;</p> </div>
<div><p>&#8198;</p> </div>
<div><p>&#8199;</p> </div>
<div><p>&#8200;</p> </div>
<div><p>&#8201;</p> </div>
<div><p>&#8202;</p> </div>
<div><p>&#8208;</p>‐</div>
<div><p>&#8209;</p>‑</div>
<div><p>&#8210;</p>‒</div>
<div><p>&#8211;</p>–</div>
<div><p>&#8212;</p>—</div>
<div><p>&#8216;</p>‘</div>
<div><p>&#8217;</p>’</div>
<div><p>&#8218;</p>‚</div>
<div><p>&#8220;</p>“</div>
<div><p>&#8221;</p>”</div>
<div><p>&#8222;</p>„</div>
<div><p>&#8226;</p>•</div>
<div><p>&#8230;</p>…</div>
<div><p>&#8239;</p> </div>
<div><p>&#8249;</p>‹</div>
<div><p>&#8250;</p>›</div>
<div><p>&#8287;</p> </div>
<div><p>&#8364;</p>€</div>
<div><p>&#8482;</p>™</div>
<div><p>&#9724;</p>◼</div>
<div><p>&#64257;</p>fi</div>
<div><p>&#64258;</p>fl</div>
<div><p>&#64259;</p>ffi</div>
<div><p>&#64260;</p>ffl</div>
</div>
</div>
</div>
</div>
<div id="specs">
</div>
<div id="installing">
<div class="section">
<div class="grid7 firstcol">
<h1>Installing Webfonts</h1>
<p>Webfonts are supported by all major browser platforms but not all in the same way. There are currently four different font formats that must be included in order to target all browsers. This includes TTF, WOFF, EOT and SVG.</p>
<h2>1. Upload your webfonts</h2>
<p>You must upload your webfont kit to your website. They should be in or near the same directory as your CSS files.</p>
<h2>2. Include the webfont stylesheet</h2>
<p>A special CSS @font-face declaration helps the various browsers select the appropriate font it needs without causing you a bunch of headaches. Learn more about this syntax by reading the <a href="http://www.fontspring.com/blog/further-hardening-of-the-bulletproof-syntax">Fontspring blog post</a> about it. The code for it is as follows:</p>
<code>
@font-face{
font-family: 'MyWebFont';
src: url('WebFont.eot');
src: url('WebFont.eot?#iefix') format('embedded-opentype'),
url('WebFont.woff') format('woff'),
url('WebFont.ttf') format('truetype'),
url('WebFont.svg#webfont') format('svg');
}
</code>
<p>We've already gone ahead and generated the code for you. All you have to do is link to the stylesheet in your HTML, like this:</p>
<code><link rel="stylesheet" href="stylesheet.css" type="text/css" charset="utf-8" /></code>
<h2>3. Modify your own stylesheet</h2>
<p>To take advantage of your new fonts, you must tell your stylesheet to use them. Look at the original @font-face declaration above and find the property called "font-family." The name linked there will be what you use to reference the font. Prepend that webfont name to the font stack in the "font-family" property, inside the selector you want to change. For example:</p>
<code>p { font-family: 'WebFont', Arial, sans-serif; }</code>
<h2>4. Test</h2>
<p>Getting webfonts to work cross-browser <em>can</em> be tricky. Use the information in the sidebar to help you if you find that fonts aren't loading in a particular browser.</p>
</div>
<div class="grid5 sidebar">
<div class="box">
<h2>Troubleshooting<br />Font-Face Problems</h2>
<p>Having trouble getting your webfonts to load in your new website? Here are some tips to sort out what might be the problem.</p>
<h3>Fonts not showing in any browser</h3>
<p>This sounds like you need to work on the plumbing. You either did not upload the fonts to the correct directory, or you did not link the fonts properly in the CSS. If you've confirmed that all this is correct and you still have a problem, take a look at your .htaccess file and see if requests are getting intercepted.</p>
<h3>Fonts not loading in iPhone or iPad</h3>
<p>The most common problem here is that you are serving the fonts from an IIS server. IIS refuses to serve files that have unknown MIME types. If that is the case, you must set the MIME type for SVG to "image/svg+xml" in the server settings. Follow these instructions from Microsoft if you need help.</p>
<h3>Fonts not loading in Firefox</h3>
<p>The primary reason for this failure? You are still using a version Firefox older than 3.5. So upgrade already! If that isn't it, then you are very likely serving fonts from a different domain. Firefox requires that all font assets be served from the same domain. Lastly it is possible that you need to add WOFF to your list of MIME types (if you are serving via IIS.)</p>
<h3>Fonts not loading in IE</h3>
<p>Are you looking at Internet Explorer on an actual Windows machine or are you cheating by using a service like Adobe BrowserLab? Many of these screenshot services do not render @font-face for IE. Best to test it on a real machine.</p>
<h3>Fonts not loading in IE9</h3>
<p>IE9, like Firefox, requires that fonts be served from the same domain as the website. Make sure that is the case.</p>
</div>
</div>
</div>
</div>
</div>
<div id="footer">
<p>©2010-2011 Font Squirrel. All rights reserved.</p>
</div>
</div>
</body>
</html>
| yujihayashi/socialismosustentavel | wp-content/themes/socialismosustentavel/fonts/raleway-thin-demo.html | HTML | gpl-2.0 | 37,757 | [
30522,
1026,
999,
9986,
13874,
16129,
2270,
1000,
1011,
1013,
1013,
1059,
2509,
2278,
1013,
1013,
26718,
2094,
1060,
11039,
19968,
1015,
1012,
1014,
17459,
1013,
1013,
4372,
1000,
1000,
8299,
1024,
1013,
1013,
7479,
1012,
1059,
2509,
1012,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
# coding: UTF-8
name 'ops_tcpdump_handler'
maintainer 'Operations Infrastructure Team - Cerner Innovation, Inc.'
maintainer_email 'OpsInfraTeam@cerner.com'
license 'Apache 2.0'
description 'Installs/Configures ops_tcpdump_handler'
long_description IO.read(File.join(File.dirname(__FILE__), 'README.md'))
version '1.1.0'
supports 'ubuntu'
supports 'centos'
supports 'redhat'
depends 'runit', '~> 1.5'
| cerner/ops_tcpdump_handler | metadata.rb | Ruby | apache-2.0 | 444 | [
30522,
1001,
16861,
1024,
21183,
2546,
1011,
1022,
2171,
1005,
23092,
1035,
30524,
27843,
27058,
2213,
1030,
8292,
18703,
1012,
4012,
1005,
6105,
1005,
15895,
1016,
1012,
1014,
1005,
6412,
1005,
16500,
2015,
1013,
9530,
8873,
27390,
2229,
2... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
var express = require('express');
var request = require('request');
// Constants
var PORT = 8080;
// App
var app = express();
app.get('/', function (req, res) {
res.send('A prototype of a micro-service hosting service. An example can be retrieved from https://funcist.ns.mg/7c9600b9d2a5f3b991ab\n');
});
app.get('/:gist_id', function (req, res) {
request({
url: 'https://api.github.com/gists/' + req.params.gist_id,
headers: {
'User-Agent': 'request'
}
}, function(error, response, body) {
var files = JSON.parse(body).files;
var filename = Object.keys(files)[0];
var content = files[filename].content;
var m = new module.constructor();
m._compile(content, filename);
res.send(m.exports);
});
});
app.listen(PORT);
console.log('Running on http://localhost:' + PORT);
| project-nsmg/funcist | index.js | JavaScript | gpl-2.0 | 871 | [
30522,
13075,
4671,
1027,
5478,
1006,
1005,
4671,
1005,
1007,
1025,
13075,
5227,
1027,
5478,
1006,
1005,
5227,
1005,
1007,
1025,
1013,
1013,
5377,
2015,
13075,
3417,
1027,
3770,
17914,
1025,
1013,
1013,
10439,
13075,
10439,
1027,
4671,
1006... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.8"/>
<title>BlackBone: C:/Users/Ton/Documents/Visual Studio 2013/Projects/BlackBone/src/BlackBone/ManualMap/MMap.h Source File</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<script type="text/javascript">
$(document).ready(initResizable);
$(window).load(resizeHeight);
</script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/search.js"></script>
<script type="text/javascript">
$(document).ready(function() { searchBox.OnSelectItem(0); });
</script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
<tbody>
<tr style="height: 56px;">
<td style="padding-left: 0.5em;">
<div id="projectname">BlackBone
</div>
<div id="projectbrief">Windows memory hacking library</div>
</td>
</tr>
</tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.8 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "search",false,'Search');
</script>
<div id="navrow1" class="tabs">
<ul class="tablist">
<li><a href="index.html"><span>Main Page</span></a></li>
<li><a href="annotated.html"><span>Classes</span></a></li>
<li class="current"><a href="files.html"><span>Files</span></a></li>
<li>
<div id="MSearchBox" class="MSearchBoxInactive">
<span class="left">
<img id="MSearchSelect" src="search/mag_sel.png"
onmouseover="return searchBox.OnSearchSelectShow()"
onmouseout="return searchBox.OnSearchSelectHide()"
alt=""/>
<input type="text" id="MSearchField" value="Search" accesskey="S"
onfocus="searchBox.OnSearchFieldFocus(true)"
onblur="searchBox.OnSearchFieldFocus(false)"
onkeyup="searchBox.OnSearchFieldChange(event)"/>
</span><span class="right">
<a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.png" alt=""/></a>
</span>
</div>
</li>
</ul>
</div>
<div id="navrow2" class="tabs2">
<ul class="tablist">
<li><a href="files.html"><span>File List</span></a></li>
</ul>
</div>
</div><!-- top -->
<div id="side-nav" class="ui-resizable side-nav-resizable">
<div id="nav-tree">
<div id="nav-tree-contents">
<div id="nav-sync" class="sync"></div>
</div>
</div>
<div id="splitbar" style="-moz-user-select:none;"
class="ui-resizable-handle">
</div>
</div>
<script type="text/javascript">
$(document).ready(function(){initNavTree('_m_map_8h_source.html','');});
</script>
<div id="doc-content">
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
onmouseover="return searchBox.OnSearchSelectShow()"
onmouseout="return searchBox.OnSearchSelectHide()"
onkeydown="return searchBox.OnSearchSelectKey(event)">
<a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(0)"><span class="SelectionMark"> </span>All</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(1)"><span class="SelectionMark"> </span>Classes</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(2)"><span class="SelectionMark"> </span>Functions</a></div>
<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0"
name="MSearchResults" id="MSearchResults">
</iframe>
</div>
<div class="header">
<div class="headertitle">
<div class="title">MMap.h</div> </div>
</div><!--header-->
<div class="contents">
<div class="fragment"><div class="line"><a name="l00001"></a><span class="lineno"> 1</span> <span class="preprocessor">#pragma once</span></div>
<div class="line"><a name="l00002"></a><span class="lineno"> 2</span> </div>
<div class="line"><a name="l00003"></a><span class="lineno"> 3</span> <span class="preprocessor">#include "../Config.h"</span></div>
<div class="line"><a name="l00004"></a><span class="lineno"> 4</span> <span class="preprocessor">#include "../Include/Winheaders.h"</span></div>
<div class="line"><a name="l00005"></a><span class="lineno"> 5</span> <span class="preprocessor">#include "../Include/Macro.h"</span></div>
<div class="line"><a name="l00006"></a><span class="lineno"> 6</span> <span class="preprocessor">#include "../PE/PEImage.h"</span></div>
<div class="line"><a name="l00007"></a><span class="lineno"> 7</span> </div>
<div class="line"><a name="l00008"></a><span class="lineno"> 8</span> <span class="preprocessor">#include "../Process/MemBlock.h"</span></div>
<div class="line"><a name="l00009"></a><span class="lineno"> 9</span> <span class="preprocessor">#include "MExcept.h"</span></div>
<div class="line"><a name="l00010"></a><span class="lineno"> 10</span> </div>
<div class="line"><a name="l00011"></a><span class="lineno"> 11</span> <span class="preprocessor">#include <map></span></div>
<div class="line"><a name="l00012"></a><span class="lineno"> 12</span> <span class="preprocessor">#include <stack></span></div>
<div class="line"><a name="l00013"></a><span class="lineno"> 13</span> </div>
<div class="line"><a name="l00014"></a><span class="lineno"> 14</span> <span class="keyword">namespace </span><a class="code" href="namespaceblackbone.html">blackbone</a></div>
<div class="line"><a name="l00015"></a><span class="lineno"> 15</span> {</div>
<div class="line"><a name="l00016"></a><span class="lineno"> 16</span> </div>
<div class="line"><a name="l00017"></a><span class="lineno"> 17</span> <span class="comment">// Loader flags</span></div>
<div class="line"><a name="l00018"></a><span class="lineno"> 18</span> <span class="keyword">enum</span> eLoadFlags</div>
<div class="line"><a name="l00019"></a><span class="lineno"> 19</span> {</div>
<div class="line"><a name="l00020"></a><span class="lineno"> 20</span>  NoFlags = 0x00, <span class="comment">// No flags</span></div>
<div class="line"><a name="l00021"></a><span class="lineno"> 21</span>  ManualImports = 0x01, <span class="comment">// Manually map import libraries</span></div>
<div class="line"><a name="l00022"></a><span class="lineno"> 22</span>  CreateLdrRef = 0x02, <span class="comment">// Create module references for native loader</span></div>
<div class="line"><a name="l00023"></a><span class="lineno"> 23</span>  WipeHeader = 0x04, <span class="comment">// Wipe image PE headers</span></div>
<div class="line"><a name="l00024"></a><span class="lineno"> 24</span>  HideVAD = 0x10, <span class="comment">// Make image appear as PAGE_NOACESS region</span></div>
<div class="line"><a name="l00025"></a><span class="lineno"> 25</span>  MapInHighMem = 0x20, <span class="comment">// Try to map image in address space beyond 4GB limit</span></div>
<div class="line"><a name="l00026"></a><span class="lineno"> 26</span>  RebaseProcess = 0x40, <span class="comment">// If target image is an .exe file, process base address will be replaced with mapped module value</span></div>
<div class="line"><a name="l00027"></a><span class="lineno"> 27</span> </div>
<div class="line"><a name="l00028"></a><span class="lineno"> 28</span>  NoExceptions = 0x01000, <span class="comment">// Do not create custom exception handler</span></div>
<div class="line"><a name="l00029"></a><span class="lineno"> 29</span>  PartialExcept = 0x02000, <span class="comment">// Only create Inverted function table, without VEH</span></div>
<div class="line"><a name="l00030"></a><span class="lineno"> 30</span>  NoDelayLoad = 0x04000, <span class="comment">// Do not resolve delay import</span></div>
<div class="line"><a name="l00031"></a><span class="lineno"> 31</span>  NoSxS = 0x08000, <span class="comment">// Do not apply SxS activation context</span></div>
<div class="line"><a name="l00032"></a><span class="lineno"> 32</span>  NoTLS = 0x10000, <span class="comment">// Skip TLS initialization and don't execute TLS callbacks</span></div>
<div class="line"><a name="l00033"></a><span class="lineno"> 33</span> };</div>
<div class="line"><a name="l00034"></a><span class="lineno"> 34</span> </div>
<div class="line"><a name="l00035"></a><span class="lineno"> 35</span> ENUM_OPS( eLoadFlags )</div>
<div class="line"><a name="l00036"></a><span class="lineno"> 36</span> </div>
<div class="line"><a name="l00037"></a><span class="lineno"> 37</span> <span class="comment">// Native loader flags callback</span></div>
<div class="line"><a name="l00038"></a><span class="lineno"> 38</span> typedef enum LdrRefFlags( *LdrCallback )(<span class="keywordtype">void</span>* context, const ModuleData& modInfo);</div>
<div class="line"><a name="l00039"></a><span class="lineno"> 39</span> </div>
<div class="line"><a name="l00040"></a><span class="lineno"> 40</span> </div>
<div class="line"><a name="l00044"></a><span class="lineno"><a class="line" href="structblackbone_1_1_image_context.html"> 44</a></span> struct <a class="code" href="structblackbone_1_1_image_context.html">ImageContext</a></div>
<div class="line"><a name="l00045"></a><span class="lineno"> 45</span> {</div>
<div class="line"><a name="l00046"></a><span class="lineno"> 46</span>  <span class="keyword">typedef</span> std::vector<ptr_t> vecPtr;</div>
<div class="line"><a name="l00047"></a><span class="lineno"> 47</span> </div>
<div class="line"><a name="l00048"></a><span class="lineno"> 48</span>  <a class="code" href="classblackbone_1_1pe_1_1_p_e_image.html">pe::PEImage</a> peImage; <span class="comment">// PE image data</span></div>
<div class="line"><a name="l00049"></a><span class="lineno"> 49</span>  <a class="code" href="classblackbone_1_1_mem_block.html">MemBlock</a> imgMem; <span class="comment">// Target image memory region</span></div>
<div class="line"><a name="l00050"></a><span class="lineno"> 50</span>  std::wstring FilePath; <span class="comment">// path to image being mapped</span></div>
<div class="line"><a name="l00051"></a><span class="lineno"> 51</span>  std::wstring FileName; <span class="comment">// File name string</span></div>
<div class="line"><a name="l00052"></a><span class="lineno"> 52</span>  vecPtr tlsCallbacks; <span class="comment">// TLS callback routines</span></div>
<div class="line"><a name="l00053"></a><span class="lineno"> 53</span>  ptr_t pExpTableAddr = 0; <span class="comment">// Exception table address (amd64 only)</span></div>
<div class="line"><a name="l00054"></a><span class="lineno"> 54</span>  ptr_t EntryPoint = 0; <span class="comment">// Target image entry point</span></div>
<div class="line"><a name="l00055"></a><span class="lineno"> 55</span>  eLoadFlags flags = NoFlags; <span class="comment">// Image loader flags</span></div>
<div class="line"><a name="l00056"></a><span class="lineno"> 56</span>  <span class="keywordtype">bool</span> initialized = <span class="keyword">false</span>; <span class="comment">// Image entry point was called</span></div>
<div class="line"><a name="l00057"></a><span class="lineno"> 57</span> };</div>
<div class="line"><a name="l00058"></a><span class="lineno"> 58</span> </div>
<div class="line"><a name="l00059"></a><span class="lineno"> 59</span> <span class="keyword">typedef</span> std::vector<std::unique_ptr<ImageContext>> vecImageCtx;</div>
<div class="line"><a name="l00060"></a><span class="lineno"> 60</span> </div>
<div class="line"><a name="l00064"></a><span class="lineno"><a class="line" href="classblackbone_1_1_m_map.html"> 64</a></span> <span class="keyword">class </span><a class="code" href="classblackbone_1_1_m_map.html">MMap</a> : <span class="keyword">public</span> <a class="code" href="classblackbone_1_1_m_except.html">MExcept</a></div>
<div class="line"><a name="l00065"></a><span class="lineno"> 65</span> {</div>
<div class="line"><a name="l00066"></a><span class="lineno"> 66</span>  </div>
<div class="line"><a name="l00067"></a><span class="lineno"> 67</span> <span class="keyword">public</span>:</div>
<div class="line"><a name="l00068"></a><span class="lineno"> 68</span>  BLACKBONE_API <a class="code" href="classblackbone_1_1_m_map.html">MMap</a>( <span class="keyword">class</span> <a class="code" href="classblackbone_1_1_process.html">Process</a>& proc );</div>
<div class="line"><a name="l00069"></a><span class="lineno"> 69</span>  BLACKBONE_API ~MMap( <span class="keywordtype">void</span> );</div>
<div class="line"><a name="l00070"></a><span class="lineno"> 70</span> </div>
<div class="line"><a name="l00079"></a><span class="lineno"> 79</span>  BLACKBONE_API <span class="keyword">const</span> <a class="code" href="structblackbone_1_1_module_data.html">ModuleData</a>* <a class="code" href="classblackbone_1_1_m_map.html#ac32ee99111f95b472fb95834657f0ac7">MapImage</a>(</div>
<div class="line"><a name="l00080"></a><span class="lineno"> 80</span>  <span class="keyword">const</span> std::wstring& path,</div>
<div class="line"><a name="l00081"></a><span class="lineno"> 81</span>  eLoadFlags flags = NoFlags,</div>
<div class="line"><a name="l00082"></a><span class="lineno"> 82</span>  LdrCallback ldrCallback = <span class="keyword">nullptr</span>,</div>
<div class="line"><a name="l00083"></a><span class="lineno"> 83</span>  <span class="keywordtype">void</span>* ldrContext = <span class="keyword">nullptr</span></div>
<div class="line"><a name="l00084"></a><span class="lineno"> 84</span>  );</div>
<div class="line"><a name="l00085"></a><span class="lineno"> 85</span> </div>
<div class="line"><a name="l00096"></a><span class="lineno"> 96</span>  BLACKBONE_API <span class="keyword">const</span> <a class="code" href="structblackbone_1_1_module_data.html">ModuleData</a>* <a class="code" href="classblackbone_1_1_m_map.html#ac32ee99111f95b472fb95834657f0ac7">MapImage</a>(</div>
<div class="line"><a name="l00097"></a><span class="lineno"> 97</span>  <span class="keywordtype">void</span>* buffer, <span class="keywordtype">size_t</span> size,</div>
<div class="line"><a name="l00098"></a><span class="lineno"> 98</span>  <span class="keywordtype">bool</span> asImage = <span class="keyword">false</span>,</div>
<div class="line"><a name="l00099"></a><span class="lineno"> 99</span>  eLoadFlags flags = NoFlags,</div>
<div class="line"><a name="l00100"></a><span class="lineno"> 100</span>  LdrCallback ldrCallback = <span class="keyword">nullptr</span>,</div>
<div class="line"><a name="l00101"></a><span class="lineno"> 101</span>  <span class="keywordtype">void</span>* ldrContext = <span class="keyword">nullptr</span></div>
<div class="line"><a name="l00102"></a><span class="lineno"> 102</span>  );</div>
<div class="line"><a name="l00103"></a><span class="lineno"> 103</span> </div>
<div class="line"><a name="l00108"></a><span class="lineno"> 108</span>  BLACKBONE_API <span class="keywordtype">bool</span> <a class="code" href="classblackbone_1_1_m_map.html#ab2c907908d1db59db079d4d2bfe4dc13">UnmapAllModules</a>();</div>
<div class="line"><a name="l00109"></a><span class="lineno"> 109</span> </div>
<div class="line"><a name="l00114"></a><span class="lineno"> 114</span>  BLACKBONE_API <span class="keywordtype">void</span> <a class="code" href="classblackbone_1_1_m_map.html#a34bc7201d03a51463824d81b2e68c3b6">Cleanup</a>();</div>
<div class="line"><a name="l00115"></a><span class="lineno"> 115</span> </div>
<div class="line"><a name="l00119"></a><span class="lineno"><a class="line" href="classblackbone_1_1_m_map.html#af662672364ee90cef246b719b5691ee0"> 119</a></span>  BLACKBONE_API <span class="keyword">inline</span> <span class="keywordtype">void</span> <a class="code" href="classblackbone_1_1_m_map.html#af662672364ee90cef246b719b5691ee0">reset</a>() { _images.clear(); _pAContext.<a class="code" href="classblackbone_1_1_mem_block.html#a05ff5f65fde58e9d89bcb8c18fc7c66a">Reset</a>(); _usedBlocks.clear(); }</div>
<div class="line"><a name="l00120"></a><span class="lineno"> 120</span> </div>
<div class="line"><a name="l00121"></a><span class="lineno"> 121</span> <span class="keyword">private</span>:</div>
<div class="line"><a name="l00133"></a><span class="lineno"> 133</span>  <span class="keyword">const</span> <a class="code" href="structblackbone_1_1_module_data.html">ModuleData</a>* <a class="code" href="classblackbone_1_1_m_map.html#ac32ee99111f95b472fb95834657f0ac7">MapImage</a>(</div>
<div class="line"><a name="l00134"></a><span class="lineno"> 134</span>  <span class="keyword">const</span> std::wstring& path,</div>
<div class="line"><a name="l00135"></a><span class="lineno"> 135</span>  <span class="keywordtype">void</span>* buffer, <span class="keywordtype">size_t</span> size,</div>
<div class="line"><a name="l00136"></a><span class="lineno"> 136</span>  <span class="keywordtype">bool</span> asImage = <span class="keyword">false</span>,</div>
<div class="line"><a name="l00137"></a><span class="lineno"> 137</span>  eLoadFlags flags = NoFlags,</div>
<div class="line"><a name="l00138"></a><span class="lineno"> 138</span>  LdrCallback ldrCallback = <span class="keyword">nullptr</span>,</div>
<div class="line"><a name="l00139"></a><span class="lineno"> 139</span>  <span class="keywordtype">void</span>* ldrContext = <span class="keyword">nullptr</span></div>
<div class="line"><a name="l00140"></a><span class="lineno"> 140</span>  );</div>
<div class="line"><a name="l00141"></a><span class="lineno"> 141</span> </div>
<div class="line"><a name="l00148"></a><span class="lineno"> 148</span>  <span class="keyword">const</span> <a class="code" href="structblackbone_1_1_module_data.html">ModuleData</a>* FindOrMapModule(</div>
<div class="line"><a name="l00149"></a><span class="lineno"> 149</span>  <span class="keyword">const</span> std::wstring& path,</div>
<div class="line"><a name="l00150"></a><span class="lineno"> 150</span>  <span class="keywordtype">void</span>* buffer, <span class="keywordtype">size_t</span> size, <span class="keywordtype">bool</span> asImage,</div>
<div class="line"><a name="l00151"></a><span class="lineno"> 151</span>  eLoadFlags flags = NoFlags</div>
<div class="line"><a name="l00152"></a><span class="lineno"> 152</span>  );</div>
<div class="line"><a name="l00153"></a><span class="lineno"> 153</span> </div>
<div class="line"><a name="l00165"></a><span class="lineno"> 165</span>  <span class="keywordtype">bool</span> RunModuleInitializers( <a class="code" href="structblackbone_1_1_image_context.html">ImageContext</a>* pImage, DWORD dwReason );</div>
<div class="line"><a name="l00166"></a><span class="lineno"> 166</span> </div>
<div class="line"><a name="l00172"></a><span class="lineno"> 172</span>  <span class="keywordtype">bool</span> CopyImage( <a class="code" href="structblackbone_1_1_image_context.html">ImageContext</a>* pImage );</div>
<div class="line"><a name="l00173"></a><span class="lineno"> 173</span> </div>
<div class="line"><a name="l00179"></a><span class="lineno"> 179</span>  <span class="keywordtype">bool</span> ProtectImageMemory( <a class="code" href="structblackbone_1_1_image_context.html">ImageContext</a>* pImage );</div>
<div class="line"><a name="l00180"></a><span class="lineno"> 180</span> </div>
<div class="line"><a name="l00186"></a><span class="lineno"> 186</span>  <span class="keywordtype">bool</span> RelocateImage( <a class="code" href="structblackbone_1_1_image_context.html">ImageContext</a>* pImage );</div>
<div class="line"><a name="l00187"></a><span class="lineno"> 187</span> </div>
<div class="line"><a name="l00194"></a><span class="lineno"> 194</span>  <span class="keywordtype">bool</span> ResolveImport( <a class="code" href="structblackbone_1_1_image_context.html">ImageContext</a>* pImage, <span class="keywordtype">bool</span> useDelayed = <span class="keyword">false</span> );</div>
<div class="line"><a name="l00195"></a><span class="lineno"> 195</span> </div>
<div class="line"><a name="l00201"></a><span class="lineno"> 201</span>  <span class="keywordtype">bool</span> InitStaticTLS( <a class="code" href="structblackbone_1_1_image_context.html">ImageContext</a>* pImage );</div>
<div class="line"><a name="l00202"></a><span class="lineno"> 202</span> </div>
<div class="line"><a name="l00208"></a><span class="lineno"> 208</span>  <span class="keywordtype">bool</span> EnableExceptions( <a class="code" href="structblackbone_1_1_image_context.html">ImageContext</a>* pImage );</div>
<div class="line"><a name="l00209"></a><span class="lineno"> 209</span> </div>
<div class="line"><a name="l00215"></a><span class="lineno"> 215</span>  <span class="keywordtype">bool</span> DisableExceptions( <a class="code" href="structblackbone_1_1_image_context.html">ImageContext</a>* pImage );</div>
<div class="line"><a name="l00216"></a><span class="lineno"> 216</span> </div>
<div class="line"><a name="l00228"></a><span class="lineno"> 228</span>  <span class="keywordtype">bool</span> CreateActx( <span class="keyword">const</span> std::wstring& path, <span class="keywordtype">int</span> <span class="keywordtype">id</span> = 2, <span class="keywordtype">bool</span> asImage = <span class="keyword">true</span> );</div>
<div class="line"><a name="l00229"></a><span class="lineno"> 229</span> </div>
<div class="line"><a name="l00235"></a><span class="lineno"> 235</span>  <span class="keywordtype">bool</span> InitializeCookie( <a class="code" href="structblackbone_1_1_image_context.html">ImageContext</a>* pImage );</div>
<div class="line"><a name="l00236"></a><span class="lineno"> 236</span> </div>
<div class="line"><a name="l00242"></a><span class="lineno"> 242</span>  NTSTATUS ConcealVad( <span class="keyword">const</span> <a class="code" href="classblackbone_1_1_mem_block.html">MemBlock</a>& imageMem );</div>
<div class="line"><a name="l00243"></a><span class="lineno"> 243</span> </div>
<div class="line"><a name="l00250"></a><span class="lineno"> 250</span>  NTSTATUS AllocateInHighMem( <a class="code" href="classblackbone_1_1_mem_block.html">MemBlock</a>& imageMem, <span class="keywordtype">size_t</span> size );</div>
<div class="line"><a name="l00251"></a><span class="lineno"> 251</span> </div>
<div class="line"><a name="l00258"></a><span class="lineno"> 258</span>  <span class="keyword">const</span> <a class="code" href="structblackbone_1_1_module_data.html">ModuleData</a>* FindOrMapDependency( <a class="code" href="structblackbone_1_1_image_context.html">ImageContext</a>* pImage, std::wstring& path );</div>
<div class="line"><a name="l00259"></a><span class="lineno"> 259</span> </div>
<div class="line"><a name="l00265"></a><span class="lineno"> 265</span>  module_t MapPureManaged();</div>
<div class="line"><a name="l00266"></a><span class="lineno"> 266</span> </div>
<div class="line"><a name="l00272"></a><span class="lineno"> 272</span>  DWORD GetSectionProt( DWORD characteristics );</div>
<div class="line"><a name="l00273"></a><span class="lineno"> 273</span> </div>
<div class="line"><a name="l00274"></a><span class="lineno"> 274</span> <span class="keyword">private</span>:</div>
<div class="line"><a name="l00275"></a><span class="lineno"> 275</span>  vecImageCtx _images; <span class="comment">// Mapped images</span></div>
<div class="line"><a name="l00276"></a><span class="lineno"> 276</span>  <span class="keyword">class </span><a class="code" href="classblackbone_1_1_process.html">Process</a>& _process; <span class="comment">// Target process manager</span></div>
<div class="line"><a name="l00277"></a><span class="lineno"> 277</span>  <a class="code" href="classblackbone_1_1_mem_block.html">MemBlock</a> _pAContext; <span class="comment">// SxS activation context memory address</span></div>
<div class="line"><a name="l00278"></a><span class="lineno"> 278</span>  LdrCallback _ldrCallback = <span class="keyword">nullptr</span>; <span class="comment">// Loader callback for adding image into loader lists</span></div>
<div class="line"><a name="l00279"></a><span class="lineno"> 279</span>  <span class="keywordtype">void</span>* _ldrContext = <span class="keyword">nullptr</span>; <span class="comment">// user context for _ldrCallback </span></div>
<div class="line"><a name="l00280"></a><span class="lineno"> 280</span> </div>
<div class="line"><a name="l00281"></a><span class="lineno"> 281</span>  std::vector<std::pair<ptr_t, size_t>> _usedBlocks; <span class="comment">// Used memory blocks </span></div>
<div class="line"><a name="l00282"></a><span class="lineno"> 282</span> };</div>
<div class="line"><a name="l00283"></a><span class="lineno"> 283</span> </div>
<div class="line"><a name="l00284"></a><span class="lineno"> 284</span> }</div>
<div class="line"><a name="l00285"></a><span class="lineno"> 285</span> </div>
<div class="ttc" id="classblackbone_1_1_m_except_html"><div class="ttname"><a href="classblackbone_1_1_m_except.html">blackbone::MExcept</a></div><div class="ttdoc">Exception handling support for arbitrary code </div><div class="ttdef"><b>Definition:</b> MExcept.h:12</div></div>
<div class="ttc" id="classblackbone_1_1_m_map_html_ac32ee99111f95b472fb95834657f0ac7"><div class="ttname"><a href="classblackbone_1_1_m_map.html#ac32ee99111f95b472fb95834657f0ac7">blackbone::MMap::MapImage</a></div><div class="ttdeci">BLACKBONE_API const ModuleData * MapImage(const std::wstring &path, eLoadFlags flags=NoFlags, LdrCallback ldrCallback=nullptr, void *ldrContext=nullptr)</div><div class="ttdoc">Manually map PE image into underlying target process </div><div class="ttdef"><b>Definition:</b> MMap.cpp:34</div></div>
<div class="ttc" id="structblackbone_1_1_image_context_html"><div class="ttname"><a href="structblackbone_1_1_image_context.html">blackbone::ImageContext</a></div><div class="ttdoc">Image data </div><div class="ttdef"><b>Definition:</b> MMap.h:44</div></div>
<div class="ttc" id="classblackbone_1_1_process_html"><div class="ttname"><a href="classblackbone_1_1_process.html">blackbone::Process</a></div><div class="ttdef"><b>Definition:</b> Process.h:43</div></div>
<div class="ttc" id="classblackbone_1_1pe_1_1_p_e_image_html"><div class="ttname"><a href="classblackbone_1_1pe_1_1_p_e_image.html">blackbone::pe::PEImage</a></div><div class="ttdoc">Primitive PE parsing class </div><div class="ttdef"><b>Definition:</b> PEImage.h:55</div></div>
<div class="ttc" id="classblackbone_1_1_m_map_html"><div class="ttname"><a href="classblackbone_1_1_m_map.html">blackbone::MMap</a></div><div class="ttdoc">Manual image mapper </div><div class="ttdef"><b>Definition:</b> MMap.h:64</div></div>
<div class="ttc" id="classblackbone_1_1_m_map_html_a34bc7201d03a51463824d81b2e68c3b6"><div class="ttname"><a href="classblackbone_1_1_m_map.html#a34bc7201d03a51463824d81b2e68c3b6">blackbone::MMap::Cleanup</a></div><div class="ttdeci">BLACKBONE_API void Cleanup()</div><div class="ttdoc">Remove any traces from remote process </div><div class="ttdef"><b>Definition:</b> MMap.cpp:1113</div></div>
<div class="ttc" id="classblackbone_1_1_mem_block_html"><div class="ttname"><a href="classblackbone_1_1_mem_block.html">blackbone::MemBlock</a></div><div class="ttdef"><b>Definition:</b> MemBlock.h:39</div></div>
<div class="ttc" id="classblackbone_1_1_m_map_html_af662672364ee90cef246b719b5691ee0"><div class="ttname"><a href="classblackbone_1_1_m_map.html#af662672364ee90cef246b719b5691ee0">blackbone::MMap::reset</a></div><div class="ttdeci">BLACKBONE_API void reset()</div><div class="ttdoc">Reset local data </div><div class="ttdef"><b>Definition:</b> MMap.h:119</div></div>
<div class="ttc" id="classblackbone_1_1_m_map_html_ab2c907908d1db59db079d4d2bfe4dc13"><div class="ttname"><a href="classblackbone_1_1_m_map.html#ab2c907908d1db59db079d4d2bfe4dc13">blackbone::MMap::UnmapAllModules</a></div><div class="ttdeci">BLACKBONE_API bool UnmapAllModules()</div><div class="ttdoc">Unmap all manually mapped modules </div><div class="ttdef"><b>Definition:</b> MMap.cpp:346</div></div>
<div class="ttc" id="namespaceblackbone_html"><div class="ttname"><a href="namespaceblackbone.html">blackbone</a></div><div class="ttdef"><b>Definition:</b> AsmHelper32.cpp:6</div></div>
<div class="ttc" id="classblackbone_1_1_mem_block_html_a05ff5f65fde58e9d89bcb8c18fc7c66a"><div class="ttname"><a href="classblackbone_1_1_mem_block.html#a05ff5f65fde58e9d89bcb8c18fc7c66a">blackbone::MemBlock::Reset</a></div><div class="ttdeci">BLACKBONE_API void Reset()</div><div class="ttdoc">Try to free memory and reset pointers </div><div class="ttdef"><b>Definition:</b> MemBlock.cpp:199</div></div>
<div class="ttc" id="structblackbone_1_1_module_data_html"><div class="ttname"><a href="structblackbone_1_1_module_data.html">blackbone::ModuleData</a></div><div class="ttdef"><b>Definition:</b> Types.h:56</div></div>
</div><!-- fragment --></div><!-- contents -->
</div><!-- doc-content -->
<!-- start footer part -->
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
<ul>
<li class="navelem"><a class="el" href="dir_aa9befc4bdfa617079e96718d920d9d2.html">Visual Studio 2013</a></li><li class="navelem"><a class="el" href="dir_9749fe1d1039c274ca5f4a0137bd5805.html">Projects</a></li><li class="navelem"><a class="el" href="dir_87d371cc6a3e9a1e307775a876c8e949.html">BlackBone</a></li><li class="navelem"><a class="el" href="dir_2dd5b37e3ce8f08186c1d7d6a8b43f79.html">src</a></li><li class="navelem"><a class="el" href="dir_c12349095ba230d0c7acc796e8f40ecd.html">BlackBone</a></li><li class="navelem"><a class="el" href="dir_989b2b1d380a6a0a22fd0ff7c0500a27.html">ManualMap</a></li><li class="navelem"><b>MMap.h</b></li>
<li class="footer">Generated on Tue Sep 23 2014 11:46:47 for BlackBone by
<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.8.8 </li>
</ul>
</div>
</body>
</html>
| drptbl/Blackbone | doc/lib/html/_m_map_8h_source.html | HTML | mit | 32,228 | [
30522,
1026,
999,
9986,
13874,
16129,
2270,
1000,
1011,
1013,
1013,
1059,
2509,
2278,
1013,
1013,
26718,
2094,
1060,
11039,
19968,
1015,
1012,
1014,
17459,
1013,
1013,
4372,
1000,
1000,
8299,
1024,
1013,
1013,
7479,
1012,
1059,
2509,
1012,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
//----------------------------------------------------------------------------
#pragma hdrstop
#include <stdio.h>
#include <memory>
#include "uCM.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma classgroup "Vcl.Controls.TControl"
#pragma resource "*.dfm"
TCM *CM;
//---------------------------------------------------------------------------
__fastcall TCM::TCM(TComponent* Owner)
: TDataModule(Owner)
{
FInstanceOwner = true;
}
__fastcall TCM::~TCM()
{
delete FSMClient;
}
TSMClient* TCM::GetSMClient(void)
{
if (FSMClient == NULL)
FSMClient= new TSMClient(DSRestConnection1, FInstanceOwner);
return FSMClient;
};
| cassioferrazzo/fila.cliente.desktop | uCM.cpp | C++ | gpl-2.0 | 695 | [
30522,
1013,
1013,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
101... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
/*
* (C) Copyright 2009
* Heiko Schocher, DENX Software Engineering, hs@denx.de.
* Changes for multibus/multiadapter I2C support.
*
* (C) Copyright 2001, 2002
* Wolfgang Denk, DENX Software Engineering, wd@denx.de.
*
* SPDX-License-Identifier: GPL-2.0+
*
* This has been changed substantially by Gerald Van Baren, Custom IDEAS,
* vanbaren@cideas.com. It was heavily influenced by LiMon, written by
* Neil Russell.
*/
#include <common.h>
#ifdef CONFIG_MPC8260 /* only valid for MPC8260 */
#include <ioports.h>
#include <asm/io.h>
#endif
#if defined(CONFIG_AVR32)
#include <asm/arch/portmux.h>
#endif
#if defined(CONFIG_AT91FAMILY)
#include <asm/io.h>
#include <asm/arch/hardware.h>
#include <asm/arch/at91_pio.h>
#ifdef CONFIG_ATMEL_LEGACY
#include <asm/arch/gpio.h>
#endif
#endif
#ifdef CONFIG_IXP425 /* only valid for IXP425 */
#include <asm/arch/ixp425.h>
#endif
#if defined(CONFIG_MPC852T) || defined(CONFIG_MPC866)
#include <asm/io.h>
#endif
#include <i2c.h>
#if defined(CONFIG_SOFT_I2C_GPIO_SCL)
# include <asm/gpio.h>
# ifndef I2C_GPIO_SYNC
# define I2C_GPIO_SYNC
# endif
# ifndef I2C_INIT
# define I2C_INIT \
do { \
gpio_request(CONFIG_SOFT_I2C_GPIO_SCL, "soft_i2c"); \
gpio_request(CONFIG_SOFT_I2C_GPIO_SDA, "soft_i2c"); \
} while (0)
# endif
# ifndef I2C_ACTIVE
# define I2C_ACTIVE do { } while (0)
# endif
# ifndef I2C_TRISTATE
# define I2C_TRISTATE do { } while (0)
# endif
# ifndef I2C_READ
# define I2C_READ gpio_get_value(CONFIG_SOFT_I2C_GPIO_SDA)
# endif
# ifndef I2C_SDA
# define I2C_SDA(bit) \
do { \
if (bit) \
gpio_direction_input(CONFIG_SOFT_I2C_GPIO_SDA); \
else \
gpio_direction_output(CONFIG_SOFT_I2C_GPIO_SDA, 0); \
I2C_GPIO_SYNC; \
} while (0)
# endif
# ifndef I2C_SCL
# define I2C_SCL(bit) \
do { \
gpio_direction_output(CONFIG_SOFT_I2C_GPIO_SCL, bit); \
I2C_GPIO_SYNC; \
} while (0)
# endif
# ifndef I2C_DELAY
# define I2C_DELAY udelay(5) /* 1/4 I2C clock duration */
# endif
#endif
/* #define DEBUG_I2C */
DECLARE_GLOBAL_DATA_PTR;
#ifndef I2C_SOFT_DECLARATIONS
# if defined(CONFIG_MPC8260)
# define I2C_SOFT_DECLARATIONS volatile ioport_t *iop = \
ioport_addr((immap_t *)CONFIG_SYS_IMMR, I2C_PORT);
# elif defined(CONFIG_8xx)
# define I2C_SOFT_DECLARATIONS volatile immap_t *immr = \
(immap_t *)CONFIG_SYS_IMMR;
# else
# define I2C_SOFT_DECLARATIONS
# endif
#endif
#if !defined(CONFIG_SYS_I2C_SOFT_SPEED)
#define CONFIG_SYS_I2C_SOFT_SPEED CONFIG_SYS_I2C_SPEED
#endif
#if !defined(CONFIG_SYS_I2C_SOFT_SLAVE)
#define CONFIG_SYS_I2C_SOFT_SLAVE CONFIG_SYS_I2C_SLAVE
#endif
/*-----------------------------------------------------------------------
* Definitions
*/
#define RETRIES 0
#define I2C_ACK 0 /* PD_SDA level to ack a byte */
#define I2C_NOACK 1 /* PD_SDA level to noack a byte */
#ifdef DEBUG_I2C
#define PRINTD(fmt,args...) do { \
printf (fmt ,##args); \
} while (0)
#else
#define PRINTD(fmt,args...)
#endif
/*-----------------------------------------------------------------------
* Local functions
*/
#if !defined(CONFIG_SYS_I2C_INIT_BOARD)
static void send_reset (void);
#endif
static void send_start (void);
static void send_stop (void);
static void send_ack (int);
static int write_byte (uchar byte);
static uchar read_byte (int);
#if !defined(CONFIG_SYS_I2C_INIT_BOARD)
/*-----------------------------------------------------------------------
* Send a reset sequence consisting of 9 clocks with the data signal high
* to clock any confused device back into an idle state. Also send a
* <stop> at the end of the sequence for belts & suspenders.
*/
static void send_reset(void)
{
I2C_SOFT_DECLARATIONS /* intentional without ';' */
int j;
I2C_SCL(1);
I2C_SDA(1);
#ifdef I2C_INIT
I2C_INIT;
#endif
I2C_TRISTATE;
for(j = 0; j < 9; j++) {
I2C_SCL(0);
I2C_DELAY;
I2C_DELAY;
I2C_SCL(1);
I2C_DELAY;
I2C_DELAY;
}
send_stop();
I2C_TRISTATE;
}
#endif
/*-----------------------------------------------------------------------
* START: High -> Low on SDA while SCL is High
*/
static void send_start(void)
{
I2C_SOFT_DECLARATIONS /* intentional without ';' */
I2C_DELAY;
I2C_SDA(1);
I2C_ACTIVE;
I2C_DELAY;
I2C_SCL(1);
I2C_DELAY;
I2C_SDA(0);
I2C_DELAY;
}
/*-----------------------------------------------------------------------
* STOP: Low -> High on SDA while SCL is High
*/
static void send_stop(void)
{
I2C_SOFT_DECLARATIONS /* intentional without ';' */
I2C_SCL(0);
I2C_DELAY;
I2C_SDA(0);
I2C_ACTIVE;
I2C_DELAY;
I2C_SCL(1);
I2C_DELAY;
I2C_SDA(1);
I2C_DELAY;
I2C_TRISTATE;
}
/*-----------------------------------------------------------------------
* ack should be I2C_ACK or I2C_NOACK
*/
static void send_ack(int ack)
{
I2C_SOFT_DECLARATIONS /* intentional without ';' */
I2C_SCL(0);
I2C_DELAY;
I2C_ACTIVE;
I2C_SDA(ack);
I2C_DELAY;
I2C_SCL(1);
I2C_DELAY;
I2C_DELAY;
I2C_SCL(0);
I2C_DELAY;
}
/*-----------------------------------------------------------------------
* Send 8 bits and look for an acknowledgement.
*/
static int write_byte(uchar data)
{
I2C_SOFT_DECLARATIONS /* intentional without ';' */
int j;
int nack;
I2C_ACTIVE;
for(j = 0; j < 8; j++) {
I2C_SCL(0);
I2C_DELAY;
I2C_SDA(data & 0x80);
I2C_DELAY;
I2C_SCL(1);
I2C_DELAY;
I2C_DELAY;
data <<= 1;
}
/*
* Look for an <ACK>(negative logic) and return it.
*/
I2C_SCL(0);
I2C_DELAY;
I2C_SDA(1);
I2C_TRISTATE;
I2C_DELAY;
I2C_SCL(1);
I2C_DELAY;
I2C_DELAY;
nack = I2C_READ;
I2C_SCL(0);
I2C_DELAY;
I2C_ACTIVE;
return(nack); /* not a nack is an ack */
}
/*-----------------------------------------------------------------------
* if ack == I2C_ACK, ACK the byte so can continue reading, else
* send I2C_NOACK to end the read.
*/
static uchar read_byte(int ack)
{
I2C_SOFT_DECLARATIONS /* intentional without ';' */
int data;
int j;
/*
* Read 8 bits, MSB first.
*/
I2C_TRISTATE;
I2C_SDA(1);
data = 0;
for(j = 0; j < 8; j++) {
I2C_SCL(0);
I2C_DELAY;
I2C_SCL(1);
I2C_DELAY;
data <<= 1;
data |= I2C_READ;
I2C_DELAY;
}
send_ack(ack);
return(data);
}
/*-----------------------------------------------------------------------
* Initialization
*/
static void soft_i2c_init(struct i2c_adapter *adap, int speed, int slaveaddr)
{
#if defined(CONFIG_SYS_I2C_INIT_BOARD)
/* call board specific i2c bus reset routine before accessing the */
/* environment, which might be in a chip on that bus. For details */
/* about this problem see doc/I2C_Edge_Conditions. */
i2c_init_board();
#else
/*
* WARNING: Do NOT save speed in a static variable: if the
* I2C routines are called before RAM is initialized (to read
* the DIMM SPD, for instance), RAM won't be usable and your
* system will crash.
*/
send_reset ();
#endif
}
/*-----------------------------------------------------------------------
* Probe to see if a chip is present. Also good for checking for the
* completion of EEPROM writes since the chip stops responding until
* the write completes (typically 10mSec).
*/
static int soft_i2c_probe(struct i2c_adapter *adap, uint8_t addr)
{
int rc;
/*
* perform 1 byte write transaction with just address byte
* (fake write)
*/
send_start();
rc = write_byte ((addr << 1) | 0);
send_stop();
return (rc ? 1 : 0);
}
/*-----------------------------------------------------------------------
* Read bytes
*/
static int soft_i2c_read(struct i2c_adapter *adap, uchar chip, uint addr,
int alen, uchar *buffer, int len)
{
int shift;
PRINTD("i2c_read: chip %02X addr %02X alen %d buffer %p len %d\n",
chip, addr, alen, buffer, len);
#ifdef CONFIG_SYS_I2C_EEPROM_ADDR_OVERFLOW
/*
* EEPROM chips that implement "address overflow" are ones
* like Catalyst 24WC04/08/16 which has 9/10/11 bits of
* address and the extra bits end up in the "chip address"
* bit slots. This makes a 24WC08 (1Kbyte) chip look like
* four 256 byte chips.
*
* Note that we consider the length of the address field to
* still be one byte because the extra address bits are
* hidden in the chip address.
*/
chip |= ((addr >> (alen * 8)) & CONFIG_SYS_I2C_EEPROM_ADDR_OVERFLOW);
PRINTD("i2c_read: fix addr_overflow: chip %02X addr %02X\n",
chip, addr);
#endif
/*
* Do the addressing portion of a write cycle to set the
* chip's address pointer. If the address length is zero,
* don't do the normal write cycle to set the address pointer,
* there is no address pointer in this chip.
*/
send_start();
if(alen > 0) {
if(write_byte(chip << 1)) { /* write cycle */
send_stop();
PRINTD("i2c_read, no chip responded %02X\n", chip);
return(1);
}
shift = (alen-1) * 8;
while(alen-- > 0) {
if(write_byte(addr >> shift)) {
PRINTD("i2c_read, address not <ACK>ed\n");
return(1);
}
shift -= 8;
}
/* Some I2C chips need a stop/start sequence here,
* other chips don't work with a full stop and need
* only a start. Default behaviour is to send the
* stop/start sequence.
*/
#ifdef CONFIG_SOFT_I2C_READ_REPEATED_START
send_start();
#else
send_stop();
send_start();
#endif
}
/*
* Send the chip address again, this time for a read cycle.
* Then read the data. On the last byte, we do a NACK instead
* of an ACK(len == 0) to terminate the read.
*/
write_byte((chip << 1) | 1); /* read cycle */
while(len-- > 0) {
*buffer++ = read_byte(len == 0);
}
send_stop();
return(0);
}
/*-----------------------------------------------------------------------
* Write bytes
*/
static int soft_i2c_write(struct i2c_adapter *adap, uchar chip, uint addr,
int alen, uchar *buffer, int len)
{
int shift, failures = 0;
PRINTD("i2c_write: chip %02X addr %02X alen %d buffer %p len %d\n",
chip, addr, alen, buffer, len);
send_start();
if(write_byte(chip << 1)) { /* write cycle */
send_stop();
PRINTD("i2c_write, no chip responded %02X\n", chip);
return(1);
}
shift = (alen-1) * 8;
while(alen-- > 0) {
if(write_byte(addr >> shift)) {
PRINTD("i2c_write, address not <ACK>ed\n");
return(1);
}
shift -= 8;
}
while(len-- > 0) {
if(write_byte(*buffer++)) {
failures++;
}
}
send_stop();
return(failures);
}
/*
* Register soft i2c adapters
*/
U_BOOT_I2C_ADAP_COMPLETE(soft0, soft_i2c_init, soft_i2c_probe,
soft_i2c_read, soft_i2c_write, NULL,
CONFIG_SYS_I2C_SOFT_SPEED, CONFIG_SYS_I2C_SOFT_SLAVE,
0)
#if defined(I2C_SOFT_DECLARATIONS2)
U_BOOT_I2C_ADAP_COMPLETE(soft1, soft_i2c_init, soft_i2c_probe,
soft_i2c_read, soft_i2c_write, NULL,
CONFIG_SYS_I2C_SOFT_SPEED_2,
CONFIG_SYS_I2C_SOFT_SLAVE_2,
1)
#endif
#if defined(I2C_SOFT_DECLARATIONS3)
U_BOOT_I2C_ADAP_COMPLETE(soft2, soft_i2c_init, soft_i2c_probe,
soft_i2c_read, soft_i2c_write, NULL,
CONFIG_SYS_I2C_SOFT_SPEED_3,
CONFIG_SYS_I2C_SOFT_SLAVE_3,
2)
#endif
#if defined(I2C_SOFT_DECLARATIONS4)
U_BOOT_I2C_ADAP_COMPLETE(soft3, soft_i2c_init, soft_i2c_probe,
soft_i2c_read, soft_i2c_write, NULL,
CONFIG_SYS_I2C_SOFT_SPEED_4,
CONFIG_SYS_I2C_SOFT_SLAVE_4,
3)
#endif
| puppies/fl2440 | u-boot-2014.01/drivers/i2c/soft_i2c.c | C | gpl-2.0 | 11,047 | [
30522,
1013,
1008,
1008,
1006,
1039,
1007,
9385,
2268,
1008,
2002,
12676,
8040,
6806,
7474,
1010,
7939,
2595,
4007,
3330,
1010,
26236,
1030,
7939,
2595,
1012,
2139,
1012,
1008,
3431,
2005,
4800,
8286,
1013,
4800,
8447,
13876,
2121,
1045,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
//
// SoundManager.h
// Jam
//
// Created by Ostap on 23.11.14.
//
//
#ifndef __Jam__SoundManager__
#define __Jam__SoundManager__
#include "cocos2d.h"
#include "audio/include/AudioEngine.h"
using namespace cocos2d;
using namespace ui;
USING_NS_CC;
enum Sounds {
sound_best_loop,
sound_drop_item,
sound_electro_loop,
sound_haha,
sound_harkem_shake,
sound_monkey,
sound_noise_loop,
sound_ouch_1,
sound_ouch_2,
sound_ouch_3,
sound_plane_crash,
sound_power_down,
sound_power_up,
sound_raaalph,
sound_scream_1,
sound_scream_2,
sound_scream_man,
sound_toilet_open,
sound_toilet,
sound_wow,
SOUND_COUNT
};
const char SOUND_NAME[SOUND_COUNT][128] = {
"sound/best_loop.mp3",
"sound/drop_item.mp3",
"sound/electro_loop.mp3",
"sound/haha.mp3",
"sound/harkem_shake.mp3",
"sound/monkey.mp3",
"sound/noise_loop.mp3",
"sound/ouch_1.mp3",
"sound/ouch_2.mp3",
"sound/ouch_3.mp3",
"sound/plane_crash.mp3",
"sound/power_down.mp3",
"sound/power_up.mp3",
"sound/raaalph.mp3",
"sound/scream_1.mp3",
"sound/scream_2.mp3",
"sound/scream_man.mp3",
"sound/toilet_open.mp3",
"sound/toilet.mp3",
"sound/wow.mp3"
};
class SoundManager {
public:
static SoundManager* getInstance();
SoundManager();
void playSound(Sounds sound, bool loop, float volume);
void pauseSound(Sounds id);
void resumeSound(Sounds id);
private:
cocos2d::experimental::AudioProfile m_audioProfile;
__Array* m_soundsIds;
};
#endif /* defined(__Ava__SoundManager__) */
| jetberry/JamPewDiePie | Classes/SoundManager/SoundManager.h | C | mit | 1,629 | [
30522,
1013,
1013,
1013,
1013,
2614,
24805,
4590,
1012,
1044,
1013,
1013,
9389,
1013,
1013,
1013,
1013,
2580,
2011,
9808,
2696,
2361,
2006,
2603,
1012,
2340,
1012,
2403,
1012,
1013,
1013,
1013,
1013,
1001,
2065,
13629,
2546,
1035,
1035,
9... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
## update-hue-ini.py
##
## This script will extract the appropriate IBM Analytics for Apache Hadoop credentials from the VCAP_SERVICES
## environment variable inside a running container. It will add the username and password to the hue.ini file
## so that the hue application has access to a specific instance
import sys
import os
import json
username = None
password = None
webhdfsurl = None
srcfile = sys.argv[1]
destfile = sys.argv[2]
if "VCAP_SERVICES" in os.environ:
vcaps = json.loads(os.environ["VCAP_SERVICES"])
if "Analytics for Apache Hadoop" in vcaps:
username = vcaps["Analytics for Apache Hadoop"][0]["credentials"]["userid"]
password = vcaps["Analytics for Apache Hadoop"][0]["credentials"]["password"]
webhdfsurl = vcaps["Analytics for Apache Hadoop"][0]["credentials"]["WebhdfsUrl"]
else:
if "WEBHDFS_USER" in os.environ:
username=os.environ["WEBHDFS_USER"]
if "WEBHDFS_PASSWORD" in os.environ:
password=os.environ["WEBHDFS_PASSWORD"]
if "WEBHDFS_URL" in os.environ:
webhdfsurl=os.environ["WEBHDFS_URL"]
if (username is not None and password is not None and webhdfsurl is not None):
filedata = None
with open (srcfile,'r') as file:
filedata = file.read()
filedata = filedata.replace('%instance_user%', username)
filedata = filedata.replace('%instance_user_password%', password)
filedata = filedata.replace('%webhdfs_url%', webhdfsurl)
with open (destfile,'w') as file:
file.write(filedata)
sys.exit(0)
else:
sys.stderr.write('Fatal error: cannot find Web HDFS credentials and/or endpoint\n')
if username is None:
sys.stderr.write('username missing\n')
if password is None:
sys.stderr.write('password missing\n')
if webhdfsurl is None:
sys.stderr.write('URL endpoint missing\n')
sys.exit(1)
| vmanoria/bluemix-hue-filebrowser | update-hue-ini.py | Python | gpl-2.0 | 1,829 | [
30522,
1001,
1001,
10651,
1011,
20639,
1011,
1999,
2072,
1012,
1052,
2100,
1001,
1001,
1001,
1001,
2023,
5896,
2097,
14817,
1996,
6413,
9980,
25095,
2005,
15895,
2018,
18589,
22496,
2013,
1996,
18315,
9331,
1035,
2578,
1001,
1001,
4044,
802... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
#ifndef _ASM_GENERIC_RWSEM_H
#define _ASM_GENERIC_RWSEM_H
#ifndef _LINUX_RWSEM_H
#error "Please don't include <asm/rwsem.h> directly, use <linux/rwsem.h> instead."
#endif
#ifdef __KERNEL__
/*
* R/W semaphores originally for PPC using the stuff in lib/rwsem.c.
* Adapted largely from include/asm-i386/rwsem.h
* by Paul Mackerras <paulus@samba.org>.
*/
/*
* the semaphore definition
*/
#ifdef CONFIG_64BIT
# define RWSEM_ACTIVE_MASK 0xffffffffL
#else
# define RWSEM_ACTIVE_MASK 0x0000ffffL
#endif
#define RWSEM_UNLOCKED_VALUE 0x00000000L
#define RWSEM_ACTIVE_BIAS 0x00000001L
#define RWSEM_WAITING_BIAS (-RWSEM_ACTIVE_MASK-1)
#define RWSEM_ACTIVE_READ_BIAS RWSEM_ACTIVE_BIAS
#define RWSEM_ACTIVE_WRITE_BIAS (RWSEM_WAITING_BIAS + RWSEM_ACTIVE_BIAS)
/*
* lock for reading
*/
static inline void __down_read(struct rw_semaphore *sem)
{
if (unlikely(atomic_long_inc_return((atomic_long_t *)&sem->count) <= 0))
rwsem_down_read_failed(sem);
}
static inline int __down_read_trylock(struct rw_semaphore *sem)
{
long tmp;
while ((tmp = sem->count) >= 0) {
if (tmp == cmpxchg(&sem->count, tmp,
tmp + RWSEM_ACTIVE_READ_BIAS)) {
return 1;
}
}
return 0;
}
/*
* lock for writing
*/
static inline void __down_write_nested(struct rw_semaphore *sem, int subclass)
{
long tmp;
tmp = atomic_long_add_return(RWSEM_ACTIVE_WRITE_BIAS,
(atomic_long_t *)&sem->count);
if (unlikely(tmp != RWSEM_ACTIVE_WRITE_BIAS))
rwsem_down_write_failed(sem);
}
static inline void __down_write(struct rw_semaphore *sem)
{
__down_write_nested(sem, 0);
}
static inline int __down_write_trylock(struct rw_semaphore *sem)
{
long tmp;
tmp = cmpxchg(&sem->count, RWSEM_UNLOCKED_VALUE,
RWSEM_ACTIVE_WRITE_BIAS);
return tmp == RWSEM_UNLOCKED_VALUE;
}
/*
* unlock after reading
*/
static inline void __up_read(struct rw_semaphore *sem)
{
long tmp;
tmp = atomic_long_dec_return((atomic_long_t *)&sem->count);
if (unlikely(tmp < -1 && (tmp & RWSEM_ACTIVE_MASK) == 0))
rwsem_wake(sem);
}
/*
* unlock after writing
*/
static inline void __up_write(struct rw_semaphore *sem)
{
if (unlikely(atomic_long_sub_return(RWSEM_ACTIVE_WRITE_BIAS,
(atomic_long_t *)&sem->count) < 0))
rwsem_wake(sem);
}
/*
* implement atomic add functionality
*/
static inline void rwsem_atomic_add(long delta, struct rw_semaphore *sem)
{
atomic_long_add(delta, (atomic_long_t *)&sem->count);
}
/*
* downgrade write lock to read lock
*/
static inline void __downgrade_write(struct rw_semaphore *sem)
{
long tmp;
tmp = atomic_long_add_return(-RWSEM_WAITING_BIAS,
(atomic_long_t *)&sem->count);
if (tmp < 0)
rwsem_downgrade_wake(sem);
}
/*
* implement exchange and add functionality
*/
static inline long rwsem_atomic_update(long delta, struct rw_semaphore *sem)
{
return atomic_long_add_return(delta, (atomic_long_t *)&sem->count);
}
#endif /* __KERNEL__ */
#endif /* _ASM_GENERIC_RWSEM_H */
| mericon/Xp_Kernel_LGH850 | virt/include/asm-generic/rwsem.h | C | gpl-2.0 | 2,931 | [
30522,
1001,
2065,
13629,
2546,
1035,
2004,
2213,
1035,
12391,
1035,
1054,
9333,
6633,
1035,
1044,
1001,
9375,
1035,
2004,
2213,
1035,
12391,
1035,
1054,
9333,
6633,
1035,
1044,
1001,
2065,
13629,
2546,
1035,
11603,
1035,
1054,
9333,
6633,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
"use strict";
/**
* @license
* Copyright 2017 Google Inc. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
var __generator = (this && this.__generator) || function (thisArg, body) {
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
function verb(n) { return function (v) { return step([n, v]); }; }
function step(op) {
if (f) throw new TypeError("Generator is already executing.");
while (_) try {
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
if (y = 0, t) op = [op[0] & 2, t.value];
switch (op[0]) {
case 0: case 1: t = op; break;
case 4: _.label++; return { value: op[1], done: false };
case 5: _.label++; y = op[1]; op = [0]; continue;
case 7: op = _.ops.pop(); _.trys.pop(); continue;
default:
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
if (t[2]) _.ops.pop();
_.trys.pop(); continue;
}
op = body.call(thisArg, _);
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
}
};
var _this = this;
Object.defineProperty(exports, "__esModule", { value: true });
var tf = require("./index");
var jasmine_util_1 = require("./jasmine_util");
var tensor_1 = require("./tensor");
var test_util_1 = require("./test_util");
jasmine_util_1.describeWithFlags('variable', jasmine_util_1.ALL_ENVS, function () {
it('simple assign', function () { return __awaiter(_this, void 0, void 0, function () {
var v, _a, _b;
return __generator(this, function (_c) {
switch (_c.label) {
case 0:
v = tf.variable(tf.tensor1d([1, 2, 3]));
_a = test_util_1.expectArraysClose;
return [4 /*yield*/, v.data()];
case 1:
_a.apply(void 0, [_c.sent(), [1, 2, 3]]);
v.assign(tf.tensor1d([4, 5, 6]));
_b = test_util_1.expectArraysClose;
return [4 /*yield*/, v.data()];
case 2:
_b.apply(void 0, [_c.sent(), [4, 5, 6]]);
return [2 /*return*/];
}
});
}); });
it('simple chain assign', function () { return __awaiter(_this, void 0, void 0, function () {
var v, _a, _b;
return __generator(this, function (_c) {
switch (_c.label) {
case 0:
v = tf.tensor1d([1, 2, 3]).variable();
_a = test_util_1.expectArraysClose;
return [4 /*yield*/, v.data()];
case 1:
_a.apply(void 0, [_c.sent(), [1, 2, 3]]);
v.assign(tf.tensor1d([4, 5, 6]));
_b = test_util_1.expectArraysClose;
return [4 /*yield*/, v.data()];
case 2:
_b.apply(void 0, [_c.sent(), [4, 5, 6]]);
return [2 /*return*/];
}
});
}); });
it('default names are unique', function () {
var v = tf.variable(tf.tensor1d([1, 2, 3]));
expect(v.name).not.toBeNull();
var v2 = tf.variable(tf.tensor1d([1, 2, 3]));
expect(v2.name).not.toBeNull();
expect(v.name).not.toBe(v2.name);
});
it('user provided name', function () {
var v = tf.variable(tf.tensor1d([1, 2, 3]), true, 'myName');
expect(v.name).toBe('myName');
});
it('if name already used, throw error', function () {
tf.variable(tf.tensor1d([1, 2, 3]), true, 'myName');
expect(function () { return tf.variable(tf.tensor1d([1, 2, 3]), true, 'myName'); })
.toThrowError();
});
it('ops can take variables', function () { return __awaiter(_this, void 0, void 0, function () {
var value, v, res, _a;
return __generator(this, function (_b) {
switch (_b.label) {
case 0:
value = tf.tensor1d([1, 2, 3]);
v = tf.variable(value);
res = tf.sum(v);
_a = test_util_1.expectArraysClose;
return [4 /*yield*/, res.data()];
case 1:
_a.apply(void 0, [_b.sent(), [6]]);
return [2 /*return*/];
}
});
}); });
it('chained variables works', function () { return __awaiter(_this, void 0, void 0, function () {
var v, res, _a;
return __generator(this, function (_b) {
switch (_b.label) {
case 0:
v = tf.tensor1d([1, 2, 3]).variable();
res = tf.sum(v);
_a = test_util_1.expectArraysClose;
return [4 /*yield*/, res.data()];
case 1:
_a.apply(void 0, [_b.sent(), [6]]);
return [2 /*return*/];
}
});
}); });
it('variables are not affected by tidy', function () { return __awaiter(_this, void 0, void 0, function () {
var v, _a;
return __generator(this, function (_b) {
switch (_b.label) {
case 0:
expect(tf.memory().numTensors).toBe(0);
tf.tidy(function () {
var value = tf.tensor1d([1, 2, 3], 'float32');
expect(tf.memory().numTensors).toBe(1);
v = tf.variable(value);
expect(tf.memory().numTensors).toBe(2);
});
expect(tf.memory().numTensors).toBe(1);
_a = test_util_1.expectArraysClose;
return [4 /*yield*/, v.data()];
case 1:
_a.apply(void 0, [_b.sent(), [1, 2, 3]]);
v.dispose();
expect(tf.memory().numTensors).toBe(0);
return [2 /*return*/];
}
});
}); });
it('disposing a named variable allows creating new named variable', function () {
var numTensors = tf.memory().numTensors;
var t = tf.scalar(1);
var varName = 'var';
var v = tf.variable(t, true, varName);
expect(tf.memory().numTensors).toBe(numTensors + 2);
v.dispose();
t.dispose();
expect(tf.memory().numTensors).toBe(numTensors);
// Create another variable with the same name.
var t2 = tf.scalar(1);
var v2 = tf.variable(t2, true, varName);
expect(tf.memory().numTensors).toBe(numTensors + 2);
t2.dispose();
v2.dispose();
expect(tf.memory().numTensors).toBe(numTensors);
});
it('double disposing a variable works', function () {
var numTensors = tf.memory().numTensors;
var t = tf.scalar(1);
var v = tf.variable(t);
expect(tf.memory().numTensors).toBe(numTensors + 2);
t.dispose();
v.dispose();
expect(tf.memory().numTensors).toBe(numTensors);
// Double dispose the variable.
v.dispose();
expect(tf.memory().numTensors).toBe(numTensors);
});
it('constructor does not dispose', function () { return __awaiter(_this, void 0, void 0, function () {
var a, v, _a, _b;
return __generator(this, function (_c) {
switch (_c.label) {
case 0:
a = tf.scalar(2);
v = tf.variable(a);
expect(tf.memory().numTensors).toBe(2);
expect(tf.memory().numDataBuffers).toBe(1);
_a = test_util_1.expectArraysClose;
return [4 /*yield*/, v.data()];
case 1:
_a.apply(void 0, [_c.sent(), [2]]);
_b = test_util_1.expectArraysClose;
return [4 /*yield*/, a.data()];
case 2:
_b.apply(void 0, [_c.sent(), [2]]);
return [2 /*return*/];
}
});
}); });
it('variables are assignable to tensors', function () {
// This test asserts compilation, not doing any run-time assertion.
var x0 = null;
var y0 = x0;
expect(y0).toBeNull();
var x1 = null;
var y1 = x1;
expect(y1).toBeNull();
var x2 = null;
var y2 = x2;
expect(y2).toBeNull();
var x3 = null;
var y3 = x3;
expect(y3).toBeNull();
var x4 = null;
var y4 = x4;
expect(y4).toBeNull();
var xh = null;
var yh = xh;
expect(yh).toBeNull();
});
it('assign does not dispose old data', function () { return __awaiter(_this, void 0, void 0, function () {
var v, _a, secondArray, _b;
return __generator(this, function (_c) {
switch (_c.label) {
case 0:
v = tf.variable(tf.tensor1d([1, 2, 3]));
expect(tf.memory().numTensors).toBe(2);
expect(tf.memory().numDataBuffers).toBe(1);
_a = test_util_1.expectArraysClose;
return [4 /*yield*/, v.data()];
case 1:
_a.apply(void 0, [_c.sent(), [1, 2, 3]]);
secondArray = tf.tensor1d([4, 5, 6]);
expect(tf.memory().numTensors).toBe(3);
expect(tf.memory().numDataBuffers).toBe(2);
v.assign(secondArray);
_b = test_util_1.expectArraysClose;
return [4 /*yield*/, v.data()];
case 2:
_b.apply(void 0, [_c.sent(), [4, 5, 6]]);
// Assign doesn't dispose the 1st array.
expect(tf.memory().numTensors).toBe(3);
expect(tf.memory().numDataBuffers).toBe(2);
v.dispose();
// Disposing the variable disposes itself. The input to variable and
// secondArray are the only remaining tensors.
expect(tf.memory().numTensors).toBe(2);
expect(tf.memory().numDataBuffers).toBe(2);
return [2 /*return*/];
}
});
}); });
it('shape must match', function () {
var v = tf.variable(tf.tensor1d([1, 2, 3]));
expect(function () { return v.assign(tf.tensor1d([1, 2])); }).toThrowError();
// tslint:disable-next-line:no-any
expect(function () { return v.assign(tf.tensor2d([3, 4], [1, 2])); }).toThrowError();
});
it('dtype must match', function () {
var v = tf.variable(tf.tensor1d([1, 2, 3]));
// tslint:disable-next-line:no-any
expect(function () { return v.assign(tf.tensor1d([1, 1, 1], 'int32')); })
.toThrowError();
// tslint:disable-next-line:no-any
expect(function () { return v.assign(tf.tensor1d([true, false, true], 'bool')); })
.toThrowError();
});
});
jasmine_util_1.describeWithFlags('x instanceof Variable', jasmine_util_1.ALL_ENVS, function () {
it('x: Variable', function () {
var t = tf.variable(tf.scalar(1));
expect(t instanceof tensor_1.Variable).toBe(true);
});
it('x: Variable-like', function () {
var t = { assign: function () { }, shape: [2], dtype: 'float32', dataId: {} };
expect(t instanceof tensor_1.Variable).toBe(true);
});
it('x: other object, fails', function () {
var t = { something: 'else' };
expect(t instanceof tensor_1.Variable).toBe(false);
});
it('x: Tensor, fails', function () {
var t = tf.scalar(1);
expect(t instanceof tensor_1.Variable).toBe(false);
});
});
//# sourceMappingURL=variable_test.js.map | ManakCP/NestJs | node_modules/@tensorflow/tfjs-core/dist/variable_test.js | JavaScript | mit | 13,815 | [
30522,
1000,
2224,
9384,
1000,
1025,
1013,
1008,
1008,
1008,
1030,
6105,
1008,
9385,
2418,
8224,
4297,
1012,
2035,
2916,
9235,
1012,
1008,
7000,
2104,
1996,
15895,
6105,
1010,
2544,
1016,
1012,
1014,
1006,
1996,
1000,
6105,
1000,
1007,
10... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
/* ISC license. */
#include <bearssl.h>
#include <s6-networking/sbearssl.h>
int sbearssl_skey_to (sbearssl_skey const *l, br_skey *k, char *s)
{
switch (l->type)
{
case BR_KEYTYPE_RSA :
sbearssl_rsa_skey_to(&l->data.rsa, &k->data.rsa, s) ;
break ;
case BR_KEYTYPE_EC :
sbearssl_ec_skey_to(&l->data.ec, &k->data.ec, s) ;
break ;
default :
return 0 ;
}
k->type = l->type ;
return 1 ;
}
| skarnet/s6-networking | src/sbearssl/sbearssl_skey_to.c | C | isc | 438 | [
30522,
1013,
1008,
2003,
2278,
6105,
1012,
1008,
1013,
1001,
2421,
1026,
6468,
14540,
1012,
1044,
1028,
1001,
2421,
1026,
1055,
2575,
1011,
14048,
1013,
24829,
26492,
14540,
1012,
1044,
1028,
20014,
24829,
26492,
14540,
1035,
15315,
3240,
1... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
package rd2wgs84
import (
"testing"
)
var parseTests = []struct {
in RD
out *WGS84
}{
{RD{163835.370083, 446830.763585}, &WGS84{52.00977421758342, 5.515894213047998}},
}
func TestConvert(t *testing.T) {
for i, tt := range parseTests {
wgs := Convert(tt.in.X, tt.in.Y)
if wgs.Latitude != tt.out.Latitude || wgs.Longitude != tt.out.Longitude {
t.Errorf("%d. Convert(%f, %f) => %+v returned, expected %+v", i, tt.in.X, tt.in.Y, wgs, tt.out)
}
}
}
| mvmaasakkers/go-rd2wgs84 | rd2wgs84_test.go | GO | mit | 463 | [
30522,
7427,
16428,
2475,
27767,
2015,
2620,
2549,
12324,
1006,
1000,
5604,
1000,
1007,
13075,
11968,
13462,
4355,
2015,
1027,
1031,
1033,
2358,
6820,
6593,
1063,
1999,
16428,
2041,
1008,
1059,
5620,
2620,
2549,
1065,
1063,
1063,
16428,
106... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
<!-- <a class="make-patch-link" target="_blank" href="<?js= obj.githubSourceLink ?>"><?js= this.lang.patchLinkText ?></a>
<a class="comments" data-id="<?js= obj.link ?>" data-title="<?js= obj.title ?>"><?js= this.lang.comments ?><i></i></a>
<div class="comments-container"
href="https://muut.com/i/seemple/comments/seemple-<?js= this.langName ?>:<?js= obj.link ?>"
title="<?js= obj.title ?>"
data-channel="Seemple"
data-show_online="false"
data-upload="false"></div>
-->
| finom/matreshka_docs | jsdoc-template/tmpl/comments.html | HTML | mit | 482 | [
30522,
1026,
999,
1011,
1011,
1026,
1037,
2465,
1027,
1000,
2191,
1011,
8983,
1011,
4957,
1000,
4539,
1027,
1000,
1035,
8744,
1000,
17850,
12879,
1027,
1000,
1026,
1029,
1046,
2015,
1027,
27885,
3501,
1012,
21025,
2705,
12083,
6499,
3126,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
# depth-in-react-demo
学习《深入react技术栈》
## React.cloneElement
```js
React.cloneElement(
element,
[props],
[...children]
)
```
以 element 作为起点,克隆并返回一个新的React元素(React Element)。生成的元素将会拥有原始元素props与新props的浅合并。新的子级会替换现有的子级。来自原始元素的 key 和 ref 将会保留。
React.cloneElement() 几乎相当于:
```html
<element.type {...element.props} {...props}>{children}</element.type>
```
如果组件是由父组件更新 props 而更新的,那么在 shouldComponentUpdate 之前会先执行
componentWillReceiveProps 方法。此方法可以作为 React 在 props 传入后,渲染之前 setState 的
机会。在此方法中调用 setState 是不会二次渲染的
## 生命周期相关 ##
1. 组件挂在或卸载时


2. 数据更新过程: 指的是父组件向下传递 props 或组件自身执行 setState 方法时发生的一系列更新
动作
### React 声明周期整体流程 ###

### React受控组件更新state的流程 ###
1. 可以通过在初始化state中设置表单的默认值.
2. 每当表单的值发生变化是,调用onchange时间处理器
3. 事件处理器通过合成事件对象e拿到改变后的状态,并更新应用的state.
4. setState触发视图的重新渲染,完成表单组件值的更新.
### 受控组件和非受控组件对比 ###
非受控组件通过defaultValue或者defaultChecked来设置表单的默认值,它仅会被渲染一次,在后续的渲染时并不起作用.
非受控组件的状态并不会受应用状态的控制,应用中也多了局部组件状态,而受控组件的值来自于组件的state.
- 性能上问题
表单每次变化,都会调用一次onChange事件处理器,所以受控组件在性能上有一些损耗,非受控组件不会出现这些问题.
- 是否需要事件绑定
受控组件需要为每个组件绑定一个change事件,某些简单的情况下,可以用一个处理器处理多个表单域.
### CSS模块化遇到的问题 ###
- 全局污染: CSS使用全局选择器机制设置样式,方便了重写样式的同时可能会发生延时被错误覆盖的现象.Web Components标准中的Shadow DOM能彻底解决这个问题,但它把样式彻底局部化,造成外部无法重写样式,损失了灵活性.
- 命名混乱
- 依赖管理不彻底: 组件应该是相互独立的, 引入一个组件式, 应该只引入它所需要的CSS样式. 如果能让JavaScript来管理CSS依赖是很好的解决办法, webpack的css-loader提供了这种能力
- 无法共享变量
- 代码压缩不彻底
CSS Modules实现了一下几点:
- 所有样式都是局部化的, 解决了命名冲突和全局污染问题
- class名的生成规则配置灵活, 可以以此来压缩class名
- 只需引用组件的JavaScript, 就能搞定组件所有的JavaScript和CSS
- 依然是CSS, 学习成本几乎为零
### 父组件向子组件通信 ###
父组件通过 `props`向子组件传递需要的信息.
### 子组件向父组件通信 ###
- 利用回调函数: 这是JavaScript灵活方便之处, 这样就可以拿到运行时的状态
- 利用自定义事件机制: 这种方法更通用, 使用也广泛.设计组件式,可考虑加入时间机制往往可以达到简化组件api的目的.
### 跨级组件通行 ###
使用context来实现跨级父子组件的通信.

### 没有嵌套关系的组件通信 ###
自定义事件机制: `EventEmitter`.
**Note**: 在componentDidMount事件中,如果组件挂在完成,再订阅事件,在组件卸载的时候, componentWillUnmount事件中取消事件订阅.
一般情况下, 自检之间的通信尽可能保持简介. 如果说程序中出现多级传递或者跨级传递是,那么首先要重新审视一下是否有更合理的方式.
### 高阶组件 ###
当react组件被包裹是,高阶组件会返回一个增强的react组件.
实现高阶组件的两种方式:
- 属性代理: 高阶组件通过被包裹的react组件来操作props
- 反向继承: 高阶组件继承于被包裹的react组件.
### react主要思想 ###
通过构建可复用组件来构建用户界面。
### 组件的生命周期在不同状态下的执行顺序 (react-lifecycle mixin) ###
- 当首次挂载组件时,按顺序执行`getDefaultProps`, `getInitialState`, `componentWillMount`, `render`和`componentDidMount`。
- 当下载组件时, 执行`componentWillUnmount`。
- 当重新挂载组件时,按顺序执行`getInitialState`, `componentWillMount`, `render`和`componentDidMount`,但并执行`getDefaultProps`
- 当再次渲染组件时,组件接受到更新状态,此时按顺序执行`componentWillReveiveProps`, `shouldComponentUpdate`, `componentWillUpdate`, `render`和`componentDidUpdate`
生命周期主要分三个阶段管理: `MOUNTING`, `REVEIVE_PROPS`, `UNMOUNTING`,对应三中方法:`mountComponent`, `updateComponent` , `unmountComponent`。
- 阶段一:MOUNTING
`mountComponent`负责管理生命周期中的`getInitialState`, `componentWillMount`, `render`和`componentDidMount`
`getDefaultProps`是通过构造函数管理的,整个生命周期中最先执行的,而且只执行一次。
***Note*** : `componentWillMount`中执行`setState()`不会触发重新渲染,而是合并state,此时无法获取到更新后的state,需要`render`之后才可以获取到

- 阶段二:RECEIVE_PROPS
`updateComponent`负责管理生命周期中的`componentWillReceiveProps`, `shouldComponentUpdate`, `componentWillUpdate`, `render`和`componentDidUpdate`
***Note*** : `componentWillUpdate`中执行`setState()`不会触发重新渲染,而是合并state,此时无法获取到更新后的state,需要`render`之后才可以获取到.
***NOTE***: 禁止在`shouldComponentUpdate`和`componentWillUpdate`中调用`setState`,这会造成循环调用,直至耗光浏览器内存后崩溃。

- 阶段三:UMOUNTING
`unmountComponent`负责管理`componentWillUnmount`,重置所有相关参数,更新队列以及更新状态
***Note*** : 尽可能使用无状态组件
### react diff 算法的三个策略 ###
- web UI中dom节点跨层级操作特别少,可以忽略不计。
- 拥有相同类的两个组件将会生成相似的树形结构,拥有不同类的两个组件将会生成不同的树形结构。
- 对于同一层级的一组子节点,它们可以通过唯一id进行区分。 | wangming-0215/depth-in-react-demo | README.md | Markdown | mit | 6,566 | [
30522,
1001,
5995,
1011,
1999,
1011,
10509,
1011,
9703,
1817,
100,
1639,
100,
100,
10509,
100,
100,
100,
1640,
1001,
1001,
10509,
1012,
17598,
12260,
3672,
1036,
1036,
1036,
1046,
2015,
10509,
1012,
17598,
12260,
3672,
1006,
5783,
1010,
1... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
using UnityEngine;
using System.Collections;
public class SpawnWater : MonoBehaviour {
//this controlls how long after using the water power the player must wait to use it again
public float interval = 3;
public float veritcalOffset = .5f;
private float timer;
private GameObject myWaterBlast;
// Use this for initialization
void Start ()
{
if (myWaterBlast == null)
{
myWaterBlast = Resources.Load ("Prefabs/WaterBlast") as GameObject;
}
this.timer = Time.time;
}
// Update is called once per frame
void Update ()
{
//detect user input and check time interval
if (Input.GetButtonDown("WaterPower") && Time.time - timer > interval)
{
//update timer
timer = Time.time;
//spawn water blast
GameObject obj = (GameObject)Instantiate(myWaterBlast);
obj.transform.position = new Vector3(this.transform.position.x,
this.transform.position.y + veritcalOffset, 0f);
Rigidbody2D objRB = obj.GetComponent<Rigidbody2D>() as Rigidbody2D;
Rigidbody2D playerRB = GetComponent<Rigidbody2D>() as Rigidbody2D;
objRB.velocity = playerRB.velocity;
}
}
}
| TeamD4D-Bothell/Sprout | TeamD4D_Sprout/Assets/Scripts/Player/SpawnWater.cs | C# | gpl-3.0 | 1,266 | [
30522,
2478,
8499,
13159,
3170,
1025,
2478,
2291,
1012,
6407,
1025,
2270,
2465,
25645,
5880,
1024,
18847,
4783,
3270,
25500,
3126,
1063,
30524,
2009,
2153,
2270,
14257,
13483,
1027,
1017,
1025,
2270,
14257,
2310,
14778,
9289,
27475,
3388,
1... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
var HDWalletProvider = require("truffle-hdwallet-provider");
var mnemonic = "candy maple cake sugar pudding cream honey rich smooth crumble sweet treat";
module.exports = {
networks: {
development: {
provider: function () {
return new HDWalletProvider(mnemonic, "http://127.0.0.1:7545/", 0, 50);
},
network_id: "*",
},
},
compilers: {
solc: {
version: "^0.5.2",
},
},
};
| manishbisht/Competitive-Programming | Hiring Challenges/Bosch/Blockchain Developer Hiring/Round 2/truffle.js | JavaScript | mit | 484 | [
30522,
13075,
10751,
9628,
3388,
21572,
17258,
2121,
1027,
5478,
1006,
1000,
19817,
16093,
21031,
1011,
10751,
9628,
3388,
1011,
10802,
1000,
1007,
1025,
13075,
24098,
26941,
2594,
1027,
1000,
9485,
11035,
9850,
5699,
29593,
6949,
6861,
4138,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
# $Id$
"""Mixins that are useful for classes using vtk_kit.
@author: Charl P. Botha <http://cpbotha.net/>
"""
from external.vtkPipeline.ConfigVtkObj import ConfigVtkObj
from external.vtkPipeline.vtkMethodParser import VtkMethodParser
from module_base import ModuleBase
from module_mixins import IntrospectModuleMixin # temporary
import module_utils # temporary, most of this should be in utils.
import re
import types
import utils
#########################################################################
class PickleVTKObjectsModuleMixin(object):
"""This mixin will pickle the state of all vtk objects whose binding
attribute names have been added to self._vtkObjects, e.g. if you have
a self._imageMath, '_imageMath' should be in the list.
Your module has to derive from module_base as well so that it has a
self._config!
Remember to call the __init__ of this class with the list of attribute
strings representing vtk objects that you want pickled. All the objects
have to exist and be initially configured by then.
Remember to call close() when your child class close()s.
"""
def __init__(self, vtkObjectNames):
# you have to add the NAMES of the objects that you want pickled
# to this list.
self._vtkObjectNames = vtkObjectNames
self.statePattern = re.compile ("To[A-Z0-9]")
# make sure that the state of the vtkObjectNames objects is
# encapsulated in the initial _config
self.logic_to_config()
def close(self):
# make sure we get rid of these bindings as well
del self._vtkObjectNames
def logic_to_config(self):
parser = VtkMethodParser()
for vtkObjName in self._vtkObjectNames:
# pickled data: a list with toggle_methods, state_methods and
# get_set_methods as returned by the vtkMethodParser. Each of
# these is a list of tuples with the name of the method (as
# returned by the vtkMethodParser) and the value; in the case
# of the stateMethods, we use the whole stateGroup instead of
# just a single name
vtkObjPD = [[], [], []]
vtkObj = getattr(self, vtkObjName)
parser.parse_methods(vtkObj)
# parser now has toggle_methods(), state_methods() and
# get_set_methods();
# toggle_methods: ['BlaatOn', 'AbortExecuteOn']
# state_methods: [['SetBlaatToOne', 'SetBlaatToTwo'],
# ['SetMaatToThree', 'SetMaatToFive']]
# get_set_methods: ['NumberOfThreads', 'Progress']
for method in parser.toggle_methods():
# if you query ReleaseDataFlag on a filter with 0 outputs,
# VTK yields an error
if vtkObj.GetNumberOfOutputPorts() == 0 and \
method == 'ReleaseDataFlagOn':
continue
# we need to snip the 'On' off
val = eval("vtkObj.Get%s()" % (method[:-2],))
vtkObjPD[0].append((method, val))
for stateGroup in parser.state_methods():
# we search up to the To
end = self.statePattern.search (stateGroup[0]).start ()
# so we turn SetBlaatToOne to GetBlaat
get_m = 'G'+stateGroup[0][1:end]
# we're going to have to be more clever when we set_config...
# use a similar trick to get_state in vtkMethodParser
val = eval('vtkObj.%s()' % (get_m,))
vtkObjPD[1].append((stateGroup, val))
for method in parser.get_set_methods():
val = eval('vtkObj.Get%s()' % (method,))
vtkObjPD[2].append((method, val))
# finally set the pickle data in the correct position
setattr(self._config, vtkObjName, vtkObjPD)
def config_to_logic(self):
# go through at least the attributes in self._vtkObjectNames
for vtkObjName in self._vtkObjectNames:
try:
vtkObjPD = getattr(self._config, vtkObjName)
vtkObj = getattr(self, vtkObjName)
except AttributeError:
print "PickleVTKObjectsModuleMixin: %s not available " \
"in self._config OR in self. Skipping." % (vtkObjName,)
else:
for method, val in vtkObjPD[0]:
if val:
eval('vtkObj.%s()' % (method,))
else:
# snip off the On
eval('vtkObj.%sOff()' % (method[:-2],))
for stateGroup, val in vtkObjPD[1]:
# keep on calling the methods in stategroup until
# the getter returns a value == val.
end = self.statePattern.search(stateGroup[0]).start()
getMethod = 'G'+stateGroup[0][1:end]
for i in range(len(stateGroup)):
m = stateGroup[i]
eval('vtkObj.%s()' % (m,))
tempVal = eval('vtkObj.%s()' % (getMethod,))
if tempVal == val:
# success! break out of the for loop
break
for method, val in vtkObjPD[2]:
try:
eval('vtkObj.Set%s(val)' % (method,))
except TypeError:
if type(val) in [types.TupleType, types.ListType]:
# sometimes VTK wants the separate elements
# and not the tuple / list
eval("vtkObj.Set%s(*val)"%(method,))
else:
# re-raise the exception if it wasn't a
# tuple/list
raise
#########################################################################
# note that the pickle mixin comes first, as its config_to_logic/logic_to_config
# should be chosen over that of noConfig
class SimpleVTKClassModuleBase(PickleVTKObjectsModuleMixin,
IntrospectModuleMixin,
ModuleBase):
"""Use this base to make a DeVIDE module that wraps a single VTK
object. The state of the VTK object will be saved when the network
is.
You only have to override the __init__ method and call the __init__
of this class with the desired parameters.
The __doc__ string of your module class will be replaced with the
__doc__ string of the encapsulated VTK class (and will thus be
shown if the user requests module help). If you don't want this,
call the ctor with replaceDoc=False.
inputFunctions is a list of the complete methods that have to be called
on the encapsulated VTK class, e.g. ['SetInput1(inputStream)',
'SetInput1(inputStream)']. The same goes for outputFunctions, except that
there's no inputStream involved. Use None in both cases if you want
the default to be used (SetInput(), GetOutput()).
"""
def __init__(self, module_manager, vtkObjectBinding, progressText,
inputDescriptions, outputDescriptions,
replaceDoc=True,
inputFunctions=None, outputFunctions=None):
self._viewFrame = None
self._configVtkObj = None
# first these two mixins
ModuleBase.__init__(self, module_manager)
self._theFilter = vtkObjectBinding
if replaceDoc:
myMessage = "<em>"\
"This is a special DeVIDE module that very simply " \
"wraps a single VTK class. In general, the " \
"complete state of the class will be saved along " \
"with the rest of the network. The documentation " \
"below is that of the wrapped VTK class:</em>"
self.__doc__ = '%s\n\n%s' % (myMessage, self._theFilter.__doc__)
# now that we have the object, init the pickle mixin so
# that the state of this object will be saved
PickleVTKObjectsModuleMixin.__init__(self, ['_theFilter'])
# make progress hooks for the object
module_utils.setup_vtk_object_progress(self, self._theFilter,
progressText)
self._inputDescriptions = inputDescriptions
self._outputDescriptions = outputDescriptions
self._inputFunctions = inputFunctions
self._outputFunctions = outputFunctions
def _createViewFrame(self):
parentWindow = self._module_manager.get_module_view_parent_window()
import resources.python.defaultModuleViewFrame
reload(resources.python.defaultModuleViewFrame)
dMVF = resources.python.defaultModuleViewFrame.defaultModuleViewFrame
viewFrame = module_utils.instantiate_module_view_frame(
self, self._module_manager, dMVF)
# ConfigVtkObj parent not important, we're passing frame + panel
# this should populate the sizer with a new sizer7
# params: noParent, noRenwin, vtk_obj, frame, panel
self._configVtkObj = ConfigVtkObj(None, None,
self._theFilter,
viewFrame, viewFrame.viewFramePanel)
module_utils.create_standard_object_introspection(
self, viewFrame, viewFrame.viewFramePanel,
{'Module (self)' : self}, None)
# we don't want the Execute button to be default... else stuff gets
# executed with every enter in the command window (at least in Doze)
module_utils.create_eoca_buttons(self, viewFrame,
viewFrame.viewFramePanel,
False)
self._viewFrame = viewFrame
return viewFrame
def close(self):
# we play it safe... (the graph_editor/module_manager should have
# disconnected us by now)
for input_idx in range(len(self.get_input_descriptions())):
self.set_input(input_idx, None)
PickleVTKObjectsModuleMixin.close(self)
IntrospectModuleMixin.close(self)
if self._viewFrame is not None:
self._configVtkObj.close()
self._viewFrame.Destroy()
ModuleBase.close(self)
# get rid of our binding to the vtkObject
del self._theFilter
def get_output_descriptions(self):
return self._outputDescriptions
def get_output(self, idx):
# this will only every be invoked if your get_output_descriptions has
# 1 or more elements
if self._outputFunctions:
return eval('self._theFilter.%s' % (self._outputFunctions[idx],))
else:
return self._theFilter.GetOutput()
def get_input_descriptions(self):
return self._inputDescriptions
def set_input(self, idx, inputStream):
# this will only be called for a certain idx if you've specified that
# many elements in your get_input_descriptions
if self._inputFunctions:
exec('self._theFilter.%s' %
(self._inputFunctions[idx]))
else:
if idx == 0:
self._theFilter.SetInput(inputStream)
else:
self._theFilter.SetInput(idx, inputStream)
def execute_module(self):
# it could be a writer, in that case, call the Write method.
if hasattr(self._theFilter, 'Write') and \
callable(self._theFilter.Write):
self._theFilter.Write()
else:
self._theFilter.Update()
def streaming_execute_module(self):
"""All VTK classes should be streamable.
"""
# it could be a writer, in that case, call the Write method.
if hasattr(self._theFilter, 'Write') and \
callable(self._theFilter.Write):
self._theFilter.Write()
else:
self._theFilter.Update()
def view(self):
if self._viewFrame is None:
# we have an initial config populated with stuff and in sync
# with theFilter. The viewFrame will also be in sync with the
# filter
self._viewFrame = self._createViewFrame()
self._viewFrame.Show(True)
self._viewFrame.Raise()
def config_to_view(self):
# the pickleVTKObjectsModuleMixin does logic <-> config
# so when the user clicks "sync", logic_to_config is called
# which transfers picklable state from the LOGIC to the CONFIG
# then we do double the work and call update_gui, which transfers
# the same state from the LOGIC straight up to the VIEW
self._configVtkObj.update_gui()
def view_to_config(self):
# same thing here: user clicks "apply", view_to_config is called which
# zaps UI changes straight to the LOGIC. Then we have to call
# logic_to_config explicitly which brings the info back up to the
# config... i.e. view -> logic -> config
# after that, config_to_logic is called which transfers all state AGAIN
# from the config to the logic
self._configVtkObj.apply_changes()
self.logic_to_config()
#########################################################################
| nagyistoce/devide | module_kits/vtk_kit/mixins.py | Python | bsd-3-clause | 13,612 | [
30522,
1001,
1002,
8909,
1002,
1000,
1000,
1000,
4666,
7076,
2008,
2024,
6179,
2005,
4280,
2478,
28879,
2243,
1035,
8934,
1012,
1030,
3166,
1024,
25869,
2140,
1052,
1012,
2119,
2050,
1026,
8299,
1024,
30524,
8873,
2290,
2615,
2102,
3683,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
#include "Board.h"
#include <iostream>
using namespace std;
void Board::enumExts( )
{
if(ptester->hasUnboundedHorizAttacks())
{
for( int i = 1; i <= nrows; i++ )
if( PiecesInRow[i] > 1 )
{
cout << 0 << endl;
return;
}
}
_enumExts();
}
void Board::_enumExts( )
{
Place P(1,1);
if( n() != 0 )
{
P = top();
if( PiecesInOrBelowRow[P.row] == n() )
{
P.row++;
P.col = 1;
}
}
while( P.col <= ncols )
{
if( ! IsAttacked(P) )
{
push(P);
if( n() == npieces )
report( );
else
_enumExts( );
pop();
}
P.col++;
}
if( n() == 0 )
cout << sol_count << endl;
}
void Board::print( )
{
int row, col;
for( row = nrows; row > 0; row-- )
{
for( col = 1; col <= ncols; col++)
// if(in(row,col)) cout << '*'; else cout << '0';
if(in(row,col)) cout << '#'; else cout << 'O';
cout << endl;
}
cout << endl;
}
void Board::report( )
{
sol_count++;
if( show_boards )
{
cout << "Board " << sol_count << ':' << endl;
print( );
}
}
#include "AttackTester.h"
static void useage()
{
cerr << "Options:\n\
--show-boards\n\
--pieces-per-row n1,n2,n3,...nr [default 1,1,1,...]\n\
--nrows m [default 4]\n\
--ncols n [default 4]\n\
--piece queen [default]\n\
--piece king\n\
--piece rook or others added" << endl;
exit( 1 );
}
int main(int argc, char *argv[])
{
int nrows=4;
int ncols=4;
bool show_boards = false;
int A[Board::Maxrows];
bool piecesPerRowGiven = false;
AttackTester *ptester = getp("queen");
argc--;
argv++;
while( argc-- )
{
if(!strcmp(*argv,"--show-boards"))
{
show_boards = true;
argv++;
continue;
}
if(!strcmp(*argv,"--pieces-per-row"))
{
char *p = *(++argv);
int i;
for(i = 0; (i < Board::Maxrows) && *p!='\0'; i++ )
{
A[i] = strtol(p,&p,0);
if( *p == ',' ) p++; else
if( *p != '\0' ) useage();
}
for( ; i < Board::Maxrows; i++ ) A[i] = 1;
piecesPerRowGiven = true;
argv++; argc--;
continue;
}
if(!strcmp(*argv,"--nrows"))
{
argv++; argc--;
nrows=strtol(*(argv++),NULL,0);
continue;
}
if(!strcmp(*argv,"--ncols"))
{
argv++; argc--;
ncols=strtol(*(argv++),NULL,0);
continue;
}
if(!strcmp(*argv,"--piece"))
{
argv++; argc--;
ptester = getp(*(argv++));
if( !ptester )
{
cerr << "Unimplemented Piece:" << *(argv - 1) << endl;
exit ( 1 );
}
continue;
}
}
if(piecesPerRowGiven)
{
Board myBoard(nrows, ncols, ptester, show_boards, A);
myBoard.enumExts( );
}
else
{
Board myBoard(nrows, ncols, ptester, show_boards, NULL );
myBoard.enumExts( );
}
return 0;
}
| chaikens/MathResearchPrograms | Queens/Ver2/Board.cpp | C++ | gpl-3.0 | 2,775 | [
30522,
1001,
2421,
1000,
2604,
1012,
1044,
1000,
1001,
2421,
1026,
16380,
25379,
1028,
2478,
3415,
15327,
2358,
2094,
1025,
11675,
2604,
1024,
1024,
4372,
17897,
18413,
2015,
1006,
1007,
1063,
2065,
1006,
13866,
20367,
1011,
1028,
2038,
460... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
//-----------------------------------------------------------------------
// <copyright file="AssemblyInfo.cs" company="Marimer LLC">
// Copyright (c) Marimer LLC. All rights reserved.
// Website: http://www.lhotka.net/cslanet/
// </copyright>
// <summary>no summary</summary>
//-----------------------------------------------------------------------
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("Csla.Web.Mvc.Test")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Csla.Web.Mvc.Test")]
[assembly: AssemblyCopyright("Copyright © 2010-13 Marimer LLC")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM componenets. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("ce943538-406f-42e7-8f13-216553ee5c09")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Revision and Build Numbers
// by using the '*' as shown below:
[assembly: AssemblyVersion("4.5.30.0")]
[assembly: AssemblyFileVersion("4.5.30.0")]
| BrettJaner/csla | Source/Csla.Web.Mvc.Test/Properties/AssemblyInfo.cs | C# | mit | 1,746 | [
30522,
1013,
1013,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
101... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
// Copyright (c) 2009-2016 The Bitcoin Core developers
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#if defined(HAVE_CONFIG_H)
#include "config/bitcoin-config.h"
#endif
#include "base58.h"
#include "clientversion.h"
#include "coins.h"
#include "consensus/consensus.h"
#include "core_io.h"
#include "keystore.h"
#include "policy/policy.h"
#include "policy/rbf.h"
#include "primitives/transaction.h"
#include "script/script.h"
#include "script/sign.h"
#include <univalue.h>
#include "util.h"
#include "utilmoneystr.h"
#include "utilstrencodings.h"
#include <stdio.h>
#include <boost/algorithm/string.hpp>
static bool fCreateBlank;
static std::map<std::string,UniValue> registers;
static const int CONTINUE_EXECUTION=-1;
//
// This function returns either one of EXIT_ codes when it's expected to stop the process or
// CONTINUE_EXECUTION when it's expected to continue further.
//
static int AppInitRawTx(int argc, char* argv[])
{
//
// Parameters
//
gArgs.ParseParameters(argc, argv);
// Check for -testnet or -regtest parameter (Params() calls are only valid after this clause)
try {
SelectParams(ChainNameFromCommandLine());
} catch (const std::exception& e) {
fprintf(stderr, "Error: %s\n", e.what());
return EXIT_FAILURE;
}
fCreateBlank = gArgs.GetBoolArg("-create", false);
if (argc<2 || gArgs.IsArgSet("-?") || gArgs.IsArgSet("-h") || gArgs.IsArgSet("-help"))
{
// First part of help message is specific to this utility
std::string strUsage = strprintf(_("%s berycoin-tx utility version"), _(PACKAGE_NAME)) + " " + FormatFullVersion() + "\n\n" +
_("Usage:") + "\n" +
" berycoin-tx [options] <hex-tx> [commands] " + _("Update hex-encoded berycoin transaction") + "\n" +
" berycoin-tx [options] -create [commands] " + _("Create hex-encoded berycoin transaction") + "\n" +
"\n";
fprintf(stdout, "%s", strUsage.c_str());
strUsage = HelpMessageGroup(_("Options:"));
strUsage += HelpMessageOpt("-?", _("This help message"));
strUsage += HelpMessageOpt("-create", _("Create new, empty TX."));
strUsage += HelpMessageOpt("-json", _("Select JSON output"));
strUsage += HelpMessageOpt("-txid", _("Output only the hex-encoded transaction id of the resultant transaction."));
AppendParamsHelpMessages(strUsage);
fprintf(stdout, "%s", strUsage.c_str());
strUsage = HelpMessageGroup(_("Commands:"));
strUsage += HelpMessageOpt("delin=N", _("Delete input N from TX"));
strUsage += HelpMessageOpt("delout=N", _("Delete output N from TX"));
strUsage += HelpMessageOpt("in=TXID:VOUT(:SEQUENCE_NUMBER)", _("Add input to TX"));
strUsage += HelpMessageOpt("locktime=N", _("Set TX lock time to N"));
strUsage += HelpMessageOpt("nversion=N", _("Set TX version to N"));
strUsage += HelpMessageOpt("replaceable(=N)", _("Set RBF opt-in sequence number for input N (if not provided, opt-in all available inputs)"));
strUsage += HelpMessageOpt("outaddr=VALUE:ADDRESS", _("Add address-based output to TX"));
strUsage += HelpMessageOpt("outpubkey=VALUE:PUBKEY[:FLAGS]", _("Add pay-to-pubkey output to TX") + ". " +
_("Optionally add the \"W\" flag to produce a pay-to-witness-pubkey-hash output") + ". " +
_("Optionally add the \"S\" flag to wrap the output in a pay-to-script-hash."));
strUsage += HelpMessageOpt("outdata=[VALUE:]DATA", _("Add data-based output to TX"));
strUsage += HelpMessageOpt("outscript=VALUE:SCRIPT[:FLAGS]", _("Add raw script output to TX") + ". " +
_("Optionally add the \"W\" flag to produce a pay-to-witness-script-hash output") + ". " +
_("Optionally add the \"S\" flag to wrap the output in a pay-to-script-hash."));
strUsage += HelpMessageOpt("outmultisig=VALUE:REQUIRED:PUBKEYS:PUBKEY1:PUBKEY2:....[:FLAGS]", _("Add Pay To n-of-m Multi-sig output to TX. n = REQUIRED, m = PUBKEYS") + ". " +
_("Optionally add the \"W\" flag to produce a pay-to-witness-script-hash output") + ". " +
_("Optionally add the \"S\" flag to wrap the output in a pay-to-script-hash."));
strUsage += HelpMessageOpt("sign=SIGHASH-FLAGS", _("Add zero or more signatures to transaction") + ". " +
_("This command requires JSON registers:") +
_("prevtxs=JSON object") + ", " +
_("privatekeys=JSON object") + ". " +
_("See signrawtransaction docs for format of sighash flags, JSON objects."));
fprintf(stdout, "%s", strUsage.c_str());
strUsage = HelpMessageGroup(_("Register Commands:"));
strUsage += HelpMessageOpt("load=NAME:FILENAME", _("Load JSON file FILENAME into register NAME"));
strUsage += HelpMessageOpt("set=NAME:JSON-STRING", _("Set register NAME to given JSON-STRING"));
fprintf(stdout, "%s", strUsage.c_str());
if (argc < 2) {
fprintf(stderr, "Error: too few parameters\n");
return EXIT_FAILURE;
}
return EXIT_SUCCESS;
}
return CONTINUE_EXECUTION;
}
static void RegisterSetJson(const std::string& key, const std::string& rawJson)
{
UniValue val;
if (!val.read(rawJson)) {
std::string strErr = "Cannot parse JSON for key " + key;
throw std::runtime_error(strErr);
}
registers[key] = val;
}
static void RegisterSet(const std::string& strInput)
{
// separate NAME:VALUE in string
size_t pos = strInput.find(':');
if ((pos == std::string::npos) ||
(pos == 0) ||
(pos == (strInput.size() - 1)))
throw std::runtime_error("Register input requires NAME:VALUE");
std::string key = strInput.substr(0, pos);
std::string valStr = strInput.substr(pos + 1, std::string::npos);
RegisterSetJson(key, valStr);
}
static void RegisterLoad(const std::string& strInput)
{
// separate NAME:FILENAME in string
size_t pos = strInput.find(':');
if ((pos == std::string::npos) ||
(pos == 0) ||
(pos == (strInput.size() - 1)))
throw std::runtime_error("Register load requires NAME:FILENAME");
std::string key = strInput.substr(0, pos);
std::string filename = strInput.substr(pos + 1, std::string::npos);
FILE *f = fopen(filename.c_str(), "r");
if (!f) {
std::string strErr = "Cannot open file " + filename;
throw std::runtime_error(strErr);
}
// load file chunks into one big buffer
std::string valStr;
while ((!feof(f)) && (!ferror(f))) {
char buf[4096];
int bread = fread(buf, 1, sizeof(buf), f);
if (bread <= 0)
break;
valStr.insert(valStr.size(), buf, bread);
}
int error = ferror(f);
fclose(f);
if (error) {
std::string strErr = "Error reading file " + filename;
throw std::runtime_error(strErr);
}
// evaluate as JSON buffer register
RegisterSetJson(key, valStr);
}
static CAmount ExtractAndValidateValue(const std::string& strValue)
{
CAmount value;
if (!ParseMoney(strValue, value))
throw std::runtime_error("invalid TX output value");
return value;
}
static void MutateTxVersion(CMutableTransaction& tx, const std::string& cmdVal)
{
int64_t newVersion = atoi64(cmdVal);
if (newVersion < 1 || newVersion > CTransaction::MAX_STANDARD_VERSION)
throw std::runtime_error("Invalid TX version requested");
tx.nVersion = (int) newVersion;
}
static void MutateTxLocktime(CMutableTransaction& tx, const std::string& cmdVal)
{
int64_t newLocktime = atoi64(cmdVal);
if (newLocktime < 0LL || newLocktime > 0xffffffffLL)
throw std::runtime_error("Invalid TX locktime requested");
tx.nLockTime = (unsigned int) newLocktime;
}
static void MutateTxRBFOptIn(CMutableTransaction& tx, const std::string& strInIdx)
{
// parse requested index
int inIdx = atoi(strInIdx);
if (inIdx < 0 || inIdx >= (int)tx.vin.size()) {
throw std::runtime_error("Invalid TX input index '" + strInIdx + "'");
}
// set the nSequence to MAX_INT - 2 (= RBF opt in flag)
int cnt = 0;
for (CTxIn& txin : tx.vin) {
if (strInIdx == "" || cnt == inIdx) {
if (txin.nSequence > MAX_BIP125_RBF_SEQUENCE) {
txin.nSequence = MAX_BIP125_RBF_SEQUENCE;
}
}
++cnt;
}
}
static void MutateTxAddInput(CMutableTransaction& tx, const std::string& strInput)
{
std::vector<std::string> vStrInputParts;
boost::split(vStrInputParts, strInput, boost::is_any_of(":"));
// separate TXID:VOUT in string
if (vStrInputParts.size()<2)
throw std::runtime_error("TX input missing separator");
// extract and validate TXID
std::string strTxid = vStrInputParts[0];
if ((strTxid.size() != 64) || !IsHex(strTxid))
throw std::runtime_error("invalid TX input txid");
uint256 txid(uint256S(strTxid));
static const unsigned int minTxOutSz = 9;
static const unsigned int maxVout = dgpMaxBlockSize / minTxOutSz;
// extract and validate vout
std::string strVout = vStrInputParts[1];
int vout = atoi(strVout);
if ((vout < 0) || (vout > (int)maxVout))
throw std::runtime_error("invalid TX input vout");
// extract the optional sequence number
uint32_t nSequenceIn=std::numeric_limits<unsigned int>::max();
if (vStrInputParts.size() > 2)
nSequenceIn = std::stoul(vStrInputParts[2]);
// append to transaction input list
CTxIn txin(txid, vout, CScript(), nSequenceIn);
tx.vin.push_back(txin);
}
static void MutateTxAddOutAddr(CMutableTransaction& tx, const std::string& strInput)
{
// Separate into VALUE:ADDRESS
std::vector<std::string> vStrInputParts;
boost::split(vStrInputParts, strInput, boost::is_any_of(":"));
if (vStrInputParts.size() != 2)
throw std::runtime_error("TX output missing or too many separators");
// Extract and validate VALUE
CAmount value = ExtractAndValidateValue(vStrInputParts[0]);
// extract and validate ADDRESS
std::string strAddr = vStrInputParts[1];
CBitcoinAddress addr(strAddr);
if (!addr.IsValid())
throw std::runtime_error("invalid TX output address");
// build standard output script via GetScriptForDestination()
CScript scriptPubKey = GetScriptForDestination(addr.Get());
// construct TxOut, append to transaction output list
CTxOut txout(value, scriptPubKey);
tx.vout.push_back(txout);
}
static void MutateTxAddOutPubKey(CMutableTransaction& tx, const std::string& strInput)
{
// Separate into VALUE:PUBKEY[:FLAGS]
std::vector<std::string> vStrInputParts;
boost::split(vStrInputParts, strInput, boost::is_any_of(":"));
if (vStrInputParts.size() < 2 || vStrInputParts.size() > 3)
throw std::runtime_error("TX output missing or too many separators");
// Extract and validate VALUE
CAmount value = ExtractAndValidateValue(vStrInputParts[0]);
// Extract and validate PUBKEY
CPubKey pubkey(ParseHex(vStrInputParts[1]));
if (!pubkey.IsFullyValid())
throw std::runtime_error("invalid TX output pubkey");
CScript scriptPubKey = GetScriptForRawPubKey(pubkey);
// Extract and validate FLAGS
bool bSegWit = false;
bool bScriptHash = false;
if (vStrInputParts.size() == 3) {
std::string flags = vStrInputParts[2];
bSegWit = (flags.find("W") != std::string::npos);
bScriptHash = (flags.find("S") != std::string::npos);
}
if (bSegWit) {
if (!pubkey.IsCompressed()) {
throw std::runtime_error("Uncompressed pubkeys are not useable for SegWit outputs");
}
// Call GetScriptForWitness() to build a P2WSH scriptPubKey
scriptPubKey = GetScriptForWitness(scriptPubKey);
}
if (bScriptHash) {
// Get the address for the redeem script, then call
// GetScriptForDestination() to construct a P2SH scriptPubKey.
CBitcoinAddress redeemScriptAddr(scriptPubKey);
scriptPubKey = GetScriptForDestination(redeemScriptAddr.Get());
}
// construct TxOut, append to transaction output list
CTxOut txout(value, scriptPubKey);
tx.vout.push_back(txout);
}
static void MutateTxAddOutMultiSig(CMutableTransaction& tx, const std::string& strInput)
{
// Separate into VALUE:REQUIRED:NUMKEYS:PUBKEY1:PUBKEY2:....[:FLAGS]
std::vector<std::string> vStrInputParts;
boost::split(vStrInputParts, strInput, boost::is_any_of(":"));
// Check that there are enough parameters
if (vStrInputParts.size()<3)
throw std::runtime_error("Not enough multisig parameters");
// Extract and validate VALUE
CAmount value = ExtractAndValidateValue(vStrInputParts[0]);
// Extract REQUIRED
uint32_t required = stoul(vStrInputParts[1]);
// Extract NUMKEYS
uint32_t numkeys = stoul(vStrInputParts[2]);
// Validate there are the correct number of pubkeys
if (vStrInputParts.size() < numkeys + 3)
throw std::runtime_error("incorrect number of multisig pubkeys");
if (required < 1 || required > 20 || numkeys < 1 || numkeys > 20 || numkeys < required)
throw std::runtime_error("multisig parameter mismatch. Required " \
+ std::to_string(required) + " of " + std::to_string(numkeys) + "signatures.");
// extract and validate PUBKEYs
std::vector<CPubKey> pubkeys;
for(int pos = 1; pos <= int(numkeys); pos++) {
CPubKey pubkey(ParseHex(vStrInputParts[pos + 2]));
if (!pubkey.IsFullyValid())
throw std::runtime_error("invalid TX output pubkey");
pubkeys.push_back(pubkey);
}
// Extract FLAGS
bool bSegWit = false;
bool bScriptHash = false;
if (vStrInputParts.size() == numkeys + 4) {
std::string flags = vStrInputParts.back();
bSegWit = (flags.find("W") != std::string::npos);
bScriptHash = (flags.find("S") != std::string::npos);
}
else if (vStrInputParts.size() > numkeys + 4) {
// Validate that there were no more parameters passed
throw std::runtime_error("Too many parameters");
}
CScript scriptPubKey = GetScriptForMultisig(required, pubkeys);
if (bSegWit) {
for (CPubKey& pubkey : pubkeys) {
if (!pubkey.IsCompressed()) {
throw std::runtime_error("Uncompressed pubkeys are not useable for SegWit outputs");
}
}
// Call GetScriptForWitness() to build a P2WSH scriptPubKey
scriptPubKey = GetScriptForWitness(scriptPubKey);
}
if (bScriptHash) {
if (scriptPubKey.size() > MAX_SCRIPT_ELEMENT_SIZE) {
throw std::runtime_error(strprintf(
"redeemScript exceeds size limit: %d > %d", scriptPubKey.size(), MAX_SCRIPT_ELEMENT_SIZE));
}
// Get the address for the redeem script, then call
// GetScriptForDestination() to construct a P2SH scriptPubKey.
CBitcoinAddress addr(scriptPubKey);
scriptPubKey = GetScriptForDestination(addr.Get());
}
// construct TxOut, append to transaction output list
CTxOut txout(value, scriptPubKey);
tx.vout.push_back(txout);
}
static void MutateTxAddOutData(CMutableTransaction& tx, const std::string& strInput)
{
CAmount value = 0;
// separate [VALUE:]DATA in string
size_t pos = strInput.find(':');
if (pos==0)
throw std::runtime_error("TX output value not specified");
if (pos != std::string::npos) {
// Extract and validate VALUE
value = ExtractAndValidateValue(strInput.substr(0, pos));
}
// extract and validate DATA
std::string strData = strInput.substr(pos + 1, std::string::npos);
if (!IsHex(strData))
throw std::runtime_error("invalid TX output data");
std::vector<unsigned char> data = ParseHex(strData);
CTxOut txout(value, CScript() << OP_RETURN << data);
tx.vout.push_back(txout);
}
static void MutateTxAddOutScript(CMutableTransaction& tx, const std::string& strInput)
{
// separate VALUE:SCRIPT[:FLAGS]
std::vector<std::string> vStrInputParts;
boost::split(vStrInputParts, strInput, boost::is_any_of(":"));
if (vStrInputParts.size() < 2)
throw std::runtime_error("TX output missing separator");
// Extract and validate VALUE
CAmount value = ExtractAndValidateValue(vStrInputParts[0]);
// extract and validate script
std::string strScript = vStrInputParts[1];
CScript scriptPubKey = ParseScript(strScript);
// Extract FLAGS
bool bSegWit = false;
bool bScriptHash = false;
if (vStrInputParts.size() == 3) {
std::string flags = vStrInputParts.back();
bSegWit = (flags.find("W") != std::string::npos);
bScriptHash = (flags.find("S") != std::string::npos);
}
if (scriptPubKey.size() > MAX_SCRIPT_SIZE) {
throw std::runtime_error(strprintf(
"script exceeds size limit: %d > %d", scriptPubKey.size(), MAX_SCRIPT_SIZE));
}
if (bSegWit) {
scriptPubKey = GetScriptForWitness(scriptPubKey);
}
if (bScriptHash) {
if (scriptPubKey.size() > MAX_SCRIPT_ELEMENT_SIZE) {
throw std::runtime_error(strprintf(
"redeemScript exceeds size limit: %d > %d", scriptPubKey.size(), MAX_SCRIPT_ELEMENT_SIZE));
}
CBitcoinAddress addr(scriptPubKey);
scriptPubKey = GetScriptForDestination(addr.Get());
}
// construct TxOut, append to transaction output list
CTxOut txout(value, scriptPubKey);
tx.vout.push_back(txout);
}
static void MutateTxDelInput(CMutableTransaction& tx, const std::string& strInIdx)
{
// parse requested deletion index
int inIdx = atoi(strInIdx);
if (inIdx < 0 || inIdx >= (int)tx.vin.size()) {
std::string strErr = "Invalid TX input index '" + strInIdx + "'";
throw std::runtime_error(strErr.c_str());
}
// delete input from transaction
tx.vin.erase(tx.vin.begin() + inIdx);
}
static void MutateTxDelOutput(CMutableTransaction& tx, const std::string& strOutIdx)
{
// parse requested deletion index
int outIdx = atoi(strOutIdx);
if (outIdx < 0 || outIdx >= (int)tx.vout.size()) {
std::string strErr = "Invalid TX output index '" + strOutIdx + "'";
throw std::runtime_error(strErr.c_str());
}
// delete output from transaction
tx.vout.erase(tx.vout.begin() + outIdx);
}
static const unsigned int N_SIGHASH_OPTS = 6;
static const struct {
const char *flagStr;
int flags;
} sighashOptions[N_SIGHASH_OPTS] = {
{"ALL", SIGHASH_ALL},
{"NONE", SIGHASH_NONE},
{"SINGLE", SIGHASH_SINGLE},
{"ALL|ANYONECANPAY", SIGHASH_ALL|SIGHASH_ANYONECANPAY},
{"NONE|ANYONECANPAY", SIGHASH_NONE|SIGHASH_ANYONECANPAY},
{"SINGLE|ANYONECANPAY", SIGHASH_SINGLE|SIGHASH_ANYONECANPAY},
};
static bool findSighashFlags(int& flags, const std::string& flagStr)
{
flags = 0;
for (unsigned int i = 0; i < N_SIGHASH_OPTS; i++) {
if (flagStr == sighashOptions[i].flagStr) {
flags = sighashOptions[i].flags;
return true;
}
}
return false;
}
static CAmount AmountFromValue(const UniValue& value)
{
if (!value.isNum() && !value.isStr())
throw std::runtime_error("Amount is not a number or string");
CAmount amount;
if (!ParseFixedPoint(value.getValStr(), 8, &amount))
throw std::runtime_error("Invalid amount");
if (!MoneyRange(amount))
throw std::runtime_error("Amount out of range");
return amount;
}
static void MutateTxSign(CMutableTransaction& tx, const std::string& flagStr)
{
int nHashType = SIGHASH_ALL;
if (flagStr.size() > 0)
if (!findSighashFlags(nHashType, flagStr))
throw std::runtime_error("unknown sighash flag/sign option");
std::vector<CTransaction> txVariants;
txVariants.push_back(tx);
// mergedTx will end up with all the signatures; it
// starts as a clone of the raw tx:
CMutableTransaction mergedTx(txVariants[0]);
bool fComplete = true;
CCoinsView viewDummy;
CCoinsViewCache view(&viewDummy);
if (!registers.count("privatekeys"))
throw std::runtime_error("privatekeys register variable must be set.");
CBasicKeyStore tempKeystore;
UniValue keysObj = registers["privatekeys"];
for (unsigned int kidx = 0; kidx < keysObj.size(); kidx++) {
if (!keysObj[kidx].isStr())
throw std::runtime_error("privatekey not a std::string");
CBitcoinSecret vchSecret;
bool fGood = vchSecret.SetString(keysObj[kidx].getValStr());
if (!fGood)
throw std::runtime_error("privatekey not valid");
CKey key = vchSecret.GetKey();
tempKeystore.AddKey(key);
}
// Add previous txouts given in the RPC call:
if (!registers.count("prevtxs"))
throw std::runtime_error("prevtxs register variable must be set.");
UniValue prevtxsObj = registers["prevtxs"];
{
for (unsigned int previdx = 0; previdx < prevtxsObj.size(); previdx++) {
UniValue prevOut = prevtxsObj[previdx];
if (!prevOut.isObject())
throw std::runtime_error("expected prevtxs internal object");
std::map<std::string, UniValue::VType> types = {
{"txid", UniValue::VSTR},
{"vout", UniValue::VNUM},
{"scriptPubKey", UniValue::VSTR},
};
if (!prevOut.checkObject(types))
throw std::runtime_error("prevtxs internal object typecheck fail");
uint256 txid = ParseHashUV(prevOut["txid"], "txid");
int nOut = atoi(prevOut["vout"].getValStr());
if (nOut < 0)
throw std::runtime_error("vout must be positive");
COutPoint out(txid, nOut);
std::vector<unsigned char> pkData(ParseHexUV(prevOut["scriptPubKey"], "scriptPubKey"));
CScript scriptPubKey(pkData.begin(), pkData.end());
{
const Coin& coin = view.AccessCoin(out);
if (!coin.IsSpent() && coin.out.scriptPubKey != scriptPubKey) {
std::string err("Previous output scriptPubKey mismatch:\n");
err = err + ScriptToAsmStr(coin.out.scriptPubKey) + "\nvs:\n"+
ScriptToAsmStr(scriptPubKey);
throw std::runtime_error(err);
}
Coin newcoin;
newcoin.out.scriptPubKey = scriptPubKey;
newcoin.out.nValue = 0;
if (prevOut.exists("amount")) {
newcoin.out.nValue = AmountFromValue(prevOut["amount"]);
}
newcoin.nHeight = 1;
view.AddCoin(out, std::move(newcoin), true);
}
// if redeemScript given and private keys given,
// add redeemScript to the tempKeystore so it can be signed:
if ((scriptPubKey.IsPayToScriptHash() || scriptPubKey.IsPayToWitnessScriptHash()) &&
prevOut.exists("redeemScript")) {
UniValue v = prevOut["redeemScript"];
std::vector<unsigned char> rsData(ParseHexUV(v, "redeemScript"));
CScript redeemScript(rsData.begin(), rsData.end());
tempKeystore.AddCScript(redeemScript);
}
}
}
const CKeyStore& keystore = tempKeystore;
bool fHashSingle = ((nHashType & ~SIGHASH_ANYONECANPAY) == SIGHASH_SINGLE);
// Sign what we can:
for (unsigned int i = 0; i < mergedTx.vin.size(); i++) {
CTxIn& txin = mergedTx.vin[i];
const Coin& coin = view.AccessCoin(txin.prevout);
if (coin.IsSpent()) {
fComplete = false;
continue;
}
const CScript& prevPubKey = coin.out.scriptPubKey;
const CAmount& amount = coin.out.nValue;
SignatureData sigdata;
// Only sign SIGHASH_SINGLE if there's a corresponding output:
if (!fHashSingle || (i < mergedTx.vout.size()))
ProduceSignature(MutableTransactionSignatureCreator(&keystore, &mergedTx, i, amount, nHashType), prevPubKey, sigdata);
// ... and merge in other signatures:
for (const CTransaction& txv : txVariants)
sigdata = CombineSignatures(prevPubKey, MutableTransactionSignatureChecker(&mergedTx, i, amount), sigdata, DataFromTransaction(txv, i));
UpdateTransaction(mergedTx, i, sigdata);
if (!VerifyScript(txin.scriptSig, prevPubKey, &txin.scriptWitness, STANDARD_SCRIPT_VERIFY_FLAGS, MutableTransactionSignatureChecker(&mergedTx, i, amount)))
fComplete = false;
}
if (fComplete) {
// do nothing... for now
// perhaps store this for later optional JSON output
}
tx = mergedTx;
}
class Secp256k1Init
{
ECCVerifyHandle globalVerifyHandle;
public:
Secp256k1Init() {
ECC_Start();
}
~Secp256k1Init() {
ECC_Stop();
}
};
static void MutateTx(CMutableTransaction& tx, const std::string& command,
const std::string& commandVal)
{
std::unique_ptr<Secp256k1Init> ecc;
if (command == "nversion")
MutateTxVersion(tx, commandVal);
else if (command == "locktime")
MutateTxLocktime(tx, commandVal);
else if (command == "replaceable") {
MutateTxRBFOptIn(tx, commandVal);
}
else if (command == "delin")
MutateTxDelInput(tx, commandVal);
else if (command == "in")
MutateTxAddInput(tx, commandVal);
else if (command == "delout")
MutateTxDelOutput(tx, commandVal);
else if (command == "outaddr")
MutateTxAddOutAddr(tx, commandVal);
else if (command == "outpubkey") {
if (!ecc) { ecc.reset(new Secp256k1Init()); }
MutateTxAddOutPubKey(tx, commandVal);
} else if (command == "outmultisig") {
if (!ecc) { ecc.reset(new Secp256k1Init()); }
MutateTxAddOutMultiSig(tx, commandVal);
} else if (command == "outscript")
MutateTxAddOutScript(tx, commandVal);
else if (command == "outdata")
MutateTxAddOutData(tx, commandVal);
else if (command == "sign") {
if (!ecc) { ecc.reset(new Secp256k1Init()); }
MutateTxSign(tx, commandVal);
}
else if (command == "load")
RegisterLoad(commandVal);
else if (command == "set")
RegisterSet(commandVal);
else
throw std::runtime_error("unknown command");
}
static void OutputTxJSON(const CTransaction& tx)
{
UniValue entry(UniValue::VOBJ);
TxToUniv(tx, uint256(), entry);
std::string jsonOutput = entry.write(4);
fprintf(stdout, "%s\n", jsonOutput.c_str());
}
static void OutputTxHash(const CTransaction& tx)
{
std::string strHexHash = tx.GetHash().GetHex(); // the hex-encoded transaction hash (aka the transaction id)
fprintf(stdout, "%s\n", strHexHash.c_str());
}
static void OutputTxHex(const CTransaction& tx)
{
std::string strHex = EncodeHexTx(tx);
fprintf(stdout, "%s\n", strHex.c_str());
}
static void OutputTx(const CTransaction& tx)
{
if (gArgs.GetBoolArg("-json", false))
OutputTxJSON(tx);
else if (gArgs.GetBoolArg("-txid", false))
OutputTxHash(tx);
else
OutputTxHex(tx);
}
static std::string readStdin()
{
char buf[4096];
std::string ret;
while (!feof(stdin)) {
size_t bread = fread(buf, 1, sizeof(buf), stdin);
ret.append(buf, bread);
if (bread < sizeof(buf))
break;
}
if (ferror(stdin))
throw std::runtime_error("error reading stdin");
boost::algorithm::trim_right(ret);
return ret;
}
static int CommandLineRawTx(int argc, char* argv[])
{
std::string strPrint;
int nRet = 0;
try {
// Skip switches; Permit common stdin convention "-"
while (argc > 1 && IsSwitchChar(argv[1][0]) &&
(argv[1][1] != 0)) {
argc--;
argv++;
}
CMutableTransaction tx;
int startArg;
if (!fCreateBlank) {
// require at least one param
if (argc < 2)
throw std::runtime_error("too few parameters");
// param: hex-encoded bitcoin transaction
std::string strHexTx(argv[1]);
if (strHexTx == "-") // "-" implies standard input
strHexTx = readStdin();
if (!DecodeHexTx(tx, strHexTx, true))
throw std::runtime_error("invalid transaction encoding");
startArg = 2;
} else
startArg = 1;
for (int i = startArg; i < argc; i++) {
std::string arg = argv[i];
std::string key, value;
size_t eqpos = arg.find('=');
if (eqpos == std::string::npos)
key = arg;
else {
key = arg.substr(0, eqpos);
value = arg.substr(eqpos + 1);
}
MutateTx(tx, key, value);
}
OutputTx(tx);
}
catch (const boost::thread_interrupted&) {
throw;
}
catch (const std::exception& e) {
strPrint = std::string("error: ") + e.what();
nRet = EXIT_FAILURE;
}
catch (...) {
PrintExceptionContinue(nullptr, "CommandLineRawTx()");
throw;
}
if (strPrint != "") {
fprintf((nRet == 0 ? stdout : stderr), "%s\n", strPrint.c_str());
}
return nRet;
}
int main(int argc, char* argv[])
{
SetupEnvironment();
try {
int ret = AppInitRawTx(argc, argv);
if (ret != CONTINUE_EXECUTION)
return ret;
}
catch (const std::exception& e) {
PrintExceptionContinue(&e, "AppInitRawTx()");
return EXIT_FAILURE;
} catch (...) {
PrintExceptionContinue(nullptr, "AppInitRawTx()");
return EXIT_FAILURE;
}
int ret = EXIT_FAILURE;
try {
ret = CommandLineRawTx(argc, argv);
}
catch (const std::exception& e) {
PrintExceptionContinue(&e, "CommandLineRawTx()");
} catch (...) {
PrintExceptionContinue(nullptr, "CommandLineRawTx()");
}
return ret;
}
| berycoin-project/berycoin | src/bitcoin-tx.cpp | C++ | gpl-3.0 | 30,448 | [
30522,
1013,
1013,
9385,
1006,
1039,
1007,
2268,
1011,
2355,
1996,
2978,
3597,
2378,
4563,
9797,
1013,
1013,
5500,
2104,
1996,
10210,
4007,
6105,
1010,
2156,
1996,
10860,
1013,
1013,
5371,
24731,
2030,
8299,
1024,
1013,
1013,
7479,
1012,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
/*
* Copyright (C) 2005-2016 Junjiro R. Okajima
*
* This program, aufs is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/*
* support for loopback block device as a branch
*/
#include "aufs.h"
/* added into drivers/block/loop.c */
static struct file *(*backing_file_func)(struct super_block *sb);
/*
* test if two lower dentries have overlapping branches.
*/
int au_test_loopback_overlap(struct super_block *sb, struct dentry *h_adding)
{
struct super_block *h_sb;
struct file *backing_file;
if (unlikely(!backing_file_func)) {
/* don't load "loop" module here */
backing_file_func = symbol_get(loop_backing_file);
if (unlikely(!backing_file_func))
/* "loop" module is not loaded */
return 0;
}
h_sb = h_adding->d_sb;
backing_file = backing_file_func(h_sb);
if (!backing_file)
return 0;
h_adding = backing_file->f_path.dentry;
/*
* h_adding can be local NFS.
* in this case aufs cannot detect the loop.
*/
if (unlikely(h_adding->d_sb == sb))
return 1;
return !!au_test_subdir(h_adding, sb->s_root);
}
/* true if a kernel thread named 'loop[0-9].*' accesses a file */
int au_test_loopback_kthread(void)
{
int ret;
struct task_struct *tsk = current;
char c, comm[sizeof(tsk->comm)];
ret = 0;
if (tsk->flags & PF_KTHREAD) {
get_task_comm(comm, tsk);
c = comm[4];
ret = ('0' <= c && c <= '9'
&& !strncmp(comm, "loop", 4));
}
return ret;
}
/* ---------------------------------------------------------------------- */
#define au_warn_loopback_step 16
static int au_warn_loopback_nelem = au_warn_loopback_step;
static unsigned long *au_warn_loopback_array;
void au_warn_loopback(struct super_block *h_sb)
{
int i, new_nelem;
unsigned long *a, magic;
static DEFINE_SPINLOCK(spin);
magic = h_sb->s_magic;
spin_lock(&spin);
a = au_warn_loopback_array;
for (i = 0; i < au_warn_loopback_nelem && *a; i++)
if (a[i] == magic) {
spin_unlock(&spin);
return;
}
/* h_sb is new to us, print it */
if (i < au_warn_loopback_nelem) {
a[i] = magic;
goto pr;
}
/* expand the array */
new_nelem = au_warn_loopback_nelem + au_warn_loopback_step;
a = au_kzrealloc(au_warn_loopback_array,
au_warn_loopback_nelem * sizeof(unsigned long),
new_nelem * sizeof(unsigned long), GFP_ATOMIC,
/*may_shrink*/0);
if (a) {
au_warn_loopback_nelem = new_nelem;
au_warn_loopback_array = a;
a[i] = magic;
goto pr;
}
spin_unlock(&spin);
AuWarn1("realloc failed, ignored\n");
return;
pr:
spin_unlock(&spin);
pr_warn("you may want to try another patch for loopback file "
"on %s(0x%lx) branch\n", au_sbtype(h_sb), magic);
}
int au_loopback_init(void)
{
int err;
struct super_block *sb __maybe_unused;
BUILD_BUG_ON(sizeof(sb->s_magic) != sizeof(unsigned long));
err = 0;
au_warn_loopback_array = kcalloc(au_warn_loopback_step,
sizeof(unsigned long), GFP_NOFS);
if (unlikely(!au_warn_loopback_array))
err = -ENOMEM;
return err;
}
void au_loopback_fin(void)
{
if (backing_file_func)
symbol_put(loop_backing_file);
au_delayed_kfree(au_warn_loopback_array);
}
/* ---------------------------------------------------------------------- */
/* support the loopback block device insude aufs */
struct file *aufs_real_loop(struct file *file)
{
struct file *f;
BUG_ON(!au_test_aufs(file->f_path.dentry->d_sb));
fi_read_lock(file);
f = au_hf_top(file);
fi_read_unlock(file);
AuDebugOn(!f);
return f;
}
| linuxium/ubuntu-yakkety | fs/aufs/loop.c | C | gpl-2.0 | 3,997 | [
30522,
1013,
1008,
1008,
9385,
1006,
1039,
1007,
2384,
1011,
2355,
12022,
4478,
3217,
1054,
1012,
7929,
13006,
9581,
1008,
1008,
2023,
2565,
1010,
21200,
2015,
2003,
2489,
4007,
1025,
2017,
2064,
2417,
2923,
3089,
8569,
2618,
2009,
1998,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
<?php
/**
* Funciones de la vista.
*
* @package Roraima
* @subpackage vistas
* @author $Author$ <desarrollo@cidesa.com.ve>
* @version SVN: $Id$
*/
// date: 2007/11/20 16:31:56
?>
<td><?php echo link_to($npdiaext->getCodnom() ? $npdiaext->getCodnom() : __('-'), 'nomdiaextlablot/edit?id='.$npdiaext->getId().'&codnom='.$npdiaext->getCodnom().'&fecha='.$npdiaext->getFecha()) ?></td>
<td><?php echo $npdiaext->getNomnom() ?></td>
<td><?php echo ($npdiaext->getFecha() !== null && $npdiaext->getFecha() !== '') ? format_date($npdiaext->getFecha(), "dd/MM/yy") : '' ?></td>
| cidesa/roraima | apps/nomina/modules/nomdiaextlablot/templates/_list_td_tabular.php | PHP | gpl-2.0 | 601 | [
30522,
1026,
1029,
25718,
1013,
1008,
1008,
1008,
4569,
10446,
2229,
2139,
2474,
13005,
1012,
1008,
1008,
1030,
7427,
20996,
14995,
2863,
1008,
1030,
4942,
23947,
4270,
13005,
2015,
1008,
1030,
3166,
1002,
3166,
1002,
1026,
4078,
2906,
2840... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
@charset "utf-8";
.Wdate{
border:#999 1px solid;
height:20px;
background:#fff url(datePicker.png) no-repeat 166px;
}
.WdateFmtErr{
font-weight:bold;
color:red;
} | wancy86/learn_TP | Public/js/My97DatePicker/skin/WdatePicker.css | CSS | mit | 167 | [
30522,
1030,
25869,
13462,
1000,
21183,
2546,
1011,
1022,
1000,
1025,
1012,
1059,
13701,
1063,
3675,
1024,
1001,
25897,
1015,
2361,
2595,
5024,
1025,
4578,
1024,
2322,
2361,
2595,
1025,
4281,
1024,
1001,
21461,
2546,
24471,
2140,
1006,
3058... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
/* Unterroutinen frs Suchen */
#define UCE_SUCHEN2 1
#include <stdio.h>
#include <macros.h>
#include <gemfast.h>
#include <window.h>
#include <uceinc.h>
#define GROSS_KLEIN 1
/* globale Variablen */
static char *text; /* Suchtext */
static WORD laenge; /* Lnge des Suchtextes */
static WORD suche_gk( zeile)
/* Suchen mit Beachtung der Gro/Kleinschreibung */
register char *zeile;
{
register char *pos, *ende;
register char zeichen;
register WORD i = 0, j;
pos = zeile;
ende = pos+toword( pos[-4])-laenge;
zeichen = *text;
while (ende > pos)
{
if (*pos == zeichen) /* erstes Zeichen stimmt berein */
{
/* restliche Zeichen untersuchen */
for ( j=1; j<laenge; j++)
if (pos[j] != text[j])
break; /* nicht identisch */
if (j == laenge) /* gefunden */
return i;
}
pos++;
i++;
}
return -1;
}
static WORD suche( zeile)
/* Suchen ohne Beachtung der Gro/Kleinschreibung */
register char *zeile;
{
register char *pos, *ende;
register char zeichen;
register WORD i = 0, j;
pos = zeile;
ende = pos+toword( pos[-4])-laenge;
zeichen = tolower( *text);
while (ende > pos)
{
if (tolower( *pos) == zeichen) /* erstes Zeichen stimmt berein */
{
/* restliche Zeichen untersuchen */
for ( j=1; j<laenge; j++)
if (tolower( pos[j]) != tolower( text[j]))
break; /* nicht identisch */
if (j == laenge) /* gefunden */
return i;
}
pos++;
i++;
}
return -1;
}
/* ----- nach auen sichtbare Funktionen ------ */
void suche_text( qt, suchtext, e_zeile, l_zeile, e_spalte, l_spalte,
zeile, spalte, modus)
register QUELLTEXT *qt;
register char *suchtext;
register LONG e_zeile, l_zeile;
register WORD e_spalte, l_spalte;
register LONG *zeile;
register WORD *spalte;
register WORD modus;
{
register char **zeilen;
register LONG i;
text = suchtext;
laenge = strlen( suchtext);
zeilen = &qt->zeile[e_zeile];
i = e_zeile;
if (modus & GROSS_KLEIN)
if (e_zeile >= l_zeile) /* abwrts suchen */
do
*spalte = suche_gk( *zeilen++);
while (i++<l_zeile && *spalte==-1);
else /* aufwrts suchen */
do
*spalte = suche_gk( *zeilen--);
while (i-->l_zeile && *spalte==-1);
else
if (e_zeile >= l_zeile) /* abwrts suchen */
do
*spalte = suche( *zeilen++);
while (i++<l_zeile && *spalte==-1);
else /* aufwrts suchen */
do
*spalte = suche( *zeilen--);
while (i-->l_zeile && *spalte==-1);
if (*spalte == -1)
*zeile = -1;
else
if (e_zeile <= l_zeile)
*zeile = i-1;
else
*zeile = i+1;
} | tensberg/atarist | atarist/UCE/MODULE/U_SUCHE2.C | C++ | mit | 2,917 | [
30522,
1013,
1008,
4895,
3334,
22494,
10196,
2078,
25188,
2107,
2368,
1008,
1013,
1001,
9375,
15384,
2063,
30524,
1028,
1001,
2421,
1026,
15384,
12377,
2278,
1012,
1044,
1028,
1001,
9375,
7977,
1035,
12555,
1015,
1013,
1008,
3795,
2063,
802... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
/*
* Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* @test
* @bug 7021614
* @summary extend sbql4j8.com.sun.source API to support parsing javadoc comments
* @build DocCommentTester
* @run main DocCommentTester LiteralTest.java
*/
class LiteralTest {
/** {@literal if (a < b) { }} */
void minimal() { }
/*
DocComment[DOC_COMMENT, pos:0
firstSentence: 1
Literal[LITERAL, pos:0, if_(a_<_b)_{_}]
body: empty
block tags: empty
]
*/
/** [{@literal if (a < b) { }}] */
void in_brackets() { }
/*
DocComment[DOC_COMMENT, pos:0
firstSentence: 3
Text[TEXT, pos:0, []
Literal[LITERAL, pos:1, if_(a_<_b)_{_}]
Text[TEXT, pos:26, ]]
body: empty
block tags: empty
]
*/
/** [ {@literal if (a < b) { }} ] */
void in_brackets_with_whitespace() { }
/*
DocComment[DOC_COMMENT, pos:0
firstSentence: 3
Text[TEXT, pos:0, [_]
Literal[LITERAL, pos:2, if_(a_<_b)_{_}]
Text[TEXT, pos:27, _]]
body: empty
block tags: empty
]
*/
/**
* {@literal {@literal nested} }
*/
void nested() { }
/*
DocComment[DOC_COMMENT, pos:1
firstSentence: 1
Literal[LITERAL, pos:1, {@literal_nested}_]
body: empty
block tags: empty
]
*/
/**
* {@literal if (a < b) {
* }
* }
*/
void embedded_newline() { }
/*
DocComment[DOC_COMMENT, pos:1
firstSentence: 1
Literal[LITERAL, pos:1, if_(a_<_b)_{|________}|_]
body: empty
block tags: empty
]
*/
/** {@literal if (a < b) { } */
void unterminated_1() { }
/*
DocComment[DOC_COMMENT, pos:0
firstSentence: 1
Erroneous[ERRONEOUS, pos:0
code: compiler.err.dc.unterminated.inline.tag
body: {@literal_if_(a_<_b)_{_}
]
body: empty
block tags: empty
]
*/
/**
* {@literal if (a < b) { }
* @author jjg */
void unterminated_2() { }
/*
DocComment[DOC_COMMENT, pos:1
firstSentence: 1
Erroneous[ERRONEOUS, pos:1
code: compiler.err.dc.unterminated.inline.tag
body: {@literal_if_(a_<_b)_{_}
]
body: empty
block tags: 1
Author[AUTHOR, pos:27
name: 1
Text[TEXT, pos:35, jjg]
]
]
*/
}
| emil-wcislo/sbql4j8 | sbql4j8/src/test/openjdk/tools/javac/doctree/LiteralTest.java | Java | apache-2.0 | 3,119 | [
30522,
1013,
1008,
1008,
9385,
1006,
1039,
1007,
2262,
1010,
14721,
1998,
1013,
2030,
2049,
18460,
1012,
2035,
2916,
9235,
1012,
1008,
2079,
2025,
11477,
2030,
6366,
9385,
14444,
2030,
2023,
5371,
20346,
1012,
1008,
1008,
2023,
3642,
2003,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
{% extends "projects/base_project.html" %}
{% load core_tags i18n highlight %}
{% block title %}{% blocktrans with query=query|default:"" %}Search: {{ query }} {% endblocktrans %}{% endblock %}
{% block extra_links %}
{{ super }}
<style>
.navigable > ul > li { border-bottom: 0; }
</style>
{% endblock %}
{% block content %}
<div class="navigable">
<ul>
<li class="{% if type == 'project' %}active{% endif %}"><a href="?{% url_replace request 'type' 'project' %}">Projects</a></li>
<li class="{% if type == 'file' %}active{% endif %}"><a href="?{% url_replace request 'type' 'file' %}">Files</a></li>
<hr>
{% if type == 'project' %}
{% if facets.language %}
<h5> Language </h5>
{% for name, count in facets.language.items %}
<li class="{% if language == name %}active{% endif %}">
{% if language == name %}
<a href="?{% url_replace request 'language' '' %}">{{ name }}
{% else %}
<a href="?{% url_replace request 'language' name %}">{{ name }}
{% endif %}
({{ count }})
</a>
</li>
{% endfor %}
{% endif %}
{% endif %}
{% if type == 'file' %}
{% if facets.project %}
<h5> Projects </h5>
{% for name, count in facets.project.items %}
<li class="{% if project == name %}active{% endif %}">
{% if project == name %}
<a href="?{% url_replace request 'project' '' %}">{{ name }}
{% else %}
<a href="?{% url_replace request 'project' name %}">{{ name }}
{% endif %}
({{ count }})
</a>
</li>
{% endfor %}
{% endif %}
{% if facets.version %}
<h5>Version</h5>
{% for name, count in facets.version.items %}
<li class="{% if version == name %}active{% endif %}">
{% if version == name %}
<a href="?{% url_replace request 'version' '' %}">{{ name }}
{% else %}
<a href="?{% url_replace request 'version' name %}">{{ name }}
{% endif %}
({{ count }})
</a>
</li>
{% endfor %}
{% endif %}
{% if facets.taxonomy %}
<h5>Taxonomy</h5>
{% for name, count in facets.taxonomy.items %}
<li class="{% if taxonomy == name %}active{% endif %}">
{% if taxonomy == name %}
<a href="?{% url_replace request 'taxonomy' '' %}">{{ name }}
{% else %}
<a href="?{% url_replace request 'taxonomy' name %}">{{ name }}
{% endif %}
({{ count }})
</a>
</li>
{% endfor %}
{% endif %}
{% endif %}
<div class="search-sponsored">
Search is sponsored by <a href="https://www.elastic.co/">Elastic</a>, and hosted at <a href="http://found.no/">Found</a>.
</div>
</ul>
<div>
<h2>Search</h2>
<!-- BEGIN search form -->
<div class="wide-search-bar">
<div class="wide-search-bar-wrapper clearfix">
<form action="." method="GET">
<div class="text-input-wrapper">
<input type="text" name="q" value="{{ query|default_if_none:"" }}" id="id_elastic_project_search">
{% if type %} <input type="hidden" name="type" value="{{ type }}"> {% endif %}
{% if project %} <input type="hidden" name="project" value="{{ project }}"> {% endif %}
{% if taxonomy %} <input type="hidden" name="taxonomy" value="{{ taxonomy }}"> {% endif %}
{% if version %} <input type="hidden" name="version" value="{{ version }}"> {% endif %}
{% if language %} <input type="hidden" name="language" value="{{ language }}"> {% endif %}
</div>
<div class="submit-input-wrapper">
{% comment %}Translators: This is about starting a search{% endcomment %}
<input type="submit" value="{% trans "Go crazy." %}">
</div>
</form>
</div>
</div>
<!-- END search form -->
{% if query %}
<!-- BEGIN search results -->
<div class="module">
<div class="module-wrapper">
<div class="module-header">
<h3>{% blocktrans with query=query|default:"" %}Results for {{ query }}{% endblocktrans %}</h3>
</div>
<div class="module-list">
<div class="module-list-wrapper">
<ul>
{% for result in results.hits.hits %}
<li class="module-item">
<p class="module-item-title">
{% if result.fields.name %}
{# Project #}
<a href="{{ result.fields.url }}">{{ result.fields.name }}</a>
{% for fragment in result.highlight.description|slice:":3" %}
<p>
...{{ fragment|safe }}...
</p>
<br>
{% endfor %}
{# End Project #}
{% elif result.fields.path %}
{# File #}
<a href="{% doc_url result.fields.project|get_project result.fields.version result.fields.path %}?highlight={{ query }}">{{ result.fields.project }} - {{ result.fields.title|safe }}</a>
{% for fragment in result.highlight.content|slice:":3" %}
<p>
...{{ fragment|safe }}...
</p>
{% endfor %}
{# End File #}
{% endif %}
</p>
</li>
{% empty %}
<li class="module-item"><span class="quiet">{% trans "No results found. Bummer." %}</span></li>
{% endfor %}
</ul>
</div>
</div>
</div>
</div>
<!-- END search results -->
{% if page.has_previous or page.has_next %}
<!-- BEGIN search pagination -->
<div class="pagination">
{% if page.has_previous %}
<a href="?q={{ query }}&page={{ page.previous_page_number }}">« {% trans "Previous" %}</a>
{% else %}
<span class="disabled">« {% trans "Previous" %}</span>
{% endif %}
{% if page.has_next %}
<a class="next" href="?q={{ query }}&page={{ page.next_page_number }}">{% trans "Next" %} »</a>
{% else %}
<span class="next disabled">{% trans "Next" %} »</span>
{% endif %}
</div>
<!-- END search pagination -->
{% endif %}
{% else %}
{# Show some example queries to run, maybe query syntax, something else? #}
{% endif %}
</div>
</div>
{% endblock %}
| sid-kap/readthedocs.org | readthedocs/templates/search/elastic_search.html | HTML | mit | 7,277 | [
30522,
1063,
1003,
8908,
1000,
3934,
1013,
2918,
1035,
2622,
1012,
16129,
1000,
1003,
1065,
1063,
1003,
7170,
4563,
1035,
22073,
1045,
15136,
2078,
12944,
1003,
1065,
1063,
1003,
3796,
2516,
1003,
1065,
1063,
1003,
3796,
6494,
3619,
2007,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
//currently commented out as TokenTester is causing a OOG error due to the Factory being too big
//Not fully needed as factory & separate tests cover token creation.
/*contract("TokenTester", function(accounts) {
it("creates 10000 initial tokens", function(done) {
var tester = TokenTester.at(TokenTester.deployed_address);
tester.tokenContractAddress.call()
.then(function(tokenContractAddr) {
var tokenContract = HumanStandardToken.at(tokenContractAddr);
return tokenContract.balanceOf.call(TokenTester.deployed_address);
}).then(function (result) {
assert.strictEqual(result.toNumber(), 10000); // 10000 as specified in TokenTester.sol
done();
}).catch(done);
});
//todo:add test on retrieving addresses
});*/
| PlutusIt/PlutusDEX | test/tokenTester.js | JavaScript | mit | 816 | [
30522,
1013,
1013,
2747,
7034,
2041,
2004,
19204,
22199,
2121,
2003,
4786,
1037,
1051,
8649,
7561,
2349,
2000,
1996,
4713,
2108,
2205,
2502,
1013,
1013,
2025,
3929,
2734,
2004,
4713,
1004,
3584,
5852,
3104,
19204,
4325,
1012,
1013,
1008,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
# JsonUtility Class
Utility class that supports the serialization from Json to type and vice versa
**Namespace:** [OfficeDevPnP.Core.Utilities](OfficeDevPnP.Core.Utilities.md)
**Assembly:** OfficeDevPnP.Core.dll
## Inheritance Hierarchy
System.Object
## Syntax
```C#
public static class JsonUtility
```
## Methods
|**Name**|**Description**|
|:-----|:-----|
| [Deserialize<T>(String)](OfficeDevPnP.Core.Utilities.JsonUtility.682d7045.md) | Deserializes a json string to an object of type T
| [Serialize<T>(T)](OfficeDevPnP.Core.Utilities.JsonUtility.ed203be7.md) | Serializes an object of type T to a json string
## See also
- [OfficeDevPnP.Core.Utilities](OfficeDevPnP.Core.Utilities.md)
| PaoloPia/PnP-Guidance | sitescore/OfficeDevPnP.Core.Utilities.JsonUtility.md | Markdown | mit | 711 | [
30522,
1001,
1046,
3385,
21823,
18605,
2465,
9710,
2465,
2008,
6753,
1996,
7642,
3989,
2013,
1046,
3385,
2000,
2828,
1998,
3580,
18601,
1008,
1008,
3415,
15327,
1024,
1008,
1008,
1031,
2436,
24844,
2361,
16275,
1012,
4563,
1012,
16548,
1033... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
/*
* Definitions for akm8975 compass chip.
*/
#ifndef AKM8975_H
#define AKM8975_H
#include <linux/ioctl.h>
#define AKM8975_I2C_NAME "akm8975"
/*! \name AK8975 operation mode
\anchor AK8975_Mode
Defines an operation mode of the AK8975.*/
/*! @{*/
#define AK8975_MODE_SNG_MEASURE 0x01
#define AK8975_MODE_SELF_TEST 0x08
#define AK8975_MODE_FUSE_ACCESS 0x0F
#define AK8975_MODE_POWERDOWN 0x00
/*! @}*/
#define SENSOR_DATA_SIZE 8
#define RWBUF_SIZE 16
/*! \name AK8975 register address
\anchor AK8975_REG
Defines a register address of the AK8975.*/
/*! @{*/
#define AK8975_REG_WIA 0x00
#define AK8975_REG_INFO 0x01
#define AK8975_REG_ST1 0x02
#define AK8975_REG_HXL 0x03
#define AK8975_REG_HXH 0x04
#define AK8975_REG_HYL 0x05
#define AK8975_REG_HYH 0x06
#define AK8975_REG_HZL 0x07
#define AK8975_REG_HZH 0x08
#define AK8975_REG_ST2 0x09
#define AK8975_REG_CNTL 0x0A
#define AK8975_REG_RSV 0x0B
#define AK8975_REG_ASTC 0x0C
#define AK8975_REG_TS1 0x0D
#define AK8975_REG_TS2 0x0E
#define AK8975_REG_I2CDIS 0x0F
/*! @}*/
/*! \name AK8975 fuse-rom address
\anchor AK8975_FUSE
Defines a read-only address of the fuse ROM of the AK8975.*/
/*! @{*/
#define AK8975_FUSE_ASAX 0x10
#define AK8975_FUSE_ASAY 0x11
#define AK8975_FUSE_ASAZ 0x12
/*! @}*/
#define AKMIO 0xA1
/* IOCTLs for AKM library */
#define ECS_IOCTL_WRITE _IOW(AKMIO, 0x01, char*)
#define ECS_IOCTL_READ _IOWR(AKMIO, 0x02, char*)
#define ECS_IOCTL_RESET _IO(AKMIO, 0x03)
#define ECS_IOCTL_SET_MODE _IOW(AKMIO, 0x04, short)
#define ECS_IOCTL_GETDATA _IOR(AKMIO, 0x05, char[SENSOR_DATA_SIZE])
#define ECS_IOCTL_SET_YPR _IOW(AKMIO, 0x06, short[12])
#define ECS_IOCTL_GET_OPEN_STATUS _IOR(AKMIO, 0x07, int)
#define ECS_IOCTL_GET_CLOSE_STATUS _IOR(AKMIO, 0x08, int)
#define ECS_IOCTL_GET_DELAY _IOR(AKMIO, 0x30, short)
#define ECS_IOCTL_GET_PROJECT_NAME _IOR(AKMIO, 0x0D, char[64])
#define ECS_IOCTL_GET_MATRIX _IOR(AKMIO, 0x0E, short [4][3][3])
/* IOCTLs for APPs */
#define ECS_IOCTL_APP_SET_MODE _IOW(AKMIO, 0x10, short)/* NOT use */
#define ECS_IOCTL_APP_SET_MFLAG _IOW(AKMIO, 0x11, short)
#define ECS_IOCTL_APP_GET_MFLAG _IOW(AKMIO, 0x12, short)
#define ECS_IOCTL_APP_SET_AFLAG _IOW(AKMIO, 0x13, short)
#define ECS_IOCTL_APP_GET_AFLAG _IOR(AKMIO, 0x14, short)
#define ECS_IOCTL_APP_SET_TFLAG _IOR(AKMIO, 0x15, short)/* NOT use */
#define ECS_IOCTL_APP_GET_TFLAG _IOR(AKMIO, 0x16, short)/* NOT use */
#define ECS_IOCTL_APP_RESET_PEDOMETER _IO(AKMIO, 0x17) /* NOT use */
#define ECS_IOCTL_APP_SET_DELAY _IOW(AKMIO, 0x18, short)
#define ECS_IOCTL_APP_GET_DELAY ECS_IOCTL_GET_DELAY
#define ECS_IOCTL_APP_SET_MVFLAG _IOW(AKMIO, 0x19, short)
#define ECS_IOCTL_APP_GET_MVFLAG _IOR(AKMIO, 0x1A, short)
/* */
#define ECS_IOCTL_APP_SET_PFLAG _IOR(AKMIO, 0x1B, short) /* Get proximity flag */
#define ECS_IOCTL_APP_GET_PFLAG _IOR(AKMIO, 0x1C, short) /* Set proximity flag */
/* */
#define ECS_IOCTL_GET_ACCEL_PATH _IOR(AKMIO, 0x20, char[30])
#define ECS_IOCTL_ACCEL_INIT _IOR(AKMIO, 0x21, int[7])
#define ECS_IOCTL_GET_ALAYOUT_INIO _IOR(AKMIO, 0x22, signed short[18])
#define ECS_IOCTL_GET_HLAYOUT_INIO _IOR(AKMIO, 0x23, signed short[18])
#define AKMD2_TO_ACCEL_IOCTL_READ_XYZ _IOWR(AKMIO, 0x31, int)
#define AKMD2_TO_ACCEL_IOCTL_ACCEL_INIT _IOWR(AKMIO, 0x32, int)
/* original source
struct akm8975_platform_data {
char layouts[3][3];
char project_name[64];
int gpio_DRDY;
};
*/
#endif
| rcunningham12/L38C-Dynamic-Kernel | include/linux/akm8975.h | C | gpl-2.0 | 3,667 | [
30522,
1013,
1008,
1008,
15182,
2005,
17712,
2213,
2620,
2683,
23352,
16681,
9090,
1012,
1008,
1013,
1001,
2065,
13629,
2546,
17712,
2213,
2620,
2683,
23352,
1035,
1044,
1001,
9375,
17712,
2213,
2620,
2683,
23352,
1035,
1044,
1001,
2421,
10... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
/* Copyright (c) 2006 Patrick Fitzgerald */
/* Modified on 2009-02-04 by Jits, based on: http://groups.google.com/group/barelyfitz/browse_thread/thread/03e8b0672238391a */
function tabberObj(argsObj)
{ if ( window.location.hash && window.location.hash.match( /^#/ ) ) { var el = document.getElementById(window.location.hash.substr(2)); if (el) { el.className = "tabbertab tabbertabdefault" } }
var arg;this.div=null;this.classMain="tabber";this.classMainLive="tabberlive";this.classTab="tabbertab";this.classTabDefault="tabbertabdefault";this.classNav="tabbernav";this.classTabHide="tabbertabhide";this.classNavActive="tabberactive";this.titleElements=['h2','h3','h4','h5','h6'];this.titleElementsStripHTML=true;this.removeTitle=true;this.addLinkId=false;this.linkIdFormat='<tabberid>nav<tabnumberone>';for(arg in argsObj){this[arg]=argsObj[arg];}
this.REclassMain=new RegExp('\\b'+this.classMain+'\\b','gi');this.REclassMainLive=new RegExp('\\b'+this.classMainLive+'\\b','gi');this.REclassTab=new RegExp('\\b'+this.classTab+'\\b','gi');this.REclassTabDefault=new RegExp('\\b'+this.classTabDefault+'\\b','gi');this.REclassTabHide=new RegExp('\\b'+this.classTabHide+'\\b','gi');this.tabs=new Array();if(this.div){this.init(this.div);this.div=null;}}
tabberObj.prototype.init=function(e)
{var
childNodes,i,i2,t,defaultTab=0,DOM_ul,DOM_li,DOM_a,aId,headingElement;if(!document.getElementsByTagName){return false;}
if(e.id){this.id=e.id;}
this.tabs.length=0;childNodes=e.childNodes;for(i=0;i<childNodes.length;i++){if(childNodes[i].className&&childNodes[i].className.match(this.REclassTab)){t=new Object();t.div=childNodes[i];this.tabs[this.tabs.length]=t;if(childNodes[i].className.match(this.REclassTabDefault)){defaultTab=this.tabs.length-1;}}}
DOM_ul=document.createElement("ul");DOM_ul.className=this.classNav;for(i=0;i<this.tabs.length;i++){t=this.tabs[i];t.headingText=t.div.title;if(this.removeTitle){t.div.title='';}
if(!t.headingText){for(i2=0;i2<this.titleElements.length;i2++){headingElement=t.div.getElementsByTagName(this.titleElements[i2])[0];if(headingElement){t.headingText=headingElement.innerHTML;if(this.titleElementsStripHTML){t.headingText.replace(/<br>/gi," ");t.headingText=t.headingText.replace(/<[^>]+>/g,"");}
break;}}}
if(!t.headingText){t.headingText=i+1;}
DOM_li=document.createElement("li");t.li=DOM_li;DOM_a=document.createElement("a");DOM_a.appendChild(document.createTextNode(t.headingText));DOM_a.href="javascript:void(null);";DOM_a.title=t.headingText;DOM_a.onclick=this.navClick;DOM_a.tabber=this;DOM_a.tabberIndex=i;if(this.addLinkId&&this.linkIdFormat){aId=this.linkIdFormat;aId=aId.replace(/<tabberid>/gi,this.id);aId=aId.replace(/<tabnumberzero>/gi,i);aId=aId.replace(/<tabnumberone>/gi,i+1);aId=aId.replace(/<tabtitle>/gi,t.headingText.replace(/[^a-zA-Z0-9\-]/gi,''));DOM_a.id=aId;}
DOM_li.appendChild(DOM_a);DOM_ul.appendChild(DOM_li);}
e.insertBefore(DOM_ul,e.firstChild);e.className=e.className.replace(this.REclassMain,this.classMainLive);this.tabShow(defaultTab);if(typeof this.onLoad=='function'){this.onLoad({tabber:this});}
return this;};tabberObj.prototype.navClick=function(event)
{var
rVal,a,self,tabberIndex,onClickArgs;a=this;if(!a.tabber){return false;}
self=a.tabber;tabberIndex=a.tabberIndex;a.blur();if(typeof self.onClick=='function'){onClickArgs={'tabber':self,'index':tabberIndex,'event':event};if(!event){onClickArgs.event=window.event;}
rVal=self.onClick(onClickArgs);if(rVal===false){return false;}}
self.tabShow(tabberIndex);return false;};tabberObj.prototype.tabHideAll=function()
{var i;for(i=0;i<this.tabs.length;i++){this.tabHide(i);}};tabberObj.prototype.tabHide=function(tabberIndex)
{var div;if(!this.tabs[tabberIndex]){return false;}
div=this.tabs[tabberIndex].div;if(!div.className.match(this.REclassTabHide)){div.className+=' '+this.classTabHide;}
this.navClearActive(tabberIndex);return this;};tabberObj.prototype.tabShow=function(tabberIndex)
{var div;if(!this.tabs[tabberIndex]){return false;}
this.tabHideAll();div=this.tabs[tabberIndex].div;div.className=div.className.replace(this.REclassTabHide,'');this.navSetActive(tabberIndex);if(typeof this.onTabDisplay=='function'){this.onTabDisplay({'tabber':this,'index':tabberIndex});}
return this;};tabberObj.prototype.navSetActive=function(tabberIndex)
{this.tabs[tabberIndex].li.className=this.classNavActive;return this;};tabberObj.prototype.navClearActive=function(tabberIndex)
{this.tabs[tabberIndex].li.className='';return this;};function tabberAutomatic(tabberArgs)
{var
tempObj,divs,i;if(!tabberArgs){tabberArgs={};}
tempObj=new tabberObj(tabberArgs);divs=document.getElementsByTagName("div");for(i=0;i<divs.length;i++){if(divs[i].className&&divs[i].className.match(tempObj.REclassMain)){tabberArgs.div=divs[i];divs[i].tabber=new tabberObj(tabberArgs);}}
return this;}
function tabberAutomaticOnLoad(tabberArgs)
{var oldOnLoad;if(!tabberArgs){tabberArgs={};}
oldOnLoad=window.onload;if(typeof window.onload!='function'){window.onload=function(){tabberAutomatic(tabberArgs);};}else{window.onload=function(){oldOnLoad();tabberAutomatic(tabberArgs);};}}
if(typeof tabberOptions=='undefined'){tabberAutomaticOnLoad();}else{if(!tabberOptions['manualStartup']){tabberAutomaticOnLoad(tabberOptions);}} | myGrid/methodbox | public/javascripts/tabber-minimized.js | JavaScript | bsd-3-clause | 5,227 | [
30522,
1013,
1008,
9385,
1006,
1039,
1007,
2294,
4754,
11864,
1008,
1013,
1013,
1008,
30524,
2497,
2692,
2575,
2581,
19317,
22025,
23499,
2487,
2050,
1008,
1013,
3853,
21628,
5677,
16429,
3501,
1006,
12098,
5620,
16429,
3501,
1007,
1063,
20... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
"use strict";
var __extends = (this && this.__extends) || function (d, b) {
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
var AsyncAction_1 = require('./AsyncAction');
var AsyncScheduler_1 = require('./AsyncScheduler');
var VirtualTimeScheduler = (function (_super) {
__extends(VirtualTimeScheduler, _super);
function VirtualTimeScheduler(SchedulerAction, maxFrames) {
var _this = this;
if (SchedulerAction === void 0) { SchedulerAction = VirtualAction; }
if (maxFrames === void 0) { maxFrames = Number.POSITIVE_INFINITY; }
_super.call(this, SchedulerAction, function () { return _this.frame; });
this.maxFrames = maxFrames;
this.frame = 0;
this.index = -1;
}
/**
* Prompt the Scheduler to execute all of its queued actions, therefore
* clearing its queue.
* @return {void}
*/
VirtualTimeScheduler.prototype.flush = function () {
var _a = this, actions = _a.actions, maxFrames = _a.maxFrames;
var error, action;
while ((action = actions.shift()) && (this.frame = action.delay) <= maxFrames) {
if (error = action.execute(action.state, action.delay)) {
break;
}
}
if (error) {
while (action = actions.shift()) {
action.unsubscribe();
}
throw error;
}
};
VirtualTimeScheduler.frameTimeFactor = 10;
return VirtualTimeScheduler;
}(AsyncScheduler_1.AsyncScheduler));
exports.VirtualTimeScheduler = VirtualTimeScheduler;
/**
* We need this JSDoc comment for affecting ESDoc.
* @ignore
* @extends {Ignored}
*/
var VirtualAction = (function (_super) {
__extends(VirtualAction, _super);
function VirtualAction(scheduler, work, index) {
if (index === void 0) { index = scheduler.index += 1; }
_super.call(this, scheduler, work);
this.scheduler = scheduler;
this.work = work;
this.index = index;
this.index = scheduler.index = index;
}
VirtualAction.prototype.schedule = function (state, delay) {
if (delay === void 0) { delay = 0; }
if (!this.id) {
return _super.prototype.schedule.call(this, state, delay);
}
// If an action is rescheduled, we save allocations by mutating its state,
// pushing it to the end of the scheduler queue, and recycling the action.
// But since the VirtualTimeScheduler is used for testing, VirtualActions
// must be immutable so they can be inspected later.
var action = new VirtualAction(this.scheduler, this.work);
this.add(action);
return action.schedule(state, delay);
};
VirtualAction.prototype.requestAsyncId = function (scheduler, id, delay) {
if (delay === void 0) { delay = 0; }
this.delay = scheduler.frame + delay;
var actions = scheduler.actions;
actions.push(this);
actions.sort(VirtualAction.sortActions);
return true;
};
VirtualAction.prototype.recycleAsyncId = function (scheduler, id, delay) {
if (delay === void 0) { delay = 0; }
return undefined;
};
VirtualAction.sortActions = function (a, b) {
if (a.delay === b.delay) {
if (a.index === b.index) {
return 0;
}
else if (a.index > b.index) {
return 1;
}
else {
return -1;
}
}
else if (a.delay > b.delay) {
return 1;
}
else {
return -1;
}
};
return VirtualAction;
}(AsyncAction_1.AsyncAction));
exports.VirtualAction = VirtualAction;
//# sourceMappingURL=VirtualTimeScheduler.js.map | diegojromerolopez/djanban | src/djanban/static/angularapps/taskboard/node_modules/rxjs/scheduler/VirtualTimeScheduler.js | JavaScript | mit | 3,914 | [
30522,
1000,
2224,
9384,
1000,
1025,
13075,
1035,
1035,
8908,
1027,
1006,
2023,
1004,
1004,
2023,
1012,
1035,
1035,
8908,
1007,
1064,
1064,
3853,
1006,
1040,
1010,
1038,
1007,
1063,
2005,
1006,
13075,
1052,
1999,
1038,
1007,
2065,
1006,
1... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
/*
* MIT License
*
* Copyright (c) 2016~2017 Z-Chess
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
*/
package com.tgx.zq.z.queen.cluster.replication.bean.raft;
import com.tgx.zq.z.queen.cluster.election.raft.RaftStage;
/**
* @author William.d.zk
*/
public class NodeEntity
{
private final long _Identify;
private RaftStage mStage;
private int mSessionCount;
private long mTermId;
private long mLastCommittedSlotIndex;
private long mLastAppendedSlotIndex;
private long mBallotId;
public NodeEntity(long identify) {
_Identify = identify;
mStage = RaftStage.DISCOVER;
mBallotId = identify;
mSessionCount = 1;
}
public void leader() {
mStage = RaftStage.LEADER;
mBallotId = _Identify;
}
public void follower() {
mStage = RaftStage.FOLLOWER;
}
public void candidate() {
mStage = RaftStage.CANDIDATE;
mBallotId = _Identify;
}
public RaftStage getStage() {
return mStage;
}
public long getIdentify() {
return _Identify;
}
public void sessionIncrement() {
mSessionCount++;
}
public boolean sessionDecrement() {
mSessionCount--;
return mSessionCount == 0;
}
public long getAppendSlotIndex() {
return mLastAppendedSlotIndex;
}
public void setAppendSlotIndex(long slotIndex) {
mLastAppendedSlotIndex = Math.max(slotIndex, mLastAppendedSlotIndex);
}
public long getCommittedSlotIndex() {
return mLastCommittedSlotIndex;
}
public void setCommittedSlotIndex(long committedSlotIndex) {
mLastCommittedSlotIndex = Math.max(committedSlotIndex, mLastCommittedSlotIndex);
}
public boolean updateBallot(long termId, long ballotId) {
if (termId > mTermId) {
mTermId = termId;
mBallotId = ballotId;
return true;
}
return false;
}
public long getBallot() {
return mBallotId;
}
}
| TGX-ZQ/Z-Queen | src/main/java/com/tgx/zq/z/queen/cluster/replication/bean/raft/NodeEntity.java | Java | mit | 3,111 | [
30522,
1013,
1008,
1008,
10210,
6105,
1008,
1008,
9385,
1006,
1039,
1007,
2355,
1066,
2418,
1062,
1011,
7433,
1008,
1008,
6656,
2003,
2182,
3762,
4379,
1010,
2489,
1997,
3715,
1010,
2000,
2151,
2711,
11381,
1037,
6100,
1008,
1997,
2023,
4... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
@extends('dashboard.main')
@section('styles')
<meta name="lang" content="{{ \Session::get('locale') }}">
<link rel="stylesheet" href="{{ URL::to('libs/vendor/iCheck/skins/square/blue.css') }}">
<link rel="stylesheet" href="{{ URL::to('libs/vendor/malihu-custom-scrollbar-plugin/jquery.mCustomScrollbar.css') }}">
<link rel="stylesheet" href="{{ URL::to('libs/vendor/datetimepicker/jquery.datetimepicker.css') }}">
<link rel="stylesheet" href="{{ URL::to('libs/vendor/bootstrap-select/dist/css/bootstrap-select.css') }}">
@endsection
@section('scripts')
<script src="{{ URL::to('libs/vendor/moment/moment.js') }}"></script>
<script src="{{ URL::to('libs/vendor/moment/locale/en-gb.js') }}"></script>
<script src="{{ URL::to('libs/dashboard/moment-ru.js') }}"></script>
<script src="{{ URL::to('libs/vendor/underscore/underscore.js') }}"></script>
<script src="{{ URL::to('libs/dashboard/notify.min.js') }}"></script>
<script src="{{ URL::to('libs/vendor/bootstrap-select/dist/js/bootstrap-select.js') }}"></script>
<script src="{{ URL::to('libs/vendor/malihu-custom-scrollbar-plugin/jquery.mCustomScrollbar.js') }}"></script>
<script src="{{ URL::to('libs/vendor/datetimepicker/build/jquery.datetimepicker.full.js') }}"></script>
<script src="{{ URL::asset('libs/vendor/clndr/src/clndr.js') }}"></script>
<script src="{{ URL::asset('libs/vendor/iCheck/icheck.js') }}"></script>
<script src="{{ URL::to('libs/dashboard/schedule.js') }}"></script>
@endsection
@section('navigation')
@include('dashboard.components.nav')
@endsection
@section('body-class', 'page-schedule')
@section('content')
<div id="full-clndr" class="clearfix">
@include('dashboard.components.clndr')
</div>
<div id="fountainTextG"><div id="fountainTextG_1" class="fountainTextG">L</div><div id="fountainTextG_2" class="fountainTextG">o</div><div id="fountainTextG_3" class="fountainTextG">a</div><div id="fountainTextG_4" class="fountainTextG">d</div><div id="fountainTextG_5" class="fountainTextG">i</div><div id="fountainTextG_6" class="fountainTextG">n</div><div id="fountainTextG_7" class="fountainTextG">g</div></div>
<div class="modal fade" tabindex="-1" role="dialog" id="modal">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
<h4 class="modal-title">@lang('dashboard.components.scheduler.modal.modalTitle')</h4>
</div>
<div class="modal-body">
<form>
<div class="form-group">
<label for="Title">@lang('dashboard.components.scheduler.modal.title')</label>
<input type="text" class="form-control" id="Title" placeholder="@lang('dashboard.components.scheduler.modal.title')" title="@lang('dashboard.components.scheduler.modal.titleTip')">
</div>
<div class="form-group">
<label for="Description">@lang('dashboard.components.scheduler.modal.desc')</label>
<input type="text" class="form-control" id="Description" placeholder="@lang('dashboard.components.scheduler.modal.desc')">
</div>
<div class="form-group">
<label for="playlist">@lang('dashboard.components.scheduler.modal.playlist')</label>
<select class="selectpicker form-control" id="playlist" name="playlist">
<option value="0">@lang('dashboard.components.scheduler.modal.emptyPlaylist')</option>
</select>
</div>
<div class="form-group">
<input type="checkbox" id="repeat-day">
<label for="repeat-day">@lang('dashboard.components.scheduler.modal.repeat.everyDay')</label>
</div>
<div class="form-group">
<input type="checkbox" id="repeat-month">
<label for="repeat-month">@lang('dashboard.components.scheduler.modal.repeat.everyWeek')</label>
<div class="form-group" id="repeat-on">
<input type="checkbox" id="repeat-on-mon">
<label for="repeat-on-mon">@lang('dashboard.components.scheduler.modal.repeat.weeks.mon')</label>
<input type="checkbox" id="repeat-on-tue">
<label for="repeat-on-tue">@lang('dashboard.components.scheduler.modal.repeat.weeks.tue')</label>
<input type="checkbox" id="repeat-on-wed">
<label for="repeat-on-wed">@lang('dashboard.components.scheduler.modal.repeat.weeks.wed')</label>
<input type="checkbox" id="repeat-on-thu">
<label for="repeat-on-thu">@lang('dashboard.components.scheduler.modal.repeat.weeks.thu')</label>
<input type="checkbox" id="repeat-on-fri">
<label for="repeat-on-fri">@lang('dashboard.components.scheduler.modal.repeat.weeks.fri')</label>
<input type="checkbox" id="repeat-on-sat">
<label for="repeat-on-sat">@lang('dashboard.components.scheduler.modal.repeat.weeks.sat')</label>
<input type="checkbox" id="repeat-on-sun">
<label for="repeat-on-sun">@lang('dashboard.components.scheduler.modal.repeat.weeks.sun')</label>
</div>
</div>
<div class="form-group">
<label for="datetimepicker">@lang('dashboard.components.scheduler.modal.datetime')</label>
<input type="text" class="form-control" id="datetimepicker" placeholder="Datetime" autocomplete="off">
</div>
</form>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-danger pull-left delete-event">@lang('dashboard.core.buttons.delete')</button>
<button type="button" class="btn btn-default" data-dismiss="modal">@lang('dashboard.core.buttons.close')</button>
<button type="button" class="btn btn-primary save-changes">@lang('dashboard.core.buttons.save')</button>
</div>
</div><!-- /.modal-content -->
</div><!-- /.modal-dialog -->
</div><!-- /.modal -->
@endsection | artemsky/EvartFM | resources/views/dashboard/pages/schedule/index.blade.php | PHP | apache-2.0 | 6,950 | [
30522,
1030,
8908,
1006,
1005,
24923,
1012,
2364,
1005,
1007,
1030,
2930,
1006,
1005,
6782,
1005,
1007,
1026,
18804,
2171,
1027,
1000,
11374,
1000,
4180,
1027,
1000,
1063,
1063,
1032,
5219,
1024,
1024,
2131,
1006,
1005,
2334,
2063,
1005,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
/*
* Copyright (C) 2012 Avionic Design GmbH
* Copyright (C) 2012-2013 NVIDIA CORPORATION. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*/
#ifndef HOST1X_DRM_H
#define HOST1X_DRM_H 1
#include <drm/drmP.h>
#include <drm/drm_crtc_helper.h>
#include <drm/drm_edid.h>
#include <drm/drm_fb_helper.h>
#include <drm/drm_fixed.h>
#include <uapi/drm/tegra_drm.h>
#include "host1x.h"
struct tegra_fb {
struct drm_framebuffer base;
struct tegra_bo **planes;
unsigned int num_planes;
};
struct tegra_fbdev {
struct drm_fb_helper base;
struct tegra_fb *fb;
};
struct host1x_drm {
struct drm_device *drm;
struct device *dev;
void __iomem *regs;
struct clk *clk;
int syncpt;
int irq;
struct mutex drm_clients_lock;
struct list_head drm_clients;
struct list_head drm_active;
struct mutex clients_lock;
struct list_head clients;
struct tegra_fbdev *fbdev;
};
struct host1x_client;
struct host1x_drm_context {
struct host1x_client *client;
struct host1x_channel *channel;
struct list_head list;
};
struct host1x_client_ops {
int (*drm_init)(struct host1x_client *client, struct drm_device *drm);
int (*drm_exit)(struct host1x_client *client);
int (*open_channel)(struct host1x_client *client,
struct host1x_drm_context *context);
void (*close_channel)(struct host1x_drm_context *context);
int (*submit)(struct host1x_drm_context *context,
struct drm_tegra_submit *args, struct drm_device *drm,
struct drm_file *file);
};
struct host1x_drm_file {
struct list_head contexts;
};
struct host1x_client {
struct host1x_drm *host1x;
struct device *dev;
const struct host1x_client_ops *ops;
enum host1x_class class;
struct host1x_channel *channel;
struct host1x_syncpt **syncpts;
unsigned int num_syncpts;
struct list_head list;
};
extern int host1x_drm_init(struct host1x_drm *host1x, struct drm_device *drm);
extern int host1x_drm_exit(struct host1x_drm *host1x);
extern int host1x_register_client(struct host1x_drm *host1x,
struct host1x_client *client);
extern int host1x_unregister_client(struct host1x_drm *host1x,
struct host1x_client *client);
struct tegra_output;
struct tegra_dc {
struct host1x_client client;
spinlock_t lock;
struct host1x_drm *host1x;
struct device *dev;
struct drm_crtc base;
int pipe;
struct clk *clk;
void __iomem *regs;
int irq;
struct tegra_output *rgb;
struct list_head list;
struct drm_info_list *debugfs_files;
struct drm_minor *minor;
struct dentry *debugfs;
/* page-flip handling */
struct drm_pending_vblank_event *event;
};
static inline struct tegra_dc *host1x_client_to_dc(struct host1x_client *client)
{
return container_of(client, struct tegra_dc, client);
}
static inline struct tegra_dc *to_tegra_dc(struct drm_crtc *crtc)
{
return container_of(crtc, struct tegra_dc, base);
}
static inline void tegra_dc_writel(struct tegra_dc *dc, unsigned long value,
unsigned long reg)
{
writel(value, dc->regs + (reg << 2));
}
static inline unsigned long tegra_dc_readl(struct tegra_dc *dc,
unsigned long reg)
{
return readl(dc->regs + (reg << 2));
}
struct tegra_dc_window {
struct {
unsigned int x;
unsigned int y;
unsigned int w;
unsigned int h;
} src;
struct {
unsigned int x;
unsigned int y;
unsigned int w;
unsigned int h;
} dst;
unsigned int bits_per_pixel;
unsigned int format;
unsigned int stride[2];
unsigned long base[3];
};
/* from dc.c */
extern unsigned int tegra_dc_format(uint32_t format);
extern int tegra_dc_setup_window(struct tegra_dc *dc, unsigned int index,
const struct tegra_dc_window *window);
extern void tegra_dc_enable_vblank(struct tegra_dc *dc);
extern void tegra_dc_disable_vblank(struct tegra_dc *dc);
extern void tegra_dc_cancel_page_flip(struct drm_crtc *crtc,
struct drm_file *file);
struct tegra_output_ops {
int (*enable)(struct tegra_output *output);
int (*disable)(struct tegra_output *output);
int (*setup_clock)(struct tegra_output *output, struct clk *clk,
unsigned long pclk);
int (*check_mode)(struct tegra_output *output,
struct drm_display_mode *mode,
enum drm_mode_status *status);
};
enum tegra_output_type {
TEGRA_OUTPUT_RGB,
TEGRA_OUTPUT_HDMI,
};
struct tegra_output {
struct device_node *of_node;
struct device *dev;
const struct tegra_output_ops *ops;
enum tegra_output_type type;
struct i2c_adapter *ddc;
const struct edid *edid;
unsigned int hpd_irq;
int hpd_gpio;
struct drm_encoder encoder;
struct drm_connector connector;
};
static inline struct tegra_output *encoder_to_output(struct drm_encoder *e)
{
return container_of(e, struct tegra_output, encoder);
}
static inline struct tegra_output *connector_to_output(struct drm_connector *c)
{
return container_of(c, struct tegra_output, connector);
}
static inline int tegra_output_enable(struct tegra_output *output)
{
if (output && output->ops && output->ops->enable)
return output->ops->enable(output);
return output ? -ENOSYS : -EINVAL;
}
static inline int tegra_output_disable(struct tegra_output *output)
{
if (output && output->ops && output->ops->disable)
return output->ops->disable(output);
return output ? -ENOSYS : -EINVAL;
}
static inline int tegra_output_setup_clock(struct tegra_output *output,
struct clk *clk, unsigned long pclk)
{
if (output && output->ops && output->ops->setup_clock)
return output->ops->setup_clock(output, clk, pclk);
return output ? -ENOSYS : -EINVAL;
}
static inline int tegra_output_check_mode(struct tegra_output *output,
struct drm_display_mode *mode,
enum drm_mode_status *status)
{
if (output && output->ops && output->ops->check_mode)
return output->ops->check_mode(output, mode, status);
return output ? -ENOSYS : -EINVAL;
}
/* from rgb.c */
extern int tegra_dc_rgb_probe(struct tegra_dc *dc);
extern int tegra_dc_rgb_init(struct drm_device *drm, struct tegra_dc *dc);
extern int tegra_dc_rgb_exit(struct tegra_dc *dc);
/* from output.c */
extern int tegra_output_parse_dt(struct tegra_output *output);
extern int tegra_output_init(struct drm_device *drm, struct tegra_output *output);
extern int tegra_output_exit(struct tegra_output *output);
/* from fb.c */
struct tegra_bo *tegra_fb_get_plane(struct drm_framebuffer *framebuffer,
unsigned int index);
extern int tegra_drm_fb_init(struct drm_device *drm);
extern void tegra_drm_fb_exit(struct drm_device *drm);
extern void tegra_fbdev_restore_mode(struct tegra_fbdev *fbdev);
extern struct drm_driver tegra_drm_driver;
#endif /* HOST1X_DRM_H */
| prasidh09/cse506 | unionfs-3.10.y/drivers/gpu/host1x/drm/drm.h | C | gpl-2.0 | 6,710 | [
30522,
1013,
1008,
1008,
9385,
1006,
1039,
1007,
2262,
20704,
3258,
2594,
2640,
18289,
1008,
9385,
1006,
1039,
1007,
2262,
1011,
2286,
1050,
17258,
2401,
3840,
1012,
2035,
2916,
9235,
1012,
1008,
1008,
2023,
2565,
2003,
2489,
4007,
1025,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
#ifndef SCENENODEQUEUE_H
#define SCENENODEQUEUE_H
#include "../../SDK/SceneGraph/SceneNodeBase.h"
#include "../../SDK/Platform.h"
#include <vector>
#include <set>
namespace Scene
{
class SceneNodeQueue
{
public:
/// <summary>Конструктор класса.</summary>
SceneNodeQueue(void);
/// <summary>Деструктор класса.</summary>
virtual ~SceneNodeQueue(void) {}
virtual void CascadeUpdate(void);
private:
typedef std::set<ISceneNodeBase*> ChildUpdateSet;
mutable ChildUpdateSet childrenToUpdate;
typedef std::vector<ISceneNodeBase*> QueuedUpdates;
static QueuedUpdates queuedUpdates;
};
}
#endif // SCENENODEQUEUE_H | victor-timoshin/SWAY-GameFramework | SceneGraph/Inc/SceneNodeQueue.h | C | mit | 672 | [
30522,
1001,
2065,
13629,
2546,
3496,
3630,
3207,
4226,
5657,
1035,
1044,
1001,
9375,
3496,
3630,
3207,
4226,
5657,
1035,
1044,
1001,
2421,
1000,
1012,
1012,
1013,
1012,
1012,
1013,
17371,
2243,
1013,
3496,
14413,
1013,
3496,
3630,
3207,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
/*globals EmberDev */
import Ember from "ember-metal/core";
import {get} from "ember-metal/property_get";
import {set} from "ember-metal/property_set";
import {forEach} from "ember-metal/array";
import run from "ember-metal/run_loop";
import Application from "ember-application/system/application";
import {DefaultResolver} from "ember-application/system/resolver";
import Router from "ember-routing/system/router";
import {View} from "ember-views/views/view";
import {Controller} from "ember-runtime/controllers/controller";
import NoneLocation from "ember-routing/location/none_location";
import EmberHandlebars from "ember-handlebars";
import EmberObject from "ember-runtime/system/object";
import {outletHelper} from "ember-routing/helpers/outlet";
import jQuery from "ember-views/system/jquery";
var trim = jQuery.trim;
var view, app, application, originalLookup, originalDebug;
module("Ember.Application", {
setup: function() {
originalLookup = Ember.lookup;
originalDebug = Ember.debug;
jQuery("#qunit-fixture").html("<div id='one'><div id='one-child'>HI</div></div><div id='two'>HI</div>");
run(function() {
application = Application.create({ rootElement: '#one', router: null });
});
},
teardown: function() {
jQuery("#qunit-fixture").empty();
Ember.debug = originalDebug;
Ember.lookup = originalLookup;
if (application) {
run(application, 'destroy');
}
if (app) {
run(app, 'destroy');
}
}
});
test("you can make a new application in a non-overlapping element", function() {
run(function() {
app = Application.create({ rootElement: '#two', router: null });
});
run(app, 'destroy');
ok(true, "should not raise");
});
test("you cannot make a new application that is a parent of an existing application", function() {
expectAssertion(function() {
run(function() {
Application.create({ rootElement: '#qunit-fixture' });
});
});
});
test("you cannot make a new application that is a descendent of an existing application", function() {
expectAssertion(function() {
run(function() {
Application.create({ rootElement: '#one-child' });
});
});
});
test("you cannot make a new application that is a duplicate of an existing application", function() {
expectAssertion(function() {
run(function() {
Application.create({ rootElement: '#one' });
});
});
});
test("you cannot make two default applications without a rootElement error", function() {
expectAssertion(function() {
run(function() {
Application.create({ router: false });
});
});
});
test("acts like a namespace", function() {
var lookup = Ember.lookup = {}, app;
run(function() {
app = lookup.TestApp = Application.create({ rootElement: '#two', router: false });
});
Ember.BOOTED = false;
app.Foo = EmberObject.extend();
equal(app.Foo.toString(), "TestApp.Foo", "Classes pick up their parent namespace");
});
module("Ember.Application initialization", {
teardown: function() {
if (app) {
run(app, 'destroy');
}
Ember.TEMPLATES = {};
}
});
test('initialized application go to initial route', function() {
run(function() {
app = Application.create({
rootElement: '#qunit-fixture'
});
app.Router.reopen({
location: 'none'
});
app.register('template:application',
EmberHandlebars.compile("{{outlet}}")
);
Ember.TEMPLATES.index = EmberHandlebars.compile(
"<h1>Hi from index</h1>"
);
});
equal(jQuery('#qunit-fixture h1').text(), "Hi from index");
});
test("initialize application via initialize call", function() {
run(function() {
app = Application.create({
rootElement: '#qunit-fixture'
});
app.Router.reopen({
location: 'none'
});
app.ApplicationView = View.extend({
template: function() { return "<h1>Hello!</h1>"; }
});
});
// This is not a public way to access the container; we just
// need to make some assertions about the created router
var router = app.__container__.lookup('router:main');
equal(router instanceof Router, true, "Router was set from initialize call");
equal(router.location instanceof NoneLocation, true, "Location was set from location implementation name");
});
test("initialize application with stateManager via initialize call from Router class", function() {
run(function() {
app = Application.create({
rootElement: '#qunit-fixture'
});
app.Router.reopen({
location: 'none'
});
app.register('template:application', function() {
return "<h1>Hello!</h1>";
});
});
var router = app.__container__.lookup('router:main');
equal(router instanceof Router, true, "Router was set from initialize call");
equal(jQuery("#qunit-fixture h1").text(), "Hello!");
});
test("ApplicationView is inserted into the page", function() {
run(function() {
app = Application.create({
rootElement: '#qunit-fixture'
});
app.ApplicationView = View.extend({
render: function(buffer) {
buffer.push("<h1>Hello!</h1>");
}
});
app.ApplicationController = Controller.extend();
app.Router.reopen({
location: 'none'
});
});
equal(jQuery("#qunit-fixture h1").text(), "Hello!");
});
test("Minimal Application initialized with just an application template", function() {
jQuery('#qunit-fixture').html('<script type="text/x-handlebars">Hello World</script>');
run(function () {
app = Application.create({
rootElement: '#qunit-fixture'
});
});
equal(trim(jQuery('#qunit-fixture').text()), 'Hello World');
});
test('enable log of libraries with an ENV var', function() {
if (EmberDev && EmberDev.runningProdBuild){
ok(true, 'Logging does not occur in production builds');
return;
}
var debug = Ember.debug;
var messages = [];
Ember.LOG_VERSION = true;
Ember.debug = function(message) {
messages.push(message);
};
Ember.libraries.register("my-lib", "2.0.0a");
run(function() {
app = Application.create({
rootElement: '#qunit-fixture'
});
});
equal(messages[1], "Ember : " + Ember.VERSION);
equal(messages[2], "Handlebars : " + EmberHandlebars.VERSION);
equal(messages[3], "jQuery : " + jQuery().jquery);
equal(messages[4], "my-lib : " + "2.0.0a");
Ember.libraries.deRegister("my-lib");
Ember.LOG_VERSION = false;
Ember.debug = debug;
});
test('disable log version of libraries with an ENV var', function() {
var logged = false;
Ember.LOG_VERSION = false;
Ember.debug = function(message) {
logged = true;
};
jQuery("#qunit-fixture").empty();
run(function() {
app = Application.create({
rootElement: '#qunit-fixture'
});
app.Router.reopen({
location: 'none'
});
});
ok(!logged, 'library version logging skipped');
});
test("can resolve custom router", function(){
var CustomRouter = Router.extend();
var CustomResolver = DefaultResolver.extend({
resolveOther: function(parsedName){
if (parsedName.type === "router") {
return CustomRouter;
} else {
return this._super(parsedName);
}
}
});
app = run(function(){
return Application.create({
Resolver: CustomResolver
});
});
ok(app.__container__.lookup('router:main') instanceof CustomRouter, 'application resolved the correct router');
});
| g13013/ember.js | packages_es6/ember-application/tests/system/application_test.js | JavaScript | mit | 7,427 | [
30522,
1013,
1008,
3795,
2015,
7861,
5677,
24844,
1008,
1013,
12324,
7861,
5677,
2013,
1000,
7861,
5677,
1011,
3384,
1013,
4563,
1000,
1025,
12324,
1063,
2131,
1065,
2013,
1000,
7861,
5677,
1011,
3384,
1013,
3200,
1035,
2131,
1000,
1025,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
<?php
class Symfony2EpamCi_Sniffs_Functions_DisallowedFunctionsSniff implements PHP_CodeSniffer_Sniff
{
private static $disallowedFunctionNames = array(
'var_dump',
'print_r',
'var_export',
'trigger_error',
'header',
'fastcgi_finish_request',
'xdebug_debug_zval',
'xdebug_debug_zval_stdout',
'xdebug_var_dump',
'xdebug_break',
'set_error_handler',
'set_exception_handler',
);
/**
* Returns an array of tokens this test wants to listen for.
*
* @return array
*/
public function register()
{
return array(
T_STRING,
);
}
/**
* Processes this test, when one of its tokens is encountered.
*
* @param PHP_CodeSniffer_File $phpcsFile The file being scanned.
* @param int $stackPtr The position of the current token in
* the stack passed in $tokens.
*
* @return void
*/
public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
{
$tokens = $phpcsFile->getTokens();
$content = $tokens[$stackPtr]['content'];
if (in_array(strtolower($content), self::$disallowedFunctionNames)) {
//Checking previous token as it could be a static method or object method
$previousTokenPtr = $phpcsFile->findPrevious(PHP_CodeSniffer_Tokens::$emptyTokens, $stackPtr - 1, null, true);
if (!is_null($previousTokenPtr)) {
switch($tokens[$previousTokenPtr]['code']) {
case T_OBJECT_OPERATOR:
case T_DOUBLE_COLON:
return;
}
}
$error = 'Disallowed function "%s" was called';
$data = array($content);
$phpcsFile->addError($error, $stackPtr, 'DisallowedFunctionCalled', $data);
}
}
}
| epam-php-solutions/EpamCiBundle | Resources/configs/phpcs/Standards/Symfony2EpamCi/Sniffs/Functions/DisallowedFunctionsSniff.php | PHP | mit | 1,954 | [
30522,
1026,
1029,
25718,
2465,
25353,
2213,
14876,
4890,
2475,
13699,
3286,
6895,
1035,
27907,
2015,
1035,
4972,
1035,
4487,
12002,
27663,
20952,
4609,
22014,
2015,
3490,
4246,
22164,
25718,
1035,
9537,
3490,
12494,
1035,
27907,
1063,
2797,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
# Copyright (c) 2011 Nick Hurley <hurley at todesschaf dot org>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of version 2 of the GNU General Public License as
# published by the Free Software Foundation.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
"""Helpers for git extensions written in python
"""
import inspect
import os
import subprocess
import sys
import traceback
config = {}
def __extract_name_email(info, type_):
"""Extract a name and email from a string in the form:
User Name <user@example.com> tstamp offset
Stick that into our config dict for either git committer or git author.
"""
val = ' '.join(info.split(' ')[:-2])
angle = val.find('<')
if angle > -1:
config['GIT_%s_NAME' % type_] = val[:angle - 1]
config['GIT_%s_EMAIL' % type_] = val[angle + 1:-1]
else:
config['GIT_%s_NAME' % type_] = val
def __create_config():
"""Create our configuration dict from git and the env variables we're given.
"""
devnull = file('/dev/null', 'w')
# Stick all our git variables in our dict, just in case anyone needs them
gitvar = subprocess.Popen(['git', 'var', '-l'], stdout=subprocess.PIPE,
stderr=devnull)
for line in gitvar.stdout:
k, v = line.split('=', 1)
if k == 'GIT_COMMITTER_IDENT':
__extract_name_email(v, 'COMMITTER')
elif k == 'GIT_AUTHOR_IDENT':
__extract_name_email(v, 'AUTHOR')
elif v == 'true':
v = True
elif v == 'false':
v = False
else:
try:
v = int(v)
except:
pass
config[k] = v
gitvar.wait()
# Find out where git's sub-exes live
gitexec = subprocess.Popen(['git', '--exec-path'], stdout=subprocess.PIPE,
stderr=devnull)
config['GIT_LIBEXEC'] = gitexec.stdout.readlines()[0].strip()
gitexec.wait()
# Figure out the git dir in our repo, if applicable
gitdir = subprocess.Popen(['git', 'rev-parse', '--git-dir'],
stdout=subprocess.PIPE, stderr=devnull)
lines = gitdir.stdout.readlines()
if gitdir.wait() == 0:
config['GIT_DIR'] = lines[0].strip()
# Figure out the top level of our repo, if applicable
gittoplevel = subprocess.Popen(['git', 'rev-parse', '--show-toplevel'],
stdout=subprocess.PIPE, stderr=devnull)
lines = gittoplevel.stdout.readlines()
if gittoplevel.wait() == 0:
config['GIT_TOPLEVEL'] = lines[0].strip()
# We may have been called by a wrapper that passes us some info through the
# environment. Use it if it's there
for k, v in os.environ.iteritems():
if k.startswith('PY_GIT_'):
config[k[3:]] = v
elif k == 'PGL_OK':
config['PGL_OK'] = True
# Make sure our git dir and toplevel are fully-qualified
if 'GIT_DIR' in config and not os.path.isabs(config['GIT_DIR']):
git_dir = os.path.join(config['GIT_TOPLEVEL'], config['GIT_DIR'])
config['GIT_DIR'] = os.path.abspath(git_dir)
def warn(msg):
"""Print a warning
"""
sys.stderr.write('%s\n' % (msg,))
def die(msg):
"""Print an error message and exit the program
"""
sys.stderr.write('%s\n' % (msg,))
sys.exit(1)
def do_checks():
"""Check to ensure we've got everything we expect
"""
try:
import argparse
except:
die('Your python must support the argparse module')
def main(_main):
"""Mark a function as the main function for our git subprogram. Based
very heavily on automain by Gerald Kaszuba, but with modifications to make
it work better for our purposes.
"""
parent = inspect.stack()[1][0]
name = parent.f_locals.get('__name__', None)
if name == '__main__':
__create_config()
if 'PGL_OK' not in config:
do_checks()
rval = 1
try:
rval = _main()
except Exception, e:
sys.stdout.write('%s\n' % str(e))
f = file('pygit.tb', 'w')
traceback.print_tb(sys.exc_info()[2], None, f)
f.close()
sys.exit(rval)
return _main
if __name__ == '__main__':
"""If we get run as a script, check to make sure it's all ok and exit with
an appropriate error code
"""
do_checks()
sys.exit(0)
| todesschaf/pgl | pgl.py | Python | gpl-2.0 | 4,786 | [
30522,
1001,
9385,
1006,
1039,
1007,
2249,
4172,
25124,
1026,
25124,
2012,
28681,
7971,
7507,
2546,
11089,
8917,
1028,
1001,
1001,
2023,
2565,
2003,
2489,
4007,
1025,
2017,
2064,
2417,
2923,
3089,
8569,
2618,
2009,
1998,
1013,
2030,
19933,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
package ua.com.fielden.platform.sample.domain;
import ua.com.fielden.platform.entity.AbstractEntity;
import ua.com.fielden.platform.entity.DynamicEntityKey;
import ua.com.fielden.platform.entity.annotation.CompanionObject;
import ua.com.fielden.platform.entity.annotation.CompositeKeyMember;
import ua.com.fielden.platform.entity.annotation.IsProperty;
import ua.com.fielden.platform.entity.annotation.KeyType;
import ua.com.fielden.platform.entity.annotation.MapEntityTo;
import ua.com.fielden.platform.entity.annotation.MapTo;
import ua.com.fielden.platform.entity.annotation.Observable;
import ua.com.fielden.platform.entity.annotation.Required;
import ua.com.fielden.platform.entity.annotation.Title;
@KeyType(DynamicEntityKey.class)
@MapEntityTo
@CompanionObject(ITgOrgUnit3.class)
public class TgOrgUnit3 extends AbstractEntity<DynamicEntityKey> {
private static final long serialVersionUID = 1L;
@IsProperty
@Required
@MapTo
@Title(value = "Parent", desc = "Parent")
@CompositeKeyMember(1)
private TgOrgUnit2 parent;
@IsProperty
@MapTo
@Title(value = "Name", desc = "Desc")
@CompositeKeyMember(2)
private String name;
@Observable
public TgOrgUnit3 setName(final String name) {
this.name = name;
return this;
}
public String getName() {
return name;
}
@Observable
public TgOrgUnit3 setParent(final TgOrgUnit2 parent) {
this.parent = parent;
return this;
}
public TgOrgUnit2 getParent() {
return parent;
}
} | fieldenms/tg | platform-pojo-bl/src/main/java/ua/com/fielden/platform/sample/domain/TgOrgUnit3.java | Java | mit | 1,556 | [
30522,
7427,
25423,
1012,
4012,
1012,
2492,
2368,
1012,
4132,
1012,
7099,
1012,
5884,
1025,
12324,
25423,
1012,
4012,
1012,
2492,
2368,
1012,
4132,
1012,
9178,
1012,
10061,
4765,
3012,
1025,
12324,
25423,
1012,
4012,
1012,
2492,
2368,
1012,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
/**
*
* This file is part of Tulip (www.tulip-software.org)
*
* Authors: David Auber and the Tulip development Team
* from LaBRI, University of Bordeaux 1 and Inria Bordeaux - Sud Ouest
*
* Tulip is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License
* as published by the Free Software Foundation, either version 3
* of the License, or (at your option) any later version.
*
* Tulip is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details.
*
*/
#include <tulip/FaceIterator.h>
using namespace std;
using namespace tlp;
//============================================================
//Iterator for Face : FaceIterator
//============================================================
FaceIterator::FaceIterator(PlanarConMap* m) {
assert(m);
mgraph = m;
i = 0;
}
//============================================================
/**
* return the next element
*/
Face FaceIterator::next() {
Face tmp = mgraph->faces[i++];
return tmp;
}
//============================================================
/**
* test if there's a next element
*/
bool FaceIterator::hasNext() {
if(i == mgraph->faces.size())
return false;
else return true;
}
//============================================================
//Iterator for Face : FaceAdjIterator
//============================================================
FaceAdjIterator::FaceAdjIterator(PlanarConMap* m, const node n) {
assert(m->isElement(n));
i = 0;
facesAdj.erase(facesAdj.begin(),facesAdj.end());
edge e;
Face f_tmp, f_tmp2;
Iterator<edge> * ite = m->getInOutEdges(n);
if(ite->hasNext()) {
e = ite->next();
f_tmp = (m->edgesFaces[e])[0];
f_tmp2 = (m->edgesFaces[e])[1];
}
if(ite->hasNext()) {
e = ite->next();
if( f_tmp == (m->edgesFaces[e])[0]) {
facesAdj.push_back(f_tmp);
f_tmp = (m->edgesFaces[e])[1];
facesAdj.push_back(f_tmp);
}
else if(f_tmp == (m->edgesFaces[e])[1]) {
facesAdj.push_back(f_tmp);
f_tmp = (m->edgesFaces[e])[0];
facesAdj.push_back(f_tmp);
}
else if(f_tmp2 == (m->edgesFaces[e])[0]) {
facesAdj.push_back(f_tmp2);
f_tmp = (m->edgesFaces[e])[1];
facesAdj.push_back(f_tmp);
}
else if(f_tmp2 == (m->edgesFaces[e])[1]) {
facesAdj.push_back(f_tmp2);
f_tmp = (m->edgesFaces[e])[0];
facesAdj.push_back(f_tmp);
}
}
else {
facesAdj.push_back(f_tmp);
// facesAdj.push_back(f_tmp2);
}
while(ite->hasNext()) {
e = ite->next();
if(f_tmp == (m->edgesFaces[e])[0]) {
f_tmp = (m->edgesFaces[e])[1];
facesAdj.push_back((m->edgesFaces[e])[1]);
}
else {
f_tmp = (m->edgesFaces[e])[0];
facesAdj.push_back((m->edgesFaces[e])[0]);
}
}
delete ite;
}
//============================================================
/**
* return the next element
*/
Face FaceAdjIterator::next() {
Face tmp = facesAdj[i];
++i;
return tmp;
}
//============================================================
/**
* test if there's a next element
*/
bool FaceAdjIterator::hasNext() {
return (i != facesAdj.size());
}
//============================================================
// NodeFaceIterator
//============================================================
NodeFaceIterator::NodeFaceIterator(PlanarConMap* m, const Face face) {
i=0;
vector<edge> e = m->facesEdges[face];
edge e1 = e[0];
edge e2 = e[1];
node prev;
pair<node, node> e1Ends = m->ends(e1);
pair<node, node> e2Ends = m->ends(e2);
if( e1Ends.first == e2Ends.first || e1Ends.first == e2Ends.second)
prev = e1Ends.first;
else
prev = e1Ends.second;
nodes.push_back(prev);
for(unsigned int j = 1; j < m->facesEdges[face].size(); ++j) {
e1 = m->facesEdges[face][j];
e1Ends = m->ends(e1);
if (e1Ends.first == prev ) {
prev = e1Ends.second;
nodes.push_back(prev);
}
else {
prev = e1Ends.first;
nodes.push_back(prev);
}
}
}
//============================================================
/**
* return the next element
*/
node NodeFaceIterator::next() {
node n = nodes[i];
i++;
return n;
}
//============================================================
/**
* test if there's a next element
*/
bool NodeFaceIterator::hasNext() {
return (i != nodes.size());
}
//============================================================
// EdgeFaceIterator
//============================================================
EdgeFaceIterator::EdgeFaceIterator(PlanarConMap * m,const Face f) {
i = 0;
ve = m->facesEdges[f];
}
//============================================================
/**
* return the next element
*/
edge EdgeFaceIterator::next() {
edge tmp = ve[i];
i++;
return tmp;
}
//============================================================
/**
* test if there's a next element
*/
bool EdgeFaceIterator::hasNext() {
return (i != ve.size());
}
| kdbanman/browseRDF | tulip-3.8.0-src/library/tulip/src/FaceIterator.cpp | C++ | gpl-3.0 | 5,125 | [
30522,
1013,
1008,
1008,
1008,
1008,
2023,
5371,
2003,
2112,
1997,
10722,
15000,
1006,
7479,
1012,
10722,
15000,
1011,
4007,
1012,
8917,
1007,
1008,
1008,
6048,
1024,
2585,
8740,
5677,
1998,
1996,
10722,
15000,
2458,
2136,
1008,
2013,
6845,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="author" content="Ginolhac">
<meta name="generator" content="Hugo 0.42.1" />
<title>Posts · Aurélien' blog</title>
<link rel="shortcut icon" href="//ginolhac.github.io/images/favicon.ico">
<link rel="stylesheet" href="//ginolhac.github.io/css/style.css">
<link rel="stylesheet" href="//ginolhac.github.io/css/highlight.css">
<link href="//ginolhac.github.io/styles/github.min.css" rel="stylesheet">
<link rel="stylesheet" href="//ginolhac.github.io/css/font-awesome.min.css">
</head>
<body>
<nav class="main-nav">
<a href='//ginolhac.github.io/'> <span class="arrow">←</span>Home</a>
<a href='//ginolhac.github.io/posts'>Archive</a>
<a href='//ginolhac.github.io/karate'>Karate</a>
<a href='//ginolhac.github.io/tags'>Tags</a>
<a href='//ginolhac.github.io/about'>About</a>
</nav>
<div class="profile">
<section id="wrapper">
<header id="header">
<a href='//ginolhac.github.io/about'>
<img id="avatar" class="2x" src="//ginolhac.github.io/images/avatar.png"/>
</a>
<h1>Aurélien' blog</h1>
<h2>bioinformatic and data science</h2>
</header>
</section>
</div>
<section id="wrapper" class="home">
<div class="archive">
<h3>2018</h3>
<ul>
<div class="post-item">
<div class="post-time">Mar 26</div>
<a href="//ginolhac.github.io/posts/latex-modern-cv/" class="post-link">
LaTex modern CV
</a>
</div>
<div class="post-item">
<div class="post-time">Jan 27</div>
<a href="//ginolhac.github.io/posts/diy-raspberry-monitored-via-telegram/" class="post-link">
home surveillance monitored via telegram
</a>
</div>
</ul>
</div>
<div class="archive">
<h3>2016</h3>
<ul>
<div class="post-item">
<div class="post-time">Dec 8</div>
<a href="//ginolhac.github.io/posts/tweening-a-poisson-distribution/" class="post-link">
tweening a Poisson distribution
</a>
</div>
<div class="post-item">
<div class="post-time">Jul 31</div>
<a href="//ginolhac.github.io/posts/teething-process/" class="post-link">
teething
</a>
</div>
</ul>
</div>
<div class="archive">
<h3>2015</h3>
<ul>
<div class="post-item">
<div class="post-time">Jan 25</div>
<a href="//ginolhac.github.io/posts/winter-is-coming/" class="post-link">
winter is coming
</a>
</div>
</ul>
</div>
<footer id="footer">
<div id="social">
<a class="symbol" href="https://github.com/ginolhac">
<i class="fa fa-github-square"></i>
</a>
<a class="symbol" href="https://www.linkedin.com/in/aur%c3%a9lien-ginolhac-07b33b92/">
<i class="fa fa-linkedin-square"></i>
</a>
<a class="symbol" href="https://twitter.com/kingsushigino">
<i class="fa fa-twitter-square"></i>
</a>
</div>
<p class="small">
© Copyright 2021 <i class="fa fa-heart" aria-hidden="true"></i> Ginolhac
</p>
<p class="small">
Powered by <a href="//www.gohugo.io/">Hugo</a> Theme By <a href="https://github.com/nodejh/hugo-theme-cactus-plus">nodejh</a>
</p>
<script src="//yihui.name/js/math-code.js"></script>
<script async
src="//cdn.bootcss.com/mathjax/2.7.1/MathJax.js?config=TeX-MML-AM_CHTML">
</script>
<script src="//ginolhac.github.io/highlight.min.js"></script>
<script src="//ginolhac.github.io/languages/r.min.js"></script>
<script>
hljs.configure({languages: []});
hljs.initHighlightingOnLoad();
</script>
</footer>
</section>
<div class="dd">
</div>
<script src="//ginolhac.github.io/js/jquery-3.3.1.min.js"></script>
<script src="//ginolhac.github.io/js/main.js"></script>
<script src="//ginolhac.github.io/js/highlight.min.js"></script>
<script>hljs.initHighlightingOnLoad();</script>
<script>
var doNotTrack = false;
if (!doNotTrack) {
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','https://www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-29962051-1', 'auto');
ga('send', 'pageview');
}
</script>
</body>
</html>
| ginolhac/ginolhac.github.com | posts/index.html | HTML | mit | 4,782 | [
30522,
1026,
999,
9986,
13874,
16129,
1028,
1026,
16129,
11374,
1027,
1000,
4372,
1000,
1028,
1026,
2132,
1028,
1026,
18804,
25869,
13462,
1027,
1000,
21183,
2546,
1011,
1022,
1000,
1028,
1026,
18804,
8299,
1011,
1041,
15549,
2615,
1027,
10... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
import * as fs from 'fs';
import * as glob from 'glob';
import { IGettextExtractorStats } from './extractor';
import { CatalogBuilder, IMessage } from './builder';
import { Validate } from './utils/validate';
export interface IMessageData {
text: string;
textPlural?: string;
context?: string;
lineNumber?: number;
fileName?: string;
comments?: string[];
}
export type IAddMessageCallback = (data: IMessageData) => void;
export interface IParseOptions {
lineNumberStart?: number;
transformSource?: (source: string) => string;
}
export abstract class Parser<TExtractorFunction extends Function, TParseOptions extends IParseOptions> {
public static STRING_LITERAL_FILENAME: string = 'gettext-extractor-string-literal';
public static createAddMessageCallback(messages: Partial<IMessage>[], fileName: string, getLineNumber: () => number | undefined): IAddMessageCallback {
return (data: IMessageData) => {
let references: string[] | undefined;
if (typeof data.lineNumber !== 'number') {
data.lineNumber = getLineNumber();
}
data.fileName = data.fileName || fileName;
if (data.fileName && data.lineNumber && data.fileName !== Parser.STRING_LITERAL_FILENAME) {
references = [`${data.fileName}:${data.lineNumber}`];
}
let message: Partial<IMessage> = {
text: data.text,
textPlural: data.textPlural || undefined,
context: data.context || undefined,
references: references,
comments: data.comments && data.comments.length ? data.comments : undefined
};
messages.push(message);
};
}
constructor(
protected builder: CatalogBuilder,
protected extractors: TExtractorFunction[] = [],
protected stats?: IGettextExtractorStats
) {
this.validateExtractors(...extractors);
}
public parseString(source: string, fileName?: string, options?: TParseOptions): this {
Validate.required.string({source});
Validate.optional.nonEmptyString({fileName});
this.validateParseOptions(options);
if (!this.extractors.length) {
throw new Error(`Missing extractor functions. Provide them when creating the parser or dynamically add extractors using 'addExtractor()'`);
}
if (options && options.transformSource) {
source = options.transformSource(source);
}
let messages = this.parse(source, fileName || Parser.STRING_LITERAL_FILENAME, options);
for (let message of messages) {
this.builder.addMessage(message);
}
this.stats && this.stats.numberOfParsedFiles++;
if (messages.length) {
this.stats && this.stats.numberOfParsedFilesWithMessages++;
}
return this;
}
public parseFile(fileName: string, options?: TParseOptions): this {
Validate.required.nonEmptyString({fileName});
this.validateParseOptions(options);
this.parseString(fs.readFileSync(fileName).toString(), fileName, options);
return this;
}
public parseFilesGlob(pattern: string, globOptions?: glob.IOptions, options?: TParseOptions): this {
Validate.required.nonEmptyString({pattern});
Validate.optional.object({globOptions});
this.validateParseOptions(options);
for (let fileName of glob.sync(pattern, globOptions)) {
this.parseFile(fileName, options);
}
return this;
}
public addExtractor(extractor: TExtractorFunction): this {
Validate.required.argument({extractor});
this.validateExtractors(extractor);
this.extractors.push(extractor);
return this;
}
protected validateParseOptions(options?: TParseOptions): void {
Validate.optional.numberProperty(options, 'options.lineNumberStart');
Validate.optional.functionProperty(options, 'options.transformSource');
}
protected validateExtractors(...extractors: TExtractorFunction[]): void {
for (let extractor of extractors) {
if (typeof extractor !== 'function') {
throw new TypeError(`Invalid extractor function provided. '${extractor}' is not a function`);
}
}
}
protected abstract parse(source: string, fileName: string, options?: TParseOptions): IMessage[];
}
| lukasgeiter/gettext-extractor | src/parser.ts | TypeScript | mit | 4,500 | [
30522,
12324,
1008,
2004,
1042,
2015,
2013,
1005,
1042,
2015,
1005,
1025,
12324,
1008,
2004,
1043,
4135,
2497,
2013,
1005,
1043,
4135,
2497,
1005,
1025,
12324,
1063,
1045,
18150,
18209,
10288,
6494,
24817,
29336,
2015,
1065,
2013,
1005,
101... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
/*
Storybook: Scene-based software for novelists and authors.
Copyright (C) 2008 - 2011 Martin Mustun
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package ch.intertec.storybook.playground.swing.undo;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JScrollPane;
import javax.swing.SwingUtilities;
import net.miginfocom.swing.MigLayout;
import ch.intertec.storybook.toolkit.swing.undo.UndoableTextArea;
import ch.intertec.storybook.toolkit.swing.undo.UndoableTextField;
@SuppressWarnings("serial")
public class PgUndo extends JFrame {
private UndoableTextArea taTest;
private UndoableTextField tfTest;
public static void main(String[] args) {
SwingUtilities.invokeLater(new Runnable() {
public void run() {
new PgUndo();
}
});
}
public PgUndo() {
super("undo / redo");
setSize(400, 400);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
initGUI();
setVisible(true);
}
private void initGUI() {
setLayout(new MigLayout("fill,wrap"));
tfTest = new UndoableTextField();
tfTest.setDragEnabled(true);
taTest = new UndoableTextArea();
taTest.setLineWrap(true);
taTest.setDragEnabled(true);
taTest.setText("press Ctrl-Z to undo, Ctrl-Y to redo");
taTest.getUndoManager().discardAllEdits();
JScrollPane scroller = new JScrollPane(taTest);
JButton btUndo = new JButton();
btUndo.setAction(taTest.getUndoAction());
JButton btRedo = new JButton();
btRedo.setAction(taTest.getRedoAction());
add(tfTest, "growx");
add(scroller, "gapy 10,grow");
add(btUndo, "split 2");
add(btRedo);
}
}
| tmhorne/storybook | src/ch/intertec/storybook/playground/swing/undo/PgUndo.java | Java | gpl-3.0 | 2,224 | [
30522,
1013,
1008,
2466,
8654,
1024,
3496,
1011,
2241,
4007,
2005,
9974,
2015,
1998,
6048,
1012,
9385,
1006,
1039,
1007,
2263,
1011,
2249,
3235,
2442,
4609,
2023,
2565,
2003,
2489,
4007,
1024,
2017,
2064,
2417,
2923,
3089,
8569,
2618,
200... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
/*******************************************************************************
* Copyright (c) 2021 Eurotech and/or its affiliates and others
*
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
* which is available at https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* Eurotech - initial API and implementation
*******************************************************************************/
package org.eclipse.kapua.service.authorization.access.shiro;
import org.eclipse.kapua.qa.markers.junit.JUnitTests;
import org.junit.Assert;
import org.junit.Test;
import org.junit.experimental.categories.Category;
import java.lang.reflect.Constructor;
import java.lang.reflect.Modifier;
@Category(JUnitTests.class)
public class AccessRoleCacheFactoryTest extends Assert {
@Test
public void accessRoleCacheFactoryTest() throws Exception {
Constructor<AccessRoleCacheFactory> accessRoleCacheFactory = AccessRoleCacheFactory.class.getDeclaredConstructor();
accessRoleCacheFactory.setAccessible(true);
accessRoleCacheFactory.newInstance();
assertTrue("True expected.", Modifier.isPrivate(accessRoleCacheFactory.getModifiers()));
}
@Test
public void getInstanceTest() {
assertTrue("True expected.", AccessRoleCacheFactory.getInstance() instanceof AccessRoleCacheFactory);
assertEquals("Expected and actual values should be the same.", "AccessRoleId", AccessRoleCacheFactory.getInstance().getEntityIdCacheName());
}
} | stzilli/kapua | service/security/shiro/src/test/java/org/eclipse/kapua/service/authorization/access/shiro/AccessRoleCacheFactoryTest.java | Java | epl-1.0 | 1,610 | [
30522,
1013,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
100... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
import EmberObject from '@ember/object';
import { module, test } from 'qunit';
import { setupTest } from 'ember-qunit';
let testSerializedData = {
'hello.txt': {
content_type: 'text/plain',
data: 'aGVsbG8gd29ybGQ=',
digest: "md5-7mkg+nM0HN26sZkLN8KVSA=="
// CouchDB doesn't add 'length'
},
'stub.txt': {
stub: true,
content_type: 'text/plain',
digest: "md5-7mkg+nM0HN26sZkLN8KVSA==",
length: 11
},
};
let testDeserializedData = [
EmberObject.create({
name: 'hello.txt',
content_type: 'text/plain',
data: 'aGVsbG8gd29ybGQ=',
digest: 'md5-7mkg+nM0HN26sZkLN8KVSA=='
}),
EmberObject.create({
name: 'stub.txt',
content_type: 'text/plain',
stub: true,
digest: 'md5-7mkg+nM0HN26sZkLN8KVSA==',
length: 11
})
];
module('Unit | Transform | attachments', function(hooks) {
setupTest(hooks);
test('it serializes an attachment', function(assert) {
let transform = this.owner.lookup('transform:attachments');
assert.equal(transform.serialize(null), null);
assert.equal(transform.serialize(undefined), null);
assert.deepEqual(transform.serialize([]), {});
let serializedData = transform.serialize(testDeserializedData);
let hello = testDeserializedData[0].get('name');
assert.equal(hello, 'hello.txt');
assert.equal(serializedData[hello].content_type, testSerializedData[hello].content_type);
assert.equal(serializedData[hello].data, testSerializedData[hello].data);
let stub = testDeserializedData[1].get('name');
assert.equal(stub, 'stub.txt');
assert.equal(serializedData[stub].content_type, testSerializedData[stub].content_type);
assert.equal(serializedData[stub].stub, true);
});
test('it deserializes an attachment', function(assert) {
let transform = this.owner.lookup('transform:attachments');
assert.deepEqual(transform.deserialize(null), []);
assert.deepEqual(transform.deserialize(undefined), []);
let deserializedData = transform.deserialize(testSerializedData);
assert.equal(deserializedData[0].get('name'), testDeserializedData[0].get('name'));
assert.equal(deserializedData[0].get('content_type'), testDeserializedData[0].get('content_type'));
assert.equal(deserializedData[0].get('data'), testDeserializedData[0].get('data'));
assert.equal(deserializedData[0].get('digest'), testDeserializedData[0].get('digest'));
assert.equal(deserializedData[1].get('name'), testDeserializedData[1].get('name'));
assert.equal(deserializedData[1].get('content_type'), testDeserializedData[1].get('content_type'));
assert.equal(deserializedData[1].get('stub'), true);
assert.equal(deserializedData[1].get('digest'), testDeserializedData[1].get('digest'));
assert.equal(deserializedData[1].get('length'), testDeserializedData[1].get('length'));
});
});
| pouchdb-community/ember-pouch | tests/unit/transforms/attachments-test.js | JavaScript | apache-2.0 | 2,849 | [
30522,
12324,
7861,
5677,
16429,
20614,
2013,
1005,
1030,
7861,
5677,
1013,
4874,
1005,
1025,
12324,
1063,
11336,
1010,
3231,
1065,
2013,
1005,
24209,
3490,
2102,
1005,
1025,
12324,
1063,
16437,
22199,
1065,
2013,
1005,
7861,
5677,
1011,
24... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
/*
Copyright 2013-2021 Paul Colby
This file is part of QtAws.
QtAws is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
QtAws is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with the QtAws. If not, see <http://www.gnu.org/licenses/>.
*/
#include "createhostedconfigurationversionrequest.h"
#include "createhostedconfigurationversionrequest_p.h"
#include "createhostedconfigurationversionresponse.h"
#include "appconfigrequest_p.h"
namespace QtAws {
namespace AppConfig {
/*!
* \class QtAws::AppConfig::CreateHostedConfigurationVersionRequest
* \brief The CreateHostedConfigurationVersionRequest class provides an interface for AppConfig CreateHostedConfigurationVersion requests.
*
* \inmodule QtAwsAppConfig
*
* <fullname>AWS AppConfig</fullname>
*
* Use AWS AppConfig, a capability of AWS Systems Manager, to create, manage, and quickly deploy application
* configurations. AppConfig supports controlled deployments to applications of any size and includes built-in validation
* checks and monitoring. You can use AppConfig with applications hosted on Amazon EC2 instances, AWS Lambda, containers,
* mobile applications, or IoT
*
* devices>
*
* To prevent errors when deploying application configurations, especially for production systems where a simple typo could
* cause an unexpected outage, AppConfig includes validators. A validator provides a syntactic or semantic check to ensure
* that the configuration you want to deploy works as intended. To validate your application configuration data, you
* provide a schema or a Lambda function that runs against the configuration. The configuration deployment or update can
* only proceed when the configuration data is
*
* valid>
*
* During a configuration deployment, AppConfig monitors the application to ensure that the deployment is successful. If
* the system encounters an error, AppConfig rolls back the change to minimize impact for your application users. You can
* configure a deployment strategy for each application or environment that includes deployment criteria, including
* velocity, bake time, and alarms to monitor. Similar to error monitoring, if a deployment triggers an alarm, AppConfig
* automatically rolls back to the previous version.
*
* </p
*
* AppConfig supports multiple use cases. Here are some
*
* examples> <ul> <li>
*
* <b>Application tuning</b>: Use AppConfig to carefully introduce changes to your application that can only be tested with
* production
*
* traffic> </li> <li>
*
* <b>Feature toggle</b>: Use AppConfig to turn on new features that require a timely deployment, such as a product launch
* or announcement.
*
* </p </li> <li>
*
* <b>Allow list</b>: Use AppConfig to allow premium subscribers to access paid content.
*
* </p </li> <li>
*
* <b>Operational issues</b>: Use AppConfig to reduce stress on your application when a dependency or other external factor
* impacts the
*
* system> </li> </ul>
*
* This reference is intended to be used with the <a
* href="http://docs.aws.amazon.com/systems-manager/latest/userguide/appconfig.html">AWS AppConfig User
*
* \sa AppConfigClient::createHostedConfigurationVersion
*/
/*!
* Constructs a copy of \a other.
*/
CreateHostedConfigurationVersionRequest::CreateHostedConfigurationVersionRequest(const CreateHostedConfigurationVersionRequest &other)
: AppConfigRequest(new CreateHostedConfigurationVersionRequestPrivate(*other.d_func(), this))
{
}
/*!
* Constructs a CreateHostedConfigurationVersionRequest object.
*/
CreateHostedConfigurationVersionRequest::CreateHostedConfigurationVersionRequest()
: AppConfigRequest(new CreateHostedConfigurationVersionRequestPrivate(AppConfigRequest::CreateHostedConfigurationVersionAction, this))
{
}
/*!
* \reimp
*/
bool CreateHostedConfigurationVersionRequest::isValid() const
{
return false;
}
/*!
* Returns a CreateHostedConfigurationVersionResponse object to process \a reply.
*
* \sa QtAws::Core::AwsAbstractClient::send
*/
QtAws::Core::AwsAbstractResponse * CreateHostedConfigurationVersionRequest::response(QNetworkReply * const reply) const
{
return new CreateHostedConfigurationVersionResponse(*this, reply);
}
/*!
* \class QtAws::AppConfig::CreateHostedConfigurationVersionRequestPrivate
* \brief The CreateHostedConfigurationVersionRequestPrivate class provides private implementation for CreateHostedConfigurationVersionRequest.
* \internal
*
* \inmodule QtAwsAppConfig
*/
/*!
* Constructs a CreateHostedConfigurationVersionRequestPrivate object for AppConfig \a action,
* with public implementation \a q.
*/
CreateHostedConfigurationVersionRequestPrivate::CreateHostedConfigurationVersionRequestPrivate(
const AppConfigRequest::Action action, CreateHostedConfigurationVersionRequest * const q)
: AppConfigRequestPrivate(action, q)
{
}
/*!
* Constructs a copy of \a other, with public implementation \a q.
*
* This copy-like constructor exists for the benefit of the CreateHostedConfigurationVersionRequest
* class' copy constructor.
*/
CreateHostedConfigurationVersionRequestPrivate::CreateHostedConfigurationVersionRequestPrivate(
const CreateHostedConfigurationVersionRequestPrivate &other, CreateHostedConfigurationVersionRequest * const q)
: AppConfigRequestPrivate(other, q)
{
}
} // namespace AppConfig
} // namespace QtAws
| pcolby/libqtaws | src/appconfig/createhostedconfigurationversionrequest.cpp | C++ | lgpl-3.0 | 5,898 | [
30522,
1013,
1008,
9385,
2286,
1011,
25682,
2703,
18650,
2023,
5371,
2003,
2112,
1997,
1053,
2696,
9333,
1012,
1053,
2696,
9333,
2003,
2489,
4007,
1024,
2017,
2064,
2417,
2923,
3089,
8569,
2618,
2009,
1998,
1013,
2030,
19933,
2009,
2104,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
<?php
/**
* TOP API: taobao.wlb.inventory.detail.get request
*
* @author auto create
* @since 1.0, 2012-11-01 12:40:06
*/
class WlbInventoryDetailGetRequest
{
/**
* 库存类型列表,值包括:
VENDIBLE--可销售库存
FREEZE--冻结库存
ONWAY--在途库存
DEFECT--残次品库存
ENGINE_DAMAGE--机损
BOX_DAMAGE--箱损
EXPIRATION--过保
**/
private $inventoryTypeList;
/**
* 商品ID
**/
private $itemId;
/**
* 仓库编码
**/
private $storeCode;
private $apiParas = array();
public function setInventoryTypeList($inventoryTypeList)
{
$this->inventoryTypeList = $inventoryTypeList;
$this->apiParas["inventory_type_list"] = $inventoryTypeList;
}
public function getInventoryTypeList()
{
return $this->inventoryTypeList;
}
public function setItemId($itemId)
{
$this->itemId = $itemId;
$this->apiParas["item_id"] = $itemId;
}
public function getItemId()
{
return $this->itemId;
}
public function setStoreCode($storeCode)
{
$this->storeCode = $storeCode;
$this->apiParas["store_code"] = $storeCode;
}
public function getStoreCode()
{
return $this->storeCode;
}
public function getApiMethodName()
{
return "taobao.wlb.inventory.detail.get";
}
public function getApiParas()
{
return $this->apiParas;
}
public function check()
{
RequestCheckUtil::checkMaxListSize($this->inventoryTypeList,20,"inventoryTypeList");
RequestCheckUtil::checkNotNull($this->itemId,"itemId");
}
public function putOtherTextParam($key, $value) {
$this->apiParas[$key] = $value;
$this->$key = $value;
}
}
| Jeepal/iLogin | API/taobao/top/request/WlbInventoryDetailGetRequest.php | PHP | gpl-2.0 | 1,597 | [
30522,
1026,
1029,
25718,
1013,
1008,
1008,
1008,
2327,
17928,
1024,
20216,
3676,
2080,
1012,
1059,
20850,
1012,
12612,
1012,
6987,
1012,
2131,
5227,
1008,
1008,
1030,
3166,
8285,
3443,
1008,
1030,
2144,
1015,
1012,
1014,
1010,
2262,
1011,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
#!/usr/bin/perl
use strict;
use warnings;
use Test::More tests => 34;
BEGIN { use_ok('li_carrays') }
require_ok('li_carrays');
# array_class
{
my $length = 5;
my $xyArray = new li_carrays::XYArray($length);
for (my $i=0; $i<$length; $i++) {
my $xy = $xyArray->getitem($i);
$xy->{x} = $i*10;
$xy->{y} = $i*100;
$xyArray->setitem($i, $xy);
}
for (my $i=0; $i<$length; $i++) {
is($xyArray->getitem($i)->{x}, $i*10);
is($xyArray->getitem($i)->{y}, $i*100);
}
}
{
# global array variable
my $length = 3;
my $xyArrayPointer = $li_carrays::globalXYArray;
my $xyArray = li_carrays::XYArray::frompointer($xyArrayPointer);
for (my $i=0; $i<$length; $i++) {
my $xy = $xyArray->getitem($i);
$xy->{x} = $i*10;
$xy->{y} = $i*100;
$xyArray->setitem($i, $xy);
}
for (my $i=0; $i<$length; $i++) {
is($xyArray->getitem($i)->{x}, $i*10);
is($xyArray->getitem($i)->{y}, $i*100);
}
}
# array_functions
{
my $length = 5;
my $abArray = li_carrays::new_ABArray($length);
for (my $i=0; $i<$length; $i++) {
my $ab = li_carrays::ABArray_getitem($abArray, $i);
$ab->{a} = $i*10;
$ab->{b} = $i*100;
li_carrays::ABArray_setitem($abArray, $i, $ab);
}
for (my $i=0; $i<$length; $i++) {
is(li_carrays::ABArray_getitem($abArray, $i)->{a}, $i*10);
is(li_carrays::ABArray_getitem($abArray, $i)->{b}, $i*100);
}
li_carrays::delete_ABArray($abArray);
}
{
# global array variable
my $length = 3;
my $abArray = $li_carrays::globalABArray;
for (my $i=0; $i<$length; $i++) {
my $ab = li_carrays::ABArray_getitem($abArray, $i);
$ab->{a} = $i*10;
$ab->{b} = $i*100;
li_carrays::ABArray_setitem($abArray, $i, $ab);
}
for (my $i=0; $i<$length; $i++) {
is(li_carrays::ABArray_getitem($abArray, $i)->{a}, $i*10);
is(li_carrays::ABArray_getitem($abArray, $i)->{b}, $i*100);
}
}
| DGA-MI-SSI/YaCo | deps/swig-3.0.7/Examples/test-suite/perl5/li_carrays_runme.pl | Perl | gpl-3.0 | 1,879 | [
30522,
1001,
999,
1013,
2149,
2099,
1013,
8026,
1013,
2566,
2140,
2224,
9384,
1025,
2224,
16234,
1025,
2224,
3231,
1024,
1024,
2062,
5852,
1027,
1028,
4090,
1025,
4088,
1063,
2224,
1035,
7929,
1006,
1005,
5622,
1035,
12385,
22916,
1005,
1... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
//
// Generated by class-dump 3.5 (64 bit).
//
// class-dump is Copyright (C) 1997-1998, 2000-2001, 2004-2013 by Steve Nygard.
//
#import "NSObject.h"
@class IBConnection, NSSet, NSString;
@interface IBDragConnectionContext : NSObject
{
NSString *connectionName;
long long relationshipType;
NSString *sourceClassName;
id source;
IBConnection *prototype;
BOOL limitToInterfaceBuilder;
NSSet *endPointProvidingDocuments;
}
@property(readonly) NSSet *endPointProvidingDocuments; // @synthesize endPointProvidingDocuments;
@property(readonly) BOOL limitToInterfaceBuilder; // @synthesize limitToInterfaceBuilder;
@property(readonly) NSString *connectionName; // @synthesize connectionName;
@property(readonly) long long relationshipType; // @synthesize relationshipType;
@property(readonly) NSString *sourceClassName; // @synthesize sourceClassName;
@property(readonly) IBConnection *prototype; // @synthesize prototype;
@property(readonly) id source; // @synthesize source;
- (void).cxx_destruct;
- (id)initWithConnectionName:(id)arg1 relationshipType:(long long)arg2 sourceClassName:(id)arg3 endPointProvidingDocuments:(id)arg4 limitedToInterfaceBuilder:(BOOL)arg5;
- (id)initWithPrototype:(id)arg1 endPointProvidingDocuments:(id)arg2;
- (id)initWithSource:(id)arg1 endPointProvidingDocuments:(id)arg2;
@end
| wczekalski/Distraction-Free-Xcode-plugin | Archived/v1/WCDistractionFreeXcodePlugin/Headers/PlugIns/IDEInterfaceBuilderKit/IBDragConnectionContext.h | C | mit | 1,348 | [
30522,
1013,
1013,
1013,
1013,
7013,
2011,
2465,
1011,
15653,
1017,
1012,
1019,
1006,
4185,
2978,
1007,
1012,
1013,
1013,
1013,
1013,
2465,
1011,
15653,
2003,
9385,
1006,
1039,
1007,
2722,
1011,
2687,
1010,
2456,
1011,
2541,
1010,
2432,
1... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.