⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 p_contif.c

📁 是一个手机功能的模拟程序
💻 C
📖 第 1 页 / 共 2 页
字号:
/*
 * Copyright (C) Ericsson Mobile Communications AB, 2000.
 * Licensed to AU-System AB.
 * All rights reserved.
 *
 * This software is covered by the license agreement between
 * the end user and AU-System AB, and may be used and copied
 * only in accordance with the terms of the said agreement.
 *
 * Neither Ericsson Mobile Communications AB nor AU-System AB
 * assumes any responsibility or liability for any errors or inaccuracies in
 * this software, or any consequential, incidental or indirect damage arising
 * out of the use of the Generic WAP Client software.
 */

/*========================================================================

	WAP Implementation Project

==========================================================================

    File: p_contif.c

    Description: PUSH Content Interface file.

    Author: Jens Pommer, AU-System AB

    Revision history:
    Date    Sig     Comment
    991116  JPR     First version

    000207  JPR     Updated to support new WBXML-decoder
    000208  JPR     New functions added
    000814  JPR     Handling of PI elements corrected
    010119  NKE     Updated Si_BuildStructure, Sl_BuildStructure and
                    Co_BuildStructure for the new decoder in wbxmldec.c.
    010126  NKE     Updated Si_BuildStructure

=========================================================================*/

#include "p_contif.h"
#include "pushelm.h"


/*========================================================================

	Service Indication Functions

=========================================================================*/

/*========================================================================
	Si_BuildStructure
======================================================================== */
pDECSTR Si_BuildStructure (BYTE *pbData, BYTE *pbEnd, INT16 iCharset, 
						   UINT8 iContentLevel, UINT8 iViewID)
{
	pWBXMLDECODESTR pDecStr=NULL;
	pELEMENTTYPE pStructure=NULL;
	BOOL finished;

	/* IS THIS PARAMETER NEEDED? (Error handling) */
	iViewID=iViewID;

	/* Create tWBXMLDECODESTR and init the attributes */
	pDecStr=WBXML_CreateWBXMLDecStr();

	if (pDecStr!=NULL)
	{
		/* Set the function pointers */
		pDecStr->DTD_CreateElement=Si_CreateElement;
		pDecStr->DTD_DeleteElement=Si_DeleteElement;
		pDecStr->DTD_ValidContent=Si_ValidContent;
		pDecStr->DTD_GetContent=Si_GetContent;
		pDecStr->DTD_AppSpecParseMod=Si_AppSpecParseMod;
		pDecStr->DTD_StoreAttributeValue=Si_StoreAttributeValue;
		pDecStr->DTD_GetAttributeValue=Si_GetAttributeValue;
		pDecStr->DTD_LiteralAttributeToToken=Si_LiteralAttributeToToken;
		pDecStr->DTD_LiteralTagToToken=Si_LiteralTagToToken;
		pDecStr->DTD_CheckPublicID=Si_CheckPublicID;

		/* Store data in the decode struct */
		pDecStr->bContentType='\x2d';	/* text/vnd.wap.sic */
		pDecStr->iCharset=iCharset;
		pDecStr->iContentLevel=iContentLevel;
		pDecStr->pbCurByte=pbData;
		pDecStr->pbEnd=pbEnd;
		pDecStr->iDecodeResult=0;		
		pDecStr->pAppSpec=NULL;
		
		/* Parse prolog */
		if (WBXML_DecodeProlog(pDecStr))
		{
			/* Step past all PI:s */
			WBXML_StepPastAllPIs (pDecStr);

			/* Parse channel */
			WBXML_InitDecode(pDecStr, FALSE);
			pStructure = WBXML_Decode(pDecStr, &finished);

			/* Step past all PI:s */
			WBXML_StepPastAllPIs (pDecStr);
		}

		/* Check if any (fatal) errors or warnings */
		if ( pDecStr->iDecodeResult == 0)
		{
			/* Store the structure under the application specific pointer
			   in the decode struct. */
			pDecStr->pAppSpec=pStructure;
		}
		else
		{
			/* Error - delete */
			Si_DeleteElement(pDecStr,&pStructure);

			/* Delete decode struct */
			WBXML_DeleteWBXMLDecStr(&pDecStr);
		}
	}

	/* Return the decode struct */
	return pDecStr;
}


/*========================================================================
	Si_DeleteStructure
======================================================================== */
void Si_DeleteStructure (pDECSTR *ppDecStr)
{
	if (*ppDecStr!=NULL)
	{
		/* Get the top element */
		pELEMENTTYPE pStructure=(*ppDecStr)->pAppSpec;

		/* Delete structure */
		Si_DeleteElement(*ppDecStr,&pStructure);
		(*ppDecStr)->pAppSpec=NULL;

		/* Delete decode struct */
		WBXML_DeleteWBXMLDecStr(ppDecStr);
	}
}


/*========================================================================
	Si_GetSi
======================================================================== */
pELEMENTTYPE Si_GetSi (pDECSTR pDecStr)
{
	if (pDecStr!=NULL)
	{
		return (pELEMENTTYPE)pDecStr->pAppSpec;
	}
	return NULL;
}


/*========================================================================
	Si_GetIndication
======================================================================== */
pELEMENTTYPE Si_GetIndication (pELEMENTTYPE pSi)
{
	pELEMENTTYPE pContent=NULL;

	if (pSi!=NULL)
	{
		/* Check type */
		if (pSi->iType==Si_Type_si)
		{
			pContent=Si_GetContent (pSi);

			while (pContent!=NULL)
			{
				/* Check if indication element */
				if (pContent->iType==Si_Type_indication)
				{
					/* Indication found */
					return pContent;
				}

				/* Get next */
				pContent=XML_GetNextElement (pContent);
			}
		}
	}

	/* Return NULL*/
	return NULL;
}


/*========================================================================
	Si_GetInfo
======================================================================== */
pELEMENTTYPE Si_GetInfo (pELEMENTTYPE pSi)
{
	pELEMENTTYPE pContent=NULL;

	if (pSi!=NULL)
	{
		/* Check type */
		if (pSi->iType==Si_Type_si)
		{
			pContent=Si_GetContent (pSi);

			while (pContent!=NULL)
			{
				/* Check if info element */
				if (pContent->iType==Si_Type_info)
				{
					/* Info found */
					return pContent;
				}

				/* Get next */
				pContent=XML_GetNextElement (pContent);
			}
		}
	}

	/* Return NULL */
	return NULL;
}


/*========================================================================
	Si_GetHref
======================================================================== */
BYTE *Si_GetHref (pELEMENTTYPE pIndication)
{
	if (pIndication!=NULL)
	{
		/* Check type */
		if (pIndication->iType==Si_Type_indication)
		{
			if (((SI_INDICATIONELEMENT*)(pIndication))->pbHref!=NULL)
			{
				/* Get copy of href */
				return B_CopyByteString (
					((SI_INDICATIONELEMENT *)(pIndication))->pbHref,-1);
			}
		}
	}

	return NULL;
}


/*========================================================================
	Si_GetIndicationText
======================================================================== */
WCHAR *Si_GetIndicationText (pDECSTR pDecStr, pELEMENTTYPE pIndication)
{
	pELEMENTTYPE pContent=NULL;

	if (pIndication!=NULL)
	{
		pContent=Si_GetContent(pIndication);

		/* Content is #PCDATA */
		if (pContent!=NULL)
		{
			return XML_GetString (pContent,pDecStr);
		}
	}
	
	return NULL;
}


/*========================================================================
	Si_GetSiId
======================================================================== */
WCHAR *Si_GetSiId (pELEMENTTYPE pIndication)
{
	WCHAR *pwchCopy=NULL;

	if (pIndication!=NULL)
	{
		/* Check type */
		if (pIndication->iType==Si_Type_indication)
		{
			/* Get copy of SiId */
			pwchCopy=CreateStringCopy (
				((SI_INDICATIONELEMENT *)(pIndication))->pwchSiId);

			/* return copy */
			return pwchCopy;
		}
	}

	return NULL;
}


/*========================================================================
	Si_GetCreated
======================================================================== */
UINT32 Si_GetCreated (pELEMENTTYPE pIndication)
{
	if (pIndication!=NULL)
	{
		/* Check type */
		if (pIndication->iType==Si_Type_indication)
		{
			/* Return created */
			return (((SI_INDICATIONELEMENT *)(pIndication))->iCreated);
		}
	}

	return 0;
}


/*========================================================================
	Si_GetExpires
======================================================================== */
UINT32 Si_GetExpires (pELEMENTTYPE pIndication)
{
	if (pIndication!=NULL)
	{
		/* Check type */
		if (pIndication->iType==Si_Type_indication)
		{
			/* Return Expires */
			return (((SI_INDICATIONELEMENT *)(pIndication))->iExpires);
		}
	}

	return 0;
}


/*========================================================================
	Si_GetAction
======================================================================== */
UINT8 Si_GetAction (pELEMENTTYPE pIndication)
{
	if (pIndication!=NULL)
	{
		/* Check type */
		if (pIndication->iType==Si_Type_indication)
		{
			/* Return action */
			return (((SI_INDICATIONELEMENT *)(pIndication))->iAction);
		}
	}

	/* Default value */
	return SI_SIGNAL_MEDIUM;
}


/*========================================================================
	Si_GetNextItem
======================================================================== */
pELEMENTTYPE Si_GetNextItem (pELEMENTTYPE pInfo, pELEMENTTYPE pItem)
{
    pELEMENTTYPE    pElem;

    if (pItem!=NULL)
    {
        /* Use pItem as starting point */
        pElem = pItem->pNextElement;
    }
    else
    {
        /* Use pInfo as starting point */
        pElem = Si_GetContent(pInfo);
    }

    return pElem;
}


/*========================================================================
	Si_GetClass
======================================================================== */
WCHAR *Si_GetClass (pELEMENTTYPE pItem)
{
	if (pItem!=NULL)
	{
		/* Check type */
		if (pItem->iType==Si_Type_item)
		{
			/* Get copy of Class */
			return CreateStringCopy (

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -