//将Tag翻译为字符串,此处的Tag就是键值对中的键
LPWSTR ReadTagString(char *tagString)//pdf中#23代表'#'
{
	int index = 0;
	int len=(int)strlen(tagString);
	List output=InitList();//每个data是byte值
	while (index < len)
	{
		if (tagString[index] != '#')
		{
			AddNode(output,(void*)tagString[index] );
			index++;
		}
		else
		{
			if (tagString[index + 1] == '#')//正常pdf几乎不可能遇到的情况,两个#相连
			{
				AddNode(output,(void*)'#');
				AddNode(output,(void*)'#');
				index += 2;
			}
			else
			{
				if (!TestValid(Substring(tagString,index + 1, 2)))//如果不符合#00~#FF的形式,原样输出,正常pdf几乎不可能遇到的情况
				{
					AddNode(output,(void*)'#');
					AddNode(output,(void*)tagString[index+1]);
					AddNode(output,(void*)tagString[index+2]);
					index+=3;
				}
				else
				{
					AddNode(output,(void*)GetDecimal(Substring(tagString,index + 1, 2)));
					index += 3;
				}
			}
		}
	}
	return UTF8ToUnicode(CharListGetString(output));
}
Beispiel #2
0
CKernelOptions::CKernelOptions (void)
:	m_nWidth (0),
	m_nHeight (0),
	m_nLogLevel (LogDebug),
	m_nUSBPowerDelay (0),
	m_CPUSpeed (CPUSpeedLow),
	m_nSoCMaxTemp (60)
{
	strcpy (m_LogDevice, "tty1");
	strcpy (m_KeyMap, DEFAULT_KEYMAP);

	s_pThis = this;

	CBcmPropertyTags Tags;
	if (!Tags.GetTag (PROPTAG_GET_COMMAND_LINE, &m_TagCommandLine, sizeof m_TagCommandLine))
	{
		return;
	}

	if (m_TagCommandLine.Tag.nValueLength >= sizeof m_TagCommandLine.String)
	{
		return;
	}
	m_TagCommandLine.String[m_TagCommandLine.Tag.nValueLength] = '\0';
	
	m_pOptions = (char *) m_TagCommandLine.String;

	char *pOption;
	while ((pOption = GetToken ()) != 0)
	{
		char *pValue = GetOptionValue (pOption);

		if (strcmp (pOption, "width") == 0)
		{
			unsigned nValue;
			if (   (nValue = GetDecimal (pValue)) != INVALID_VALUE
			    && 640 <= nValue && nValue <= 1980)
			{
				m_nWidth = nValue;
			}
		}
		else if (strcmp (pOption, "height") == 0)
		{
			unsigned nValue;
			if (   (nValue = GetDecimal (pValue)) != INVALID_VALUE
			    && 480 <= nValue && nValue <= 1080)
			{
				m_nHeight = nValue;
			}
		}
		else if (strcmp (pOption, "logdev") == 0)
		{
			strncpy (m_LogDevice, pValue, sizeof m_LogDevice-1);
			m_LogDevice[sizeof m_LogDevice-1] = '\0';
		}
		else if (strcmp (pOption, "loglevel") == 0)
		{
			unsigned nValue;
			if (   (nValue = GetDecimal (pValue)) != INVALID_VALUE
			    && nValue <= LogDebug)
			{
				m_nLogLevel = nValue;
			}
		}
		else if (strcmp (pOption, "keymap") == 0)
		{
			strncpy (m_KeyMap, pValue, sizeof m_KeyMap-1);
			m_KeyMap[sizeof m_KeyMap-1] = '\0';
		}
		else if (strcmp (pOption, "usbpowerdelay") == 0)
		{
			unsigned nValue;
			if (   (nValue = GetDecimal (pValue)) != INVALID_VALUE
			    && 200 <= nValue && nValue <= 8000)
			{
				m_nUSBPowerDelay = nValue;
			}
		}
		else if (strcmp (pOption, "fast") == 0)
		{
			if (strcmp (pValue, "true") == 0)
			{
				m_CPUSpeed = CPUSpeedMaximum;
			}
		}
		else if (strcmp (pOption, "socmaxtemp") == 0)
		{
			unsigned nValue;
			if (   (nValue = GetDecimal (pValue)) != INVALID_VALUE
			    && 40 <= nValue && nValue <= 78)
			{
				m_nSoCMaxTemp = nValue;
			}
		}
	}
}
Beispiel #3
0
		// attempt to return a stored decimal
		double GetDecimal(const std::string& key) const { return GetDecimal(key, 0.0); };