コード例 #1
0
ファイル: array.c プロジェクト: fmccabe/cafe
retCode sliceDisp(ioPo out, termPo t, integer precision, integer depth, logical alt) {
  listPo list = C_LIST(t);
  basePo base = C_BASE(list->base);

  retCode ret = outChar(out, '[');

  if (depth > 0) {
    integer ix = list->start;
    integer lx = ix + list->length;
    integer maxIx = (precision == 0 ? list->length + 1 : precision);

    char *sep = "";

    while (ret == Ok && ix < lx && maxIx-- > 0) {
      ret = outStr(out, sep);
      sep = ", ";
      if (ret == Ok)
        ret = dispTerm(out, base->els[ix], precision, depth - 1, alt);
      ix++;
    }
    if (ret == Ok && maxIx <= 0) {
      ret = outStr(out, "..");
    }
  } else if (ret == Ok)
    ret = outStr(out, "..");

  if (ret == Ok)
    ret = outChar(out, ']');
  return ret;
}
コード例 #2
0
ファイル: array.c プロジェクト: fmccabe/cafe
retCode baseDisp(ioPo out, termPo t, integer precision, integer depth, logical alt) {
  basePo base = C_BASE(t);

  retCode ret = outStr(out, "<");

  if (depth > 0) {
    integer ix = base->min;
    integer lx = base->max;

    char *sep = "";

    while (ret == Ok && ix < lx) {
      ret = outStr(out, sep);
      sep = ", ";
      if (ret == Ok)
        ret = dispTerm(out, base->els[ix], precision, depth - 1, alt);
      ix++;
    }
  } else if (ret == Ok)
    ret = outStr(out, "..");

  if (ret == Ok)
    ret = outStr(out, ">");
  return ret;
}
コード例 #3
0
ファイル: cell.c プロジェクト: fmccabe/cafe
retCode cellDisp(ioPo out, termPo t, integer precision, integer depth, logical alt) {
  cellPo cell = C_CELL(t);

  retCode ret = outStr(out, "{");
  if (ret == Ok) {
    if (depth > 0)
      ret = dispTerm(out, cell->content, precision, depth - 1, alt);
    else
      ret = outStr(out, "..");
  }
  if (ret == Ok)
    ret = outStr(out, "}");
  return ret;
}
コード例 #4
0
ファイル: zmserver.cpp プロジェクト: fastcat/mythtv
void ZMServer::handleHello()
{
    // just send OK so the client knows all is well
    // followed by the protocol version we understand
    string outStr("");
    ADD_STR(outStr, "OK");
    ADD_STR(outStr, ZM_PROTOCOL_VERSION);
    send(outStr);
}
コード例 #5
0
ファイル: SkpSkGrTest.cpp プロジェクト: MIPS/external-skia
 bool match(const SkString& filename, SkFILEWStream* stream, TestResult* result) {
     if (fIndex < fResults.count()) {
         *result = fResults[fIndex++];
         SkASSERT(filename.equals(result->fFilename));
         SkString outStr(result->status());
         stream->write(outStr.c_str(), outStr.size());
         stream->flush();
         return true;
     }
     return false;
 }
コード例 #6
0
string fileList::compile()
{
    string outStr(STANDARD_FILELIST_HEADER);
    outStr+="\n";
    for(list<fileList::entry>::iterator it=filelst.begin();
    it!=filelst.end(); ++it)
    {
        outStr+=it->getpath();
        outStr+="\n";
    }
    return outStr;
}
コード例 #7
0
void ServerThread::registerNewClient(MessageEnvelop &e)
{
    if(database->existsUser(e.getName().toStdString()))
    {
        sendError("The Username already exists M'kay, pick another one M'kay");
        emit error(this->s->error());
        return;
    }
    std::ifstream rand("/dev/urandom",std::ios::binary);
    char * newSalt = new char[8];
    rand.read(newSalt, 8);
    rand.close();
    char * corrSalt = getAscii85(newSalt, 8);
    delete[] newSalt;


    std::string s(e.getPassword().toStdString()), qCorrSalt(corrSalt);
    s = s + qCorrSalt;

    free(corrSalt);
    unsigned char hash[32];
    char *printableHash;

    sha2((unsigned char *) s.c_str(), s.length(), hash, 0);
    printableHash = getAscii85((char*) hash, 32);
    QString pass(printableHash), Qsalt(qCorrSalt.c_str());
    try
    {
        database->insertUser(e.getName().toStdString(), pass.toStdString(),
                         Qsalt.toStdString());
    }
    catch(SqlConnection::SqlException e)
    {
        sendError("The user was not added");
        emit error(this->s->error());
        return;
    }

    QByteArray b;
    QDataStream outStr(&b, QIODevice::WriteOnly);
    MessageEnvelop ret(REGISTER_APROOVED);

    isInitialized = false;
    outStr << ret;

    this->s->write(b);





}
コード例 #8
0
    std::string StdStringFromAsciiVString(const XBOX::VString inStr)
    {
        int len=inStr.GetLength();
        char* buf=new char[len];

        if(!buf)
            return std::string();

        inStr.ToBlock(buf, len, XBOX::VTC_US_ASCII, false, false);

        std::string outStr(buf, len);
        delete[] buf;

        return outStr;
    }
コード例 #9
0
ファイル: debug.c プロジェクト: fmccabe/cafe
static DebugWaitFor dbgShowCode(char *line, processPo p, termPo loc, insWord ins, void *cl) {
  integer count = maximum(1, cmdCount(line, 1));
  methodPo mtd = p->prog;
  insPo pc = p->pc;

  insPo last = entryPoint(mtd) + insCount(mtd);

  for (integer ix = 0; ix < count && pc < last; ix++) {
    pc = disass(debugOutChnnl, p, mtd, pc, Null, Null);
    outStr(debugOutChnnl, "\n");
  }

  flushFile(debugOutChnnl);
  resetDeflt("n");

  return moreDebug;
}
コード例 #10
0
ファイル: tools.hpp プロジェクト: miherius/DirChangesWatcher
boost::shared_array<WCHAR> DuplicateStringW(LPCWSTR inStr)
{
	int len = 0;
	
	if(!inStr)
		throw INVALID_ARGUMENT_EXCEPTION_1("inStr");
	
	len = lstrlenW(inStr);
	
	++len;
	boost::shared_array<WCHAR> outStr(new WCHAR[len]);
	
	HRESULT hResult = StringCchCopyW(outStr.get(), len, inStr);
	if(FAILED(hResult))
		throw WIN32EXCEPTION_FROM_HRESULT_2(hResult, "StringCchCopyW");

	return outStr;
}
コード例 #11
0
void LatexTables::addRow(QDocumentCursor &c,const int numberOfColumns ){
	QDocumentCursor cur(c);
	bool stopSearch=false;
	if(cur.columnNumber()>1){
		cur.movePosition(2,QDocumentCursor::Left,QDocumentCursor::KeepAnchor);
		QString res=cur.selectedText();
		if(res=="\\\\") stopSearch=true;
		cur.movePosition(2,QDocumentCursor::Right);
	}
	const QStringList tokens("\\\\");
	int result=0;
	if(!stopSearch) result=findNextToken(cur,tokens);
	if(result==0 || result==-2){
		//if last line before end, check whether the user was too lazy to put in a linebreak
		if(result==-2){
			QDocumentCursor ch(cur);
			int res=findNextToken(ch,tokens,true,true);
			if(res==-2){
				cur.movePosition(1,QDocumentCursor::Left);
				cur.insertText("\\\\\n");
			}else{
				ch.movePosition(2,QDocumentCursor::Right,QDocumentCursor::KeepAnchor);
				if(ch.selectedText().contains(QRegExp("^\\S+$"))){
					cur.movePosition(1,QDocumentCursor::Left);
					cur.insertText("\\\\\n");
				}
			}
		}
		//
		//result=findNextToken(cur,tokens);
		cur.beginEditBlock();
		if(result>-2) cur.insertText("\n");
		QString str("& ");
		QString outStr(" ");
		for(int i=1;i<numberOfColumns;i++){
			outStr+=str;
		}
		cur.insertText(outStr);
		cur.insertText("\\\\");
		if(!cur.atLineEnd()) cur.insertText("\n");
		cur.endEditBlock();
	}
}
コード例 #12
0
void ServerThread::sendError(QString str)
{
    QByteArray bl;
    QDataStream outStr(&bl, QIODevice::WriteOnly);

    MessageEnvelop e(ERROR_SERVER_RESPONSE);
    e.setName(str);

    outStr << e;

    s->write(bl);
    s->disconnectFromHost();
    //s->waitForDisconnected();





}
コード例 #13
0
std::string eSDKTool::MergeString(const std::vector<std::string>& strList)
{
	unsigned int iSize = strList.size();
	std::string outStr("");
	if(iSize == 0)
	{
		return outStr;
	}
	if(iSize == 1)
	{
		outStr.append(strList.at(0));
		return outStr;
	}
	for(unsigned int i=0;i<(iSize-1);++i)
	{
		outStr.append(strList.at(i));
		outStr.append(",");
	}
	outStr.append(strList.at(iSize-1));
	return outStr;
}
コード例 #14
0
ファイル: RapMapMapper.cpp プロジェクト: COMBINE-lab/RapMap
void processReadsSingle(single_parser* parser,
        RapMapIndex& rmi,
	CollectorT& hitCollector,
        MutexT* iomutex,
	std::shared_ptr<spdlog::logger> outQueue,
        HitCounters& hctr,
        uint32_t maxNumHits,
        bool noOutput) {

    auto& txpNames = rmi.txpNames;
    auto& txpLens = rmi.txpLens;
    uint32_t n{0};
    uint32_t k = rapmap::utils::my_mer::k();
    std::vector<std::string> transcriptNames;
    constexpr char bases[] = {'A', 'C', 'G', 'T'};

    fmt::MemoryWriter sstream;
    size_t batchSize{1000};
    std::vector<QuasiAlignment> hits;

    SingleAlignmentFormatter<RapMapIndex*> formatter(&rmi);

    size_t readLen{0};

    while(true) {
        typename single_parser::job j(*parser); // Get a job from the parser: a bunch of read (at most max_read_group)
        if(j.is_empty()) break;           // If got nothing, quit
        for(size_t i = 0; i < j->nb_filled; ++i) { // For each sequence
            readLen = j->data[i].seq.length();
            ++hctr.numReads;
            hits.clear();
            hitCollector(j->data[i].seq, hits, MateStatus::SINGLE_END);
            /*
               std::set_intersection(leftHits.begin(), leftHits.end(),
               rightHits.begin(), rightHits.end(),
               std::back_inserter(jointHits));
               */
            auto numHits = hits.size();
            hctr.totHits += numHits;

             if (hits.size() > 0 and !noOutput and hits.size() <= maxNumHits) {
                rapmap::utils::writeAlignmentsToStream(j->data[i], formatter,
                        hctr, hits, sstream);
            }

            if (hctr.numReads > hctr.lastPrint + 1000000) {
		hctr.lastPrint.store(hctr.numReads.load());
                if (iomutex->try_lock()){
                    if (hctr.numReads > 0) {
#if defined(__DEBUG__) || defined(__TRACK_CORRECT__)
                        std::cerr << "\033[F\033[F\033[F";
#else
                        std::cerr << "\033[F\033[F";
#endif // __DEBUG__
                    }
                    std::cerr << "saw " << hctr.numReads << " reads\n";
                    std::cerr << "# hits per read = "
                        << hctr.totHits / static_cast<float>(hctr.numReads) << "\n";
#if defined(__DEBUG__) || defined(__TRACK_CORRECT__)
                    std::cerr << "The true hit was in the returned set of hits "
                        << 100.0 * (hctr.trueHits / static_cast<float>(hctr.numReads))
                        <<  "% of the time\n";
#endif // __DEBUG__
                    iomutex->unlock();
                }
            }
        } // for all reads in this job

	if (!noOutput) {
        std::string outStr(sstream.str());
        // Get rid of last newline
        if (!outStr.empty()) {
            outStr.pop_back();
            outQueue->info() << std::move(outStr);
        }
	    sstream.clear();
	}
	/*
        // DUMP OUTPUT
        iomutex->lock();
        outStream << sstream.str();
        iomutex->unlock();
        sstream.clear();
	*/

    } // processed all reads
}
コード例 #15
0
ファイル: zmserver.cpp プロジェクト: fastcat/mythtv
void ZMServer::sendError(string error)
{
    string outStr("");
    ADD_STR(outStr, string("ERROR - ") + error);
    send(outStr);
}
コード例 #16
0
ファイル: RapMapMapper.cpp プロジェクト: COMBINE-lab/RapMap
void processReadsPair(paired_parser* parser,
        RapMapIndex& rmi,
	CollectorT& hitCollector,
        MutexT* iomutex,
	std::shared_ptr<spdlog::logger> outQueue,
        HitCounters& hctr,
        uint32_t maxNumHits,
        bool noOutput) {
    auto& txpNames = rmi.txpNames;
    std::vector<uint32_t>& txpLens = rmi.txpLens;
    uint32_t n{0};
    uint32_t k = rapmap::utils::my_mer::k();
    std::vector<std::string> transcriptNames;
    constexpr char bases[] = {'A', 'C', 'G', 'T'};

    auto logger = spdlog::get("stderrLog");

    fmt::MemoryWriter sstream;
    size_t batchSize{1000};
    std::vector<QuasiAlignment> leftHits;
    std::vector<QuasiAlignment> rightHits;
    std::vector<QuasiAlignment> jointHits;

    PairAlignmentFormatter<RapMapIndex*> formatter(&rmi);

    size_t readLen{0};
	bool tooManyHits{false};

    JumpStats js;
    // 0 means properly aligned
    // 0x1 means only alignments for left read
    // 0x2 means only alignments for right read
    // 0x3 means "orphaned" alignments for left and right
    // (currently not treated as orphan).
    uint32_t orphanStatus{0};
    while(true) {
        typename paired_parser::job j(*parser); // Get a job from the parser: a bunch of read (at most max_read_group)
        if(j.is_empty()) break;           // If got nothing, quit
        for(size_t i = 0; i < j->nb_filled; ++i) { // For each sequence
	    tooManyHits = false;
            readLen = j->data[i].first.seq.length();
            ++hctr.numReads;
            jointHits.clear();
            leftHits.clear();
            rightHits.clear();
    	    hitCollector(j->data[i].first.seq,
                        leftHits, MateStatus::PAIRED_END_LEFT);
            hitCollector(j->data[i].second.seq,
                        rightHits, MateStatus::PAIRED_END_RIGHT);

            rapmap::utils::mergeLeftRightHits(
                    leftHits, rightHits, jointHits,
                    readLen, maxNumHits, tooManyHits, hctr);


            if (jointHits.size() > 0 and !noOutput and jointHits.size() <= maxNumHits) {
                rapmap::utils::writeAlignmentsToStream(j->data[i], formatter,
                                                       hctr, jointHits, sstream);
            }

            if (hctr.numReads > hctr.lastPrint + 1000000) {
		hctr.lastPrint.store(hctr.numReads.load());
                if (iomutex->try_lock()) {
                    if (hctr.numReads > 0) {
#if defined(__DEBUG__) || defined(__TRACK_CORRECT__)
                        std::cerr << "\033[F\033[F\033[F\033[F";
#else
                        std::cerr << "\033[F\033[F\033[F";
#endif // __DEBUG__
                    }
                    std::cerr << "saw " << hctr.numReads << " reads\n";
                    std::cerr << "# pe hits per read = "
                        << hctr.peHits / static_cast<float>(hctr.numReads) << "\n";
                    std::cerr << "# se hits per read = "
                        << hctr.seHits / static_cast<float>(hctr.numReads) << "\n";
#if defined(__DEBUG__) || defined(__TRACK_CORRECT__)
                    std::cerr << "The true hit was in the returned set of hits "
                        << 100.0 * (hctr.trueHits / static_cast<float>(hctr.numReads))
                        <<  "% of the time\n";
		    /*
                    std::cerr << "Average jump size = "
                              << js.jumpSizes / static_cast<double>(js.numJumps) << "\n";
			      */
#endif // __DEBUG__
                    iomutex->unlock();
                }
            }
        } // for all reads in this job

	if (!noOutput) {
        std::string outStr(sstream.str());
        // Get rid of last newline
        if (!outStr.empty()){
            outStr.pop_back();
            outQueue->info() << std::move(outStr);
        }
	    sstream.clear();
	}

        // DUMP OUTPUT
	/*
        if (!noOutput) {
            iomutex->lock();
            outStream << sstream.str();
            iomutex->unlock();
            sstream.clear();
        }
	*/

    } // processed all reads

}
コード例 #17
0
 const char* Quote::DoubleLeft (const char* str)
 {
   csStringBase& outStr (GetReturnString());
   DoubleLeft (outStr, str);
   return outStr;
 }
コード例 #18
0
ファイル: SkpSkGrTest.cpp プロジェクト: MIPS/external-skia
DEF_TEST(SkpSkGr, reporter) {
    SkTArray<TestResult, true> errors;
    if (!initTest()) {
        return;
    }
    SkpSkGrThreadState state;
    state.init(0);
    int smallCount = 0;
    for (int dirNo = 1; dirNo <= 100; ++dirNo) {
        SkString pictDir = make_in_dir_name(dirNo);
        SkASSERT(pictDir.size());
        if (reporter->verbose()) {
            SkDebugf("dirNo=%d\n", dirNo);
        }
        SkOSFile::Iter iter(pictDir.c_str(), "skp");
        SkString filename;
        int testCount = 0;
        PreParser preParser(dirNo);
        SkFILEWStream statusStream(makeStatusString(dirNo).c_str());
        while (iter.next(&filename)) {
            for (size_t index = 0; index < skipOverSkGrCount; ++index) {
                if (skipOverSkGr[index].directory == dirNo
                        && strcmp(filename.c_str(), skipOverSkGr[index].filename) == 0) {
                    goto skipOver;
                }
            }
            if (preParser.match(filename, &statusStream, &state.fResult)) {
                addError(&state);
                ++testCount;
                goto checkEarlyExit;
            }
            if (state.fSmallestError > 5000000) {
                goto breakOut;
            }
            {
                TestResult& result = state.fResult;
                result.test(dirNo, filename);
                SkString outStr(result.status());
                statusStream.write(outStr.c_str(), outStr.size());
                statusStream.flush();
                if (1) {
                    SkDebugf("%s", outStr.c_str());
                }
                bool noMatch = addError(&state);
                if (noMatch) {
                    smallCount = 0;
                } else if (++smallCount > 10000) {
                    goto breakOut;
                }
            }
            ++testCount;
            if (reporter->verbose()) {
                if (testCount % 100 == 0) {
                    SkDebugf("#%d\n", testCount);
                }
            }
     skipOver:
             reporter->bumpTestCount();
    checkEarlyExit:
            if (1 && testCount == 20) {
                break;
            }
        }
    }
breakOut:
    if (reporter->verbose()) {
        for (int index = 0; index < state.fFoundCount; ++index) {
            SkDebugf("%d %s %d\n", state.fDirsFound[index], state.fFilesFound[index],
                     state.fError[index]);
        }
    }
    for (int index = 0; index < state.fFoundCount; ++index) {
        TestResult::Test(state.fDirsFound[index], state.fFilesFound[index], kEncodeFiles,
                reporter->verbose());
        if (reporter->verbose()) SkDebugf("+");
    }
}
コード例 #19
0
 const char* Quote::SingleRight (const char* str)
 {
   csStringBase& outStr (GetReturnString());
   SingleRight (outStr, str);
   return outStr;
 }