LOCAL ICACHE_FLASH_ATTR void webserver_recv(void *arg, char *pusrdata, unsigned short length) { LOCAL uint8 upgrade_lock = 0; if (upgrade_lock) { return; } struct espconn *ptrespconn = arg; char *precvbuffer = NULL, *p = "command"; os_printf("webserver recv \n"); URL_Frame *pURL_Frame = (URL_Frame *)os_zalloc(sizeof(URL_Frame)); do { void (*handler)(struct espconn * ctx, const char *const parm) = NULL; precvbuffer = save_data(pusrdata, length); //数据保存到precvbuffer if (precvbuffer == NULL) { break; } os_printf("%s\n", precvbuffer); parse_url(precvbuffer, pURL_Frame); // os_printf("select is %s\nfilename is %s\n",pURL_Frame->pSelect,pURL_Frame->pFilename); if (pURL_Frame->Type == GET) { handler = getCommandHandler(pURL_Frame->pSelect, pURL_Frame->pFilename);//指定处理函数 if (handler != NULL) { char *s = (char *)os_strstr(pusrdata, "&"); handler(ptrespconn, s);//处理函数 } } else if (pURL_Frame->Type == POST) { if (os_strstr(precvbuffer, p)) { os_printf("has command\n"); } } } while (0); os_free(pURL_Frame); }
int main(int ac,char **av) { /*****************************************/ /* COMMANDHANDLER is the function type */ /* of the engine's panel command handler */ /* this MUST be resolved at run time */ /* since some HDL module might have */ /* redirected the initial engine function*/ /*****************************************/ COMMANDHANDLER ch; char *str,*bfr; #if defined( OPTION_DYNAMIC_LOAD ) && defined( HDL_USE_LIBTOOL ) /* LTDL Preloaded symbols for HDL using libtool */ LTDL_SET_PRELOADED_SYMBOLS(); #endif /******************************************/ /* Register the 'mywrite' function as the */ /* log callback routine */ /******************************************/ registerLogCallback(mywrite); /******************************************/ /* Initialize the HERCULE Engine */ /******************************************/ impl(ac,av); /******************************************/ /* Get the command handler function */ /* This MUST be done after IML */ /******************************************/ ch=getCommandHandler(); /******************************************/ /* Read STDIN and pass to Command Handler */ /******************************************/ bfr=(char *)malloc(1024); while ( #ifdef _MSVC_ !hLogCallbackThread || WaitForSingleObject(hLogCallbackThread,0) != WAIT_OBJECT_0 #else 1 #endif ) { #ifdef _MSVC_ if (!kbhit()) Sleep(50); else #endif if ((str=fgets(bfr,1024,stdin))) { str[strlen(str)-1]=0; ch(str); } } #ifdef _MSVC_ CloseHandle(hLogCallbackThread); #endif return 0; }