SMDFPutNextField

Formats data into an SIDF compliant field.

Syntax

  #include <smsutapi.h> 
   
  CCODE SMDFPutNextField ( 
     BUFFERPTR           buffer, 
     UINT32              bufferSize, 
     SMDF_FIELD_DATA     *field, 
     UINT8               dataSizeMap, 
     UINT32              sizeOfData);
  

Parameters

buffer

(IN) Points to the buffer to receive the field.

bufferSize

(IN) Specifies the amount of free space in buffer.

field

(IN) Points to the field information to format.

dataSizeMap

(IN) Specifies where to find the data size for field.data.

sizeOfData

(IN) Specifies how many bytes of data are in field.data.

Return Values

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

0x00000000

Successful

0xFFFBFFFA

NWSMUT_BUFFER_OVERFLOW

0xFFFBFFFD

NWSMUT_INVALID_PARAMETER

Remarks

SMDFPutNextField puts one field into a buffer and indicates how many bytes were moved into buffer.

Even if SMDFPutNextField successfully completes, you should always check for a data overflow condition. If the data overflows, field.dataOverflow contains the amount of data that was not transferred.

If field.data contains part of the total field data, you must put the rest of the data into the buffer. To figure out where to put the rest of the data, track the offset into buffer through field.bytesTransferred.

The value of dataSizeMap depends upon the amount of data in field.data. If the total amount of data is less than 128 bytes, set dataSizeMap to the data’s size. If the total amount of data is 128 bytes or more, set dataSizeMap to NWSM_VARIABLE_SIZE and field.dataSize to the total amount of data that the field will contain.

field.dataSize specifies the total amount of data the field will contain. This value may or may not be the size of data because data might point to only part of the field's data. For example, if the data set's size is 64 KB, but only 32 KB is being transferred, this field contains 64 KB.

See Also

SMDFPutFields

SMDFPutNextField Example

  /* Places a whole section with no offset to end field. */ 
   
  PutSection(BUFFERPTR buffer, UINT32 bufferSize, NWSM_FIELD_TABLE_DATA *section) 
  { 
     UINT16 sync = 0xA55A, i; 
     SMDF_FIELD_DATA lastField = {{0},0}; 
     BUFFERPTR begin = buffer; 
     UINT32 crc = 0xFFFFFFFF; 
   
     /* The first element is the section fid. */ 
     section->sizeOfData = section->dataSizeMap = sizeof(UINT16); 
     section->data = &sync; 
     SMDFPutNextField(buffer, bufferSize, &section->field, section->dataSizeMap, section->sizeOfData); 
     buffer += section->field.bytesTransferred; 
     bufferSize -= section->field.bytesTransferred; 
   
     for (i = 1; section[i].field.fid != NWSM_END; i++) 
     { 
        SMDFPutNextField(buffer, bufferSize, &section[i].field, 
              section[i].dataSizeMap, section[i].sizeOfData); 
        buffer += section[i].field.bytesTransferred; 
        bufferSize -= section[i].field.bytesTransferred; 
     }  
   
     /* Set the last field into the buffer */ 
     lastField.fid = section[0].field.fid; 
     crc = NWSMGenerateCRC(buffer - begin, crc, begin); 
     lastField.data = &crc; 
     SMDFPutUINT64(&lastField.dataSize, sizeof(UINT32)); 
     SMDFPutNextField(buffer, bufferSize, &lastField, (UINT8)sizeof(UINT16), 
           (UINT32)sizeof(UINT16)); 
  }