Example in ILE C: Program for packaging a product

This example shows you the steps necessary to package your product like IBM's.

/********************************************************************/
/* Program Name:          SFTWPRDEX                                 */
/*                                                                  */
/* Program Language:      ILE C                                     */
/*                                                                  */
/* Description:           This example shows you the steps necessary*/
/*                        to package your product like IBM's.       */
/*                                                                  */
/* Header Files Included: <stdlib.h>                                */
/*                        <signal.h>                                */
/*                        <string.h>                                */
/*                        <stdio.h>                                 */
/*                        <qszcrtpd.h>                              */
/*                        <qszcrtpl.h>                              */
/*                        <qszpkgpo.h>                              */
/*                        <qlicobjd.h>                              */
/*                        <qusec.h>                                 */
/*                        <qliept.h>                                */
/*                                                                  */
/* APIs Used:             QSZCRTPD - Create Product Definition      */
/*                        QSZCRTPL - Create Product Load            */
/*                        QSZPKGPO - Package Product Option         */
/*                        QLICOBJD - Change Object Description      */
/********************************************************************/
 #include <stdlib.h>
 #include <signal.h>
 #include <string.h>
 #include <stdio.h>
 #include <qszcrtpd.h>
 #include <qszcrtpl.h>
 #include <qszpkgpo.h>
 #include <qlicobjd.h>
 #include <qusec.h>
 #include <qliept.h>

/********************************************************************/
/* Function:     Create_Prod_Def_Obj                                */
/* Description:  Create the product definition ABC0050 for product  */
/*               ABC.                                               */
/********************************************************************/
void Create_Prod_Def_Obj()
{
  Qsz_Prd_Inf_t prod_info;           /* Product information         */
  Qsz_Prd_Opt_t prod_opt_list;       /* Product option list         */
  Qsz_Lng_Lod_t prod_lang_load;      /* Product language load list  */
  Qus_EC_t error_code;               /* Error code parameter        */
  char text_desc[50];                /* Text description            */

  /******************************************************************/
  /* Fill in the product information.                               */
  /******************************************************************/
  memset(&prod_info,' ',sizeof(prod_info));
  memcpy(prod_info.PID,"0ABCABC",7);
  memcpy(prod_info.Rls_Lvl,"V3R1M0",6);
  memcpy(prod_info.Msg_File,"ABCMSG    ",10);
  memcpy(prod_info.Fst_Cpyrt,"*CURRENT  ",10);
  memcpy(prod_info.Cur_Cpyrt,"*CURRENT  ",10);
  memcpy(prod_info.Rls_Date,"941201",6);
  memcpy(prod_info.Alw_Mult_Rls,"*NO ",4);
  memcpy(prod_info.Reg_ID_Type,"*PHONE    ",10);
  memcpy(prod_info.Reg_ID_Val,"5072530927    ",14);
  /******************************************************************/
  /* Fill in the product option list.                               */
  /******************************************************************/
  memset(&prod_opt_list,' ',sizeof(prod_opt_list));
  memcpy(prod_opt_list.Opt,"0000",4);
  memcpy(prod_opt_list.Msg_ID,"ABC0001",7);
  memcpy(prod_opt_list.Alw_Dyn_Nam,"*NODYNNAM ",10);
  memcpy(prod_opt_list.Cod_Lod,"5001",4);
  /******************************************************************/
  /* Fill in the product language load list.                        */
  /******************************************************************/
  memset(&prod_lang_load,' ',sizeof(prod_lang_load));
  memcpy(prod_lang_load.Lng_Lod,"2924    ",8);
  memcpy(prod_lang_load.Opt,"0000",4);

  memset(text_desc,' ',50);
  memcpy(text_desc,"Product ABC",11);

  /******************************************************************/
  /* Initialize the error code to have the API send errors through  */
  /* the error code parameter.                                      */
  /******************************************************************/
  error_code.Bytes_Provided=sizeof(error_code);
  QSZCRTPD("ABC0050   ABC       ",   /* Product definition name     */
           &prod_info,               /* Product definition info     */
           &prod_opt_list,           /* Product option list         */
           1,                        /* Number of options           */
           &prod_lang_load,          /* Language load list          */
           1,                        /* Number languages            */
           text_desc,                /* Text description            */
           "*USE      ",             /* Public authority            */
           &error_code);             /* Error code                  */

  if (error_code.Bytes_Available > 0)
  {
     printf("Failed in QSZCRTPD API with error: %.7s",
             error_code.Exception_Id);
     exit(1);
  }
}

/********************************************************************/
/* Function:     Create_Prod_Load_Obj                               */
/* Description:  Create the product loads ABC0050 (MRM object) and  */
/*               ABC0029 (MRI object) for product ABC.              */
/********************************************************************/
void Create_Prod_Load_Obj()
{
  Qsz_Lod_Inf_t prod_load_info;      /* Product load information    */
  Qsz_Lib_Inf_t prin_lib_info;       /* Principal library info      */
  Qsz_Add_Lib_t add_libs;            /* Additional library list     */
  Qsz_Pre_Ext_t preop_expgm;         /* Preoperational exit program */
  Qsz_Flr_Lst_t folder_list;         /* Folder list                 */
  Qus_EC_t error_code;               /* Error code parameter        */
  char text_desc[50];                /* Text description            */


  /******************************************************************/
  /* Fill in the product load information.                          */
  /******************************************************************/
  memset(&prod_load_info,' ',sizeof(prod_load_info));
  memcpy(prod_load_info.PID,"0ABCABC",7);
  memcpy(prod_load_info.Rls_Lvl,"V3R1M0",6);
  memcpy(prod_load_info.Opt,"0000",4);
  memcpy(prod_load_info.Lod_Type,"*CODE     ",10);
  memcpy(prod_load_info.Lod_ID,"*CODEDFT",8);
  memcpy(prod_load_info.Reg_ID_Type,"*PRDDFN   ",10);
  memcpy(prod_load_info.Min_Tgt_Rls,"*CURRENT  ",10);

  /******************************************************************/
  /* Fill in the principal library information.  There are no       */
  /* additional libraries.                                          */
  /******************************************************************/
  memcpy(prin_lib_info.Dev_Lib,"ABC       ",10);
  memcpy(prin_lib_info.Prim_Lib,"ABC       ",10);
  memcpy(prin_lib_info.Post_Exit_Pgm,"ABCPGMMRM2",10);

  memset(&add_libs,' ',sizeof(add_libs));

  /******************************************************************/
  /* Fill in the preoperational exit program.                       */
  /******************************************************************/
  memcpy(preop_expgm.Pre_Ext_Pgm,"ABCPGMMRM1",10);
  memcpy(preop_expgm.Dev_Lib,"ABC       ",10);

  /******************************************************************/
  /* There are no folders.                                          */
  /******************************************************************/
  memset(&folder_list,' ',sizeof(folder_list));

  memset(text_desc,' ',50);
  memcpy(text_desc,"Product ABC",11);

  /******************************************************************/
  /* Initialize the error code to have the API send errors through  */
  /* the error code parameter.                                      */
  /******************************************************************/
  error_code.Bytes_Provided=sizeof(error_code);
  QSZCRTPL("ABC0050   ",             /* Product load name           */
           &prod_load_info,          /* Product load information    */
           "          ",             /* Secondary language lib name */
           &prin_lib_info,           /* Principal library           */
           &add_libs,                /* Additional libraries        */
           0,                        /* Number of additional libs   */
           &preop_expgm,             /* Preoperational exit program */
           1,                        /* Number of preop exit pgms   */
           &folder_list,             /* Folder list                 */
           0,                        /* Number of folders           */
           text_desc,                /* Text description            */
           "*USE      ",             /* Public authority            */
           &error_code);             /* Error code                  */

  if (error_code.Bytes_Available > 0)
  {
     printf("Failed in QSZCRTPL API with error: %.7s",
             error_code.Exception_Id);
     exit(1);
  }

  /******************************************************************/
  /* Fill in the product load information.                          */
  /******************************************************************/
  memcpy(prod_load_info.Lod_Type,"*LNG      ",10);
  memcpy(prod_load_info.Lod_ID,"2924    ",8);

  /******************************************************************/
  /* Fill in the principal library information.  There are no       */
  /* additional libraries.                                          */
  /******************************************************************/
  memcpy(prin_lib_info.Post_Exit_Pgm,"ABCPGMMRI2",10);

  /******************************************************************/
  /* Fill in the preoperational exit program.                       */
  /******************************************************************/
  memcpy(preop_expgm.Pre_Ext_Pgm,"ABCPGMMRI1",10);

  QSZCRTPL("ABC0029   ",             /* Product load name           */
           &prod_load_info,          /* Product load information    */
           "ABC2924   ",             /* Secondary language lib name */
           &prin_lib_info,           /* Principal library           */
           &add_libs,                /* Additional libraries        */
           0,                        /* Number of additional libs   */
           &preop_expgm,             /* Preoperational exit program */
           1,                        /* Number of preop exit pgms   */
           &folder_list,             /* Folder list                 */
           0,                        /* Number of folders           */
           text_desc,                /* Text description            */
           "*USE      ",             /* Public authority            */
           &error_code);             /* Error code                  */

  if (error_code.Bytes_Available > 0)
  {
     printf("Failed in QSZCRTPL API with error: %.7s",
             error_code.Exception_Id);
     exit(1);
  }

}

/********************************************************************/
/* Function:     Change_Obj_Descr                                   */
/* Description:  Change object descriptions for all objects         */
/*               that make up Product ABC.  Currently there are 15  */
/*               objects.                                           */
/********************************************************************/
void Change_Obj_Descr()
{
  typedef struct {
    char obj_name_lib[21];
    char obj_type[11];
    char prd_opt_id[5];
    char prd_opt_ld[5];
    char lp_id[4];
  } obj_info_t;

  typedef struct {
    int numkey;
    Qus_Vlen_Rec_3_t PID_rec;
    char PID[4];
    Qus_Vlen_Rec_3_t LID_rec;
    char LID[4];
    Qus_Vlen_Rec_3_t LP_rec;
    char LP[13];
  } change_obj_info_t;

  int i;
  obj_info_t obj_info[15] = {"ABCPGMMRM1ABC       ","*PGM      ",
                             "0000","5001","0ABCABCV3R1M0",
                             "ABCPGMMRM2ABC       ","*PGM      ",
                             "0000","5001","0ABCABCV3R1M0",
                             "ABCPGMMRI1ABC       ","*PGM      ",
                             "0000","2924","0ABCABCV3R1M0",
                             "ABCPGMMRI2ABC       ","*PGM      ",
                             "0000","2924","0ABCABCV3R1M0",
                             "ABCPGM    ABC       ","*PGM      ",
                             "0000","5001","0ABCABCV3R1M0",
                             "QCLSRC    ABC       ","*FILE     ",
                             "0000","2924","0ABCABCV3R1M0",
                             "ABCDSPF   ABC       ","*FILE     ",
                             "0000","2924","0ABCABCV3R1M0",
                             "ABCPF     ABC       ","*FILE     ",
                             "0000","2924","0ABCABCV3R1M0",
                             "ABCMSG    ABC       ","*MSGF     ",
                             "0000","2924","0ABCABCV3R1M0",
                             "ABC       ABC       ","*CMD      ",
                             "0000","2924","0ABCABCV3R1M0",
                             "ABCPNLGRP ABC       ","*PNLGRP   ",
                             "0000","2924","0ABCABCV3R1M0",
                             "ABC0050   ABC       ","*PRDDFN   ",
                             "0000","5001","0ABCABCV3R1M0",
                             "ABC0050   ABC       ","*PRDLOD   ",
                             "0000","5001","0ABCABCV3R1M0",
                             "ABC0029   ABC       ","*PRDLOD   ",
                             "0000","2924","0ABCABCV3R1M0",
                             "ABC       ABC       ","*LIB      ",
                             "0000","5001","0ABCABCV3R1M0"};
  change_obj_info_t cobji;           /* Change object information   */
  Qus_EC_t error_code;               /* Error code parameter        */
  char rtn_lib[10];                  /* Return library              */

  /******************************************************************/
  /* Fill in the changed object information.                        */
  /******************************************************************/
  cobji.numkey=3;
  cobji.PID_rec.Key=13;
  cobji.PID_rec.Length_Vlen_Record=4;
  cobji.LID_rec.Key=12;
  cobji.LID_rec.Length_Vlen_Record=4;
  cobji.LP_rec.Key=5;
  cobji.LP_rec.Length_Vlen_Record=13;

  /******************************************************************/
  /* Initialize the error code to have the API send errors through  */
  /* the error code parameter.                                      */
  /******************************************************************/
  error_code.Bytes_Provided=sizeof(error_code);

  for (i=0; i<15; i++)
  {
    memcpy(cobji.PID,obj_info[i].prd_opt_id,4);
    memcpy(cobji.LID,obj_info[i].prd_opt_ld,4);
    memcpy(cobji.LP,obj_info[i].lp_id,13);

    QLICOBJD(rtn_lib,                  /* Return library            */
             obj_info[i].obj_name_lib, /* Object name               */
             obj_info[i].obj_type,     /* Object type               */
             &cobji,                   /* Changed object information*/
             &error_code);             /* Error code                */

    if (error_code.Bytes_Available > 0)
    {
       printf("Failed in QLICOBJD API with error: %.7s",
               error_code.Exception_Id);
       exit(1);
    }
  }
}

/********************************************************************/
/* Function:     Package_Prod                                       */
/* Description:  Package Product ABC so that all the SAVLICPGM,     */
/*               RSTLICPGM and DLTLICPGM commands work with the     */
/*               product.                                           */
/********************************************************************/
void Package_Prod()
{
  Qsz_Prd_Opt_Inf_t prod_opt_info;   /* Product option information  */
  Qus_EC_t error_code;               /* Error code parameter        */



  /******************************************************************/
  /* Fill in the product option information.                        */
  /******************************************************************/
  memset(&prod_opt_info,' ',sizeof(prod_opt_info));
  memcpy(prod_opt_info.Opt,"0000",4);
  memcpy(prod_opt_info.PID,"0ABCABC",7);
  memcpy(prod_opt_info.Rls_Lvl,"V3R1M0",6);
  memcpy(prod_opt_info.Lod_ID,"*ALL    ",8);

  /******************************************************************/
  /* Initialize the error code to have the API send errors through  */
  /* the error code parameter.                                      */
  /******************************************************************/
  error_code.Bytes_Provided=sizeof(error_code);
  QSZPKGPO(&prod_opt_info,           /* Product option information  */
           "*YES",                   /* Repackage                   */
           "*NO  ",                  /* Allow object change         */
           &error_code);             /* Error code                  */

  if (error_code.Bytes_Available > 0)
  {
     printf("Failed in QSZPKGPO API with error: %.7s",
             error_code.Exception_Id);
     exit(1);
  }
}

/********************************************************************/
/* Start of main procedure                                          */
/********************************************************************/

void main()
{

  /******************************************************************/
  /* Create Product Definition Object                               */
  /******************************************************************/
  Create_Prod_Def_Obj();

  /******************************************************************/
  /* Create Product Load Objects                                    */
  /******************************************************************/
  Create_Prod_Load_Obj();

  /******************************************************************/
  /* Change Object Description                                      */
  /******************************************************************/
  Change_Obj_Descr();

  /******************************************************************/
  /* Package Product ABC                                            */
  /******************************************************************/
  Package_Prod();

}