コード例 #1
0
TEST_F(ScriptStreamingTest, CompilingStreamedScriptWithParseError)
{
    // Test that scripts with parse errors are handled properly. In those cases,
    // the V8 side typically finished before loading finishes: make sure we
    // handle it gracefully.
    ScriptStreamer::startStreaming(pendingScript(), m_settings.get(), m_scope.scriptState(), PendingScript::ParsingBlocking);
    TestScriptResourceClient client;
    pendingScript().watchForLoad(&client);
    appendData("function foo() {");
    appendData("this is the part which will be a parse error");
    // V8 won't realize the parse error until it actually starts parsing the
    // script, and this happens only when its buffer is filled.
    appendPadding();

    EXPECT_FALSE(client.finished());

    // Force the V8 side to finish before the loading.
    processTasksUntilStreamingComplete();
    EXPECT_FALSE(client.finished());

    finish();
    EXPECT_TRUE(client.finished());

    bool errorOccurred = false;
    ScriptSourceCode sourceCode = pendingScript().getSource(KURL(), errorOccurred);
    EXPECT_FALSE(errorOccurred);
    EXPECT_TRUE(sourceCode.streamer());
    v8::TryCatch tryCatch;
    v8::Handle<v8::Script> script = V8ScriptRunner::compileScript(sourceCode, isolate());
    EXPECT_TRUE(script.IsEmpty());
    EXPECT_TRUE(tryCatch.HasCaught());
}
コード例 #2
0
ファイル: 4-3.c プロジェクト: gsrr/Programs
void appendData(tNode** root, tNode* tmp)
{
        tNode* r = *root;
        int* ritem = (int*)r->item;
        int* titem = (int*)tmp->item;

        if(*titem < *ritem)
        {
                if(r->lchild == NULL)
                {
                        r->lchild = tmp;
                }
                else
                {
                        appendData(&(r->lchild), tmp);
                }
        }
        else
        {
                if(r->rchild == NULL)
                {
                        r->rchild = tmp;
                }
                else
                {
                        appendData(&(r->rchild), tmp);
                }
        }
}
コード例 #3
0
TEST_F(ScriptStreamingTest, CompilingStreamedScript)
{
    // Test that we can successfully compile a streamed script.
    ScriptStreamer::startStreaming(pendingScript(), m_settings.get(), m_scope.scriptState(), PendingScript::ParsingBlocking);
    TestScriptResourceClient client;
    pendingScript().watchForLoad(&client);

    appendData("function foo() {");
    appendPadding();
    appendData("return 5; }");
    appendPadding();
    appendData("foo();");
    EXPECT_FALSE(client.finished());
    finish();

    // Process tasks on the main thread until the streaming background thread
    // has completed its tasks.
    processTasksUntilStreamingComplete();
    EXPECT_TRUE(client.finished());
    bool errorOccurred = false;
    ScriptSourceCode sourceCode = pendingScript().getSource(KURL(), errorOccurred);
    EXPECT_FALSE(errorOccurred);
    EXPECT_TRUE(sourceCode.streamer());
    v8::TryCatch tryCatch;
    v8::Handle<v8::Script> script = V8ScriptRunner::compileScript(sourceCode, isolate());
    EXPECT_FALSE(script.IsEmpty());
    EXPECT_FALSE(tryCatch.HasCaught());
}
コード例 #4
0
    //hardcoded 3 vaste parameters maken. met daarin de waarden die worden meegegeven met de functie.
    void JsonClass::piData(char macaddress[],char cpu_temp[],char free_memory[],char piData[]){

        char * data1,*data2,*data3,*data4,*data5;

        buildData("macaddress",macaddress,data1);
        buildData("cpu_temp",cpu_temp,data2);
        buildData("freememory",free_memory,data3);

        appendData(data1,data2,data4);
        appendData(data4,data3,data5);

        eindeBuildData(data5,piData);
    }
コード例 #5
0
ファイル: CFBWriter.cpp プロジェクト: abhishekmurthy/Calligra
qint64 CFBWriter::StreamIODevice::internalWriteData(const char *data, qint64 len, qint64 pos)
{
    Q_ASSERT(pos >= 0 && pos <= size());
    if (pos == size()) {
        appendData(data, len);
        return len;
    } else {
        if (pos + len > size()) {
            len = size() - pos;
        }
        qint64 bufferStart = m_entry.streamSize;
        if (pos < bufferStart) {
            unsigned sectorIndex = pos / m_writer.m_sectorSize;
            unsigned sector = m_entry.firstSector;
            while (sectorIndex--) {
                sector = m_writer.m_fat[sector];
            }
            unsigned sectorOffset = pos % m_writer.m_sectorSize;
            if (sectorOffset + len > m_writer.m_sectorSize) {
                len = m_writer.m_sectorSize - sectorOffset;
            }
            m_writer.writeData(sector, sectorOffset, QByteArray::fromRawData(data, len));
        } else {
            // len has already been adjusted to be fully inside the buffer, so just overwrite what is in the buffer with the subset of data we have
            m_buffer.replace(pos - bufferStart, len, QByteArray::fromRawData(data, len));
        }
        return len;
    }
}
コード例 #6
0
void            Packet_v1_UserInfo::setUserInfo(m_userinfo const *userinfo)
{
  assert(getRequestId() == USERINFO_GETINFO_RESPONSE_OK);
  char const	* serialized = serialize(userinfo);

  appendData(PROTOV1_USERINFO_START_OF_DATA, PROTOV1_USERINFO_DATA_USERINFO, reinterpret_cast<byte_t const *>(serialized));
}
コード例 #7
0
void            Packet_v1_UserInfo::setAvatar(char const *avatar)
{
  assert(getRequestId() == USERINFO_GETAVATAR_RESPONSE_OK);
  appendData(PROTOV1_USERINFO_START_OF_DATA,
	     PROTOV1_USERINFO_DATA_AVATAR,
	     reinterpret_cast<byte_t const *>(avatar));
}
コード例 #8
0
ファイル: ReplyLine.cpp プロジェクト: Bodyfarm/vidalia
/** Constructor */
ReplyLine::ReplyLine(const QString &status, const QString &msg,
                     const QString &data)
{
  _status = status;
  setMessage(msg);
  appendData(data);
}
コード例 #9
0
TEST_F(ScriptStreamingTest, SuppressingStreaming)
{
    // If we notice during streaming that there is a code cache, streaming
    // is suppressed (V8 doesn't parse while the script is loading), and the
    // upper layer (ScriptResourceClient) should get a notification when the
    // script is loaded.
    ScriptStreamer::startStreaming(pendingScript(), m_settings.get(), m_scope.scriptState(), PendingScript::ParsingBlocking);
    TestScriptResourceClient client;
    pendingScript().watchForLoad(&client);
    appendData("function foo() {");
    appendPadding();

    m_resource->setCachedMetadata(V8ScriptRunner::tagForCodeCache(), "X", 1, Resource::CacheLocally);

    appendPadding();
    finish();
    processTasksUntilStreamingComplete();
    EXPECT_TRUE(client.finished());

    bool errorOccurred = false;
    ScriptSourceCode sourceCode = pendingScript().getSource(KURL(), errorOccurred);
    EXPECT_FALSE(errorOccurred);
    // ScriptSourceCode doesn't refer to the streamer, since we have suppressed
    // the streaming and resumed the non-streaming code path for script
    // compilation.
    EXPECT_FALSE(sourceCode.streamer());
}
コード例 #10
0
TEST_F(ScriptStreamingTest, CancellingStreaming)
{
    // Test that the upper layers (PendingScript and up) can be ramped down
    // while streaming is ongoing, and ScriptStreamer handles it gracefully.
    ScriptStreamer::startStreaming(pendingScript(), m_settings.get(), m_scope.scriptState(), PendingScript::ParsingBlocking);
    TestScriptResourceClient client;
    pendingScript().watchForLoad(&client);
    appendData("function foo() {");

    // In general, we cannot control what the background thread is doing
    // (whether it's parsing or waiting for more data). In this test, we have
    // given it so little data that it's surely waiting for more.

    // Simulate cancelling the network load (e.g., because the user navigated
    // away).
    EXPECT_FALSE(client.finished());
    pendingScript().stopWatchingForLoad(&client);
    m_pendingScript = PendingScriptWrapper::create(); // This will destroy m_resource.
    m_resource = 0;

    // The V8 side will complete too. This should not crash. We don't receive
    // any results from the streaming and the client doesn't get notified.
    processTasksUntilStreamingComplete();
    EXPECT_FALSE(client.finished());
}
コード例 #11
0
ファイル: XMLHttpRequest.cpp プロジェクト: MYSHLIFE/webkit
Blob* XMLHttpRequest::responseBlob()
{
    ASSERT(m_responseTypeCode == ResponseTypeBlob);
    ASSERT(doneWithoutErrors());

    if (!m_responseBlob) {
        // FIXME: This causes two (or more) unnecessary copies of the data.
        // Chromium stores blob data in the browser process, so we're pulling the data
        // from the network only to copy it into the renderer to copy it back to the browser.
        // Ideally we'd get the blob/file-handle from the ResourceResponse directly
        // instead of copying the bytes. Embedders who store blob data in the
        // same process as WebCore would at least to teach BlobData to take
        // a SharedBuffer, even if they don't get the Blob from the network layer directly.
        auto blobData = std::make_unique<BlobData>();
        // If we errored out or got no data, we still return a blob, just an empty one.
        size_t size = 0;
        if (m_binaryResponseBuilder) {
            RefPtr<RawData> rawData = RawData::create();
            size = m_binaryResponseBuilder->size();
            rawData->mutableData()->append(m_binaryResponseBuilder->data(), size);
            blobData->appendData(rawData, 0, BlobDataItem::toEndOfFile);
            String normalizedContentType = Blob::normalizedContentType(responseMIMEType());
            blobData->setContentType(normalizedContentType); // responseMIMEType defaults to text/xml which may be incorrect.
            m_binaryResponseBuilder.clear();
        }
        m_responseBlob = Blob::create(std::move(blobData), size);
    }

    return m_responseBlob.get();
}
コード例 #12
0
void FormData::appendItem(const BlobItem* item, bool shouldGenerateFile)
{
    const DataBlobItem* dataItem = item->toDataBlobItem();
    if (dataItem) {
        appendData(dataItem->data(), static_cast<size_t>(dataItem->size()));
        return;
    }

    const FileBlobItem* fileItem = item->toFileBlobItem();
    ASSERT(fileItem);
    if (fileItem->path().isEmpty()) {
        // If the path is empty do not add the item.
        return;
    }

#if ENABLE(BLOB_SLICE)
    const FileRangeBlobItem* fileRangeItem = item->toFileRangeBlobItem();
    if (fileRangeItem) {
        appendFileRange(fileItem->path(), fileRangeItem->start(), fileRangeItem->size(), fileRangeItem->snapshotModificationTime(), shouldGenerateFile);
        return;
    }
#endif

    appendFile(fileItem->path(), shouldGenerateFile);
}
コード例 #13
0
ファイル: Service.cpp プロジェクト: atria-soft/zeus
void jus::Service::onClientData(jus::Buffer& _value) {
	uint32_t tmpID = _value.getTransactionId();
	uint32_t clientId = _value.getClientId();;
	auto it = m_callMultiData.begin();
	while (it != m_callMultiData.end()) {
		if (    it->getTransactionId() == tmpID
		     && it->getClientId() == clientId) {
			JUS_WARNING("Append data ... " << tmpID);
			it->appendData(_value);
			if (it->isFinished() == true) {
				JUS_WARNING("CALL Function ...");
				callBinary(tmpID, it->getRaw());
				it = m_callMultiData.erase(it);
			}
			return;
		}
		++it;
	}
	jus::FutureCall futCall(clientId, tmpID, _value);
	if (futCall.isFinished() == true) {
		JUS_INFO("Call Binary ..");
		callBinary(tmpID, futCall.getRaw());
	} else {
		m_callMultiData.push_back(futCall);
	}
}
コード例 #14
0
ファイル: element.C プロジェクト: shkeshavarz/OOF2
// Overwrites the data indexed under the indicated name, appends
// it, whichever.
void Element::setDataByName(ElementData *x) const {
  int i=getIndexByName(x->name());
  if (i>=0)
    // NB Does this overwrite have implications for reference counts
    // of the referred-to Python data?
    setData(i,x);
  else
    appendData(x);
}
コード例 #15
0
ファイル: canimxy3d.c プロジェクト: rossdrummond/scilab
/** \fn void cmscope(scicos_block * block,int flag)
    \brief the computational function
    \param block A pointer to a scicos_block
    \param flag An int which indicates the state of the block (init, update, ending)
*/
SCICOS_BLOCKS_IMPEXP void canimxy3d(scicos_block * block, scicos_flag flag)
{
    char const* pFigureUID;

    sco_data *sco;

    int j;
    BOOL result;

    switch (flag)
    {

        case Initialization:
            sco = getScoData(block);
            if (sco == NULL)
            {
                set_block_error(-5);
                break;
            }
            pFigureUID = getFigure(block);
            if (pFigureUID == NULL)
            {
                // allocation error
                set_block_error(-5);
                break;
            }
            break;

        case StateUpdate:
            pFigureUID = getFigure(block);
            if (pFigureUID == NULL)
            {
                // allocation error
                set_block_error(-5);
                break;
            }

            appendData(block, block->inptr[0], block->inptr[1], block->inptr[2]);
            for (j = 0; j < block->insz[0]; j++)
            {
                result = pushData(block, j);
                if (result == FALSE)
                {
                    Coserror("%s: unable to push some data.", "cscopxy3d");
                    break;
                }
            }
            break;

        case Ending:
            freeScoData(block);
            break;

        default:
            break;
    }
}
コード例 #16
0
ファイル: htsmessage.cpp プロジェクト: BtbN/vlc-htsp-plugin
HtsList::HtsList(uint32_t /*length*/, void *buf)
{
    char *tmpbuf = (char*)buf;

    if(tmpbuf[0] != getType())
        return;
    tmpbuf += 1;

    unsigned char nlen = (unsigned char)tmpbuf[0];
    tmpbuf += 1;

    int64_t mlen = ntohl(*((uint32_t*)tmpbuf));
    tmpbuf += sizeof(uint32_t);

    if(nlen > 0)
    {
        setName(std::string(tmpbuf, (size_t)nlen));
        tmpbuf += nlen;
    }

    while(mlen > 0)
    {
        unsigned char mtype = (unsigned char)tmpbuf[0];
        unsigned char subNameLen = (unsigned char)tmpbuf[1];
        uint32_t subLen = ntohl(*((uint32_t*)(tmpbuf+2)));

        uint32_t psize = 1+1+4;
        psize += subNameLen;
        psize += subLen;

        std::shared_ptr<HtsData> newData;
        switch(mtype)
        {
            case 1:
                newData = std::make_shared<HtsMap>(psize, tmpbuf);
                break;
            case 2:
                newData = std::make_shared<HtsInt>(psize, tmpbuf);
                break;
            case 3:
                newData = std::make_shared<HtsStr>(psize, tmpbuf);
                break;
            case 4:
                newData = std::make_shared<HtsBin>(psize, tmpbuf);
                break;
            case 5:
                newData = std::make_shared<HtsList>(psize, tmpbuf);
                break;
        }

        appendData(newData);

        tmpbuf += psize;
        mlen -= psize;
    }
}
コード例 #17
0
int StatsMsgBuff::appendString(const char* string)
{
    char nullBuffer[8];
    memset(nullBuffer, 0, sizeof(nullBuffer));
    if (!string)
    {
        string = "";
        //return appendData(string, strlen(string) + 1);
    }
    // else
    int nStrLen = strlen(string);
    appendData(string, nStrLen + 1);    // Append null byte
    int nPadBytes = (STATS_ALIGN(nStrLen + 1)) - (nStrLen + 1);
    if (nPadBytes)
    {
        appendData(nullBuffer, nPadBytes);
    }
    return length();
}
コード例 #18
0
void		Packet_v1_Channel::setChannelName(char const * name)
{
  assert(getRequestId() == CHANNEL_JOIN ||
	 getRequestId() == CHANNEL_JOIN_OK ||
	 getRequestId() == CHANNEL_JOIN_NOK_ALREADYINCHAN ||
         getRequestId() == CHANNEL_JOINED ||
         getRequestId() == CHANNEL_LEAVED ||
	 getRequestId() == CHANNEL_LEAVE_OK);
  appendData(PROTOV1_CHANNEL_START_OF_DATA, PROTOV1_CHANNEL_DATA_CHANNEL_NAME, reinterpret_cast<byte_t const *>(name));
}
コード例 #19
0
ファイル: cscopxy3d.c プロジェクト: leowzukw/scilab-mirror
/** \fn void cmscope(scicos_block * block,int flag)
    \brief the computational function
    \param block A pointer to a scicos_block
    \param flag An int which indicates the state of the block (init, update, ending)
*/
SCICOS_BLOCKS_IMPEXP void cscopxy3d(scicos_block * block, scicos_flag flag)
{
    int iFigureUID;

    sco_data *sco;

    int j;
    BOOL result;

    switch (flag)
    {

        case Initialization:
            sco = getScoData(block);
            if (sco == NULL)
            {
                set_block_error(-5);
            }
            iFigureUID = getFigure(block);
            if (iFigureUID == 0)
            {
                // allocation error
                set_block_error(-5);
            }
            break;

        case StateUpdate:
            iFigureUID = getFigure(block);
            if (iFigureUID == 0)
            {
                // allocation error
                set_block_error(-5);
                break;
            }

            appendData(block, GetRealInPortPtrs(block, 1), GetRealInPortPtrs(block, 2), GetRealInPortPtrs(block, 3));
            for (j = 0; j < block->insz[0]; j++)
            {
                result = pushData(block, j);
                if (result == FALSE)
                {
                    Coserror("%s: unable to push some data.", "cscopxy3d");
                    break;
                }
            }
            break;

        case Ending:
            freeScoData(block);
            break;

        default:
            break;
    }
}
コード例 #20
0
ファイル: qpcurve.cpp プロジェクト: UbuntuChina/sensorapp
void QPCurve::appendData(const QVector<float> &data)
{
    QVector<QPointF> dataVector(data.size());

    int id = m_data.size();

    for (int i = 0; i < data.size(); ++i, ++id) {
        dataVector[i] = QPointF(id, data[i]);
    }

    appendData(dataVector);
}
コード例 #21
0
// Parse GFX
int parseGfx(TiXmlElement *zbeXML, FILE *output)
{
	// Total # gfx. Do the same like total number assets
	fpos_t totalGfxPos = tempVal<uint32_t>("Total GFX", output);
	uint32_t totalGfx = 0;

	// For all the graphics in the XML file
	TiXmlElement *graphicsXML = zbeXML->FirstChildElement("bin")->FirstChildElement("graphics");
	if (graphicsXML)
	{
		TiXmlElement *gfxXML = graphicsXML->FirstChildElement("gfx");
		while (gfxXML)
		{
			// Increment total gfx counter
			++totalGfx;

			// Get all the needed attributes
			string thisBin = getStrAttr(gfxXML, "bin");
			int w = getIntAttr(gfxXML, "w");
			int h = getIntAttr(gfxXML, "h");
			int t = getIntAttr(gfxXML, "top");
			int l = getIntAttr(gfxXML, "left");

			// Copy it into the zbe file
			debug("\tGFX: %d x %d at (%d, %d)\n", w, h, t, l);
			fwrite<uint8_t>((uint8_t) w, output);
			fwrite<uint8_t>((uint8_t) h, output);
			fwrite<uint8_t>((uint8_t) t, output);
			fwrite<uint8_t>((uint8_t) l, output);
			// The length is unknown right now, it'll be counted in the copy op and returned
			// so we'll return here after that copy is done
			debug("\t");
			fpos_t lenPos = tempVal<uint16_t>("Tiles Length", output);
			debug("\tAppending GFX's Tiles Data from file %s\n", thisBin.c_str());
			uint16_t len = appendData(output, thisBin);

			// Now we have the length, so go back and write it down
			goWrite<uint16_t>(uint16_t(len), output, &lenPos);
			debug("\tTiles' length: %d B\n", int(len));

			// Get the next sibling
			gfxXML = gfxXML->NextSiblingElement("gfx");
			debug("GFX done\n");
		}
	}
	// Now that the total number of gfx are known, go back and write that down
	goWrite<uint32_t>(totalGfx, output, &totalGfxPos);
	debug("%d GFX processed\n\n", int(totalGfx));
	return totalGfx;
}
コード例 #22
0
ファイル: linkedList01.c プロジェクト: CMDody/GitHub_C
int main(void) {

printf("Simple Single Linked List Demo ... \n");

addData(3);  // add data to the end of the list...
addData(5);
addData(7);
addData(9);
addData(11);
addData(13);
addData(15);

appendData(21); // add data to the begining of the list...
appendData(0);
appendData(88);
appendData(23);

printList(firstNode);

finalize();

return 0;
}
コード例 #23
0
ファイル: narcomgr.cpp プロジェクト: yuxiuyang/qt-client
void NarcoMgr::appendData(const BYTE* buf,int len){
	static string str;
	static char tmp[10];
	str = "";
	for(int i=0;i<len;i++){
		memset(tmp,0,sizeof(tmp));
		sprintf(tmp,"%02x ",buf[i]);
		str += tmp;
	}
	str += " ";
	appendData(str.c_str());


}
コード例 #24
0
void		Packet_v1_Channel::setChannelList(std::map<unsigned int, Channel*> *m_channel)
{
  Channel		*chan;
  std::string		name = "";

  std::map<unsigned int, Channel*>::iterator it, end = m_channel->end();
  for (it = m_channel->begin(); it != end; ++it)
    {
      chan = it->second;
      name += chan->getName();
      name += '#';
    }
  appendData(PROTOV1_CHANNEL_START_OF_DATA, PROTOV1_CHANNEL_DATA_CHANNEL_LIST, reinterpret_cast<byte_t const *>(name.c_str()));
}
コード例 #25
0
ファイル: 4-3.c プロジェクト: gsrr/Programs
void appendBST(tNode** root, int* arr, int low, int high)
{
        if(high < low)
        {
                return;
        }
        tNode* data = *root;
        int* ritem = (int*)data->item; 
        int middle = (low + high)/2;
        tNode* tmp = createTreeNode(&arr[middle]);
          
        appendData(root, tmp);
        appendBST(root, arr, low, middle-1);
        appendBST(root, arr, middle+1, high);
}
コード例 #26
0
ファイル: process.c プロジェクト: JackWangCUMT/bitmeteros
struct Data* extractDiffs(int ts, struct Data* oldList, struct Data* newList){
 /* Accepts 2 lists of Data structs and iterates through them looking for adapter names that
    match. When a matching pair is found the differences between the dl and ul figures are calculated
    and if they are non-zero the delta is stored in the 'diffData' list which is evetually returned. This
    routine must handle cases where one or both lists are null, where the adapters do not appear in the
    same order within the 2 lists, and where adapters are present in one list and not in the other (this
    will happen if adapters are enabled or disabled while the application is running). */
	BW_INT dl,ul;

 // These pointers reference the Data structs that we are currently examining, from each of the 2 lists
	struct Data* oldData;
	struct Data* newData;

	struct Data* diffData = NULL;
	struct Data* newDiff = NULL;

	oldData = oldList; // Point oldData at the start of the oldList
	while(oldData != NULL){
		newData = newList;  // Point newData at the start of the newList
		while(newData != NULL){
			if (strcmp(oldData->ad, newData->ad) == 0){
             // We found an adapter that appears in both lists, so look at the dl and ul values
			    if ((newData->dl >= oldData->dl) && (newData->ul >= oldData->ul)){;
                    dl = newData->dl - oldData->dl;
                    ul = newData->ul - oldData->ul;
                    if (dl > 0 || ul > 0){
                     // At least 1 of the values increased since last time, so we add an item the the diffData list for this adapter
                        newDiff = allocData();
                        newDiff->dl = dl;
                        newDiff->ul = ul;
                        newDiff->ts = ts;
                        setAddress(newDiff, oldData->ad);
                        setHost(newDiff, oldData->hs);

                        appendData(&diffData, newDiff);
                    }
			    } else {
                    logMsg(LOG_WARN, "Values wrapped around for adapter %s", oldData->ad);
			    }
			    break; // We found the match so no point looking at any remaining items in newList
			}
			newData = newData->next; // We didn't find a match so move to the next item in the newList
		}
		oldData = oldData->next;
	}

	return diffData;
}
コード例 #27
0
    /**
     * @brief BasicCppProjectGenerator::addProfile
     */
    void BasicCppProjectGenerator::addProfile()
    {
        // TODO: add different strateges for different project types
        QString name(m_ProjectName.remove(" ").toLower());
        name.append(".pro");

        auto file = m_RootOutputDirectory->addFile(name);

        // TODO: add more variables
        m_ProfileData.variables["HEADERS"] = m_ProfileData.headers.join(" \\\n" + INDENT).append("\n");
        m_ProfileData.variables["SOURCES"] = m_ProfileData.sources.join(" \\\n" + INDENT);

        for (auto &&key : m_ProfileData.variables.keys())
           file->appendData(QString("%1 %2 \\\n%3%4").arg(key,
                                                          "=",
                                                          INDENT,
                                                          m_ProfileData.variables[key]));
    }
コード例 #28
0
ファイル: Logging.cpp プロジェクト: shiduanguang/passenger
static void
realPrintAppOutput(char *buf, unsigned int bufSize,
	const char *pidStr, unsigned int pidStrLen,
	const char *channelName, unsigned int channelNameLen,
	const char *message, unsigned int messageLen)
{
	char *pos = buf;
	char *end = buf + bufSize;

	pos = appendData(pos, end, "App ");
	pos = appendData(pos, end, pidStr, pidStrLen);
	pos = appendData(pos, end, " ");
	pos = appendData(pos, end, channelName, channelNameLen);
	pos = appendData(pos, end, ": ");
	pos = appendData(pos, end, message, messageLen);
	pos = appendData(pos, end, "\n");
	_writeLogEntry(buf, pos - buf);
}
コード例 #29
0
ファイル: process.c プロジェクト: JackWangCUMT/bitmeteros
int processCapture(){
    int status;

 // Called continuously by the main processing loop of the application
	int ts = getTime();

 // Get the current values for each network adapter
	struct Data* currData = getData();

 // Calculate the differences between the current values and the previous ones
	struct Data* diffList = extractDiffs(ts, prevData, currData);
	appendData(&unwrittenDiffs, diffList);
	
 // Save the current values so we can compare against them next time
	freeData(prevData);
	prevData = currData;

 // Is it time to write the values to the database yet?
	if (++unwrittenDiffCount >= dbWriteInterval) {
	 // Write the changes in values to the database
		status = writeUnwrittenDiffs();
	
		if (status == FAIL) {
	        return FAIL;
		}
	
	 // Is it time to compress the database yet?
		if (ts > tsCompress) {
			status = compressDb();
			if (status == FAIL){
	            return FAIL;
			}
			tsCompress = getNextCompressTime();
		}
		
		unwrittenDiffCount = 0;	
	} else {
		status = SUCCESS;	
	}

	return status;
}
コード例 #30
0
// Parse Simple binary, like Palette or bgTiles
int parseBins(TiXmlElement *zbeXML, string type, FILE *output)
{
	// Total # Bin.
	fpos_t totalBinPos = tempVal<uint32_t>("Total " + type + "s", output);
	uint32_t totalBin = 0;

	// For all the bins in the XML file
	TiXmlElement *binsXML = zbeXML->FirstChildElement(string(type + "s").c_str());
	if (binsXML)
	{
		TiXmlElement *binXML = binsXML->FirstChildElement(type.c_str());
		while (binXML)
		{
			// Increment total bin counter
			++totalBin;

			// Get all the needed attributes
			string thisBin = getStrAttr(binXML, "bin");

			// The length is unknown right now, it'll be counted in the copy op and returned
			// so we'll return here after that copy is done
			debug("\t");
			fpos_t lenPos = tempVal<uint16_t>(type + " Length", output);
			debug("\tAppending %s Data from file %s\n", type.c_str(), thisBin.c_str());
			uint16_t len = appendData(output, thisBin);

			// Now we have the length, so go back and write it down
			goWrite<uint16_t>(uint16_t(len), output, &lenPos);
			debug("\t%s's Length: %d B\n", type.c_str(), len);

			// Get the next sibling
			binXML = binXML->NextSiblingElement(type.c_str());
			debug("%s Done\n", type.c_str());
		}
	}

	// Now that the total number of bins are known, go back and write that down
	goWrite<uint32_t>(totalBin, output, &totalBinPos);
	debug("%d %s Processed\n\n", int(totalBin), type.c_str());
	return totalBin;
}