Ejemplo n.º 1
0
BOOST_FIXTURE_TEST_CASE(DestroyFace, AuthorizedCommandFixture<FaceFixture>)
{
  shared_ptr<DummyFace> dummy(make_shared<DummyFace>());
  FaceTableFixture::m_faceTable.add(dummy);

  ControlParameters parameters;
  parameters.setFaceId(dummy->getId());

  Block encodedParameters(parameters.wireEncode());

  Name commandName("/localhost/nfd/faces");
  commandName.append("destroy");
  commandName.append(encodedParameters);

  shared_ptr<Interest> command(make_shared<Interest>(commandName));
  generateCommand(*command);

  ndn::nfd::FaceEventNotification expectedFaceEvent;
  expectedFaceEvent.setKind(ndn::nfd::FACE_EVENT_DESTROYED)
                   .setFaceId(dummy->getId())
                   .setRemoteUri(dummy->getRemoteUri().toString())
                   .setLocalUri(dummy->getLocalUri().toString())
                   .setFlags(0);

  getFace()->onReceiveData +=
    bind(&FaceFixture::callbackDispatch, this, _1, command->getName(),
         200, "Success", ref(encodedParameters), expectedFaceEvent);

  destroyFace(*command, parameters);

  BOOST_REQUIRE(didCallbackFire());
  BOOST_REQUIRE(didReceiveNotication());
}
Ejemplo n.º 2
0
BOOST_FIXTURE_TEST_CASE(TestFaceList, FaceListFixture)
{
  Name commandName("/localhost/nfd/faces/list");
  shared_ptr<Interest> command(make_shared<Interest>(commandName));

  // MAX_SEGMENT_SIZE == 4400, FaceStatus size with filler counters is 75
  // use 59 FaceStatuses to force a FaceStatus to span Data packets
  for (int i = 0; i < 59; i++)
    {
      shared_ptr<TestCountersFace> dummy(make_shared<TestCountersFace>());

      uint64_t filler = std::numeric_limits<uint64_t>::max() - 1;
      dummy->setCounters(filler, filler, filler, filler, filler, filler);

      m_referenceFaces.push_back(dummy);

      add(dummy);
    }

  ndn::EncodingBuffer buffer;

  m_face->onReceiveData +=
    bind(&FaceStatusPublisherFixture::decodeFaceStatusBlock, this, _1);

  m_manager.listFaces(*command);
  BOOST_REQUIRE(m_finished);
}
Ejemplo n.º 3
0
static void cmdExecution(u8 cmdCode, btlCommandArgType *args, u16 replyLength, u8 *reply, u8 broadcast)
{
  u8 status;
  char *command;
  char commandString[64];

  txBufferInit(broadcast);
  rxBufferInit();

  status = bootloadCommand(cmdCode, args, replyLength, reply);

  command = commandName(cmdCode);
  strcpy(commandString, command);
  if (broadcast) {
    strcpy(commandString + strlen(commandString), "(broadcast)");
  }

  responsePrintf("{&N Bootload command... &t2x \r\n", commandString, "status", status);
  responsePrintf("{%t:","reply");
  if (replyLength == 0xFFFF) {
    replyLength = reply[0]+2;
  }
  if (status == BOOTLOAD_COMMAND_SUCCESS)
  {
    u8 i;
    for (i = 0; i < replyLength; i++) {
      responsePrintf("%x", reply[i]);
    }
    responsePrintf ("}");
  }
  responsePrintf ("}\r\n");
}
Ejemplo n.º 4
0
void Swiftob::handleMessageReceived(Swift::Message::ref message) {
	Swift::Message::Type type = message->getType();
	if (type == Swift::Message::Error || type == Swift::Message::Headline) {
		std::cout << "Ignoring typed message" << std::endl;
		return;
	}
	std::string body = message->getBody();
	std::cout << "Got message with body " << body << std::endl;
	if (body.size() == 0) {
		std::cout << "Not handling empty body" << std::endl;
		return;
	}
	/*Convert body into !command if it's not a MUC, and it misses the bang*/
	std::string bangBody(body);
	if (type != Swift::Message::Groupchat && body[0] != '!') {
		bangBody = "!" + body;
	}
	std::cout << "After banging, body is " << bangBody << std::endl;
	std::pair<std::string, std::string> split = Swift::String::getSplittedAtFirst(bangBody, ' ');
	std::string commandName(split.first);
	commandName = Swift::String::getSplittedAtFirst(commandName, '!').second;
	/*FIXME: remove leading bang in commandName*/
	if (commands_->hasCommand(commandName)) {
		std::cout << "Matched command " << commandName << std::endl;
		commands_->runCommand(commandName, split.second, message);
	}
}
	void displayHelp()
	{
		Poco::Util::HelpFormatter helpFormatter(options());
		helpFormatter.setCommand(commandName());
		helpFormatter.setUsage("OPTIONS");
		helpFormatter.setHeader("A server application that serves the current date and time.");
		helpFormatter.format(std::cout);
	}
Ejemplo n.º 6
0
 void displayHelp()
 {
     Poco::Util::HelpFormatter helpFormatter(options());
     helpFormatter.setCommand(commandName());
     helpFormatter.setUsage("OPTIONS");
     helpFormatter.setHeader("A simple UPnP Controller.");
     helpFormatter.format(std::cout);
 }
Ejemplo n.º 7
0
void BeeServer::displayHelp()
{
	HelpFormatter helpFormatter(options());
	helpFormatter.setCommand(commandName());
	helpFormatter.setUsage("OPTIONS");
	helpFormatter.setHeader("A sample server application that demonstrates some of the features of the Util::ServerApplication class.");
	helpFormatter.format(std::cout);
}
Ejemplo n.º 8
0
	void displayHelp()
	{
		HelpFormatter helpFormatter(options());
		helpFormatter.setCommand(commandName());
		helpFormatter.setUsage("OPTIONS");
		helpFormatter.setHeader(".");
		helpFormatter.format(std::cout);
	}
Ejemplo n.º 9
0
	void HALService::displayHelp() {
		help = true;
		Poco::Util::HelpFormatter helpFormatter(options());
		helpFormatter.setCommand(commandName());
		helpFormatter.setUsage("OPTIONS");
		helpFormatter.setHeader("HAL.CanModules server.");
		helpFormatter.format(std::cout);
	}
Ejemplo n.º 10
0
	void displayHelp()
	{
		HelpFormatter helpFormatter(options());
		helpFormatter.setCommand(commandName());
		helpFormatter.setUsage("OPTIONS");
		helpFormatter.setHeader("An echo client implemented using the Reactor and Acceptor patterns.");
		helpFormatter.format(std::cout);
	}
Ejemplo n.º 11
0
 void displayHelp()
 {
   Poco::Util::HelpFormatter helpFormatter(options());
   helpFormatter.setCommand(commandName());
   helpFormatter.setUsage("OPTIONS");
   helpFormatter.setHeader("TCP server sample application.");
   helpFormatter.format(std::cout);
 }
Ejemplo n.º 12
0
void RestServer::handleHelp(const string& name, const string& value)
{
    HelpFormatter helpFormatter(options());
    helpFormatter.setCommand(commandName());
    helpFormatter.setUsage("OPTIONS");
    helpFormatter.setHeader("A rest server that serves rest data and handles rest udpates and commands");
    helpFormatter.format(std::cout);
    stopOptionsProcessing();
    _helpRequested = true;
}
Ejemplo n.º 13
0
void Plugin::handleHelp(const std::string& name, const std::string& value)
{
    HelpFormatter helpFormatter(options());
    helpFormatter.setCommand(commandName());
    helpFormatter.setUsage("OPTIONS");
    helpFormatter.setHeader(
            "git-bin plugin for git: Help with tracking of large files in git");
    helpFormatter.format(std::cout);
    stopOptionsProcessing();
    _terminate = true;
}
Ejemplo n.º 14
0
void Mine::evaluateAndPrint(RobotCommands commandList) {
  print();
  for (auto c : commandList) {
    if (!doCommand(c))
      std::cout << "Illegal command: " << commandName(c) << std::endl;

    print();
    if (state != State::InProgress)
      break;
  }
  std::cout << "Final state: " << stateToString(state) << std::endl;
  std::cout << "Final score: " << score() << std::endl;
}
Ejemplo n.º 15
0
 void displayHelp(void)
 {
     Poco::Util::HelpFormatter helpFormatter(this->options());
     helpFormatter.setUnixStyle(true); //always unix style --option
     helpFormatter.setCommand(commandName());
     helpFormatter.setUsage("OPTIONS");
     helpFormatter.setHeader("\n"
         "PothosUtil is a helper exectuable for the Pothos Library; "
         "used both internally by the library, and externally by the user. "
         "The util provides a command-line interface for the self-tests, "
         "and can spawn servers and daemons for remote interfaces. ");
     helpFormatter.format(std::cout);
 }
Ejemplo n.º 16
0
Scenario::Command::MoveNewState::MoveNewState(ObjectPath &&scenarioPath,
                                              id_type<StateModel> stateId,
                                              const double y):
    SerializableCommand {"ScenarioControl",
             commandName(),
             description()},
    m_path(std::move(scenarioPath)),
    m_stateId{stateId},
    m_y{y}
{
    auto& scenar = m_path.find<ScenarioModel>();
    m_oldy = scenar.state(m_stateId).heightPercentage();
}
//-----------------------------------------------------------------------------
// Deregister
//-----------------------------------------------------------------------------
MStatus CVsMayaMPxCommand::Deregister(
	MFnPlugin &pluginFn,
	const MString &name )
{
	MString commandName( name );
	MStatus regStat = pluginFn.deregisterCommand( commandName );

	if ( !regStat )
		return regStat;

	commandName.toLowerCase();
	return pluginFn.deregisterCommand( commandName );
}
Ejemplo n.º 18
0
void
PitchBendSequenceDialog::accept()
{
    /* The user has finished the dialog, other than aborting. */

    // We don't enable "OK" if the interval isn't sensible, so
    // something's badly wrong if this test fails.
    Q_ASSERT_X(m_startTime < m_endTime, "accept",
             "got a zero or negative time interval");

    /* Save current settings.  They'll be the defaults next time. */
    saveSettings();

    // TRANSLATORS: The arg value will be either a controller name or
    // Pitchbend, so the resulting text is like "Pitchbend Sequence",
    // "Expression Sequence", etc.
    QString controllerName(m_control.getName().data());
    QString commandName(tr("%1 Sequence").arg(controllerName));
    MacroCommand *macro = new MacroCommand(commandName);

    if (getReplaceMode() != OnlyAdd) {
        // Selection initially contains no event, and we add all the
        // relevant ones.  
        EventSelection *selection = new EventSelection(*m_segment);
        for (Segment::const_iterator i = m_segment->findTime(m_startTime);
             i != m_segment->findTime(m_endTime);
             ++i) {
            Event *e = *i;
            if (m_control.matches(e)) {
                selection->addEvent(e, false);
            }
        }

        // EraseCommand takes ownership of "selection".
        macro->addCommand(new EraseCommand(*selection));
    }

    if (getReplaceMode() != OnlyErase) {
        if ((getRampMode() == Linear) &&
            (getStepSizeCalculation() == StepSizeByCount)) {
            addLinearCountedEvents(macro);
        } else {
            addStepwiseEvents(macro);
        }
    }
    CommandHistory::getInstance()->addCommand(macro);

    QDialog::accept();
}
Ejemplo n.º 19
0
void BasicApplication::initialize(Application& self)
{
    // Don't use logger here because it is not configured yet.
    if (_echoCommand) {
        cout << "Executing: " << commandName() << _optionsString << endl;
    }

    initializeDirectories();
    initializeConfiguration();

    // Application::initialize must _NOT_ be called before
    // initialize(Directories|Configuration) or else any subsystems will be
    // initialized without any prior configuration of directories, etc.
    Application::initialize(self);
}
//-----------------------------------------------------------------------------
// Register
//-----------------------------------------------------------------------------
MStatus CVsMayaMPxCommand::Register(
	MFnPlugin &pluginFn,
	const MString &name,
	MCreatorFunction creatorFunction,
	MCreateSyntaxFunction createSyntaxFunction )
{
	MString commandName( name );
	MStatus regStat = pluginFn.registerCommand( commandName, creatorFunction, createSyntaxFunction );

	if ( !regStat )
		return regStat;

	commandName.toLowerCase();
	return pluginFn.registerCommand( commandName, creatorFunction, createSyntaxFunction );
}
void
StrategyChoiceHelper::sendCommand(const ControlParameters& parameters, Ptr<Node> node)
{
  NS_LOG_DEBUG("Strategy choice command was initialized");
  Block encodedParameters(parameters.wireEncode());

  Name commandName("/localhost/nfd/strategy-choice");
  commandName.append("set");
  commandName.append(encodedParameters);

  shared_ptr<Interest> command(make_shared<Interest>(commandName));
  StackHelper::getKeyChain().sign(*command);

  Ptr<L3Protocol> l3protocol = node->GetObject<L3Protocol>();
  l3protocol->injectInterest(*command);
}
Ejemplo n.º 22
0
void
FibHelper::RemoveNextHop(const ControlParameters& parameters, Ptr<Node> node)
{
  Block encodedParameters(parameters.wireEncode());

  Name commandName("/localhost/nfd/fib");
  commandName.append("remove-nexthop");
  commandName.append(encodedParameters);

  shared_ptr<Interest> command(make_shared<Interest>(commandName));
  command->setCanBePrefix(false);
  StackHelper::getKeyChain().sign(*command);

  Ptr<L3Protocol> l3protocol = node->GetObject<L3Protocol>();
  l3protocol->injectInterest(*command);
}
Ejemplo n.º 23
0
//writes command from the file depending on its size
void writeCommandToFile(FILE *f, tCommandWithOperands command_with_operands,
                        tAddressDatabase addresses_values)
{
    tLine line;
    if (isJumpCommand(command_with_operands) && command_with_operands.left.type == NUMBER)
    {
        snprintf(line.str, MAX_COMMAND_LINE_LENGTH-1, "%s %s",
            commandName(command_with_operands.cmd),
            getAddressLabel(command_with_operands.left.value, addresses_values).str);
    }
    else
    {
        line = makeLine(command_with_operands);
    }
    fputs(line.str, f);
    fputc('\n', f);
}
Ejemplo n.º 24
0
void
FibHelper::AddNextHop(const ControlParameters& parameters, Ptr<Node> node)
{
  NS_LOG_DEBUG("Add Next Hop command was initialized");
  Block encodedParameters(parameters.wireEncode());

  Name commandName("/localhost/nfd/fib");
  commandName.append("add-nexthop");
  commandName.append(encodedParameters);

  shared_ptr<Interest> command(make_shared<Interest>(commandName));
  StackHelper::getKeyChain().sign(*command);

  Ptr<L3Protocol> l3protocol = node->GetObject<L3Protocol>();
  shared_ptr<nfd::FibManager> fibManager = l3protocol->getFibManager();
  fibManager->onFibRequest(*command);
}
Ejemplo n.º 25
0
std::string Shell::getCommandName(const std::string& commandWithArgs) const {
  int indexOfNonWhitespace = 0;
  while (isspace(commandWithArgs[indexOfNonWhitespace])) {
    indexOfNonWhitespace++;
  };
  std::string commandName("");
  char symbol;
  for (int i = indexOfNonWhitespace; i < commandWithArgs.length(); i++) {
    symbol = commandWithArgs[i];
    if (! isspace(symbol)) {
      commandName+=symbol;
    } else {
      break;
    }
  }
  return commandName;
}
Ejemplo n.º 26
0
BOOST_FIXTURE_TEST_CASE(ValidatedFaceRequestDestroyFace,
                        AuthorizedCommandFixture<ValidatedFaceRequestFixture>)
{
  ControlParameters parameters;
  parameters.setUri("tcp://127.0.0.1");

  Block encodedParameters(parameters.wireEncode());

  Name commandName("/localhost/nfd/faces");
  commandName.append("destroy");
  commandName.append(encodedParameters);

  shared_ptr<Interest> command(make_shared<Interest>(commandName));
  generateCommand(*command);

  onValidatedFaceRequest(command);
  BOOST_CHECK(didDestroyFaceFire());
}
Ejemplo n.º 27
0
BOOST_FIXTURE_TEST_CASE(ValidatedFaceRequestBadOptionParse,
                        AuthorizedCommandFixture<ValidatedFaceRequestFixture>)
{
  Name commandName("/localhost/nfd/faces");
  commandName.append("create");
  commandName.append("NotReallyParameters");

  shared_ptr<Interest> command(make_shared<Interest>(commandName));
  generateCommand(*command);

  getFace()->onReceiveData +=
    bind(&ValidatedFaceRequestFixture::validateControlResponse, this, _1,
         command->getName(), 400, "Malformed command");

  onValidatedFaceRequest(command);

  BOOST_REQUIRE(didCallbackFire());
}
Ejemplo n.º 28
0
void
FibHelper::RemoveNextHop(const ControlParameters& parameters, Ptr<Node> node)
{
  NS_LOG_DEBUG("Remove Next Hop command was initialized");
  Block encodedParameters(parameters.wireEncode());

  Name commandName("/localhost/nfd/fib");
  commandName.append("remove-nexthop");
  commandName.append(encodedParameters);

  shared_ptr<Interest> command(make_shared<Interest>(commandName));
  StackHelper::getKeyChain().sign(*command);

  Ptr<L3Protocol> L3protocol = node->GetObject<L3Protocol>();
  shared_ptr<nfd::FibManager> fibManager = L3protocol->getFibManager();
  // fibManager->addInterestRule(commandName.toUri(), key, *keyChain.getPublicKey (key));
  fibManager->onFibRequest(*command);
}
Ejemplo n.º 29
0
int Server::run()
{
    if (config().hasOption("help"))
    {
        Poco::Util::HelpFormatter helpFormatter(Server::options());
        std::stringstream header;
        header << commandName() << " [OPTION] [-- [ARG]...]\n";
        header << "positional arguments can be used to rewrite config.xml properties, for example, --http_port=8010";
        helpFormatter.setHeader(header.str());
        helpFormatter.format(std::cout);
        return 0;
    }
    if (config().hasOption("version"))
    {
        std::cout << DBMS_NAME << " server version " << VERSION_STRING << VERSION_OFFICIAL << "." << std::endl;
        return 0;
    }
    return Application::run();
}
// -----------------------------------------------------------------------------
// CCFSourceCommandAction::ActL
// -----------------------------------------------------------------------------
//
void CCFSourceCommandAction::ActL()
    {
    FUNC_LOG;

    if ( iCommand )
        {
        TPtrC commandName( iCommand->Name() );
        ACTION_INFO_3( "CCFSourceCommandAction::ActL - Script ID=[%d] Firing action: %S for source [%x]",
                iServices.ScriptId(),
                &commandName,
                iCommand->SourceUid() );

        iServices.FireActionL( *iCommand );
        }
    else
        {
        ERROR_GEN_1( "CCFSourceCommandAction::ActL - Command is NULL for script ID=[%d]",
                iServices.ScriptId() );
        }
    }