libnjb  2.2.7
Functions
The libnjb configuration API

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)
 

Detailed Description

Function Documentation

◆ NJB_Error_Dump()

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);
}
Parameters
njba pointer to the NJB object to use
fpa file pointer to dump the textual representation of the error stack to.
See also
NJB_Error_Pending()
Examples
cursesplay.c, delfile.c, deltr.c, dumpeax.c, dumptime.c, files.c, fwupgrade.c, getfile.c, getowner.c, gettr.c, getusage.c, handshake.c, pl.c, play.c, playlists.c, sendfile.c, sendtr.c, setowner.c, setpbm.c, settime.c, tagtr.c, and tracks.c.

References NJB_Error_Geterror(), and NJB_Error_Reset_Geterror().

◆ NJB_Error_Geterror()

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.

Parameters
njba pointer to the NJB object to use
Returns
a string representing one error on the error stack or NULL.

References njb_error_stack_struct::count, njb_struct::error_stack, njb_error_stack_struct::idx, and njb_error_stack_struct::msg.

Referenced by NJB_Error_Dump().

◆ NJB_Error_Pending()

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().

Parameters
njba pointer to the NJB object to use
Returns
0 if there are no errors pending, 1 if there are errors pending
See also
NJB_Error_Reset_Geterror()
NJB_Error_Geterror()
NJB_Error_Dump()
Examples
dumptime.c, files.c, gettr.c, playlists.c, and tracks.c.

References njb_error_stack_struct::count, and njb_struct::error_stack.

◆ NJB_Error_Reset_Geterror()

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);
   }
}
Parameters
njba pointer to the NJB object to use
See also
NJB_Error_Pending()
NJB_Error_Geterror()

References njb_struct::error_stack, and njb_error_stack_struct::idx.

Referenced by NJB_Error_Dump().

◆ NJB_Set_Debug()

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.

See also
Debug flags
Parameters
debug_flagsthe debug flags to use
Examples
cursesplay.c, delfile.c, deltr.c, dumpeax.c, dumptime.c, files.c, fwupgrade.c, getfile.c, getowner.c, gettr.c, getusage.c, handshake.c, pl.c, play.c, playlists.c, sendfile.c, sendtr.c, setowner.c, setpbm.c, settime.c, tagtr.c, and tracks.c.

References njb_set_debug().

◆ NJB_Set_Unicode()

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.

See also
Unicode flags
Parameters
unicode_flagthe encoding to use
Examples
files.c, fwupgrade.c, getowner.c, pl.c, playlists.c, sendfile.c, sendtr.c, setowner.c, tagtr.c, and tracks.c.

References njb_set_unicode().