uIP实验handle_input()函数如下:
{
char *strx;
u8 dbuf[17];
PSOCK_BEGIN(&s->sin);
PSOCK_READTO(&s->sin, ISO_space);
if(strncmp(s->inputbuf, http_get, 4)!=0)PSOCK_CLOSE_EXIT(&s->sin); //±??????§???????÷????????????·????ê??WEB???? ?°GET ?±
PSOCK_READTO(&s->sin, ISO_space); //" "
if(s->inputbuf[0] != ISO_slash)PSOCK_CLOSE_EXIT(&s->sin); //??????????(????IP???·?®?ó)????,??·???"/"
if(s->inputbuf[1] == ISO_space||s->inputbuf[1] == '?') //????????????????/????
{
if(s->inputbuf[1]=='?'&&s->inputbuf[6]==0x31)//LED1
{
LED0=!LED0;
strx=strstr((const char*)(data_index_html+13),"LED0×???");
if(strx)//????"LED0×???"????×?·??®
{
strx=strstr((const char*)strx,"color:#");//????"color:#"×?·??®
if(LED0)//LED0??
{
strncpy(strx+7,"5B5B5B",6); //????
strncpy(strx+24,"??",2); //??
strx=strstr((const char*)strx,"http:");//????"http:"×?·??®
strncpy(strx,(const char*)LED_OFF_PIC_ADDR,strlen((const char*)LED_OFF_PIC_ADDR));//LED0??????
}else
{
strncpy(strx+7,"FF0000",6); //?ì??
strncpy(strx+24,"??",2); //"??"
strx=strstr((const char*)strx,"http:");//????"http:"×?·??®
strncpy(strx,(const char*)LED0_ON_PIC_ADDR,strlen((const char*)LED0_ON_PIC_ADDR));//LED0??????
}
}
}else if(s->inputbuf[1]=='?'&&s->inputbuf[6]==0x32)//LED2
{
LED1=!LED1;
strx=strstr((const char*)(data_index_html+13),"LED1×???");
if(strx)//????"LED1×???"????×?·??®
{
strx=strstr((const char*)strx,"color:#");//????"color:#"×?·??®
if(LED1)//LED1??
{
strncpy(strx+7,"5B5B5B",6); //????
strncpy(strx+24,"??",2); //??
strx=strstr((const char*)strx,"http:");//????"http:"×?·??®
strncpy(strx,(const char*)LED_OFF_PIC_ADDR,strlen((const char*)LED_OFF_PIC_ADDR));//LED1??????
}else
{
strncpy(strx+7,"00FF00",6); //????
strncpy(strx+24,"??",2); //"??"
strx=strstr((const char*)strx,"http:");//????"http:"×?·??®
strncpy(strx,(const char*)LED1_ON_PIC_ADDR,strlen((const char*)LED1_ON_PIC_ADDR));//LED1??????
}
}
}
strx=strstr((const char*)(data_index_html+13),"??");//????"??"×?·?
if(strx)
{
get_temperature(dbuf); //????????
strncpy(strx-4,(const char*)dbuf,4); //?ü??????
}
strx=strstr((const char*)strx,"RTC?±??:");//????"RTC?±??:"×?·?
if(strx)
{
get_time(dbuf); //?????±??
strncpy(strx+33,(const char*)dbuf,16); //?ü???±??
}
strncpy(s->filename, http_index_html, sizeof(s->filename));
}else //????????' '/'?'
{
s->inputbuf[PSOCK_DATALEN(&s->sin)-1] = 0;
strncpy(s->filename,&s->inputbuf[0],sizeof(s->filename));
}
s->state = STATE_OUTPUT;
while(1)
{
PSOCK_READTO(&s->sin, ISO_nl);
if(strncmp(s->inputbuf, http_referer, 8) == 0)
{
s->inputbuf[PSOCK_DATALEN(&s->sin) - 2] = 0;
}
}
PSOCK_END(&s->sin);
}
最后这个while(1) 死循环是怎么退出的?请高人指点啊!
|