|
|
|
|
This chapter describes the SNAP-IX sample LUA program /opt/sna/samples/lsample.c , written for the Solaris operating system, which illustrates the use of LUA verbs.
The following information is provided:
Processing overview of the application
Instructions for compiling, linking, and running the application
The application is a very simple 3270 emulation program. It provides an unformatted display of screen data sent from the host (on both the LU and SSCP sessions), together with status messages (indicating whether the application is connected to the LU session or the SSCP session). When a definite-response request is received from the host, a positive response is sent automatically. Data typed in by the user is sent to the host, with the exception of two special keystrokes:
Toggles between the LU and SSCP sessions
Terminates the application
Once it has completed some initialization processing, the program essentially consists of two main loops: one reading data from the host and one sending data supplied by the user to the host. These are implemented as follows:
The read loop uses recursive calls to the RUI_READ verb. The following processing is performed by the callback routine, which LUA calls when the verb completes asynchronously:
Any screen data is written to the screen
Any session status information is processed
If a response is required, a positive response is built and sent
The RUI_READ verb is then re-issued to continue the loop
If the verb completes synchronously, the same routine used as a callback routine is called explicitly on return. This ensures that the same processing is done whatever the type of return.
The write loop reads data from the keyboard. If either of the two special keystrokes is supplied, it is acted on; otherwise, the incoming data is translated to extended binary coded decimal interchange code (EBCDIC) (using the CSV CONVERT verb) to be sent to the host on either the LU session or the SSCP session, depending on which the application is currently connected to. The data is sent using the RUI_WRITE verb; again, the callback routine is used whether or not the verb returns asynchronously. The program waits for a semaphore to be cleared by the callback routine before continuing with the loop.
When the user types the ] keystroke to terminate the application, the program breaks out of the write loop and issues the RUI_TERM verb to end the session. The session is also terminated if the read loop encounters a non-LUA_OK return code from the RUI_READ verb.
The program flow can be represented by the diagram shown in Program Flow for the Sample LUA Application:
|
|
|
|
|