This example program shows how to save a large library using more than one device at the same time.
/*******************************************************************/ /* PROGRAM: SaveBigLib */ /* */ /* LANGUAGE: ILE C */ /* */ /* DESCRIPTION: This is an example program for the use of */ /* a media definition in a save operation. */ /* It saves library BIGLIB in parallel format to */ /* two media files, using tape media library */ /* TAPMLB01. */ /* */ /* The flow of this program is as follows: */ /* (1) Build media definition input. */ /* (2) Create a media definition using */ /* QsrCreateMediaDefinition. */ /* (3) Save library BIGLIB using the media */ /* definition. */ /* */ /* APIs USED: QsrCreateMediaDefinition, QCMDEXC */ /* */ /*******************************************************************/ #include <qcmdexc.h> #include <qsrlib01.h> #include <qusec.h> #include <string.h> /*******************************************************************/ /* Variables for QsrCreateMediaDefinition */ /*******************************************************************/ char Data_Buffer[1000]; Qsr_TAPE0100_t *Input_Data; Qsr_TAPE0100_Device_t *Device; Qsr_TAPE0100_File_t *Media_File; char *Next_Free; char *Volid; Qus_EC_t Err_Code; int Data_Length; char Text[50]; /*******************************************************************/ /* Variables for QCMDEXC */ /*******************************************************************/ char Cmd_String[100]; decimal(15,5) Cmd_Length; /*******************************************************************/ /* Start of main() */ /*******************************************************************/ int main (int argc, char *argv[]) { /*******************************************************************/ /* Specify input data for QsrCreateMediaDefinition. */ /*******************************************************************/ /*-----------------------------------------------------------------*/ /* Build general media definition input data. */ /* Use one device with two parallel device resources. */ /*-----------------------------------------------------------------*/ memset(Data_Buffer,0,sizeof(Data_Buffer)); Input_Data = (Qsr_TAPE0100_t*)Data_Buffer; Next_Free = (char*)(Input_Data + 1); Input_Data->Maximum_Resources = 2; Input_Data->Minimum_Resources = 2; Input_Data->Offset_First_Device = Next_Free - Data_Buffer; Input_Data->Device_Count = 1; /*-----------------------------------------------------------------*/ /* Build input data for the first device. */ /* Use device TAPMLB01 with two media files. */ /*-----------------------------------------------------------------*/ Device = (Qsr_TAPE0100_Device_t*)Next_Free; Next_Free = (char*)(Device + 1); memcpy(Device->Device_Name,"TAPMLB01 ",10); Device->Offset_First_File = Next_Free - Data_Buffer; Device->File_Count = 2; /*-----------------------------------------------------------------*/ /* Build input data for the first media file for device TAPMLB01. */ /* Use the default sequence number, and volumes VOL11 and VOL12. */ /*-----------------------------------------------------------------*/ Media_File = (Qsr_TAPE0100_File_t*)Next_Free; Next_Free = (char*)(Media_File + 1); Media_File->Sequence_Number = 0; Media_File->Offset_First_Volume_Id = Next_Free - Data_Buffer; Media_File->Volume_Id_Count = 2; Media_File->Volume_Id_Length = 6; Media_File->Starting_Volume = 1; Data_Length = Media_File->Volume_Id_Count * Media_File->Volume_Id_Length; Volid = Next_Free; memcpy(Volid,"VOL11 VOL12 ",Data_Length); if (Data_Length % 4) /* Ensure that Next_Free */ Data_Length += (4 - (Data_Length % 4)); /* is incremented by a */ Next_Free += Data_Length; /* multiple of 4. */ Media_File->Offset_Next_File = Next_Free - Data_Buffer; /*------------------------------------------------------------------*/ /* Build input data for the second media file for device TAPMLB01. */ /* Use the default sequence number, and volumes VOL21 and VOL22. */ /*------------------------------------------------------------------*/ Media_File = (Qsr_TAPE0100_File_t*)Next_Free; Next_Free = (char*)(Media_File + 1); Media_File->Sequence_Number = 0; Media_File->Offset_First_Volume_Id = Next_Free - Data_Buffer; Media_File->Volume_Id_Count = 2; Media_File->Volume_Id_Length = 6; Media_File->Starting_Volume = 1; Data_Length = Media_File->Volume_Id_Count * Media_File->Volume_Id_Length; Volid = Next_Free; memcpy(Volid,"VOL21 VOL22 ",Data_Length); if (Data_Length % 4) /* Ensure that Next_Free */ Data_Length += (4 - (Data_Length % 4)); /* is incremented by a */ Next_Free += Data_Length; /* multiple of 4. */ /********************************************************************/ /* Create the media definition. */ /********************************************************************/ Data_Length = Next_Free - Data_Buffer; memset(Text,' ',sizeof(Text)); memcpy(Text,"Save BIGLIB",11); QsrCreateMediaDefinition( "SAVEBIGLIBQTEMP ", /* Media definition */ name, library */ Data_Buffer, /* Input data */ Data_Length, /* Length of data */ "TAPE0100", /* Format name */ "*USE ", /* Public authority */ Text, /* Text description */ 1, /* Replace if it exists */ &Err_Code); /* Error code */ /********************************************************************/ /* Save library BIGLIB using the media definition. */ /********************************************************************/ strcpy(Cmd_String, "SAVLIB LIB(BIGLIB) DEV(*MEDDFN) MEDDFN(QTEMP/SAVEBIGLIB)"); Cmd_Length = strlen(Cmd_String); QCMDEXC(Cmd_String,Cmd_Length); return 0; }