NWSMTSListTSResources

Returns a list of primary resources.

Syntax

  #include <smstsapi.h> 
   
  CCODE NWSMTSListTSResources (
     UINT32              connection, 
     NWSM_NAME_LIST **serviceResourceList);
  

Parameters

connection

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

serviceResourceList

(OUT) Points to the list containing the primary resources found on the Target Service (maximum length is NWSM_MAX_RESOURCE_LEN bytes).

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

0xFFFEFFFD

NWSMDR_OUT_OF_MEMORY

0xFFFEFFFF

NWSMDR_INVALID_CONNECTION

Remarks

Before NWSMTSListTSResources is called, the engine must be connected to the TSA and Target Service and you should call NWSMTSBuildResourceList.

The first entry in the list that NWSMTSListTSResources returns contains all the resources on a Target Service (see Resources).

The behavior of NWSMTSListTSResources differs from cluster backup and normal backup. If the engine is connected to a pool, NWSMTSListTSResources only lists the mounted resources under the pool. If the engine is connected to the server node, then all the non-clustered resources that are mounted on the server are listed.

Before passing a resource name to NWSMTSScanDataSetBegin, the engine must convert it to an NWSM_DATA_SET_NAME_LIST structure. Use the data set name functions described in Storage Management Services Utilities Library to help convert this name.

NWSMTSListTSResources is implemented with NWSMTSScanTargetServiceResource.

See Also

NWSMTSBuildResourceList, NWSMTSGetNameSpaceTypeInfo, NWSMTSGetOpenModeOptionString, NWSMTSGetTargetResourceInfo, NWSMTSGetTargetScanTypeString, NWSMTSGetTargetSelectionTypeStr, NWSMTSListSupportedNameSpaces, NWSMTSScanSupportedNameSpaces, NWSMTSScanDataSetBegin

Example

  /* This example queries the user for the resource that is to be selected for the session. */ 
   
  #include <smstsapi.h> 
  #include <smsutapi.h> 
   
  UINT32 sequence = 0, nameSpaceType, defaultNameSpaceType, selectionType; 
  char nameSpaceName[61]; /* Name space names not longer than 60 characters */ 
  NWSM_NAME_LIST *nameList = NULL; 
  NWSM_DATA_SET_NAME_LIST dataSetName = NULL, *parent; 
  NWBOOLEAN   reverseOrder; 
  NWSM_SCAN_CONTROL scanControl = {0}; 
  NWSM_SELECTION_LIST   *selectionList; 
  STRING string = (STRING)nameSpaceName, firstResourceName 
  STRING_BUFFER *firstSeparator = NULL, *secondSeparator = NULL; 
   
  /*Build a complete list of primary resources that are on the file server. */ 
  NWSMTSListTSResources(connection, &nameList); 
   
  /*If the resource name list is not empty, get the name spaces supported on the file server. Remember that the first name 
  returned by NWSMTSListTSResources or NWSMScanTargetServiceResrouce is always the resource that contains 
  all other resources. Here, the first name is “FILE SERVER” */ 
   
  if (nameList != NULL) 
  { 
     /* Get all the name spaces supported by the file server. */ 
     sequence = 0; 
   while(NWSMTSScanSupportedNameSpaces(connection, &sequence, nameList->name, 
        &nameSpaceType, string) == 0) 
     { 
      /* Build the name space list here. Remember that the first returned name 
       space name is the default name space of the Target Service. 
        defaultNameSpaceType is set to this name space. */ 
     } 
  } 
  /* Get the default name space information */ 
  defaultNameSpaceType = default name space type; 
  NWSMTSGetNameSpaceTypeInfo(connection, defaultNameSpaceType, &reverseOrder, &firstSeparator, &secondSeparator); 
   
  /* Present the primary resource name list to the user and find out which resource is to be selected. */ 
  /* If the user has chosen a resource, see if it has any secondary resources. 
  If it has secondary resources, list them and show them to the user for selection. 
  If the first resource name was chosen, there is no need to scan for secondary resources. 
  Note: We are assuming that the selected resource was put into firstResourceName. 
  The following code can form the path to what the user wants to select or ignore. */ 
  while(1) 
  { 
     /* First put the resource name into an NWSM_DATA_SET_NAME_LIST structure. 
        selectionType is set to zero to indicate that dataSetName is being used 
       as a name list only. */ 
     selectionType = 0; 
     firstResourceName = nameList->name; 
     NWSMPutOneName(&dataSetName, nameSpaceType, selectionType, reverseOrder, firstSeparator->string, 
  secondSeparator->string, firstResourceName); 
   
     /* Now setup scanControl to specify that we are looking for names of the parents just under the resource, not their 
  path information, the following are set. Here will assume that the TSA supports all scan types. See 
  NWSMTSGetTargetScanTypeString for more information. */ 
     scanControl.scanType = 0; 
     scanControl.returnChildTerminalNodeNameOnly = FALSE; 
     scanControl.childrenOnly = FALSE; 
     scanControl.parentsOnly = TRUE; 
     scanControl.returnNameSpaceType = NWSM_ALL_NAME_SPACES; 
     scanControl.bufferSize = scanControl.scanControlSize = 
          sizeof(NWSM_SCAN_CONTROL); 
     /* Since we want the names of all parents (subdirectories) just under the 
    resource name, set selectionList to NULL. */ 
     selectionList = NULL; 
     parent = NULL; 
     /* We do not know if the resource has any parents (subdirectories or    
        children (files). To find this out, call data set begin. */ 
    if (NWSMTSScanDataSetBegin(connection, dataSetName, &scanControl, 
          selectionList, &sequence, NULL, &parent) == 0) 
    { 
    /* Found one parent. Put the name into a name list. */ 
    /* Find the rest of subdirectory names, and put them into the name list. */ 
        while(NWSMTSScanNextDataSet(connection, &sequence, NULL, &dataSetname) == 0) 
        { 
           /* Put the name into the name list. */ 
        } 
   
     /* Now show the finished list to the user for selection. If the user chooses a name from this list, 
  it can be appended to what we already have. 
  Information from NWSMTSGetNameSpaceTypeInfo can be used to help build the path. */ 
     } /* end if data set begin */ 
  } /* end while(1) */