예제 #1
0
char *strrstr(const char *text, const char *hledany) {
	//najdeme konce obou retezcu
	char *textEnd = endOfString(text);
	char *hledanyEnd = endOfString(hledany);

	//od konce prochazime zadany text a postupne testujeme vsechny znaky z hledaneho
	while (textEnd >= text) {
		while(hledanyEnd >= hledany) {
			if (*hledanyEnd != *textEnd) break;
			//pokud nedoslo k breaku a jsme na konci hledaneho, muzeme vratit
			if(hledanyEnd == hledany) return textEnd;
			hledanyEnd--,textEnd--;
		}
	textEnd--;
	}

	return NULL;
}
OMX_ERRORTYPE 
CBellagioOpenMaxSymbianLoader::GetComponentsOfRole(OMX_STRING role,
                                                   OMX_U32 *pNumComps,
                                                   OMX_U8  **compNames)
{
    TInt index = 0;
    TInt count = 0;
    TInt length = 0;
    TInt roles = 0;
    TInt nameIndex = 0;

    count = componentInfos.Count();
    
    if (count < 1)
    {
        return OMX_ErrorComponentNotFound;
    }

    /* Turn the role into Symbian descriptor */
    length = strlen(role);
    TPtrC8 role8(reinterpret_cast<const TUint8 *>(role), length);
   
    /* Search all the components for the roles count */ 
    for (index = 0; index < count; index++)
    {
        if (role8.Compare((componentInfos[index])->DataType()) == 0)
        {
            roles++;
        }
    }

    *pNumComps = roles;

    // check if client is asking only for the number of components
    if (compNames == NULL)
    {
        return OMX_ErrorNone;
    }

    TBuf8<257> component;
    TBufC8<1> endOfString((TText8*)"\0");

    /* Search all the components for the component names */ 
    for (index = 0; index < count; index++)
    {
        if (role8.Compare((componentInfos[index])->DataType()) == 0)
        {
            CnvUtfConverter::ConvertFromUnicodeToUtf8(component, (componentInfos[index])->DisplayName());
            component.Append(endOfString);
            strcpy((char*)compNames[nameIndex], (char*)component.Ptr());
            nameIndex++;
        }
    }

    return OMX_ErrorNone;
}
OMX_ERRORTYPE 
CBellagioOpenMaxSymbianLoader::GetRolesOfComponent(OMX_STRING compName,
                                                   OMX_U32 *pNumRoles,
                                                   OMX_U8 **roles)
{
    TInt index = 0;

    index = GetInfoIndex(compName);

    if (index < 0)
    {
        return OMX_ErrorComponentNotFound;
    }

    TLex8 lexer = TLex8((componentInfos[index])->OpaqueData());
    lexer.Val((TUint32 &)(*pNumRoles), EDecimal);

    if((*pNumRoles) == 0) 
    {
        return OMX_ErrorNone;
    }

    // check if client is asking only for the number of roles
    if (roles == NULL)
    {
        return OMX_ErrorNone;
    }

    // TODO We copy only one role here and there might be several of those
    TBuf8<257> role;
    TBufC8<1> endOfString((TText8*)"\0");

    role.Append((componentInfos[index])->DataType());
    role.Append(endOfString);

    strcpy((char*)roles[0], (char*)role.Ptr());

    return OMX_ErrorNone;
}
예제 #4
0
void Page::makeText(string& html)
{
	bool foundTitle = false;
	bool inBody = false;
	string temp = "";
	for (int i = 0; i < html.length() ; i++)
	{
		if(!foundTitle)
		{
			if(html[i] == '<')
			{
				//title>
				i++;
				string titleTag = html.substr(i, 5); //legth of title
				if(titleTag == "title") //check if the tag is title
				{
					while(html[i] != '>')
						i++;
					i++;
					while(html[i] != '<')
					{
						temp += html[i];
						i++;
					}
					foundTitle = true;
					this->title = temp;
				}
			}
			temp = "" ; //clear temp BUFFER
		}
		else
		{
			if(html[i] == '<')
			{
				//body>
				i++;
				string bodyTag = html.substr(i, 4); //legth of "body"
				if(bodyTag == "body") //check if the tag is body tag
				{
					while(html[i] != '>')
						i++;
					inBody = true;
				}
			}
		}
		
		/**
		 * Actual Body Text In String
		 */
		 if(inBody)
		 {
		 	if(html[i] == '<')
		 	{
				//tr> / td>
		 		i++;
				string tableTag = html.substr(i, 2); //legth of "tr/td"
				if(tableTag == "tr")
				{
					temp += "\n"; //new row -> new line
					while(html[i] != '>')
						i++;
					i++;
				}
				else if(tableTag == "td")
				{
					temp += "\t"; // new cell -> tab between data	
					while(html[i] != '>')
						i++;
					i++;
				}
			}
			if(html[i] == '>')
			{
				i++;
				if(endOfString(i, html.length()))
					goto finishBuild; //Cheak if EOF (Text)
				while(html[i] != '<')
				{
					if(endOfString(i, html.length()))
						goto finishBuild; //Cheak if EOF (Text)
					if(html[i] == '&')
					{
					//&nbsp;
						string nbspChr = html.substr(i, 6);
						if(nbspChr == "&nbsp;")
						i += 6;
						if(endOfString(i, html.length()))
							goto finishBuild; //Cheak if EOF (Text)
					}
					if(html[i] == '<')
						continue;
					else if(html[i] != '\n')
						temp += html[i];
					i++;
				}
			}
		}
	}
	finishBuild:
		this->text = temp;
}