// --------------------------------------------------------- // (c) Copyright IBM Corp. 1999 All rights reserved. // // This sample program is owned by International Business Machines // Corporation or one of its subsidiaries ("IBM") and is copyrighted // and licensed, not sold. // // You may copy, modify, and distribute this sample program in any // form without payment to IBM, for any purpose including developing, // using, marketing or distributing programs that include or are // derivative works of the sample program. // // The sample program is provided to you on an "AS IS" basis, without // warranty of any kind. IBM HEREBY EXPRESSLY DISCLAIMS ALL WARRANTIES, // EITHER EXPRESS OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED // WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. // Some jurisdictions do not allow for the exclusion or limitation of // implied warranties, so the above limitations or exclusions may not // apply to you. IBM shall not be liable for any damages you suffer as // a result of using, modifying or distributing the sample program or // its derivatives. // // Each copy of any portion of this sample program or any derivative // work, must include the above copyright notice and disclaimer of // warranty. //**************************************************************** // Sample code showing how to get specific input container members. // Uses data structure members, StringMember and LongMember // // This program must be invoked from a Program Activity from within a process. // // To compile and link on WindowsNT with MSVC++, Enter: // // cl -MD sampgicm.c fmcjdcom.lib fmcjdcbr.lib fmcjdcon.lib fmcjdrun.lib // // created 01-04-99 dsb. // ----------------------------------------------------------------------- #include #include "fmcjcrun.h" int main () { APIRET rc= FMC_OK; FmcjExecutionServiceHandle hService=0; FmcjReadWriteContainerHandle hOutContainer=0; FmcjReadOnlyContainerHandle hInContainer=0; char sTextData[4097]=""; char sResponse[2]=""; char sNumValue[10]=""; long lNumValue=0; // ***** Make a connection *************** rc=FmcjGlobalConnect(); if (rc !=FMC_OK) { printf("Could not connect. rc = %u%\n",rc); return 99; } // ***** Allocate a session handle *********** rc=FmcjExecutionServiceAllocate(&hService); if (rc != FMC_OK) { printf("Could not allocate service. rc = %u%\n",rc); return 99; } // ***** Passthrough to existing session ******* rc = FmcjExecutionServicePassthrough(hService); if (rc != FMC_OK) { printf("Could not passthrough. rc = %u%\n",rc); return 99; } //******** get the input container rc = FmcjContainerInContainer(&hInContainer); if (rc != FMC_OK) { printf("Could not get In Container. rc = %u%\n",rc); return 99; } //******** get the output container rc = FmcjContainerOutContainer(&hOutContainer); if (rc != FMC_OK) { printf("Could not get Out Container. rc = %u%\n",rc); return 99; } //**** Get members of the input container // *** Get the long value for member LongMember rc=FmcjReadOnlyContainerLongValue(hInContainer, "LongMember", &lNumValue); if (rc == FMC_ERROR_MEMBER_NOT_SET) { // member not set rc=113 // prompt user for some data to put in this field printf("Data member was not set.\n"); printf("Enter a number to be put into the member LongMember: \n"); gets(sNumValue); lNumValue=atoi(sNumValue); } else { if (rc != FMC_OK) printf("Error getting value for LongMember. rc = %u%\n",rc); else printf("LongMember = %u%\n",lNumValue); } // *** Get the string value for member StringMember rc=FmcjReadOnlyContainerStringValue(hInContainer, "StringMember", sTextData, 4096 ); if (rc == FMC_ERROR_MEMBER_NOT_SET) { // member not set rc=113 // prompt user for some data to put in this field printf("Data member was not set.\n"); printf("Enter a string to be put into the member StringMember: \n"); gets(sTextData); } else { if (rc != FMC_OK) printf("Error getting value for StringMember. rc = %u%\n",rc); else printf("StringMember = %s\n",sTextData); } //*** set the members in the output container rc = FmcjReadWriteContainerSetStringValue(hOutContainer, "StringMember", sTextData); if (rc != FMC_OK) printf("Error setting StringMember. rc = %u%\n",rc); rc = FmcjReadWriteContainerSetLongValue(hOutContainer, "LongMember", lNumValue); if (rc != FMC_OK) printf("Error setting LongMember. rc = %u%\n",rc); // ******* Send output container back rc = FmcjContainerSetOutContainer(hOutContainer); if (rc != FMC_OK) printf ("Error sending out container to PEA. rc = %u%\n",rc); // **** logoff and disconnect rc = FmcjExecutionServiceLogoff(hService); rc = FmcjGlobalDisconnect(); // *** pause so you can see the messages printf("\nEnter to continue."); gets(sResponse); return 0; }