cwbSV_GetErrLibNameIndexed
Use the cwbSV_GetErrLibNameIndexed API with this product.
Purpose
Returns the message file library name for the message identified by the index provided. This message attribute only pertains to IBM i returned messages. The library name is the name of the IBM i library containing the message file for the message.
Syntax
unsigned int CWB_ENTRY cwbSV_GetErrLibNameIndexed(
cwbSV_ErrHandle errorHandle,
unsigned long index,
char *libraryName,
unsigned long libraryNameLength,
unsigned long *returnLength);
Parameters
- cwbSV_ErrHandle errorHandle - input
- Handle that was returned by a previous call to the cwbSV_CreateErrHandle() API.
- unsigned long index - input
- Index value indicating which message file library name to return if multiple errors are associated with the error handle. The valid index range is from 1 to the number of messages contained in the error handle. The number of messages can be obtained by calling the cwbSV_GetErrCount() API.
- char * libraryName - input/output
- Pointer to a buffer that will receive the message file library name stored in the error identified by the index. The value returned is an ASCIIZ string.
- unsigned long libraryNameLength - input
- Length of the receive buffer passed in. It should include space for the terminating null character. If the buffer is too small, the value will be truncated and CWB_BUFFER_OVERFLOW and returnLength will be set. NOTE: The recommended size is CWBSV_MAX_MSGFILE_LIBR.
- unsigned long * returnLength - input/output
- Optional, may be NULL. A return address to store the number of bytes needed to hold the output string if the receive buffer is too small.
Return Codes
The following list shows common return values.
- CWB_OK
- Successful completion.
- CWB_BUFFER_OVERFLOW
- Output buffer too small, data truncated.
- CWB_INVALID_POINTER
- NULL passed on output parameter.
- CWB_INVALID_HANDLE
- Invalid handle.
- CWBSV_NO_ERROR_MESSAGES
- No messages are in the error handle.
- CWBSV_ATTRIBUTE_NOT_SET
- Attribute not set in current message.
Usage
IBM i messages are sometimes added to the error handle when using the cwbRC_CallPgm() and cwbRC_RunCmd() API's. In these cases, you can use this API to retrieve the message file library name for the IBM i messages contained in the error handle. If there is no message file library name attribute for the message, return code CWBSV_ATTRIBUTE_NOT_SET will be returned. An index value of 1 works with the lowest-level (i.e. oldest) message in the error handle. An index value equal to the count returned by the cwbSV_GetErrCount() API works with the top-level (i.e. most recent) message in the error handle. Index values less than 1 act as if 1 was passed in. Index values greater than the number of messages contained in the error handle act as if the returned count value from the cwbSV_GetErrCount() API was passed in.