The following example shows how to invoke the CEATsoRequest API
from a C program. For a sample compile job that you can use to compile
this sample program, see Sample compile job.
/*****************************************************************/
/* */
/* CEASAMPT.c Sample code to demonstrate the */
/* CEATsoRequest() API for CEA HBB7780 */
/* CEA TSO ADDRESS SPACE MANAGER */
/* */
/* */
/* Classification: Unclassified */
/* */
/* Copyright: (C) Copyright IBM Corp. 2011, 2012 */
/* Liscensed Materials - Property of IBM */
/* */
/* */
/* Change History: */
/* $1.0 20110314 CYL: Initial Version */
/* $1.1 20111015 PDA2: Sample Program */
/* */
/*****************************************************************/
#define _XOPEN_SOURCE
#define _POSIX1_SOURCE 2
#define SESS_SESSIONNOLONGERINTABLE 16
#define SESS_MATCHMISSING 11
#define SESS_INDEXOUTOFRANGE 13
#define kMaximumSessions 50
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <env.h>
#include <iconv.h>
#include <sys/msg.h>
#include <sys/types.h>
#include <time.h>
#include "ceaytsor.h"
#include "ceaxrdef.h"
void init_expected_values( void );
void init_ceatso_struct( void );
void print_request_struct( void );
void print_query_struct( void );
void print_error_struct( void );
int send_message( void );
int check_message( int, int );
int verify_messages( int, int );
int verify_attn_messages( int, int );
void save_required_members( void );
void init_required_members( void );
void set_required_members( void );
#define NUMVARS 56
struct message_queue_s {
long int message_type;
char message_text[200];
} ;
typedef struct message_queue_s message_queue_t;
int error_counter; /* Total errors */
CEATsoRequestStruct_t ceatso_request;
CEATsoQueryStruct_t ceatso_query;
CEATsoError_t ceatso_error;
char userid[8];
uint32_t asid;
char apptag[8];
uint32_t ascbaddr;
int index_value; /* Save index value */
char stoken[8]; /* Stoken buffer */
char *stoken_ptr; /* Stoken pointer */
char *ptr;
message_queue_t message_queue;
int message_id;
size_t message_size;
char message_text[200];
int wait_seconds; /* Msg receive time */
int sleep_time;
char *tso_cmd_ptr;
char tso_cmd[80] =
"{\"TSO RESPONSE\":{\"VERSION\":\"0100\",\"DATA\":\"ALLOC DA\"}}";
int32_t expected_rc;
uint32_t expected_rsn;
uint32_t expected_diag1;
uint32_t expected_diag2;
uint32_t expected_diag3;
uint32_t expected_diag4;
uint32_t reason_mask;
int CeaTsoSamp1( void );
int main() {
int rc; /* Return code */
CeaTsoSamp1(); /* Invoke the sample code */
return 0;
}
/*******************************************************************/
/** **/
/** Routine to initialize the expected return code, **/
/** reason code and diag codes. **/
/** **/
/*******************************************************************/
void init_expected_values( void ) {
expected_rc = CEASUCCESS;
expected_rsn = 0;
expected_diag1 = 0;
expected_diag2 = 0;
expected_diag3 = 0;
expected_diag4 = 0;
return;
}
/*******************************************************************/
/** **/
/** Routine to initialize the CEA TSO request structure **/
/** query structure and error strucure for API call **/
/** **/
/*******************************************************************/
void init_ceatso_struct( void ) {
/* Initialize CEA TSO Request structure for CEATsoRequest() */
memset(&ceatso_request, '\0', sizeof(CEATsoRequestStruct_t));
strcpy(ceatso_request.ceatso_eyecatcher, CEATSOREQUEST_EYECATCHER);
ceatso_request.ceatso_version = CEATSOREQUEST_CURRENTVERSION;
ceatso_request.ceatso_requesttype = 0;
/*
ceatso_request.ceatso_asid = 0;
*/
strcpy(ceatso_request.ceatso_userid, "IBMUSER ");
strcpy(ceatso_request.ceatso_logonproc, "OMVS0803");
memset(&ceatso_request.ceatso_command, ' ', 80);
/*
ceatso_request.ceatso_numqueryreq = 12;
ceatso_request.ceatso_numqueryrslt = 12;
ceatso_request.ceatso_duration = 0;
ceatso_request.ceatso_msgqueueid = 0;
*/
ceatso_request.ceatso_charset = 697;
ceatso_request.ceatso_codepage = 1047;
ceatso_request.ceatso_screenrows = 24;
ceatso_request.ceatso_screencols = 80;
memset(ceatso_request.ceatso_account, '0', 40);
memset(ceatso_request.ceatso_group, ' ', 8);
strcpy(ceatso_request.ceatso_region, "2000000");
/*
memset(ceatso_request.ceatso_instance, ' ', 1);
*/
strcpy(ceatso_request.ceatso_apptag, "IZUIS ");
ceatso_request.ceatso_flags = CEATSO_ABLOGOFF;
/*
memset(ceatso_request.ceatso_stoken, 0xFF, 8);
ceatso_request.ceatso_ascbaddr = 0;
ceatso_request.ceatso_index = 0;
*/
/* Initialize the CEA TSO Query structure for CEATsoRequest() */
memset(&ceatso_query, '\0', sizeof(CEATsoQueryStruct_t));
strcpy(ceatso_query.ceatsoq_eyecatcher, CEATSOQUERY_EYECATCHER);
memset(&ceatso_request.ceatso_command, ' ', 40);
/* Initialize the CEA TSO Error structure for CEATsoRequest() */
memset(&ceatso_error, 0x00, sizeof(CEATsoError_t));
strcpy(ceatso_error.eyeCatcher, CEAINCT_EYE_CEAIERRO);
ceatso_error.version = CEAIERRO_CURRENTVERSION;
return;
}
/*******************************************************************/
/** **/
/** Routine to print out the CEATsoRequest structure **/
/** used by CEATsoRequest( ) API. **/
/** **/
/*******************************************************************/
void print_request_struct( void ) {
int i;
printf("\n\n\nCEATsoRequest structure\n\n");
printf("sizeof(CEATsoRequestStruct_t) = %d\n\n",
sizeof(CEATsoRequestStruct_t));
printf("CeaTsoRequest Eyecatcher = ");
ptr = ceatso_request.ceatso_eyecatcher;
for ( i = 1; i <= 8; i++ )
printf("%C", *ptr++);
printf("\n");
printf("CeaTsoRequest Version = %d\n",
ceatso_request.ceatso_version);
printf("CeaTsoRequest Requesttype = %d\n",
ceatso_request.ceatso_requesttype);
printf("CeaTsoRequest Userid = ");
ptr = ceatso_request.ceatso_userid;
for ( i = 1; i <= 8; i++ )
printf("%C", *ptr++);
printf("\n");
printf("CeaTsoRequest Asid = %X\n",
ceatso_request.ceatso_asid);
printf("CeaTsoRequest LogonProc = ");
ptr = ceatso_request.ceatso_logonproc;
for ( i = 1; i <= 8; i++ )
printf("%C", *ptr++);
printf("\n");
printf("CeaTsoRequest Command = ");
ptr = ceatso_request.ceatso_command;
for ( i = 1; i <= 40; i++ )
printf("%C", *ptr++);
printf("\n");
printf("CeaTsoRequest Numqueryreq = %d\n",
ceatso_request.ceatso_numqueryreq);
printf("CeaTsoRequest Numqueryrslt = %d\n",
ceatso_request.ceatso_numqueryrslt);
printf("CeaTsoRequest Duration = %d\n",
ceatso_request.ceatso_duration);
printf("CeaTsoRequest Msgqueueid = %d\n",
ceatso_request.ceatso_msgqueueid);
printf("CeaTsoRequest Charset = %d\n",
ceatso_request.ceatso_charset);
printf("CeaTsoRequest Codepage = %d\n",
ceatso_request.ceatso_codepage);
printf("CeaTsoRequest Screenrows = %d\n",
ceatso_request.ceatso_screenrows);
printf("CeaTsoRequest Screencols = %d\n",
ceatso_request.ceatso_screencols);
printf("CeaTsoRequest Account = ");
ptr = ceatso_request.ceatso_account + 32;
for ( i = 1; i < 8; i++)
printf("%C", *ptr++);
printf("\n");
printf("CeaTsoRequest Group = ");
ptr = ceatso_request.ceatso_group;
for ( i = 1; i <= 8; i++)
printf("%C", *ptr++);
printf("\n");
printf("CeaTsoRequest Region = ");
ptr = ceatso_request.ceatso_region;
for ( i = 1; i <= 7; i++)
printf("%C", *ptr++);
printf("\n");
ptr = ceatso_request.ceatso_instance;
printf("CeaTsoRequest Instance = %C\n", *ptr);
printf("CeaTsoRequest Apptag = ");
ptr = ceatso_request.ceatso_apptag;
for ( i = 1; i <= 8; i++)
printf("%C", *ptr++);
printf("\n");
printf("CeaTsoRequest Stoken = ");
stoken_ptr = ceatso_request.ceatso_stoken;
for ( i = 1; i <= 8; i++)
printf("%X ", *stoken_ptr++);
printf("\n");
printf("CeaTsoRequest ASCBaddr = %8X\n",
ceatso_request.ceatso_ascbaddr);
printf("CeaTsoRequest Flags = %d\n",
ceatso_request.ceatso_flags);
printf("CeaTsoRequest Index = %d\n",
ceatso_request.ceatso_index);
printf("\n");
return;
}
/*******************************************************************/
/** **/
/** Routine to print out the CEATsoQuery structure **/
/** used by CEATsoRequest( ) API. **/
/** **/
/*******************************************************************/
void print_query_struct( void ) {
int i;
printf("\n\n\nCEATsoQuery structure\n\n");
printf("sizeof(CEATsoQueryStruct_t) = %d\n\n",
sizeof(CEATsoQueryStruct_t));
printf("CeaTsoQuery Eyecatcher = ");
ptr = ceatso_query.ceatsoq_eyecatcher;
for ( i = 1; i <= 8; i++ )
printf("%C", *ptr++);
printf("\n");
printf("CeaTsoQuery Version = %d\n",
ceatso_query.ceatsoq_version);
printf("CeaTsoQuery Requesttype = %d\n",
ceatso_query.ceatsoq_requesttype);
printf("CeaTsoQuery Userid = ");
ptr = ceatso_query.ceatsoq_userid;
for ( i = 1; i <= 8; i++ )
printf("%C", *ptr++);
printf("\n");
printf("CeaTsoQuery Asid = %X\n",
ceatso_query.ceatsoq_asid);
printf("CeaTsoQuery LogonProc = ");
ptr = ceatso_query.ceatsoq_logonproc;
for ( i = 1; i <= 8; i++ )
printf("%C", *ptr++);
printf("\n");
printf("CeaTsoQuery Command = ");
ptr = ceatso_query.ceatsoq_command;
for ( i = 1; i <= 40; i++ )
printf("%C", *ptr++);
printf("\n");
printf("CeaTsoQuery Numqueryreq = %d\n",
ceatso_query.ceatsoq_numqueryreq);
printf("CeaTsoQuery Numqueryrslt = %d\n",
ceatso_query.ceatsoq_numqueryrslt);
printf("CeaTsoQuery Duration = %d\n",
ceatso_query.ceatsoq_duration);
printf("CeaTsoQuery Msgqueueid = %d\n",
ceatso_query.ceatsoq_msgqueueid);
printf("CeaTsoQuery Charset = %d\n",
ceatso_query.ceatsoq_charset);
printf("CeaTsoQuery Codepage = %d\n",
ceatso_query.ceatsoq_codepage);
printf("CeaTsoQuery Screenrows = %d\n",
ceatso_query.ceatsoq_screenrows);
printf("CeaTsoQuery Screencols = %d\n",
ceatso_query.ceatsoq_screencols);
printf("CeaTsoQuery Account = ");
ptr = ceatso_query.ceatsoq_account + 32;
for ( i = 1; i < 8; i++)
printf("%C", *ptr++);
printf("\n");
printf("CeaTsoQuery Group = ");
ptr = ceatso_query.ceatsoq_group;
for ( i = 1; i <= 8; i++)
printf("%C", *ptr++);
printf("\n");
printf("CeaTsoQuery Region = ");
ptr = ceatso_query.ceatsoq_region;
for ( i = 1; i <= 7; i++)
printf("%C", *ptr++);
printf("\n");
ptr = ceatso_query.ceatsoq_instance;
printf("CeaTsoQuery Instance = %C\n", *ptr);
printf("CeaTsoQuery Apptag = ");
ptr = ceatso_query.ceatsoq_apptag;
for ( i = 1; i <= 8; i++)
printf("%C", *ptr++);
printf("\n");
printf("CeaTsoQuery Stoken = ");
stoken_ptr = ceatso_query.ceatsoq_stoken;
for ( i = 1; i < 9; i++)
printf("%X ", *stoken_ptr++);
printf("\n");
printf("CeaTsoQuery ASCBaddr = %8X\n",
ceatso_query.ceatsoq_ascbaddr);
printf("CeaTsoQuery Flags = %d\n",
ceatso_query.ceatsoq_flags);
printf("CeaTsoQuery Index = %d\n",
ceatso_query.ceatsoq_index);
printf("\n");
return;
}
/*******************************************************************/
/** **/
/** Routine to print out the CEATsoError structure **/
/** used by CEATsoRequest( ) API. **/
/** **/
/*******************************************************************/
void print_error_struct( void ) {
int i;
printf("\n\n\nCEATsoError structure\n\n");
printf("sizeof(CEATsoError_t) = %d\n\n",
sizeof(CEATsoError_t));
printf("CEAError Eyecatcher = ");
ptr = ceatso_error.eyeCatcher;
for ( i = 1; i <= 8; i++)
printf("%C", *ptr++);
printf("\n");
printf("CEAError Version = %8d\n",
ceatso_error.version);
printf("CEAError ReturnCode(hex) = %8X\n",
ceatso_error.returnCode);
printf("CEAError ReasonCode(hex) = %8X\n",
ceatso_error.reasonCode);
printf("CEAError Diag.diag1(hex) = %8X\n",
ceatso_error.diag.diag1);
printf("CEAError Diag.diag2(hex) = %8X\n",
ceatso_error.diag.diag2);
printf("CEAError Diag.diag3(hex) = %8X\n",
ceatso_error.diag.diag3);
printf("CEAError Diag.diag4(hex) = %8X\n",
ceatso_error.diag.diag4);
printf("\n");
return;
}
/*******************************************************************/
/** **/
/** Verify messages **/
/** **/
/*******************************************************************/
int verify_messages(int message_id, int wait_seconds ) {
int rc;
char *string1;
char *string2;
char *string3;
char *string4;
char *string5;
char *string6;
if ( ceatso_request.ceatso_requesttype == CeaTsoStart ) {
rc = check_message(message_id, wait_seconds);
string1 = "LOGON IN PROGRESS";
if ( rc != 0 || strstr(message_text, string1) == NULL ) {
printf(" Failed to receive %s message.\n\n\n", string1);
return 99;
}
rc = check_message(message_id, wait_seconds);
string2 = "NO BROADCAST MESSAGES";
if ( rc != 0 || strstr(message_text, string2) == NULL ) {
printf(" Failed to receive %s.\n\n\n", string2);
return 99;
}
rc = check_message(message_id, wait_seconds);
string3 = "READY ";
if ( rc != 0 || strstr(message_text, string3) == NULL ) {
printf(" Failed to receive %s prompt.\n\n\n", string3);
return 99;
}
rc = check_message(message_id, wait_seconds);
string4 = "HIDDEN";
string5 = "FALSE";
if ( rc != 0 ||
strstr(message_text, string4) == NULL ||
strstr(message_text, string5) == NULL ) {
printf(" Failed to receive %s : %s message.\n\n\n",
string4, string5 );
return 99;
}
}
if ( ceatso_request.ceatso_requesttype == CeaTsoAttn ) {
rc = check_message( message_id, wait_seconds );
string6 = "ENTER DATA SET NAME OR * -";
if ( rc != 0 ||
strstr(message_text, string6) == NULL ) {
printf(" Failed to receive %s message.\n\n\n", string6);
return 99;
}
rc = check_message(message_id, wait_seconds);
string4 = "HIDDEN";
string5 = "FALSE";
if ( rc != 0 ||
strstr(message_text, string4) == NULL ||
strstr(message_text, string5) == NULL ) {
printf(" Failed to receive %s : %s message.\n\n\n",
string4, string5 );
return 99;
}
}
return 0;
}
/*******************************************************************/
/** **/
/** Verify messages after Attn **/
/** **/
/*******************************************************************/
int verify_attn_messages(int message_id, int wait_seconds ) {
int rc;
char *string1;
char *string2;
char *string3;
rc = check_message(message_id, wait_seconds);
string1 = "READY ";
if ( rc != 0 || strstr(message_text, string1) == NULL ) {
printf(" Failed to receive %s prompt after Attn.\n\n\n",
string1);
return 99;
}
rc = check_message(message_id, wait_seconds);
string2 = "HIDDEN";
string3 = "FALSE";
if ( rc != 0 ||
strstr(message_text, string2) == NULL ||
strstr(message_text, string3) == NULL ) {
printf(" Failed to receive %s : %s message.\n\n\n",
string2, string3);
return 99;
}
return 0;
}
/*******************************************************************/
/** **/
/** Check message text **/
/** **/
/*******************************************************************/
int check_message( int message_id, int wait_seconds ) {
int rc;
size_t iconv_rc;
ssize_t msg_rc;
iconv_t cd;
char *input_ptr;
char *output_ptr;
size_t input_msgsize;
size_t output_msgsize;
time_t wait_time;
time_t start_time;
time_t receive_time;
message_size = sizeof(message_queue_t) - sizeof(long int);
memset(&message_text, '\0', message_size);
time(&start_time);
/* -6 should include 2 and 3 */
message_queue.message_type = (long int)-6;
sleep_time = 2;
msg_rc = 0;
/* Must include IPC_NOWAIT flag, otherwise could hang */
/* the program execution when no msg sending back. */
do {
msg_rc = msgrcv(message_id, &message_queue, message_size,
message_queue.message_type, MSG_NOERROR | IPC_NOWAIT);
sleep( sleep_time);
wait_time = time(&receive_time) - start_time;
} while ( wait_time <= wait_seconds && msg_rc <= 0 );
if ( msg_rc == -1 ) {
printf("\n\nReceive message failed with\n");
printf(" msg_rc = %d ", msg_rc);
printf(" Wait time = %d seconds\n", wait_time);
printf(" Errno = %X", errno);
printf(" Errno_Jr = %X\n\n", __errno2());
return 99;
}
else
printf(" Received Message in %d seconds.\n",
wait_time);
if ( (rc = setenv("_ICONV_UCS2", "D", 1)) != 0) {
printf("\n setenv( ) failed with ");
printf(" rc = %d ", rc);
printf(" Errno = %X ", errno);
printf(" Errno_Jr = %X\n\n", __errno2());
return rc;
}
if ( (cd = iconv_open("IBM-1047", "UTF-8")) == (iconv_t)-1 ) {
printf(" iconv_open( ) failed with ");
printf(" Errno = %X ", errno);
printf(" Errno_Jr = %X\n\n", __errno2());
return 99;
}
input_ptr = message_queue.message_text;
output_ptr = message_text;
input_msgsize = msg_rc;
output_msgsize = msg_rc;
if ((iconv_rc = iconv(cd, &input_ptr, &input_msgsize, &output_ptr,
&output_msgsize)) == (size_t)-1 ) {
printf(" iconv( ) failed with ");
printf(" rc = %d ", iconv_rc);
printf(" Errno = %X ", errno);
printf(" Errno_Jr = %X\n\n", __errno2());
return 99;
}
if ( (rc = iconv_close( cd )) == -1 ) {
printf(" iconv_close( ) failed with ");
printf(" rc = %d ", rc);
printf(" Errno = %X ", errno);
printf(" Errno_Jr = %X\n\n", __errno2());
return rc;
}
printf(" Reveived Message Type: %2d\n",
message_queue.message_type);
printf(" Reveived Message Length: %d\n", strlen(message_text));
printf(" Received Message Text: \n");
printf(" %s\n", message_text);
printf("\n");
return 0;
}
/*******************************************************************/
/** **/
/** Send TSO command and check the proper message received **/
/** **/
/*******************************************************************/
int send_message( void ) {
int rc;
size_t iconv_rc;
iconv_t cd;
size_t input_msgsize;
size_t output_msgsize;
char *input_ptr;
char *output_ptr;
message_size = sizeof(message_queue_t) - sizeof(long int);
memset(&message_queue.message_text, '\0', message_size);
memset(&message_text, '\0', message_size);
strcpy(message_text, tso_cmd);
if ( (cd = iconv_open("UTF-8", "IBM-1047")) == (iconv_t)-1 ) {
printf(" iconv_open( ) failed with ");
printf(" Errno = %X ", errno);
printf(" Errno_Jr = %X\n\n", __errno2());
return 99;
}
input_ptr = message_text;
output_ptr = message_queue.message_text;
input_msgsize = strlen(message_text);
output_msgsize = input_msgsize;
if ((iconv_rc = iconv(cd, &input_ptr, &input_msgsize, &output_ptr,
&output_msgsize)) == (size_t)-1 ) {
printf(" iconv( ) failed with ");
printf(" rc = %d ", iconv_rc);
printf(" Errno = %X ", errno);
printf(" Errno_Jr = %X\n\n", __errno2());
return 99;
}
if ( (rc = iconv_close( cd )) == -1 ) {
printf(" iconv_close( ) failed with ");
printf(" rc = %d ", rc);
printf(" Errno = %X ", errno);
printf(" Errno_Jr = %X\n\n", __errno2());
return rc;
}
message_queue.message_type = (long int)7;
message_size = strlen(message_queue.message_text);
rc = msgsnd(message_id, &message_queue, message_size, 0);
return rc;
}
/*******************************************************************/
/** **/
/** Save some required members of request structure **/
/** for ATTN and END process **/
/** **/
/*******************************************************************/
void save_required_members( void ) {
int i;
/* Not required input for End
if ( ceatso_request.ceatso_requesttype == CeaTsoEnd ) {
strcpy(userid, ceatso_request.ceatso_userid);
strcpy(apptag, ceatso_request.ceatso_apptag);
}
if ( ceatso_request.ceatso_requesttype == CeaTsoAttn )
asid = ceatso_request.ceatso_asid;
*/
asid = ceatso_request.ceatso_asid;
stoken_ptr = stoken;
ptr = ceatso_request.ceatso_stoken;
for ( i = 1; i < 9; i++)
*stoken_ptr++ = *ptr++;
ascbaddr = ceatso_request.ceatso_ascbaddr;
index_value = ceatso_request.ceatso_index;
/*
printf("\nSave the following value:\n");
*/
/* Not required input for End
if ( ceatso_request.ceatso_requesttype == CeaTsoEnd ) {
printf(" userid = ");
ptr = userid;
for ( i = 1; i <= 8; i++ )
printf("%C", *ptr++);
printf("\n");
printf(" apptag = ");
ptr = apptag;
for ( i = 1; i <= 8; i++ )
printf("%C", *ptr++);
printf("\n");
}
*/
/*
printf(" asid = %X\n", asid);
ptr = ceatso_request.ceatso_stoken;
printf(" stoken = ");
for ( i = 1; i < 9; i++)
printf("%X ", *ptr++);
printf("\n");
printf(" ascdaddr = %X\n", ascbaddr);
printf(" index_value = %X\n", index_value);
printf("\n");
*/
return;
}
/*******************************************************************/
/** **/
/** Initialize some required members of request structure **/
/** for ATTN and END process **/
/** **/
/*******************************************************************/
void init_required_members( void ) {
int i;
memset(ceatso_request.ceatso_eyecatcher, 'F', 8);
ceatso_request.ceatso_version = 0;
if ( ceatso_request.ceatso_requesttype == CeaTsoAttn )
ceatso_request.ceatso_asid = 0;
/*
if ( ceatso_request.ceatso_requesttype == CeaTsoEnd ) {
memset(ceatso_request.ceatso_userid, 'F', 8);
memset(ceatso_request.ceatso_apptag, 'F', 8);
}
*/
memset(ceatso_request.ceatso_stoken, 0xFF, 8);
ceatso_request.ceatso_ascbaddr = 0;
ceatso_request.ceatso_index = 0;
/* Initialize the CEA TSO Error structure for CEATsoRequest() */
memset(&ceatso_error, 0x00, sizeof(CEATsoError_t));
return;
}
/*******************************************************************/
/** **/
/** Set some required members of request structure back **/
/** to the original value for ATTN and END process **/
/** **/
/*******************************************************************/
void set_required_members( void ) {
int i;
strcpy(ceatso_request.ceatso_eyecatcher, CEATSOREQUEST_EYECATCHER);
ceatso_request.ceatso_version = CEATSOREQUEST_CURRENTVERSION;
/*
if ( ceatso_request.ceatso_requesttype == CeaTsoEnd ) {
strcpy(ceatso_request.ceatso_userid, userid);
strcpy(ceatso_request.ceatso_apptag, apptag);
}
*/
if ( ceatso_request.ceatso_requesttype == CeaTsoAttn )
ceatso_request.ceatso_asid = asid;
stoken_ptr = stoken;
ptr = ceatso_request.ceatso_stoken;
for ( i = 1; i < 9; i++)
*ptr++ = *stoken_ptr++;
ceatso_request.ceatso_ascbaddr = ascbaddr;
ceatso_request.ceatso_index = index_value;
/* Initialize the CEA TSO Error structure for CEATsoRequest() */
memset(&ceatso_error, 0x00, sizeof(CEATsoError_t));
strcpy(ceatso_error.eyeCatcher, CEAINCT_EYE_CEAIERRO);
ceatso_error.version = CEAIERRO_CURRENTVERSION;
return;
}
/*******************************************************************/
/** **/
/** CeaTsoSamp1: Sample code to invoke CEATsoRequest() to start **/
/** a CEA TSo Session send it an Attn interrupt the end the TSO **/
/** session. **/
/** **/
/** Results are returned in the error structure **/
/** **/
/*******************************************************************/
int CeaTsoSamp1( ) {
int i;
int rc;
printf("====================================================\n");
printf("== Start CeaTsoRequest( ) Example ==\n");
printf("====================================================\n");
printf("\n");
printf("CEATSORequest( ) Start session.\n\n");
init_ceatso_struct( );
init_expected_values( );
ceatso_request.ceatso_requesttype = CeaTsoStart;
CEATsoRequest(&ceatso_request, &ceatso_query, &ceatso_error);
if ( ceatso_error.returnCode == expected_rc &&
ceatso_error.reasonCode == expected_rsn &&
ceatso_error.diag.diag1 == expected_diag1 &&
ceatso_error.diag.diag2 == expected_diag2 &&
ceatso_error.diag.diag3 == expected_diag3 &&
ceatso_error.diag.diag4 == expected_diag4 )
printf(" Verifying logon messages.\n\n");
else {
error_counter = error_counter + 1;
printf("CEATsoRequest( ) Start session failed.\n\n\n");
print_error_struct( );
print_request_struct( );
printf("\nVariation %d failed.\n\n\n", variation_id);
printf("\n\n");
return error_counter;
}
wait_seconds = 8;
message_id = ceatso_request.ceatso_msgqueueid;
rc = verify_messages( message_id, wait_seconds );
if ( rc == 0)
printf("\nCEATsoRequest( ) Start seesion successful.\n\n");
else {
error_counter = error_counter + 1;
printf("CEATsoRequest( ) Start failed to receive the message ");
printf("with rc = %d.\n\n\n", rc);
printf("\nVariation %d failed.\n\n\n", variation_id);
printf("\n\n");
return error_counter;
}
save_required_members( );
ceatso_request.ceatso_requesttype = CeaTsoAttn;
rc = send_message( );
if ( rc == 0 ) {
printf("\n\nSend TSO Command Successful.\n\n");
printf(" Send Message Type: %2d\n",
message_queue.message_type);
printf(" Send Message Length: %d\n",
strlen(message_queue.message_text));
printf("\n");
}
else {
printf("\nSend message failed with ");
printf(" rc = %d ", rc);
printf(" Errno = %X ", errno);
printf(" Errno_Jr = %X\n\n", __errno2());
error_counter = error_counter + 1;
printf("\nVariation %d failed.\n\n\n", variation_id);
printf("\n");
return error_counter;
}
rc = verify_messages(message_id, wait_seconds);
if ( rc == 0)
printf("\n\nCEATsoRequest( ) Attn starts.\n\n");
else {
error_counter = error_counter + 1;
printf("\nVariation %d failed.\n\n\n", variation_id);
printf("\n\n");
return error_counter;
}
ceatso_request.ceatso_requesttype = CeaTsoAttn;
set_required_members( );
init_expected_values( );
strcpy(ceatso_request.ceatso_eyecatcher, CEATSOREQUEST_EYECATCHER);
CEATsoRequest(&ceatso_request, &ceatso_query, &ceatso_error);
if ( ceatso_error.returnCode == expected_rc &&
ceatso_error.reasonCode == expected_rsn &&
ceatso_error.diag.diag1 == expected_diag1 &&
ceatso_error.diag.diag2 == expected_diag2 &&
ceatso_error.diag.diag3 == expected_diag3 &&
ceatso_error.diag.diag4 == expected_diag4 )
printf(" Verifying messages after Attn.\n\n");
else {
error_counter = error_counter + 1;
printf("CEATsoRequest( ) Attn failed.\n\n");
print_error_struct( );
print_request_struct( );
printf("\nVariation %d failed.\n\n\n", variation_id);
return error_counter;
}
rc = verify_attn_messages(message_id, wait_seconds);
if ( rc == 0 )
printf("\nCEATsoRequest( ) Attn successful.\n\n");
else {
error_counter = error_counter + 1;
printf("CEATsoRequest( ) Attn failed.\n\n");
print_error_struct( );
print_request_struct( );
printf("\nVariation %d failed.\n\n\n", variation_id);
return error_counter;
}
printf("\n\nCEATsoRequest( ) End starts.\n");
set_required_members( );
init_expected_values( );
ceatso_request.ceatso_requesttype = CeaTsoEnd;
CEATsoRequest(&ceatso_request, &ceatso_query, &ceatso_error);
if ( ceatso_error.returnCode == expected_rc &&
ceatso_error.reasonCode == expected_rsn &&
ceatso_error.diag.diag1 == expected_diag1 &&
ceatso_error.diag.diag2 == expected_diag2 &&
ceatso_error.diag.diag3 == expected_diag3 &&
ceatso_error.diag.diag4 == expected_diag4 )
printf("\n\n\nCEATsoRequest( ) End session successful.\n");
else {
error_counter = error_counter + 1;
printf("\n\nCEATsoRequest( ) End session failed.\n\n");
print_request_struct( );
print_error_struct( );
printf("\nVariation %d failed.\n\n\n", variation_id);
return error_counter;
}
if ( ceatso_error.returnCode == CEASUCCESS )
printf("\n\n\nVariation %d succeeded.\n\n\n\n", variation_id);
else {
error_counter = error_counter + 1;
printf("\n\n\nVariation %d failed.\n\n\n\n", variation_id);
}
printf("====================================================\n");
printf("== Finished Start CeaTsoRequest( ) Example \n");
printf("====================================================\n");
printf("\n\n\n\n");
return error_counter;
}