diff options
author | patacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3> | 2012-09-05 18:03:37 +0000 |
---|---|---|
committer | patacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3> | 2012-09-05 18:03:37 +0000 |
commit | 2323c98f7bfe6367f48ba025d586a9d1ff22c6bc (patch) | |
tree | ce1a329f597da59fb575f6d476befe38affd2780 /apps/netutils/webserver/httpd.c | |
parent | 05c66e9f991c28717a1955f4aba1e7691a74d418 (diff) | |
download | nuttx-2323c98f7bfe6367f48ba025d586a9d1ff22c6bc.tar.gz nuttx-2323c98f7bfe6367f48ba025d586a9d1ff22c6bc.tar.bz2 nuttx-2323c98f7bfe6367f48ba025d586a9d1ff22c6bc.zip |
Add URL/CGI function mapping option to uIP web server
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@5096 42af7a65-404d-4744-a932-0658087f49c3
Diffstat (limited to 'apps/netutils/webserver/httpd.c')
-rw-r--r-- | apps/netutils/webserver/httpd.c | 25 |
1 files changed, 24 insertions, 1 deletions
diff --git a/apps/netutils/webserver/httpd.c b/apps/netutils/webserver/httpd.c index 0e255416a..2fd019157 100644 --- a/apps/netutils/webserver/httpd.c +++ b/apps/netutils/webserver/httpd.c @@ -214,7 +214,13 @@ static int handle_script(struct httpd_state *pstate) } else { - httpd_cgi(pstate->ht_scriptptr)(pstate, pstate->ht_scriptptr); + httpd_cgifunction f; + + f = httpd_cgi(pstate->ht_scriptptr); + if (f != NULL) + { + f(pstate, pstate->ht_scriptptr); + } } next_scriptstate(pstate); @@ -392,6 +398,21 @@ static int httpd_sendfile(struct httpd_state *pstate) nvdbg("[%d] sending file '%s'\n", pstate->ht_sockfd, pstate->ht_filename); +#ifdef CONFIG_NETUTILS_HTTPD_CGIPATH + { + httpd_cgifunction f; + + f = httpd_cgi(pstate->ht_filename); + if (f != NULL) + { + f(pstate, pstate->ht_filename); + + ret = OK; + goto done; + } + } +#endif + if (httpd_open(pstate->ht_filename, &pstate->ht_file) != OK) { ndbg("[%d] '%s' not found\n", pstate->ht_sockfd, pstate->ht_filename); @@ -434,6 +455,8 @@ static int httpd_sendfile(struct httpd_state *pstate) (void)httpd_close(&pstate->ht_file); +done: + /* Send anything remaining in the buffer */ if (ret == OK && pstate->ht_sndlen > 0) |