📄 hdrutil.c
字号:
{
/* Not used */
}
}
/* Type (Multipart/Related) */
else if (bParam==9)
{
pbTemp=pbValue;
/* Check if Constrained-media */
if (isWapShortInteger(&pbValue,pbEnd))
{
pParams->bMPRType=WSP_GetShortInt(*pbTemp);
}
else if (isWapExtensionMedia(&pbValue,pbEnd))
{
/* Convert the value to byte */
if (!(WSP_ConvertContentStringByte(&(pParams->bMPRType),&pbTemp)))
{
/* Not supported type */
pParams->bMPRType=0;
}
}
}
/* Start */
else if (bParam==0xa)
{
/* Text-string */
pParams->pbMPRStart=WSP_GetTextString(&pbValue,pbEnd,fError);
}
/* Start-info */
else if (bParam==0xb)
{
/* Text-string */
pParams->pbMPRStartInfo=WSP_GetTextString(&pbValue,pbEnd,fError);
}
/* SEC */
else if (bParam==0x11)
{
pbTemp=pbValue;
/* Check if Constrained-media */
if (isWapShortInteger(&pbValue,pbEnd))
{
pParams->iSEC=WSP_GetShortInt(*pbTemp);
}
else
{
pParams->iSEC=255;
}
}
/* MAC */
else if (bParam==0x12)
{
/* Text-string */
pParams->pbMAC=WSP_GetTextString(&pbValue,pbEnd,fError);
}
}
else if (isWapLongInteger(&pbValue,pbEnd))
{
if (isWapTypedValue(&pbValue,pbEnd))
{
/* Not supported here */
}
else
{
/* Error */
*fError=TRUE;
}
}
else if (isWapTokenText(&pbValue,pbEnd))
{
/* Untyped-parameter */
if (isWapUnTypedValue(&pbValue,pbEnd))
{
/* Not supported here */
}
else
{
/* Error */
*fError=TRUE;
}
}
else
{
/* Error */
*fError=TRUE;
}
}
*ppParameters=pParams;
}
BYTE WSP_GetContentTypeByte (pHEADERELEMENT pElement, BOOL *fError,
pWSPPARAMETERS* ppParameters)
{
BYTE *pbValue=NULL;
BYTE *pbTemp=NULL;
BOOL fParameter=FALSE;
BYTE bValue=0;
*fError=TRUE;
if (pElement!=NULL)
{
/* Check code page. */
/* Just code page 1 */
if (pElement->bCodePage==1)
{
pbValue=pElement->pbFieldValStart;
pbTemp=pbValue;
/* Check if Constrained-media or Content-general-form */
if (isWapShortInteger(&pbValue,pElement->pbFieldValEnd))
{
bValue=WSP_GetShortInt(*pbTemp);
*fError=FALSE;
}
else if (isWapExtensionMedia(&pbValue,pElement->pbFieldValEnd))
{
if (WSP_ConvertContentStringByte(&bValue,&pbTemp))
{
*fError=FALSE;
if (bValue==TEXT_X_WAP_WTA_WML)
{
/* WTA-WML (text) internally --> Not supported */
*fError=TRUE;
}
}
}
/* Content-general-form ( Value-length Media-type ) */
else if (isWapValueLength(&pbValue,pElement->pbFieldValEnd))
{
/* Parameter */
fParameter=TRUE;
pbTemp=pbValue;
/* Check if well-known value */
if (isWapShortInteger(&pbValue,pElement->pbFieldValEnd))
{
bValue=WSP_GetShortInt(*pbTemp);
*fError=FALSE;
}
else if (isWapExtensionMedia(&pbValue,pElement->pbFieldValEnd))
{
if (WSP_ConvertContentStringByte(&bValue,&pbTemp))
{
*fError=FALSE;
if (bValue==TEXT_X_WAP_WTA_WML)
{
/* WTA-WML (text) internally --> Not supported */
*fError=TRUE;
}
}
}
}
/* Get all parameters (only if general form - fParameter TRUE)*/
if (fParameter)
{
WSP_GetParameters (pbValue, pElement->pbFieldValEnd,
fError, ppParameters);
}
else
{
/* Store NULL in ppParameters */
*ppParameters=NULL;
}
}
}
return bValue;
}
BYTE *WSP_GetContentTypeString (pHEADERELEMENT pElement, BOOL *fError,
pWSPPARAMETERS* ppParameters)
{
BYTE *pbValue=NULL;
BYTE *pbNewString=NULL;
BYTE *pbTemp=NULL;
BOOL fParameter=FALSE;
BYTE bValue=0;
*fError=TRUE;
if (pElement!=NULL)
{
/* Check code page. */
/* Just code page 1 */
if (pElement->bCodePage==1)
{
pbValue=pElement->pbFieldValStart;
pbTemp=pbValue;
/* Check if Constrained-media or Content-general-form */
if (isWapShortInteger(&pbValue,pElement->pbFieldValEnd))
{
bValue=WSP_GetShortInt(*pbTemp);
/* Convert byte to string */
if (WSP_ConvertContentStringByte(&bValue,&pbNewString))
{
*fError=FALSE;
}
}
else if (isWapExtensionMedia(&pbValue,pElement->pbFieldValEnd))
{
*fError=FALSE;
/* Copy string (-1 indicates null-terminated) */
pbNewString=B_CopyByteString(pbTemp, -1);
}
/* Content-general-form ( Value-length Media-type ) */
else if (isWapValueLength(&pbValue,pElement->pbFieldValEnd))
{
/* Parameter */
fParameter=TRUE;
pbTemp=pbValue;
/* Check if well-known value */
if (isWapShortInteger(&pbValue,pElement->pbFieldValEnd))
{
bValue=WSP_GetShortInt(*pbTemp);
/* Convert byte to string */
if (WSP_ConvertContentStringByte(&bValue,&pbNewString))
{
*fError=FALSE;
}
}
else if (isWapExtensionMedia(&pbValue,pElement->pbFieldValEnd))
{
*fError=FALSE;
/* Copy string (-1 indicates null-terminated) */
pbNewString=B_CopyByteString(pbTemp, -1);
}
}
/* Get all parameters (only if general form - fParameter TRUE)*/
if (fParameter)
{
WSP_GetParameters (pbValue, pElement->pbFieldValEnd,
fError, ppParameters);
}
else
{
/* Store NULL in ppParameters */
*ppParameters=NULL;
}
}
}
return pbNewString;
}
BYTE WSP_GetCacheControlByte (pHEADERELEMENT pElement, UINT32 *piDeltaSec,
BOOL *fError)
{
BYTE bValue=0;
BYTE *pbValue=NULL;
BYTE *pbTemp=NULL;
*fError=TRUE;
if (pElement!=NULL)
{
/* Check code page. */
/* Just code page 1 */
if (pElement->bCodePage==1)
{
pbValue=pElement->pbFieldValStart;
if (pbValue<pElement->pbFieldValEnd)
{
bValue=*pbValue;
/* Check if well known cache control-value */
if ((bValue>=128)&&(bValue<=138)&&
(bValue!=130)&&(bValue!=132))
{
*fError=FALSE;
}
else if (isWapTokenText(&pbValue,pElement->pbFieldValEnd))
{
/* Cache extension */
}
else if (isWapValueLength(&pbValue,pElement->pbFieldValEnd))
{
if (pbValue<pElement->pbFieldValEnd)
{
bValue=*pbValue;
/* Check if no-cache */
if (bValue==128)
{
*fError=FALSE;
}
/* Check if Max-age, Max-stale or Min-Fresh */
else if ((bValue==130)||(bValue==130)||(bValue==130))
{
if (HdrNextByte(&pbValue,pElement->pbFieldValEnd))
{
pbTemp=pbValue;
if (isWapShortInteger(&pbTemp,pElement->pbFieldValEnd))
{
*piDeltaSec=(UINT32)WSP_GetShortInt(*pbValue);
*fError=FALSE;
}
else if (isWapLongInteger(&pbTemp,pElement->pbFieldValEnd))
{
*fError=FALSE;
*piDeltaSec=WSP_GetLongInteger(&pbValue,pElement->pbFieldValEnd,fError);
}
}
}
/* Check if Private */
else if ((bValue==135))
{
*fError=FALSE;
}
else if (isWapTokenText(&pbValue,pElement->pbFieldValEnd))
{
/* Cache extension */
}
}
}
}
}
}
return bValue;
}
/* Value-length Challenge */
BYTE *WSP_GetProxyAuthenticateRealm (pHEADERELEMENT pElement)
{
BYTE *pbValue=NULL;
BYTE *pbResult=NULL;
if (pElement!=NULL)
{
/* Check code page. */
/* Just code page 1 */
if (pElement->bCodePage==1)
{
pbValue=pElement->pbFieldValStart;
/* Check length */
if (!isWapValueLength(&pbValue,pElement->pbFieldValEnd))
{
/* Error in length - return NULL */
}
/* Get Challenge */
if (isWapBasic(&pbValue,pElement->pbFieldValEnd))
{
/* Basic. Get Realm-value */
pbResult=pbValue;
/* Check if text-string */
if (!isWapTextString(&pbValue,pElement->pbFieldValEnd))
{
return NULL;
}
}
else if (isWapAuthenticationScheme(&pbValue,pElement->pbFieldValEnd))
{
/* Authentication-scheme. Get Realm-value */
pbResult=pbValue;
/* Check if text-string */
if (!isWapTextString(&pbValue,pElement->pbFieldValEnd))
{
return NULL;
}
}
}
}
return pbResult;
}
BYTE *WSP_GetWWWAuthenticateRealm (pHEADERELEMENT pElement)
{
return (WSP_GetProxyAuthenticateRealm(pElement));
}
/* Delta-seconds-value */
UINT32 WSP_GetAge (pHEADERELEMENT pElement, BOOL *pfError)
{
BYTE *pbTemp=NULL;
BYTE *pbValue=NULL;
if (pElement!=NULL)
{
/* Check code page. */
/* Just code page 1 */
if (pElement->bCodePage==1)
{
pbValue=pElement->pbFieldValStart;
pbTemp=pbValue;
if (isWapShortInteger(&pbTemp,pElement->pbFieldValEnd))
{
/* Short integer - return BYTE */
return (UINT32) (WSP_GetShortInt(*pbValue));
}
else if (isWapLongInteger(&pbTemp,pElement->pbFieldValEnd))
{
/* Get long integer */
return WSP_GetLongInteger(&pbValue,pElement->pbFieldValEnd,pfError);
}
}
}
return 0;
}
/* Date-value */
UINT32 WSP_GetDate (pHEADERELEMENT pElement, BOOL *pfError)
{
BYTE *pbValue=NULL;
if (pElement!=NULL)
{
/* Check code page. */
/* Just code page 1 */
if (pElement->bCodePage==1)
{
pbValue=pElement->pbFieldValStart;
/* Read date */
return WSP_GetLongInteger(&pbValue,pElement->pbFieldValEnd,pfError);
}
}
*pfError=TRUE;
return 0;
}
/* Text-string */
BYTE *WSP_GetEtag (pHEADERELEMENT pElement)
{
return WSP_GetLocation(pElement);
}
/* Date-value */
UINT32 WSP_GetExpires (pHEADERELEMENT pElement, BOOL *pfError)
{
return WSP_GetDate(pElement,pfError);
}
/* Date-value */
UINT32 WSP_GetLastModified (pHEADERELEMENT pElement, BOOL *pfError)
{
return WSP_GetDate(pElement,pfError);
}
/* Uri-value */
BYTE *WSP_GetLocation (pHEADERELEMENT pElement)
{
BYTE *pbTemp=NULL;
BOOL fError=FALSE;
if (pElement!=NULL)
{
/* Check code page. */
/* Just code page 1 */
if (pElement->bCodePage==1)
{
pbTemp=pElement->pbFieldValStart;
return WSP_GetTextString(&pbTemp,pElement->pbFieldValEnd,&fError);
}
}
/* Error */
return NULL;
}
/* Uri-value */
BYTE *WSP_GetContentLocation (pHEADERELEMENT pElement)
{
return WSP_GetLocation(pElement);
}
/* Uri-value */
BYTE *WSP_GetContentBase (pHEADERELEMENT pElement)
{
return WSP_GetLocation(pElement);
}
UINT8 WSP_GetPushFlag (pHEADERELEMENT pElement)
{
BYTE *pbTemp=NULL;
BYTE *pbValue=NULL;
if (pElement!=NULL)
{
/* Check code page. */
/* Just code page 1 */
if (pElement->bCodePage==1)
{
pbValue=pElement->pbFieldValStart;
pbTemp=pbValue;
if (isWapShortInteger(&pbTemp,pElement->pbFieldValEnd))
{
/* Short integer - return BYTE */
return (UINT8) (WSP_GetShortInt(*pbValue));
}
}
}
return 0;
}
/* Uri-value */
BYTE *WSP_GetXInitiatorURI(pHEADERELEMENT pElement)
{
return WSP_GetLocation(pElement);
}
/* Uri-value */
BYTE *WSP_GetXContentURI (pHEADERELEMENT pElement)
{
return WSP_GetLocation(pElement);
}
/* Profile-warning-value = Warn-code | (Value-length Warn-code Warn-target *Warn-date)
Warn-code = Short-integer
Warn-target = Uri-value
Warn-date = Date-value
*/
BYTE WSP_GetProfileWarning (pHEADERELEMENT pElement)
{
BYTE* pbTemp=NULL;
BYTE* pbValue=NULL;
if (pElement!=NULL)
{
/* Check code page. */
/* Just code page 1 */
if (pElement->bCodePage==1)
{
pbValue=pElement->pbFieldValStart;
pbTemp=pbValue;
/* Check if Short-integer */
if (isWapShortInteger(&pbValue,pElement->pbFieldValEnd))
{
return WSP_GetShortInt(*pbTemp);
}
/* Value-length */
else if (isWapValueLength(&pbValue,pElement->pbFieldValEnd))
{
pbTemp=pbValue;
/* Check if Short-integer */
if (isWapShortInteger(&pbValue,pElement->pbFieldValEnd))
{
return WSP_GetShortInt(*pbTemp);
}
}
}
}
return 0;
}
/* Encoding-version-value = Version-value | Value-length Code-page [Version-value]
;encoded using values from tables in the Assigned Numbers Appendix or from an
;extended header code page.
Code-page = Short-integer
;Identity of the extended header code page which the encoding applies for. If the
;Code-page is omitted, the version value refers to the header code pages reserved for
;headers specified by WAP Forum
*/
BYTE WSP_GetEncodingVersion (pHEADERELEMENT pElement)
{
return WSP_GetProfileWarning(pElement);
}
/* Set-Cookie-value = Value-length Cookie-version Cookie-name Cookie-val
*Parameter
Cookie-version = Version-value
Version-value = Short-integer | Text-string
; in the cooie case only version 0-1 are defined (yet)
; so the Short-integer form must be used and in the short
; integer byte the 3 most significant bits of the 7 bits range,
; is the major version number
Cookie-name = Text-string
Cookie-val = Text-string
Parameter = Typed-parameter | Untyped-parameter
Typed-parameter = Well-known-parameter-token Typed-value
Well-known-parameter-token = Integer-value
; Well known parameters and their expected value type in the cookie case
; are:
; Comment: 0x0C, Text-string
; Domain: 0x0D, Text-string
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -