The content for uIP web server demo is no longer canned, but is not built dynameically (Thanks to Max Holtzberg)

git-svn-id: https://nuttx.svn.sourceforge.net/svnroot/nuttx/trunk@5073 7fd9a85b-ad96-42d3-883c-3090e2eb8679
This commit is contained in:
patacongo
2012-08-31 23:05:51 +00:00
parent ee6cba7a01
commit 0eb58dfb72
49 changed files with 1896 additions and 1884 deletions
+120 -8
View File
@@ -1,7 +1,7 @@
/****************************************************************************
* apps/include/netutils/httpd.h
*
* Copyright (C) 2007, 2009, 2011 Gregory Nutt. All rights reserved.
* Copyright (C) 2007, 2009, 2011-2012 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Based on uIP which also has a BSD style license:
@@ -44,19 +44,131 @@
* Included Files
****************************************************************************/
#include <nuttx/net/uip/uip.h>
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
#ifdef __cplusplus
# define EXTERN extern "C"
extern "C" {
#else
# define EXTERN extern
#endif
/* As threads are created to handle each request, a stack must be allocated
* for the thread. Use a default if the user provided no stacksize.
*/
#ifndef CONFIG_NETUTILS_HTTPDSTACKSIZE
# define CONFIG_NETUTILS_HTTPDSTACKSIZE 4096
#endif
#ifndef CONFIG_NETUTILS_HTTPDFSSTATS
# define CONFIG_NETUTILS_HTTPDFSSTATS
#endif
#ifndef CONFIG_NETUTILS_HTTPDFILESTATS
# define CONFIG_NETUTILS_HTTPDFILESTATS
#endif
#ifndef CONFIG_NET_STATISTICS
# undef CONFIG_NETUTILS_HTTPDNETSTATS
#endif
/* For efficiency reasons, the size of the IO buffer should be a multiple
* of the TCP MSS value. Also, the current design requires that the IO
* buffer be sufficiently large to contain the entire GET request.
*/
#define HTTPD_IOBUFFER_SIZE (3*UIP_TCP_MSS)
/* this is the maximum size of a file path */
#define HTTPD_MAX_FILENAME 20
/****************************************************************************
* Public types
****************************************************************************/
struct httpd_fs_file
{
char *data;
int len;
};
struct httpd_state
{
char ht_buffer[HTTPD_IOBUFFER_SIZE]; /* recv()/send() buffer */
char ht_filename[HTTPD_MAX_FILENAME]; /* filename from GET command */
struct httpd_fs_file ht_file; /* Fake file data to send */
int ht_sockfd; /* The socket descriptor from accept() */
char *ht_scriptptr;
uint16_t ht_scriptlen;
uint16_t ht_sndlen;
};
struct httpd_fsdata_file
{
const struct httpd_fsdata_file *next;
FAR const uint8_t *name;
FAR const uint8_t *data;
int len;
#ifdef CONFIG_NETUTILS_HTTPDFSSTATS
uint16_t count;
#endif
};
struct httpd_fsdata_file_noconst
{
FAR struct httpd_fsdata_file *next;
FAR char *name;
FAR char *data;
int len;
#ifdef CONFIG_NETUTILS_HTTPDFSSTATS
uint16_t count;
#endif
};
typedef void (*httpd_cgifunction)(struct httpd_state *, char *);
struct httpd_cgi_call
{
struct httpd_cgi_call *next;
const char *name;
httpd_cgifunction function;
};
/* HTTPD CGI function declaration
*
* Description:
* This macro is used for declaring a HTTPD CGI function. This function is
* then added to the list of HTTPD CGI functions with the httpd_cgi_register()
* function.
* Input Paramters:
*
* name The C variable name of the function
* str The string name of the function, used in the script file
* function A pointer to the function that implements it
*/
#define HTTPD_CGI_CALL(name, str, function) \
static void function(struct httpd_state *, char *); \
static struct httpd_cgi_call name = {NULL, str, function}
/****************************************************************************
* Public Function Prototypes
****************************************************************************/
#ifdef __cplusplus
#define EXTERN extern "C"
extern "C" {
#else
#define EXTERN extern
#endif
EXTERN void httpd_init(void);
EXTERN int httpd_listen(void);
EXTERN void httpd_cgi_register(struct httpd_cgi_call *cgi_call);
EXTERN uint16_t httpd_fs_count(char *name);
EXTERN const struct httpd_fsdata_file g_httpdfs_root[];
EXTERN const int g_httpd_numfiles;
#undef EXTERN
#ifdef __cplusplus