SMDFPutFields

Formats data into an SIDF section.

Syntax

  #include <smsutapi.h> 
   
  CCODE SMDFPutFields ( 
     NWSM_FIELD_TABLE_DATA     table[ ], 
     BUFFERPTR                 *buffer, 
     UINT32                    *bufferSize, 
     UINT32                     crcFlag);
  

Parameters

table[ ]

(IN) Points to the table that represents the section to put into buffer.

buffer

(OUT) Points to the part of the buffer where the section should be placed on input. Points to the beginning of the next section on output.

bufferSize

(IN/OUT) Points to the amount of free space in buffer.

crcFlag

(IN) Specifies the CRC flag:

  • CRC_YES Generate CRC now
  • CRC_NO Do not generate CRC
  • CRC_LATER Generate the CRC at a later time

Return Values

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

0x00000000

Successful

0xFFFBFFF0

NWSMUT_BUFFER_UNDERFLOW: The offset to end value cannot fit into the provided space.

0xFFFBFFFA

NWSMUT_BUFFER_OVERFLOW: The buffer is too small. Increase the buffer size and call SMDFPutFields again.

0xFFFBFFFD

NWSMUT_INVALID_PARAMETER

Remarks

SMDFPutFields checks for boundary conditions such as field and buffer overflow or underflow, but it does not handle buffer overflow or underflow conditions or check for valid FIDs.

SMDFPutFields converts table into a section and writes it into buffer by calling SMDFPutNextField.

SMDFPutFields sets the size of the data to 4 and the field data to 0xA55A (synchronization data). The data for Offset to End field is set if table contains this field.

crcFlag affects the data portion of the last field in the section. If no CRC_NO is passed, the CRC data is zero. If CRC_LATER is passed, the CRC data is 0xFFFFFFFF. You must decrement buffer by four bytes (UINT32) before inserting its CRC value into buffer.

See Also

SMDFPutNextField

SMDFPutFields Example

  /* This example shows how to use the structures. */ 
   
  #define DEBUG_CODE 1 
  #define OFFSET_TO_END_INDEX 4 
  #define VOLUME_NAME_INDEX 5 
  #define HEADER_STRING “NWSM_VOLUME_RESTRICTIONS” 
  #define HEADER_STRING_LEN sizeof(NWSM_HEADER_DEBUG_STRING) 
   
  char buffer[255]; /* arbitrary size */ 
  UINT32 bufferSize = 255; 
  UINT64 offsetToEnd = UINT64_ZERO; 
   
  NWSM_FIELD_TABLE_DATA volumeRestrictionHeaderTable[] = 
  { 
     /* Signal SMDFPutFields that the second field in the table is the beginning of the section. 
  Create the synchronization data for that field. */ 
     { { NWSM_BEGIN } }, 
   
     /* The next field contains the section FID, used to construct the start and end Fields of the section. */ 
     { {NWSM_VOLUME_RESTRICTIONS, UINT64_ZERO, NULL, 0, UINT64_ZERO }, 0, NULL, 0 }, 
   
     /* The field is not required, but it is helpful when searching. It places a string describing the section into 
  the data stream. */ 
     { {NWSM_HEADER_DEBUG_STRING, UINT64_ZERO, HEADER_STRING}, HEADER_STRING_LEN, NULL, HEADER_STRING_LEN}, 
   
     /* For this field we want the address of the data area in buffer */ 
     { { NWSM_OFFSET_TO_END, UINT64_ZERO, NULL, 0, UINT64_ZERO }, 4, GET_ADDRESS, 4}, 
   
     /* This field needs a string, but the information will not be known until the program is running. */ 
     { { NWSM_VOLUME_NAME, UINT64_ZERO, NULL, 0, UINT64_ZERO }, 0, NULL,       NWSM_VARIABLE_SIZE}, 
   
     /* This field is required to let the function know that this the end of the table. The section header field does 
  not repeat. */ 
     { {NWSM_END } } 
  }, 
  volumeRestrictionEntryTable[] =  
  /* Another table. Note that this one does not have a “beginning” field. */ 
  { 
     #if defined(NETWARE_V320) 
     { { NWSM_VOLUME_RSTRCTNS_NAME, UINT64_ZERO, NULL, 0, UINT64_ZERO }, 0, NULL, NWSM_VARIABLE_SIZE }, 
     #else 
        { { NWSM_VOLUME_RSTRCTNS_ID, UINT64_ZERO, NULL, 0, UINT64_ZERO }, 0, NULL, NWSM_VARIABLE_SIZE }, 
     #endif 
        { { NWSM_VOLUME_RSTRCTNS_LIMIT, UINT64_ZERO, NULL, 0, UINT64_ZERO }, 0, NULL, 0 }, 
        { {   NWSM_END } } 
  }; 
   
  /* Set up the variable data for sourceVersion to the table. Set volumeName somewhere in the program. */ 
  SMDFPutUINT64( &volumeRestrictionHeaderTable[VOLUME_NAME_INDEX].field.dataSize, 
        (UINT32)strlen(volumeName)); 
  volumeRestrictionHeaderTable[VOLUME_NAME_INDEX].field.data = volumeName; 
  volumeRestrictionHeaderTable[VOLUME_NAME_INDEX].sizeOfData = 
        (UINT32)strlen(volumeName); 
  volumeRestrictionHeaderTable[VOLUME_NAME_INDEX].dataSizeMap = 
        (UINT8)strlen(volumeName); 
  SMDFPutFields(volumeRestrictionHeaderTable, &buffer, &bufferSize, CRC_NO); 
   
  /* Now set the offset to end value. */ 
  SMDFPutUINT64(&offsetToEnd, buffer - 
         ((BUFFERPTR)volumeRestrictionHeaderTable[ 
         OFFSET_TO_END_INDEX].addressOfData +  
         volumeRestrictionHeaderTable[OFFSET_TO_END_INDEX].dataSizeMap)); 
   
  memcpy(volumeRestrictionHeaderTable[OFFSET_TO_END_INDEX].addressOfData, 
        &offsetToEnd,      volumeRestrictionHeaderTable[OFFSET_TO_END_INDEX].dataSizeMap);