Chapter 21. Using the backend API to implement new output formats
Prev | Part V. Programmer's manual | Next

## Chapter 21. Using the backend API to implement new output formats

While there is nothing like a runtime-plugin mechanism to add new output formats, the RefDB code is sufficiently modularized to make the implementation of a new format a fairly easy task. You don't have to parse the query results directly, but you call wrapper functions instead. This also has the nice advantage that changes in the database design show up only in one place and thus are less likely to break the backend implementations.

We will first have a look at the API that `backend.c` provides. Then we'll have a look at those parts in the existing code that need to be modified in order to accept a new backend.

## The backend API

In general, the backend API provides a `get_foo()` for every tag foo in the RIS specification. There are, however, two fundamentally different types of tag retrieval functions:

1. The simple retrievals pull out values from the main table (t_refdb) of the database with a single function call.

2. The compound retrievals need three functions: A `request_foo()` obtains an array of possible values. A `get_foo()` retrieves one or more of these values and can be used in a loop to retrieve all values. Finally, the `clean_request()` frees the allocated memory. Compound retrievals are used to get at values which are stored outside the main table, like authors or keywords.

The prototypes of these functions can be found in `backend.h`, and their use is shown in the existing backends `backend-scrn.c`, `backend-ris.c`, `backend-db31.c`, and `backend-bibtex.c`.

Prev | Up | Next
Classes and their functions | Home | How to insert a new backend into RefDB