Previous Page Contents Page Next Page

1.4 Issuing a Verb

The major steps in issuing a Common Service Verb follow. Each step is illustrated by sample code pertaining to the CONVERT verb; for more information about this verb, see Common Service Verbs Reference.

  1. Create a structure variable from the VCB structure that applies to the verb to be issued.

         #include <acssvcc.h>
              .
              .
              .
         struct convert  conv_block;

         #include <wincsv.h>
              .
              .
              .
         struct convert  conv_block;

    The VCB structures are declared in the CSV header file /usr/include/sna/acssvcc.h(for Solaris) or sdk/wincsv.h (for Windows). One of these structures is named convert.

  2. Clear (set to zero) the variables within the structure.

         memset(&conv_block, 0, sizeof( conv_block ) );

    This step is important to ensure that the application can later be upgraded to work with future CSV versions (which can use fields that are reserved in the current version). It also helps in debugging and interpreting trace data.

  3. Assign values to the required VCB variables.

         conv_block.opcode = SV_CONVERT;
         conv_block.direction = SV_ASCII_TO_EBCDIC;
         conv_block.char_set = SV_AE;
         conv_block.len = sizeof(tpstart_name);
         conv_block.source = (unsigned char *) tpstart_name;
         conv_block.target = (unsigned char *) tpstart.tp_name;

    The fields SV_CONVERT, SV_ASCII_TO_EBCDIC, and SV_AE are symbolic constants representing integers. These constants are defined in the CSV header file.

    The character array tpstart_name contains an ASCII string to be converted to EBCDIC and placed in the character array tpstart.tp_name.

  4. Invoke the verb. The only parameter is a pointer to the structure containing the VCB for the verb.

         ACSSVC_C ((char *)&conv_block);

    For compatibility with other CSV implementations, the entry points ACSSVC_P or ACSSVC can be used instead of ACSSVC_C.

         WinCSV ( (long) ( (char far *) &conv_block ) );
    
    

    Use the values returned by the verb.

         if (conv_block.primary_rc == SV_OK)
         {
              /* other statements   */
                   .
                   .
                   .
         }

Previous Page Contents Page Top of Page Next page