summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2009-07-13 01:35:15 +0000
committerpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2009-07-13 01:35:15 +0000
commit1cb000c6f96d40ccbeb25069c1b939e915b79cba (patch)
tree74a0d516e1320be9f264880b3706e43ee1a45d7b
parente7a04578288c0d41c819cb051b7fa80977a92d27 (diff)
downloadpx4-nuttx-1cb000c6f96d40ccbeb25069c1b939e915b79cba.tar.gz
px4-nuttx-1cb000c6f96d40ccbeb25069c1b939e915b79cba.tar.bz2
px4-nuttx-1cb000c6f96d40ccbeb25069c1b939e915b79cba.zip
Add fileno()
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@1985 42af7a65-404d-4744-a932-0658087f49c3
-rw-r--r--nuttx/ChangeLog1
-rw-r--r--nuttx/Documentation/NuttX.html1
-rw-r--r--nuttx/Documentation/NuttxPortingGuide.html113
-rw-r--r--nuttx/binfmt/binfmt_exec.c7
-rw-r--r--nuttx/configs/README.txt57
-rw-r--r--nuttx/include/stdio.h1
-rw-r--r--nuttx/lib/Makefile2
-rw-r--r--nuttx/lib/lib_fileno.c65
8 files changed, 241 insertions, 6 deletions
diff --git a/nuttx/ChangeLog b/nuttx/ChangeLog
index 9e2b42602..12c99f651 100644
--- a/nuttx/ChangeLog
+++ b/nuttx/ChangeLog
@@ -815,4 +815,5 @@
load_ and exec_module() in a more familiar manner. It is not consistent
with more standard exec() functions, however, because (1) it returns
and (2) it requires symbol table arguments.
+ * lib/: Add fileno()
diff --git a/nuttx/Documentation/NuttX.html b/nuttx/Documentation/NuttX.html
index f1bf734e9..0f4459c15 100644
--- a/nuttx/Documentation/NuttX.html
+++ b/nuttx/Documentation/NuttX.html
@@ -1488,6 +1488,7 @@ nuttx-0.4.10 2009-xx-xx Gregory Nutt &lt;spudmonkey@racsa.co.cr&gt;
load_ and exec_module() in a more familiar manner. It is not consistent
with more standard exec() functions, however, because (1) it returns
and (2) it requires symbol table arguments.
+ * lib/: Add fileno()
nuttx-0.4.10 2009-xx-xx Gregory Nutt &lt;spudmonkey@racsa.co.cr&gt;
diff --git a/nuttx/Documentation/NuttxPortingGuide.html b/nuttx/Documentation/NuttxPortingGuide.html
index 9acd622cd..5c5b49ef1 100644
--- a/nuttx/Documentation/NuttxPortingGuide.html
+++ b/nuttx/Documentation/NuttxPortingGuide.html
@@ -12,7 +12,7 @@
<h1><big><font color="#3c34ec">
<i>NuttX RTOS Porting Guide</i>
</font></big></h1>
- <p>Last Updated: July 11, 2009</p>
+ <p>Last Updated: July 12, 2009</p>
</td>
</tr>
</table>
@@ -2347,6 +2347,117 @@ extern void up_ledoff(int led);
</li>
</ul>
+<h3>THTTPD</h3>
+<ul>
+ <li>
+ <code>CONFIG_THTTPD_PORT</code>: THTTPD Server port number
+ </li>
+ <li>
+ <code>CONFIG_THTTPD_IPADDR</code>: Server IP address (no host name)
+ </li>
+ <li>
+ <code>CONFIG_THTTPD_SERVER_ADDRESS</code>: SERVER_ADDRESS: response
+ </li>
+ <li>
+ <code>CONFIG_THTTPD_SERVER_SOFTWARE</code>: SERVER_SOFTWARE: response
+ </li>
+ <li>
+ <code>CONFIG_THTTPD_CGI_PATH</code>:
+ </li>
+ <li>
+ <code>CONFIG_THTTPD_CGI_PATTERN</code>: Only CGI programs matching this
+ pattern will be executed. In fact, if this value is not defined
+ then no CGI logic will be built.
+ </li>
+ <li>
+ <code>CONFIG_THTTPD_CGI_PRIORITY</code>: Provides the priority of CGI child tasks
+ </li>
+ <li>
+ <code>CONFIG_THTTPD_CGI_STACKSIZE</code>: Provides the initial stack size of
+ CGI child task (will be overridden by the stack size in the NXFLAT
+ header)
+ </li>
+ <li>
+ <code>CONFIG_THTTPD_CGI_BYTECOUNT</code>: Byte output limit for CGI tasks.
+ </li>
+ <li>
+ <code>CONFIG_THTTPD_CGI_TIMELIMIT</code>: How many seconds to allow CGI programs
+ to run before killing them.
+ </li>
+ <li>
+ <code>CONFIG_THTTPD_CGI_OUTFD</code>: In NuttX, CGI cannot use stdout for output.
+ Rather, it must use this file descriptor number.
+ </li>
+ <li>
+ <code>CONFIG_THTTPD_CHARSET- The default character set name to use with
+ text MIME types.
+ </li>
+ <li>
+ <code>CONFIG_THTTPD_IOBUFFERSIZE</code>:
+ </li>
+ <li>
+ <code>CONFIG_THTTPD_INDEX_NAMES</code>: A list of index filenames to check. The
+ files are searched for in this order.
+ </li>
+ <li>
+ <code>CONFIG_AUTH_FILE</code>: The file to use for authentication. If this is
+ defined then thttpd checks for this file 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. A typical
+ value is &quot;.htpasswd&quout;
+ </li>
+ <li>
+ <code>CONFIG_THTTPD_LISTEN_BACKLOG</code>: The listen() backlog queue length.
+ </li>
+ <li>
+ <code>CONFIG_THTTPD_LINGER_MSEC</code>: How many milliseconds to leave a connection
+ open while doing a lingering close.
+ </li>
+ <li>
+ <code>CONFIG_THTTPD_OCCASIONAL_MSEC</code>: How often to run the occasional
+ cleanup job.
+ </li>
+ <li>
+ <code>CONFIG_THTTPD_IDLE_READ_LIMIT_SEC</code>: How many seconds to allow for
+ reading the initial request on a new connection.
+ </li>
+ <li>
+ <code>CONFIG_THTTPD_IDLE_SEND_LIMIT_SEC</code>: How many seconds before an
+ idle connection gets closed.
+ </li>
+ <li>
+ <code>CONFIG_THTTPD_TILDE_MAP1 and CONFIG_THTTPD_TILDE_MAP2</code>: 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.
+ <ol>
+ <li>
+ Map ~username to &lt;prefix&gt;/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.
+ </li>
+ <li>
+ Map ~username to &lt;user's homedir&gt;/&lt;postfix&gt;. The postfix would be
+ the name of a subdirectory off of the user's actual home dir,
+ something like &quot;public_html&quot;.
+ </li>
+ </ol>
+ You can also leave both options undefined, and thttpd will not do
+ anything special about tildes. Enabling both options is an error.
+ Typical values, if they're defined, are &quot;users&quot; for
+ CONFIG_THTTPD_TILDE_MAP1 and &quot;public_html&quot; forCONFIG_THTTPD_TILDE_MAP2.
+ </li>
+ <li>
+ <code>CONFIG_THTTPD_GENERATE_INDICES
+ </li>
+ <li>
+ <code>CONFIG_THTTPD_URLPATTERN</code>: If defined, then it will be used to match
+ and verify referrers.
+ </li>
+</ul>
+
<h2>USB Device-Side Support</h2>
<h3>USB Device Controller Driver</h3>
<ul>
diff --git a/nuttx/binfmt/binfmt_exec.c b/nuttx/binfmt/binfmt_exec.c
index 8a25445c0..2305f6d63 100644
--- a/nuttx/binfmt/binfmt_exec.c
+++ b/nuttx/binfmt/binfmt_exec.c
@@ -96,24 +96,23 @@ int exec(FAR const char *filename, FAR const char **argv,
{
struct binary_s bin;
int ret;
- int i;
memset(&bin, 0, sizeof(struct binary_s));
bin.filename = filename;
bin.exports = exports;
- bin.nexports = NEXPORTS;
+ bin.nexports = nexports;
ret = load_module(&bin);
if (ret < 0)
{
- bdbg("ERROR: Failed to load program '%s'\n", dirlist[i]);
+ bdbg("ERROR: Failed to load program '%s'\n", filename);
return ERROR;
}
ret = exec_module(&bin, 50);
if (ret < 0)
{
- bdbg("ERROR: Failed to execute program '%s'\n", dirlist[i]);
+ bdbg("ERROR: Failed to execute program '%s'\n", filename);
unload_module(&bin);
return ERROR;
}
diff --git a/nuttx/configs/README.txt b/nuttx/configs/README.txt
index 04833669b..9c23b9d92 100644
--- a/nuttx/configs/README.txt
+++ b/nuttx/configs/README.txt
@@ -353,6 +353,63 @@ defconfig -- This is a configuration file similar to the Linux
CONFIG_NET_DHCP_LIGHT - Reduces size of DHCP
CONFIG_NET_RESOLV_ENTRIES - Number of resolver entries
+ THTTPD:
+ CONFIG_THTTPD_PORT - THTTPD Server port number
+ CONFIG_THTTPD_IPADDR - Server IP address (no host name)
+ CONFIG_THTTPD_SERVER_ADDRESS - SERVER_ADDRESS: response
+ CONFIG_THTTPD_SERVER_SOFTWARE - SERVER_SOFTWARE: response
+ CONFIG_THTTPD_CGI_PATH -
+ CONFIG_THTTPD_CGI_PATTERN - Only CGI programs matching this
+ pattern will be executed. In fact, if this value is not defined
+ then no CGI logic will be built.
+ CONFIG_THTTPD_CGI_PRIORITY - Provides the priority of CGI child tasks
+ CONFIG_THTTPD_CGI_STACKSIZE - Provides the initial stack size of
+ CGI child task (will be overridden by the stack size in the NXFLAT
+ header)
+ CONFIG_THTTPD_CGI_BYTECOUNT - Byte output limit for CGI tasks.
+ CONFIG_THTTPD_CGI_TIMELIMIT - How many seconds to allow CGI programs
+ to run before killing them.
+ CONFIG_THTTPD_CGI_OUTFD - In NuttX, CGI cannot use stdout for output.
+ Rather, it must use this file descriptor number.
+ CONFIG_THTTPD_CHARSET- The default character set name to use with
+ text MIME types.
+ CONFIG_THTTPD_IOBUFFERSIZE -
+ CONFIG_THTTPD_INDEX_NAMES - A list of index filenames to check. The
+ files are searched for in this order.
+ CONFIG_AUTH_FILE - The file to use for authentication. If this is
+ defined then thttpd checks for this file 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. A typical
+ value is ".htpasswd"
+ CONFIG_THTTPD_LISTEN_BACKLOG - The listen() backlog queue length.
+ CONFIG_THTTPD_LINGER_MSEC - How many milliseconds to leave a connection
+ open while doing a lingering close.
+ CONFIG_THTTPD_OCCASIONAL_MSEC - How often to run the occasional
+ cleanup job.
+ CONFIG_THTTPD_IDLE_READ_LIMIT_SEC - How many seconds to allow for
+ reading the initial request on a new connection.
+ CONFIG_THTTPD_IDLE_SEND_LIMIT_SEC - How many seconds before an
+ idle connection gets closed.
+ CONFIG_THTTPD_TILDE_MAP1 and CONFIG_THTTPD_TILDE_MAP2 - 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.
+ 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
+ the name of a subdirectory off of the user's actual home dir,
+ something like "public_html".
+ You can also leave both options undefined, and thttpd will not do
+ 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"forCONFIG_THTTPD_TILDE_MAP2.
+ CONFIG_THTTPD_GENERATE_INDICES
+ CONFIG_THTTPD_URLPATTERN - If defined, then it will be used to match
+ and verify referrers.
+
USB device controller driver
CONFIG_USBDEV - Enables USB device support
CONFIG_USBDEV_ISOCHRONOUS - Build in extra support for isochronous
diff --git a/nuttx/include/stdio.h b/nuttx/include/stdio.h
index 9528600e7..728c1d634 100644
--- a/nuttx/include/stdio.h
+++ b/nuttx/include/stdio.h
@@ -106,6 +106,7 @@ EXTERN int fclose(FAR FILE *stream);
EXTERN int fflush(FAR FILE *stream);
EXTERN int feof(FAR FILE *stream);
EXTERN int ferror(FAR FILE *stream);
+EXTERN int fileno(FAR FILE *stream);
EXTERN int fgetc(FAR FILE *stream);
EXTERN int fgetpos(FAR FILE *stream, FAR fpos_t *pos);
EXTERN char *fgets(FAR char *s, int n, FAR FILE *stream);
diff --git a/nuttx/lib/Makefile b/nuttx/lib/Makefile
index 0255234ac..27fdd3b0c 100644
--- a/nuttx/lib/Makefile
+++ b/nuttx/lib/Makefile
@@ -53,7 +53,7 @@ STRING_SRCS = lib_checkbase.c lib_isbasedigit.c lib_memset.c lib_memcpy.c \
CTYPE_SRCS =
-STDIO_SRCS = lib_printf.c lib_rawprintf.c lib_lowprintf.c \
+STDIO_SRCS = lib_fileno.c lib_printf.c lib_rawprintf.c lib_lowprintf.c \
lib_sprintf.c lib_snprintf.c lib_libsprintf.c lib_vsprintf.c \
lib_vsnprintf.c lib_libvsprintf.c lib_meminstream.c \
lib_memoutstream.c lib_lowinstream.c lib_lowoutstream.c \
diff --git a/nuttx/lib/lib_fileno.c b/nuttx/lib/lib_fileno.c
new file mode 100644
index 000000000..b91798974
--- /dev/null
+++ b/nuttx/lib/lib_fileno.c
@@ -0,0 +1,65 @@
+/****************************************************************************
+ * lib/lib_fileno.c
+ *
+ * Copyright (C) 2009 Gregory Nutt. All rights reserved.
+ * Author: Gregory Nutt <spudmonkey@racsa.co.cr>
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ * 3. Neither the name NuttX nor the names of its contributors may be
+ * used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+#include <sys/types.h>
+
+#include <stdio.h>
+#include <errno.h>
+
+/****************************************************************************
+ * Global Functions
+ ****************************************************************************/
+
+int ileno(FAR FILE *stream)
+{
+ int ret = -1;
+ if (stream)
+ {
+ ret = stream->fs_filedes;
+ }
+
+ if (ret < 0)
+ {
+ errno = EBADF;
+ return ERROR;
+ }
+ return ret;
+}
+