コード例 #1
0
ファイル: httpd_form.c プロジェクト: Astralix/ethernut32
int main(void)
{
#ifdef NUT_OS
    NutRegisterDevice(&DEV_CONSOLE, 0, 0);
    freopen(DEV_CONSOLE.dev_name, "w", stdout);
#endif

    puts("uHTTP form sample\nBuild " __DATE__ " " __TIME__);

#ifdef NUT_OS
    NutRegisterDevice(&DEV_ETHER, 0, 0);
    NutDhcpIfConfig(DEV_ETHER_NAME, NULL, 60000);
    NutRegisterDevice(&devUrom, 0, 0);
#endif

    StreamInit();
    MediaTypeInitDefaults();
    HttpRegisterRedir("", "/index.html", 301);
    HttpRegisterCgiFunction("getform.cgi", CgiGetForm);
    HttpRegisterCgiFunction("postform.cgi", CgiPostForm);
    HttpRegisterMediaType("cgi", NULL, NULL, HttpCgiFunctionHandler);
    StreamClientAccept(HttpdClientHandler, NULL);

    puts("Exit");
#ifdef NUT_OS
    for (;;) ;
#endif

    return 0;
}
コード例 #2
0
ファイル: uhttpd.c プロジェクト: MultiCalorNV/ChibiOS
msg_t HttpTask (void *p)
{
   (void)p;

   chRegSetThreadName("HttpTask");

   /*
    * Initialize the TCP socket interface.
    */
   StreamInit();

   /*
    * Register media type defaults. These are configurable
    * in include/cfg/http.h or the Nut/OS Configurator.
    */
   MediaTypeInitDefaults();
   HttpRegisterRedir("", "/index.html", 301);

   HttpRegisterCgiFunction("clock.cgi", CgiClock);
   HttpRegisterCgiFunction("getform.cgi", CgiGetForm);
   HttpRegisterCgiFunction("postform.cgi", CgiPostForm);
   HttpRegisterMediaType("cgi", NULL, NULL, HttpCgiFunctionHandler);

   /*
    * Wait for a client (browser) and handle its request.
    * This function will only return on unrecoverable errors.
    */
   StreamClientAccept(HttpdClientHandler, NULL);

   /* Typically this point will be never reached. */
   while(1)
   {
	   chThdSleepMilliseconds(500);
   }

   return(0);
} /* HttpTask */