OpenCores
URL https://opencores.org/ocsvn/mlite/mlite/trunk

Subversion Repositories mlite

[/] [mlite/] [trunk/] [kernel/] [http.c] - Diff between revs 161 and 162

Go to most recent revision | Show entire file | Details | Blame | View Log

Rev 161 Rev 162
Line 18... Line 18...
#endif
#endif
#include "rtos.h"
#include "rtos.h"
#include "tcpip.h"
#include "tcpip.h"
#ifdef WIN32
#ifdef WIN32
#define UartPrintf printf
#define UartPrintf printf
 
#else
 
#undef printf
 
#define printf UartPrintfPoll
 
//#define printf UartPrintfNull
#endif
#endif
 
 
const char pageGif[]=
const char pageGif[]=
{
{
   "HTTP/1.0 200 OK\r\n"
   "HTTP/1.0 200 OK\r\n"
Line 46... Line 50...
   "Content-Type: text/html\r\n\r\n"
   "Content-Type: text/html\r\n\r\n"
};
};
 
 
static const PageEntry_t *HtmlPages;
static const PageEntry_t *HtmlPages;
static int HtmlFiles;
static int HtmlFiles;
 
static OS_MQueue_t *HttpMQueue;
 
 
 
 
void HttpServer(IPSocket *socket)
void HttpServerAction(IPSocket *socket)
{
{
   uint8 buf[600];
   uint8 buf[600];
   int bytes, i, length, len, needFooter;
   int bytes, i, length, len, needFooter;
   char *name=NULL, *page=NULL;
   char *name=NULL, *page=NULL;
 
 
Line 132... Line 137...
      }
      }
   }
   }
}
}
 
 
 
 
 
void HttpThread(void *Arg)
 
{
 
   IPSocket *socket;
 
   (void)Arg;
 
   for(;;)
 
   {
 
      OS_MQueueGet(HttpMQueue, &socket, OS_WAIT_FOREVER);
 
      HttpServerAction(socket);
 
   }
 
}
 
 
 
 
 
void HttpServer(IPSocket *socket)
 
{
 
#ifdef WIN32
 
   HttpServerAction(socket);
 
#else
 
   OS_MQueueSend(HttpMQueue, &socket);
 
#endif
 
}
 
 
 
 
void HttpInit(const PageEntry_t *Pages, int UseFiles)
void HttpInit(const PageEntry_t *Pages, int UseFiles)
{
{
   HtmlPages = Pages;
   HtmlPages = Pages;
   HtmlFiles = UseFiles;
   HtmlFiles = UseFiles;
 
   HttpMQueue = OS_MQueueCreate("http", 100, 4);
 
   OS_ThreadCreate("http", HttpThread, NULL, 50, 0);
   IPOpen(IP_MODE_TCP, 0, 80, HttpServer);
   IPOpen(IP_MODE_TCP, 0, 80, HttpServer);
   IPOpen(IP_MODE_TCP, 0, 8080, HttpServer);
   IPOpen(IP_MODE_TCP, 0, 8080, HttpServer);
}
}
 
 
 
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.