예제 #1
0
//! Reads program settings from the data structures in the Config class
//! @returns false on any error, true otherwise
//! @see Window()
bool Window::importSettings()
{
	bool retval = config->xmlRead(configFileURI, "charles_n_burns-data_parser");
	if(!retval) statusBarMessage->setText("Unable to read config file.");
	retval = config->xmlParse();
	if(!retval) statusBarMessage->setText("Unable to parse config file.");

	if(! config->pathlistInfile.isEmpty())
		comboInfile->addItems(config->pathlistInfile);
	if(! config->pathlistOutfile.isEmpty())
		comboOutfile->addItems(config->pathlistOutfile);

	checkBoxOpenWhenDone->setChecked(config->boxOpen);
	comboRowLimit->insertItem(0, QString::number(
			getUint64(config->limitRows.trimmed())));
	comboRowLimit->setCurrentIndex(0);

	int colCount = config->colCount;

	if(this->spinColumns->value() < colCount) spinColumns->setValue(colCount);
	for(int index = 0; index < colCount; ++index) {
		if(config->colNames.size() > index)
			dataComboName.at(index)->addItems(config->colNames.at(index));
		if(config->colBoxChecked.size() > index)
			dataCheckBox.at(index)->setChecked(config->colBoxChecked.at(index));
		if(config->colBytes.size() > index)
			dataSpinNumBytes.at(index)->setValue(config->colBytes.at(index));
	}
	spinColumns->setValue(config->colCount);
	return retval;
}
예제 #2
0
int Drawboard::authenticate(Client* client)
{
    uint32_t curpos = 1;
    uint32_t len=getUint16((uint8_t *)(&client->buffer[0]+curpos));         curpos += 2;

    #ifdef DEBUG
    std::cout << "    Len: " << len << std::endl;
    #endif
    if(client->buffer.size()-curpos < len)
    {
      return NEED_MORE_DATA;
    }
    std::string hash(' ',32);
    
    int32_t UID=getSint16((uint8_t *)(&client->buffer[0]+curpos));          curpos += 2;
    uint8_t  chanID = client->buffer[curpos];                               curpos++;
    uint64_t timestamp = getUint64((uint8_t *)(&client->buffer[0]+curpos)); curpos += 8;
    uint8_t  adminbit = client->buffer[curpos];                             curpos++;
    memcpy((void *)hash.data(), (uint8_t *)(&client->buffer[0]+curpos),32); curpos += 32;
    uint32_t nicklen=client->buffer[curpos];                                curpos++;

    std::string nick;
    for(uint32_t i = 0; i < nicklen; i++)
    {
      nick+=(char)client->buffer[curpos]; curpos ++;
    }

    //Clear the data from the buffer
    client->eraseFromBuffer(curpos);

    //ToDo: implement configuration reader etc
    if(0)//config.check_auth)
    {
      std::string user_time;
      myItoa(timestamp,user_time,10);

      //Check the auth data
      std::string combination=user_time+"|SECRET_STRING|"+(char)('0'+adminbit)+"|"+nick;

      std::string hash2;
      MD5_CTX mdContext;

		  MD5Init (&mdContext);
		  MD5Update (&mdContext, (unsigned char *)(combination.c_str()), combination.size());
		  MD5Final (&mdContext);
    			
		  for (int iii = 0; iii < 16; iii++)
			  hash2+=toHex((unsigned int)mdContext.digest[iii]);

      if(hash2 != hash)
      {
        return DATA_ERROR;
      }
    }
    client->nick = nick;
    client->admin = (adminbit==0)?false:true;


    return DATA_OK;
}
예제 #3
0
uint64_t TraderApi::insertOrder(dict req, uint64_t sessionid)
{
	XTPOrderInsertInfo myreq = XTPOrderInsertInfo();
	memset(&myreq, 0, sizeof(myreq));
	getDouble(req, "stop_price", &myreq.stop_price);
	getDouble(req, "price", &myreq.price);
	getStr(req, "ticker", myreq.ticker);

	getUint32(req, "order_client_id", &myreq.order_client_id);
	getUint64(req, "order_xtp_id", &myreq.order_xtp_id);
	getInt64(req, "quantity", &myreq.quantity);

	int price_type;
	int side;
	int market;
	int business_type;
	getInt(req, "price_type", &price_type);
	getInt(req, "side", &side);
	getInt(req, "market", &market);
	getInt(req, "business_type", &business_type);
	myreq.price_type = (XTP_PRICE_TYPE)price_type;
	myreq.side = (XTP_SIDE_TYPE)side;
	myreq.market = (XTP_MARKET_TYPE)market;
	myreq.business_type = (XTP_BUSINESS_TYPE)business_type;

	return this->api->InsertOrder(&myreq, sessionid);
};
예제 #4
0
/*parse mysql coded length*/
static uint64_t decodeint(uint8_t *ev ,uint32_t *cur){
	uint8_t v = getInt8(ev);
	*cur += 1;
	if(v < 251) return v;
	if(v == 251) return 0;	
	if(v == 252){ *cur += 2; return getUint16(ev + 1); }
	if(v == 253){ *cur += 3; return getUint24(ev + 1); }
	if(v == 254){ *cur += 8; return getUint64(ev + 1); }
	return 0;
}
예제 #5
0
파일: main.c 프로젝트: gansidui/fuck
int main() {
	uint64_t ret = getUint64();
	printf("ret == %llu\n", ret);
	
	Node a;
	a = getStruct();
	printf("a.v == %d\n", a.v);

	return 0;
 }
예제 #6
0
void printCell(Cell *cell){
	switch(cell->ctype){
		case INT32:
			printf("%d\t",getInt32(cell->value));
			break;
		case UINT32:
			printf("%d\t",getUint32(cell->value));
			break;
		case INT64:
			printf("%ld\t",getInt64(cell->value));
			break;
		case UINT64:
			printf("%lu\t",getUint64(cell->value));
			break;
		case INT8:
			printf("%d",getInt8(cell->value));
			break;
		case INT16:
			printf("%d",getInt16(cell->value));
			break;
		case FLOAT:
			printf("%f\t",getFloat(cell->value));
			break;
		case DOUBLE:
			printf("%f\t",getDouble(cell->value));
			break;
		case STRING: //MySQL type BINARY may be STRING
			{   
				char *value =(char *) cell->value;
				printf("%s\t",(char*)value);
				break;

			}   
		case BINARY:
			printf("BINARY\t");
			break;
		default:
			printf("UNKNOW\t");
			break;

	}
}
int main(int argc, TCHAR **argv) {
//  _tprintf(_T("sizeof(long double):%s\n"), FSZ(sizeof(long double)));
//  _tprintf(_T("sizeof(Double80:%s\n"), FSZ(sizeof(Double80)));

  unsigned __int64 ui64max = _UI64_MAX;
  Double80         dui64 = ui64max;
  unsigned __int64 rui64 = getUint64(dui64);

  for (;;) {
    double x = inputDouble(_T("Enter x:"));
//    double y = inputDouble(_T("Enter y:"));
    Double80 x80 = x; // , y80 = y;
//    Double80 z80 = pow(x80, y80);
    Double80 z80 = exp2(x80);
    double z64 = getDouble(z80);
    _tprintf(_T("exp2(%lg)=%le\n"), x, z64);
  }
  Double80 x;
  Double80 y;
  unsigned long l1 = 1;
  x = 1;
  y = 2.3;
  Double80 z = x + y;
  double z64 = getDouble(z);
  _tprintf(_T("x+y:%le\n"), z64);

  x = 9.7;
  y = 4;
  z = fmod(x, y);
  z64 = getDouble(z);

  x = M_PI;
  x *= 2;
  x /= 3;
  double x64 = getDouble(x);
  Double80 c = x, s;
  sincos(c, s);
  double c64 = getDouble(c);
  double s64 = getDouble(s);
  z = cos(x);
  z64 = getDouble(z);

  double e10 = 9.999e20;
  Double80 d1080 = e10;
  int expo10 = Double80::getExpo10(d1080);

  Double80 exp80 = exp(z);
  double exp64 = getDouble(exp80);
  const long             maxi32     = 0x7fffffff;
  Double80               zi32(maxi32);
  const long             i32_1      = getInt(zi32);

  const unsigned long    ui32_a1    = maxi32;
  Double80               dui32_a(ui32_a1);
  const unsigned long    ui32_a2    = getUint(dui32_a);

  const unsigned long    ui32_b1    = (unsigned long)maxi32 + 1;
  Double80               dui32_b(ui32_b1);
  const unsigned long    ui32_b2    = getUint(dui32_b);

  const __int64          maxi64     = 0x7fffffffffffffffui64;
  Double80               di64(maxi64);
  const __int64          i64_1      = getInt64(di64);

  const unsigned __int64 ui64_a1    = maxi64;
  Double80               dui64_a(ui64_a1);
  const unsigned __int64 ui64_a2    = getUint64(dui64_a);

  const unsigned __int64 ui64_b1    = (unsigned __int64)maxi64 + 1;
  Double80               dui64_b(ui64_b1);
  const unsigned __int64 ui64_b2    = getUint64(dui64_b);

  const float            f1         = 1.23456f;
  Double80               zf(f1);
  const float            f2         = getFloat(zf);

  return 0;
}
예제 #8
0
static void handleAggDataUpdate(DDTypedBufferMsg_t *msg, PS_DataBuffer_t *data)
{
    char *ptr = data->buf;
    AccountDataExt_t aggData;
    PStask_ID_t logger;

    /* get logger's task ID */
    getInt32(&ptr, &logger);

    if (!findJobByLogger(logger)) {
	mlog("%s: update unknown logger %s\n", __func__, PSC_printTID(logger));
	return;
    }

    getUint64(&ptr, &aggData.maxThreadsTotal);
    getUint64(&ptr, &aggData.maxVsizeTotal);
    getUint64(&ptr, &aggData.maxRssTotal);
    getUint64(&ptr, &aggData.maxThreads);
    getUint64(&ptr, &aggData.maxVsize);
    getUint64(&ptr, &aggData.maxRss);

    getUint64(&ptr, &aggData.avgThreadsTotal);
    getUint64(&ptr, &aggData.avgThreadsCount);
    getUint64(&ptr, &aggData.avgVsizeTotal);
    getUint64(&ptr, &aggData.avgVsizeCount);
    getUint64(&ptr, &aggData.avgRssTotal);
    getUint64(&ptr, &aggData.avgRssCount);

    getUint64(&ptr, &aggData.cutime);
    getUint64(&ptr, &aggData.cstime);
    getUint64(&ptr, &aggData.minCputime);
    getUint64(&ptr, &aggData.pageSize);
    getUint32(&ptr, &aggData.numTasks);

    getUint64(&ptr, &aggData.maxMajflt);
    getUint64(&ptr, &aggData.totMajflt);
    getUint64(&ptr, &aggData.totCputime);
    getUint64(&ptr, &aggData.cpuFreq);

    getDouble(&ptr, &aggData.maxDiskRead);
    getDouble(&ptr, &aggData.totDiskRead);
    getDouble(&ptr, &aggData.maxDiskWrite);
    getDouble(&ptr, &aggData.totDiskWrite);

    getInt32(&ptr, &aggData.taskIds[ACCID_MAX_VSIZE]);
    getInt32(&ptr, &aggData.taskIds[ACCID_MAX_RSS]);
    getInt32(&ptr, &aggData.taskIds[ACCID_MAX_PAGES]);
    getInt32(&ptr, &aggData.taskIds[ACCID_MIN_CPU]);
    getInt32(&ptr, &aggData.taskIds[ACCID_MAX_DISKREAD]);
    getInt32(&ptr, &aggData.taskIds[ACCID_MAX_DISKWRITE]);

    getTime(&ptr, &aggData.rusage.ru_utime.tv_sec);
    getTime(&ptr, &aggData.rusage.ru_utime.tv_usec);
    getTime(&ptr, &aggData.rusage.ru_stime.tv_sec);
    getTime(&ptr, &aggData.rusage.ru_stime.tv_usec);

    setAggData(msg->header.sender, logger, &aggData);

    mdbg(PSACC_LOG_UPDATE_MSG, "%s: from %s maxThreadsTot %lu maxVsizeTot %lu"
	 " maxRsstot %lu maxThreads %lu maxVsize %lu maxRss %lu numTasks %u\n",
	 __func__, PSC_printTID(msg->header.sender), aggData.maxThreadsTotal,
	 aggData.maxVsizeTotal, aggData.maxRssTotal, aggData.maxThreads,
	 aggData.maxVsize, aggData.maxRss, aggData.numTasks);
}
 uint64_t ClientMessage::get() {
     return getUint64();
 }
예제 #10
0
static uint64_t readUint64(EventCursor *evcur){
	uint64_t v = getUint64(evcur->ev + evcur->cur);
	evcur->cur += 8;
	return v;
}
예제 #11
0
luabridge::LuaRef CLuaBinary::getStruct(luabridge::LuaRef objAttr)
{
    assert(objAttr.isTable());

    DataType emType;
    int iSize = Q_INIT_NUMBER;
    std::string strName;
    luabridge::LuaRef objVal = luabridge::newTable(m_pLua);

    for (int i = 1; i <= objAttr.length(); i++)
    {
        luabridge::LuaRef objTmp = objAttr[i];
        if (!objTmp.isTable()
            || STATTRTAB_MINLENS > objTmp.length())
        {
            break;
        }

        luabridge::LuaRef objChildStAttr = getStructAttr(objTmp, strName, emType, iSize);
        switch(emType)
        {
        case DTYPE_SINT8:
            {
                objVal[strName] = getSint8();
            }
            break;
        case DTYPE_UINT8:
            {
                objVal[strName] = getUint8();
            }
            break;
        case DTYPE_BOOL:
            {
                objVal[strName] = getBool();
            }
            break;
        case DTYPE_SINT16:
            {
                objVal[strName] = getSint16();
            }
            break;
        case DTYPE_UINT16:
            {
                objVal[strName] = getUint16();
            }
            break;
        case DTYPE_SINT32:
            {
                objVal[strName] = getSint32();
            }
            break;
        case DTYPE_UINT32:
            {
                objVal[strName] = getUint32();
            }
            break;
        case DTYPE_SINT64:
            {
                objVal[strName] = getSint64();
            }
            break;
        case DTYPE_UINT64:
            {
                objVal[strName] = getUint64();
            }
            break;
        case DTYPE_FLOAT:
            {
                objVal[strName] = getFloat();
            }
            break;
        case DTYPE_DOUBLE:
            {
                objVal[strName] = getDouble();
            }
            break;
        case DTYPE_STRING:
            {
                std::string strVal = getString();
                objVal[strName] = strVal;
                skipRead((unsigned int)(iSize - (strVal.size() + 1)));
            }
            break;
        case DTYPE_BYTE:
            {
                objVal[strName] = getByte(iSize);
            }
            break;
        case DTYPE_STRUCT:
            {
                objVal[strName] = getStruct(objChildStAttr);
            }
            break;
        case DTYPE_SKIP:
            {
                if (iSize > Q_INIT_NUMBER)
                {
                    skipRead(iSize);
                }
            }
            break;

        default:
            break;
        }
    }

    return objVal;
}