void Texture2D::loadImage(const Image& inImage, GLenum inEdgeMode,
        bool inEnableMipmapping)
    {
        bind();

        if (inEnableMipmapping)
        {
            const GLenum params1[] = {
                GL_TEXTURE_WRAP_S, inEdgeMode,
                GL_TEXTURE_WRAP_T, inEdgeMode,
                GL_TEXTURE_MAG_FILTER, GL_LINEAR,
                0 };

            const GLenum params2[] = {
                GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR,
                0 };

            processParams(params1);
            inImage.loadIntoTexture(mTarget);
            glGenerateMipmap(mTarget);
            processParams(params2);
        }
        else
        {
            const GLenum params[] = {
                GL_TEXTURE_WRAP_S, inEdgeMode,
                GL_TEXTURE_WRAP_T, inEdgeMode,
                GL_TEXTURE_MAG_FILTER, GL_LINEAR,
                GL_TEXTURE_MIN_FILTER, GL_LINEAR,
                0 };

            processParams(params);
            inImage.loadIntoTexture(mTarget);
        }
    }
Example #2
0
int main(int argc, char *argv[])
{
	std::string url, path;
	int port;
	int res = processParams(argc, argv, url, port, path);
	if (res > 0)
	{
		std::cerr << "Program run with incorrect arguments." << std::endl;
		return res;
	}

	installSigPipeHandle();

	Client client;
	if (!client.init(url, port))
		return 10;

	if (!client.requestFile(path))
	{
		client.release();
		std::cerr << "File transfer was unsuccessful." << std::endl;
		return 50;
	}

	client.release();
	return 0;
}
Example #3
0
Model::Model(
  const Configuration & configuration,
  const ModelBlock &            MB,
  const FactoryBlock &  factory_block)
  : DevicePDEModel(MB, configuration.getModelParameters(), factory_block)
{
  processParams ();
}
Example #4
0
int
main (int argc, char *argv[])
{
  int code;
  TParams tp = {.mat1.add = NULL,.mat2.add = NULL };
  if ((code = processParams (&tp, argc, argv)) != RET_OK)
    {
      errmsg (code);
      return EXIT_FAILURE;
    };
  switch (tp.function)
    {
    case 0:
      errmsg (RET_OK);
      break;
    case 1:
      code = sucet (&(tp.mat1), &(tp.mat2));
      break;
    case 2:
      code = sucin (&(tp.mat1), &(tp.mat2));
      break;
    case 3:
      code = submatrix (&(tp.mat1), &(tp.mat2));
      break;
    case 4:
      code = crot (&(tp.mat1));
      break;
    case 5:
      code = plough (&(tp.mat1));
      break;
    case 6:
      code = sudoku (&(tp.mat1));
      break;
    default:
      return EXIT_FAILURE;
    }

  if (tp.mat1.add != NULL)
    {
      freeMat (&(tp.mat1));
    }


  if (tp.mat2.add != NULL)
    {
      freeMat (&(tp.mat2));
    }


  if (code != RET_OK)
    {
      errmsg (code);
      return EXIT_FAILURE;
    }

  return EXIT_SUCCESS;
}
Example #5
0
    void Texture2D::loadImage(const Image& inImage)
    {
        const GLenum params1[] = {
            GL_TEXTURE_WRAP_S, GL_REPEAT,
            GL_TEXTURE_WRAP_T, GL_REPEAT,
            GL_TEXTURE_MAG_FILTER, GL_LINEAR,
            0 };

        const GLenum params2[] = {
            GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR,
            0 };

        bind();
        processParams(params1);
        inImage.loadIntoTexture(mTarget);
        glGenerateMipmap(mTarget);
        processParams(params2);
    }
Example #6
0
static int
handleLoginResp(isess_t *sess, pdu_t *pp)
{
    login_rsp_t *lp = (login_rsp_t *)pp;
    uint	st_class, status = ntohs(lp->status);

    debug_called(3);
    debug(4, "Tbit=%d csg=%d nsg=%d status=%x", lp->T, lp->CSG, lp->NSG, status);

    st_class  = status >> 8;
    if(status) {
        int	st_detail = status & 0xff;

        switch(st_class) {
        case 1: // Redirect
            switch(st_detail) {
            // the ITN (iSCSI target Name) requests a:
            case 1: // temporary address change
            case 2: // permanent address change
                status = 0;
            }
            break;

        case 2: // Initiator Error
            if(st_detail < CLASS1_ERRS)
                printf("0x%04x: %s\n", status, status_class1[st_detail]);
            break;

        case 3:
            if(st_detail < CLASS3_ERRS)
                printf("0x%04x: %s\n", status, status_class3[st_detail]);
            break;
        }
    }

    if(status == 0) {
        processParams(sess, pp);
        setOptions(sess, 0); // XXX: just in case ...

        if(lp->T) {
            isc_opt_t	*op = sess->op;

            if(sess->csg == SN_PHASE && (op->tgtChapDigest != NULL))
                if(handleTgtResp(sess, pp) != 0)
                    return 1; // XXX: Authentication failure ...
            sess->csg = lp->NSG;
            if(sess->csg == FF_PHASE) {
                // XXX: will need this when implementing reconnect.
                sess->tsih = lp->tsih;
                debug(2, "TSIH=%x", sess->tsih);
            }
        }
    }

    return st_class;
}
Example #7
0
void Application::processMessage(const QString &message)
{
    QStringList params = message.split(QLatin1String(PARAMS_SEPARATOR), QString::SkipEmptyParts);
    // If Application is not running (i.e., other
    // components are not ready) store params
    if (m_running)
        processParams(params);
    else
        m_paramsQueue.append(params);
}
Example #8
0
QString OOoReportBuilder::processWord(const QString source)
{
    if (source.isEmpty())
        return QString();

    QString text = source;
    text.remove(QRegExp("\\{|\\}"));

    if (text[0] == 'P') {
        return processParams(text.mid(2));
    }

    return source;

}
Example #9
0
bool Connection::processRecord(const FCGIRecord & rec)
{
    MLOG_MESSAGE(Debug, "processRecord(type: " << static_cast<int>(rec.type) << ", len: " << mstd::ntoh(rec.contentLength) << 
                        ", request: " << mstd::ntoh(rec.requestId) << ", padding: " << rec.paddingLength << ")");

    char * begin = &buffer_[0] + sizeof(rec);
    switch(rec.type) {
    case FCGI_BEGIN_REQUEST:
        {
            FCGIBeginRequestBody * body = mstd::pointer_cast<FCGIBeginRequestBody*>(begin);
            keepAlive_ = (body->flags & FCGI_KEEP_CONN) != 0;
            stream_.clear();
        }
        break;
    case FCGI_PARAMS:
        {
            if(rec.contentLength)
                stream_.insert(stream_.end(), begin, begin + mstd::ntoh(rec.contentLength));
            else {
                processParams();
                stream_.clear();
            }
        }
        break;
    case FCGI_STDIN:
        {
            if(rec.contentLength)
                stream_.insert(stream_.end(), begin, begin + mstd::ntoh(rec.contentLength));
            else {
                RequestPtr request(new Request);
                requestId_ = mstd::ntoh(rec.requestId);
                request->params.swap(params_);
                request->body = stream_.empty() ? nexus::Buffer::blank() : nexus::Buffer(&stream_[0], stream_.size());
                stream_.clear();
                (*socket_)->get_io_service().post(boost::bind(requestHandler_, request, ptr()));
                if(!keepAlive_)
                    return false;
            }
        }
        break;
    default:
        MLOG_MESSAGE(Warning, "Unexpected type: " << static_cast<int>(rec.type));
        break;
    }
    return true;
}
Example #10
0
bool Application::event(QEvent *ev)
{
    if (ev->type() == QEvent::FileOpen) {
        QString path = static_cast<QFileOpenEvent *>(ev)->file();
        if (path.isEmpty())
            // Get the url instead
            path = static_cast<QFileOpenEvent *>(ev)->url().toString();
        qDebug("Received a mac file open event: %s", qUtf8Printable(path));
        if (m_running)
            processParams(QStringList(path));
        else
            m_paramsQueue.append(path);
        return true;
    }
    else {
        return BaseApplication::event(ev);
    }
}
Example #11
0
void Channel::draw() {   // each frame, process the parameters first, then draw the effect
	processParams();
	effect->draw();
}
Example #12
0
OSSim::OSSim(int32_t argc, char **argv, char **envp)
    : traceFile(0)
    ,snapshotGlobalClock(0)
    ,finishWorkNowCB(&cpus)
{
    I(osSim == 0);
    osSim = this;

    //  signal(SIGSEGV,sescConfSignal);

    signal(SIGUSR1,signalCatcher);
    signal(SIGQUIT,signalCatcher);

    char *tmp=(char *)malloc(argc*50+4096);
    tmp[0] = 0;
    for(int32_t i = 0; i < argc; i++) {
        strcat(tmp,argv[i]);
        strcat(tmp," ");
    }

    benchRunning=tmp;

    benchSection = 0;

#ifndef SESC_PASS_ENVIRONMENT
    // The problem of passign the environment is that the stack size is
    // different depending of the machine where the simulator is
    // running. This produces different results. Incredible but true
    // (ask Basilio if you don't believe it)

    // JJ
    // hack for parsec
    char *nenv[3];
    int envpassed =  0;
    char * threads = getenv("OMP_NUM_THREADS");
    if (threads) {
        int bufsize = strlen("OMP_NUM_THREADS")+1+strlen(threads);
        char * buf = new char[bufsize];
        sprintf(buf,"OMP_NUM_THREADS=%s",threads);
        nenv[0] = buf;
        envpassed++;
        //printf("Setting omp: %s threads\n", threads);
    }
    //fix for vips
    threads = getenv("IM_CONCURRENCY");
    if (threads) {
        int bufsize = strlen("IM_CONCURRENCY")+1+strlen(threads);
        char * buf = new char[bufsize];
        sprintf(buf,"IM_CONCURRENCY=%s",threads);
        nenv[0] = buf;
        envpassed++;
    }
    nenv[envpassed] = 0;

//  char *nenv[2];
//  nenv[0] = 0;
    processParams(argc,argv,nenv);
#else
    processParams(argc,argv,envp);
#endif

#ifdef SESC_ENERGY
    // initialize the energy subsystem
    EnergyMgr::init();
#endif
}
Example #13
0
int Application::exec(const QStringList &params)
{
    Net::ProxyConfigurationManager::initInstance();
    Net::DownloadManager::initInstance();
#ifdef DISABLE_GUI
    IconProvider::initInstance();
#else
    GuiIconProvider::initInstance();
#endif

    try {
        BitTorrent::Session::initInstance();
        connect(BitTorrent::Session::instance(), &BitTorrent::Session::torrentFinished, this, &Application::torrentFinished);
        connect(BitTorrent::Session::instance(), &BitTorrent::Session::allTorrentsFinished, this, &Application::allTorrentsFinished, Qt::QueuedConnection);

#ifndef DISABLE_COUNTRIES_RESOLUTION
        Net::GeoIPManager::initInstance();
#endif
        ScanFoldersModel::initInstance(this);

#ifndef DISABLE_WEBUI
        m_webui = new WebUI;
#ifdef DISABLE_GUI
        if (m_webui->isErrored())
            return 1;
        connect(m_webui, &WebUI::fatalError, this, []() { QCoreApplication::exit(1); });
#endif // DISABLE_GUI
#endif // DISABLE_WEBUI

        new RSS::Session; // create RSS::Session singleton
        new RSS::AutoDownloader; // create RSS::AutoDownloader singleton
    }
    catch (const RuntimeError &err) {
#ifdef DISABLE_GUI
        fprintf(stderr, "%s", err.what());
#else
        QMessageBox msgBox;
        msgBox.setIcon(QMessageBox::Critical);
        msgBox.setText(tr("Application failed to start."));
        msgBox.setInformativeText(err.message());
        msgBox.show(); // Need to be shown or to moveToCenter does not work
        msgBox.move(Utils::Misc::screenCenter(&msgBox));
        msgBox.exec();
#endif
        return 1;
    }

#ifdef DISABLE_GUI
#ifndef DISABLE_WEBUI
    Preferences *const pref = Preferences::instance();
    // Display some information to the user
    const QString mesg = QString("\n******** %1 ********\n").arg(tr("Information"))
        + tr("To control qBittorrent, access the Web UI at %1")
            .arg(QString("http://localhost:") + QString::number(pref->getWebUiPort())) + '\n';
    printf("%s", qUtf8Printable(mesg));

    if (pref->getWebUIPassword() == "ARQ77eY1NUZaQsuDHbIMCA==:0WMRkYTUWVT9wVvdDtHAjU9b3b7uB8NR1Gur2hmQCvCDpm39Q+PsJRJPaCU51dEiz+dTzh8qbPsL8WkFljQYFQ==") {
        const QString warning = tr("The Web UI administrator username is: %1").arg(pref->getWebUiUsername()) + '\n'
            + tr("The Web UI administrator password is still the default one: %1").arg("adminadmin") + '\n'
            + tr("This is a security risk, please consider changing your password from program preferences.") + '\n';
        printf("%s", qUtf8Printable(warning));
    }
#endif // DISABLE_WEBUI
#else
    m_window = new MainWindow;
#endif // DISABLE_GUI

    m_running = true;

    // Now UI is ready to process signals from Session
    BitTorrent::Session::instance()->startUpTorrents();

    m_paramsQueue = params + m_paramsQueue;
    if (!m_paramsQueue.isEmpty()) {
        processParams(m_paramsQueue);
        m_paramsQueue.clear();
    }
    return BaseApplication::exec();
}
Example #14
0
bool Recab::processReadBuildTable(SamRecord& samRecord)
{
    static BaseData data;
    static std::string chromosomeName;
    static std::string readGroup;
    static std::string aligTypes;

    int seqLen = samRecord.getReadLength();
    
    // Check if the parameters have been processed.
    if(!myParamsSetup)
    {
        // This throws an exception if the reference cannot be setup.
        processParams();
    }

    uint16_t  flag = samRecord.getFlag();

    if(!SamFlag::isMapped(flag))
    {
        // Unmapped, skip processing
        ++myUnMappedCount;
    }
    else
    {
        // This read is mapped.
        ++myMappedCount;
    }

    if(SamFlag::isSecondary(flag))
    {
        // Secondary read
        ++mySecondaryCount;
    }
    if(SamFlag::isDuplicate(flag))
    {
        ++myDupCount;
    }
    if(SamFlag::isQCFailure(flag))
    {
        ++myQCFailCount;
    }

    // Check if the flag contains an exclude.
    if((flag & myIntBuildExcludeFlags) != 0)
    {
        // Do not use this read for building the recalibration table.
        ++myNumBuildSkipped;
        return(false);
    }

    if(samRecord.getMapQuality() == 0)
    {
        // 0 mapping quality, so skip processing.
        ++myMapQual0Count;
        ++myNumBuildSkipped;
        return(false);
    }
    if(samRecord.getMapQuality() == 255)
    {
        // 255 mapping quality, so skip processing.
        ++myMapQual255Count;
        ++myNumBuildSkipped;
        return(false);
    }
    
    chromosomeName = samRecord.getReferenceName();
    readGroup = samRecord.getString("RG").c_str();

    // Look for the read group in the map.
    // TODO - extra string constructor??
    RgInsertReturn insertRet = 
        myRg2Id.insert(std::pair<std::string, uint16_t>(readGroup, 0));
    if(insertRet.second == true)
    {
        // New element inserted.
        insertRet.first->second = myId2Rg.size();
        myId2Rg.push_back(readGroup);
    }

    data.rgid = insertRet.first->second;


    //reverse
    bool reverse;
    if(SamFlag::isReverse(flag))
        reverse = true;
    else
        reverse = false;

    if(myReferenceGenome == NULL)
    {
        throw std::runtime_error("Failed to setup Reference File.\n");
    }

    genomeIndex_t mapPos = 
        myReferenceGenome->getGenomePosition(chromosomeName.c_str(), 
                                             samRecord.get1BasedPosition());

    if(mapPos==INVALID_GENOME_INDEX)
    {
    	Logger::gLogger->warning("INVALID_GENOME_INDEX (chrom:pos %s:%ld) and record skipped... Reference in BAM is different from the ref used here!", chromosomeName.c_str(), samRecord.get1BasedPosition());

        ++myNumBuildSkipped;
        return false;
    }

    if(!myQField.IsEmpty())
    {
        // Check if there is an old quality.
        const String* oldQPtr = 
            samRecord.getStringTag(myQField.c_str());
        if((oldQPtr != NULL) && (oldQPtr->Length() == seqLen))
        {
            // There is an old quality, so use that.
            myQualityStrings.oldq = oldQPtr->c_str();
        }
        else
        {
            // Tag was not found, so use the current quality.
            ++myNumQualTagErrors;
            if(myNumQualTagErrors == 1)
            {
                Logger::gLogger->warning("Recab: %s tag was not found/invalid, so using the quality field in records without the tag", myQField.c_str());
            }
            myQualityStrings.oldq = samRecord.getQuality();
        }
        //printf("%s\n",samRecord.getQuality());
        //printf("%s:%s\n",myQField.c_str(),temp.c_str());
    }
    else
    {
        myQualityStrings.oldq = samRecord.getQuality();
    }

    if(myQualityStrings.oldq.length() != (unsigned int)seqLen)
    {
        Logger::gLogger->warning("Quality is not the correct length, so skipping recalibration on that record.");
        ++myNumBuildSkipped;
        return(false);
    }

    aligTypes = "";
    Cigar* cigarPtr = samRecord.getCigarInfo();

    if(cigarPtr == NULL)
    {
        Logger::gLogger->warning("Failed to get the cigar");
        ++myNumBuildSkipped;
        return(false);
    }

    // This read will be used for building the recab table.
    ++myNumBuildReads;

    ////////////////
    ////// iterate sequence
    ////////////////
    genomeIndex_t refPos = 0;
    int32_t refOffset = 0;
    int32_t prevRefOffset = Cigar::INDEX_NA;
    int32_t seqPos = 0;
    int seqIncr = 1;
    if(reverse)
    {
        seqPos = seqLen - 1;
        seqIncr = -1;
    }

    // read
    if(!SamFlag::isPaired(flag) || SamFlag::isFirstFragment(flag))
        // Mark as first if it is not paired or if it is the
        // first in the pair.
        data.read = 0;
    else
        data.read = 1;

    // Set unsetbase for curBase.
    // This will be used for the prebase of cycle 0.
    data.curBase = 'K';

    for (data.cycle = 0; data.cycle < seqLen; data.cycle++, seqPos += seqIncr)
    {
        // Store the previous current base in preBase.
        data.preBase = data.curBase;

        // Get the current base before checking if we are going to
        // process this position so it will be set for the next position.
        data.curBase = samRecord.getSequence(seqPos);
        if(reverse)
        {
            // Complement the current base.
            // The prebase is already complemented.
            data.curBase = 
                BaseAsciiMap::base2complement[(unsigned int)(data.curBase)];
        }
        
        // Get the reference offset.
        refOffset = cigarPtr->getRefOffset(seqPos);
        if(refOffset == Cigar::INDEX_NA)
        {
            // Not a match/mismatch, so continue to the next one which will
            // not have a previous match/mismatch.
            // Set previous ref offset to a negative so
            // the next one won't be kept.
            prevRefOffset = -2;
            continue;
        }

        // This one is a match.
        refPos = mapPos + refOffset;

        // Check to see if we should process this position.
        // Do not process if it is cycle 0 and:
        //   1) current base is in dbsnp
        if(data.cycle == 0)
        {
            if(!(myDbsnpFile.IsEmpty()) && myDbSNP[refPos])
            {
                // Save the previous reference offset.
                ++myNumDBSnpSkips;
                prevRefOffset = refOffset;
                continue;
            }
        }
        else
        {
            // Do not process if it is not cycle 0 and:
            //   1) previous reference position not adjacent 
            //      (not a match/mismatch)
            //   2) previous base is in dbsnp
            //   3) current base is in dbsnp
            if((!myKeepPrevNonAdjacent && (refOffset != (prevRefOffset + seqIncr))) ||
               (data.preBase == 'K'))
            {
                // Save the previous reference offset.
                prevRefOffset = refOffset;
                continue;
            }
            if(!(myDbsnpFile.IsEmpty()) && 
               (myDbSNP[refPos] ||
                (!myKeepPrevDbsnp && myDbSNP[refPos - seqIncr])))
            {
                ++myNumDBSnpSkips;
                // Save the previous reference offset.
                prevRefOffset = refOffset;
                continue;
            }
       }
        
        // Save the previous reference offset.
        prevRefOffset = refOffset;

        // Set the reference & read bases in the Covariates
        char refBase = (*myReferenceGenome)[refPos];

        if(BaseUtilities::isAmbiguous(refBase))
        {
            // N reference, so skip it when building the table.
            ++myAmbiguous;
            continue;
        }

        if(reverse)
        {
            refBase = BaseAsciiMap::base2complement[(unsigned int)(refBase)];
        }

        // Get quality char
        data.qual = 
            BaseUtilities::getPhredBaseQuality(myQualityStrings.oldq[seqPos]);

        // skip bases with quality below the minimum set.
        if(data.qual < myMinBaseQual)
        {
            ++mySubMinQual;
            continue;
        }

        if(BaseUtilities::areEqual(refBase, data.curBase)
           && (BaseAsciiMap::base2int[(unsigned int)(data.curBase)] < 4))
            myBMatchCount++;
        else
            myBMismatchCount++;

        hasherrormodel.setCell(data, refBase);
        myBasecounts++;
    }
    return true;
}
Example #15
0
QDomElement OOoReportBuilder::processDetail(const QDomElement &rowDetail)
{
    QDomElement lastElement = rowDetail;

    if (rowDetail.isNull() || reportBand(rowDetail) != Detail)
        return QDomElement();

    QString textCell = cellText(rowDetail.firstChild().toElement());
    textCell.remove(QRegExp("\\{|\\}|detail"));
    int modelId = textCell.toInt() - 1;

    if (modelId < m_models.count() - 1) {
        rowDetail.parentNode().removeChild(rowDetail);
        return lastElement.previousSibling().toElement();
    }

    QAbstractItemModel *model = m_models.at(modelId);

    for (int i = 0; i < model->rowCount(); i++) {
        QDomElement tmpRow = rowDetail.cloneNode(true).toElement();

        QDomElement cell = tmpRow.firstChild().toElement();
        cell = cell.nextSibling().toElement();

        while (!cell.isNull()) {
            QString str = cellText(cell);

            if (!str.isEmpty()) {
                str.remove(QRegExp("\\{|\\}"));

                if (!QString::compare(str,"rowno",Qt::CaseInsensitive)) {
                    setText(cell,QString::number(i));
                } else if (str[0] == 'P') {

                    QVariant var = processParams(str.mid(2));
                    if (var.type() == QVariant::Double) {
                        setText(cell,var.toDouble());
                    } else {
                        setText(cell,var.toString());
                    }
                } else {
                    QRegExp rx("col\\d{1,2}");

                    if (rx.indexIn(str) == 0) {
                        int colNo = str.remove(QRegExp("col")).toInt();
                        QVariant var = model->data(model->index(i,colNo));
                        if (colNo <= model->columnCount() - 1) {
                            if (var.type() == QVariant::Double) {
                                setText(cell, var.toDouble());
                            } else
                                setText(cell, var.toString());
                        } else
                            setText(cell,"Err");
                    } else
                        setText(cell,str);
                }
            }

            if (cell.attributes().contains("table:formula")) {
                QString formula = processFormula(cell.attribute("table:formula"), i);
                cell.setAttribute("table:formula",formula);
            }

            cell = cell.nextSibling().toElement();
        }

        lastElement = rowDetail.parentNode().insertBefore(tmpRow,rowDetail).toElement();
    }

    rowDetail.parentNode().removeChild(rowDetail);
    return lastElement;
}
Example #16
0
// update fi params with data from fi.input file
void updateFIParams(){
#ifdef MPI_ENABLED
	MPI_Comm_rank(MPI_COMM_WORLD, &currentRank);
#endif	
	char * line = NULL;
	char *name,*value;
    size_t len = 0;
    ssize_t read;
	FILE* fp;

	// initialize rand seed once
	srand(time(NULL));

	// init execution key
	//execKey = time(NULL);
	updateTimeStamp();
	fp = fopen(fiParams,"r");
	if (fp == NULL){
		printf("\nError:Coudn't find fi param file \"fi.in\"\n");
		exit(-1);
	}

	// read fault injection params
	while ((read = getline(&line, &len, fp)) != -1) {
	    name = getStrFieldByIndex(line,":\n",0);
	    value = getStrFieldByIndex(line,":\n",1);
	    processParams(name,value);
    }
	// select dyn instr only in fi mode
	if(pfs==0){
		// update interval size
		if(tf>0){
			intvsz = tf;
		}

		// update interval count
		if(dynFSCount>0 && intvsz>0){
			if(dynFSCount%intvsz==0){
				intvCount = dynFSCount/intvsz;
			} else {
				intvCount = floor(dynFSCount/intvsz)+1;
			}
		}

		// update target dynamic FS indices only once at runtime
		if(!fidatardflag){
			updateFSIdx();
		}
		if(dynFSIdx==NULL){
			printf("\nError:memory allocation failed for dynFSIdx!!\n");
			exit(-1);
		}
	}

	// write FI headers
	const char* instrfield = "Instr_Name";
	const char* originalVal = "Original_Value";
	const char* corruptedVal = "Corrupted_Value";
	const char* bitPosVal = "Bit_Position";
	if(!file_exists(fiStat) && pfs==0){
		writeFIData(instrfield,(void*)originalVal,(void*)corruptedVal,(void*)bitPosVal,StringTy,"w");
	}
#ifndef MPI_ENABLED
	printParams();
#endif
    checkParams();
    fidatardflag=1;
	fclose(fp);
	return;
}
Example #17
0
Browser::Browser()
{	
	string input, destination, newpath;
	path = "/";
	vector<string> params;
	
	// pass buffer
	manager.setBuffer(&buffer);
	
	string command;
	pwd = Folder(0, 0, "root");

	// WELCOME
	//printw("%s", "## Welcome in Rapidshare Manager \n");
	//printw("%s", "rs#~/ ");
	
	//refresh();
	//move(linenum,6);
	//cout << "## Welcome in Rapidshare Manager" << endl;
	//cout << "rs#~/ ";
	
	while(true) {
		
		input = buffer.getCommand();
		//getline(cin, input);
		//printw("---- %s -----", input.c_str());
		trim(input);
		split(params, input, is_any_of(" "));

		command = params[0];
	
		if(command == "ls"){
			manager.listFolder(pwd);
		}
		if(command == "help"){
			showHelp();
		}
		if(command == "mv"){
			
			params = processParams(input, command, 2);
			
			mv(getCurrentPath(params[0]), getCurrentPath(params[1]));
			
		}
		if(command == "cd"){
			
			params = processParams(input, "cd", 1);
					
			if(params[0] == ".."){
				if(!pwd.isRoot()){
					pwd = manager.getFolder(pwd.parent);
					path = pwd.path;
				}else{
					path = "/";
				}
					
			}else{		
				
				if(pwd.isRoot()){
					path = pwd.path + params[0];
				}else{
					path = pwd.path + "/" + params[0];
				}
				
				if(manager.getFolder(path).notFound()) {
					cout << "not found" << endl;
				}else{
					pwd = manager.getFolder(path);
				}			
			}
			
		}
		if(command == "cp"){	
			
			params = processParams(input, "cp", 2);		
			if(params.size() == 2){
				bool local = isLocal(params[0]);
				string destination;
				
				if(local){
					destination = getCurrentPath(params[1]);
					path = params[0];
					
				}else{				
					path = getCurrentPath(params[0]);
					destination = params[1];
				
				}
				copy(path, destination, local);				
			}
			
		}
		if(command == "pwd"){
			cout << pwd.path << endl;
		}
		if(command == "play"){
			
			
			params = processParams(input, command, 1);	
			/*if(params.size() == 1){
				
				bool isNumber = true;
				// jedna se o cislo?
				for(int i = 0; i < (int)params.size();i++){
					if(!isdigit(params[0][i])){
						isNumber = false;
					}
				}
				
				if(isNumber){
					play(pwd.path, lexical_cast<int>(params[0]));
				}else{
					play(getCurrentPath(params[0]));
				}
				
			}else{
				cout << "Wrond number of params" << endl;
			}*/

			
			
			
		}
		if(command == "clear"){
			system("clear");
		}
		if(command == "mkdir")
		{
			params = processParams(input, command, 1);
			mkdir(pwd.path, params[0]);
		}
		if(command == "rename"){
			
			params = processParams(input, "rename", 2);
			path = getCurrentPath(params[0]);
			rename(path, params[1]);
		}
		if(command == "rm")
		{
			
			params = processParams(input, command, 1);
			path = getCurrentPath(params[0]);
			rm(path);
			
		}
		if(command == "exit"){
			
			// ukoncime ncurses
			endwin();
			exit(1);
		}
		
		//cout  << "rs#~" << pwd.path << " ";
		buffer.changeStart("rs#~" + pwd.path + " ");
		buffer.writeStart();
		
	};
	
	cout << endl;
}
Example #18
0
// Constructor
MainWindow::MainWindow(QWidget *parent, QStringList torrentCmdLine)
    :
      QMainWindow(parent),
      m_posInitialized(false),
      force_exit(false),
      icon_TrayConn(res::trayConnected()),
      icon_TrayDisconn(res::trayDisconnected()),
      icon_CurTray(icon_TrayDisconn)
{
    setupUi(this);
    stackedWidget->addWidget(new transfers_widget(this));
    stackedWidget->addWidget(new search_widget(this));
    stackedWidget->addWidget(new preferences_widget(this));
    stackedWidget->setCurrentIndex(0);
    setWindowTitle(tr("qDonkey %1").arg(misc::versionString()));
    QCoreApplication::instance()->installEventFilter(this);

    //QApplication::setOverrideCursor(Qt::WaitCursor);
    m_last_file_error = QDateTime::currentDateTime().addSecs(-1); // imagine last file error event was 1 seconds in past

#ifdef Q_WS_WIN
    m_nTaskbarButtonCreated = RegisterWindowMessage(L"TaskbarButtonCreated");
#else
    m_nTaskbarButtonCreated = 0;
#endif

    Preferences pref;

    // Clean exit on log out
    connect(static_cast<SessionApplication*>(qApp), SIGNAL(sessionIsShuttingDown()), this, SLOT(deleteSession()));

    this->setWindowIcon(QIcon(res::favicon()));

#ifdef Q_WS_MAC
    connect(static_cast<QMacApplication*>(qApp), SIGNAL(newFileOpenMacEvent(QString)), this, SLOT(processParams(QString)));
#endif

    statusBar = new status_bar(this, QMainWindow::statusBar());
    m_pwr = new PowerManagement(this);

    // Configure session according to options
    loadPreferences(false);

    // Start connection checking timer
    guiUpdater = new QTimer(this);
    connect(guiUpdater, SIGNAL(timeout()), this, SLOT(updateGUI()));
    guiUpdater->start(2000);

    // Accept drag 'n drops
    //setAcceptDrops(true);
    createKeyboardShortcuts();

#ifdef Q_WS_MAC
    setUnifiedTitleAndToolBarOnMac(true);
#endif

    // View settings



    // Auto shutdown actions
/*    QActionGroup * autoShutdownGroup = new QActionGroup(this);
    autoShutdownGroup->setExclusive(true);
    autoShutdownGroup->addAction(actionAutoShutdown_Disabled);
    autoShutdownGroup->addAction(actionAutoExit_mule);
    autoShutdownGroup->addAction(actionAutoShutdown_system);
    autoShutdownGroup->addAction(actionAutoSuspend_system);

#if !defined(Q_WS_X11) || defined(QT_DBUS_LIB)
    actionAutoShutdown_system->setChecked(pref.shutdownWhenDownloadsComplete());
    actionAutoSuspend_system->setChecked(pref.suspendWhenDownloadsComplete());
#else
    actionAutoShutdown_system->setDisabled(true);
    actionAutoSuspend_system->setDisabled(true);
#endif

    actionAutoExit_mule->setChecked(pref.shutdownqBTWhenDownloadsComplete());

    if (!autoShutdownGroup->checkedAction())
        actionAutoShutdown_Disabled->setChecked(true);
*/

    readSettings();

    show();
    activateWindow();
    raise();

    // Start watching the executable for updates
    executable_watcher = new QFileSystemWatcher();
    connect(executable_watcher, SIGNAL(fileChanged(QString)), this, SLOT(notifyOfUpdate(QString)));
    executable_watcher->addPath(qApp->applicationFilePath());

    // Add torrent given on command line
    processParams(torrentCmdLine);
#ifdef Q_WS_MAC
    //qt_mac_set_dock_menu(icon_CurTray);
#endif

    // Make sure the Window is visible if we don't have a tray icon
    if (!systrayIcon && isHidden())  {
        show();
        activateWindow();
        raise();
    }

    connect(Session::instance(), SIGNAL(serverNameResolved(QString)), this, SLOT(handleServerNameResolved(QString)));
    connect(Session::instance(), SIGNAL(serverConnectionInitialized(quint32,quint32,quint32)), this, SLOT(handleServerConnectionInitialized(quint32,quint32,quint32)));
    connect(Session::instance(), SIGNAL(serverConnectionClosed(QString)), this, SLOT(handleServerConnectionClosed(QString)));
    connect(Session::instance(), SIGNAL(serverStatus(int,int)), this, SLOT(handleServerStatus(int,int)));
    connect(Session::instance(), SIGNAL(serverMessage(QString)), this, SLOT(handleServerMessage(QString)));
    connect(Session::instance(), SIGNAL(serverIdentity(QString,QString)), this, SLOT(handleServerIdentity(QString,QString)));

    connect(Session::instance(), SIGNAL(transferAdded(QED2KHandle)), SLOT(addedTransfer(QED2KHandle)));
    connect(Session::instance(), SIGNAL(transferFinished(QED2KHandle)), SLOT(finishedTransfer(QED2KHandle)));

    //Tray actions.
    //connect(actionToggleVisibility, SIGNAL(triggered()), this, SLOT(toggleVisibility()));
    //connect(actionStart_All, SIGNAL(triggered()), Session::instance(), SLOT(resumeAllTransfers()));
    //connect(actionPause_All, SIGNAL(triggered()), Session::instance(), SLOT(pauseAllTransfers()));

    actionConnect->trigger();
    Session::instance()->loadDirectory(pref.inputDir());
}
Example #19
0
// As program parameters, we can get paths or urls.
// This function parse the parameters and call
// the right addTorrent function, considering
// the parameter type.
void MainWindow::processParams(const QString& params_str)
{
    processParams(QStringList(params_str));
}