RSC/MP Programming Manual

Application Development
TMF Code Example
/********* ****** **** ******* ****** ************* ****** *********** ****** ********
Automatic TMF tr ansa ction c ontrol with a singl e-requ est tr ansac tion
********** ****** **** ******* ****** ************* ****** *********** ****** *******/
/* Create options structure, set for automatic transaction BEGIN and END */
RscCreateOptions ( &ulOptions );
RscSetOption ( ulOptions, "TMF_OPTION", NULL, RSC_BEGIN_END_TRANS );
RscSetOption ( ulOptions, "SUCCESS_LO", NULL, 0 );
RscSetOption ( ulOptions, "SUCCESS_HI", NULL, 100 );
/* Send the request to the server */
uReplySize = sizeof ( sReply );
rc = RscWriteRead ( ulOptions, ulConnect , ulSession, "$XYZ", RSC_IO_WAI TED,
&sRequest, sizeof ( sRequest ), &sReply, &uReplySize );
/* If the transaction was not automatically ended, end it explicitly now */
if ( rc == RSC_TRANSACTION_NOT_ENDED )
{
nServerCode = RscSwapSh ort ( sReply.nRetcode );
if ( nServerCode == 999 )
RscEndTransaction ( ulConnect, ulSession );
else
RscAbortTransaction ( ulConnect, ulSession );
}
RscDestroyOptions ( ulOptions );
/********* ****** **** ******* ****** ************* ****** *********** ****** ********
Automatic TMF tr ansa ction c ontrol with a multi ple-re quest trans action
********** ****** **** ******* ****** ************* ****** *********** ****** *******/
/* Create options structure, set up for automatic transaction BEGIN */
RscCreateOptions ( &ulOptions );
RscSetOption ( ulOptions, "TMF_OPTION", NULL, RSC_BEGIN_TRANS );
/* Send first request to a server */
uReplySize = sizeof ( sReply );
rc = RscWriteRead ( ulOptions, ulConnect , ulSession, "$ABC", RSC_IO_WAI TED,
&sRequest, sizeof ( sRequest ), &sReply, &uReplySize );
/* For this server request we will consider any non-zero return as a failure
and abort the transaction without issuing the second request. */
nServerCode = RscSwapShort ( sReply.nRetcode );
if ( nServerCode != 0 )
RscAbortTransaction ( ulConnect, ulSession );
else
{
/* Set up to continue the transaction in progress; send second request */
RscSetOption ( ulOption s, "TMF_OPTION", NULL, 0 );
uReplySize = sizeof ( sReply );
rc = RscWriteRead ( ulOptions, ulConnect, ulSession, "$ABC", RSC_IO_WAITED,
&sRequest, sizeof ( sRequest ), &sReply, &uReplySize );
/* Set up to end the transaction with the next request */
RscSetOption ( ulOptions, "TMF_OPTION", NULL, RSC_END_TRANS );
RscSetOption ( ulOptions, "SU CCESS_ LO", NULL, 0 );
RscSetOption ( ulOption s, "SUCCESS_HI", NULL, 100 );
HP NonStop Remote Server Call (RSC/MP) Programming Manual 522360-006
6- 14