<commit_before>#include "handler_unittest.hpp"

#include "fake_sys_file.hpp"

#include <google/protobuf/message_lite.h>
#include <google/protobuf/text_format.h>

#include <algorithm>
#include <boost/endian/arithmetic.hpp>
#include <memory>
#include <string>
#include <vector>

#include "binaryblob.pb.h"

#include <gtest/gtest.h>

using ::testing::_;
using ::testing::AtLeast;
using ::testing::ElementsAreArray;
using ::testing::IsEmpty;
using ::testing::Return;
using ::testing::StrEq;
using ::testing::StrNe;
using ::testing::UnorderedElementsAreArray;

using namespace std::string_literals;
using namespace binstore;

namespace blobs
{

class BinaryStoreBlobHandlerBasicTest : public BinaryStoreBlobHandlerTest
{
  protected:
    static inline std::string basicTestBaseId = "/test/"s;
    static inline std::string basicTestBlobId = "/test/blob0"s;

    static const std::vector<std::string> basicTestBaseIdList;
    static inline std::string basicTestInvalidBlobId = "/invalid/blob0"s;

    void addAllBaseIds()
    {
        for (size_t i = 0; i < basicTestBaseIdList.size(); ++i)
        {
            auto store = defaultMockStore(basicTestBaseIdList[i]);

            EXPECT_CALL(*store, getBaseBlobId()).Times(AtLeast(1));

            handler.addNewBinaryStore(std::move(store));
        }
    }
};

const std::vector<std::string>
    BinaryStoreBlobHandlerBasicTest::basicTestBaseIdList = {
        BinaryStoreBlobHandlerBasicTest::basicTestBaseId, "/another/"s,
        "/null\0/"s};

TEST_F(BinaryStoreBlobHandlerBasicTest, CanHandleBlobZeroStoreFail)
{
    // Cannot handle since there is no store. Shouldn't crash.
    EXPECT_FALSE(handler.canHandleBlob(basicTestInvalidBlobId));
}

TEST_F(BinaryStoreBlobHandlerBasicTest, CanHandleBlobChecksName)
{
    auto store = defaultMockStore(basicTestBaseId);

    EXPECT_CALL(*store, getBaseBlobId()).Times(AtLeast(1));

    handler.addNewBinaryStore(std::move(store));

    // Verify canHandleBlob checks and returns false on an invalid name.
    EXPECT_FALSE(handler.canHandleBlob(basicTestInvalidBlobId));
    // Verify canHandleBlob return true for a blob id that it can handle
    EXPECT_TRUE(handler.canHandleBlob(basicTestBlobId));
}

TEST_F(BinaryStoreBlobHandlerBasicTest, GetBlobIdEqualsConcatenationsOfBaseIds)
{
    addAllBaseIds();

    // When there is no other blob id, ids are just base ids (might be
    // re-ordered).
    EXPECT_THAT(handler.getBlobIds(),
                UnorderedElementsAreArray(basicTestBaseIdList));
}

TEST_F(BinaryStoreBlobHandlerBasicTest, CanHandleBlobInvalidNames)
{
    addAllBaseIds();

    const std::vector<std::string> invalidNames = {
        basicTestInvalidBlobId,
        "/"s,
        "//"s,
        "/test"s, // Cannot handle the base path
        "/test/"s,
        "/test/this/blob"s, // Cannot handle nested path
    };

    // Unary helper for algorithm
    auto canHandle = [this](const std::string& blobId) {
        return handler.canHandleBlob(blobId);
    };

    EXPECT_TRUE(
        std::none_of(invalidNames.cbegin(), invalidNames.cend(), canHandle));
}

TEST_F(BinaryStoreBlobHandlerBasicTest, CanHandleBlobValidNames)
{
    addAllBaseIds();

    const std::vector<std::string> validNames = {
        basicTestBlobId,  "/test/test"s,          "/test/xyz.abc"s,
        "/another/blob"s, "/null\0/\0\0zer\0\0"s,
    };

    // Unary helper for algorithm
    auto canHandle = [this](const std::string& blobId) {
        return handler.canHandleBlob(blobId);
    };

    // Verify canHandleBlob can handle a valid blob under the path.
    EXPECT_TRUE(std::all_of(validNames.cbegin(), validNames.cend(), canHandle));
}

TEST_F(BinaryStoreBlobHandlerBasicTest, DeleteReturnsWhatStoreReturns)
{
    auto store = defaultMockStore(basicTestBaseId);

    EXPECT_CALL(*store, getBaseBlobId()).Times(AtLeast(1));
    EXPECT_CALL(*store, deleteBlob(StrEq(basicTestBlobId)))
        .WillOnce(Return(false))
        .WillOnce(Return(true));
    handler.addNewBinaryStore(std::move(store));

    // Unary helper for algorithm
    auto canHandle = [this](const std::string& blobId) {
        return handler.canHandleBlob(blobId);
    };

    // Verify canHandleBlob return true for a blob id that it can handle
    EXPECT_FALSE(canHandle(basicTestInvalidBlobId));
    EXPECT_TRUE(canHandle(basicTestBlobId));
    EXPECT_FALSE(handler.deleteBlob(basicTestInvalidBlobId));
    EXPECT_FALSE(handler.deleteBlob(basicTestBlobId));
    EXPECT_TRUE(handler.deleteBlob(basicTestBlobId));
}

TEST_F(BinaryStoreBlobHandlerBasicTest, StaleDataIsClearedDuringCreation)
{
    using namespace google::protobuf;

    auto basicTestStaleBlobStr =
        R"(blob_base_id: "/stale/"
          blobs {
            blob_id: "/stale/blob"
          })";

    // Create sysfile containing a valid but stale blob
    const std::string staleBaseId = "/stale/"s;
    const std::string staleBlobId = "/stale/blob"s;
    binaryblobproto::BinaryBlobBase staleBlob;
    EXPECT_TRUE(TextFormat::ParseFromString(basicTestStaleBlobStr, &staleBlob));

    // Serialize to string stored in the fakeSysFile
    auto staleBlobData = staleBlob.SerializeAsString();
    boost::endian::little_uint64_t sizeLE = staleBlobData.size();
    std::string commitData(reinterpret_cast<const char*>(sizeLE.data()),
                           sizeof(sizeLE));
    commitData += staleBlobData;

    std::vector<std::string> expectedIdList = {basicTestBaseId};

    handler.addNewBinaryStore(BinaryStore::createFromConfig(
        basicTestBaseId, std::make_unique<FakeSysFile>(commitData)));
    EXPECT_FALSE(handler.canHandleBlob(staleBlobId));
    EXPECT_EQ(handler.getBlobIds(), expectedIdList);
}

TEST_F(BinaryStoreBlobHandlerBasicTest, CreatingFromEmptySysfile)
{
    const std::string emptyData;
    EXPECT_NO_THROW(handler.addNewBinaryStore(BinaryStore::createFromConfig(
        basicTestBaseId, std::make_unique<FakeSysFile>(emptyData))));
    EXPECT_TRUE(handler.canHandleBlob(basicTestBlobId));
}

TEST_F(BinaryStoreBlobHandlerBasicTest, CreatingFromJunkData)
{
    boost::endian::little_uint64_t tooLarge = 0xffffffffffffffffull;
    const std::string junkDataWithLargeSize(
        reinterpret_cast<const char*>(tooLarge.data()), sizeof(tooLarge));
    EXPECT_GE(tooLarge, junkDataWithLargeSize.max_size());

    EXPECT_NO_THROW(handler.addNewBinaryStore(BinaryStore::createFromConfig(
        basicTestBaseId,
        std::make_unique<FakeSysFile>(junkDataWithLargeSize))));

    EXPECT_TRUE(handler.canHandleBlob(basicTestBlobId));
}

} // namespace blobs
<commit_msg>test: use char arrays instead of strings<commit_after>#include "handler_unittest.hpp"

#include "fake_sys_file.hpp"

#include <google/protobuf/message_lite.h>
#include <google/protobuf/text_format.h>

#include <algorithm>
#include <boost/endian/arithmetic.hpp>
#include <memory>
#include <string>
#include <vector>

#include "binaryblob.pb.h"

#include <gtest/gtest.h>

using ::testing::_;
using ::testing::AtLeast;
using ::testing::ElementsAreArray;
using ::testing::IsEmpty;
using ::testing::Return;
using ::testing::StrEq;
using ::testing::StrNe;
using ::testing::UnorderedElementsAreArray;

using namespace std::string_literals;
using namespace binstore;

namespace blobs
{

class BinaryStoreBlobHandlerBasicTest : public BinaryStoreBlobHandlerTest
{
  protected:
    static inline char basicTestBaseId[] = "/test/";
    static inline char basicTestBlobId[] = "/test/blob0";

    static const std::vector<std::string> basicTestBaseIdList;
    static inline char basicTestInvalidBlobId[] = "/invalid/blob0";

    void addAllBaseIds()
    {
        for (size_t i = 0; i < basicTestBaseIdList.size(); ++i)
        {
            auto store = defaultMockStore(basicTestBaseIdList[i]);

            EXPECT_CALL(*store, getBaseBlobId()).Times(AtLeast(1));

            handler.addNewBinaryStore(std::move(store));
        }
    }
};

const std::vector<std::string>
    BinaryStoreBlobHandlerBasicTest::basicTestBaseIdList = {
        BinaryStoreBlobHandlerBasicTest::basicTestBaseId, "/another/"s,
        "/null\0/"s};

TEST_F(BinaryStoreBlobHandlerBasicTest, CanHandleBlobZeroStoreFail)
{
    // Cannot handle since there is no store. Shouldn't crash.
    EXPECT_FALSE(handler.canHandleBlob(basicTestInvalidBlobId));
}

TEST_F(BinaryStoreBlobHandlerBasicTest, CanHandleBlobChecksName)
{
    auto store = defaultMockStore(basicTestBaseId);

    EXPECT_CALL(*store, getBaseBlobId()).Times(AtLeast(1));

    handler.addNewBinaryStore(std::move(store));

    // Verify canHandleBlob checks and returns false on an invalid name.
    EXPECT_FALSE(handler.canHandleBlob(basicTestInvalidBlobId));
    // Verify canHandleBlob return true for a blob id that it can handle
    EXPECT_TRUE(handler.canHandleBlob(basicTestBlobId));
}

TEST_F(BinaryStoreBlobHandlerBasicTest, GetBlobIdEqualsConcatenationsOfBaseIds)
{
    addAllBaseIds();

    // When there is no other blob id, ids are just base ids (might be
    // re-ordered).
    EXPECT_THAT(handler.getBlobIds(),
                UnorderedElementsAreArray(basicTestBaseIdList));
}

TEST_F(BinaryStoreBlobHandlerBasicTest, CanHandleBlobInvalidNames)
{
    addAllBaseIds();

    const std::vector<std::string> invalidNames = {
        basicTestInvalidBlobId,
        "/"s,
        "//"s,
        "/test"s, // Cannot handle the base path
        "/test/"s,
        "/test/this/blob"s, // Cannot handle nested path
    };

    // Unary helper for algorithm
    auto canHandle = [this](const std::string& blobId) {
        return handler.canHandleBlob(blobId);
    };

    EXPECT_TRUE(
        std::none_of(invalidNames.cbegin(), invalidNames.cend(), canHandle));
}

TEST_F(BinaryStoreBlobHandlerBasicTest, CanHandleBlobValidNames)
{
    addAllBaseIds();

    const std::vector<std::string> validNames = {
        basicTestBlobId,  "/test/test"s,          "/test/xyz.abc"s,
        "/another/blob"s, "/null\0/\0\0zer\0\0"s,
    };

    // Unary helper for algorithm
    auto canHandle = [this](const std::string& blobId) {
        return handler.canHandleBlob(blobId);
    };

    // Verify canHandleBlob can handle a valid blob under the path.
    EXPECT_TRUE(std::all_of(validNames.cbegin(), validNames.cend(), canHandle));
}

TEST_F(BinaryStoreBlobHandlerBasicTest, DeleteReturnsWhatStoreReturns)
{
    auto store = defaultMockStore(basicTestBaseId);

    EXPECT_CALL(*store, getBaseBlobId()).Times(AtLeast(1));
    EXPECT_CALL(*store, deleteBlob(StrEq(basicTestBlobId)))
        .WillOnce(Return(false))
        .WillOnce(Return(true));
    handler.addNewBinaryStore(std::move(store));

    // Unary helper for algorithm
    auto canHandle = [this](const std::string& blobId) {
        return handler.canHandleBlob(blobId);
    };

    // Verify canHandleBlob return true for a blob id that it can handle
    EXPECT_FALSE(canHandle(basicTestInvalidBlobId));
    EXPECT_TRUE(canHandle(basicTestBlobId));
    EXPECT_FALSE(handler.deleteBlob(basicTestInvalidBlobId));
    EXPECT_FALSE(handler.deleteBlob(basicTestBlobId));
    EXPECT_TRUE(handler.deleteBlob(basicTestBlobId));
}

TEST_F(BinaryStoreBlobHandlerBasicTest, StaleDataIsClearedDuringCreation)
{
    using namespace google::protobuf;

    auto basicTestStaleBlobStr =
        R"(blob_base_id: "/stale/"
          blobs {
            blob_id: "/stale/blob"
          })";

    // Create sysfile containing a valid but stale blob
    const std::string staleBaseId = "/stale/"s;
    const std::string staleBlobId = "/stale/blob"s;
    binaryblobproto::BinaryBlobBase staleBlob;
    EXPECT_TRUE(TextFormat::ParseFromString(basicTestStaleBlobStr, &staleBlob));

    // Serialize to string stored in the fakeSysFile
    auto staleBlobData = staleBlob.SerializeAsString();
    boost::endian::little_uint64_t sizeLE = staleBlobData.size();
    std::string commitData(reinterpret_cast<const char*>(sizeLE.data()),
                           sizeof(sizeLE));
    commitData += staleBlobData;

    std::vector<std::string> expectedIdList = {basicTestBaseId};

    handler.addNewBinaryStore(BinaryStore::createFromConfig(
        basicTestBaseId, std::make_unique<FakeSysFile>(commitData)));
    EXPECT_FALSE(handler.canHandleBlob(staleBlobId));
    EXPECT_EQ(handler.getBlobIds(), expectedIdList);
}

TEST_F(BinaryStoreBlobHandlerBasicTest, CreatingFromEmptySysfile)
{
    const std::string emptyData;
    EXPECT_NO_THROW(handler.addNewBinaryStore(BinaryStore::createFromConfig(
        basicTestBaseId, std::make_unique<FakeSysFile>(emptyData))));
    EXPECT_TRUE(handler.canHandleBlob(basicTestBlobId));
}

TEST_F(BinaryStoreBlobHandlerBasicTest, CreatingFromJunkData)
{
    boost::endian::little_uint64_t tooLarge = 0xffffffffffffffffull;
    const std::string junkDataWithLargeSize(
        reinterpret_cast<const char*>(tooLarge.data()), sizeof(tooLarge));
    EXPECT_GE(tooLarge, junkDataWithLargeSize.max_size());

    EXPECT_NO_THROW(handler.addNewBinaryStore(BinaryStore::createFromConfig(
        basicTestBaseId,
        std::make_unique<FakeSysFile>(junkDataWithLargeSize))));

    EXPECT_TRUE(handler.canHandleBlob(basicTestBlobId));
}

} // namespace blobs
<|endoftext|>


<commit_before>// Micro Power Snitch code, including periodic radio packet transmissions.
// See http://jeelabs.org/2015/03/11/micro-power-snitch-part-4/

#include "sys.h"

#define chThdYield() // FIXME still used in rf69.h
#include "spi.h"
#include "rf69.h"

RF69<SpiDev0> rf;

static void sleep (int ticks) {
  LPC_WKT->COUNT = ticks;             // sleep time in 0.1 ms steps
  SCB->SCR |= 1<<2;                   // enable SLEEPDEEP mode
  __WFI();
  SCB->SCR &= ~(1<<2);                // disable SLEEPDEEP mode
}

int main () {
  // enable wake-ups via low-power watchdog interrupts
  LPC_SYSCON->SYSAHBCLKCTRL |= 1<<9;  // SYSCTL_CLOCK_WKT
  LPC_WKT->CTRL = 1<<0;               // WKT_CTRL_CLKSEL
  NVIC_EnableIRQ(WKT_IRQn);

  // power-down setup (can't use deep power down, loses I/O pin statet)
  LPC_SYSCON->STARTERP1 = 1<<15;      // wake up from alarm/wake timer
  LPC_PMU->DPDCTRL = (1<<2) | (1<<1); // LPOSCEN, no wakepad
  LPC_PMU->PCON = 2;                  // use normal power-down mode

  // disable all special pin functions
  LPC_SWM->PINENABLE0 = ~0;

  // make all SPI pins "0" outputs to prevent radio back-feeding
  LPC_GPIO_PORT->DIR[0] |= 0b111110;  // pio1..5 all outputs
  LPC_GPIO_PORT->CLR[0] = 0b111100;   // pio2..5 set to 0
  LPC_GPIO_PORT->SET[0] = 0b000010;   // pio1 set to 1

  sleep(10000); // sleep 1 sec to let power supply rise further

  LPC_GPIO_PORT->DIR[0] &= ~0b111100; // pio2..5 all inputs again
  LPC_GPIO_PORT->B[0][1] = 0;         // low, turns radio power on

  sleep(100); // sleep 10 ms to let the radio start up

  // SPI0 pin configuration
  // lpc810: sck=3p3, ssel=4p2, miso=2p4, mosi=5p1
  LPC_SWM->PINASSIGN[3] = 0x03FFFFFF;   // sck  -    -    -
  LPC_SWM->PINASSIGN[4] = 0xFF040205;   // -    nss  miso mosi

  // initialise the radio and put it into idle mode asap
  rf.init(61, 42, 8683);              // node 61, group 42, 868.3 MHz
  rf.sleep();

  // configure the radio a bit more
  // rf.encrypt("mysecret");
  rf.txPower(0); // 0 = min .. 31 = max

  sleep(10000); // sleep 1 sec before entering the main loop

  while (true) {
    // send out one packet and go back to sleep
    rf.send(0, "xyz", 3);
    rf.sleep();

    sleep(10000); // sleep 1 sec
  }
}

extern "C" void WKT_IRQHandler () {
  LPC_WKT->CTRL = LPC_WKT->CTRL;      // clear the alarm interrupt
  // LPC_WKT->CTRL |= (1<<1) | (1<<2);   // clear alarm
}
<commit_msg>comment tweaks<commit_after>// Micro Power Snitch code, including periodic radio packet transmissions.
// See http://jeelabs.org/2015/03/11/micro-power-snitch-part-4/

#include "sys.h"

#define chThdYield() // FIXME still used in rf69.h
#include "spi.h"
#include "rf69.h"

RF69<SpiDev0> rf;

static void sleep (int ticks) {
  LPC_WKT->COUNT = ticks;             // sleep time in 0.1 ms steps
  SCB->SCR |= 1<<2;                   // enable SLEEPDEEP mode
  __WFI();
  SCB->SCR &= ~(1<<2);                // disable SLEEPDEEP mode
}

int main () {
  // enable wake-ups via low-power watchdog interrupts
  LPC_SYSCON->SYSAHBCLKCTRL |= 1<<9;  // SYSCTL_CLOCK_WKT
  LPC_WKT->CTRL = 1<<0;               // WKT_CTRL_CLKSEL
  NVIC_EnableIRQ(WKT_IRQn);

  // power-down setup (can't use deep power down, loses I/O pin state)
  LPC_SYSCON->STARTERP1 = 1<<15;      // wake up from alarm/wake timer
  LPC_PMU->DPDCTRL = (1<<2) | (1<<1); // LPOSCEN, no wakepad
  LPC_PMU->PCON = 2;                  // use normal power-down mode

  // disable all special pin functions
  LPC_SWM->PINENABLE0 = ~0;

  // make all SPI pins "0" outputs to prevent radio back-feeding
  LPC_GPIO_PORT->DIR[0] |= 0b111110;  // pio1..5 all outputs
  LPC_GPIO_PORT->CLR[0] = 0b111100;   // pio2..5 set to 0
  LPC_GPIO_PORT->SET[0] = 0b000010;   // pio1 set to 1

  sleep(10000); // sleep 1 sec to let power supply rise further

  LPC_GPIO_PORT->DIR[0] &= ~0b111100; // pio2..5 all inputs again
  LPC_GPIO_PORT->B[0][1] = 0;         // low, turns radio power on

  sleep(100); // sleep 10 ms to let the radio start up

  // SPI0 pin configuration
  // lpc810: sck=3p3, ssel=4p2, miso=2p4, mosi=5p1
  LPC_SWM->PINASSIGN[3] = 0x03FFFFFF; // sck  -    -    -
  LPC_SWM->PINASSIGN[4] = 0xFF040205; // -    nss  miso mosi

  // initialise the radio and put it into idle mode asap
  rf.init(61, 42, 8683);              // node 61, group 42, 868.3 MHz
  rf.sleep();

  // configure the radio a bit more
  // rf.encrypt("mysecret");
  rf.txPower(0); // 0 = min .. 31 = max

  sleep(10000); // sleep 1 sec before entering the main loop

  while (true) {
    // send out one packet and go back to sleep
    rf.send(0, "xyz", 3);
    rf.sleep();

    sleep(10000); // sleep 1 sec
  }
}

extern "C" void WKT_IRQHandler () {
  LPC_WKT->CTRL = LPC_WKT->CTRL;      // clear the alarm interrupt
  // LPC_WKT->CTRL |= (1<<1) | (1<<2);   // clear alarm
}
<|endoftext|>


<commit_before>void CreateCalibPars_Miscalibrated(){
  // Create TOF Calibration Object for miscalibrated detector
  // and write it on CDB
  AliTOFGeometry *geom = new AliTOFGeometryV5();
  AliTOFcalib *tofcalib = new AliTOFcalib(geom);
  AliTOFCal *tofCal= new AliTOFCal(geom);
  tofCal->CreateArray();

  // Input data for decalibration

  TFile f("$ALICE_ROOT/TOF/data/spectrum.root","READ");

  TH1F *hTimeToTFit=  (TH1F*)f.Get("TimeToTFit");
  TF1  *fit=hTimeToTFit->GetFunction("poly5");

  // Slewing parameters (same for all channels)

  Float_t par[6] = {0.,0.,0.,0.,0.,0.};
  for(Int_t i =0;i<6;i++){
    par[i]=fit->GetParameter(i);
    //    cout << " Slewing parameters=" << par[i] << endl;
  }

  // Global time offset (randomly gen, gaussian with mean = 0.3, sig=0.08 ns)

  Float_t delay=0.;
  Float_t meanDelay=0.3;
  Float_t sigmaDelay=0.08;

  // ToT spectrum

  TH1F *hToT=  (TH1F*)f.Get("ToT");

  // Fill the Sim calibration object

  TRandom *rnd   = new TRandom(4357);
  for (Int_t ipad = 0 ; ipad<tofCal->NPads(); ipad++){
    AliTOFChannel *calChannel = tofCal->GetChannel(ipad);
    calChannel->SetSlewPar(par);
    delay=rnd->Gaus(meanDelay,sigmaDelay);
    // cout << " delay=" << delay << endl;
    calChannel->SetDelay(delay);
  }
  tofcalib->WriteSimParOnCDB("TOF/Calib",0,0,tofCal,hToT);
  f.Close();
}

<commit_msg>Updates to fetch the restricted spectra in TOF/data/spectrum.root<commit_after>void CreateCalibPars_Miscalibrated(){
  // Create TOF Calibration Object for miscalibrated detector
  // and write it on CDB
  AliTOFGeometry *geom = new AliTOFGeometryV5();
  AliTOFcalib *tofcalib = new AliTOFcalib(geom);
  AliTOFCal *tofCal= new AliTOFCal(geom);
  tofCal->CreateArray();

  // Input data for decalibration

  TFile f("$ALICE_ROOT/TOF/data/spectrum.root","READ");

  TH1F *hTimeToTFit=  (TH1F*)f.Get("hTimeToTLim");
  TF1  *fit=hTimeToTFit->GetFunction("pol5");

  // Slewing parameters (same for all channels)

  Float_t par[6] = {0.,0.,0.,0.,0.,0.};
  for(Int_t i =0;i<6;i++){
    par[i]=fit->GetParameter(i);
    cout << " Slewing parameters=" << par[i] << endl;
  }

  // Global time offset (randomly gen, gaussian with mean = 0.3, sig=0.08 ns)

  Float_t delay=0.;
  Float_t meanDelay=0.3;
  Float_t sigmaDelay=0.08;

  // ToT spectrum

  TH1F *hToT=  (TH1F*)f.Get("hToTLim");

  // Fill the Sim calibration object

  TRandom *rnd   = new TRandom(4357);
  for (Int_t ipad = 0 ; ipad<tofCal->NPads(); ipad++){
    AliTOFChannel *calChannel = tofCal->GetChannel(ipad);
    calChannel->SetSlewPar(par);
    delay=rnd->Gaus(meanDelay,sigmaDelay);
    calChannel->SetDelay(delay);
  }
  tofcalib->WriteSimParOnCDB("TOF/Calib",0,0,tofCal,hToT);
  f.Close();
}

<|endoftext|>


<commit_before>// $Id: atomContainer.C,v 1.10 2001/07/15 16:12:42 oliver Exp $

#include <BALL/KERNEL/atomContainer.h>

#include <BALL/KERNEL/atom.h>
#include <BALL/KERNEL/bond.h>
#include <BALL/KERNEL/forEach.h>
#include <BALL/KERNEL/global.h>
#include <BALL/KERNEL/molecule.h>

using namespace std;

namespace BALL
{

	AtomContainer::AtomContainer()
		throw()
		:	Composite(),
			PropertyManager(),
			name_(BALL_ATOMCONTAINER_DEFAULT_NAME)
	{
	}

	AtomContainer::AtomContainer(const AtomContainer& atom_container, bool deep)
		throw()
		:	Composite(),
			PropertyManager(),
			name_()
	{
		set(atom_container, deep);
	}

	AtomContainer::AtomContainer(const String& name)
		throw()
		:	Composite(),
			PropertyManager(),
			name_(name)
	{
	}

	AtomContainer::~AtomContainer()
		throw()
	{
		destroy();
	}

	void AtomContainer::clear()
		throw()
	{
		Composite::clear();
		PropertyManager::clear();

		name_ = BALL_ATOMCONTAINER_DEFAULT_NAME;
	}

	void AtomContainer::destroy()
		throw()
	{
		Composite::destroy();
		PropertyManager::destroy();

		name_ = BALL_ATOMCONTAINER_DEFAULT_NAME;
	}

	void AtomContainer::persistentWrite(PersistenceManager& pm, const char* name) const
		throw(Exception::GeneralException)
	{
		pm.writeObjectHeader(this, name);
			Composite::persistentWrite(pm);

			pm.writeStorableObject(*(PropertyManager*)this, "PropertyManager");

			pm.writePrimitive(name_, "name_");
		pm.writeObjectTrailer(name);
	}

	void AtomContainer::persistentRead(PersistenceManager& pm)
		throw(Exception::GeneralException)
	{
		pm.checkObjectHeader(RTTI::getStreamName<Composite>());
			Composite::persistentRead(pm);
		pm.checkObjectTrailer(0);

		pm.readStorableObject(*(PropertyManager*)this, "PropertyManager");

		pm.readPrimitive(name_, "name_");
	}

	void AtomContainer::set(const AtomContainer& atom_container, bool deep)
		throw()
	{
    bool clone_them = clone_bonds;
    clone_bonds = false;

		Composite::set(atom_container, deep);
		PropertyManager::set(atom_container);
		name_ = atom_container.name_;

		// clone the bonds only of we are the outmost set method
		// involved!
    if (clone_them && deep)
    {
      BALL::cloneBonds(atom_container, *this);
		}

    clone_bonds = clone_them;
	}

	const AtomContainer& AtomContainer::operator = (const AtomContainer& atom_container)
		throw()
	{
		set(atom_container);
		return *this;
	}

	void AtomContainer::get(AtomContainer& atom_container, bool deep) const
		throw()
	{
		atom_container.set(*this, deep);
	}

	void AtomContainer::swap(AtomContainer& atom_container)
		throw()
	{
		Composite::swap(atom_container);
		PropertyManager::swap(atom_container);
		name_.swap(atom_container.name_);
	}

	void AtomContainer::setName(const String& name)
		throw()
	{
		name_ = name;
	}

	const String& AtomContainer::getName() const
		throw()
	{
		return name_;
	}

/*  BAUSTELLE - remove?
	Molecule* AtomContainer::getMolecule()
		throw()
	{
		for (Composite::AncestorIterator ancestor_it = beginAncestor();
				 !ancestor_it.isEnd(); ++ancestor_it)
		{
			if (RTTI::isKindOf<Molecule>(*ancestor_it) == true)
			{
				return (Molecule *)&*ancestor_it;
			}
		}

		return 0;
	}

	const Molecule* AtomContainer::getMolecule() const
		throw()
	{
		return ((AtomContainer *)this)->getMolecule();
	}
*/
	AtomContainer* AtomContainer::getSuperAtomContainer()
		throw()
	{
		for (Composite::AncestorIterator ancestor_it = beginAncestor();
				 !ancestor_it.isEnd(); ++ancestor_it)
		{
			if (RTTI::isKindOf<AtomContainer>(*ancestor_it) == true)
			{
				return (AtomContainer *)&*ancestor_it;
			}
		}

		return 0;
	}

	const AtomContainer* AtomContainer::getSuperAtomContainer() const
		throw()
	{
		return ((AtomContainer *)this)->getSuperAtomContainer();
	}

	AtomContainer* AtomContainer::getAtomContainer(Position position)
		throw()
	{
		for (AtomContainerIterator atom_container_it = ++beginAtomContainer();
				 !atom_container_it.isEnd(); ++atom_container_it)
		{
			if (position-- == 0)
			{
				return &(*atom_container_it);
			}
		}

		return 0;
	}

	const AtomContainer*  AtomContainer::getAtomContainer(Position position) const
		throw()
	{
		return ((AtomContainer *)this)->getAtomContainer(position);
	}

	Atom* AtomContainer::getAtom(Position position)
		throw()
	{
		for (AtomIterator atom_it = beginAtom(); !atom_it.isEnd(); ++atom_it)
		{
			if (position-- == 0)
			{
				return &(*atom_it);
			}
		}

		return 0;
	}

	const Atom* AtomContainer::getAtom(Position position) const
		throw()
	{
		return ((AtomContainer *)this)->getAtom(position);
	}

	Atom* AtomContainer::getAtom(const String& name)
		throw()
	{
		for (AtomIterator atom_it = beginAtom(); !atom_it.isEnd(); ++atom_it)
		{
			if ((*atom_it).getName() == name)
			{
				return &(*atom_it);
			}
		}

		return 0;
	}

	const Atom* AtomContainer::getAtom(const String& name) const
		throw()
	{
		return ((AtomContainer *)this)->getAtom(name);
	}

	Size AtomContainer::countAtomContainers() const
		throw()
	{
		Size size = 0;

		for (AtomContainerConstIterator atom_container_it = ++beginAtomContainer();
				 !atom_container_it.isEnd();++atom_container_it)
		{
			++size;
		}

		return size;
	}

	Size AtomContainer::countAtoms() const
		throw()
	{
		Size size = 0;

		for (AtomConstIterator atom_it = beginAtom(); !atom_it.isEnd(); ++atom_it)
		{
			++size;
		}

		return size;
	}

	Size  AtomContainer::countBonds() const
		throw()
	{
		Size								size = 0;
		AtomConstIterator				atom_it;
		Atom::BondConstIterator	bond_it;

		BALL_FOREACH_BOND(*this, atom_it, bond_it)
		{
			++size;
		}

		return size;
	}

	Size AtomContainer::countInterBonds() const
		throw()
	{
		Size size = 0;
		AtomConstIterator atom_it;
		Atom::BondConstIterator bond_it;

		BALL_FOREACH_INTERBOND(*this, atom_it, bond_it)
		{
			++size;
		}

		return size;
	}

	Size AtomContainer::countIntraBonds() const
		throw()
	{
		Size size = 0;
		AtomConstIterator atom_it;
		Atom::BondConstIterator bond_it;

		BALL_FOREACH_INTRABOND(*this, atom_it, bond_it)
		{
			++size;
		}

		return size;
	}

	void AtomContainer::prepend(Atom& atom)
		throw()
	{
		Composite::prependChild(atom);
	}

	void AtomContainer::append(Atom &atom)
		throw()
	{
		Composite::appendChild(atom);
	}

	void AtomContainer::insert(Atom &atom)
		throw()
	{
		append(atom);
	}

	void AtomContainer::insertBefore(Atom &atom, Composite& before)
		throw()
	{
		before.Composite::insertBefore(atom);
	}

	void AtomContainer::insertAfter(Atom& atom, Composite &after)
		throw()
	{
		after.Composite::insertAfter(atom);
	}

	bool AtomContainer::remove(Atom& atom)
		throw()
	{
		return Composite::removeChild(atom);
	}

	void AtomContainer::prepend(AtomContainer& atom_container)
		throw()
	{
		Composite::prependChild(atom_container);
	}

	void AtomContainer::append(AtomContainer& atom_container)
		throw()
	{
		Composite::appendChild(atom_container);
	}

	void AtomContainer::insert(AtomContainer& atom_container)
		throw()
	{
		append(atom_container);
	}

	void AtomContainer::insertBefore(AtomContainer& atom_container, Composite& before)
		throw()
	{
		before.Composite::insertBefore(atom_container);
	}

	void AtomContainer::insertAfter(AtomContainer& atom_container, Composite& after)
		throw()
	{
		after.Composite::insertAfter(atom_container);
	}

	void AtomContainer::spliceBefore(AtomContainer& atom_container)
		throw()
	{
		Composite::spliceBefore(atom_container);
	}

	void AtomContainer::spliceAfter(AtomContainer& atom_container)
		throw()
	{
		Composite::spliceAfter(atom_container);
	}

	void AtomContainer::splice(AtomContainer& atom_container)
		throw()
	{
		Composite::splice(atom_container);
	}

	bool AtomContainer::remove(AtomContainer& atom_container)
		throw()
	{
		return Composite::removeChild(atom_container);
	}

	void AtomContainer::destroyBonds()
		throw()
	{
		for (AtomIterator atom_it = beginAtom(); !atom_it.isEnd(); ++atom_it)
		{
			(*atom_it).destroyBonds();
		}
	}

	bool AtomContainer::isSubAtomContainerOf(const AtomContainer& atom_container) const
		throw()
	{
		return atom_container.isAncestorOf(*this);
	}

	bool AtomContainer::isSuperAtomContainerOf(const AtomContainer& atom_container) const
		throw()
	{
		return isAncestorOf(atom_container);
	}

	bool AtomContainer::isValid() const
		throw()
	{
		return (Composite::isValid() && PropertyManager::isValid() && name_.isValid());
	}

	void AtomContainer::dump(ostream& s, Size depth) const
		throw()
	{
		BALL_DUMP_STREAM_PREFIX(s);

		Composite::dump(s, depth);

		BALL_DUMP_DEPTH(s, depth);
		s << "  name: " << name_ << endl;

		BALL_DUMP_STREAM_SUFFIX(s);
	}

	bool AtomContainer::applyInterBond(UnaryProcessor<Bond>& processor)
		throw()
	{
		if (processor.start() == false)
		{
			return false;
		}

		Processor::Result		result;
		AtomIterator				atom_it;
		Atom::BondIterator	bond_it;

		BALL_FOREACH_INTERBOND(*this, atom_it, bond_it)
		{
			result = processor(*bond_it);

			if (result <= Processor::BREAK)
			{
				return (result == Processor::BREAK) ? true : false;
			}
		}

		return processor.finish();
	}

	bool AtomContainer::applyIntraBond(UnaryProcessor<Bond> &processor)
		throw()
	{
    if (processor.start() == false)
		{
      return false;
		}

		Processor::Result  result;
		AtomIterator			 atom_it;
		Atom::BondIterator bond_it;

		BALL_FOREACH_INTRABOND(*this, atom_it, bond_it)
		{
			result = processor(*bond_it);

			if (result <= Processor::BREAK)
			{
				return (result == Processor::BREAK) ? true : false;
			}
		}

		return processor.finish();
	}

	bool AtomContainer::operator == (const AtomContainer& atom_container) const
		throw()
	{
		return(Object::operator == (atom_container));
	}

	bool AtomContainer::operator != (const AtomContainer& atom_container) const
		throw()
	{
		return ! (*this == atom_container);
	}

} // namespace BALL
<commit_msg>removed: obsolete code<commit_after>// $Id: atomContainer.C,v 1.11 2001/07/15 20:41:33 oliver Exp $

#include <BALL/KERNEL/atomContainer.h>

#include <BALL/KERNEL/atom.h>
#include <BALL/KERNEL/bond.h>
#include <BALL/KERNEL/forEach.h>
#include <BALL/KERNEL/global.h>
#include <BALL/KERNEL/molecule.h>

using namespace std;

namespace BALL
{

	AtomContainer::AtomContainer()
		throw()
		:	Composite(),
			PropertyManager(),
			name_(BALL_ATOMCONTAINER_DEFAULT_NAME)
	{
	}

	AtomContainer::AtomContainer(const AtomContainer& atom_container, bool deep)
		throw()
		:	Composite(),
			PropertyManager(),
			name_()
	{
		set(atom_container, deep);
	}

	AtomContainer::AtomContainer(const String& name)
		throw()
		:	Composite(),
			PropertyManager(),
			name_(name)
	{
	}

	AtomContainer::~AtomContainer()
		throw()
	{
		destroy();
	}

	void AtomContainer::clear()
		throw()
	{
		Composite::clear();
		PropertyManager::clear();

		name_ = BALL_ATOMCONTAINER_DEFAULT_NAME;
	}

	void AtomContainer::destroy()
		throw()
	{
		Composite::destroy();
		PropertyManager::destroy();

		name_ = BALL_ATOMCONTAINER_DEFAULT_NAME;
	}

	void AtomContainer::persistentWrite(PersistenceManager& pm, const char* name) const
		throw(Exception::GeneralException)
	{
		pm.writeObjectHeader(this, name);
			Composite::persistentWrite(pm);

			pm.writeStorableObject(*(PropertyManager*)this, "PropertyManager");

			pm.writePrimitive(name_, "name_");
		pm.writeObjectTrailer(name);
	}

	void AtomContainer::persistentRead(PersistenceManager& pm)
		throw(Exception::GeneralException)
	{
		pm.checkObjectHeader(RTTI::getStreamName<Composite>());
			Composite::persistentRead(pm);
		pm.checkObjectTrailer(0);

		pm.readStorableObject(*(PropertyManager*)this, "PropertyManager");

		pm.readPrimitive(name_, "name_");
	}

	void AtomContainer::set(const AtomContainer& atom_container, bool deep)
		throw()
	{
    bool clone_them = clone_bonds;
    clone_bonds = false;

		Composite::set(atom_container, deep);
		PropertyManager::set(atom_container);
		name_ = atom_container.name_;

		// clone the bonds only of we are the outmost set method
		// involved!
    if (clone_them && deep)
    {
      BALL::cloneBonds(atom_container, *this);
		}

    clone_bonds = clone_them;
	}

	const AtomContainer& AtomContainer::operator = (const AtomContainer& atom_container)
		throw()
	{
		set(atom_container);
		return *this;
	}

	void AtomContainer::get(AtomContainer& atom_container, bool deep) const
		throw()
	{
		atom_container.set(*this, deep);
	}

	void AtomContainer::swap(AtomContainer& atom_container)
		throw()
	{
		Composite::swap(atom_container);
		PropertyManager::swap(atom_container);
		name_.swap(atom_container.name_);
	}

	void AtomContainer::setName(const String& name)
		throw()
	{
		name_ = name;
	}

	const String& AtomContainer::getName() const
		throw()
	{
		return name_;
	}

	AtomContainer* AtomContainer::getSuperAtomContainer()
		throw()
	{
		for (Composite::AncestorIterator ancestor_it = beginAncestor();
				 !ancestor_it.isEnd(); ++ancestor_it)
		{
			if (RTTI::isKindOf<AtomContainer>(*ancestor_it) == true)
			{
				return (AtomContainer *)&*ancestor_it;
			}
		}

		return 0;
	}

	const AtomContainer* AtomContainer::getSuperAtomContainer() const
		throw()
	{
		return ((AtomContainer *)this)->getSuperAtomContainer();
	}

	AtomContainer* AtomContainer::getAtomContainer(Position position)
		throw()
	{
		for (AtomContainerIterator atom_container_it = ++beginAtomContainer();
				 !atom_container_it.isEnd(); ++atom_container_it)
		{
			if (position-- == 0)
			{
				return &(*atom_container_it);
			}
		}

		return 0;
	}

	const AtomContainer*  AtomContainer::getAtomContainer(Position position) const
		throw()
	{
		return ((AtomContainer *)this)->getAtomContainer(position);
	}

	Atom* AtomContainer::getAtom(Position position)
		throw()
	{
		for (AtomIterator atom_it = beginAtom(); !atom_it.isEnd(); ++atom_it)
		{
			if (position-- == 0)
			{
				return &(*atom_it);
			}
		}

		return 0;
	}

	const Atom* AtomContainer::getAtom(Position position) const
		throw()
	{
		return ((AtomContainer *)this)->getAtom(position);
	}

	Atom* AtomContainer::getAtom(const String& name)
		throw()
	{
		for (AtomIterator atom_it = beginAtom(); !atom_it.isEnd(); ++atom_it)
		{
			if ((*atom_it).getName() == name)
			{
				return &(*atom_it);
			}
		}

		return 0;
	}

	const Atom* AtomContainer::getAtom(const String& name) const
		throw()
	{
		return ((AtomContainer *)this)->getAtom(name);
	}

	Size AtomContainer::countAtomContainers() const
		throw()
	{
		Size size = 0;

		for (AtomContainerConstIterator atom_container_it = ++beginAtomContainer();
				 !atom_container_it.isEnd();++atom_container_it)
		{
			++size;
		}

		return size;
	}

	Size AtomContainer::countAtoms() const
		throw()
	{
		Size size = 0;

		for (AtomConstIterator atom_it = beginAtom(); !atom_it.isEnd(); ++atom_it)
		{
			++size;
		}

		return size;
	}

	Size  AtomContainer::countBonds() const
		throw()
	{
		Size								size = 0;
		AtomConstIterator				atom_it;
		Atom::BondConstIterator	bond_it;

		BALL_FOREACH_BOND(*this, atom_it, bond_it)
		{
			++size;
		}

		return size;
	}

	Size AtomContainer::countInterBonds() const
		throw()
	{
		Size size = 0;
		AtomConstIterator atom_it;
		Atom::BondConstIterator bond_it;

		BALL_FOREACH_INTERBOND(*this, atom_it, bond_it)
		{
			++size;
		}

		return size;
	}

	Size AtomContainer::countIntraBonds() const
		throw()
	{
		Size size = 0;
		AtomConstIterator atom_it;
		Atom::BondConstIterator bond_it;

		BALL_FOREACH_INTRABOND(*this, atom_it, bond_it)
		{
			++size;
		}

		return size;
	}

	void AtomContainer::prepend(Atom& atom)
		throw()
	{
		Composite::prependChild(atom);
	}

	void AtomContainer::append(Atom &atom)
		throw()
	{
		Composite::appendChild(atom);
	}

	void AtomContainer::insert(Atom &atom)
		throw()
	{
		append(atom);
	}

	void AtomContainer::insertBefore(Atom &atom, Composite& before)
		throw()
	{
		before.Composite::insertBefore(atom);
	}

	void AtomContainer::insertAfter(Atom& atom, Composite &after)
		throw()
	{
		after.Composite::insertAfter(atom);
	}

	bool AtomContainer::remove(Atom& atom)
		throw()
	{
		return Composite::removeChild(atom);
	}

	void AtomContainer::prepend(AtomContainer& atom_container)
		throw()
	{
		Composite::prependChild(atom_container);
	}

	void AtomContainer::append(AtomContainer& atom_container)
		throw()
	{
		Composite::appendChild(atom_container);
	}

	void AtomContainer::insert(AtomContainer& atom_container)
		throw()
	{
		append(atom_container);
	}

	void AtomContainer::insertBefore(AtomContainer& atom_container, Composite& before)
		throw()
	{
		before.Composite::insertBefore(atom_container);
	}

	void AtomContainer::insertAfter(AtomContainer& atom_container, Composite& after)
		throw()
	{
		after.Composite::insertAfter(atom_container);
	}

	void AtomContainer::spliceBefore(AtomContainer& atom_container)
		throw()
	{
		Composite::spliceBefore(atom_container);
	}

	void AtomContainer::spliceAfter(AtomContainer& atom_container)
		throw()
	{
		Composite::spliceAfter(atom_container);
	}

	void AtomContainer::splice(AtomContainer& atom_container)
		throw()
	{
		Composite::splice(atom_container);
	}

	bool AtomContainer::remove(AtomContainer& atom_container)
		throw()
	{
		return Composite::removeChild(atom_container);
	}

	void AtomContainer::destroyBonds()
		throw()
	{
		for (AtomIterator atom_it = beginAtom(); !atom_it.isEnd(); ++atom_it)
		{
			(*atom_it).destroyBonds();
		}
	}

	bool AtomContainer::isSubAtomContainerOf(const AtomContainer& atom_container) const
		throw()
	{
		return atom_container.isAncestorOf(*this);
	}

	bool AtomContainer::isSuperAtomContainerOf(const AtomContainer& atom_container) const
		throw()
	{
		return isAncestorOf(atom_container);
	}

	bool AtomContainer::isValid() const
		throw()
	{
		return (Composite::isValid() && PropertyManager::isValid() && name_.isValid());
	}

	void AtomContainer::dump(ostream& s, Size depth) const
		throw()
	{
		BALL_DUMP_STREAM_PREFIX(s);

		Composite::dump(s, depth);

		BALL_DUMP_DEPTH(s, depth);
		s << "  name: " << name_ << endl;

		BALL_DUMP_STREAM_SUFFIX(s);
	}

	bool AtomContainer::applyInterBond(UnaryProcessor<Bond>& processor)
		throw()
	{
		if (processor.start() == false)
		{
			return false;
		}

		Processor::Result		result;
		AtomIterator				atom_it;
		Atom::BondIterator	bond_it;

		BALL_FOREACH_INTERBOND(*this, atom_it, bond_it)
		{
			result = processor(*bond_it);

			if (result <= Processor::BREAK)
			{
				return (result == Processor::BREAK) ? true : false;
			}
		}

		return processor.finish();
	}

	bool AtomContainer::applyIntraBond(UnaryProcessor<Bond> &processor)
		throw()
	{
    if (processor.start() == false)
		{
      return false;
		}

		Processor::Result  result;
		AtomIterator			 atom_it;
		Atom::BondIterator bond_it;

		BALL_FOREACH_INTRABOND(*this, atom_it, bond_it)
		{
			result = processor(*bond_it);

			if (result <= Processor::BREAK)
			{
				return (result == Processor::BREAK) ? true : false;
			}
		}

		return processor.finish();
	}

	bool AtomContainer::operator == (const AtomContainer& atom_container) const
		throw()
	{
		return(Object::operator == (atom_container));
	}

	bool AtomContainer::operator != (const AtomContainer& atom_container) const
		throw()
	{
		return ! (*this == atom_container);
	}

} // namespace BALL
<|endoftext|>


<commit_before>/*
 * Copyright © 2015 Christian Persch
 *
 * 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 General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

/**
 * SECTION: vte-regex
 * @short_description: Regex for matching and searching. Uses PCRE2 internally.
 *
 * Since: 0.44
 */

#include "config.h"

#include "vtemacros.h"
#include "vteenums.h"
#include "vteregex.h"

#ifdef WITH_PCRE2
#include "vtepcre2.h"
#endif /* WITH_PCRE2 */

#include "vteregexinternal.hh"

struct _VteRegex {
        volatile int ref_count;
#ifdef WITH_PCRE2
        pcre2_code_8 *code;
#endif /* WITH_PCRE2 */
};

#ifdef WITH_PCRE2
#define DEFAULT_COMPILE_OPTIONS (PCRE2_UTF)
#define JIT_OPTIONS (PCRE2_JIT_COMPLETE)
#define DEFAULT_MATCH_OPTIONS (0)
#else
#define DEFAULT_COMPILE_OPTIONS (0
#define JIT_OPTIONS (0)
#define DEFAULT_MATCH_OPTIONS (0)
#endif /* WITH_PCRE2 */

#ifdef WITH_PCRE2

static VteRegex *
regex_new(pcre2_code_8 *code)
{
        VteRegex *regex;

        regex = g_slice_new(VteRegex);
        regex->ref_count = 1;
        regex->code = code;

        return regex;
}

static void
regex_free(VteRegex *regex)
{
        pcre2_code_free_8(regex->code);
        g_slice_free(VteRegex, regex);
}

static gboolean
set_gerror_from_pcre_error(int errcode,
                           GError **error)
{
        PCRE2_UCHAR8 buf[128];
        int n;

        n = pcre2_get_error_message_8(errcode, buf, sizeof (buf));
        g_assert(n >= 0);
        g_set_error_literal(error, VTE_REGEX_ERROR, errcode, (const char*)buf);
        return FALSE;
}

#else

static gboolean
set_unsupported_error(GError **error)
{
        g_set_error_literal(error, VTE_REGEX_ERROR, VTE_REGEX_ERROR_NOT_SUPPORTED,
                            "PCRE2 not supported");
        return FALSE;
}

#endif /* WITH_PCRE2 */

G_DEFINE_BOXED_TYPE(VteRegex, vte_regex,
                    vte_regex_ref, (GBoxedFreeFunc)vte_regex_unref)

G_DEFINE_QUARK(vte-regex-error, vte_regex_error)

/**
 * vte_regex_ref:
 * @regex: (transfer none): a #VteRegex
 *
 * Increases the reference count of @regex by one.
 *
 * Returns: @regex
 */
VteRegex *
vte_regex_ref(VteRegex *regex)
{
        g_return_val_if_fail (regex, NULL);

#ifdef WITH_PCRE2
        g_atomic_int_inc (&regex->ref_count);
#endif
        return regex;
}

/**
 * vte_regex_ref:
 * @regex: (transfer full): a #VteRegex
 *
 * Decreases the reference count of @regex by one, and frees @regex
 * if the refcount reaches zero.
 *
 * Returns: %NULL
 */
VteRegex *
vte_regex_unref(VteRegex *regex)
{
        g_return_val_if_fail (regex, NULL);

#ifdef WITH_PCRE2
        if (g_atomic_int_dec_and_test (&regex->ref_count))
                regex_free (regex);
#endif
        return NULL;
}

/**
 * vte_regex_new:
 * @pattern: a regex pattern string
 * @pattern_length: the length of @pattern in bytes, or -1 if the
 *  string is NUL-terminated and the length is unknown
 * @flags: PCRE2 compile flags
 * @error: (allow-none): return location for a #GError, or %NULL
 *
 * Compiles @pattern into a regex. See man:pcre2pattern(3) for information
 * about the supported regex language.
 *
 * The regex will be compiled using %PCRE2_UTF and possibly other flags, in
 * addition to the flags supplied in @flags.
 *
 * Returns: (transfer full): a newly created #VteRegex, or %NULL with @error filled in
 */
VteRegex *
vte_regex_new(const char *pattern,
              gssize      pattern_length,
              guint32     flags,
              GError    **error)
{
#ifdef WITH_PCRE2
        pcre2_code_8 *code;
        int r, errcode;
        guint32 v;
        PCRE2_SIZE erroffset;

        g_return_val_if_fail(pattern != NULL, NULL);
        g_return_val_if_fail(pattern_length >= -1, NULL);
        g_return_val_if_fail(error == NULL || *error == NULL, NULL);

        /* Check library compatibility */
        r = pcre2_config_8(PCRE2_CONFIG_UNICODE, &v);
        if (r != 0 || v != 1) {
                g_set_error(error, VTE_REGEX_ERROR, VTE_REGEX_ERROR_INCOMPATIBLE,
                            "PCRE2 library was built without unicode support");
                return NULL;
        }

        code = pcre2_compile_8((PCRE2_SPTR8)pattern,
                               pattern_length >= 0 ? pattern_length : PCRE2_ZERO_TERMINATED,
                               (uint32_t)flags |
                               PCRE2_UTF |
                               (flags & PCRE2_UTF ? PCRE2_NO_UTF_CHECK : 0) |
                               PCRE2_NEVER_BACKSLASH_C,
                               &errcode, &erroffset,
                               NULL);

        if (code == 0) {
                set_gerror_from_pcre_error(errcode, error);
                g_prefix_error(error, "Failed to compile pattern to regex at %" G_GSIZE_FORMAT ":",
                               erroffset);
                return NULL;
        }

        return regex_new(code);
#else
        set_unsupported_error(error);
        return NULL;
#endif /* WITH_PCRE2 */
}

#if 0
/*
 * vte_regex_new_pcre:
 * @code: a #pcre2_code_8
 *
 * Creates a new #VteRegex for @code. @code must have been compiled with
 * %PCRE2_UTF and %PCRE2_NEVER_BACKSLASH_C.
 *
 * Returns: (transfer full): a newly created #VteRegex, or %NULL if VTE
 *   was not compiled with PCRE2 support.
 */
VteRegex *
vte_regex_new_pcre(pcre2_code_8 *code,
                   GError      **error)
{
#ifdef WITH_PCRE2
        guint32 flags;

        g_return_val_if_fail(code != NULL, NULL);
        g_return_val_if_fail(error == NULL || *error == NULL, NULL);

        pcre2_pattern_info_8(code, PCRE2_INFO_ALLOPTIONS, &flags);
        g_return_val_if_fail(flags & PCRE2_UTF, NULL);
        g_return_val_if_fail(flags & PCRE2_NEVER_BACKSLASH_C, NULL);

        return regex_new(code);
#else
        set_unsupported_error(error);
        return NULL;
#endif
}
#endif

#ifdef WITH_PCRE2
/*
 * _vte_regex_get_pcre:
 * @regex: a #VteRegex
 *
 *
 * Returns: the #pcre2_code_8 from @regex
 */
const pcre2_code_8 *
_vte_regex_get_pcre(VteRegex *regex)
{
#ifdef WITH_PCRE2
        g_return_val_if_fail(regex != NULL, NULL);

        return regex->code;
#else
        return NULL;
#endif
}
#endif

/**
 * vte_regex_jit:
 * @regex: a #VteRegex
 *
 * If the platform supports JITing, JIT compiles @regex.
 *
 * Returns: %TRUE if JITing succeeded, or %FALSE with @error filled in
 */
gboolean
vte_regex_jit(VteRegex *regex,
              guint     flags,
              GError  **error)
{
#ifdef WITH_PCRE2
        int r;

        g_return_val_if_fail(regex != NULL, FALSE);

        r = pcre2_jit_compile_8(regex->code, flags);

        return set_gerror_from_pcre_error(r, error);
#else
        return set_unsupported_error(error);
#endif /* WITH_PCRE2 */
}

/*
 * _vte_regex_get_jited:
 *
 * Note: We can't tell if the regex has been JITed for a particular mode,
 * just if it has been JITed at all.
 *
 * Returns: %TRUE iff the regex has been JITed
 */
gboolean
_vte_regex_get_jited(VteRegex *regex)
{
#ifdef WITH_PCRE2
        PCRE2_SIZE s;
        int r;

        g_return_val_if_fail(regex != NULL, FALSE);

        r = pcre2_pattern_info_8(regex->code, PCRE2_INFO_JITSIZE, &s);

        return r == 0 && s != 0;
#else
        return FALSE;
#endif
}
<commit_msg>regex: Fix pcre2_jit_compile return value check<commit_after>/*
 * Copyright © 2015 Christian Persch
 *
 * 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 General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

/**
 * SECTION: vte-regex
 * @short_description: Regex for matching and searching. Uses PCRE2 internally.
 *
 * Since: 0.44
 */

#include "config.h"

#include "vtemacros.h"
#include "vteenums.h"
#include "vteregex.h"

#ifdef WITH_PCRE2
#include "vtepcre2.h"
#endif /* WITH_PCRE2 */

#include "vteregexinternal.hh"

struct _VteRegex {
        volatile int ref_count;
#ifdef WITH_PCRE2
        pcre2_code_8 *code;
#endif /* WITH_PCRE2 */
};

#ifdef WITH_PCRE2
#define DEFAULT_COMPILE_OPTIONS (PCRE2_UTF)
#define JIT_OPTIONS (PCRE2_JIT_COMPLETE)
#define DEFAULT_MATCH_OPTIONS (0)
#else
#define DEFAULT_COMPILE_OPTIONS (0
#define JIT_OPTIONS (0)
#define DEFAULT_MATCH_OPTIONS (0)
#endif /* WITH_PCRE2 */

#ifdef WITH_PCRE2

static VteRegex *
regex_new(pcre2_code_8 *code)
{
        VteRegex *regex;

        regex = g_slice_new(VteRegex);
        regex->ref_count = 1;
        regex->code = code;

        return regex;
}

static void
regex_free(VteRegex *regex)
{
        pcre2_code_free_8(regex->code);
        g_slice_free(VteRegex, regex);
}

static gboolean
set_gerror_from_pcre_error(int errcode,
                           GError **error)
{
        PCRE2_UCHAR8 buf[128];
        int n;

        n = pcre2_get_error_message_8(errcode, buf, sizeof (buf));
        g_assert(n >= 0);
        g_set_error_literal(error, VTE_REGEX_ERROR, errcode, (const char*)buf);
        return FALSE;
}

#else

static gboolean
set_unsupported_error(GError **error)
{
        g_set_error_literal(error, VTE_REGEX_ERROR, VTE_REGEX_ERROR_NOT_SUPPORTED,
                            "PCRE2 not supported");
        return FALSE;
}

#endif /* WITH_PCRE2 */

G_DEFINE_BOXED_TYPE(VteRegex, vte_regex,
                    vte_regex_ref, (GBoxedFreeFunc)vte_regex_unref)

G_DEFINE_QUARK(vte-regex-error, vte_regex_error)

/**
 * vte_regex_ref:
 * @regex: (transfer none): a #VteRegex
 *
 * Increases the reference count of @regex by one.
 *
 * Returns: @regex
 */
VteRegex *
vte_regex_ref(VteRegex *regex)
{
        g_return_val_if_fail (regex, NULL);

#ifdef WITH_PCRE2
        g_atomic_int_inc (&regex->ref_count);
#endif
        return regex;
}

/**
 * vte_regex_ref:
 * @regex: (transfer full): a #VteRegex
 *
 * Decreases the reference count of @regex by one, and frees @regex
 * if the refcount reaches zero.
 *
 * Returns: %NULL
 */
VteRegex *
vte_regex_unref(VteRegex *regex)
{
        g_return_val_if_fail (regex, NULL);

#ifdef WITH_PCRE2
        if (g_atomic_int_dec_and_test (&regex->ref_count))
                regex_free (regex);
#endif
        return NULL;
}

/**
 * vte_regex_new:
 * @pattern: a regex pattern string
 * @pattern_length: the length of @pattern in bytes, or -1 if the
 *  string is NUL-terminated and the length is unknown
 * @flags: PCRE2 compile flags
 * @error: (allow-none): return location for a #GError, or %NULL
 *
 * Compiles @pattern into a regex. See man:pcre2pattern(3) for information
 * about the supported regex language.
 *
 * The regex will be compiled using %PCRE2_UTF and possibly other flags, in
 * addition to the flags supplied in @flags.
 *
 * Returns: (transfer full): a newly created #VteRegex, or %NULL with @error filled in
 */
VteRegex *
vte_regex_new(const char *pattern,
              gssize      pattern_length,
              guint32     flags,
              GError    **error)
{
#ifdef WITH_PCRE2
        pcre2_code_8 *code;
        int r, errcode;
        guint32 v;
        PCRE2_SIZE erroffset;

        g_return_val_if_fail(pattern != NULL, NULL);
        g_return_val_if_fail(pattern_length >= -1, NULL);
        g_return_val_if_fail(error == NULL || *error == NULL, NULL);

        /* Check library compatibility */
        r = pcre2_config_8(PCRE2_CONFIG_UNICODE, &v);
        if (r != 0 || v != 1) {
                g_set_error(error, VTE_REGEX_ERROR, VTE_REGEX_ERROR_INCOMPATIBLE,
                            "PCRE2 library was built without unicode support");
                return NULL;
        }

        code = pcre2_compile_8((PCRE2_SPTR8)pattern,
                               pattern_length >= 0 ? pattern_length : PCRE2_ZERO_TERMINATED,
                               (uint32_t)flags |
                               PCRE2_UTF |
                               (flags & PCRE2_UTF ? PCRE2_NO_UTF_CHECK : 0) |
                               PCRE2_NEVER_BACKSLASH_C,
                               &errcode, &erroffset,
                               NULL);

        if (code == 0) {
                set_gerror_from_pcre_error(errcode, error);
                g_prefix_error(error, "Failed to compile pattern to regex at %" G_GSIZE_FORMAT ":",
                               erroffset);
                return NULL;
        }

        return regex_new(code);
#else
        set_unsupported_error(error);
        return NULL;
#endif /* WITH_PCRE2 */
}

#if 0
/*
 * vte_regex_new_pcre:
 * @code: a #pcre2_code_8
 *
 * Creates a new #VteRegex for @code. @code must have been compiled with
 * %PCRE2_UTF and %PCRE2_NEVER_BACKSLASH_C.
 *
 * Returns: (transfer full): a newly created #VteRegex, or %NULL if VTE
 *   was not compiled with PCRE2 support.
 */
VteRegex *
vte_regex_new_pcre(pcre2_code_8 *code,
                   GError      **error)
{
#ifdef WITH_PCRE2
        guint32 flags;

        g_return_val_if_fail(code != NULL, NULL);
        g_return_val_if_fail(error == NULL || *error == NULL, NULL);

        pcre2_pattern_info_8(code, PCRE2_INFO_ALLOPTIONS, &flags);
        g_return_val_if_fail(flags & PCRE2_UTF, NULL);
        g_return_val_if_fail(flags & PCRE2_NEVER_BACKSLASH_C, NULL);

        return regex_new(code);
#else
        set_unsupported_error(error);
        return NULL;
#endif
}
#endif

#ifdef WITH_PCRE2
/*
 * _vte_regex_get_pcre:
 * @regex: a #VteRegex
 *
 *
 * Returns: the #pcre2_code_8 from @regex
 */
const pcre2_code_8 *
_vte_regex_get_pcre(VteRegex *regex)
{
#ifdef WITH_PCRE2
        g_return_val_if_fail(regex != NULL, NULL);

        return regex->code;
#else
        return NULL;
#endif
}
#endif

/**
 * vte_regex_jit:
 * @regex: a #VteRegex
 *
 * If the platform supports JITing, JIT compiles @regex.
 *
 * Returns: %TRUE if JITing succeeded, or %FALSE with @error filled in
 */
gboolean
vte_regex_jit(VteRegex *regex,
              guint     flags,
              GError  **error)
{
#ifdef WITH_PCRE2
        int r;

        g_return_val_if_fail(regex != NULL, FALSE);

        r = pcre2_jit_compile_8(regex->code, flags);
        if (r < 0)
                return set_gerror_from_pcre_error(r, error);

        return TRUE;
#else
        return set_unsupported_error(error);
#endif /* WITH_PCRE2 */
}

/*
 * _vte_regex_get_jited:
 *
 * Note: We can't tell if the regex has been JITed for a particular mode,
 * just if it has been JITed at all.
 *
 * Returns: %TRUE iff the regex has been JITed
 */
gboolean
_vte_regex_get_jited(VteRegex *regex)
{
#ifdef WITH_PCRE2
        PCRE2_SIZE s;
        int r;

        g_return_val_if_fail(regex != NULL, FALSE);

        r = pcre2_pattern_info_8(regex->code, PCRE2_INFO_JITSIZE, &s);

        return r == 0 && s != 0;
#else
        return FALSE;
#endif
}
<|endoftext|>


<commit_before>//
// Aspia Project
// Copyright (C) 2020 Dmitry Chapyshev <dmitry@aspia.ru>
//
// 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 <https://www.gnu.org/licenses/>.
//

#include "base/sys_info.h"

#include "base/logging.h"

namespace base {

//static
std::string SysInfo::operatingSystemName()
{
    NOTIMPLEMENTED();
    return std::string();
}

// static
std::string SysInfo::operatingSystemVersion()
{
    NOTIMPLEMENTED();
    return std::string();
}

// static
std::string SysInfo::operatingSystemArchitecture()
{
    NOTIMPLEMENTED();
    return std::string();
}

// static
std::string SysInfo::operatingSystemDir()
{
    NOTIMPLEMENTED();
    return std::string();
}

// static
uint64_t SysInfo::uptime()
{
    NOTIMPLEMENTED();
    return 0;
}

// static
std::string SysInfo::computerName()
{
    NOTIMPLEMENTED();
    return std::string();
}

// static
std::string SysInfo::computerDomain()
{
    NOTIMPLEMENTED();
    return std::string();
}

// static
std::string SysInfo::computerWorkgroup()
{
    NOTIMPLEMENTED();
    return std::string();
}

// static
int SysInfo::processorPackages()
{
    NOTIMPLEMENTED();
    return 0;
}

// static
int SysInfo::processorCores()
{
    NOTIMPLEMENTED();
    return 0;
}

// static
int SysInfo::processorThreads()
{
    NOTIMPLEMENTED();
    return 0;
}

} // namespace base
<commit_msg>Implement operatingSystemName/operatingSystemVersion/uptime/computerName methods for Linux.<commit_after>//
// Aspia Project
// Copyright (C) 2020 Dmitry Chapyshev <dmitry@aspia.ru>
//
// 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 <https://www.gnu.org/licenses/>.
//

#include "base/sys_info.h"

#include "base/logging.h"

#include <sys/param.h>
#include <sys/sysinfo.h>
#include <sys/utsname.h>
#include <unistd.h>

namespace base {

//static
std::string SysInfo::operatingSystemName()
{
    struct utsname info;
    if (uname(&info) < 0)
        return std::string();

    return std::string(info.sysname);
}

// static
std::string SysInfo::operatingSystemVersion()
{
    struct utsname info;
    if (uname(&info) < 0)
        return std::string();

    return std::string(info.release);
}

// static
std::string SysInfo::operatingSystemArchitecture()
{
    NOTIMPLEMENTED();
    return std::string();
}

// static
std::string SysInfo::operatingSystemDir()
{
    NOTIMPLEMENTED();
    return std::string();
}

// static
uint64_t SysInfo::uptime()
{
    struct sysinfo info;
    if (sysinfo(&info) < 0)
        return 0;

    return info.uptime;
}

// static
std::string SysInfo::computerName()
{
    char buffer[256];
    if (gethostname(buffer, std::size(buffer)) < 0)
        return std::string();

    return std::string(buffer);
}

// static
std::string SysInfo::computerDomain()
{
    NOTIMPLEMENTED();
    return std::string();
}

// static
std::string SysInfo::computerWorkgroup()
{
    NOTIMPLEMENTED();
    return std::string();
}

// static
int SysInfo::processorPackages()
{
    NOTIMPLEMENTED();
    return 0;
}

// static
int SysInfo::processorCores()
{
    NOTIMPLEMENTED();
    return 0;
}

// static
int SysInfo::processorThreads()
{
    NOTIMPLEMENTED();
    return 0;
}

} // namespace base
<|endoftext|>


<commit_before>/*
 *  Copyright (c) 2014 The WebM project authors. All Rights Reserved.
 *
 *  Use of this source code is governed by a BSD-style license
 *  that can be found in the LICENSE file in the root of the source
 *  tree. An additional intellectual property rights grant can be found
 *  in the file PATENTS.  All contributing project authors may
 *  be found in the AUTHORS file in the root of the source tree.
 */

#include <cstdio>
#include <cstdlib>
#include <string>
#include <vector>
#include "third_party/googletest/src/include/gtest/gtest.h"
#include "./vpx_config.h"
#include "test/codec_factory.h"
#include "test/decode_test_driver.h"
#include "test/ivf_video_source.h"
#include "test/util.h"
#if CONFIG_WEBM_IO
#include "test/webm_video_source.h"
#endif
#include "vpx_mem/vpx_mem.h"

namespace {

struct DecodeParam {
  int threads;
  const char *filename;
};

std::ostream &operator<<(std::ostream &os, const DecodeParam &dp) {
  return os << "threads: " << dp.threads << " file: " << dp.filename;
}

class InvalidFileTest
    : public ::libvpx_test::DecoderTest,
      public ::libvpx_test::CodecTestWithParam<DecodeParam> {
 protected:
  InvalidFileTest() : DecoderTest(GET_PARAM(0)), res_file_(NULL) {}

  virtual ~InvalidFileTest() {
    if (res_file_ != NULL)
      fclose(res_file_);
  }

  void OpenResFile(const std::string &res_file_name_) {
    res_file_ = libvpx_test::OpenTestDataFile(res_file_name_);
    ASSERT_TRUE(res_file_ != NULL) << "Result file open failed. Filename: "
        << res_file_name_;
  }

  virtual bool HandleDecodeResult(
      const vpx_codec_err_t res_dec,
      const libvpx_test::CompressedVideoSource &video,
      libvpx_test::Decoder *decoder) {
    EXPECT_TRUE(res_file_ != NULL);
    int expected_res_dec;

    // Read integer result.
    const int res = fscanf(res_file_, "%d", &expected_res_dec);
    EXPECT_NE(res, EOF) << "Read result data failed";

    // Check results match.
    EXPECT_EQ(expected_res_dec, res_dec)
        << "Results don't match: frame number = " << video.frame_number()
        << ". (" << decoder->DecodeError() << ")";

    return !HasFailure();
  }

  void RunTest() {
    const DecodeParam input = GET_PARAM(1);
    libvpx_test::CompressedVideoSource *video = NULL;
    vpx_codec_dec_cfg_t cfg = {0};
    cfg.threads = input.threads;
    const std::string filename = input.filename;

    // Open compressed video file.
    if (filename.substr(filename.length() - 3, 3) == "ivf") {
      video = new libvpx_test::IVFVideoSource(filename);
    } else if (filename.substr(filename.length() - 4, 4) == "webm") {
#if CONFIG_WEBM_IO
      video = new libvpx_test::WebMVideoSource(filename);
#else
      fprintf(stderr, "WebM IO is disabled, skipping test vector %s\n",
              filename.c_str());
      return;
#endif
    }
    video->Init();

    // Construct result file name. The file holds a list of expected integer
    // results, one for each decoded frame.  Any result that doesn't match
    // the files list will cause a test failure.
    const std::string res_filename = filename + ".res";
    OpenResFile(res_filename);

    // Decode frame, and check the md5 matching.
    ASSERT_NO_FATAL_FAILURE(RunLoop(video, cfg));
    delete video;
  }

 private:
  FILE *res_file_;
};

TEST_P(InvalidFileTest, ReturnCode) {
  RunTest();
}

const DecodeParam kVP9InvalidFileTests[] = {
  {1, "invalid-vp90-02-v2.webm"},
  {1, "invalid-vp90-2-00-quantizer-00.webm.ivf.s5861_r01-05_b6-.v2.ivf"},
  {1, "invalid-vp90-03-v2.webm"},
  {1, "invalid-vp90-2-00-quantizer-11.webm.ivf.s52984_r01-05_b6-.ivf"},
  {1, "invalid-vp90-2-00-quantizer-11.webm.ivf.s52984_r01-05_b6-z.ivf"},
};

VP9_INSTANTIATE_TEST_CASE(InvalidFileTest,
                          ::testing::ValuesIn(kVP9InvalidFileTests));

// This class will include test vectors that are expected to fail
// peek. However they are still expected to have no fatal failures.
class InvalidFileInvalidPeekTest : public InvalidFileTest {
 protected:
  InvalidFileInvalidPeekTest() : InvalidFileTest() {}
  virtual void HandlePeekResult(libvpx_test::Decoder *const decoder,
                                libvpx_test::CompressedVideoSource *video,
                                const vpx_codec_err_t res_peek) {}
};

TEST_P(InvalidFileInvalidPeekTest, ReturnCode) {
  RunTest();
}

const DecodeParam kVP9InvalidFileInvalidPeekTests[] = {
  {1, "invalid-vp90-01-v2.webm"},
};

VP9_INSTANTIATE_TEST_CASE(InvalidFileInvalidPeekTest,
                          ::testing::ValuesIn(kVP9InvalidFileInvalidPeekTests));

const DecodeParam kMultiThreadedVP9InvalidFileTests[] = {
  {4, "invalid-vp90-2-08-tile_1x4_frame_parallel_all_key.webm"},
};

INSTANTIATE_TEST_CASE_P(
    VP9MultiThreaded, InvalidFileTest,
    ::testing::Combine(
        ::testing::Values(
            static_cast<const libvpx_test::CodecFactory*>(&libvpx_test::kVP9)),
        ::testing::ValuesIn(kMultiThreadedVP9InvalidFileTests)));
}  // namespace
<commit_msg>invalid_file_test.cc: remove unused param warnings<commit_after>/*
 *  Copyright (c) 2014 The WebM project authors. All Rights Reserved.
 *
 *  Use of this source code is governed by a BSD-style license
 *  that can be found in the LICENSE file in the root of the source
 *  tree. An additional intellectual property rights grant can be found
 *  in the file PATENTS.  All contributing project authors may
 *  be found in the AUTHORS file in the root of the source tree.
 */

#include <cstdio>
#include <cstdlib>
#include <string>
#include <vector>
#include "third_party/googletest/src/include/gtest/gtest.h"
#include "./vpx_config.h"
#include "test/codec_factory.h"
#include "test/decode_test_driver.h"
#include "test/ivf_video_source.h"
#include "test/util.h"
#if CONFIG_WEBM_IO
#include "test/webm_video_source.h"
#endif
#include "vpx_mem/vpx_mem.h"

namespace {

struct DecodeParam {
  int threads;
  const char *filename;
};

std::ostream &operator<<(std::ostream &os, const DecodeParam &dp) {
  return os << "threads: " << dp.threads << " file: " << dp.filename;
}

class InvalidFileTest
    : public ::libvpx_test::DecoderTest,
      public ::libvpx_test::CodecTestWithParam<DecodeParam> {
 protected:
  InvalidFileTest() : DecoderTest(GET_PARAM(0)), res_file_(NULL) {}

  virtual ~InvalidFileTest() {
    if (res_file_ != NULL)
      fclose(res_file_);
  }

  void OpenResFile(const std::string &res_file_name_) {
    res_file_ = libvpx_test::OpenTestDataFile(res_file_name_);
    ASSERT_TRUE(res_file_ != NULL) << "Result file open failed. Filename: "
        << res_file_name_;
  }

  virtual bool HandleDecodeResult(
      const vpx_codec_err_t res_dec,
      const libvpx_test::CompressedVideoSource &video,
      libvpx_test::Decoder *decoder) {
    EXPECT_TRUE(res_file_ != NULL);
    int expected_res_dec;

    // Read integer result.
    const int res = fscanf(res_file_, "%d", &expected_res_dec);
    EXPECT_NE(res, EOF) << "Read result data failed";

    // Check results match.
    EXPECT_EQ(expected_res_dec, res_dec)
        << "Results don't match: frame number = " << video.frame_number()
        << ". (" << decoder->DecodeError() << ")";

    return !HasFailure();
  }

  void RunTest() {
    const DecodeParam input = GET_PARAM(1);
    libvpx_test::CompressedVideoSource *video = NULL;
    vpx_codec_dec_cfg_t cfg = {0};
    cfg.threads = input.threads;
    const std::string filename = input.filename;

    // Open compressed video file.
    if (filename.substr(filename.length() - 3, 3) == "ivf") {
      video = new libvpx_test::IVFVideoSource(filename);
    } else if (filename.substr(filename.length() - 4, 4) == "webm") {
#if CONFIG_WEBM_IO
      video = new libvpx_test::WebMVideoSource(filename);
#else
      fprintf(stderr, "WebM IO is disabled, skipping test vector %s\n",
              filename.c_str());
      return;
#endif
    }
    video->Init();

    // Construct result file name. The file holds a list of expected integer
    // results, one for each decoded frame.  Any result that doesn't match
    // the files list will cause a test failure.
    const std::string res_filename = filename + ".res";
    OpenResFile(res_filename);

    // Decode frame, and check the md5 matching.
    ASSERT_NO_FATAL_FAILURE(RunLoop(video, cfg));
    delete video;
  }

 private:
  FILE *res_file_;
};

TEST_P(InvalidFileTest, ReturnCode) {
  RunTest();
}

const DecodeParam kVP9InvalidFileTests[] = {
  {1, "invalid-vp90-02-v2.webm"},
  {1, "invalid-vp90-2-00-quantizer-00.webm.ivf.s5861_r01-05_b6-.v2.ivf"},
  {1, "invalid-vp90-03-v2.webm"},
  {1, "invalid-vp90-2-00-quantizer-11.webm.ivf.s52984_r01-05_b6-.ivf"},
  {1, "invalid-vp90-2-00-quantizer-11.webm.ivf.s52984_r01-05_b6-z.ivf"},
};

VP9_INSTANTIATE_TEST_CASE(InvalidFileTest,
                          ::testing::ValuesIn(kVP9InvalidFileTests));

// This class will include test vectors that are expected to fail
// peek. However they are still expected to have no fatal failures.
class InvalidFileInvalidPeekTest : public InvalidFileTest {
 protected:
  InvalidFileInvalidPeekTest() : InvalidFileTest() {}
  virtual void HandlePeekResult(libvpx_test::Decoder* /*decoder*/,
                                libvpx_test::CompressedVideoSource* /*video*/,
                                const vpx_codec_err_t /*res_peek*/) {}
};

TEST_P(InvalidFileInvalidPeekTest, ReturnCode) {
  RunTest();
}

const DecodeParam kVP9InvalidFileInvalidPeekTests[] = {
  {1, "invalid-vp90-01-v2.webm"},
};

VP9_INSTANTIATE_TEST_CASE(InvalidFileInvalidPeekTest,
                          ::testing::ValuesIn(kVP9InvalidFileInvalidPeekTests));

const DecodeParam kMultiThreadedVP9InvalidFileTests[] = {
  {4, "invalid-vp90-2-08-tile_1x4_frame_parallel_all_key.webm"},
};

INSTANTIATE_TEST_CASE_P(
    VP9MultiThreaded, InvalidFileTest,
    ::testing::Combine(
        ::testing::Values(
            static_cast<const libvpx_test::CodecFactory*>(&libvpx_test::kVP9)),
        ::testing::ValuesIn(kMultiThreadedVP9InvalidFileTests)));
}  // namespace
<|endoftext|>


<commit_before>/*
 * IceWM
 *
 * Copyright (C) 1997-2001 Marko Macek
 */
#include "config.h"

#include "wmbutton.h"

#include "wmframe.h"
#include "wmtitle.h"
#include "yxapp.h"
#include "yicon.h"
#include "yprefs.h"
#include "prefs.h"
#include "wpixmaps.h"

static YColor *titleButtonBg = 0;
static YColor *titleButtonFg = 0;

//!!! get rid of this
extern YColor *activeTitleBarBg;
extern YColor *inactiveTitleBarBg;

YFrameButton::YFrameButton(YWindow *parent,
                           bool right,
                           YFrameWindow *frame,
                           YAction action,
                           YAction action2):
    YButton(desktop, actionNull),
    fFrame(frame),
    fRight(right),
    fAction(action),
    fAction2(action2)
{
    reparent(parent, 0, 0);
    if (titleButtonBg == 0)
        titleButtonBg = new YColor(clrNormalTitleButton);
    if (titleButtonFg == 0)
        titleButtonFg = new YColor(clrNormalTitleButtonText);

    if (fAction == actionNull)
        setPopup(frame->windowMenu());
    if (right)
        setWinGravity(NorthEastGravity);

    setSize(0,0);
}

YFrameButton::~YFrameButton() {
}

void YFrameButton::handleButton(const XButtonEvent &button) {
    if (button.type == ButtonPress &&
        (buttonRaiseMask & (1 << (button.button - 1))))
    {
        if (!(button.state & ControlMask) && raiseOnClickButton) {
            getFrame()->activate();
            if (raiseOnClickButton && fAction != actionDepth)
                getFrame()->wmRaise();
        }
    }
    YButton::handleButton(button);
}

void YFrameButton::handleClick(const XButtonEvent &up, int count) {
    if (fAction == actionNull && up.button == 1) {
        if ((count % 2) == 0) {
            setArmed(false, false);
            getFrame()->wmClose();
        }
    } else if (up.button == 3 && (KEY_MODMASK(up.state) & (xapp->AltMask)) == 0) {
        if (!isPopupActive())
            getFrame()->popupSystemMenu(this, up.x_root, up.y_root,
                                        YPopupWindow::pfCanFlipVertical |
                                        YPopupWindow::pfCanFlipHorizontal);
    }
}

void YFrameButton::handleBeginDrag(const XButtonEvent &down, const XMotionEvent &/*motion*/) {
    if (down.button == 3 && getFrame()->canMove()) {
        if (!isPopupActive()) {
            YFrameTitleBar* tbar = getFrame()->titlebar();
            getFrame()->startMoveSize(true, true,
                                      0, 0,
                                      down.x + x() + (tbar ? tbar->x() : 0),
                                      down.y + y() + (tbar ? tbar->y() : 0));
        }
    }
}

void YFrameButton::setActions(YAction action, YAction action2) {
    fAction2 = action2;
    if (action != fAction) {
        fAction = action;
        repaint();
    }
}

void YFrameButton::updatePopup() {
    getFrame()->updateMenu();
}

void YFrameButton::actionPerformed(YAction /*action*/, unsigned int modifiers) {
    if ((modifiers & ShiftMask) && fAction2 != actionNull)
        getFrame()->actionPerformed(fAction2, modifiers);
    else
        getFrame()->actionPerformed(fAction, modifiers);
}

ref<YPixmap> YFrameButton::getPixmap(int pn) const {
    if (fAction == actionMaximize)
        return maximizePixmap[pn];
    else if (fAction == actionMinimize)
        return minimizePixmap[pn];
    else if (fAction == actionRestore)
        return restorePixmap[pn];
    else if (fAction == actionClose)
        return closePixmap[pn];
    else if (fAction == actionHide)
        return hidePixmap[pn];
    else if (fAction == actionRollup)
        return getFrame()->isRollup() ? rolldownPixmap[pn] : rollupPixmap[pn];
    else if (fAction == actionDepth)
        return depthPixmap[pn];
    else if (fAction == actionNull &&
             LOOK(lookPixmap | lookMetal | lookGtk | lookFlat | lookMotif))
        return menuButton[pn];
    else
        return null;
}

void YFrameButton::paint(Graphics &g, const YRect &/*r*/) {
    int xPos = 1, yPos = 1;
    int pn = LOOK(lookPixmap | lookMetal | lookGtk | lookFlat)
        && getFrame()->focused() ? 1 : 0;
    const bool armed(isArmed());

    g.setColor(titleButtonBg);

    if (fOver && rolloverTitleButtons) {
        if (pn == 1) {
            pn = 2;
        } else {
            pn = 0;
        }
    }

    int iconSize =
    YIcon::smallSize();
    ref<YIcon> icon =
        (fAction == actionNull) ? getFrame()->clientIcon() : null;

    ref<YPixmap> pixmap = getPixmap(pn);
    if (pixmap == null && pn) {
        pixmap = getPixmap(0);
    }

    if (pixmap != null && pixmap->depth() != g.rdepth()) {
        tlog("YFrameButton::%s: attempt to use pixmap 0x%lx of depth %d with gc of depth %d\n",
                __func__, pixmap->pixmap(), pixmap->depth(), g.rdepth());
    }

    if (wmLook == lookWarp4) {
        if (fAction == actionNull) {
            g.fillRect(0, 0, width(), height());

            if (armed)
                g.setColor(activeTitleBarBg);

            g.fillRect(1, 1, width() - 2, height() - 2);

            if (icon != null && showFrameIcon) {
                icon->draw(g,
                           (width() - iconSize) / 2,
                           (height() - iconSize) / 2,
                           iconSize);
            }
        } else {
            g.fillRect(0, 0, width(), height());

            if (pixmap != null)
                g.copyPixmap(pixmap, 0, armed ? 20 : 0,
                             pixmap->width(), pixmap->height() / 2,
                             (width() - pixmap->width()) / 2,
                             (height() - pixmap->height() / 2));
        }
    }
    else if (LOOK(lookMotif | lookWarp3 | lookNice)) {
        g.draw3DRect(0, 0, width() - 1, height() - 1, !armed);

        if (wmLook != lookMotif) {
            if (armed) {
                xPos = 3;
                yPos = 3;
                g.drawLine(1, 1, width() - 2, 1);
                g.drawLine(1, 1, 1, height() - 2);
                g.drawLine(2, 2, width() - 3, 2);
                g.drawLine(2, 2, 2, height() - 3);
            } else {
                xPos = 2;
                yPos = 2;
                g.drawRect(1, 1, width() - 3, width() - 3);
            }
        }

        unsigned const w(LOOK(lookMotif) ? width() - 2 : width() - 4);
        unsigned const h(LOOK(lookMotif) ? height() - 2 : height() - 4);

        if (fAction == actionNull) {
            g.fillRect(xPos, yPos, w, h);

            if (icon != null && showFrameIcon) {
                icon->draw(g,
                           xPos + (w - iconSize) / 2,
                           yPos + (h - iconSize) / 2,
                           iconSize);
            }
            else if (pixmap != null) {
                g.drawCenteredPixmap(xPos, yPos, w, h, pixmap);
            }
        } else {
            if (pixmap != null)
                g.drawCenteredPixmap(xPos, yPos, w, h, pixmap);
        }
    }
    else if (wmLook == lookWin95) {
        if (fAction == actionNull) {
            if (!armed) {
                YColor * bg(getFrame()->focused() ? activeTitleBarBg
                            : inactiveTitleBarBg);
                g.setColor(bg);
            }

            g.fillRect(0, 0, width(), height());

            if (icon != null && showFrameIcon) {
                icon->draw(g,
                           (width() - iconSize) / 2,
                           (height() - iconSize) / 2,
                           iconSize);
            }
        } else {
            g.drawBorderW(0, 0, width() - 1, height() - 1, !armed);

            if (armed)
                xPos = yPos = 2;

            if (pixmap != null)
                g.drawCenteredPixmap(xPos, yPos, width() - 3, height() - 3,
                                     pixmap);
        }
    }
    else if (LOOK(lookPixmap | lookMetal | lookFlat | lookGtk)) {
        if (pixmap != null) {
            if ( getPixmap(1) != null ) {
                int const h(pixmap->height() / 2);
                g.copyPixmap(pixmap, 0, armed ? h : 0, pixmap->width(), h, 0, 0);
            } else {
                // If we have only an image we change
                // the over or armed color and paint it.
               g.fillRect(0, 0, width(), height());
               if (armed)
                   g.setColor(activeTitleBarBg->darker());
               else if (rolloverTitleButtons && fOver)
                   g.setColor(activeTitleBarBg->brighter());
               g.fillRect(1, 1, width()-2, height()-3);
               int x(((int)width()  - (int)pixmap->width())  / 2);
               int y(((int)height() - (int)pixmap->height()) / 2);
               g.drawPixmap(pixmap, x, y);
            }
        }
        else {
            g.fillRect(0, 0, width(), height());
        }

        if (fAction == actionNull && icon != null && showFrameIcon) {
            icon->draw(g,
                       ((int)width() - (int)iconSize) / 2,
                       ((int)height() - (int)iconSize) / 2,
                       iconSize);
        }
    }
}

void YFrameButton::paintFocus(Graphics &/*g*/, const YRect &/*r*/) {
}

// vim: set sw=4 ts=4 et:
<commit_msg>More fixes for unsigned width/height.<commit_after>/*
 * IceWM
 *
 * Copyright (C) 1997-2001 Marko Macek
 */
#include "config.h"

#include "wmbutton.h"

#include "wmframe.h"
#include "wmtitle.h"
#include "yxapp.h"
#include "yicon.h"
#include "yprefs.h"
#include "prefs.h"
#include "wpixmaps.h"

static YColor *titleButtonBg = 0;
static YColor *titleButtonFg = 0;

//!!! get rid of this
extern YColor *activeTitleBarBg;
extern YColor *inactiveTitleBarBg;

YFrameButton::YFrameButton(YWindow *parent,
                           bool right,
                           YFrameWindow *frame,
                           YAction action,
                           YAction action2):
    YButton(desktop, actionNull),
    fFrame(frame),
    fRight(right),
    fAction(action),
    fAction2(action2)
{
    reparent(parent, 0, 0);
    if (titleButtonBg == 0)
        titleButtonBg = new YColor(clrNormalTitleButton);
    if (titleButtonFg == 0)
        titleButtonFg = new YColor(clrNormalTitleButtonText);

    if (fAction == actionNull)
        setPopup(frame->windowMenu());
    if (right)
        setWinGravity(NorthEastGravity);

    setSize(0,0);
}

YFrameButton::~YFrameButton() {
}

void YFrameButton::handleButton(const XButtonEvent &button) {
    if (button.type == ButtonPress &&
        (buttonRaiseMask & (1 << (button.button - 1))))
    {
        if (!(button.state & ControlMask) && raiseOnClickButton) {
            getFrame()->activate();
            if (raiseOnClickButton && fAction != actionDepth)
                getFrame()->wmRaise();
        }
    }
    YButton::handleButton(button);
}

void YFrameButton::handleClick(const XButtonEvent &up, int count) {
    if (fAction == actionNull && up.button == 1) {
        if ((count % 2) == 0) {
            setArmed(false, false);
            getFrame()->wmClose();
        }
    } else if (up.button == 3 && (KEY_MODMASK(up.state) & (xapp->AltMask)) == 0) {
        if (!isPopupActive())
            getFrame()->popupSystemMenu(this, up.x_root, up.y_root,
                                        YPopupWindow::pfCanFlipVertical |
                                        YPopupWindow::pfCanFlipHorizontal);
    }
}

void YFrameButton::handleBeginDrag(const XButtonEvent &down, const XMotionEvent &/*motion*/) {
    if (down.button == 3 && getFrame()->canMove()) {
        if (!isPopupActive()) {
            YFrameTitleBar* tbar = getFrame()->titlebar();
            getFrame()->startMoveSize(true, true,
                                      0, 0,
                                      down.x + x() + (tbar ? tbar->x() : 0),
                                      down.y + y() + (tbar ? tbar->y() : 0));
        }
    }
}

void YFrameButton::setActions(YAction action, YAction action2) {
    fAction2 = action2;
    if (action != fAction) {
        fAction = action;
        repaint();
    }
}

void YFrameButton::updatePopup() {
    getFrame()->updateMenu();
}

void YFrameButton::actionPerformed(YAction /*action*/, unsigned int modifiers) {
    if ((modifiers & ShiftMask) && fAction2 != actionNull)
        getFrame()->actionPerformed(fAction2, modifiers);
    else
        getFrame()->actionPerformed(fAction, modifiers);
}

ref<YPixmap> YFrameButton::getPixmap(int pn) const {
    if (fAction == actionMaximize)
        return maximizePixmap[pn];
    else if (fAction == actionMinimize)
        return minimizePixmap[pn];
    else if (fAction == actionRestore)
        return restorePixmap[pn];
    else if (fAction == actionClose)
        return closePixmap[pn];
    else if (fAction == actionHide)
        return hidePixmap[pn];
    else if (fAction == actionRollup)
        return getFrame()->isRollup() ? rolldownPixmap[pn] : rollupPixmap[pn];
    else if (fAction == actionDepth)
        return depthPixmap[pn];
    else if (fAction == actionNull &&
             LOOK(lookPixmap | lookMetal | lookGtk | lookFlat | lookMotif))
        return menuButton[pn];
    else
        return null;
}

void YFrameButton::paint(Graphics &g, const YRect &/*r*/) {
    int xPos = 1, yPos = 1;
    int pn = LOOK(lookPixmap | lookMetal | lookGtk | lookFlat)
        && getFrame()->focused() ? 1 : 0;
    const bool armed(isArmed());

    g.setColor(titleButtonBg);

    if (fOver && rolloverTitleButtons) {
        if (pn == 1) {
            pn = 2;
        } else {
            pn = 0;
        }
    }

    int iconSize =
    YIcon::smallSize();
    ref<YIcon> icon =
        (fAction == actionNull) ? getFrame()->clientIcon() : null;

    ref<YPixmap> pixmap = getPixmap(pn);
    if (pixmap == null && pn) {
        pixmap = getPixmap(0);
    }

    if (pixmap != null && pixmap->depth() != g.rdepth()) {
        tlog("YFrameButton::%s: attempt to use pixmap 0x%lx of depth %d with gc of depth %d\n",
                __func__, pixmap->pixmap(), pixmap->depth(), g.rdepth());
    }

    if (wmLook == lookWarp4) {
        if (fAction == actionNull) {
            g.fillRect(0, 0, width(), height());

            if (armed)
                g.setColor(activeTitleBarBg);

            g.fillRect(1, 1, width() - 2, height() - 2);

            if (icon != null && showFrameIcon) {
                icon->draw(g,
                           ((int) width() - iconSize) / 2,
                           ((int) height() - iconSize) / 2,
                           iconSize);
            }
        } else {
            g.fillRect(0, 0, width(), height());

            if (pixmap != null)
                g.copyPixmap(pixmap, 0, armed ? 20 : 0,
                             pixmap->width(), pixmap->height() / 2,
                             ((int) width() - (int) pixmap->width()) / 2,
                             ((int) height() - (int) pixmap->height() / 2));
        }
    }
    else if (LOOK(lookMotif | lookWarp3 | lookNice)) {
        g.draw3DRect(0, 0, width() - 1, height() - 1, !armed);

        if (wmLook != lookMotif) {
            if (armed) {
                xPos = 3;
                yPos = 3;
                g.drawLine(1, 1, width() - 2, 1);
                g.drawLine(1, 1, 1, height() - 2);
                g.drawLine(2, 2, width() - 3, 2);
                g.drawLine(2, 2, 2, height() - 3);
            } else {
                xPos = 2;
                yPos = 2;
                g.drawRect(1, 1, width() - 3, width() - 3);
            }
        }

        unsigned const w(LOOK(lookMotif) ? width() - 2 : width() - 4);
        unsigned const h(LOOK(lookMotif) ? height() - 2 : height() - 4);

        if (fAction == actionNull) {
            g.fillRect(xPos, yPos, w, h);

            if (icon != null && showFrameIcon) {
                icon->draw(g,
                           xPos + ((int) w - iconSize) / 2,
                           yPos + ((int) h - iconSize) / 2,
                           iconSize);
            }
            else if (pixmap != null) {
                g.drawCenteredPixmap(xPos, yPos, w, h, pixmap);
            }
        } else {
            if (pixmap != null)
                g.drawCenteredPixmap(xPos, yPos, w, h, pixmap);
        }
    }
    else if (wmLook == lookWin95) {
        if (fAction == actionNull) {
            if (!armed) {
                YColor * bg(getFrame()->focused() ? activeTitleBarBg
                            : inactiveTitleBarBg);
                g.setColor(bg);
            }

            g.fillRect(0, 0, width(), height());

            if (icon != null && showFrameIcon) {
                icon->draw(g,
                           ((int) width() - iconSize) / 2,
                           ((int) height() - iconSize) / 2,
                           iconSize);
            }
        } else {
            g.drawBorderW(0, 0, width() - 1, height() - 1, !armed);

            if (armed)
                xPos = yPos = 2;

            if (pixmap != null)
                g.drawCenteredPixmap(xPos, yPos, width() - 3, height() - 3,
                                     pixmap);
        }
    }
    else if (LOOK(lookPixmap | lookMetal | lookFlat | lookGtk)) {
        if (pixmap != null) {
            if ( getPixmap(1) != null ) {
                int const h(pixmap->height() / 2);
                g.copyPixmap(pixmap, 0, armed ? h : 0, pixmap->width(), h, 0, 0);
            } else {
                // If we have only an image we change
                // the over or armed color and paint it.
               g.fillRect(0, 0, width(), height());
               if (armed)
                   g.setColor(activeTitleBarBg->darker());
               else if (rolloverTitleButtons && fOver)
                   g.setColor(activeTitleBarBg->brighter());
               g.fillRect(1, 1, width()-2, height()-3);
               int x(((int)width()  - (int)pixmap->width())  / 2);
               int y(((int)height() - (int)pixmap->height()) / 2);
               g.drawPixmap(pixmap, x, y);
            }
        }
        else {
            g.fillRect(0, 0, width(), height());
        }

        if (fAction == actionNull && icon != null && showFrameIcon) {
            icon->draw(g,
                       ((int)width() - (int)iconSize) / 2,
                       ((int)height() - (int)iconSize) / 2,
                       iconSize);
        }
    }
}

void YFrameButton::paintFocus(Graphics &/*g*/, const YRect &/*r*/) {
}

// vim: set sw=4 ts=4 et:
<|endoftext|>