NWSMTSGetTargetResourceInfoEx

Returns information about a primary resource.

Syntax

  #include <smstsapi.h> 
   
  CCODE NWSMTSGetTargetResourceInfoEx (
     UINT32      connectionID, 
     STRING      resourceName, 
     UINT32      *bufferSize, 
     void        *buffer);
  

Parameters

connectionID

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

resourceName

(IN) Specifies the resource name returned by NWSMTSScanTargetServiceResource or NWSMTSListTSResources.

bufferSize

(IN/OUT) Specifies the size of buffer in bytes.

buffer

(OUT) Points to the buffer containing resource information.

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

0xFFFDFFC5

NWSMTS_RESOURCE_NAME_NOT_FOUND

0xFFFDFFDD

NWSMTS_INVALID_PARAMETER

0xFFFDFFE9

NWSMTS_GET_SERVER_INFO_ERR

0xFFFEFFFE

NWSMDR_INVALID_PARAMETER

0xFFFEFFFF

NWSMDR_INVALID_CONNECTION

Remarks

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

NWSMTSGetTargetResourceEx does not return information for all resources listed by NWSMTSScanTargetServiceResource or NWSMTSListTSResources. Only resources that return information by calling NWSMTSGetTargetResourceInfoEx can return information. NWSMTS_INVALID_PARAMETER is returned for resources that do not have any information.

buffer contains TSA encoded extensions that hold resource information. This can be processed using the extension functions. See Section 6.3, Extension Functions. The extensions and their fields are detailed in Section 5.7, Extensions.

buffer should be allocated by the application and the corresponding size should be passed in bufferSize parameter. Applications can invoke the API with a bufferSize of 0 and a buffer of NULL to get the required bufferSize to encode all extensions.

If passed in buffer size is not adequate to store all extensions NWSMTS_BUFFER_UNDERFLOW error is returned. The engine can then try with a larger buffer size.

NOTE:This symbol is not present in the SMS import file, as all versions of SMS do not export this symbol. To use this function, programmatically import the symbol and invoke it.

See Also

NWSMTSGetTargetResourceInfo, NWSMTSGetUnsupportedOptions, NWSMGetFirstExtension

Example

  #include <smsutapi.h> 
  #include <smsdrapi.h> 
   
  CCODE   cCode;
  UINT32   connection;
  UINT32   tsaSequence = 0;
  STRING   resourceName;
  UINT32   bufferSize = 0;
  void   *buffer = NULL;
  UINT32  handle = 0;
  BOOL   doNotInvokeSetArchiveStatus = FALSE;
  NWSM_EXTENSION_INFORMATION     *extension = NULL;
  NWSM_RESOURCE_INFO_EXTN_UNSUPPORTED_DATA_1 *unsupExtension;
  
  /* connection related code goes here */
  /* After the connection:
  
  We will call NWSMTSScanTargetServiceResource and for each resource, retrieve resource information using 
  NWSMTSGetTargetResourceInfoEx   and check the unsupported options for each. 
  Based on modify bit   support we will set a global to call set archive status or not */
  
  /* Loop till no more resources or no errors */
  while(!cCode)
  {
  
    /* Scan a resource */
    cCode = NWSMTSScanTargetServiceResource(connection, &tsaSequence, resourceName);
    if (cCode)
                continue;
  
    /* Get the required size to allocate the buffer */
    bufferSize = 0;
    if (buffer)
            free(buffer);
    cCode = NWMSTSGetTargetResourceInfoEx(connection, resourceName, &bufferSize, NULL);
    /* Check if error is invalid parameter, as not all resources can return resource specific information */
    if (cCode && cCode != NWSMTS_INVALID_PARAMETER)
                continue;
    else if (cCode == NWSMTS_INVALID_PARAMETER)
    {
  
    /* As the error is invalid parameter, could be that the resource does not provide resource specific 
  information, continue to try and get information regarding other resources */
      cCode = 0;
            continue;
    }
  
  /* Allocate the required size and invoke the API again */
    buffer = malloc(bufferSize);
    if (!buffer)
    {
               cCode = -1;
               continue;
    }
  
    cCode = NWMSTSGetTargetResourceInfoEx(connection, resourceName, &bufferSize, buffer);
    if (cCode)
    {
               free(buffer);
               buffer = NULL;
               continue;
    }
  
    /* Get the unsupported options extension from the resource information buffer */
    cCode = NWSMGetExtension(buffer, bufferSize, NWSM_RESOURCE_INFO_EXTN_UNSUPPORTED_TAG, &extension, &handle);
    if (cCode)
    {
      free(buffer);
      buffer = NULL;
      continue;
    }
  
    unsupExtension = (NWSM_RESOURCE_INFO_EXTN_UNSUPPORTED_DATA_1 *)(extension->info);
  
    /* Check if modify flag is supported on the resource */
    if (unsupExtension->usupportedBackupOptions & NWSM_BACK_MODIFY_FLAG)
  /* Although this needs to be determined for each resource, this example assumes that this is globally true */
                  doNotInvokeSetArchiveStatus = TRUE;
           NWSMCloseExtension(&handle);
  }