mirror of
https://github.com/apache/nuttx.git
synced 2026-06-04 23:03:27 +08:00
NSH redirected output
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@823 42af7a65-404d-4744-a932-0658087f49c3
This commit is contained in:
@@ -404,4 +404,6 @@
|
||||
* Implement sh and crude script handler in NSH
|
||||
* Fix prototype of read() and write(). Need to use ssize_t and size_t, not
|
||||
int and unsigned int.
|
||||
* Add support for redirection of command output in NSH
|
||||
* NSH can now use both telnet and serial front ends together
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
<tr align="center" bgcolor="#e4e4e4">
|
||||
<td>
|
||||
<h1><big><font color="#3c34ec"><i>NuttX RTOS</i></font></big></h1>
|
||||
<p>Last Updated: August 12, 2008</p>
|
||||
<p>Last Updated: August 16, 2008</p>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
@@ -1038,6 +1038,8 @@ nuttx-0.3.13 2008-xx-xx Gregory Nutt <spudmonkey@racsa.co.cr>
|
||||
* Implement sh and crude script handler in NSH
|
||||
* Fix prototype of read() and write(). Need to use ssize_t and size_t, not
|
||||
int and unsigned int.
|
||||
* Add support for redirection of command output in NSH
|
||||
* NSH can now use both telnet and serial front ends together
|
||||
|
||||
pascal-0.1.3 2008-xx-xx Gregory Nutt <spudmonkey@racsa.co.cr>
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
############################################################
|
||||
############################################################################
|
||||
# configs/c5471evm/defconfig
|
||||
#
|
||||
# Copyright (C) 2007 Gregory Nutt. All rights reserved.
|
||||
# Copyright (C) 2007, 2008 Gregory Nutt. All rights reserved.
|
||||
# Author: Gregory Nutt <spudmonkey@racsa.co.cr>
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
@@ -14,7 +14,7 @@
|
||||
# notice, this list of conditions and the following disclaimer in
|
||||
# the documentation and/or other materials provided with the
|
||||
# distribution.
|
||||
# 3. Neither the name Gregory Nutt nor the names of its contributors may be
|
||||
# 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.
|
||||
#
|
||||
@@ -31,7 +31,7 @@
|
||||
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
# POSSIBILITY OF SUCH DAMAGE.
|
||||
#
|
||||
############################################################
|
||||
############################################################################
|
||||
#
|
||||
# architecture selection
|
||||
#
|
||||
@@ -326,6 +326,7 @@ CONFIG_EXAMPLE_NETTEST_CLIENTIP=(10<<24|0<<16|0<<8|1)
|
||||
|
||||
#
|
||||
# Settings for examples/nsh
|
||||
CONFIG_EXAMPLES_NSH_CONSOLE=y
|
||||
CONFIG_EXAMPLES_NSH_TELNET=n
|
||||
CONFIG_EXAMPLES_NSH_IOBUFFER_SIZE=512
|
||||
CONFIG_EXAMPLES_NSH_CMD_SIZE=40
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
############################################################
|
||||
############################################################################
|
||||
# configs/c5471evm/dhcpconfig
|
||||
#
|
||||
# Copyright (C) 2007 Gregory Nutt. All rights reserved.
|
||||
# Copyright (C) 2007, 2008 Gregory Nutt. All rights reserved.
|
||||
# Author: Gregory Nutt <spudmonkey@racsa.co.cr>
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
@@ -14,7 +14,7 @@
|
||||
# notice, this list of conditions and the following disclaimer in
|
||||
# the documentation and/or other materials provided with the
|
||||
# distribution.
|
||||
# 3. Neither the name Gregory Nutt nor the names of its contributors may be
|
||||
# 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.
|
||||
#
|
||||
@@ -31,7 +31,7 @@
|
||||
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
# POSSIBILITY OF SUCH DAMAGE.
|
||||
#
|
||||
############################################################
|
||||
############################################################################
|
||||
#
|
||||
# architecture selection
|
||||
#
|
||||
@@ -326,6 +326,7 @@ CONFIG_EXAMPLE_NETTEST_CLIENTIP=(10<<24|0<<16|0<<8|1)
|
||||
|
||||
#
|
||||
# Settings for examples/nsh
|
||||
CONFIG_EXAMPLES_NSH_CONSOLE=y
|
||||
CONFIG_EXAMPLES_NSH_TELNET=n
|
||||
CONFIG_EXAMPLES_NSH_IOBUFFER_SIZE=512
|
||||
CONFIG_EXAMPLES_NSH_CMD_SIZE=40
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
############################################################
|
||||
############################################################################
|
||||
# configs/c5471evm/netconfig
|
||||
#
|
||||
# Copyright (C) 2007 Gregory Nutt. All rights reserved.
|
||||
# Copyright (C) 2007, 2008 Gregory Nutt. All rights reserved.
|
||||
# Author: Gregory Nutt <spudmonkey@racsa.co.cr>
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
@@ -14,7 +14,7 @@
|
||||
# notice, this list of conditions and the following disclaimer in
|
||||
# the documentation and/or other materials provided with the
|
||||
# distribution.
|
||||
# 3. Neither the name Gregory Nutt nor the names of its contributors may be
|
||||
# 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.
|
||||
#
|
||||
@@ -31,7 +31,7 @@
|
||||
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
# POSSIBILITY OF SUCH DAMAGE.
|
||||
#
|
||||
############################################################
|
||||
############################################################################
|
||||
#
|
||||
# architecture selection
|
||||
#
|
||||
@@ -326,6 +326,7 @@ CONFIG_EXAMPLE_NETTEST_CLIENTIP=(10<<24|0<<16|0<<8|1)
|
||||
|
||||
#
|
||||
# Settings for examples/nsh
|
||||
CONFIG_EXAMPLES_NSH_CONSOLE=y
|
||||
CONFIG_EXAMPLES_NSH_TELNET=n
|
||||
CONFIG_EXAMPLES_NSH_IOBUFFER_SIZE=512
|
||||
CONFIG_EXAMPLES_NSH_CMD_SIZE=40
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
############################################################
|
||||
############################################################################
|
||||
# configs/c5471evm/nshconfig
|
||||
#
|
||||
# Copyright (C) 2007 Gregory Nutt. All rights reserved.
|
||||
# Copyright (C) 2007, 2008 Gregory Nutt. All rights reserved.
|
||||
# Author: Gregory Nutt <spudmonkey@racsa.co.cr>
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
@@ -14,7 +14,7 @@
|
||||
# notice, this list of conditions and the following disclaimer in
|
||||
# the documentation and/or other materials provided with the
|
||||
# distribution.
|
||||
# 3. Neither the name Gregory Nutt nor the names of its contributors may be
|
||||
# 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.
|
||||
#
|
||||
@@ -31,7 +31,7 @@
|
||||
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
# POSSIBILITY OF SUCH DAMAGE.
|
||||
#
|
||||
############################################################
|
||||
############################################################################
|
||||
#
|
||||
# architecture selection
|
||||
#
|
||||
@@ -326,6 +326,7 @@ CONFIG_EXAMPLE_NETTEST_CLIENTIP=(10<<24|0<<16|0<<8|1)
|
||||
|
||||
#
|
||||
# Settings for examples/nsh
|
||||
CONFIG_EXAMPLES_NSH_CONSOLE=n
|
||||
CONFIG_EXAMPLES_NSH_TELNET=y
|
||||
CONFIG_EXAMPLES_NSH_IOBUFFER_SIZE=512
|
||||
CONFIG_EXAMPLES_NSH_CMD_SIZE=40
|
||||
|
||||
@@ -316,6 +316,7 @@ CONFIG_EXAMPLES_OSTEST_STACKSIZE=256
|
||||
|
||||
#
|
||||
# Settings for examples/nsh
|
||||
CONFIG_EXAMPLES_NSH_CONSOLE=y
|
||||
CONFIG_EXAMPLES_NSH_TELNET=n
|
||||
CONFIG_EXAMPLES_NSH_IOBUFFER_SIZE=512
|
||||
CONFIG_EXAMPLES_NSH_CMD_SIZE=40
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
############################################################
|
||||
# defconfig
|
||||
############################################################################
|
||||
# configs/m68332evb/defconfig
|
||||
#
|
||||
# Copyright (C) 2007 Gregory Nutt. All rights reserved.
|
||||
# Copyright (C) 2007, 2008 Gregory Nutt. All rights reserved.
|
||||
# Author: Gregory Nutt <spudmonkey@racsa.co.cr>
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
@@ -14,7 +14,7 @@
|
||||
# notice, this list of conditions and the following disclaimer in
|
||||
# the documentation and/or other materials provided with the
|
||||
# distribution.
|
||||
# 3. Neither the name Gregory Nutt nor the names of its contributors may be
|
||||
# 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.
|
||||
#
|
||||
@@ -31,7 +31,7 @@
|
||||
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
# POSSIBILITY OF SUCH DAMAGE.
|
||||
#
|
||||
############################################################
|
||||
############################################################################
|
||||
#
|
||||
# architecture selection
|
||||
#
|
||||
@@ -292,6 +292,7 @@ CONFIG_NET_RESOLV_ENTRIES=4
|
||||
|
||||
#
|
||||
# Settings for examples/nsh
|
||||
CONFIG_EXAMPLES_NSH_CONSOLE=y
|
||||
CONFIG_EXAMPLES_NSH_TELNET=n
|
||||
CONFIG_EXAMPLES_NSH_IOBUFFER_SIZE=512
|
||||
CONFIG_EXAMPLES_NSH_CMD_SIZE=40
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
############################################################
|
||||
# defconfig
|
||||
############################################################################
|
||||
# configs/mcu123-lpc214x/defconfig
|
||||
#
|
||||
# Copyright (C) 2007 Gregory Nutt. All rights reserved.
|
||||
# Copyright (C) 2007, 2008 Gregory Nutt. All rights reserved.
|
||||
# Author: Gregory Nutt <spudmonkey@racsa.co.cr>
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
@@ -14,7 +14,7 @@
|
||||
# notice, this list of conditions and the following disclaimer in
|
||||
# the documentation and/or other materials provided with the
|
||||
# distribution.
|
||||
# 3. Neither the name Gregory Nutt nor the names of its contributors may be
|
||||
# 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.
|
||||
#
|
||||
@@ -31,7 +31,7 @@
|
||||
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
# POSSIBILITY OF SUCH DAMAGE.
|
||||
#
|
||||
############################################################
|
||||
############################################################################
|
||||
#
|
||||
# architecture selection
|
||||
#
|
||||
@@ -316,6 +316,7 @@ CONFIG_NET_RESOLV_ENTRIES=4
|
||||
|
||||
#
|
||||
# Settings for examples/nsh
|
||||
CONFIG_EXAMPLES_NSH_CONSOLE=y
|
||||
CONFIG_EXAMPLES_NSH_TELNET=n
|
||||
CONFIG_EXAMPLES_NSH_IOBUFFER_SIZE=512
|
||||
CONFIG_EXAMPLES_NSH_CMD_SIZE=40
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
############################################################
|
||||
############################################################################
|
||||
# configs/ntosd-dm320/defconfig
|
||||
#
|
||||
# Copyright (C) 2007 Gregory Nutt. All rights reserved.
|
||||
# Copyright (C) 2007, 2008 Gregory Nutt. All rights reserved.
|
||||
# Author: Gregory Nutt <spudmonkey@racsa.co.cr>
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
@@ -14,7 +14,7 @@
|
||||
# notice, this list of conditions and the following disclaimer in
|
||||
# the documentation and/or other materials provided with the
|
||||
# distribution.
|
||||
# 3. Neither the name Gregory Nutt nor the names of its contributors may be
|
||||
# 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.
|
||||
#
|
||||
@@ -31,7 +31,7 @@
|
||||
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
# POSSIBILITY OF SUCH DAMAGE.
|
||||
#
|
||||
############################################################
|
||||
############################################################################
|
||||
#
|
||||
# architecture selection
|
||||
#
|
||||
@@ -322,6 +322,7 @@ CONFIG_EXAMPLE_NETTEST_CLIENTIP=(10<<24|0<<16|0<<8|1)
|
||||
|
||||
#
|
||||
# Settings for examples/nsh
|
||||
CONFIG_EXAMPLES_NSH_CONSOLE=y
|
||||
CONFIG_EXAMPLES_NSH_TELNET=n
|
||||
CONFIG_EXAMPLES_NSH_IOBUFFER_SIZE=512
|
||||
CONFIG_EXAMPLES_NSH_CMD_SIZE=40
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
############################################################
|
||||
############################################################################
|
||||
# configs/ntosd-dm320/netconfig
|
||||
#
|
||||
# Copyright (C) 2007 Gregory Nutt. All rights reserved.
|
||||
# Copyright (C) 2007, 2008 Gregory Nutt. All rights reserved.
|
||||
# Author: Gregory Nutt <spudmonkey@racsa.co.cr>
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
@@ -14,7 +14,7 @@
|
||||
# notice, this list of conditions and the following disclaimer in
|
||||
# the documentation and/or other materials provided with the
|
||||
# distribution.
|
||||
# 3. Neither the name Gregory Nutt nor the names of its contributors may be
|
||||
# 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.
|
||||
#
|
||||
@@ -31,7 +31,7 @@
|
||||
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
# POSSIBILITY OF SUCH DAMAGE.
|
||||
#
|
||||
############################################################
|
||||
############################################################################
|
||||
#
|
||||
# architecture selection
|
||||
#
|
||||
@@ -322,6 +322,7 @@ CONFIG_EXAMPLE_NETTEST_CLIENTIP=(10<<24|0<<16|0<<8|1)
|
||||
|
||||
#
|
||||
# Settings for examples/nsh
|
||||
CONFIG_EXAMPLES_NSH_CONSOLE=y
|
||||
CONFIG_EXAMPLES_NSH_TELNET=n
|
||||
CONFIG_EXAMPLES_NSH_IOBUFFER_SIZE=512
|
||||
CONFIG_EXAMPLES_NSH_CMD_SIZE=40
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
############################################################
|
||||
############################################################################
|
||||
# configs/ntosd-dm320/udpconfig
|
||||
#
|
||||
# Copyright (C) 2007 Gregory Nutt. All rights reserved.
|
||||
# Copyright (C) 2007, 2008 Gregory Nutt. All rights reserved.
|
||||
# Author: Gregory Nutt <spudmonkey@racsa.co.cr>
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
@@ -14,7 +14,7 @@
|
||||
# notice, this list of conditions and the following disclaimer in
|
||||
# the documentation and/or other materials provided with the
|
||||
# distribution.
|
||||
# 3. Neither the name Gregory Nutt nor the names of its contributors may be
|
||||
# 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.
|
||||
#
|
||||
@@ -31,7 +31,7 @@
|
||||
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
# POSSIBILITY OF SUCH DAMAGE.
|
||||
#
|
||||
############################################################
|
||||
############################################################################
|
||||
#
|
||||
# architecture selection
|
||||
#
|
||||
@@ -330,6 +330,7 @@ CONFIG_EXAMPLE_UDP_SERVERIP=(10<<24|0<<16|0<<8|1)
|
||||
|
||||
#
|
||||
# Settings for examples/nsh
|
||||
CONFIG_EXAMPLES_NSH_CONSOLE=y
|
||||
CONFIG_EXAMPLES_NSH_TELNET=n
|
||||
CONFIG_EXAMPLES_NSH_IOBUFFER_SIZE=512
|
||||
CONFIG_EXAMPLES_NSH_CMD_SIZE=40
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
############################################################
|
||||
############################################################################
|
||||
# configs/ntosd-dm320/uipconfig
|
||||
#
|
||||
# Copyright (C) 2007 Gregory Nutt. All rights reserved.
|
||||
# Copyright (C) 2007, 2008 Gregory Nutt. All rights reserved.
|
||||
# Author: Gregory Nutt <spudmonkey@racsa.co.cr>
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
@@ -14,7 +14,7 @@
|
||||
# notice, this list of conditions and the following disclaimer in
|
||||
# the documentation and/or other materials provided with the
|
||||
# distribution.
|
||||
# 3. Neither the name Gregory Nutt nor the names of its contributors may be
|
||||
# 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.
|
||||
#
|
||||
@@ -31,7 +31,7 @@
|
||||
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
# POSSIBILITY OF SUCH DAMAGE.
|
||||
#
|
||||
############################################################
|
||||
############################################################################
|
||||
#
|
||||
# architecture selection
|
||||
#
|
||||
@@ -322,6 +322,7 @@ CONFIG_EXAMPLE_NETTEST_CLIENTIP=(10<<24|0<<16|0<<8|1)
|
||||
|
||||
#
|
||||
# Settings for examples/nsh
|
||||
CONFIG_EXAMPLES_NSH_CONSOLE=y
|
||||
CONFIG_EXAMPLES_NSH_TELNET=n
|
||||
CONFIG_EXAMPLES_NSH_IOBUFFER_SIZE=512
|
||||
CONFIG_EXAMPLES_NSH_CMD_SIZE=40
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
############################################################
|
||||
# defconfig
|
||||
############################################################################
|
||||
# configs/pjrc-8051/defconfig
|
||||
#
|
||||
# Copyright (C) 2007 Gregory Nutt. All rights reserved.
|
||||
# Copyright (C) 2007, 2008 Gregory Nutt. All rights reserved.
|
||||
# Author: Gregory Nutt <spudmonkey@racsa.co.cr>
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
@@ -14,7 +14,7 @@
|
||||
# notice, this list of conditions and the following disclaimer in
|
||||
# the documentation and/or other materials provided with the
|
||||
# distribution.
|
||||
# 3. Neither the name Gregory Nutt nor the names of its contributors may be
|
||||
# 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.
|
||||
#
|
||||
@@ -31,7 +31,7 @@
|
||||
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
# POSSIBILITY OF SUCH DAMAGE.
|
||||
#
|
||||
############################################################
|
||||
############################################################################
|
||||
#
|
||||
# Architecture selection
|
||||
#
|
||||
@@ -289,6 +289,7 @@ CONFIG_NET_RESOLV_ENTRIES=4
|
||||
|
||||
#
|
||||
# Settings for examples/nsh
|
||||
CONFIG_EXAMPLES_NSH_CONSOLE=y
|
||||
CONFIG_EXAMPLES_NSH_TELNET=n
|
||||
CONFIG_EXAMPLES_NSH_IOBUFFER_SIZE=512
|
||||
CONFIG_EXAMPLES_NSH_CMD_SIZE=40
|
||||
|
||||
@@ -288,6 +288,7 @@ CONFIG_EXAMPLES_OSTEST_STACKSIZE=8192
|
||||
|
||||
#
|
||||
# Settings for examples/nsh
|
||||
CONFIG_EXAMPLES_NSH_CONSOLE=y
|
||||
CONFIG_EXAMPLES_NSH_TELNET=n
|
||||
CONFIG_EXAMPLES_NSH_IOBUFFER_SIZE=512
|
||||
CONFIG_EXAMPLES_NSH_CMD_SIZE=40
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
############################################################
|
||||
# defconfig
|
||||
############################################################################
|
||||
# sim/nettest/defconfig
|
||||
#
|
||||
# Copyright (C) 2007 Gregory Nutt. All rights reserved.
|
||||
# Copyright (C) 2007, 2008 Gregory Nutt. All rights reserved.
|
||||
# Author: Gregory Nutt <spudmonkey@racsa.co.cr>
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
@@ -14,7 +14,7 @@
|
||||
# notice, this list of conditions and the following disclaimer in
|
||||
# the documentation and/or other materials provided with the
|
||||
# distribution.
|
||||
# 3. Neither the name Gregory Nutt nor the names of its contributors may be
|
||||
# 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.
|
||||
#
|
||||
@@ -31,15 +31,14 @@
|
||||
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
# POSSIBILITY OF SUCH DAMAGE.
|
||||
#
|
||||
############################################################
|
||||
############################################################################
|
||||
#
|
||||
# architecture selection
|
||||
# Architecture selection
|
||||
#
|
||||
# CONFIG_ARCH - identifies the arch subdirectory and, hence, the
|
||||
# processor architecture.
|
||||
# CONFIG_ARCH_name - for use in C code. This identifies the
|
||||
# particular chip or SoC that the architecture is implemented
|
||||
# in.
|
||||
# CONFIG_ARCH_name - for use in C code. This identifies the particular
|
||||
# processor architecture (CONFIG_ARCH_SIM).
|
||||
# CONFIG_ARCH_BOARD - identifies the configs subdirectory and, hence,
|
||||
# the board that supports the particular chip or SoC.
|
||||
# CONFIG_ARCH_BOARD_name - for use in C code
|
||||
@@ -50,16 +49,6 @@ CONFIG_ARCH_SIM=y
|
||||
CONFIG_ARCH_BOARD=sim
|
||||
CONFIG_ARCH_BOARD_SIM=y
|
||||
|
||||
#
|
||||
# General build options
|
||||
#
|
||||
# CONFIG_RRLOAD_BINARY - make the rrload binary format used with
|
||||
# BSPs from www.ridgerun.com
|
||||
# CONFIG_HAVE_LIBM - toolchain supports libm.a
|
||||
#
|
||||
CONFIG_RRLOAD_BINARY=n
|
||||
CONFIG_HAVE_LIBM=y
|
||||
|
||||
#
|
||||
# General OS setup
|
||||
#
|
||||
@@ -92,7 +81,6 @@ CONFIG_HAVE_LIBM=y
|
||||
# CONFIG_DEV_CONSOLE - Set if architecture-specific logic
|
||||
# provides /dev/console. Enables stdout, stderr, stdin.
|
||||
#
|
||||
#CONFIG_EXAMPLE=uip
|
||||
CONFIG_EXAMPLE=nettest
|
||||
CONFIG_DEBUG=n
|
||||
CONFIG_DEBUG_VERBOSE=n
|
||||
@@ -101,9 +89,9 @@ CONFIG_ARCH_LOWPUTC=y
|
||||
CONFIG_RR_INTERVAL=0
|
||||
CONFIG_SCHED_INSTRUMENTATION=n
|
||||
CONFIG_TASK_NAME_SIZE=32
|
||||
CONFIG_START_YEAR=2007
|
||||
CONFIG_START_MONTH=2
|
||||
CONFIG_START_DAY=27
|
||||
CONFIG_START_YEAR=2008
|
||||
CONFIG_START_MONTH=8
|
||||
CONFIG_START_DAY=16
|
||||
CONFIG_JULIAN_TIME=n
|
||||
CONFIG_DEV_CONSOLE=y
|
||||
|
||||
@@ -157,6 +145,16 @@ CONFIG_ARCH_KMALLOC=n
|
||||
CONFIG_ARCH_KZMALLOC=n
|
||||
CONFIG_ARCH_KFREE=n
|
||||
|
||||
#
|
||||
# General build options
|
||||
#
|
||||
# CONFIG_RRLOAD_BINARY - make the rrload binary format used with
|
||||
# BSPs from www.ridgerun.com
|
||||
# CONFIG_HAVE_LIBM - toolchain supports libm.a
|
||||
#
|
||||
CONFIG_RRLOAD_BINARY=n
|
||||
CONFIG_HAVE_LIBM=y
|
||||
|
||||
#
|
||||
# Sizes of configurable things (0 disables)
|
||||
#
|
||||
@@ -283,8 +281,14 @@ CONFIG_EXAMPLE_NETTEST_DRIPADDR=(192<<24|168<<16|0<<8|1)
|
||||
CONFIG_EXAMPLE_NETTEST_NETMASK=(255<<24|255<<16|255<<8|0)
|
||||
CONFIG_EXAMPLE_NETTEST_CLIENTIP=(192<<24|168<<16|0<<8|106)
|
||||
|
||||
#
|
||||
# Settings for examples/ostest
|
||||
CONFIG_EXAMPLES_OSTEST_LOOPS=100
|
||||
CONFIG_EXAMPLES_OSTEST_STACKSIZE=8192
|
||||
|
||||
#
|
||||
# Settings for examples/nsh
|
||||
CONFIG_EXAMPLES_NSH_CONSOLE=y
|
||||
CONFIG_EXAMPLES_NSH_TELNET=n
|
||||
CONFIG_EXAMPLES_NSH_IOBUFFER_SIZE=512
|
||||
CONFIG_EXAMPLES_NSH_CMD_SIZE=40
|
||||
@@ -295,6 +299,13 @@ CONFIG_EXAMPLES_NSH_IPADDR=(10<<24|0<<16|0<<8|2)
|
||||
CONFIG_EXAMPLES_NSH_DRIPADDR=(10<<24|0<<16|0<<8|1)
|
||||
CONFIG_EXAMPLES_NSH_NETMASK=(255<<24|255<<16|255<<8|0)
|
||||
|
||||
#
|
||||
# Settings for examples/mount
|
||||
CONFIG_EXAMPLES_MOUNT_DEVNAME="/dev/ram0"
|
||||
#CONFIG_EXAMPLES_MOUNT_NSECTORS=2048
|
||||
#CONFIG_EXAMPLES_MOUNT_SECTORSIZE=512
|
||||
#CONFIG_EXAMPLES_MOUNT_RAMDEVNO=1
|
||||
|
||||
# Stack and heap information
|
||||
#
|
||||
# CONFIG_BOOT_FROM_FLASH - Some configurations support XIP
|
||||
|
||||
@@ -289,6 +289,7 @@ CONFIG_EXAMPLES_OSTEST_STACKSIZE=8192
|
||||
|
||||
#
|
||||
# Settings for examples/nsh
|
||||
CONFIG_EXAMPLES_NSH_CONSOLE=y
|
||||
CONFIG_EXAMPLES_NSH_TELNET=n
|
||||
CONFIG_EXAMPLES_NSH_IOBUFFER_SIZE=512
|
||||
CONFIG_EXAMPLES_NSH_CMD_SIZE=40
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
############################################################################
|
||||
# sim/defconfig
|
||||
# configs/sim/defconfig
|
||||
#
|
||||
# Copyright (C) 2007, 2008 Gregory Nutt. All rights reserved.
|
||||
# Author: Gregory Nutt <spudmonkey@racsa.co.cr>
|
||||
@@ -283,6 +283,7 @@ CONFIG_EXAMPLE_NETTEST_CLIENTIP=(192<<24|168<<16|0<<8|106)
|
||||
|
||||
#
|
||||
# Settings for examples/nsh
|
||||
CONFIG_EXAMPLES_NSH_CONSOLE=y
|
||||
CONFIG_EXAMPLES_NSH_TELNET=n
|
||||
CONFIG_EXAMPLES_NSH_IOBUFFER_SIZE=512
|
||||
CONFIG_EXAMPLES_NSH_CMD_SIZE=40
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
############################################################
|
||||
# defconfig
|
||||
############################################################################
|
||||
# sim/xtrs/nsh/defconfig
|
||||
#
|
||||
# Copyright (C) 2007 Gregory Nutt. All rights reserved.
|
||||
# Copyright (C) 2007, 2008 Gregory Nutt. All rights reserved.
|
||||
# Author: Gregory Nutt <spudmonkey@racsa.co.cr>
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
@@ -14,7 +14,7 @@
|
||||
# notice, this list of conditions and the following disclaimer in
|
||||
# the documentation and/or other materials provided with the
|
||||
# distribution.
|
||||
# 3. Neither the name Gregory Nutt nor the names of its contributors may be
|
||||
# 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.
|
||||
#
|
||||
@@ -31,7 +31,7 @@
|
||||
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
# POSSIBILITY OF SUCH DAMAGE.
|
||||
#
|
||||
############################################################
|
||||
############################################################################
|
||||
#
|
||||
# Architecture selection
|
||||
#
|
||||
@@ -287,6 +287,7 @@ CONFIG_NET_RESOLV_ENTRIES=4
|
||||
|
||||
#
|
||||
# Settings for examples/nsh
|
||||
CONFIG_EXAMPLES_NSH_CONSOLE=y
|
||||
CONFIG_EXAMPLES_NSH_TELNET=n
|
||||
CONFIG_EXAMPLES_NSH_IOBUFFER_SIZE=512
|
||||
CONFIG_EXAMPLES_NSH_CMD_SIZE=40
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
############################################################
|
||||
# configs/z80/defconfig
|
||||
############################################################################
|
||||
# configs/xtrs/ostest/defconfig
|
||||
#
|
||||
# Copyright (C) 2008 Gregory Nutt. All rights reserved.
|
||||
# Author: Gregory Nutt <spudmonkey@racsa.co.cr>
|
||||
@@ -31,7 +31,7 @@
|
||||
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
# POSSIBILITY OF SUCH DAMAGE.
|
||||
#
|
||||
############################################################
|
||||
############################################################################
|
||||
#
|
||||
# Architecture selection
|
||||
#
|
||||
@@ -287,6 +287,7 @@ CONFIG_NET_RESOLV_ENTRIES=4
|
||||
|
||||
#
|
||||
# Settings for examples/nsh
|
||||
CONFIG_EXAMPLES_NSH_CONSOLE=y
|
||||
CONFIG_EXAMPLES_NSH_TELNET=n
|
||||
CONFIG_EXAMPLES_NSH_IOBUFFER_SIZE=512
|
||||
CONFIG_EXAMPLES_NSH_CMD_SIZE=40
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
############################################################
|
||||
# configs/z80/defconfig
|
||||
############################################################################
|
||||
# configs/xtrs/pashello/defconfig
|
||||
#
|
||||
# Copyright (C) 2008 Gregory Nutt. All rights reserved.
|
||||
# Author: Gregory Nutt <spudmonkey@racsa.co.cr>
|
||||
@@ -31,7 +31,7 @@
|
||||
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
# POSSIBILITY OF SUCH DAMAGE.
|
||||
#
|
||||
############################################################
|
||||
############################################################################
|
||||
#
|
||||
# Architecture selection
|
||||
#
|
||||
@@ -287,6 +287,7 @@ CONFIG_NET_RESOLV_ENTRIES=4
|
||||
|
||||
#
|
||||
# Settings for examples/nsh
|
||||
CONFIG_EXAMPLES_NSH_CONSOLE=y
|
||||
CONFIG_EXAMPLES_NSH_TELNET=n
|
||||
CONFIG_EXAMPLES_NSH_IOBUFFER_SIZE=512
|
||||
CONFIG_EXAMPLES_NSH_CMD_SIZE=40
|
||||
|
||||
@@ -306,6 +306,7 @@ CONFIG_NET_RESOLV_ENTRIES=4
|
||||
|
||||
#
|
||||
# Settings for examples/nsh
|
||||
CONFIG_EXAMPLES_NSH_CONSOLE=y
|
||||
CONFIG_EXAMPLES_NSH_TELNET=n
|
||||
CONFIG_EXAMPLES_NSH_IOBUFFER_SIZE=512
|
||||
CONFIG_EXAMPLES_NSH_CMD_SIZE=40
|
||||
|
||||
@@ -306,6 +306,7 @@ CONFIG_NET_RESOLV_ENTRIES=4
|
||||
|
||||
#
|
||||
# Settings for examples/nsh
|
||||
CONFIG_EXAMPLES_NSH_CONSOLE=y
|
||||
CONFIG_EXAMPLES_NSH_TELNET=n
|
||||
CONFIG_EXAMPLES_NSH_IOBUFFER_SIZE=512
|
||||
CONFIG_EXAMPLES_NSH_CMD_SIZE=40
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
############################################################
|
||||
# defconfig
|
||||
############################################################################
|
||||
# sim/z80sim/nsh/defconfig
|
||||
#
|
||||
# Copyright (C) 2007 Gregory Nutt. All rights reserved.
|
||||
# Copyright (C) 2007, 2008 Gregory Nutt. All rights reserved.
|
||||
# Author: Gregory Nutt <spudmonkey@racsa.co.cr>
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
@@ -14,7 +14,7 @@
|
||||
# notice, this list of conditions and the following disclaimer in
|
||||
# the documentation and/or other materials provided with the
|
||||
# distribution.
|
||||
# 3. Neither the name Gregory Nutt nor the names of its contributors may be
|
||||
# 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.
|
||||
#
|
||||
@@ -31,7 +31,7 @@
|
||||
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
# POSSIBILITY OF SUCH DAMAGE.
|
||||
#
|
||||
############################################################
|
||||
############################################################################
|
||||
#
|
||||
# Architecture selection
|
||||
#
|
||||
@@ -278,6 +278,7 @@ CONFIG_NET_RESOLV_ENTRIES=4
|
||||
|
||||
#
|
||||
# Settings for examples/nsh
|
||||
CONFIG_EXAMPLES_NSH_CONSOLE=y
|
||||
CONFIG_EXAMPLES_NSH_TELNET=n
|
||||
CONFIG_EXAMPLES_NSH_IOBUFFER_SIZE=512
|
||||
CONFIG_EXAMPLES_NSH_CMD_SIZE=40
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
############################################################
|
||||
# configs/z80/defconfig
|
||||
############################################################################
|
||||
# configs/z80sim/ostest/defconfig
|
||||
#
|
||||
# Copyright (C) 2007, 2008 Gregory Nutt. All rights reserved.
|
||||
# Author: Gregory Nutt <spudmonkey@racsa.co.cr>
|
||||
@@ -31,7 +31,7 @@
|
||||
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
# POSSIBILITY OF SUCH DAMAGE.
|
||||
#
|
||||
############################################################
|
||||
############################################################################
|
||||
#
|
||||
# Architecture selection
|
||||
#
|
||||
@@ -278,6 +278,7 @@ CONFIG_NET_RESOLV_ENTRIES=4
|
||||
|
||||
#
|
||||
# Settings for examples/nsh
|
||||
CONFIG_EXAMPLES_NSH_CONSOLE=y
|
||||
CONFIG_EXAMPLES_NSH_TELNET=n
|
||||
CONFIG_EXAMPLES_NSH_IOBUFFER_SIZE=512
|
||||
CONFIG_EXAMPLES_NSH_CMD_SIZE=40
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
############################################################
|
||||
# configs/z80/defconfig
|
||||
############################################################################
|
||||
# configs/z80sim/pashello/defconfig
|
||||
#
|
||||
# Copyright (C) 2007, 2008 Gregory Nutt. All rights reserved.
|
||||
# Author: Gregory Nutt <spudmonkey@racsa.co.cr>
|
||||
@@ -31,7 +31,7 @@
|
||||
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
# POSSIBILITY OF SUCH DAMAGE.
|
||||
#
|
||||
############################################################
|
||||
############################################################################
|
||||
#
|
||||
# Architecture selection
|
||||
#
|
||||
@@ -279,6 +279,7 @@ CONFIG_NET_RESOLV_ENTRIES=4
|
||||
|
||||
#
|
||||
# Settings for examples/nsh
|
||||
CONFIG_EXAMPLES_NSH_CONSOLE=y
|
||||
CONFIG_EXAMPLES_NSH_TELNET=n
|
||||
CONFIG_EXAMPLES_NSH_IOBUFFER_SIZE=512
|
||||
CONFIG_EXAMPLES_NSH_CMD_SIZE=40
|
||||
|
||||
@@ -317,6 +317,7 @@ CONFIG_EXAMPLES_OSTEST_STACKSIZE=256
|
||||
|
||||
#
|
||||
# Settings for examples/nsh
|
||||
CONFIG_EXAMPLES_NSH_CONSOLE=y
|
||||
CONFIG_EXAMPLES_NSH_TELNET=n
|
||||
CONFIG_EXAMPLES_NSH_IOBUFFER_SIZE=512
|
||||
CONFIG_EXAMPLES_NSH_CMD_SIZE=40
|
||||
|
||||
@@ -317,6 +317,7 @@ CONFIG_EXAMPLES_OSTEST_STACKSIZE=256
|
||||
|
||||
#
|
||||
# Settings for examples/nsh
|
||||
CONFIG_EXAMPLES_NSH_CONSOLE=y
|
||||
CONFIG_EXAMPLES_NSH_TELNET=n
|
||||
CONFIG_EXAMPLES_NSH_IOBUFFER_SIZE=512
|
||||
CONFIG_EXAMPLES_NSH_CMD_SIZE=40
|
||||
|
||||
+20
-10
@@ -46,13 +46,18 @@ examples/nsh
|
||||
ifconfig CONFIG_NET && CONFIG_NSOCKET_DESCRIPTORS > 0
|
||||
ls CONFIG_NFILE_DESCRIPTORS > 0
|
||||
mkdir !CONFIG_DISABLE_MOUNTPOINT && CONFIG_NFILE_DESCRIPTORS > 0
|
||||
mount !CONFIG_DISABLE_MOUNTPOINT && CONFIG_NFILE_DESCRIPTORS > 0
|
||||
mkfatfs !CONFIG_DISABLE_MOUNTPOINT && CONFIG_NFILE_DESCRIPTORS > 0 && CONFIG_FS_FAT
|
||||
mkfifo !CONFIG_DISABLE_MOUNTPOINT && CONFIG_NFILE_DESCRIPTORS > 0
|
||||
mount !CONFIG_DISABLE_MOUNTPOINT && CONFIG_NFILE_DESCRIPTORS > 0 && CONFIG_FS_FAT
|
||||
ps --
|
||||
set !CONFIG_DISABLE_ENVIRON
|
||||
sleep !CONFIG_DISABLE_SIGNALS
|
||||
sh CONFIG_NFILE_DESCRIPTORS > 0 && CONFIG_NFILE_STREAMS > 0
|
||||
rm !CONFIG_DISABLE_MOUNTPOINT && CONFIG_NFILE_DESCRIPTORS > 0
|
||||
rmdir !CONFIG_DISABLE_MOUNTPOINT && CONFIG_NFILE_DESCRIPTORS > 0
|
||||
umount !CONFIG_DISABLE_MOUNTPOINT && CONFIG_NFILE_DESCRIPTORS > 0
|
||||
umount !CONFIG_DISABLE_MOUNTPOINT && CONFIG_NFILE_DESCRIPTORS > 0 && CONFIG_FS_FAT
|
||||
unset !CONFIG_DISABLE_ENVIRON
|
||||
usleep !CONFIG_DISABLE_SIGNALS
|
||||
|
||||
Other behavior of NSH can be modified with the following settings in
|
||||
the configs/<board-name>/defconfig file:
|
||||
@@ -69,24 +74,29 @@ examples/nsh
|
||||
The maximum length of one command line and of one output line.
|
||||
Default: 80
|
||||
|
||||
* CONFIG_EXAMPLES_NSH_STACKSIZE
|
||||
The stack size to use when spawning new threads or tasks. Such
|
||||
new threads are generated when a command is executed in background
|
||||
or as new TELNET connections are established.
|
||||
|
||||
* CONFIG_EXAMPLES_NSH_CONSOLE
|
||||
If CONFIG_EXAMPLES_NSH_CONSOLE is set to 'y', then a serial
|
||||
console front-end is selected.
|
||||
|
||||
* CONFIG_EXAMPLES_NSH_TELNET
|
||||
By default, NSH is configured to use the serial console.
|
||||
If CONFIG_EXAMPLES_NSH_TELNET is set to 'y', then a TELENET
|
||||
server front-end is selected. When this option is provided,
|
||||
you must log into NuttX remotely using telnet in order to
|
||||
you may log into NuttX remotely using telnet in order to
|
||||
access NSH.
|
||||
|
||||
If CONFIG_EXAMPLES_NSH_TELNET is selected, then there some other
|
||||
configuration settings that apply:
|
||||
One or both of CONFIG_EXAMPLES_NSH_CONSOLE and CONFIG_EXAMPLES_NSH_TELNET
|
||||
must be defined. If CONFIG_EXAMPLES_NSH_TELNET is selected, then there some
|
||||
other configuration settings that apply:
|
||||
|
||||
* CONFIG_EXAMPLES_NSH_IOBUFFER_SIZE
|
||||
Determines the size of the I/O buffer to use for sending/
|
||||
receiving TELNET commands/reponses
|
||||
|
||||
* CONFIG_EXAMPLES_NSH_STACKSIZE
|
||||
The stack size to use when spawning new threads as new TELNET
|
||||
connections are established.
|
||||
|
||||
* CONFIG_EXAMPLES_NSH_DHCPC
|
||||
Obtain the the IP address via DHCP.
|
||||
|
||||
|
||||
@@ -45,10 +45,12 @@ CSRCS += nsh_netcmds.c
|
||||
endif
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_EXAMPLES_NSH_CONSOLE),y)
|
||||
CSRCS += nsh_serial.c
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_EXAMPLES_NSH_TELNET),y)
|
||||
CSRCS += nsh_telnetd.c
|
||||
else
|
||||
CSRCS += nsh_serial.c
|
||||
endif
|
||||
|
||||
AOBJS = $(ASRCS:.S=$(OBJEXT))
|
||||
|
||||
+56
-39
@@ -41,8 +41,7 @@
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
#ifdef CONFIG_EXAMPLES_NSH_TELNET
|
||||
#else
|
||||
#ifdef CONFIG_EXAMPLES_NSH_CONSOLE
|
||||
# include <stdio.h>
|
||||
#endif
|
||||
|
||||
@@ -50,6 +49,10 @@
|
||||
* Definitions
|
||||
****************************************************************************/
|
||||
|
||||
#if !defined(CONFIG_EXAMPLES_NSH_CONSOLE) && !defined(CONFIG_EXAMPLES_NSH_TELNET)
|
||||
# error "No NSH front end defined"
|
||||
#endif
|
||||
|
||||
/* This is the maximum number of arguments that will be accepted for a command */
|
||||
|
||||
#define NSH_MAX_ARGUMENTS 6
|
||||
@@ -89,11 +92,35 @@
|
||||
#undef CONFIG_EXAMPLES_NSH_TELNETD_DUMPBUFFER
|
||||
#undef CONFIG_EXAMPLES_NSH_FULLPATH
|
||||
|
||||
#define nsh_clone(v) (v)->clone(v)
|
||||
#define nsh_addref(v) (v)->addref(v)
|
||||
#define nsh_release(v) (v)->release(v)
|
||||
#define nsh_linebuffer(v) (v)->linebuffer(v)
|
||||
#define nsh_redirect(v,f) (v)->redirect(v,f)
|
||||
#define nsh_undirect(v,d) (v)->undirect(v,d)
|
||||
|
||||
#ifdef CONFIG_CPP_HAVE_VARARGS
|
||||
# define nsh_output(v, fmt...) (v)->output(v, ##fmt)
|
||||
#else
|
||||
# define nsh_output vtbl->output
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Public Types
|
||||
****************************************************************************/
|
||||
|
||||
typedef void (*cmd_t)(FAR void *handle, int argc, char **argv);
|
||||
struct nsh_vtbl_s
|
||||
{
|
||||
FAR struct nsh_vtbl_s *(*clone)(FAR struct nsh_vtbl_s *vtbl);
|
||||
void (*addref)(FAR struct nsh_vtbl_s *vtbl);
|
||||
void (*release)(FAR struct nsh_vtbl_s *vtbl);
|
||||
int (*output)(FAR struct nsh_vtbl_s *vtbl, const char *fmt, ...);
|
||||
FAR char *(*linebuffer)(FAR struct nsh_vtbl_s *vtbl);
|
||||
FAR void *(*redirect)(FAR struct nsh_vtbl_s *vtbl, int fd);
|
||||
void (*undirect)(FAR struct nsh_vtbl_s *vtbl, FAR void *direct);
|
||||
};
|
||||
|
||||
typedef void (*cmd_t)(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv);
|
||||
|
||||
/****************************************************************************
|
||||
* Public Data
|
||||
@@ -115,67 +142,57 @@ extern const char g_fmtcmdoutofmemory[];
|
||||
|
||||
/* Message handler */
|
||||
|
||||
extern int nsh_parse(FAR void *handle, char *cmdline);
|
||||
extern int nsh_parse(FAR struct nsh_vtbl_s *vtbl, char *cmdline);
|
||||
|
||||
/* I/O interfaces */
|
||||
|
||||
extern int nsh_main(void);
|
||||
extern int nsh_output(FAR void *handle, const char *fmt, ...);
|
||||
extern FAR char *nsh_linebuffer(FAR void *handle);
|
||||
#ifdef CONFIG_EXAMPLES_NSH_CONSOLE
|
||||
extern int nsh_consolemain(int argc, char *argv[]);
|
||||
#endif
|
||||
|
||||
#ifndef CONFIG_EXAMPLES_NSH_TELNET /* Not yet supported on telnetd interface */
|
||||
extern FAR void *nsh_clone(FAR void *handle);
|
||||
extern void nsh_addref(FAR void *handle);
|
||||
extern void nsh_release(FAR void *handle);
|
||||
extern void *nsh_redirect(int fd);
|
||||
extern void nsh_restore(void *direct);
|
||||
#else
|
||||
# define nsh_clone(handle) (handle)
|
||||
# define nsh_addref(handle)
|
||||
# define nsh_release(handle);
|
||||
# define nsh_redirect(fd) (NULL);
|
||||
# define nsh_restore(direct)
|
||||
#ifdef CONFIG_EXAMPLES_NSH_TELNET
|
||||
extern int nsh_telnetmain(int argc, char *argv[]);
|
||||
#endif
|
||||
|
||||
/* Shell command handlers */
|
||||
|
||||
extern void cmd_echo(FAR void *handle, int argc, char **argv);
|
||||
extern void cmd_exec(FAR void *handle, int argc, char **argv);
|
||||
extern void cmd_exit(FAR void *handle, int argc, char **argv);
|
||||
extern void cmd_ps(FAR void *handle, int argc, char **argv);
|
||||
extern void cmd_echo(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv);
|
||||
extern void cmd_exec(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv);
|
||||
extern void cmd_exit(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv);
|
||||
extern void cmd_ps(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv);
|
||||
|
||||
#if CONFIG_NFILE_DESCRIPTORS > 0
|
||||
extern void cmd_cat(FAR void *handle, int argc, char **argv);
|
||||
extern void cmd_cp(FAR void *handle, int argc, char **argv);
|
||||
extern void cmd_ls(FAR void *handle, int argc, char **argv);
|
||||
extern void cmd_cat(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv);
|
||||
extern void cmd_cp(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv);
|
||||
extern void cmd_ls(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv);
|
||||
# if CONFIG_NFILE_STREAMS > 0
|
||||
extern void cmd_sh(FAR void *handle, int argc, char **argv);
|
||||
extern void cmd_sh(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv);
|
||||
# endif /* CONFIG_NFILE_STREAMS */
|
||||
# ifndef CONFIG_DISABLE_MOUNTPOINT
|
||||
extern void cmd_mkdir(FAR void *handle, int argc, char **argv);
|
||||
extern void cmd_mkfifo(FAR void *handle, int argc, char **argv);
|
||||
extern void cmd_rm(FAR void *handle, int argc, char **argv);
|
||||
extern void cmd_rmdir(FAR void *handle, int argc, char **argv);
|
||||
extern void cmd_mkdir(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv);
|
||||
extern void cmd_mkfifo(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv);
|
||||
extern void cmd_rm(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv);
|
||||
extern void cmd_rmdir(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv);
|
||||
# ifdef CONFIG_FS_FAT
|
||||
extern void cmd_mkfatfs(FAR void *handle, int argc, char **argv);
|
||||
extern void cmd_mount(FAR void *handle, int argc, char **argv);
|
||||
extern void cmd_umount(FAR void *handle, int argc, char **argv);
|
||||
extern void cmd_mkfatfs(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv);
|
||||
extern void cmd_mount(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv);
|
||||
extern void cmd_umount(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv);
|
||||
# endif /* CONFIG_FS_FAT */
|
||||
# endif /* !CONFIG_DISABLE_MOUNTPOINT */
|
||||
#endif /* CONFIG_NFILE_DESCRIPTORS */
|
||||
|
||||
#if defined(CONFIG_NET) && CONFIG_NSOCKET_DESCRIPTORS > 0
|
||||
extern void cmd_ifconfig(FAR void *handle, int argc, char **argv);
|
||||
extern void cmd_ifconfig(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv);
|
||||
#endif
|
||||
|
||||
#ifndef CONFIG_DISABLE_ENVIRON
|
||||
extern void cmd_set(FAR void *handle, int argc, char **argv);
|
||||
extern void cmd_unset(FAR void *handle, int argc, char **argv);
|
||||
extern void cmd_set(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv);
|
||||
extern void cmd_unset(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv);
|
||||
#endif /* CONFIG_DISABLE_ENVIRON */
|
||||
|
||||
#ifndef CONFIG_DISABLE_SIGNALS
|
||||
extern void cmd_sleep(FAR void *handle, int argc, char **argv);
|
||||
extern void cmd_usleep(FAR void *handle, int argc, char **argv);
|
||||
extern void cmd_sleep(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv);
|
||||
extern void cmd_usleep(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv);
|
||||
#endif /* CONFIG_DISABLE_SIGNALS */
|
||||
|
||||
#endif /* __NSH_H */
|
||||
|
||||
@@ -79,7 +79,7 @@
|
||||
* Name: cmd_echo
|
||||
****************************************************************************/
|
||||
|
||||
void cmd_echo(FAR void *handle, int argc, char **argv)
|
||||
void cmd_echo(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv)
|
||||
{
|
||||
int i;
|
||||
|
||||
@@ -97,16 +97,16 @@ void cmd_echo(FAR void *handle, int argc, char **argv)
|
||||
char *value = getenv(argv[i]+1);
|
||||
if (value)
|
||||
{
|
||||
nsh_output(handle, "%s ", value);
|
||||
nsh_output(vtbl, "%s ", value);
|
||||
}
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
nsh_output(handle, "%s ", argv[i]);
|
||||
nsh_output(vtbl, "%s ", argv[i]);
|
||||
}
|
||||
}
|
||||
nsh_output(handle, "\n");
|
||||
nsh_output(vtbl, "\n");
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
@@ -114,11 +114,11 @@ void cmd_echo(FAR void *handle, int argc, char **argv)
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef CONFIG_DISABLE_ENVIRON
|
||||
void cmd_set(FAR void *handle, int argc, char **argv)
|
||||
void cmd_set(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv)
|
||||
{
|
||||
if (setenv(argv[1], argv[2], TRUE) < 0)
|
||||
{
|
||||
nsh_output(handle, g_fmtcmdfailed, argv[0], "setenv", NSH_ERRNO);
|
||||
nsh_output(vtbl, g_fmtcmdfailed, argv[0], "setenv", NSH_ERRNO);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -128,11 +128,11 @@ void cmd_set(FAR void *handle, int argc, char **argv)
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef CONFIG_DISABLE_ENVIRON
|
||||
void cmd_unset(FAR void *handle, int argc, char **argv)
|
||||
void cmd_unset(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv)
|
||||
{
|
||||
if (unsetenv(argv[1]) < 0)
|
||||
{
|
||||
nsh_output(handle, g_fmtcmdfailed, argv[0], "unsetenv", NSH_ERRNO);
|
||||
nsh_output(vtbl, g_fmtcmdfailed, argv[0], "unsetenv", NSH_ERRNO);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
+56
-56
@@ -93,7 +93,7 @@
|
||||
* Private Types
|
||||
****************************************************************************/
|
||||
|
||||
typedef int (*direntry_handler_t)(FAR void *, const char *, struct dirent *, void *);
|
||||
typedef int (*direntry_handler_t)(FAR struct nsh_vtbl_s *, const char *, struct dirent *, void *);
|
||||
|
||||
/****************************************************************************
|
||||
* Private Function Prototypes
|
||||
@@ -105,7 +105,7 @@ typedef int (*direntry_handler_t)(FAR void *, const char *, struct dirent *, voi
|
||||
|
||||
/* Common buffer for file I/O. Note the use of this common buffer precludes
|
||||
* multiple copies of NSH running concurrently. It should be allocated per
|
||||
* NSH instance and retained in the "handle" as is done for the telnet
|
||||
* NSH instance and retained in the "vtbl" as is done for the telnet
|
||||
* connection.
|
||||
*/
|
||||
|
||||
@@ -161,7 +161,7 @@ static char *getdirpath(const char *path, const char *file)
|
||||
****************************************************************************/
|
||||
|
||||
#if CONFIG_NFILE_DESCRIPTORS > 0
|
||||
static int foreach_direntry(FAR void *handle, const char *cmd, const char *dirpath,
|
||||
static int foreach_direntry(FAR struct nsh_vtbl_s *vtbl, const char *cmd, const char *dirpath,
|
||||
direntry_handler_t handler, void *pvarg)
|
||||
{
|
||||
DIR *dirp;
|
||||
@@ -181,7 +181,7 @@ static int foreach_direntry(FAR void *handle, const char *cmd, const char *dirpa
|
||||
{
|
||||
/* Failed to open the directory */
|
||||
|
||||
nsh_output(handle, g_fmtnosuch, cmd, "directory", dirpath);
|
||||
nsh_output(vtbl, g_fmtnosuch, cmd, "directory", dirpath);
|
||||
return ERROR;
|
||||
}
|
||||
|
||||
@@ -199,7 +199,7 @@ static int foreach_direntry(FAR void *handle, const char *cmd, const char *dirpa
|
||||
|
||||
/* Call the handler with this directory entry */
|
||||
|
||||
if (handler(handle, dirpath, entryp, pvarg) < 0)
|
||||
if (handler(vtbl, dirpath, entryp, pvarg) < 0)
|
||||
{
|
||||
/* The handler reported a problem */
|
||||
|
||||
@@ -218,7 +218,7 @@ static int foreach_direntry(FAR void *handle, const char *cmd, const char *dirpa
|
||||
****************************************************************************/
|
||||
|
||||
#if CONFIG_NFILE_DESCRIPTORS > 0
|
||||
static int ls_handler(FAR void *handle, const char *dirpath, struct dirent *entryp, void *pvarg)
|
||||
static int ls_handler(FAR struct nsh_vtbl_s *vtbl, const char *dirpath, struct dirent *entryp, void *pvarg)
|
||||
{
|
||||
unsigned int lsflags = (unsigned int)pvarg;
|
||||
int ret;
|
||||
@@ -236,7 +236,7 @@ static int ls_handler(FAR void *handle, const char *dirpath, struct dirent *entr
|
||||
free(fullpath);
|
||||
if (ret != 0)
|
||||
{
|
||||
nsh_output(handle, g_fmtcmdfailed, "ls", "stat", NSH_ERRNO);
|
||||
nsh_output(vtbl, g_fmtcmdfailed, "ls", "stat", NSH_ERRNO);
|
||||
return OK;
|
||||
}
|
||||
|
||||
@@ -301,30 +301,30 @@ static int ls_handler(FAR void *handle, const char *dirpath, struct dirent *entr
|
||||
details[9]='x';
|
||||
}
|
||||
|
||||
nsh_output(handle, " %s", details);
|
||||
nsh_output(vtbl, " %s", details);
|
||||
}
|
||||
|
||||
if ((lsflags & LSFLAGS_SIZE) != 0)
|
||||
{
|
||||
nsh_output(handle, "%8d", buf.st_size);
|
||||
nsh_output(vtbl, "%8d", buf.st_size);
|
||||
}
|
||||
}
|
||||
|
||||
/* then provide the filename that is common to normal and verbose output */
|
||||
|
||||
#ifdef CONFIG_EXAMPLES_NSH_FULLPATH
|
||||
nsh_output(handle, " %s/%s", arg, entryp->d_name);
|
||||
nsh_output(vtbl, " %s/%s", arg, entryp->d_name);
|
||||
#else
|
||||
nsh_output(handle, " %s", entryp->d_name);
|
||||
nsh_output(vtbl, " %s", entryp->d_name);
|
||||
#endif
|
||||
|
||||
if (DIRENT_ISDIRECTORY(entryp->d_type))
|
||||
{
|
||||
nsh_output(handle, "/\n");
|
||||
nsh_output(vtbl, "/\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
nsh_output(handle, "\n");
|
||||
nsh_output(vtbl, "\n");
|
||||
}
|
||||
return OK;
|
||||
}
|
||||
@@ -335,7 +335,7 @@ static int ls_handler(FAR void *handle, const char *dirpath, struct dirent *entr
|
||||
****************************************************************************/
|
||||
|
||||
#if CONFIG_NFILE_DESCRIPTORS > 0
|
||||
static int ls_recursive(FAR void *handle, const char *dirpath, struct dirent *entryp, void *pvarg)
|
||||
static int ls_recursive(FAR struct nsh_vtbl_s *vtbl, const char *dirpath, struct dirent *entryp, void *pvarg)
|
||||
{
|
||||
/* Is this entry a directory? */
|
||||
|
||||
@@ -348,12 +348,12 @@ static int ls_recursive(FAR void *handle, const char *dirpath, struct dirent *en
|
||||
|
||||
/* List the directory contents */
|
||||
|
||||
nsh_output(handle, "%s:\n", newpath);
|
||||
foreach_direntry(handle, "ls", newpath, ls_handler, pvarg);
|
||||
nsh_output(vtbl, "%s:\n", newpath);
|
||||
foreach_direntry(vtbl, "ls", newpath, ls_handler, pvarg);
|
||||
|
||||
/* Then recurse to list each directory within the directory */
|
||||
|
||||
foreach_direntry(handle, "ls", newpath, ls_recursive, pvarg);
|
||||
foreach_direntry(vtbl, "ls", newpath, ls_recursive, pvarg);
|
||||
free(newpath);
|
||||
}
|
||||
return OK;
|
||||
@@ -369,7 +369,7 @@ static int ls_recursive(FAR void *handle, const char *dirpath, struct dirent *en
|
||||
****************************************************************************/
|
||||
|
||||
#if CONFIG_NFILE_DESCRIPTORS > 0
|
||||
void cmd_cat(FAR void *handle, int argc, char **argv)
|
||||
void cmd_cat(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv)
|
||||
{
|
||||
char buffer[IOBUFFERSIZE];
|
||||
|
||||
@@ -378,7 +378,7 @@ void cmd_cat(FAR void *handle, int argc, char **argv)
|
||||
int fd = open(argv[1], O_RDONLY);
|
||||
if (fd < 0)
|
||||
{
|
||||
nsh_output(handle, g_fmtcmdfailed, argv[0], "open", NSH_ERRNO);
|
||||
nsh_output(vtbl, g_fmtcmdfailed, argv[0], "open", NSH_ERRNO);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -396,7 +396,7 @@ void cmd_cat(FAR void *handle, int argc, char **argv)
|
||||
|
||||
if (errno != EINTR)
|
||||
{
|
||||
nsh_output(handle, g_fmtcmdfailed, argv[0], "read", NSH_ERRNO);
|
||||
nsh_output(vtbl, g_fmtcmdfailed, argv[0], "read", NSH_ERRNO);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -416,7 +416,7 @@ void cmd_cat(FAR void *handle, int argc, char **argv)
|
||||
|
||||
if (errno != EINTR)
|
||||
{
|
||||
nsh_output(handle, g_fmtcmdfailed, argv[0], "write", NSH_ERRNO);
|
||||
nsh_output(vtbl, g_fmtcmdfailed, argv[0], "write", NSH_ERRNO);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -444,7 +444,7 @@ void cmd_cat(FAR void *handle, int argc, char **argv)
|
||||
****************************************************************************/
|
||||
|
||||
#if CONFIG_NFILE_DESCRIPTORS > 0
|
||||
void cmd_cp(FAR void *handle, int argc, char **argv)
|
||||
void cmd_cp(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv)
|
||||
{
|
||||
struct stat buf;
|
||||
char *fullpath = NULL;
|
||||
@@ -459,7 +459,7 @@ void cmd_cp(FAR void *handle, int argc, char **argv)
|
||||
rdfd = open(argv[1], O_RDONLY);
|
||||
if (rdfd < 0)
|
||||
{
|
||||
nsh_output(handle, g_fmtcmdfailed, argv[0], "open", NSH_ERRNO);
|
||||
nsh_output(vtbl, g_fmtcmdfailed, argv[0], "open", NSH_ERRNO);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -481,7 +481,7 @@ void cmd_cp(FAR void *handle, int argc, char **argv)
|
||||
fullpath = getdirpath(argv[2], basename(argv[1]) );
|
||||
if (!fullpath)
|
||||
{
|
||||
nsh_output(handle, g_fmtcmdoutofmemory, argv[0]);
|
||||
nsh_output(vtbl, g_fmtcmdoutofmemory, argv[0]);
|
||||
goto out_with_rdfd;
|
||||
}
|
||||
|
||||
@@ -501,7 +501,7 @@ void cmd_cp(FAR void *handle, int argc, char **argv)
|
||||
wrfd = open(wrpath, oflags, 0666);
|
||||
if (wrfd < 0)
|
||||
{
|
||||
nsh_output(handle, g_fmtcmdfailed, argv[0], "open", NSH_ERRNO);
|
||||
nsh_output(vtbl, g_fmtcmdfailed, argv[0], "open", NSH_ERRNO);
|
||||
goto out_with_fullpath;
|
||||
}
|
||||
|
||||
@@ -525,7 +525,7 @@ void cmd_cp(FAR void *handle, int argc, char **argv)
|
||||
{
|
||||
/* Read error */
|
||||
|
||||
nsh_output(handle, g_fmtcmdfailed, argv[0], "read", NSH_ERRNO);
|
||||
nsh_output(vtbl, g_fmtcmdfailed, argv[0], "read", NSH_ERRNO);
|
||||
goto out_with_wrfd;
|
||||
}
|
||||
}
|
||||
@@ -542,7 +542,7 @@ void cmd_cp(FAR void *handle, int argc, char **argv)
|
||||
{
|
||||
/* Read error */
|
||||
|
||||
nsh_output(handle, g_fmtcmdfailed, argv[0], "write", NSH_ERRNO);
|
||||
nsh_output(vtbl, g_fmtcmdfailed, argv[0], "write", NSH_ERRNO);
|
||||
goto out_with_wrfd;
|
||||
}
|
||||
}
|
||||
@@ -568,7 +568,7 @@ out_with_rdfd:
|
||||
****************************************************************************/
|
||||
|
||||
#if CONFIG_NFILE_DESCRIPTORS > 0
|
||||
void cmd_ls(FAR void *handle, int argc, char **argv)
|
||||
void cmd_ls(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv)
|
||||
{
|
||||
unsigned int lsflags = 0;
|
||||
int ret;
|
||||
@@ -594,7 +594,7 @@ void cmd_ls(FAR void *handle, int argc, char **argv)
|
||||
|
||||
case '?':
|
||||
default:
|
||||
nsh_output(handle, g_fmtarginvalid, argv[0]);
|
||||
nsh_output(vtbl, g_fmtarginvalid, argv[0]);
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -603,24 +603,24 @@ void cmd_ls(FAR void *handle, int argc, char **argv)
|
||||
|
||||
if (optind + 1 < argc)
|
||||
{
|
||||
nsh_output(handle, g_fmttoomanyargs, argv[0]);
|
||||
nsh_output(vtbl, g_fmttoomanyargs, argv[0]);
|
||||
return;
|
||||
}
|
||||
else if (optind + 1 > argc)
|
||||
{
|
||||
nsh_output(handle, g_fmtargrequired, argv[0]);
|
||||
nsh_output(vtbl, g_fmtargrequired, argv[0]);
|
||||
return;
|
||||
}
|
||||
|
||||
/* List the directory contents */
|
||||
|
||||
nsh_output(handle, "%s:\n", argv[optind]);
|
||||
ret = foreach_direntry(handle, "ls", argv[optind], ls_handler, (void*)lsflags);
|
||||
nsh_output(vtbl, "%s:\n", argv[optind]);
|
||||
ret = foreach_direntry(vtbl, "ls", argv[optind], ls_handler, (void*)lsflags);
|
||||
if (ret == OK && (lsflags & LSFLAGS_RECURSIVE) != 0)
|
||||
{
|
||||
/* Then recurse to list each directory within the directory */
|
||||
|
||||
ret = foreach_direntry(handle, "ls", argv[optind], ls_recursive, (void*)lsflags);
|
||||
ret = foreach_direntry(vtbl, "ls", argv[optind], ls_recursive, (void*)lsflags);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -630,12 +630,12 @@ void cmd_ls(FAR void *handle, int argc, char **argv)
|
||||
****************************************************************************/
|
||||
|
||||
#if !defined(CONFIG_DISABLE_MOUNTPOINT) && CONFIG_NFILE_DESCRIPTORS > 0
|
||||
void cmd_mkdir(FAR void *handle, int argc, char **argv)
|
||||
void cmd_mkdir(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv)
|
||||
{
|
||||
int result = mkdir(argv[1], 0777);
|
||||
if ( result < 0)
|
||||
{
|
||||
nsh_output(handle, g_fmtcmdfailed, argv[0], "mkdir", NSH_ERRNO);
|
||||
nsh_output(vtbl, g_fmtcmdfailed, argv[0], "mkdir", NSH_ERRNO);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -645,13 +645,13 @@ void cmd_mkdir(FAR void *handle, int argc, char **argv)
|
||||
****************************************************************************/
|
||||
|
||||
#if !defined(CONFIG_DISABLE_MOUNTPOINT) && CONFIG_NFILE_DESCRIPTORS > 0 && defined(CONFIG_FS_FAT)
|
||||
void cmd_mkfatfs(FAR void *handle, int argc, char **argv)
|
||||
void cmd_mkfatfs(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv)
|
||||
{
|
||||
struct fat_format_s fmt = FAT_FORMAT_INITIALIZER;
|
||||
int result = mkfatfs(argv[1], &fmt);
|
||||
if ( result < 0)
|
||||
{
|
||||
nsh_output(handle, g_fmtcmdfailed, argv[0], "mkfatfs", NSH_ERRNO);
|
||||
nsh_output(vtbl, g_fmtcmdfailed, argv[0], "mkfatfs", NSH_ERRNO);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -661,12 +661,12 @@ void cmd_mkfatfs(FAR void *handle, int argc, char **argv)
|
||||
****************************************************************************/
|
||||
|
||||
#if !defined(CONFIG_DISABLE_MOUNTPOINT) && CONFIG_NFILE_DESCRIPTORS > 0
|
||||
void cmd_mkfifo(FAR void *handle, int argc, char **argv)
|
||||
void cmd_mkfifo(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv)
|
||||
{
|
||||
int result = mkfifo(argv[1], 0777);
|
||||
if ( result < 0)
|
||||
{
|
||||
nsh_output(handle, g_fmtcmdfailed, argv[0], "mkfifo", NSH_ERRNO);
|
||||
nsh_output(vtbl, g_fmtcmdfailed, argv[0], "mkfifo", NSH_ERRNO);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -677,7 +677,7 @@ void cmd_mkfifo(FAR void *handle, int argc, char **argv)
|
||||
|
||||
#if !defined(CONFIG_DISABLE_MOUNTPOINT) && CONFIG_NFILE_DESCRIPTORS > 0
|
||||
#ifdef CONFIG_FS_FAT /* Need at least one filesytem in configuration */
|
||||
void cmd_mount(FAR void *handle, int argc, char **argv)
|
||||
void cmd_mount(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv)
|
||||
{
|
||||
char *filesystem = 0;
|
||||
int result;
|
||||
@@ -694,12 +694,12 @@ void cmd_mount(FAR void *handle, int argc, char **argv)
|
||||
break;
|
||||
|
||||
case ':':
|
||||
nsh_output(handle, g_fmtargrequired, argv[0]);
|
||||
nsh_output(vtbl, g_fmtargrequired, argv[0]);
|
||||
return;
|
||||
|
||||
case '?':
|
||||
default:
|
||||
nsh_output(handle, g_fmtarginvalid, argv[0]);
|
||||
nsh_output(vtbl, g_fmtarginvalid, argv[0]);
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -708,12 +708,12 @@ void cmd_mount(FAR void *handle, int argc, char **argv)
|
||||
|
||||
if (optind + 2 < argc)
|
||||
{
|
||||
nsh_output(handle, g_fmttoomanyargs, argv[0]);
|
||||
nsh_output(vtbl, g_fmttoomanyargs, argv[0]);
|
||||
return;
|
||||
}
|
||||
else if (optind + 2 > argc)
|
||||
{
|
||||
nsh_output(handle, g_fmtargrequired, argv[0]);
|
||||
nsh_output(vtbl, g_fmtargrequired, argv[0]);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -721,7 +721,7 @@ void cmd_mount(FAR void *handle, int argc, char **argv)
|
||||
result = mount(argv[optind], argv[optind+1], filesystem, 0, NULL);
|
||||
if ( result < 0)
|
||||
{
|
||||
nsh_output(handle, g_fmtcmdfailed, argv[0], "mount", NSH_ERRNO);
|
||||
nsh_output(vtbl, g_fmtcmdfailed, argv[0], "mount", NSH_ERRNO);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -732,11 +732,11 @@ void cmd_mount(FAR void *handle, int argc, char **argv)
|
||||
****************************************************************************/
|
||||
|
||||
#if !defined(CONFIG_DISABLE_MOUNTPOINT) && CONFIG_NFILE_DESCRIPTORS > 0
|
||||
void cmd_rm(FAR void *handle, int argc, char **argv)
|
||||
void cmd_rm(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv)
|
||||
{
|
||||
if (unlink(argv[1]) < 0)
|
||||
{
|
||||
nsh_output(handle, g_fmtcmdfailed, argv[0], "unlink", NSH_ERRNO);
|
||||
nsh_output(vtbl, g_fmtcmdfailed, argv[0], "unlink", NSH_ERRNO);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -746,11 +746,11 @@ void cmd_rm(FAR void *handle, int argc, char **argv)
|
||||
****************************************************************************/
|
||||
|
||||
#if !defined(CONFIG_DISABLE_MOUNTPOINT) && CONFIG_NFILE_DESCRIPTORS > 0
|
||||
void cmd_rmdir(FAR void *handle, int argc, char **argv)
|
||||
void cmd_rmdir(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv)
|
||||
{
|
||||
if (rmdir(argv[1]) < 0)
|
||||
{
|
||||
nsh_output(handle, g_fmtcmdfailed, argv[0], "rmdir", NSH_ERRNO);
|
||||
nsh_output(vtbl, g_fmtcmdfailed, argv[0], "rmdir", NSH_ERRNO);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -760,7 +760,7 @@ void cmd_rmdir(FAR void *handle, int argc, char **argv)
|
||||
****************************************************************************/
|
||||
|
||||
#if CONFIG_NFILE_DESCRIPTORS > 0 && CONFIG_NFILE_STREAMS > 0
|
||||
void cmd_sh(FAR void *handle, int argc, char **argv)
|
||||
void cmd_sh(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv)
|
||||
{
|
||||
FILE *stream;
|
||||
char *buffer;
|
||||
@@ -768,13 +768,13 @@ void cmd_sh(FAR void *handle, int argc, char **argv)
|
||||
|
||||
/* Get a reference to the common input buffer */
|
||||
|
||||
buffer = nsh_linebuffer(handle);
|
||||
buffer = nsh_linebuffer(vtbl);
|
||||
if (buffer)
|
||||
{
|
||||
stream = fopen(argv[1], "r");
|
||||
if (!stream)
|
||||
{
|
||||
nsh_output(handle, g_fmtcmdfailed, argv[0], "fopen", NSH_ERRNO);
|
||||
nsh_output(vtbl, g_fmtcmdfailed, argv[0], "fopen", NSH_ERRNO);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -791,7 +791,7 @@ void cmd_sh(FAR void *handle, int argc, char **argv)
|
||||
* considerable amount of stack may be used.
|
||||
*/
|
||||
|
||||
(void)nsh_parse(handle, buffer);
|
||||
(void)nsh_parse(vtbl, buffer);
|
||||
}
|
||||
}
|
||||
while(pret);
|
||||
@@ -806,13 +806,13 @@ void cmd_sh(FAR void *handle, int argc, char **argv)
|
||||
|
||||
#if !defined(CONFIG_DISABLE_MOUNTPOINT) && CONFIG_NFILE_DESCRIPTORS > 0
|
||||
#ifdef CONFIG_FS_FAT /* Need at least one filesytem in configuration */
|
||||
void cmd_umount(FAR void *handle, int argc, char **argv)
|
||||
void cmd_umount(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv)
|
||||
{
|
||||
/* Perform the umount */
|
||||
int result = umount(argv[1]);
|
||||
if ( result < 0)
|
||||
{
|
||||
nsh_output(handle, g_fmtcmdfailed, argv[0], "umount", NSH_ERRNO);
|
||||
nsh_output(vtbl, g_fmtcmdfailed, argv[0], "umount", NSH_ERRNO);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
+273
-72
File diff suppressed because it is too large
Load Diff
+51
-50
@@ -1,7 +1,7 @@
|
||||
/****************************************************************************
|
||||
* examples/nsh/nsh_netcmds.c
|
||||
*
|
||||
* Copyright (C) 2007 Gregory Nutt. All rights reserved.
|
||||
* Copyright (C) 2007, 2008 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@@ -14,7 +14,7 @@
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name Gregory Nutt nor the names of its contributors may be
|
||||
* 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.
|
||||
*
|
||||
@@ -86,112 +86,112 @@
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_NET_STATISTICS
|
||||
static inline void uip_statistics(void *handle)
|
||||
static inline void uip_statistics(FAR struct nsh_vtbl_s *vtbl)
|
||||
{
|
||||
nsh_output(handle, "uIP IP ");
|
||||
nsh_output(vtbl, "uIP IP ");
|
||||
#ifdef CONFIG_NET_TCP
|
||||
nsh_output(handle, " TCP");
|
||||
nsh_output(vtbl, " TCP");
|
||||
#endif
|
||||
#ifdef CONFIG_NET_UDP
|
||||
nsh_output(handle, " UDP");
|
||||
nsh_output(vtbl, " UDP");
|
||||
#endif
|
||||
#ifdef CONFIG_NET_ICMP
|
||||
nsh_output(handle, " ICMP");
|
||||
nsh_output(vtbl, " ICMP");
|
||||
#endif
|
||||
nsh_output(handle, "\n");
|
||||
nsh_output(vtbl, "\n");
|
||||
|
||||
/* Received packets */
|
||||
|
||||
nsh_output(handle, "Received %04x",uip_stat.ip.recv);
|
||||
nsh_output(vtbl, "Received %04x",uip_stat.ip.recv);
|
||||
#ifdef CONFIG_NET_TCP
|
||||
nsh_output(handle, " %04x",uip_stat.tcp.recv);
|
||||
nsh_output(vtbl, " %04x",uip_stat.tcp.recv);
|
||||
#endif
|
||||
#ifdef CONFIG_NET_UDP
|
||||
nsh_output(handle, " %04x",uip_stat.udp.recv);
|
||||
nsh_output(vtbl, " %04x",uip_stat.udp.recv);
|
||||
#endif
|
||||
#ifdef CONFIG_NET_ICMP
|
||||
nsh_output(handle, " %04x",uip_stat.icmp.recv);
|
||||
nsh_output(vtbl, " %04x",uip_stat.icmp.recv);
|
||||
#endif
|
||||
nsh_output(handle, "\n");
|
||||
nsh_output(vtbl, "\n");
|
||||
|
||||
/* Dropped packets */
|
||||
|
||||
nsh_output(handle, "Dropped %04x",uip_stat.ip.drop);
|
||||
nsh_output(vtbl, "Dropped %04x",uip_stat.ip.drop);
|
||||
#ifdef CONFIG_NET_TCP
|
||||
nsh_output(handle, " %04x",uip_stat.tcp.drop);
|
||||
nsh_output(vtbl, " %04x",uip_stat.tcp.drop);
|
||||
#endif
|
||||
#ifdef CONFIG_NET_UDP
|
||||
nsh_output(handle, " %04x",uip_stat.udp.drop);
|
||||
nsh_output(vtbl, " %04x",uip_stat.udp.drop);
|
||||
#endif
|
||||
#ifdef CONFIG_NET_ICMP
|
||||
nsh_output(handle, " %04x",uip_stat.icmp.drop);
|
||||
nsh_output(vtbl, " %04x",uip_stat.icmp.drop);
|
||||
#endif
|
||||
nsh_output(handle, "\n");
|
||||
nsh_output(vtbl, "\n");
|
||||
|
||||
nsh_output(handle, " IP VHL: %04x HBL: %04x\n",
|
||||
nsh_output(vtbl, " IP VHL: %04x HBL: %04x\n",
|
||||
uip_stat.ip.vhlerr, uip_stat.ip.hblenerr);
|
||||
nsh_output(handle, " LBL: %04x Frg: %04x\n",
|
||||
nsh_output(vtbl, " LBL: %04x Frg: %04x\n",
|
||||
uip_stat.ip.lblenerr, uip_stat.ip.fragerr);
|
||||
|
||||
nsh_output(handle, " Checksum %04x",uip_stat.ip.chkerr);
|
||||
nsh_output(vtbl, " Checksum %04x",uip_stat.ip.chkerr);
|
||||
#ifdef CONFIG_NET_TCP
|
||||
nsh_output(handle, " %04x",uip_stat.tcp.chkerr);
|
||||
nsh_output(vtbl, " %04x",uip_stat.tcp.chkerr);
|
||||
#endif
|
||||
#ifdef CONFIG_NET_UDP
|
||||
nsh_output(handle, " %04x",uip_stat.udp.chkerr);
|
||||
nsh_output(vtbl, " %04x",uip_stat.udp.chkerr);
|
||||
#endif
|
||||
#ifdef CONFIG_NET_ICMP
|
||||
nsh_output(handle, " ----");
|
||||
nsh_output(vtbl, " ----");
|
||||
#endif
|
||||
nsh_output(handle, "\n");
|
||||
nsh_output(vtbl, "\n");
|
||||
|
||||
#ifdef CONFIG_NET_TCP
|
||||
nsh_output(handle, " TCP ACK: %04x SYN: %04x\n",
|
||||
nsh_output(vtbl, " TCP ACK: %04x SYN: %04x\n",
|
||||
uip_stat.tcp.ackerr, uip_stat.tcp.syndrop);
|
||||
nsh_output(handle, " RST: %04x %04x\n",
|
||||
nsh_output(vtbl, " RST: %04x %04x\n",
|
||||
uip_stat.tcp.rst, uip_stat.tcp.synrst);
|
||||
#endif
|
||||
|
||||
nsh_output(handle, " Type %04x",uip_stat.ip.protoerr);
|
||||
nsh_output(vtbl, " Type %04x",uip_stat.ip.protoerr);
|
||||
#ifdef CONFIG_NET_TCP
|
||||
nsh_output(handle, " ----");
|
||||
nsh_output(vtbl, " ----");
|
||||
#endif
|
||||
#ifdef CONFIG_NET_UDP
|
||||
nsh_output(handle, " ----");
|
||||
nsh_output(vtbl, " ----");
|
||||
#endif
|
||||
#ifdef CONFIG_NET_ICMP
|
||||
nsh_output(handle, " %04x",uip_stat.icmp.typeerr);
|
||||
nsh_output(vtbl, " %04x",uip_stat.icmp.typeerr);
|
||||
#endif
|
||||
nsh_output(handle, "\n");
|
||||
nsh_output(vtbl, "\n");
|
||||
|
||||
/* Sent packets */
|
||||
|
||||
nsh_output(handle, "Sent ----",uip_stat.ip.sent);
|
||||
nsh_output(vtbl, "Sent ----",uip_stat.ip.sent);
|
||||
#ifdef CONFIG_NET_TCP
|
||||
nsh_output(handle, " %04x",uip_stat.tcp.sent);
|
||||
nsh_output(vtbl, " %04x",uip_stat.tcp.sent);
|
||||
#endif
|
||||
#ifdef CONFIG_NET_UDP
|
||||
nsh_output(handle, " %04x",uip_stat.udp.sent);
|
||||
nsh_output(vtbl, " %04x",uip_stat.udp.sent);
|
||||
#endif
|
||||
#ifdef CONFIG_NET_ICMP
|
||||
nsh_output(handle, " %04x",uip_stat.icmp.sent);
|
||||
nsh_output(vtbl, " %04x",uip_stat.icmp.sent);
|
||||
#endif
|
||||
nsh_output(handle, "\n");
|
||||
nsh_output(vtbl, "\n");
|
||||
|
||||
#ifdef CONFIG_NET_TCP
|
||||
nsh_output(handle, " Rexmit ---- %04x",uip_stat.tcp.rexmit);
|
||||
nsh_output(vtbl, " Rexmit ---- %04x",uip_stat.tcp.rexmit);
|
||||
#ifdef CONFIG_NET_UDP
|
||||
nsh_output(handle, " ----");
|
||||
nsh_output(vtbl, " ----");
|
||||
#endif
|
||||
#ifdef CONFIG_NET_ICMP
|
||||
nsh_output(handle, " ----");
|
||||
nsh_output(vtbl, " ----");
|
||||
#endif
|
||||
nsh_output(handle, "\n");
|
||||
nsh_output(vtbl, "\n");
|
||||
#endif
|
||||
nsh_output(handle, "\n");
|
||||
nsh_output(vtbl, "\n");
|
||||
}
|
||||
#else
|
||||
# define uip_statistics(handle)
|
||||
# define uip_statistics(vtbl)
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
@@ -200,15 +200,16 @@ static inline void uip_statistics(void *handle)
|
||||
|
||||
int ifconfig_callback(FAR struct uip_driver_s *dev, void *arg)
|
||||
{
|
||||
struct nsh_vtbl_s *vtbl = (struct nsh_vtbl_s*)arg;
|
||||
struct in_addr addr;
|
||||
|
||||
nsh_output(arg, "%s\tHWaddr %s\n", dev->d_ifname, ether_ntoa(&dev->d_mac));
|
||||
nsh_output(vtbl, "%s\tHWaddr %s\n", dev->d_ifname, ether_ntoa(&dev->d_mac));
|
||||
addr.s_addr = dev->d_ipaddr;
|
||||
nsh_output(arg, "\tIPaddr:%s ", inet_ntoa(addr));
|
||||
nsh_output(vtbl, "\tIPaddr:%s ", inet_ntoa(addr));
|
||||
addr.s_addr = dev->d_draddr;
|
||||
nsh_output(arg, "DRaddr:%s ", inet_ntoa(addr));
|
||||
nsh_output(vtbl, "DRaddr:%s ", inet_ntoa(addr));
|
||||
addr.s_addr = dev->d_netmask;
|
||||
nsh_output(arg, "Mask:%s\n\n", inet_ntoa(addr));
|
||||
nsh_output(vtbl, "Mask:%s\n\n", inet_ntoa(addr));
|
||||
return OK;
|
||||
}
|
||||
|
||||
@@ -220,10 +221,10 @@ int ifconfig_callback(FAR struct uip_driver_s *dev, void *arg)
|
||||
* Name: cmd_ifconfig
|
||||
****************************************************************************/
|
||||
|
||||
void cmd_ifconfig(FAR void *handle, int argc, char **argv)
|
||||
void cmd_ifconfig(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv)
|
||||
{
|
||||
netdev_foreach(ifconfig_callback, handle);
|
||||
uip_statistics(handle);
|
||||
netdev_foreach(ifconfig_callback, vtbl);
|
||||
uip_statistics(vtbl);
|
||||
}
|
||||
|
||||
#endif /* CONFIG_NET && CONFIG_NSOCKET_DESCRIPTORS */
|
||||
|
||||
+16
-15
@@ -96,11 +96,12 @@ static const char *g_statenames[] =
|
||||
|
||||
static void ps_task(FAR _TCB *tcb, FAR void *arg)
|
||||
{
|
||||
struct nsh_vtbl_s *vtbl = (struct nsh_vtbl_s*)arg;
|
||||
int i;
|
||||
|
||||
/* Show task status */
|
||||
|
||||
nsh_output(arg, "%5d %3d %4s %7s%c%c %8s ",
|
||||
nsh_output(vtbl, "%5d %3d %4s %7s%c%c %8s ",
|
||||
tcb->pid, tcb->sched_priority,
|
||||
tcb->flags & TCB_FLAG_ROUND_ROBIN ? "RR " : "FIFO",
|
||||
tcb->flags & TCB_FLAG_PTHREAD ? "PTHREAD" : "TASK ",
|
||||
@@ -110,13 +111,13 @@ static void ps_task(FAR _TCB *tcb, FAR void *arg)
|
||||
|
||||
/* Show task name and arguments */
|
||||
|
||||
nsh_output(arg, "%s(", tcb->argv[0]);
|
||||
nsh_output(vtbl, "%s(", tcb->argv[0]);
|
||||
|
||||
/* Special case 1st argument (no comma) */
|
||||
|
||||
if (tcb->argv[1])
|
||||
{
|
||||
nsh_output(arg, "%p", tcb->argv[1]);
|
||||
nsh_output(vtbl, "%p", tcb->argv[1]);
|
||||
}
|
||||
|
||||
/* Then any additional arguments */
|
||||
@@ -124,10 +125,10 @@ static void ps_task(FAR _TCB *tcb, FAR void *arg)
|
||||
#if CONFIG_MAX_TASK_ARGS > 2
|
||||
for (i = 2; i <= CONFIG_MAX_TASK_ARGS && tcb->argv[i]; i++)
|
||||
{
|
||||
nsh_output(arg, ", %p", tcb->argv[i]);
|
||||
nsh_output(vtbl, ", %p", tcb->argv[i]);
|
||||
}
|
||||
#endif
|
||||
nsh_output(arg, ")\n");
|
||||
nsh_output(vtbl, ")\n");
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
@@ -138,7 +139,7 @@ static void ps_task(FAR _TCB *tcb, FAR void *arg)
|
||||
* Name: cmd_exec
|
||||
****************************************************************************/
|
||||
|
||||
void cmd_exec(FAR void *handle, int argc, char **argv)
|
||||
void cmd_exec(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv)
|
||||
{
|
||||
char *endptr;
|
||||
long addr;
|
||||
@@ -146,11 +147,11 @@ void cmd_exec(FAR void *handle, int argc, char **argv)
|
||||
addr = strtol(argv[1], &endptr, 0);
|
||||
if (!addr || endptr == argv[1] || *endptr != '\0')
|
||||
{
|
||||
nsh_output(handle, g_fmtarginvalid, argv[0]);
|
||||
nsh_output(vtbl, g_fmtarginvalid, argv[0]);
|
||||
return;
|
||||
}
|
||||
|
||||
nsh_output(handle, "Calling %p\n", (exec_t)addr);
|
||||
nsh_output(vtbl, "Calling %p\n", (exec_t)addr);
|
||||
((exec_t)addr)();
|
||||
}
|
||||
|
||||
@@ -158,10 +159,10 @@ void cmd_exec(FAR void *handle, int argc, char **argv)
|
||||
* Name: cmd_ps
|
||||
****************************************************************************/
|
||||
|
||||
void cmd_ps(FAR void *handle, int argc, char **argv)
|
||||
void cmd_ps(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv)
|
||||
{
|
||||
nsh_output(handle, "PID PRI SCHD TYPE NP STATE NAME\n");
|
||||
sched_foreach(ps_task, handle);
|
||||
nsh_output(vtbl, "PID PRI SCHD TYPE NP STATE NAME\n");
|
||||
sched_foreach(ps_task, vtbl);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
@@ -169,7 +170,7 @@ void cmd_ps(FAR void *handle, int argc, char **argv)
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef CONFIG_DISABLE_SIGNALS
|
||||
void cmd_sleep(FAR void *handle, int argc, char **argv)
|
||||
void cmd_sleep(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv)
|
||||
{
|
||||
char *endptr;
|
||||
long secs;
|
||||
@@ -177,7 +178,7 @@ void cmd_sleep(FAR void *handle, int argc, char **argv)
|
||||
secs = strtol(argv[1], &endptr, 0);
|
||||
if (!secs || endptr == argv[1] || *endptr != '\0')
|
||||
{
|
||||
nsh_output(handle, g_fmtarginvalid, argv[0]);
|
||||
nsh_output(vtbl, g_fmtarginvalid, argv[0]);
|
||||
return;
|
||||
}
|
||||
sleep(secs);
|
||||
@@ -189,7 +190,7 @@ void cmd_sleep(FAR void *handle, int argc, char **argv)
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef CONFIG_DISABLE_SIGNALS
|
||||
void cmd_usleep(FAR void *handle, int argc, char **argv)
|
||||
void cmd_usleep(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv)
|
||||
{
|
||||
char *endptr;
|
||||
long usecs;
|
||||
@@ -197,7 +198,7 @@ void cmd_usleep(FAR void *handle, int argc, char **argv)
|
||||
usecs = strtol(argv[1], &endptr, 0);
|
||||
if (!usecs || endptr == argv[1] || *endptr != '\0')
|
||||
{
|
||||
nsh_output(handle, g_fmtarginvalid, argv[0]);
|
||||
nsh_output(vtbl, g_fmtarginvalid, argv[0]);
|
||||
return;
|
||||
}
|
||||
usleep(usecs);
|
||||
|
||||
+216
-91
@@ -42,6 +42,7 @@
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
#include <stdarg.h>
|
||||
|
||||
@@ -57,7 +58,10 @@
|
||||
|
||||
struct serial_s
|
||||
{
|
||||
int ss_refs; /* Reference counts on the intance */
|
||||
struct nsh_vtbl_s vtbl;
|
||||
int ss_refs; /* Reference counts on the instance */
|
||||
int ss_fd; /* Re-direct file descriptor */
|
||||
FILE *ss_stream; /* Redirect file descriptor */
|
||||
char ss_line[CONFIG_EXAMPLES_NSH_LINELEN];
|
||||
};
|
||||
|
||||
@@ -65,6 +69,14 @@ struct serial_s
|
||||
* Private Function Prototypes
|
||||
****************************************************************************/
|
||||
|
||||
static FAR struct nsh_vtbl_s *nsh_consoleclone(FAR struct nsh_vtbl_s *vtbl);
|
||||
static void nsh_consoleaddref(FAR struct nsh_vtbl_s *vtbl);
|
||||
static void nsh_consolerelease(FAR struct nsh_vtbl_s *vtbl);
|
||||
static int nsh_consoleoutput(FAR struct nsh_vtbl_s *vtbl, const char *fmt, ...);
|
||||
static FAR char *nsh_consolelinebuffer(FAR struct nsh_vtbl_s *vtbl);
|
||||
static FAR void *nsh_consoleredirect(FAR struct nsh_vtbl_s *vtbl, int fd);
|
||||
static void nsh_consoleundirect(FAR struct nsh_vtbl_s *vtbl, FAR void *direct);
|
||||
|
||||
/****************************************************************************
|
||||
* Private Data
|
||||
****************************************************************************/
|
||||
@@ -86,11 +98,207 @@ static inline FAR struct serial_s *nsh_allocstruct(void)
|
||||
struct serial_s *pstate = (struct serial_s *)malloc(sizeof(struct serial_s));
|
||||
if (pstate)
|
||||
{
|
||||
pstate->vtbl.clone = nsh_consoleclone;
|
||||
pstate->vtbl.addref = nsh_consoleaddref;
|
||||
pstate->vtbl.release = nsh_consolerelease;
|
||||
pstate->vtbl.output = nsh_consoleoutput;
|
||||
pstate->vtbl.linebuffer = nsh_consolelinebuffer;
|
||||
pstate->vtbl.redirect = nsh_consoleredirect;
|
||||
pstate->vtbl.undirect = nsh_consoleundirect;
|
||||
|
||||
pstate->ss_refs = 1;
|
||||
pstate->ss_fd = 1;
|
||||
pstate->ss_stream = stdout;
|
||||
}
|
||||
return pstate;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: nsh_openifnotopen
|
||||
****************************************************************************/
|
||||
|
||||
static int nsh_openifnotopen(struct serial_s *pstate)
|
||||
{
|
||||
/* The stream is open in a lazy fashion. This is done because the file
|
||||
* descriptor may be opened on a different task than the stream.
|
||||
*/
|
||||
|
||||
if (!pstate->ss_stream)
|
||||
{
|
||||
pstate->ss_stream = fdopen(pstate->ss_fd, "w");
|
||||
if (!pstate->ss_stream)
|
||||
{
|
||||
return ERROR;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: nsh_closeifnotclosed
|
||||
****************************************************************************/
|
||||
|
||||
static void nsh_closeifnotclosed(struct serial_s *pstate)
|
||||
{
|
||||
if (pstate->ss_stream == stdout)
|
||||
{
|
||||
fflush(stdout);
|
||||
pstate->ss_fd = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (pstate->ss_stream)
|
||||
{
|
||||
fflush(pstate->ss_stream);
|
||||
fclose(pstate->ss_stream);
|
||||
}
|
||||
else if (pstate->ss_fd >= 0 && pstate->ss_fd != 1)
|
||||
{
|
||||
close(pstate->ss_fd);
|
||||
}
|
||||
|
||||
pstate->ss_fd = -1;
|
||||
pstate->ss_stream = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: nsh_consoleoutput
|
||||
*
|
||||
* Description:
|
||||
* Print a string to the currently selected stream.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
static int nsh_consoleoutput(FAR struct nsh_vtbl_s *vtbl, const char *fmt, ...)
|
||||
{
|
||||
FAR struct serial_s *pstate = (FAR struct serial_s *)vtbl;
|
||||
va_list ap;
|
||||
int ret;
|
||||
|
||||
/* The stream is open in a lazy fashion. This is done because the file
|
||||
* descriptor may be opened on a different task than the stream. The
|
||||
* actual open will then occur with the first output from the new task.
|
||||
*/
|
||||
|
||||
if (nsh_openifnotopen(pstate) != 0)
|
||||
{
|
||||
return ERROR;
|
||||
}
|
||||
|
||||
va_start(ap, fmt);
|
||||
ret = vfprintf(pstate->ss_stream, fmt, ap);
|
||||
va_end(ap);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: nsh_consolelinebuffer
|
||||
*
|
||||
* Description:
|
||||
* Return a reference to the current line buffer
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
static FAR char *nsh_consolelinebuffer(FAR struct nsh_vtbl_s *vtbl)
|
||||
{
|
||||
FAR struct serial_s *pstate = (FAR struct serial_s *)vtbl;
|
||||
return pstate->ss_line;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: nsh_consoleclone
|
||||
*
|
||||
* Description:
|
||||
* Make an independent copy of the vtbl
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
static FAR struct nsh_vtbl_s *nsh_consoleclone(FAR struct nsh_vtbl_s *vtbl)
|
||||
{
|
||||
FAR struct serial_s *pstate = (FAR struct serial_s *)vtbl;
|
||||
FAR struct serial_s *pclone = nsh_allocstruct();
|
||||
pclone->ss_fd = pstate->ss_fd;
|
||||
pclone->ss_stream = NULL;
|
||||
return &pclone->vtbl;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: nsh_consoleaddref
|
||||
*
|
||||
* Description:
|
||||
* Increment the reference count on the vtbl.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
static void nsh_consoleaddref(FAR struct nsh_vtbl_s *vtbl)
|
||||
{
|
||||
FAR struct serial_s *pstate = (FAR struct serial_s *)vtbl;
|
||||
pstate->ss_refs++;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: nsh_consolerelease
|
||||
*
|
||||
* Description:
|
||||
* Decrement the reference count on the vtbl, releasing it when the count
|
||||
* decrements to zero.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
static void nsh_consolerelease(FAR struct nsh_vtbl_s *vtbl)
|
||||
{
|
||||
FAR struct serial_s *pstate = (FAR struct serial_s *)vtbl;
|
||||
if (pstate->ss_refs > 1)
|
||||
{
|
||||
pstate->ss_refs--;
|
||||
}
|
||||
else
|
||||
{
|
||||
nsh_closeifnotclosed(pstate);
|
||||
free(vtbl);
|
||||
}
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: nsh_consoleredirect
|
||||
*
|
||||
* Description:
|
||||
* Set up for redirected output
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
static FAR void *nsh_consoleredirect(FAR struct nsh_vtbl_s *vtbl, int fd)
|
||||
{
|
||||
FAR struct serial_s *pstate = (FAR struct serial_s *)vtbl;
|
||||
void *ret;
|
||||
|
||||
(void)nsh_openifnotopen(pstate);
|
||||
ret = pstate->ss_stream;
|
||||
fflush(pstate->ss_stream);
|
||||
|
||||
pstate->ss_fd = fd;
|
||||
pstate->ss_stream = NULL;
|
||||
return ret;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: nsh_consoleredirect
|
||||
*
|
||||
* Description:
|
||||
* Set up for redirected output
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
static void nsh_consoleundirect(FAR struct nsh_vtbl_s *vtbl, FAR void *direct)
|
||||
{
|
||||
FAR struct serial_s *pstate = (FAR struct serial_s *)vtbl;
|
||||
nsh_closeifnotclosed(pstate);
|
||||
pstate->ss_fd = -1;
|
||||
pstate->ss_stream = (FILE*)direct;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
@@ -99,19 +307,19 @@ static inline FAR struct serial_s *nsh_allocstruct(void)
|
||||
* Name: nsh_main
|
||||
****************************************************************************/
|
||||
|
||||
int nsh_main(void)
|
||||
int nsh_consolemain(int argc, char *argv[])
|
||||
{
|
||||
FAR struct serial_s *pstate = nsh_allocstruct();
|
||||
|
||||
printf("NuttShell (NSH)\n");
|
||||
fflush(stdout);
|
||||
fflush(pstate->ss_stream);
|
||||
|
||||
for (;;)
|
||||
{
|
||||
/* Display the prompt string */
|
||||
|
||||
fputs(g_nshprompt, stdout);
|
||||
fflush(stdout);
|
||||
fputs(g_nshprompt, pstate->ss_stream);
|
||||
fflush(pstate->ss_stream);
|
||||
|
||||
/* Get the next line of input */
|
||||
|
||||
@@ -119,95 +327,12 @@ int nsh_main(void)
|
||||
{
|
||||
/* Parse process the command */
|
||||
|
||||
(void)nsh_parse(pstate, pstate->ss_line);
|
||||
fflush(stdout);
|
||||
(void)nsh_parse(&pstate->vtbl, pstate->ss_line);
|
||||
fflush(pstate->ss_stream);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: nsh_output
|
||||
*
|
||||
* Description:
|
||||
* Print a string to stdout.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int nsh_output(FAR void *handle, const char *fmt, ...)
|
||||
{
|
||||
va_list ap;
|
||||
int ret;
|
||||
|
||||
va_start(ap, fmt);
|
||||
ret = vfprintf(stdout, fmt, ap);
|
||||
va_end(ap);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: nsh_linebuffer
|
||||
*
|
||||
* Description:
|
||||
* Return a reference to the current line buffer
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
FAR char *nsh_linebuffer(FAR void *handle)
|
||||
{
|
||||
FAR struct serial_s *pstate = (FAR struct serial_s *)handle;
|
||||
return pstate->ss_line;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: nsh_clone
|
||||
*
|
||||
* Description:
|
||||
* Make an independent copy of the handle
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
FAR void *nsh_clone(FAR void *handle)
|
||||
{
|
||||
return nsh_allocstruct();
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: nsh_addref
|
||||
*
|
||||
* Description:
|
||||
* Increment the reference count on the handle.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
void nsh_addref(FAR void *handle)
|
||||
{
|
||||
FAR struct serial_s *pstate = (FAR struct serial_s *)handle;
|
||||
pstate->ss_refs++;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: nsh_release
|
||||
*
|
||||
* Description:
|
||||
* Decrement the reference count on the handle, releasing it when the count
|
||||
* decrements to zero.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
void nsh_release(FAR void *handle)
|
||||
{
|
||||
FAR struct serial_s *pstate = (FAR struct serial_s *)handle;
|
||||
if (pstate->ss_refs > 1)
|
||||
{
|
||||
pstate->ss_refs--;
|
||||
}
|
||||
else
|
||||
{
|
||||
free(handle);
|
||||
}
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: cmd_exit
|
||||
*
|
||||
@@ -216,7 +341,7 @@ void nsh_release(FAR void *handle)
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
void cmd_exit(void *handle, int argc, char **argv)
|
||||
void cmd_exit(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv)
|
||||
{
|
||||
exit(0);
|
||||
}
|
||||
|
||||
+114
-81
@@ -85,6 +85,7 @@
|
||||
|
||||
struct telnetd_s
|
||||
{
|
||||
struct nsh_vtbl_s vtbl;
|
||||
int tn_sockfd;
|
||||
uint16 tn_sndlen;
|
||||
uint8 tn_bufndx;
|
||||
@@ -93,6 +94,18 @@ struct telnetd_s
|
||||
char tn_cmd[CONFIG_EXAMPLES_NSH_LINELEN];
|
||||
};
|
||||
|
||||
/****************************************************************************
|
||||
* Private Function Prototypes
|
||||
****************************************************************************/
|
||||
|
||||
static FAR struct nsh_vtbl_s *nsh_telnetclone(FAR struct nsh_vtbl_s *vtbl);
|
||||
static void nsh_telnetaddref(FAR struct nsh_vtbl_s *vtbl);
|
||||
static void nsh_telnetrelease(FAR struct nsh_vtbl_s *vtbl);
|
||||
static int nsh_telnetoutput(FAR struct nsh_vtbl_s *vtbl, const char *fmt, ...);
|
||||
static FAR char *nsh_telnetlinebuffer(FAR struct nsh_vtbl_s *vtbl);
|
||||
static FAR void *nsh_telnetredirect(FAR struct nsh_vtbl_s *vtbl, int fd);
|
||||
static void nsh_telnetundirect(FAR struct nsh_vtbl_s *vtbl, FAR void *direct);
|
||||
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
@@ -147,6 +160,27 @@ static void nsh_dumpbuffer(const char *msg, const char *buffer, ssize_t nbytes)
|
||||
# define nsh_dumpbuffer(msg,buffer,nbytes)
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Name: nsh_allocstruct
|
||||
****************************************************************************/
|
||||
|
||||
static inline FAR struct telnetd_s *nsh_allocstruct(void)
|
||||
{
|
||||
struct telnetd_s *pstate = (struct telnetd_s *)malloc(sizeof(struct telnetd_s));
|
||||
if (pstate)
|
||||
{
|
||||
memset(pstate, 0, sizeof(struct telnetd_s));
|
||||
pstate->vtbl.clone = nsh_telnetclone;
|
||||
pstate->vtbl.addref = nsh_telnetaddref;
|
||||
pstate->vtbl.release = nsh_telnetrelease;
|
||||
pstate->vtbl.output = nsh_telnetoutput;
|
||||
pstate->vtbl.linebuffer = nsh_telnetlinebuffer;
|
||||
pstate->vtbl.redirect = nsh_telnetredirect;
|
||||
pstate->vtbl.undirect = nsh_telnetundirect;
|
||||
}
|
||||
return pstate;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: nsh_putchar
|
||||
*
|
||||
@@ -178,7 +212,7 @@ static void nsh_putchar(struct telnetd_s *pstate, uint8 ch)
|
||||
}
|
||||
|
||||
nsh_dumpbuffer("TELNET CMD", pstate->tn_cmd, strlen(pstate->tn_cmd));
|
||||
nsh_parse((void*)pstate, pstate->tn_cmd);
|
||||
nsh_parse(&pstate->vtbl, pstate->tn_cmd);
|
||||
pstate->tn_bufndx = 0;
|
||||
}
|
||||
else
|
||||
@@ -340,7 +374,7 @@ static int nsh_receive(struct telnetd_s *pstate, size_t len)
|
||||
|
||||
static void *nsh_connection(void *arg)
|
||||
{
|
||||
struct telnetd_s *pstate = (struct telnetd_s *)malloc(sizeof(struct telnetd_s));
|
||||
struct telnetd_s *pstate = nsh_allocstruct();
|
||||
int sockfd = (int)arg;
|
||||
int ret = ERROR;
|
||||
|
||||
@@ -352,13 +386,12 @@ static void *nsh_connection(void *arg)
|
||||
{
|
||||
/* Initialize the thread state structure */
|
||||
|
||||
memset(pstate, 0, sizeof(struct telnetd_s));
|
||||
pstate->tn_sockfd = sockfd;
|
||||
pstate->tn_state = STATE_NORMAL;
|
||||
|
||||
/* Output a greeting */
|
||||
|
||||
nsh_output(pstate, "NuttShell (NSH)\n");
|
||||
nsh_output(&pstate->vtbl, "NuttShell (NSH)\n");
|
||||
|
||||
/* Loop processing each TELNET command */
|
||||
|
||||
@@ -366,7 +399,7 @@ static void *nsh_connection(void *arg)
|
||||
{
|
||||
/* Display the prompt string */
|
||||
|
||||
nsh_output(pstate, g_nshprompt);
|
||||
nsh_output(&pstate->vtbl, g_nshprompt);
|
||||
nsh_flush(pstate);
|
||||
|
||||
/* Read a buffer of data from the TELNET client */
|
||||
@@ -396,6 +429,79 @@ static void *nsh_connection(void *arg)
|
||||
pthread_exit(NULL);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: nsh_telnetoutput
|
||||
*
|
||||
* Description:
|
||||
* Print a string to the remote shell window.
|
||||
*
|
||||
* This function is implemented by the shell GUI / telnet server and
|
||||
* can be called by the shell back-end to output a string in the
|
||||
* shell window. The string is automatically appended with a linebreak.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
static int nsh_telnetoutput(FAR struct nsh_vtbl_s *vtbl, const char *fmt, ...)
|
||||
{
|
||||
struct telnetd_s *pstate = (struct telnetd_s *)vtbl;
|
||||
int nbytes = pstate->tn_sndlen;
|
||||
int len;
|
||||
va_list ap;
|
||||
|
||||
/* Put the new info into the buffer. Here we are counting on the fact that
|
||||
* no output strings will exceed CONFIG_EXAMPLES_NSH_LINELEN!
|
||||
*/
|
||||
|
||||
va_start(ap, fmt);
|
||||
vsnprintf(&pstate->tn_iobuffer[nbytes],
|
||||
(CONFIG_EXAMPLES_NSH_IOBUFFER_SIZE - 1) - nbytes, fmt, ap);
|
||||
va_end(ap);
|
||||
|
||||
/* Get the size of the new string just added and the total size of
|
||||
* buffered data
|
||||
*/
|
||||
|
||||
len = strlen(&pstate->tn_iobuffer[nbytes]);
|
||||
nbytes += len;
|
||||
|
||||
/* Expand any terminating \n to \r\n */
|
||||
|
||||
if (nbytes < (CONFIG_EXAMPLES_NSH_IOBUFFER_SIZE - 2) &&
|
||||
pstate->tn_iobuffer[nbytes-1] == '\n')
|
||||
{
|
||||
pstate->tn_iobuffer[nbytes-1] = ISO_cr;
|
||||
pstate->tn_iobuffer[nbytes] = ISO_nl;
|
||||
pstate->tn_iobuffer[nbytes+1] = '\0';
|
||||
nbytes++;
|
||||
}
|
||||
pstate->tn_sndlen = nbytes;
|
||||
|
||||
/* Flush to the network if the buffer does not have room for one more
|
||||
* maximum length string.
|
||||
*/
|
||||
|
||||
if (nbytes > CONFIG_EXAMPLES_NSH_IOBUFFER_SIZE - CONFIG_EXAMPLES_NSH_LINELEN)
|
||||
{
|
||||
nsh_flush(pstate);
|
||||
}
|
||||
|
||||
return len;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: nsh_telnetlinebuffer
|
||||
*
|
||||
* Description:
|
||||
* Return a reference to the current line buffer
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
static FAR char *nsh_telnetlinebuffer(FAR struct nsh_vtbl_s *vtbl)
|
||||
{
|
||||
struct telnetd_s *pstate = (struct telnetd_s *)vtbl;
|
||||
return pstate->tn_cmd;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
@@ -409,7 +515,7 @@ static void *nsh_connection(void *arg)
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int nsh_main(void)
|
||||
int nsh_telnetmain(int argc, char *argv[])
|
||||
{
|
||||
struct in_addr addr;
|
||||
#if defined(CONFIG_EXAMPLES_NSH_DHCPC) || defined(CONFIG_EXAMPLES_NSH_NOMAC)
|
||||
@@ -491,79 +597,6 @@ int nsh_main(void)
|
||||
return OK;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: nsh_output
|
||||
*
|
||||
* Description:
|
||||
* Print a string to the remote shell window.
|
||||
*
|
||||
* This function is implemented by the shell GUI / telnet server and
|
||||
* can be called by the shell back-end to output a string in the
|
||||
* shell window. The string is automatically appended with a linebreak.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int nsh_output(FAR void *handle, const char *fmt, ...)
|
||||
{
|
||||
struct telnetd_s *pstate = (struct telnetd_s *)handle;
|
||||
int nbytes = pstate->tn_sndlen;
|
||||
int len;
|
||||
va_list ap;
|
||||
|
||||
/* Put the new info into the buffer. Here we are counting on the fact that
|
||||
* no output strings will exceed CONFIG_EXAMPLES_NSH_LINELEN!
|
||||
*/
|
||||
|
||||
va_start(ap, fmt);
|
||||
vsnprintf(&pstate->tn_iobuffer[nbytes],
|
||||
(CONFIG_EXAMPLES_NSH_IOBUFFER_SIZE - 1) - nbytes, fmt, ap);
|
||||
va_end(ap);
|
||||
|
||||
/* Get the size of the new string just added and the total size of
|
||||
* buffered data
|
||||
*/
|
||||
|
||||
len = strlen(&pstate->tn_iobuffer[nbytes]);
|
||||
nbytes += len;
|
||||
|
||||
/* Expand any terminating \n to \r\n */
|
||||
|
||||
if (nbytes < (CONFIG_EXAMPLES_NSH_IOBUFFER_SIZE - 2) &&
|
||||
pstate->tn_iobuffer[nbytes-1] == '\n')
|
||||
{
|
||||
pstate->tn_iobuffer[nbytes-1] = ISO_cr;
|
||||
pstate->tn_iobuffer[nbytes] = ISO_nl;
|
||||
pstate->tn_iobuffer[nbytes+1] = '\0';
|
||||
nbytes++;
|
||||
}
|
||||
pstate->tn_sndlen = nbytes;
|
||||
|
||||
/* Flush to the network if the buffer does not have room for one more
|
||||
* maximum length string.
|
||||
*/
|
||||
|
||||
if (nbytes > CONFIG_EXAMPLES_NSH_IOBUFFER_SIZE - CONFIG_EXAMPLES_NSH_LINELEN)
|
||||
{
|
||||
nsh_flush(pstate);
|
||||
}
|
||||
|
||||
return len;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: nsh_linebuffer
|
||||
*
|
||||
* Description:
|
||||
* Return a reference to the current line buffer
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
FAR char *nsh_linebuffer(FAR void *handle)
|
||||
{
|
||||
struct telnetd_s *pstate = (struct telnetd_s *)handle;
|
||||
return pstate->tn_cmd;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: cmd_exit
|
||||
*
|
||||
@@ -572,9 +605,9 @@ FAR char *nsh_linebuffer(FAR void *handle)
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
void cmd_exit(void *handle, int argc, char **argv)
|
||||
void cmd_exit(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv)
|
||||
{
|
||||
struct telnetd_s *pstate = (struct telnetd_s *)handle;
|
||||
struct telnetd_s *pstate = (struct telnetd_s *)vtbl;
|
||||
pstate->tn_state = STATE_CLOSE;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user