Learn From RSS Samples Step By Step

By Liu Rui

Nov. 2003

I have put some simple but interesting sample applications developed with RSSI. These samples may guide you to learn RSS and RSSI step by step. All of these sample applications are very simple. Most of them have less than 200 lines of code. Before testing these samples, make sure to unzip RSS package to a directory. For example, put RSS files into "/usr/rss-v2.0" on UNIX/LINUX, or "c:\rss-v2.0" on Windows. Although RSS can run on all brands of UNIX, Only libraries on LINUX and Windows are  provided within current package.

If you want to test RSS in Linux, make sure to add the "lib" directory of RSS into environment variables such as "CLASSPATH" and "LD_LIBRARY_PATH". For example, if you put RSS into "/usr/rss-v2.0" directory, use following command to set environment variables:

CLASSPATH=.:/usr/rss-v2.0/lib
export CLASSPATH
LD_LIBRARY_PATH=/usr/lib:/usr/rss-v2.0/lib
export LD_LIBRARY_PATH
If you want to test RSS in Windows, make sure to add the "lib" directory of RSS into environment variables such as "CLASSPATH" and "PATH". For example, if you put RSS into "/usr/rss-v2.0" directory, use following command to set environment variables:
set Path=c:\rss-v2.0\lib;%PATH%
set CLASSPATH=.;c:\rss-v2.0\lib;%CLASSPATH%
set include=c:\rss-v2.0\include;%include%
set lib=c:\rss-v2.0\lib;%lib%
A sample application named "Xmler" needs jar file "xerces.jar" to be in the "CLASSPATH".

There are 4 samples in the current RSS version 1.1 package. Following is the information:
 
Name Description Language Platform
Simple Command Shell To build a simple command shell Server: C;      Client: C Linux/Windows
Registry To read/write information from/into different registries. Server: C;      Client: C, Java, VB Linux/Windows
Weeb A simple Web server Server: Java;  Client: Java, C, VB Linux/Windows
Waiter A sample can start MS Office applications Server: VB;    Client: VB, C, Java Windows
XMLer To manipulate XML document Server Java;   Client: Java, C, VB Linux/Windows

 

Simple Command Shell

The RSSI sample program "cmdshell" can build a simple command shell, which can parse commands and manipulate RSS. I have test the code in Windows, Linux, Solaris, HP-UX and AIX machines. From this sample you can learn:


Use following commands to build the server implementation:
For Windows:

nmake -f cmdshell.win.mk
For Linux:
make -f cmdshell.linux.mk
Use following commands to build the client program:
For Windows:
nmake -f test.win.mk
For Linux:
make -f test.linux.mk
Run the client program "test", use command "?" or "help" to see the help text, use "exit" or "quit" to exit the program. Following is the scenario:
[root@vmln cmdshell]# ./test
====================================================================
Simple Command Shell Test Program
====================================================================
 => ?
exit,quit - exit the command shell
help,? - provide help information
prompt <prompt string>
Command RtCode = <10002>
 => exit
Command RtCode = <10001>
You can use "prompt" command  to change the "prompt string" of the command shell. Following is the scenario:
 => prompt $
Command RtCode = <10003>
$prompt " # "
Command RtCode = <10003>
 #
You can test the command shell to parse commands. Following is the scenario:
 # aaa bb cc d
You have input a command with 3 argument(s)
Command = aaa
Argument No.1 = bb
Argument No.2 = cc
Argument No.3 = d

 # aaa bb "cc d"
You have input a command with 2 argument(s)
Command = aaa
Argument No.1 = bb
Argument No.2 = cc d
Let's see the Interface Definition Manual named "manual.txt". We can find 5 Actions defined in the file. Each Action has its own keys. If an input key is marked with "<Required>", it must be provided for the Action. If an input key is marked with "<Optional>", it is an optional key. Action "Print" and "ParseCommand" are static Actions which means that they can be taken at any time.

The server source file is "cmdshell.c". Its RSSI entry point is function "CmdShellRssi". This function is short but powerful. It can process 5 Actions requested by the client side. You can consult "manual.txt" file to know what the function will do. What I should explain is that I allocate a RSSI Handle in the Action "Activate". RSSI Handle can hold data for use at any time when in the lifecycle of the interface.

The client source file is "test.c". It invocates Actions defined in RSSI.
 

Registry

The RSSI sample program "registry" is a friendly user interface to build a Registry application. The meaning of Registry is an initialization file or Windows Registry. I have test the code in Windows, Linux, Solaris, HP-UX and AIX machines. From this sample you can learn: Use following commands to build the server implementation:
For Windows:
nmake -f registry.win.mk
For Linux:
make -f registry.linux.mk
Use following commands to build the client program:
For Windows:
nmake -f test.win.mk
For Linux:
make -f test.linux.mk
Run the client program "test", you can find the following scenario:
[root@vmln registry]# ./test
---Write Registry File---

---Read Registry File---
The phone number got from registry file is: 123-456-7890
You can find a new created registry file named "myreg.ini" as following:
[Profile]
Name=Liu Rui
Title=Mr.
Phone=123-456-7890
[Products]
Software=Regular Statement String (RSS)
The application has created a new "myreg.ini" and read one item from that registry file.

Let's see the Interface Definition Manual named "manual.txt". We can find 5 Actions defined in the file. Each Action has its own keys. If an input key is marked with "<Required>", it must be provided for the Action. If an input key is marked with "<Optional>", it is an optional key.

The server source file is "registry.c". Its RSSI entry point is function "RegistryRssi". This function is short but powerful. It can process 5 Actions requested by the client side. You can consult "manual.txt" file to know what the function will do. What I should explain is that I allocate a RSSI Handle in the Action "Activate". RSSI Handle can hold data for use at any time when in the lifecycle of the interface.

The client source file is "test.c". It invocates Actions defined in RSSI.

You can also use Java or Visual Basic to invocate the interface easily. Before use this client, make sure you have set correct environment variables (CLASSPATH, LD_LIBRARY_PATH, PATH). You can use following command to run Java client. The Java client program need one command line argument to specify where to find the server library, you can find the following scenario:

on Linux:

# java Test ./libregistry.so
---Write Registry File---

---Read Registry File---
The phone number got from registry file is: 123-456-7890
on Windows:
# java Test registry.dll
---Write Registry File---

---Read Registry File---
The phone number got from registry file is: 123-456-7890
There's also a VBScript client script file in the "dll" subdirectory. Before use this client, make sure you have registered the RSS COM server ("regsvr32 rsscom.dll"). Double click the VBScript file ("test.vbs"), you can get a Message Window showing the CLSID of the COM server as following:

 


Weeb

Weeb is a small Web server built with Java. It can run on any platforms supporting Java and RSS. The source code is in the directory "sample/http". From this sample you can learn: Make sure you have set correct environment variables (CLASSPATH, LD_LIBRARY_PATH, PATH). Use following commands to build the server implementation:

For Windows:

javac weeb\*.java
For Unix/Linux:
javac weeb/*.java
Use following commands to build the client (The client is used to control Weeb, and can be called back from the server.):
javac Test.java
Use following command to start Weeb (The command argument specifies where to locate the root of the Web document.):
java Test .
From a Web browser, you can visit Weeb with correct IP address and default port number (80). Proxy server is not supported.

Let's see the Interface Definition Manual named "manual.txt". We can find 54 Actions defined in the file. Each Action has its own keys. If an input key is marked with "<Required>", it must be provided for the Action. If an input key is marked with "<Optional>", it is an optional key.

The major server source file is "Weeb.java". Its RSSI entry point is function "WeebRssi". This function is short but powerful. It can process 4 Actions requested by the client side. You can consult "manual.txt" file to know what the function will do. What I should explain is that I allocate a RSSI Handle in the Action "Activate". RSSI Handle can hold data for use at any time when in the lifecycle of the interface. The client source file is "Test.java". It invocates Actions defined in RSSI.

There are also C and VB client source files inside the directory. Use the following commands to compile and run C client:
For Windows:

nmake -f test.win.mk
test
For Linux:
nmake -f test.linux.mk
./test
I have test the program in many platforms. I found there may be some issue in old version Linux because the thread support of Linux is limited.
You can also run a Visual Basic Script client in the comand window. It shows a message box when it launches the Web server. Use the following commands to run the VB client on Windows:
test.vbs
 

Waiter

Waiter is an unusual program. The server program is written by Visual Basic. It can control Microsoft Office tools. From this sample you can learn: Make sure you have set correct environment variables (CLASSPATH, PATH) and registered the RSS COM server ("regsvr32 rsscom.dll"). Use Visual Basic and project file "Waiter.vbp" to build the server implementation.

Use Visual Basic project file "test.vbp", you can build client written with Visual Basic.

Use following commands to build the client written with C:

nmake -f test.win.mk
Use following commands to build the client written with Java
javac Test.java
All of these clients prompt a task list. You can choose one task to invocate the service.
 

XMLer

XMLer is a semifinished project. Now only the java implementation based on xerces is available. With XMLer we can use a specific format string to directly locate the node or attribute in a XML file. From this sample you can learn: Make sure you have set correct environment variables (CLASSPATH, LD_LIBRARY_PATH, PATH). Use following commands to build the server implementation:

For Windows:

javac xmlerj\*.java
For Unix/Linux:
javac xmlerj/*.java
Use following commands to build the client (The client is used to control Weeb, and can be called back from the server.):
javac Test.java
Use following command to start Weeb, the XML file to be parsed is named "gjobs.xml" inside the directory:
java Test
There are also C and VB client source files inside the directory. Use the following commands to compile and run C client:
For Windows:
nmake -f test.win.mk
test
For Linux:
nmake -f test.linux.mk
./test
I have test the program in many platforms. I found there may be some issue in old version Linux because the thread support of Linux is limited.

You can also run a Visual Basic Script client in the comand window. Use the following commands to run the VB client on Windows:

test.vbs