//****************************************************************************** //****************************************************************************** // Code disclaimer information //------------------------------------------------------------------------------ // This file contains programming code examples. // // IBM grants you a nonexclusive copyright license to use all programming // code examples from which you can generate similar functions tailored to // your own specific needs. // // All sample code is provided by IBM for illustrative purposes only. // These examples have not been thoroughly tested under all conditions. IBM, // therefore, cannot guarantee or imply reliability, serviceability, or // function of these programs. // // All programs contained herein are provided to you "AS IS" without any // warranties of any kind. The implied warranties of non-infringement, // merchantability, and fitness for a particular purpose are expressly // disclaimed. //****************************************************************************** //****************************************************************************** //-- START OF SPECIFICATIONS ------------------------------------------------ // // Source File Name : replay.C // // Module Name : REPLAY // // Program Name : REPLAY // // Source File Description: Source code for the main driver program of the // IFS Journaling Replication demo. // This program is the one that is directly called // by the demo-er. It will call the RCVJRNE command // to have our exit program, RPL *PGM, receive matching // journal entries to replay. // //****** WARNING ***** PLEASE READ ME ****************************************** // USE OF THIS SOURCE CODE IS AT YOUR OWN RISK. // This code is being used in the IFS Journaling Replication demo that was // first used at COMMON in March 2003. This code is NOT a complete replication // solution, and should not be used to provide object or data replication. // It was written to provide a way to demo replication of a small subset of IFS // journal entries using a remote journal on the SAME system. It is being made // available for public browsing as an example what was really involved in // performing some of the steps required in providing IFS object/data // replication. Therefore, some of the code within this demo takes shortcuts // that would not be available in a normal replication environment involving // separate source and target systems. //****************************************************************************** // // Change Activity : // // CFD List : // // FLAG REASON RELEASE DATE PGMR CHANGE DESCRIPTION // ---- --------- ---------- ------ --------- ---------------------------------- // $A0= DEMO xxxx 030129 IBMG8PA: New module // // End CFD List. // // Additional notes about the Change Activity // // End Change Activity. // //------------------------------------------------------------------------------ #include "rplcmn.H" #include "fidtbl.H" #include #include #include #include #include #include //-- START OF FUNCTION SPECIFICATIONS -------------------------------------- // // Function Name : replay (main) // // Descriptive Name : Main driver function of the replicator demo. // This program is the one that is directly called // by the demo-er. It will call the RCVJRNE command // to have our exit program, rpl, receive matching // journal entries to replay. // // // Input : // argv[1] - char * // Pointer to null-terminated string containing the IASP name // that contains the target journal and target directory, since // they will always be one in the same. May specify *NONE // if not using a remote journal. If *NONE, then parm 2 is // required. // //-- END OF SPECIFICATIONS ------------------------------------------------- int main(int argc, char *argv[]) { char cmdString[100]; if (argc < 2) { printf("%s parms:\n",argv[0]); printf(" 1) IASP Name or *NONE.\n"); return -1; } // Create a user space object to be used to store the FIDTable data. Qus_EC_t errorCode; errorCode.Bytes_Provided = 0; // Cause exception if fails char initValue = 0; char textDescription[50]; memset(textDescription, 0x40, sizeof(textDescription)); memcpy(textDescription, "IFS Replay FID Table", strlen("IFS Replay FID Table")); QUSCRTUS ((void *)USRSPC_NAME_LIB,// Qualified User Space Name " ", // Extended Attribute sizeof(FIDTable) + (sizeof(FIDTableEntry) * 100), // Initial Size &initValue, // Initial Value "*ALL ", // Public Authority textDescription, // Text Description "*YES ", // Replace existing &errorCode ); // Resolve to get the system pointer to the new user space. _SYSPTR usrspcP; usrspcP = getUsrspcPtr(); if (usrspcP == NULL) { return -1; } char targetPath[MAX_PATH_LENGTH]; // If the caller did not pass an IASP name, then use target dir name as-is. if (0 == strcmp(argv[1],"*NONE")) { strcpy(targetPath,TGTDIR); } else // Else, pre-pend the IASP name onto the path. { strcpy(targetPath,"/"); // Starting slash strcat(targetPath,argv[1]); // IASP name strcat(targetPath,TGTDIR); // target dir, already has beginning slash. // Switch to the ASP group necessary. char setCmdString[100]; sprintf(setCmdString, "SETASPGRP ASPGRP(%s)", argv[1]); if (-1 == system(setCmdString)) { return -1; } } // Construct the fid table in the user space. new(setsppfp(usrspcP)) FIDTable((char *)SRCDIR,targetPath); char *jrnP; // Decide whether to use the "target" remote journal, or if we should use // the "local" journal. This demo assumes that remote journal is only // used if the target is on an IASP. if (0 == memcmp(argv[1], "*NONE", 5)) { jrnP = (char *)SRC_JOURNAL_LIB_AND_NAME; } else { jrnP = (char *)TGT_JOURNAL_LIB_AND_NAME; } // Build the command string. sprintf(cmdString, "RCVJRNE JRN(%s) EXITPGM(IFSRJDEMO/RPL) JRNCDE((B)) ENTFMT(*TYPEPTR) DELAY(*NEXTENT)", jrnP); // Execute the command. We do this inside of a loop, since the RCVJRNE may // end if the journal receiver gets changed out from under the journal. // This processing could be made more robust, but for a demo, the user // will just have to terminate the job (or issue a cancel request) to get // us to stop looping. while(1) { system(cmdString); } // If the caller did not pass an IASP name, then use target dir name as-is. if (0 == strcmp(argv[1],"*NONE")) { strcpy(targetPath,TGTDIR); } else // Else, pre-pend the IASP name onto the path. { strcpy(targetPath,"/"); // Starting slash strcat(targetPath,argv[1]); // IASP name strcat(targetPath,TGTDIR); // target dir, already has beginning slash. // Switch to the ASP group necessary. char setCmdString[100]; sprintf(setCmdString, "SETASPGRP ASPGRP(%s)", "*NONE"); system(setCmdString); } return(0); }