Skip to content

Commit

Permalink
Make whitespace consistent for all files
Browse files Browse the repository at this point in the history
  • Loading branch information
RonIovine committed Mar 21, 2019
1 parent 22ada15 commit f449d1d
Show file tree
Hide file tree
Showing 64 changed files with 1,514 additions and 1,514 deletions.
34 changes: 17 additions & 17 deletions Makefile
Expand Up @@ -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 =
Expand Down Expand Up @@ -311,30 +311,30 @@ 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
$(VERBOSE)$(CC) $(INCLUDE) $(TF_FLAGS) $(SHARED_OBJ) $(SRC_DIR)/TraceFilter.$(SRC_EXT) -o TraceFilter.o
$(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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down
82 changes: 41 additions & 41 deletions README
Expand Up @@ -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
Expand All @@ -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'
Expand All @@ -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:
Expand All @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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),
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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<timeout>] {<hostName> | <ipAddress> | unix}
{<serverName> | <portNum>} [-h | ? | {<command> [<rate> [clear]]} |
Usage: pshell -h | ? | -s | [-t<timeout>] {<hostName> | <ipAddress> | unix}
{<serverName> | <portNum>} [-h | ? | {<command> [<rate> [clear]]} |
{-f <fileName> [<rate> [clear]]}]

where:
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down

0 comments on commit f449d1d

Please sign in to comment.