NWSMTSGetTargetSelectionTypeStr

Returns the SMS-defined selection type strings.

Syntax

  #include <smsutapi.h> 
  #include <smstsapi.h> 
   
  CCODE NWSMTSGetTargetSelectionTypeStr (
     UINT32   connection, 
     UINT8    typeNumber, 
     STRING   selectionTypeString1, 
     STRING   selectionTypeString2);
  

Parameters

connection

(IN) Specifies the connection information returned by NWSMTSConnectToTargetService or NWSMTSConnectToTargetServicEx.

typeNumber

(IN) Specifies the selection type number (1-31) to query the TSA about.

selectionTypeString1

(OUT) Receives the string that describes that describes the selection type.

selectionTypeString2

(OUT) Receives the string that describes the selection type if bit zero and typeNumber of selectionType are set.

Return Values

See Section 9.3, Target Service Return Values for more information.

The following table lists the return values associated with the function.

0x00000000

Successful

0xFFFDFFB9

NWSMTS_UNSUPPORTED_FUNCTION

0xFFFDFFBE

NWSMTS_SELECTION_TYPE_NOT_USED

0xFFFDFFD9

NWSMTS_INVALID_SELECTION_TYPE

0xFFFDFFE7

NWSMTS_INVALID_CONNECTION_HANDL

0xFFFEFFFE

NWSMDR_INVALID_PARAMETER

0xFFFEFFFF

NWSMDR_INVALID_CONNECTION

Remarks

Before NWSMTSGetTargetSelectionTypeStr is called, the engine must be connected to the TSA and Target Service.

One or both of the strings that NWSMTSGetTargetSelectionTypeStr returns can be NULL strings, depending on the options supported by the TSA. For a list of selection types, see NWSM_SELECTION_LIST. typeNumber is used as an index to a string table and must be converted to a bit value before being used in the selection list.

If only one selection option of the selection option pair is supported, NWSMTSGetTargetSelectionTypeStr returns successfully. If both selection types of the selection pair are not supported, NWSMTSGetTargetSelectionTypeStr returns NWSMTS_SELECTION_TYPE_NOT_USED.

If there is no option for bit zero and typeNumber of selectionType being set in selectionTypeString2, a NULL string is returned. The engine must allocate NWSM_MAX_STRING_LEN bytes for the buffer.

You must call NWSMTSGetTargetSelectionTypeStr repeatedly until all selection option strings are returned.

The first pair of returned strings represents the combination of bits 0 and 1. The second pair of returned strings represents the combination of bits 0 and 2, etc. This information is important so the proper bits can be set when the user chooses a selection type from the selection option list.

See Also

NWSMTSGetOpenModeOptionString

Example

  /* This example retrieves the selection types from the TSA, queries the user for the selection types to use, 
  and sends the user selected selection types back to the TSA. */ 
   
  #include <smsutapi.h> 
  #include <smstsapi.h> 
   
  typedef struct TSA_SELECTION_TYPE 
  { 
     UINT32 selectionType1; 
     UINT32 selectionType2; 
     STRING selectionStringType1; 
     STRING selectionStringType2; 
     struct TSA_SELECTION_TYPE *next; 
  } TSA_SELECTION_TYPE; 
   
  typedef struct USER_SELECTION 
  { 
     UINT32 selectionType; 
     STRING resourceName; 
     struct USER_SELECTION *next; 
  } USER_SELECTION; 
   
  UINT8 typeNumber; 
  unsigned char s1[NWSM_MAX_STRING_LEN], s2[NWSM_MAX_STRING_LEN]; 
  STRING selectionTypeString1 = s1, selectionTypeString2 = s2; 
  TSA_SELECTION_TYPE *selectionTypeList = NULL, *last = NULL, *tmp; 
  USER_SELECTION *userSelections, *nextUserSelection; 
  NWSM_SELECTION_LIST *selectionList; 
  UINT32 HUGE nameHandle; 
  UINT32 selectionType; 
  CCODE ccode; 
   
  /* Get the target selection type strings. */ 
  for(typeNumber = 1, selectionType = 2; typeNumber < 32; typeNumber++, 
        selectionType <<= 1) 
  { 
     if((ccode = NWSMTSGetTargetSelectionTypeStr(connection, typeNumber, 
           selectionTypeString1, selectionTypeString2)) ==  
           NWSMTS_SELECTION_TYPE_NOT_USED) 
        continue; 
   
     if(ccode) 
        break; 
   
     /* Append selection type to selection type list. */ 
     TMp = (TSA_SELECTION_TYPE *)calloc(1, sizeof(TSA_SELECTION_TYPE)); 
     TMp->selectionType1 = selectionType; 
     TMp->selectionType2 = selectionType + 1; 
     TMp->selectionStringType1 = selectionTypeString1; 
     TMp->selectionStringType2 = selectionTypeString2; 
   
     if (last) 
     { 
        last->next = TMp; 
        last = TMp; 
     } 
     else 
        selectionTypeList = last = TMp; 
  } /* /End for */ 
   
  /* Build a display from the information retrieved from NWSMTSGetTargetSelectionTypeStr, and NWSMTSListTSResources or
  NWSMTSScanTargetServiceResource. 
  The last two functions build a list of resources that can be used with each selection type. 
  See "Data Set Selection Options" and "Using Resources with Selection Options." 
  Also see NWSMTSListTSResources or example code. */ 
   
  /* Using the display, get the user's selection (put each selection type and resource name into a list 
  using USER_SELECTION) userSelections points to this list. */ 
   
  /* Build the selection list to pass to the TSA. For defaultNameSpaceType, 
  reverseOrder, firstSeparator, and secondSeparator see example code of NWSMTSListTSResources */ 
   
  selectionList = NULL; 
  NWSMPutFirstName(&selectionList, defaultNameSpaceType, 
        userSelections->selectionType, reverseOrder, firstSeparator, 
        secondSeparator, userSelections->resourceName, &nameHandle); 
   
  for (nextUserSelection = userSelections; nextUserSelection; 
        nextUserSelection = nextUserSelection->next) 
  { 
     NWSMPutNextName(&selectionList, &nameHandle, defaultNameSpaceType, 
         nextUserSelection->selectionType, reverseOrder, firstSeparator, 
        secondSeparator, nextUserSelection->resourceName); 
  } 
   
  NWSMCloseName(&nameHandle); 
   
  /* Get open modes. */ 
  
  

This is a simplified example of retrieving strings from the TSA.

  /* typeNumber is initialized to 1 to indicate to start from the first pair of selection strings. 
  It is incremented from 0 through 31 to get all the strings. selectionType contains the bit mask for the first option 
  of the selection pair. 
  One is added to this bit mask to get the bit mask for the second option of the selection type pair. 
  selectionType is initialized to 0x2 because the first selection type starts at bit 1 of the selection bit map. */ 
   
  for (typeNumber = 1, selectionType = 0x2; typeNumber < 32; typeNumber++, 
          selectionType <<= 1) 
  { 
     if ((ccode = NWSMTSGetTargetSelectionTypeStr(connection, typeNumber, 
           selectionTypeString1, 
           selectionTypeString2)) == NWSMTS_SELECTION_TYPE_NOT_USED) 
        continue; 
  /* Continue takes care of any cases where a TSA does not support a selection type. */ 
      if(ccode) 
          break; 
     /* Copy each selection type string and bit map pair (i.e., selectionType/ 
        selectionTypeString1 and selectionType + 1/selectionTypeString2) to a 
        linked list that is used to build the selection option list. */ 
     ... 
  }