HP-UX SNAplus2 R7 APPC Programmer's Guide
Sample Transaction Programs
Pseudocode
6 Sample Transaction Programs
The SNAplus2 APPC sample transaction programs (TPs) illustrate the use of APPC verbs in a mapped conversation.
The programs are provided with SNAplus2 as asample1.c and asample2.c, in the directory /opt/sna/
samples.
The following information is provided in this chapter:
• Processing overview of the sample TPs
• Pseudocode for each TP
• Instructions for compiling, linking, and running the TPs
6.1 Processing Overview
The TPs presented in this chapter enable a user to browse through a file on another system. The user is presented
with a single data block at a time, in hexadecimal and character format. After each block, a user can request the
next block, request the previous block, or quit.
asample1 (the invoking TP) sends a file name to asample2 (the invoked TP). If asample2 locates the file, it
returns the first data block to asample1; otherwise, it deallocates the conversation and ends.
If asample1 receives a block, it displays the block on the screen and waits for the user to enter
F for forward, B
for backward, or Q for quit. If the user selects forward or backward, asample1 sends the request to asample2,
which in turn sends the appropriate block. This process continues until the user selects the quit option, at which
time asample1 deallocates the conversation and both programs end.
If the user asks for the next block and asample2 has sent the last one, asample2 wraps to the beginning of
file. Similarly, asample2 wraps to send the last block if the user requests the previous one and the first block is
displayed.
Neither program attempts to recover from errors. A bad return code from APPC causes the program to terminate
with an explanatory message.
6.2 Pseudocode
This section contains the pseudocode for the TPs asample1 and asample2.
6.2.1 asample1 (Invoking TP)
The pseudocode for asample1 (the invoking TP) is as follows:
TP_started
mc_allocate (sync_level none)
mc_send_data (data = filename), send type prepare_to_receive_flush
do while no error and prompt not Q
mc_receive_and_wait
if data block received
display data block
else if permission to send received
267