---
name: "njb_internals"
section: "3"
platform: "linux"
package: "libnjb-doc"
version: "2.2.5-4.3"
release: "Debian 6.0 (Squeeze)"
platforms: ["linux"]
url: "https://new.carta.tech/njb_internals"
---

# njb\_internals(3)

## NAME

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)\

## Function Documentation

### 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:**

*njb* a pointer to the NJB object to use \
 *fp* a 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().

### 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:**

*njb* a 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().

### 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:**

*njb* a 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.

### 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:**

*njb* **a 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().**

### 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\_flags* **the 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().**

### 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\_flag* **the 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().**

## Author

**Generated automatically by Doxygen for libnjb from the source code.**
