/* This program uses Dynamic Screen Manager API calls to */
/* create a window and echo whatever is entered. This is an */
/* example of bound API calls. Note the use of #pragma argument */
/* in the <qsnsess.h> header file. OS, nowiden ensures that a pointer */
/* to an unwidened copy of the argument is passed to the API. */
/* */
/* Use BNDDIR(QSNAPI) on the CRTPGM command to build this */
/* example. */
#include <stddef.h>
#include <string.h>
#include <stdio.h>
#include "QSYSINC/H/QSNAPI"
/* QSNSESS nests QSNWIN and QSNLL include files. To get these 3 */
/* include files, do the following: */
/* 1) If you do not have a SRCPF called H in your Library (MYLIB), */
/* create one. */
/* 2) Copy QUSRTOOL/QATTSYSC/OPSN3API to MYLIB/H/QSNSESS */
/* 3) Copy QUSRTOOL/QATTSYSC/OPSN2API to MYLIB/H/QSNWIN */
/* 4) Copy QUSRTOOL/QATTSYSC/OPSN1API to MYLIB/H/QSNLL */
#define BOTLINE " Echo lines until: PF3 - exit"
/* DSM Session Descriptor Structure. */
typedef struct{
Qsn_Ssn_Desc_T sess_desc;
char buffer[300];
}storage_t;
void F3Exit(const Qsn_Ssn_T *Ssn, const Qsn_Inp_Buf_T *Buf, char *action)
{
*action = '1';
}
int main(void)
{
int i;
storage_t storage;
/* Declarators for declaring windows. Types are from the <qsnsess.h> */
/* header file. */
Qsn_Inp_Buf_T input_buffer = 0;
Q_Bin4 input_buffer_size = 50;
char char_buffer[100];
Q_Bin4 char_buffer_size;
Qsn_Ssn_T session1;
Qsn_Ssn_Desc_T *sess_desc = (Qsn_Ssn_Desc_T *) &storage;
Qsn_Win_Desc_T win_desc;
Q_Bin4 win_desc_length = sizeof(Qsn_Win_Desc_T);
char *botline = BOTLINE;
Q_Bin4 botline_len = sizeof(BOTLINE) - 1;
Q_Bin4 sess_desc_length = sizeof(Qsn_Ssn_Desc_T) +
botline_len;
Q_Bin4 bytes_read;
/* Initialize Session Descriptor API. */
QsnInzSsnD( sess_desc, sess_desc_length, NULL);
/* Initialize Window Descriptor API. */
QsnInzWinD( &win_desc, win_desc_length, NULL);
sess_desc->cmd_key_desc_line_1_offset = sizeof(Qsn_Ssn_Desc_T);
sess_desc->cmd_key_desc_line_1_len = botline_len;
memcpy( storage.buffer, botline, botline_len );
sess_desc->cmd_key_desc_line_2_offset = sizeof(Qsn_Ssn_Desc_T) +
botline_len;
/* Set up the session type. */
sess_desc->EBCDIC_dsp_cc = '1';
sess_desc->scl_line_dsp = '1';
sess_desc->num_input_line_rows = 1;
sess_desc->wrap = '1';
/* Set up the window size. */
win_desc.top_row = 3;
win_desc.left_col = 3;
win_desc.num_rows = 13;
win_desc.num_cols = 45;
/* Create a window session. */
sess_desc->cmd_key_action[2] = F3Exit;
session1 = QsnCrtSsn( sess_desc, sess_desc_length,
NULL, 0,
'1',
&win_desc, win_desc_length,
NULL, 0,
NULL, NULL);
if(input_buffer == 0)
{
input_buffer = QsnCrtInpBuf(100, 50, 0, NULL, NULL);
}
for (;;)
{
/* Echo lines until F3 is pressed. */
QsnReadSsnDta(session1, input_buffer, NULL, NULL);
if (QsnRtvReadAID(input_buffer, NULL, NULL) == QSN_F3)
{
break;
}
}
}
|