📄 cms_wap12.c
字号:
case WAP_MULTIPLE_CHOICES:
case WAP_MOVED_PERMANENTLY:
case WAP_MOVED_TEMPORARILY:
case WAP_SEE_OTHER:
case WAP_NOT_MODIFIED:
case WAP_USE_PROXY:
case WAP_TEMPORARY_REDIRECT:
{
CMS_S64 datalen = 0;
datalen=octstr_len(event->SMethodResultIndication.content_data);
if(statproc)
{
(*statproc)((CMS_S32)WAP_OBJ_MOVED,(char*)event->SMethodResultIndication.content_data->data,(CMS_S32)datalen);
event->SMethodResultIndication.content_data->data = NULL;
event->SMethodResultIndication.content_data->len = 0;
}
}
break;
case WAP_BAD_REQUEST:
{
if(statproc)
{
(*statproc)((CMS_S32)WAP_BAD_REQUEST,(char*)NULL,(CMS_S32)0);
}
}
break;
case WAP_UNAUTHORIZED:
{
if(statproc)
{
(*statproc)((CMS_S32)WAP_UNAUTHORIZED,(char*)NULL,(CMS_S32)0);
}
}
break;
case WAP_PAYMENT_REQUIRED:
{
if(statproc)
{
(*statproc)((CMS_S32)WAP_PAYMENT_REQUIRED,(char*)NULL,(CMS_S32)0);
}
}
break;
case WAP_FORBIDDEN:
{
if(statproc)
{
(*statproc)((CMS_S32)WAP_FORBIDDEN,(char*)NULL,(CMS_S32)0);
}
}
break;
case WAP_NOT_FOUND:
{
if(statproc)
{
(*statproc)((CMS_S32)WAP_NOT_FOUND,(char*)NULL,(CMS_S32)0);
}
}
break;
case WAP_METHOD_NOT_ALLOWED:
{
if(statproc)
{
(*statproc)((CMS_S32)WAP_METHOD_NOT_ALLOWED,(char*)NULL,(CMS_S32)0);
}
}
break;
case WAP_NOT_ACCEPTABLE:
{
if(statproc)
{
(*statproc)((CMS_S32)WAP_NOT_ACCEPTABLE,(char*)NULL,(CMS_S32)0);
}
}
break;
case WAP_PROXY_AUTHENTICATION_REQUIRED:
{
if(statproc)
{
(*statproc)((CMS_S32)WAP_PROXY_AUTHENTICATION_REQUIRED,(char*)NULL,(CMS_S32)0);
}
}
break;
case WAP_REQUEST_TIMEOUT:
{
if(statproc)
{
(*statproc)((CMS_S32)WAP_REQUEST_TIMEOUT,(char*)NULL,(CMS_S32)0);
}
}
break;
case WAP_CONFLICT:
{
if(statproc)
{
(*statproc)((CMS_S32)WAP_CONFLICT,(char*)NULL,(CMS_S32)0);
}
}
break;
case WAP_GONE:
{
if(statproc)
{
(*statproc)((CMS_S32)WAP_GONE,(char*)NULL,(CMS_S32)0);
}
}
break;
case WAP_LENGTH_REQUIRED:
{
if(statproc)
{
(*statproc)((CMS_S32)WAP_LENGTH_REQUIRED,(char*)NULL,(CMS_S32)0);
}
}
break;
case WAP_PRECONDITION_FAILED:
{
if(statproc)
{
(*statproc)((CMS_S32)WAP_PRECONDITION_FAILED,(char*)NULL,(CMS_S32)0);
}
}
break;
case WAP_REQUEST_ENTITY_TOO_LARGE:
{
if(statproc)
{
(*statproc)((CMS_S32)WAP_REQUEST_ENTITY_TOO_LARGE,(char*)NULL,(CMS_S32)0);
}
}
break;
case WAP_UNSUPPORTED_MEDIA_TYPE:
{
if(statproc)
{
(*statproc)((CMS_S32)WAP_UNSUPPORTED_MEDIA_TYPE,(char*)NULL,(CMS_S32)0);
}
}
break;
case WAP_REQUESTED_RANGE_NOT_SATISFIABLE:
{
if(statproc)
{
(*statproc)((CMS_S32)WAP_REQUESTED_RANGE_NOT_SATISFIABLE,(char*)NULL,(CMS_S32)0);
}
}
break;
case WAP_EXPECTATION_FAILED:
{
if(statproc)
{
(*statproc)((CMS_S32)WAP_EXPECTATION_FAILED,(char*)NULL,(CMS_S32)0);
}
}
break;
case WAP_INTERNAL_SERVER_ERROR:
{
if(statproc)
{
(*statproc)((CMS_S32)WAP_INTERNAL_SERVER_ERROR,(char*)NULL,(CMS_S32)0);
}
}
break;
case WAP_NOT_IMPLEMENTED:
{
if(statproc)
{
(*statproc)((CMS_S32)WAP_NOT_IMPLEMENTED,(char*)NULL,(CMS_S32)0);
}
}
break;
case WAP_BAD_GATEWAY:
{
if(statproc)
{
(*statproc)((CMS_S32)WAP_BAD_GATEWAY,(char*)NULL,(CMS_S32)0);
}
}
break;
case WAP_SERVICE_UNAVAILABLE:
{
if(statproc)
{
(*statproc)((CMS_S32)WAP_SERVICE_UNAVAILABLE,(char*)NULL,(CMS_S32)0);
}
}
break;
case WAP_GATEWAY_TIMEOUT:
{
if(statproc)
{
(*statproc)((CMS_S32)WAP_GATEWAY_TIMEOUT,(char*)NULL,(CMS_S32)0);
}
}
break;
case WAP_HTTP_VERSION_NOT_SUPPORTED:
{
if(statproc)
{
(*statproc)((CMS_S32)WAP_HTTP_VERSION_NOT_SUPPORTED,(char*)NULL,(CMS_S32)0);
}
}
break;
default:
{
//CmsDebugFunc((unsigned char*)"aaaaattt fail defalt case",(short)4,(void*)&event->SMethodResultIndication.status);
//cms_trace("error pdu in default case");
if(statproc)
{
(*statproc)((CMS_S32)WAP_INTERNAL_SERVER_ERROR,(char*)NULL,(CMS_S32)0);
}
}
break;
}
//CmsDebugFunc((unsigned char*)"aaaaaab",(short)4,(void*)&event->SMethodResultIndication.status);
}
break;
//case SMethodResultResponse: /*WSP/WTP协议栈已结束当前请求会话*/
// {
// if(statproc)
// {
// //(*statproc)(WAP_DATA);
// //cms_debug("error!%s","impossible to handle event SMethodResultResponse!");
// }
// }
// return;
}
wsp_event_destroy(event);
event = NULL;
return;
}
/*************************************************************************
* 函数名: setWAP12JustDownloadContentType
getWAP12JustDownloadContentType
* 描 述: 当1.2协议栈接收到UDP数据包后,如果是reply WTP 且是reply WSP, 记录下载的文件类型
* 返回值: void
* 输 入: MessageID 事件类型
* 全局量:
* 日 期: 7/30/2004
* 作 者: 李守明; shoumingl@mobilesoft.com.cn
* 修改者:
* 时 间:
************************************************************************/
//Cms_ContentType_e wap12JustDownloadContentType = CMS_HTTP_CONTENT_DLING_FILE;//默认为网页
//void setWAP12JustDownloadContentType(Cms_ContentType_e contentTyep)
//{
// wap12JustDownloadContentType = contentTyep;
//}
////0,表示不是网页;1,是网页
//Cms_ContentType_e getIfPageInJustDownloadContentType(void)
//{
// return wap12JustDownloadContentType;
//}
/*************************************************************************
* 描 述: 检查刚刚接收的udp包中文件类型是否是页面
* 返回值:
* 全局量:
* 日 期: 2005-4-5
* 作 者: lee; yongt@mobilesoft.com.cn
************************************************************************/
static CMS_S32 lee_unpack_uint8(P_CMS_U64 u, const char *os, P_CMS_S32 off)
{
*u = (CMS_U64)os[(CMS_S64)*off];
++(*off);
return 0;
}
static CMS_S32 lee_unpack_uintvar(P_CMS_U64 u, const char *os,P_CMS_S32 off)
{
CMS_U64 o;
*u = 0;
do
{
if (lee_unpack_uint8(&o, os, off) == -1)
{
return -1;
}
*u = ((*u) << 7) | (o & 0x7F);
} while ((o & 0x80) != 0);
return 0;
}
//void checkIfPageInWTPpacket(const char *buf)
//{
// if (NULL == buf)
// {
// setWAP12JustDownloadContentType(CMS_HTTP_CONTENT_DLING_FILE);
// return ;
// }
// else
// {
// if (getIfPageInJustDownloadContentType() != CMS_HTTP_CONTENT_DLING_FILE)
// {
// return;//检查过就无需检查
// }
// if (buf[3] != 0x04)//如果不是应答wsp就设置为未知类型
// {
// setWAP12JustDownloadContentType(CMS_HTTP_CONTENT_DLING_FILE);
// return ;
// }
// else
// {
// CMS_U64 headerLen = 0;
// int u = 0;
// int off = 0;
// lee_unpack_uintvar(&headerLen,buf+5,&off);
// u = (int)buf[off + 5];
//
// if(u < (int)0x80)
// {
// u = buf[off + 5];
// if(u >= (int)0x80)
// {
// u -= (int)0x80;
// }
// else
// {
// CMS_U8 text_content_type[50];
// CMS_S32 contentlen = 0;
// CMS_S32 contentoff = 0;
// contentoff = 6;
// cms_memset(text_content_type,0,50);
// /*=== 获取content-type ===*/
// while(buf[contentoff+contentlen] !=0 && contentlen<49)
// {
// text_content_type[contentlen] = buf[contentoff+contentlen];
// contentlen++;
// }
// text_content_type[contentlen] = 0;
//
// /*=== 根据content-type的值决定处理方式 ===*/
// if(strstr((char *)text_content_type,"application/vnd.wap.wmlc")!=NULL ||\
// strstr((char *)text_content_type,"text/plain")!=NULL ||\
// strstr((char *)text_content_type,"text/css") !=NULL ||\
// strstr((char *)text_content_type,"text/vnd.wap.wml") !=NULL ||\
// strstr((char *)text_content_type,"application/xhtml+xml") !=NULL)
// {
// u=0x02;
// }
// /* else
// {
// u=0x07;
// }
// */
// }
// }
// else
// {
// u=u-0x80;
// }
//
// if (u == 0x02 || u == 0x08 || u == 0x03 || 0x14 == u)
// {
// setWAP12JustDownloadContentType(CMS_HTTP_CONTENT_ML);
// }
// else
// {
// setWAP12JustDownloadContentType(CMS_HTTP_CONTENT_MIDI);//表示不是网页
// }
// }
// }
//}
int get_up_target( void )
{
if( NULL != WTPGlobalMachine )
{
return WTPGlobalMachine->up_target;
}
return 0;
}
#if 0
/*************************************************************************
* 描 述: 将取得的安全模式设置到全局变量中
* 返回值: void
* 全局量: last_security_mode
* 日 期: 2005-5-31
* 作 者: changweil@mobilesoft.com.cn
************************************************************************/
void SetSecurityMode(int iSecurityMode)
{
last_security_mode = iSecurityMode;
}
/*************************************************************************
* 描 述: 判断在浏览器运行过程中安全模式是否改变
* 返回值: 1、已改变 0、未改变
* 全局量: last_security_mode
* 日 期: 2005-5-31
* 作 者: changweil@mobilesoft.com.cn
************************************************************************/
int SecurityModeChanged()
{
int iRtn = 0;
// 如果浏览器正在运行
if(Cms_IsBrowserRunning())
{
// 安全模式在浏览器运行过程中是否改变
iRtn = (Cms_Brower_GetSecuritySetting() == last_security_mode) ? 0 : 1;
if(iRtn)
{
cms_trace("Security Mode Has Changed!\n");
last_security_mode = Cms_Brower_GetSecuritySetting();
}
else
{
cms_trace("Security Mode Has not Changed!\n");
}
}
return iRtn;
}
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -