Add a THTTPD configuratin for zkit-arm-1769

git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@5675 42af7a65-404d-4744-a932-0658087f49c3
This commit is contained in:
patacongo 2013-02-26 16:28:30 +00:00
parent 11b87dd5d9
commit 888c3d1618
6 changed files with 170 additions and 59 deletions

View File

@ -10,4 +10,20 @@ config EXAMPLES_THTTPD
Enable the THTTPD web server example Enable the THTTPD web server example
if EXAMPLES_THTTPD if EXAMPLES_THTTPD
config EXAMPLES_THTTPD_NOMAC
bool "Use Canned MAC Address"
default n
---help---
May be defined to use a hard-coded, software assigned MAC of
00:0e:de:ad:be:ef
config EXAMPLES_THTTPD_DRIPADDR
hex "Default Router IP address (Gateway)"
default 0x0a000001
config EXAMPLES_THTTPD_NETMASK
hex "Network Mask"
default 0xffffff00
endif endif

View File

@ -107,7 +107,7 @@ static const char *g_ttypenames[4] =
{ {
int i; int i;
/* Show task status */ /* Show task/thread status */
printf("%5d %3d %4s %7s%c%c %8s ", printf("%5d %3d %4s %7s%c%c %8s ",
tcb->pid, tcb->sched_priority, tcb->pid, tcb->sched_priority,
@ -117,26 +117,49 @@ static const char *g_ttypenames[4] =
tcb->flags & TCB_FLAG_CANCEL_PENDING ? 'P' : ' ', tcb->flags & TCB_FLAG_CANCEL_PENDING ? 'P' : ' ',
g_statenames[tcb->task_state]); g_statenames[tcb->task_state]);
/* Is this a task or a thread? */
#ifndef CONFIG_DISABLE_PTHREAD
if ((tcb->flags & TCB_FLAG_TTYPE_MASK) == TCB_FLAG_TTYPE_PTHREAD)
{
FAR struct pthread_tcb_s *ptcb = (FAR struct pthread_tcb_s *)tcb;
/* It is a pthread. Show any name assigned to the pthread via prtcl() along
* with the startup value.
*/
#if CONFIG_TASK_NAME_SIZE > 0
printf("%s(%p)\n", tcb->name, ptcb->arg);
#else
printf("pthread(%p)\n", ptcb->arg);
#endif
}
else
#endif
{
FAR struct task_tcb_s *ttcb = (FAR struct task_tcb_s *)tcb;
/* Show task name and arguments */ /* Show task name and arguments */
printf("%s(", tcb->argv[0]); printf("%s(", ttcb->argv[0]);
/* Special case 1st argument (no comma) */ /* Special case 1st argument (no comma) */
if (tcb->argv[1]) if (ttcb->argv[1])
{ {
printf("%p", tcb->argv[1]); printf("%p", ttcb->argv[1]);
} }
/* Then any additional arguments */ /* Then any additional arguments */
#if CONFIG_MAX_TASK_ARGS > 2 #if CONFIG_MAX_TASK_ARGS > 2
for (i = 2; i <= CONFIG_MAX_TASK_ARGS && tcb->argv[i]; i++) for (i = 2; i <= CONFIG_MAX_TASK_ARGS && ttcb->argv[i]; i++)
{ {
printf(", %p", tcb->argv[i]); printf(", %p", ttcb->argv[i]);
} }
#endif #endif
printf(")\n"); printf(")\n");
}
} }
/**************************************************************************** /****************************************************************************

View File

@ -133,16 +133,26 @@ config THTTPD_INDEX_NAMES
A list of index filenames to check. The files are searched for A list of index filenames to check. The files are searched for
in this order. Default: "\"index.html\", \"index.htm\", \"index.cgi\"" in this order. Default: "\"index.html\", \"index.htm\", \"index.cgi\""
config THTTPD_USE_AUTH_FILE
bool "Use authentication file"
default n
---help---
Select to define an authentication file that thttpd will check in
the local directory before every fetch. If the file exists then
authentication is done, otherwise the fetch proceeds as usual. If
you leave this undefined then thttpd will not implement
authentication at all and will not check for auth files, which saves
a bit of CPU time.
config AUTH_FILE config AUTH_FILE
string "Authorization file" string "Authorization file"
# default ".htpasswd" default ".htpasswd"
depends on THTTPD_USE_AUTH_FILE
---help--- ---help---
The file to use for authentication. If this is defined then thttpd The file to use for authentication. thttpd checks for this file in
checks for this file in the local directory before every fetch. If the local directory before every fetch. If the file exists then
the file exists then authentication is done, otherwise the fetch proceeds authentication is done, otherwise the fetch proceeds as usual. A
as usual. If you leave this undefined then thttpd will not implement typical value is ".htpasswd"
authentication at all and will not check for auth files, which saves a
bit of CPU time. A typical value is ".htpasswd"
config THTTPD_LISTEN_BACKLOG config THTTPD_LISTEN_BACKLOG
int "Listen backlog" int "Listen backlog"
@ -185,56 +195,117 @@ config THTTPD_IDLE_SEND_LIMIT_SEC
How many seconds before an idle connection gets closed. How many seconds before an idle connection gets closed.
Default: 300 Default: 300
config THTTPD_TILDE_MAP1 choice
string "Tilde mapping" prompt "Tilde Mapping"
default THTTPD_TILDE_MAP_NONE
---help--- ---help---
Tilde mapping. Tilde mapping. Many URLs use ~username to indicate a user's home
directory. thttpd provides two options for mapping this construct to
an actual filename.
Many URLs use ~username to indicate a user's home directory. thttpd 1) Map ~username to <prefix>/username. This is the recommended
provides two options for mapping this construct to an actual filename. choice. Each user gets a subdirectory in the main web tree, and
the tilde construct points there.
The prefix could be something like "users", or it could be empty.
1) Map ~username to <prefix>/username. This is the recommended choice.
Each user gets a subdirectory in the main web tree, and the tilde
construct points there. The prefix could be something like "users",
or it could be empty.
2) Map ~username to <user's homedir>/<postfix>. The postfix would be 2) Map ~username to <user's homedir>/<postfix>. The postfix would be
the name of a subdirectory off of the user's actual home dir, the name of a subdirectory off of the user's actual home dir,
something like "public_html". something like "public_html".
You can also leave both options undefined, and thttpd will not do 3) Niether. You can also leave both options undefined, and thttpd
anything special about tildes. Enabling both options is an error. will not do anything special about tildes. Enabling both options
Typical values, if they're defined, are "users" for is an error.
config THTTPD_TILDE_MAP1 and "public_html" for THTTPD_TILDE_MAP2.
Typical values, if they're defined, are "users" for THTTPD_TILDE_MAP1
and "public_html" for THTTPD_TILDE_MAP2.
config THTTPD_USE_TILDE_MAP1
bool "Tilde mapping 1"
---help---
Tilde mapping. Many URLs use ~username to indicate a user's home
directory. thttpd provides two options for mapping this construct to
an actual filename. Choose this option for the first mapping:
1) Map ~username to <prefix>/username. This is the recommended
choice. Each user gets a subdirectory in the main web tree, and
the tilde construct points there.
The prefix could be something like "users", or it could be empty.
config THTTPD_USE_TILDE_MAP2
bool "Tilde mapping 2"
---help---
Tilde mapping. Many URLs use ~username to indicate a user's home
directory. thttpd provides two options for mapping this construct to
an actual filename. Choose this option for the second mapping:
2) Map ~username to <user's homedir>/<postfix>. The postfix would be
the name of a subdirectory off of the user's actual home dir,
something like "public_html".
The typical value THTTPD_TILDE_MAP2 is "public_html".
config THTTPD_TILDE_MAP_NONE
bool "No tilde mapping"
---help---
Tilde mapping. Many URLs use ~username to indicate a user's home
directory. thttpd provides two options for mapping this construct to
an actual filename. Choose this option to omit tilde mapping: thttpd
will not do anything special about tildes.
endchoice
config THTTPD_TILDE_MAP1
string "Tilde mapping 1"
default "user"
depends on THTTPD_USE_TILDE_MAP1
---help---
Tilde mapping. Many URLs use ~username to indicate a user's home
directory. thttpd provides two options for mapping this construct to
an actual filename. Choose this option defines the <prefix> string
for the first mapping:
1) Map ~username to <prefix>/username. This is the recommended
choice. Each user gets a subdirectory in the main web tree, and
the tilde construct points there.
The prefix could be something like "users", or it could be empty.
config THTTPD_TILDE_MAP2 config THTTPD_TILDE_MAP2
string "Tilde mapping" string "Tilde mapping 2"
default "public_html"
depends on THTTPD_USE_TILDE_MAP2
---help--- ---help---
Tilde mapping. Tilde mapping. Many URLs use ~username to indicate a user's home
directory. thttpd provides two options for mapping this construct to
an actual filename. Choose this option defines the <postfix> string
for the second mapping:
Many URLs use ~username to indicate a user's home directory. thttpd
provides two options for mapping this construct to an actual filename.
1) Map ~username to <prefix>/username. This is the recommended choice.
Each user gets a subdirectory in the main web tree, and the tilde
construct points there. The prefix could be something like "users",
or it could be empty.
2) Map ~username to <user's homedir>/<postfix>. The postfix would be 2) Map ~username to <user's homedir>/<postfix>. The postfix would be
the name of a subdirectory off of the user's actual home dir, the name of a subdirectory off of the user's actual home dir,
something like "public_html". something like "public_html".
You can also leave both options undefined, and thttpd will not do The typical value THTTPD_TILDE_MAP2 is "public_html".
anything special about tildes. Enabling both options is an error.
Typical values, if they're defined, are "users" for
config THTTPD_TILDE_MAP1 and "public_html" for THTTPD_TILDE_MAP2.
config THTTPD_GENERATE_INDICES config THTTPD_GENERATE_INDICES
bool "Generate name indices" bool "Generate name indices"
default n default n
---help--- ---help---
config THTTPD_USE_URLPATTERN
bool "Use URL pattern"
default n
---help---
Select to define a URL pattern that will be used to match and verify
referrers.
config THTTPD_URLPATTERN config THTTPD_URLPATTERN
string "URL pattern" string "URL pattern"
default ""
depends on THTTPD_USE_URLPATTERN
---help--- ---help---
If defined, then it will be used to match and verify referrers. This string defines the UARL pattern that will be used to match and
verify referrers.
endif endif

View File

@ -236,7 +236,7 @@
*/ */
# if defined(CONFIG_THTTPD_TILDE_MAP1) && defined(CONFIG_THTTPD_TILDE_MAP2) # if defined(CONFIG_THTTPD_TILDE_MAP1) && defined(CONFIG_THTTPD_TILDE_MAP2)
# error "Both CONFIG_THTTPD_TILDE_MAP1 andCONFIG_THTTPD_TILDE_MAP2 are defined" # error "Both CONFIG_THTTPD_TILDE_MAP1 and CONFIG_THTTPD_TILDE_MAP2 are defined"
# endif # endif
/* If CONFIG_THTTPD_URLPATTERN is defined, then it will be used to match and verify /* If CONFIG_THTTPD_URLPATTERN is defined, then it will be used to match and verify

View File

@ -2,7 +2,7 @@
* netutils/thttpd/libhttpd.c * netutils/thttpd/libhttpd.c
* HTTP Protocol Library * HTTP Protocol Library
* *
* Copyright (C) 2009, 2011 Gregory Nutt. All rights reserved. * Copyright (C) 2009, 2011, 2013 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org> * Author: Gregory Nutt <gnutt@nuttx.org>
* *
* Derived from the file of the same name in the original THTTPD package: * Derived from the file of the same name in the original THTTPD package:
@ -1913,8 +1913,9 @@ static int check_referer(httpd_conn *hc)
/* Are we doing referer checking at all? */ /* Are we doing referer checking at all? */
#ifdef CONFIG_THTTPD_URLPATTERN #ifdef CONFIG_THTTPD_URLPATTERN
int r;
char *cp; char *cp;
int r;
int child;
child = really_check_referer(hc); child = really_check_referer(hc);

View File

@ -856,7 +856,7 @@ static int cgi_child(int argc, char **argv)
/* Run the CGI program. */ /* Run the CGI program. */
nllvdbg("Starting CGI: %s\n", hc->expnfilename); nllvdbg("Starting CGI: %s\n", hc->expnfilename);
child = exec(hc->expnfilename, (FAR const char **)argp, g_thttpdsymtab, g_thttpdnsymbols); child = exec(hc->expnfilename, (FAR char * const *)argp, g_thttpdsymtab, g_thttpdnsymbols);
if (child < 0) if (child < 0)
{ {
/* Something went wrong. */ /* Something went wrong. */