Add fileno()
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@1985 42af7a65-404d-4744-a932-0658087f49c3
This commit is contained in:
parent
470cba238e
commit
485c3066e1
@ -815,4 +815,5 @@
|
|||||||
load_ and exec_module() in a more familiar manner. It is not consistent
|
load_ and exec_module() in a more familiar manner. It is not consistent
|
||||||
with more standard exec() functions, however, because (1) it returns
|
with more standard exec() functions, however, because (1) it returns
|
||||||
and (2) it requires symbol table arguments.
|
and (2) it requires symbol table arguments.
|
||||||
|
* lib/: Add fileno()
|
||||||
|
|
||||||
|
@ -1488,6 +1488,7 @@ nuttx-0.4.10 2009-xx-xx Gregory Nutt <spudmonkey@racsa.co.cr>
|
|||||||
load_ and exec_module() in a more familiar manner. It is not consistent
|
load_ and exec_module() in a more familiar manner. It is not consistent
|
||||||
with more standard exec() functions, however, because (1) it returns
|
with more standard exec() functions, however, because (1) it returns
|
||||||
and (2) it requires symbol table arguments.
|
and (2) it requires symbol table arguments.
|
||||||
|
* lib/: Add fileno()
|
||||||
|
|
||||||
nuttx-0.4.10 2009-xx-xx Gregory Nutt <spudmonkey@racsa.co.cr>
|
nuttx-0.4.10 2009-xx-xx Gregory Nutt <spudmonkey@racsa.co.cr>
|
||||||
|
|
||||||
|
@ -12,7 +12,7 @@
|
|||||||
<h1><big><font color="#3c34ec">
|
<h1><big><font color="#3c34ec">
|
||||||
<i>NuttX RTOS Porting Guide</i>
|
<i>NuttX RTOS Porting Guide</i>
|
||||||
</font></big></h1>
|
</font></big></h1>
|
||||||
<p>Last Updated: July 11, 2009</p>
|
<p>Last Updated: July 12, 2009</p>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
@ -2347,6 +2347,117 @@ extern void up_ledoff(int led);
|
|||||||
</li>
|
</li>
|
||||||
</ul>
|
</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 ".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 <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.
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
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".
|
||||||
|
</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 "users" for
|
||||||
|
CONFIG_THTTPD_TILDE_MAP1 and "public_html" 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>
|
<h2>USB Device-Side Support</h2>
|
||||||
<h3>USB Device Controller Driver</h3>
|
<h3>USB Device Controller Driver</h3>
|
||||||
<ul>
|
<ul>
|
||||||
|
@ -96,24 +96,23 @@ int exec(FAR const char *filename, FAR const char **argv,
|
|||||||
{
|
{
|
||||||
struct binary_s bin;
|
struct binary_s bin;
|
||||||
int ret;
|
int ret;
|
||||||
int i;
|
|
||||||
|
|
||||||
memset(&bin, 0, sizeof(struct binary_s));
|
memset(&bin, 0, sizeof(struct binary_s));
|
||||||
bin.filename = filename;
|
bin.filename = filename;
|
||||||
bin.exports = exports;
|
bin.exports = exports;
|
||||||
bin.nexports = NEXPORTS;
|
bin.nexports = nexports;
|
||||||
|
|
||||||
ret = load_module(&bin);
|
ret = load_module(&bin);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
{
|
{
|
||||||
bdbg("ERROR: Failed to load program '%s'\n", dirlist[i]);
|
bdbg("ERROR: Failed to load program '%s'\n", filename);
|
||||||
return ERROR;
|
return ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = exec_module(&bin, 50);
|
ret = exec_module(&bin, 50);
|
||||||
if (ret < 0)
|
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);
|
unload_module(&bin);
|
||||||
return ERROR;
|
return ERROR;
|
||||||
}
|
}
|
||||||
|
@ -353,6 +353,63 @@ defconfig -- This is a configuration file similar to the Linux
|
|||||||
CONFIG_NET_DHCP_LIGHT - Reduces size of DHCP
|
CONFIG_NET_DHCP_LIGHT - Reduces size of DHCP
|
||||||
CONFIG_NET_RESOLV_ENTRIES - Number of resolver entries
|
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
|
USB device controller driver
|
||||||
CONFIG_USBDEV - Enables USB device support
|
CONFIG_USBDEV - Enables USB device support
|
||||||
CONFIG_USBDEV_ISOCHRONOUS - Build in extra support for isochronous
|
CONFIG_USBDEV_ISOCHRONOUS - Build in extra support for isochronous
|
||||||
|
@ -106,6 +106,7 @@ EXTERN int fclose(FAR FILE *stream);
|
|||||||
EXTERN int fflush(FAR FILE *stream);
|
EXTERN int fflush(FAR FILE *stream);
|
||||||
EXTERN int feof(FAR FILE *stream);
|
EXTERN int feof(FAR FILE *stream);
|
||||||
EXTERN int ferror(FAR FILE *stream);
|
EXTERN int ferror(FAR FILE *stream);
|
||||||
|
EXTERN int fileno(FAR FILE *stream);
|
||||||
EXTERN int fgetc(FAR FILE *stream);
|
EXTERN int fgetc(FAR FILE *stream);
|
||||||
EXTERN int fgetpos(FAR FILE *stream, FAR fpos_t *pos);
|
EXTERN int fgetpos(FAR FILE *stream, FAR fpos_t *pos);
|
||||||
EXTERN char *fgets(FAR char *s, int n, FAR FILE *stream);
|
EXTERN char *fgets(FAR char *s, int n, FAR FILE *stream);
|
||||||
|
@ -53,7 +53,7 @@ STRING_SRCS = lib_checkbase.c lib_isbasedigit.c lib_memset.c lib_memcpy.c \
|
|||||||
|
|
||||||
CTYPE_SRCS =
|
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_sprintf.c lib_snprintf.c lib_libsprintf.c lib_vsprintf.c \
|
||||||
lib_vsnprintf.c lib_libvsprintf.c lib_meminstream.c \
|
lib_vsnprintf.c lib_libvsprintf.c lib_meminstream.c \
|
||||||
lib_memoutstream.c lib_lowinstream.c lib_lowoutstream.c \
|
lib_memoutstream.c lib_lowinstream.c lib_lowoutstream.c \
|
||||||
|
65
lib/lib_fileno.c
Normal file
65
lib/lib_fileno.c
Normal file
@ -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;
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user