home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / LUA.ZIP / LUA / LUA_C / LUASAMPC.C < prev    next >
Text File  |  1991-09-10  |  26KB  |  526 lines

  1. /****************************************************************************/
  2. /*                                                                          */
  3. /*   MODULE NAME      : LUASAMP.C                                           */
  4. /*                                                                          */
  5. /*   DESCRIPTIVE NAME : LUA C SAMPLE PROGRAM FOR IBM EXTENDED SERVICES      */
  6. /*                      FOR OS/2                                            */
  7. /*                                                                          */
  8. /*   COPYRIGHT        : (C) COPYRIGHT IBM CORP. 1989, 1990, 1991            */
  9. /*                      LICENSED MATERIAL - PROGRAM PROPERTY OF IBM         */
  10. /*                      ALL RIGHTS RESERVED                                 */
  11. /*                                                                          */
  12. /*   FUNCTION         : This program                                        */
  13. /*                      - Issues an SLI_OPEN to establish an LU_LU session. */
  14. /*                      - Issues an SLI_SEND to transmit data to the host.  */
  15. /*                      - Issues an SLI_RECEIVE to get data from the host.  */
  16. /*                      - Issues an SLI_SEND to transmit a response.        */
  17. /*                      - Issues an SLI_CLOSE to end the LU_LU session.     */
  18. /*                                                                          */
  19. /*   GENERAL SERVICE                                                        */
  20. /*     VERBS USED     : CONVERT - Translates data between ASCII and EBCDIC. */
  21. /*                                                                          */
  22. /*   MODULE TYPE      : C (Compiles with large memory model)                */
  23. /*                                                                          */
  24. /*                                                                          */
  25. /****************************************************************************/
  26.  
  27. /****************************************************************************/
  28. /*          Standard include files from 'C'                                 */
  29. /****************************************************************************/
  30. #include <STDIO.H>   /* declarations and definitions for stream I/O routines*/
  31. #include <STDDEF.H>  /* definitions of common pointers, variables, & types  */
  32. #include <STRING.H>  /* string manipulation function declarations           */
  33. #include <DOS.H>     /* DOS interface declarations and definitions          */
  34.  
  35. /****************************************************************************/
  36. /*          Include file from OS/2 Dev. Tkt.                                */
  37. /****************************************************************************/
  38. #include <DOSCALLS.H>           /* DOS API functions                        */
  39.  
  40. /****************************************************************************/
  41. /*               Include files from OS/2 Comms Mgr                          */
  42. /****************************************************************************/
  43. #include "LUA_C.H"              /* LUA defines and struct include file      */
  44. #include "ACSSVCC.H"            /* Common Srvs defines and struct incl. file*/
  45.  
  46. /****************************************************************************/
  47. /*                       Definitions                                        */
  48. /****************************************************************************/
  49.  
  50. /* ClrLuaVerb() is used to set the lua verb record to 0.                     */
  51. #define ClrLuaVerb() memset(&LuaVerb,(unsigned char)'\0',sizeof(LUA_VERB_RECORD))
  52.  
  53. #define byte  unsigned char      /* used to allow ease of declarations of   */
  54. #define word  unsigned int       /*        other variables.                 */
  55.  
  56. /****************************************************************************/
  57. /*                  Externals    Declarations                               */
  58. /****************************************************************************/
  59. extern far pascal SLI (LUA_VERB_RECORD far *);
  60.  
  61. /****************************************************************************/
  62. /*                Function Calls definitions                                */
  63. /****************************************************************************/
  64. unsigned  pascal  Sli_Open();                 /* Sends open session request */
  65. unsigned  pascal  Sli_Send_Data();            /* Sends data to server       */
  66. unsigned  pascal  Sli_Receive();              /* Receives response from host*/
  67. unsigned  pascal  Sli_Send_Response();        /* Sends acknowledgement      */
  68. unsigned  pascal  Sli_Close(unsigned char);   /* Sends close session request*/
  69.  
  70. /* Error routines                                                           */
  71. void      pascal  error1(unsigned short,unsigned long);
  72. void      pascal  error2(unsigned short,unsigned long,unsigned int);
  73.  
  74. /* Conversion routines                                                      */
  75. unsigned  pascal  ascii_ebcdic(unsigned char far *,unsigned);
  76. unsigned  pascal  ebcdic_ascii(unsigned char far *,unsigned);
  77.  
  78. /*****************************************************************************/
  79. /* Data structures and pointers for LUA SLI interface and Common Svcs Inter.*/
  80. /*****************************************************************************/
  81. LUA_VERB_RECORD      LuaVerb;                       /* SLI API Verb Record   */
  82. LUA_VERB_RECORD far *LuaVerbPtr = &LuaVerb;
  83.  
  84. struct convert    ConvertVerb;                      /* Conversion structure  */
  85.  
  86. struct ru_sli_open {                                /* INITSELF Command      */
  87.                      byte iself_rq_01_hdr[3];       /* Structure             */
  88.                      byte iself_rq_01_f0;
  89.                      byte iself_rq_01_mode[8];
  90.                      byte iself_rq_01_ty;
  91.                      byte iself_rq_01_n_l;
  92.                      byte iself_rq_01_plu_n[8];
  93.                      byte iself_rq_01_rid_l;
  94.                      byte iself_rq_01_pw_l;
  95.                      byte iself_rq_01_ud_l;
  96.  
  97.                    } InitSelfRU = {
  98.                                  { 0x01,0x06,0x81 },  /* Initializes INITSELF*/
  99.                                  0x00,
  100.                                  {'L','U','A','7','6','8','R','U'},
  101.                                  0xF3,
  102.                                  0x08,
  103.                                  {'V','T','A','M','P','G','M',' '},
  104.                                  0x00,
  105.                                  0x00,
  106.                                  0x00
  107.                                };
  108.  
  109. unsigned char *TestData    = "TEST#SENDING#DATA#TO#HOST";
  110. unsigned char DataBuffer[265];                /* Receive Data Buffer         */
  111. unsigned long UserRamSem   = 0x00000000;      /* Posting semaphore           */
  112. unsigned long LU_SessionID = 0x00000000;      /* LU_LU Session ID            */
  113. unsigned char *LU_Name     = "LUA1    ";      /* it must be up to 8 byte     */
  114. char     SavedSeqNum[2]    = { 0x00, 0x00};   /* Used to save sequence number*/
  115.  
  116.  
  117. /****************************************************************************/
  118. /****************************************************************************/
  119. /* Main function      LUA Sample conversation code                          */
  120. /****************************************************************************/
  121.  
  122. main()
  123. {
  124.    unsigned rc = 0;                /* Return code */
  125.  
  126.    printf("\nOpening communication with SLI interface....");
  127.    rc = Sli_Open();
  128.    if (rc == LUA_OK)
  129.      {
  130.       printf("\nSLI interface opened and Init_self sent to the host.");
  131.       rc = Sli_Send_Data();
  132.       if (rc == LUA_OK)
  133.         {
  134.          printf("\nTest data sent to host.  Waiting for host data.");
  135.          rc = Sli_Receive();
  136.          if (rc == LUA_OK)
  137.            {
  138.             printf("\nHost data received. Responding to host.");
  139.             rc = Sli_Send_Response();
  140.             if (rc == LUA_OK)
  141.               {
  142.                printf("\nResponse sent. Preparing to close sesssion.");
  143.                rc = Sli_Close(0);
  144.               }                     /* End if (Sli_Send_Response rc==LUA_OK) */
  145.            }                        /* End if (Sli_Receive  rc==LUA_OK)      */
  146.         }                           /* End if (Sli_Send_Data rc==LUA_OK)     */
  147.       if ((rc != LUA_OK ) && (rc != LUA_SESSION_FAILURE))
  148.         {
  149.          rc = Sli_Close(1);         /* Close communication in ab_end         */
  150.          printf("\nQuit from LUA conversation due to an error. Ab-ended.\n");
  151.         }
  152.       else if (rc != LUA_SESSION_FAILURE)
  153.              {
  154.               printf("\nSLI interface closed with no errors.");
  155.              }
  156.            else
  157.              {
  158.               printf("\nThe LU_LU session has failed due to an error.");
  159.              }
  160.      }                              /* End if (Sli_Open rc==LUA_OK)          */
  161.      else
  162.        {
  163.          printf("\nQuit from LUA conversation due to an error. Ab-ended\n");
  164.        }
  165. }  /* end main() */
  166.  
  167.  
  168. /****************************************************************************/
  169. /****************************************************************************/
  170. /* Function : SLI_OPEN                                                      */
  171. /* Purpose  : Open a Session with the host using the SLI_OPEN verb and an   */
  172. /*            INITSELF command.                                             */
  173. /****************************************************************************/
  174. unsigned pascal  Sli_Open()
  175. {
  176.  unsigned rc;                                       /* return code          */
  177.  ClrLuaVerb();                                      /* set record to 0      */
  178.  
  179.  /******************************************************************/
  180.  /* Set the required fields for SLI_OPEN: verb, verb length,       */
  181.  /*     opcode, luname, posthandle, and init type.                 */
  182.  /* Set the data pointer and data length to reflect the INITSELF   */
  183.  /*     command to be sent as part of the SLI_OPEN.                */
  184.  /******************************************************************/
  185.  LuaVerb.common.lua_verb = LUA_VERB_SLI;
  186.  LuaVerb.common.lua_verb_length = sizeof(struct LUA_COMMON) + 4;
  187.  LuaVerb.common.lua_opcode = LUA_OPCODE_SLI_OPEN;
  188.  memcpy(LuaVerb.common.lua_luname,LU_Name,strlen(LU_Name));
  189.  LuaVerb.common.lua_data_length = sizeof(InitSelfRU);
  190.  LuaVerb.common.lua_data_ptr = (char far *) &InitSelfRU;
  191.  LuaVerb.common.lua_post_handle = (unsigned long) &UserRamSem;
  192.  LuaVerb.specific.open.lua_init_type = LUA_INIT_TYPE_SEC_IS;
  193.  
  194.  /* Convert the InitSelfRU PluName to EBCDIC */
  195.  rc = ascii_ebcdic(InitSelfRU.iself_rq_01_plu_n,
  196.                    sizeof(InitSelfRU.iself_rq_01_plu_n) );
  197.  /* If conversion ok */
  198.  if (rc == SV_OK)
  199.   {    /* then convert the InitSelfRU ModeName */
  200.     rc = ascii_ebcdic(InitSelfRU.iself_rq_01_mode,
  201.                       sizeof(InitSelfRU.iself_rq_01_mode) );
  202.  
  203.    /* If conversion ok */
  204.     if (rc == SV_OK)
  205.      {
  206.       /**********************************************************/
  207.       /* Call the SLI API.  Check for completion of call.       */
  208.       /* If call is in progress, wait for semaphore to post     */
  209.       /* completion.  If not successfully completed, call the   */
  210.       /* error routine to display an error message.  Else save  */
  211.       /* Session ID to use in subsequent verbs.                 */
  212.       /**********************************************************/
  213.        SLI(LuaVerbPtr);
  214.  
  215.        if (LuaVerb.common.lua_prim_rc == LUA_IN_PROGRESS)
  216.          DOSSEMWAIT((unsigned long) &UserRamSem, (long) -1);
  217.  
  218.        if (LuaVerb.common.lua_prim_rc != LUA_OK)
  219.          error2(LuaVerb.common.lua_prim_rc,LuaVerb.common.lua_sec_rc,
  220.                 LuaVerb.common.lua_opcode);
  221.        else
  222.          LU_SessionID = LuaVerb.common.lua_sid;
  223.  
  224.         rc = LuaVerb.common.lua_prim_rc;
  225.  
  226.      } /* end if */
  227.   } /* end if */
  228.  
  229.   return(rc);                                 /* Send return code to main */
  230. } /* End Sli_Open */
  231.  
  232.  
  233. /****************************************************************************/
  234. /****************************************************************************/
  235. /* Function : SLI_SEND                                                      */
  236. /* Purpose  : Send data to the host on LU Normal flow.                      */
  237. /****************************************************************************/
  238. unsigned pascal  Sli_Send_Data()
  239. {
  240.  unsigned rc;                                       /* return code          */
  241.  ClrLuaVerb();                                      /* set record to 0      */
  242.  
  243.  /******************************************************************/
  244.  /* Set the required fields for SLI_SEND request: verb, verb       */
  245.  /*     length, opcode, sid, data pointer, data length,            */
  246.  /*     posthandle, message type, certain rh bits.                 */
  247.  /******************************************************************/
  248.  LuaVerb.common.lua_verb = LUA_VERB_SLI;
  249.  LuaVerb.common.lua_verb_length = sizeof(struct LUA_COMMON) + 2;
  250.  LuaVerb.common.lua_opcode = LUA_OPCODE_SLI_SEND;
  251.  LuaVerb.common.lua_sid = LU_SessionID;
  252.  LuaVerb.common.lua_data_length = strlen(TestData);
  253.  LuaVerb.common.lua_data_ptr = (char far *) TestData;
  254.  LuaVerb.common.lua_post_handle = (unsigned long) &UserRamSem;
  255.  LuaVerb.common.lua_rh.ri   = 1;
  256.  LuaVerb.common.lua_rh.dr1i = 1;
  257.  LuaVerb.common.lua_rh.bbi  = 1;
  258.  LuaVerb.common.lua_rh.cdi  = 1;
  259.  LuaVerb.common.lua_message_type = LUA_MESSAGE_TYPE_LU_DATA;
  260.  
  261.  /* Convert the Data to EBCDIC */
  262.  rc = ascii_ebcdic(LuaVerb.common.lua_data_ptr,
  263.                    LuaVerb.common.lua_data_length) ;
  264.  
  265.  /* If conversion ok */
  266.  if (rc == SV_OK)
  267.  {
  268.    /**********************************************************/
  269.    /* Call the SLI API.  Check for completion of call.       */
  270.    /* If call is in progress, wait for semaphore to post     */
  271.    /* completion.  If not successfully completed, call the   */
  272.    /* error routine to display an error message.             */
  273.    /**********************************************************/
  274.    SLI(LuaVerbPtr);
  275.  
  276.    if (LuaVerb.common.lua_prim_rc == LUA_IN_PROGRESS)
  277.      DOSSEMWAIT((unsigned long) &UserRamSem, (long) -1);
  278.  
  279.    if (LuaVerb.common.lua_prim_rc != LUA_OK)
  280.      error2(LuaVerb.common.lua_prim_rc,LuaVerb.common.lua_sec_rc,
  281.             LuaVerb.common.lua_opcode);
  282.  
  283.    rc = LuaVerb.common.lua_prim_rc;
  284.  }
  285.  return(rc);                                   /* send return code to main */
  286.  
  287. } /* End Sli_Send_Data */
  288.  
  289.  
  290. /****************************************************************************/
  291. /****************************************************************************/
  292. /* Function : SLI_RECEIVE                                                   */
  293. /* Purpose  : Receive a message from the host on LU normal flow.            */
  294. /****************************************************************************/
  295. unsigned pascal  Sli_Receive()
  296. {
  297.  unsigned rc;                                       /* return code          */
  298.  ClrLuaVerb();                                      /* set record to 0      */
  299.  
  300.  /******************************************************************/
  301.  /* Set the required fields for SLI_RECEIVE: verb, verb length,    */
  302.  /*     opcode, sid, data pointer, max length, posthandle,         */
  303.  /*     and a flag1 flow bit.                                      */
  304.  /******************************************************************/
  305.  LuaVerb.common.lua_verb = LUA_VERB_SLI;
  306.  LuaVerb.common.lua_verb_length = sizeof(struct LUA_COMMON);
  307.  LuaVerb.common.lua_opcode = LUA_OPCODE_SLI_RECEIVE;
  308.  LuaVerb.common.lua_sid = LU_SessionID;
  309.  LuaVerb.common.lua_max_length   = sizeof(DataBuffer) ;
  310.  LuaVerb.common.lua_data_ptr     = (char far *) DataBuffer;
  311.  LuaVerb.common.lua_post_handle  = (unsigned long) &UserRamSem;
  312.  LuaVerb.common.lua_flag1.lu_norm = 1;
  313.  
  314.  /**********************************************************/
  315.  /* Call the SLI API.  Check for completion of call.       */
  316.  /* If call is in progress, wait for semaphore to post     */
  317.  /* completion.  If not successfully completed, call the   */
  318.  /* error routine to display an error message.  Otherwise  */
  319.  /* translate the data and save the sequence number for    */
  320.  /* the response.                                          */
  321.  /**********************************************************/
  322.  SLI(LuaVerbPtr);
  323.  
  324.  if (LuaVerb.common.lua_prim_rc == LUA_IN_PROGRESS)
  325.    DOSSEMWAIT((unsigned long) &UserRamSem, (long) -1);
  326.  
  327.  if (LuaVerb.common.lua_prim_rc != LUA_OK)
  328.   {
  329.    error2(LuaVerb.common.lua_prim_rc,LuaVerb.common.lua_sec_rc,
  330.           LuaVerb.common.lua_opcode);
  331.    rc = LuaVerb.common.lua_prim_rc;
  332.   }
  333.  else
  334.   {
  335.        rc = ebcdic_ascii(LuaVerb.common.lua_data_ptr,
  336.                          LuaVerb.common.lua_data_length);
  337.        SavedSeqNum[0] = LuaVerb.common.lua_th.snf[0];
  338.        SavedSeqNum[1] = LuaVerb.common.lua_th.snf[1];
  339.   }
  340.  
  341.  return(rc);                                    /* send return code to main */
  342.  
  343. } /* End Sli_Receive */
  344.  
  345.  
  346. /****************************************************************************/
  347. /****************************************************************************/
  348. /* Function : SLI_SEND_RESPONSE                                             */
  349. /* Purpose  : Send a response to LU Normal data to the host.                */
  350. /****************************************************************************/
  351. unsigned pascal  Sli_Send_Response()
  352. {
  353.  unsigned rc;                                       /* return code          */
  354.  ClrLuaVerb();                                      /* set record to 0      */
  355.  
  356.  /******************************************************************/
  357.  /* Set the required fields for SLI_SEND response: verb, verb      */
  358.  /*     length, opcode, sid, data pointer, data length, th snf     */
  359.  /*     posthandle, message type, certain rh bits and a flag1 flow.*/
  360.  /******************************************************************/
  361.  LuaVerb.common.lua_verb = LUA_VERB_SLI;
  362.  LuaVerb.common.lua_verb_length = sizeof(struct LUA_COMMON) + 2;
  363.  LuaVerb.common.lua_opcode = LUA_OPCODE_SLI_SEND;
  364.  LuaVerb.common.lua_sid = LU_SessionID;
  365.  LuaVerb.common.lua_post_handle  = (unsigned long) &UserRamSem;
  366.  LuaVerb.common.lua_th.snf[0] = SavedSeqNum[0];
  367.  LuaVerb.common.lua_th.snf[1] = SavedSeqNum[1];
  368.  LuaVerb.common.lua_rh.dr1i = 1;
  369.  LuaVerb.common.lua_flag1.lu_norm = 1;
  370.  LuaVerb.common.lua_message_type = LUA_MESSAGE_TYPE_RSP;
  371.  
  372.  /**********************************************************/
  373.  /* Call SLI API.  Check for completion of call.           */
  374.  /* If call is in progress, wait for semaphore to post     */
  375.  /* completion.  If not successfully completed, call for   */
  376.  /* error routine to be performed.                         */
  377.  /**********************************************************/
  378.  SLI(LuaVerbPtr);
  379.  
  380.  if (LuaVerb.common.lua_prim_rc == LUA_IN_PROGRESS)
  381.    DOSSEMWAIT((unsigned long) &UserRamSem, (long) -1);
  382.  
  383.  if (LuaVerb.common.lua_prim_rc != LUA_OK)
  384.      error2(LuaVerb.common.lua_prim_rc,LuaVerb.common.lua_sec_rc,
  385.             LuaVerb.common.lua_opcode);
  386.  
  387.  rc = LuaVerb.common.lua_prim_rc;
  388.  
  389.  return(rc);                                    /* send return code to main */
  390.  
  391. } /* End Sli_Send_Response */
  392.  
  393.  
  394. /****************************************************************************/
  395. /****************************************************************************/
  396. /* Function : SLI_CLOSE                                                     */
  397. /* Purpose  : Issue an SLI_CLOSE to end the session.                        */
  398. /****************************************************************************/
  399. unsigned pascal Sli_Close(unsigned char CloseType)
  400. {
  401.  unsigned rc;                                       /* return code          */
  402.  ClrLuaVerb();                                      /* set record to 0      */
  403.  
  404.  /******************************************************************/
  405.  /* Set the required fields for SLI_CLOSE: verb, verb length       */
  406.  /*     opcode, sid, posthandle, and flag1 close abend.            */
  407.  /******************************************************************/
  408.  LuaVerb.common.lua_verb = LUA_VERB_SLI;
  409.  LuaVerb.common.lua_verb_length = sizeof(struct LUA_COMMON);
  410.  LuaVerb.common.lua_opcode = LUA_OPCODE_SLI_CLOSE;
  411.  LuaVerb.common.lua_sid = LU_SessionID;
  412.  LuaVerb.common.lua_post_handle = (unsigned long) &UserRamSem;
  413.  LuaVerb.common.lua_flag1.close_abend = CloseType;
  414.  
  415.  /**********************************************************/
  416.  /* Call the SLI API.  Check for completion of call.       */
  417.  /* If call is in progress, wait for semaphore to post     */
  418.  /* completion.  If not successfully completed, call the   */
  419.  /* error routine to display an error message.             */
  420.  /**********************************************************/
  421.  SLI(LuaVerbPtr);
  422.  
  423.  if (LuaVerb.common.lua_prim_rc == LUA_IN_PROGRESS)
  424.    DOSSEMWAIT((unsigned long) &UserRamSem, (long) -1);
  425.  
  426.  if (LuaVerb.common.lua_prim_rc != LUA_OK)
  427.      error2(LuaVerb.common.lua_prim_rc,LuaVerb.common.lua_sec_rc,
  428.             LuaVerb.common.lua_opcode);
  429.  
  430.  rc = LuaVerb.common.lua_prim_rc;
  431.  
  432.  return(rc);                                     /* send return code to main */
  433.  
  434. } /* End Sli_Close */
  435.  
  436.  
  437. /****************************************************************************/
  438. /****************************************************************************/
  439. /* Function : ASCII_EBCDIC                                                  */
  440. /* Purpose  : Convert selected data from ASCII to EBCDIC representation.    */
  441. /****************************************************************************/
  442. unsigned pascal  ascii_ebcdic(unsigned char far *ptr, unsigned len)
  443. {
  444.  /***************************************************************/
  445.  /* Set opcode for conversion, direction for ASCII to EBCDIC.   */
  446.  /* Select character set.  Provide length of data to be         */
  447.  /* converted, as well as source and target addresses.          */
  448.  /***************************************************************/
  449.  ConvertVerb.opcode = SV_CONVERT;
  450.  ConvertVerb.direction = SV_ASCII_TO_EBCDIC;
  451.  ConvertVerb.char_set = SV_AE;
  452.  ConvertVerb.len = len;
  453.  ConvertVerb.source = ptr;
  454.  ConvertVerb.target = ptr;
  455.  
  456.  /****************************************************************/
  457.  /* Send convert request to host and check return code for error */
  458.  /****************************************************************/
  459.  ACSSVC  ((long) &ConvertVerb);
  460.  
  461.  if (ConvertVerb.primary_rc != SV_OK)
  462.    error1(ConvertVerb.primary_rc,ConvertVerb.secondary_rc);
  463.  
  464.  return(ConvertVerb.primary_rc);
  465. } /* end ascii_ebcdic */
  466.  
  467.  
  468. /****************************************************************************/
  469. /****************************************************************************/
  470. /* Function : EBCDIC_ASCII                                                  */
  471. /* Purpose  : Convert selected data from EBCDIC to ASCII representation.    */
  472. /****************************************************************************/
  473. unsigned pascal  ebcdic_ascii(unsigned char far *ptr, unsigned len)
  474. {
  475.  /***************************************************************/
  476.  /* Set opcode for conversion, direction for EBCDIC to ASCII.   */
  477.  /* Select character set.  Provide length of data to be         */
  478.  /* converted, as well as source and target addresses.          */
  479.  /***************************************************************/
  480.  ConvertVerb.opcode = SV_CONVERT;
  481.  ConvertVerb.direction = SV_EBCDIC_TO_ASCII;
  482.  ConvertVerb.char_set = SV_AE;
  483.  ConvertVerb.len = len;
  484.  ConvertVerb.source = ptr;
  485.  ConvertVerb.target = ptr;
  486.  
  487.  /****************************************************************/
  488.  /* Send convert request to host and check return code for error */
  489.  /****************************************************************/
  490.  ACSSVC  ((long) &ConvertVerb);
  491.  
  492.  if (ConvertVerb.primary_rc != SV_OK)
  493.    error1(ConvertVerb.primary_rc,ConvertVerb.secondary_rc);
  494.  
  495.  return(ConvertVerb.primary_rc);
  496. } /* end ebcdic_ascii */
  497.  
  498.  
  499. /****************************************************************************/
  500. /****************************************************************************/
  501. /* Procedure : ERROR1                                                       */
  502. /* Purpose   : Display return codes for conversion errors.                  */
  503. /****************************************************************************/
  504. void pascal  error1(unsigned short primary_rc, unsigned long secondary_rc)
  505. {
  506.  printf("\nAn error has occurred during the conversion process.");
  507.  printf("\nThe primary return code is: %x .",primary_rc);
  508.  printf("\nThe secondary return code is: %lx .",secondary_rc);
  509. } /* End Error1 */
  510.  
  511.  
  512. /****************************************************************************/
  513. /****************************************************************************/
  514. /* Procedure : ERROR2                                                       */
  515. /* Purpose   : Display return codes for unsuccessful function calls.        */
  516. /****************************************************************************/
  517. void pascal  error2(unsigned short primary_rc,unsigned long  secondary_rc,
  518.                     unsigned int verb)
  519. {
  520.  printf("\nAn error has occurred with SLI interface. Verb opcode: %x",
  521.          verb);
  522.  printf("\nThe primary return code is: %x .",primary_rc);
  523.  printf("\nThe secondary return code is: %lx .",secondary_rc);
  524. } /* End Error2 */
  525.  
  526.