SMDFGetNextField

Separates an SIDF compliant field into its various components.

Syntax

  #include <smsutapi.h> 
   
  CCODE SMDFGetNextField ( 
     BUFFERPTR         buffer, 
     UINT32            bufferSize, 
     SMDF_FIELD_DATA  *field);
  

Parameters

buffer

(IN) Points to the buffer containing the field to be parsed.

bufferSize

(IN) Specifies the size of buffer.

field

(OUT) Points to the structure to receive the parsed data.

Return Values

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

0x00000000

Successful

Remarks

SMDFGetNextField parses the next field in buffer into its various field components. If buffer contains a partial field (because the field spans the buffer), field.dataOverFlow is set to a positive value. You must save this data, call the function again with the next buffer, and append the spanned data.

The FID from buffer is converted to a byte stream when it is placed into field.fid.

See Also

SMDFPutFields

SMDFGetNextField Example

  CCODE GetFields(UINT32 sectionFID, NWSM_GET_FIELDS_TABLE section[], BUFFERPTR *buffer, UINT32 *bufferSize) 
  { 
     CCODE ccode; 
     SMDF_FIELD_DATA field; 
     int index; 
   
     /* Get the first field from buffer. */ 
     if ((ccode = SMDFGetNextField(*buffer, *bufferSize, &field)) != 0) 
        goto Return; 
   
    /* If the first field is not the section field, return. */ 
     if (field.fid != sectionFID) 
     { 
        ccode = NWSMUT_INVALID_FIELD_ID; 
        goto Return; 
      } 
   
     /* Adjust the buffer information to point to the next field. */ 
     *buffer += field.bytesTransfered; 
     *bufferSize -= field.bytesTransfered; 
   
   
     /* Search through buffer for the fields specified in section until you find the section's ending field. */ 
     while(1) 
     { 
        if ((ccode = SMDFGetNextField(*buffer, *bufferSize, &field)) != 0) 
           goto Return; 
   
        /* Adjust the buffer information to point to the next field. */ 
        *buffer += field.bytesTransfered; 
        *bufferSize -= field.bytesTransfered; 
   
        /* If the section's last field is found, break. */ 
        if (field.fid == sectionFID) 
           break; 
   
        /* See if field is in section; if it is, put field's information into section. The code will loop until field 
  matches a corresponding element in section, or when all elements in section are searched.*/ 
   
        for (index = 0; section[index].fid != NWSM_END; index++) 
        { 
          /* If the field was previously found, break and get the next field. */ 
           if (section[index].found) 
              break; 
   
        /* Put the field into section. */ 
           if (field.fid == section[index].fid) 
           { 
              UINT32 dataSize; 
   
          /* Check if the field's data will fit into section’s buffer */ 
              SMDFGetUINT64(&field.dataSize, &dataSize); 
              if (dataSize > section[index].dataSize) 
              { 
                 ccode = NWSMUT_BUFFER_OVERFLOW; 
                 goto Return; 
              } 
   
              memmove(section[index].data, field.data, dataSize); 
              section[index].dataSize = dataSize; 
              section[index].found = TRUE; 
              break; 
           } 
        } /* end of for loop */ 
     } /* end of while loop */ 
   
  Return: 
     return(ccode); 
  }