Ejemplo n.º 1
0
bool Reference::updateOffset(FILE* file, long newOffset)
{
	if(getFilePosition() > 0)
	{
		// save the current offset
		long saveOffset = ftell(file);

		// update the offset data for us
		_offset = newOffset;
		// seek this Reference object in the file.
		fseek(file, getFilePosition(), SEEK_SET);

		//Skip over the id string
		skipString(file);

		// Skip
		skipUint(file);

		// write over the old offset.
		write(_offset, file);

		// restore the offset.
		fseek(file, saveOffset, SEEK_SET);
		return true;
	}

	return false;
}
Ejemplo n.º 2
0
bool loadSystemSettings()
{
	bool bRet = false;
	char *sysCfgStr = NULL, *saveSysCfgStr;

	int iValue;
	uint32_t uValue;
	char sBuffer[128];

	if(readFileFull(SYS_SETTINGS_FILE, &sysCfgStr))
	{
		saveSysCfgStr = sysCfgStr;
		if(FIRMWARE_VER_MAJOR == 1)
		{
			if(FIRMWARE_VER_MINOR == 0) /* for 01.00 */
			{
				do
				{
					if(!skipUint((const char**)&sysCfgStr, &gSysCfg.fwVerMinor ))
						break;

					if(!skipUint((const char**)&sysCfgStr, &gSysCfg.fwVerMajor))
						break;

					if(!skipInt((const char**)&sysCfgStr, (int*)&gSysCfg.wifiStationIsConfigured))
						break;
					gSysCfg.wifiStationIsConfigured = iValue;

					if(!skipString((const char**)&sysCfgStr, sBuffer, sizeof(sBuffer)))
						break;
					iValue = strlen(sBuffer);
					if(iValue < sizeof(sBuffer))
					{
						if(gSysCfg.wifiSSID)
							delete gSysCfg.wifiSSID;
						gSysCfg.wifiSSID = new char[iValue];
						memcpy(gSysCfg.wifiSSID, sBuffer, iValue);
						gSysCfg.wifiSSID[iValue - 1] = 0;
					}

					if(!skipString((const char**)&sysCfgStr, sBuffer, sizeof(sBuffer)))
						break;
					iValue = strlen(sBuffer);
					if(iValue < sizeof(sBuffer))
					{
						if(gSysCfg.wifiPwd)
							delete gSysCfg.wifiPwd;
						gSysCfg.wifiPwd = new char[iValue];
						memcpy(gSysCfg.wifiPwd, sBuffer, iValue);
						gSysCfg.wifiPwd[iValue - 1] = 0;
					}

					if(!skipUint((const char**)&sysCfgStr, &gSysCfg.dbgNumRestarts))
						break;

					if(!skipUint((const char**)&sysCfgStr, &gSysCfg.lastKnownTimeStamp))
						break;

					if(!skipInt((const char**)&sysCfgStr, (int*)&gSysCfg.timeZone))
						break;

					bRet = true;
				}while(0);
			}
		}
		if(saveSysCfgStr)
			delete saveSysCfgStr;
	}
	return bRet;
}