-
-
Notifications
You must be signed in to change notification settings - Fork 35
How To Add a Driver
This page provides an introduction to adding drivers to LPrint.
Most drivers consist of two source files:
- "lprint-NAME.h": List of driver names, descriptions (usually the make and model), and IEEE-1284 device IDs.
- "lprint-NAME.c": The code for the driver, including this driver's callback.
where "NAME" is the base name of the driver such as "acme" for ACME printers or "apcl" for printers that support an ACME Page Control Language. This name will also be used as a prefix for driver name strings (also lowercase, for example "acme_4inch-300dpi") and for global functions (this time capitalized, for example "lprintAcme" or "lprintAPCL").
You'll reference the driver in the "lprint.h" header, from the driver callback in "lprint.c", and in the makefile for the LPrint software.
Add a function called "lprintNAME" using the PAPPL pappl_pr_driver_cb_t
interface, where "NAME" is the driver base name. The previous "Acme" and "APCL" examples would look like:
// Acme driver callback
extern bool lprintAcme(pappl_system_t *system, const char *driver_name, const char *device_uri, const char *device_id, pappl_pr_driver_data_t *data, ipp_t **attrs, void *cbdata);
// APCL driver callback
extern bool lprintAPCL(pappl_system_t *system, const char *driver_name, const char *device_uri, const char *device_id, pappl_pr_driver_data_t *data, ipp_t **attrs, void *cbdata);
The driver_cb
function handles calling the appropriate driver callback function.
// Acme driver
else if (!strncmp(driver_name, "acme_", 5))
ret = lprintAcme(system, driver_name, device_uri, device_id, data, attrs, cbdata);
// APCL driver
else if (!strncmp(driver_name, "apcl_", 5))
ret = lprintAPCL(system, driver_name, device_uri, device_id, data, attrs, cbdata);
Add the "lprint-NAME.o" file to the list of OBJS
files:
OBJS = \
lprint.o \
lprint-NAME.o \
lprint-brother.o \
lprint-common.o \
...