Beispiel #1
0
int main(int argc, char* argv[])
{
	std::string user, pwd, url, path;
	int port;
	if (!checkParams(argc, argv, user, pwd, url, port, path))
	{
		std::cerr << "Program run with incorrect arguments!" << std::endl;
		return 1;
	}

	Client client;
	if (!client.init(url, port, user, pwd))
	{
		std::cerr << "Failed to initialize the client." << std::endl;
		return 1;
	}
	std::string list;
	if (!client.list(path, list))
	{
		std::cerr << "Failed to receive list of files." << std::endl;
		return 1;
	}
	std::cout << list << std::endl;

	return 0;
}
void SearchController::resultsAction()
{
    checkParams({"id"});

    const int id = params()["id"].toInt();
    int limit = params()["limit"].toInt();
    int offset = params()["offset"].toInt();

    const auto searchHandlers = sessionManager()->session()->getData<SearchHandlerDict>(SEARCH_HANDLERS);
    if (!searchHandlers.contains(id))
        throw APIError(APIErrorType::NotFound);

    const SearchHandlerPtr searchHandler = searchHandlers[id];
    const QList<SearchResult> searchResults = searchHandler->results();
    const int size = searchResults.size();

    if (offset > size)
        throw APIError(APIErrorType::Conflict, tr("Offset is out of range"));

    // normalize values
    if (offset < 0)
        offset = size + offset;
    if (offset < 0)  // check again
        throw APIError(APIErrorType::Conflict, tr("Offset is out of range"));
    if (limit <= 0)
        limit = -1;

    if ((limit > 0) || (offset > 0))
        setResult(getResults(searchResults.mid(offset, limit), searchHandler->isActive(), size));
    else
        setResult(getResults(searchResults, searchHandler->isActive(), size));
}
Beispiel #3
0
bool check(const php::Func& f) {
  assert(checkParams(f));
  assert(checkName(f.name));
  for (DEBUG_ONLY auto& block : f.blocks) assert(checkBlock(*block));

  /*
   * Some of these relationships may change as async/await
   * implementation progresses.  Asserting them now so they are
   * revisited here if they aren't true anymore.
   */
  if (f.isClosureBody)          assert(!f.top);
  if (f.isPairGenerator)        assert(f.isGenerator);

  if (f.isClosureBody) {
    assert(f.cls &&
           f.cls->parentName &&
           f.cls->parentName->isame(s_Closure.get()));
  }

  boost::dynamic_bitset<> seenId(f.nextBlockId);
  for (auto& block : f.blocks) {
    assert(checkBlock(*block));

    // All blocks have unique ids in a given function; not necessarily
    // consecutive.
    assert(block->id < f.nextBlockId);
    assert(!seenId.test(block->id));
    seenId.set(block->id);
  }

  assert(checkExnTree(f));

  return true;
}
Beispiel #4
0
Picdok::Picdok(QWidget *parent) :
    QMainWindow(parent), ui(new Ui::Picdok)     // Set up form.
{
    WaitPtr(true);
    ui->setupUi(this);
    showPic = 0;
    inParams = new QStringList(QApplication::arguments());
    curDir = "";
    curDirHdg = new QLabel;
    curDirLabel = new QLabel;
    curDirNum = new QLabel;
    img = new QImage;
    imgDisp = new QImage;
    pixmDisp = new QPixmap;
    matx = new QTransform;
    settings = new QSettings(QDir::homePath() + QDir::separator() + SETTINGS_FILE, QSettings::IniFormat, this);
    // Check command line parameter and use supplied directory if valid, else use saved settings,or current directory if none.
    readSettings(checkParams(inParams));
    noAutomove = false;
    setupStatusBar();
    // Connect the context menu signals from lblPic to the required slots here.
    connect(ui->lblPic, SIGNAL(pdlSigDesel()), this, SLOT(doDeselect()));
    connect(ui->lblPic, SIGNAL(pdlSigDel()), this, SLOT(doDelete()));
    connect(ui->lblPic, SIGNAL(pdlSigRen()), this, SLOT(doPicRename()));
    connect(ui->lblPic, SIGNAL(pdlSigMov()), this, SLOT(doPicMove()));
    desk = QApplication::desktop();
    setFocusOnCommentIfEmpty();
    WaitPtr(false);
}
void SearchController::installPluginAction()
{
    checkParams({"sources"});

    const QStringList sources = params()["sources"].split('|');
    for (const QString &source : sources)
        SearchPluginManager::instance()->installPlugin(source);
}
void SearchController::uninstallPluginAction()
{
    checkParams({"names"});

    const QStringList names = params()["names"].split('|');
    for (const QString &name : names)
        SearchPluginManager::instance()->uninstallPlugin(name.trimmed());
}
double ExpectedValueFitness::evaluateFitness(map<string, vector3> _pos, map<string, double> _dblAcc, map<string, long> _intAcc){
    if(!checkParams(_pos, _dblAcc, _intAcc))
        return 0;

    if(_dblAcc["LowerBound"] > _dblAcc["Value"])
        return (_dblAcc["LowerBound"] - _dblAcc["Value"]) * _dblAcc["EVWeight"];
    else if(_dblAcc["Value"] > _dblAcc["UpperBound"])
        return (_dblAcc["Value"] - _dblAcc["UpperBound"]) * _dblAcc["EVWeight"];
    else return 0;
}
Beispiel #8
0
int GEI_Unit_InactiveTime (GEI_Unit unit){
  int ret = isInitialized("GEI_Unit_InactiveTime");
  if (ret == 0){
    LocalMapUnits::iterator u = ld.units->find(unit);
    ret = checkParams("GEI_Unit_InactiveTime", &u);
    if (ret == 0)
      ret = u->second.inactiveTime;
  }
  return ret;
}
Beispiel #9
0
float GEI_Unit_GetHealth (GEI_Unit unit){
  int ret = isInitialized("GEI_Unit_GetHealth");
  if (ret == 0){
    LocalMapUnits::iterator u = ld.units->find(unit);
    ret = checkParams("GEI_Unit_GetHealth", &u);
    if (ret == 0)
      return u->second.health;
  }
  return ret;
}
void SearchController::enablePluginAction()
{
    checkParams({"names", "enable"});

    const QStringList names = params()["names"].split('|');
    const bool enable = Utils::String::parseBool(params()["enable"].trimmed(), false);

    for (const QString &name : names)
        SearchPluginManager::instance()->enablePlugin(name.trimmed(), enable);
}
Beispiel #11
0
int GEI_Unit_GetGroup (GEI_Unit unit){
  int ret = isInitialized("GEI_Unit_GetGroup");
  if (ret == 0){
    LocalMapUnits::iterator u = ld.units->find(unit);
    ret = checkParams("GEI_Unit_GetGroup", &u);
    if (ret == 0)
      ret = u->second.group;
  }
  return ret;
}
Beispiel #12
0
int GEI_Unit_GetType (GEI_Unit unit){
  int ret = isInitialized("GEI_Unit_GetType");
  if (ret == 0){
    // récupération de l'unité
    LocalMapUnits::iterator u = ld.units->find(unit);
    ret = checkParams("GEI_Unit_GetType", &u);
    if (ret == 0)
      ret = u->second.type;
  }
  return ret;
}
Beispiel #13
0
GEI_Coalition GEI_Unit_GetCoalition (GEI_Unit unit){
  int ret = isInitialized("GEI_Unit_GetCoalition");
  if (ret == 0){
    // récupération de l'unité
    LocalMapUnits::iterator u = ld.units->find(unit);
    ret = checkParams("GEI_Unit_GetCoalition", &u);
    if (ret == 0)
      ret = u->second.coalition;
  }
  return (GEI_Coalition)ret;
}
bool Monitor::sendParamsToWorker(RoboCompCommonBehavior::ParameterList params)
{
	if(checkParams(params))
	{
		//Set params to worker
		if(worker->setParams(params) == true)
			return true;
	}
	rError("Incorrect parameters");
	return false;
}
Beispiel #15
0
int GEI_Unit_Stop (GEI_Unit unit){
  int ret = isInitialized("GEI_Unit_Stop");
  if (ret == 0){
    LocalMapUnits::iterator u = ld.units->find(unit);
    ret = checkParams("GEI_Unit_Stop", &u, true);
    if (ret == 0){
      std::vector<float> bidon; // seulement pour passer un paramètre
      addCommand(unit, CMD_STOP, bidon);
    }
  }
  return ret;
}
Beispiel #16
0
GEI_Pos GEI_StartPosition (){
  GEI_Pos tmp;
  // vérification de l'initialisation
  int ret = checkParams("GEI_StartPosition");
  if (ret == 0)
    return ld.startPosition;
  else{
    tmp.x = ret;
    tmp.y = ret;
  }
  return tmp;
}
Beispiel #17
0
GEI_Pos GEI_MapSize (){
  GEI_Pos tmp;
  // vérification de l'initialisation
  int ret = checkParams("GEI_MapSize");
  if (ret == 0)
    return ld.mapSize;
  else{
    tmp.x = ret;
    tmp.y = ret;
  }
  return tmp;
}
Beispiel #18
0
double expoTreeSIRSurvival(int parVecLen, double* K, double* beta, double* mu, 
                           double* psi, double rho, vector<double>& times, 
                           vector<int>& ttypes, int extant, int est_norm, 
                           int vflag, int rescale, int nroot)
{
  double fx = -INFINITY;

  if (! checkParams(parVecLen,K,beta,mu,psi,rho,nroot)) {
    if (vflag > 0) {
      fprintf(stderr,"Ilegal parameters. Returning inf.\n");
      fprintf(stderr,"N = %g, beta = %g, mu = %g, psi = %g, rho = %g\n",
              K[0],beta[0],mu[0],psi[0],rho);
    }
    return -INFINITY;
  }

  double* maxK = max_element(K,K+parVecLen);
  int maxN = ceil(*maxK);

  int dim = sir_index_N(0,maxN,maxN)+1;
  vector<double> p0(dim,0.0);

  double t0 = 0.0;
  double scale = 0.0;

  int ki = 0;
  int nt = times.size();
  int Ncur = (int) ceil(K[0]);

  p0[0] = 1.0; /* probability that the tree went extinct before the present */
  for (int R(0); R <= Ncur; ++R) {
    for (int I(0); I <= Ncur-R; ++I) {
      int i = sir_index_N(I,R,maxN);
      p0[i] = (rho > 0.0) ? pow(1.-rho,I) : 1.0;
    }
  }

  int info = 0;
  sir_expotree(K,&ki,beta,mu,psi,&nt,&parVecLen,
               times.data(),ttypes.data(),p0.data(),
               &t0,&info,&est_norm,&vflag,&rescale);

  if (info > 0) {
    int m = sir_index_N(1,0,maxN);
    fx = 1.0 - exp(p0[m] + scale);
    if (vflag > 0) fprintf(stderr,"ln(p(1,t)) = %20.12e\n",fx);
  } else {
    if (vflag > 0) fprintf(stderr,"rExpoTree returned %d!\n",info);
    return -INFINITY;
  }

  return (fx > 0) ? log(fx) : -INFINITY;
}
Beispiel #19
0
//----------------------------------------------------------------------------
Guido2ImageErrorCodes Guido2Image::gmnFileToImage	( const char * gmnFileName, const char * imageFileName	, Guido2ImageImageFormat imageFormat, 
	int pageIndex, const QSize& outputSizeConstraint, float zoom, char * errorMsgBuffer, int bufferSize )
{
	Guido2ImageErrorCodes errorCode = checkParams( true, gmnFileName, imageFileName, imageFormat, pageIndex, outputSizeConstraint, zoom, errorMsgBuffer, bufferSize );
	if ( errorCode != GUIDO_2_IMAGE_SUCCESS )
		return errorCode;
		
	QGuidoPainter * painter = buildPainterFromGMNFile(gmnFileName);
	if ( !painter )
		return GUIDO_2_IMAGE_GUIDO_ENGINE_NOT_STARTED;
	return guidoPainterToImage(painter,imageFileName,imageFormat,pageIndex,outputSizeConstraint,zoom,errorMsgBuffer, bufferSize);
}
Beispiel #20
0
void LazyGraph::loadIndexed(bool loadSubgraphs)
{
    assert(fileReader != 0);
    int nodeCount;
    int curveCount;
    int areaCount;
    int subgraphCount;
    long int offset;

    nParamsNodes = fileReader->read<int>();
    nParamsCurves = fileReader->read<int>();
    nParamsAreas = fileReader->read<int>();
    nParamsCurveExtremities = fileReader->read<int>();
    nParamsCurvePoints = fileReader->read<int>();
    nParamsAreaCurves = fileReader->read<int>();
    nParamsSubgraphs = fileReader->read<int>();

    checkParams(nParamsNodes, nParamsCurves, nParamsAreas, nParamsCurveExtremities, nParamsCurvePoints, nParamsAreaCurves, nParamsSubgraphs);

    offset = fileReader->read<long int>();
    fileReader->seekg(offset, ios::beg);

    nodeCount = fileReader->read<int>();
    curveCount = fileReader->read<int>();
    areaCount = fileReader->read<int>();
    subgraphCount = fileReader->read<int>();

    for (int i = 0; i < nodeCount; i++) {
        NodeId nid = nextNodeId;
        nextNodeId.id++;
        offset = fileReader->read<long int>();
        nodeOffsets.insert(make_pair(nid, offset));
    }
    for (int i = 0; i < curveCount; i++) {
        CurveId cid = nextCurveId;
        nextCurveId.id++;
        offset = fileReader->read<long int>();
        curveOffsets.insert(make_pair(cid, offset));
    }
    for (int i = 0; i < areaCount; i++) {
        AreaId aid = nextAreaId;
        nextAreaId.id++;
        offset = fileReader->read<long int>();
        areaOffsets.insert(make_pair(aid, offset));
    }
    for (int i = 0; i < subgraphCount; i++) {
        AreaId aid;
        aid.id = fileReader->read<int>();
        offset = fileReader->read<long int>();
        subgraphOffsets.insert(make_pair(aid, offset));
    }
}
Beispiel #21
0
void dspCheckRegister::sPrint()
{
  if(!checkParams())
    return;
  
  ParameterList params;
  
  params.append("bankaccnt_id", _bankaccnt->id());
  _dates->appendValue(params);
  params.append("print");
  
  rptCheckRegister newdlg(this, "", TRUE);
  newdlg.set(params);
}
Beispiel #22
0
void dspARApplications::sPrint()
{
  if (!checkParams())
    return;

  ParameterList params;
  setParams(params);

  orReport report("ARApplications", params);
  if (report.isValid())
    report.print();
  else
    report.reportError(this);
}
Beispiel #23
0
GEI_Unit GEI_GetUnitAt (int index, GEI_Coalition c){
  int ret = checkParams("GEI_GetUnitAt", NULL, false, (int*)&c);
  if (ret == 0){
    try{
      // retourne directement la donnée. Si l'index n'est pas bon, une
      // exeption sera levée
      ret = ld.coalitions[c]->at(index);
    } catch (std::out_of_range e) {
      std::cerr << "GEI_GetUnitAt : index out of range" << std::endl;
      ret = -7;
    }
  }
  return ret;
}
Beispiel #24
0
int GEI_Unit_ActionOnUnit (int unit, int action, int target){
  int ret = isInitialized("GEI_Unit_ActionOnUnit");
  if (ret == 0){
    LocalMapUnits::iterator u = ld.units->find(unit);
    LocalMapUnits::iterator t = ld.units->find(target);
    ret = checkParams("GEI_Unit_ActionOnUnit", &u, true, NULL, &t);
    if (ret == 0){
      // enregistrer la commande
      std::vector<float> params (1, 0);
      params[0] = target;
      addCommand(unit, action, params);
    }
  }
  return ret;
}
Beispiel #25
0
bool procMainArg(MainParam* params, int argc, char* argv[])
{
    int argp = 1, ret = 1;
    while(ret != 0 && argp < argc){
        ret = getMainParam(params, argc, argv, argp);
        argp += ret;
    }

    if(argp < argc || !checkParams(params)){
        //zostali nespracovatelne argumenty alebo parametre boli nekorektne
        fprintf(stderr, "%s", ECODEMSG[ECLWRONG]);
        return false;
    }
    else
        return true;
}
Beispiel #26
0
GEI_Pos GEI_Unit_GetPosition (GEI_Unit unit){
  GEI_Pos tmp;
  int ret = isInitialized("GEI_Unit_GetPosition");
  if (ret == 0){
    // vérification de l'initialisation
    LocalMapUnits::iterator u = ld.units->find(unit);
    ret = checkParams("GEI_Unit_GetPosition", &u);
    if (ret == 0)
      tmp = u->second.pos;
    else{
      tmp.x = ret;
      tmp.y = ret;
    }
  }
  return tmp;
}
Beispiel #27
0
void IPXMenic::filterIPXPackets()
{
	vector<unsigned char> actualPacket;
	int i;

	for (i = 0; i < packets.size(); i++)
	{
		actualPacket = packets[i];

		if ((actualPacket[14] == 0xFF) && (actualPacket[15] == 0xFF) && 
			checkParams(actualPacket))
		{
			changeIPXPacket(&actualPacket);
			filtered->push_back(actualPacket);
		}
	}
}
Beispiel #28
0
int GEI_Unit_ActionOnPosition (int unit, int action, float x, float y){
  int ret = isInitialized("GEI_Unit_ActionOnPosition");
  if (ret == 0){
    LocalMapUnits::iterator u = ld.units->find(unit);
    ret = checkParams("GEI_Unit_ActionOnPosition", &u, true);
    if (ret == 0){
      // enregistrer la commande
      std::vector<float> params (3, 0);
      params[0] = x;
      params[1] = -1; // ce champs est rempli lors de l'éxécution de la
                      // commande (càd coté moteur du jeu)
      params[2] = y;
      addCommand(unit, action, params);
    }
  }
  return ret;
}
void SearchController::startAction()
{
    checkParams({"pattern", "category", "plugins"});

    if (!Utils::ForeignApps::pythonInfo().isValid())
        throw APIError(APIErrorType::Conflict, "Python must be installed to use the Search Engine.");

    const QString pattern = params()["pattern"].trimmed();
    const QString category = params()["category"].trimmed();
    const QStringList plugins = params()["plugins"].split('|');

    QStringList pluginsToUse;
    if (plugins.size() == 1) {
        const QString pluginsLower = plugins[0].toLower();
        if (pluginsLower == "all")
            pluginsToUse = SearchPluginManager::instance()->allPlugins();
        else if ((pluginsLower == "enabled") || (pluginsLower == "multi"))
            pluginsToUse = SearchPluginManager::instance()->enabledPlugins();
        else
            pluginsToUse << plugins;
    }
    else {
        pluginsToUse << plugins;
    }

    ISession *const session = sessionManager()->session();
    auto activeSearches = session->getData<QSet<int>>(ACTIVE_SEARCHES);
    if (activeSearches.size() >= MAX_CONCURRENT_SEARCHES)
        throw APIError(APIErrorType::Conflict, QString("Unable to create more than %1 concurrent searches.").arg(MAX_CONCURRENT_SEARCHES));

    const auto id = generateSearchId();
    const SearchHandlerPtr searchHandler {SearchPluginManager::instance()->startSearch(pattern, category, pluginsToUse)};
    QObject::connect(searchHandler.data(), &SearchHandler::searchFinished, this, [session, id, this]() { searchFinished(session, id); });
    QObject::connect(searchHandler.data(), &SearchHandler::searchFailed, this, [session, id, this]() { searchFailed(session, id); });

    auto searchHandlers = session->getData<SearchHandlerDict>(SEARCH_HANDLERS);
    searchHandlers.insert(id, searchHandler);
    session->setData(SEARCH_HANDLERS, QVariant::fromValue(searchHandlers));

    activeSearches.insert(id);
    session->setData(ACTIVE_SEARCHES, QVariant::fromValue(activeSearches));

    const QJsonObject result = {{"id", id}};
    setResult(result);
}
Beispiel #30
0
void TCP_UDPMenic::filterUDPPackets()
{
	vector<unsigned char> actualPacket;
	int i;

	for (i = 0; i < packets.size(); i++)
	{
		actualPacket = packets[i];
		if ((actualPacket[23] == 0x11) && checkParams(actualPacket))
		{
			changeUDPPacket(&actualPacket);
			calculateChecksumTCP_UDP(&actualPacket, "UDP");
			calculateChecksumIPv4(&actualPacket);
			filtered->push_back(actualPacket);
		}

	}
}