Ejemplo n.º 1
0
bool CIwGameFile::GetFileType(const char* file_path, CIwGameString& type)
{
	int						len = strlen(file_path) - 1;
	const char*				name_ptr = file_path + len;

	// Scan backwards looking for dot
	int index = 0;
	while (len >= 0)
	{
		if (*name_ptr == '.')
		{
			type.setString(name_ptr + 1, index);
			type.ToLower();
			break;
		}
		else
		if (len == 0)
		{
			type.setString(name_ptr, index + 1);
			type.ToLower();
			break;
		}
		name_ptr--;
		index++;
		len--;
	}
	
	return true;
}
Ejemplo n.º 2
0
int CIwGameString::GetNextMarkedStringAfterString(const char* search_string, char start_mark, char end_mark, CIwGameString& out_string)
{
	int pos = FindNext(search_string);
	if (pos >= 0)
	{
		// Get the text label
		int offset;
		StepFindIndex(strlen(search_string));
		int len = GetNextMarkedString(start_mark, end_mark, offset);
		if (len > 0)
		{
			out_string.setString(getString() + offset, len);
			return pos;
		}
		
		return -1;
	}

	return -1;
}
Ejemplo n.º 3
0
bool CIwGameAds::ExtractAdAdFonic(CIwGameAd& ad, CIwGameString& ad_body)
{
	// We dont use a full on XML parser to parse the returned XML, instead we just search for the required info
	int pos, offset, len;

	ad.isHtml = false;
	ad.isText = false;
	ad.ImageURI = "";
	ad.LinkURI = "";
	ad.Text = "";
	ad.AdTime = s3eTimerGetMs();

	// Get Error Response
	ad_body.FindReset();
	pos = ad_body.FindNext("<status");
	if (pos >= 0)
	{
		len = ad_body.GetNextMarkedString('>', '<', offset);
		if (len > 0)
		{
			ErrorString.setString(ad_body.getString() + offset, len);
			if (ErrorString == "error")
			{
				Error = ErrorInternalError;
				return false;
			}
			else
				Error = ErrorNone;
		}
	}

	// Get Ad format
	pos = ad_body.FindNext("<format");
	if (pos >= 0)
	{
		len = ad_body.GetNextMarkedString('>', '<', offset);
		if (len > 0)
		{
			CIwGameString format;
			format.setString(ad_body.getString() + offset, len);
			if (format == "banner")
				ad.isText = false;
			else
				ad.isText = true;

#if defined(_DEBUG)
			CIwGameError::LogError("Info: Ad Format: ", ad.Text.c_str());
#endif	// _DEBUG
		}
	}

	// Get Ad text
	pos = ad_body.FindNext("<![CDATA[");
	if (pos >= 0)
	{
		int end_pos = ad_body.FindNext("]]>");
		if (end_pos > 0)
		{
			ad.Text.setString(ad_body.getString() + pos + 9, end_pos - pos - 9);
#if defined(_DEBUG)
			CIwGameError::LogError("Info: Ad Text: ", ad.Text.c_str());
#endif	// _DEBUG
			ad.isHtml = true;
		}
	}
	ad_body.FindReset();

	// Get Ad link
	pos = ad_body.FindNext("url=");
	if (pos >= 0)
	{
		len = ad_body.GetNextMarkedString('"', '"', offset);
		if (len > 0)
		{
			ad.LinkURI.setString(ad_body.getString() + offset, len);
#if defined(_DEBUG)
			CIwGameError::LogError("Info: Ad Click URL: ", ad.LinkURI.c_str());
#endif	// _DEBUG
		}
	}

	// Get Ad image
	pos = ad_body.FindNext("src=");
	if (pos >= 0)
	{
		len = ad_body.GetNextMarkedString('"', '"', offset);
		if (len > 0)
		{
			ad.ImageURI.setString(ad_body.getString() + offset, len);
#if defined(_DEBUG)
			CIwGameError::LogError("Info: Ad Image URL: ", ad.ImageURI.c_str());
#endif	// _DEBUG
		}
	}

	return true;
}