A number of arguments used in Client-Library functions affect the contents of buffers: action, buffer, buf_len, outlen.
These arguments are described individually below. For a summary of argument values and their interaction, see Table 2-1.
action describes what is done to the data. For most functions, action can take the following symbolic values:
CS_SET |
Assigns a value |
CS_GET |
Retrieves a value |
CS_CLEAR |
Clears the buffer, or, resets to the default property value |
buffer is a program variable, called a “buffer.”
When action is CS_SET |
buffer is the data being read by the function. |
When action is CS_GET |
buffer is the information retrieved by the function. |
When action is CS_CLEAR |
buffer remains unchanged. |
buf_len is the length, in bytes, of the buffer argument.
When the value in the buffer is a fixed-length or symbolic value: |
Assign buf_len the actual length of the value, or CS_UNUSED. |
When the value in the buffer is of variable length: |
Assign buf_len the maximum number of bytes that the buffer can contain. |
If buf_len is set to CS_GET and the buffer is too small to hold the returned value, the function returns CS_FAIL. When this happens, you can query the length of the incoming data by setting CS_SET to 0 and executing the function. The actual length of the data is returned to the outlen argument. Enlarge the buffer, assign the value in outlen to buf_len, and execute the function again.
outlen is an integer variable where the function returns the actual length, in bytes, of the data being retrieved during a CS_GET operation. For all other operations, outlen is ignored.When the retrieved data is longer than buf_len bytes, an application can use the value of outlen to determine how many bytes are needed to hold the information. To do this:
Set the value of outlen to 0 and call the function
Set the value of buf_len to the length returned in outlen
Call the function again
Table 2-1 summarizes the interaction among action, buffer, buf_len, and outlen.
For this action |
When buffer |
buf_len is |
outlen is |
Result |
---|---|---|---|---|
CS_CLEAR |
N/A |
CS_UNUSED |
Ignored |
The property reverts to its default value. |
CS_SET |
Contains a variable-length character string. |
The length of the string |
Ignored |
The data in buffer is read by the function. |
CS_SET |
Contains a variable-length character string for which the terminating character is the last non-blank character. |
The maximum length of the string |
Ignored |
The data in buffer is read by the function. |
CS_SET |
Contains a fixed-length character string or symbolic value. |
CS_UNUSED |
Ignored |
The data in buffer is read by the function. |
CS_GET |
Is large enough for the return character string. |
The length of the buffer |
Set by Client-Library |
The retrieved value is copied to the buffer. outlen returns the length of the retrieved value. |
CS_GET |
Is not large enough for the return character string. |
The length of the buffer |
Set by Client-Library |
No data is copied to the buffer. outlen returns the length of the value being retrieved. The function returns CS_FAIL, indicating that you should assign the value returned here to the length argument and execute the program again. |
CS_GET |
Is assumed to be large enough for a fixed-length or symbolic value. |
CS_UNUSED |
Set by Client-Library |
The retrieved value is copied to the buffer. outlen returns the length of the value being retrieved. |