Writing data, Datasetput function, Figure 77 – HP XP P9500 Storage User Manual

Page 126

Advertising
background image

Figure 77 Format Requirements for Reading Variable-Length Records

.

When the datasetGet function terminates successfully, it returns the length of the data entity read
from the dataset. If the datasetGet function detects the end of dataset (EOF) or terminates
unsuccessfully, it returns a value of -1. To get the error code information, execute the
datasetGetLastError

function (see

Acquiring Error Information

” on page 127). For example,

when the datasetGet function detects the EOF, datasetGetLastError will return
DATASET_ERROR_END_OF_FILE

.

Writing Data

reclen = datasetPut (datasetHandle, buf, buflen)

The datasetPut function writes one record from the buf into the dataset specified by
datasetHandle

.

Table 43

on page 126 shows the datasetPut arguments and return values.

Table 43 DatasetPut Function

Description

Type

Value

Item

The datasetHandle value returned by the
datasetOpen

function.

DATASET_HANDLE

datasetHandle

Argument

Buffer area for storing the write data.

char *

buf

Size of the buffer area. If any of the following
conditions are detected, datasetPut
returns an error and does not transfer any
data to the dataset:

For a fixed-length record: buflen ≠ RL
of the dataset

For a variable-length record: (buflen +
4) > RL of dataset

For a variable-length record: buflen =
0 (no data entity)

long

buflen

Data entity size written into the dataset.

long

reclen

Return value

Abnormal end

-1

Figure 78

on page 127 shows the format requirements for variable-length records accessed by the

datasetPut

function. When the target dataset is variable length, the datasetPut function takes

the data entity from the buf, automatically adds the 2-byte RL field, and writes the record into the

Performing FAL Operations

126

Advertising