CAPS Universe documentation  1.0.4
All you need to know to be successful
Functions

How to deal with error messages. More...

Functions

int caps_si_error_messages_catch (struct caps_si_handle *h, char **ptr, size_t *size)
 
void caps_si_error_messages_reset (struct caps_si_handle *h)
 

Detailed Description

This mechanism is similar to the one in libcapsclient. Thus, refer its description for details.

If not used, all error messages go to a tty or are suppressed entirely.

Function Documentation

◆ caps_si_error_messages_catch()

int caps_si_error_messages_catch ( struct caps_si_handle h,
char **  ptr,
size_t *  size 
)

Setup a self growing storage to catch error messages

Parameters
[in,out]hLibrary instance
[out]ptrWhere to store the base address of the buffer
[out]sizeWhere to store the buffer size
Return values
0Error catching successfully initialized
negativeerrno from the open_memstream() call

If your local ptr is still NULL or your local size is still '0', then no error messages were created. Else the memory was dynamically allocated and needs to be freed after use. The buffer contains a '\0' terminated string.

Precondition
h must be a valid library instance handle returned by caps_si_create() call
Postcondition
The allocated memory needs to be freed after its use
Todo:
What about more than one error message at the same time?

◆ caps_si_error_messages_reset()

void caps_si_error_messages_reset ( struct caps_si_handle h)

Reset the error message buffer

Parameters
[in]hLibrary instance

If you have processed an error message, you can reset the buffer for the next error message.

Precondition
instance must be a valid library instance handle returned by caps_si_create() call