diff --git a/Makefile b/Makefile index de1e6c0..a4f0e5a 100644 --- a/Makefile +++ b/Makefile @@ -64,16 +64,16 @@ UTILS_DIR = utils DEMO_DIR = c/demo PSHELL_FLAGS = -TF_FLAGS = -TRACE_FLAGS = +TF_FLAGS = +TRACE_FLAGS = CLIENT_FLAGS = TRACE_FILTER_DEMO_FLAGS = TRACE_LOG_DEMO_FLAGS = -PSHELL_SERVER_DEMO_LIBS = -L$(LIB_DIR) -lpshell-server -lpthread -PSHELL_CONTROL_DEMO_LIBS = -L$(LIB_DIR) -lpshell-control -lpthread -PSHELL_READLINE_DEMO_LIBS = -L$(LIB_DIR) -lpshell-readline -TRACE_FILTER_DEMO_LIBS = -L$(LIB_DIR) -lpshell-server -lpthread +PSHELL_SERVER_DEMO_LIBS = -L$(LIB_DIR) -lpshell-server -lpthread +PSHELL_CONTROL_DEMO_LIBS = -L$(LIB_DIR) -lpshell-control -lpthread +PSHELL_READLINE_DEMO_LIBS = -L$(LIB_DIR) -lpshell-readline +TRACE_FILTER_DEMO_LIBS = -L$(LIB_DIR) -lpshell-server -lpthread VERBOSE = @ LOCAL = @@ -311,7 +311,7 @@ lib: $(VERBOSE)$(CC) $(INCLUDE) $(TRACE_FLAGS) $(STATIC_OBJ) $(SRC_DIR)/TraceLog.$(SRC_EXT) -o TraceLog.o $(VERBOSE)$(STATIC_LIB) $(LIB_DIR)/libpshell-server-full.a $(PSHELL_OBJS) $(VERBOSE)rm *.o - + @echo "Building libpshell-server-full.so..." $(VERBOSE)$(CC) $(INCLUDE) $(PSHELL_FLAGS) $(SHARED_OBJ) $(SRC_DIR)/PshellServer.$(SRC_EXT) -o PshellServer.o $(VERBOSE)$(CC) $(INCLUDE) $(SHARED_OBJ) $(SRC_DIR)/PshellReadline.$(SRC_EXT) -o PshellReadline.o @@ -319,22 +319,22 @@ lib: $(VERBOSE)$(CC) $(INCLUDE) $(TRACE_FLAGS) $(SHARED_OBJ) $(SRC_DIR)/TraceLog.$(SRC_EXT) -o TraceLog.o $(VERBOSE)$(SHARED_LIB) $(LIB_DIR)/libpshell-server-full.so $(PSHELL_OBJS) $(VERBOSE)rm *.o - + @echo "Building libpshell-server-stub.a..." $(VERBOSE)$(CC) $(INCLUDE) $(PSHELL_FLAGS) $(TF_FLAGS) $(STATIC_OBJ) $(SRC_DIR)/PshellStub.$(SRC_EXT) -o PshellStub.o $(VERBOSE)$(STATIC_LIB) $(LIB_DIR)/libpshell-server-stub.a PshellStub.o $(VERBOSE)rm *.o - + @echo "Building libpshell-server-stub.so..." $(VERBOSE)$(CC) $(INCLUDE) $(PSHELL_FLAGS) $(TF_FLAGS) $(SHARED_OBJ) $(SRC_DIR)/PshellStub.$(SRC_EXT) -o PshellStub.o $(VERBOSE)$(SHARED_LIB) $(LIB_DIR)/libpshell-server-stub.so PshellStub.o $(VERBOSE)rm *.o - + @echo "Building libpshell-control.a..." $(VERBOSE)$(CC) $(INCLUDE) $(PSHELL_FLAGS) $(STATIC_OBJ) $(SRC_DIR)/PshellControl.$(SRC_EXT) -o PshellControl.o $(VERBOSE)$(STATIC_LIB) $(LIB_DIR)/libpshell-control.a PshellControl.o $(VERBOSE)rm *.o - + @echo "Building libpshell-control.so..." $(VERBOSE)$(CC) $(INCLUDE) $(PSHELL_FLAGS) $(SHARED_OBJ) $(SRC_DIR)/PshellControl.$(SRC_EXT) -o PshellControl.o $(VERBOSE)$(SHARED_LIB) $(LIB_DIR)/libpshell-control.so PshellControl.o @@ -344,7 +344,7 @@ lib: $(VERBOSE)$(CC) $(INCLUDE) $(STATIC_OBJ) $(SRC_DIR)/PshellReadline.$(SRC_EXT) -o PshellReadline.o $(VERBOSE)$(STATIC_LIB) $(LIB_DIR)/libpshell-readline.a PshellReadline.o $(VERBOSE)rm *.o - + @echo "Building libpshell-readline.so..." $(VERBOSE)$(CC) $(INCLUDE) $(SHARED_OBJ) $(SRC_DIR)/PshellReadline.$(SRC_EXT) -o PshellReadline.o $(VERBOSE)$(SHARED_LIB) $(LIB_DIR)/libpshell-readline.so PshellReadline.o @@ -363,19 +363,19 @@ pshell: demo: @echo "Building pshellServerDemo program..." $(VERBOSE)$(CC) $(INCLUDE) $(WARNINGS) $(DEMO_DIR)/pshellServerDemo.$(SRC_EXT) $(PSHELL_SERVER_DEMO_LIBS) -o $(BIN_DIR)/pshellServerDemo - + @echo "Building pshellNoServerDemo program..." $(VERBOSE)$(CC) $(INCLUDE) $(WARNINGS) $(DEMO_DIR)/pshellNoServerDemo.$(SRC_EXT) $(PSHELL_SERVER_DEMO_LIBS) -o $(BIN_DIR)/pshellNoServerDemo @echo "Building pshellControlDemo program..." $(VERBOSE)$(CC) $(INCLUDE) $(WARNINGS) $(DEMO_DIR)/pshellControlDemo.$(SRC_EXT) $(PSHELL_CONTROL_DEMO_LIBS) -o $(BIN_DIR)/pshellControlDemo - + @echo "Building pshellReadlineDemo program..." $(VERBOSE)$(CC) $(INCLUDE) $(WARNINGS) $(DEMO_DIR)/pshellReadlineDemo.$(SRC_EXT) $(PSHELL_READLINE_DEMO_LIBS) -o $(BIN_DIR)/pshellReadlineDemo - + @echo "Building pshellAggregatorDemo program..." $(VERBOSE)$(CC) $(INCLUDE) $(WARNINGS) $(DEMO_DIR)/pshellAggregatorDemo.$(SRC_EXT) $(PSHELL_CONTROL_DEMO_LIBS) $(PSHELL_SERVER_DEMO_LIBS) -o $(BIN_DIR)/pshellAggregatorDemo - + ifeq ($(TF_INTEGRATED_TRACE_LOG),y) @echo "Building traceFilterDemo program..." $(VERBOSE)$(CC) $(INCLUDE) $(WARNINGS) $(TRACE_FILTER_DEMO_FLAGS) $(DEMO_DIR)/traceFilterDemo.$(SRC_EXT) $(TRACE_FILTER_DEMO_LIBS) -o $(BIN_DIR)/traceFilterDemo @@ -390,7 +390,7 @@ all: clean lib pshell demo install: all $(VERBOSE)./install.sh $(LOCAL) $(SHELL_ENV_FILE) -clean: +clean: @echo "Cleaning directory bin..." $(VERBOSE)rm -f $(BIN_DIR)/*Demo $(VERBOSE)rm -f $(BIN_DIR)/pshell diff --git a/README b/README index 0c6fa30..9ec26d6 100644 --- a/README +++ b/README @@ -5,17 +5,17 @@ PSHELL - A Lightweight, Process-Specific, Embedded Command Line Shell INTRODUCTION: This package contains all the necessary code, documentation and examples for -building C/C++/Python/Go applications that incorporate a Process Specific Embedded +building C/C++/Python/Go applications that incorporate a Process Specific Embedded Command Line Shell (PSHELL). The PSHELL library provides a simple, lightweight, -framework and API to embed functions within a C/C++/Python/Go application that can +framework and API to embed functions within a C/C++/Python/Go application that can be invoked either via a separate client program or directly from the within application itself. There is also a control API provided by where any external program can invoke another program's registered pshell functions (only supported for UDP or UNIX pshell servers). -This will provide direct programmatic control of a remote process' pshell functions -without having to fork the calling process to call the 'pshell' command line client -program via the 'system' call. This provides functionality similar to the familiar +This will provide direct programmatic control of a remote process' pshell functions +without having to fork the calling process to call the 'pshell' command line client +program via the 'system' call. This provides functionality similar to the familiar Remote Procedure Call (RPC) mechanism. The control API can function as a simple control plane IPC mechanism for inter-process @@ -27,13 +27,13 @@ driven and tested manually via one of the interactive client programs (pshell or pshellAggregator). The control API supports both unicast and 'multicast' (not true subscriber based multicast -like IGMP, it's more like sender based aggregated unicast) messaging paradigms. It also -supports messaging to broadcast pshell servers (i.e. UDP server running at a subnet +like IGMP, it's more like sender based aggregated unicast) messaging paradigms. It also +supports messaging to broadcast pshell servers (i.e. UDP server running at a subnet broadcast address, e.g. x.y.z.255). The Python, 'C', and 'go' versions are consistent with each other at the API level (i.e. similar functional API, usage, process interaction etc) and fully interoperable with each -other at the protocol level and can be mixed and matched in any combination. +other at the protocol level and can be mixed and matched in any combination. The prototype for the callback functions follow the paradigms of the 'main' for each language. A pshell callback function can be thought of as a collection of mini 'mains' @@ -54,7 +54,7 @@ def myFunc(argv) func myFunc(argv []string) -Command line pshell functions can also display information back to the interactive clients +Command line pshell functions can also display information back to the interactive clients via a mechanism similar to the familiar 'printf' as follows: 'C' printf: @@ -69,31 +69,31 @@ def printf(string) func Printf(format string, message ...interface{}) -These functions can be invoked in several ways depending on how the internal PSHELL server is -configured. The following shows the various PSHELL server types along with their associated +These functions can be invoked in several ways depending on how the internal PSHELL server is +configured. The following shows the various PSHELL server types along with their associated invokation method: TCP Server : Uses standard 'telnet' interactive client to invoke functions UDP Server : Uses included 'pshell' interactive client or control API to invoke functions UNIX Server : Uses included 'pshell' interactive client or control API to invoke functions -LOCAL Server : No client program needed, functions invoked directly from within application +LOCAL Server : No client program needed, functions invoked directly from within application itself via local command line interactive prompting -The functions are dispatched via its registered command name (keyword), along with 0 or more +The functions are dispatched via its registered command name (keyword), along with 0 or more command line arguments, similar to command line shell processing. This framework also provides the ability to run in non-server, non-interactive mode. In this -mode, the registered commands can be dispatched via the host's shell command line directly as -single shot commands via the main registering program. In this mode, there is no interactive -user prompting, and control is returned to the calling host's command line shell when the command -is complete. This mode also provides the ability to setup softlink shortcuts to each internal -command and to invoke those commands from the host's command line shell directly via the shortcut +mode, the registered commands can be dispatched via the host's shell command line directly as +single shot commands via the main registering program. In this mode, there is no interactive +user prompting, and control is returned to the calling host's command line shell when the command +is complete. This mode also provides the ability to setup softlink shortcuts to each internal +command and to invoke those commands from the host's command line shell directly via the shortcut name rather than the parent program name, in a manner similar to Busybox functionality. Note this is only available in the 'C' implementation. -This package also provides an optional integrated interactive dynamic trace filtering mechanism -that can be incorporated into any software that uses an existing trace logging system that uses -the `__FILE__`, `__LINE__`, `__FUNCTION__`, and `level` paradigm. If this functionality is not +This package also provides an optional integrated interactive dynamic trace filtering mechanism +that can be incorporated into any software that uses an existing trace logging system that uses +the `__FILE__`, `__LINE__`, `__FUNCTION__`, and `level` paradigm. If this functionality is not desired, it can be easily compiled out via the build-time config files. Along with the optional trace filtering mechanism, there is also an optional integrated trace logging @@ -108,15 +108,15 @@ of the various APIs for each component. See the respective 'demo' directories u specific examples. Finally, a stub module/library is provided that will honor the complete API of the normal pshell -library but with all the underlying functionality stubbed out. This will allow all the pshell -functionality to easily be completly removed from an application without requiring any code -changes or recompilation, only a re-link (for static linking) or restart (when using a shared +library but with all the underlying functionality stubbed out. This will allow all the pshell +functionality to easily be completly removed from an application without requiring any code +changes or recompilation, only a re-link (for static linking) or restart (when using a shared library/module acessed via a softlink) of the target program is necessary. GETTING STARTED: This package consists of the following components, all provided binaries (libs -and executables) were built for the x86_64 target. The script pshell.exp requires +and executables) were built for the x86_64 target. The script pshell.exp requires the 'expect' package to be installed. - install.sh -- Install shell script for this package @@ -263,10 +263,10 @@ $PSHELL_INSTALL/go/src/pshellServerDemo/pshellServerDemo.go -- Server demo fo EXECUTION: There are several demo programs, two that demonstrate a program that incorporates -a pshell server (pshellServerDemo and pshellServerDemo.py), one that demonstrates -a program that incorporates the trace filter functionality (traceFilterDemo), two -that demonstrate the control of a program that is running a pshell server from -another program (pshellControlDemo and pshellControlDemo.py), two that demonstrate +a pshell server (pshellServerDemo and pshellServerDemo.py), one that demonstrates +a program that incorporates the trace filter functionality (traceFilterDemo), two +that demonstrate the control of a program that is running a pshell server from +another program (pshellControlDemo and pshellControlDemo.py), two that demonstrate the aggregation of multiple pshell servers into a single server via the control API (pshellAggregatorDemo, pshellAggregatorDemo.py), two that demonstrates the usage of readline-like command line user input (pshellReadlineDemo and pshellReadlineDemo.py), @@ -280,10 +280,10 @@ line functionality. The demo program pshellControlDemo can control the other tw programs through a simple command line UI, but it is really meant to demonstrate the programmitic control of an external program that is running a PshellServer via the PshellControl API and library. The pshellControlDemo programs can control either the -pshellServerDemo or traceControlDemo program. The pshellAggregatorDemos can control both -the pshellServerDemo or traceControlDemo within a single invocation. The functionality -of the pshellNoServerDemo is only accessed directly from the host's command line shell, -either directly from the pshellNoServerDemo itself, or via the setup softlinks for each +pshellServerDemo or traceControlDemo program. The pshellAggregatorDemos can control both +the pshellServerDemo or traceControlDemo within a single invocation. The functionality +of the pshellNoServerDemo is only accessed directly from the host's command line shell, +either directly from the pshellNoServerDemo itself, or via the setup softlinks for each command (need to run 'pshellNoServerDemo --setup' to setup softlinks). After the install.sh script has been excuted (and the local env sourced if doing @@ -311,7 +311,7 @@ Usage: pshellServerDemo -udp | -unix | -tcp | -local -local - Local command dispatching server Execute "pshellServerDemo -udp" or "pshellServerDemo -unix" at the command line, -either in the foreground or background. You can now interact with the +either in the foreground or background. You can now interact with the "pshellServerDemo" program via the "pshell" client program. Note, you can also run the "pshellServerDemo" program with the "-tcp" option and connect with the expect script "pshell.exp" which wraps a telnet session to make the look and @@ -328,8 +328,8 @@ wrapper. The usage of the "pshell" and "pshell.exp" (see NOTE) command line client programs are as follows: -Usage: pshell -h | ? | -s | [-t] { | | unix} - { | } [-h | ? | { [ [clear]]} | +Usage: pshell -h | ? | -s | [-t] { | | unix} + { | } [-h | ? | { [ [clear]]} | {-f [ [clear]]}] where: @@ -473,10 +473,10 @@ MAC/OSX based system. NOTE: While an overriding design goal was to write all the code in standard ANSI C and use standard C linkages, and a standard functional 'C' API, there are - a couple of small places where some C++ semantics snuck in, namely with - function prototypes that take default parameters and one struct that has + a couple of small places where some C++ semantics snuck in, namely with + function prototypes that take default parameters and one struct that has a constructor. Because of this, all the source modules have a '.cc' C++ - style extension instead of the customary '.c' C style extension in order + style extension instead of the customary '.c' C style extension in order to be able to use the standard 'gcc' compiler as well the 'g++' compiler. The following is the usage of the Makefile, see the included 'defconfig' file for @@ -519,8 +519,8 @@ a local network or secure VPN, but should not be exposed for general use over untrusted networks, such as the public Internet. For maximum security between the client and server, the server can be run either as a UNIX domain server or at the target host's local loopback address (i.e. 127.0.0.1) and the -PSHELL client application (pshell) can be installed to run on the same local -host as the target application. Of course, a secure mechanism (like ssh) would +PSHELL client application (pshell) can be installed to run on the same local +host as the target application. Of course, a secure mechanism (like ssh) would then need to be used to provide a secure user access method to that host. PORTING: diff --git a/README.md b/README.md index 7811364..094677b 100644 --- a/README.md +++ b/README.md @@ -2,17 +2,17 @@ **A Lightweight, Process-Specific, Embedded Command Line Shell for C/C++/Python/Go Applications** This package contains all the necessary code, documentation and examples for -building C/C++/Python/Go applications that incorporate a Process Specific Embedded +building C/C++/Python/Go applications that incorporate a Process Specific Embedded Command Line Shell (PSHELL). The PSHELL library provides a simple, lightweight, -framework and API to embed functions within a C/C++/Python/Go application that can +framework and API to embed functions within a C/C++/Python/Go application that can be invoked either via a separate client program or directly from the within application itself. There is also a control API provided by where any external program can invoke another program's registered pshell functions (only supported for UDP or UNIX pshell servers). -This will provide direct programmatic control of a remote process' pshell functions -without having to fork the calling process to call the 'pshell' command line client -program via the 'system' call. This provides functionality similar to the familiar +This will provide direct programmatic control of a remote process' pshell functions +without having to fork the calling process to call the 'pshell' command line client +program via the 'system' call. This provides functionality similar to the familiar Remote Procedure Call (RPC) mechanism. The control API can function as a simple control plane IPC mechanism for inter-process @@ -23,13 +23,13 @@ processing and control/message event processing. All inter-process control can driven and tested manually via one of the interactive client programs (pshell or pshellAggregator). The control API supports both unicast and 'multicast' (not true subscriber based multicast -like IGMP, it's more like sender based aggregated unicast) messaging paradigms. It also -supports messaging to broadcast pshell servers (i.e. UDP server running at a subnet +like IGMP, it's more like sender based aggregated unicast) messaging paradigms. It also +supports messaging to broadcast pshell servers (i.e. UDP server running at a subnet broadcast address, e.g. x.y.z.255). The Python, 'C', and 'go' versions are consistent with each other at the API level (i.e. similar functional API, usage, process interaction etc) and fully interoperable with each -other at the protocol level and can be mixed and matched in any combination. +other at the protocol level and can be mixed and matched in any combination. The prototype for the callback functions follow the paradigms of the 'main' for each language. A pshell callback function can be thought of as a collection of mini 'mains' @@ -50,7 +50,7 @@ Python callback: `func myFunc(argv []string)` -Command line pshell functions can also display information back to the interactive clients +Command line pshell functions can also display information back to the interactive clients via a mechanism similar to the familiar 'printf' as follows: 'C' printf: @@ -65,31 +65,31 @@ Python printf: `func Printf(format string, message ...interface{})` -These functions can be invoked via several methods depending on how the internal PSHELL -server is configured. The following shows the various PSHELL server types along with their +These functions can be invoked via several methods depending on how the internal PSHELL +server is configured. The following shows the various PSHELL server types along with their associated invokation method: * TCP Server : Uses standard telnet interactive client to invoke functions * UDP Server : Uses included pshell/pshellAggregator interactive client or control API to invoke functions * UNIX Server : Uses included pshell/pshellAggregator interactive client or control API to invoke functions -* LOCAL Server : No client program needed, functions invoked directly from within application +* LOCAL Server : No client program needed, functions invoked directly from within application itself via local command line interactive prompting The functions are dispatched via its registered command name (keyword), along with 0 or more command line arguments, similar to command line shell processing. This framework also provides the ability to run in non-server, non-interactive mode. In this -mode, the registered commands can be dispatched via the host's shell command line directly as -single shot commands via the main registering multi-call binary program. In this mode, there -is no interactive user prompting, and control is returned to the calling host's command line -shell when the command is complete. This mode also provides the ability to setup softlink -shortcuts to each internal command and to invoke those commands from the host's command line -shell directly via the shortcut name rather than the parent program name, in a manner similar +mode, the registered commands can be dispatched via the host's shell command line directly as +single shot commands via the main registering multi-call binary program. In this mode, there +is no interactive user prompting, and control is returned to the calling host's command line +shell when the command is complete. This mode also provides the ability to setup softlink +shortcuts to each internal command and to invoke those commands from the host's command line +shell directly via the shortcut name rather than the parent program name, in a manner similar to [Busybox](https://busybox.net/about.html) functionality. Note this is only available in the 'C' implementation. -This package also provides an optional integrated interactive dynamic trace filtering mechanism that -can be incorporated into any software that uses an existing trace logging system that uses the `__FILE__`, +This package also provides an optional integrated interactive dynamic trace filtering mechanism that +can be incorporated into any software that uses an existing trace logging system that uses the `__FILE__`, `__LINE__`, `__FUNCTION__`, and `level` paradigm. If this functionality is not desired, it can be easily compiled out via the build-time config files. @@ -105,13 +105,13 @@ of the various APIs for each component. See the respective 'demo' directories u specific examples. Finally, a stub module/library is provided that will honor the complete API of the normal pshell -library but with all the underlying functionality stubbed out. This will allow all the pshell -functionality to easily be completly removed from an application without requiring any code -changes or recompilation, only a re-link (for static linking) or restart (when using a shared +library but with all the underlying functionality stubbed out. This will allow all the pshell +functionality to easily be completly removed from an application without requiring any code +changes or recompilation, only a re-link (for static linking) or restart (when using a shared library/module acessed via a softlink) of the target program is necessary. See the full README file for a complete description of all the components, installation, building, and usage. -Note, this package was originally hosted at [code.google.com](https://code.google.com) as -[RDB-Lite](https://code.google.com/p/rdb-lite), it was re-christened as 'pshell' when it was +Note, this package was originally hosted at [code.google.com](https://code.google.com) as +[RDB-Lite](https://code.google.com/p/rdb-lite), it was re-christened as 'pshell' when it was migrated to this hosting service. diff --git a/batch/pshellServerDemo.batch b/batch/pshellServerDemo.batch index 64e46e4..7870c16 100644 --- a/batch/pshellServerDemo.batch +++ b/batch/pshellServerDemo.batch @@ -1,28 +1,28 @@ ################################################################################# -# -# Copyright (c) 2009, Ron Iovine, All rights reserved. -# -# Redistribution and use in source and binary forms, with or without +# +# Copyright (c) 2009, Ron Iovine, All rights reserved. +# +# Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: # * Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # * Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. -# * Neither the name of Ron Iovine nor the names of its contributors -# may be used to endorse or promote products derived from this software +# * Neither the name of Ron Iovine nor the names of its contributors +# may be used to endorse or promote products derived from this software # without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY Ron Iovine ''AS IS'' AND ANY EXPRESS OR -# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -# IN NO EVENT SHALL Ron Iovine BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -# BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER -# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -# POSSIBILITY OF SUCH DAMAGE. +# +# THIS SOFTWARE IS PROVIDED BY Ron Iovine ''AS IS'' AND ANY EXPRESS OR +# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +# IN NO EVENT SHALL Ron Iovine BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR +# BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. # ################################################################################# diff --git a/batch/traceFilterDemo.batch b/batch/traceFilterDemo.batch index da9abf9..01a0844 100644 --- a/batch/traceFilterDemo.batch +++ b/batch/traceFilterDemo.batch @@ -1,28 +1,28 @@ ################################################################################# -# -# Copyright (c) 2009, Ron Iovine, All rights reserved. -# -# Redistribution and use in source and binary forms, with or without +# +# Copyright (c) 2009, Ron Iovine, All rights reserved. +# +# Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: # * Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # * Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. -# * Neither the name of Ron Iovine nor the names of its contributors -# may be used to endorse or promote products derived from this software +# * Neither the name of Ron Iovine nor the names of its contributors +# may be used to endorse or promote products derived from this software # without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY Ron Iovine ''AS IS'' AND ANY EXPRESS OR -# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -# IN NO EVENT SHALL Ron Iovine BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -# BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER -# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -# POSSIBILITY OF SUCH DAMAGE. +# +# THIS SOFTWARE IS PROVIDED BY Ron Iovine ''AS IS'' AND ANY EXPRESS OR +# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +# IN NO EVENT SHALL Ron Iovine BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR +# BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. # ################################################################################# @@ -42,7 +42,7 @@ #trace file TraceFilter.c:135,156,300-400,190 trace global all trace on -#trace function myFunction1 myFunction2 +#trace function myFunction1 myFunction2 #trace function myFunction3 myFunction2 foo #trace file TraceFilter.c:1,5,7 diff --git a/c/demo/pshellAggregatorDemo.cc b/c/demo/pshellAggregatorDemo.cc index 5f6bfb6..2712aa9 100644 --- a/c/demo/pshellAggregatorDemo.cc +++ b/c/demo/pshellAggregatorDemo.cc @@ -33,7 +33,7 @@ * servers into a single local pshell server. This can be useful in presenting * a consolidated user shell who's functionality spans several discrete pshell * servers. Since this uses the PshellControl API, the external servers must - * all be either UDP or Unix servers. The consolidation point in this example + * all be either UDP or Unix servers. The consolidation point in this example * is a local pshell server. Note that this is a hard coded aggregator, meaning * that the remote servers that are aggregated are hard-coded, as opposed to * the generic, dynamic PshellAggregator.cc client program, which can aggregate @@ -90,7 +90,7 @@ void registerSignalHandlers(void) * this function will re-create the original command into one * string from the argc, argv items */ - + /******************************************************************************/ /******************************************************************************/ char *buildCommand(char *command, unsigned size, int argc, char *argv[]) @@ -107,7 +107,7 @@ char *buildCommand(char *command, unsigned size, int argc, char *argv[]) /* * this function is the common generic function to control any server - * based on only the SID and entered command, it should be called from + * based on only the SID and entered command, it should be called from * every control specific callback for this aggregator */ @@ -127,9 +127,9 @@ void controlServer(int sid, int argc, char *argv[]) { /* this contains the re-constituted command */ char command[300]; - if ((pshell_sendCommand3(sid, - results, - sizeof(results), + if ((pshell_sendCommand3(sid, + results, + sizeof(results), buildCommand(command, sizeof(command), argc, argv)) == PSHELL_COMMAND_SUCCESS) && (strlen(results) > 0)) { pshell_printf("%s", results); @@ -137,8 +137,8 @@ void controlServer(int sid, int argc, char *argv[]) } } -/* - * the SIDs of all the remote pshell servers we are aggregating, add more SID +/* + * the SIDs of all the remote pshell servers we are aggregating, add more SID * identifiers for each external server being controlled/aggregated */ int pshellServerDemoSid; @@ -172,14 +172,14 @@ void traceFilterDemo(int argc, char *argv[]) * example meta command that will call multiple discrete pshell commands from * multiple pshell servers */ - + /******************************************************************************/ /******************************************************************************/ void meta(int argc, char *argv[]) { - if ((pshell_sendCommand3(pshellServerDemoSid, - results, - sizeof(results), + if ((pshell_sendCommand3(pshellServerDemoSid, + results, + sizeof(results), "hello %s %s", argv[0], argv[1]) == PSHELL_COMMAND_SUCCESS) && (strlen(results) > 0)) { pshell_printf("%s", results); @@ -192,7 +192,7 @@ void meta(int argc, char *argv[]) * multicast receivers for that multicast group, multicast groups are based on * the command's keyword */ - + /******************************************************************************/ /******************************************************************************/ void multicast(int argc, char *argv[]) @@ -208,7 +208,7 @@ int main (int argc, char *argv[]) { unsigned pshellServerDemoPort = 6001; unsigned traceFilterDemoPort = 6002; - + if ((argc != 2) && (argc != 4)) { printf("Usage: pshellAggregatorDemo { | } [ ]\n"); @@ -224,13 +224,13 @@ int main (int argc, char *argv[]) pshellServerDemoPort = atoi(argv[2]); traceFilterDemoPort = atoi(argv[3]); } - + /* register signal handlers so we can do a graceful termination and cleanup any system resources */ registerSignalHandlers(); - - /* + + /* * connect to our remote servers, the hostname/ipAddress, port, - * and timeout values can be overridden via the pshell-control.conf + * and timeout values can be overridden via the pshell-control.conf * file */ if ((pshellServerDemoSid = pshell_connectServer("pshellServerDemo", @@ -250,20 +250,20 @@ int main (int argc, char *argv[]) printf("ERROR: Could not connect to remote pshell server traceFilterControl\n"); exit(0); } - - /* + + /* * add some multicast groups for our control sids, a multicast group is based * on the command's keyword */ pshell_addMulticast(pshellServerDemoSid, "trace"); - pshell_addMulticast(traceFilterDemoSid, "trace"); - + pshell_addMulticast(traceFilterDemoSid, "trace"); + pshell_addMulticast(pshellServerDemoSid, "test"); pshell_addMulticast(traceFilterDemoSid, "test"); /* register our local pshell commands */ - - /* these will aggregrate the commands from the two separate servers we are connected to */ + + /* these will aggregrate the commands from the two separate servers we are connected to */ pshell_addCommand(pshellServerDemo, /* function */ "pshellServerDemo", /* command */ "control the remote pshellServerDemo process", /* description */ @@ -279,8 +279,8 @@ int main (int argc, char *argv[]) 0, /* minArgs */ 30, /* maxArgs */ false); /* showUsage on "?" */ - - /* + + /* * add any "meta" commands here, meta commands can aggregate multiple discrete * pshell commands, either within one server or across multiple servers, into * one command @@ -291,9 +291,9 @@ int main (int argc, char *argv[]) " ", /* usage */ 3, /* minArgs */ 3, /* maxArgs */ - true); /* showUsage on "?" */ + true); /* showUsage on "?" */ - /* + /* * add an example command that uses the one-to-many multicast feature of * the control API */ @@ -303,14 +303,14 @@ int main (int argc, char *argv[]) NULL, /* usage */ 0, /* minArgs */ 0, /* maxArgs */ - true); /* showUsage on "?" */ + true); /* showUsage on "?" */ /* start our local pshell server */ pshell_startServer("pshellAggregatorDemo", PSHELL_LOCAL_SERVER, PSHELL_BLOCKING); - + /* disconnect all our remote control servers */ pshell_disconnectAllServers(); - + /* cleanup our local server's resources */ pshell_cleanupResources(); diff --git a/c/demo/pshellNoServerDemo.cc b/c/demo/pshellNoServerDemo.cc index f319160..4ef40e5 100644 --- a/c/demo/pshellNoServerDemo.cc +++ b/c/demo/pshellNoServerDemo.cc @@ -30,7 +30,7 @@ * * This is an example demo program that uses all the basic features of the * PSHELL library in non-server mode, non-server mode is a non-interactive, - * one shot command processing mode, i.e. it will take all the arguments + * one shot command processing mode, i.e. it will take all the arguments * typed after the program name and process them as a single-shot command * and exit. This mode will also allow for the setup of each individual * command to be softlinked back to the main parent program via the '--setup' @@ -58,7 +58,7 @@ * remote client. The interface to this function is exactly the same as * the standard 'printf' function. */ - + /******************************************************************************/ /******************************************************************************/ void hello(int argc, char *argv[]) @@ -148,16 +148,16 @@ void wildcardMatch(int argc, char *argv[]) /* * if a command is registered with the "showUsage" flag set to "false" - * the PshellServer will invoke the command when the user types a "?" or + * the PshellServer will invoke the command when the user types a "?" or * "-h" rather than automatically giving the registered usage, the callback - * command can then see if the user asked for help (i.e. typed a "?" or + * command can then see if the user asked for help (i.e. typed a "?" or * "-h") by calling pshell_isHelp, the user can then display the standard * registered usage with the pshell_showUsage call and then give some * optional enhanced usage with the pshell_printf call */ /******************************************************************************/ -/******************************************************************************/ +/******************************************************************************/ void enhancedUsage(int argc, char *argv[]) { @@ -305,7 +305,7 @@ void advancedParsing(int argc, char *argv[]) * 'value_' will only be extracted if the option matches the requested option_ * name, */ - + /******************************************************************************/ /******************************************************************************/ void getOptions(int argc, char *argv[]) @@ -415,7 +415,7 @@ int main(int argc, char *argv[]) 1, /* minArgs */ 1, /* maxArgs */ true); /* showUsage on "?" */ - + pshell_addCommand(getOptions, /* function */ "getOptions", /* command */ "example of parsing command line options", /* description */ @@ -423,7 +423,7 @@ int main(int argc, char *argv[]) 2, /* minArgs */ 20, /* maxArgs */ false); /* showUsage on "?" */ - + /* * example of running in non-server mode, i.e. non-interactive, command line mode, * this will run the command as typed at the command line as a single-shot command @@ -431,6 +431,6 @@ int main(int argc, char *argv[]) * into the 'main' from the host's command line */ pshell_noServer(argc, argv); - + return (0); } diff --git a/c/demo/pshellServerDemo.cc b/c/demo/pshellServerDemo.cc index 36b4b1c..2c1c062 100644 --- a/c/demo/pshellServerDemo.cc +++ b/c/demo/pshellServerDemo.cc @@ -64,7 +64,7 @@ * remote client. The interface to this function is exactly the same as * the standard 'printf' function. */ - + /******************************************************************************/ /******************************************************************************/ void hello(int argc, char *argv[]) @@ -86,15 +86,15 @@ void world(int argc, char *argv[]) /* * this command shows an example client keep alive, - * the PSHELL UDP client has a default 5 second timeout, - * if a command will be known to take longer than 5 - * seconds, it must give some kind of output back to - * the client, this shows the two helper functions + * the PSHELL UDP client has a default 5 second timeout, + * if a command will be known to take longer than 5 + * seconds, it must give some kind of output back to + * the client, this shows the two helper functions * created the assist in this, the TCP client does not * need a keep alive since the TCP protocol itself * handles that */ - + /******************************************************************************/ /******************************************************************************/ void keepAlive(int argc, char *argv[]) @@ -219,16 +219,16 @@ void wildcardMatch(int argc, char *argv[]) /* * if a command is registered with the "showUsage" flag set to "false" - * the PshellServer will invoke the command when the user types a "?" or + * the PshellServer will invoke the command when the user types a "?" or * "-h" rather than automatically giving the registered usage, the callback - * command can then see if the user asked for help (i.e. typed a "?" or + * command can then see if the user asked for help (i.e. typed a "?" or * "-h") by calling pshell_isHelp, the user can then display the standard * registered usage with the pshell_showUsage call and then give some * optional enhanced usage with the pshell_printf call */ /******************************************************************************/ -/******************************************************************************/ +/******************************************************************************/ void enhancedUsage(int argc, char *argv[]) { @@ -376,7 +376,7 @@ void advancedParsing(int argc, char *argv[]) * 'value_' will only be extracted if the option matches the requested option_ * name, */ - + /******************************************************************************/ /******************************************************************************/ void getOptions(int argc, char *argv[]) @@ -586,7 +586,7 @@ int main(int argc, char *argv[]) 1, /* minArgs */ 1, /* maxArgs */ true); /* showUsage on "?" */ - + pshell_addCommand(getOptions, /* function */ "getOptions", /* command */ "example of parsing command line options", /* description */ @@ -594,12 +594,12 @@ int main(int argc, char *argv[]) 2, /* minArgs */ 20, /* maxArgs */ false); /* showUsage on "?" */ - + /* * example of issuing an pshell command from within a program, this can be done before * or after the server is started, as long as the command being called is regstered */ - + pshell_runCommand("hello"); /* @@ -608,7 +608,7 @@ int main(int argc, char *argv[]) * The 1st argument is our serverName (i.e. "pshellServerDemo"). * * The 2nd argument specifies the type of PSHELL server, the four valid values are: - * + * * PSHELL_UDP_SERVER - Server runs as a multi-session UDP based server. This requires * the special stand-alone command line UDP/UNIX client program * 'pshell'. This server has no timeout for idle client sessions. @@ -634,10 +634,10 @@ int main(int argc, char *argv[]) * control to the calling context. * PSHELL_BLOCKING - No thread is created, all processing of user input is done within * this function call, it will never return control to the calling context. - * + * * The 4th and 5th arguments must be provided for a UDP or TCP server, for a LOCAL or * UNIX server they can be omitted, and if provided they will be ignored. - * + * * For the 4th argument, a valid IP address or hostname can be used. There are also 3 special * "hostname" type identifiers defined as follows: * @@ -648,16 +648,16 @@ int main(int argc, char *argv[]) * * Finally, the 5th argument is the desired port number. * - * All of these arguments (except the server name and mode, i.e. args 1 & 3) can be overridden + * All of these arguments (except the server name and mode, i.e. args 1 & 3) can be overridden * via the 'pshell-server.conf' file on a per-server basis. * */ - + pshell_startServer("pshellServerDemo", serverType, PSHELL_BLOCKING, PSHELL_ANYHOST, port); - + /* should never get here, but cleanup any pshell system resources as good practice */ pshell_cleanupResources(); - + return (0); - + } diff --git a/c/demo/traceFilterDemo.cc b/c/demo/traceFilterDemo.cc index 0b165c4..ea8dcce 100644 --- a/c/demo/traceFilterDemo.cc +++ b/c/demo/traceFilterDemo.cc @@ -61,7 +61,7 @@ * this macro should be typically be placed at the very top of the source file * immediatly after all the 'include' statements */ -TF_SYMBOL_TABLE; +TF_SYMBOL_TABLE; /* a couple of functions to show function name filtering */ @@ -90,10 +90,10 @@ void bar(void) void *myThread(void*) { - /* + /* * add a trace thread name, this should be done in the initialization * of each thread (i.e. before the "infinite" loop), this will allow - * the TraceFilter to be able to do thread based filtering + * the TraceFilter to be able to do thread based filtering */ tf_registerThread("myThread"); @@ -177,10 +177,10 @@ void sampleLogFunction(const char *outputString_) * what to do with that string, i.e. write to stdout, write to * a custom logfile, write to syslog etc */ - + /* write to stdout */ printf("%s", outputString_); - + /* write to syslog */ syslog(LOG_INFO, "%s", outputString_); } @@ -313,7 +313,7 @@ int main (int argc, char *argv[]) * mechanism, this must register our trace levels before * calling 'tf_init' */ - + trace_registerLevels(); /* @@ -323,19 +323,19 @@ int main (int argc, char *argv[]) * function instead of 'tf_addLevel' directly so we can keep * track of our max level name string length so our trace display * can be formatted and aligned correctly - * + * * format of call is "name", level, isDefault, isMaskable */ trace_addUserLevel(TL_USER_LEVEL1_STRING, TL_USER_LEVEL1, false, true); trace_addUserLevel(TL_USER_LEVEL2_STRING, TL_USER_LEVEL2, false, true); - trace_addUserLevel(TL_USER_LEVEL3_STRING, TL_USER_LEVEL3, false, true); + trace_addUserLevel(TL_USER_LEVEL3_STRING, TL_USER_LEVEL3, false, true); /* * optionally set a log prefix, if not set, 'TRACE' will be used, * if set to 'NULL', no prefix will be used */ - + trace_setLogPrefix("demo"); /* @@ -347,19 +347,19 @@ int main (int argc, char *argv[]) * trace logging service will just use 'printf' to output the * log message */ - - /* open syslog with our program name */ + + /* open syslog with our program name */ openlog(argv[0], (LOG_CONS | LOG_PID | LOG_NDELAY), LOG_USER); - + /* register our log function */ trace_registerLogFunction(sampleLogFunction); - /* + /* * add a trace thread name, this should be done in the initialization * of each thread (i.e. before the "infinite" loop), this will allow - * the TraceFilter to be able to do thread based filtering + * the TraceFilter to be able to do thread based filtering */ - + tf_registerThread("main"); /* initialize our dynamic trace filtering feature, this should be done @@ -367,7 +367,7 @@ int main (int argc, char *argv[]) * any registration of pshell user commands and before starting the * pshell server */ - + tf_init(); /* @@ -392,9 +392,9 @@ int main (int argc, char *argv[]) * change will be shown, if the control is TF_ABORT, a program termination (with core file) * will be forced upon the first detected change */ - + TF_WATCH("watchAddress", &watchAddress, sizeof(watchAddress), "0x%x", TF_CONTINUOUS); - + /* * register a callback function to be called at every trace statement, the function must * return either 'true' or 'false', an indication will be printed upon the first transition @@ -403,7 +403,7 @@ int main (int argc, char *argv[]) * to TF_ABORT, a program termination (with core file) will be forced upon the first detected * transition */ - + TF_CALLBACK("callbackFunction", callbackFunction, TF_CONTINUOUS); /* issue a trace so we can trigger the TRACE_WATCH functionality */ @@ -411,7 +411,7 @@ int main (int argc, char *argv[]) /* start our pshell server */ pshell_startServer("traceFilterDemo", serverType, PSHELL_NON_BLOCKING, PSHELL_LOCALHOST, port); - + /* create a sample thread to show thread based filtering */ pthread_t threadId; pthread_create(&threadId, NULL, myThread, NULL); @@ -442,10 +442,10 @@ int main (int argc, char *argv[]) TRACE_USER_LEVEL3("message 8"); sleep(1); } - + /* should never get here, but cleanup any pshell system resources as good practice */ pshell_cleanupResources(); - + return (0); - + } diff --git a/c/demo/traceLogDemo.cc b/c/demo/traceLogDemo.cc index 532273d..899aee6 100644 --- a/c/demo/traceLogDemo.cc +++ b/c/demo/traceLogDemo.cc @@ -74,10 +74,10 @@ void sampleLogFunction(const char *outputString_) * what to do with that string, i.e. write to stdout, write to * a custom logfile, write to syslog etc */ - + /* write to stdout */ printf("%s", outputString_); - + /* write to syslog */ syslog(LOG_INFO, "%s", outputString_); } @@ -135,7 +135,7 @@ int main (int argc, char *argv[]) showUsage(); return (0); } - + #ifndef TRACE_LOG_DISABLED /* initialize a sample memory hex dump buffer */ for (unsigned i = 0; i < DUMP_BUFFER_SIZE; i++) @@ -145,24 +145,24 @@ int main (int argc, char *argv[]) #endif /* - * register our standard trace levels with the trace log system + * register our standard trace levels with the trace log system * so our trace display can be formatted and aligned correctly */ - + trace_registerLevels(); /* * register our program specific trace log levels with the trace log system - * this must be done after registering our standard levels so we can keep - * track of our max level name string length so our trace display can be + * this must be done after registering our standard levels so we can keep + * track of our max level name string length so our trace display can be * formatted and aligned correctly - * + * * format of call is "name", level */ trace_addUserLevel(TL_USER_LEVEL1_STRING, TL_USER_LEVEL1); trace_addUserLevel(TL_USER_LEVEL2_STRING, TL_USER_LEVEL2); - trace_addUserLevel(TL_USER_LEVEL3_STRING, TL_USER_LEVEL3); + trace_addUserLevel(TL_USER_LEVEL3_STRING, TL_USER_LEVEL3); /* set our log level */ trace_setLogLevel(logLevel); @@ -171,7 +171,7 @@ int main (int argc, char *argv[]) * optionally set a log prefix, if not set, 'TRACE' will be used, * if set to 'NULL', no prefix will be used */ - + trace_setLogPrefix("demo"); /* @@ -183,10 +183,10 @@ int main (int argc, char *argv[]) * trace logging service will just use 'printf' to output the * log message */ - - /* open syslog with our program name */ + + /* open syslog with our program name */ openlog(argv[0], (LOG_CONS | LOG_PID | LOG_NDELAY), LOG_USER); - + /* register our log function */ trace_registerLogFunction(sampleLogFunction); @@ -216,7 +216,7 @@ int main (int argc, char *argv[]) TRACE_USER_LEVEL3("message 8"); sleep(1); } - + return (0); - + } diff --git a/c/include/PshellCommon.h b/c/include/PshellCommon.h index b08821c..2f6c9c0 100644 --- a/c/include/PshellCommon.h +++ b/c/include/PshellCommon.h @@ -1,27 +1,27 @@ /******************************************************************************* * - * Copyright (c) 2009, Ron Iovine, All rights reserved. + * Copyright (c) 2009, Ron Iovine, All rights reserved. * - * Redistribution and use in source and binary forms, with or without + * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * * Neither the name of Ron Iovine nor the names of its contributors - * may be used to endorse or promote products derived from this software + * * Neither the name of Ron Iovine nor the names of its contributors + * may be used to endorse or promote products derived from this software * without specific prior written permission. * - * THIS SOFTWARE IS PROVIDED BY Ron Iovine ''AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL Ron Iovine BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR - * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER - * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * THIS SOFTWARE IS PROVIDED BY Ron Iovine ''AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL Ron Iovine BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR + * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * *******************************************************************************/ @@ -31,18 +31,18 @@ #include -/* +/* * this file contains items that are used in common * between the pshell UDP/UNIX client and server */ #define PSHELL_UNIX_SOCKET_PATH "/tmp" -/* - * this is just used for the initial receive message used by the - * UDP/UNIX client, the actual payload size is then negotiated between - * the UDP/UNIX client and server, this is also used as-is for the client - * side transmit message (i.e. in the "send"), so the payload size +/* + * this is just used for the initial receive message used by the + * UDP/UNIX client, the actual payload size is then negotiated between + * the UDP/UNIX client and server, this is also used as-is for the client + * side transmit message (i.e. in the "send"), so the payload size * needs to be big enough for any reasonable sized command and * its arguments */ @@ -67,14 +67,14 @@ struct PshellMsg #define PSHELL_HEADER_SIZE sizeof(PshellMsgHdr) -/* +/* * the first message exchanged on the UDP/UNIX client/server handshake - * is a request for the version info, the client and server need - * to be running compatible versions for the session to continue. - * The version number should only be changed if the actual handshaking + * is a request for the version info, the client and server need + * to be running compatible versions for the session to continue. + * The version number should only be changed if the actual handshaking * protocol used between the client and server changes */ - + #define PSHELL_VERSION_1 1 #define PSHELL_VERSION PSHELL_VERSION_1 diff --git a/c/include/PshellControl.h b/c/include/PshellControl.h index 948b8c7..8b252b2 100644 --- a/c/include/PshellControl.h +++ b/c/include/PshellControl.h @@ -1,27 +1,27 @@ /******************************************************************************* * - * Copyright (c) 2009, Ron Iovine, All rights reserved. + * Copyright (c) 2009, Ron Iovine, All rights reserved. * - * Redistribution and use in source and binary forms, with or without + * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * * Neither the name of Ron Iovine nor the names of its contributors - * may be used to endorse or promote products derived from this software + * * Neither the name of Ron Iovine nor the names of its contributors + * may be used to endorse or promote products derived from this software * without specific prior written permission. * - * THIS SOFTWARE IS PROVIDED BY Ron Iovine ''AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL Ron Iovine BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR - * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER - * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * THIS SOFTWARE IS PROVIDED BY Ron Iovine ''AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL Ron Iovine BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR + * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * *******************************************************************************/ @@ -44,7 +44,7 @@ extern "C" { * provides a very lightweight way to provide a control mechanism into a program * that is running a pshell, this is analagous to a remote procedure call (rpc). * - * A complete example of the usage of the API can be found in the included + * A complete example of the usage of the API can be found in the included * demo programs pshellControlDemo.cc and pshellAggregatorDemo.cc * *******************************************************************************/ @@ -85,8 +85,8 @@ enum PshellControlResponse * the following "COMMAND" enums are returned by the remote pshell server * and must match their corresponding values in PshellServer.cc */ - PSHELL_COMMAND_SUCCESS, - PSHELL_COMMAND_NOT_FOUND, + PSHELL_COMMAND_SUCCESS, + PSHELL_COMMAND_NOT_FOUND, PSHELL_COMMAND_INVALID_ARG_COUNT, /* the following "SOCKET" enums are generated internally by the pshell_sendCommandN functions */ PSHELL_SOCKET_SEND_FAILURE, @@ -98,7 +98,7 @@ enum PshellControlResponse /* * pshell_getResponseString: - * + * * map the above enums to their corresponding strings */ const char *pshell_getResponseString(int results_); @@ -115,12 +115,12 @@ const char *pshell_getResponseString(int results_); * from the remote command in the pshell_sendCommandN functions, a timeout * value of 0 will not wait for a response, in which case the function * will return either PSHELL_SOCKET_NOT_CONNECTED, PSHELL_SOCKET_SEND_FAILURE, - * or PSHELL_COMMAND_SUCCESS, the timeout value entered in this funcition - * will be used as the default timeout for all calls to pshell_sendCommandN - * that do not provide an override timeout value, for a UDP server, the - * remoteServer must be either a valid hostname or IP address and a valid - * destination port must be provided, for a UNIX server, only a valid server - * name must be provided along with the identifier PSHELL_UNIX_CONTROL (i.e. 0) + * or PSHELL_COMMAND_SUCCESS, the timeout value entered in this funcition + * will be used as the default timeout for all calls to pshell_sendCommandN + * that do not provide an override timeout value, for a UDP server, the + * remoteServer must be either a valid hostname or IP address and a valid + * destination port must be provided, for a UNIX server, only a valid server + * name must be provided along with the identifier PSHELL_UNIX_CONTROL (i.e. 0) * for the 'port' parameter * * this function returns a Server ID (sid) handle which must be saved and @@ -182,9 +182,9 @@ void pshell_extractCommands(int sid_, char *results_, int size_); /* * pshell_addMulticast: - * - * this command will add a given multicast receiver (i.e. sid) to a multicast - * group, multicast groups are based either on the command's keyword, or if + * + * this command will add a given multicast receiver (i.e. sid) to a multicast + * group, multicast groups are based either on the command's keyword, or if * no keyword is supplied, the given sid will receive all multicast commands */ #define PSHELL_MULTICAST_ALL "__all__" @@ -193,12 +193,12 @@ void pshell_addMulticast(int sid_, const char *keyword_ = PSHELL_MULTICAST_ALL); /* * pshell_sendMulticast: - * + * * this command will send a given command to all the registered multicast - * receivers (i.e. sids) for this multicast group, multicast groups are - * based on the command's keyword, this function will issue the command as - * a best effort fire-and-forget command to each receiver in the multicast - * group, no results will be requested or expected, and no response will be + * receivers (i.e. sids) for this multicast group, multicast groups are + * based on the command's keyword, this function will issue the command as + * a best effort fire-and-forget command to each receiver in the multicast + * group, no results will be requested or expected, and no response will be * requested or expected */ void pshell_sendMulticast(const char *command_, ...); @@ -215,7 +215,7 @@ void pshell_sendMulticast(const char *command_, ...); * * there are 4 version of this command, since we are using standard 'C' linkage, * we cannot overload the function names, hence the separate names - * + * * the return of the following 4 functions is one of the PshellControlResponse enums */ int pshell_sendCommand1(int sid_, const char *command_, ...); @@ -225,8 +225,8 @@ int pshell_sendCommand2(int sid_, unsigned timeoutOverride_, const char *command * the following two commands will issue the remote command and extract any * results that are returned in the payload of the message, this will only * work with a non-0 timeout and a return result of PSHELL_COMMAND_SUCCESS, - * the data in the payload is NULL terminated ascii formatted character data, - * it is the responsibility of the calling application to parse & understand + * the data in the payload is NULL terminated ascii formatted character data, + * it is the responsibility of the calling application to parse & understand * the results */ int pshell_sendCommand3(int sid_, char *results_, int size_, const char *command_, ...); diff --git a/c/include/PshellReadline.h b/c/include/PshellReadline.h index bc2c598..17b27d0 100644 --- a/c/include/PshellReadline.h +++ b/c/include/PshellReadline.h @@ -1,27 +1,27 @@ /******************************************************************************* * - * Copyright (c) 2009, Ron Iovine, All rights reserved. + * Copyright (c) 2009, Ron Iovine, All rights reserved. * - * Redistribution and use in source and binary forms, with or without + * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * * Neither the name of Ron Iovine nor the names of its contributors - * may be used to endorse or promote products derived from this software + * * Neither the name of Ron Iovine nor the names of its contributors + * may be used to endorse or promote products derived from this software * without specific prior written permission. * - * THIS SOFTWARE IS PROVIDED BY Ron Iovine ''AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL Ron Iovine BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR - * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER - * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * THIS SOFTWARE IS PROVIDED BY Ron Iovine ''AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL Ron Iovine BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR + * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * *******************************************************************************/ @@ -88,7 +88,7 @@ extern "C" { enum PshellTabStyle { PSHELL_RL_FAST_TAB, - PSHELL_RL_BASH_TAB + PSHELL_RL_BASH_TAB }; /* @@ -166,7 +166,7 @@ bool pshell_rl_isSubString(const char *string1_, /* * pshell_rl_addTabCompletion: - * + * * Add a keyword to the TAB completion list. TAB completion will only be applied * to the first keyword of a given user typed command */ @@ -174,7 +174,7 @@ void pshell_rl_addTabCompletion(const char *keyword_); /* * pshell_rl_setTabStyle: - * + * * Set the tabbing method to either be bash/readline style tabbing, i.e. double * tabbing to initiate and display completions, or "fast" tabbing, where all * completions and displays are initiated via a single tab only, the default is @@ -185,7 +185,7 @@ void pshell_rl_setTabStyle(PshellTabStyle tabStyle_); /* * pshell_rl_setIdleTimeout: - * + * * Set the idle session timeout as described above. Use the identifiers * PSHELL_RL_ONE_SEC and PSHELL_RL_ONE_MINUTE as follows, e.g. PSHELL_RL_ONE_MINUTE*5 * for a 5 minute idleSession timeout. diff --git a/c/include/PshellServer.h b/c/include/PshellServer.h index 903e720..cbb4117 100644 --- a/c/include/PshellServer.h +++ b/c/include/PshellServer.h @@ -1,27 +1,27 @@ /******************************************************************************* * - * Copyright (c) 2009, Ron Iovine, All rights reserved. + * Copyright (c) 2009, Ron Iovine, All rights reserved. * - * Redistribution and use in source and binary forms, with or without + * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * * Neither the name of Ron Iovine nor the names of its contributors - * may be used to endorse or promote products derived from this software + * * Neither the name of Ron Iovine nor the names of its contributors + * may be used to endorse or promote products derived from this software * without specific prior written permission. * - * THIS SOFTWARE IS PROVIDED BY Ron Iovine ''AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL Ron Iovine BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR - * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER - * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * THIS SOFTWARE IS PROVIDED BY Ron Iovine ''AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL Ron Iovine BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR + * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * *******************************************************************************/ @@ -46,7 +46,7 @@ extern "C" { * embedded functions based on how the pshell server is configured, which is * described in documentation further down in this file. * - * A complete example of the usage of the API can be found in the included + * A complete example of the usage of the API can be found in the included * demo program file pshellServerDemo.cc * *******************************************************************************/ @@ -72,7 +72,7 @@ enum PshellServerType PSHELL_UDP_SERVER, PSHELL_TCP_SERVER, PSHELL_UNIX_SERVER, - PSHELL_LOCAL_SERVER + PSHELL_LOCAL_SERVER }; /* @@ -86,15 +86,15 @@ enum PshellServerType enum PshellServerMode { PSHELL_BLOCKING, - PSHELL_NON_BLOCKING + PSHELL_NON_BLOCKING }; /* - * These four identifiers that can be used for the hostnameOrIpAddr argument + * These four identifiers that can be used for the hostnameOrIpAddr argument * of the startServer call. PSHELL_ANYHOST will bind the server socket * to all interfaces of a multi-homed host, PSHELL_ANYBCAST will bind to - * 255.255.255.255, PSHELL_LOCALHOST will bind the server socket to the - * local loopback address (i.e. 127.0.0.1), and PSHELL_MYHOST will bind + * 255.255.255.255, PSHELL_LOCALHOST will bind the server socket to the + * local loopback address (i.e. 127.0.0.1), and PSHELL_MYHOST will bind * to the default interface (i.e. eth0), note that subnet broadcast is * also supported, e.g. x.y.z.255 */ @@ -109,7 +109,7 @@ enum PshellServerMode /* * pshell_setServerLogLevel: - * + * * function and constants to let the host program set the * internal debug log level, if the user of this API does * not want to see any internal message printed out, set @@ -126,7 +126,7 @@ void pshell_setServerLogLevel(unsigned level_); /* * pshell_registerServerLogFunction: - * + * * typedef and function to allow the host program to register a logging * function for message output logging, if no output function is registered * 'printf' will be used to print out the log messages @@ -135,44 +135,44 @@ typedef void (*PshellLogFunction)(const char *outputString_); void pshell_registerServerLogFunction(PshellLogFunction logFunction_); /* - * PSHELL user callback function prototype definition, the interface - * is similar to the "main" in C, with the argc being the argument - * count (excluding the actual command itself), and argv[] being the + * PSHELL user callback function prototype definition, the interface + * is similar to the "main" in C, with the argc being the argument + * count (excluding the actual command itself), and argv[] being the * argument list (also excluding the actual command), the interface * can be changed to include the actual command in argc and argv by * compiling the library with the command line compile option of * PSHELL_INCLUDE_COMMAND_IN_ARGS_LIST */ -typedef void (*PshellFunction)(int argc_, char *argv_[]); +typedef void (*PshellFunction)(int argc_, char *argv_[]); /* * pshell_addCommand: - * + * * this is the function used to register pshell commands, if the command * takes no arguments, the minArgs and maxArgs should be 0 and the usage * should be NULL, a usage is required if the command takes any arguments, * if the command takes a fixed number of arguments, then set minArgs and * maxArgs equal to that fixed count, if the parameter count validation * fails, the command will not be dispatched and the usage will be shown, - * if the showUsage argument is set to "true", then the PshellServer will - * display the registered usage upon the user typing a "?" or "-h" after - * the command, the command will not be dispatched, if this argument is set - * to "false", the command will be dispatched, the command can then call + * if the showUsage argument is set to "true", then the PshellServer will + * display the registered usage upon the user typing a "?" or "-h" after + * the command, the command will not be dispatched, if this argument is set + * to "false", the command will be dispatched, the command can then call * the pshell_isHelp function below to determine if the user is requesting * help, finally, the function's command cannot contain any whitespace (i.e. * multi-keyword commands are not supported) */ void pshell_addCommand(PshellFunction function_, - const char *command_, - const char *description_, - const char *usage_ = NULL, - unsigned char minArgs_ = 0, - unsigned char maxArgs_ = 0, + const char *command_, + const char *description_, + const char *usage_ = NULL, + unsigned char minArgs_ = 0, + unsigned char maxArgs_ = 0, bool showUsage_ = true); /* * pshell_runCommand: - * + * * this function can be called from within a program in order to execute any * locally registered callback functions, the passed in string command should * be the exact same format as when calling the same desired command interactively @@ -182,61 +182,61 @@ void pshell_addCommand(PshellFunction function_, void pshell_runCommand(const char *command_, ...); /* - * pshell_noServer: - * - * this function is used to run in non-server mode, i.e. non-interactive, command - * line mode, this will run the command as typed at the host's command line as a - * single-shot command and exit, this command must be run with the initial argc, - * argv as they are passed into the 'main' from the command line, see the example - * demo program pshellNoServerDemo.cc that is included with this package for the + * pshell_noServer: + * + * this function is used to run in non-server mode, i.e. non-interactive, command + * line mode, this will run the command as typed at the host's command line as a + * single-shot command and exit, this command must be run with the initial argc, + * argv as they are passed into the 'main' from the command line, see the example + * demo program pshellNoServerDemo.cc that is included with this package for the * usage of this function */ -void pshell_noServer(int argc_, char *argv_[]); +void pshell_noServer(int argc_, char *argv_[]); /* * pshell_startServer: - * + * * this is the command used to start the pshell server, this function can * be invoked in either blocking or non-blocking mode, non-blocking mode * will create a separate thread to process the user input and return, * blocking mode will process the user input directly from this function, * i.e. it will never return control to the calling context - * - * this command can only be invoked once per-process, an error message is + * + * this command can only be invoked once per-process, an error message is * displayed if a program tries to invoke this more than once - * + * * see the example demo program pshellServerDemo.cc that is included with * this package for the usage of this function * * NOTE: for a LOCAL or UNIX server, the last two parameters should be omitted */ -void pshell_startServer(const char *serverName_, +void pshell_startServer(const char *serverName_, PshellServerType serverType_, PshellServerMode serverMode_, - const char *hostnameOrIpAddr_ = NULL, + const char *hostnameOrIpAddr_ = NULL, unsigned port_ = 0); /* * pshell_cleanupResources: - * - * this is the command used to cleanup any system resources associated with - * a pshell server upon program termination, either via a normal, graceful - * termination or via a signal handler exception based termination, this is - * only really necessary for a 'unix' type pshell server in order to cleanup + * + * this is the command used to cleanup any system resources associated with + * a pshell server upon program termination, either via a normal, graceful + * termination or via a signal handler exception based termination, this is + * only really necessary for a 'unix' type pshell server in order to cleanup * the temporary file handle in the /tmp directory that is associated with the - * server, although as good practice, this function should be called upon program + * server, although as good practice, this function should be called upon program * termination regardless of the server type */ void pshell_cleanupResources(void); /* - * the following commands should ONLY be called from + * the following commands should ONLY be called from * within the scope of a PSHELL callback function */ /* * pshell_printf: - * + * * this is the command used to display user data back the the pshell client, * the interface is exactly the same as the normal printf, the UDP/UNIX * pshell client has a default 5 second response timeout (which can be changed @@ -251,7 +251,7 @@ void pshell_printf(const char *format_, ...); /* * pshell_flush: - * + * * this command is used to flush the transfer buffer from the pshell server * back to the client, which will then display the contents of the buffer * to the user, this only has an effect with a UDP, UNIX, or LOCAL server, @@ -261,7 +261,7 @@ void pshell_printf(const char *format_, ...); void pshell_flush(void); /* - * these helper commands are used to keep the UDP/UNIX client alive with output + * these helper commands are used to keep the UDP/UNIX client alive with output * if a command is known to take longer than the 5 second client timeout */ void pshell_wheel(const char *string_ = NULL); /* spinning ascii wheel, user string string is optional */ @@ -269,15 +269,15 @@ void pshell_march(const char *string_); /* march a string or character a /* * pshell_isHelp: - * - * this function will return "true" if the user types a '?' - * or '-h' after the command name, this can be checked from - * within a callback function to see if the user asked for - * help, the command MUST be registered with the "showUsage" - * arg set to "false" in its addCommand registration, otherwise + * + * this function will return "true" if the user types a '?' + * or '-h' after the command name, this can be checked from + * within a callback function to see if the user asked for + * help, the command MUST be registered with the "showUsage" + * arg set to "false" in its addCommand registration, otherwise * the PSHELL server itself will give the registered usage on * a '?' or '-h' without dispatching the command - */ + */ bool pshell_isHelp(void); /* @@ -316,11 +316,11 @@ bool pshell_getOption(const char *string_, char *option_, char *value_); /* * format checking functions: - * + * * the following functions are some simple helper functions - * to assist in interpreting the string based command line + * to assist in interpreting the string based command line * arguments, note that unlike some of the previous functions, - * the remaining functions do not need to be called strictly + * the remaining functions do not need to be called strictly * from within the context of a pshell callback function */ unsigned pshell_getLength(const char *string_); @@ -332,15 +332,15 @@ bool pshell_isAlpha(const char *string_); bool pshell_isAlphaNumeric(const char *string_); bool pshell_isDec(const char *string_); /* if needHexPrefix == true, format is 0x, if needHexPrefix == false, format is */ -bool pshell_isHex(const char *string_, bool needHexPrefix_ = true); +bool pshell_isHex(const char *string_, bool needHexPrefix_ = true); bool pshell_isNumeric(const char *string_, bool needHexPrefix_ = true); /* isDec || isHex */ bool pshell_isFloat(const char *string_); /* * various data extraction functions: - * + * * the following functions are some simple helper functions - * to assist in converting the string based command line + * to assist in converting the string based command line * arguments to other data types */ @@ -358,11 +358,11 @@ enum PshellRadix PSHELL_RADIX_ANY /* will transparently work for or 0x */ }; -/* +/* * integer extraction functions: - * + * * return numeric values from string value, the needHexPrefix parameter is only used - * for a radix of PSHELL_RADIX_HEX, if set to true, the value needs to be preceeded + * for a radix of PSHELL_RADIX_HEX, if set to true, the value needs to be preceeded * by the 0x identifier, if set to false, then the prefix is not necessary */ long pshell_getLong(const char *string_, PshellRadix radix_ = PSHELL_RADIX_ANY, bool needHexPrefix_ = true); @@ -374,8 +374,8 @@ unsigned long pshell_getUnsignedLong(const char *string_, PshellRadix radix_ = P unsigned short pshell_getUnsignedShort(const char *string_, PshellRadix radix_ = PSHELL_RADIX_ANY, bool needHexPrefix_ = true); unsigned char pshell_getUnsignedChar(const char *string_, PshellRadix radix_ = PSHELL_RADIX_ANY, bool needHexPrefix_ = true); -/* - * floating point extraction functions +/* + * floating point extraction functions */ float pshell_getFloat(const char *string_); double pshell_getDouble(const char *string_); diff --git a/c/include/TraceFilter.h b/c/include/TraceFilter.h index f8bff20..daade51 100644 --- a/c/include/TraceFilter.h +++ b/c/include/TraceFilter.h @@ -133,7 +133,7 @@ bool tf_isFilterPassed(const char *file_, /* * the following two functions should not be called directly, but * rather should only be call via their respective following macros - */ + */ void tf_watch(const char *file_, int line_, const char *function_, @@ -142,7 +142,7 @@ void tf_watch(const char *file_, int width_, const char *format_, tf_TraceControl control_); - + void tf_callback(const char *file_, int line_, const char *function_, @@ -153,7 +153,7 @@ void tf_callback(const char *file_, /* * macro to registger a memory location to watch at every trace statement, * use this instead of a direct call to tf_watch - */ + */ #define TF_WATCH(symbol, address, width, format, control) \ tf_watch(__FILE__, __LINE__, __FUNCTION__, symbol, address, width, format, control) diff --git a/c/include/TraceLog.h b/c/include/TraceLog.h index 9b8ee8c..00a4616 100644 --- a/c/include/TraceLog.h +++ b/c/include/TraceLog.h @@ -67,7 +67,7 @@ extern "C" { #define TL_DEFAULT_LEVEL TL_FAILURE /* define the string based names of the trace levels */ -#define TL_ERROR_STRING "Error" +#define TL_ERROR_STRING "Error" #define TL_WARNING_STRING "Warning" #define TL_FAILURE_STRING "Failure" #define TL_INFO_STRING "Info" @@ -77,12 +77,12 @@ extern "C" { #define TL_DUMP_STRING "Dump" #define TL_FORCE_STRING "Force" -/* +/* * the following are some example TRACE macros to illustrate integrating the * function 'tf_isFilterPassed' into an existing trace logging system to provide * dynamic trace control via an integrated pshell server, the existing trace * logging utility must utilize the __FILE__, __FUNCTION__, __LINE__ (and - * optionally a 'level') trace logging paradigm + * optionally a 'level') trace logging paradigm */ /* trace output macros, these are called directly by client code */ @@ -150,7 +150,7 @@ void trace_registerLevels(void); */ void trace_addUserLevel(const char *levelName_, unsigned levelValue_, bool isDefault_ = false, bool isMaskable_ = true); -/* +/* * if we are using a stand-alone traceLog system and not integrating it into the * traceFilter mechanism we need to provide an internal trace log level and a way * to set it @@ -159,7 +159,7 @@ void trace_addUserLevel(const char *levelName_, unsigned levelValue_, bool isDef /* * trace_setLogLevel: - * + * * this function is used to set the internal trace log level when this module * is built with the DYNAMIC_TRACE_FILTER flag NOT set (i.e. stand-alone mode) */ @@ -167,7 +167,7 @@ void trace_setLogLevel(unsigned _logLevel); /* * trace_getLogLevel: - * + * * this function is used to return the internal trace log level when this module * is built with the DYNAMIC_TRACE_FILTER flag NOT set (i.e. stand-alone mode) */ @@ -232,11 +232,11 @@ void trace_enablePrefix(bool enable_); bool trace_isPrefixEnabled(void); /**************************************************************************** - * + * * NOTE: There are no public APIs beyhond this point, all public functional * APIs and macros appear above this section, do not call anything * below this section directly!! - * + * ****************************************************************************/ /* @@ -257,8 +257,8 @@ extern void trace_outputDump(void *address_, unsigned length_, const char *type_ #ifdef DYNAMIC_TRACE_FILTER -/* - * dynamic trace filtering enabled, use the tf_isFilterPassed function in the dynamic +/* + * dynamic trace filtering enabled, use the tf_isFilterPassed function in the dynamic * trace filter module to determine if a given trace should be printed out */ #define __TRACE(level, name, format, args...) if (tf_isFilterPassed(__FILE__, __LINE__, __FUNCTION__, level)) {trace_outputLog(name, __FILE__, __FUNCTION__, __LINE__, format, ## args);} @@ -266,9 +266,9 @@ extern void trace_outputDump(void *address_, unsigned length_, const char *type_ #else /* stand-alone trace logs (i.e. no dynamic filtering) */ -/* +/* * dynamic trace filtering not enabled, use use a simple compare of the desired hierarchical - * trace level against the configures trace level to determine if a given trace should be + * trace level against the configures trace level to determine if a given trace should be * printed out */ extern unsigned _traceLogLevel; diff --git a/c/lib/libpshell-control.a b/c/lib/libpshell-control.a index 165b3ec..e582ed0 100644 Binary files a/c/lib/libpshell-control.a and b/c/lib/libpshell-control.a differ diff --git a/c/lib/libpshell-readline.a b/c/lib/libpshell-readline.a index 0cec228..da93a5d 100644 Binary files a/c/lib/libpshell-readline.a and b/c/lib/libpshell-readline.a differ diff --git a/c/lib/libpshell-server-full.a b/c/lib/libpshell-server-full.a index 3e71244..349e6da 100644 Binary files a/c/lib/libpshell-server-full.a and b/c/lib/libpshell-server-full.a differ diff --git a/c/lib/libpshell-server-stub.a b/c/lib/libpshell-server-stub.a index 4a1ec7e..48ab5ee 100644 Binary files a/c/lib/libpshell-server-stub.a and b/c/lib/libpshell-server-stub.a differ diff --git a/c/man/man1/pshell.1 b/c/man/man1/pshell.1 index b086fd5..4431f84 100644 --- a/c/man/man1/pshell.1 +++ b/c/man/man1/pshell.1 @@ -1,4 +1,4 @@ -.TH pshell 1 "Sep 2012" "PSHELL" "PSHELL - Process Specific Embedded Command Line Shell" +.TH pshell 1 "Sep 2012" "PSHELL" "PSHELL - Process Specific Embedded Command Line Shell" .SH NAME pshell/pshell.exp - PSHELL UDP/UNIX client program/Telnet TCP client 'expect' script wrapper .SH DESCRIPTION @@ -12,7 +12,7 @@ UDP or UNIX based PshellServer. The corresponding 'pshell.exp' 'expect' script provides a wrapper around a standard 'telnet' client to give a similar functionality (i.e. batch mode, command line mode etc) for programs -that are running a TCP based PshellServer as the 'pshell' UDP/UNIX client program . Use of +that are running a TCP based PshellServer as the 'pshell' UDP/UNIX client program . Use of the 'pshell.exp' script is optional, the 'telnet' client can be used directly to interface to a TCP PshellServer, however, only interactive mode is supported. @@ -39,7 +39,7 @@ Usage: pshell -s | [-t] {{ } | NOTE: If no is given, pshell will be started up in interactive mode, commands issued in command - line mode that require arguments must be enclosed + line mode that require arguments must be enclosed in double quotes, commands issued in interactive mode that require arguments do not require double quotes. diff --git a/c/man/man1/pshellAggregator.1 b/c/man/man1/pshellAggregator.1 index c5d91b0..a8cd00d 100644 --- a/c/man/man1/pshellAggregator.1 +++ b/c/man/man1/pshellAggregator.1 @@ -1,28 +1,28 @@ -.TH pshellAggregator 1 "Sep 2012" "PSHELL" "PSHELL - Process Specific Embedded Command Line Shell" +.TH pshellAggregator 1 "Sep 2012" "PSHELL" "PSHELL - Process Specific Embedded Command Line Shell" .SH NAME pshellAggregator - PSHELL UDP/UNIX client remote server aggregator program .SH DESCRIPTION This stand-alone client allows several remote UDP/UNIX pshell servers to be consolidated into one interactive client shell. There is a binary 'C' version as well as Python version. -This can be useful in presenting a consolidated user shell who's functionality spans -several discrete pshell servers. Since this uses the PshellControl API, the external -servers must all be either UDP or Unix servers. The consolidation point a local pshell +This can be useful in presenting a consolidated user shell who's functionality spans +several discrete pshell servers. Since this uses the PshellControl API, the external +servers must all be either UDP or Unix servers. The consolidation point a local pshell server. This is a generic dynamic aggregator, i.e. it is server agnostic. Servers can be added to the aggregation via the 'add server' command either at startup via -the pshellAggregator.startup file or interactively via the interactive command +the pshellAggregator.startup file or interactively via the interactive command line. -This program can also create multicast groups commands via the 'add multicast' command -(also at startup or interactively). The multicast commands can then be distributed +This program can also create multicast groups commands via the 'add multicast' command +(also at startup or interactively). The multicast commands can then be distributed to multiple aggregated servers. This program replaces the old, static, hard-wired, pshellAggregatorDemo.py program which hard-coded the remote servers to aggregate. -The aggregation and multicast functionality can be useful to manually drive a set +The aggregation and multicast functionality can be useful to manually drive a set of processes that use the pshell control mechanism as a control plane IPC. .SH USAGE Usage: pshellAggregator diff --git a/c/man/man3/PshellControl.3 b/c/man/man3/PshellControl.3 index f75a3e3..beaadba 100644 --- a/c/man/man3/PshellControl.3 +++ b/c/man/man3/PshellControl.3 @@ -1,4 +1,4 @@ -.TH PshellControl 3 "Sep 2012" "PSHELL" "External Client Control Of Remote Pshell" +.TH PshellControl 3 "Sep 2012" "PSHELL" "External Client Control Of Remote Pshell" .SH NAME PshellControl - External Client Program Control of Remote PSHELL Server .SH DESCRIPTION @@ -15,7 +15,7 @@ int pshell_connectServer(const char *controlName_, const char *remoteServer_, unsigned port_ = PSHELL_UNIX_SERVER, unsigned defaultTimeout_ = PSHELL_ONE_MSEC*100); - + /* release resources for this connection */ void pshell_disconnectServer(int sid_); @@ -47,11 +47,11 @@ Link with the library libpshell-control Note, there is also python and go version implementations of this functionality in the modules 'PshellControl.py' and 'PshellControl.go' - + Their APIs and examples can be found in their corresponding language based directories of this install package. .SH EXAMPLES -See the file pshellControlDemo.cc in the pshell distribution package for a complete +See the file pshellControlDemo.cc in the pshell distribution package for a complete list of examples of invoking functions in a remote pshell via a local client program. .SH MT-LEVEL Safe diff --git a/c/man/man3/PshellReadline.3 b/c/man/man3/PshellReadline.3 index 704b24a..82099ff 100644 --- a/c/man/man3/PshellReadline.3 +++ b/c/man/man3/PshellReadline.3 @@ -1,11 +1,11 @@ -.TH PshellReadline 3 "Sep 2012" "PSHELL" "Readline Like Functionality" +.TH PshellReadline 3 "Sep 2012" "PSHELL" "Readline Like Functionality" .SH NAME PshellReadline - API and library to provide readline like user input functionality .SH DESCRIPTION This API implements a readline like functionality for user input. This can -work with any character stream based input/output terminal device, i.e. -keyboard input over a serial tty, or over a TCP/telnet connection. This module -will provide up-arrow command history recall, command line editing, and TAB +work with any character stream based input/output terminal device, i.e. +keyboard input over a serial tty, or over a TCP/telnet connection. This module +will provide up-arrow command history recall, command line editing, and TAB completion of registered keywords. .SH SYNOPSIS @@ -50,7 +50,7 @@ Note, there is also a corresponding python implementation of this functionality the module 'PshellReadline.py'. Its API and examples can be found in the python subdirectory of this install package. .SH EXAMPLES -See the file pshellReadlineDemo.cc in the pshell distribution package for a complete +See the file pshellReadlineDemo.cc in the pshell distribution package for a complete example of using the various parts of the API for this module/library. .SH MT-LEVEL Safe diff --git a/c/man/man3/PshellServer.3 b/c/man/man3/PshellServer.3 index c4c8338..f2e2baa 100644 --- a/c/man/man3/PshellServer.3 +++ b/c/man/man3/PshellServer.3 @@ -1,15 +1,15 @@ -.TH PshellServer 3 "Sep 2012" "PSHELL" "Process Specific Embedded Command Line Shell" +.TH PshellServer 3 "Sep 2012" "PSHELL" "Process Specific Embedded Command Line Shell" .SH NAME PshellServer - A Lightweight, Process-Specific, Embedded Command Line Shell .SH DESCRIPTION The PshellServer will provide the API for embedding a lightweight CLI into any C/C++ program. The PshellServer can run as either a UDP, TCP, UNIX, or LOCAL. -server. The UDP and UNIX servers supports multiple client sessions with no -idle session timeout. It requires the included stand-alone UDP/UNIX client program -(called 'pshell') to communicate with the server. The TCP based server provides -for a single client session with a configurable idle session timeout (defaults -to 10 minutes). The TCP based server can be used with a standard 'telnet' client. -The LOCAL server supports a single session server with no idle session timeout. +server. The UDP and UNIX servers supports multiple client sessions with no +idle session timeout. It requires the included stand-alone UDP/UNIX client program +(called 'pshell') to communicate with the server. The TCP based server provides +for a single client session with a configurable idle session timeout (defaults +to 10 minutes). The TCP based server can be used with a standard 'telnet' client. +The LOCAL server supports a single session server with no idle session timeout. It will solicit user input directly from the host program, no external client program is needed. @@ -35,22 +35,22 @@ for details on the API. /* signature prototype of callback function */ -typedef void (*PshellFunction) (int argc, char *argv[]); +typedef void (*PshellFunction) (int argc, char *argv[]); void pshell_addCommand(PshellFunction function_, - const char *command_, - const char *description_, - const char *usage_ = NULL, - unsigned char minArgs_ = 0, - unsigned char maxArgs_ = 0, + const char *command_, + const char *description_, + const char *usage_ = NULL, + unsigned char minArgs_ = 0, + unsigned char maxArgs_ = 0, bool showUsage_ = true); /* note, for a LOCAL or UNIX server, the last two parameters should be omitted */ -void pshell_startServer(const char *serverName_, +void pshell_startServer(const char *serverName_, PshellServerType serverType_, PshellServerMode serverMode_, - const char *hostnameOrIpAddr_ = NULL, + const char *hostnameOrIpAddr_ = NULL, unsigned port_ = 0); void pshell_printf(const char *format_, ...); @@ -62,11 +62,11 @@ Link with the library libpshell-server Note, there is also python and go version implementations of this functionality in the modules 'PshellServer.py' and 'PshellServer.go' - + Their APIs and examples can be found in their corresponding language based directories of this install package. .SH EXAMPLES -See the file pshellServerDemo.c in the pshell distribution package for a complete +See the file pshellServerDemo.c in the pshell distribution package for a complete list of examples of writing and registering PSHELL callback functions. .SH MT-LEVEL Only one PshellServer server can be opened and run per executable image. diff --git a/c/man/man3/TraceFilter.3 b/c/man/man3/TraceFilter.3 index 3e1fef4..9f56771 100644 --- a/c/man/man3/TraceFilter.3 +++ b/c/man/man3/TraceFilter.3 @@ -18,7 +18,7 @@ typedef bool (*tf_TraceCallback) (void); enum tf_TraceControl {TF_ONCE, TF_CONTINUOUS, TF_ABORT}; void tf_addLevel(const char *name_, unsigned value_, bool isDefault_, bool isMaskable_); - + void tf_init(void); void tf_registerThread(const char *threadName_); @@ -27,7 +27,7 @@ bool tf_isFilterPassed(const char *file_, int line_, const char *function_, unsi /* macro to registger a memory location to watch at every trace statement */ .br -#define TF_WATCH(symbol, address, width, format, control) +#define TF_WATCH(symbol, address, width, format, control) /* macro to registger a function to be called at every trace statement */ .br diff --git a/c/src/PshellAggregator.cc b/c/src/PshellAggregator.cc index 96e9583..d1932a4 100644 --- a/c/src/PshellAggregator.cc +++ b/c/src/PshellAggregator.cc @@ -125,7 +125,7 @@ Server *getServer(char *localName) } return (NULL); } - + /******************************************************************************/ /******************************************************************************/ char *buildCommand(char *command, unsigned size, int argc, char *argv[]) @@ -156,9 +156,9 @@ void controlServer(int argc, char *argv[]) { /* this contains the re-constituted command */ char command[MAX_COMMAND_SIZE]; - if ((pshell_sendCommand3(server->sid, - results, - sizeof(results), + if ((pshell_sendCommand3(server->sid, + results, + sizeof(results), buildCommand(command, sizeof(command), argc, argv)) == PSHELL_COMMAND_SUCCESS) && (strlen(results) > 0)) { pshell_printf("%s", results); @@ -174,7 +174,7 @@ bool isDuplicate(char *localName, char *remoteServer, int port) for (unsigned server = 0; server < numServers; server++) { if ((strcmp(servers[server].localName, localName) == 0) || - ((strcmp(servers[server].remoteServer, remoteServer) == 0) && + ((strcmp(servers[server].remoteServer, remoteServer) == 0) && (servers[server].port == port))) { return (true); @@ -223,19 +223,19 @@ void add(int argc, char *argv[]) strcpy(servers[numServers].localName, argv[1]); strcpy(servers[numServers].remoteServer, argv[2]); servers[numServers].port = port; - servers[numServers].sid = pshell_connectServer(argv[1], - argv[2], - port, + servers[numServers].sid = pshell_connectServer(argv[1], + argv[2], + port, PSHELL_ONE_SEC*5); numServers++; char description[MAX_STRING_SIZE]; sprintf(description, "control the remote %s process", argv[1]); - pshell_addCommand(controlServer, - argv[1], - description, - "[ | ? | -h]", - 0, - 30, + pshell_addCommand(controlServer, + argv[1], + description, + "[ | ? | -h]", + 0, + 30, false); } else @@ -370,7 +370,7 @@ void show(int argc, char *argv[]) } pshell_printf("%-*s %-*s", maxLocalName, multicastGroups[multicast].servers[server]->localName, - maxRemoteName, + maxRemoteName, multicastGroups[multicast].servers[server]->remoteServer); if (multicastGroups[multicast].servers[server]->port == 0) { @@ -449,7 +449,7 @@ void registerSignalHandlers(void) /******************************************************************************/ int main (int argc, char *argv[]) { - + /* verify usage */ if (argc != 1) { @@ -467,42 +467,42 @@ int main (int argc, char *argv[]) /* register signal handlers so we can do a graceful termination and cleanup any system resources */ registerSignalHandlers(); - + /* set some special backdoor settings in PshellServer.cc us to run as both server and client */ pshell_copyAddCommandStrings = true; pshell_allowDuplicateFunction = true; - + /* register our callback commands */ - pshell_addCommand(add, - "add", - "add a new remote server or multicast group entry", + pshell_addCommand(add, + "add", + "add a new remote server or multicast group entry", "{server []} | {multicast [...]}", - 3, - 30, + 3, + 30, false); - - pshell_addCommand(show, - "show", - "show aggregated servers or multicast group info", - "servers | multicast", - 1, - 1, + + pshell_addCommand(show, + "show", + "show aggregated servers or multicast group info", + "servers | multicast", + 1, + 1, true); - - pshell_addCommand(multicast, - "multicast", + + pshell_addCommand(multicast, + "multicast", "send multicast command to registered server group", "", 0, 30, false); - + /* start our local pshell server */ pshell_startServer("pshellAggregator", PSHELL_LOCAL_SERVER, PSHELL_BLOCKING); - + /* disconnect all our remote control servers */ pshell_disconnectAllServers(); - + /* cleanup our local server's resources */ pshell_cleanupResources(); diff --git a/c/src/PshellClient.cc b/c/src/PshellClient.cc index c96aec0..8b3bb8e 100644 --- a/c/src/PshellClient.cc +++ b/c/src/PshellClient.cc @@ -92,7 +92,7 @@ /* * the maximum number of command line arguments that can be tokenized */ - + #define MAX_TOKENS 20 /* enums */ @@ -474,7 +474,7 @@ bool init(const char *destination_, const char *server_) /* UDP socket destination */ _serverType = UDP; - + /* * we don't care what our source address is because the pshellServer * will just do a reply to us based on the source address it receives @@ -491,7 +491,7 @@ bool init(const char *destination_, const char *server_) return (false); } - /* + /* * see if we are trying to connect to a broadcast address, * if so, set our socket options to allow for broadcast */ @@ -570,7 +570,7 @@ bool init(const char *destination_, const char *server_) sprintf(_sourceUnixAddress.sun_path, "%s/%s%d", PSHELL_UNIX_SOCKET_PATH, server_, (rand()%MAX_UNIX_CLIENTS)); retCode = bind(_socketFd, (struct sockaddr *) &_sourceUnixAddress, sizeof(_sourceUnixAddress)); } - + if (retCode < 0) { printf("PSHELL_ERROR: Cannot bind to UNIX socket: %s\n", _sourceUnixAddress.sun_path); @@ -594,11 +594,11 @@ bool init(const char *destination_, const char *server_) } else { - return (getVersion() && - getPayloadSize() && - getServerName() && - getTitle() && - getBanner() && + return (getVersion() && + getPayloadSize() && + getServerName() && + getTitle() && + getBanner() && getPrompt()); } } @@ -943,7 +943,7 @@ void processBatchFile(char *filename_, unsigned rate_, unsigned repeat_, bool cl } } } - + if (fp != NULL) { do @@ -1094,14 +1094,14 @@ void getNamedServers(void) _pshellServersList = (PshellServers*)malloc(_pshellServersListSize*sizeof(PshellServers)); while (fgets(line, 180, fp) != NULL) { - if (line[0] != '#') + if (line[0] != '#') { tokenize(line, ":", tokens, MAX_TOKENS, &numTokens); if ((numTokens >=2) && (numTokens <= 3)) { /* got at least both args */ if (_numPshellServers < _pshellServersListSize) - { + { _pshellServersList[_numPshellServers].serverName = strdup(tokens[0]); _pshellServersList[_numPshellServers].portNum = strdup(tokens[1]); if (numTokens == 3) @@ -1139,7 +1139,7 @@ void getNamedServers(void) { _maxServerNameLength = strlen(_pshellServersList[_numPshellServers].serverName); } - _numPshellServers++; + _numPshellServers++; } } } @@ -1512,7 +1512,7 @@ int main(int argc, char *argv[]) { showUsage(); } - + /* command line processed, now execute results */ if (init(_host, _server)) { diff --git a/c/src/PshellControl.cc b/c/src/PshellControl.cc index c3e2df4..d10f77b 100644 --- a/c/src/PshellControl.cc +++ b/c/src/PshellControl.cc @@ -296,7 +296,7 @@ void pshell_addMulticast(int sid_, const char *keyword_) } } if (sidIndex < PSHELL_MAX_SERVERS) - { + { /* see if we have a new multicast group (keyword) */ if (groupIndex == _multicastList.numGroups) { @@ -306,12 +306,12 @@ void pshell_addMulticast(int sid_, const char *keyword_) } /* see if we have a new sid for this group */ if (sidIndex == _multicastList.groups[groupIndex].numSids) - { + { /* new sid for this group, add it */ _multicastList.groups[groupIndex].sidList[_multicastList.groups[groupIndex].numSids++] = sid_; - PSHELL_INFO("Adding new multicast group sid: %d, keyword: '%s', numGroups: %d, numSids: %d", + PSHELL_INFO("Adding new multicast group sid: %d, keyword: '%s', numGroups: %d, numSids: %d", sid_, - keyword_, + keyword_, _multicastList.numGroups, _multicastList.groups[groupIndex].numSids); } @@ -353,7 +353,7 @@ void pshell_sendMulticast(const char *command_, ...) } for (int group = 0; group < _multicastList.numGroups; group++) { - if ((strcmp(_multicastList.groups[group].keyword, PSHELL_MULTICAST_ALL) == 0) || + if ((strcmp(_multicastList.groups[group].keyword, PSHELL_MULTICAST_ALL) == 0) || (((keyword = strstr(_multicastList.groups[group].keyword, command)) != NULL) && (keyword == _multicastList.groups[group].keyword))) { @@ -368,8 +368,8 @@ void pshell_sendMulticast(const char *command_, ...) { if ((control = getControl(_multicastList.groups[group].sidList[sid])) != NULL) { - /* - * since we are sending to multiple servers, we don't want any data + /* + * since we are sending to multiple servers, we don't want any data * back and we don't even want any response, we just do fire-and-forget */ control->pshellMsg.header.dataNeeded = false; @@ -389,7 +389,7 @@ void pshell_sendMulticast(const char *command_, ...) { PSHELL_WARNING("Command truncated: '%s', length exceeds %d bytes, %d bytes needed, command not sent", command, sizeof(command), bytesFormatted); } - pthread_mutex_unlock(&_mutex); + pthread_mutex_unlock(&_mutex); } /******************************************************************************/ @@ -417,7 +417,7 @@ int pshell_sendCommand1(int sid_, const char *command_, ...) PSHELL_WARNING("Command truncated: '%s', length exceeds %d bytes, %d bytes needed, command not sent", command, sizeof(command), bytesFormatted); } } - pthread_mutex_unlock(&_mutex); + pthread_mutex_unlock(&_mutex); return (retCode); } @@ -446,7 +446,7 @@ int pshell_sendCommand2(int sid_, unsigned timeoutOverride_, const char *command PSHELL_WARNING("Command truncated: '%s', length exceeds %d bytes, %d bytes needed, command not sent", command, sizeof(command), bytesFormatted); } } - pthread_mutex_unlock(&_mutex); + pthread_mutex_unlock(&_mutex); return (retCode); } @@ -526,7 +526,7 @@ int pshell_sendCommand4(int sid_, char *results_, int size_, unsigned timeoutOve PSHELL_WARNING("Command truncated: '%s', length exceeds %d bytes, %d bytes needed, command not sent", command, sizeof(command), bytesFormatted); } } - pthread_mutex_unlock(&_mutex); + pthread_mutex_unlock(&_mutex); return (retCode); } @@ -553,7 +553,7 @@ const char *pshell_getResponseString(int results_) case PSHELL_SOCKET_NOT_CONNECTED: return ("PSHELL_SOCKET_NOT_CONNECTED"); default: - return ("PSHELL_UNKNOWN_RESPONSE"); + return ("PSHELL_UNKNOWN_RESPONSE"); } } @@ -573,7 +573,7 @@ bool connectServer(PshellControl *control_, const char *remoteServer_ , unsigned { control_->serverType = UNIX; - + if ((control_->socketFd = socket(AF_UNIX, SOCK_DGRAM, 0)) < 0) { PSHELL_ERROR("PSHELL_ERROR: Cannot create UNIX socket"); @@ -593,7 +593,7 @@ bool connectServer(PshellControl *control_, const char *remoteServer_ , unsigned (struct sockaddr *)&control_->sourceUnixAddress, sizeof(control_->sourceUnixAddress)); } - + if (retCode < 0) { PSHELL_ERROR("PSHELL_ERROR: Cannot bind to UNIX socket: %s", control_->sourceUnixAddress.sun_path); @@ -605,10 +605,10 @@ bool connectServer(PshellControl *control_, const char *remoteServer_ , unsigned } else - { - + { + control_->serverType = UDP; - + /* * we don't care what our source address is because the pshell server * will just do a reply to us based on the source address it receives @@ -654,7 +654,7 @@ bool connectServer(PshellControl *control_, const char *remoteServer_ , unsigned return (false); } } - + } return (true); } @@ -671,7 +671,7 @@ int sendPshellCommand(PshellControl *control_, int commandType_, const char *com if (control_ != NULL) { - + FD_ZERO (&readFd); FD_SET(control_->socketFd,&readFd); @@ -693,7 +693,7 @@ int sendPshellCommand(PshellControl *control_, int commandType_, const char *com memset(&timeout, 0, sizeof(timeout)); timeout.tv_sec = timeoutOverride_/1000; timeout.tv_usec = (timeoutOverride_%1000)*1000; - + /* loop in case we have any stale responses we need to flush from the socket */ while (true) { @@ -717,12 +717,12 @@ int sendPshellCommand(PshellControl *control_, int commandType_, const char *com } else if (seqNum > control_->pshellMsg.header.seqNum) { - /* - * make sure we have the correct response, this condition can happen if we had - * a very short timeout for the previous call and missed the response, in which - * case the response to the previous call will be queued in the socket ahead of - * our current expected response, when we detect that condition, we read the - * socket until we either find the correct response or timeout, we toss any previous + /* + * make sure we have the correct response, this condition can happen if we had + * a very short timeout for the previous call and missed the response, in which + * case the response to the previous call will be queued in the socket ahead of + * our current expected response, when we detect that condition, we read the + * socket until we either find the correct response or timeout, we toss any previous * unmatched responses */ PSHELL_WARNING("Received seqNum: %d, does not match sent seqNum: %d", control_->pshellMsg.header.seqNum, seqNum) @@ -748,7 +748,7 @@ int sendPshellCommand(PshellControl *control_, int commandType_, const char *com } if ((strlen(control_->pshellMsg.payload) > 0) && - (retCode > PSHELL_COMMAND_SUCCESS) && + (retCode > PSHELL_COMMAND_SUCCESS) && (retCode < PSHELL_SOCKET_SEND_FAILURE)) { PSHELL_ERROR("Remote pshell command: '%s', server: %s, %s\n%s%s", @@ -770,9 +770,9 @@ int sendPshellCommand(PshellControl *control_, int commandType_, const char *com PSHELL_INFO("Remote pshell command: '%s', %s", command_, pshell_getResponseString(retCode)); retCode = PSHELL_COMMAND_SUCCESS; } - + return (retCode); - + } /******************************************************************************/ diff --git a/c/src/PshellStub.cc b/c/src/PshellStub.cc index 6d1ec4b..e3abc64 100644 --- a/c/src/PshellStub.cc +++ b/c/src/PshellStub.cc @@ -35,9 +35,9 @@ /* * This module honors the complete public API of the PshellServer, TraceFilter, - * and TraceLog modules but with all the underlying functionality stubbed - * out, link with this module (or the corresponding "stub" library) to - * easily remove all PSHELL functionality from a program without making + * and TraceLog modules but with all the underlying functionality stubbed + * out, link with this module (or the corresponding "stub" library) to + * easily remove all PSHELL functionality from a program without making * any changes to actual source code */ @@ -48,12 +48,12 @@ static PshellTokens _dummyTokens; /* PshellServer public API functions */ void pshell_setServerLogLevel(unsigned level_){}; void pshell_registerServerLogFunction(PshellLogFunction logFunction_){}; -void pshell_startServer(const char *serverName_, +void pshell_startServer(const char *serverName_, PshellServerType serverType_, PshellServerMode serverMode_, - const char *hostnameOrIpAddr_, + const char *hostnameOrIpAddr_, unsigned port_) -{ +{ printf("PSHELL_INFO: STUB Server: %s Started\n", serverName_); if (serverMode_ == PSHELL_BLOCKING) for (;;) sleep(30000); } diff --git a/c/src/README b/c/src/README index 929b0f6..d0f797b 100644 --- a/c/src/README +++ b/c/src/README @@ -1,3 +1,3 @@ This directory contains all the source code used for the pshell server library, -pshell control library, and the stand-alone pshell and pshellAggregator UDP/UNIX +pshell control library, and the stand-alone pshell and pshellAggregator UDP/UNIX client programs. diff --git a/c/src/TraceFilter.cc b/c/src/TraceFilter.cc index 1073220..df9bef9 100644 --- a/c/src/TraceFilter.cc +++ b/c/src/TraceFilter.cc @@ -112,7 +112,7 @@ struct RegisteredThread /*********************************** * "private" function prototypes ***********************************/ - + static void showConfig(void); static void showUsage(void); static void configureFilter(int argc, char *argv[]); @@ -310,7 +310,7 @@ static unsigned _defaultHierarchicalLevel = 0; /************************************ * "public" function bodies ************************************/ - + /******************************************************************************/ /******************************************************************************/ void tf_init(void) @@ -423,7 +423,7 @@ void tf_addLevel(const char *levelName_, _levelFilters[levelValue_].name = levelName_; _levelFilters[levelValue_].level = 1<<(levelValue_+1); _levelFilters[levelValue_].isDefault = isDefault_; - _levelFilters[levelValue_].isMaskable = isMaskable_; + _levelFilters[levelValue_].isMaskable = isMaskable_; } } @@ -445,19 +445,19 @@ bool tf_isFilterPassed(const char *file_, unsigned level = _levelFilters[level_].level; if (isWatchHit() && ((_watchNumHits == 0) || (_watchControl != TF_ONCE))) { - + /* print out the most recent trace for which the value was unchanged */ sprintf(traceOutputString, _watchFormatString, "prev", _watchPrevValue); printLog(TF_WATCH_STRING, _watchPrevFile, _watchPrevFunction, _watchPrevLine, traceOutputString); - + /* print out the current trace where the value change was detected */ sprintf(traceOutputString, _watchFormatString, "curr", _watchCurrValue); printLog(TF_WATCH_STRING, file_, function_, line_, traceOutputString); - + _watchPrevValue = _watchCurrValue; _watchNumHits++; filterPassed = false; - + /* see if they requested an abort on the condition being met */ if (_watchControl == TF_ABORT) { @@ -617,7 +617,7 @@ bool tf_isFilterPassed(const char *file_, _watchPrevFunction = function_; _watchPrevLine = line_; } - + /* if we have a callback enabled, remember our previous, file/function/line info */ if (_callbackFunction != NULL) { @@ -625,9 +625,9 @@ bool tf_isFilterPassed(const char *file_, _callbackPrevFunction = function_; _callbackPrevLine = line_; } - + return (filterPassed); - + } /******************************************************************************/ diff --git a/c/src/TraceLog.cc b/c/src/TraceLog.cc index 1bf7c6a..dfd8d2d 100644 --- a/c/src/TraceLog.cc +++ b/c/src/TraceLog.cc @@ -49,10 +49,10 @@ * public "member" data *************************/ -/* +/* * note that this data item is only used for a stand-alone TraceLog module, i.e. * it is not part of the dynamic trace filtering mechanism, i.e. this module is - * built with the DYNAMIC_TRACE_FILTER flag NOT set, the levels can be set from + * built with the DYNAMIC_TRACE_FILTER flag NOT set, the levels can be set from * within the program by making calls to the trace_setLogLevel function */ #ifndef DYNAMIC_TRACE_FILTER @@ -75,7 +75,7 @@ static unsigned _maxTypeLength = 0; /*************************************** * private "member" function prototypes ***************************************/ - + static void printLine(char *line_); static void formatHeader(const char *type_, const char *file_, @@ -336,7 +336,7 @@ void formatHeader(const char *type_, const char *file_, const char *function_, i { file = file_; } - + if (_printLocation && _printTimestamp) { sprintf(outputString_, "%s%-*s | %s.%-6ld | %s(%s):%d | ", _printPrefix, _maxTypeLength, type_, timestamp, (long)tv.tv_usec, file, function_, line_); @@ -353,7 +353,7 @@ void formatHeader(const char *type_, const char *file_, const char *function_, i { sprintf(outputString_, "%s%-*s | ", _printPrefix, _maxTypeLength, type_); } - + } /******************************************************************************/ diff --git a/config/pshell-client.conf b/config/pshell-client.conf index 11de3a9..6ca0d0d 100644 --- a/config/pshell-client.conf +++ b/config/pshell-client.conf @@ -1,8 +1,8 @@ ################################################################################# # -# Copyright (c) 2009, Ron Iovine, All rights reserved. +# Copyright (c) 2009, Ron Iovine, All rights reserved. # -# Redistribution and use in source and binary forms, with or without +# Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: # * Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. diff --git a/config/pshell-control.conf b/config/pshell-control.conf index 543c760..aaa30b1 100644 --- a/config/pshell-control.conf +++ b/config/pshell-control.conf @@ -1,28 +1,28 @@ ################################################################################# -# -# Copyright (c) 2009, Ron Iovine, All rights reserved. -# -# Redistribution and use in source and binary forms, with or without +# +# Copyright (c) 2009, Ron Iovine, All rights reserved. +# +# Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: # * Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # * Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. -# * Neither the name of Ron Iovine nor the names of its contributors -# may be used to endorse or promote products derived from this software +# * Neither the name of Ron Iovine nor the names of its contributors +# may be used to endorse or promote products derived from this software # without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY Ron Iovine ''AS IS'' AND ANY EXPRESS OR -# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -# IN NO EVENT SHALL Ron Iovine BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -# BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER -# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -# POSSIBILITY OF SUCH DAMAGE. +# +# THIS SOFTWARE IS PROVIDED BY Ron Iovine ''AS IS'' AND ANY EXPRESS OR +# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +# IN NO EVENT SHALL Ron Iovine BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR +# BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. # ################################################################################# diff --git a/config/pshell-server.conf b/config/pshell-server.conf index b4e3e01..c107b52 100644 --- a/config/pshell-server.conf +++ b/config/pshell-server.conf @@ -1,28 +1,28 @@ ################################################################################# -# -# Copyright (c) 2009, Ron Iovine, All rights reserved. -# -# Redistribution and use in source and binary forms, with or without +# +# Copyright (c) 2009, Ron Iovine, All rights reserved. +# +# Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: # * Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # * Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. -# * Neither the name of Ron Iovine nor the names of its contributors -# may be used to endorse or promote products derived from this software +# * Neither the name of Ron Iovine nor the names of its contributors +# may be used to endorse or promote products derived from this software # without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY Ron Iovine ''AS IS'' AND ANY EXPRESS OR -# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -# IN NO EVENT SHALL Ron Iovine BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -# BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER -# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -# POSSIBILITY OF SUCH DAMAGE. +# +# THIS SOFTWARE IS PROVIDED BY Ron Iovine ''AS IS'' AND ANY EXPRESS OR +# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +# IN NO EVENT SHALL Ron Iovine BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR +# BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. # ################################################################################# @@ -32,7 +32,7 @@ # # This file contains configuration override information for all the PSHELL # servers configured on a given host. The startup configuration information -# can be overridden on a per-server basis. +# can be overridden on a per-server basis. # # The format of a configuration statement is as follows # @@ -45,7 +45,7 @@ # # myServer.title=My Window Title # myServer.banner=My Welcome Banner -# myServer.prompt=MyPrompt> +# myServer.prompt=MyPrompt> # myServer.host=anyhost # myServer.port=6002 # myServer.timeout=30 @@ -60,8 +60,8 @@ # 'serverName[ipAddress]:prompt' # # The valid values for 'host' are 'anyhost', 'myhost', 'localhost', -# 'anybcast', or a valid 'ipAddress' (host is used for UDP or TCP -# servers only, it should be omitted or is ignored if supplied for +# 'anybcast', or a valid 'ipAddress' (host is used for UDP or TCP +# servers only, it should be omitted or is ignored if supplied for # LOCAL or UNIX server types) # # The config item 'port' is used for UDP or TCP servers and should be @@ -83,7 +83,7 @@ #pshellServerDemo.title=My Window Title #pshellServerDemo.banner=My Welcome Banner -#pshellServerDemo.prompt=MyPrompt> +#pshellServerDemo.prompt=MyPrompt> #pshellServerDemo.host=anyhost #pshellServerDemo.port=8001 #pshellServerDemo.timeout=30 diff --git a/defconfig b/defconfig index 3b91231..9d7a85a 100644 --- a/defconfig +++ b/defconfig @@ -30,7 +30,7 @@ # # Example pshell build-time configuration, the Makefile uses the '.config' # file for it's build-time configuration settings. The user should copy the -# provided 'defconfig' file to '.config' and make any desired modifications +# provided 'defconfig' file to '.config' and make any desired modifications # to that file, then run the 'make'. If the file '.config' is not found, the # 'defconfig' file will be copied to '.config' by the makefile processing before # the build process starts. The user should NOT modify the provided 'defconfig' @@ -48,7 +48,7 @@ ################################################################################# # # The following set of compile options are used by the PshellServer library part -# of this package. +# of this package. # ################################################################################# @@ -61,20 +61,20 @@ # # change the default single-line welcome banner for all servers, this can -# also be changed at runtime on a per-server basis via the pshell-server.conf +# also be changed at runtime on a per-server basis via the pshell-server.conf # file # #PSHELL_DEFAULT_BANNER="PSHELL: Process Specific Embedded Command Line Shell" # # change the default prompt for all servers, the full prompt format is -# 'shellName[ipAddress]:prompt', this can also be changed at runtime +# 'shellName[ipAddress]:prompt', this can also be changed at runtime # on a per-server basis via the pshell-server.conf file # #PSHELL_DEFAULT_PROMPT="PSHELL>" # -# change the default TCP server idle session timeout (in minutes), this can also +# change the default TCP server idle session timeout (in minutes), this can also # be changed at runtime on a per-server basis via the pshell-server.conf file # #PSHELL_DEFAULT_TIMEOUT=10 @@ -96,7 +96,7 @@ # These config files can be used to set various server, client, and control # settings. Refer to the example files in the 'config' directory of this # package for usage of these files. -# +# #PSHELL_CONFIG_DIR="/etc/pshell/config" # @@ -123,7 +123,7 @@ # # The batch processing will first look for the batch file in the directory # specified by the $PSHELL_BATCH_DIR environment variable, and if not found -# will look in the default PSHELL_BATCH_DIR (i.e. /etc/pshell/batch), and if +# will look in the default PSHELL_BATCH_DIR (i.e. /etc/pshell/batch), and if # still not found, will take the passed in batch file name verbatim. # #PSHELL_BATCH_DIR="/etc/pshell/batch" @@ -236,7 +236,7 @@ PSHELL_INCLUDE_TRACE_FILTER=y # # This flag specifies whether to build in the example TraceLog service into the -# PshellServer libraries along with the traceFilterDemo program to demonstrate +# PshellServer libraries along with the traceFilterDemo program to demonstrate # interactive trace control via the TraceFilter mechanism. This can only be # enabled if the above PSHELL_INCLUDE_TRACE_FILTER flag is also enabled. # diff --git a/go/src/PshellControl/PshellControl.go b/go/src/PshellControl/PshellControl.go index d51b8a3..edbadac 100644 --- a/go/src/PshellControl/PshellControl.go +++ b/go/src/PshellControl/PshellControl.go @@ -1,28 +1,28 @@ ///////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2009, Ron Iovine, All rights reserved. -// -// Redistribution and use in source and binary forms, with or without +// +// Copyright (c) 2009, Ron Iovine, All rights reserved. +// +// Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. -// * Neither the name of Ron Iovine nor the names of its contributors -// may be used to endorse or promote products derived from this software +// * Neither the name of Ron Iovine nor the names of its contributors +// may be used to endorse or promote products derived from this software // without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY Ron Iovine ''AS IS'' AND ANY EXPRESS OR -// IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL Ron Iovine BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -// BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER -// IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -// POSSIBILITY OF SUCH DAMAGE. +// +// THIS SOFTWARE IS PROVIDED BY Ron Iovine ''AS IS'' AND ANY EXPRESS OR +// IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +// IN NO EVENT SHALL Ron Iovine BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR +// BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +// IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +// POSSIBILITY OF SUCH DAMAGE. // ///////////////////////////////////////////////////////////////////////////////// @@ -34,7 +34,7 @@ // provides a very lightweight way to provide a control mechanism into a program // that is running a pshell, this is analagous to a remote procedure call (rpc). // -// A complete example of the usage of the API can be found in the included +// A complete example of the usage of the API can be found in the included // demo program pshellControlDemo.go // package PshellControl @@ -64,7 +64,7 @@ const ( COMMAND_SUCCESS = 0 COMMAND_NOT_FOUND = 1 COMMAND_INVALID_ARG_COUNT = 2 - // the following "SOCKET" enums are generated internally by the sendCommandN functions + // the following "SOCKET" enums are generated internally by the sendCommandN functions SOCKET_SEND_FAILURE = 3 SOCKET_SELECT_FAILURE = 4 SOCKET_RECEIVE_FAILURE = 5 @@ -152,10 +152,10 @@ const ( // will return either SOCKET_NOT_CONNECTED, SOCKET_SEND_FAILURE, or // COMMAND_SUCCESS, the timeout value entered in this funcition will // be used as the default timeout for all calls to sendCommandN that -// do not provide an override timeout value, for a UDP server, the -// remoteServer must be either a valid hostname or IP address and a -// valid destination port must be provided, for a UNIX server, only -// a valid server name must be provided along with the identifier +// do not provide an override timeout value, for a UDP server, the +// remoteServer must be either a valid hostname or IP address and a +// valid destination port must be provided, for a UNIX server, only +// a valid server name must be provided along with the identifier // PshellControl.UNIX for the 'port' parameter // // This function returns a Server ID (sid) handle which must be saved and @@ -175,7 +175,7 @@ func ConnectServer(controlName string, remoteServer string, port string, default } // -// Cleanup any resources associated with the server connection, including +// Cleanup any resources associated with the server connection, including // releasing any temp file handles, closing any local socket handles etc. // // Args: @@ -189,10 +189,10 @@ func DisconnectServer(sid int) { } // -// Use this function to cleanup any resources for all connected servers, this -// function should be called upon program termination, either in a graceful -// termination or within an exception signal handler, it is especially important -// that this be called when a unix server is used since there are associated file +// Use this function to cleanup any resources for all connected servers, this +// function should be called upon program termination, either in a graceful +// termination or within an exception signal handler, it is especially important +// that this be called when a unix server is used since there are associated file // handles that need to be cleaned up // // Args: @@ -206,7 +206,7 @@ func DisconnectAllServers() { } // -// Set the default server response timeout that is used in the 'send' commands +// Set the default server response timeout that is used in the 'send' commands // that don't take a timeout override // // Args: @@ -221,8 +221,8 @@ func SetDefaultTimeout(sid int, defaultTimeout int) { } // -// This command will add a given multicast receiver (i.e. sid) to a multicast -// group, multicast groups are either based on the command's keyword, or if +// This command will add a given multicast receiver (i.e. sid) to a multicast +// group, multicast groups are either based on the command's keyword, or if // no keyword is supplied, the given sid will receive all multicast commands // // Args: @@ -240,10 +240,10 @@ func AddMulticast(sid int, keyword string) { // // This command will send a given command to all the registered multicast -// receivers (i.e. sids) for this multicast group, multicast groups are -// based on the command's keyword, this function will issue the command as -// a best effort fire-and-forget command to each receiver in the multicast -// group, no results will be requested or expected, and no response will be +// receivers (i.e. sids) for this multicast group, multicast groups are +// based on the command's keyword, this function will issue the command as +// a best effort fire-and-forget command to each receiver in the multicast +// group, no results will be requested or expected, and no response will be // requested or expected // // Args: @@ -257,7 +257,7 @@ func SendMulticast(format string, command ...interface{}) { } // -// Send a command using the default timeout setup in the connectServer call, +// Send a command using the default timeout setup in the connectServer call, // if the default timeout is 0, the server will not reply with a response and // this function will not wait for one // @@ -281,8 +281,8 @@ func SendCommand1(sid int, format string, command ...interface{}) int { } // -// Send a command overriding the default timeout, if the override timeout is 0, -// the server will not reply with a response and this function will not wait for +// Send a command overriding the default timeout, if the override timeout is 0, +// the server will not reply with a response and this function will not wait for // one // // Args: @@ -306,9 +306,9 @@ func SendCommand2(sid int, timeoutOverride int, format string, command ...interf } // -// Send a command using the default timeout setup in the connectServer call and -// return any results received in the payload, if the default timeout is 0, the -// server will not reply with a response and this function will not wait for one, +// Send a command using the default timeout setup in the connectServer call and +// return any results received in the payload, if the default timeout is 0, the +// server will not reply with a response and this function will not wait for one, // and no results will be extracted // // Args: @@ -333,9 +333,9 @@ func SendCommand3(sid int, format string, command ...interface{}) (int, string) } // -// Send a command overriding the default timeout and return any results received -// in the payload, if the timeout override default timeout is 0, the server will -// not reply with a response and this function will not wait for one, and no +// Send a command overriding the default timeout and return any results received +// in the payload, if the timeout override default timeout is 0, the server will +// not reply with a response and this function will not wait for one, and no // results will be extracted // // Args: @@ -399,9 +399,9 @@ func connectServer(controlName_ string, remoteServer_ string, port_ string, defa break } } - _gControlList = append(_gControlList, + _gControlList = append(_gControlList, pshellControl{socket, - defaultTimeout_, + defaultTimeout_, "unix", sourceAddress, // unix file handle, used for cleanup []byte{}, // sendMsg @@ -414,16 +414,16 @@ func connectServer(controlName_ string, remoteServer_ string, port_ string, defa remoteAddr, _ := net.ResolveUDPAddr("udp", strings.Join([]string{remoteServer_, ":", port_,}, "")) socket, retCode = net.DialUDP("udp", nil, remoteAddr) if (retCode == nil) { - _gControlList = append(_gControlList, + _gControlList = append(_gControlList, pshellControl{socket, - defaultTimeout_, + defaultTimeout_, "udp", "", // sourceAddress not used for UDP socket []byte{}, // sendMsg make([]byte, _RCV_BUFFER_SIZE), // recvMsg 0, // recvSize strings.Join([]string{controlName_, "[", remoteServer_, "]"}, "")}) - + sid = len(_gControlList)-1 } } @@ -598,7 +598,7 @@ func sendCommand(control_ *pshellControl, command_ string, timeout_ int, dataNee } else { retCode = SOCKET_SEND_FAILURE } - + return retCode } @@ -665,9 +665,9 @@ func loadConfigFile(controlName_ string, remoteServer_ string, port_ string, def // // PshellMsg datagram message processing functions // -// A PshellMsg is just a byte slice, there is a small 8 byte header along +// A PshellMsg is just a byte slice, there is a small 8 byte header along // with an ascii byte payload as follows: -// +// // type PshellMsg struct { // msgType byte // respNeeded byte @@ -679,7 +679,7 @@ func loadConfigFile(controlName_ string, remoteServer_ string, port_ string, def // // I did not have any luck serializing this using 'gob' or binary/encoder to // send 'over-the-wire' as-is, so I am just representing this as a byte slice -// and packing/extracting the header elements myself based on byte offsets, +// and packing/extracting the header elements myself based on byte offsets, // everything in the message except the 4 byte seqNum are single bytes, so I // didn't think this was to bad. There is probably a correct way to do this // in 'go', but since I'm new to the language, this was the easiest way I got diff --git a/go/src/PshellServer-full/PshellServer-full.go b/go/src/PshellServer-full/PshellServer-full.go index 0a48fe9..2a48a1b 100644 --- a/go/src/PshellServer-full/PshellServer-full.go +++ b/go/src/PshellServer-full/PshellServer-full.go @@ -1,28 +1,28 @@ ///////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2009, Ron Iovine, All rights reserved. -// -// Redistribution and use in source and binary forms, with or without +// +// Copyright (c) 2009, Ron Iovine, All rights reserved. +// +// Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. -// * Neither the name of Ron Iovine nor the names of its contributors -// may be used to endorse or promote products derived from this software +// * Neither the name of Ron Iovine nor the names of its contributors +// may be used to endorse or promote products derived from this software // without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY Ron Iovine ''AS IS'' AND ANY EXPRESS OR -// IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL Ron Iovine BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -// BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER -// IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -// POSSIBILITY OF SUCH DAMAGE. +// +// THIS SOFTWARE IS PROVIDED BY Ron Iovine ''AS IS'' AND ANY EXPRESS OR +// IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +// IN NO EVENT SHALL Ron Iovine BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR +// BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +// IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +// POSSIBILITY OF SUCH DAMAGE. // ///////////////////////////////////////////////////////////////////////////////// @@ -38,7 +38,7 @@ // functions based on how the pshell server is configured, which is described // in documentation further down in this file. // -// A complete example of the usage of the API can be found in the included +// A complete example of the usage of the API can be found in the included // demo program file pshellServerDemo.go // package PshellServer @@ -72,19 +72,19 @@ const ( LOCAL = "local" ) -// These are the identifiers for the serverMode. BLOCKING wil never return -// control to the caller of startServer, NON_BLOCKING will spawn a thread to +// These are the identifiers for the serverMode. BLOCKING wil never return +// control to the caller of startServer, NON_BLOCKING will spawn a thread to // run the server and will return control to the caller of startServer const ( BLOCKING = 0 NON_BLOCKING = 1 ) -// These three identifiers that can be used for the hostnameOrIpAddr argument +// These three identifiers that can be used for the hostnameOrIpAddr argument // of the startServer call. PshellServer.ANYHOST will bind the server socket // to all interfaces of a multi-homed host, PSHELL_ANYBCAST will bind to -// 255.255.255.255, PshellServer.LOCALHOST will bind the server socket to -// the local loopback address (i.e. 127.0.0.1), note that subnet broadcast +// 255.255.255.255, PshellServer.LOCALHOST will bind the server socket to +// the local loopback address (i.e. 127.0.0.1), note that subnet broadcast // it also supported, e.g. x.y.z.255 const ( ANYHOST = "anyhost" @@ -303,7 +303,7 @@ func RunCommand(format string, command ...interface{}) { //////////////////////////////////////////////////////////////////////////////// // -// The following public functions should only be called from within a +// The following public functions should only be called from within a // registered callback function // //////////////////////////////////////////////////////////////////////////////// @@ -361,7 +361,7 @@ func March(message string) { } // -// Check if the user has asked for help on this command. Command must be +// Check if the user has asked for help on this command. Command must be // registered with the showUsage = false option. // // Args: @@ -388,7 +388,7 @@ func ShowUsage() { } // -// This function will return True if string1 is a substring of string2 at +// This function will return True if string1 is a substring of string2 at // position 0. If the minMatchLength is 0, then it will compare up to the // length of string1. If the minMatchLength > 0, it will require a minimum // of that many characters to match. A string that is longer than the min @@ -413,7 +413,7 @@ func IsSubString(string1 string, string2 string, minMatchLength int) bool { // This function will parse an argument string of the formats - where // key is one letter only, i.e. '-t', or = where key can be any length // word, i.e. 'timeout', and return a 3-tuple indicating if the arg was parsed -// correctly, along with the associated key and corresponding value. An example +// correctly, along with the associated key and corresponding value. An example // of the two valid formats are -t10, timeout=10. // // Args: @@ -436,22 +436,22 @@ func GetOption(arg string) (bool, string, string) { //////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////// -func addCommand(function_ pshellFunction, - command_ string, - description_ string, - usage_ string, - minArgs_ int, - maxArgs_ int, +func addCommand(function_ pshellFunction, + command_ string, + description_ string, + usage_ string, + minArgs_ int, + maxArgs_ int, showUsage_ bool, - prepend_ bool) { - - // see if we have a NULL command name + prepend_ bool) { + + // see if we have a NULL command name if ((command_ == "") || (len(command_) == 0)) { fmt.Printf("PSHELL_ERROR: NULL command name, command not added\n") return } - // see if we have a NULL description + // see if we have a NULL description if ((description_ == "") || (len(description_) == 0)) { fmt.Printf("PSHELL_ERROR: NULL description, command: '%s' not added\n", command_) return @@ -474,7 +474,7 @@ func addCommand(function_ pshellFunction, fmt.Printf("PSHELL_ERROR: minArgs: %d is greater than maxArgs: %d, command: '%s' not added\n", minArgs_, maxArgs_, command_) return } - + // see if it is a duplicate command for _, entry := range _gCommandList { if (entry.command == command_) { @@ -483,13 +483,13 @@ func addCommand(function_ pshellFunction, return } } - + // everything ok, good to add command - + if (len(command_) > _gMaxLength) { _gMaxLength = len(command_) } - + if (prepend_ == true) { _gCommandList = append([]pshellCmd{{command_, usage_, @@ -500,12 +500,12 @@ func addCommand(function_ pshellFunction, showUsage_}}, _gCommandList...) } else { - _gCommandList = append(_gCommandList, - pshellCmd{command_, + _gCommandList = append(_gCommandList, + pshellCmd{command_, usage_, - description_, + description_, function_, - minArgs_, + minArgs_, maxArgs_, showUsage_}) } @@ -516,7 +516,7 @@ func addCommand(function_ pshellFunction, func startServer(serverName_ string, serverType_ string, serverMode_ int, - hostnameOrIpAddr_ string, + hostnameOrIpAddr_ string, port_ string) { if (_gRunning == false) { _gServerName = serverName_ @@ -525,7 +525,7 @@ func startServer(serverName_ string, _gHostnameOrIpAddr = hostnameOrIpAddr_ _gPort = port_ loadConfigFile() - loadStartupFile() + loadStartupFile() _gRunning = true if (_gServerMode == BLOCKING) { runServer() @@ -874,11 +874,11 @@ func runServer() { runTCPServer() } else if (_gServerType == UNIX) { runUNIXServer() - } else { // local server + } else { // local server runLocalServer() } } - + //////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////// func runUDPServer() { @@ -1373,7 +1373,7 @@ func getInput(command_ string, //_write("\nchar value: %d" % char) //_write("\n"+prompt_) } - } + } } return command_, fullCommand, quit, cursorPos_, tabCount_ } @@ -1442,7 +1442,7 @@ func receiveTCP() { addHistory(_gCommandHistory[index]) if (_gCommandHistory[index] == "history") { showHistory() - } else { + } else { processCommand(_gCommandHistory[index]) } } else { @@ -1573,7 +1573,7 @@ func processCommand(command_ string) { } else { if (IsHelp()) { if (_gFoundCommand.showUsage == true) { - ShowUsage() + ShowUsage() } else { _gFoundCommand.function(_gArgs) } @@ -1591,10 +1591,10 @@ func processCommand(command_ string) { //////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////// func reply(response_ byte) { - pshellSendMsg := createMessage(response_, - getRespNeeded(_gPshellRcvMsg), - getDataNeeded(_gPshellRcvMsg), - getSeqNum(_gPshellRcvMsg), + pshellSendMsg := createMessage(response_, + getRespNeeded(_gPshellRcvMsg), + getDataNeeded(_gPshellRcvMsg), + getSeqNum(_gPshellRcvMsg), _gPshellSendPayload) if (_gServerType == UDP) { _gUdpSocket.WriteTo(pshellSendMsg, _gRecvAddr) @@ -1608,9 +1608,9 @@ func reply(response_ byte) { // // PshellMsg datagram message processing functions // -// A PshellMsg is just a byte slice, there is a small 8 byte header along +// A PshellMsg is just a byte slice, there is a small 8 byte header along // with an ascii byte payload as follows: -// +// // type PshellMsg struct { // msgType byte // respNeeded byte @@ -1622,7 +1622,7 @@ func reply(response_ byte) { // // I did not have any luck serializing this using 'gob' or binary/encoder to // send 'over-the-wire' as-is, so I am just representing this as a byte slice -// and packing/extracting the header elements myself based on byte offsets, +// and packing/extracting the header elements myself based on byte offsets, // everything in the message except the 4 byte seqNum are single bytes, so I // didn't think this was to bad. There is probably a correct way to do this // in 'go', but since I'm new to the language, this was the easiest way I got diff --git a/go/src/PshellServer-stub/PshellServer-stub.go b/go/src/PshellServer-stub/PshellServer-stub.go index 6d16656..6f6b72d 100644 --- a/go/src/PshellServer-stub/PshellServer-stub.go +++ b/go/src/PshellServer-stub/PshellServer-stub.go @@ -1,33 +1,33 @@ ///////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2009, Ron Iovine, All rights reserved. -// -// Redistribution and use in source and binary forms, with or without +// +// Copyright (c) 2009, Ron Iovine, All rights reserved. +// +// Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. -// * Neither the name of Ron Iovine nor the names of its contributors -// may be used to endorse or promote products derived from this software +// * Neither the name of Ron Iovine nor the names of its contributors +// may be used to endorse or promote products derived from this software // without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY Ron Iovine ''AS IS'' AND ANY EXPRESS OR -// IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL Ron Iovine BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -// BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER -// IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -// POSSIBILITY OF SUCH DAMAGE. +// +// THIS SOFTWARE IS PROVIDED BY Ron Iovine ''AS IS'' AND ANY EXPRESS OR +// IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +// IN NO EVENT SHALL Ron Iovine BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR +// BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +// IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +// POSSIBILITY OF SUCH DAMAGE. // ///////////////////////////////////////////////////////////////////////////////// // -// This is the STUB version of the PshellServer module, to use the actual version, +// This is the STUB version of the PshellServer module, to use the actual version, // set the PshellServer softlink to PshellServer-full, or use the provided utility // shell script 'setPshellLib' to set the desired softlink and 'showPshellLib' to // display the current softlink settings. Note, since go is statically linked, a @@ -55,19 +55,19 @@ const ( LOCAL = "local" ) -// These are the identifiers for the serverMode. BLOCKING wil never return -// control to the caller of startServer, NON_BLOCKING will spawn a thread to +// These are the identifiers for the serverMode. BLOCKING wil never return +// control to the caller of startServer, NON_BLOCKING will spawn a thread to // run the server and will return control to the caller of startServer const ( BLOCKING = 0 NON_BLOCKING = 1 ) -// These three identifiers that can be used for the hostnameOrIpAddr argument +// These three identifiers that can be used for the hostnameOrIpAddr argument // of the startServer call. PshellServer.ANYHOST will bind the server socket // to all interfaces of a multi-homed host, PSHELL_ANYBCAST will bind to -// 255.255.255.255, PshellServer.LOCALHOST will bind the server socket to -// the local loopback address (i.e. 127.0.0.1), note that subnet broadcast +// 255.255.255.255, PshellServer.LOCALHOST will bind the server socket to +// the local loopback address (i.e. 127.0.0.1), note that subnet broadcast // it also supported, e.g. x.y.z.255 const ( ANYHOST = "anyhost" diff --git a/go/src/pshellControlDemo/pshellControlDemo.go b/go/src/pshellControlDemo/pshellControlDemo.go index 42fc9d0..f1a1f32 100644 --- a/go/src/pshellControlDemo/pshellControlDemo.go +++ b/go/src/pshellControlDemo/pshellControlDemo.go @@ -1,28 +1,28 @@ ///////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2009, Ron Iovine, All rights reserved. -// -// Redistribution and use in source and binary forms, with or without +// +// Copyright (c) 2009, Ron Iovine, All rights reserved. +// +// Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. -// * Neither the name of Ron Iovine nor the names of its contributors -// may be used to endorse or promote products derived from this software +// * Neither the name of Ron Iovine nor the names of its contributors +// may be used to endorse or promote products derived from this software // without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY Ron Iovine ''AS IS'' AND ANY EXPRESS OR -// IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL Ron Iovine BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -// BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER -// IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -// POSSIBILITY OF SUCH DAMAGE. +// +// THIS SOFTWARE IS PROVIDED BY Ron Iovine ''AS IS'' AND ANY EXPRESS OR +// IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +// IN NO EVENT SHALL Ron Iovine BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR +// BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +// IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +// POSSIBILITY OF SUCH DAMAGE. // ///////////////////////////////////////////////////////////////////////////////// @@ -124,8 +124,8 @@ func main() { // register signal handlers so we can do a graceful termination and cleanup any system resources registerSignalHandlers() - - sid := PshellControl.ConnectServer("pshellControlDemo", os.Args[1], os.Args[2], timeout) + + sid := PshellControl.ConnectServer("pshellControlDemo", os.Args[1], os.Args[2], timeout) if (sid != PshellControl.INVALID_SID) { command := "" @@ -138,7 +138,7 @@ func main() { if ((len(command) > 0) && !strings.HasPrefix("quit", command)) { if (extract == true) { retCode, results := PshellControl.SendCommand3(sid, command) - if (retCode == PshellControl.COMMAND_SUCCESS) { + if (retCode == PshellControl.COMMAND_SUCCESS) { fmt.Printf("%d bytes extracted, results:\n", len(results)) fmt.Printf("%s", results) } @@ -151,6 +151,6 @@ func main() { } PshellControl.DisconnectServer(sid) } - + } diff --git a/go/src/pshellServerDemo/pshellServerDemo.go b/go/src/pshellServerDemo/pshellServerDemo.go index 59eeed3..36b9c98 100644 --- a/go/src/pshellServerDemo/pshellServerDemo.go +++ b/go/src/pshellServerDemo/pshellServerDemo.go @@ -1,28 +1,28 @@ ///////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2009, Ron Iovine, All rights reserved. -// -// Redistribution and use in source and binary forms, with or without +// +// Copyright (c) 2009, Ron Iovine, All rights reserved. +// +// Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. -// * Neither the name of Ron Iovine nor the names of its contributors -// may be used to endorse or promote products derived from this software +// * Neither the name of Ron Iovine nor the names of its contributors +// may be used to endorse or promote products derived from this software // without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY Ron Iovine ''AS IS'' AND ANY EXPRESS OR -// IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL Ron Iovine BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -// BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER -// IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -// POSSIBILITY OF SUCH DAMAGE. +// +// THIS SOFTWARE IS PROVIDED BY Ron Iovine ''AS IS'' AND ANY EXPRESS OR +// IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +// IN NO EVENT SHALL Ron Iovine BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR +// BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +// IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +// POSSIBILITY OF SUCH DAMAGE. // ///////////////////////////////////////////////////////////////////////////////// @@ -30,12 +30,12 @@ package main //////////////////////////////////////////////////////////////////////////////// // -// This is an example demo program that uses all the basic features of the PSHELL -// server Go module. This program can be run as either a UDP, TCP, UNIX, or -// local server based on the command line options. If it is run as a UDP or UNIX -// based server, you must use the provided stand-alone UDP client program 'pshell' +// This is an example demo program that uses all the basic features of the PSHELL +// server Go module. This program can be run as either a UDP, TCP, UNIX, or +// local server based on the command line options. If it is run as a UDP or UNIX +// based server, you must use the provided stand-alone UDP client program 'pshell' // or 'pshell.py' to connect to it, if it is run as a TCP server, you must use -// 'telnet, if it is run as a local server, user command line input is solicited +// 'telnet, if it is run as a local server, user command line input is solicited // directly from this program, no external client is needed. // //////////////////////////////////////////////////////////////////////////////// @@ -50,17 +50,17 @@ import "PshellServer" //////////////////////////////////////////////////////////////////////////////// // -// PSHELL user callback functions, the interface is similar to the "main" in +// PSHELL user callback functions, the interface is similar to the "main" in // Go, with the argv argument being the argument list and the len and contents // of argv are the user entered arguments, excluding the actual command itself // (arguments only). // -// Use the special 'PshellServer.Printf' function call to display data back to +// Use the special 'PshellServer.Printf' function call to display data back to // the remote client. The interface to this function is similar to the standard // 'fmt.Printf' function in Go. // //////////////////////////////////////////////////////////////////////////////// - + //////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////// func hello(argv []string) { @@ -81,12 +81,12 @@ func world(argv []string) { func enhancedUsage(argv []string) { // see if the user asked for help if (PshellServer.IsHelp()) { - // show standard usage + // show standard usage PshellServer.ShowUsage() - // give some enhanced usage + // give some enhanced usage PshellServer.Printf("Enhanced usage here...\n") } else { - // do normal function processing + // do normal function processing PshellServer.Printf("enhancedUsage command dispatched:\n") for index, arg := range argv { PshellServer.Printf(" argv[%d]: '%s'\n", index, arg) @@ -256,32 +256,32 @@ func main() { // register signal handlers so we can do a graceful termination and cleanup any system resources registerSignalHandlers() - + // register our callback commands, commands consist of single keyword only PshellServer.AddCommand(hello, // function "hello", // command "example hello command", // description - "[ ... ]", // usage + "[ ... ]", // usage 0, // minArgs 20, // maxArgs true) // showUsage on '?' - + PshellServer.AddCommand(world, // function "world", // command "world command description", // description - "", // usage + "", // usage 0, // minArgs 0, // maxArgs true) // showUsage on '?' - + PshellServer.AddCommand(enhancedUsage, // function "enhancedUsage", // command "command with enhanced usage", // description - "", // usage + "", // usage 1, // minArgs 1, // maxArgs false) // showUsage on '?' - + PshellServer.AddCommand(wildcardMatch, // function "wildcardMatch", // command "command that does a wildcard matching", // description @@ -293,12 +293,12 @@ func main() { PshellServer.AddCommand(getOptions, // function "getOptions", // command "example of parsing command line options", // description - " [...]", // usage + " [...]", // usage 1, // minArgs 20, // maxArgs false) // showUsage on '?' - - // TCP or LOCAL servers don't need a keep-alive, so only add + + // TCP or LOCAL servers don't need a keep-alive, so only add // this command for connectionless datagram type servers if ((serverType == PshellServer.UDP) || (serverType == PshellServer.UNIX)) { PshellServer.AddCommand(keepAlive, // function @@ -319,7 +319,7 @@ func main() { // The 1st argument is our serverName (i.e. "pshellServerDemo"). // // The 2nd argument specifies the type of PSHELL server, the four valid values are: - // + // // PshellServer.UDP - Server runs as a multi-session UDP based server. This requires // the special stand-alone command line UDP/UNIX client program // 'pshell'. This server has no timeout for idle client sessions. @@ -345,10 +345,10 @@ func main() { // control to the calling context. // PshellServer.BLOCKING - No thread is created, all processing of user input is done within // this function call, it will never return control to the calling context. - // + // // The 4th and 5th arguments are only used for a UDP or TCP server, for a LOCAL or // UNIX server they are ignored. - // + // // For the 4th argument, a valid IP address or hostname can be used. There are also 3 special // "hostname" type identifiers defined as follows: // @@ -359,7 +359,7 @@ func main() { // // Finally, the 5th argument is the desired port number. // - // All of these arguments (except the server name and mode, i.e. args 1 & 3) can be overridden + // All of these arguments (except the server name and mode, i.e. args 1 & 3) can be overridden // via the 'pshell-server.conf' file on a per-server basis. PshellServer.StartServer("pshellServerDemo", serverType, PshellServer.BLOCKING, PshellServer.ANYHOST, "7001") diff --git a/install.sh b/install.sh index 55374dc..1a74ffe 100755 --- a/install.sh +++ b/install.sh @@ -1,30 +1,30 @@ #!/bin/bash ################################################################################# -# -# Copyright (c) 2009, Ron Iovine, All rights reserved. -# -# Redistribution and use in source and binary forms, with or without +# +# Copyright (c) 2009, Ron Iovine, All rights reserved. +# +# Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: # * Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # * Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. -# * Neither the name of Ron Iovine nor the names of its contributors -# may be used to endorse or promote products derived from this software +# * Neither the name of Ron Iovine nor the names of its contributors +# may be used to endorse or promote products derived from this software # without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY Ron Iovine ''AS IS'' AND ANY EXPRESS OR -# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -# IN NO EVENT SHALL Ron Iovine BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -# BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER -# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -# POSSIBILITY OF SUCH DAMAGE. +# +# THIS SOFTWARE IS PROVIDED BY Ron Iovine ''AS IS'' AND ANY EXPRESS OR +# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +# IN NO EVENT SHALL Ron Iovine BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR +# BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. # ################################################################################# @@ -66,7 +66,7 @@ then echo exit 1 else - + # local install, setup some softlinks and create .pshellrc env file echo "Setting softlink libpshell-server to libpshell-server-full" cd $localDir/c/lib @@ -74,24 +74,24 @@ then ln -s libpshell-server-full.so libpshell-server.so rm -f libpshell-server.a ln -s libpshell-server-full.a libpshell-server.a - - echo "Setting softlink PshellServer.py PshellServer-full.py" + + echo "Setting softlink PshellServer.py PshellServer-full.py" cd $localDir/python/src - rm -f PshellServer.py - ln -s PshellServer-full.py PshellServer.py + rm -f PshellServer.py + ln -s PshellServer-full.py PshellServer.py if [ ! -e "$localDir/go/src/PshellServer" ] then mkdir $localDir/go/src/PshellServer fi - - echo "Setting softlink PshellServer.go PshellServer-full.go" - cd $localDir/go/src/PshellServer + + echo "Setting softlink PshellServer.go PshellServer-full.go" + cd $localDir/go/src/PshellServer rm -f $localDir/go/src/PshellServer/PshellServer.go ln -s $localDir/go/src/PshellServer-full/PshellServer-full.go $localDir/go/src/PshellServer/PshellServer.go - echo "Setting softlink PshellServer.a PshellServer-full.a" - cd $localDir/go/pkg/linux_amd64 + echo "Setting softlink PshellServer.a PshellServer-full.a" + cd $localDir/go/pkg/linux_amd64 rm -f PshellServer.a ln -s PshellServer-full.a PshellServer.a @@ -111,7 +111,7 @@ then ln -s pshellNoServerDemo$fileExt wildcardMatch$fileExt rm -f world* ln -s pshellNoServerDemo$fileExt world$fileExt - + cd $localDir rm -f .pshellrc echo "#" >> .pshellrc @@ -172,23 +172,23 @@ else localLibDir="c/lib" localMan1Dir="c/man/man1" localMan3Dir="c/man/man3" - + if [ -d "/usr/lib64" ] then libDir="/usr/lib64" else libDir="/usr/lib" fi - + echo "Installing pshell files..." echo "Installing libs..." - + if [ ! -d $libDir/pshell ] then echo "Creating lib directory $libDir/pshell" mkdir $libDir/pshell fi - + echo "Copying libpshell-server-full.so to $libDir/pshell" cp -f $localLibDir/libpshell-server-full.so $libDir/pshell/. echo "Copying libpshell-server-full.a to $libDir/pshell" @@ -201,18 +201,18 @@ else cp -f $localLibDir/libpshell-control.so $libDir/pshell/. echo "Copying libpshell-control.a to $libDir/pshell" cp -f $localLibDir/libpshell-control.a $libDir/pshell/. - - echo "Setting softlink $libDir/libpshell-server to $libDir/pshell/libpshell-server-full" + + echo "Setting softlink $libDir/libpshell-server to $libDir/pshell/libpshell-server-full" rm -f $libDir/libpshell-server.so ln -s $libDir/pshell/libpshell-server-full.so $libDir/libpshell-server.so - + rm -f $libDir/libpshell-server.a ln -s $libDir/pshell/libpshell-server-full.a $libDir/libpshell-server.a echo "Setting softlink $libDir/libpshell-control to $libDir/pshell/libpshell-control" rm -f $libDir/libpshell-control.so ln -s $libDir/pshell/libpshell-control.so $libDir/libpshell-control.so - + rm -f $libDir/libpshell-control.a ln -s $libDir/pshell/libpshell-control.a $libDir/libpshell-control.a @@ -223,7 +223,7 @@ else echo "Copying pshellAggregator$fileExt to $binDir" cp -f $localBinDir/pshellAggregator $binDir/. chmod +x $binDir/pshellAggregator$fileExt - + echo "Installing includes..." echo "Copying PshellServer.h to $includeDir" cp -f $localIncludeDir/PshellServer.h $includeDir/. @@ -235,7 +235,7 @@ else cp -f $localIncludeDir/TraceFilter.h $includeDir/. echo "Copying TraceLog.h to $includeDir" cp -f $localIncludeDir/TraceLog.h $includeDir/. - + if [ ! -d $pshellDir ] then echo "Creating pshell directory $pshellDir" @@ -249,7 +249,7 @@ else echo "Creating config directory $configDir" mkdir $configDir fi - + echo "Copying pshell-server.conf to $configDir" cp -f config/pshell-server.conf $configDir/. echo "Copying pshell-client.conf to $configDir" @@ -259,29 +259,29 @@ else echo "Copying README to $configDir" cp -f config/README $configDir/. chmod 666 $configDir/* - + echo "Installing batch files..." if [ ! -d $batchDir ] then echo "Creating batch directory $batchDir" mkdir $batchDir fi - + echo "Copying README to $batchDir" cp -f batch/README $batchDir/. chmod 666 $batchDir/* - + echo "Installing startup files..." if [ ! -d $startupDir ] then echo "Creating startup directory $startupDir" mkdir $startupDir fi - + echo "Copying README to $startupDir" cp -f startup/README $startupDir/. chmod 666 $startupDir/* - + echo "Installing manpages..." echo "Copying pshell.1 to $man1Dir" cp -f $localMan1Dir/pshell.1 $man1Dir/. diff --git a/python/demo/README b/python/demo/README index 7fd5836..dbc8ebc 100644 --- a/python/demo/README +++ b/python/demo/README @@ -1,3 +1,3 @@ -This directory contains the various demo programs that demonstrate the -usage of the Python versions of the PshellControl, PshellServer, and the +This directory contains the various demo programs that demonstrate the +usage of the Python versions of the PshellControl, PshellServer, and the PshellReadline modules. diff --git a/python/demo/pshellAggregatorDemo.py b/python/demo/pshellAggregatorDemo.py index 2682e21..60a7583 100755 --- a/python/demo/pshellAggregatorDemo.py +++ b/python/demo/pshellAggregatorDemo.py @@ -1,30 +1,30 @@ #!/usr/bin/python ################################################################################# -# -# Copyright (c) 2009, Ron Iovine, All rights reserved. -# -# Redistribution and use in source and binary forms, with or without +# +# Copyright (c) 2009, Ron Iovine, All rights reserved. +# +# Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: # * Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # * Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. -# * Neither the name of Ron Iovine nor the names of its contributors -# may be used to endorse or promote products derived from this software +# * Neither the name of Ron Iovine nor the names of its contributors +# may be used to endorse or promote products derived from this software # without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY Ron Iovine ''AS IS'' AND ANY EXPRESS OR -# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -# IN NO EVENT SHALL Ron Iovine BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -# BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER -# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -# POSSIBILITY OF SUCH DAMAGE. +# +# THIS SOFTWARE IS PROVIDED BY Ron Iovine ''AS IS'' AND ANY EXPRESS OR +# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +# IN NO EVENT SHALL Ron Iovine BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR +# BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. # ################################################################################# @@ -35,7 +35,7 @@ # servers into a single local pshell server. This can be useful in presenting # a consolidated user shell who's functionality spans several discrete pshell # servers. Since this uses the PshellControl API, the external servers must -# all be either UDP or Unix servers. The consolidation point in this example +# all be either UDP or Unix servers. The consolidation point in this example # is a local pshell server. Note that this is a hard coded aggregator, meaning # that the remote servers that are aggregated are hard-coded, as opposed to # the generic, dynamic pshellAggregator.py client program, which can aggregate @@ -52,7 +52,7 @@ import PshellControl # this function is the common generic function to control any server -# based on only the SID and entered command, it should be called from +# based on only the SID and entered command, it should be called from # every control specific callback for this aggregator ################################################################################# @@ -66,7 +66,7 @@ def controlServer(sid, argv): (results, retCode) = PshellControl.sendCommand3(sid, command) if (retCode == PshellControl.COMMAND_SUCCESS): PshellServer.printf(results, newline=False) - + # the following two functions are the control specific functions that interface # directly to a given remote server via the control API for a give SID, this is # how multiple remote pshell servers can be aggregated into a single local pshell @@ -98,13 +98,13 @@ def meta(argv): (results, retCode) = PshellControl.sendCommand3(pshellServerDemoSid, "hello %s %s" % (argv[0], argv[1])) if (retCode == PshellControl.COMMAND_SUCCESS): PshellServer.printf(results, newline=False) - + PshellControl.sendCommand1(traceFilterDemoSid, "set callback %s" % argv[2]) # example multicast command, this will send a given command to all the registered # multicast receivers for that multicast group, multicast groups are based on # the command's keyword - + ################################################################################# ################################################################################# def multicast(argv): @@ -133,15 +133,15 @@ def multicast(argv): exit (0) elif (len(sys.argv) == 4): pshellServerDemoPort = sys.argv[2] - traceFilterDemoPort = sys.argv[3] - + traceFilterDemoPort = sys.argv[3] + # add PshellControl entries to our aggregator list, the hostname/ipAddress, # port and timeout values can be overridden via the pshell-control.conf file pshellServerDemoSid = PshellControl.connectServer("pshellServerDemo", sys.argv[1], pshellServerDemoPort, PshellControl.ONE_SEC*5) - + traceFilterDemoSid = PshellControl.connectServer("traceFilterDemo", sys.argv[1], traceFilterDemoPort, @@ -150,8 +150,8 @@ def multicast(argv): # add some multicast groups for our control sids, a multicast group is based # on the command's keyword PshellControl.addMulticast(pshellServerDemoSid, "trace"); - PshellControl.addMulticast(traceFilterDemoSid, "trace"); - + PshellControl.addMulticast(traceFilterDemoSid, "trace"); + PshellControl.addMulticast(pshellServerDemoSid, "test"); PshellControl.addMulticast(traceFilterDemoSid, "test"); @@ -163,7 +163,7 @@ def multicast(argv): 0, 30, False) - + PshellServer.addCommand(traceFilterDemo, "traceFilterDemo", "control the remote traceFilterDemo process", @@ -190,10 +190,10 @@ def multicast(argv): # start our local pshell server PshellServer.startServer("pshellAggregatorDemo", PshellServer.LOCAL, PshellServer.BLOCKING) - + # disconnect all our remote control servers PshellControl.disconnectAllServers() - + # cleanup our local server's resources PshellServer.cleanupResources() - + diff --git a/python/demo/pshellControlDemo.py b/python/demo/pshellControlDemo.py index 2aeab66..2af2618 100755 --- a/python/demo/pshellControlDemo.py +++ b/python/demo/pshellControlDemo.py @@ -1,30 +1,30 @@ #!/usr/bin/python ################################################################################# -# -# Copyright (c) 2009, Ron Iovine, All rights reserved. -# -# Redistribution and use in source and binary forms, with or without +# +# Copyright (c) 2009, Ron Iovine, All rights reserved. +# +# Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: # * Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # * Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. -# * Neither the name of Ron Iovine nor the names of its contributors -# may be used to endorse or promote products derived from this software +# * Neither the name of Ron Iovine nor the names of its contributors +# may be used to endorse or promote products derived from this software # without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY Ron Iovine ''AS IS'' AND ANY EXPRESS OR -# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -# IN NO EVENT SHALL Ron Iovine BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -# BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER -# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -# POSSIBILITY OF SUCH DAMAGE. +# +# THIS SOFTWARE IS PROVIDED BY Ron Iovine ''AS IS'' AND ANY EXPRESS OR +# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +# IN NO EVENT SHALL Ron Iovine BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR +# BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. # ################################################################################# diff --git a/python/demo/pshellReadlineDemo.py b/python/demo/pshellReadlineDemo.py index 7185d50..b9d9c7a 100755 --- a/python/demo/pshellReadlineDemo.py +++ b/python/demo/pshellReadlineDemo.py @@ -1,30 +1,30 @@ #!/usr/bin/python ################################################################################# -# -# Copyright (c) 2009, Ron Iovine, All rights reserved. -# -# Redistribution and use in source and binary forms, with or without +# +# Copyright (c) 2009, Ron Iovine, All rights reserved. +# +# Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: # * Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # * Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. -# * Neither the name of Ron Iovine nor the names of its contributors -# may be used to endorse or promote products derived from this software +# * Neither the name of Ron Iovine nor the names of its contributors +# may be used to endorse or promote products derived from this software # without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY Ron Iovine ''AS IS'' AND ANY EXPRESS OR -# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -# IN NO EVENT SHALL Ron Iovine BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -# BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER -# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -# POSSIBILITY OF SUCH DAMAGE. +# +# THIS SOFTWARE IS PROVIDED BY Ron Iovine ''AS IS'' AND ANY EXPRESS OR +# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +# IN NO EVENT SHALL Ron Iovine BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR +# BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. # ################################################################################# @@ -107,18 +107,18 @@ def showUsage(): # and pass the connected file descriptors to our PshellReadline # module if (serialType == PshellReadline.SOCKET): - + # Create a TCP/IP socket sockFd = socket.socket(socket.AF_INET, socket.SOCK_STREAM) sockFd.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) - + # Bind the socket to the port port = 9005 sockFd.bind(("", port)) - + # Listen for incoming connections sockFd.listen(1) - + # Wait for a connection print("waiting for a connection on port %d, use 'telnet localhost %d' to connect" % (port, port)) connectFd, clientAddr = sockFd.accept() @@ -126,7 +126,7 @@ def showUsage(): # set our connected file descriptors and serial type PshellReadline.setFileDescriptors(connectFd, connectFd, PshellReadline.SOCKET) - + # shutdown our original listening socket sockFd.shutdown(socket.SHUT_RDWR); diff --git a/python/demo/pshellServerDemo.py b/python/demo/pshellServerDemo.py index 168ab78..67a4e41 100755 --- a/python/demo/pshellServerDemo.py +++ b/python/demo/pshellServerDemo.py @@ -1,41 +1,41 @@ #!/usr/bin/python ################################################################################# -# -# Copyright (c) 2009, Ron Iovine, All rights reserved. -# -# Redistribution and use in source and binary forms, with or without +# +# Copyright (c) 2009, Ron Iovine, All rights reserved. +# +# Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: # * Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # * Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. -# * Neither the name of Ron Iovine nor the names of its contributors -# may be used to endorse or promote products derived from this software +# * Neither the name of Ron Iovine nor the names of its contributors +# may be used to endorse or promote products derived from this software # without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY Ron Iovine ''AS IS'' AND ANY EXPRESS OR -# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -# IN NO EVENT SHALL Ron Iovine BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -# BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER -# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -# POSSIBILITY OF SUCH DAMAGE. +# +# THIS SOFTWARE IS PROVIDED BY Ron Iovine ''AS IS'' AND ANY EXPRESS OR +# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +# IN NO EVENT SHALL Ron Iovine BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR +# BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. # ################################################################################# ################################################################################# # -# This is an example demo program that uses all the basic features of the PSHELL -# server python module. This program can be run as either a UDP, TCP, UNIX, or -# local server based on the command line options. If it is run as a UDP or UNIX -# based server, you must use the provided stand-alone UDP client program 'pshell' +# This is an example demo program that uses all the basic features of the PSHELL +# server python module. This program can be run as either a UDP, TCP, UNIX, or +# local server based on the command line options. If it is run as a UDP or UNIX +# based server, you must use the provided stand-alone UDP client program 'pshell' # or 'pshell.py' to connect to it, if it is run as a TCP server, you must use -# 'telnet, if it is run as a local server, user command line input is solicited +# 'telnet, if it is run as a local server, user command line input is solicited # directly from this program, no external client is needed. # ################################################################################# @@ -53,12 +53,12 @@ # contents of argv are the user entered arguments, excluding the actual command # itself (arguments only). # -# Use the special 'PshellServer.printf' function call to display data back to +# Use the special 'PshellServer.printf' function call to display data back to # the remote client. The interface to this function is similar to the standard # 'print' function in Python. # ################################################################################# - + ################################################################################# ################################################################################# def hello(argv): @@ -76,12 +76,12 @@ def world(argv): def enhancedUsage(argv): # see if the user asked for help if (PshellServer.isHelp()): - # show standard usage + # show standard usage PshellServer.showUsage() - # give some enhanced usage + # give some enhanced usage PshellServer.printf("Enhanced usage here...") else: - # do normal function processing + # do normal function processing PshellServer.printf("enhancedUsage command dispatched:") for index, arg in enumerate(argv): PshellServer.printf(" argv[%d]: '%s'" % (index, arg)) @@ -231,46 +231,46 @@ def registerSignalHandlers(): registerSignalHandlers() # register our callback commands, commands consist of single keyword only - PshellServer.addCommand(function = hello, - command = "hello", - description = "hello command description", - usage = "[ ... ]", - minArgs = 0, + PshellServer.addCommand(function = hello, + command = "hello", + description = "hello command description", + usage = "[ ... ]", + minArgs = 0, maxArgs = 20) - - PshellServer.addCommand(function = world, - command = "world", + + PshellServer.addCommand(function = world, + command = "world", description = "world command description") - - PshellServer.addCommand(function = enhancedUsage, - command = "enhancedUsage", - description = "command with enhanced usage", - usage = "", + + PshellServer.addCommand(function = enhancedUsage, + command = "enhancedUsage", + description = "command with enhanced usage", + usage = "", minArgs = 1, showUsage = False) - - PshellServer.addCommand(function = wildcardMatch, + + PshellServer.addCommand(function = wildcardMatch, command = "wildcardMatch", - description = "command that does a wildcard matching", - usage = "", + description = "command that does a wildcard matching", + usage = "", minArgs = 1, - showUsage = False) + showUsage = False) - PshellServer.addCommand(function = getOptions, - command = "getOptions", - description = "example of parsing command line options", - usage = " [...]", - minArgs = 1, - maxArgs = 20, + PshellServer.addCommand(function = getOptions, + command = "getOptions", + description = "example of parsing command line options", + usage = " [...]", + minArgs = 1, + maxArgs = 20, showUsage = False) - - # TCP or LOCAL servers don't need a keep-alive, so only add + + # TCP or LOCAL servers don't need a keep-alive, so only add # this command for connectionless datagram type servers if ((serverType == PshellServer.UDP) or (serverType == PshellServer.UNIX)): - PshellServer.addCommand(function = keepAlive, - command = "keepAlive", - description = "command to show client keep-alive", - usage = "dots | bang | pound | wheel", + PshellServer.addCommand(function = keepAlive, + command = "keepAlive", + description = "command to show client keep-alive", + usage = "dots | bang | pound | wheel", minArgs = 1) # run a registered command from within it's parent process, this can be done before @@ -282,7 +282,7 @@ def registerSignalHandlers(): # The 1st argument is our serverName (i.e. "pshellServerDemo"). # # The 2nd argument specifies the type of PSHELL server, the four valid values are: - # + # # PshellServer.UDP - Server runs as a multi-session UDP based server. This requires # the special stand-alone command line UDP/UNIX client program # 'pshell'. This server has no timeout for idle client sessions. @@ -308,10 +308,10 @@ def registerSignalHandlers(): # control to the calling context. # PshellServer.BLOCKING - No thread is created, all processing of user input is done within # this function call, it will never return control to the calling context. - # + # # The 4th and 5th arguments must be provided for a UDP or TCP server, for a LOCAL or # UNIX server they can be omitted, and if provided they will be ignored. - # + # # For the 4th argument, a valid IP address or hostname can be used. There are also 3 special # "hostname" type identifiers defined as follows: # @@ -322,7 +322,7 @@ def registerSignalHandlers(): # # Finally, the 5th argument is the desired port number. # - # All of these arguments (except the server name and mode, i.e. args 1 & 3) can be overridden + # All of these arguments (except the server name and mode, i.e. args 1 & 3) can be overridden # via the 'pshell-server.conf' file on a per-server basis. PshellServer.startServer("pshellServerDemo", serverType, PshellServer.BLOCKING, PshellServer.ANYHOST, 9001) diff --git a/python/src/PshellControl.py b/python/src/PshellControl.py index 4a50859..d662e5b 100755 --- a/python/src/PshellControl.py +++ b/python/src/PshellControl.py @@ -1,30 +1,30 @@ #!/usr/bin/python ################################################################################# -# -# Copyright (c) 2009, Ron Iovine, All rights reserved. -# -# Redistribution and use in source and binary forms, with or without +# +# Copyright (c) 2009, Ron Iovine, All rights reserved. +# +# Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: # * Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # * Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. -# * Neither the name of Ron Iovine nor the names of its contributors -# may be used to endorse or promote products derived from this software +# * Neither the name of Ron Iovine nor the names of its contributors +# may be used to endorse or promote products derived from this software # without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY Ron Iovine ''AS IS'' AND ANY EXPRESS OR -# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -# IN NO EVENT SHALL Ron Iovine BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -# BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER -# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -# POSSIBILITY OF SUCH DAMAGE. +# +# THIS SOFTWARE IS PROVIDED BY Ron Iovine ''AS IS'' AND ANY EXPRESS OR +# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +# IN NO EVENT SHALL Ron Iovine BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR +# BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. # ################################################################################# @@ -41,7 +41,7 @@ This module provides the same functionality as the PshellControl.h API and the libpshell-control linkable 'C' library, but implemented as a Python module. - + Functions: connectServer() -- connect to a remote pshell server @@ -59,7 +59,7 @@ Integer constants: -Helpful items used for the server response timeout values +Helpful items used for the server response timeout values NO_WAIT ONE_MSEC @@ -84,7 +84,7 @@ String constants: -Use this as the "port" identifier for the connectServer +Use this as the "port" identifier for the connectServer call when using a UNIX domain server UNIX @@ -93,7 +93,7 @@ MULTICAST_ALL -A complete example of the usage of the API can be found in the included +A complete example of the usage of the API can be found in the included demo programs pshellControlDemo.py and pshellAggregatorDemo.py """ @@ -114,14 +114,14 @@ # ################################################################################# -# helpful items used for the timeout values +# helpful items used for the timeout values NO_WAIT = 0 ONE_MSEC = 1 ONE_SEC = ONE_MSEC*1000 # use this as the "port" identifier for the connectServer call when # using a UNIX domain server -UNIX = "unix" +UNIX = "unix" # the following enum values are returned by the non-extraction # based sendCommand1 and sendCommand2 functions @@ -131,7 +131,7 @@ COMMAND_SUCCESS = 0 COMMAND_NOT_FOUND = 1 COMMAND_INVALID_ARG_COUNT = 2 -# the following "SOCKET" enums are generated internally by the sendCommandN functions +# the following "SOCKET" enums are generated internally by the sendCommandN functions SOCKET_SEND_FAILURE = 3 SOCKET_SELECT_FAILURE = 4 SOCKET_RECEIVE_FAILURE = 5 @@ -149,7 +149,7 @@ # "public" API functions # # Users of this module should only access functionality via these "public" -# methods. This is broken up into "public" and "private" sections for +# methods. This is broken up into "public" and "private" sections for # readability and to not expose the implementation in the API definition # ################################################################################# @@ -169,12 +169,12 @@ def connectServer(controlName, remoteServer, port, defaultTimeout): will return either SOCKET_NOT_CONNECTED, SOCKET_SEND_FAILURE, or COMMAND_SUCCESS, the timeout value entered in this funcition will be used as the default timeout for all calls to sendCommandN that - do not provide an override timeout value, for a UDP server, the - remoteServer must be either a valid hostname or IP address and a - valid destination port must be provided, for a UNIX server, only - a valid server name must be provided along with the identifier + do not provide an override timeout value, for a UDP server, the + remoteServer must be either a valid hostname or IP address and a + valid destination port must be provided, for a UNIX server, only + a valid server name must be provided along with the identifier PshellControl.UNIX for the 'port' parameter - + This function returns a Server ID (sid) handle which must be saved and used for all subsequent calls into this module @@ -193,7 +193,7 @@ def connectServer(controlName, remoteServer, port, defaultTimeout): ################################################################################# def disconnectServer(sid): """ - Cleanup any resources associated with the server connection, including + Cleanup any resources associated with the server connection, including releasing any temp file handles, closing any local socket handles etc. Args: @@ -208,10 +208,10 @@ def disconnectServer(sid): ################################################################################# def disconnectAllServers(): """ - Use this function to cleanup any resources for all connected servers, this - function should be called upon program termination, either in a graceful - termination or within an exception signal handler, it is especially important - that this be called when a unix server is used since there are associated file + Use this function to cleanup any resources for all connected servers, this + function should be called upon program termination, either in a graceful + termination or within an exception signal handler, it is especially important + that this be called when a unix server is used since there are associated file handles that need to be cleaned up Args: @@ -226,7 +226,7 @@ def disconnectAllServers(): ################################################################################# def setDefaultTimeout(sid, defaultTimeout): """ - Set the default server response timeout that is used in the 'send' commands + Set the default server response timeout that is used in the 'send' commands that don't take a timeout override Args: @@ -241,10 +241,10 @@ def setDefaultTimeout(sid, defaultTimeout): ################################################################################# ################################################################################# def extractCommands(sid, includeName = True): - """ - This function will extract all the commands of a remote pshell server and - present them in a human readable form, this is useful when writing a multi - server control aggregator, see the demo program pshellAggregatorDemo.py in + """ + This function will extract all the commands of a remote pshell server and + present them in a human readable form, this is useful when writing a multi + server control aggregator, see the demo program pshellAggregatorDemo.py in the demo directory for examples Args: @@ -260,8 +260,8 @@ def extractCommands(sid, includeName = True): ################################################################################# def addMulticast(sid, keyword = MULTICAST_ALL): """ - This command will add a given multicast receiver (i.e. sid) to a multicast - group, multicast groups are either based on the command's keyword, or if + This command will add a given multicast receiver (i.e. sid) to a multicast + group, multicast groups are either based on the command's keyword, or if no keyword is supplied, the given sid will receive all multicast commands Args: @@ -272,7 +272,7 @@ def addMulticast(sid, keyword = MULTICAST_ALL): Returns: none - """ + """ _addMulticast(sid, keyword) ################################################################################# @@ -280,10 +280,10 @@ def addMulticast(sid, keyword = MULTICAST_ALL): def sendMulticast(command): """ This command will send a given command to all the registered multicast - receivers (i.e. sids) for this multicast group, multicast groups are - based on the command's keyword, this function will issue the command as - a best effort fire-and-forget command to each receiver in the multicast - group, no results will be requested or expected, and no response will be + receivers (i.e. sids) for this multicast group, multicast groups are + based on the command's keyword, this function will issue the command as + a best effort fire-and-forget command to each receiver in the multicast + group, no results will be requested or expected, and no response will be requested or expected Args: @@ -291,14 +291,14 @@ def sendMulticast(command): Returns: none - """ + """ _sendMulticast(command) ################################################################################# ################################################################################# def sendCommand1(sid, command): """ - Send a command using the default timeout setup in the connectServer call, + Send a command using the default timeout setup in the connectServer call, if the default timeout is 0, the server will not reply with a response and this function will not wait for one @@ -323,8 +323,8 @@ def sendCommand1(sid, command): ################################################################################# def sendCommand2(sid, timeoutOverride, command): """ - Send a command overriding the default timeout, if the override timeout is 0, - the server will not reply with a response and this function will not wait for + Send a command overriding the default timeout, if the override timeout is 0, + the server will not reply with a response and this function will not wait for one Args: @@ -349,9 +349,9 @@ def sendCommand2(sid, timeoutOverride, command): ################################################################################# def sendCommand3(sid, command): """ - Send a command using the default timeout setup in the connectServer call and - return any results received in the payload, if the default timeout is 0, the - server will not reply with a response and this function will not wait for one, + Send a command using the default timeout setup in the connectServer call and + return any results received in the payload, if the default timeout is 0, the + server will not reply with a response and this function will not wait for one, and no results will be extracted Args: @@ -377,9 +377,9 @@ def sendCommand3(sid, command): ################################################################################# def sendCommand4(sid, timeoutOverride, command): """ - Send a command overriding the default timeout and return any results received - in the payload, if the timeout override default timeout is 0, the server will - not reply with a response and this function will not wait for one, and no + Send a command overriding the default timeout and return any results received + in the payload, if the timeout override default timeout is 0, the server will + not reply with a response and this function will not wait for one, and no results will be extracted Args: @@ -446,7 +446,7 @@ def _connectServer(controlName_, remoteServer_, port_, defaultTimeout_): try: socketFd.bind(sourceAddress) bound = True - except Exception as e: + except Exception as e: sourceAddress = _gUnixSocketPath+remoteServer_+str(random.randrange(1000)) _gPshellControl.append({"socket":socketFd, "timeout":defaultTimeout_, @@ -712,8 +712,8 @@ def _sendCommand(control_, commandType_, command_, timeout_): seqNum = control_["pshellMsg"]["seqNum"] control_["pshellMsg"]["payload"] = str(command_) try: - sentSize = control_["socket"].sendto(struct.pack(_gPshellMsgHeaderFormat+str(len(control_["pshellMsg"]["payload"]))+"s", - *control_["pshellMsg"].values()), + sentSize = control_["socket"].sendto(struct.pack(_gPshellMsgHeaderFormat+str(len(control_["pshellMsg"]["payload"]))+"s", + *control_["pshellMsg"].values()), control_["destAddress"]) except: sentSize = 0 @@ -729,11 +729,11 @@ def _sendCommand(control_, commandType_, command_, timeout_): control_["pshellMsg"], addr = control_["socket"].recvfrom(_gPshellMsgPayloadLength) control_["pshellMsg"] = _PshellMsg._asdict(_PshellMsg._make(struct.unpack(_gPshellMsgHeaderFormat+str(len(control_["pshellMsg"])-struct.calcsize(_gPshellMsgHeaderFormat))+"s", control_["pshellMsg"]))) if (seqNum > control_["pshellMsg"]["seqNum"]): - # make sure we have the correct response, this condition can happen if we had - # a very short timeout for the previous call and missed the response, in which - # case the response to the previous call will be queued in the socket ahead of - # our current expected response, when we detect that condition, we read the - # socket until we either find the correct response or timeout, we toss any previous + # make sure we have the correct response, this condition can happen if we had + # a very short timeout for the previous call and missed the response, in which + # case the response to the previous call will be queued in the socket ahead of + # our current expected response, when we detect that condition, we read the + # socket until we either find the correct response or timeout, we toss any previous # unmatched responses print("PSHELL_WARNING: Received seqNum: %d, does not match sent seqNum: %d" % (control_["pshellMsg"]["seqNum"], seqNum)) else: @@ -788,7 +788,7 @@ def _getControl(sid_): ################################################################################# ################################################################################# -def _loadConfigFile(controlName_, remoteServer_, port_, defaultTimeout_): +def _loadConfigFile(controlName_, remoteServer_, port_, defaultTimeout_): configFile1 = "" configPath = os.getenv('PSHELL_CONFIG_DIR') if (configPath != None): @@ -860,7 +860,7 @@ def _loadConfigFile(controlName_, remoteServer_, port_, defaultTimeout_): _PshellMsg = namedtuple('PshellMsg', 'msgType respNeeded dataNeeded pad seqNum payload') # format of PshellMsg header, 4 bytes and 1 (4 byte) integer, we use this for packing/unpacking -# the PshellMessage to/from an OrderedDict into a packed binary structure that can be transmitted +# the PshellMessage to/from an OrderedDict into a packed binary structure that can be transmitted # over-the-wire via a socket _gPshellMsgHeaderFormat = "4BI" @@ -869,15 +869,15 @@ def _loadConfigFile(controlName_, remoteServer_, port_, defaultTimeout_): _gPshellMsgPayloadLength = 1024*64 # mapping of above definitions to strings so we can display text in error messages -_gPshellControlResponse = {COMMAND_SUCCESS:"PSHELL_COMMAND_SUCCESS", - COMMAND_NOT_FOUND:"PSHELL_COMMAND_NOT_FOUND", - COMMAND_INVALID_ARG_COUNT:"PSHELL_COMMAND_INVALID_ARG_COUNT", - SOCKET_SEND_FAILURE:"PSHELL_SOCKET_SEND_FAILURE", - SOCKET_SELECT_FAILURE:"PSHELL_SOCKET_SELECT_FAILURE", - SOCKET_RECEIVE_FAILURE:"PSHELL_SOCKET_RECEIVE_FAILURE", +_gPshellControlResponse = {COMMAND_SUCCESS:"PSHELL_COMMAND_SUCCESS", + COMMAND_NOT_FOUND:"PSHELL_COMMAND_NOT_FOUND", + COMMAND_INVALID_ARG_COUNT:"PSHELL_COMMAND_INVALID_ARG_COUNT", + SOCKET_SEND_FAILURE:"PSHELL_SOCKET_SEND_FAILURE", + SOCKET_SELECT_FAILURE:"PSHELL_SOCKET_SELECT_FAILURE", + SOCKET_RECEIVE_FAILURE:"PSHELL_SOCKET_RECEIVE_FAILURE", SOCKET_TIMEOUT:"PSHELL_SOCKET_TIMEOUT", SOCKET_NOT_CONNECTED:"PSHELL_SOCKET_NOT_CONNECTED"} - + # the suppress flag is used as a backdoor for the pshell.py client to allow # a remote server to pass the command usage back to the local server that # is run by the client diff --git a/python/src/PshellReadline.py b/python/src/PshellReadline.py index 378581b..19ccee0 100755 --- a/python/src/PshellReadline.py +++ b/python/src/PshellReadline.py @@ -1,30 +1,30 @@ #!/usr/bin/python ################################################################################# -# -# Copyright (c) 2009, Ron Iovine, All rights reserved. -# -# Redistribution and use in source and binary forms, with or without +# +# Copyright (c) 2009, Ron Iovine, All rights reserved. +# +# Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: # * Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # * Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. -# * Neither the name of Ron Iovine nor the names of its contributors -# may be used to endorse or promote products derived from this software +# * Neither the name of Ron Iovine nor the names of its contributors +# may be used to endorse or promote products derived from this software # without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY Ron Iovine ''AS IS'' AND ANY EXPRESS OR -# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -# IN NO EVENT SHALL Ron Iovine BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -# BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER -# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -# POSSIBILITY OF SUCH DAMAGE. +# +# THIS SOFTWARE IS PROVIDED BY Ron Iovine ''AS IS'' AND ANY EXPRESS OR +# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +# IN NO EVENT SHALL Ron Iovine BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR +# BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. # ################################################################################# @@ -32,10 +32,10 @@ A Python module to provide readline like user input functionality This API implements a readline like functionality for user input. This can -work with any character stream based input/output terminal device, i.e. -keyboard input over a serial tty, or over a TCP/telnet connection. This module -will provide up-arrow command history recall, command line editing, and TAB -completion of registered keywords. +work with any character stream based input/output terminal device, i.e. +keyboard input over a serial tty, or over a TCP/telnet connection. This module +will provide up-arrow command history recall, command line editing, and TAB +completion of registered keywords. Functions: @@ -74,7 +74,7 @@ FAST_TAB -A complete example of the usage of the API can be found in the included demo +A complete example of the usage of the API can be found in the included demo program pshellReadlineDemo.py """ @@ -114,7 +114,7 @@ # "public" API functions # # Users of this module should only access functionality via these "public" -# methods. This is broken up into "public" and "private" sections for +# methods. This is broken up into "public" and "private" sections for # readability and to not expose the implementation in the API definition # ################################################################################# @@ -125,12 +125,12 @@ def setFileDescriptors(inFd, outFd, serialType, idleTimeout = IDLE_TIMEOUT_NONE) """ Set the input and output file descriptors, if this function is not called, the default is stdin and stdout. The file descriptors given to this function - must be opened and running in raw serial character mode. The idleTimeout + must be opened and running in raw serial character mode. The idleTimeout specifies the time to wait for any user activity in the getInput function. Use the identifiers PshellReadline.ONE_SECOND and PshellReadline.ONE_MINUTE to set this timeout value, e.g. PshellReadline.ONE_MINUTE*5, for serialType use the identifiers PshellReadline.TTY and PshellReadline.SOCKET. For the - socket identifier, use the file descriptor that is returned from the TCP + socket identifier, use the file descriptor that is returned from the TCP socket server 'accept' call for both the inFd and outFd. Args: @@ -211,12 +211,12 @@ def setTabStyle(tabStyle): ################################################################################# def getInput(prompt): """ - Issue the user prompt and return the entered command line value. This + Issue the user prompt and return the entered command line value. This function will return the tuple (command, idleSession). If the idle session - timeout is set to IDLE_TIMEOUT_NONE (default), the idleSession will always + timeout is set to IDLE_TIMEOUT_NONE (default), the idleSession will always be false and this function will not return until the user has typed a command and pressed return. Otherwise this function will set the idleSession value - to true and return if no user activity is detected for the idleSessionTimeout + to true and return if no user activity is detected for the idleSessionTimeout period Args: @@ -232,13 +232,13 @@ def getInput(prompt): ################################################################################# def isSubString(string1, string2, minMatchLength = 0): """ - This function will return True if string1 is a substring of string2 at + This function will return True if string1 is a substring of string2 at position 0. If the minMatchLength is 0, then it will compare up to the length of string1. If the minMatchLength > 0, it will require a minimum of that many characters to match. A string that is longer than the min match length must still match for the remaining characters, e.g. with a minMatchLength of 2, 'q' will not match 'quit', but 'qu', 'qui' or 'quit' - will match, 'quix' or 'uit' will not match. This function is useful for + will match, 'quix' or 'uit' will not match. This function is useful for wildcard matching. Args: @@ -511,7 +511,7 @@ def _getInput(prompt_): if (command == "history"): # add command to our command history _addHistory(command) - # we process the history internally + # we process the history internally _showHistory() command = "" cursorPos = 0 @@ -525,14 +525,14 @@ def _getInput(prompt_): command = _gCommandHistory[index] _addHistory(command) if command == "history": - # we process the history internally + # we process the history internally _showHistory() command = "" cursorPos = 0 tabCount = 0 _writeOutput(prompt_) else: - return (command.strip(), False) + return (command.strip(), False) else: command = "" cursorPos = 0 @@ -554,7 +554,7 @@ def _getInput(prompt_): _writeOutput(prompt_) elif (ord(char) == 11): # kill to eol - _writeOutput(" "*len(command[cursorPos:]) + "\b"*(len(command[cursorPos:]))) + _writeOutput(" "*len(command[cursorPos:]) + "\b"*(len(command[cursorPos:]))) command = command[:cursorPos] elif (ord(char) == 21): # kill whole line @@ -588,7 +588,7 @@ def _getInput(prompt_): _clearLine(cursorPos, command) (cursorPos, command) = _showCommand(_findLongestMatch(matchList, command)) else: # BASH_TAB - # this code below implements the more standard readline/bash double tabbing method + # this code below implements the more standard readline/bash double tabbing method if (tabCount == 2): if (len(command) == 0): # nothing typed, just a double TAB, show all registered TAB completions @@ -645,7 +645,7 @@ def _showHistory(): global _gCommandHistory for index, keyword in enumerate(_gCommandHistory): _writeOutput("%-3d %s\n" % (index+1, keyword)) - + ################################################################################# ################################################################################# def _writeOutput(string_): diff --git a/python/src/PshellServer-full.py b/python/src/PshellServer-full.py index 7157164..0a0b9b3 100755 --- a/python/src/PshellServer-full.py +++ b/python/src/PshellServer-full.py @@ -1,30 +1,30 @@ #!/usr/bin/python ################################################################################# -# -# Copyright (c) 2009, Ron Iovine, All rights reserved. -# -# Redistribution and use in source and binary forms, with or without +# +# Copyright (c) 2009, Ron Iovine, All rights reserved. +# +# Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: # * Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # * Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. -# * Neither the name of Ron Iovine nor the names of its contributors -# may be used to endorse or promote products derived from this software +# * Neither the name of Ron Iovine nor the names of its contributors +# may be used to endorse or promote products derived from this software # without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY Ron Iovine ''AS IS'' AND ANY EXPRESS OR -# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -# IN NO EVENT SHALL Ron Iovine BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -# BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER -# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -# POSSIBILITY OF SUCH DAMAGE. +# +# THIS SOFTWARE IS PROVIDED BY Ron Iovine ''AS IS'' AND ANY EXPRESS OR +# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +# IN NO EVENT SHALL Ron Iovine BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR +# BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. # ################################################################################# @@ -32,17 +32,17 @@ A Lightweight, Process-Specific, Embedded Command Line Shell This API provides the Process Specific Embedded Command Line Shell (PSHELL) -user API functionality. It provides the ability for a program to register -functions that can be invoked via a command line user interface. There are -several ways to invoke these embedded functions based on how the pshell server +user API functionality. It provides the ability for a program to register +functions that can be invoked via a command line user interface. There are +several ways to invoke these embedded functions based on how the pshell server is configured, which is described in documentation further down in this file. - + This module provides the same functionality as the PshellServer.h API and -the libpshell-server linkable 'C' library, but implemented as a Python module. -It supports all the server types as the corresponding 'C' impelmentation, TCP, -UDP, UNIX and LOCAL server types are all supported. Applications using this -module can be controlled via the pshell UDP/UNIX stand-alone 'C' client program -or via the PshellControl.h/libpshell-control or PshellControl.py +the libpshell-server linkable 'C' library, but implemented as a Python module. +It supports all the server types as the corresponding 'C' impelmentation, TCP, +UDP, UNIX and LOCAL server types are all supported. Applications using this +module can be controlled via the pshell UDP/UNIX stand-alone 'C' client program +or via the PshellControl.h/libpshell-control or PshellControl.py control mechanism. Functions: @@ -52,7 +52,7 @@ cleanupResources() -- release all resources claimed by the server runCommand() -- run a registered command from the parent (i.e. registering) program -The following commands can only be called from within the context of +The following commands can only be called from within the context of a pshell callback function printf() -- display a message from a pshell callback function to the client @@ -66,15 +66,15 @@ Integer constants: -These are the identifiers for the serverMode. BLOCKING wil never return -control to the caller of startServer, NON_BLOCKING will spawn a thread to +These are the identifiers for the serverMode. BLOCKING wil never return +control to the caller of startServer, NON_BLOCKING will spawn a thread to run the server and will return control to the caller of startServer BLOCKING NON_BLOCKING -String constants: - +String constants: + Valid server types, UDP/UNIX servers require the 'pshell' or 'pshell.py' client programs, TCP servers require a 'telnet' client, local servers require no client (all user interaction done directly with server running @@ -85,18 +85,18 @@ UNIX LOCAL -These three identifiers that can be used for the hostnameOrIpAddr argument +These three identifiers that can be used for the hostnameOrIpAddr argument of the startServer call. PshellServer.ANYHOST will bind the server socket to all interfaces of a multi-homed host, PshellServer.ANYBCAST will bind to -255.255.255.255, PshellServer.LOCALHOST will bind the server socket to -the local loopback address (i.e. 127.0.0.1), note that subnet broadcast +255.255.255.255, PshellServer.LOCALHOST will bind the server socket to +the local loopback address (i.e. 127.0.0.1), note that subnet broadcast it also supported, e.g. x.y.z.255 ANYHOST ANYBCAST LOCALHOST -A complete example of the usage of the API can be found in the included +A complete example of the usage of the API can be found in the included demo program pshellServerDemo.py. """ @@ -128,17 +128,17 @@ UNIX = "unix" LOCAL = "local" -# These are the identifiers for the serverMode. BLOCKING wil never return -# control to the caller of startServer, NON_BLOCKING will spawn a thread to +# These are the identifiers for the serverMode. BLOCKING wil never return +# control to the caller of startServer, NON_BLOCKING will spawn a thread to # run the server and will return control to the caller of startServer BLOCKING = 0 NON_BLOCKING = 1 -# These three identifiers that can be used for the hostnameOrIpAddr argument +# These three identifiers that can be used for the hostnameOrIpAddr argument # of the startServer call. PshellServer.ANYHOST will bind the server socket # to all interfaces of a multi-homed host, PSHELL_ANYBCAST will bind to -# 255.255.255.255, PshellServer.LOCALHOST will bind the server socket to -# the local loopback address (i.e. 127.0.0.1), note that subnet broadcast +# 255.255.255.255, PshellServer.LOCALHOST will bind the server socket to +# the local loopback address (i.e. 127.0.0.1), note that subnet broadcast # it also supported, e.g. x.y.z.255 ANYHOST = "anyhost" ANYBCAST = "anybcast" @@ -149,7 +149,7 @@ # "public" API functions # # Users of this module should only access functionality via these "public" -# methods. This is broken up into "public" and "private" sections for +# methods. This is broken up into "public" and "private" sections for # readability and to not expose the implementation in the API definition # ################################################################################# @@ -234,7 +234,7 @@ def runCommand(command): ################################################################################# # -# The following public functions should only be called from within a +# The following public functions should only be called from within a # registered callback function # ################################################################################# @@ -314,7 +314,7 @@ def showUsage(): ################################################################################# def isHelp(): """ - Check if the user has asked for help on this command. Command must be + Check if the user has asked for help on this command. Command must be registered with the showUsage = False option. Args: @@ -329,7 +329,7 @@ def isHelp(): ################################################################################# def isSubString(string1, string2, minMatchLength = 0): """ - This function will return True if string1 is a substring of string2 at + This function will return True if string1 is a substring of string2 at position 0. If the minMatchLength is 0, then it will compare up to the length of string1. If the minMatchLength > 0, it will require a minimum of that many characters to match. A string that is longer than the min @@ -355,7 +355,7 @@ def getOption(arg): This function will parse an argument string of the formats - where key is one letter only, i.e. '-t', or = where key can be any length word, i.e. 'timeout', and return a 3-tuple indicating if the arg was parsed - correctly, along with the associated key and corresponding value. An example + correctly, along with the associated key and corresponding value. An example of the two valid formats are -t10, timeout=10. Args: @@ -377,7 +377,7 @@ def getOption(arg): # API above # ################################################################################# - + ################################################################################# ################################################################################# def _isSubString(string1_, string2_, minMatchLength_): @@ -411,13 +411,13 @@ def _addCommand(function_, global _gMaxLength global _gServerType global _gPshellClient - - # see if we have a NULL command name + + # see if we have a NULL command name if ((command_ == None) or (len(command_) == 0)): print("PSHELL_ERROR: NULL command name, command not added") return - # see if we have a NULL description + # see if we have a NULL description if ((description_ == None) or (len(description_) == 0)): print("PSHELL_ERROR: NULL description, command: '%s' not added" % command_) return @@ -438,25 +438,25 @@ def _addCommand(function_, if ((minArgs_ > maxArgs_) and (maxArgs_ > 0)): print("PSHELL_ERROR: minArgs: %d is greater than maxArgs: %d, command: '%s' not added" % (minArgs_, maxArgs_, command_)) return - + # see if it is a duplicate command for command in _gCommandList: if (command["name"] == command_): # command name already exists, don't add it again print("PSHELL_ERROR: Command: %s already exists, not adding command" % command_) return - + # everything ok, good to add command - - # see if they gave the default for maxArgs, if so, set maxArgs to minArgs + + # see if they gave the default for maxArgs, if so, set maxArgs to minArgs if (maxArgs_ == 0): maxArgs = minArgs_ else: maxArgs = maxArgs_ - + if (len(command_) > _gMaxLength): _gMaxLength = len(command_) - + if (prepend_ == True): _gCommandList.insert(0, {"function":function_, "name":command_, @@ -490,7 +490,7 @@ def _startServer(serverName_, serverType_, serverMode_, hostnameOrIpAddr_, port_ _gHostnameOrIpAddr = hostnameOrIpAddr_ _gPort = port_ _loadConfigFile() - _loadStartupFile() + _loadStartupFile() _gRunning = True if (_gServerMode == BLOCKING): _runServer() @@ -502,7 +502,7 @@ def _startServer(serverName_, serverType_, serverMode_, hostnameOrIpAddr_, port_ ################################################################################# def _serverThread(): _runServer() - + ################################################################################# ################################################################################# def _createSocket(): @@ -566,7 +566,7 @@ def _runServer(): _runTCPServer() elif (_gServerType == UNIX): _runUNIXServer() - else: # local server + else: # local server _runLocalServer() ################################################################################# @@ -832,7 +832,7 @@ def _processCommand(command_): else: if (isHelp()): if (_gFoundCommand["showUsage"] == True): - showUsage() + showUsage() else: _gFoundCommand["function"](_gArgs) elif (not _isValidArgCount()): @@ -1058,7 +1058,7 @@ def _setFirstArgPos(position): _gFirstArgPos = 1 _gHelpLength = 1 _gHelpPos = 0 - + ################################################################################# ################################################################################# def _isHelp(): @@ -1075,7 +1075,7 @@ def _reply(): global _gSocketFd global _gPshellMsg global _gServerType - global _gPshellMsgHeaderFormat + global _gPshellMsgHeaderFormat # only issue a reply for a 'datagram' oriented remote server, TCP # uses a character stream and is not message based and LOCAL uses # no client app @@ -1103,7 +1103,7 @@ def _cleanupResources(): ################################################################################# ################################################################################# -def _loadConfigFile(): +def _loadConfigFile(): global _gServerName global _gServerType global _gHostnameOrIpAddr @@ -1146,9 +1146,9 @@ def _loadConfigFile(): elif ((option[1].lower() == "port") and (value[1].isdigit())): _gPort = int(value[1]) elif (option[1].lower() == "type"): - if ((value[1].lower() == UDP) or - (value[1].lower() == TCP) or - (value[1].lower() == UNIX) or + if ((value[1].lower() == UDP) or + (value[1].lower() == TCP) or + (value[1].lower() == UNIX) or (value[1].lower() == LOCAL)): _gServerType = value[1].lower() elif ((option[1].lower() == "timeout") and (value[1].isdigit())): @@ -1255,8 +1255,8 @@ def _flush(): _gPrompt = "PSHELL> " _gTitle = "PSHELL" _gBanner = "PSHELL: Process Specific Embedded Command Line Shell" -_gSocketFd = None -_gConnectFd = None +_gSocketFd = None +_gConnectFd = None _gFromAddr = None _gUnixSocketPath = "/tmp/" _gArgs = None @@ -1277,20 +1277,20 @@ def _flush(): # structure,that structure is the message passed between the pshell client and # server, these values must match their corresponding #define definitions in # the C file PshellCommon.h -_gMsgTypes = {"commandSuccess": 0, - "queryVersion":1, - "commandNotFound":1, - "queryPayloadSize":2, - "invalidArgCount":2, - "queryName":3, - "queryCommands1":4, - "queryCommands2":5, - "updatePayloadSize":6, - "userCommand":7, - "commandComplete":8, - "queryBanner":9, - "queryTitle":10, - "queryPrompt":11, +_gMsgTypes = {"commandSuccess": 0, + "queryVersion":1, + "commandNotFound":1, + "queryPayloadSize":2, + "invalidArgCount":2, + "queryName":3, + "queryCommands1":4, + "queryCommands2":5, + "updatePayloadSize":6, + "userCommand":7, + "commandComplete":8, + "queryBanner":9, + "queryTitle":10, + "queryPrompt":11, "controlCommand":12} # fields of PshellMsg, we use this definition to unpack the received PshellMsg @@ -1325,13 +1325,13 @@ def _flush(): _gWheelPos = 0 _gWheel = "|/-\\" -_gQuitTcp = False +_gQuitTcp = False _gTcpTimeout = 10 # minutes -_gTcpConnectSockName = None +_gTcpConnectSockName = None _gTcpPrompt = None _gTcpTitle = None # flag to indicate the special pshell.py client -_gPshellClient = False +_gPshellClient = False ############################## # diff --git a/python/src/PshellServer-stub.py b/python/src/PshellServer-stub.py index 676e3e4..133eed1 100755 --- a/python/src/PshellServer-stub.py +++ b/python/src/PshellServer-stub.py @@ -1,38 +1,38 @@ #!/usr/bin/python ################################################################################# -# -# Copyright (c) 2009, Ron Iovine, All rights reserved. -# -# Redistribution and use in source and binary forms, with or without +# +# Copyright (c) 2009, Ron Iovine, All rights reserved. +# +# Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: # * Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # * Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. -# * Neither the name of Ron Iovine nor the names of its contributors -# may be used to endorse or promote products derived from this software +# * Neither the name of Ron Iovine nor the names of its contributors +# may be used to endorse or promote products derived from this software # without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY Ron Iovine ''AS IS'' AND ANY EXPRESS OR -# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -# IN NO EVENT SHALL Ron Iovine BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -# BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER -# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -# POSSIBILITY OF SUCH DAMAGE. +# +# THIS SOFTWARE IS PROVIDED BY Ron Iovine ''AS IS'' AND ANY EXPRESS OR +# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +# IN NO EVENT SHALL Ron Iovine BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR +# BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. # ################################################################################# """ A Lightweight, Process-Specific, Embedded Command Line Shell -This is the STUB version of the PshellServer module, to use the actual version, -set the PshellServer.py softlink to PshellServer-full.py, or use the provided +This is the STUB version of the PshellServer module, to use the actual version, +set the PshellServer.py softlink to PshellServer-full.py, or use the provided utility shell script 'setPshellLib' to set the desired softlink and 'showPshellLib' to display the current softlink settings. """ @@ -55,17 +55,17 @@ UNIX = "unix" LOCAL = "local" -# These are the identifiers for the serverMode. BLOCKING wil never return -# control to the caller of startServer, NON_BLOCKING will spawn a thread to +# These are the identifiers for the serverMode. BLOCKING wil never return +# control to the caller of startServer, NON_BLOCKING will spawn a thread to # run the server and will return control to the caller of startServer BLOCKING = 0 NON_BLOCKING = 1 -# These three identifiers that can be used for the hostnameOrIpAddr argument +# These three identifiers that can be used for the hostnameOrIpAddr argument # of the startServer call. PshellServer.ANYHOST will bind the server socket # to all interfaces of a multi-homed host, PSHELL_ANYBCAST will bind to -# 255.255.255.255, PshellServer.LOCALHOST will bind the server socket to -# the local loopback address (i.e. 127.0.0.1), note that subnet broadcast +# 255.255.255.255, PshellServer.LOCALHOST will bind the server socket to +# the local loopback address (i.e. 127.0.0.1), note that subnet broadcast # it also supported, e.g. x.y.z.255 ANYHOST = "anyhost" ANYBCAST = "anybcast" @@ -178,7 +178,7 @@ def isSubString(string1, string2, minMatchLength = 0): Stub function, set PshellServer.py softlink to PshellServer-full.py for full functionality """ return (True) - + ############################## # # start of main program diff --git a/python/src/README b/python/src/README index 138b89d..0763d76 100644 --- a/python/src/README +++ b/python/src/README @@ -1,6 +1,6 @@ This directory contains Python versions of the PshellControl, PshellServer, -PshellClient (pshell.py), pshellAggregator, and PshellReadline functionality. -There are three demo Python programs in the 'python/demo' directory showing -their usage. None of these files are copied/setup on a system wide install. -On a local install, environment variables are setup to allow access to these +PshellClient (pshell.py), pshellAggregator, and PshellReadline functionality. +There are three demo Python programs in the 'python/demo' directory showing +their usage. None of these files are copied/setup on a system wide install. +On a local install, environment variables are setup to allow access to these files and modules. diff --git a/python/src/pshell.py b/python/src/pshell.py index d4c2c04..82f227f 100755 --- a/python/src/pshell.py +++ b/python/src/pshell.py @@ -1,47 +1,47 @@ #!/usr/bin/python ################################################################################# -# -# Copyright (c) 2009, Ron Iovine, All rights reserved. -# -# Redistribution and use in source and binary forms, with or without +# +# Copyright (c) 2009, Ron Iovine, All rights reserved. +# +# Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: # * Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # * Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. -# * Neither the name of Ron Iovine nor the names of its contributors -# may be used to endorse or promote products derived from this software +# * Neither the name of Ron Iovine nor the names of its contributors +# may be used to endorse or promote products derived from this software # without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY Ron Iovine ''AS IS'' AND ANY EXPRESS OR -# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -# IN NO EVENT SHALL Ron Iovine BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -# BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER -# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -# POSSIBILITY OF SUCH DAMAGE. +# +# THIS SOFTWARE IS PROVIDED BY Ron Iovine ''AS IS'' AND ANY EXPRESS OR +# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +# IN NO EVENT SHALL Ron Iovine BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR +# BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. # ################################################################################# """ A Python program to provide remote client access to UDP/UNIX PshellServers -This stand-alone client process will provide remote user interaction to -any process that is running a UDP or UNIX PshellServer (TCP PshellServers -are controlled via a standard 'telnet' client). It can control processes -that are running either the 'C' version of the PshellServer, which is -provided via the PshellServer.h API and the libpshell-server link libaray, +This stand-alone client process will provide remote user interaction to +any process that is running a UDP or UNIX PshellServer (TCP PshellServers +are controlled via a standard 'telnet' client). It can control processes +that are running either the 'C' version of the PshellServer, which is +provided via the PshellServer.h API and the libpshell-server link libaray, or the Python version that is provided via the PshellServer.py module. Modules: The following Python modules are provided for programs to embed their own -PshellServer functionality and to programatically control PshellServers +PshellServer functionality and to programatically control PshellServers running in other processes. PshellServer.py -- provide PshellServer capability in a given process @@ -72,7 +72,7 @@ def _showWelcome(): # show our welcome screen # put up our window title banner sys.stdout.write("\033]0;PSHELL: %s[%s], Mode: INTERACTIVE\007" % (_gServerName, _gRemoteServer)) - sys.stdout.flush() + sys.stdout.flush() banner = "# PSHELL: Process Specific Embedded Command Line Shell" server = "# Multi-session BROADCAST server: %s[%s]" % (_gServerName, _gRemoteServer) maxBorderWidth = max(58, len(banner), len(server))+2 @@ -153,7 +153,7 @@ def _getIpAddress(): return ("127.0.0.1") else: return (_gRemoteServer) - + ################################################################################# ################################################################################# def _processCommandLine(): @@ -187,7 +187,7 @@ def _processCommandLine(): time.sleep(_gRate) elif (_gRepeat == 0): break - + ################################################################################# ################################################################################# def _processBatchFile(): @@ -247,7 +247,7 @@ def _processBatchFile(): elif (_gRepeat == 0): break file.close() - + ################################################################################# ################################################################################# def _configureLocalServer(): @@ -259,7 +259,7 @@ def _configureLocalServer(): # need to set the first arg position to 0 so we can pass # through the exact command to our remote server for dispatching PshellServer._gFirstArgPos = 0 - # we tell the local server we are the special UDP/UNIX command + # we tell the local server we are the special UDP/UNIX command # line client so it can process commands correctly and display # the correct banner information PshellServer._gPshellClient = True @@ -272,15 +272,15 @@ def _configureLocalServer(): prompt = PshellControl._extractPrompt(_gSid) if (len(prompt) > 0): PshellServer._gPromptOverride = prompt - + title = PshellControl._extractTitle(_gSid) if (len(title) > 0): PshellServer._gTitleOverride = title - + serverName = PshellControl._extractName(_gSid) if (len(serverName) > 0): PshellServer._gServerNameOverride = serverName - + banner = PshellControl._extractBanner(_gSid) if (len(banner) > 0): PshellServer._gBannerOverride = banner @@ -445,19 +445,19 @@ def _registerSignalHandlers(): # ############################## if (__name__ == '__main__'): - - if ((len(sys.argv) < 2) or - ((len(sys.argv)) > 8) or + + if ((len(sys.argv) < 2) or + ((len(sys.argv)) > 8) or ((len(sys.argv) > 1) and (sys.argv[1] == "-h"))): _showUsage() # make sure we cleanup any system resorces on an abnormal termination _registerSignalHandlers() - + _gTimeout = 5 _gPort = PshellServer.UNIX - + _gRate = 0 _gRepeat = 0 _gIteration = 0 @@ -465,7 +465,7 @@ def _registerSignalHandlers(): _gFilename = None _gCommand = None _gInteractive = False - + _gDefaultInstallDir = "/etc/pshell" _gDefaultConfigDir = _gDefaultInstallDir+"/config" _gDefaultBatchDir = _gDefaultInstallDir+"/batch" @@ -528,7 +528,7 @@ def _registerSignalHandlers(): # needed filename but it was not fulfilled if needFile or needCommand: _showUsage() - + # see if we are requesting a server sitting on a subnet broadcast address, # if so, we configure for one-way, fire-and-forget messaging since there may # be many hosts/servers on our subnet which might all be listening on the @@ -547,12 +547,12 @@ def _registerSignalHandlers(): # command line mode, using batch file containing commands _processBatchFile() else: - + # interactive mode, setup local server and interact with user _gInteractive = True - + if (_gIsBroadcastAddr == False): - + # if not a broadcast server address, extract all the commands from # our unicast remote server and add them to our local server commandList = PshellControl.extractCommands(_gSid) @@ -574,7 +574,7 @@ def _registerSignalHandlers(): PshellServer.startServer("pshellServer", PshellServer.LOCAL, PshellServer.BLOCKING) else: print("PSHELL_ERROR: Could not connect to server: '%s:%s'" % (_gRemoteServer, _gPort)) - + else: _gServerName = "broadcastAddr" @@ -592,5 +592,5 @@ def _registerSignalHandlers(): _processCommand(command) _cleanupAndExit() - + diff --git a/python/src/pshellAggregator.py b/python/src/pshellAggregator.py index 66a67b6..3c2ee2c 100755 --- a/python/src/pshellAggregator.py +++ b/python/src/pshellAggregator.py @@ -1,30 +1,30 @@ #!/usr/bin/python ################################################################################# -# -# Copyright (c) 2009, Ron Iovine, All rights reserved. -# -# Redistribution and use in source and binary forms, with or without +# +# Copyright (c) 2009, Ron Iovine, All rights reserved. +# +# Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: # * Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # * Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. -# * Neither the name of Ron Iovine nor the names of its contributors -# may be used to endorse or promote products derived from this software +# * Neither the name of Ron Iovine nor the names of its contributors +# may be used to endorse or promote products derived from this software # without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY Ron Iovine ''AS IS'' AND ANY EXPRESS OR -# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -# IN NO EVENT SHALL Ron Iovine BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -# BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER -# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -# POSSIBILITY OF SUCH DAMAGE. +# +# THIS SOFTWARE IS PROVIDED BY Ron Iovine ''AS IS'' AND ANY EXPRESS OR +# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +# IN NO EVENT SHALL Ron Iovine BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR +# BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. # ################################################################################# @@ -35,19 +35,19 @@ into single local pshell server that serves as an interactive client to the remote servers. This can be useful in presenting a consolidated user shell who's functionality spans several discrete pshell servers. Since this uses -the PshellControl API, the external servers must all be either UDP or Unix +the PshellControl API, the external servers must all be either UDP or Unix servers. The consolidation point a local pshell server. This is a generic dynamic aggregator, i.e. it is server agnostic. Servers can be added to the aggregation via the 'add server' command either at startup via -the pshellAggregator.startup file or interactively via the interactive command +the pshellAggregator.startup file or interactively via the interactive command line. This program can also create multicast groups commands via the 'add multicast' command (also at startup or interactively). The multicast commands can then be distributed to multiple aggregated servers. -The aggregation and multicast functionality can be useful to manually drive a set +The aggregation and multicast functionality can be useful to manually drive a set of processes that use the pshell control mechanism as a control plane IPC. """ @@ -87,19 +87,19 @@ def _getServer(localName): if (PshellServer.isSubString(localName, server["localName"])): return (server) return (None) - + ################################################################################# ################################################################################# def _controlServer(argv): server = _getServer(argv[0]) if (server != None): # see if they asked for help - if ((len(argv) == 1) or - (argv[1] == "help") or - (argv[1] == "-h") or - (argv[1] == "-help") or - (argv[1] == "--h") or - (argv[1] == "--help") or + if ((len(argv) == 1) or + (argv[1] == "help") or + (argv[1] == "-h") or + (argv[1] == "-help") or + (argv[1] == "--h") or + (argv[1] == "--help") or (argv[1] == "?")): # user asked for help, display all the registered commands of the remote server PshellServer.printf(PshellControl.extractCommands(server["sid"]), newline=False) @@ -109,7 +109,7 @@ def _controlServer(argv): # good return, display results back to user if (retCode == PshellControl.COMMAND_SUCCESS): PshellServer.printf(results, newline=False) - + ################################################################################# ################################################################################# def _isDuplicate(localName_, remoteServer_, port_): @@ -154,16 +154,16 @@ def _add(argv): _gPshellServers.append({"localName":argv[2], "remoteServer":argv[3], "port":port, - "sid":PshellControl.connectServer(argv[2], - argv[3], - port, + "sid":PshellControl.connectServer(argv[2], + argv[3], + port, PshellControl.ONE_SEC*5)}) - PshellServer.addCommand(_controlServer, - argv[2], - "control the remote " + argv[2] + " process", - "[ | ? | -h]", - 0, - 30, + PshellServer.addCommand(_controlServer, + argv[2], + "control the remote " + argv[2] + " process", + "[ | ? | -h]", + 0, + 30, False) PshellServer._addTabCompletions() else: @@ -226,8 +226,8 @@ def _show(argv): for index, server in enumerate(multicast["servers"]): if (index > 0): PshellServer.printf("%s " % " ".ljust(_gMaxMulticastKeyword, " "), newline=False) - PshellServer.printf("%s %s %s" % (server["localName"].ljust(_gMaxLocalName), - server["remoteServer"].ljust(_gMaxRemoteName), + PshellServer.printf("%s %s %s" % (server["localName"].ljust(_gMaxLocalName), + server["remoteServer"].ljust(_gMaxRemoteName), server["port"])) PshellServer.printf() else: @@ -246,7 +246,7 @@ def _multicast(argv): else: # reconstitute the original command PshellControl.sendMulticast(' '.join(argv[1:])) - + ################################################################################# ################################################################################# def _cleanupAndExit(): @@ -307,7 +307,7 @@ def _registerSignalHandlers(): # through the exact command to our remote server for dispatching PshellServer._setFirstArgPos(0) - # we tell the local server we are the special UDP/UNIX command + # we tell the local server we are the special UDP/UNIX command # line client so it can process commands correctly and display # the correct banner information PshellServer._gPshellClient = True @@ -317,24 +317,24 @@ def _registerSignalHandlers(): PshellControl._gSupressInvalidArgCountMessage = True # register our callback commands - PshellServer.addCommand(_add, - "add", - "add a new remote server or multicast group entry", + PshellServer.addCommand(_add, + "add", + "add a new remote server or multicast group entry", "{server []} | {multicast [...]}", - 4, - 30, + 4, + 30, False) - - PshellServer.addCommand(_show, - "show", - "show aggregated servers or multicast group info", - "servers | multicast", - 2, - 2, + + PshellServer.addCommand(_show, + "show", + "show aggregated servers or multicast group info", + "servers | multicast", + 2, + 2, True) - - PshellServer.addCommand(_multicast, - "multicast", + + PshellServer.addCommand(_multicast, + "multicast", "send multicast command to registered server group", "", 2, @@ -343,9 +343,9 @@ def _registerSignalHandlers(): # start our local pshell server PshellServer.startServer("pshellAggregator", PshellServer.LOCAL, PshellServer.BLOCKING) - + # disconnect all our remote control servers PshellControl.disconnectAllServers() - + # cleanup our local server's resources PshellServer.cleanupResources() diff --git a/startup/pshellAggregator.startup b/startup/pshellAggregator.startup index 52953a7..97e3e78 100644 --- a/startup/pshellAggregator.startup +++ b/startup/pshellAggregator.startup @@ -1,28 +1,28 @@ ################################################################################# -# -# Copyright (c) 2009, Ron Iovine, All rights reserved. -# -# Redistribution and use in source and binary forms, with or without +# +# Copyright (c) 2009, Ron Iovine, All rights reserved. +# +# Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: # * Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # * Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. -# * Neither the name of Ron Iovine nor the names of its contributors -# may be used to endorse or promote products derived from this software +# * Neither the name of Ron Iovine nor the names of its contributors +# may be used to endorse or promote products derived from this software # without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY Ron Iovine ''AS IS'' AND ANY EXPRESS OR -# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -# IN NO EVENT SHALL Ron Iovine BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -# BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER -# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -# POSSIBILITY OF SUCH DAMAGE. +# +# THIS SOFTWARE IS PROVIDED BY Ron Iovine ''AS IS'' AND ANY EXPRESS OR +# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +# IN NO EVENT SHALL Ron Iovine BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR +# BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. # ################################################################################# diff --git a/startup/pshellServerDemo.startup b/startup/pshellServerDemo.startup index fceb80f..eba9e75 100644 --- a/startup/pshellServerDemo.startup +++ b/startup/pshellServerDemo.startup @@ -1,28 +1,28 @@ ################################################################################# -# -# Copyright (c) 2009, Ron Iovine, All rights reserved. -# -# Redistribution and use in source and binary forms, with or without +# +# Copyright (c) 2009, Ron Iovine, All rights reserved. +# +# Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: # * Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # * Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. -# * Neither the name of Ron Iovine nor the names of its contributors -# may be used to endorse or promote products derived from this software +# * Neither the name of Ron Iovine nor the names of its contributors +# may be used to endorse or promote products derived from this software # without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY Ron Iovine ''AS IS'' AND ANY EXPRESS OR -# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -# IN NO EVENT SHALL Ron Iovine BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -# BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER -# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -# POSSIBILITY OF SUCH DAMAGE. +# +# THIS SOFTWARE IS PROVIDED BY Ron Iovine ''AS IS'' AND ANY EXPRESS OR +# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +# IN NO EVENT SHALL Ron Iovine BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR +# BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. # ################################################################################# diff --git a/startup/traceFilterDemo.startup b/startup/traceFilterDemo.startup index b5ba66b..3c2b737 100644 --- a/startup/traceFilterDemo.startup +++ b/startup/traceFilterDemo.startup @@ -1,28 +1,28 @@ ################################################################################# -# -# Copyright (c) 2009, Ron Iovine, All rights reserved. -# -# Redistribution and use in source and binary forms, with or without +# +# Copyright (c) 2009, Ron Iovine, All rights reserved. +# +# Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: # * Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # * Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. -# * Neither the name of Ron Iovine nor the names of its contributors -# may be used to endorse or promote products derived from this software +# * Neither the name of Ron Iovine nor the names of its contributors +# may be used to endorse or promote products derived from this software # without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY Ron Iovine ''AS IS'' AND ANY EXPRESS OR -# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -# IN NO EVENT SHALL Ron Iovine BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -# BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER -# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -# POSSIBILITY OF SUCH DAMAGE. +# +# THIS SOFTWARE IS PROVIDED BY Ron Iovine ''AS IS'' AND ANY EXPRESS OR +# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +# IN NO EVENT SHALL Ron Iovine BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR +# BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. # ################################################################################# @@ -45,7 +45,7 @@ #trace file TraceFilter.c:135,156,300-400,190 trace global all #trace on -#trace function myFunction1 myFunction2 +#trace function myFunction1 myFunction2 #trace function myFunction3 myFunction2 foo #trace file TraceFilter.c:1,5,7 diff --git a/uninstall.sh b/uninstall.sh index 95fa3d2..7d12815 100755 --- a/uninstall.sh +++ b/uninstall.sh @@ -1,30 +1,30 @@ #!/bin/bash ################################################################################# -# -# Copyright (c) 2009, Ron Iovine, All rights reserved. -# -# Redistribution and use in source and binary forms, with or without +# +# Copyright (c) 2009, Ron Iovine, All rights reserved. +# +# Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: # * Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # * Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. -# * Neither the name of Ron Iovine nor the names of its contributors -# may be used to endorse or promote products derived from this software +# * Neither the name of Ron Iovine nor the names of its contributors +# may be used to endorse or promote products derived from this software # without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY Ron Iovine ''AS IS'' AND ANY EXPRESS OR -# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -# IN NO EVENT SHALL Ron Iovine BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -# BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER -# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -# POSSIBILITY OF SUCH DAMAGE. +# +# THIS SOFTWARE IS PROVIDED BY Ron Iovine ''AS IS'' AND ANY EXPRESS OR +# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +# IN NO EVENT SHALL Ron Iovine BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR +# BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. # ################################################################################# @@ -45,7 +45,7 @@ then echo " installed via a system wide install. This script must be run as 'root'." echo exit 1 - + else # system wide uninstall @@ -68,70 +68,70 @@ else startupDir="/etc/pshell/startup" man1Dir="/usr/share/man/man1" man3Dir="/usr/share/man/man3" - + if [ -d "/usr/lib64" ] then libDir="/usr/lib64" else libDir="/usr/lib" fi - + echo "Removing pshell files..." - + echo "Removing libs..." - + echo "Removing lib directory $libDir/pshell" rm -rf $libDir/pshell - + echo "Removing softlink $libDir/libpshell-server" rm -f $libDir/libpshell-server.so rm -f $libDir/libpshell-server.a - + echo "Removing softlink $libDir/libpshell-control" rm -f $libDir/libpshell-control.so rm -f $libDir/libpshell-control.a - + echo "Removing pshell$fileExt from $binDir" rm -f $binDir/pshell$fileExt - + echo "Removing pshellAggregator$fileExt from $binDir" rm -f $binDir/pshellAggregator$fileExt - + echo "Removing includes..." - + echo "Removing PshellServer.h from $includeDir" rm -f $includeDir/PshellServer.h - + echo "Removing PshellControl.h from $includeDir" rm -f $includeDir/PshellControl.h - + echo "Removing PshellReadline.h from $includeDir" rm -f $includeDir/PshellReadline.h echo "Removing TraceFilter.h from $includeDir" rm -f $includeDir/TraceFilter.h - + echo "Removing TraceLog.h from $includeDir" rm -f $includeDir/TraceLog.h - + echo "Removing pshell directory $pshellDir" rm -rf $pshellDir echo "Removing manpages..." - + echo "Removing pshell.1 from $man1Dir" rm -f $man1Dir/pshell.1.gz - + echo "Removing PshellControl.3 from $man3Dir" rm -f $man3Dir/PshellControl.3.gz - + echo "Removing PshellServer.3 from $man3Dir" rm -f $man3Dir/PshellServer.3.gz - + echo "Removing TraceFilter.3 from $man3Dir" rm -f $man3Dir/TraceFilter.3.gz - + echo "Removing TraceLog.3 from $man3Dir" rm -f $man3Dir/TraceLog.3.gz - + fi diff --git a/utils/archivePshell b/utils/archivePshell index d493ae7..5607758 100755 --- a/utils/archivePshell +++ b/utils/archivePshell @@ -1,34 +1,34 @@ #!/bin/bash ################################################################################# -# -# Copyright (c) 2009, Ron Iovine, All rights reserved. -# -# Redistribution and use in source and binary forms, with or without +# +# Copyright (c) 2009, Ron Iovine, All rights reserved. +# +# Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: # * Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # * Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. -# * Neither the name of Ron Iovine nor the names of its contributors -# may be used to endorse or promote products derived from this software +# * Neither the name of Ron Iovine nor the names of its contributors +# may be used to endorse or promote products derived from this software # without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY Ron Iovine ''AS IS'' AND ANY EXPRESS OR -# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -# IN NO EVENT SHALL Ron Iovine BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -# BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER -# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -# POSSIBILITY OF SUCH DAMAGE. +# +# THIS SOFTWARE IS PROVIDED BY Ron Iovine ''AS IS'' AND ANY EXPRESS OR +# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +# IN NO EVENT SHALL Ron Iovine BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR +# BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. # ################################################################################# -if [ $# -lt 1 -o $# -gt 2 ] +if [ $# -lt 1 -o $# -gt 2 ] then echo "Usage: archivePshell " exit 1 diff --git a/utils/logProfiler b/utils/logProfiler index 0c9ffb5..b964ca1 100755 --- a/utils/logProfiler +++ b/utils/logProfiler @@ -1,30 +1,30 @@ #!/usr/bin/python ################################################################################# -# -# Copyright (c) 2009, Ron Iovine, All rights reserved. -# -# Redistribution and use in source and binary forms, with or without +# +# Copyright (c) 2009, Ron Iovine, All rights reserved. +# +# Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: # * Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # * Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. -# * Neither the name of Ron Iovine nor the names of its contributors -# may be used to endorse or promote products derived from this software +# * Neither the name of Ron Iovine nor the names of its contributors +# may be used to endorse or promote products derived from this software # without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY Ron Iovine ''AS IS'' AND ANY EXPRESS OR -# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -# IN NO EVENT SHALL Ron Iovine BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -# BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER -# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -# POSSIBILITY OF SUCH DAMAGE. +# +# THIS SOFTWARE IS PROVIDED BY Ron Iovine ''AS IS'' AND ANY EXPRESS OR +# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +# IN NO EVENT SHALL Ron Iovine BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR +# BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. # ################################################################################# @@ -39,12 +39,12 @@ # This profiler understands logfile entries of the following formats: # # app | level | 14:40:32.377256 | file(function):line | user-message -# app | Sat Nov 23 04:02:35.005624 | file | line | function | level | user-message +# app | Sat Nov 23 04:02:35.005624 | file | line | function | level | user-message # 2014-08-17 23:11:00.114 level [app:file:line] user-message # 2017-10-12T09:26:04.31081 level hostname: app: function: file@line: user-message # 2017-10-16T10:38:11.419563 level 2017-10-16T10:38:11.418026 level hostname: app: function: file@line: user-message # -# Modify the functions 'parseLine' and 'findApp' to add additional log +# Modify the functions 'parseLine' and 'findApp' to add additional log # entry formats # ################################################################################ @@ -272,13 +272,13 @@ def findProfile(profiles, filename1, function1, line1, filename2, function2, lin # ###################################################################### def parseLine(line): - + # change this line parsing function for different log line formats, # we need to extract the file, function, line, and timestamp, an # example of the currently parsed log line formats are: # # app | level | 14:40:32.377256 | file(function):line | user-message - # app | Sat Nov 23 04:02:35.005624 | file | line | function | level | user-message + # app | Sat Nov 23 04:02:35.005624 | file | line | function | level | user-message # 2017-10-12T09:26:04.31081 level hostname: app: function: file@line: user-message # 2014-08-17 23:11:00.114 level [app:file:line] user-message # 2017-10-16T10:38:11.419563 level 2017-10-16T10:38:11.418026 level hostname: app: function: file@line: user-message @@ -298,7 +298,7 @@ def parseLine(line): line = location[1][:-1] function = tokens[functionTokenPos].strip().split(":")[0] return (filename, "("+function+")", ":"+line, timestamp) - + # parse format: 2017-10-12T09:26:04.31081 level hostname: app: function: file@line: user-message expectedNumTokens = 6 timestampTokenPos = 0 @@ -314,7 +314,7 @@ def parseLine(line): function = tokens[functionTokenPos].strip().split(":")[0] return (filename, "("+function+")", ":"+line, timestamp) - # parse format: app | Sat Nov 23 04:02:35.005624 | file | line | function | level | user-message + # parse format: app | Sat Nov 23 04:02:35.005624 | file | line | function | level | user-message expectedNumTokens = 6 timestampTokenPos = 1 filenameTokenPos = 2 @@ -328,7 +328,7 @@ def parseLine(line): line = tokens[lineTokenPos].strip() function = tokens[functionTokenPos].strip() return (filename, "("+function+")", ":"+line, timestamp) - + # parse format: app | level | 14:40:32.377256 | file(function):line | user-message expectedNumTokens = 5 timestampTokenPos = 2 @@ -344,7 +344,7 @@ def parseLine(line): function = tokens[functionTokenPos].strip().split("(")[-1] function = function.split(")")[0] return (filename, "("+function+")", ":"+line, timestamp) - + # parse format: 2014-08-17 23:11:00.114 level [app:file:line] user-message expectedNumTokens = 4 timestampTokenPos = 1 @@ -358,10 +358,10 @@ def parseLine(line): line = location[2][:-1] # this format does not have a function, so we just return "" return (filename, "", ":"+line, timestamp) - + # dropped through, return nothing return (None, None, None, None) - + ###################################################################### # # return true if line matches app filter @@ -369,13 +369,13 @@ def parseLine(line): ###################################################################### def findApp(line, appFilter): global gNoFilter - + # change this line parsing function for different log line formats, # we need to extract the file, function, line, and timestamp, an # example of the currently parsed log line formats are: # # app | level | 14:40:32.377256 | file(function):line | user-message - # app | Sat Nov 23 04:02:35.005624 | file | line | function | level | user-message + # app | Sat Nov 23 04:02:35.005624 | file | line | function | level | user-message # 2017-10-12T09:26:04.31081 level hostname: app: function: file@line: user-message # 2014-08-17 23:11:00.114 level [app:file:line] user-message # 2017-10-16T10:38:11.419563 level 2017-10-16T10:38:11.418026 level hostname: app: function: file@line: user-message @@ -391,7 +391,7 @@ def findApp(line, appFilter): app = tokens[appTokenPos].strip().split(":")[0] if (app == appFilter): return (True) - + # parse format: 2017-10-12T09:26:04.31081 level hostname: app: function: file@line: user-message expectedNumTokens = 6 appTokenPos = 3 @@ -401,7 +401,7 @@ def findApp(line, appFilter): if (app == appFilter): return (True) - # parse format: app | Sat Nov 23 04:02:35.005624 | file | line | function | level | user-message + # parse format: app | Sat Nov 23 04:02:35.005624 | file | line | function | level | user-message expectedNumTokens = 6 appTokenPos = 0 tokens = line.split("|") @@ -409,7 +409,7 @@ def findApp(line, appFilter): app = tokens[appTokenPos].strip() if (app == appFilter): return (True) - + # parse format: app | level | 14:40:32.377256 | file(function):line | user-message expectedNumTokens = 5 appTokenPos = 0 @@ -418,7 +418,7 @@ def findApp(line, appFilter): app = tokens[appTokenPos].strip() if (app == appFilter): return (True) - + # parse format: 2014-08-17 23:11:00.114 level [app:file:line] user-message expectedNumTokens = 4 locationTokenPos = 3 @@ -428,10 +428,10 @@ def findApp(line, appFilter): app = location[0][1:] if (app == appFilter): return (True) - + # dropped through, return nothing return (False) - + else: return (True) @@ -441,16 +441,16 @@ def findApp(line, appFilter): # ###################################################### def updateProfile(profiles, prevLine, currLine): - + global gTotalProfiledTime global gMaxAreaWidth1 global gMaxAreaWidth2 - + (filename1, function1, line1, timestamp1) = parseLine(prevLine) (filename2, function2, line2, timestamp2) = parseLine(currLine) - + if ((filename1 != None) and (filename2 != None)): - + # both lines are good, now either update an existing area profile, or create a new one currTime = datetime.datetime.strptime(timestamp2, gTimestampFormat) prevTime = datetime.datetime.strptime(timestamp1, gTimestampFormat) @@ -516,7 +516,7 @@ def createProfile(logfile): appFilter = gNoFilter if (os.path.isfile(logfile)): # create a new profile for this logfile - profile = {"logfile":logfile1, + profile = {"logfile":logfile1, "appFilter":appFilter, "contents":open(logfile, 'r').readlines(), "totTime":datetime.timedelta(0), @@ -626,10 +626,10 @@ def showProfile(profiles, outfile, option, count, fileFilter, functionFilter): global gClearStatusUpdate global gDiffRequested - + global gAreaLabel1 global gAreaLabel2 - + global gMinAreaWidth1 global gMinAreaWidth2 @@ -868,8 +868,8 @@ def diffProfiles(profiles1, profiles2): gCountWidthAdjust = 5 gProfilesDiff = {"logfile":"Diff: %s->%s" % (profiles1["logfile"], profiles2["logfile"]), "profile":[]} for profile1 in profiles1["profile"]: - profile2 = findProfile(profiles2["profile"], - profile1["file1"], profile1["function1"], profile1["line1"], + profile2 = findProfile(profiles2["profile"], + profile1["file1"], profile1["function1"], profile1["line1"], profile1["file2"], profile1["function2"], profile1["line2"]) if (profile2 != None): gProfilesDiff["profile"].append({"file1":profile1["file1"], @@ -926,11 +926,11 @@ def createDelta(profile, maxTimeDelta): global gKeepAliveType global gProfilesDelta - gProfilesDelta = {"logfile":profile["logfile"], + gProfilesDelta = {"logfile":profile["logfile"], "appFilter":profile["appFilter"], - "maxTimeDelta":maxTimeDelta, - "maxTimeDeltaDiff":0.0, - "minTimeDeltaDiff":sys.float_info.max, + "maxTimeDelta":maxTimeDelta, + "maxTimeDeltaDiff":0.0, + "minTimeDeltaDiff":sys.float_info.max, "delta":[]} sys.stdout.write("\n") sys.stdout.write("Creating time delta profile from logfile: %s, please wait...processing line: " % profile["logfile"]) @@ -1092,7 +1092,7 @@ def showCommands(): print(" for a 'diff' based profile, exactly two profile IDs must be given, for a") print(" time 'delta' based analysis, only one profile ID should be provided.") print("") - + ########################################################## # # get interactive user input and perform desired action @@ -1194,7 +1194,7 @@ def getInput(): # process command line selections # if not idList populated, default to 0 if (len(idList) == 0): - idList = [0] + idList = [0] if (deltaRequested): if (len(idList) == 1): createDelta(gProfiles[idList[0]], float(maxTimeDelta)) @@ -1224,7 +1224,7 @@ if (__name__ == '__main__'): else: # read in all our logfiles & create profiles sys.stdout.write("\033]0;logProfiler\007") - sys.stdout.flush() + sys.stdout.flush() gProfiles = [] for arg in sys.argv[1:]: logfile = arg diff --git a/utils/pshell.exp b/utils/pshell.exp index db841eb..aa38dac 100755 --- a/utils/pshell.exp +++ b/utils/pshell.exp @@ -1,30 +1,30 @@ #!/usr/bin/expect ################################################################################# -# -# Copyright (c) 2009, Ron Iovine, All rights reserved. -# -# Redistribution and use in source and binary forms, with or without +# +# Copyright (c) 2009, Ron Iovine, All rights reserved. +# +# Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: # * Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # * Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. -# * Neither the name of Ron Iovine nor the names of its contributors -# may be used to endorse or promote products derived from this software +# * Neither the name of Ron Iovine nor the names of its contributors +# may be used to endorse or promote products derived from this software # without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY Ron Iovine ''AS IS'' AND ANY EXPRESS OR -# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -# IN NO EVENT SHALL Ron Iovine BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -# BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER -# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -# POSSIBILITY OF SUCH DAMAGE. +# +# THIS SOFTWARE IS PROVIDED BY Ron Iovine ''AS IS'' AND ANY EXPRESS OR +# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +# IN NO EVENT SHALL Ron Iovine BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR +# BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. # ################################################################################# @@ -196,7 +196,7 @@ if {[llength $argv] == 1} { } else { showUsage } -} +} # dropped through to here, try to connect to the specified server set hostOrIpAddr [lindex $argv 0] @@ -293,11 +293,11 @@ expect { "Unknown host" { exit } "Connection timed out" { exit } "bad port" { exit } - timeout { - puts "telnet: connect to address $hostOrIpAddr: Connection timed out" - exit + timeout { + puts "telnet: connect to address $hostOrIpAddr: Connection timed out" + exit } - $prompt + $prompt } # get our actual server name & ip address based on the prompt @@ -308,7 +308,7 @@ set serverName [lindex [split $serverName "\r"] 1] set ipAddress [lindex [split $serverNameAndIpAddress "\]"] 0] set ipAddress [lindex [split $ipAddress "\["] 1] -# process our request +# process our request if {$command != ""} { if {$rate > 0 || $repeat > 0} { set keyword $command @@ -385,13 +385,13 @@ if {$command != ""} { while {[gets $file command] != -1} { if {[string index $command 0] != "#" && [string length $command] > 0} { send "$command\r" - expect $prompt + expect $prompt } } if {$iteration == $repeat} { break } - sleep $rate + sleep $rate } send "quit\r" puts "" @@ -402,7 +402,7 @@ if {$command != ""} { while {[gets $file command] != -1} { if {[string index $command 0] != "#" && [string length $command] > 0} { send "$command\r" - expect $prompt + expect $prompt } } send "quit\r" diff --git a/utils/setPshellLib b/utils/setPshellLib index c59e191..3d4b74b 100755 --- a/utils/setPshellLib +++ b/utils/setPshellLib @@ -1,34 +1,34 @@ #!/bin/bash ################################################################################ -# -# Copyright (c) 2009, Ron Iovine, All rights reserved. -# -# Redistribution and use in source and binary forms, with or without +# +# Copyright (c) 2009, Ron Iovine, All rights reserved. +# +# Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: # * Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # * Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. -# * Neither the name of Ron Iovine nor the names of its contributors -# may be used to endorse or promote products derived from this software +# * Neither the name of Ron Iovine nor the names of its contributors +# may be used to endorse or promote products derived from this software # without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY Ron Iovine ''AS IS'' AND ANY EXPRESS OR -# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -# IN NO EVENT SHALL Ron Iovine BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -# BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER -# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -# POSSIBILITY OF SUCH DAMAGE. +# +# THIS SOFTWARE IS PROVIDED BY Ron Iovine ''AS IS'' AND ANY EXPRESS OR +# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +# IN NO EVENT SHALL Ron Iovine BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR +# BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. # ################################################################################# -if [ $# -ne 1 ] +if [ $# -ne 1 ] then echo "Usage: setPshellLib -stub | -full" exit 1 @@ -60,7 +60,7 @@ then mkdir $GO_SRC fi -if [ "$1" == "-stub" ] +if [ "$1" == "-stub" ] then # C/C++ libraries, shared and static @@ -73,44 +73,44 @@ then else echo "Setting softlink libpshell-server to libpshell-server-stub" rm -f $LIB_DIR/libpshell-server.so - ln -s $LIB_DIR/libpshell-server-stub.so $LIB_DIR/libpshell-server.so + ln -s $LIB_DIR/libpshell-server-stub.so $LIB_DIR/libpshell-server.so rm -f $LIB_DIR/libpshell-server.a ln -s $LIB_DIR/libpshell-server-stub.a $LIB_DIR/libpshell-server.a fi - + # Python modules if [ ! -e "$PYTHON_DIR/PshellServer-stub.py" ] then echo "ERROR: Could not find module: '$PYTHON_DIR/PshellServer-stub.py'" else - echo "Setting softlink PshellServer.py PshellServer-stub.py" + echo "Setting softlink PshellServer.py PshellServer-stub.py" rm -f $PYTHON_DIR/PshellServer.py - ln -s $PYTHON_DIR/PshellServer-stub.py $PYTHON_DIR/PshellServer.py + ln -s $PYTHON_DIR/PshellServer-stub.py $PYTHON_DIR/PshellServer.py fi - + # Go source module if [ ! -e "$GO_SRC_STUB/PshellServer-stub.go" ] then echo "ERROR: Could not find module: '$GO_SRC_STUB/PshellServer-stub.go'" else - echo "Setting softlink PshellServer.go PshellServer-stub.go" + echo "Setting softlink PshellServer.go PshellServer-stub.go" rm -f $GO_SRC/PshellServer.go ln -s $GO_SRC_STUB/PshellServer-stub.go $GO_SRC/PshellServer.go fi - + # Go library module, static only if [ ! -e "$GO_PKG/PshellServer-stub.a" ] then echo "ERROR: Could not find module: '$GO_PKG/PshellServer-stub.a'" else - echo "Setting softlink PshellServer.a PshellServer-stub.a" + echo "Setting softlink PshellServer.a PshellServer-stub.a" rm -f $GO_PKG/PshellServer.a ln -s $GO_PKG/PshellServer-stub.a $GO_PKG/PshellServer.a # need to do this to force a re-link when building the demo app touch $GO_PKG/PshellServer.a fi - -elif [ "$1" == "-full" ] + +elif [ "$1" == "-full" ] then # C/C++ libraries, shared and static @@ -123,43 +123,43 @@ then else echo "Setting softlink libpshell-server to libpshell-server-full" rm -f $LIB_DIR/libpshell-server.so - ln -s $LIB_DIR/libpshell-server-full.so $LIB_DIR/libpshell-server.so + ln -s $LIB_DIR/libpshell-server-full.so $LIB_DIR/libpshell-server.so rm -f $LIB_DIR/libpshell-server.a ln -s $LIB_DIR/libpshell-server-full.a $LIB_DIR/libpshell-server.a fi - + # Python modules if [ ! -e "$PYTHON_DIR/PshellServer-full.py" ] then echo "ERROR: Could not find module: '$PYTHON_DIR/PshellServer-full.py'" else - echo "Setting softlink PshellServer.py PshellServer-full.py" + echo "Setting softlink PshellServer.py PshellServer-full.py" rm -f $PYTHON_DIR/PshellServer.py - ln -s $PYTHON_DIR/PshellServer-full.py $PYTHON_DIR/PshellServer.py + ln -s $PYTHON_DIR/PshellServer-full.py $PYTHON_DIR/PshellServer.py fi - + # Go source module if [ ! -e "$GO_SRC_FULL/PshellServer-full.go" ] then echo "ERROR: Could not find module: '$GO_SRC_FULL/PshellServer-full.go'" else - echo "Setting softlink PshellServer.go PshellServer-full.go" + echo "Setting softlink PshellServer.go PshellServer-full.go" rm -f $GO_SRC/PshellServer.go ln -s $GO_SRC_FULL/PshellServer-full.go $GO_SRC/PshellServer.go fi - + # Go library module, static only if [ ! -e "$GO_PKG/PshellServer-full.a" ] then echo "ERROR: Could not find module: '$GO_PKG/PshellServer-full.a'" else - echo "Setting softlink PshellServer.a PshellServer-full.a" + echo "Setting softlink PshellServer.a PshellServer-full.a" rm -f $GO_PKG/PshellServer.a ln -s $GO_PKG/PshellServer-full.a $GO_PKG/PshellServer.a # need to do this to force a re-link when building the demo app touch $GO_PKG/PshellServer.a fi - + else echo "Usage: setPshellLib -stub | -full" fi diff --git a/utils/showPshellLib b/utils/showPshellLib index ed5f300..338d926 100755 --- a/utils/showPshellLib +++ b/utils/showPshellLib @@ -1,34 +1,34 @@ #!/bin/bash ################################################################################# -# -# Copyright (c) 2009, Ron Iovine, All rights reserved. -# -# Redistribution and use in source and binary forms, with or without +# +# Copyright (c) 2009, Ron Iovine, All rights reserved. +# +# Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: # * Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # * Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. -# * Neither the name of Ron Iovine nor the names of its contributors -# may be used to endorse or promote products derived from this software +# * Neither the name of Ron Iovine nor the names of its contributors +# may be used to endorse or promote products derived from this software # without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY Ron Iovine ''AS IS'' AND ANY EXPRESS OR -# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -# IN NO EVENT SHALL Ron Iovine BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -# BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER -# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -# POSSIBILITY OF SUCH DAMAGE. +# +# THIS SOFTWARE IS PROVIDED BY Ron Iovine ''AS IS'' AND ANY EXPRESS OR +# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +# IN NO EVENT SHALL Ron Iovine BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR +# BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. # ################################################################################# -if [ $# -ne 0 ] +if [ $# -ne 0 ] then echo "Usage: showPshellLib" exit 1