Functions | |
void | NJB_Set_Debug (int debug_flags) |
void | NJB_Set_Unicode (int unicode_flag) |
int | NJB_Error_Pending (njb_t *njb) |
void | NJB_Error_Reset_Geterror (njb_t *njb) |
const char * | NJB_Error_Geterror (njb_t *njb) |
void | NJB_Error_Dump (njb_t *njb, FILE *fp) |
void NJB_Error_Dump | ( | njb_t * | njb, | |
FILE * | fp | |||
) |
This function dumps the current libnjb error stack to a file, such as stderr. All errors currently on the stack are dumped. After dumping, the error stack is cleared and errors are not returned again. The function may be called on an empty error stack without effect, but you may just as well check the stack yourself using NJB_Error_Pending()
as in the example below.
Typical usage:
njb_t *njb;
if (NJB_Error_Pending(njb)) { NJB_Error_Dump(njb, stderr); }
njb | a pointer to the NJB object to use | |
fp | a file pointer to dump the textual representation of the error stack to. |
const char* NJB_Error_Geterror | ( | njb_t * | njb | ) |
This function returns the topmost error on the error stack as a string. The result is statically allocated and MUST NOT be freed by the calling application. This function should be repeatedly called until no errors remain and the function returns NULL. After retrieveing all error strings like this, the error stack is cleared and none of the errors will be returned again.
njb | a pointer to the NJB object to use |
int NJB_Error_Pending | ( | njb_t * | njb | ) |
This function tells wheter an error message is queued and pending for the current device. If so, the error should be retrieved using NJB_Error_Geterror()
or dumped using NJB_Error_Dumperror()
.
njb | a pointer to the NJB object to use |
void NJB_Error_Reset_Geterror | ( | njb_t * | njb | ) |
This function resets the internal error stack, so that old errors do not remain on following calls to retrieve the error.
Retrieve the errors if the function NJB_Error_Pending()
indicate that there are errors pending. Typical usage:
njb_t *njb; char *errstr;
if (NJB_Error_Pending(njb) { NJB_Error_Reset_Geterror(njb); while ( (errstr = NJB_Error_Geterror(njb)) != NULL ) { printf("%s\n", errstr); } }
njb | a pointer to the NJB object to use |
void NJB_Set_Debug | ( | int | debug_flags | ) |
Set the debug print mode for libnjb. The debug flag is created by OR:ing up the different possible flags.
debug_flags | the debug flags to use |
void NJB_Set_Unicode | ( | int | unicode_flag | ) |
Defines the encoding used by libnjb. By default, ISO 8859-1 (or rather Windows Codepage 1252) will be used. However, all modern applications should make a call to this function and set the encoding to NJB_UC_UTF8
.
unicode_flag | the encoding to use |