示例#1
0
void KConfigBase::revertToDefault(const QString &key)
{
    setDirty(true);

    KEntryKey aEntryKey(mGroup, key.utf8());
    aEntryKey.bDefault = true;

    if(!locale().isNull())
    {
        // try the localized key first
        aEntryKey.bLocal = true;
        KEntry entry = lookupData(aEntryKey);
        if(entry.mValue.isNull())
            entry.bDeleted = true;

        entry.bDirty = true;
        putData(aEntryKey, entry, true); // Revert
        aEntryKey.bLocal = false;
    }

    // try the non-localized version
    KEntry entry = lookupData(aEntryKey);
    if(entry.mValue.isNull())
        entry.bDeleted = true;
    entry.bDirty = true;
    putData(aEntryKey, entry, true); // Revert
}
示例#2
0
bool I2c::wReg (uint8_t adress, uint8_t reg, uint8_t *data, uint8_t l)
{
  start ();
  //Записываем в регистр данных адрес ведомого устройства
  putData (adress & 0xFE);
  
  while(!flagAddr());
  //Очистка бита ADDR чтением регистра SR3
  uint8_t temp = I2C->SR3;
  
  
  //Ждем освобождения регистра данных
  while(!flagTxe());
  //Отправляем адрес регистра
  putData (reg);
  
  //Отправка данных
  while(l--){
    //Ждем освобождения регистра данных
    while(!flagTxe());
    //Отправляем адрес регистра
    putData (*data++);
  }
  
  //Ловим момент, когда DR освободился и данные попали в сдвиговый регистр
  while(!(flagTxe() && flagBtf ()));
  
  //Посылаем СТОП-посылку
  stop ();
  //Ждем выполнения условия СТОП
  while(flagStop ());
  return true;
}
示例#3
0
文件: util.c 项目: iruka-/ORANGEpico
/*********************************************************************
 *	ターゲット側のメモリー内容(1バイト)を書き換える.
 *********************************************************************
 *	int            adr :ターゲット側のメモリーアドレス
 *	int          arena :ターゲット側のメモリー種別(現在未使用)
 *	int          data0 :書き込みデータ.      (OR)
 *	int          data1 :書き込みビットマスク.(AND)
 *注意
 *	pic32mxのbootloaderはメモリー節約のため DWORDアクセスのみ実装されている.
 *	よって、maskは実装されない.
 *	char,shortのアクセスを行う場合はread modifiedにする必要がある.
 */
int	pokemem(int adr,int arena,int data0,int data1)
{
	int buf[64/4];
	char *byte=(char *)buf;
	int off = adr & 3;	//端数.
	int size = 4;
	if(arena == MEM_BYTE) {
		int rc = UsbRead(adr & (-4),MEM_WORD,byte,size);
		byte[off]=data0;
	}else if(arena == MEM_HALF) {
		int rc = UsbRead(adr & (-4),MEM_WORD,byte,size);
		byte[off]=data0;		// FIXME! SHORT WORD!
	}else{
		buf[0]=data0;
	}
	return putData(adr & (-4),size,(char*) buf);

#if	0
	int 					size = 1;
	if(arena==MEM_HALF) 	size = 2;
	if(arena==MEM_WORD) 	size = 4;

	buf[0]=data0;

	printf("putData(%x %d)\n",adr,size);

	return putData(adr,size,(char*) buf);
#endif
}
示例#4
0
文件: logger.cpp 项目: gen1izh/cpp
/**
  * ¬ывод последнего собщени¤ по событию на представление
  */
void logger::sendDataToViewer( int type, QString msg, int logger ) {
  if ( logger == SYSTEM_LOGGER ) {
    putData( QString("%1  %2").arg(hsTypeMsg[type]).arg(msg), logger );
  }
  else {
    putData( QString("%1").arg(msg), logger );
  }

  signalReceiveLastMsg( logger );
}
示例#5
0
// renyang - 替音訊解碼
void Call::decodeAudioData(char *buf, int len)
{
#ifdef REN_DEBUG
	qWarning("Call::decodeAudioData()");
#endif
	if (dec_state)
	{
		// renyang - Initializes the bit-stream from the data in an area of memory
		// renyang - 把一連串的buf轉到bit-stream
		speex_bits_read_from(&bits, buf, len);
		// renyang - 把bits解碼到outBuffer(為float型態)
		// renyang - 當<0表示解碼失敗
		if (speex_decode(dec_state, &bits, outBuffer) < 0)
		{
			emit warning("Warning: wrong decryption key or stream corrupted!");
			disableDecrypt();
		}
		else
		{
			// renyang - 來到這裡表示解碼成功
			// renyang - 把解碼之後的音訊(outBuffer)放到soundBuffer中
			putData(outBuffer, frame_size);
		}
	}
}
示例#6
0
文件: putChunk.cpp 项目: MP2E/GDCC
         //
         // Info::putChunkATAG
         //
         void Info::putChunkATAG()
         {
            if(!numChunkATAG) return;

            for(auto const &itr : init)
               if(itr.first->space.base == IR::AddrBase::MapArr)
            {
               auto const &ini = itr.second;

               if(!ini.needTag || ini.onlyStr) continue;

               putData("ATAG", 4);
               putWord(ini.vals.size() + 5);

               putByte(0); // version
               putWord(itr.first->value);

               for(auto const &i : itr.second.vals) switch(i.tag)
               {
               case InitTag::Empty: putByte(0); break;
               case InitTag::Fixed: putByte(0); break;
               case InitTag::Funct: putByte(2); break;
               case InitTag::StrEn: putByte(1); break;
               }
            }
         }
示例#7
0
bool KConfigBase::deleteGroup(const QString &group, bool bDeep, bool bGlobal)
{
    KEntryMap aEntryMap = internalEntryMap(group);

    if(!bDeep)
    {
        // Check if it empty
        return aEntryMap.isEmpty();
    }

    bool dirty = false;
    bool checkGroup = true;
    // we want to remove all entries in the group
    KEntryMapIterator aIt;
    for(aIt = aEntryMap.begin(); aIt != aEntryMap.end(); ++aIt)
    {
        if(!aIt.key().mKey.isEmpty() && !aIt.key().bDefault && !(*aIt).bDeleted)
        {
            (*aIt).bDeleted = true;
            (*aIt).bDirty = true;
            (*aIt).bGlobal = bGlobal;
            (*aIt).mValue = 0;
            putData(aIt.key(), *aIt, checkGroup);
            checkGroup = false;
            dirty = true;
        }
    }
    if(dirty)
        setDirty(true);
    return true;
}
示例#8
0
void KConfigBase::writeEntry(const char *pKey, const QString &value, bool bPersistent, bool bGlobal, bool bNLS, bool bExpand)
{
    // the KConfig object is dirty now
    // set this before any IO takes place so that if any derivative
    // classes do caching, they won't try and flush the cache out
    // from under us before we read. A race condition is still
    // possible but minimized.
    if(bPersistent)
        setDirty(true);

    if(!bLocaleInitialized && KGlobal::locale())
        setLocale();

    KEntryKey entryKey(mGroup, pKey);
    entryKey.bLocal = bNLS;

    KEntry aEntryData;
    aEntryData.mValue = value.utf8(); // set new value
    aEntryData.bGlobal = bGlobal;
    aEntryData.bNLS = bNLS;
    aEntryData.bExpand = bExpand;

    if(bPersistent)
        aEntryData.bDirty = true;

    // rewrite the new value
    putData(entryKey, aEntryData, true);
}
示例#9
0
文件: putChunk.cpp 项目: MP2E/GDCC
         //
         // Info::putChunkMIMP
         //
         void Info::putChunkMIMP()
         {
            if(!numChunkMIMP) return;

            Core::Array<IR::Object const *> imps{numChunkMIMP};

            auto itr = imps.begin();
            for(auto const &obj : prog->rangeObject())
            {
               if(!obj.defin && obj.space.base == IR::AddrBase::MapReg)
                  *itr++ = &obj;
            }

            Core::FastU size = numChunkMIMP * 4;
            for(auto const &imp : imps)
               size += lenString(imp->glyph);

            putData("MIMP", 4);
            putWord(size);

            for(auto const &imp : imps)
            {
               putWord(imp->value);
               putString(imp->glyph);
            }
         }
示例#10
0
void Engine::setAccType(QString type) {
    if (currentType != type || recoveredDStack) {
        if (dStack.isEmpty()) {
            currentType = type;
            executeInstructionOnStack("Factory"); // No tr
            state = sAppend;
        } else {
            if (recoveredDStack) {
                //don't call dualReset() or recoveredDStack will be deleted
                dStack.clear();
                iStack.clear();
                braceCount = 0;
                softReset();
                changeResetState(drNone);
                putData(recoveredDStack);
            }
            wantedType = type;

            if (currentType == "NONE") // workaround for bug #3356
                currentType = dStack.top()->getType();

            if (currentType != wantedType) {
                if (!recoveredDStack)
                    executeInstructionOnStack("Convert"); // No tr
                else  // don't convert recoveredStack
                    recoveredDStack = 0;
            }
        }
        // Doublecheck the type in case a factory or convert doesn't go as planned.
        currentType = dStack.top()->getType();
        emit(stackChanged());
    }
    changeResetState(drs);
}
示例#11
0
文件: putChunk.cpp 项目: MP2E/GDCC
         //
         // Info::putChunkSFLG
         //
         void Info::putChunkSFLG()
         {
            if(!numChunkSFLG) return;

            putData("SFLG", 4);
            putWord(numChunkSFLG * 4);

            for(auto const &itr : prog->rangeFunction())
            {
               if(itr.ctype != IR::CallType::Script  &&
                  itr.ctype != IR::CallType::ScriptI &&
                  itr.ctype != IR::CallType::ScriptS)
                  continue;

               if(!itr.defin) continue;

               Core::FastU flags = 0;

               if(itr.sflagClS) flags |= 0x0002;
               if(itr.sflagNet) flags |= 0x0001;

               if(!flags) continue;

               putHWord(itr.valueInt);
               putHWord(flags);
            }
         }
示例#12
0
文件: putChunk.cpp 项目: MP2E/GDCC
         //
         // Info::putChunkCODE
         //
         void Info::putChunkCODE()
         {
            putData("\0\0\0\0", 4);
            putWord(numChunkCODE);

            // Put statements.
            for(auto &itr : prog->rangeFunction())
               putFunc(itr);
         }
示例#13
0
RddResultCode GroupTransformer::transform(const ActorMessagePtr& msg, const vector<BaseRddPartition*>& input,
    RddPartition* output) {
  if (input.size() != 1) {
    LOG(ERROR)<< "group transformer '" << output->getRddName() << "' with partition " << output->getPartition() << " must have one input RDD, caused by code " << RRC_INVALID_RDD_INPUT;
    return RRC_INVALID_RDD_INPUT;
  }

  if (input[0]->empty()) {
    DVLOG(3) << "group transformer '" << output->getRddName() << "' with partition " << output->getPartition() << " have no data.";
    return RRC_SUCCESS;
  }

  RddResultCode code = RRC_SUCCESS;
  ExpressionContext ctx;
  auto& outMsg = output->getOutMessage(0);
  auto filterExpr = output->getFilterExpression(0);

  std::multimap<PbMessagePtr, PbMessagePtr, idgs::store::less> localCache;

  input[0]->foreach([this, output, outMsg, filterExpr, &code, &ctx, &localCache] (const PbMessagePtr& key, const PbMessagePtr& value) {
        ctx.setKeyValue(&key, &value);
        try {
          if (filterExpr) {
            PbVariant var = filterExpr->evaluate(&ctx);
            if (!(bool) var) {
              return;
            }
          }
        } catch (RddResultCode& err) {
          LOG(ERROR) << "evaluate error, caused by code " << err;
          code = err;
        }

        PbMessagePtr outKey, outValue;
        outMsg.key.fillMessage(outKey, ctx);
        outMsg.value.fillMessage(outValue, ctx);
#if (REPARTITION_BATCH <= 1)
        std::vector<PbMessagePtr> values;
        values.push_back(outValue);
        output->put(outKey, values);
#else // (REPARTITION_BATCH == 0)
        localCache.insert(std::pair<PbMessagePtr, PbMessagePtr>(outKey, outValue));

        static idgs::pb::ClusterConfig* clusterConfig = ::idgs::util::singleton<idgs::cluster::ClusterFramework>::getInstance().getClusterConfig();

        if(localCache.size() > clusterConfig->repartition_batch()) {
          this->putData(output, localCache);
        }
#endif // (REPARTITION_BATCH == 0)
      });
#if (REPARTITION_BATCH > 1)
  putData(output, localCache);
#endif
  return code;
}
示例#14
0
文件: putChunk.cpp 项目: MP2E/GDCC
         //
         // Info::putChunkSPTR
         //
         void Info::putChunkSPTR()
         {
            if(!numChunkSPTR) return;

            putData("SPTR", 4);
            putWord(numChunkSPTR * (UseFakeACS0 ? 8 : 12));

            for(auto const &itr : prog->rangeFunction())
            {
               if(itr.ctype != IR::CallType::Script  &&
                  itr.ctype != IR::CallType::ScriptI &&
                  itr.ctype != IR::CallType::ScriptS)
                  continue;

               if(!itr.defin) continue;

               Core::FastU stype, value;

               // Convert script type.
               switch(itr.stype)
               {
               case IR::ScriptType::None:       stype =  0; break;
               case IR::ScriptType::Death:      stype =  3; break;
               case IR::ScriptType::Disconnect: stype = 14; break;
               case IR::ScriptType::Enter:      stype =  4; break;
               case IR::ScriptType::Lightning:  stype = 12; break;
               case IR::ScriptType::Open:       stype =  1; break;
               case IR::ScriptType::Respawn:    stype =  2; break;
               case IR::ScriptType::Return:     stype = 15; break;
               case IR::ScriptType::Unloading:  stype = 13; break;
               }

               // Convert script index.
               if(itr.ctype == IR::CallType::ScriptS)
                  value = -static_cast<Core::FastI>(itr.valueInt) - 1;
               else
                  value = itr.valueInt;

               // Write entry.
               if(UseFakeACS0)
               {
                  putHWord(value);
                  putByte(stype);
                  putByte(itr.param);
                  putExpWord(resolveGlyph(itr.label));
               }
               else
               {
                  putHWord(value);
                  putHWord(stype);
                  putExpWord(resolveGlyph(itr.label));
                  putWord(itr.param);
               }
            }
         }
示例#15
0
void ODBCStatementImpl::bindImpl()
{
	doBind();

	SQLRETURN rc = SQLExecute(_stmt);

	if (SQL_NEED_DATA == rc) putData();
	else checkError(rc, "SQLExecute()");

	_pBinder->synchronize();
}
示例#16
0
void Engine::setError(QString s, bool resetStack) {
    if (s.isEmpty())
        s = qApp->translate("Engine","Error");
    if (!resetStack) {
        recoveredDStack = getData();
        putData(recoveredDStack);
    }

    changeState(sError);
    errorString = s;
    emit(stackChanged());
}
示例#17
0
文件: putChunk.cpp 项目: MP2E/GDCC
         //
         // Info::putChunkMSTR
         //
         void Info::putChunkMSTR()
         {
            if(!numChunkMSTR) return;

            putData("MSTR", 4);
            putWord(numChunkMSTR * 4);

            auto const &ini = init[&prog->getSpaceMapReg()];

            for(std::size_t i = 0, e = ini.vals.size(); i != e; ++i)
               if(ini.vals[i].tag == InitTag::StrEn) putWord(i);
         }
示例#18
0
文件: putChunk.cpp 项目: MP2E/GDCC
         //
         // Info::putChunkMINI
         //
         void Info::putChunkMINI()
         {
            if(!numChunkMINI) return;

            auto const &ini = init[&prog->getSpaceMapReg()];

            for(std::size_t i = 0, e = ini.vals.size(); i != e; ++i) if(ini.vals[i].val)
            {
               putData("MINI", 4);
               putWord(8);
               putWord(i);
               putWord(ini.vals[i].val);
            }
         }
int main(int argc, char **argv)
{ struct soap soap;
  // use HTTP 1.1 chunking
  // HTTP chunking allows streaming of DIME content without requiring DIME attachment size to be set
  // DIME attachments can be streamed without chunking ONLY if the attachment size is set
  soap_init1(&soap, SOAP_IO_CHUNK);
  // set DIME callbacks
  soap.fdimereadopen = dime_read_open;
  soap.fdimereadclose = dime_read_close;
  soap.fdimeread = dime_read;
  soap.fdimewriteopen = dime_write_open;
  soap.fdimewriteclose = dime_write_close;
  soap.fdimewrite = dime_write;
  // connect timeout value (not supported by Linux)
  soap.connect_timeout = 10;
  // IO timeouts
  soap.send_timeout = 30;
  soap.recv_timeout = 30;
  // Unix/Linux SIGPIPE, this is OS dependent:
  // soap.accept_flags = SO_NOSIGPIPE;	// some systems like this
  // soap.socket_flags = MSG_NOSIGNAL;	// others need this
  // signal(SIGPIPE, sigpipe_handle);	// or a sigpipe handler (portable)
  if (argc < 3)
  { char *name;
    if (argc < 2)
      name = "image.jpg";
    else
      name = argv[1];
    getImage(&soap, name);
  }
  else
  { switch (argv[1][1])
    { case 'p':
	endpoint = localhost;
        putData(&soap, argc, argv);
        break;
      case 'g':
	endpoint = localhost;
        getData(&soap, argc, argv);
        break;
      default:
        fprintf(stderr, "Usage: [-p] [-g] name ...\n");
	exit(0);
    }
  }
  soap_destroy(&soap);
  soap_end(&soap);
  soap_done(&soap);
  return SOAP_OK;
}
示例#20
0
文件: putChunk.cpp 项目: MP2E/GDCC
         //
         // Info::putChunkASTR
         //
         void Info::putChunkASTR()
         {
            if(!numChunkASTR) return;

            putData("ASTR", 4);
            putWord(numChunkASTR * 4);

            for(auto const &itr : init)
               if(itr.first->space.base == IR::AddrBase::MapArr)
            {
               if(itr.second.needTag && itr.second.onlyStr)
                  putWord(itr.first->value);
            }
         }
示例#21
0
文件: putChunk.cpp 项目: MP2E/GDCC
         //
         // Info::putChunkFUNC
         //
         void Info::putChunkFUNC()
         {
            if(!numChunkFUNC) return;

            Core::Array<IR::Function const *> funcs{numChunkFUNC};

            for(auto &f : funcs) f = nullptr;

            for(auto const &itr : prog->rangeFunction())
            {
               if(itr.ctype != IR::CallType::LangACS)
                  continue;

               funcs[itr.valueInt] = &itr;
            }

            putData("FUNC", 4);
            putWord(numChunkFUNC * 8);

            for(auto f : funcs)
            {
               if(f)
               {
                  putByte(f->param);
                  putByte(std::max(f->localReg, f->param));
                  putByte(!!f->retrn);
                  putByte(0);

                  if(f->defin)
                     putExpWord(resolveGlyph(f->label));
                  else
                     putWord(0);
               }
               else
                  putData("\0\0\0\0\0\0\0\0", 8);
            }
         }
示例#22
0
// 재귀호출
void putData(char *pszParam) {
	if (*pszParam == '\0') {
		return;
	}

	// 다음 두 구문의 순서를 바꾸면 문자열이 뒤집어져 출력됨
	putchar(*pszParam);

	//Sleep(500); // 한글자씩 표기되는거 보기 위해 슬립 걸어준다.

	// 다음 글자를 가리키는 주소를 매개변수로 재귀호출한다.
	putData(pszParam + 1); // 메모리 주소 이동..

	
}
示例#23
0
文件: putChunk.cpp 项目: MP2E/GDCC
         //
         // Info::putChunkAINI
         //
         void Info::putChunkAINI()
         {
            if(!numChunkAINI) return;

            for(auto const &itr : init)
               if(itr.first->space.base == IR::AddrBase::MapArr)
            {
               putData("AINI", 4);
               putWord(itr.second.vals.size() * 4 + 4);
               putWord(itr.first->value);

               for(auto const &i : itr.second.vals)
                  putWord(i.val);
            }
         }
示例#24
0
文件: putChunk.cpp 项目: MP2E/GDCC
         //
         // Info::putChunkARAY
         //
         void Info::putChunkARAY()
         {
            if(!numChunkARAY) return;

            putData("ARAY", 4);
            putWord(numChunkARAY * 8);

            for(auto const &itr : prog->rangeSpaceMapArs())
            {
               if(!itr.defin) continue;

               putWord(itr.value);
               putWord(itr.words);
            }
         }
示例#25
0
文件: putChunk.cpp 项目: MP2E/GDCC
         //
         // Info::putChunkLOAD
         //
         void Info::putChunkLOAD()
         {
            numChunkLOAD = prog->sizeImport();

            if(!numChunkLOAD) return;

            Core::FastU size = 0;

            for(auto const &itr : prog->rangeImport())
               size += lenString(itr.glyph);

            putData("LOAD", 4);
            putWord(size);

            for(auto const &itr : prog->rangeImport())
               putString(itr.glyph);
         }
示例#26
0
文件: putChunk.cpp 项目: MP2E/GDCC
         //
         // Info::putChunk
         //
         void Info::putChunk(char const *name, Core::Array<Core::String> const &strs, bool junk)
         {
            std::size_t base;
            std::size_t off;

            // Calculate base offset.
            base = strs.size() * 4 + 4;
            if(junk) base += 8;

            // Calculate size of chunk.
            off = base;
            for(auto const &s : strs)
               off += lenString(s);

            // Write chunk header.
            putData(name, 4);
            putWord(off);

            // Write string count.
            if(junk) putWord(0);
            putWord(strs.size());
            if(junk) putWord(0);

            // Write string offsets.
            off = base;
            for(auto const &s : strs)
            {
               putWord(off);
               off += lenString(s);
            }

            // Write strings.
            if(junk && UseChunkSTRE)
            {
               off = base;
               for(auto const &s : strs)
               {
                  putString(s, off * 157135);
                  off += lenString(s);
               }
            }
            else for(auto const &s : strs)
               putString(s);
         }
示例#27
0
文件: putChunk.cpp 项目: MP2E/GDCC
         //
         // Info::putChunkSVCT
         //
         void Info::putChunkSVCT()
         {
            if(!numChunkSVCT) return;

            putData("SVCT", 4);
            putWord(numChunkSFLG * 4);

            for(auto const &itr : prog->rangeFunction())
            {
               if(itr.ctype != IR::CallType::Script  &&
                  itr.ctype != IR::CallType::ScriptI &&
                  itr.ctype != IR::CallType::ScriptS)
                  continue;

               if(!itr.defin) continue;

               if(itr.localReg <= 20) continue;

               putHWord(itr.valueInt);
               putHWord(itr.localReg);
            }
         }
示例#28
0
void KConfigBase::deleteEntry(const char *pKey, bool bNLS, bool bGlobal)
{
    // the KConfig object is dirty now
    // set this before any IO takes place so that if any derivative
    // classes do caching, they won't try and flush the cache out
    // from under us before we read. A race condition is still
    // possible but minimized.
    setDirty(true);

    if(!bLocaleInitialized && KGlobal::locale())
        setLocale();

    KEntryKey entryKey(mGroup, pKey);
    KEntry aEntryData;

    aEntryData.bGlobal = bGlobal;
    aEntryData.bNLS = bNLS;
    aEntryData.bDirty = true;
    aEntryData.bDeleted = true;

    // rewrite the new value
    putData(entryKey, aEntryData, true);
}
示例#29
0
void
SystemControl::insert(char* buf, uval len)
{
    uval x;
    for (uval i=0; i<len; ++i) {
	if (buf[i]=='|') {
	    buf[i]='\n';
	}
    }
    while (len) {
	lock.acquire();
	x = spaceAvail();
	if (x<len) {
	    len = x;
	}
	if (len>0) {
	    x = putData(buf, len);
	    buf += x;
	    sem.V(x);
	    len -= x;
	}
	lock.release();
    }
}
示例#30
0
文件: putChunk.cpp 项目: MP2E/GDCC
         //
         // Info::putChunkAIMP
         //
         void Info::putChunkAIMP()
         {
            if(!numChunkAIMP) return;

            Core::Array<IR::Space const *> imps{numChunkAIMP};

            auto itr = imps.begin();
            for(auto const &sp : prog->rangeSpaceMapArs())
               if(!sp.defin) *itr++ = &sp;

            Core::FastU size = numChunkAIMP * 8;
            for(auto const &imp : imps)
               size += lenString(imp->glyph);

            putData("AIMP", 4);
            putWord(size);

            for(auto const &imp : imps)
            {
               putWord(imp->value);
               putWord(imp->words);
               putString(imp->glyph);
            }
         }