Beispiel #1
0
/**
 * ファイルからログイン情報を取得
 */
void Login::Read()
{
	// ----------------------------------------
	// IDとパスワードを取得
	// ----------------------------------------

	// 初期値設定
	m_idList.clear();

	// 実行ファイルのパスからデータファイル名を作成
	CString fileName = theApp.GetAppDirPath() + _T("\\user.dat");

	// ファイルが存在していればそのファイルを読み込む
	if( util::ExistFile(fileName) ) {

		// ----------------------------------------
		// デコード処理
		// ----------------------------------------
		FILE* fp = _wfopen(fileName, _T("rb"));
		if (fp == NULL) {
			return;
		}

		// mixi
		CString s;
		SetMixiEmail( ReadItem(fp) );
		SetMixiPassword( ReadItem(fp) );
		CString dummy = ReadItem(fp);		// 旧オーナーID(互換性確保のためのパディング)

		// Twitter
		SetTwitterId( ReadItem(fp) );
		SetTwitterPassword( ReadItem(fp) );

		// Wassr
		SetWassrId( ReadItem(fp) );
		SetWassrPassword( ReadItem(fp) );

		// gooホーム
		SetGooId( ReadItem(fp) );
		SetGoohomeQuoteMailAddress( ReadItem(fp) );

		//--- 以上の9項目は旧バージョンとの互換用データ。
		//--- v1.0.0 以降は下記の汎用データ構造を正とし、上書きする。

		// その他の汎用ID
		// シリアライズした形式で保存されているのでデコードする
		CString serializedId = ReadItem(fp, true);

		UnserializeId(serializedId);

//		MZ3LOGGER_DEBUG(serializedId);
//		MZ3LOGGER_DEBUG(util::FormatString(L"serializedId len: %d", serializedId.GetLength()));

		fclose(fp);
	}
}
void ccf::ReadItem(XmlFile * const xml, T item[], int count)
{
    QMap<QString, int> mapItemCount;
    int subcount = 0;
    QStringList lst = xml->childKeys();
    for (int i = 0; i < lst.count(); ++i)
    {
        QString strSubKey = lst.at(i);
        subcount = mapItemCount[strSubKey];
        mapItemCount[strSubKey] = subcount + 1;
        if (subcount)
            strSubKey = strSubKey + QString("<%1>").arg(subcount);
        T tmp;
        // Initialize with possible item
        int num = ItemNumber(xml, tmp, strSubKey);
        if (num == 0 && i < count)
            num = i;
        else
            num--; // Make it 0-baed
        if (num < count)
        {
            tmp = item[num];
            ReadItem(xml, tmp, strSubKey);
            item[num] = tmp;
        }
    }
}
Beispiel #3
0
// ----------------------------------------------------------------------- //
//
//	ROUTINE:	CInventoryButeMgr::Init()
//
//	PURPOSE:	Init mgr
//
// ----------------------------------------------------------------------- //
LTBOOL CInventoryButeMgr::Init(const char* szAttributeFile)
{
    if (g_pInventoryButeMgr || !szAttributeFile) return LTFALSE;
    if (!Parse(szAttributeFile))
	{
		char szError[512];
		sprintf( szError, "CInventoryButeMgr::Init: Failed to parse %s", szAttributeFile );
		return LTFALSE;
	}

	// Set up global pointer
	g_pInventoryButeMgr = this;

	// Read Goal Sets.
	uint32 iItem = 0;
	sprintf(s_aTagName, "%s%d", "Item", iItem);
	
	while(m_buteMgr.Exist(s_aTagName))
	{
		ReadItem();
		iItem++;
		sprintf(s_aTagName, "%s%d", "Item", iItem);
	}

	m_buteMgr.Term();
    return LTTRUE;
}
Beispiel #4
0
/****************************************************************************\
**
**  tInputFile::writeLogFile
**
**  Write log file.
**  - 11/07/2003 AD
\****************************************************************************/
void tInputFile::writeLogFile() const
{
  std::ofstream inoutfile;  // output file in which items are recorded
  char inoutname[kMaxNameLength];
  // Create log file for inputs
  ReadItem( inoutname, sizeof(inoutname), "OUTFILENAME" );
  strcat( inoutname, ".inputs" );
  inoutfile.open( inoutname );
  if( !inoutfile.good() )
    {
      std::cerr << "Unable to open '" << inoutname << "'.\n"
	"(Error generated in module tInputFile,"
	" function tInputFile::tInputFile( const char * ) )" << std::endl;
      ReportFatalError( "The specified path name may not exist.\n" );
    }
  // write header
  {
    const time_t now = time(NULL);
    char *p = ctime(&now);
    *strchr(p, '\n') = '\0';
    inoutfile << "# Created by CHILD on " << p << "." << std::endl;
  }
  // dump content of KeyWordTable
  {
    const int len = KeyWordTable.getSize();
     for( int i = 0; i < len; ++i ) {
       inoutfile << KeyWordTable[i].key() << '\n'
		 << KeyWordTable[i].value() << '\n';
     }
  }
  inoutfile.close();
}
bool QPOIDatabase::ReadDatabase(QString strPathName)
{
    bool bRet = false;

    unsigned short RecvedBytes = 0;
    unsigned short DataHeader = ID_END_OF_DATA;

    //Read MyFlashDisk data file
     m_DbFile.setFileName(strPathName);
    if(m_DbFile.open(QIODevice::ReadOnly))
    {
        //read header first
        RecvedBytes = m_DbFile.read((char*)&DataHeader, SIZE_OF_ID);
        if((RecvedBytes) && (DataHeader == ID_HEADER_OF_DATA))
        {
            for(;m_ItemCount < MAX_ITEM_NUMS;)
            {
                RecvedBytes = m_DbFile.read((char*)&DataHeader, SIZE_OF_ID);
                m_pItemArray[m_ItemCount] = new QItemInfo();

                if(RecvedBytes)
                {
                    if(DataHeader == ID_ITEM_HEADER)
                    {
                        if(ReadItem(m_pItemArray[m_ItemCount]))
                        {
                            IncreaseItemCount(m_pItemArray[m_ItemCount]);
                            bRet = true;
                        }
                        else
                        {
                            delete m_pItemArray[m_ItemCount];
                            m_pItemArray[m_ItemCount] = NULL;
                        }
                    }
                    else
                    {
                        delete m_pItemArray[m_ItemCount];
                        m_pItemArray[m_ItemCount] = NULL;
                        break;
                    }
                }
                else
                {
                    delete m_pItemArray[m_ItemCount];
                    m_pItemArray[m_ItemCount] = NULL;
                    break;
                }
            }
        }
        m_DbFile.close();
    }

    return bRet;
}
Beispiel #6
0
otError SpinelDecoder::ReadDataWithLen(const uint8_t *&aData, uint16_t &aDataLen)
{
    otError  error = OT_ERROR_NONE;
    uint16_t len;

    SuccessOrExit(error = ReadUint16(len));
    SuccessOrExit(error = ReadItem(&aData, len));
    aDataLen = len;

exit:
    return error;
}
void ccf::ReadItem(XmlFile * const xml, T pItem[], int count1, int count2, QString strName)
{
    if (!xml->beginGroup(strName))
    {
        QMap<QString, int> mapItemCount;
        int subcount = 0;
        QStringList lst = xml->childKeys();
        count1 = std::min(lst.count(), count1);
        for (int i = 0; i < count1; ++i)
        {
            QString strSubKey = lst.at(i);
            subcount = mapItemCount[strSubKey];
            mapItemCount[strSubKey] = subcount + 1;
            if (subcount)
                strSubKey = strSubKey + QString("<%1>").arg(subcount);
            ReadItem(xml, pItem[i], count2, strSubKey);
        }
    }
    xml->endGroup();
}
bool IObjectMapPropertyType<KeyType, ValueType>::SerializeItem(
	ISerializer &value_serializer,
	IDeserializer &key_deserializer,
	int multi_index,
	const Object *object) const
{
	KeyType key;
	ValueType value;


	BidirectionalSerializer(key_deserializer) | key;

	if(ReadItem(object, key, multi_index, value))
	{
		BidirectionalSerializer(value_serializer) | value;
		return true;
	}
	else
	{
		return false;
	}
}
Beispiel #9
0
 /**
  * This method decodes and reads an EUI48 value form the frame.
  *
  * On success, the read position gets updated.
  *
  * @param[out] aEui48BufPtr         Reference to a buffer pointer to output the value.
  *                                  On success, the pointer variable is updated.
  *
  * @retval OT_ERROR_NONE            Successfully read the value.
  * @retval OT_ERROR_PARSE           Failed to parse/decode the value.
  *
  */
 otError ReadEui48(const uint8_t *&aEui48BufPtr) {
     return ReadItem(&aEui48BufPtr, sizeof(spinel_eui48_t));
 }
Beispiel #10
0
 /**
  * This method decodes and reads an EUI48 value form the frame.
  *
  * On success, the read position gets updated.
  *
  * @param[out] aEui48Ptr            Reference to an EUI48 pointer to output the value (as `spinel_eui48_t`).
  *                                  On success, the pointer variable is updated.
  *
  * @retval OT_ERROR_NONE            Successfully read the value.
  * @retval OT_ERROR_PARSE           Failed to parse/decode the value.
  *
  */
 otError ReadEui48(const spinel_eui48_t *&aEui48Ptr) {
     return ReadItem(reinterpret_cast<const uint8_t **>(&aEui48Ptr), sizeof(spinel_eui48_t));
 }
Beispiel #11
0
 /**
  * This method decodes and reads an EUI64 value form the frame.
  *
  * On success, the read position gets updated.
  *
  * @param[out] aEui64Ptr            Reference to an EUI64 pointer to output the value (as `otExtAddress`).
  *                                  On success, the pointer variable is updated.
  *
  * @retval OT_ERROR_NONE            Successfully read the value.
  * @retval OT_ERROR_PARSE           Failed to parse/decode the value.
  *
  */
 otError ReadEui64(const otExtAddress *&aEui64Ptr) {
     return ReadItem(reinterpret_cast<const uint8_t **>(&aEui64Ptr), sizeof(spinel_eui64_t));
 }
Beispiel #12
0
 /**
  * This method decodes and reads an IPv6 address form the frame.
  *
  * On success, the read position gets updated.
  *
  * @param[out] aIp6AddrBufPtr       Reference to a buffer pointer to output the value.
  *                                  On success, the pointer variable is updated.
  *
  * @retval OT_ERROR_NONE            Successfully read the value.
  * @retval OT_ERROR_PARSE           Failed to parse/decode the value.
  *
  */
 otError ReadIp6Address(const uint8_t *&aIp6AddrBufPtr) {
     return ReadItem(&aIp6AddrBufPtr, sizeof(spinel_ipv6addr_t));
 }
Beispiel #13
0
 /**
  * This method decodes and reads an IPv6 address form the frame.
  *
  * On success, the read position gets updated.
  *
  * @param[out] aIp6AddrPtr          Reference to IPv6 address pointer to output the value (as `otIp6Address`).
  *                                  On success, the pointer variable is updated.
  *
  * @retval OT_ERROR_NONE            Successfully read the value.
  * @retval OT_ERROR_PARSE           Failed to parse/decode the value.
  *
  */
 otError ReadIp6Address(const otIp6Address *&aIp6AddrPtr) {
     return ReadItem(reinterpret_cast<const uint8_t **>(&aIp6AddrPtr), sizeof(spinel_ipv6addr_t));
 }
Beispiel #14
0
void RTFParser::ReadItemGroup(int level)
{
	while(!PassEndGroup(level))
		ReadItem();
}
Beispiel #15
0
//typedef CCfgCalc* CalcType;
void ReadItem(CCfgCalc*& tReader, const TCHAR* sTitle, FIELD_CHECKER pFunFieldChecker,
              float fFieldCheckerParam)
{
    ReadItem(tReader, sTitle, false, 0.0f, pFunFieldChecker, fFieldCheckerParam);
}
Beispiel #16
0
void ReadItem(string& tReader, const TCHAR* sTitle,
              FIELD_CHECKER_STRING pFunFieldChecker)
{
    SetItemTitle(sTitle);
    ReadItem(tReader, sTitle, false, "", pFunFieldChecker);
}
Beispiel #17
0
//ReadItem()
void ReadItem(uint32& tReader, const TCHAR* sTitle,
              FIELD_CHECKER pFunFieldChecker, uint32 fFieldCheckerParam)
{
    ReadItem(tReader, sTitle, false, 0, pFunFieldChecker, fFieldCheckerParam);
}
Beispiel #18
0
int CConfig::ReadItem(const std::string& key, unsigned int defaultvalue, unsigned int & itemvalue, vector<string> * suffixList )
{
    return ReadItem(CGIMAGIC_UN_SECTIONED, key, defaultvalue, itemvalue, suffixList);
}
Beispiel #19
0
int CConfig::ReadItem(const std::string& key, unsigned int defaultvalue, unsigned int & itemvalue )
{
    return ReadItem(CGIMAGIC_UN_SECTIONED, key, defaultvalue, itemvalue);
}
void ccf::ReadItem(XmlFile * const xml, T item[], int count, QString strName)
{
    if (!xml->beginGroup(strName))
        ReadItem(xml, item, count);
    xml->endGroup();
}
Beispiel #21
0
int CV8File::LoadFile(BYTE *pFileData, bool boolUndeflate, bool UnpackWhenNeed)
{
	if (!pFileData)
		return -1;

	//mb("", "LoadFile");

	//BYTE *cpp1251_string = (BYTE*)malloc(100000);
	//UINT cpp1251_string_size;

	UINT undeflate_size;
	UINT BlocksAddrSize;

	BYTE *DataOut = NULL;//(BYTE*)malloc(100000);

	stFileHeader *pFileHeader = (stFileHeader*) pFileData;
	if (pFileHeader->sig != 0x7fffffff || pFileHeader->sig2 != 0x00000200)
		return -1;

	memcpy(&FileHeader, pFileHeader, sizeof(stFileHeader));

	stItemHeader *pItemHeader = (stItemHeader*) &pFileHeader[1];

	ReadItem(pItemHeader, pFileData, (BYTE*&)pBlocksAddr, &BlocksAddrSize);

	//pBlocks = (stBlock*) malloc(sizeof(stBlock) * FileHeader.blocks_num);

	FileHeader.blocks_num = BlocksAddrSize / sizeof(stBlockAddr);

	pBlocks = new stBlock[FileHeader.blocks_num];

	for (UINT i = 0; i < FileHeader.blocks_num; i++)
	{

		if (pBlocksAddr[i].fffffff != 0x7fffffff)
		{
			FileHeader.blocks_num = i;
			break;
		}

		//_RPT1(_CRT_WARN, "i = %i ", i);

		pItemHeader = (stItemHeader*) &pFileData[pBlocksAddr[i].block_header_addr];

		if (pItemHeader->space1 != ' ' || pItemHeader->space2 != ' ' || pItemHeader->space3 != ' ')
		{
			AfxMessageBox("BlockAdrr not correct!");
			break;
		}


		ReadItem(pItemHeader, pFileData, pBlocks[i].pHeader, &pBlocks[i].HeaderSize);

		//v8.unicode_to_1251((wchar_t*)pBlocks[i].pHeader, &cpp1251_string, _a/2);
		//memcpy(pBlocks[i].pHeader, cpp1251_string + 8 + 2, _a/2 - 8 - 2);


		//080228 ����� ������ ����� �� ����, ����� ����� ����� ������ ����� 0x7fffffff
		if (pBlocksAddr[i].block_data_addr != 0x7fffffff)
		{
			pItemHeader = (stItemHeader*) &pFileData[pBlocksAddr[i].block_data_addr];
			ReadItem(pItemHeader, pFileData, pBlocks[i].pData, &pBlocks[i].DataSize);
		}
		else
			ReadItem(NULL, pFileData, pBlocks[i].pData, &pBlocks[i].DataSize);

		//pBlocks[i].IsDataPacked = true;

		pBlocks[i].UnpakedData.IsDataPacked = false;

		if (boolUndeflate && IsDataPacked)
		{
			undeflate_size = Undeflate(pBlocks[i].pData, pBlocks[i].DataSize, &DataOut);

			if (!undeflate_size)
				IsDataPacked = false;
			else
			{

				if (UnpackWhenNeed)
				{

					delete[] pBlocks[i].pData;
					pBlocks[i].pData = new BYTE[undeflate_size];
					pBlocks[i].DataSize = undeflate_size;
					memcpy(pBlocks[i].pData, DataOut, undeflate_size);

					stFileHeader *pFileHeader = (stFileHeader*) DataOut;
					if (pFileHeader->sig != 0x7fffffff || pFileHeader->sig2 != 0x00000200)
						pBlocks[i].IsV8File = false;
					else
					{
						pBlocks[i].IsV8File = true;
						pBlocks[i].NeedUnpack = true;
					}
				}
				else
				{
					pBlocks[i].NeedUnpack = false;
					delete[] pBlocks[i].pData;
					if (!pBlocks[i].UnpakedData.LoadFile(DataOut, boolUndeflate))
					{
						pBlocks[i].pData = NULL;
						pBlocks[i].IsV8File = true;
					}
					else
					{
						pBlocks[i].pData = new BYTE[undeflate_size];
						pBlocks[i].DataSize = undeflate_size;
						memcpy(pBlocks[i].pData, DataOut, undeflate_size);
					}
				}
				
			}


		}
	}

	if (DataOut)
		free(DataOut);
	//free(cpp1251_string);
	return 0;
}
Beispiel #22
0
otError SpinelDecoder::ReadData(const uint8_t *&aData, uint16_t &aDataLen)
{
    aDataLen = mEnd - mIndex;

    return ReadItem(&aData, aDataLen);
}
Beispiel #23
0
int DBObjTable::Read(FILE *file, int swap) {
    DBInt id;
    DBDate date;
    DBCoordinate coord;
    DBRegion region;
    DBPosition pos;
    DBUShort row, col;
    DBObjRecord *record;
    DBObjTableField *field;

    if (DBObjectLIST<DBObjRecord>::Read(file, swap) != DBSuccess) return (DBFault);
    if (FieldPTR->Read(file, swap) != DBSuccess) return (DBFault);
    for (id = 0; id < FieldPTR->ItemNum(); ++id)
        if (FieldPTR->ReadItem(file, id, swap) == DBFault) return (DBFault);

    RecordLengthVAR = 0;
    for (field = FieldPTR->First(); field != (DBObjTableField *) NULL; field = FieldPTR->Next())
        RecordLengthVAR = RecordLengthVAR > field->StartByte() + field->Length() ?
                          RecordLengthVAR : field->StartByte() + field->Length();

    for (id = 0; id < ItemNum(); ++id) {
        if (ReadItem(file, id, swap) == DBFault) return (DBFault);
        record = Item(id);
        if (swap == false) continue;
        for (field = FieldPTR->First(); field != (DBObjTableField *) NULL; field = FieldPTR->Next())
            switch (field->Type()) {
                case DBTableFieldInt:
                case DBTableFieldFloat:
                case DBTableFieldTableRec:
                case DBTableFieldDataRec:
                    switch (field->Length()) {
                        case 2:
                            DBByteOrderSwapHalfWord((char *) record->Data() + field->StartByte());
                            break;
                        case 4:
                            DBByteOrderSwapWord((char *) record->Data() + field->StartByte());
                            break;
                        case 8:
                            DBByteOrderSwapLongWord((char *) record->Data() + field->StartByte());
                            break;
                    }
                    break;
                case DBTableFieldDate:
                    date = field->Date(record);
                    date.Swap();
                    field->Date(record, date);
                    break;
                case DBTableFieldCoord:
                    coord = field->Coordinate(record);
                    coord.Swap();
                    field->Coordinate(record, coord);
                    break;
                case DBTableFieldRegion:
                    region = field->Region(record);
                    region.Swap();
                    field->Region(record, region);
                    break;
                case DBTableFieldPosition:
                    pos = field->Position(record);
                    switch (field->Length()) {
                        case sizeof(DBPosition):
                            pos.Swap();
                            break;
                        default:
                            row = pos.Row;
                            col = pos.Col;
                            DBByteOrderSwapHalfWord(&row);
                            DBByteOrderSwapHalfWord(&col);
                            pos.Row = row;
                            pos.Col = col;
                            break;
                    }
                    field->Position(record, pos);
                    break;
                default:
                    break;
            }
    }
    if (MethodPTR->Read(file, swap) != DBSuccess) return (DBFault);
    for (id = 0; id < MethodPTR->ItemNum(); ++id) if (MethodPTR->ReadItem(file, id, swap) == DBFault) return (DBFault);
    return (DBSuccess);
}
void ccf::ReadItem(XmlFile * const xml, T & item, QString strName)
{
    if (!xml->beginGroup(strName))
        ReadItem(xml, item);
    xml->endGroup();
}